3 setenv START_OF_COMPILE
"`date`"
7 if ( ! -e configure.wrf
) then
9 echo "You must run the 'configure' script before running the 'compile' script!"
15 #----------------------------------
16 # identify the commit where the compiled code came from
19 set v
='No git found or not a git repository, git commit version not available.'
21 set v
=(git
`git log | head -1` `git diff --shortstat`) >& /dev
/null
23 echo " CHARACTER (LEN=*), PARAMETER :: commit_version = '$v'" > inc
/commit_decl
25 #----------------------------------
26 if ( ! $?WRF_KPP
) setenv WRF_KPP
0
27 if ( $WRF_KPP == 1 ) then
31 #---------------------------------
35 set prev_was_j
= false
39 if ( "$a" == "-h" ) then
41 else if ( "$a" == "all_wrfvar" ||
"$a" == "gen_be" ) then
42 set arglist
= ( $arglist $a )
43 grep "DA_CORE=1" configure.wrf
> /dev
/null
45 # If configuration file has DA_CORE=1, set WRF_DA_CORE to 1
48 # If the user ran the configure script without the "wrfda" option, "./compile all_wrfvar"
49 # will fail in non-obvious ways, and some executables will be created incorrectly.
50 # Let's just quit right away to avoid the hassle.
52 echo "To build WRFDA, you must run the 'configure' script with the 'wrfda' option:"
53 echo " ./configure wrfda"
59 else if ( "$a" == "em_real" ) then
60 set arglist
= ( $arglist $a )
61 set ZAP
= ( main
/wrf.exe main
/real.exe main
/ndown.exe main
/tc.exe
)
62 else if ( `echo $a | cut -c 1-3` == "em_" ) then
63 set arglist
= ( $arglist $a )
64 set ZAP
= ( main
/wrf.exe main
/ideal.exe
)
65 else if ( "$a" == "io" ) then
66 set arglist
= ( $arglist $a )
67 else if ( "$a" == "wrfplus" ) then
68 set arglist
= ( $arglist $a )
69 set ZAP
= ( main
/wrfplus.exe
)
71 setenv WRF_PLUS_CORE
1
72 else if ( "$a" == "wrf" ) then
73 set arglist
= ( $arglist $a )
74 set ZAP
= ( main
/wrf.exe
)
75 else if ( "$a" == "-j" ) then
77 setenv J
"-j $argv[$JJ]"
79 else if ( "$prev_was_j" == "true" ) then
80 set prev_was_j
= false
81 else if ( "$a" == "emi_conv" ) then
82 set arglist
= ( $arglist $a )
83 set ZAP
= ( chem
/convert_emiss.exe
)
85 echo "This option is not recognized: $a"
90 if ( "$arglist" == "" ) then
94 setenv A2DCASE
`echo $arglist | grep 2d`
96 setenv A1DCASE
`echo $arglist | grep scm`
98 if ( ! ( $?WRF_EM_CORE || $?WRF_PLUS_CORE
) ) then
99 echo 'Neither WRF_EM_CORE nor WRF_PLUS_CORE'
100 echo ' are explicitly specified in shell environment.... '
102 setenv WRF_COAMPS_CORE
0
103 setenv WRF_EXP_CORE
0
104 setenv WRF_PLUS_CORE
0
107 # these settings get passed down through the environment in the
109 if ( ! $?WRF_HYDRO
) then
111 setenv LIB_WRF_HYDRO
""
113 if($WRF_HYDRO == 1) then
114 setenv LIB_WRF_HYDRO
"-L../hydro/lib -lHYDRO"
116 setenv LIB_WRF_HYDRO
""
120 if ( ! $?WRF_DA_CORE
) setenv WRF_DA_CORE
0
121 if ( ! $?WRF_EM_CORE
) setenv WRF_EM_CORE
0
122 if ( ! $?WRF_COAMPS_CORE
) setenv WRF_COAMPS_CORE
0
123 if ( ! $?WRF_EXP_CORE
) setenv WRF_EXP_CORE
0
124 if ( ! $?WRF_PLUS_CORE
) setenv WRF_PLUS_CORE
0
125 if ( ! $?WRF_CHEM
) setenv WRF_CHEM
0
126 if ( ! $?WRF_DFI_RADAR
) setenv WRF_DFI_RADAR
0
127 if ( ! $?WRF_CONVERT
) then
128 if ( "$arglist" == "convert_em" ) then
136 # temporary - until all vestiges of NMM ifdefs are gone from WRF source
137 setenv WRF_NMM_CORE
0
138 setenv WRF_NMM_NEST
0
141 if ( ! $?DA_ARCHFLAGS
) setenv DA_ARCHFLAGS
""
143 # if ( ( $WRF_CHEM == 1 ) && ( $WRF_DA_CORE == 1 ) ) then
145 # echo "WRFDA can not be compiled with WRF_CHEM=1"
146 # echo "unset the WRF_CHEM env variable."
151 if ( ( $WRF_DA_CORE == 1 ) && ( ! -d var
) ) then
153 echo "You need to download and untar the Var code, or"
154 echo "unset the WRF_DA_CORE env variable."
159 if ( ( $WRF_CHEM == 1 ) && ( ! -d chem
) ) then
161 echo "You need to download and untar the chem code, or"
162 echo "unset the WRF_CHEM env variable."
170 if ($WRF_EM_CORE == 0 && ! $WRF_CONVERT == 1 ) then
171 echo "Cannot compile because both EM core is set to 0."
174 if (($WRF_EM_CORE == 1)&&($WRF_DA_CORE == 0 ) &&($WRF_CHEM == 0 )&&($WRF_CONVERT == 0)&&($WRF_PLUS_CORE == 0) ) then
175 if ( ! -f Registry
/Registry
) then
178 head -2 Registry
/Registry |
tail -1 |
grep EM
> /dev
/null
182 set em_time
=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM' | grep -v 'Registry.EM.' | awk '{print $1}'`
183 set rg_time
=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
184 if ( $em_time > $rg_time ) set overwrite
=1
187 if ( $overwrite ) then
188 echo copying Registry
/Registry.EM to Registry
/Registry
189 echo '## WARNING: this file is autogenerated from Registry/Registry.EM. Changes may be lost' > Registry
/Registry
190 /bin
/cat Registry
/Registry.EM
>> Registry
/Registry
192 else if ( ($WRF_EM_CORE == 1)&&($WRF_PLUS_CORE == 1) ) then
193 if ( ! -f Registry
/Registry
) then
196 head -2 Registry
/Registry |
tail -1 |
grep WRFPLUS
> /dev
/null
200 set em_time
=`ls -1tr Registry | cat -n | grep -w 'Registry\.tladj' | grep -v 'Registry.tladj.' | awk '{print $1}'`
201 set rg_time
=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
202 if ( $em_time > $rg_time ) set overwrite
=1
205 if ( $overwrite ) then
206 echo copying Registry
/Registry.tladj to Registry
/Registry
207 echo '## WARNING: this file is autogenerated from Registry/Registry.tladj. Changes may be lost' > Registry
/Registry
208 /bin
/cat Registry
/Registry.tladj
>> Registry
/Registry
210 else if (($WRF_EM_CORE == 1)&&($WRF_CHEM == 1 )&&($WRF_DA_CORE == 0)) then
211 if ( ! -f Registry
/Registry
) then
214 head -2 Registry
/Registry |
tail -1 |
grep EM_CHEM
> /dev
/null
218 set em_time
=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM_CHEM' | grep -v 'Registry.EM_CHEM.' | awk '{print $1}'`
219 set rg_time
=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
220 if ( $em_time > $rg_time ) set overwrite
=1
223 if ( $overwrite ) then
224 echo copying Registry
/Registry.EM_CHEM to Registry
/Registry
225 echo '## WARNING: this file is autogenerated from Registry/Registry.EM_CHEM. Changes may be lost' > Registry
/Registry
226 /bin
/cat Registry
/Registry.EM_CHEM
>> Registry
/Registry
228 else if (($WRF_EM_CORE == 1)&&($WRF_DFI_RADAR == 1 )) then
229 if ( ! -f Registry
/Registry
) then
232 if ( $overwrite ) then
233 echo copying Registry
/Registry.EM to Registry
/Registry
234 echo '## WARNING: this file is autogenerated from Registry/Registry.EM. Changes may be lost' > Registry
/Registry
235 /bin
/cat Registry
/Registry.EM
>> Registry
/Registry
237 else if (($WRF_EM_CORE == 0)&&($WRF_CONVERT == 1 )) then
238 if ( ! -f Registry
/Registry
) then
241 head -2 Registry
/Registry |
tail -1 |
grep EM_CONVERT
> /dev
/null
245 set em_time
=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM_CONVERT' | grep -v 'Registry.EM_CONVERT.' | awk '{print $1}'`
246 set rg_time
=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
247 if ( $em_time > $rg_time ) set overwrite
=1
250 if ( $overwrite ) then
251 echo copying Registry
/Registry.CONVERT to Registry
/Registry
252 echo '## WARNING: this file is autogenerated from Registry/Registry.CONVERT. Changes may be lost' > Registry
/Registry
253 /bin
/cat Registry
/Registry.CONVERT
>> Registry
/Registry
255 else if ( $WRF_DA_CORE == 1 ) then
256 if ( ! -f Registry
/Registry
) then
259 if ( $WRF_CHEM == 1 ) then
260 head -2 Registry
/Registry |
tail -1 |
grep WRFCHEMVAR
> /dev
/null
262 head -2 Registry
/Registry |
tail -1 |
grep WRFVAR
> /dev
/null
268 if ( $overwrite ) then
269 /bin
/rm -f Registry
/Registry.rconfig
270 /bin
/cat Registry
/Registry.EM_COMMON |
grep '^rconfig' > Registry
/Registry.rconfig
271 if ($WRF_CHEM == 1 ) then
272 echo copying Registry
/Registry.wrfchemvar to Registry
/Registry
273 echo '## WARNING: this file is autogenerated from Registry/Registry.wrfchemvar Registry/Registry.EM_COMMON.var. Changes may be lost' > Registry
/Registry
274 /bin
/cat Registry
/Registry.wrfchemvar
>> Registry
/Registry
276 echo copying Registry
/Registry.wrfvar to Registry
/Registry
277 echo '## WARNING: this file is autogenerated from Registry/Registry.wrfvar Registry/Registry.EM_COMMON.var. Changes may be lost' > Registry
/Registry
278 /bin
/cat Registry
/Registry.wrfvar
>> Registry
/Registry
282 set wrfpluspath
= ( `grep "^WRFPLUSPATH" configure.wrf | cut -d"=" -f2-` )
283 if ( $wrfpluspath == "" ) then
284 setenv WRFPLUS_INC
" "
286 setenv WRFPLUS_DIR
$wrfpluspath
287 setenv WRFPLUS_INC
"-I${wrfpluspath}/dyn_em -I${wrfpluspath}/main -I${wrfpluspath}/frame -I${wrfpluspath}/share -I${wrfpluspath}/wrftladj"
291 set CRTM
= ( `grep "\-DCRTM" configure.wrf | sed -e 's/\\//g' | sed 's/-//g' ` )
292 if ( $CRTM != "" ) then
294 echo "Will compile with CRTM library"
298 echo "BUFR library is needed for radiance data ingest."
299 echo "setting BUFR=1"
303 setenv CRTM_CPP
"-DCRTM"
304 setenv CRTM_LIB
"-L../external/crtm_2.3.0/libsrc -lCRTM"
305 setenv CRTM_SRC
"-I../external/crtm_2.3.0/libsrc"
306 #setenv SFC_CRTM `grep '^SFC' configure.wrf | awk '{print $3}' | sed -e 's/\// /g' | awk '{print $NF}'`
307 #setenv ABI_CRTM `grep '^SFC' configure.wrf | sed -n 's/.*\(\-m[0-9]\{2\}\).*/\1/p'`
311 echo "Compiling WRFDA without CRTM library"
318 set hdf5path
= ( `grep "^HDF5PATH" configure.wrf | cut -d"=" -f2-` )
319 if ( $hdf5path == "" ) then
324 echo "Compiling with HDF5 libraries in:"
327 setenv HDF5_INC
"-I${hdf5path}/include"
330 set RTTOV
= ( `grep "^RTTOVPATH" configure.wrf | cut -d"=" -f2-` )
331 if ( $RTTOV == "" ) then
336 if ( $hdf5path == "" ) then
337 echo "As of version 12.1 of RTTOV, WRFDA requires HDF5 in order utilize the RTTOV library."
338 echo "RTTOV emissivity atlas files are now provided only in HDF5 format."
339 echo "Please supply an HDF5 path prior to configure or unset RTTOV."
343 echo "Compiling with RTTOV libraries in:"
348 echo "BUFR library is needed for radiance data ingest."
349 echo "setting BUFR=1"
353 if ( -e ${RTTOV}/lib
/librttov12_main.a
) then
354 setenv RTTOV_LIB
"-L${hdf5path}/lib -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -L${RTTOV}/lib -lrttov12_coef_io -lrttov12_emis_atlas -lrttov12_main -lrttov12_hdf"
356 echo "Can not find a compatible RTTOV library! Please ensure that your RTTOV build was successful,"
357 echo "your 'RTTOV' environment variable is set correctly, and you are using a supported version of RTTOV."
358 echo "Current supported version(s): 12.1"
362 setenv RTTOV_SRC
"-I${RTTOV}/include -I${RTTOV}/mod"
366 if ( $?CLOUD_CV
) then
367 setenv CLOUD_CV_CPP
"-DCLOUD_CV"
369 setenv CLOUD_CV_CPP
" "
372 setenv BUFR_CPP
"-DBUFR"
373 setenv BUFR_LIB
"-L../external/bufr -lbufr"
378 if ( $?WAVELET
) then
379 setenv WAVELET_LIB
"../external/wavelet/libWavelet.a ../external/wavelet/lib_wavelet.a"
381 setenv WAVELET_LIB
" "
384 setenv MADIS_CPP
"-DMADIS"
385 setenv MADIS_STATIC
${MADIS}/static
386 setenv MADIS_LIB
"-L${MADIS} -lmadis"
391 setenv DA_ARCHFLAGS
"${BUFR_CPP} ${MADIS_CPP} -DFFTPACK -DNORESHAPE"
395 echo "============================================================================================== "
397 cat inc
/version_decl | cut
-d"'" -f2 |
head -1
398 cat inc
/commit_decl | cut
-d"'" -f2
400 echo -n "Compiling: "
401 if ( $WRF_DA_CORE ) echo -n "WRF_DA_CORE "
402 if ( $WRF_EM_CORE ) echo -n "WRF_EM_CORE "
403 if ( $WRF_COAMPS_CORE ) echo -n "WRF_COAMPS_CORE "
404 if ( $WRF_EXP_CORE ) echo -n "WRF_EXP_CORE "
410 set comp
= ( `grep "^SFC" configure.wrf | cut -d"=" -f2-` )
411 if ( "$comp[1]" == "gfortran" ) then
413 else if ( "$comp[1]" == "pgf90" ) then
415 else if ( "$comp[1]" == "ifort" ) then
418 echo "Not sure how to figure out the version of this compiler: $comp[1]"
421 echo "============================================================================================== "
424 if ( ! $?WRF_SRC_ROOT_DIR
) setenv WRF_SRC_ROOT_DIR
`pwd`
426 # new dec 2009. check to see if make supports parallel -j option
427 make -j 2 >& /dev
/null
428 if ( $status == 0 ) then # Parallel make ok
429 if ( ! $?J
) then # J not defined
430 echo setting parallel
make -j 2 # Set default to 2
433 # J is defined, check that it is a correctly formed variable
434 set first2chars
= `echo $J | cut -c 1-2` # Are 1st two chars are -j?
435 set second_word
= `echo $J | cut -d" " -f2` # Is second word a number?
436 if ( "$first2chars" == "-j" ) then
437 if ( ( "$second_word" >= "2" ) && \
438 ( "$second_word" <= "20" ) ) then
439 echo setting parallel
make $J
440 else if ( "$second_word" == "1" ) then
441 echo setting serial
make $J
443 echo "badly formed -j option for parallel make: $J"
444 echo "or you set the number of processors above 20 "
445 echo setting parallel
make -j 2 # Set default to 2
449 if ( "$J" == "" ) then # J blank is OK
450 echo setting serial
make $J
452 echo "parallel option for make is -j, you entered: $first2chars"
453 echo setting parallel
make -j 2 # Set default to 2
459 echo not setting parallel
make
462 /bin
/rm -f $ZAP >& /dev
/null
463 make $arglist A2DCASE
="$A2DCASE" WRF_SRC_ROOT_DIR
="$WRF_SRC_ROOT_DIR"
474 echo ' compile [-j n] wrf compile wrf in run dir (NOTE: no real.exe, ndown.exe, or ideal.exe generated)'
476 echo ' or choose a test case (see README_test_cases for details) :'
477 foreach d
( `/bin/ls test` )
478 if ( "$d" != "CVS" ) then
479 echo " compile [-j n] $d"
483 echo ' compile -j n parallel make using n tasks if supported (default 2)'
484 echo ' compile -h help message'