forked from jswhit/da_scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompute_ensmean_fcst.sh
executable file
·106 lines (96 loc) · 4.03 KB
/
compute_ensmean_fcst.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
#!/bin/sh
source $MODULESHOME/init/sh
if [ $machine == 'gaea' ]; then
nces=/ncrc/home2/Jeffrey.S.Whitaker/anaconda2/bin/nces
else
module load nco
nces=`which nces`
fi
module list
export OMP_STACKSIZE=1024M
cd ${datapath2}
fh=${FHMIN}
while [ $fh -le $FHMAX ]; do
charfhr="fhr`printf %02i $fh`"
if [ $cleanup_ensmean == 'true' ] || ([ $cleanup_ensmean == 'false' ] && [ ! -s ${datapath}/${analdate}/bfg_${analdate}_${charfhr}_ensmean ]); then
echo "running ${execdir}/getsfcensmeanp.x ${datapath2}/ bfg_${analdate}_${charfhr}_ensmean bfg_${analdate}_${charfhr} ${nanals}"
/bin/rm -f ${datapath2}/bfg_${analdate}_${charfhr}_ensmean
export PGM="${execdir}/getsfcensmeanp.x ${datapath2}/ bfg_${analdate}_${charfhr}_ensmean bfg_${analdate}_${charfhr} ${nanals}"
${enkfscripts}/runmpi
fi
if [ $cleanup_ensmean == 'true' ] || ([ $cleanup_ensmean == 'false' ] && [ ! -s ${datapath}/${analdate}/sfg_${analdate}_${charfhr}_ensmean ]); then
/bin/rm -f ${datapath2}/sfg_${analdate}_${charfhr}_ensmean
echo "running ${execdir}/getsigensmeanp_smooth.x ${datapath2}/ sfg_${analdate}_${charfhr}_ensmean sfg_${analdate}_${charfhr} ${nanals} sfg_${analdate}_${charfhr}_enssprd"
if [ $fh -eq $ANALINC ]; then # just save spread at middle of window
export PGM="${execdir}/getsigensmeanp_smooth.x ${datapath2}/ sfg_${analdate}_${charfhr}_ensmean sfg_${analdate}_${charfhr} ${nanals} sfg_${analdate}_${charfhr}_enssprd"
else
export PGM="${execdir}/getsigensmeanp_smooth.x ${datapath2}/ sfg_${analdate}_${charfhr}_ensmean sfg_${analdate}_${charfhr} ${nanals}"
fi
${enkfscripts}/runmpi
fi
fh=$((fh+FHOUT))
done
# now compute ensemble mean restart files (only at 00UTC).
if [ $ensmean_restart == 'true' ] && [ $fg_only == 'false' ] && [ $hr == '06' ]; then
if [ $cleanup_ensmean == 'true' ] || ([ $cleanup_ensmean == 'false' ] && [ ! -s ${datapath2}/ensmean/INPUT/fv_core.res.tile1.nc ]); then
echo "compute ensemble mean restart files `date`"
export nprocs=1
export mpitaskspernode=1
export OMP_NUM_THREADS=$corespernode
pathout=${datapath2}/ensmean/INPUT
mkdir -p $pathout
ncount=1
tiles="tile1 tile2 tile3 tile4 tile5 tile6"
for tile in $tiles; do
files="fv_core.res.${tile}.nc fv_tracer.res.${tile}.nc fv_srf_wnd.res.${tile}.nc sfc_data.${tile}.nc phy_data.${tile}.nc"
for file in $files; do
export PGM="${nces} -O `ls -1 ${datapath2}/mem*/INPUT/${filename}` ${pathout}/${filename}"
echo "computing ens mean for $filename"
#${enkfscripts}/runmpi &
$PGM &
if [ $ncount == $NODES ]; then
echo "waiting for backgrounded jobs to finish..."
wait
ncount=1
else
ncount=$((ncount+1))
fi
done
done
wait
/bin/rm -f ${datapath2}/hostfile_nces*
/bin/cp -f ${datapath2}/mem001/INPUT/fv_core.res.nc ${pathout}
echo "done computing ensemble mean restart files `date`"
fi
fi
if [ $controlfcst == 'false' ] && [ $cleanup_ensmean == 'true' ] && [ ! -z $copy_history_files ]; then
echo "compute ensemble mean history files `date`"
export nprocs=1
export mpitaskspernode=1
export OMP_NUM_THREADS=$corespernode
pathout=${datapath2}/ensmean
mkdir -p $pathout
ncount=1
tiles="tile1 tile2 tile3 tile4 tile5 tile6"
for tile in $tiles; do
filename="fv3_historyp.${tile}.nc"
export PGM="${nces} -4 -L 5 -O `ls -1 ${datapath2}/mem*/${filename}` ${pathout}/${filename}"
echo "computing ens mean for $filename"
#${enkfscripts}/runmpi &
$PGM &
if [ $ncount == $NODES ]; then
echo "waiting for backgrounded jobs to finish..."
wait
ncount=1
else
ncount=$((ncount+1))
fi
done
wait
/bin/rm -f ${datapath2}/hostfile_nces*
echo "done computing ensemble mean history files `date`"
# interpolate to 1x1 grid
cd ${enkfscripts}
$python ncinterp.py ${datapath2}/ensmean ${datapath2}/fv3ensmean_historyp_${analdatem1}_latlon.nc $RES $analdatem1
fi
echo "all done `date`"