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
00038
00039
00040
00041
00042 #pragma ident "@(#) libf/fort/bounds_chk.c 92.1 06/24/99 10:18:36"
00043 #include <fortran.h>
00044 #include <liberrno.h>
00045 #include <stddef.h>
00046 #if defined(__mips) || defined(_LITTLE_ENDIAN)
00047 #include <stdlib.h>
00048 #endif
00049 #include "fio.h"
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 void
00068 _BOUNDS_ERROR(
00069 char *file,
00070 int *line,
00071 char *variable,
00072 int *dim,
00073 int *lowerbnd,
00074 int *upperbnd,
00075 int sub[1],
00076 int *count)
00077 {
00078 int *retcnt;
00079 int intcnt = 0;
00080 #ifdef _UNICOS
00081
00082 if (_numargs() < 8)
00083 retcnt = &intcnt;
00084 else
00085 #endif
00086 retcnt = count;
00087 if ((*retcnt)++ == 0) {
00088 (void) _fwarn(FWARGSBV, sub[0], *dim, variable, *line,
00089 file, *lowerbnd, *upperbnd);
00090 }
00091 return;
00092 }
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 void
00113 _RBOUNDS_ERROR(
00114 char *file,
00115 int *line,
00116 char *variable,
00117 int *dim,
00118 int *lowerbnd,
00119 int *upperbnd,
00120 int *start,
00121 int *end,
00122 int *incr,
00123 int *count)
00124 {
00125 int *retcnt;
00126 int intcnt = 0;
00127 #ifdef _UNICOS
00128
00129 if (_numargs() < 10)
00130 retcnt = &intcnt;
00131 else
00132 #endif
00133 retcnt = count;
00134 if ((*retcnt)++ == 0) {
00135 (void) _fwarn(FWARGSBR, *start, *end, *incr, *dim,
00136 variable, *line, file, *lowerbnd, *upperbnd);
00137 }
00138 return;
00139 }
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159 void
00160 _VBOUNDS_ERROR(
00161 char *file,
00162 int *line,
00163 char *variable,
00164 int *dim,
00165 int *lowerbnd,
00166 int *upperbnd,
00167 int sub[128],
00168 long vm[2],
00169 int *vl,
00170 int *count)
00171 {
00172 int i, len;
00173 long mask;
00174 int stride;
00175 int first_error_sub;
00176 int last_error_sub;
00177 int constant_stride = 1;
00178 int error_count = 0;
00179 int *retcnt;
00180 int intcnt = 0;
00181 #ifdef _UNICOS
00182
00183 if (_numargs() < 10)
00184 retcnt = &intcnt;
00185 else
00186 #endif
00187 retcnt = count;
00188 if ((*retcnt)++ != 0)
00189 return;
00190 len = *vl;
00191 for ( mask = vm[0], i = 0; i < len; i++, mask <<= 1 ) {
00192 if ( i == 64 ) {
00193 mask = vm[1];
00194 }
00195 if ( mask < 0 ) {
00196 error_count++;
00197 if ( error_count == 1 ) {
00198 first_error_sub = sub[i];
00199 }
00200 else if ( error_count == 2 ) {
00201 stride = sub[i] - last_error_sub;
00202 }
00203 else {
00204 if ( stride != sub[i] - last_error_sub ) {
00205 constant_stride = 0;
00206 break;
00207 }
00208 }
00209 last_error_sub = sub[i];
00210 }
00211 }
00212 if ( error_count == 1 ) {
00213 (void) _fwarn(FWARGSBV, first_error_sub, *dim, variable,
00214 *line, file, *lowerbnd, *upperbnd);
00215 return;
00216 }
00217 else if ( constant_stride ) {
00218 if ( stride == 0 ) {
00219 (void) _fwarn(FWARGSBV, first_error_sub, *dim,
00220 variable, *line, file, *lowerbnd,
00221 *upperbnd);
00222 }
00223 else {
00224 (void) _fwarn(FWARGSBR, first_error_sub,
00225 last_error_sub, stride, *dim,
00226 variable, *line, file, *lowerbnd,
00227 *upperbnd);
00228 }
00229 return;
00230 }
00231 for ( mask = vm[0], i = 0; i < len; i++, mask <<= 1 ) {
00232 if ( i == 64 ) {
00233 mask = vm[1];
00234 }
00235 if ( mask < 0 ) {
00236 (void) _fwarn(FWARGSBV, sub[i], *dim, variable,
00237 *line, file, *lowerbnd, *upperbnd);
00238 }
00239 }
00240 }
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263 void
00264 _VRBOUNDS_ERROR(
00265 char *file,
00266 int *line,
00267 char *variable,
00268 int *dim,
00269 int *lowerbnd,
00270 int *upperbnd,
00271 int start[128],
00272 int end[128],
00273 int incr[128],
00274 long vm[2],
00275 int *vl,
00276 int *count)
00277 {
00278 int i, len;
00279 long mask;
00280 int first_error_start;
00281 int first_error_end;
00282 int first_error_incr;
00283 int all_same = 1;
00284 int first_error = 1;
00285 int *retcnt;
00286 int intcnt = 0;
00287
00288 #ifdef _UNICOS
00289
00290 if (_numargs() < 12)
00291 retcnt = &intcnt;
00292 else
00293 #endif
00294 retcnt = count;
00295 if ((*retcnt)++ != 0)
00296 return;
00297 len = *vl;
00298 for ( mask = vm[0], i = 0; i < len; i++, mask <<= 1 ) {
00299 if ( i == 64 ) {
00300 mask = vm[1];
00301 }
00302 if ( mask < 0 ) {
00303 if ( first_error ) {
00304 first_error = 0;
00305 first_error_start = start[i];
00306 first_error_end = end[i];
00307 first_error_incr = incr[i];
00308 }
00309 else if ( first_error_start != start[i] ||
00310 first_error_end != end[i] ||
00311 first_error_incr != incr[i] ) {
00312 all_same = 0;
00313 break;
00314 }
00315 }
00316 }
00317 if ( all_same ) {
00318 (void) _fwarn(FWARGSBR, first_error_start,
00319 first_error_end, first_error_incr, *dim,
00320 variable, *line, file, *lowerbnd,
00321 *upperbnd);
00322 return;
00323 }
00324 for ( mask = vm[0], i = 0; i < len; i++, mask <<= 1 ) {
00325 if ( i == 64 ) {
00326 mask = vm[1];
00327 }
00328 if ( mask < 0 ) {
00329 (void) _fwarn(FWARGSBR, start[i], end[i], incr[i],
00330 *dim, variable, *line, file,
00331 *lowerbnd, *upperbnd);
00332 }
00333 }
00334 }
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349 void
00350 _SBOUNDS_ERROR(
00351 char *file,
00352 int *line,
00353 char *variable,
00354 int *size,
00355 int *subst,
00356 int *subln,
00357 int *count )
00358 {
00359 int *retcnt;
00360 int intcnt = 0;
00361 int endst;
00362 #ifdef _UNICOS
00363
00364 if (_numargs() < 7)
00365 retcnt = &intcnt;
00366 else
00367 #endif
00368 retcnt = count;
00369
00370
00371 if ( *subln > 0) {
00372 if ((*retcnt)++ == 0) {
00373
00374
00375
00376
00377
00378 endst = *subln + *subst - 1;
00379 (void) _fwarn (FWARGSTR, *subst, endst, variable,
00380 *line, file, *size);
00381 }
00382 }
00383 return;
00384 }
00385
00386 #if defined(__mips) || defined(_LITTLE_ENDIAN)
00387 void
00388 __f90_bounds_check(char *procedure_name, _f_int4 line_number, char *array_name, _f_int4 axis_number)
00389 {
00390 char *unknown_nm = "name_unknown";
00391 char *abort_now = NULL;
00392 char *rtn_nm = "__f90_bounds_check";
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402 abort_now = getenv("F90_BOUNDS_CHECK_ABORT");
00403 if (abort_now) {
00404 if (*abort_now == 'y' || *abort_now == 'Y') {
00405 if (array_name) {
00406 (void) _lerror(_LELVL_MSG, FWARGSVB,
00407 axis_number, array_name, line_number,
00408 procedure_name, rtn_nm);
00409 } else {
00410 (void) _lerror(_LELVL_MSG, FWARGSVB,
00411 axis_number, unknown_nm, line_number,
00412 procedure_name, rtn_nm);
00413 }
00414
00415
00416 _fcleanup();
00417 abort();
00418 }
00419 }
00420 if (array_name)
00421 (void) _fwarn(FWARGSVB,axis_number, array_name,
00422 line_number, procedure_name, rtn_nm);
00423 else
00424 (void) _fwarn(FWARGSVB,axis_number, unknown_nm,
00425 line_number, procedure_name, rtn_nm);
00426 return;
00427 }
00428 #endif