From 8a95e5532f749d7dd37900548525aa03c4039865 Mon Sep 17 00:00:00 2001 From: Saeideh Banihashemi Date: Thu, 1 Aug 2024 16:58:13 +0000 Subject: [PATCH] adding time0/timeN overwrite protection --- model/src/w3odatmd.F90 | 1 + model/src/wav_comp_nuopc.F90 | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) 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 84c70e3ee..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) @@ -1667,19 +1667,19 @@ subroutine waveinit_ufs( gcomp, ntrace, mpi_comm, mds, rc) ! 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 - - write(logmsg,'(A,l)') trim(subname)//': time0/timeN overwrite is protected',use_overwrite_protect if (use_overwrite_protect) then - call read_shel_config(mpi_comm, mds) + call ESMF_LogWrite(trim(subname)//': no time0/timeN overwrite') + call read_shel_config(mpi_comm, mds) else - call read_shel_config(mpi_comm, mds, time0_overwrite=time0, timen_overwrite=timen) + call ESMF_LogWrite(trim(subname)//': time0/timeN overwrite') + call read_shel_config(mpi_comm, mds, time0_overwrite=time0, timen_overwrite=timen) end if - !call read_shel_config(mpi_comm, mds, time0_overwrite=time0, timen_overwrite=timen) call ESMF_LogWrite(trim(subname)//' call w3init', ESMF_LOGMSG_INFO) call w3init ( 1, .false., 'ww3', mds, ntrace, odat, flgrd, flgr2, flgd, flg2, &