5 set TOP_DIR
=/glade
/p
/mmm
/liuz
/cy_code
/cwb2017
6 set JOB
='PBS' # LSF or PBS
10 set WRFDA_DIR
=$TOP_DIR/..
/WRF_Github
/wrf_myfork
11 set MULTI_INC_TOOLS
=$WRFDA_DIR/var
/mri4dvar
12 set DATA_DIR
=$TOP_DIR/case_2015061400
/2015061400_ztd30min_cloud_radar
18 #---------------- User Configuration --------------
19 set VAR4D
=$1 # false if 3DVAR
24 set observerclocktime
=00:10:00
25 set minimizeclocktime
=00:35:00
26 set WORK_DIR
=$TOP_DIR/case_2015061400
/$5
27 set THIN_FACTOR
=($6 $7)
28 set BE1
=$TOP_DIR/2km_domain
/be.dat_
$8
29 set BE2
=$TOP_DIR/2km_domain
/be.dat_
$9
30 set BE3
=$TOP_DIR/2km_domain
/be.dat_2km
31 #----------------- User Configuration -------------
33 mkdir
-p $WORK_DIR; cd $WORK_DIR
35 if ( $VAR4D == true
) then
36 ln -sf ${WRFDA_DIR}/run
/RRTM_DATA_DBL RRTM_DATA
37 ln -sf ${WRFDA_DIR}/run
/RRTMG_LW_DATA_DBL RRTMG_LW_DATA
38 ln -sf ${WRFDA_DIR}/run
/RRTMG_SW_DATA_DBL RRTMG_SW_DATA
39 ln -sf ${WRFDA_DIR}/run
/SOILPARM.TBL .
40 ln -sf ${WRFDA_DIR}/run
/VEGPARM.TBL .
41 ln -sf ${WRFDA_DIR}/run
/GENPARM.TBL .
43 ln -sf ${WRFDA_DIR}/run
/LANDUSE.TBL .
44 ln -sf ${WRFDA_DIR}/var
/da
/da_wrfvar.exe .
46 cp ${DATA_DIR}/wrfinput_d01 orig_fg
47 if ( $VAR4D == true
) then
48 cp ${DATA_DIR}/wrfinput_d01 orig_wrfinput_d01
49 cp ${DATA_DIR}/wrfbdy_d01 orig_wrfbdy_d01
50 cp ${DATA_DIR}/fg02 orig_fg02
53 if ( $VAR4D == true
) then
54 cp ${DATA_DIR}/namelist.input_cv7_4dvar orig_namelist.input
55 ln -sf ${DATA_DIR}/ob
*.ascii .
56 ln -sf ${DATA_DIR}/ob
*.radar .
58 cp ${DATA_DIR}/namelist.input_cv7_3dvar orig_namelist.input
59 ln -sf ${DATA_DIR}/ob01.ascii .
/ob.ascii
62 #=============================================================================;
63 # Purpose : Script for running WRF-3D/4DVAR with Multi-resolution
65 # Assuming : 1. All the necessary files required by 4DVAR run are
66 # already under $RUN_DIR, such as be.dat, namelist.input, *.tbl,
67 # fg, fg02, wrfbdy_d01, da_wrfvar.exe, da_update_bc, etc.
69 # 2. da_bilin.exe, da_bdy.exe, da_thin.exe, da_vp_bilin.exe
70 # da_vp_split.exe located under ${MULTI_INC_TOOLS}
72 # How to run : When everything is ready to go, call this script instead of
73 # da_wrfvar.exe for a Multi-incremental run
77 # Limitation : Grids need to match
79 # where n is the x/y grid number of high resolution, m is the
80 # x/y grid number of low resolution. Default ratio is 1:3.
82 # Platform : All the commands involved by this script are GNU/Linux
83 # commands on CentOS box. If involved this script other than
84 # CentOS, commands may not run as your expect, double check
87 # Not fullly test with all platforms, use it at your own risk
89 # jliu@ucar.edu, MMM/NCAR, 01/13/2012
92 # Add the capability of different resolutions for different outer-loops
93 # xinzhang@ucar.edu, MMM/NCAR, 11/25/2013
95 # Re-write script and add more comments to ease understanding
96 # Unify Multi-Resolution Incremental 3DVAR and 4DVAR, i.e., MRI-3D/4DVAR
97 # Zhiquan (Jake) Liu, liuz@ucar.edu, NCAR/MMM, August 2016
98 #=============================================================================;
101 #----------------------------User settings------------------------------------;
103 # Use these environment variables to override the default settings
105 # Variable Names Default Value Description
107 # RUN_CMD mpirun -np 16 Job submit command, "" for serial and OpenMP
109 # TIME_STEP_STAGE2 auto detect Stage2 Time step for integration in integer
110 # seconds as large as 6*DX (in km) and must be
111 # exactly divisible by VAR4D_bin exactly.
113 # RADT_STAGE2 auto detect Minutes between radiation physics calls for
114 # Multi_inc stage2. 1 minute per km of dx.
116 # THIN_FACTOR 3 Thinning ratio
118 # MULTI_INC TRUE TRUE/FALSE - Multi-incremental/full resolution
120 # MAX_OUTERLOOP 1 outerloop number for Multi-incremental run
122 if ( ! $?RUN_CMD
) set RUN_CMD
="mpiexec -n " # "" - Serial/OpenMP
123 if ( ! $?NPROCS_NL
) set NPROCS_NL
=512 # Number of processing cores
124 if ( ! $?NNODES_NL
) set NNODES_NL
=16 # Number of nodes
125 if ( ! $?NPROCS
) set NPROCS
=(512 512) # Number of processing cores
126 if ( ! $?NNODES
) set NNODES
=(16 16) # Number of nodes
127 if ( ! $?MAX_OUTERLOOP
) set MAX_OUTERLOOP
=2 # Only available for Multi-incremental run
128 if ( ! $?THIN_FACTOR
) set THIN_FACTOR
=(1 1) # default decimation factor
129 @ n1
= $MAX_OUTERLOOP
132 if ( $n1 > $n2 ||
$n1 > $n3 ) then
133 echo "The dimension of THIN_FACTOR ($#THIN_FACTOR) should be equal to MAX_OUTERLOOP ($MAX_OUTERLOOP) "
137 #----------------------------End of User settings-----------------------------;
139 if ( ! $?MULTI_INC_TOOLS
) then
140 if ( ${#argv} > 0 ) then
141 set MULTI_INC_TOOLS
=$1
144 set MULTI_INC_TOOLS
=${0:h}
145 if ( "$MULTI_INC_TOOLS" == "$appname" ) set MULTI_INC_TOOLS
="."
149 if ( $MULTI_INC == true
) then
151 foreach f
(da_thin.exe da_bilin.exe da_bdy.exe \
152 da_vp_bilin.exe da_vp_split.exe \
153 nc_vpglobal.ncl nc_vphires.ncl nc_increment.ncl
)
154 if ( -e ${MULTI_INC_TOOLS}/$f ) then
155 if ( "$MULTI_INC_TOOLS" != "." ) then
156 ln -sf ${MULTI_INC_TOOLS}/$f .
159 echo "$f NOT exists" > FAIL
164 set FILES_TO_CLEAN
=(ana02 ana02_hires ana02_lores \
165 wrfvar_output wrfvar_output_hires wrfvar_output_lores \
166 FAIL .current_stage .last_stage .final_stage \
168 rsl
* gts
* vp_
* outerloop_
*)
170 #rm -rf $FILES_TO_CLEAN
172 touch .current_stage .last_stage .final_stage
175 #if ( $VAR4D == true ) then
176 @ nloop
= $MAX_OUTERLOOP + 1
178 # @ nloop = $MAX_OUTERLOOP
181 while ( $N <= $nloop )
183 if ( $N == $nloop ) then
184 set RUN_STAGE1
=true
# only run omb for the last loop
187 set istage
=1 # 1 for observer; 0 for normal 3dvar mode
199 #---------------- User Configuration --------------
200 if ( $N == 1 ) ln -sf ${BE1} be.dat
201 if ( $N == 2 ) ln -sf ${BE2} be.dat
202 if ( $N == 3 ) ln -sf ${BE3} be.dat
203 #---------------- User Configuration --------------
206 cp orig_fg o
${N}s1_fg
# stage1 for observer step
207 if ( $VAR4D == true
) then
208 cp orig_fg02 o
${N}s1_fg02
210 else # from 2nd loop, use previous loop's analysis
212 cp .
/o
${NM1}s
3/wrfvar_output_hires o
${N}s1_fg
213 if ( $VAR4D == true
) then
214 cp orig_fg02 o
${N}s1_fg02
218 if ( $RUN_STAGE1 == "true" ) then
220 echo "--------------------------------------"
221 echo "| Run outerloop-$N : Stage1-Observer |"
222 echo "--------------------------------------"
224 echo "--------------------------------------"
225 echo "| 1.0 Set up namlist.input for stage1 |"
226 echo "--------------------------------------"
227 #-----------------------------------
229 # multi_inc=1, # stage1 for omb only
230 #---------------------------------------
231 if ( $OS == "Darwin" ) then
232 sed -e "/[Mm][Uu][Ll][Tt][Ii]_[Ii][Nn][Cc][ \t]*=/ c\ \
233 multi_inc=${istage}," \
234 -e "/[m][a][x]_[e][x][t]_[i][t][s][ \t]*=/ c\ \
235 max_ext_its=${nouterloop}," \
236 -e "/[n][t][m][a][x][ \t]*=/ c\ \
237 ntmax=${ninnerloop}," \
238 orig_namelist.input
> o
${N}s1_namelist.input
240 sed -e "/[Mm][Uu][Ll][Tt][Ii]_[Ii][Nn][Cc][ \t]*=/ c\multi_inc=${istage}," \
241 -e "/[m][a][x]_[e][x][t]_[i][t][s][ \t]*=/ c\max_ext_its=${nouterloop}," \
242 -e "/[n][t][m][a][x][ \t]*=/ c\ntmax=${ninnerloop}," \
243 orig_namelist.input
> o
${N}s1_namelist.input
247 if ( $VAR4D == true
) then
248 echo "--------------------------------------------"
249 echo "| 1.1 Generating boundary file for stage1 |"
250 echo "--------------------------------------------"
252 da_bdy.exe
-fg o
${N}s1_fg \
254 -bdy orig_wrfbdy_d01 \
255 -o o
${N}s1_wrfbdy_d01 \
256 >& o
${N}s1_da_bdy.log
257 if ( ! -e o
${N}s1_wrfbdy_d01
) then
258 echo "generating bdy file for outloop1 stage1 failed" > FAIL
263 echo "--------------------------------------------"
264 echo "| 1.2 run WRF-VAR in observer mode |"
265 echo "--------------------------------------------"
267 if ( -e namelist.input
) rm namelist.input
268 ln -sf o
${N}s1_namelist.input namelist.input
270 if ( $VAR4D == true
) then
271 ln -sf o
${N}s1_fg02 fg02
272 ln -sf o
${N}s1_fg wrfinput_d01
273 ln -sf o
${N}s1_wrfbdy_d01 wrfbdy_d01
276 echo "outerloop${N}_stage1" > .current_stage
277 echo "outerloop${N}_stage1" > .final_stage
279 #--------------------------------------
280 if ( $JOB == 'LSF' ) then
281 if ( -e submit_lsf.csh
) rm -f submit_lsf.csh
282 cat > submit_lsf.csh
<<EOF
285 ### LSF batch script to run an MPI application
287 #BSUB -P $PROJID # project code
288 #BSUB -W $observerclocktime # wall-clock time (hrs:mins)
289 #BSUB -n $NPROCS_NL # number of tasks in job
290 #BSUB -R "span[ptile=16]" # run 16 MPI tasks per node
291 #BSUB -J o${N}s1 # job name
292 #BSUB -o o${N}s1.%J.out # output file name in which %J is replaced by the job ID
293 #BSUB -e o${N}s1.%J.err # error file name in which %J is replaced by the job ID
294 #BSUB -q $QUEUE # queue
297 mpirun.lsf ./da_wrfvar.exe
299 bsub
-K < submit_lsf.csh
301 else #if ( $JOB == 'PBS' )
302 if ( -e submit_pbs.csh
) rm -f submit_pbs.csh
303 cat > submit_pbs.csh
<<EOF
306 ### PBS batch script to run an MPI application
309 #PBS -l walltime=$observerclocktime
310 #PBS -l select=16:ncpus=36:mpiprocs=36:mem=110G
316 mpirun ./da_wrfvar.exe
318 set jobid
= `qsub submit_pbs.csh`
321 # $RUN_CMD $NPROCS_NL ${PWD}/da_wrfvar.exe < /dev/null
323 #------------------------------------------
328 echo "sleep 30" >> log
329 if ( "`qstat | grep -o -m 1 $jobid`" != $jobid ) then
330 if ( "`tail rsl.out.0000 | grep -o -m 1 successfully`" != "successfully" ) then
331 echo "da_wrfvar stage1 failed " > FAIL
342 echo "------------------------------"
343 echo "| 1.3 Save and clean output |"
344 echo "------------------------------"
346 set out_storage
=o
${N}s1
347 if ( ! -d $out_storage ) mkdir
$out_storage
348 mkdir
$out_storage/RSL
349 mv submit_pbs.csh fort
.140 namelist.input namelist.output
* $out_storage
350 mv rsl.
* $out_storage/RSL
351 #mv o${N}s1.*.out o${N}s1.*.err $out_storage
353 mv gts_omb.
* $out_storage # to be used in stage2
354 mv buddy_check check_max_iv jo cost_fn grad_fn statistics
$out_storage
356 echo "outerloop${N}_stage1" > .last_stage
358 if ( "`cat .current_stage`" != "outerloop${N}_stage1" && \
359 "`cat .last_stage`" != "outerloop${N}_stage1" ) then
360 echo "outerloop${N}_stage1 was NOT done, aborted Stage2"
363 endif
# end if RUN_STAGE1
365 #---------------------------------
366 if ( $RUN_STAGE2 == "true" ) then
368 echo "--------------------------------------"
369 echo "| Run outerloop-$N : Stage2-Minimizer |"
370 echo "--------------------------------------"
372 echo "--------------------------------------------"
373 echo "| 2.0 Set up namelist.input for stage2 |"
374 echo "--------------------------------------------"
376 #---------------------------------------
378 # multi_inc=2, # stage2 for minimization
383 # time_step=$TIME_STEP_STAGE2,
385 #------------------------------------------
386 set NL_DX
=`grep -i -E "dx[ \t]*=" orig_namelist.input | sed -e 's/\t/ /g' -e 's/ *//g' -e 's/,//' -e 's/\r//g'| cut -c4-`
387 set NL_DY
=`grep -i -E "dy[ \t]*=" orig_namelist.input | sed -e 's/\t/ /g' -e 's/ *//g' -e 's/,//' -e 's/\r//g'| cut -c4-`
388 set NL_E_WE
=`grep -i -E "e_we[ \t]*=" orig_namelist.input | sed -e 's/\t/ /g' -e 's/ *//g' -e 's/,//' -e 's/\r//g'| cut -c6-`
389 set NL_E_SN
=`grep -i -E "e_sn[ \t]*=" orig_namelist.input | sed -e 's/\t/ /g' -e 's/ *//g' -e 's/,//' -e 's/\r//g'| cut -c6-`
391 set NL_DX
=`echo $NL_DX | sed 's/\.[0-9]*//g'`
392 set NL_DY
=`echo $NL_DY | sed 's/\.[0-9]*//g'`
393 set NL_E_WE
=`echo $NL_E_WE | sed 's/\.[0-9]*//g'`
394 set NL_E_SN
=`echo $NL_E_SN | sed 's/\.[0-9]*//g'`
396 @ NL_DX
= $NL_DX * $THIN_FACTOR[$N]
397 @ NL_DY
= $NL_DY * $THIN_FACTOR[$N]
398 @ NL_E_WE
= ($NL_E_WE - 1) / $THIN_FACTOR[$N] + 1
399 @ NL_E_SN
= ($NL_E_SN - 1) / $THIN_FACTOR[$N] + 1
401 @ RADT_STAGE2
= $NL_DX / 1000
403 set NL_VAR4D_BIN
=`grep -i -E "var4d_bin[ \t]*=" orig_namelist.input | \
404 sed -e 's/\t/ /g' -e 's/ *//g' \
405 -e 's/\.[0-9]*//g' -e 's/,//' \
408 @ TIME_STEP_STAGE2
= ( $NL_DX / 1000 ) * 6
409 set i
=$TIME_STEP_STAGE2
411 @ i
= $NL_VAR4D_BIN % $TIME_STEP_STAGE2
416 if ( $OS == "Darwin" ) then
417 sed -e '/[Mm][Uu][Ll][Tt][Ii]_[Ii][Nn][Cc]/d' \
418 -e '/&[Ww][Rr][Ff][Vv][Aa][Rr]1$/ a\ \
420 -e "/[Dd][Xx][ \t]*=/ c\ \
422 -e "/[Dd][Yy][ \t]*=/ c\ \
424 -e "/[Ee]_[Ww][Ee][ \t]*=/ c\ \
426 -e "/[Ee]_[Ss][Nn][ \t]*=/ c\ \
428 -e "/[Tt][Ii][Mm][Ee]_[Ss][Tt][Ee][Pp][ \t]*=/ c\ \
429 time_step=$TIME_STEP_STAGE2," \
430 -e "/[u][s][e]_[i][n][v][e][r][s][e]_[s][q][u][a][r][e][r][o][o][t][b][ \t]*=/ c\ \
431 use_inverse_squarerootb=$use_vp," \
432 -e "/[u][s][e]_[i][n][t][e][r][p][o][l][a][t][e]_[c][v][t][ \t]*=/ c\ \
433 use_interpolate_cvt=$use_cvt," \
434 orig_namelist.input
> o
${N}s2_namelist.input
436 sed -e '/[Mm][Uu][Ll][Tt][Ii]_[Ii][Nn][Cc]/d' \
437 -e '/&[Ww][Rr][Ff][Vv][Aa][Rr]1$/ a\multi_inc=2,' \
438 -e "/[Dd][Xx][ \t]*=/ c\dx=${NL_DX}.0," \
439 -e "/[Dd][Yy][ \t]*=/ c\dy=${NL_DY}.0," \
440 -e "/[Ee]_[Ww][Ee][ \t]*=/ c\e_we=$NL_E_WE," \
441 -e "/[Ee]_[Ss][Nn][ \t]*=/ c\e_sn=$NL_E_SN," \
442 -e "/[Tt][Ii][Mm][Ee]_[Ss][Tt][Ee][Pp][ \t]*=/ c\time_step=$TIME_STEP_STAGE2," \
443 -e "/[u][s][e]_[i][n][v][e][r][s][e]_[s][q][u][a][r][e][r][o][o][t][b][ \t]*=/ c\use_inverse_squarerootb=$use_vp," \
444 -e "/[u][s][e]_[i][n][t][e][r][p][o][l][a][t][e]_[c][v][t][ \t]*=/ c\use_interpolate_cvt=$use_cvt," \
445 orig_namelist.input
> o
${N}s2_namelist.input
448 if ( $N > 1 ) then # only do this step from outer loop 2
452 if ( $use_vp == true ||
$use_cvt == true
) then
453 echo "--------------------------------------------"
454 echo "| 2.1 Scatter the global cvt or vp to PEs |"
455 echo "--------------------------------------------"
457 ln -sf .
/o
${NM1}s
3/vp_output.global_hires .
458 if ( ! -e vp_output.global_hires
) then
459 echo "vp_output.global_hires is not found"
463 #-------------------------------------------
464 if ( $JOB == 'LSF' ) then
465 if ( -e submit_lsf.csh
) rm -f submit_lsf.csh
466 cat > submit_lsf.csh
<<EOF
469 ## LSF batch script to run an MPI application
471 #BSUB -P $PROJID # project code
472 #BSUB -W 00:05 # wall-clock time (hrs:mins)
473 #BSUB -n $NPROCS[$N] # number of tasks in job
474 #BSUB -R "span[ptile=16]" # run 16 MPI tasks per node
475 #BSUB -J o${N}s2_split # job name
476 #BSUB -o o${N}s2_split.%J.out # output file name in which %J is replaced by the job ID
477 #BSUB -e o${N}s2_split.%J.err # error file name in which %J is replaced by the job ID
478 #BSUB -q $QUEUE # queue
481 mpirun.lsf ./da_vp_split.exe
483 bsub
-K < submit_lsf.csh
485 else #if ( $JOB == 'PBS' )
486 if ( -e submit_pbs.csh
) rm -f submit_pbs.csh
487 cat > submit_pbs.csh
<<EOF
490 ### PBS batch script to run an MPI application
493 #PBS -l walltime=00:05:00
494 #PBS -l select=16:ncpus=36:mpiprocs=36:mem=110G
495 #PBS -N o${N}s2_split
500 mpirun ./da_vp_split.exe -cloud_cv_options 3 -use_cv_w 1
502 set jobid
= `qsub submit_pbs.csh`
505 # $RUN_CMD $NPROCS[$N] ${PWD}/da_vp_split.exe < /dev/null
507 #---------------------------------------------
508 endif
# end if ( $use_vp == true || $use_cvt == true )
513 echo "sleep 20" >> log
514 if ( "`qstat | grep -o -m 1 $jobid`" != $jobid ) then # if job finish
515 if ( $use_vp == true ||
$use_cvt == true
) then
516 foreach f
( vp_input
.0* )
518 echo "$f NOT exists" > FAIL
532 if ( $THIN_FACTOR[$N] > 1 ) then
533 echo "--------------------------------------------"
534 echo "| 2.2 Thin high-res guess to low-res |"
535 echo "--------------------------------------------"
537 .
/da_thin.exe
-i o
${N}s1_fg \
539 -thin $THIN_FACTOR[$N] \
540 >& o
${N}s2_thin_fg.log
541 if ( ! -e o
${N}s2_fg
) then
542 echo "thinning fg failed" > FAIL
546 if ( $VAR4D == true
) then # 2nd level fg only for 4DVAR
547 .
/da_thin.exe
-i o
${N}s1_fg02 \
549 -thin $THIN_FACTOR[$N] \
550 >>& o
${N}s2_thin_fg02.log
551 if ( ! -e o
${N}s2_fg02
) then
552 echo "thinning fg02 failed" > FAIL
557 cp o
${N}s1_fg o
${N}s2_fg
558 if ( $VAR4D == true
) cp o
${N}s1_fg02 o
${N}s2_fg02
561 if ( $VAR4D == true
) then
562 echo "--------------------------------------------"
563 echo "| 2.3 Generating boundary file for stage2 |"
564 echo "--------------------------------------------"
565 da_bdy.exe
-fg o
${N}s2_fg \
567 -bdy orig_wrfbdy_d01 \
568 -o o
${N}s2_wrfbdy_d01 \
570 if ( ! -e o
${N}s2_wrfbdy_d01
) then
571 echo "generating bdy file for outerloop$N stage2 failed" > FAIL
576 echo "--------------------------------------------"
577 echo "| 2.4 Run WRF-VAR minimization at low-res |"
578 echo "--------------------------------------------"
580 if ( -e namelist.input
) rm -f namelist.input
581 ln -sf o
${N}s2_namelist.input namelist.input
582 ln -sf .
/o
${N}s
1/gts_omb.
* .
584 if ( $VAR4D == true
) then
585 ln -sf o
${N}s2_fg02 fg02
586 ln -sf o
${N}s2_fg wrfinput_d01
587 ln -sf o
${N}s2_wrfbdy_d01 wrfbdy_d01
590 echo "outerloop${N}_stage2" > .current_stage
591 echo "outerloop${N}_stage2" > .last_stage
593 #---------------------------------
594 if ( $JOB == 'LSF' ) then
595 if ( -e submit_lsf.csh
) rm -f submit_lsf.csh
596 cat > submit_lsf.csh
<<EOF
599 ### LSF batch script to run an MPI application
601 #BSUB -P $PROJID # project code
602 #BSUB -W $minimizeclocktime # wall-clock time (hrs:mins)
603 #BSUB -n $NPROCS[$N] # number of tasks in job
604 #BSUB -R "span[ptile=16]" # run 16 MPI tasks per node
605 #BSUB -J o${N}s2 # job name
606 #BSUB -o o${N}s2.%J.out # output file name in which %J is replaced by the job ID
607 #BSUB -e o${N}s2.%J.err # error file name in which %J is replaced by the job ID
608 #BSUB -q $QUEUE # queue
611 mpirun.lsf ./da_wrfvar.exe
613 bsub
-K < submit_lsf.csh
615 else #if ( $JOB == 'PBS' )
616 if ( -e submit_pbs.csh
) rm -f submit_pbs.csh
617 cat > submit_pbs.csh
<<EOF
620 ### PBS batch script to run an MPI application
623 #PBS -l walltime=$minimizeclocktime
624 #PBS -l select=16:ncpus=36:mpiprocs=36:mem=110G
630 mpirun ./da_wrfvar.exe
632 set jobid
= `qsub submit_pbs.csh`
635 # $RUN_CMD $NPROCS[$N] ${PWD}/da_wrfvar.exe < /dev/null
637 #------------------------------------
642 echo "sleep 30" >> log
643 if ( "`qstat | grep -o -m 1 $jobid`" != $jobid ) then # if job finish
644 if ( "`tail rsl.out.0000 | grep -o -m 1 successfully`" != "successfully" ) then
645 echo "da_wrfvar stage2_$N failed " > FAIL
656 echo "------------------------------"
657 echo "| 2.5 Save and clean output |"
658 echo "------------------------------"
660 #if ( $use_vp == true ) ncl nc_vpglobal.ncl
661 #ncl nc_increment.ncl
663 set out_storage
=o
${N}s2
664 if ( ! -d $out_storage ) mkdir
$out_storage; mkdir
$out_storage/RSL
665 rm unpert
* gts_omb.
* gts_omb_oma_
*.
* radar_omb_oma_
*.
* filtered_obs.
* rej_obs
*
666 mv buddy_check check_max_iv qcstat_conv_01
$out_storage
667 mv rsl.
* $out_storage/RSL
668 mv cost_fn grad_fn jo fort.
* statistics
$out_storage
669 mv wrfvar_output namelist.output
* $out_storage
670 mv gts_omb_oma_
* radar_omb_oma_
* filtered_obs_
* submit_pbs.csh
$out_storage
671 mv analysis_increments
* $out_storage
672 if ( $use_vp == true ||
$use_cvt == true
) then
673 if ( $N > 1 ) rm vp_output.global_hires
674 mv vp_input.
* vv_input.
* vv_after
* vp_output.global
* $out_storage
677 endif
# end if RUN_STAGE2
679 #-----------------------------------
680 if ( $RUN_STAGE3 == "true" ) then
682 echo "--------------------------------------"
683 echo "| Run outerloop${N} : Stage3-Regrid |"
684 echo "--------------------------------------"
688 if ( "$VAR4D_LBC" == "t" ||
"$VAR4D_LBC" == "T" ) then
689 # this is not well tested yet. turned it off
690 echo "------------------------------------------------------------"
691 echo "| 3.1 regridding in model space for 2nd time level (fg02) |"
692 echo "------------------------------------------------------------"
693 # only if var4d_lbc=true.
694 # NOTE: interpolate to original resolution in model space
696 .
/da_bilin.exe
-fg_lores o
${N}s2_fg02 \
697 -fg_hires o
${N}s1_fg02 \
699 -ns $THIN_FACTOR[$N] \
700 -o ana02_hires
>& o
${N}s2_bilin_fg02.log
701 if ( ! -e ana02_hires
) then
702 echo "regridding increment failed" > FAIL
707 echo "# Skipped, VAR4D_LBC=$VAR4D_LBC \n"
710 echo "------------------------------------------------------------"
711 echo "| 3.1 regridding in model space for 1st time level (fg) |"
712 echo "------------------------------------------------------------"
713 # wrfvar_output_hires = fg_stage1 + S (wrfvar_output_lores - fg_stage2)
714 #----------------------------------------------------------------------------
715 if ( $THIN_FACTOR[$N] > 1 ) then # regrid to model resolution
716 .
/da_bilin.exe
-fg_lores o
${N}s2_fg \
717 -fg_hires o
${N}s1_fg \
718 -an_lores .
/o
${N}s
2/wrfvar_output \
719 -ns $THIN_FACTOR[$N] \
720 -o wrfvar_output_hires
>& o
${N}s3_da_bilin.log
721 if ( ! -e wrfvar_output_hires
) then
722 echo "regridding increment failed" > FAIL
725 else # if DA res. is same as model res., no need for interpolation
726 cp .
/o
${N}s
2/wrfvar_output wrfvar_output_hires
729 if ( $N < $MAX_OUTERLOOP ) then # no need to do this for the last loop
730 #------------------------------------------------------
731 # interpolate vp to next outer loop's resolution
732 #-------------------------------------------------------------
733 if ( $use_vp == true ||
$use_cvt == true
) then
734 if ( $THIN_FACTOR[$N] != $THIN_FACTOR[$NP1] ) then # only do this if res diff for two loops
735 echo "---------------------------------------------"
736 echo "| 3.2 regridding in control variable space |"
737 echo "---------------------------------------------"
738 if ( $N < $MAX_OUTERLOOP ) then
739 @ ratio
= $THIN_FACTOR[$N] / $THIN_FACTOR[$NP1]
741 @ ratio
= $THIN_FACTOR[$N] # / 1
744 if ( -e vp_output.global
) rm -f vp_output.global
745 ln -sf .
/o
${N}s
2/vp_output.global .
746 .
/da_vp_bilin.exe
-ratio $ratio \
747 -cloud_cv_options 3 \
748 -use_cv_w 1 >& o
${N}s3_vp_bilin.log
749 if ( ! -e vp_output.global_hires
) then
750 echo "vp_output.global_hires is not generated" > FAIL
753 else # if resolution same, no interpolation needed.
754 cp .
/o
${N}s
2/vp_output.global vp_output.global_hires
759 echo "---------------------------------"
760 echo "| 3.3 Save and Clean results |"
761 echo "---------------------------------"
763 set out_storage
=o
${N}s3
764 if ( ! -d $out_storage ) mkdir
$out_storage
766 mv wrfvar_output_hires
$out_storage
769 if ( $use_vp == true ||
$use_cvt == true
) then
770 mv vp_output.global_hires
* $out_storage
774 endif
# $N < $MAX_OUTERLOOP
776 endif
## end if RUN_STAGE3=true
780 end
# End of outerloop
782 rm fg fg02 wrfinput_d01 wrfbdy_d01
784 else ## if NOT multi-resolution incremental 3D/4DVAR, no stop outer loop
785 ###########################################################################
789 if ( $VAR4D == true
) then
790 ln -sf orig_wrfinput_d01 wrfinput_d01
791 ln -sf orig_wrfbdy_d01 wrfbdy_d01
794 if ( $OS == "Darwin" ) then
795 sed -e "/[u][s][e]_[i][n][v][e][r][s][e]_[s][q][u][a][r][e][r][o][o][t][b][ \t]*=/ c\ \
796 use_inverse_squarerootb=$use_vp," \
797 -e "/[u][s][e]_[i][n][t][e][r][p][o][l][a][t][e]_[c][v][t][ \t]*=/ c\ \
798 use_interpolate_cvt=$use_cvt," \
799 orig_namelist.input
> namelist.input
801 sed -e "/[u][s][e]_[i][n][v][e][r][s][e]_[s][q][u][a][r][e][r][o][o][t][b][ \t]*=/ c\use_inverse_squarerootb=$use_vp," \
802 -e "/[u][s][e]_[i][n][t][e][r][p][o][l][a][t][e]_[c][v][t][ \t]*=/ c\use_interpolate_cvt=$use_cvt," \
803 orig_namelist.input
> namelist.input
806 #---------------------------------
807 if ( $JOB == 'LSF' ) then
808 if ( -e submit_lsf.csh
) rm -f submit_lsf.csh
809 cat > submit_lsf.csh
<<EOF
812 ### LSF batch script to run an MPI application
814 #BSUB -P $PROJID # project code
815 #BSUB -W 5:00 # ban 00:20 # wall-clock time (hrs:mins)
816 #BSUB -n 1024 # number of tasks in job
817 #BSUB -R "span[ptile=16]" # run 16 MPI tasks per node
818 #BSUB -J wrfvar # job name
819 #BSUB -o wrfvar.%J.out # output file name in which %J is replaced by the job ID
820 #BSUB -e wrfvar.%J.err # error file name in which %J is replaced by the job ID
821 #BSUB -q premium # regular # queue
824 mpirun.lsf ./da_wrfvar.exe
826 bsub
-K < submit_lsf.csh
828 else #if ( $JOB == 'PBS' )
829 if ( -e submit_pbs.csh
) rm -f submit_pbs.csh
830 cat > submit_pbs.csh
<<EOF
833 ### PBS batch script to run an MPI application
836 #PBS -l walltime=5:00:00
837 #PBS -l select=16:ncpus=36:mpiprocs=36:mem=110G
843 mpirun ./da_wrfvar.exe
849 # $RUN_CMD $NPROCS[$N] ${PWD}/da_wrfvar.exe < /dev/null
851 #-----------------------------------
853 ln -sf $MULTI_INC_TOOLS/nc_increment.ncl .
856 set out_storage
=$WORK_DIR
857 if ( ! -d $out_storage ) mkdir
$out_storage; mkdir
$out_storage/RSL
858 rm unpert
* gts_omb_oma_
*.
* filtered_obs.
*
859 mv rsl.
* rej_obs
* qcstat_conv_01
$out_storage/RSL