1 | #include <stdio.h> |
---|
2 | #include <stdlib.h> |
---|
3 | #include <sys/time.h> |
---|
4 | #include <sys/resource.h> |
---|
5 | #include <unistd.h> |
---|
6 | #include <string.h> |
---|
7 | #include <strings.h> |
---|
8 | |
---|
9 | #define DEFINE_GLOBALS |
---|
10 | #include "protos.h" |
---|
11 | #include "registry.h" |
---|
12 | #include "data.h" |
---|
13 | #include "sym.h" |
---|
14 | |
---|
15 | main( int argc, char *argv[], char *env[] ) |
---|
16 | { |
---|
17 | char fname_in[NAMELEN], dir[NAMELEN], fname_tmp[NAMELEN], command[NAMELEN] ; |
---|
18 | FILE * fp_in, *fp_tmp ; |
---|
19 | char * thisprog ; |
---|
20 | int mypid ; |
---|
21 | struct rlimit rlim ; |
---|
22 | |
---|
23 | mypid = (int) getpid() ; |
---|
24 | strcpy( thiscom, argv[0] ) ; |
---|
25 | argv++ ; |
---|
26 | |
---|
27 | sw_deref_kludge = 0 ; |
---|
28 | sw_io_deref_kludge = 0 ; |
---|
29 | sw_3dvar_iry_kludge = 0 ; |
---|
30 | sw_distrib_io_layer = 1 ; |
---|
31 | sw_limit_args = 0 ; /* usually set -- except for GRAPS */ |
---|
32 | sw_dm_parallel = 0 ; |
---|
33 | sw_all_x_staggered = 0 ; |
---|
34 | sw_move = 0 ; |
---|
35 | sw_all_y_staggered = 0 ; |
---|
36 | sw_fort_kludge = 1 ; /* unconditionally true for v3 */ |
---|
37 | sw_dm_serial_in_only = 0 ; /* input and bdy data set is distributed by node 0, |
---|
38 | other data streams are written to file per process */ |
---|
39 | sw_new_bdys = 0 ; |
---|
40 | |
---|
41 | strcpy( fname_in , "" ) ; |
---|
42 | |
---|
43 | rlim.rlim_cur = RLIM_INFINITY ; |
---|
44 | rlim.rlim_max = RLIM_INFINITY ; |
---|
45 | |
---|
46 | setrlimit ( RLIMIT_STACK , &rlim ) ; |
---|
47 | |
---|
48 | sym_forget() ; |
---|
49 | thisprog = *argv ; |
---|
50 | while (*argv) { |
---|
51 | if (*argv[0] == '-') { /* an option */ |
---|
52 | if (!strncmp(*argv,"-D",2)) { |
---|
53 | char * p ; |
---|
54 | p = *argv ; |
---|
55 | sym_add(p+2) ; |
---|
56 | } |
---|
57 | |
---|
58 | if (!strcmp(*argv,"-DDEREF_KLUDGE")) { |
---|
59 | sw_deref_kludge = 1 ; |
---|
60 | } |
---|
61 | if (!strcmp(*argv,"-DIO_DEREF_KLUDGE")) { |
---|
62 | sw_io_deref_kludge = 1 ; |
---|
63 | } |
---|
64 | if (!strcmp(*argv,"-DLIMIT_ARGS")) { |
---|
65 | sw_limit_args = 1 ; |
---|
66 | } |
---|
67 | if (!strcmp(*argv,"-DMOVE_NESTS")) { |
---|
68 | sw_move = 1 ; |
---|
69 | } |
---|
70 | if (!strcmp(*argv,"-DMOVE_NL_OUTSIDE_MODULE_CONFIGURE")) { |
---|
71 | sw_fort_kludge = 1 ; |
---|
72 | } |
---|
73 | if (!strcmp(*argv,"-DD3VAR_IRY_KLUDGE")) { |
---|
74 | #if 0 |
---|
75 | sw_3dvar_iry_kludge = 1 ; |
---|
76 | #else |
---|
77 | fprintf(stderr,"WARNING: -DD3VAR_IRY_KLUDGE option obsolete (it is now disabled by default). Ignored.\n") ; |
---|
78 | #endif |
---|
79 | } |
---|
80 | if (!strcmp(*argv,"-DALL_X_STAGGERED")) { |
---|
81 | sw_all_x_staggered = 1 ; |
---|
82 | } |
---|
83 | if (!strcmp(*argv,"-DALL_Y_STAGGERED")) { |
---|
84 | sw_all_y_staggered = 1 ; |
---|
85 | } |
---|
86 | if (!strcmp(*argv,"-DDM_PARALLEL")) { |
---|
87 | sw_dm_parallel = 1 ; |
---|
88 | } |
---|
89 | if (!strcmp(*argv,"-DNEW_BDYS")) { |
---|
90 | sw_new_bdys = 1 ; |
---|
91 | } |
---|
92 | if (!strcmp(*argv,"-DNEW_WITH_OLD_BDYS")) { |
---|
93 | sw_new_with_old_bdys = 1 ; |
---|
94 | } |
---|
95 | if (!strcmp(*argv,"-DDISTRIB_IO_LAYER")) { |
---|
96 | #if 0 |
---|
97 | sw_distrib_io_layer = 1 ; |
---|
98 | #else |
---|
99 | fprintf(stderr,"WARNING: -DDISTRIB_IO_LAYER option obsolete (it is now default). Ignored.\n") ; |
---|
100 | #endif |
---|
101 | } |
---|
102 | if (!strcmp(*argv,"-DDM_SERIAL_IN_ONLY")) { |
---|
103 | sw_dm_serial_in_only = 1 ; |
---|
104 | } |
---|
105 | if (!strncmp(*argv,"-h",2)) { |
---|
106 | fprintf(stderr,"Usage: %s [-DDEREF_KLUDGE] [-DDM_PARALLEL] [-DDISTRIB_IO_LAYER] [-DDM_SERIAL_IN_ONLY] [-DD3VAR_IRY_KLUDGE] registryfile\n",thisprog) ; |
---|
107 | exit(1) ; |
---|
108 | } |
---|
109 | } |
---|
110 | else /* consider it an input file */ |
---|
111 | { |
---|
112 | strcpy( fname_in , *argv ) ; |
---|
113 | } |
---|
114 | argv++ ; |
---|
115 | } |
---|
116 | |
---|
117 | init_parser() ; |
---|
118 | init_type_table() ; |
---|
119 | init_dim_table() ; |
---|
120 | |
---|
121 | if ( !strcmp(fname_in,"") ) fp_in = stdin ; |
---|
122 | else |
---|
123 | if (( fp_in = fopen( fname_in , "r" )) == NULL ) |
---|
124 | { |
---|
125 | fprintf(stderr,"Registry program cannot open %s for reading. Ending.\n", fname_in ) ; |
---|
126 | exit(2) ; |
---|
127 | } |
---|
128 | |
---|
129 | sprintf( fname_tmp , "Registry_tmp.%d",mypid) ; |
---|
130 | if (( fp_tmp = fopen( fname_tmp , "w" )) == NULL ) |
---|
131 | { |
---|
132 | fprintf(stderr,"Registry program cannot open temporary %s for writing. Ending.\n", fname_tmp ) ; |
---|
133 | exit(2) ; |
---|
134 | } |
---|
135 | |
---|
136 | { char *e ; |
---|
137 | strcpy( dir , fname_in ) ; |
---|
138 | if ( ( e = rindex ( dir , '/' ) ) != NULL ) { *e = '\0' ; } else { strcpy( dir, "." ) ; } |
---|
139 | } |
---|
140 | if ( pre_parse( dir, fp_in, fp_tmp ) ) { |
---|
141 | fprintf(stderr,"Problem with Registry File %s\n", fname_in ) ; |
---|
142 | goto cleanup ; |
---|
143 | } |
---|
144 | sym_forget() ; |
---|
145 | |
---|
146 | fclose(fp_in) ; |
---|
147 | fclose(fp_tmp) ; |
---|
148 | |
---|
149 | if (( fp_tmp = fopen( fname_tmp , "r" )) == NULL ) |
---|
150 | { |
---|
151 | fprintf(stderr,"Registry program cannot open %s for reading. Ending.\n", fname_tmp ) ; |
---|
152 | goto cleanup ; |
---|
153 | } |
---|
154 | |
---|
155 | reg_parse(fp_tmp) ; |
---|
156 | |
---|
157 | fclose(fp_tmp) ; |
---|
158 | |
---|
159 | check_dimspecs() ; |
---|
160 | |
---|
161 | gen_state_struct( "inc" ) ; |
---|
162 | gen_state_subtypes( "inc" ) ; |
---|
163 | gen_alloc( "inc" ) ; |
---|
164 | gen_alloc_count( "inc" ) ; |
---|
165 | gen_dealloc( "inc" ) ; |
---|
166 | gen_scalar_indices( "inc" ) ; |
---|
167 | gen_module_state_description( "frame" ) ; |
---|
168 | gen_actual_args( "inc" ) ; |
---|
169 | gen_actual_args_new( "inc" ) ; |
---|
170 | gen_dummy_args( "inc" ) ; |
---|
171 | gen_dummy_args_new( "inc" ) ; |
---|
172 | gen_dummy_decls( "inc" ) ; |
---|
173 | gen_dummy_decls_new( "inc" ) ; |
---|
174 | gen_i1_decls( "inc" ) ; |
---|
175 | gen_namelist_statements("inc") ; |
---|
176 | gen_namelist_defines ( "inc", 0 ) ; /* without dimension statements */ |
---|
177 | gen_namelist_defines ( "inc", 1 ) ; /* with dimension statements */ |
---|
178 | gen_namelist_defaults ( "inc" ) ; |
---|
179 | gen_namelist_script ( "inc" ) ; |
---|
180 | gen_get_nl_config( "inc" ) ; |
---|
181 | gen_config_assigns( "inc" ) ; |
---|
182 | gen_config_reads( "inc" ) ; |
---|
183 | gen_wrf_io( "inc" ) ; |
---|
184 | gen_model_data_ord( "inc" ) ; |
---|
185 | gen_nest_interp( "inc" ) ; |
---|
186 | gen_scalar_derefs( "inc" ) ; |
---|
187 | |
---|
188 | /* this has to happen after gen_nest_interp, which adds halos to the AST */ |
---|
189 | gen_comms( "inc" ) ; /* this is either package supplied (by copying a */ |
---|
190 | /* gen_comms.c file into this directory) or a */ |
---|
191 | /* stubs routine. */ |
---|
192 | |
---|
193 | cleanup: |
---|
194 | sprintf(command,"/bin/rm -f %s\n",fname_tmp ); |
---|
195 | system( command ) ; |
---|
196 | |
---|
197 | } |
---|
198 | |
---|