PageRenderTime 54ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/wrfv2_fire/tools/reg_parse.c

http://github.com/jbeezley/wrf-fire
C | 1039 lines | 890 code | 94 blank | 55 comment | 400 complexity | a8b1d00565f7e2c5145dc1bab3a37952 MD5 | raw file
Possible License(s): AGPL-1.0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #ifdef _WIN32
  5. # define rindex(X,Y) strrchr(X,Y)
  6. # define index(X,Y) strchr(X,Y)
  7. #else
  8. # include <strings.h>
  9. #endif
  10. #include "registry.h"
  11. #include "protos.h"
  12. #include "data.h"
  13. #include "sym.h"
  14. /* read in the Registry file and build the internal representation of the registry */
  15. #define MAXTOKENS 5000 /*changed MAXTOKENS from 1000 to 5000 by Manish Shrivastava on 01/28/2010*/
  16. /* fields for state entries (note, these get converted to field entries in the
  17. reg_parse routine; therefore, only TABLE needs to be looked at */
  18. #define TABLE 0
  19. /* fields for field entries (TABLE="typedef" and, with some munging, TABLE="state") */
  20. #define FIELD_OF 1
  21. #define FIELD_TYPE 2
  22. #define FIELD_SYM 3
  23. #define FIELD_DIMS 4
  24. #define FIELD_USE 5
  25. #define FIELD_NTL 6
  26. #define FIELD_STAG 7
  27. #define FIELD_IO 8
  28. #define FIELD_DNAME 9
  29. #define FIELD_DESCRIP 10
  30. #define FIELD_UNITS 11
  31. #define F_OF 0
  32. #define F_TYPE 1
  33. #define F_SYM 2
  34. #define F_DIMS 3
  35. #define F_USE 4
  36. #define F_NTL 5
  37. #define F_STAG 6
  38. #define F_IO 7
  39. #define F_DNAME 8
  40. #define F_DESCRIP 9
  41. #define F_UNITS 10
  42. /* fields for rconfig entries (RCNF) */
  43. #define RCNF_TYPE_PRE 1
  44. #define RCNF_SYM_PRE 2
  45. #define RCNF_HOWSET_PRE 3
  46. #define RCNF_NENTRIES_PRE 4
  47. #define RCNF_DEFAULT_PRE 5
  48. #define RCNF_IO_PRE 6
  49. #define RCNF_DNAME_PRE 7
  50. #define RCNF_DESCRIP_PRE 8
  51. #define RCNF_UNITS_PRE 9
  52. #define RCNF_TYPE 2
  53. #define RCNF_SYM 3
  54. #define RCNF_USE FIELD_USE
  55. #define RCNF_IO FIELD_IO
  56. #define RCNF_DNAME FIELD_DNAME
  57. #define RCNF_DESCRIP FIELD_DESCRIP
  58. #define RCNF_UNITS FIELD_UNITS
  59. #define RCNF_HOWSET 20
  60. #define RCNF_NENTRIES 21
  61. #define RCNF_DEFAULT 22
  62. /* fields for dimension entries (TABLE="dimspec") */
  63. #define DIM_NAME 1
  64. #define DIM_ORDER 2
  65. #define DIM_SPEC 3
  66. #define DIM_ORIENT 4
  67. #define DIM_DATA_NAME 5
  68. #define PKG_SYM 1
  69. #define PKG_ASSOC 2
  70. #define PKG_STATEVARS 3
  71. #define PKG_4DSCALARS 4
  72. #define COMM_ID 1
  73. #define COMM_USE 2
  74. #define COMM_DEFINE 3
  75. static int ntracers = 0 ;
  76. static char tracers[1000][100] ;
  77. int
  78. pre_parse( char * dir, FILE * infile, FILE * outfile )
  79. {
  80. /* Decreased size for SOA from 8192 to 8000--double check if necessary, Manish Shrivastava 2010 */
  81. char inln[8000], parseline[8000], parseline_save[8000] ;
  82. int found ;
  83. char *p, *q ;
  84. char *tokens[MAXTOKENS], *toktmp[MAXTOKENS], newdims[NAMELEN_LONG], newdims4d[NAMELEN_LONG],newname[NAMELEN_LONG] ;
  85. int i, ii, len_of_tok ;
  86. char x, xstr[NAMELEN_LONG] ;
  87. int is4d, wantstend, wantsbdy ;
  88. int ifdef_stack_ptr = 0 ;
  89. int ifdef_stack[100] ;
  90. int inquote, retval ;
  91. ifdef_stack[0] = 1 ;
  92. retval = 0 ;
  93. parseline[0] = '\0' ;
  94. /* main parse loop over registry lines */
  95. /* Had to increase size for SOA from 4096 to 7000, Manish Shrivastava 2010 */
  96. while ( fgets ( inln , 7000 , infile ) != NULL )
  97. {
  98. /*** preprocessing directives ****/
  99. /* look for an include statement */
  100. for ( p = inln ; ( *p == ' ' || *p == ' ' ) && *p != '\0' ; p++ ) ;
  101. if ( !strncmp( p , "include", 7 ) && ! ( ifdef_stack_ptr >= 0 && ! ifdef_stack[ifdef_stack_ptr] ) ) {
  102. FILE *include_fp ;
  103. char include_file_name[128] ;
  104. p += 7 ; for ( ; ( *p == ' ' || *p == ' ' ) && *p != '\0' ; p++ ) ;
  105. if ( strlen( p ) > 127 ) { fprintf(stderr,"Registry warning: invalid include file name: %s\n", p ) ; }
  106. else {
  107. sprintf( include_file_name , "%s/%s", dir , p ) ;
  108. if ( (p=index(include_file_name,'\n')) != NULL ) *p = '\0' ;
  109. fprintf(stderr,"opening %s\n",include_file_name) ;
  110. if (( include_fp = fopen( include_file_name , "r" )) != NULL ) {
  111. fprintf(stderr,"including %s\n",include_file_name ) ;
  112. pre_parse( dir , include_fp , outfile ) ;
  113. fclose( include_fp ) ;
  114. } else {
  115. fprintf(stderr,"Registry warning: cannot open %s. Ignoring.\n", include_file_name ) ;
  116. }
  117. }
  118. }
  119. else if ( !strncmp( p , "ifdef", 5 ) ) {
  120. char value[32] ;
  121. p += 5 ; for ( ; ( *p == ' ' || *p == ' ' ) && *p != '\0' ; p++ ) ;
  122. strncpy(value, p, 31 ) ; value[31] = '\0' ;
  123. if ( (p=index(value,'\n')) != NULL ) *p = '\0' ;
  124. if ( (p=index(value,' ')) != NULL ) *p = '\0' ; if ( (p=index(value,' ')) != NULL ) *p = '\0' ;
  125. ifdef_stack_ptr++ ;
  126. ifdef_stack[ifdef_stack_ptr] = ( sym_get(value) != NULL && ifdef_stack[ifdef_stack_ptr-1] ) ;
  127. if ( ifdef_stack_ptr >= 100 ) { fprintf(stderr,"Registry fatal: too many nested ifdefs\n") ; exit(1) ; }
  128. continue ;
  129. }
  130. else if ( !strncmp( p , "ifndef", 6 ) ) {
  131. char value[32] ;
  132. p += 6 ; for ( ; ( *p == ' ' || *p == ' ' ) && *p != '\0' ; p++ ) ;
  133. strncpy(value, p, 31 ) ; value[31] = '\0' ;
  134. if ( (p=index(value,'\n')) != NULL ) *p = '\0' ;
  135. if ( (p=index(value,' ')) != NULL ) *p = '\0' ; if ( (p=index(value,' ')) != NULL ) *p = '\0' ;
  136. ifdef_stack_ptr++ ;
  137. ifdef_stack[ifdef_stack_ptr] = ( sym_get(value) == NULL && ifdef_stack[ifdef_stack_ptr-1] ) ;
  138. if ( ifdef_stack_ptr >= 100 ) { fprintf(stderr,"Registry fatal: too many nested ifdefs\n") ; exit(1) ; }
  139. continue ;
  140. }
  141. else if ( !strncmp( p , "endif", 5 ) ) {
  142. ifdef_stack_ptr-- ;
  143. if ( ifdef_stack_ptr < 0 ) { fprintf(stderr,"Registry fatal: unmatched endif\n") ; exit(1) ; }
  144. continue ;
  145. }
  146. else if ( !strncmp( p , "define", 6 ) ) {
  147. char value[32] ;
  148. p += 6 ; for ( ; ( *p == ' ' || *p == ' ' ) && *p != '\0' ; p++ ) ;
  149. strncpy(value, p, 31 ) ; value[31] = '\0' ;
  150. if ( (p=index(value,'\n')) != NULL ) *p = '\0' ;
  151. if ( (p=index(value,' ')) != NULL ) *p = '\0' ; if ( (p=index(value,' ')) != NULL ) *p = '\0' ;
  152. sym_add( value ) ;
  153. continue ;
  154. }
  155. if ( ifdef_stack_ptr >= 0 && ! ifdef_stack[ifdef_stack_ptr] ) continue ;
  156. /*** end of preprocessing directives ****/
  157. strcat( parseline , inln ) ;
  158. /* allow \ to continue the end of a line */
  159. if (( p = index( parseline, '\\' )) != NULL )
  160. {
  161. if ( *(p+1) == '\n' || *(p+1) == '\0' )
  162. {
  163. *p = '\0' ;
  164. continue ; /* go get another line */
  165. }
  166. }
  167. make_lower( parseline ) ;
  168. if (( p = index( parseline , '\n' )) != NULL ) *p = '\0' ; /* discard newlines */
  169. /* check line and zap any # characters that are in double quotes */
  170. for ( p = parseline, inquote = 0 ; *p ; p++ ) {
  171. if ( *p == '"' && inquote ) inquote = 0 ;
  172. else if ( *p == '"' && !inquote ) inquote = 1 ;
  173. else if ( *p == '#' && inquote ) *p = ' ' ;
  174. else if ( *p == '#' && !inquote ) { *p = '\0' ; break ; }
  175. }
  176. if ( inquote ) { retval=1 ; fprintf(stderr,"Registry error: unbalanced quotes in line:\n%s\n",parseline) ;}
  177. for ( i = 0 ; i < MAXTOKENS ; i++ ) tokens[i] = NULL ;
  178. i = 0 ;
  179. strcpy( parseline_save, parseline ) ;
  180. if ((tokens[i] = my_strtok(parseline)) != NULL ) i++ ;
  181. while (( tokens[i] = my_strtok(NULL) ) != NULL && i < MAXTOKENS ) i++ ;
  182. if ( i <= 0 ) continue ;
  183. for ( i = 0 ; i < MAXTOKENS ; i++ )
  184. {
  185. if ( tokens[i] == NULL ) tokens[i] = "-" ;
  186. }
  187. /* remove quotes from quoted entries */
  188. for ( i = 0 ; i < MAXTOKENS ; i++ )
  189. {
  190. char * pp ;
  191. if ( tokens[i][0] == '"' ) tokens[i]++ ;
  192. if ((pp=rindex( tokens[i], '"' )) != NULL ) *pp = '\0' ;
  193. }
  194. if ( !strcmp( tokens[ TABLE ] , "state" ) )
  195. {
  196. int inbrace = 0 ;
  197. strcpy( newdims, "" ) ;
  198. strcpy( newdims4d, "" ) ;
  199. is4d = 0 ; wantstend = 0 ; wantsbdy = 0 ;
  200. for ( i = 0 ; i < (len_of_tok = strlen(tokens[F_DIMS])) ; i++ )
  201. {
  202. x = tolower(tokens[F_DIMS][i]) ;
  203. if ( x == '{' ) { inbrace = 1 ; }
  204. if ( x == '}' ) { inbrace = 0 ; }
  205. if ( x >= 'a' && x <= 'z' && !inbrace ) {
  206. if ( x == 'f' ) { is4d = 1 ; }
  207. if ( x == 't' ) { wantstend = 1 ; }
  208. if ( x == 'b' ) { wantsbdy = 1 ; }
  209. }
  210. sprintf(xstr,"%c",x) ;
  211. if ( x != 'b' || inbrace ) strcat ( newdims , xstr ) ;
  212. if ( x != 'f' && x != 't' || inbrace ) strcat( newdims4d , xstr ) ;
  213. }
  214. if ( wantsbdy ) {
  215. /* first re-gurg the original entry without the b in the dims */
  216. fprintf( outfile,"state %s %s %s %s %s %s %s \"%s\" \"%s\" \"%s\"\n",tokens[F_TYPE],tokens[F_SYM], newdims,
  217. tokens[F_USE],tokens[F_NTL],tokens[F_STAG],tokens[F_IO],
  218. tokens[F_DNAME],tokens[F_DESCRIP],tokens[F_UNITS] ) ;
  219. if ( strcmp( tokens[F_SYM] , "-" ) ) { /* if not unnamed, as can happen with first 4d tracer */
  220. /* next, output some additional entries for the boundary arrays for these guys */
  221. if ( is4d == 1 ) {
  222. for ( i = 0, found = 0 ; i < ntracers ; i++ ) {
  223. if ( !strcmp( tokens[F_USE] , tracers[i] ) ) found = 1 ;
  224. }
  225. if ( found == 0 ) {
  226. sprintf(tracers[ntracers],tokens[F_USE]) ;
  227. ntracers++ ;
  228. /* add entries for _b and _bt arrays */
  229. sprintf(newname,"%s_b",tokens[F_USE]) ;
  230. fprintf( outfile,"state %s %s %s %s %s %s %s \"%s\" \"bdy %s\" \"%s\"\n",tokens[F_TYPE],newname,newdims4d,
  231. "_4d_bdy_array_","-",tokens[F_STAG],"b",
  232. newname,tokens[F_DESCRIP],tokens[F_UNITS] ) ;
  233. sprintf(newname,"%s_bt",tokens[F_USE]) ;
  234. fprintf( outfile,"state %s %s %s %s %s %s %s \"%s\" \"bdy tend %s\" \"(%s)/dt\"\n",tokens[F_TYPE],newname,newdims4d,
  235. "_4d_bdy_array_","-",tokens[F_STAG],"b",
  236. newname,tokens[F_DESCRIP],tokens[F_UNITS] ) ;
  237. }
  238. } else {
  239. /* add entries for _b and _bt arrays */
  240. sprintf(newname,"%s_b",tokens[F_SYM]) ;
  241. fprintf( outfile,"state %s %s %s %s %s %s %s \"%s\" \"bdy %s\" \"%s\"\n",tokens[F_TYPE],newname,tokens[F_DIMS],
  242. tokens[F_USE],"-",tokens[F_STAG],"b",
  243. newname,tokens[F_DESCRIP],tokens[F_UNITS] ) ;
  244. sprintf(newname,"%s_bt",tokens[F_SYM]) ;
  245. fprintf( outfile,"state %s %s %s %s %s %s %s \"%s\" \"bdy tend %s\" \"(%s)/dt\"\n",tokens[F_TYPE],newname,tokens[F_DIMS],
  246. tokens[F_USE],"-",tokens[F_STAG],"b",
  247. newname,tokens[F_DESCRIP],tokens[F_UNITS] ) ;
  248. }
  249. }
  250. parseline[0] = '\0' ; /* reset parseline */
  251. continue ;
  252. }
  253. }
  254. normal:
  255. /* otherwise output the line as is */
  256. fprintf(outfile,"%s\n",parseline_save) ;
  257. parseline[0] = '\0' ; /* reset parseline */
  258. }
  259. return(retval) ;
  260. }
  261. int
  262. reg_parse( FILE * infile )
  263. {
  264. /* Had to increase size for SOA from 4096 to 7000, Manish Shrivastava 2010 */
  265. char inln[7000], parseline[7000] ;
  266. char *p, *q ;
  267. char *tokens[MAXTOKENS], *toktmp[MAXTOKENS] ;
  268. int i, ii ;
  269. int defining_state_field, defining_rconfig_field, defining_i1_field ;
  270. parseline[0] = '\0' ;
  271. max_time_level = 1 ;
  272. /* main parse loop over registry lines */
  273. /* Had to increase size for SOA from 4096 to 7000, Manish Shrivastava 2010 */
  274. while ( fgets ( inln , 7000 , infile ) != NULL )
  275. {
  276. strcat( parseline , inln ) ;
  277. /* allow \ to continue the end of a line */
  278. if (( p = index( parseline, '\\' )) != NULL )
  279. {
  280. if ( *(p+1) == '\n' || *(p+1) == '\0' )
  281. {
  282. *p = '\0' ;
  283. continue ; /* go get another line */
  284. }
  285. }
  286. make_lower( parseline ) ;
  287. if (( p = index( parseline , '#' )) != NULL ) *p = '\0' ; /* discard comments (dont worry about quotes for now) */
  288. if (( p = index( parseline , '\n' )) != NULL ) *p = '\0' ; /* discard newlines */
  289. for ( i = 0 ; i < MAXTOKENS ; i++ ) tokens[i] = NULL ;
  290. i = 0 ;
  291. if ((tokens[i] = my_strtok(parseline)) != NULL ) i++ ;
  292. while (( tokens[i] = my_strtok(NULL) ) != NULL && i < MAXTOKENS ) i++ ;
  293. if ( i <= 0 ) continue ;
  294. for ( i = 0 ; i < MAXTOKENS ; i++ )
  295. {
  296. if ( tokens[i] == NULL ) tokens[i] = "-" ;
  297. }
  298. /* remove quotes from quoted entries */
  299. for ( i = 0 ; i < MAXTOKENS ; i++ )
  300. {
  301. char * pp ;
  302. if ( tokens[i][0] == '"' ) tokens[i]++ ;
  303. if ((pp=rindex( tokens[i], '"' )) != NULL ) *pp = '\0' ;
  304. }
  305. defining_state_field = 0 ;
  306. defining_rconfig_field = 0 ;
  307. defining_i1_field = 0 ;
  308. /* state entry */
  309. if ( !strcmp( tokens[ TABLE ] , "state" ) )
  310. {
  311. /* turn a state entry into a typedef to define a field in the top-level built-in type domain */
  312. tokens[TABLE] = "typedef" ;
  313. for ( i = MAXTOKENS-1 ; i >= 2 ; i-- ) tokens[i] = tokens[i-1] ; /* shift the fields to the left */
  314. tokens[FIELD_OF] = "domain" ;
  315. if ( !strcmp( tokens[FIELD_TYPE], "double" ) ) tokens[FIELD_TYPE] = "doubleprecision" ;
  316. defining_state_field = 1 ;
  317. }
  318. if ( !strcmp( tokens[ TABLE ] , "rconfig" ) )
  319. {
  320. char *pp, value[256] ;
  321. for ( pp = tokens[RCNF_SYM_PRE] ; (*pp == ' ' || *pp == ' ') && *pp ; pp++ ) ;
  322. sprintf(value, "RCONFIG_%s" ,pp) ;
  323. if ( sym_get(value) == NULL ) {
  324. sym_add(value) ;
  325. } else {
  326. parseline[0] = '\0' ; /* reset parseline */
  327. continue ;
  328. }
  329. /* turn a rconfig entry into a typedef to define a field in the top-level built-in type domain */
  330. for ( i = 0 ; i < MAXTOKENS ; i++ ) { toktmp[i] = tokens[i] ; tokens[i] = "-" ; }
  331. tokens[TABLE] = "typedef" ;
  332. tokens[FIELD_OF] = "domain" ;
  333. tokens[RCNF_TYPE] = toktmp[RCNF_TYPE_PRE] ;
  334. if ( !strcmp( tokens[RCNF_TYPE], "double" ) ) tokens[RCNF_TYPE] = "doubleprecision" ;
  335. tokens[RCNF_SYM] = toktmp[RCNF_SYM_PRE] ;
  336. tokens[RCNF_IO] = toktmp[RCNF_IO_PRE] ;
  337. tokens[RCNF_DNAME] = toktmp[RCNF_DNAME_PRE] ;
  338. tokens[RCNF_USE] = "-" ;
  339. tokens[RCNF_DESCRIP] = toktmp[RCNF_DESCRIP_PRE] ;
  340. tokens[RCNF_UNITS] = toktmp[RCNF_UNITS_PRE] ;
  341. tokens[RCNF_HOWSET] = toktmp[RCNF_HOWSET_PRE] ;
  342. tokens[RCNF_NENTRIES] = toktmp[RCNF_NENTRIES_PRE] ;
  343. tokens[RCNF_DEFAULT] = toktmp[RCNF_DEFAULT_PRE] ;
  344. defining_rconfig_field = 1 ;
  345. }
  346. if ( !strcmp( tokens[ TABLE ] , "i1" ) )
  347. {
  348. /* turn a state entry into a typedef to define a field in
  349. the top-level built-in type domain */
  350. tokens[TABLE] = "typedef" ;
  351. /* shift the fields to the left */
  352. for ( i = MAXTOKENS-1 ; i >= 2 ; i-- ) tokens[i] = tokens[i-1] ;
  353. tokens[FIELD_OF] = "domain" ;
  354. if ( !strcmp( tokens[FIELD_TYPE], "double" ) ) tokens[FIELD_TYPE] = "doubleprecision" ;
  355. defining_i1_field = 1 ;
  356. }
  357. /* NOTE: fall through */
  358. /* typedef entry */
  359. if ( !strcmp( tokens[ TABLE ] , "typedef" ) )
  360. {
  361. node_t * field_struct ;
  362. node_t * type_struct ;
  363. if ( !defining_state_field && ! defining_i1_field &&
  364. !defining_rconfig_field && !strcmp(tokens[FIELD_OF],"domain") )
  365. { fprintf(stderr,"Registry warning: 'domain' is a reserved registry type name. Cannot 'typedef domain'\n") ; }
  366. type_struct = get_type_entry( tokens[ FIELD_OF ] ) ;
  367. if ( type_struct == NULL )
  368. {
  369. type_struct = new_node( TYPE ) ;
  370. strcpy( type_struct->name, tokens[FIELD_OF] ) ;
  371. type_struct->type_type = DERIVED ;
  372. add_node_to_end( type_struct , &Type ) ;
  373. }
  374. if ( defining_i1_field ) {
  375. field_struct = new_node( I1 ) ;
  376. } else if ( defining_rconfig_field ) {
  377. field_struct = new_node( RCONFIG ) ;
  378. } else {
  379. field_struct = new_node( FIELD ) ;
  380. }
  381. strcpy( field_struct->name, tokens[FIELD_SYM] ) ;
  382. if ( set_state_type( tokens[FIELD_TYPE], field_struct ) )
  383. { fprintf(stderr,"Registry warning: type %s used before defined \n",tokens[FIELD_TYPE] ) ; }
  384. if ( set_state_dims( tokens[FIELD_DIMS], field_struct ) )
  385. { fprintf(stderr,"Registry warning: some problem with dimstring %s\n", tokens[FIELD_DIMS] ) ; }
  386. if ( strcmp( tokens[FIELD_NTL], "-" ) ) /* that is, if not equal "-" */
  387. { field_struct->ntl = atoi(tokens[FIELD_NTL]) ; }
  388. field_struct->ntl = ( field_struct->ntl > 0 )?field_struct->ntl:1 ;
  389. /* calculate the maximum number of time levels and store in global variable */
  390. if ( field_struct->ntl > max_time_level && field_struct->ntl <= 3 ) max_time_level = field_struct->ntl ;
  391. field_struct->stag_x = 0 ; field_struct->stag_y = 0 ; field_struct->stag_z = 0 ;
  392. for ( i = 0 ; i < strlen(tokens[FIELD_STAG]) ; i++ )
  393. {
  394. if ( tolower(tokens[FIELD_STAG][i]) == 'x' || sw_all_x_staggered ) field_struct->stag_x = 1 ;
  395. if ( tolower(tokens[FIELD_STAG][i]) == 'y' || sw_all_y_staggered ) field_struct->stag_y = 1 ;
  396. if ( tolower(tokens[FIELD_STAG][i]) == 'z' ) field_struct->stag_z = 1 ;
  397. }
  398. field_struct->restart = 0 ; field_struct->boundary = 0 ;
  399. for ( i = 0 ; i < MAX_STREAMS ; i++ ) {
  400. reset_mask( field_struct->io_mask, i ) ;
  401. }
  402. {
  403. char prev = '\0' ;
  404. char x ;
  405. char tmp[NAMELEN], tmp1[NAMELEN], tmp2[NAMELEN] ;
  406. int len_of_tok ;
  407. char fcn_name[2048], aux_fields[2048] ;
  408. strcpy(tmp,tokens[FIELD_IO]) ;
  409. if (( p = index(tmp,'=') ) != NULL ) { *p = '\0' ; }
  410. for ( i = 0 ; i < strlen(tmp) ; i++ )
  411. {
  412. x = tolower(tmp[i]) ;
  413. if ( x == 'h' || x == 'i' ) {
  414. char c, *p, *pp ;
  415. int unitid ;
  416. int stream ;
  417. unsigned int * mask ;
  418. stream = ( x == 'h' )?HISTORY_STREAM:INPUT_STREAM ;
  419. mask = field_struct->io_mask ;
  420. set_mask( mask , stream ) ;
  421. strcpy(tmp1, &(tmp[++i])) ;
  422. for ( p = tmp1 ; *p ; i++, p++ ) {
  423. c = tolower(*p) ; if ( c >= 'a' && c <= 'z' ) { *p = '\0' ; i-- ; break ; }
  424. reset_mask( mask , stream ) ;
  425. }
  426. for ( p = tmp1 ; *p ; p++ ) {
  427. x = *p ;
  428. if ( x >= '0' && x <= '9' ) {
  429. set_mask( mask , stream + x - '0' ) ;
  430. }
  431. else if ( x == '{' ) {
  432. strcpy(tmp2,p+1) ;
  433. if (( pp = index(tmp2,'}') ) != NULL ) {
  434. *pp = '\0' ;
  435. unitid = atoi(tmp2) ; /* JM 20100416 */
  436. if ( unitid >= 0 || unitid < MAX_STREAMS && stream + unitid < MAX_HISTORY ) {
  437. set_mask( mask , stream + unitid ) ;
  438. }
  439. p = p + strlen(tmp2) + 1 ;
  440. } else {
  441. fprintf(stderr,"registry syntax error: unmatched {} in the io string for definition of %s\n",tokens[FIELD_SYM]) ;
  442. exit(9) ;
  443. }
  444. }
  445. }
  446. }
  447. }
  448. for ( i = 0 ; i < (len_of_tok = strlen(tokens[FIELD_IO])) ; i++ )
  449. {
  450. int unitid = -1 ;
  451. x = tolower(tokens[FIELD_IO][i]) ;
  452. if ( x == '{' ) {
  453. int ii,iii ;
  454. char * pp ;
  455. char tmp[NAMELEN] ;
  456. strcpy(tmp,tokens[FIELD_IO]) ;
  457. if (( pp = index(tmp,'}') ) != NULL ) {
  458. *pp = '\0' ;
  459. iii = pp - (tmp + i + 1) ;
  460. unitid = atoi(tmp+i+1) ; /* JM 20091102 */
  461. if ( unitid >= 0 || unitid < MAX_STREAMS && unitid < MAX_HISTORY ) {
  462. if ( prev == 'i' ) {
  463. set_mask( field_struct->io_mask , unitid + MAX_HISTORY ) ;
  464. } else if ( prev == 'h' ) {
  465. set_mask( field_struct->io_mask , unitid ) ;
  466. }
  467. }
  468. /* avoid infinite loop. iii can go negative if the '}' is at the end of the line. */
  469. if ( iii > 0 ) i += iii ;
  470. continue ;
  471. } else {
  472. fprintf(stderr,"registry syntax error: unmatched {} in the io string for definition of %s\n",tokens[FIELD_SYM]) ;
  473. exit(9) ;
  474. }
  475. } else if ( x >= 'a' && x <= 'z' ) {
  476. if ( x == 'r' ) { field_struct->restart = 1 ; set_mask( field_struct->io_mask , RESTART_STREAM ) ; }
  477. if ( x == 'b' ) { field_struct->boundary = 1 ; set_mask( field_struct->io_mask , BOUNDARY_STREAM ) ; }
  478. if ( x == 'f' || x == 'd' || x == 'u' || x == 's' ) {
  479. strcpy(aux_fields,"") ;
  480. strcpy(fcn_name,"") ;
  481. if ( tokens[FIELD_IO][i+1] == '(' ) /* catch a possible error */
  482. {
  483. fprintf(stderr,
  484. "Registry warning: syntax error in %c specifier of IO field for %s\n",x,tokens[FIELD_SYM]) ;
  485. fprintf(stderr,
  486. " equal sign needed before left paren\n") ;
  487. }
  488. if ( tokens[FIELD_IO][i+1] == '=' )
  489. {
  490. int ii, jj, state ;
  491. state = 0 ;
  492. jj = 0 ;
  493. for ( ii = i+3 ; ii < len_of_tok ; ii++ )
  494. {
  495. if ( tokens[FIELD_IO][ii] == ')' ) { if (state == 0 )fcn_name[jj] = '\0' ; aux_fields[jj] = '\0' ; break ; }
  496. if ( tokens[FIELD_IO][ii] == ':' ) { fcn_name[jj] = '\0' ; jj= 0 ; state++ ; continue ;}
  497. if ( tokens[FIELD_IO][ii] == ',' && state == 0 ) {
  498. fprintf(stderr,
  499. "Registry warning: syntax error in %c specifier of IO field for %s\n",x,
  500. tokens[FIELD_SYM]) ;
  501. }
  502. if ( state == 0 ) /* looking for interpolation fcn name */
  503. {
  504. fcn_name[jj++] = tokens[FIELD_IO][ii] ;
  505. }
  506. if ( state > 0 )
  507. {
  508. aux_fields[jj++] = tokens[FIELD_IO][ii] ;
  509. }
  510. }
  511. i = ii ;
  512. }
  513. else
  514. {
  515. if ( x == 'f' || x == 'd' ) strcpy(fcn_name,"interp_fcn") ;
  516. if ( x == 'u' ) strcpy(fcn_name,"copy_fcn") ;
  517. if ( x == 's' ) strcpy(fcn_name,"smoother") ;
  518. }
  519. if ( x == 'f' ) {
  520. field_struct->nest_mask |= FORCE_DOWN ;
  521. strcpy(field_struct->force_fcn_name, fcn_name ) ;
  522. strcpy(field_struct->force_aux_fields, aux_fields ) ;
  523. }
  524. else if ( x == 'd' ) {
  525. field_struct->nest_mask |= INTERP_DOWN ;
  526. strcpy(field_struct->interpd_fcn_name, fcn_name ) ;
  527. strcpy(field_struct->interpd_aux_fields, aux_fields ) ;
  528. }
  529. else if ( x == 's' ) {
  530. field_struct->nest_mask |= SMOOTH_UP ;
  531. strcpy(field_struct->smoothu_fcn_name, fcn_name ) ;
  532. strcpy(field_struct->smoothu_aux_fields, aux_fields ) ;
  533. }
  534. else if ( x == 'u' ) {
  535. field_struct->nest_mask |= INTERP_UP ;
  536. strcpy(field_struct->interpu_fcn_name, fcn_name ) ;
  537. strcpy(field_struct->interpu_aux_fields, aux_fields ) ;
  538. }
  539. }
  540. prev = x ;
  541. }
  542. }
  543. }
  544. field_struct->dname[0] = '\0' ;
  545. if ( strcmp( tokens[FIELD_DNAME], "-" ) ) /* that is, if not equal "-" */
  546. { strcpy( field_struct->dname , tokens[FIELD_DNAME] ) ; }
  547. strcpy(field_struct->descrip,"-") ;
  548. if ( strcmp( tokens[FIELD_DESCRIP], "-" ) ) /* that is, if not equal "-" */
  549. { strcpy( field_struct->descrip , tokens[FIELD_DESCRIP] ) ; }
  550. strcpy(field_struct->units,"-") ;
  551. if ( strcmp( tokens[FIELD_UNITS], "-" ) ) /* that is, if not equal "-" */
  552. { strcpy( field_struct->units , tokens[FIELD_UNITS] ) ; }
  553. strcpy(field_struct->use,"-") ;
  554. if ( strcmp( tokens[FIELD_USE], "-" ) ) /* that is, if not equal "-" */
  555. { strcpy( field_struct->use , tokens[FIELD_USE] ) ;
  556. }
  557. /* specific settings for RCONFIG entries */
  558. if ( defining_rconfig_field )
  559. {
  560. if ( strcmp( tokens[RCNF_NENTRIES] , "-" ) ) /* that is, if not equal "-" */
  561. {
  562. strcpy(field_struct->nentries, tokens[RCNF_NENTRIES] ) ;
  563. } else {
  564. strcpy(field_struct->nentries, "1" ) ;
  565. }
  566. if ( strcmp( tokens[RCNF_HOWSET] , "-" ) ) /* that is, if not equal "-" */
  567. {
  568. strcpy(field_struct->howset,tokens[RCNF_HOWSET]) ;
  569. } else {
  570. strcpy(field_struct->howset,"") ;
  571. }
  572. if ( strcmp( tokens[RCNF_DEFAULT] , "-" ) ) /* that is, if not equal "-" */
  573. {
  574. strcpy(field_struct->dflt,tokens[RCNF_DEFAULT]) ;
  575. } else {
  576. strcpy(field_struct->dflt,"") ;
  577. }
  578. }
  579. if ( field_struct->type != NULL )
  580. if ( field_struct->type->type_type == DERIVED && field_struct->ndims > 0 )
  581. { fprintf(stderr,"Registry warning: type item %s of type %s can not be multi-dimensional ",
  582. tokens[FIELD_SYM], tokens[FIELD_TYPE] ) ; }
  583. /**/ if ( ! field_struct->scalar_array_member )
  584. {
  585. add_node_to_end( field_struct , &(type_struct->fields) ) ;
  586. }
  587. /**/ else /* if ( field_struct->scalar_array_member ) */
  588. {
  589. /*
  590. Here we are constructing a list of nodes to represent the list of 4D scalar arrays in the model
  591. This list is rooted at the FourD pointer.
  592. Each array is represented by its own node; each node has a pointer, members, to the list
  593. of fields that make it up.
  594. */
  595. node_t * q , * member ;
  596. if (( q = get_4d_entry(field_struct->use )) == NULL ) /* first instance of a 4d array member */
  597. {
  598. q = new_node( FOURD ) ;
  599. *q = *field_struct ; /* this overwrites the node */
  600. strcpy( q->name, field_struct->use ) ;
  601. strcpy( q->use, "" ) ;
  602. q->node_kind = FOURD ;
  603. q->scalar_array_member = 0 ;
  604. q->next4d = NULL ;
  605. q->next = NULL ;
  606. /* add 4d q node to the list of fields of this type and also attach
  607. it to the global list of 4d arrays */
  608. add_node_to_end( q , &(type_struct->fields) ) ;
  609. add_node_to_end_4d( q , &(FourD) ) ;
  610. }
  611. member = new_node( MEMBER ) ;
  612. *member = *q ;
  613. member->node_kind = MEMBER ;
  614. member->members = NULL ;
  615. member->scalar_array_member = 1 ;
  616. strcpy( member->name , field_struct->name ) ;
  617. strcpy( member->dname , field_struct->dname ) ;
  618. strcpy( member->use , field_struct->use ) ;
  619. strcpy( member->descrip , field_struct->descrip ) ;
  620. strcpy( member->units , field_struct->units ) ;
  621. member->next = NULL ;
  622. for ( i = 0 ; i < IO_MASK_SIZE ; i++ ) {
  623. member->io_mask[i] = field_struct->io_mask[i] ;
  624. }
  625. member->nest_mask = field_struct->nest_mask ;
  626. member->ndims = field_struct->ndims ;
  627. member->restart = field_struct->restart ;
  628. member->boundary = field_struct->boundary ;
  629. strcpy( member->interpd_fcn_name, field_struct->interpd_fcn_name) ;
  630. strcpy( member->interpd_aux_fields, field_struct->interpd_aux_fields) ;
  631. strcpy( member->interpu_fcn_name, field_struct->interpu_fcn_name) ;
  632. strcpy( member->interpu_aux_fields, field_struct->interpu_aux_fields) ;
  633. strcpy( member->smoothu_fcn_name, field_struct->smoothu_fcn_name) ;
  634. strcpy( member->smoothu_aux_fields, field_struct->smoothu_aux_fields) ;
  635. strcpy( member->force_fcn_name, field_struct->force_fcn_name) ;
  636. strcpy( member->force_aux_fields, field_struct->force_aux_fields) ;
  637. for ( ii = 0 ; ii < member->ndims ; ii++ )
  638. member->dims[ii] = field_struct->dims[ii] ;
  639. add_node_to_end( member , &(q->members) ) ;
  640. free(field_struct) ; /* We've used all the information about this entry.
  641. It is not a field but the name of one of the members of
  642. a 4d field. we have handled that here. Discard the original node. */
  643. }
  644. }
  645. /* dimespec entry */
  646. else if ( !strcmp( tokens[ TABLE ] , "dimspec" ) )
  647. {
  648. node_t * dim_struct ;
  649. dim_struct = new_node( DIM ) ;
  650. if ( get_dim_entry ( tokens[DIM_NAME] ) != NULL )
  651. { fprintf(stderr,"Registry warning: dimspec (%s) already defined\n",tokens[DIM_NAME] ) ; }
  652. strcpy(dim_struct->dim_name,tokens[DIM_NAME]) ;
  653. if ( set_dim_order( tokens[DIM_ORDER], dim_struct ) )
  654. { fprintf(stderr,"Registry warning: problem with dimorder (%s)\n",tokens[DIM_ORDER] ) ; }
  655. if ( set_dim_len( tokens[DIM_SPEC], dim_struct ) )
  656. { fprintf(stderr,"Registry warning: problem with dimspec (%s)\n",tokens[DIM_SPEC] ) ; }
  657. if ( set_dim_orient( tokens[DIM_ORIENT], dim_struct ) )
  658. { fprintf(stderr,"Registry warning: problem with dimorient (%s)\n",tokens[DIM_ORIENT] ) ; }
  659. if ( strcmp( tokens[DIM_DATA_NAME], "-" ) ) /* that is, if not equal "-" */
  660. { strcpy( dim_struct->dim_data_name , tokens[DIM_DATA_NAME] ) ; }
  661. add_node_to_end( dim_struct , &Dim ) ;
  662. }
  663. /* package */
  664. else if ( !strcmp( tokens[ TABLE ] , "package" ) )
  665. {
  666. node_t * package_struct ;
  667. package_struct = new_node( PACKAGE ) ;
  668. strcpy( package_struct->name , tokens[PKG_SYM] ) ;
  669. strcpy( package_struct->pkg_assoc , tokens[PKG_ASSOC] ) ;
  670. strcpy( package_struct->pkg_statevars , tokens[PKG_STATEVARS] ) ;
  671. strcpy( package_struct->pkg_4dscalars , tokens[PKG_4DSCALARS] ) ;
  672. add_node_to_end( package_struct , &Packages ) ;
  673. }
  674. /* halo, period, xpose */
  675. else if ( !strcmp( tokens[ TABLE ] , "halo" ) )
  676. {
  677. node_t * comm_struct ;
  678. comm_struct = new_node( HALO ) ;
  679. strcpy( comm_struct->name , tokens[COMM_ID] ) ;
  680. strcpy( comm_struct->use , tokens[COMM_USE] ) ;
  681. #if 1
  682. for ( i = COMM_DEFINE, q=comm_struct->comm_define ; strcmp(tokens[i],"-") ; i++ ) {
  683. for(p=tokens[i];*p;p++)if(*p!=' '&&*p!='\t'){*q++=*p;}
  684. }
  685. #else
  686. strcpy( comm_struct->comm_define , tokens[COMM_DEFINE] ) ;
  687. #endif
  688. add_node_to_end( comm_struct , &Halos ) ;
  689. }
  690. else if ( !strcmp( tokens[ TABLE ] , "period" ) )
  691. {
  692. node_t * comm_struct ;
  693. comm_struct = new_node( PERIOD ) ;
  694. strcpy( comm_struct->name , tokens[COMM_ID] ) ;
  695. strcpy( comm_struct->use , tokens[COMM_USE] ) ;
  696. #if 1
  697. for ( i = COMM_DEFINE, q=comm_struct->comm_define ; strcmp(tokens[i],"-") ; i++ ) {
  698. for(p=tokens[i];*p;p++)if(*p!=' '&&*p!='\t'){*q++=*p;}
  699. }
  700. #else
  701. strcpy( comm_struct->comm_define , tokens[COMM_DEFINE] ) ;
  702. #endif
  703. add_node_to_end( comm_struct , &Periods ) ;
  704. }
  705. else if ( !strcmp( tokens[ TABLE ] , "xpose" ) )
  706. {
  707. node_t * comm_struct ;
  708. comm_struct = new_node( XPOSE ) ;
  709. strcpy( comm_struct->name , tokens[COMM_ID] ) ;
  710. strcpy( comm_struct->use , tokens[COMM_USE] ) ;
  711. #if 1
  712. for ( i = COMM_DEFINE, q=comm_struct->comm_define ; strcmp(tokens[i],"-") ; i++ ) {
  713. for(p=tokens[i];*p;p++)if(*p!=' '&&*p!='\t'){*q++=*p;}
  714. }
  715. #else
  716. strcpy( comm_struct->comm_define , tokens[COMM_DEFINE] ) ;
  717. #endif
  718. add_node_to_end( comm_struct , &Xposes ) ;
  719. }
  720. else if ( !strcmp( tokens[ TABLE ] , "swap" ) )
  721. {
  722. node_t * comm_struct ;
  723. comm_struct = new_node( SWAP ) ;
  724. strcpy( comm_struct->name , tokens[COMM_ID] ) ;
  725. strcpy( comm_struct->use , tokens[COMM_USE] ) ;
  726. #if 1
  727. for ( i = COMM_DEFINE, q=comm_struct->comm_define ; strcmp(tokens[i],"-") ; i++ ) {
  728. for(p=tokens[i];*p;p++)if(*p!=' '&&*p!='\t'){*q++=*p;}
  729. }
  730. #else
  731. strcpy( comm_struct->comm_define , tokens[COMM_DEFINE] ) ;
  732. #endif
  733. add_node_to_end( comm_struct , &Swaps ) ;
  734. }
  735. else if ( !strcmp( tokens[ TABLE ] , "cycle" ) )
  736. {
  737. node_t * comm_struct ;
  738. comm_struct = new_node( CYCLE ) ;
  739. strcpy( comm_struct->name , tokens[COMM_ID] ) ;
  740. strcpy( comm_struct->use , tokens[COMM_USE] ) ;
  741. #if 1
  742. for ( i = COMM_DEFINE, q=comm_struct->comm_define ; strcmp(tokens[i],"-") ; i++ ) {
  743. for(p=tokens[i];*p;p++)if(*p!=' '&&*p!='\t'){*q++=*p;}
  744. }
  745. #else
  746. strcpy( comm_struct->comm_define , tokens[COMM_DEFINE] ) ;
  747. #endif
  748. add_node_to_end( comm_struct , &Cycles ) ;
  749. }
  750. #if 0
  751. fprintf(stderr,"vvvvvvvvvvvvvvvvvvvvvvvvvvv\n") ;
  752. show_nodelist( Type ) ;
  753. fprintf(stderr,"^^^^^^^^^^^^^^^^^^^^^^^^^^^\n") ;
  754. #endif
  755. parseline[0] = '\0' ; /* reset parseline */
  756. }
  757. Domain = *(get_type_entry( "domain" )) ;
  758. #if 0
  759. show_node( &Domain ) ;
  760. #endif
  761. return(0) ;
  762. }
  763. node_t *
  764. get_dim_entry( char *s )
  765. {
  766. node_t * p ;
  767. for ( p = Dim ; p != NULL ; p = p->next )
  768. {
  769. if ( !strcmp(p->dim_name, s ) ) {
  770. return( p ) ;
  771. }
  772. }
  773. return(NULL) ;
  774. }
  775. int
  776. set_state_type( char * typename, node_t * state_entry )
  777. {
  778. if ( typename == NULL ) return(1) ;
  779. return (( state_entry->type = get_type_entry( typename )) == NULL ) ;
  780. }
  781. int
  782. set_dim_len ( char * dimspec , node_t * dim_entry )
  783. {
  784. if (!strcmp( dimspec , "standard_domain" ))
  785. { dim_entry->len_defined_how = DOMAIN_STANDARD ; }
  786. else if (!strncmp( dimspec, "constant=" , 9 ))
  787. {
  788. char *p, *colon, *paren ;
  789. p = &(dimspec[9]) ;
  790. /* check for colon */
  791. if (( colon = index(p,':')) != NULL )
  792. {
  793. *colon = '\0' ;
  794. if (( paren = index(p,'(')) !=NULL )
  795. {
  796. dim_entry->coord_start = atoi(paren+1) ;
  797. }
  798. else
  799. {
  800. fprintf(stderr,"WARNING: illegal syntax (missing opening paren) for constant: %s\n",p) ;
  801. }
  802. dim_entry->coord_end = atoi(colon+1) ;
  803. }
  804. else
  805. {
  806. dim_entry->coord_start = 1 ;
  807. dim_entry->coord_end = atoi(p) ;
  808. }
  809. dim_entry->len_defined_how = CONSTANT ;
  810. }
  811. else if (!strncmp( dimspec, "namelist=", 9 ))
  812. {
  813. char *p, *colon ;
  814. p = &(dimspec[9]) ;
  815. /* check for colon */
  816. if (( colon = index(p,':')) != NULL )
  817. {
  818. *colon = '\0' ;
  819. strcpy( dim_entry->assoc_nl_var_s, p ) ;
  820. strcpy( dim_entry->assoc_nl_var_e, colon+1 ) ;
  821. }
  822. else
  823. {
  824. strcpy( dim_entry->assoc_nl_var_s, "1" ) ;
  825. strcpy( dim_entry->assoc_nl_var_e, p ) ;
  826. }
  827. dim_entry->len_defined_how = NAMELIST ;
  828. }
  829. else
  830. {
  831. return(1) ;
  832. }
  833. return(0) ;
  834. }
  835. int
  836. set_dim_orient ( char * dimorient , node_t * dim_entry )
  837. {
  838. if (!strcmp( dimorient , "x" ))
  839. { dim_entry->coord_axis = COORD_X ; }
  840. else if (!strcmp( dimorient , "y" ))
  841. { dim_entry->coord_axis = COORD_Y ; }
  842. else if (!strcmp( dimorient , "z" ))
  843. { dim_entry->coord_axis = COORD_Z ; }
  844. else
  845. { dim_entry->coord_axis = COORD_C ; }
  846. return(0) ;
  847. }
  848. /* integrity checking of dimension list; make sure that
  849. namelist specified dimensions have an associated namelist variable */
  850. int
  851. check_dimspecs()
  852. {
  853. node_t * p, *q ;
  854. int ord ;
  855. for ( p = Dim ; p != NULL ; p = p->next )
  856. {
  857. if ( p->len_defined_how == DOMAIN_STANDARD )
  858. {
  859. if ( p->dim_order < 1 || p->dim_order > 3 )
  860. {
  861. fprintf(stderr,"WARNING: illegal dim order %d for dimspec %s\n",p->dim_order,p->name) ;
  862. }
  863. ord = p->dim_order-1 ;
  864. if ( model_order[ord] != p->coord_axis )
  865. {
  866. if ( model_order[ord] == -1 ) model_order[ord] = p->coord_axis ;
  867. else
  868. {
  869. fprintf(stderr,"WARNING: coord-axis/dim-order for dimspec %s is inconsistent with previous dimspec.\n",p->name) ;
  870. }
  871. }
  872. }
  873. else if ( p->len_defined_how == NAMELIST )
  874. {
  875. if ( strcmp( p->assoc_nl_var_s, "1" ) ) /* if not equal to "1" */
  876. {
  877. if (( q = get_entry(p->assoc_nl_var_s,Domain.fields)) == NULL )
  878. {
  879. fprintf(stderr,"WARNING: no namelist variable %s defined for dimension %s\n",
  880. p->assoc_nl_var_s,p->name ) ;
  881. return(1) ;
  882. }
  883. if ( ! q->node_kind & RCONFIG )
  884. {
  885. fprintf(stderr,"WARNING: no namelist variable %s defined for dimension %s\n",
  886. p->assoc_nl_var_s,p->name ) ;
  887. return(1) ;
  888. }
  889. if ( strcmp( q->type->name , "integer" ) ) /* if not integer */
  890. {
  891. fprintf(stderr,"WARNING: namelist variable %s must be an integer if used to define dimension %s\n",
  892. p->assoc_nl_var_s,p->name ) ;
  893. return(1) ;
  894. }
  895. if ( strcmp( q->nentries , "1" ) ) /* if not 1 entry */
  896. {
  897. fprintf(stderr,"WARNING: namelist variable %s must have only one entry if used to define dimension %s\n",
  898. p->assoc_nl_var_s,p->name ) ;
  899. return(1) ;
  900. }
  901. }
  902. if (( q = get_entry(p->assoc_nl_var_e,Domain.fields)) == NULL )
  903. {
  904. fprintf(stderr,"WARNING: no namelist variable %s defined for dimension %s\n",
  905. p->assoc_nl_var_e,p->name ) ;
  906. return(1) ;
  907. }
  908. if ( ! q->node_kind & RCONFIG )
  909. {
  910. fprintf(stderr,"WARNING: no namelist variable %s defined for dimension %s\n",
  911. p->assoc_nl_var_e,p->name ) ;
  912. return(1) ;
  913. }
  914. if ( strcmp( q->type->name , "integer" ) ) /* if not integer */
  915. {
  916. fprintf(stderr,"WARNING: namelist variable %s must be an integer if used to define dimension %s\n",
  917. p->assoc_nl_var_e,p->name ) ;
  918. return(1) ;
  919. }
  920. if ( strcmp( q->nentries , "1" ) ) /* if not 1 entry */
  921. {
  922. fprintf(stderr,"WARNING: namelist variable %s must have only one entry if used to define dimension %s\n",
  923. p->assoc_nl_var_e,p->name ) ;
  924. return(1) ;
  925. }
  926. }
  927. }
  928. return(0) ;
  929. }
  930. int
  931. set_dim_order ( char * dimorder , node_t * dim_entry )
  932. {
  933. dim_entry->dim_order = atoi(dimorder) ;
  934. return(0) ;
  935. }
  936. int
  937. init_parser()
  938. {
  939. model_order[0] = -1 ;
  940. model_order[1] = -1 ;
  941. model_order[2] = -1 ;
  942. return(0) ;
  943. }