Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions config_src/drivers/nuopc_cap/mom_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ module MOM_cap_mod
use MOM_get_input, only: get_MOM_input, directories
use MOM_domains, only: pass_var
use MOM_error_handler, only: MOM_error, FATAL, is_root_pe
use MOM_ocean_model_nuopc, only: ice_ocean_boundary_type
use MOM_grid, only: ocean_grid_type, get_global_grid_size
use MOM_ocean_model_nuopc, only: ice_ocean_boundary_type
use MOM_ocean_model_nuopc, only: ocean_model_restart, ocean_public_type, ocean_state_type
use MOM_ocean_model_nuopc, only: ocean_model_init_sfc
use MOM_ocean_model_nuopc, only: ocean_model_init, update_ocean_model, ocean_model_end
use MOM_ocean_model_nuopc, only: get_ocean_grid, get_eps_omesh
use MOM_ocean_model_nuopc, only: get_ocean_grid, get_eps_omesh, query_ocean_state
use MOM_cap_time, only: AlarmInit
use MOM_cap_methods, only: mom_import, mom_export, mom_set_geomtype, mod2med_areacor
use MOM_cap_methods, only: med2mod_areacor, state_diagnose
Expand Down Expand Up @@ -421,6 +421,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
character(len=64) :: logmsg
logical :: isPresent, isPresentDiro, isPresentLogfile, isSet
logical :: existflag
logical :: use_waves ! If true, the wave modules are active.
integer :: userRc
integer :: localPet
integer :: localPeCount
Expand Down Expand Up @@ -695,19 +696,22 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
Ice_ocean_boundary%lrunoff = 0.0
Ice_ocean_boundary%frunoff = 0.0

if (ocean_state%use_waves) then
Ice_ocean_boundary%num_stk_bands=ocean_state%Waves%NumBands
call query_ocean_state(ocean_state, use_waves=use_waves)
if (use_waves) then
call query_ocean_state(ocean_state, NumWaveBands=Ice_ocean_boundary%num_stk_bands)
allocate ( Ice_ocean_boundary% ustk0 (isc:iec,jsc:jec), &
Ice_ocean_boundary% vstk0 (isc:iec,jsc:jec), &
Ice_ocean_boundary% ustkb (isc:iec,jsc:jec,Ice_ocean_boundary%num_stk_bands), &
Ice_ocean_boundary% vstkb (isc:iec,jsc:jec,Ice_ocean_boundary%num_stk_bands), &
Ice_ocean_boundary%stk_wavenumbers (Ice_ocean_boundary%num_stk_bands))
Ice_ocean_boundary%ustk0 = 0.0
Ice_ocean_boundary%vstk0 = 0.0
Ice_ocean_boundary%stk_wavenumbers = ocean_state%Waves%WaveNum_Cen
call query_ocean_state(ocean_state, WaveNumbers=Ice_ocean_boundary%stk_wavenumbers, unscale=.true.)
Ice_ocean_boundary%ustkb = 0.0
Ice_ocean_boundary%vstkb = 0.0
endif
! Consider adding this:
! if (.not.use_waves) Ice_ocean_boundary%num_stk_bands = 0

ocean_internalstate%ptr%ocean_state_type_ptr => ocean_state
call ESMF_GridCompSetInternalState(gcomp, ocean_internalstate, rc)
Expand Down Expand Up @@ -752,7 +756,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
!These are not currently used and changing requires a nuopc dictionary change
!call fld_list_add(fldsToOcn_num, fldsToOcn, "mean_runoff_heat_flx" , "will provide")
!call fld_list_add(fldsToOcn_num, fldsToOcn, "mean_calving_heat_flx" , "will provide")
if (ocean_state%use_waves) then
if (use_waves) then
if (Ice_ocean_boundary%num_stk_bands > 3) then
call MOM_error(FATAL, "Number of Stokes Bands > 3, NUOPC cap not set up for this")
endif
Expand Down
35 changes: 27 additions & 8 deletions config_src/drivers/nuopc_cap/mom_ocean_model_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module MOM_ocean_model_nuopc
use mpp_mod, only : mpp_chksum
use MOM_EOS, only : gsw_sp_from_sr, gsw_pt_from_ct
use MOM_wave_interface, only : wave_parameters_CS, MOM_wave_interface_init
use MOM_wave_interface, only : Update_Surface_Waves
use MOM_wave_interface, only : Update_Surface_Waves, query_wave_properties
use MOM_surface_forcing_nuopc, only : surface_forcing_init, convert_IOB_to_fluxes
use MOM_surface_forcing_nuopc, only : convert_IOB_to_forces, ice_ocn_bnd_type_chksum
use MOM_surface_forcing_nuopc, only : ice_ocean_boundary_type, surface_forcing_CS
Expand All @@ -80,7 +80,7 @@ module MOM_ocean_model_nuopc
public ocean_model_restart
public ice_ocn_bnd_type_chksum
public ocean_public_type_chksum
public get_ocean_grid
public get_ocean_grid, query_ocean_state
public get_eps_omesh

!> This type is used for communication with other components via the FMS coupler.
Expand Down Expand Up @@ -391,12 +391,6 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i
! MOM_wave_interface_init is called regardless of the value of USE_WAVES because
! it also initializes statistical waves.
call MOM_wave_interface_init(OS%Time, OS%grid, OS%GV, OS%US, param_file, OS%Waves, OS%diag)
if (OS%use_waves) then
! I do not know why this is being set here. It seems out of place. -RWH
call get_param(param_file,mdl,"SURFBAND_WAVENUMBERS", OS%Waves%WaveNum_Cen, &
"Central wavenumbers for surface Stokes drift bands.", &
units='rad/m', default=0.12566, scale=OS%US%Z_to_m)
endif

if (associated(OS%grid%Domain%maskmap)) then
call initialize_ocean_public_type(OS%grid%Domain%mpp_domain, Ocean_sfc, &
Expand Down Expand Up @@ -1006,6 +1000,31 @@ subroutine ocean_model_flux_init(OS, verbosity)

end subroutine ocean_model_flux_init

!> This interface allows certain properties that are stored in the ocean_state_type to be
!! obtained.
subroutine query_ocean_state(OS, use_waves, NumWaveBands, Wavenumbers, unscale)
type(ocean_state_type), intent(in) :: OS !< The structure with the complete ocean state
logical, optional, intent(out) :: use_waves !< Indicates whether surface waves are in use
integer, optional, intent(out) :: NumWaveBands !< If present, this gives the number of
!! wavenumber partitions in the wave discretization
real, dimension(:), optional, intent(out) :: Wavenumbers !< If present, this gives the characteristic
!! wavenumbers of the wave discretization [m-1 or Z-1 ~> m-1]
logical, optional, intent(in) :: unscale !< If present and true, undo any dimensional
!! rescaling and return dimensional values in MKS units

logical :: undo_scaling
undo_scaling = .false. ; if (present(unscale)) undo_scaling = unscale

if (present(use_waves)) use_waves = OS%use_waves
if (present(NumWaveBands)) call query_wave_properties(OS%Waves, NumBands=NumWaveBands)
if (present(Wavenumbers) .and. undo_scaling) then
call query_wave_properties(OS%Waves, WaveNumbers=WaveNumbers, US=OS%US)
elseif (present(Wavenumbers)) then
call query_wave_properties(OS%Waves, WaveNumbers=WaveNumbers)
endif

end subroutine query_ocean_state

!> Ocean_stock_pe - returns the integrated stocks of heat, water, etc. for conservation checks.
!! Because of the way FMS is coded, only the root PE has the integrated amount,
!! while all other PEs get 0.
Expand Down
28 changes: 28 additions & 0 deletions src/user/MOM_wave_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module MOM_wave_interface
#include <MOM_memory.h>

public MOM_wave_interface_init ! Public interface to fully initialize the wave routines.
public query_wave_properties ! Public interface to obtain information from the waves control structure.
public Update_Surface_Waves ! Public interface to update wave information at the
! coupler/driver level.
public Update_Stokes_Drift ! Public interface to update the Stokes drift profiles
Expand Down Expand Up @@ -323,6 +324,9 @@ subroutine MOM_wave_interface_init(time, G, GV, US, param_file, CS, diag )
"This has to be consistent with the number of Stokes drift bands in WW3, "//&
"or the model will fail.",units='', default=1)
allocate( CS%WaveNum_Cen(CS%NumBands) )
call get_param(param_file, mdl, "SURFBAND_WAVENUMBERS", CS%WaveNum_Cen, &
"Central wavenumbers for surface Stokes drift bands.", &
units='rad/m', default=0.12566, scale=US%Z_to_m)
allocate( CS%STKx0(G%isdB:G%iedB,G%jsd:G%jed,CS%NumBands))
allocate( CS%STKy0(G%isdB:G%iedB,G%jsd:G%jed,CS%NumBands))
CS%WaveNum_Cen(:) = 0.0
Expand Down Expand Up @@ -428,6 +432,30 @@ subroutine MOM_wave_interface_init(time, G, GV, US, param_file, CS, diag )

end subroutine MOM_wave_interface_init

!> This interface provides the caller with information from the waves control structure.
subroutine query_wave_properties(CS, NumBands, WaveNumbers, US)
type(wave_parameters_CS), pointer :: CS !< Wave parameter Control structure
integer, optional, intent(out) :: NumBands !< If present, this returns the number of
!!< wavenumber partitions in the wave discretization
real, dimension(:), optional, intent(out) :: Wavenumbers !< If present this returns the characteristic
!! wavenumbers of the wave discretization [m-1 or Z-1 ~> m-1]
type(unit_scale_type), optional, intent(in) :: US !< A dimensional unit scaling type that is used to undo
!! the dimensional scaling of the output variables, if present
integer :: n

if (present(NumBands)) NumBands = CS%NumBands
if (present(Wavenumbers)) then
if (size(Wavenumbers) < CS%NumBands) call MOM_error(FATAL, "query_wave_properties called "//&
"with a Wavenumbers array that is smaller than the number of bands.")
if (present(US)) then
do n=1,CS%NumBands ; Wavenumbers(n) = US%m_to_Z * CS%WaveNum_Cen(n) ; enddo
else
do n=1,CS%NumBands ; Wavenumbers(n) = CS%WaveNum_Cen(n) ; enddo
endif
endif

end subroutine query_wave_properties

!> Subroutine that handles updating of surface wave/Stokes drift related properties
subroutine Update_Surface_Waves(G, GV, US, Day, dt, CS, forces)
type(wave_parameters_CS), pointer :: CS !< Wave parameter Control structure
Expand Down