small changes adde ids, etc
[wrffire.git] / wrfv2_fire / compile
blob8a8593b01ebbcf8b4840eb5f385914b9aef3fbca
1 #!/bin/csh -f
3 cont1:
5 if ( ! -e configure.wrf ) then
6 if ( $1 == "all_wrfvar" ) then
7 ./configure wrfda
8 set dontask
9 else
10 ./configure $1
11 set dontask
12 endif
13 endif
16 #----------------------------------
17 if ( ! $?WRF_KPP ) setenv WRF_KPP 0
18 if ( $WRF_KPP == 1 ) then
19 chem/KPP/compile_wkc
20 endif
22 #---------------------------------
24 if ( ! $?dontask && $?prompt ) then
25 echo "This script assumes you have configured the code already."
26 echo "You only need to configure once."
27 echo "If you wish to reconfigure, type c at the prompt below"
28 echo " "
29 echo "Ready to compile? [ync]"
30 set resp=$<
32 if ( "$resp" == "c" ) then
33 ./configure
34 goto cont1
35 endif
37 if ( "$resp" == "n" ) then
38 exit 2
39 endif
40 endif
42 set arglist=""
43 foreach a ( $argv )
44 if ( "$a" == "-h" ) then
45 goto hlp
46 else
47 if ( "$a" != "-d" ) then
48 set arglist = ( $arglist $a )
49 endif
50 if ( "$a" == "all_wrfvar" ) then
51 grep "DA_CORE=1" configure.wrf > /dev/null
52 if ( ! $status ) then
53 # If configuration file has DA_CORE=1 hardwired, ok to set WRF_DA_CORE to 1
54 setenv WRF_DA_CORE 1
55 endif
56 endif
57 if ( "$a" == "nmm_real" ) then
58 grep "NMM_CORE=1" configure.wrf > /dev/null
59 if ( ! $status ) then
60 # If configuration file has NMM_CORE=1 hardwired, ok to set WRF_NMM_CORE to 1
61 if ( ! $?WRF_NMM_CORE ) setenv WRF_NMM_CORE 1
62 endif
63 endif
64 if ( "$a" == "-j" ) then
65 shift argv
66 setenv J "-j $argv[1]"
67 endif
68 endif
69 end
71 if ( "$arglist" == "" ) then
72 goto hlp
73 else
74 unsetenv A2DCASE
75 setenv A2DCASE `echo $arglist | grep 2d`
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
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_DFI_RADAR ) setenv WRF_DFI_RADAR 0
93 if ( ! $?WRF_NMM_CORE ) setenv WRF_NMM_CORE 0
94 if ( ! $?WRF_NMM_NEST ) setenv WRF_NMM_NEST 0
95 if ( ! $?WRF_COAMPS_CORE ) setenv WRF_COAMPS_CORE 0
96 if ( ! $?WRF_EXP_CORE ) setenv WRF_EXP_CORE 0
97 if ( ! $?WRF_CHEM ) setenv WRF_CHEM 0
98 if ( ! $?HWRF ) setenv HWRF 0
99 if ( ! $?WRF_CONVERT ) then
100 if ( "$arglist" == "convert_em" ) then
101 setenv WRF_CONVERT 1
102 setenv WRF_EM_CORE 0
103 else
104 setenv WRF_CONVERT 0
105 endif
106 endif
108 if ( ! $?DA_ARCHFLAGS ) setenv DA_ARCHFLAGS ""
110 if ( ( $WRF_DA_CORE == 1 ) && ( ! -d var ) ) then
111 echo " "
112 echo "You need to download and untar the Var code, or"
113 echo "unset the WRF_DA_CORE env variable."
114 echo " "
115 exit
116 endif
118 if ( ( $WRF_CHEM == 1 ) && ( ! -d chem ) ) then
119 echo " "
120 echo "You need to download and untar the chem code, or"
121 echo "unset the WRF_CHEM env variable."
122 echo " "
123 exit
124 endif
126 set overwrite=0
127 if ($WRF_NMM_CORE == 1 && $WRF_CHEM == 1 ) then
128 echo "Chemistry not yet supported in NMM core, set WRF_CHEM to 0 "
129 if ( ! -f Registry/Registry ) then
130 echo Registry file does not exist
131 set overwrite=1
132 else
133 head -2 Registry/Registry | tail -1 | grep NMM_CHEM > /dev/null
134 if ( $status ) then
135 set overwrite=1
136 else
137 set nmm_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.NMM_CHEM' | grep -v 'Registry.NMM_CHEM.' | awk '{print $1}'`
138 set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
139 if ( $nmm_time > $rg_time ) set overwrite=1
140 endif
141 endif
142 if ( $overwrite ) then
143 echo copying Registry/Registry.NMM_CHEM to Registry/Registry
144 echo '## WARNING: this file is autogenerated from Registry/Registry.NMM_CHEM. Changes may be lost' > Registry/Registry
145 /bin/cat Registry/Registry.NMM_CHEM >> Registry/Registry
146 endif
147 # exit 2
148 endif
151 if ($WRF_EM_CORE == 1 && $WRF_NMM_CORE == 1 ) then
152 echo "Cannot compile both EM and NMM cores in same executable yet."
153 exit 2
154 endif
155 if ($WRF_EM_CORE == 0 && $WRF_NMM_CORE == 0 && ! $WRF_CONVERT == 1 ) then
156 echo "Cannot compile because both EM and NMM cores are set to 0."
157 exit 2
158 endif
159 if ("$arglist" == 'nmm_real' && $WRF_NMM_CORE == 0) then
160 echo WRF_NMM_CORE must be set to 1 in order to compile nmm_real
161 exit 2
162 endif
163 if (($WRF_EM_CORE == 1)&&($WRF_DA_CORE == 0 ) &&($WRF_CHEM == 0 )&&($WRF_CONVERT == 0)) then
164 if ( ! -f Registry/Registry ) then
165 set overwrite=1
166 else
167 head -2 Registry/Registry | tail -1 | grep EM > /dev/null
168 if ( $status ) then
169 set overwrite=1
170 else
171 set em_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM' | grep -v 'Registry.EM.' | awk '{print $1}'`
172 set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
173 if ( $em_time > $rg_time ) set overwrite=1
174 endif
175 endif
176 if ( $overwrite ) then
177 echo copying Registry/Registry.EM to Registry/Registry
178 echo '## WARNING: this file is autogenerated from Registry/Registry.EM. Changes may be lost' > Registry/Registry
179 /bin/cat Registry/Registry.EM >> Registry/Registry
180 endif
181 else if (($WRF_EM_CORE == 1)&&($WRF_CHEM == 1 )) then
182 if ( ! -f Registry/Registry ) then
183 set overwrite=1
184 else
185 head -2 Registry/Registry | tail -1 | grep EM_CHEM > /dev/null
186 if ( $status ) then
187 set overwrite=1
188 else
189 set em_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM_CHEM' | grep -v 'Registry.EM_CHEM.' | awk '{print $1}'`
190 set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
191 if ( $em_time > $rg_time ) set overwrite=1
192 endif
193 endif
194 if ( $overwrite ) then
195 echo copying Registry/Registry.EM_CHEM to Registry/Registry
196 echo '## WARNING: this file is autogenerated from Registry/Registry.EM_CHEM. Changes may be lost' > Registry/Registry
197 /bin/cat Registry/Registry.EM_CHEM >> Registry/Registry
198 endif
199 else if (($WRF_EM_CORE == 0)&&($WRF_CONVERT == 1 )) then
200 if ( ! -f Registry/Registry ) then
201 set overwrite=1
202 else
203 head -2 Registry/Registry | tail -1 | grep EM_CONVERT > /dev/null
204 if ( $status ) then
205 set overwrite=1
206 else
207 set em_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM_CONVERT' | grep -v 'Registry.EM_CONVERT.' | awk '{print $1}'`
208 set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
209 if ( $em_time > $rg_time ) set overwrite=1
210 endif
211 endif
212 if ( $overwrite ) then
213 echo copying Registry/Registry.CONVERT to Registry/Registry
214 echo '## WARNING: this file is autogenerated from Registry/Registry.CONVERT. Changes may be lost' > Registry/Registry
215 /bin/cat Registry/Registry.CONVERT >> Registry/Registry
216 endif
217 else if ( $WRF_DA_CORE == 1 ) then
218 if ( ! -f Registry/Registry ) then
219 set overwrite=1
220 else
221 head -2 Registry/Registry | tail -1 | grep WRFVAR > /dev/null
222 if ( $status ) then
223 set overwrite=1
224 else
225 set nmm_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.NMM' | grep -v 'Registry.NMM.' | awk '{print $1}'`
226 set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
227 if ( $nmm_time > $rg_time ) set overwrite=1
228 endif
229 endif
230 if ( $overwrite ) then
231 echo copying Registry/Registry.wrfvar to Registry/Registry
232 echo '## WARNING: this file is autogenerated from Registry/Registry.wrfvar. Changes may be lost' > Registry/Registry
233 /bin/cat Registry/Registry.wrfvar >> Registry/Registry
234 endif
235 if ( $?CRTM ) then
236 if ( ! $?BUFR ) then
237 echo " "
238 echo "BUFR library will be compiled for radiance data ingest."
239 echo " "
240 setenv BUFR 1
241 endif
242 setenv CRTM_CPP "-DCRTM"
243 setenv CRTM_LIB "-L${CRTM} -lcrtm"
244 setenv CRTM_SRC "-I${CRTM}/src"
245 else
246 setenv CRTM_CPP " "
247 setenv CRTM_LIB " "
248 setenv CRTM_SRC " "
249 endif
250 if ( $?RTTOV ) then
251 if ( ! $?BUFR ) then
252 echo " "
253 echo "BUFR library is needed for radiance data ingest."
254 echo " "
255 setenv BUFR 1
256 endif
257 setenv RTTOV_CPP "-DRTTOV"
258 setenv RTTOV_LIB "-L${RTTOV} -lrttov"
259 setenv RTTOV_SRC "-I${RTTOV}/src"
260 else
261 setenv RTTOV_CPP " "
262 setenv RTTOV_LIB " "
263 setenv RTTOV_SRC " "
264 endif
265 if ( $?BUFR ) then
266 setenv BUFR_CPP "-DBUFR"
267 setenv BUFR_LIB "-L../external/bufr -lbufr"
268 else
269 setenv BUFR_CPP " "
270 setenv BUFR_LIB " "
271 endif
272 if ( $?MADIS ) then
273 setenv MADIS_CPP "-DMADIS"
274 setenv MADIS_STATIC ${MADIS}/static
275 setenv MADIS_LIB "-L${MADIS} -lmadis"
276 else
277 setenv MADIS_CPP " "
278 setenv MADIS_LIB " "
279 endif
280 setenv DA_ARCHFLAGS "${BUFR_CPP} ${MADIS_CPP} -DFFTPACK -DNORESHAPE"
281 endif
282 if (($WRF_NMM_CORE == 1)&&($WRF_CHEM == 0 )) then
283 if ( ! -f Registry/Registry ) then
284 set overwrite=1
285 else
286 head -2 Registry/Registry | tail -1 | grep NMM > /dev/null
287 if ( $status ) then
288 set overwrite=1
289 else
290 set nmm_time=`ls -1tr Registry | cat -n | grep -w 'Registry\.NMM' | grep -v 'Registry.NMM.' | awk '{print $1}'`
291 set rg_time=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
292 if ( $nmm_time > $rg_time ) set overwrite=1
293 endif
294 endif
295 if ( $overwrite ) then
296 if (($WRF_NMM_CORE == 1)&&($WRF_NMM_NEST == 1)) then
297 echo copying Registry/Registry.NMM_NEST to Registry/Registry
298 echo '## WARNING: this file is autogenerated from Registry/Registry.NMM_NEST. Changes may be lost' > Registry/Registry
299 /bin/cat Registry/Registry.NMM_NEST >> Registry/Registry
300 else
301 echo copying Registry/Registry.NMM to Registry/Registry
302 echo '## WARNING: this file is autogenerated from Registry/Registry.NMM. Changes may be lost' > Registry/Registry
303 /bin/cat Registry/Registry.NMM >> Registry/Registry
304 endif
305 endif
306 # integrity check for a kludge where a hard coded value in the
307 # registry must match the same value in arch/preamble_new
308 set registryvalue=`grep 'dimspec.* q ' Registry/registry.dimspec | sed -e 's/..*constant=//' -e 's/ ..*$//'`
309 set preamblevalue=`grep 'DNMM_MAX_DIM=.*' arch/preamble_new | sed -e 's/..*-DNMM_MAX_DIM=//' -e 's/ ..*$//'`
310 if ( $registryvalue != $preamblevalue ) then
311 echo "Harded coded value of dimspec q in Registry ($registryvalue) does not"
312 echo "equal the hard coded value of NMM_MAX_DIM in arch/preamble_new ($preamblevalue)"
313 echo "Please fix and try again."
314 exit 2
315 endif
316 endif
318 echo " "
319 echo -n "Compiling: "
320 if ( $WRF_DA_CORE ) echo -n "WRF_DA_CORE "
321 if ( $WRF_EM_CORE ) echo -n "WRF_EM_CORE "
322 if ( $WRF_NMM_CORE ) echo -n "WRF_NMM_CORE "
323 if ( $WRF_COAMPS_CORE ) echo -n "WRF_COAMPS_CORE "
324 if ( $WRF_EXP_CORE ) echo -n "WRF_EXP_CORE "
325 echo "."
326 echo " "
328 if ( ! $?WRF_SRC_ROOT_DIR ) setenv WRF_SRC_ROOT_DIR `pwd`
330 # new dec 2009. check to see if make supports parallel -j option
331 make -j 6 >& /dev/null
332 if ( $status == 0 ) then
333 if ( ! $?J ) then
334 echo setting parallel make -j 6
335 setenv J "-j 6"
336 else
337 echo setting parallel make $J
338 endif
339 else
340 echo not setting parallel make
341 endif
343 make $arglist A2DCASE="$A2DCASE" WRF_SRC_ROOT_DIR="$WRF_SRC_ROOT_DIR"
345 endif
347 exit 0
349 hlp:
351 echo ' '
352 echo 'Usage:'
353 echo ' '
354 echo ' compile [-d] [-j n] wrf compile wrf in run dir (NOTE: no real.exe, ndown.exe, or ideal.exe generated)'
355 echo ' '
356 echo ' or choose a test case (see README_test_cases for details) :'
357 foreach d ( `/bin/ls test` )
358 if ( "$d" != "CVS" ) then
359 echo " compile $d"
360 endif
362 echo ' '
363 echo ' compile -d compile without optimization and with debugging'
364 echo ' compile -j n parallel make using n tasks if supported (default 6)'
365 echo ' compile -h help message'