~ubuntu-branches/ubuntu/raring/gpp4/raring

« back to all changes in this revision

Viewing changes to src/ccp4_fortran.h

  • Committer: Bazaar Package Importer
  • Author(s): Morten Kjeldgaard
  • Date: 2008-12-03 11:21:42 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20081203112142-bvuelg39lt2lnokb
Tags: 1.1.0-0ubuntu1
* New upstream version (LP: #322205)
* Some compilation warnings fixed, patch 01-ubuntu-fixes
  sent upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
    @brief Header file for Fortran APIs
27
27
    @author Eugene Krissinel
28
 
 
 
28
*/
 
29
 
 
30
 
 
31
 
 
32
#ifndef __CCP4_FORTRAN
 
33
#define __CCP4_FORTRAN
 
34
 
 
35
#include "ccp4_types.h"
 
36
 
 
37
/* stardent is now obsolete, but we retain this category in case it is useful later */
 
38
#ifdef CALL_LIKE_STARDENT
 
39
  /* SStrParam is used in Ardent-like machines' fortran calls */
 
40
  /* for passing a string parameter */
 
41
  DefineStructure(SStrPar)
 
42
  struct SStrPar  {
 
43
    pstr S;
 
44
    int  len;
 
45
    int  id;
 
46
  };
 
47
#endif
 
48
 
 
49
#define _LVTOB(l) ((long) ((l) == 0 ? 0 : 1))  
 
50
#define _BTOLV(l) ((int) ((l) == 0 ? 0 : 1))
 
51
#if defined (__OSF1__) || defined (__osf__)
 
52
#undef _BTOLV
 
53
#define _BTOLV(l) ((int) ((l) == 0 ? 0 : -1))  
 
54
#endif    
 
55
 
 
56
/**
29
57
   Macro  FORTRAN_SUBR(NAME,name,p_send,p_sstruct,p_sflw)
30
58
   makes function header statements that allow for linking with
31
59
   programs written in FORTRAN.
58
86
             complex parameter, 'fpstr' is identical to the
59
87
             pointer on the corresponding structure:
60
88
@verbatim 
61
 
              CALL_LIKE_STARDENT :
 
89
               CALL_LIKE_STARDENT :
62
90
                   'fpstr' is identical to 'PSStrPar'
63
91
               CALL_LIKE_VMS      :
64
92
                   'fpstr' is identical to 'dsc$descriptor_s *'
119
147
           fpstr s2, int s2_len, int * m ) )
120
148
  @endcode
121
149
  
122
 
  The macro should replace ordinary function header
 
150
    The macro should replace ordinary function header
123
151
  statements to assure compatibility with FORTRAN links.
124
152
  In header files, do not forget to add semicolon:
125
153
  
145
173
 
146
174
 
147
175
 
148
 
#ifndef __CCP4_FORTRAN
149
 
#define __CCP4_FORTRAN
150
 
 
151
 
#include "ccp4_types.h"
152
 
 
153
 
/* stardent is now obsolete, but we retain this category in case it is useful later */
154
 
#ifdef CALL_LIKE_STARDENT
155
 
  /* SStrParam is used in Ardent-like machines' fortran calls */
156
 
  /* for passing a string parameter */
157
 
  DefineStructure(SStrPar)
158
 
  struct SStrPar  {
159
 
    pstr S;
160
 
    int  len;
161
 
    int  id;
162
 
  };
163
 
#endif
164
 
 
165
 
#define _LVTOB(l) ((long) ((l) == 0 ? 0 : 1))  
166
 
#define _BTOLV(l) ((int) ((l) == 0 ? 0 : 1))
167
 
#if defined (__OSF1__) || defined (__osf__)
168
 
#undef _BTOLV
169
 
#define _BTOLV(l) ((int) ((l) == 0 ? 0 : -1))  
170
 
#endif    
171
 
 
172
 
 
173
 
 
174
176
#if  defined(CALL_LIKE_SUN)
175
177
 
176
178
  typedef pstr fpstr;
177
179
 
178
 
#  define FTN_STR(s)  s
179
 
#  define FTN_LEN(s)  s##_len
 
180
#define FTN_STR(s)  s
 
181
#define FTN_LEN(s)  s##_len
180
182
 
181
 
#  define char_struct(s)           \
 
183
#define char_struct(s)           \
182
184
    pstr  s;                       \
183
185
    int   s##_len;
184
 
#  define fill_char_struct(s,str)  \
 
186
#define fill_char_struct(s,str)  \
185
187
    s  = str;                      \
186
188
    s##_len = strlen(str);
187
 
#  define init_char_struct(s,str,size)  \
 
189
#define init_char_struct(s,str,size)  \
188
190
    s  = str;                      \
189
191
    s##_len = size;
190
192
 
191
 
#  define FORTRAN_SUBR(NAME,name,p_sun,p_stardent,p_mvs) \
 
193
#define FORTRAN_SUBR(NAME,name,p_sun,p_stardent,p_mvs) \
192
194
    void name##_ p_sun
193
 
#  define FORTRAN_CALL(NAME,name,p_sun,p_stardent,p_mvs) \
 
195
#define FORTRAN_CALL(NAME,name,p_sun,p_stardent,p_mvs) \
194
196
    name##_ p_sun
195
 
#  define FORTRAN_FUN(val,NAME,name,p_sun,p_stardent,p_mvs) \
 
197
#define FORTRAN_FUN(val,NAME,name,p_sun,p_stardent,p_mvs) \
196
198
    val name##_ p_sun
197
199
#elif defined(CALL_LIKE_HPUX)
198
200
 
271
273
 
272
274
#elif defined(CALL_LIKE_MVS)
273
275
 
 
276
#if (CALL_LIKE_MVS == 2)
 
277
 
 
278
  typedef pstr fpstr;
 
279
 
 
280
#define FTN_STR(s)  s
 
281
#define FTN_LEN(s)  s##_len
 
282
 
 
283
#define char_struct(s)           \
 
284
    pstr  s;                       \
 
285
    int   s##_len;
 
286
#define fill_char_struct(s,str)  \
 
287
    s  = str;          \
 
288
        s##_len = strlen(str);
 
289
#define init_char_struct(s,str,size)  \
 
290
    s  = str;                   \
 
291
        s##_len = size;
 
292
 
 
293
#define FORTRAN_SUBR(NAME,name,p_sun,p_stardent,p_mvs) \
 
294
    void NAME p_sun
 
295
#define FORTRAN_CALL(NAME,name,p_sun,p_stardent,p_mvs) \
 
296
    NAME p_sun
 
297
#define FORTRAN_FUN(val,NAME,name,p_sun,p_stardent,p_mvs) \
 
298
    val NAME p_sun
 
299
 
 
300
#else
 
301
 
274
302
  typedef pstr fpstr;
275
303
 
276
304
#  define FTN_STR(s)  s
293
321
#  define FORTRAN_FUN(val,NAME,name,p_sun,p_stardent,p_mvs) \
294
322
    val __stdcall NAME p_mvs
295
323
 
 
324
# endif
 
325
 
296
326
#else
297
327
 
298
328
#  error  Unknown machine!!!