-
Notifications
You must be signed in to change notification settings - Fork 29
/
module_enkf.sh
executable file
·127 lines (110 loc) · 3.8 KB
/
module_enkf.sh
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
#!/bin/bash
. $CONFIG_FILE
rundir=$WORK_DIR/run/$DATE/enkf
if [[ ! -d $rundir ]]; then mkdir -p $rundir; echo waiting > $rundir/stat; fi
cd $rundir
if [[ `cat stat` == "complete" ]]; then exit; fi
wait_for_module ../../$PREVDATE/wrf_ens ../obsproc
#Run EnKF
echo running > stat
domlist=`seq 1 $MAX_DOM`
for n in $domlist; do
dm=d`expr $n + 100 |cut -c2-`
if [[ ! -d $dm ]]; then mkdir -p $dm; fi
if [ -f $dm/${DATE}.finish_flag ]; then continue; fi
cd $dm
#link priors
for NE in `seq 1 $NUM_ENS`; do
id=`expr $NE + 1000 |cut -c2-`
ln -fs ../../../../fc/$PREVDATE/wrfinput_${dm}_`wrf_time_string $DATE`_$id fort.`expr 80010 + $NE`
cp -L fort.`expr 80010 + $NE` fort.`expr 90010 + $NE` >> link.log 2>&1 &
done
wait
cp -L fort.80011 fort.`expr 80011 + $NUM_ENS`
cp -L fort.80011 fort.`expr 90011 + $NUM_ENS`
ln -fs $ENKF_DIR/enkf.mpi .
ln -fs $WRF_DIR/run/LANDUSE.TBL .
#link observations
#LITTLE_R format from obsproc
ln -fs $WORK_DIR/obs/$DATE/obs_gts_`wrf_time_string $DATE`.3DVAR obs_3dvar_${DATE}00
#airborne radar superobs
ln -fs $DATA_DIR/so/${DATE}_all.so_ass airborne_${DATE}_so
#link truth for OSSE
# ln -fs $WORK/data/DYNAMO/3km_run_9km/wrfout_d01_`wrf_time_string $DATE` fort.80010
$SCRIPT_DIR/namelist_enkf.sh $n > namelist.enkf
cd ..
done
#run enkf.mpi
echo " Running EnKF..."
tid=0
nn=$((($enkf_ntasks+$enkf_ppn-$enkf_ntasks%$enkf_ppn)/$enkf_ppn))
nt=$(($total_ntasks/$HOSTPPN/$nn))
for n in $domlist; do
dm=d`expr $n + 100 |cut -c2-`
if [ -f $dm/${DATE}.finish_flag ]; then continue; fi
cd $dm
$SCRIPT_DIR/job_submit.sh $enkf_ntasks $((tid*$enkf_ntasks)) $enkf_ppn ./enkf.mpi >& enkf.log &
tid=$((tid+1))
if [[ $tid == $nt ]]; then
tid=0
wait
fi
cd ..
done
wait
#Check output
for n in $domlist; do
dm=d`expr $n + 100 |cut -c2-`
cd $dm
watch_log enkf.log Successful 5 $rundir
#Replace mean
#1. replacing mean with 4DVar analysis (recentering) if running hybrid DA
if $RUN_4DVAR; then
wait_for_module ../../4dvar ../../wrf_window
if [[ ! -d replace_mean ]]; then mkdir -p replace_mean; fi
cd replace_mean
echo " Replacing ens mean with 4DVar analysis for domain $dm"
for NE in `seq 1 $((NUM_ENS+1))`; do
mv ../fort.`expr 90010 + $NE` fort.`expr 80010 + $NE`
cp fort.`expr 80010 + $NE` fort.`expr 90010 + $NE`
done
ln -fs $WORK_DIR/fc/$DATE/wrfinput_${dm}_`wrf_time_string $DATE` fort.70010
ln -fs $ENKF_DIR/replace_mean.exe .
./replace_mean.exe $NUM_ENS >& replace_mean.log
watch_log replace_mean.log Successful 1 $rundir
for NE in `seq 1 $((NUM_ENS+1))`; do
mv fort.`expr 90010 + $NE` ../
done
cd ..
fi
#2. replacing mean with first guess (GFS/FNL) reanalysis
if $REPLACE_MEAN; then
if [[ ! -d replace_mean ]]; then mkdir -p replace_mean; fi
cd replace_mean
echo " Replacing ens mean with $REPLACE_MEAN_WITH for domain $dm"
for NE in `seq 1 $((NUM_ENS+1))`; do
mv ../fort.`expr 90010 + $NE` fort.`expr 80010 + $NE`
cp fort.`expr 80010 + $NE` fort.`expr 90010 + $NE`
done
if [[ $REPLACE_MEAN_WITH == "forecast" ]]; then
ln -fs $WORK_DIR/fc/$DATE/wrfinput_$dm fort.70010
elif [[ $REPLACE_MEAN_WITH == "gfs" ]]; then
ln -fs $WORK_DIR/rc/$DATE/wrfinput_$dm fort.70010
fi
ln -fs $ENKF_DIR/replace_mean.exe .
./replace_mean.exe $NUM_ENS >& replace_mean.log
watch_log replace_mean.log Successful 1 $rundir
for NE in `seq 1 $((NUM_ENS+1))`; do
mv fort.`expr 90010 + $NE` ../
done
cd ..
fi
for NE in `seq 1 $NUM_ENS`; do
id=`expr $NE + 1000 |cut -c2-`
mv fort.`expr 90010 + $NE` $WORK_DIR/fc/$DATE/wrfinput_${dm}_$id
ln -fs ../../../../fc/$DATE/wrfinput_${dm}_$id fort.`expr 90010 + $NE`
done
cp fort.`expr 90011 + $NUM_ENS` $WORK_DIR/fc/$DATE/wrfinput_${dm}_mean
cd ..
done
echo complete > stat