Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
fortran.h
Go to the documentation of this file.
00001 /* USMID @(#) clibinc/fortran.h 92.5    10/06/99 12:10:46 */
00002 
00003 
00004 /*
00005 
00006   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00007 
00008   This program is free software; you can redistribute it and/or modify it
00009   under the terms of version 2 of the GNU General Public License as
00010   published by the Free Software Foundation.
00011 
00012   This program is distributed in the hope that it would be useful, but
00013   WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00015 
00016   Further, this software is distributed without any warranty that it is
00017   free of the rightful claim of any third person regarding infringement 
00018   or the like.  Any license provided herein, whether implied or 
00019   otherwise, applies only to this software file.  Patent licenses, if 
00020   any, provided herein do not apply to combinations of this program with 
00021   other software, or any other product whatsoever.  
00022 
00023   You should have received a copy of the GNU General Public License along
00024   with this program; if not, write the Free Software Foundation, Inc., 59
00025   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00026 
00027   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00028   Mountain View, CA 94043, or:
00029 
00030   http://www.sgi.com
00031 
00032   For further information regarding this notice, see:
00033 
00034   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00035 
00036 */
00037 
00038 #ifndef _FORTRAN_H
00039 #define _FORTRAN_H
00040 
00041 
00042 /*
00043  * C declarations for Fortran data types and for interlanguage data and
00044  * descriptor conversions.
00045  *
00046  * This header file defines a C type for each of the supported Fortran-90
00047  * types and kinds.   Descriptor conversion macros are defined to map
00048  * between C character pointers and the FORTRAN Character Descriptor format.
00049  * Data conversion macros are available for converting between Fortran
00050  * LOGICAL and C boolean (integer).
00051  */
00052 
00053 /*
00054  * Fortran data types:   
00055  *
00056  * The mappings listed below match a Fortran data type with a corresponding
00057  * C data type.   The related data types agree in:
00058  *
00059  *      1) Memory packing size.
00060  *      2) Range of values which can be operated on or stored.
00061  *
00062  * Each data type has a macro of the form _F_INT4 which is defined only
00063  * on platforms which support the data type.  In cases where there is a
00064  * set of data types which all have the same memory packing size, and the
00065  * same range of values, only the one with the largest declared kind is
00066  * defined.
00067  */
00068 
00069 #if     defined(_CRAY1)
00070 
00071 /*
00072  * The non-declaration of _F_INT4 is an exception to our rule of defining
00073  * the macros for data types.  While int kind=4 is defined for YMP, the
00074  * compiler does not treat it differently from int kind=6, and does not
00075  * create any new entry points for it.  Therefore, it was decided not to
00076  * define _F_INT4.  The declared value for these macros is dependent upon
00077  * whether the data type is really supported, or whether the type is defined
00078  * as an array of another type, or is a single entity.  Those which are
00079  * a single entity are defined as 1, which those which are defined as array
00080  * are defined to be (-1).
00081  *
00082  * 6/13/95 - typedef statements are being added for non-supported data
00083  *           types for use in the array intrinsics.  These data types are
00084  *           valid for PVP, but they are treated by the compiler as instances
00085  *           of the next larger distinct type.  (i.e. _f_int4 is valid, but
00086  *           is treated as an _f_int6).  These new entry points are being
00087  *           added for the MAXVAL/MINVAL routines, which can have distinct
00088  *           entry points for each valid data type.
00089  */
00090 
00091 #define _F_INT6         1
00092 #define _F_INT8         1
00093 
00094 typedef int             _f_int6;        /* integer kind=6 (46-bit on CX/CEA) */
00095 typedef long            _f_int8;        /* integer kind=8 */
00096 typedef _f_int6         _f_int;         /* integer of default kind */
00097 typedef _f_int8         _f_int4;        /* integer kind=4 */
00098 typedef _f_int8         _f_int2;        /* integer kind=2 */
00099 typedef _f_int8         _f_int1;        /* integer kind=1 */
00100 
00101 #define _F_LOG8         1
00102 
00103 typedef long            _f_log8;        /* logical kind=8 */
00104 typedef _f_log8         _f_log;         /* logical of default kind */
00105 typedef _f_log8         _f_log4;        /* logical kind=4 */
00106 typedef _f_log8         _f_log2;        /* logical kind=2 */
00107 typedef _f_log8         _f_log1;        /* logical kind=1 */
00108 
00109 #define _F_REAL8        1
00110 #define _F_REAL16       1
00111 
00112 typedef double          _f_real8;       /* real kind=8 */
00113 typedef long double     _f_real16;      /* real kind=16 */
00114 
00115 typedef _f_real8        _f_real;        /* real of default kind */
00116 typedef _f_real16       _f_dble;        /* double precision */
00117 typedef _f_real8        _f_real4;       /* real kind=4 */
00118 
00119 #define _F_COMP8        1
00120 #define _F_COMP16       1
00121 
00122 #if !defined(__cplusplus)
00123 #if __STDC__ == 1
00124 #include <complex.h>
00125 #endif
00126 typedef _Complex double _f_comp8;       /* complex kind=8 */
00127 /* typedef _Complex long double _f_comp16; */   /* complex kind=16 */
00128 typedef _f_comp8        _f_comp;        /* complex of default kind */
00129 #endif
00130 
00131 #endif  /* defined(_CRAY1) */
00132 
00133 
00134 #if     defined(_CRAYMPP)
00135 
00136 /*
00137  * 6/13/95 - typedef statements are being added for non-supported data
00138  *           types for use in the array intrinsics.  These data types are
00139  *           valid for PVP, but they are treated by the compiler as instances
00140  *           of the next larger distinct type.  (i.e. _f_int2 is valid, but
00141  *           is treated as an _f_int4).  These new entry points are being
00142  *           added for the MAXVAL/MINVAL routines, which can have distinct
00143  *           entry points for each valid data type.  */
00144 
00145 #define _F_INT4         1
00146 #define _F_INT8         1
00147 
00148 typedef short           _f_int4;        /* integer kind=4 */
00149 typedef int             _f_int8;        /* integer kind=8 */
00150 typedef _f_int8         _f_int;         /* integer of default kind */
00151 typedef _f_int4         _f_int2;        /* integer kind=2 */
00152 typedef _f_int4         _f_int1;        /* integer kind=1 */
00153 
00154 #define _F_LOG4         1
00155 #define _F_LOG8         1
00156 
00157 typedef short           _f_log4;        /* logical kind=4 */
00158 typedef long            _f_log8;        /* logical kind=8 */
00159 typedef _f_log8         _f_log;         /* logical of default kind */
00160 typedef _f_log4         _f_log2;        /* logical kind=2 */
00161 typedef _f_log4         _f_log1;        /* logical kind=1 */
00162 
00163 #define _F_REAL4        1
00164 #define _F_REAL8        1
00165 
00166 typedef float           _f_real4;       /* real kind=4 */
00167 typedef double          _f_real8;       /* real kind=8 */
00168 #if _LD64
00169 typedef struct {long x[2];} _f_real16;  /* real kind=16 */
00170 #define _F_REAL16       (-1)
00171 #else
00172 typedef long double     _f_real16;      /* real kind=16 */
00173 #define _F_REAL16       1
00174 #endif
00175 typedef _f_real8        _f_real;        /* real of default kind */
00176 typedef _f_real16       _f_dble;        /* double precision */
00177 typedef _f_real4        _f_real2;       /* real kind=2 */
00178 
00179 #define _F_COMP4        1
00180 #define _F_COMP8        1
00181 
00182 #if !defined(__cplusplus)
00183 #include <complex.h>
00184 typedef _Complex float  _f_comp4;       /* complex kind=4 */
00185 typedef _Complex double _f_comp8;       /* complex kind=8 */
00186 /* typedef _Complex long double _f_comp16; */   /* complex kind=16 */
00187 typedef _f_comp8        _f_comp;        /* complex of default kind */
00188 #endif
00189 
00190 #endif  /* _CRAYMPP */
00191 
00192 
00193 #if     defined(__mips)
00194 
00195 /*
00196  *      MIPS n32 and 64 ABIs.
00197  */
00198 
00199 #define _F_INT1         1
00200 #define _F_INT2         1
00201 #define _F_INT4         1
00202 #define _F_INT8         1
00203 
00204 typedef signed char     _f_int1;         /* integer kind=1 */
00205 typedef short           _f_int2;        /* integer kind=2 */
00206 typedef int             _f_int4;        /* integer kind=4 */
00207 typedef long long       _f_int8;        /* integer kind=8 */
00208 typedef _f_int4         _f_int;         /* integer of default kind */
00209 
00210 #define _F_LOG1         1
00211 #define _F_LOG2         1
00212 #define _F_LOG4         1
00213 #define _F_LOG8         1
00214 
00215 typedef signed char     _f_log1;        /* logical kind=1 */
00216 typedef short           _f_log2;        /* logical kind=2 */
00217 typedef int             _f_log4;        /* logical kind=4 */
00218 typedef long long       _f_log8;        /* logical kind=8 */
00219 typedef _f_log4         _f_log;         /* logical of default kind */
00220 
00221 #define _F_REAL4        1
00222 #define _F_REAL8        1
00223 #define _F_REAL16       1
00224 
00225 typedef float           _f_real4;       /* real kind=4 */
00226 typedef double          _f_real8;       /* real kind=8 */
00227 typedef long double     _f_real16;      /* real kind=16 */
00228 typedef _f_real4        _f_real;        /* real of default kind */
00229 typedef _f_real8        _f_dble;        /* double precision */
00230 
00231 #define _F_COMP4        (-1)
00232 #define _F_COMP8        (-1)
00233 #define _F_COMP16       (-1)
00234 
00235 typedef struct {_f_real4 x[2];} _f_comp4;  /* complex kind=4 */
00236 typedef struct {_f_real8 x[2];} _f_comp8;  /* complex kind=8 */
00237 typedef struct {_f_real16 x[2];} _f_comp16;  /* complex kind=16 */
00238 typedef _f_comp4        _f_comp;        /* complex of default kind */
00239 
00240 #endif  /* __mips */
00241 
00242 #if     defined(_LITTLE_ENDIAN)
00243 /*
00244  *      32- and 64-bit ABIs.
00245  */
00246 
00247 #define _F_INT1         1
00248 #define _F_INT2         1
00249 #define _F_INT4         1
00250 #define _F_INT8         1
00251 
00252 typedef signed char     _f_int1;         /* integer kind=1 */
00253 typedef short           _f_int2;        /* integer kind=2 */
00254 typedef int             _f_int4;        /* integer kind=4 */
00255 typedef long            _f_int8;        /* integer kind=8 */
00256 typedef _f_int4         _f_int;         /* integer of default kind */
00257 
00258 #define _F_LOG1         1
00259 #define _F_LOG2         1
00260 #define _F_LOG4         1
00261 #define _F_LOG8         1
00262 
00263 typedef signed char     _f_log1;        /* logical kind=1 */
00264 typedef short           _f_log2;        /* logical kind=2 */
00265 typedef int             _f_log4;        /* logical kind=4 */
00266 typedef long            _f_log8;        /* logical kind=8 */
00267 typedef _f_log4         _f_log;         /* logical of default kind */
00268 
00269 #define _F_REAL4        1
00270 #define _F_REAL8        1
00271 #define _F_REAL16       1
00272 
00273 typedef float           _f_real4;       /* real kind=4 */
00274 typedef double          _f_real8;       /* real kind=8 */
00275 typedef long double     _f_real16;      /* real kind=16 */
00276 typedef _f_real4        _f_real;        /* real of default kind */
00277 typedef _f_real8        _f_dble;        /* double precision */
00278 
00279 /* For cray sv2 with a specific complex data type */
00280 #ifdef _CRAY
00281 #define _F_COMP4        1
00282 #define _F_COMP8        1
00283 #define _F_COMP16       1
00284 
00285 #if !defined(__cplusplus)
00286 #if __STDC__ == 1
00287 #include <complex.h>
00288 #endif
00289 typedef _Complex float  _f_comp4;       /* complex kind=8 */
00290 typedef _Complex double _f_comp8;       /* complex kind=8 */
00291 typedef _Complex long double    _f_comp16;      /* complex kind=16 */
00292 typedef _f_comp8        _f_comp;        /* complex of default kind */
00293 #endif
00294 
00295 #else   /* _CRAY */
00296 #define _F_COMP4        (-1)
00297 #define _F_COMP8        (-1)
00298 #define _F_COMP16       (-1)
00299 
00300 typedef struct {_f_real4 x[2];} _f_comp4;  /* complex kind=4 */
00301 typedef struct {_f_real8 x[2];} _f_comp8;  /* complex kind=8 */
00302 typedef struct {_f_real16 x[2];} _f_comp16;  /* complex kind=16 */
00303 typedef _f_comp4        _f_comp;        /* complex of default kind */
00304 #endif  /* _CRAY */
00305 
00306 #endif  /* _LITTLE_ENDIAN */
00307 
00308 #if     !defined(__mips) && defined(_WORD32) && !defined(_LITTLE_ENDIAN)
00309 
00310 /*
00311  * 6/13/95 - typedef statements are being added for non-supported data
00312  *           types for use in the array intrinsics.  These data types are
00313  *           valid for PVP, but they are treated by the compiler as instances
00314  *           of the next larger distinct type.  (i.e. _f_int1 is valid, but
00315  *           is treated as an _f_int2).  These new entry points are being
00316  *           added for the MAXVAL/MINVAL routines, which can have distinct
00317  *           entry points for each valid data type.
00318  */
00319 
00320 #define _F_INT2         1
00321 #define _F_INT4         1
00322 #define _F_INT8         1
00323 
00324 typedef int             _f_int2;        /* integer kind=2 */
00325 typedef int             _f_int4;        /* integer kind=4 */
00326 typedef long long       _f_int8;        /* integer kind=8 */
00327 typedef _f_int4         _f_int;         /* integer of default kind */
00328 typedef _f_int2         _f_int1;        /* integer kind=1 */
00329 
00330 #define _F_LOG2         1
00331 #define _F_LOG4         1
00332 #define _F_LOG8         1
00333 
00334 typedef int             _f_log2;        /* logical kind=2 */
00335 typedef int             _f_log4;        /* logical kind=4 */
00336 typedef long long       _f_log8;        /* logical kind=8 */
00337 typedef _f_log4         _f_log;         /* logical of default kind */
00338 typedef _f_log2         _f_log1;        /* logical kind=1 */
00339 
00340 #define _F_REAL4        1
00341 #define _F_REAL8        1
00342 #if defined(_SOLARIS)   /* only Solaris is 128-bit for now */
00343 #define _F_REAL16       1
00344 #endif
00345 
00346 typedef float           _f_real4;       /* real kind=4 */
00347 typedef double          _f_real8;       /* real kind=8 */
00348 typedef long double     _f_real16;      /* real kind=16 */
00349 typedef _f_real4        _f_real;        /* real of default kind */
00350 typedef _f_real8        _f_dble;        /* double precision */
00351 
00352 #define _F_COMP4        (-1)
00353 #define _F_COMP8        (-1)
00354 #define _F_COMP16       (-1)
00355 
00356 typedef struct {_f_real4 x[2];} _f_comp4;  /* complex kind=4 */
00357 typedef struct {_f_real8 x[2];} _f_comp8;  /* complex kind=8 */
00358 typedef struct {_f_real16 x[2];} _f_comp16;  /* complex kind=16 */
00359 typedef _f_comp4        _f_comp;        /* complex of default kind */
00360 
00361 #endif  /* NOT __mips, _WORD32, _LITTLE_ENDIAN */
00362 
00363 
00364 /* Conversion between Fortran character descriptors and C character pointers */
00365 
00366 /*
00367  * The "_fcd" type defines a Fortran character variable of default kind.
00368  * The use of this type is intended for interlanguage communication
00369  * between C and FORTRAN.  The type _fcd must not be used for any other 
00370  * purposes.  
00371  * 
00372  * The format of Fortran character descriptors on 24-bit A-register systems:
00373  * 
00374  *     | 17 bits          | 17 bits       |6 bits|       24 bits       |
00375  *     -----------------------------------------------------------------
00376  *     |                  | length        | BO   |     word address    |
00377  *     -----------------------------------------------------------------
00378  * 
00379  * The format of Fortran character descriptors on 32-bit A-register systems:
00380  * 
00381  *     |6 bits|         26 bits         |         32 bits              | 
00382  *     -----------------------------------------------------------------
00383  *     | BO   |         length          |       word address           |
00384  *     -----------------------------------------------------------------
00385  *
00386  * The format of Fortran character descriptors on 64-bit A-register systems
00387  * is defined as a two-word structure.  Note that in this instance, there
00388  * is no need to be concerned about the format of a C character pointer.
00389  * 
00390  *     |                             64 bits                           | 
00391  *     -----------------------------------------------------------------
00392  *     |                      C Character Pointer                      |
00393  *     -----------------------------------------------------------------
00394  *     |   Length (in bits on PVP and T3D; bytes on IRIX/Solaris/T3E )  |
00395  *     -----------------------------------------------------------------
00396  * 
00397  * 
00398  * The format of C character pointers on 24-bit A-register systems:
00399  * 
00400  *     |6 bits|         34 bits                 |       24 bits        | 
00401  *     -----------------------------------------------------------------
00402  *     | BO   |                                 |     word address     |
00403  *     -----------------------------------------------------------------
00404  * 
00405  * The format of C character pointers on 32-bit A-register systems:
00406  * 
00407  *     |6 bits|         26 bits         |         32 bits              | 
00408  *     -----------------------------------------------------------------
00409  *     | BO   |                         |       word address           |
00410  *     -----------------------------------------------------------------
00411  * 
00412  * where BO = bit offset.
00413  *
00414  * 
00415  * _fcdtocp() converts a Fortran character descriptor to a C character 
00416  * pointer.
00417  *
00418  * _fcdlen() extracts the length (in bytes) of a Fortran character
00419  * descriptor.
00420  *
00421  * _isfcd() returns true if an object (of type long) is an _fcd.  This
00422  * is NOT available on _ADDR64 systems and its use is being deprecated.
00423  *
00424  * _cptofcd() converts a C character pointer and a length into a Fortran 
00425  * character descriptor.
00426  *
00427  * The functions _fcdlen and _fcdtocp are guaranteed to work if their 
00428  * parameters have type _fcd.
00429  *
00430  * A Fortran character descriptor converted to a C charactor pointer and back
00431  * to a Fortran character descriptor:
00432  *
00433  *      f = _cptofcd(_fcdtocp(f), _fcdlen(f))
00434  * 
00435  * _lvtob() converts a Fortran LOGICAL value to a zero or a one.  The
00436  * parameter must be of type _f_log.
00437  *
00438  * _ltob() converts a Fortran LOGICAL value to a zero or a one.  The
00439  * parameter must be a pointer.
00440  *
00441  * _btol() converts a zero or nonzero value to a Fortran LOGICAL value.
00442  * The parameter must have integral type.
00443  *
00444  * _dvel_len() extracts the element length (in bytes) of an array from
00445  * a Fortran dope vector.
00446  *
00447  * All these functions have both function implementations (so that the address
00448  * of it can be taken) and macro or inline implementations (for speed).
00449  */ 
00450 /*
00451  * The C 6.0 (and later) compiler on Unicos and Unicos/MK systems 
00452  * recognizes a struct, class, or union with the name "_FCD" as a
00453  * Fortran character descriptor.
00454  * It allows an object of this type to be passed to a Fortran function
00455  * by value instead of taking its address.  (Normally, an object with
00456  * non-pointer type will have its address taken before being passed to
00457  * Fortran function.)  Typedefs can be used to rename the type, but the
00458  * but the underlying struct, class, or union must have the name 
00459  * "_FCD". The C 4.0 and 5.0 compilers recognize a struct with
00460  * the name "_FCD" on Cray-T90 and Cray-MPP machines.
00461  */
00462 #if     !defined(_UNICOS)               /* IRIX, Solaris */
00463  
00464 typedef struct  _FCD    {
00465         char            *c_pointer;     /* C character pointer          */
00466         unsigned long   byte_len;       /* Length of item (in bytes)    */
00467 } _fcd;
00468  
00469 typedef _fcd    _dcf;                   /* Equal on this architecture   */
00470 
00471 /* Define a temporary function to map _dcf's to _fcd's */
00472 
00473 #define _fcdtodcf(f)    (f)
00474 #define _dcftofcd(f)    (f)
00475 
00476 
00477 #elif   defined(_ADDR64)                /* CRAY T3D, CRAY TS, Solaris */
00478  
00479 typedef struct  _FCD    {
00480         char            *c_pointer;     /* C character pointer  */
00481         unsigned long   fcd_len;        /* Length of item       */
00482 } _fcd;
00483  
00484 typedef _fcd    _dcf;                   /* Equal on this architecture   */
00485 
00486 /* Define a temporary function to map _dcf's to _fcd's */
00487 
00488 #define _fcdtodcf(f)    (f)
00489 #define _dcftofcd(f)    (f)
00490 
00491 
00492 #elif   _ADDR32 && ! defined(_WORD32)   /* CRAY Y-MP and CRAY-2 */
00493  
00494 typedef union   _FCD    {
00495         char    *c_pointer;             /* C character pointer          */
00496 
00497         struct  {
00498         unsigned bit_offset     :  6,   /* Starting bit offset          */
00499                  fcd_len        : 26,   /* Length of item (in bits)     */
00500                  word_addr      : 32;   /* Word address                 */
00501         } _F;
00502 } _dcf;         /* This can be _fcd when compiler knows about _FCD      */
00503 
00504 typedef void    *_fcd;  /* Temporary, to ensure fortran functions work  */
00505 
00506 /* Define a temporary function to map _dcf's to _fcd's */
00507 
00508 #define _dcftofcd(f)    (*(_fcd *) &f)
00509 #define _fcdtodcf(f)    (*(_dcf *) &f)
00510 
00511 
00512 #elif   _ADDR32 == 0                    /* CRAY X-MP */
00513 
00514 typedef union   _FCD    {
00515 
00516         struct  {
00517         unsigned bit_offset     :  6,   /* Starting bit offset          */
00518                  _Unused        : 34,   /* Unused                       */
00519                  word_addr      : 24;   /* Word address                 */
00520         } _C;
00521 
00522         struct  {
00523         unsigned _Unused        : 17,   /* Unused                       */
00524                  fcd_len        : 17,   /* Length of item (in bits)     */
00525                  bit_offset     :  6,   /* Starting bit offset          */
00526                  word_addr      : 24;   /* Word address                 */
00527         } _F;
00528 } _dcf; /* This can be _fcd when compiler knows about _FCD */
00529 
00530 typedef void    *_fcd;  /* Temporary, to ensure fortran functions work  */
00531 
00532 /* Define a temporary function to map _dcf's to _fcd's */
00533 
00534 #define _dcftofcd(f)    (*(_fcd *) &f)
00535 #define _fcdtodcf(f)    (*(_dcf *) &f)
00536 
00537 #endif  /* CRAY X-MP */
00538 
00539 #if defined(__sun) || defined(__alpha)
00540 # include <cdefs.h>      /* use crayf90/fe90/cdefs.h */
00541 #else
00542 # include <sys/cdefs.h>  /* use system's header */
00543 #endif
00544 
00545 __BEGIN_DECLS
00546 extern  _fcd            _cptofcd (char *_Ccp, unsigned _Len);
00547 extern  char *          _fcdtocp (_fcd _Fcd);
00548 extern  unsigned long   _fcdlen (_fcd _Fcd);
00549 extern  _f_log          _btol (long _BV);
00550 extern  long            _lvtob (_f_log _LV);
00551 extern  long            _ltob (_f_log *_LP);
00552 #ifdef  _UNICOS
00553 extern  char *          _f2ccpy (_fcd f, ...);
00554 #endif
00555 extern  char *          _fc_copy (_fcd f, char *s, int slen);
00556 extern  char *          _fc_acopy (_fcd f);
00557 extern  int             _c2fcpy(char *c, _fcd f);
00558 
00559 #if     defined(_UNICOS) && !defined(_ADDR64) && !defined(_WORD32) 
00560 extern  int             _isfcd (long _P);
00561 #endif
00562 
00563 #ifdef  _CRAYMPP
00564 extern  void            *_S2PC (void *_SDP, unsigned int _ELSZ);
00565 #endif
00566 
00567 extern  unsigned long   _dvel_len (long _DVEL);
00568 
00569 __END_DECLS
00570 
00571 #if     !defined(_UNICOS)               /* IRIX, Solaris */
00572 
00573 static  _fcd
00574 __cptofcd(char *c, unsigned long l);
00575 static  _fcd
00576 __cptofcd(char *c, unsigned long l)
00577 {
00578         _dcf    f;
00579  
00580         f.c_pointer     = c;
00581         f.byte_len      = l;
00582  
00583         return (_dcftofcd(f));
00584 }
00585 
00586 #define __fcdtocp(f)    ((_fcdtodcf(f)).c_pointer)
00587 
00588 #define __fcdlen(f)     ((unsigned long) (_fcdtodcf(f)).byte_len)
00589 
00590 
00591 #elif   defined(_ADDR64)                /* CRAY T3D, CRAY TS */
00592 
00593 static  _fcd
00594 __cptofcd(char *c, unsigned long l);
00595 static  _fcd
00596 __cptofcd(char *c, unsigned long l)
00597 {
00598         _dcf    f;
00599  
00600         f.c_pointer     = c;
00601 #ifdef  _CRAYT3E
00602         f.fcd_len       = l;
00603 #else
00604         f.fcd_len       = l << 3;
00605 #endif
00606  
00607         return (_dcftofcd(f));
00608 }
00609 
00610 #define __fcdtocp(f)    ((_fcdtodcf(f)).c_pointer)
00611 
00612 #ifdef  _CRAYT3E
00613 #define __fcdlen(f)     ((unsigned long) (_fcdtodcf(f)).fcd_len)
00614 #else
00615 #define __fcdlen(f)     ((unsigned long) ((_fcdtodcf(f)).fcd_len) >> 3)
00616 #endif
00617 
00618 
00619 #elif   _ADDR32                         /* CRAY Y-MP and CRAY-2 */
00620 
00621 static  _fcd
00622 __cptofcd(char *c, unsigned long l);
00623 #pragma _CRI inline __cptofcd
00624 static  _fcd
00625 __cptofcd(char *c, unsigned long l)
00626 {
00627         _dcf    f;
00628  
00629         f.c_pointer     = c;
00630         f._F.fcd_len    = l << 3;
00631  
00632         return (_dcftofcd(f));
00633 }
00634 
00635 static  char *
00636 __fcdtocp(_fcd f);
00637 #pragma _CRI inline __fcdtocp
00638 static  char *
00639 __fcdtocp(_fcd f)
00640 {
00641         char    *c;
00642         _dcf    d;
00643 
00644         d               = _fcdtodcf(f);
00645         d._F.fcd_len    = 0;
00646         c               = d.c_pointer;
00647 
00648         return (c);
00649 }
00650 
00651 #define __fcdlen(f)     ((unsigned int) ((_fcdtodcf(f))._F.fcd_len) >> 3)
00652 
00653 #define __isfcd(f)      (__fcdlen(f) != 0)
00654 
00655 #elif   _ADDR32 == 0                    /* CRAY X-MP */
00656 
00657 static  _fcd
00658 __cptofcd(char *c, unsigned long l);
00659 #pragma _CRI inline __cptofcd
00660 static  _fcd
00661 __cptofcd(char *c, unsigned long l)
00662 {
00663         _dcf    d;
00664  
00665         d               = *(_dcf *) &c;
00666         d._F.bit_offset = d._C.bit_offset;
00667         d._F._Unused    = 0;
00668         d._F.fcd_len    = l << 3;
00669  
00670         return (_dcftofcd(d));
00671 }
00672 
00673 static  char *
00674 __fcdtocp(_fcd f);
00675 #pragma _CRI inline __fcdtocp
00676 static  char *
00677 __fcdtocp(_fcd f)
00678 {
00679         char    *c;
00680         _dcf    d;
00681 
00682         d               = _fcdtodcf(f);
00683         d._C.bit_offset = d._F.bit_offset;
00684         d._C._Unused    = 0;
00685         c               = *(char **) &d;
00686 
00687         return (c);
00688 }
00689 
00690 #define __fcdlen(f)     ((unsigned long) ((_fcdtodcf(f))._F.fcd_len) >> 3)
00691 
00692 #define __isfcd(f)      (__fcdlen(f) != 0)
00693 
00694 #endif  /* CRAY X-MP */
00695 
00696 /* Conversion functions between Fortran LOGICAL data and C boolean data */
00697 
00698 #if     defined(__mips) || defined(_CRAYIEEE) || defined(_SOLARIS) || \
00699         defined(_SUNOS)  || defined(_ABSOFT) || defined(_LITTLE_ENDIAN)
00700 
00701 #define __lvtob(l)      ((long)((l) == 0 ? 0 : 1))
00702 #define __btol(b)       ((_f_log)((b) == 0 ? 0 : 1))
00703 
00704 #elif   defined(_CRAY1)
00705 
00706 #define __lvtob(l)      ((long)((l) >> 63))
00707 #define __btol(b)       ((_f_log)((b) == 0 ? 0 : -1))
00708 
00709 #endif /* __mips, _CRAYIEEE, _SOLARIS, _SUNOS, _ABSOFT, _LITTLE_ENDIAN */
00710 
00711 #define __devl_len(dvl) ((long)((dvl) >> 3))
00712 
00713 /* Equivalence inline functions to user-level functions */
00714 
00715 #define _cptofcd(_C, _L)        __cptofcd(_C, _L)
00716 #define _fcdtocp(_F)            __fcdtocp(_F)
00717 #define _fcdlen(_F)             __fcdlen(_F)
00718 #define _btol(_BV)              __btol(_BV)
00719 #define _lvtob(_LV)             __lvtob(_LV)
00720 #define _ltob(_LP)              __lvtob(*(_f_log *)_LP)
00721 #define __dvel_len(_DVEL)       __dvel_len(long _DVEL)
00722 
00723 #if     !defined(_ADDR64) && !defined(_WORD32) && !defined(__mips) && \
00724         !defined(_LITTLE_ENDIAN)
00725 #define _isfcd(_U)              __isfcd(_U)
00726 #endif /* NOT _ADDR64,_WORD32, __mips, and _LITTLE_ENDIAN */
00727 
00728 /*
00729  *      Determine whether a pointer points to a shared data descriptor.
00730  *      Note that a shared data descriptor presupposes the centrifuge
00731  *      function which presupposes CRAFT; which is available only on
00732  *      the CRAY-T3D.
00733  */
00734 
00735 #ifdef  _CRAYT3D
00736 #define _issddptr(_P)           ((unsigned)(_P) >> 63)
00737 #else
00738 #define _issddptr(_P)           0
00739 #define _S2PC(_PTR, _SIZE)      ((void *)(_PTR))
00740 #endif
00741 
00742 #endif /* !_FORTRAN_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines