forked from jswhit/replay_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.csh
executable file
·160 lines (136 loc) · 4.76 KB
/
main.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# main driver script
# single resolution hybrid using jacobian in the EnKF
# allow this script to submit other scripts on WCOSS
unsetenv LSB_SUB_RES_REQ
source $datapath/fg_only.csh # define fg_only variable (true for cold start).
echo "nodes = $NODES"
setenv startupenv "${datapath}/analdate.csh"
source $startupenv
#------------------------------------------------------------------------
mkdir -p $datapath
echo "BaseDir: ${basedir}"
echo "DataPath: ${datapath}"
############################################################################
# Main Program
env
echo "starting the cycle"
# substringing to get yr, mon, day, hr info
setenv yr `echo $analdate | cut -c1-4`
setenv mon `echo $analdate | cut -c5-6`
setenv day `echo $analdate | cut -c7-8`
setenv hr `echo $analdate | cut -c9-10`
setenv ANALHR $hr
# set environment analdate
setenv datapath2 "${datapath}/${analdate}/"
# current analysis time.
setenv analdate $analdate
# previous analysis time.
set FHOFFSET=`expr $ANALINC \/ 2`
setenv analdatem1 `${incdate} $analdate -$ANALINC`
# next analysis time.
setenv analdatep1 `${incdate} $analdate $ANALINC`
# beginning of current assimilation window
setenv analdatem3 `${incdate} $analdate -$FHOFFSET`
# beginning of next assimilation window
setenv analdatep1m3 `${incdate} $analdate $FHOFFSET`
setenv hrp1 `echo $analdatep1 | cut -c9-10`
setenv hrm1 `echo $analdatem1 | cut -c9-10`
setenv hr `echo $analdate | cut -c9-10`
setenv datapathp1 "${datapath}/${analdatep1}/"
setenv datapathm1 "${datapath}/${analdatem1}/"
mkdir -p $datapathp1
setenv CDATE $analdate
date
echo "analdate minus 1: $analdatem1"
echo "analdate: $analdate"
echo "analdate plus 1: $analdatep1"
# make log dir for analdate
setenv current_logdir "${datapath2}/logs"
echo "Current LogDir: ${current_logdir}"
mkdir -p ${current_logdir}
setenv PREINP "${RUN}.t${hr}z."
setenv PREINP1 "${RUN}.t${hrp1}z."
setenv PREINPm1 "${RUN}.t${hrm1}z."
if ($fg_only == 'false') then
if ($replay_run_observer == "true") then
setenv charnanal 'control'
setenv charnanal2 'control'
setenv lobsdiag_forenkf '.false.'
setenv skipcat "false"
echo "$analdate run gsi observer with `printenv | grep charnanal` `date`"
csh ${scriptsdir}/run_gsiobserver.csh >&! ${current_logdir}/run_gsi_observer.out
# once observer has completed, check log files.
set hybrid_done=`cat ${current_logdir}/run_gsi_observer.log`
if ($hybrid_done == 'yes') then
echo "$analdate gsi observer completed successfully `date`"
else
echo "$analdate gsi observer did not complete successfully, exiting `date`"
exit 1
endif
endif
endif
echo "$analdate run high-res control first guess `date`"
csh ${scriptsdir}/run_fg_control.csh >&! ${current_logdir}/run_fg_control.out
set control_done=`cat ${current_logdir}/run_fg_control.log`
if ($control_done == 'yes') then
echo "$analdate high-res control first-guess completed successfully `date`"
else
echo "$analdate high-res control did not complete successfully, exiting `date`"
exit 1
endif
if ($fg_only == 'false') then
# cleanup
if ($do_cleanup == 'true') then
csh ${scriptsdir}/clean.csh >&! ${current_logdir}/clean.out
endif # do_cleanup = true
cd $homedir
if ( $save_hpss == 'true' ) then
if ( ! -z $SLURM_JOB_ID ) then
cat ${machine}_preamble_hpss_slurm hpss.sh > job_hpss.sh
else
cat ${machine}_preamble_hpss hpss.sh > job_hpss.sh
endif
if ( ! -z $SLURM_JOB_ID ) then
#sbatch --export=ALL job_hpss.sh
sbatch --export=machine=${machine},analdate=${analdate},datapath2=${datapath2},hsidir=${hsidir} job_hpss.sh
else if ( $machine == 'wcoss' ) then
bsub -env "all" < job_hpss.sh
else if ( $machine == 'gaea' ) then
msub -V job_hpss.sh
else
qsub -V job_hpss.sh
endif
endif
endif # skip to here if fg_only = true
echo "$analdate all done"
# next analdate: increment by $ANALINC
setenv analdate `${incdate} $analdate $ANALINC`
echo "setenv analdate ${analdate}" >! $startupenv
echo "setenv analdate_end ${analdate_end}" >> $startupenv
echo "setenv fg_only false" >! $datapath/fg_only.csh
cd $homedir
echo "$analdate all done `date`"
if ( ${analdate} <= ${analdate_end} && ${resubmit} == 'true') then
echo "current time is $analdate"
if ($resubmit == "true") then
echo "resubmit script"
echo "machine = $machine"
if ( $?SLURM_JOB_ID ) then
cat ${machine}_preamble_slurm config.sh >! job.sh
else
cat ${machine}_preamble config.sh >! job.sh
endif
if ( $?SLURM_JOB_ID ) then
sbatch --export=ALL job.sh
else if ($machine == 'wcoss') then
bsub < job.sh
else if ($machine == 'gaea') then
msub job.sh
else if ($machine == 'cori') then
sbatch job.sh
else
qsub job.sh
endif
endif
endif
exit 0