5 # define rindex(X,Y) strrchr(X,Y)
6 # define index(X,Y) strchr(X,Y)
9 # include <sys/resource.h>
15 #define DEFINE_GLOBALS
22 main( int argc
, char *argv
[], char *env
[] )
24 char fname_in
[NAMELEN
], dir
[NAMELEN
], fname_tmp
[NAMELEN
], command
[NAMELEN
] ;
25 FILE * fp_in
, *fp_tmp
;
32 mypid
= (int) getpid() ;
33 strcpy( thiscom
, argv
[0] ) ;
37 sw_io_deref_kludge
= 0 ;
38 sw_3dvar_iry_kludge
= 0 ;
39 sw_distrib_io_layer
= 1 ;
40 sw_limit_args
= 0 ; /* usually set -- except for GRAPS */
42 sw_all_x_staggered
= 0 ;
44 sw_all_y_staggered
= 0 ;
45 sw_fort_kludge
= 1 ; /* unconditionally true for v3 */
46 sw_dm_serial_in_only
= 0 ; /* input and bdy data set is distributed by node 0,
47 other data streams are written to file per process */
50 strcpy( fname_in
, "" ) ;
53 rlim
.rlim_cur
= RLIM_INFINITY
;
54 rlim
.rlim_max
= RLIM_INFINITY
;
55 setrlimit ( RLIMIT_STACK
, &rlim
) ;
61 if (*argv
[0] == '-') { /* an option */
62 if (!strncmp(*argv
,"-D",2)) {
68 if (!strcmp(*argv
,"-DDEREF_KLUDGE")) {
71 if (!strcmp(*argv
,"-DIO_DEREF_KLUDGE")) {
72 sw_io_deref_kludge
= 1 ;
74 if (!strcmp(*argv
,"-DLIMIT_ARGS")) {
77 if (!strcmp(*argv
,"-DMOVE_NESTS")) {
80 if (!strcmp(*argv
,"-DMOVE_NL_OUTSIDE_MODULE_CONFIGURE")) {
83 if (!strcmp(*argv
,"-DD3VAR_IRY_KLUDGE")) {
85 sw_3dvar_iry_kludge
= 1 ;
87 fprintf(stderr
,"WARNING: -DD3VAR_IRY_KLUDGE option obsolete (it is now disabled by default). Ignored.\n") ;
90 if (!strcmp(*argv
,"-DALL_X_STAGGERED")) {
91 sw_all_x_staggered
= 1 ;
93 if (!strcmp(*argv
,"-DALL_Y_STAGGERED")) {
94 sw_all_y_staggered
= 1 ;
96 if (!strcmp(*argv
,"-DDM_PARALLEL")) {
99 if (!strcmp(*argv
,"-DNEW_BDYS")) {
102 if (!strcmp(*argv
,"-DNEW_WITH_OLD_BDYS")) {
103 sw_new_with_old_bdys
= 1 ;
105 if (!strcmp(*argv
,"-DDISTRIB_IO_LAYER")) {
107 sw_distrib_io_layer
= 1 ;
109 fprintf(stderr
,"WARNING: -DDISTRIB_IO_LAYER option obsolete (it is now default). Ignored.\n") ;
112 if (!strcmp(*argv
,"-DDM_SERIAL_IN_ONLY")) {
113 sw_dm_serial_in_only
= 1 ;
115 if (!strncmp(*argv
,"-h",2)) {
116 fprintf(stderr
,"Usage: %s [-DDEREF_KLUDGE] [-DDM_PARALLEL] [-DDISTRIB_IO_LAYER] [-DDM_SERIAL_IN_ONLY] [-DD3VAR_IRY_KLUDGE] registryfile\n",thisprog
) ;
120 else /* consider it an input file */
122 strcpy( fname_in
, *argv
) ;
127 gen_io_boilerplate() ; /* 20091213 jm. Generate the io_boilerplate_temporary.inc file */
133 if ( !strcmp(fname_in
,"") ) fp_in
= stdin
;
135 if (( fp_in
= fopen( fname_in
, "r" )) == NULL
)
137 fprintf(stderr
,"Registry program cannot open %s for reading. Ending.\n", fname_in
) ;
141 sprintf( fname_tmp
, "Registry_tmp.%d",mypid
) ;
142 if (( fp_tmp
= fopen( fname_tmp
, "w" )) == NULL
)
144 fprintf(stderr
,"Registry program cannot open temporary %s for writing. Ending.\n", fname_tmp
) ;
149 strcpy( dir
, fname_in
) ;
150 if ( ( e
= rindex ( dir
, '/' ) ) != NULL
) { *e
= '\0' ; } else { strcpy( dir
, "." ) ; }
152 if ( pre_parse( dir
, fp_in
, fp_tmp
) ) {
153 fprintf(stderr
,"Problem with Registry File %s\n", fname_in
) ;
161 if (( fp_tmp
= fopen( fname_tmp
, "r" )) == NULL
)
163 fprintf(stderr
,"Registry program cannot open %s for reading. Ending.\n", fname_tmp
) ;
174 gen_state_struct( "inc" ) ;
175 gen_state_subtypes( "inc" ) ;
177 /* gen_alloc_count( "inc" ) ; */
178 gen_dealloc( "inc" ) ;
179 gen_scalar_indices( "inc" ) ;
180 gen_module_state_description( "frame" ) ;
181 gen_actual_args( "inc" ) ;
182 gen_actual_args_new( "inc" ) ;
183 gen_dummy_args( "inc" ) ;
184 gen_dummy_args_new( "inc" ) ;
185 gen_dummy_decls( "inc" ) ;
186 gen_dummy_decls_new( "inc" ) ;
187 gen_i1_decls( "inc" ) ;
188 gen_namelist_statements("inc") ;
189 gen_namelist_defines ( "inc", 0 ) ; /* without dimension statements */
190 gen_namelist_defines ( "inc", 1 ) ; /* with dimension statements */
191 gen_namelist_defaults ( "inc" ) ;
192 gen_namelist_script ( "inc" ) ;
193 gen_get_nl_config( "inc" ) ;
194 gen_config_assigns( "inc" ) ;
195 gen_config_reads( "inc" ) ;
196 gen_wrf_io( "inc" ) ;
197 gen_model_data_ord( "inc" ) ;
198 gen_nest_interp( "inc" ) ;
199 gen_scalar_derefs( "inc" ) ;
202 /* this has to happen after gen_nest_interp, which adds halos to the AST */
203 gen_comms( "inc" ) ; /* this is either package supplied (by copying a */
204 /* gen_comms.c file into this directory) or a */
209 sprintf(command
,"del /F /Q %s\n",fname_tmp
);
211 sprintf(command
,"/bin/rm -f %s\n",fname_tmp
);