1 | #!/bin/csh -f |
---|
2 | |
---|
3 | cont1: |
---|
4 | |
---|
5 | if ( ! -e configure.wrf ) then |
---|
6 | ./configure $1 |
---|
7 | set dontask |
---|
8 | endif |
---|
9 | |
---|
10 | |
---|
11 | #---------------------------------- |
---|
12 | if ( ! $?WRF_KPP ) setenv WRF_KPP 0 |
---|
13 | if ( $WRF_KPP == 1 ) then |
---|
14 | chem/KPP/compile_wkc |
---|
15 | endif |
---|
16 | |
---|
17 | |
---|
18 | |
---|
19 | |
---|
20 | #--------------------------------- |
---|
21 | |
---|
22 | if ( ! $?dontask && $?prompt ) then |
---|
23 | echo "This script assumes you have configured the code already." |
---|
24 | echo "You only need to configure once." |
---|
25 | echo "If you wish to reconfigure, type c at the prompt below" |
---|
26 | echo " " |
---|
27 | echo "Ready to compile? [ync]" |
---|
28 | set resp=$< |
---|
29 | |
---|
30 | if ( "$resp" == "c" ) then |
---|
31 | ./configure |
---|
32 | goto cont1 |
---|
33 | endif |
---|
34 | |
---|
35 | if ( "$resp" == "n" ) then |
---|
36 | exit 2 |
---|
37 | endif |
---|
38 | endif |
---|
39 | |
---|
40 | set arglist="" |
---|
41 | foreach a ( $argv ) |
---|
42 | if ( "$a" == "-h" ) then |
---|
43 | goto hlp |
---|
44 | else |
---|
45 | if ( "$a" != "-d" ) then |
---|
46 | set arglist = ( $arglist $a ) |
---|
47 | endif |
---|
48 | if ( "$a" == "all_wrfvar" ) then |
---|
49 | grep "DA_CORE=1" configure.wrf > /dev/null |
---|
50 | if ( ! $status ) then |
---|
51 | # If configuration file has DA_CORE=1 hardwired, ok to set WRF_DA_CORE to 1 |
---|
52 | if ( ! $?WRF_DA_CORE ) setenv WRF_DA_CORE 1 |
---|
53 | endif |
---|
54 | if ( ! -d var ) then |
---|
55 | echo " " |
---|
56 | echo "You need to download and untar the WRF DA code" |
---|
57 | echo " " |
---|
58 | exit |
---|
59 | endif |
---|
60 | endif |
---|
61 | if ( "$a" == "nmm_real" ) then |
---|
62 | grep "NMM_CORE=1" configure.wrf > /dev/null |
---|
63 | if ( ! $status ) then |
---|
64 | # If configuration file has NMM_CORE=1 hardwired, ok to set WRF_NMM_CORE to 1 |
---|
65 | if ( ! $?WRF_NMM_CORE ) setenv WRF_NMM_CORE 1 |
---|
66 | endif |
---|
67 | endif |
---|
68 | endif |
---|
69 | end |
---|
70 | |
---|
71 | if ( $arglist == "" ) then |
---|
72 | goto hlp |
---|
73 | else |
---|
74 | unsetenv A2DCASE |
---|
75 | setenv A2DCASE `echo $arglist | grep 2d` |
---|
76 | |
---|
77 | if ( ! ( $?WRF_EM_CORE || $?WRF_NMM_CORE \ |
---|
78 | || $?WRF_COAMPS_CORE || $?WRF_EXP_CORE )) then |
---|
79 | echo 'None of WRF_EM_CORE, WRF_NMM_CORE, ' |
---|
80 | # echo ' WRF_COAMPS_CORE, or WRF_EXP_CORE ' |
---|
81 | echo ' specified in shell environment.... ' |
---|
82 | setenv WRF_EM_CORE 1 |
---|
83 | setenv WRF_NMM_CORE 0 |
---|
84 | setenv WRF_COAMPS_CORE 0 |
---|
85 | setenv WRF_EXP_CORE 0 |
---|
86 | endif |
---|
87 | |
---|
88 | # these settings get passed down through the environment in the |
---|
89 | # calls to Make |
---|
90 | if ( ! $?WRF_DA_CORE ) setenv WRF_DA_CORE 0 |
---|
91 | if ( ! $?WRF_EM_CORE ) setenv WRF_EM_CORE 0 |
---|
92 | if ( ! $?WRF_NMM_CORE ) setenv WRF_NMM_CORE 0 |
---|
93 | if ( ! $?WRF_NMM_NEST ) setenv WRF_NMM_NEST 0 |
---|
94 | if ( ! $?WRF_COAMPS_CORE ) setenv WRF_COAMPS_CORE 0 |
---|
95 | if ( ! $?WRF_EXP_CORE ) setenv WRF_EXP_CORE 0 |
---|
96 | if ( ! $?WRF_CHEM ) setenv WRF_CHEM 0 |
---|
97 | if ( ! $?WRF_CONVERT ) then |
---|
98 | if ( "$arglist" == "convert_em" ) then |
---|
99 | setenv WRF_CONVERT 1 |
---|
100 | setenv WRF_EM_CORE 0 |
---|
101 | else |
---|
102 | setenv WRF_CONVERT 0 |
---|
103 | endif |
---|
104 | endif |
---|
105 | |
---|
106 | if ( ! $?DA_ARCHFLAGS ) setenv DA_ARCHFLAGS "" |
---|
107 | |
---|
108 | if ( ( $WRF_DA_CORE == 1 ) && ( ! -d var ) ) then |
---|
109 | echo " " |
---|
110 | echo "You need to download and untar the Var code, or" |
---|
111 | echo "unset the WRF_DA_CORE env variable." |
---|
112 | echo " " |
---|
113 | exit |
---|
114 | endif |
---|
115 | |
---|
116 | if ( ( $WRF_CHEM == 1 ) && ( ! -d chem ) ) then |
---|
117 | echo " " |
---|
118 | echo "You need to download and untar the chem code, or" |
---|
119 | echo "unset the WRF_CHEM env variable." |
---|
120 | echo " " |
---|
121 | exit |
---|
122 | endif |
---|
123 | |
---|
124 | set overwrite=0 |
---|
125 | if ($WRF_NMM_CORE == 1 && $WRF_CHEM == 1 ) then |
---|
126 | echo "Chemistry not yet supported in NMM core, set WRF_CHEM to 0 " |
---|
127 | if ( ! -f Registry/Registry ) then |
---|
128 | echo Registry file does not exist |
---|
129 | set overwrite=1 |
---|
130 | else |
---|
131 | head -2 Registry/Registry | tail -1 | grep NMM_CHEM > /dev/null |
---|
132 | if ( $status ) then |
---|
133 | set overwrite=1 |
---|
134 | else |
---|
135 | set nmm_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.NMM_CHEM' | grep -v 'Registry.NMM_CHEM.' | awk '{print $1}'` |
---|
136 | set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'` |
---|
137 | if ( $nmm_time > $rg_time ) set overwrite=1 |
---|
138 | endif |
---|
139 | endif |
---|
140 | if ( $overwrite ) then |
---|
141 | echo copying Registry/Registry.NMM_CHEM to Registry/Registry |
---|
142 | echo '## WARNING: this file is autogenerated from Registry/Registry.NMM_CHEM. Changes may be lost' > Registry/Registry |
---|
143 | /bin/cat Registry/Registry.NMM_CHEM >> Registry/Registry |
---|
144 | endif |
---|
145 | # exit 2 |
---|
146 | endif |
---|
147 | |
---|
148 | |
---|
149 | if ($WRF_EM_CORE == 1 && $WRF_NMM_CORE == 1 ) then |
---|
150 | echo "Cannot compile both EM and NMM cores in same executable yet." |
---|
151 | exit 2 |
---|
152 | endif |
---|
153 | if ($WRF_EM_CORE == 0 && $WRF_NMM_CORE == 0 && ! $WRF_CONVERT == 1 ) then |
---|
154 | echo "Cannot compile because both EM and NMM cores are set to 0." |
---|
155 | exit 2 |
---|
156 | endif |
---|
157 | if ($arglist == 'nmm_real' && $WRF_NMM_CORE == 0) then |
---|
158 | echo WRF_NMM_CORE must be set to 1 in order to compile nmm_real |
---|
159 | exit 2 |
---|
160 | endif |
---|
161 | if (($WRF_EM_CORE == 1)&&($WRF_DA_CORE == 0 ) &&($WRF_CHEM == 0 )&&($WRF_CONVERT == 0)) then |
---|
162 | if ( ! -f Registry/Registry ) then |
---|
163 | set overwrite=1 |
---|
164 | else |
---|
165 | head -2 Registry/Registry | tail -1 | grep EM > /dev/null |
---|
166 | if ( $status ) then |
---|
167 | set overwrite=1 |
---|
168 | else |
---|
169 | set em_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM' | grep -v 'Registry.EM.' | awk '{print $1}'` |
---|
170 | set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'` |
---|
171 | if ( $em_time > $rg_time ) set overwrite=1 |
---|
172 | endif |
---|
173 | endif |
---|
174 | if ( $overwrite ) then |
---|
175 | echo copying Registry/Registry.EM to Registry/Registry |
---|
176 | echo '## WARNING: this file is autogenerated from Registry/Registry.EM. Changes may be lost' > Registry/Registry |
---|
177 | /bin/cat Registry/Registry.EM >> Registry/Registry |
---|
178 | endif |
---|
179 | else if (($WRF_EM_CORE == 1)&&($WRF_CHEM == 1 )) then |
---|
180 | if ( ! -f Registry/Registry ) then |
---|
181 | set overwrite=1 |
---|
182 | else |
---|
183 | head -2 Registry/Registry | tail -1 | grep EM_CHEM > /dev/null |
---|
184 | if ( $status ) then |
---|
185 | set overwrite=1 |
---|
186 | else |
---|
187 | set em_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM_CHEM' | grep -v 'Registry.EM_CHEM.' | awk '{print $1}'` |
---|
188 | set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'` |
---|
189 | if ( $em_time > $rg_time ) set overwrite=1 |
---|
190 | endif |
---|
191 | endif |
---|
192 | if ( $overwrite ) then |
---|
193 | echo copying Registry/Registry.EM_CHEM to Registry/Registry |
---|
194 | echo '## WARNING: this file is autogenerated from Registry/Registry.EM_CHEM. Changes may be lost' > Registry/Registry |
---|
195 | /bin/cat Registry/Registry.EM_CHEM >> Registry/Registry |
---|
196 | endif |
---|
197 | else if (($WRF_EM_CORE == 0)&&($WRF_CONVERT == 1 )) then |
---|
198 | if ( ! -f Registry/Registry ) then |
---|
199 | set overwrite=1 |
---|
200 | else |
---|
201 | head -2 Registry/Registry | tail -1 | grep EM_CONVERT > /dev/null |
---|
202 | if ( $status ) then |
---|
203 | set overwrite=1 |
---|
204 | else |
---|
205 | set em_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM_CONVERT' | grep -v 'Registry.EM_CONVERT.' | awk '{print $1}'` |
---|
206 | set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'` |
---|
207 | if ( $em_time > $rg_time ) set overwrite=1 |
---|
208 | endif |
---|
209 | endif |
---|
210 | if ( $overwrite ) then |
---|
211 | echo copying Registry/Registry.CONVERT to Registry/Registry |
---|
212 | echo '## WARNING: this file is autogenerated from Registry/Registry.CONVERT. Changes may be lost' > Registry/Registry |
---|
213 | /bin/cat Registry/Registry.CONVERT >> Registry/Registry |
---|
214 | endif |
---|
215 | else if ( $WRF_DA_CORE == 1 ) then |
---|
216 | if ( ! -f Registry/Registry ) then |
---|
217 | set overwrite=1 |
---|
218 | else |
---|
219 | head -2 Registry/Registry | tail -1 | grep WRFVAR > /dev/null |
---|
220 | if ( $status ) then |
---|
221 | set overwrite=1 |
---|
222 | else |
---|
223 | set nmm_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.NMM' | grep -v 'Registry.NMM.' | awk '{print $1}'` |
---|
224 | set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'` |
---|
225 | if ( $nmm_time > $rg_time ) set overwrite=1 |
---|
226 | endif |
---|
227 | endif |
---|
228 | if ( $overwrite ) then |
---|
229 | echo copying Registry/Registry.wrfvar to Registry/Registry |
---|
230 | echo '## WARNING: this file is autogenerated from Registry/Registry.wrfvar. Changes may be lost' > Registry/Registry |
---|
231 | /bin/cat Registry/Registry.wrfvar >> Registry/Registry |
---|
232 | setenv DA_ARCHFLAGS "-DBUFR -DFFTPACK -DPROMOTE_FLOAT -DNONSTANDARD_SYSTEM -DNORESHAPE" |
---|
233 | endif |
---|
234 | endif |
---|
235 | if (($WRF_NMM_CORE == 1)&&($WRF_CHEM == 0 )) then |
---|
236 | if ( ! -f Registry/Registry ) then |
---|
237 | set overwrite=1 |
---|
238 | else |
---|
239 | head -2 Registry/Registry | tail -1 | grep NMM > /dev/null |
---|
240 | if ( $status ) then |
---|
241 | set overwrite=1 |
---|
242 | else |
---|
243 | set nmm_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.NMM' | grep -v 'Registry.NMM.' | awk '{print $1}'` |
---|
244 | set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'` |
---|
245 | if ( $nmm_time > $rg_time ) set overwrite=1 |
---|
246 | endif |
---|
247 | endif |
---|
248 | if ( $overwrite ) then |
---|
249 | if (($WRF_NMM_CORE == 1)&&($WRF_NMM_NEST == 1)) then |
---|
250 | echo copying Registry/Registry.NMM_NEST to Registry/Registry |
---|
251 | echo '## WARNING: this file is autogenerated from Registry/Registry.NMM_NEST. Changes may be lost' > Registry/Registry |
---|
252 | /bin/cat Registry/Registry.NMM_NEST >> Registry/Registry |
---|
253 | else |
---|
254 | echo copying Registry/Registry.NMM to Registry/Registry |
---|
255 | echo '## WARNING: this file is autogenerated from Registry/Registry.NMM. Changes may be lost' > Registry/Registry |
---|
256 | /bin/cat Registry/Registry.NMM >> Registry/Registry |
---|
257 | endif |
---|
258 | endif |
---|
259 | # integrity check for a kludge where a hard coded value in the |
---|
260 | # registry must match the same value in arch/preamble_new |
---|
261 | set registryvalue=`grep 'dimspec.* q ' Registry/Registry.NMM | sed -e 's/..*constant=//' -e 's/ ..*$//'` |
---|
262 | set preamblevalue=`grep 'DNMM_MAX_DIM=.*' arch/preamble_new | sed -e 's/..*-DNMM_MAX_DIM=//' -e 's/ ..*$//'` |
---|
263 | if ( $registryvalue != $preamblevalue ) then |
---|
264 | echo "Harded coded value of dimspec q in Registry ($registryvalue) does not" |
---|
265 | echo "equal the hard coded value of NMM_MAX_DIM in arch/preamble_new ($preamblevalue)" |
---|
266 | echo "Please fix and try again." |
---|
267 | exit 2 |
---|
268 | endif |
---|
269 | endif |
---|
270 | |
---|
271 | echo " " |
---|
272 | echo -n "**** Compiling: " |
---|
273 | if ( $WRF_DA_CORE ) echo -n "WRF_DA_CORE " |
---|
274 | if ( $WRF_EM_CORE ) echo -n "WRF_EM_CORE " |
---|
275 | if ( $WRF_NMM_CORE ) echo -n "WRF_NMM_CORE " |
---|
276 | if ( $WRF_COAMPS_CORE ) echo -n "WRF_COAMPS_CORE " |
---|
277 | if ( $WRF_EXP_CORE ) echo -n "WRF_EXP_CORE " |
---|
278 | echo "." |
---|
279 | echo " " |
---|
280 | |
---|
281 | if ( ! $?WRF_SRC_ROOT_DIR ) setenv WRF_SRC_ROOT_DIR `pwd` |
---|
282 | make $arglist A2DCASE="$A2DCASE" WRF_SRC_ROOT_DIR="$WRF_SRC_ROOT_DIR" |
---|
283 | |
---|
284 | endif |
---|
285 | |
---|
286 | exit 0 |
---|
287 | |
---|
288 | hlp: |
---|
289 | |
---|
290 | echo ' ' |
---|
291 | echo 'Usage:' |
---|
292 | echo ' ' |
---|
293 | echo ' compile wrf compile wrf in run dir (NOTE: no real.exe, ndown.exe, or ideal.exe generated)' |
---|
294 | echo ' ' |
---|
295 | echo ' or choose a test case (see README_test_cases for details) :' |
---|
296 | foreach d ( `/bin/ls test` ) |
---|
297 | if ( "$d" != "CVS" ) then |
---|
298 | echo " compile $d" |
---|
299 | endif |
---|
300 | end |
---|
301 | echo ' ' |
---|
302 | echo ' compile -h help message' |
---|
303 | |
---|
304 | |
---|