Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #pragma ident "@(#) libfi/element/selrealkind.c 92.1 06/16/99 15:47:23"
00038 #include <fortran.h>
00039 #include <stddef.h>
00040 #include <fmath.h>
00041
00042 static struct {
00043 int kind;
00044 int maxprecision;
00045 int maxexprange;
00046 } values[] = {
00047 { 4, PRECISION_REAL4_F90, RANGE_REAL4_F90 },
00048 { 8, PRECISION_REAL8_F90, RANGE_REAL8_F90 },
00049 #if _F_REAL16 == 1
00050 { 16, PRECISION_REAL16_F90, RANGE_REAL16_F90 },
00051 #endif
00052 };
00053
00054
00055 #define NUMKINDS (signed)(sizeof(values)/sizeof(values[0]))
00056
00057 #define _CODE_SEL() \
00058 if (prec != NULL) \
00059 precval = *prec; \
00060 if (range != NULL) \
00061 exprangval = *range; \
00062 for (i=0; i<NUMKINDS; i++) { \
00063 if (exp_match == 0 && exprangval <= values[i].maxexprange) { \
00064 exp_match = values[i].kind; \
00065 } \
00066 if (prec_match == 0 && precval <= values[i].maxprecision) { \
00067 prec_match = values[i].kind; \
00068 } \
00069 if (exp_match && prec_match) \
00070 break; \
00071 } \
00072 if (exp_match == 0 && prec_match == 0) \
00073 return(-3); \
00074 else if (prec_match == 0) \
00075 return(-1); \
00076 else if (exp_match == 0) \
00077 return(-2); \
00078 return ( (exp_match > prec_match) ? exp_match : prec_match);
00079
00080 #define _CODE_SEL_MIPS() \
00081 if (prec != NULL) \
00082 precval = *prec; \
00083 if (range != NULL) \
00084 exprangval = *range; \
00085 for (i=0; i<NUMKINDS; i++) { \
00086 if (exp_match == 0 && exprangval <= values[i].maxexprange) { \
00087 exp_match = values[i].kind; \
00088 e_indx = i + 1; \
00089 } \
00090 if (prec_match == 0 && precval <= values[i].maxprecision) { \
00091 prec_match = values[i].kind; \
00092 p_indx = i + 1; \
00093 } \
00094 if (exp_match && prec_match) \
00095 break; \
00096 } \
00097 if (exp_match == 0 && prec_match == 0) \
00098 return(-3); \
00099 else if (prec_match == 0) \
00100 return(-1); \
00101 else if (exp_match == 0) \
00102 return(-2); \
00103
00104
00105
00106
00107
00108
00109 \
00110 if (exp_match > prec_match) \
00111 result = e_indx - 1; \
00112 else \
00113 result = p_indx - 1; \
00114 if (values[result].maxexprange < exprangval ) return (-2); \
00115 if (values[result].maxprecision < precval ) return (-1); \
00116 return (values[result].kind);
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 #ifdef _UNICOS
00136
00137 #pragma _CRI duplicate _SELECTED_REAL_KIND_ as _SELECTED_REAL_KIND
00138 #endif
00139
00140 _f_int
00141 _SELECTED_REAL_KIND_ (_f_int *prec,
00142 _f_int *range)
00143 {
00144 #if defined(__mips)
00145 int e_indx = 0;
00146 int p_indx = 0;
00147 int result;
00148 #endif
00149 int i;
00150 int exprangval = 0;
00151 int precval = 0;
00152 int exp_match = 0;
00153 int prec_match = 0;
00154 #if defined(__mips)
00155 _CODE_SEL_MIPS();
00156 #else
00157 _CODE_SEL();
00158 #endif
00159 }
00160
00161 #ifndef _UNICOS
00162
00163 _f_int _SELECTED_REAL_KIND(_f_int *prec, _f_int *range)
00164 {
00165 #if defined(__mips)
00166 int e_indx = 0;
00167 int p_indx = 0;
00168 int result;
00169 #endif
00170 int i;
00171 int exprangval = 0;
00172 int precval = 0;
00173 int exp_match = 0;
00174 int prec_match = 0;
00175 #if defined(__mips)
00176 _CODE_SEL_MIPS();
00177 #else
00178 _CODE_SEL();
00179 #endif
00180 }
00181 #endif
00182
00183 #ifdef _F_INT4
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202 #ifdef _UNICOS
00203
00204 #pragma _CRI duplicate _SELECTED_REAL_KIND_4_ as _SELECTED_REAL_KIND_4
00205 #endif
00206
00207 _f_int4
00208 _SELECTED_REAL_KIND_4_ (_f_int *prec,
00209 _f_int *range)
00210 {
00211 #if defined(__mips)
00212 int e_indx = 0;
00213 int p_indx = 0;
00214 int result;
00215 #endif
00216 int i;
00217 int exprangval = 0;
00218 int precval = 0;
00219 _f_int4 exp_match = 0;
00220 _f_int4 prec_match = 0;
00221 #if defined(__mips)
00222 _CODE_SEL_MIPS();
00223 #else
00224 _CODE_SEL();
00225 #endif
00226 }
00227
00228 #ifndef _UNICOS
00229
00230 _f_int4 _SELECTED_REAL_KIND_4(_f_int *prec, _f_int *range)
00231 {
00232 #if defined(__mips)
00233 int e_indx = 0;
00234 int p_indx = 0;
00235 int result;
00236 #endif
00237 int i;
00238 int exprangval = 0;
00239 int precval = 0;
00240 _f_int4 exp_match = 0;
00241 _f_int4 prec_match = 0;
00242 #if defined(__mips)
00243 _CODE_SEL_MIPS();
00244 #else
00245 _CODE_SEL();
00246 #endif
00247 }
00248 #endif
00249
00250 #endif
00251
00252
00253 #ifdef _F_INT8
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 #ifdef _UNICOS
00273
00274 #pragma _CRI duplicate _SELECTED_REAL_KIND_8_ as _SELECTED_REAL_KIND_8
00275 #endif
00276
00277 _f_int8
00278 _SELECTED_REAL_KIND_8_ (_f_int *prec,
00279 _f_int *range)
00280 {
00281 #if defined(__mips)
00282 int e_indx = 0;
00283 int p_indx = 0;
00284 int result;
00285 #endif
00286 int i;
00287 int exprangval = 0;
00288 int precval = 0;
00289 _f_int8 exp_match = 0;
00290 _f_int8 prec_match = 0;
00291 #if defined(__mips)
00292 _CODE_SEL_MIPS();
00293 #else
00294 _CODE_SEL();
00295 #endif
00296 }
00297
00298 #ifndef _UNICOS
00299
00300 _f_int8 _SELECTED_REAL_KIND_8(_f_int *prec, _f_int *range)
00301 {
00302 #if defined(__mips)
00303 int e_indx = 0;
00304 int p_indx = 0;
00305 int result;
00306 #endif
00307 int i;
00308 int exprangval = 0;
00309 int precval = 0;
00310 _f_int8 exp_match = 0;
00311 _f_int8 prec_match = 0;
00312 #if defined(__mips)
00313 _CODE_SEL_MIPS();
00314 #else
00315 _CODE_SEL();
00316 #endif
00317 }
00318 #endif
00319
00320 #endif