1 /**
2 * Copyright 1981-2016 ECMWF.
3 *
4 * This software is licensed under the terms of the Apache Licence
5 * Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 *
7 * In applying this licence, ECMWF does not waive the privileges and immunities
8 * granted to it by virtue of its status as an intergovernmental organisation
9 * nor does it submit to any jurisdiction.
10 */
11 #ifndef FORT2C_H
12 #define FORT2C_H
13 /*
14 	fort2c.h
15 */
16 #ifdef CRAY
17 /*  #include <fortran.h>  */
18 typedef	int		_f_int6;
19 typedef	long		_f_int8;
20 typedef	_f_int6		_f_int;
21 typedef	_f_int8		_f_int4;
22 typedef	_f_int8		_f_int2;
23 typedef	_f_int8		_f_int1;
24 typedef	long		_f_log8;
25 typedef	_f_log8		_f_log;
26 typedef	_f_log8		_f_log4;
27 typedef	_f_log8		_f_log2;
28 typedef	_f_log8		_f_log1;
29 typedef	double		_f_real8;
30 typedef	long double	_f_real16;
31 typedef	_f_real8	_f_real;
32 typedef	_f_real16	_f_dble;
33 typedef	_f_real8	_f_real4;
34 typedef	_Complex double	_f_comp8;
35 
36 typedef	_f_comp8	_f_comp;
37 
38 
39 
40 typedef	union	_FCD	{
41 	char	*c_pointer;
42 	struct	{
43 	unsigned bit_offset	:  6,
44 		 fcd_len	: 26,
45 		 word_addr	: 32;
46 	} _F;
47 } _dcf;
48 typedef	void	*_fcd;
49 
50 
51 
52 
53 typedef void *_GPTR;
54 typedef const void *_GPTR2CONST;
55 
56 extern	_fcd		_cptofcd (char *_Ccp, unsigned _Len);
57 extern	char *		_fcdtocp (_fcd _Fcd);
58 extern	unsigned int	_fcdlen (_fcd _Fcd);
59 extern	_f_log		_btol (long _BV);
60 extern	long		_lvtob (_f_log _LV);
61 extern	long		_ltob (_f_log *_LP);
62 extern	char *		_f2ccpy (_fcd f, ...);
63 extern	char *		_fc_copy (_fcd f, char *s, int slen);
64 extern	char *		_fc_acopy (_fcd f);
65 extern  int		_c2fcpy(char *c, _fcd f);
66 extern	int		_isfcd (long _P);
67 
68 static	_fcd
69 __cptofcd(char *c, unsigned int l);
70 #pragma _CRI inline	__cptofcd
71 static	_fcd
__cptofcd(char * c,unsigned int l)72 __cptofcd(char *c, unsigned int l)
73 {
74 	_dcf	f;
75 
76 	f.c_pointer	= c;
77 	f._F.fcd_len   	= l << 3;
78 
79 	return ((*(_fcd *) &f));
80 }
81 static	char *
82 __fcdtocp(_fcd f);
83 #pragma _CRI inline	__fcdtocp
84 static	char *
__fcdtocp(_fcd f)85 __fcdtocp(_fcd f)
86 {
87 	char	*c;
88 	_dcf	d;
89 	d		= (*(_dcf *) &f);
90 	d._F.fcd_len	= 0;
91 	c		= d.c_pointer;
92 	return (c);
93 }
94 #else
95 #define _fcd char *
96 #define _fcdtocp(a) a
97 #define _fcdlen(a) strlen(a)
98 #endif
99 
100 #ifdef VAX
101 typedef struct {short length; short magic; char * address;}DESC;
102 #define _fcdtocp(a) fcdtocp(a)
103 #define _fcd DESC *
104 #endif
105 
106 char *fcd2char();	/* fortran to c string convertion (alloc memory) */
107 
108 #endif /* end of  FORT2C_H */
109