Skip to content

Commit

Permalink
enable standalone ww3 run
Browse files Browse the repository at this point in the history
  • Loading branch information
uturuncoglu committed Apr 19, 2024
1 parent 8c75b2d commit f2b10a5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
16 changes: 14 additions & 2 deletions model/src/wav_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
27 changes: 22 additions & 5 deletions model/src/wav_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module wav_import_export
use wav_shr_mod , only : chkerr
use wav_shr_mod , only : state_diagnose, state_reset, state_getfldptr, state_fldchk
use wav_shr_mod , only : wav_coupling_to_cice, nwav_elev_spectrum, merge_import, dbug_flag, multigrid, unstr_mesh
use wav_shr_mod , only : standalone
use constants , only : grav, tpi, dwat, dair
use w3parall , only : init_get_isea

Expand Down Expand Up @@ -381,12 +382,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)
Expand All @@ -396,8 +399,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

Expand All @@ -418,6 +423,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
Expand All @@ -438,6 +449,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
Expand Down
2 changes: 2 additions & 0 deletions model/src/wav_shr_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,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
Expand Down

0 comments on commit f2b10a5

Please sign in to comment.