DyLP  1.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dylib_fortran.h
Go to the documentation of this file.
1 #ifndef _DYLIB_FORTRAN_H
2 #define _DYLIB_FORTRAN_H
3 /*
4  This file is part of the support library for the Dylp LP distribution.
5 
6  Copyright (C) 2005 -- 2007 Lou Hafer
7 
8  School of Computing Science
9  Simon Fraser University
10  Burnaby, B.C., V5A 1S6, Canada
11  lou@cs.sfu.ca
12 
13  This code is licensed under the terms of the Eclipse Public License (EPL).
14 */
15 
16 /*
17  @(#)fortran.h 1.1 09/01/99
18  svn/cvs: $Id: dylib_fortran.h 407 2010-12-31 20:48:48Z lou $
19 */
20 
21 /*
22  Common typedefs, definitions, macros, etc., which are handy when constructing
23  C code that must talk to Fortran code.
24 
25  Off the top, typedefs and defines for the basic equivalences between
26  Fortran and C data types. This list isn't complete, but it covers the
27  common ones. (Taken from the Sun Fortran Programmer's Guide.)
28 */
29 
30 typedef short int integer_2 ;
31 typedef long int integer ;
32 typedef long int logical ;
33 typedef float real ;
34 typedef double double_precision ;
35 
36 #define TRUEL 1L
37 #define FALSEL 0L
38 
39 /*
40  A note about string handling in mixed code. C goes by the convention that
41  strings are terminated by a '\0' character, and padded with '\0' on the
42  rare occasions when padding is necessary. Fortran, on the other hand, keeps
43  an explicit (though hidden) length, and pads with ' '. The two forms are
44  just not compatible. Take care when passing strings back and forth. Adding
45  an explicit null in the Fortran definition of the string is your best bet.
46  The output routines in io.c and errs.c expect this, and do not make use of
47  the 'hidden' parameter giving the string length.
48 */
49 
50 /*
51  Some macros to help with Fortran arrays. 2-D arrays should simply be declared
52  as array[rows*cols], and let the macro take care of the rest. This avoids
53  complications due to column-major order in Fortran vs. row-major order in C.
54 
55  NOTE that these macros assume you are using the Fortran indexing convention,
56  which starts at 1.
57 */
58 
59 #define f_chr(zz_ptr,zz_ndx,zz_strsze) (*(zz_ptr+((zz_ndx)-1)*(zz_strsze)))
60 #define f_arr1(zz_ptr,zz_ndx) (*(zz_ptr+(zz_ndx)-1))
61 #define f_arr2(zz_ptr,zz_row,zz_col,zz_collen) \
62  (*(zz_ptr+((zz_col)-1)*(zz_collen)+((zz_row)-1)))
63 
64 
65 /*
66  These codes are used by the Fortran part of the code to identify arguments
67  supplied to errmsg_, warn_, and outfmt_. The Fortran code sees them from
68  the common block argcod_, which is initialised in errs.c:errinit (from the
69  io library. Do not rearrange the structure declaration without making
70  corresponding changes in the Fortran common block.
71 
72  The codes ftnargVARNAME and ftnargCONNAME are peculiar to the bonsai MILP
73  program (which prompted the development of the Fortran interface for i/o
74  and error messages) and likely of little use in other contexts. At best,
75  modifications to the routines in errs.c and io.c are required to support
76  them.
77 */
78 
79 #define ftnargINTEGER ((integer) 1)
80 #define ftnargDOUBLE_PRECISION ((integer) 2)
81 #define ftnargCHARACTER ((integer) 3)
82 #define ftnargVARNAME ((integer) 4)
83 #define ftnargCONNAME ((integer) 5)
84 #define ftnargEND ((integer) 6)
85 
86 extern struct { integer integer_code ;
92 
93 #endif /* _DYLIB_FORTRAN_H */
integer conname_code
Definition: dylib_fortran.h:90
double double_precision
Definition: dylib_fortran.h:34
short int integer_2
Definition: dylib_fortran.h:30
integer double_precision_code
Definition: dylib_fortran.h:87
long int integer
Definition: dylib_fortran.h:31
integer varname_code
Definition: dylib_fortran.h:89
long int logical
Definition: dylib_fortran.h:32
integer integer_code
Definition: dylib_fortran.h:86
integer character_code
Definition: dylib_fortran.h:88
struct @23 argcod_
integer end_code
Definition: dylib_fortran.h:91
float real
Definition: dylib_fortran.h:33