1 #if HAVE_CONFIG_H 2 # include "config.h" 3 #endif 4 5 /* $Id: datatypes.c,v 1.9.10.1 2006-12-14 13:24:47 manoj Exp $ 6 * conversion of MA identifiers between C to Fortran data types 7 * Note that ga_type_c2f(MT_F_INT) == MT_F_INT 8 */ 9 10 #include "gacommon.h" 11 #include "macommon.h" 12 #include "ga-papi.h" 13 pnga_type_f2c(Integer type)14Integer pnga_type_f2c(Integer type) 15 { 16 Integer ctype; 17 switch(type){ 18 case MT_F_INT: 19 # if SIZEOF_F77_INTEGER == SIZEOF_INT 20 ctype = C_INT; 21 # elif SIZEOF_F77_INTEGER == SIZEOF_LONG 22 ctype = C_LONG; 23 # elif SIZEOF_F77_INTEGER == SIZEOF_LONG_LONG 24 ctype = C_LONGLONG; 25 # else 26 # error SIZEOF_F77_INTEGER == SIZEOF_??? 27 # endif 28 break; 29 case MT_F_REAL: 30 # if SIZEOF_F77_REAL == SIZEOF_FLOAT 31 ctype = C_FLOAT; 32 # elif SIZEOF_F77_REAL == SIZEOF_DOUBLE 33 ctype = C_DBL; 34 # elif SIZEOF_F77_REAL == SIZEOF_LONG_DOUBLE 35 # error SIZEOF_F77_REAL == SIZEOF_LONG_DOUBLE not supported? 36 # else 37 # error SIZEOF_F77_REAL == SIZEOF_??? 38 # endif 39 break; 40 case MT_F_DBL: 41 # if SIZEOF_F77_DOUBLE_PRECISION == SIZEOF_DOUBLE 42 ctype = C_DBL; 43 # elif SIZEOF_F77_DOUBLE_PRECISION == SIZEOF_LONG_DOUBLE 44 # error SIZEOF_F77_DOUBLE_PRECISION == SIZEOF_LONG_DOUBLE not supported? 45 # else 46 # error SIZEOF_F77_DOUBLE_PRECISION == SIZEOF_??? 47 # endif 48 break; 49 case MT_F_DCPL: 50 ctype = C_DCPL; 51 break; 52 case MT_F_SCPL: 53 # if SIZEOF_F77_REAL == SIZEOF_FLOAT 54 ctype = C_SCPL; 55 # elif SIZEOF_F77_REAL == SIZEOF_DOUBLE 56 ctype = C_DCPL; 57 # elif SIZEOF_F77_REAL == SIZEOF_LONG_DOUBLE 58 # error SIZEOF_F77_REAL == SIZEOF_LONG_DOUBLE not supported? 59 # else 60 # error SIZEOF_F77_REAL == SIZEOF_??? 61 # endif 62 break; 63 default: ctype = type; 64 break; 65 } 66 67 return(ctype); 68 } 69 70 pnga_type_c2f(Integer type)71Integer pnga_type_c2f(Integer type) 72 { 73 Integer ftype; 74 switch(type){ 75 case C_INT: 76 ftype = (sizeof(int) != sizeof(Integer))? -1: MT_F_INT; 77 break; 78 case C_LONG: 79 ftype = (sizeof(long) != sizeof(Integer))? -1: MT_F_INT; 80 break; 81 case C_LONGLONG: 82 ftype = (sizeof(long long) != sizeof(Integer))? -1: MT_F_INT; 83 break; 84 case C_FLOAT: 85 # if SIZEOF_FLOAT == SIZEOF_F77_REAL 86 ftype = MT_F_REAL; 87 # elif SIZEOF_FLOAT == SIZEOF_F77_DOUBLE_PRECISION 88 ftype = MT_F_DBL; 89 # else 90 ftype = -1; 91 # endif 92 break; 93 case C_DBL: 94 ftype = MT_F_DBL; 95 break; 96 case C_DCPL: 97 ftype = MT_F_DCPL; 98 break; 99 case C_SCPL: 100 # if SIZEOF_FLOAT == SIZEOF_F77_REAL 101 ftype = MT_F_SCPL; 102 # elif SIZEOF_FLOAT == SIZEOF_F77_DOUBLE_PRECISION 103 ftype = MT_F_DCPL; 104 # else 105 ftype = -1; 106 # endif 107 break; 108 default: ftype = type; 109 break; 110 } 111 112 return(ftype); 113 } 114