-
Notifications
You must be signed in to change notification settings - Fork 145
/
init_ensemble_var.csh
executable file
·131 lines (97 loc) · 4.09 KB
/
init_ensemble_var.csh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/csh
#
# DART software - Copyright UCAR. This open source software is provided
# by UCAR, "as is", without charge, subject to all terms of use at
# http://www.image.ucar.edu/DAReS/DART/DART_download
# init_ensemble_var.csh - script that creates perturbed initial
# conditions from the WRF-VAR system.
# (perts are drawn from the perturbation bank)
#
# created Nov. 2007, Ryan Torn NCAR/MMM
# modified by G. Romine 2011-2018
set initial_date = ${1}
set paramfile = `readlink -f ${2}` # Get absolute path for param.csh from command line arg
source $paramfile
cd ${RUN_DIR}
# KRF Generate the i/o lists in rundir automatically when initializing the ensemble
set num_ens = ${NUM_ENS}
set input_file_name = "input_list_d01.txt"
set input_file_path = "./advance_temp"
set output_file_name = "output_list_d01.txt"
set n = 1
if ( -e $input_file_name ) rm $input_file_name
if ( -e $output_file_name ) rm $output_file_name
while ($n <= $num_ens)
set ensstring = `printf %04d $n`
set in_file_name = ${input_file_path}${n}"/wrfinput_d01"
set out_file_name = "filter_restart_d01."$ensstring
echo $in_file_name >> $input_file_name
echo $out_file_name >> $output_file_name
@ n++
end
###
set gdate = (`echo $initial_date 0h -g | ${DART_DIR}/models/wrf/work/advance_time`)
set gdatef = (`echo $initial_date ${ASSIM_INT_HOURS}h -g | ${DART_DIR}/models/wrf/work/advance_time`)
set wdate = `echo $initial_date 0h -w | ${DART_DIR}/models/wrf/work/advance_time`
set yyyy = `echo $initial_date | cut -b1-4`
set mm = `echo $initial_date | cut -b5-6`
set dd = `echo $initial_date | cut -b7-8`
set hh = `echo $initial_date | cut -b9-10`
${COPY} ${TEMPLATE_DIR}/namelist.input.meso namelist.input
${COPY} ${TEMPLATE_DIR}/input.nml.template input.nml
${REMOVE} ${RUN_DIR}/WRF
${LINK} ${OUTPUT_DIR}/${initial_date} WRF
set n = 1
while ( $n <= $NUM_ENS )
echo " QUEUEING ENSEMBLE MEMBER $n at `date`"
mkdir -p ${RUN_DIR}/advance_temp${n}
# TJH why does the run_dir/*/input.nml come from the template_dir and not the rundir?
# TJH furthermore, template_dir/input.nml.template and rundir/input.nml are identical. SIMPLIFY.
${LINK} ${RUN_DIR}/WRF_RUN/* ${RUN_DIR}/advance_temp${n}/.
${LINK} ${TEMPLATE_DIR}/input.nml.template ${RUN_DIR}/advance_temp${n}/input.nml
${COPY} ${OUTPUT_DIR}/${initial_date}/wrfinput_d01_${gdate[1]}_${gdate[2]}_mean \
${RUN_DIR}/advance_temp${n}/wrfvar_output.nc
sleep 3
${COPY} ${RUN_DIR}/add_bank_perts.ncl ${RUN_DIR}/advance_temp${n}/.
set cmd3 = "ncl 'MEM_NUM=${n}' 'PERTS_DIR="\""${PERTS_DIR}"\""' ${RUN_DIR}/advance_temp${n}/add_bank_perts.ncl"
${REMOVE} ${RUN_DIR}/advance_temp${n}/nclrun3.out
cat >! ${RUN_DIR}/advance_temp${n}/nclrun3.out << EOF
$cmd3
EOF
echo $cmd3 >! ${RUN_DIR}/advance_temp${n}/nclrun3.out.tim # TJH replace cat above
cat >! ${RUN_DIR}/rt_assim_init_${n}.csh << EOF
#!/bin/csh
#=================================================================
#PBS -N first_advance_${n}
#PBS -j oe
#PBS -A ${COMPUTER_CHARGE_ACCOUNT}
#PBS -l walltime=${ADVANCE_TIME}
#PBS -q ${ADVANCE_QUEUE}
#PBS -m ae
#PBS -M ${EMAIL}
#PBS -k eod
#PBS -l select=${ADVANCE_NODES}:ncpus=${ADVANCE_PROCS}:mpiprocs=${ADVANCE_MPI}
#=================================================================
echo "rt_assim_init_${n}.csh is running in `pwd`"
cd ${RUN_DIR}/advance_temp${n}
if (-e wrfvar_output.nc) then
echo "Running nclrun3.out to create wrfinput_d01 for member $n at `date`"
chmod +x nclrun3.out
./nclrun3.out >& add_perts.out
if ( -z add_perts.err ) then
echo "Perts added to member ${n}"
else
echo "ERROR! Non-zero status returned from add_bank_perts.ncl. Check ${RUN_DIR}/advance_temp${n}/add_perts.err."
cat add_perts.err
exit
endif
${MOVE} wrfvar_output.nc wrfinput_d01
endif
cd $RUN_DIR
echo "Running first_advance.csh for member $n at `date`"
${SHELL_SCRIPTS_DIR}/first_advance.csh $initial_date $n $paramfile
EOF
qsub ${RUN_DIR}/rt_assim_init_${n}.csh
@ n++
end
exit 0