-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfortran.h
More file actions
83 lines (64 loc) · 1.37 KB
/
Copy pathfortran.h
File metadata and controls
83 lines (64 loc) · 1.37 KB
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
#ifndef _LAWRAP_FORTRAN_H_
#define _LAWRAP_FORTRAN_H_
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#pragma pack(push)
#pragma pack(4)
typedef struct
{
float real;
float imag;
} lawrap_fake_scomplex;
#pragma pack(8)
typedef struct
{
double real;
double imag;
} lawrap_fake_dcomplex;
#pragma pack(pop)
#ifndef LAWRAP_COMPLEX_DEFINED
#ifdef __cplusplus
#include <complex>
#define creal real
#define crealf real
#define cimag imag
#define cimagf imag
typedef std::complex<float> scomplex;
typedef std::complex<double> dcomplex;
#elif __STDC_VERSION__ >= 199901L
#include <complex.h>
typedef float complex scomplex;
typedef double complex dcomplex;
#else
typedef lawrap_fake_scomplex scomplex;
typedef lawrap_fake_dcomplex dcomplex;
//TODO: add creal etc.
#endif
#endif
/*
* integer == integer*4 is usually a safe bet
*/
#ifndef FORTRAN_INTEGER_SIZE
#define FORTRAN_INTEGER_SIZE 4
#endif
#if FORTRAN_INTEGER_SIZE == 1
typedef int8_t integer;
#elif FORTRAN_INTEGER_SIZE == 2
typedef int16_t integer;
#elif FORTRAN_INTEGER_SIZE == 4
typedef int32_t integer;
#elif FORTRAN_INTEGER_SIZE == 8
typedef int64_t integer;
#else
#error "A valid FORTRAN_INTEGER_SIZE must be specified"
#endif
typedef integer logical;
/*
* lowercase symbols with underscore are most common
*/
#ifndef FC_FUNC
#define FC_FUNC(lower,UPPER) lower ## _
#endif
#endif