/usr/include/ccp4/ccp4_fortran.h is in libccp4-dev 6.4.5-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | /*
ccp4_fortran.h: header file for Fortran APIs
Copyright (C) 2001 Eugene Krissinel
This library is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
version 3, modified in accordance with the provisions of the
license to address the requirements of UK law.
You should have received a copy of the modified GNU Lesser General
Public License along with this library. If not, copies may be
downloaded from http://www.ccp4.ac.uk/ccp4license.php
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
*/
/** @file ccp4_fortran.h
* header file for Fortran APIs
* Eugene Krissinel
*/
#ifndef __CCP4_FORTRAN
#define __CCP4_FORTRAN
#include "ccp4_types.h"
/* rcsidhh[] = "$Id$" */
/* stardent is now obsolete, but we retain this category in case it is useful later */
#ifdef CALL_LIKE_STARDENT
/* SStrParam is used in Ardent-like machines' fortran calls */
/* for passing a string parameter */
DefineStructure(SStrPar)
struct SStrPar {
pstr S;
int len;
int id;
};
#endif
#define _LVTOB(l) ((long) ((l) == 0 ? 0 : 1))
#define _BTOLV(l) ((int) ((l) == 0 ? 0 : 1))
#if defined (__OSF1__) || defined (__osf__)
#undef _BTOLV
#define _BTOLV(l) ((int) ((l) == 0 ? 0 : -1))
#endif
/*
Macro FORTRAN_SUBR(NAME,name,p_send,p_sstruct,p_sflw)
makes function header statements that allow for linking with
programs written in FORTRAN.
Parameters:
NAME name of the FORTRAN subroutine in capital letters
name name of the FORTRAN subroutine in small letters
p_send parameter list (in brackets) with string lengths
attached to the end of it (see below)
p_sstruct parameter list (in brackets) with strings passed
as complex parameters, or structures
p_sflw parameter list (in brackets) with string lengths
following immediately the string parameters
(see below)
All non-string parameters must be passed as pointers, in
the same order as they enter the FORTRAN call. Rules for
the string parameters are as follows.
1. All strings should be specified as of 'fpstr' type.
The 'fpstr' type is defined below and depends on the
platform:
a) whenever length of string is passed as a separate
parameter ( CALL_LIKE_SUN, CALL_LIKE_HPUX,
CALL_LIKE_MVS ) 'fpstr' is identical to 'pstr'.
You may choose arbitrary name for the string,
but you MUST use the same name, appended with
suffix '_len', for its length (see example below).
b) whenever string and its length are passed as
complex parameter, 'fpstr' is identical to the
pointer on the corresponding structure:
CALL_LIKE_STARDENT :
'fpstr' is identical to 'PSStrPar'
CALL_LIKE_VMS :
'fpstr' is identical to 'dsc$descriptor_s *'
With 'fpstr' type, two important macro definition come:
i) FTN_STR(s) - returns pointer to fortran-passed
string s. This pointer is always
of 'pstr' type
ii) FTN_LEN(s) - returns integer length of fortran-
passed string s. For this macro to
work properly with SUN- and MVS-like
machines, always use suffix '_len'
for the string length parameters as
described in a) above.
2. Three parameter lists, each enclosed in brackets, should
be given. These lists retain the general order of
parameters in the corresponding fortran call. Non-string
parameters are passed as pointers. String parameters
and their lengths are passed differently in different
lists:
p_send strings enter their place in the list as in
the corresponding FORTRAN call, having 'fpstr'
parameter type. Their lengths are appended as
'int' to the end of the list. They should
retain the order in which the strings appear
in the list.
p_sstruct strings enter their place in the list as in
the corresponding FORTRAN call, having 'fpstr'
parameter type.
p_sflw strings enter their place in the list as in
the corresponding FORTRAN call, having 'fpstr'
type and being immediately followed by their
lengths as 'int' parameters.
Example:
FORTRAN statement
subroutine SomeSub ( k,s1,a,s2,m )
integer k,m
real a
character*(*) s1,s2
is translated to
FORTRAN_SUBR ( SOMESUB, somesub,
( int * k, fpstr s1, float * a, fpstr s2, int * m,
int s1_len, int s2_len ),
( int * k, fpstr s1, float * a, fpstr s2, int * m ),
( int * k, fpstr s1, int s1_len, float * a,
fpstr s2, int s2_len, int * m ) )
The macro should replace ordinary function header
statements to assure compatibility with FORTRAN links.
In header files, do not forget to add semicolumn:
FORTRAN_SUBR ( .... );
while in source files use simply
FORTRAN_SUBR ( .... ) {
<source body, operators>
}
Macro FORTRAN_CALL(NAME,name,p_send,p_sstruct,p_sflw)
calls function defined with macro FORTRAN_SUBR(...), from
a C/C++ application. Its parameters and their meaning are
exactly identical to those of FORTRAN_SUBR(...).
FORTRAN_CALL(...) should be followed by semicolon. */
#if defined(CALL_LIKE_SUN)
typedef pstr fpstr;
#define FTN_STR(s) s
#define FTN_LEN(s) s##_len
#define char_struct(s) \
pstr s; \
int s##_len;
#define fill_char_struct(s,str) \
s = str; \
s##_len = strlen(str);
#define init_char_struct(s,str,size) \
s = str; \
s##_len = size;
#define FORTRAN_SUBR(NAME,name,p_sun,p_stardent,p_mvs) \
void name##_ p_sun
#define FORTRAN_CALL(NAME,name,p_sun,p_stardent,p_mvs) \
name##_ p_sun
#define FORTRAN_FUN(val,NAME,name,p_sun,p_stardent,p_mvs) \
val name##_ p_sun
#elif defined(CALL_LIKE_HPUX)
typedef pstr fpstr;
# define FTN_STR(s) s
# define FTN_LEN(s) s##_len
# define char_struct(s) \
pstr s; \
int s##_len;
# define fill_char_struct(s,str) \
s = str; \
s##_len = strlen(str);
# define init_char_struct(s,str,size) \
s = str; \
s##_len = size;
# define FORTRAN_SUBR(NAME,name,p_sun,p_stardent,p_mvs) \
void name p_sun
# define FORTRAN_CALL(NAME,name,p_sun,p_stardent,p_mvs) \
name p_sun
# define FORTRAN_FUN(val,NAME,name,p_sun,p_stardent,p_mvs) \
val name p_sun
#elif defined(CALL_LIKE_STARDENT)
typedef PStrPar fpstr;
# define FTN_STR(s) s->Str_pointer
# define FTN_LEN(s) s->Str_length
# define char_struct(s) \
SStrPar s;
# define fill_char_struct(s,str) \
s.S = str; \
s.len = strlen(FName); \
s.id = 0;
# define init_char_struct(s,str,size) \
s.S = str; \
s.len = size; \
s.id = 0;
# define FORTRAN_SUBR(NAME,name,p_send,p_sstruct,p_sflw) \
void NAME p_stardent
# define FORTRAN_CALL(NAME,name,p_send,p_sstruct,p_sflw) \
NAME p_stardent
# define FORTRAN_FUN(val,NAME,name,p_send,p_sstruct,p_sflw) \
val NAME p_stardent
#elif defined(CALL_LIKE_VMS)
typedef dsc$descriptor_s * fpstr;
# define FTN_STR(s) s->dsc$a_pointer;
# define FTN_LEN(s) s->dsc$w_length;
# define char_struct(s) \
dsc$descriptor_s s;
# define fill_char_struct(s,str) \
s.dsc$a_pointer = str; \
s.dsc$w_length = strlen(str); \
s.dsc$b_dtype = DSC$K_DTYPE_T; \
s.dsc$b_class = DSC$K_CLASS_S;
# define init_char_struct(s,str,size) \
s.dsc$a_pointer = str; \
s.dsc$w_length = size; \
s.dsc$b_dtype = DSC$K_DTYPE_T; \
s.dsc$b_class = DSC$K_CLASS_S;
# define FORTRAN_SUBR(NAME,name,p_sun,p_stardent,p_mvs) \
void NAME p_stardent
# define FORTRAN_CALL(NAME,name,p_sun,p_stardent,p_mvs) \
NAME p_stardent
# define FORTRAN_FUN(val,NAME,name,p_sun,p_stardent,p_mvs) \
val NAME p_stardent
#elif defined(CALL_LIKE_MVS)
#if (CALL_LIKE_MVS == 2)
typedef pstr fpstr;
#define FTN_STR(s) s
#define FTN_LEN(s) s##_len
#define char_struct(s) \
pstr s; \
int s##_len;
#define fill_char_struct(s,str) \
s = str; \
s##_len = strlen(str);
#define init_char_struct(s,str,size) \
s = str; \
s##_len = size;
#define FORTRAN_SUBR(NAME,name,p_sun,p_stardent,p_mvs) \
void NAME p_sun
#define FORTRAN_CALL(NAME,name,p_sun,p_stardent,p_mvs) \
NAME p_sun
#define FORTRAN_FUN(val,NAME,name,p_sun,p_stardent,p_mvs) \
val NAME p_sun
#else
typedef pstr fpstr;
# define FTN_STR(s) s
# define FTN_LEN(s) s##_len
# define char_struct(s) \
pstr s; \
int s##_len;
# define fill_char_struct(s,str) \
s = str; \
s##_len = strlen(str);
# define init_char_struct(s,str,size) \
s = str; \
s##_len = size;
# define FORTRAN_SUBR(NAME,name,p_sun,p_stardent,p_mvs) \
void __stdcall NAME p_mvs
# define FORTRAN_CALL(NAME,name,p_sun,p_stardent,p_mvs) \
NAME p_mvs
# define FORTRAN_FUN(val,NAME,name,p_sun,p_stardent,p_mvs) \
val __stdcall NAME p_mvs
# endif
#else
# error Unknown machine!!!
typedef pstr fpstr;
# define FTN_STR(s) s
# define FTN_LEN(s) s##_len
# define char_struct(s) \
pstr s; \
int s##_len;
# define fill_char_struct(s,str) \
s = str; \
s##_len = strlen(str);
# define init_char_struct(s,str,size) \
s = str; \
s##_len = size;
/** Macro to define a function such that it is callable as
* a Fortran subroutine.
* @param NAME Subroutine name in upper case
* @param name Subroutine name in lower case
* @param p_sun Argument list in Sun style
* @param p_stardent Argument list in Stardent style
* @param p_mvs Argument list in MVS style
*/
# define FORTRAN_SUBR(NAME,name,p_sun,p_stardent,p_mvs) \
void name##_ p_sun
/** Macro to call a Fortran subroutine from a C function.
* @param NAME Subroutine name in upper case
* @param name Subroutine name in lower case
* @param p_sun Argument list in Sun style
* @param p_stardent Argument list in Stardent style
* @param p_mvs Argument list in MVS style
*/
# define FORTRAN_CALL(NAME,name,p_sun,p_stardent,p_mvs) \
name##_ p_sun
/** Macro to define a function such that it is callable as
* a Fortran function.
* @param val Data type of return value.
* @param NAME Function name in upper case
* @param name Function name in lower case
* @param p_sun Argument list in Sun style
* @param p_stardent Argument list in Stardent style
* @param p_mvs Argument list in MVS style
*/
# define FORTRAN_FUN(val,NAME,name,p_sun,p_stardent,p_mvs) \
val name##_ p_sun
#endif
/* Define Fortran logical */
typedef unsigned int ftn_logical;
#define FORTRAN_LOGICAL_TRUE 1
#define FORTRAN_LOGICAL_FALSE 0
#if defined (__OSF1__) || defined (__osf__)
# undef FORTRAN_LOGICAL_TRUE
# define FORTRAN_LOGICAL_TRUE -1
#endif
char *ccp4_FtoCString(fpstr str1, int str1_len);
void ccp4_CtoFString(fpstr str1, int str1_len, const char *cstring);
#endif /* __CCP4_FORTRAN */
|