Skip to content

Commit

Permalink
Merge branch 'dev/gfdl' into fix_rho_diag_h_neglect_bug
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallward authored Feb 28, 2024
2 parents ec032d9 + f2e7abf commit db921bc
Show file tree
Hide file tree
Showing 9 changed files with 257 additions and 184 deletions.
235 changes: 152 additions & 83 deletions config_src/drivers/nuopc_cap/mom_cap.F90

Large diffs are not rendered by default.

179 changes: 90 additions & 89 deletions config_src/drivers/nuopc_cap/mom_cap_methods.F90
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@ end subroutine mom_set_geomtype
!> This function has a few purposes:
!! (1) it imports surface fluxes using data from the mediator; and
!! (2) it can apply restoring in SST and SSS.
subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary, cesm_coupled, rc)
subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary, rc)
type(ocean_public_type) , intent(in) :: ocean_public !< Ocean surface state
type(ocean_grid_type) , intent(in) :: ocean_grid !< Ocean model grid
type(ESMF_State) , intent(inout) :: importState !< incoming data from mediator
type(ice_ocean_boundary_type) , intent(inout) :: ice_ocean_boundary !< Ocean boundary forcing
logical , intent(in) :: cesm_coupled !< Flag to check if coupled with cesm
integer , intent(inout) :: rc !< Return code

! Local Variables
Expand All @@ -103,43 +102,42 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary,
!----
! surface height pressure
!----
call state_getimport(importState, 'inst_pres_height_surface', &
isc, iec, jsc, jec, ice_ocean_boundary%p, rc=rc)
call state_getimport(importState, 'Sa_pslv', isc, iec, jsc, jec, ice_ocean_boundary%p, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
! near-IR, direct shortwave (W/m2)
!----
call state_getimport(importState, 'mean_net_sw_ir_dir_flx', &
isc, iec, jsc, jec, ice_ocean_boundary%sw_flux_nir_dir, areacor=med2mod_areacor, rc=rc)
call state_getimport(importState, 'Foxx_swnet_idr', isc, iec, jsc, jec, &
ice_ocean_boundary%sw_flux_nir_dir, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
! near-IR, diffuse shortwave (W/m2)
!----
call state_getimport(importState, 'mean_net_sw_ir_dif_flx', &
isc, iec, jsc, jec, ice_ocean_boundary%sw_flux_nir_dif, areacor=med2mod_areacor, rc=rc)
call state_getimport(importState, 'Foxx_swnet_idf', isc, iec, jsc, jec, &
ice_ocean_boundary%sw_flux_nir_dif, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
! visible, direct shortwave (W/m2)
!----
call state_getimport(importState, 'mean_net_sw_vis_dir_flx', &
isc, iec, jsc, jec, ice_ocean_boundary%sw_flux_vis_dir, areacor=med2mod_areacor, rc=rc)
call state_getimport(importState, 'Foxx_swnet_vdr', isc, iec, jsc, jec, &
ice_ocean_boundary%sw_flux_vis_dir, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
! visible, diffuse shortwave (W/m2)
!----
call state_getimport(importState, 'mean_net_sw_vis_dif_flx', &
isc, iec, jsc, jec, ice_ocean_boundary%sw_flux_vis_dif, areacor=med2mod_areacor, rc=rc)
call state_getimport(importState, 'Foxx_swnet_vdf', isc, iec, jsc, jec, &
ice_ocean_boundary%sw_flux_vis_dif, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! -------
! Net longwave radiation (W/m2)
! -------
call state_getimport(importState, 'mean_net_lw_flx', &
isc, iec, jsc, jec, ice_ocean_boundary%lw_flux, areacor=med2mod_areacor, rc=rc)
call state_getimport(importState, 'Foxx_lwnet', isc, iec, jsc, jec, &
ice_ocean_boundary%lw_flux, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
Expand All @@ -148,10 +146,10 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary,
allocate (taux(isc:iec,jsc:jec))
allocate (tauy(isc:iec,jsc:jec))

call state_getimport(importState, 'mean_zonal_moment_flx', isc, iec, jsc, jec, taux, &
call state_getimport(importState, 'Foxx_taux', isc, iec, jsc, jec, taux, &
areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getimport(importState, 'mean_merid_moment_flx', isc, iec, jsc, jec, tauy, &
call state_getimport(importState, 'Foxx_tauy', isc, iec, jsc, jec, tauy, &
areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand All @@ -172,29 +170,29 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary,
!----
! sensible heat flux (W/m2)
!----
call state_getimport(importState, 'mean_sensi_heat_flx', &
isc, iec, jsc, jec, ice_ocean_boundary%t_flux, areacor=med2mod_areacor, rc=rc)
call state_getimport(importState, 'Foxx_sen', isc, iec, jsc, jec, &
ice_ocean_boundary%t_flux, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
! evaporation flux (W/m2)
!----
call state_getimport(importState, 'mean_evap_rate', &
isc, iec, jsc, jec, ice_ocean_boundary%q_flux, areacor=med2mod_areacor, rc=rc)
call state_getimport(importState, 'Foxx_evap', isc, iec, jsc, jec, &
ice_ocean_boundary%q_flux, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
! liquid precipitation (rain)
!----
call state_getimport(importState, 'mean_prec_rate', &
isc, iec, jsc, jec, ice_ocean_boundary%lprec, areacor=med2mod_areacor, rc=rc)
call state_getimport(importState, 'Faxa_rain', isc, iec, jsc, jec, &
ice_ocean_boundary%lprec, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
! frozen precipitation (snow)
!----
call state_getimport(importState, 'mean_fprec_rate', &
isc, iec, jsc, jec, ice_ocean_boundary%fprec, areacor=med2mod_areacor, rc=rc)
call state_getimport(importState, 'Faxa_snow', isc, iec, jsc, jec, &
ice_ocean_boundary%fprec, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
Expand All @@ -216,75 +214,85 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary,
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
! Enthalpy terms (only in CESM)
! Enthalpy terms
!----
if (cesm_coupled) then
!----
! enthalpy from liquid precipitation (hrain)
!----
call state_getimport(importState, 'heat_content_lprec', &
isc, iec, jsc, jec, ice_ocean_boundary%hrain, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
! enthalpy from frozen precipitation (hsnow)
!----
call state_getimport(importState, 'heat_content_fprec', &
isc, iec, jsc, jec, ice_ocean_boundary%hsnow, areacor=med2mod_areacor, rc=rc)
!----
! enthalpy from liquid precipitation (hrain)
!----
if ( associated(ice_ocean_boundary%hrain) ) then
call state_getimport(importState, 'Foxx_hrain', isc, iec, jsc, jec, &
ice_ocean_boundary%hrain, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

!----
! enthalpy from liquid runoff (hrofl)
!----
call state_getimport(importState, 'heat_content_rofl', &
isc, iec, jsc, jec, ice_ocean_boundary%hrofl, areacor=med2mod_areacor, rc=rc)
!----
! enthalpy from frozen precipitation (hsnow)
!----
if ( associated(ice_ocean_boundary%hsnow) ) then
call state_getimport(importState, 'Foxx_hsnow', isc, iec, jsc, jec, &
ice_ocean_boundary%hsnow, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

!----
! enthalpy from frozen runoff (hrofi)
!----
call state_getimport(importState, 'heat_content_rofi', &
isc, iec, jsc, jec, ice_ocean_boundary%hrofi, areacor=med2mod_areacor, rc=rc)
!----
! enthalpy from liquid runoff (hrofl)
!----
if ( associated(ice_ocean_boundary%hrofl) ) then
call state_getimport(importState, 'Foxx_hrofl', isc, iec, jsc, jec, &
ice_ocean_boundary%hrofl, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

!----
! enthalpy from evaporation (hevap)
!----
call state_getimport(importState, 'heat_content_evap', &
isc, iec, jsc, jec, ice_ocean_boundary%hevap, areacor=med2mod_areacor, rc=rc)
!----
! enthalpy from frozen runoff (hrofi)
!----
if ( associated(ice_ocean_boundary%hrofi) ) then
call state_getimport(importState, 'Foxx_hrofi', isc, iec, jsc, jec, &
ice_ocean_boundary%hrofi, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

!----
! enthalpy from condensation (hcond)
!----
call state_getimport(importState, 'heat_content_cond', &
isc, iec, jsc, jec, ice_ocean_boundary%hcond, areacor=med2mod_areacor, rc=rc)
!----
! enthalpy from evaporation (hevap)
!----
if ( associated(ice_ocean_boundary%hevap) ) then
call state_getimport(importState, 'Foxx_hevap', isc, iec, jsc, jec, &
ice_ocean_boundary%hevap, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

!----
! enthalpy from condensation (hcond)
!----
if ( associated(ice_ocean_boundary%hcond) ) then
call state_getimport(importState, 'Foxx_hcond', isc, iec, jsc, jec, &
ice_ocean_boundary%hcond, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
endif

!----
! salt flux from ice
!----
ice_ocean_boundary%salt_flux(:,:) = 0._ESMF_KIND_R8
call state_getimport(importState, 'mean_salt_rate', &
isc, iec, jsc, jec, ice_ocean_boundary%salt_flux, areacor=med2mod_areacor, rc=rc)
call state_getimport(importState, 'Fioi_salt', isc, iec, jsc, jec, &
ice_ocean_boundary%salt_flux, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
! snow&ice melt heat flux (W/m^2)
!----
ice_ocean_boundary%seaice_melt_heat(:,:) = 0._ESMF_KIND_R8
call state_getimport(importState, 'net_heat_flx_to_ocn', &
isc, iec, jsc, jec, ice_ocean_boundary%seaice_melt_heat, areacor=med2mod_areacor, rc=rc)
call state_getimport(importState, 'Fioi_melth', isc, iec, jsc, jec, &
ice_ocean_boundary%seaice_melt_heat, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
! snow&ice melt water flux (W/m^2)
!----
ice_ocean_boundary%seaice_melt(:,:) = 0._ESMF_KIND_R8
call state_getimport(importState, 'mean_fresh_water_to_ocean_rate', &
isc, iec, jsc, jec, ice_ocean_boundary%seaice_melt, areacor=med2mod_areacor, rc=rc)
call state_getimport(importState, 'Fioi_meltw', isc, iec, jsc, jec, &
ice_ocean_boundary%seaice_melt, areacor=med2mod_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
Expand All @@ -293,33 +301,33 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary,
! Note - preset values to 0, if field does not exist in importState, then will simply return
! and preset value will be used
ice_ocean_boundary%mi(:,:) = 0._ESMF_KIND_R8
call state_getimport(importState, 'mass_of_overlying_ice', &
isc, iec, jsc, jec, ice_ocean_boundary%mi,rc=rc)
call state_getimport(importState, 'mass_of_overlying_ice', isc, iec, jsc, jec, &
ice_ocean_boundary%mi,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
! sea-ice fraction
!----
ice_ocean_boundary%ice_fraction(:,:) = 0._ESMF_KIND_R8
call state_getimport(importState, 'Si_ifrac', &
isc, iec, jsc, jec, ice_ocean_boundary%ice_fraction, rc=rc)
call state_getimport(importState, 'Si_ifrac', isc, iec, jsc, jec, &
ice_ocean_boundary%ice_fraction, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
! 10m wind squared
!----
ice_ocean_boundary%u10_sqr(:,:) = 0._ESMF_KIND_R8
call state_getimport(importState, 'So_duu10n', &
isc, iec, jsc, jec, ice_ocean_boundary%u10_sqr, rc=rc)
call state_getimport(importState, 'So_duu10n', isc, iec, jsc, jec, &
ice_ocean_boundary%u10_sqr, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!----
! Langmuir enhancement factor
!----
if ( associated(ice_ocean_boundary%lamult) ) then
ice_ocean_boundary%lamult (:,:) = 0._ESMF_KIND_R8
call state_getimport(importState, 'Sw_lamult', &
isc, iec, jsc, jec, ice_ocean_boundary%lamult, rc=rc)
call state_getimport(importState, 'Sw_lamult', isc, iec, jsc, jec, &
ice_ocean_boundary%lamult, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
endif

Expand Down Expand Up @@ -424,24 +432,21 @@ subroutine mom_export(ocean_public, ocean_grid, ocean_state, exportState, clock,
enddo
enddo

call State_SetExport(exportState, 'ocean_mask', &
isc, iec, jsc, jec, omask, ocean_grid, rc=rc)
call State_SetExport(exportState, 'So_omask', isc, iec, jsc, jec, omask, ocean_grid, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

deallocate(omask)

! -------
! Sea surface temperature
! -------
call State_SetExport(exportState, 'sea_surface_temperature', &
isc, iec, jsc, jec, ocean_public%t_surf, ocean_grid, rc=rc)
call State_SetExport(exportState, 'So_t', isc, iec, jsc, jec, ocean_public%t_surf, ocean_grid, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! -------
! Sea surface salinity
! -------
call State_SetExport(exportState, 's_surf', &
isc, iec, jsc, jec, ocean_public%s_surf, ocean_grid, rc=rc)
call State_SetExport(exportState, 'So_s', isc, iec, jsc, jec, ocean_public%s_surf, ocean_grid, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! -------
Expand All @@ -467,12 +472,10 @@ subroutine mom_export(ocean_public, ocean_grid, ocean_state, exportState, clock,
enddo
enddo

call State_SetExport(exportState, 'ocn_current_zonal', &
isc, iec, jsc, jec, ocz_rot, ocean_grid, rc=rc)
call State_SetExport(exportState, 'So_u', isc, iec, jsc, jec, ocz_rot, ocean_grid, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call State_SetExport(exportState, 'ocn_current_merid', &
isc, iec, jsc, jec, ocm_rot, ocean_grid, rc=rc)
call State_SetExport(exportState, 'So_v', isc, iec, jsc, jec, ocm_rot, ocean_grid, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

deallocate(ocz, ocm, ocz_rot, ocm_rot)
Expand All @@ -482,8 +485,8 @@ subroutine mom_export(ocean_public, ocean_grid, ocean_state, exportState, clock,
! -------
call ESMF_StateGet(exportState, 'So_bldepth', itemFlag, rc=rc)
if (itemFlag /= ESMF_STATEITEM_NOTFOUND) then
call State_SetExport(exportState, 'So_bldepth', &
isc, iec, jsc, jec, ocean_public%obld, ocean_grid, rc=rc)
call State_SetExport(exportState, 'So_bldepth', isc, iec, jsc, jec, &
ocean_public%obld, ocean_grid, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
endif

Expand All @@ -506,8 +509,8 @@ subroutine mom_export(ocean_public, ocean_grid, ocean_state, exportState, clock,
enddo
enddo

call State_SetExport(exportState, 'freezing_melting_potential', &
isc, iec, jsc, jec, melt_potential, ocean_grid, areacor=mod2med_areacor, rc=rc)
call State_SetExport(exportState, 'Fioo_q', isc, iec, jsc, jec, &
melt_potential, ocean_grid, areacor=mod2med_areacor, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

deallocate(melt_potential)
Expand Down Expand Up @@ -620,12 +623,10 @@ subroutine mom_export(ocean_public, ocean_grid, ocean_state, exportState, clock,
enddo
enddo

call State_SetExport(exportState, 'sea_surface_slope_zonal', &
isc, iec, jsc, jec, dhdx_rot, ocean_grid, rc=rc)
call State_SetExport(exportState, 'So_dhdx', isc, iec, jsc, jec, dhdx_rot, ocean_grid, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call State_SetExport(exportState, 'sea_surface_slope_merid', &
isc, iec, jsc, jec, dhdy_rot, ocean_grid, rc=rc)
call State_SetExport(exportState, 'So_dhdy', isc, iec, jsc, jec, dhdy_rot, ocean_grid, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

deallocate(ssh, dhdx, dhdy, dhdx_rot, dhdy_rot)
Expand Down
6 changes: 5 additions & 1 deletion src/core/MOM_forcing_type.F90
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ module MOM_forcing_type
integer :: id_saltflux = -1
integer :: id_saltFluxIn = -1
integer :: id_saltFluxAdded = -1
integer :: id_saltFluxBehind = -1

integer :: id_total_saltflux = -1
integer :: id_total_saltFluxIn = -1
Expand Down Expand Up @@ -2099,7 +2100,7 @@ subroutine register_forcing_type_diags(Time, diag, US, use_temperature, handles,
diag%axesT1,Time,'Salt flux into ocean at surface due to restoring or flux adjustment', &
units='kg m-2 s-1', conversion=US%RZ_T_to_kg_m2s)

handles%id_saltFluxAdded = register_diag_field('ocean_model', 'salt_left_behind', &
handles%id_saltFluxBehind = register_diag_field('ocean_model', 'salt_left_behind', &
diag%axesT1,Time,'Salt left in ocean at surface due to ice formation', &
units='kg m-2 s-1', conversion=US%RZ_T_to_kg_m2s)

Expand Down Expand Up @@ -3130,6 +3131,9 @@ subroutine forcing_diagnostics(fluxes_in, sfc_state, G_in, US, time_end, diag, h
call post_data(handles%id_total_saltFluxIn, total_transport, diag)
endif

if (handles%id_saltFluxBehind > 0 .and. associated(fluxes%salt_left_behind)) &
call post_data(handles%id_saltFluxBehind, fluxes%salt_left_behind, diag)

if (handles%id_saltFluxGlobalAdj > 0) &
call post_data(handles%id_saltFluxGlobalAdj, fluxes%saltFluxGlobalAdj, diag)
if (handles%id_vPrecGlobalAdj > 0) &
Expand Down
Loading

0 comments on commit db921bc

Please sign in to comment.