From cea2a52e807040eeb30c59bd715d5f6cff5fc401 Mon Sep 17 00:00:00 2001 From: JessicaMeixner-NOAA Date: Wed, 18 Dec 2024 09:22:38 -0600 Subject: [PATCH] define ww3 variable for netcdf or binary restart --- ush/forecast_postdet.sh | 63 ++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/ush/forecast_postdet.sh b/ush/forecast_postdet.sh index 0158ba913a..df98fd9112 100755 --- a/ush/forecast_postdet.sh +++ b/ush/forecast_postdet.sh @@ -350,37 +350,34 @@ WW3_postdet() { echo "Copying WW3 restarts for 'RUN=${RUN}' at '${restart_date}' from '${restart_dir}'" - if [[ "${WW3_restart_from_binary}" == "true" ]]; then - ww3_restart_file="${restart_dir}/${restart_date:0:8}.${restart_date:8:2}0000.restart.ww3" - if [[ -s "${ww3_restart_file}" ]]; then - ${NCP} "${ww3_restart_file}" "${DATA}/restart.ww3" \ + ww3_restart_file="${restart_dir}/${restart_date:0:8}.${restart_date:8:2}0000.restart.ww3" + if [[ -s "${ww3_restart_file}" ]]; then + #first check if a binary restart exists, if it does set + export WW3_restart_from_binary=true + ${NCP} "${ww3_restart_file}" "${DATA}/restart.ww3" \ || ( echo "FATAL ERROR: Unable to copy WW3 IC, ABORT!"; exit 1 ) - first_ww3_restart_out=$(date --utc -d "${restart_date:0:8} ${restart_date:8:2} + ${restart_interval} hours" +%Y%m%d%H) - else - if [[ "${RERUN}" == "YES" ]]; then - # In the case of a RERUN, the WW3 restart file is required - echo "FATAL ERROR: WW3 restart file '${ww3_restart_file}' not found for RERUN='${RERUN}', ABORT!" - exit 1 - else - echo "WARNING: WW3 restart file '${ww3_restart_file}' not found for warm_start='${warm_start}', will start from rest!" - first_ww3_restart_out=${model_start_date_current_cycle} - fi - fi + first_ww3_restart_out=$(date --utc -d "${restart_date:0:8} ${restart_date:8:2} + ${restart_interval} hours" +%Y%m%d%H) else + #now check to see if a NetCDF restart exists: seconds=$(to_seconds "${restart_date:8:2}0000") # convert HHMMSS to seconds ww3_restart_dest_file="ufs.cpld.ww3.r.${restart_date:0:4}-${restart_date:4:2}-${restart_date:6:2}-${seconds}.nc" + ww3_restart_file="${restart_dir}/${restart_date:0:8}.${restart_date:8:2}0000.restart.ww3.nc" - if [[ -s "${ww3_restart_file}" ]]; then + if [[ -s "${ww3_restart_file}" ]]; then + #NetCDF restart exists: + export WW3_restart_from_binary=false ${NCP} "${ww3_restart_file}" "${DATA}/${ww3_restart_dest_file}" \ - || ( echo "FATAL ERROR: Unable to copy WW3 IC, ABORT!"; exit 1 ) + || ( echo "FATAL ERROR: Unable to copy WW3 IC, ABORT!"; exit 1 ) first_ww3_restart_out=$(date --utc -d "${restart_date:0:8} ${restart_date:8:2} + ${restart_interval} hours" +%Y%m%d%H) - else + else if [[ "${RERUN}" == "YES" ]]; then - # In the case of a RERUN, the WW3 restart file is required - echo "FATAL ERROR: WW3 restart file '${ww3_restart_file}' not found for RERUN='${RERUN}', ABORT!" + # In the case of a RERUN, the WW3 restart file is required + echo "FATAL ERROR: WW3 restart file '${ww3_restart_file}' not found for RERUN='${RERUN}', ABORT!" exit 1 - echo "WARNING: WW3 restart file '${ww3_restart_file}' not found for warm_start='${warm_start}', will start from rest!" - first_ww3_restart_out=${model_start_date_current_cycle} + else + #TODO: See if this will work still with new options... might not + echo "WARNING: WW3 restart file '${ww3_restart_file}' not found for warm_start='${warm_start}', will start from rest!" + first_ww3_restart_out=${model_start_date_current_cycle} fi fi fi @@ -389,13 +386,9 @@ WW3_postdet() { for (( vdate = first_ww3_restart_out; vdate <= forecast_end_cycle; vdate = $(date --utc -d "${vdate:0:8} ${vdate:8:2} + ${restart_interval} hours" +%Y%m%d%H) )); do seconds=$(to_seconds "${vdate:8:2}0000") # convert HHMMSS to seconds - - if [[ "${WW3_restartnc}" == "true" ]]; then - ww3_restart_file="ufs.cpld.ww3.r.${vdate:0:4}-${vdate:4:2}-${vdate:6:2}-${seconds}.nc" - else - ww3_restart_file="${vdate:0:8}.${vdate:8:2}0000.restart.ww3" - fi - ${NLN} "${DATArestart}/WW3_RESTART/${ww3_restart_file}" "${ww3_restart_file}" + ww3_restart_ufs_file="ufs.cpld.ww3.r.${vdate:0:4}-${vdate:4:2}-${vdate:6:2}-${seconds}.nc" + ww3_restart_file="${vdate:0:8}.${vdate:8:2}0000.restart.ww3.nc" + ${NLN} "${DATArestart}/WW3_RESTART/${ww3_restart_file}" "${ww3_restart_ufs_file}" done # Link output files @@ -459,10 +452,10 @@ WW3_out() { local seconds source_file target_file if [[ "${RUN}" == "gfs" || "${RUN}" == "gefs" ]]; then echo "Copying WW3 restarts for 'RUN=${RUN}' at ${forecast_end_cycle}" - seconds=$(to_seconds "${forecast_end_cycle:8:2}0000") # convert HHMMSS to seconds - source_file="ufs.cpld.ww3.r.${forecast_end_cycle:0:4}-${forecast_end_cycle:4:2}-${forecast_end_cycle:6:2}-${seconds}.nc" + #seconds=$(to_seconds "${forecast_end_cycle:8:2}0000") # convert HHMMSS to seconds + #source_file="ufs.cpld.ww3.r.${forecast_end_cycle:0:4}-${forecast_end_cycle:4:2}-${forecast_end_cycle:6:2}-${seconds}.nc" target_file="${forecast_end_cycle:0:8}.${forecast_end_cycle:8:2}0000.restart.ww3.nc" - ${NCP} "${DATArestart}/WW3_RESTART/${source_file}" \ + ${NCP} "${DATArestart}/WW3_RESTART/${target_file}" \ "${COMOUT_WAVE_RESTART}/${target_file}" fi fi @@ -472,10 +465,10 @@ WW3_out() { local restart_date restart_date="${model_start_date_next_cycle}" echo "Copying CICE restarts for 'RUN=${RUN}' at ${restart_date}" - seconds=$(to_seconds "${restart_date:8:2}0000") # convert HHMMSS to seconds - source_file="ufs.cpld.ww3.r.${restart_date:0:4}-${restart_date:4:2}-${restart_date:6:2}-${seconds}.nc" + #seconds=$(to_seconds "${restart_date:8:2}0000") # convert HHMMSS to seconds + #source_file="ufs.cpld.ww3.r.${restart_date:0:4}-${restart_date:4:2}-${restart_date:6:2}-${seconds}.nc" target_file="${restart_date:0:8}.${restart_date:8:2}0000.restart.ww3.nc" - ${NCP} "${DATArestart}/WW3_RESTART/${source_file}" \ + ${NCP} "${DATArestart}/WW3_RESTART/${target_file}" \ "${COMOUT_WAVE_RESTART}/${target_file}" fi