diff --git a/model/src/w3odatmd.F90 b/model/src/w3odatmd.F90 index 5c1c7d239..40167fa1f 100644 --- a/model/src/w3odatmd.F90 +++ b/model/src/w3odatmd.F90 @@ -563,6 +563,7 @@ MODULE W3ODATMD !! if runtype is startup or branch run, then initfile is used logical :: use_user_histname = .false. !<@public logical flag for user set history filenames logical :: use_user_restname = .false. !<@public logical flag for user set restart filenames + logical :: use_overwrite_protect = .false. !<@public logical flag for protecting time0/timeN overwrite character(len=512) :: user_histfname = '' !<@public user history filename prefix, timestring !! YYYY-MM-DD-SSSSS will be appended character(len=512) :: user_restfname = '' !<@public user restart filename prefix, timestring diff --git a/model/src/wav_comp_nuopc.F90 b/model/src/wav_comp_nuopc.F90 index c7bb14ef2..72c697254 100644 --- a/model/src/wav_comp_nuopc.F90 +++ b/model/src/wav_comp_nuopc.F90 @@ -44,7 +44,7 @@ module wav_comp_nuopc use wav_shr_mod , only : wav_coupling_to_cice, nwav_elev_spectrum use wav_shr_mod , only : merge_import, dbug_flag use w3odatmd , only : nds, iaproc, napout - use w3odatmd , only : runtype, use_user_histname, user_histfname, use_user_restname, user_restfname + use w3odatmd , only : runtype, use_user_histname, user_histfname, use_user_restname, user_restfname, use_overwrite_protect use w3odatmd , only : user_netcdf_grdout use w3odatmd , only : time_origin, calendar_name, elapsed_secs use wav_shr_mod , only : casename, multigrid, inst_suffix, inst_index, unstr_mesh @@ -1642,7 +1642,7 @@ subroutine waveinit_ufs( gcomp, ntrace, mpi_comm, mds, rc) if (isPresent .and. isSet) then use_user_restname=(trim(cvalue)=="true") end if - write(logmsg,'(A,l)') trim(subname)//': Custom restart names in use ',use_user_restname + write(logmsg,'(A,l)') trim(subname)//': Custom restart names in use',use_user_restname call ESMF_LogWrite(trim(logmsg), ESMF_LOGMSG_INFO) call NUOPC_CompAttributeGet(gcomp, name='gridded_netcdfout', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) @@ -1663,7 +1663,23 @@ subroutine waveinit_ufs( gcomp, ntrace, mpi_comm, mds, rc) fnmpre = './' call ESMF_LogWrite(trim(subname)//' call read_shel_config', ESMF_LOGMSG_INFO) - call read_shel_config(mpi_comm, mds, time0_overwrite=time0, timen_overwrite=timen) + + + ! Added attribute for restart time0/timeN overwrite option + call NUOPC_CompAttributeGet(gcomp, name='overwrite_protect', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + use_overwrite_protect=(trim(cvalue)=="true") + end if + + if (use_overwrite_protect) then + call ESMF_LogWrite(trim(subname)//': no time0/timeN overwrite') + call read_shel_config(mpi_comm, mds) + else + call ESMF_LogWrite(trim(subname)//': time0/timeN overwrite') + call read_shel_config(mpi_comm, mds, time0_overwrite=time0, timen_overwrite=timen) + end if call ESMF_LogWrite(trim(subname)//' call w3init', ESMF_LOGMSG_INFO) call w3init ( 1, .false., 'ww3', mds, ntrace, odat, flgrd, flgr2, flgd, flg2, &