From 520900e519cae1df94cd582294b64b55db84d789 Mon Sep 17 00:00:00 2001 From: Ufuk Turuncoglu Date: Thu, 8 Feb 2024 14:19:10 -0600 Subject: [PATCH] enable standalone ww3 run --- model/src/wav_comp_nuopc.F90 | 16 ++++++++++++++-- model/src/wav_import_export.F90 | 29 +++++++++++++++++++++++------ model/src/wav_shr_mod.F90 | 2 ++ 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/model/src/wav_comp_nuopc.F90 b/model/src/wav_comp_nuopc.F90 index 6f3eeef5a..b0e65bfd6 100644 --- a/model/src/wav_comp_nuopc.F90 +++ b/model/src/wav_comp_nuopc.F90 @@ -47,7 +47,7 @@ module wav_comp_nuopc use w3odatmd , only : runtype, use_user_histname, user_histfname, use_user_restname, user_restfname 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 + use wav_shr_mod , only : casename, multigrid, inst_suffix, inst_index, unstr_mesh, standalone use wav_wrapper_mod , only : ufs_settimer, ufs_logtimer, ufs_file_setlogunit, wtime #ifndef W3_CESMCOUPLED use wmwavemd , only : wmwave @@ -379,10 +379,22 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) runtimelog=(trim(cvalue)=="true") write(logmsg,*) runtimelog - call ESMF_LogWrite('WW3_cap:RunTimeLog = '//trim(logmsg), ESMF_LOGMSG_INFO) + call ESMF_LogWrite(trim(subname)//': RunTimeLog = '//trim(logmsg), ESMF_LOGMSG_INFO) if (runtimelog) then call ufs_file_setLogUnit('./log.ww3.timer',nu_timer,runtimelog) end if + + ! Determine if this is standalone run + call NUOPC_CompAttributeGet(gcomp, name="standalone", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + if (trim(cvalue) == '.true.' .or. trim(cvalue) == 'true') then + standalone = .true. + end if + end if + write(logmsg,'(A,l)') trim(subname)//': Standalone setting is ', standalone + call ESMF_LogWrite(trim(logmsg), ESMF_LOGMSG_INFO) + call advertise_fields(importState, exportState, flds_scalar_name, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return diff --git a/model/src/wav_import_export.F90 b/model/src/wav_import_export.F90 index cea967bfd..f13e34efc 100644 --- a/model/src/wav_import_export.F90 +++ b/model/src/wav_import_export.F90 @@ -19,7 +19,8 @@ module wav_import_export use wav_shr_mod , only : ymd2date use wav_shr_mod , only : chkerr use wav_shr_mod , only : state_diagnose, state_reset, state_getfldptr, state_fldchk, state_write_vtk - use wav_shr_mod , only : wav_coupling_to_cice, nwav_elev_spectrum, merge_import, dbug_flag, multigrid, unstr_mesh + use wav_shr_mod , only : wav_coupling_to_cice, nwav_elev_spectrum, merge_import, dbug_flag, multigrid + use wav_shr_mod , only : standalone, unstr_mesh use constants , only : grav, tpi, dwat use w3parall , only : init_get_isea @@ -398,12 +399,14 @@ subroutine import_fields( gcomp, time0, timen, rc ) TW0 = time0 ! times for atm wind/temp fields. TWN = timen - if (merge_import) then + if (merge_import .or. standalone) then ! set mask using u-wind field if merge_import; assume all import fields ! will have same missing overlap region ! import_mask memory will be allocate in set_importmask - call set_importmask(importState, clock, trim(uwnd), vm, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (merge_import) then + call set_importmask(importState, clock, trim(uwnd), vm, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if allocate(wxdata(nsea)) allocate(wydata(nsea)) call readfromfile('WND', wxdata, wydata, time0, timen, rc) @@ -413,8 +416,10 @@ subroutine import_fields( gcomp, time0, timen, rc ) if (ChkErr(rc,__LINE__,u_FILE_u)) return call check_globaldata(gcomp, 'wydata', wydata, nsea, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call check_globaldata(gcomp, 'import_mask', import_mask, nsea, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (merge_import) then + call check_globaldata(gcomp, 'import_mask', import_mask, nsea, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if end if end if @@ -435,6 +440,12 @@ subroutine import_fields( gcomp, time0, timen, rc ) call FillGlobalInput(global_data, WX0) call FillGlobalInput(global_data, WXN) end if + else + if (standalone) then + call ESMF_LogWrite(trim(subname)//' no connected uwnd field. reading data from wind.ww3.', ESMF_LOGMSG_INFO) + call FillGlobalInput(wxdata, WX0) + call FillGlobalInput(wxdata, WXN) + end if end if ! atm v wind @@ -455,6 +466,12 @@ subroutine import_fields( gcomp, time0, timen, rc ) call FillGlobalInput(global_data, WY0) call FillGlobalInput(global_data, WYN) end if + else + if (standalone) then + call ESMF_LogWrite(trim(subname)//' no connected vwnd field. reading data from wind.ww3.', ESMF_LOGMSG_INFO) + call FillGlobalInput(wydata, WY0) + call FillGlobalInput(wydata, WYN) + end if end if ! air temp - ocn temp diff --git a/model/src/wav_shr_mod.F90 b/model/src/wav_shr_mod.F90 index 6625ea357..9e5c4a745 100644 --- a/model/src/wav_shr_mod.F90 +++ b/model/src/wav_shr_mod.F90 @@ -76,6 +76,8 @@ module wav_shr_mod !! be merged with a field provided from a file logical , public :: multigrid = .false. !< @public logical to control whether wave model is run !! as multigrid + logical , public :: standalone = .false. !< @public logical to control whether wave model is run + !! in standalone mode - read fields from file interface ymd2date module procedure ymd2date_int