@@ -26,7 +26,7 @@ UFS_det(){
2626 IAU_OFFSET=0
2727 model_start_date_current_cycle=${current_cycle}
2828
29- DO_LAND_IAU=" .false."
29+ DO_LAND_IAU=" .false."
3030
3131 # It is still possible that a restart is available from a previous forecast attempt
3232 # So we have to continue checking for restarts
@@ -35,7 +35,7 @@ UFS_det(){
3535 # Lets assume this is was not run before and hence this is not a RERUN
3636 RERUN=" NO"
3737
38- # RERUN is only available for RUN=gfs|gefs It is not available for RUN=gdas|enkfgdas|enkfgfs
38+ # RERUN is only available for RUN=gfs|gefs. It is not available for RUN=gdas|enkfgdas|enkfgfs
3939 if [[ " ${RUN} " =~ " gdas" ]] || [[ " ${RUN} " == " enkfgfs" ]]; then
4040 echo " RERUN is not available for RUN='${RUN} '"
4141 return 0
@@ -46,15 +46,19 @@ UFS_det(){
4646 # shellcheck disable=SC2312
4747 mapfile -t file_array < <( find " ${DATArestart} /FV3_RESTART" -name " ????????.??0000.coupler.res" | sort)
4848 nrestarts=${# file_array[@]}
49- if (( nrestarts == 0 )) ; then
49+ if [[ ${ nrestarts} -eq 0 ]] ; then
5050 echo " No restarts found in '${DATArestart} /FV3_RESTART', RERUN='${RERUN} '"
5151 return 0
52+ else
53+ echo " Found ${nrestarts} restarts in '${DATArestart} /FV3_RESTART' to check for RERUN"
54+ ls -1 " ${DATArestart} /FV3_RESTART/" ???????? .?? 0000.coupler.res
5255 fi
5356
5457 # Look in reverse order of file_array to determine available restart times
5558 local ii filepath filename
5659 local rdate seconds
5760 local fv3_rst_ok cmeps_rst_ok mom6_rst_ok cice6_rst_ok ww3_rst_ok
61+ local hdate hdatep1 fhout_ocn_by_2
5862 for (( ii= nrestarts- 1 ; ii>= 0 ; ii-- )) ; do
5963
6064 filepath=" ${file_array[ii]} "
@@ -80,9 +84,26 @@ UFS_det(){
8084 if [[ ! -f " ${DATArestart} /CMEPS_RESTART/ufs.cpld.cpl.r.${rdate: 0: 4} -${rdate: 4: 2} -${rdate: 6: 2} -${seconds} .nc" ]]; then
8185 cmeps_rst_ok=" NO"
8286 fi
83- if [[ ! -f " ${DATArestart} /MOM6_RESTART/${rdate: 0: 8} .${rdate: 8: 2} 0000.MOM.res.nc" ]]; then
8487 # TODO: add checks for other MOM6 restarts as well
88+ if [[ ! -f " ${DATArestart} /MOM6_RESTART/${rdate: 0: 8} .${rdate: 8: 2} 0000.MOM.res.nc" ]]; then
8589 mom6_rst_ok=" NO"
90+ else
91+ # Also check for MOM6 history file availability
92+ # TODO: SFS runs with 24-hr averaging of ocean output, which causes issues with restart checks,
93+ # TODO: so we will skip them for now, and revisit this logic later
94+ if [[ ${FHOUT_OCN} -le 6 ]]; then
95+ fhout_ocn_by_2=$(( FHOUT_OCN / 2 ))
96+ hdate=$( date -u -d " ${rdate: 0: 8} ${rdate: 8: 2} + ${fhout_ocn_by_2} hours" +" %Y%m%d%H" )
97+ if [[ ! -f " ${DATAoutput} /MOM6_OUTPUT/ocn_${hdate: 0: 4} _${hdate: 4: 2} _${hdate: 6: 2} _${hdate: 8: 2} .nc" ]]; then
98+ mom6_rst_ok=" NO"
99+ else
100+ # Also check for the next MOM6 history file (hdate + FHOUT_OCN hours)
101+ hdatep1=$( date -u -d " ${hdate: 0: 8} ${hdate: 8: 2} + ${FHOUT_OCN} hours" +" %Y%m%d%H" )
102+ if [[ ! -f " ${DATAoutput} /MOM6_OUTPUT/ocn_${hdatep1: 0: 4} _${hdatep1: 4: 2} _${hdatep1: 6: 2} _${hdatep1: 8: 2} .nc" ]]; then
103+ mom6_rst_ok=" NO"
104+ fi
105+ fi
106+ fi
86107 fi
87108 MOM6_RESTART_SETTING=' r'
88109 MOM6_INIT_FROM_Z=True
0 commit comments