-
Notifications
You must be signed in to change notification settings - Fork 0
/
subXs2sfcsts_check_and_run.csh
executable file
·90 lines (78 loc) · 3.14 KB
/
subXs2sfcsts_check_and_run.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
#!/bin/csh
#
#home/mathomp4/S2SScript/
set SLEEP_AMOUNT=3600
set CURRDATE=`(date +%Y-%m-%d)`
set CURR_YEAR=`(date +%Y)`
set CURR_MONTH=`(date +%m)`
set CURR_DAY=`(date +%d)`
set FORECAST_DATE_M1=`(date -d 'yesterday' +%Y-%m-%d)`
set FORECAST_DATE_MONWORD_M1=`(date -d 'yesterday' +%d-%b)`
set FORECAST_YM1=`(date -d 'yesterday' +%Y)`
set FORECAST_MM1=`(date -d 'yesterday' +%m)`
set FORECAST_DM1=`(date -d 'yesterday' +%d)`
set FORECAST_DATE_M2=`(date -d '2 days ago' +%Y-%m-%d)`
set FORECAST_DATE_MONWORD_M2=`(date -d '2 days ago' +%d-%b)`
set FORECAST_YM2=`(date -d '2 days ago' +%Y)`
set FORECAST_MM2=`(date -d '2 days ago' +%m)`
set FORECAST_DM2=`(date -d '2 days ago' +%d)`
set FORECAST_DATE_M3=`(date -d '3 days ago' +%Y-%m-%d)`
set FORECAST_DATE_MONWORD_M3=`(date -d '3 days ago' +%d-%b)`
set FORECAST_YM3=`(date -d '3 days ago' +%Y)`
set FORECAST_MM3=`(date -d '3 days ago' +%m)`
set FORECAST_DM3=`(date -d '3 days ago' +%d)`
echo "Execution Date: $CURRDATE"
echo "1 day before : $FORECAST_DATE_M1"
echo "2 days before : $FORECAST_DATE_M2"
set FORECAST_DATE_FILE=/discover/nobackup/projects/gmao/m2oasf/aogcm/g5fcst/forecast/production/geos-s2s/util/subXs2sfcsts_dates.txt
# Check yesterday and day before yesterday
# ----------------------------------
@ day = 1
while ( $day <= 2 )
echo -n "Checking if forecast should run... "
if ($day == 1) then
set FORECAST_DATE_MONWORD = ${FORECAST_DATE_MONWORD_M1}
set FORECAST_Y = ${FORECAST_YM2}
set FORECAST_M = ${FORECAST_MM2}
set FORECAST_D = ${FORECAST_DM2}
else
set FORECAST_DATE_MONWORD = ${FORECAST_DATE_MONWORD_M2}
set FORECAST_Y = ${FORECAST_YM3}
set FORECAST_M = ${FORECAST_MM3}
set FORECAST_D = ${FORECAST_DM3}
endif
# If the file exists, look for the date in it...
# ----------------------------------------------
grep -Fxq $FORECAST_DATE_MONWORD $FORECAST_DATE_FILE
set GREPstatus = $status
if ( ${GREPstatus} == 0 ) then
# The date was found
# ------------------
echo "$CURRDATE : Forecast date $FORECAST_DATE_MONWORD found."
# Here is our command to check if files are ready from analysis
# --------------------------------------------------------
set S2S_CHECK_COMMAND="/discover/nobackup/projects/gmao/m2oasf/aogcm/g5fcst/forecast/production/geos-s2s/util/s2sfcsts_ic_check.py --year $FORECAST_Y --month $FORECAST_M --day $FORECAST_D"
# Run a sleep loop until the command succeeds
# -------------------------------------------
@ counter = 1
@ counter_times = 20
while ( $counter <= ${counter_times})
${S2S_CHECK_COMMAND}
set ICstatus = $status
if ( $ICstatus == 1 ) sleep $SLEEP_AMOUNT
if ( $ICstatus == 0 ) then
echo "IC available to submit subX forecast "
/discover/nobackup/projects/gmao/m2oasf/aogcm/g5fcst/forecast/production/geos-s2s/util/subXsubmit_forecast.sh
exit
endif
@ counter = $counter + 1
end
echo "IC not available"
else
# The date was not found
# ----------------------
echo "$CURRDATE : Forecast date $FORECAST_DATE_MONWORD not found."
endif
@ day = $day + 1
end
exit