-
Notifications
You must be signed in to change notification settings - Fork 180
/
Copy pathexgfs_atmos_gempak_meta.sh
executable file
·138 lines (112 loc) · 2.88 KB
/
exgfs_atmos_gempak_meta.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
127
128
129
130
131
132
133
134
135
136
137
138
#! /usr/bin/env bash
source "$HOMEgfs/ush/preamble.sh"
cd $DATA
GEMGRD1=${RUN}_${PDY}${cyc}f
#find out what fcst hr to start processing
fhr=$fhend
export numproc=23
while [ $fhr -ge $fhbeg ] ; do
fhr=$(printf "%03d" $fhr)
ls -l $COMIN/$GEMGRD1${fhr}
err1=$?
if [ $err1 -eq 0 -o $fhr -eq $fhbeg ] ; then
break
fi
fhr=$(expr $fhr - $fhinc)
done
maxtries=180
first_time=0
do_all=0
#loop through and process needed forecast hours
while [ $fhr -le $fhend ]
do
#
# First check to see if this is a rerun. If so make all Meta files
if [ $fhr -gt 126 -a $first_time -eq 0 ] ; then
do_all=1
fi
first_time=1
if [ $fhr -eq 120 ] ; then
fhr=126
fi
icnt=1
while [ $icnt -lt 1000 ]
do
ls -l $COMIN/$GEMGRD1${fhr}
err1=$?
if [ $err1 -eq 0 ] ; then
break
else
sleep 20
let "icnt= icnt + 1"
fi
if [ $icnt -ge $maxtries ]
then
echo "ABORTING after 1 hour of waiting for gempak grid F$fhr to end."
export err=7 ; err_chk
exit $err
fi
done
export fhr
########################################################
# Create a script to be poe'd
#
# Note: The number of scripts to be run MUST match the number
# of total_tasks set in the ecf script, or the job will fail.
#
# if [ -f $DATA/poescript ]; then
rm $DATA/poescript
# fi
fhr=$(printf "%02d" $fhr)
if [ $do_all -eq 1 ] ; then
do_all=0
awk '{print $1}' $FIXgempak/gfs_meta > $DATA/tmpscript
else
#
# Do not try to grep out 12, it will grab the 12 from 126.
# This will work as long as we don't need 12 fhr metafiles
#
if [ $fhr -ne 12 ] ; then
grep $fhr $FIXgempak/gfs_meta |awk -F" [0-9]" '{print $1}' > $DATA/tmpscript
fi
fi
for script in $(cat $DATA/tmpscript)
do
eval "echo $script" >> $DATA/poescript
done
num=$(cat $DATA/poescript |wc -l)
while [ $num -lt $numproc ] ; do
echo "hostname" >>poescript
num=$(expr $num + 1)
done
chmod 775 $DATA/poescript
cat $DATA/poescript
export MP_PGMMODEL=mpmd
export MP_CMDFILE=$DATA/poescript
# If this is the final fcst hour, alert the
# file to all centers.
#
if [ 10#$fhr -ge $fhend ] ; then
export DBN_ALERT_TYPE=GFS_METAFILE_LAST
fi
export fend=$fhr
sleep 20
ntasks=${NTASKS_META:-$(cat $DATA/poescript | wc -l)}
ptile=${PTILE_META:-4}
threads=${NTHREADS_META:-1}
export OMP_NUM_THREADS=$threads
APRUN="mpiexec -l -n $ntasks -ppn $ntasks --cpu-bind verbose,core cfp"
APRUN_METACFP=${APRUN_METACFP:-$APRUN}
APRUNCFP=$(eval echo $APRUN_METACFP)
$APRUNCFP $DATA/poescript
export err=$?; err_chk
fhr=$(printf "%03d" $fhr)
if [ $fhr -eq 126 ] ; then
let fhr=fhr+6
else
let fhr=fhr+fhinc
fi
done
#####################################################################
exit
#