3 setenv START_OF_COMPILE
"`date`"
8 if ( ! -e configure.wrf
) then
10 echo "You must run the 'configure' script before running the 'compile' script!"
16 echo Building on
`hostname` on
`date`
18 #----------------------------------
19 # identify the commit where the compiled code came from
22 set v
='No git found or not a git repository, git commit version not available.'
24 set v
=(git
`git log | head -1` `git diff --shortstat`) >& /dev
/null
26 echo " CHARACTER (LEN=*), PARAMETER :: commit_version = '$v'" > inc
/commit_decl
27 # make sure to recompile with the current inc/commit_decl
28 touch main
/module_wrf_top.F
30 #----------------------------------
31 if ( ! $?WRF_KPP
) setenv WRF_KPP
0
32 if ( $WRF_KPP == 1 ) then
36 #---------------------------------
40 set prev_was_j
= false
44 if ( "$a" == "-h" ) then
46 else if ( "$a" == "all_wrfvar" ||
"$a" == "gen_be" ) then
47 set arglist
= ( $arglist $a )
48 grep "DA_CORE=1" configure.wrf
> /dev
/null
50 # If configuration file has DA_CORE=1, set WRF_DA_CORE to 1
53 # If the user ran the configure script without the "wrfda" option, "./compile all_wrfvar"
54 # will fail in non-obvious ways, and some executables will be created incorrectly.
55 # Let's just quit right away to avoid the hassle.
57 echo "To build WRFDA, you must run the 'configure' script with the 'wrfda' option:"
58 echo " ./configure wrfda"
64 else if ( "$a" == "em_real" ) then
65 set arglist
= ( $arglist $a )
66 set ZAP
= ( main
/wrf.exe main
/real.exe main
/ndown.exe main
/tc.exe
)
67 else if ( `echo $a | cut -c 1-3` == "em_" ) then
68 set arglist
= ( $arglist $a )
69 set ZAP
= ( main
/wrf.exe main
/ideal.exe
)
70 else if ( "$a" == "io" ) then
71 set arglist
= ( $arglist $a )
72 else if ( "$a" == "wrfplus" ) then
73 set arglist
= ( $arglist $a )
74 set ZAP
= ( main
/wrfplus.exe
)
76 setenv WRF_PLUS_CORE
1
77 else if ( "$a" == "wrf" ) then
78 set arglist
= ( $arglist $a )
79 set ZAP
= ( main
/wrf.exe
)
80 else if ( "$a" == "-j" ) then
82 setenv J
"-j $argv[$JJ]"
84 else if ( "$prev_was_j" == "true" ) then
85 set prev_was_j
= false
86 else if ( "$a" == "emi_conv" ) then
87 set arglist
= ( $arglist $a )
88 set ZAP
= ( chem
/convert_emiss.exe
)
90 echo "This option is not recognized: $a"
95 if ( "$arglist" == "" ) then
99 setenv A2DCASE
`echo $arglist | grep 2d`
101 setenv A1DCASE
`echo $arglist | grep scm`
103 if ( ! ( $?WRF_EM_CORE || $?WRF_PLUS_CORE
) ) then
104 echo 'Neither WRF_EM_CORE nor WRF_PLUS_CORE'
105 echo ' are explicitly specified in shell environment.... '
107 setenv WRF_COAMPS_CORE
0
108 setenv WRF_EXP_CORE
0
109 setenv WRF_PLUS_CORE
0
112 # these settings get passed down through the environment in the
114 if ( ! $?WRF_HYDRO
) then
116 setenv LIB_WRF_HYDRO
""
118 if($WRF_HYDRO == 1) then
119 setenv LIB_WRF_HYDRO
"-L../hydro/lib -lHYDRO"
121 setenv LIB_WRF_HYDRO
""
125 if ( ! $?WRF_DA_CORE
) setenv WRF_DA_CORE
0
126 if ( ! $?WRF_EM_CORE
) setenv WRF_EM_CORE
0
127 if ( ! $?WRF_COAMPS_CORE
) setenv WRF_COAMPS_CORE
0
128 if ( ! $?WRF_EXP_CORE
) setenv WRF_EXP_CORE
0
129 if ( ! $?WRF_PLUS_CORE
) setenv WRF_PLUS_CORE
0
130 if ( ! $?WRF_CHEM
) setenv WRF_CHEM
0
131 if ( ! $?WRF_DFI_RADAR
) setenv WRF_DFI_RADAR
0
132 if ( ! $?WRF_CONVERT
) then
133 if ( "$arglist" == "convert_em" ) then
141 # temporary - until all vestiges of NMM ifdefs are gone from WRF source
142 setenv WRF_NMM_CORE
0
143 setenv WRF_NMM_NEST
0
146 if ( ! $?DA_ARCHFLAGS
) setenv DA_ARCHFLAGS
""
148 # if ( ( $WRF_CHEM == 1 ) && ( $WRF_DA_CORE == 1 ) ) then
150 # echo "WRFDA can not be compiled with WRF_CHEM=1"
151 # echo "unset the WRF_CHEM env variable."
156 if ( ( $WRF_DA_CORE == 1 ) && ( ! -d var
) ) then
158 echo "You need to download and untar the Var code, or"
159 echo "unset the WRF_DA_CORE env variable."
164 if ( ( $WRF_CHEM == 1 ) && ( ! -d chem
) ) then
166 echo "You need to download and untar the chem code, or"
167 echo "unset the WRF_CHEM env variable."
175 if ($WRF_EM_CORE == 0 && ! $WRF_CONVERT == 1 ) then
176 echo "Cannot compile because both EM core is set to 0."
179 if (($WRF_EM_CORE == 1)&&($WRF_DA_CORE == 0 ) &&($WRF_CHEM == 0 )&&($WRF_CONVERT == 0)&&($WRF_PLUS_CORE == 0) ) then
180 if ( ! -f Registry
/Registry
) then
183 head -2 Registry
/Registry |
tail -1 |
grep EM
> /dev
/null
187 set em_time
=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM' | grep -v 'Registry.EM.' | 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
192 if ( $overwrite ) then
193 echo copying Registry
/Registry.EM to Registry
/Registry
194 echo '## WARNING: this file is autogenerated from Registry/Registry.EM. Changes may be lost' > Registry
/Registry
195 /bin
/cat Registry
/Registry.EM
>> Registry
/Registry
197 else if ( ($WRF_EM_CORE == 1)&&($WRF_PLUS_CORE == 1) ) then
198 if ( ! -f Registry
/Registry
) then
201 head -2 Registry
/Registry |
tail -1 |
grep WRFPLUS
> /dev
/null
205 set em_time
=`ls -1tr Registry | cat -n | grep -w 'Registry\.tladj' | grep -v 'Registry.tladj.' | 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
210 if ( $overwrite ) then
211 echo copying Registry
/Registry.tladj to Registry
/Registry
212 echo '## WARNING: this file is autogenerated from Registry/Registry.tladj. Changes may be lost' > Registry
/Registry
213 /bin
/cat Registry
/Registry.tladj
>> Registry
/Registry
215 else if (($WRF_EM_CORE == 1)&&($WRF_CHEM == 1 )&&($WRF_DA_CORE == 0)) then
216 if ( ! -f Registry
/Registry
) then
219 head -2 Registry
/Registry |
tail -1 |
grep EM_CHEM
> /dev
/null
223 set em_time
=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM_CHEM' | grep -v 'Registry.EM_CHEM.' | awk '{print $1}'`
224 set rg_time
=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
225 if ( $em_time > $rg_time ) set overwrite
=1
228 if ( $overwrite ) then
229 echo copying Registry
/Registry.EM_CHEM to Registry
/Registry
230 echo '## WARNING: this file is autogenerated from Registry/Registry.EM_CHEM. Changes may be lost' > Registry
/Registry
231 /bin
/cat Registry
/Registry.EM_CHEM
>> Registry
/Registry
233 else if (($WRF_EM_CORE == 1)&&($WRF_DFI_RADAR == 1 )) then
234 if ( ! -f Registry
/Registry
) then
237 if ( $overwrite ) then
238 echo copying Registry
/Registry.EM to Registry
/Registry
239 echo '## WARNING: this file is autogenerated from Registry/Registry.EM. Changes may be lost' > Registry
/Registry
240 /bin
/cat Registry
/Registry.EM
>> Registry
/Registry
242 else if (($WRF_EM_CORE == 0)&&($WRF_CONVERT == 1 )) then
243 if ( ! -f Registry
/Registry
) then
246 head -2 Registry
/Registry |
tail -1 |
grep EM_CONVERT
> /dev
/null
250 set em_time
=`ls -1tr Registry | cat -n | grep -w 'Registry\.EM_CONVERT' | grep -v 'Registry.EM_CONVERT.' | awk '{print $1}'`
251 set rg_time
=`ls -1tr Registry | cat -n | grep -w 'Registry' | grep -v 'Registry.' | awk '{print $1}'`
252 if ( $em_time > $rg_time ) set overwrite
=1
255 if ( $overwrite ) then
256 echo copying Registry
/Registry.CONVERT to Registry
/Registry
257 echo '## WARNING: this file is autogenerated from Registry/Registry.CONVERT. Changes may be lost' > Registry
/Registry
258 /bin
/cat Registry
/Registry.CONVERT
>> Registry
/Registry
260 else if ( $WRF_DA_CORE == 1 ) then
261 if ( ! -f Registry
/Registry
) then
264 if ( $WRF_CHEM == 1 ) then
265 head -2 Registry
/Registry |
tail -1 |
grep WRFCHEMVAR
> /dev
/null
267 head -2 Registry
/Registry |
tail -1 |
grep WRFVAR
> /dev
/null
273 if ( $overwrite ) then
274 /bin
/rm -f Registry
/Registry.rconfig
275 /bin
/cat Registry
/Registry.EM_COMMON |
grep '^rconfig' > Registry
/Registry.rconfig
276 if ($WRF_CHEM == 1 ) then
277 echo copying Registry
/Registry.wrfchemvar to Registry
/Registry
278 echo '## WARNING: this file is autogenerated from Registry/Registry.wrfchemvar Registry/Registry.EM_COMMON.var. Changes may be lost' > Registry
/Registry
279 /bin
/cat Registry
/Registry.wrfchemvar
>> Registry
/Registry
281 echo copying Registry
/Registry.wrfvar to Registry
/Registry
282 echo '## WARNING: this file is autogenerated from Registry/Registry.wrfvar Registry/Registry.EM_COMMON.var. Changes may be lost' > Registry
/Registry
283 /bin
/cat Registry
/Registry.wrfvar
>> Registry
/Registry
287 set wrfpluspath
= ( `grep "^WRFPLUSPATH" configure.wrf | cut -d"=" -f2-` )
288 if ( $wrfpluspath == "" ) then
289 setenv WRFPLUS_INC
" "
291 setenv WRFPLUS_DIR
$wrfpluspath
292 setenv WRFPLUS_INC
"-I${wrfpluspath}/dyn_em -I${wrfpluspath}/main -I${wrfpluspath}/frame -I${wrfpluspath}/share -I${wrfpluspath}/wrftladj"
296 set CRTM
= ( `grep "\-DCRTM" configure.wrf | sed -e 's/\\//g' | sed 's/-//g' ` )
297 if ( $CRTM != "" ) then
299 echo "Will compile with CRTM library"
303 echo "BUFR library is needed for radiance data ingest."
304 echo "setting BUFR=1"
308 setenv CRTM_CPP
"-DCRTM"
309 setenv CRTM_LIB
"-L../external/crtm_2.3.0/libsrc -lCRTM"
310 setenv CRTM_SRC
"-I../external/crtm_2.3.0/libsrc"
311 #setenv SFC_CRTM `grep '^SFC' configure.wrf | awk '{print $3}' | sed -e 's/\// /g' | awk '{print $NF}'`
312 #setenv ABI_CRTM `grep '^SFC' configure.wrf | sed -n 's/.*\(\-m[0-9]\{2\}\).*/\1/p'`
316 echo "Compiling WRFDA without CRTM library"
323 set hdf5path
= ( `grep "^HDF5PATH" configure.wrf | cut -d"=" -f2-` )
324 if ( $hdf5path == "" ) then
329 echo "Compiling with HDF5 libraries in:"
332 setenv HDF5_INC
"-I${hdf5path}/include"
335 set RTTOV
= ( `grep "^RTTOVPATH" configure.wrf | cut -d"=" -f2-` )
336 if ( $RTTOV == "" ) then
341 if ( $hdf5path == "" ) then
342 echo "As of version 12.1 of RTTOV, WRFDA requires HDF5 in order utilize the RTTOV library."
343 echo "RTTOV emissivity atlas files are now provided only in HDF5 format."
344 echo "Please supply an HDF5 path prior to configure or unset RTTOV."
348 echo "Compiling with RTTOV libraries in:"
353 echo "BUFR library is needed for radiance data ingest."
354 echo "setting BUFR=1"
358 if ( -e ${RTTOV}/lib
/librttov12_main.a
) then
359 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"
361 echo "Can not find a compatible RTTOV library! Please ensure that your RTTOV build was successful,"
362 echo "your 'RTTOV' environment variable is set correctly, and you are using a supported version of RTTOV."
363 echo "Current supported version(s): 12.1"
367 setenv RTTOV_SRC
"-I${RTTOV}/include -I${RTTOV}/mod"
371 if ( $?CLOUD_CV
) then
372 setenv CLOUD_CV_CPP
"-DCLOUD_CV"
374 setenv CLOUD_CV_CPP
" "
377 setenv BUFR_CPP
"-DBUFR"
378 setenv BUFR_LIB
"-L../external/bufr -lbufr"
383 if ( $?WAVELET
) then
384 setenv WAVELET_LIB
"../external/wavelet/libWavelet.a ../external/wavelet/lib_wavelet.a"
386 setenv WAVELET_LIB
" "
389 setenv MADIS_CPP
"-DMADIS"
390 setenv MADIS_STATIC
${MADIS}/static
391 setenv MADIS_LIB
"-L${MADIS} -lmadis"
396 setenv DA_ARCHFLAGS
"${BUFR_CPP} ${MADIS_CPP} -DFFTPACK -DNORESHAPE"
400 echo "============================================================================================== "
402 cat inc
/version_decl | cut
-d"'" -f2 |
head -1
403 cat inc
/commit_decl | cut
-d"'" -f2
405 echo -n "Compiling: "
406 if ( $WRF_DA_CORE ) echo -n "WRF_DA_CORE "
407 if ( $WRF_EM_CORE ) echo -n "WRF_EM_CORE "
408 if ( $WRF_COAMPS_CORE ) echo -n "WRF_COAMPS_CORE "
409 if ( $WRF_EXP_CORE ) echo -n "WRF_EXP_CORE "
415 set comp
= ( `grep "^SFC" configure.wrf | cut -d"=" -f2-` )
416 if ( "$comp[1]" == "gfortran" ) then
418 else if ( "$comp[1]" == "pgf90" ) then
420 else if ( "$comp[1]" == "ifort" ) then
423 echo "Not sure how to figure out the version of this compiler: $comp[1]"
426 echo "============================================================================================== "
429 if ( ! $?WRF_SRC_ROOT_DIR
) setenv WRF_SRC_ROOT_DIR
`pwd`
431 # new dec 2009. check to see if make supports parallel -j option
432 make -j 2 >& /dev
/null
433 if ( $status == 0 ) then # Parallel make ok
434 if ( ! $?J
) then # J not defined
435 echo setting parallel
make -j 2 # Set default to 2
438 # J is defined, check that it is a correctly formed variable
439 set first2chars
= `echo $J | cut -c 1-2` # Are 1st two chars are -j?
440 set second_word
= `echo $J | cut -d" " -f2` # Is second word a number?
441 if ( "$first2chars" == "-j" ) then
442 if ( ( "$second_word" >= "2" ) && \
443 ( "$second_word" <= "20" ) ) then
444 echo setting parallel
make $J
445 else if ( "$second_word" == "1" ) then
446 echo setting serial
make $J
448 echo "badly formed -j option for parallel make: $J"
449 echo "or you set the number of processors above 20 "
450 echo setting parallel
make -j 2 # Set default to 2
454 if ( "$J" == "" ) then # J blank is OK
455 echo setting serial
make $J
457 echo "parallel option for make is -j, you entered: $first2chars"
458 echo setting parallel
make -j 2 # Set default to 2
464 echo not setting parallel
make
467 /bin
/rm -f $ZAP >& /dev
/null
468 make $arglist A2DCASE
="$A2DCASE" WRF_SRC_ROOT_DIR
="$WRF_SRC_ROOT_DIR"
479 echo ' compile [-j n] wrf compile wrf in run dir (NOTE: no real.exe, ndown.exe, or ideal.exe generated)'
481 echo ' or choose a test case (see README_test_cases for details) :'
482 foreach d
( `/bin/ls test` )
483 if ( "$d" != "CVS" ) then
484 echo " compile [-j n] $d"
488 echo ' compile -j n parallel make using n tasks if supported (default 2)'
489 echo ' compile -h help message'