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
11 changes: 6 additions & 5 deletions mediator/esmFldsExchange_nems_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)

if ( trim(coupling_mode) == 'nems_orig_data') then
! atm and ocn fields required for atm/ocn flux calculation'
allocate(flds(6))
flds = (/'Sa_u ','Sa_v ', 'Sa_z ', 'Sa_tbot', 'Sa_pbot', 'Sa_shum'/)
allocate(flds(10))
flds = (/'Sa_u ','Sa_v ', 'Sa_z ', 'Sa_tbot', 'Sa_pbot', 'Sa_shum', &
'Sa_u10m','Sa_v10m', 'Sa_t2m ', 'Sa_q2m'/)
do n = 1,size(flds)
fldname = trim(flds(n))
call addfld(fldListFr(compatm)%flds, trim(fldname))
Expand Down Expand Up @@ -121,9 +122,9 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)

! to atm: unmerged from ice
! - zonal surface stress, meridional surface stress
! - surface latent heat flux,
! - surface latent heat flux,
! - surface sensible heat flux
! - surface upward longwave heat flux
! - surface upward longwave heat flux
! - evaporation water flux from water
! - mean ice volume per unit area
! - mean snow volume per unit area
Expand Down Expand Up @@ -242,7 +243,7 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
end do
deallocate(flds)

! to ocn: long wave net via auto merge
! to ocn: long wave net via auto merge
call addfld(fldListTo(compocn)%flds, 'Foxx_lwnet')
call addfld(fldListFr(compatm)%flds, 'Faxa_lwdn')
call addmap(fldListFr(compatm)%flds, 'Faxa_lwdn', compocn, maptype, 'none', 'unset')
Expand Down
30 changes: 21 additions & 9 deletions mediator/fd_nems.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,26 @@
canonical_units: W m-2
description: atmosphere import - merged ocn/ice flux
#
- standard_name: Sa_u10m
alias: inst_zonal_wind_height10m
canonical_units: m s-1
description: atmosphere export - zonal wind height 10m
#
- standard_name: Sa_v10m
alias: inst_merid_wind_height10m
canonical_units: m s-1
description: atmosphere export - meridional wind height 10m
#
- standard_name: Sa_t2m
alias: inst_temp_height2m
canonical_units: K
description: atmosphere export - temperature height 2m
#
- standard_name: Sa_q2m
alias: inst_spec_humid_height2m
canonical_units: kg kg -1
description: atmosphere export - specifc humidity height 2m
#
#-----------------------------------
# section: sea-ice export
#-----------------------------------
Expand Down Expand Up @@ -306,7 +326,7 @@
description: sea-ice export
#
- standard_name: Si_u10
canonical_units: m
canonical_units: m/s
description: sea-ice export
#
- standard_name: Si_vice
Expand Down Expand Up @@ -521,10 +541,6 @@
# section: atmosphere fields that need to be defined but are not used
#-----------------------------------
#
- standard_name: inst_temp_height2m
canonical_units: K
- standard_name: inst_spec_humid_height2m
canonical_units: K
- standard_name: inst_down_lw_flx
canonical_units: W m-2
- standard_name: inst_net_lw_flx
Expand All @@ -551,10 +567,6 @@
canonical_units: W m-2
- standard_name: inst_surface_height
canonical_units: m
- standard_name: inst_zonal_wind_height10m
canonical_units: m s-1
- standard_name: inst_merid_wind_height10m
canonical_units: m s-1
- standard_name: inst_zonal_moment_flx
canonical_units: N m-2
- standard_name: inst_merid_moment_flx
Expand Down
4 changes: 2 additions & 2 deletions mediator/med_fraction_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ subroutine med_fraction_init(gcomp, rc)
use ESMF , only : ESMF_SUCCESS, ESMF_FAILURE
use ESMF , only : ESMF_GridComp, ESMF_GridCompGet, ESMF_StateIsCreated
use ESMF , only : ESMF_FieldBundle, ESMF_FieldBundleIsCreated, ESMF_FieldBundleDestroy
use ESMF , only : ESMF_FieldBundleGet
use ESMF , only : ESMF_FieldBundleGet
use ESMF , only : ESMF_Field, ESMF_FieldGet
use esmFlds , only : coupling_mode
use esmFlds , only : compatm, compocn, compice, complnd
Expand Down Expand Up @@ -608,7 +608,7 @@ subroutine med_fraction_set(gcomp, rc)
! Update time varying fractions

use ESMF , only : ESMF_GridComp, ESMF_GridCompGet
use ESMF , only : ESMF_Field, ESMF_FieldGet
use ESMF , only : ESMF_Field, ESMF_FieldGet
use ESMF , only : ESMF_FieldBundleGet, ESMF_FieldBundleIsCreated
use ESMF , only : ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_SUCCESS
use esmFlds , only : compatm, compocn, compice, compname
Expand Down
2 changes: 1 addition & 1 deletion mediator/med_internalstate_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module med_internalstate_mod
end type mesh_info_type

type, public :: packed_data_type
integer, allocatable :: fldindex(:) ! size of number of packed fields
integer, allocatable :: fldindex(:) ! size of number of packed fields
character(len=CS) :: mapnorm ! normalization for packed field
type(ESMF_Field) :: field_src ! packed sourced field
type(ESMF_Field) :: field_dst ! packed destination field
Expand Down
6 changes: 4 additions & 2 deletions mediator/med_merge_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,10 @@ subroutine med_merge_auto_field(merge_type, field_out, ungriddedUBound_out, &
integer :: n
type(ESMF_Field) :: field_wgt
type(ESMF_Field) :: field_in
real(R8), pointer :: dp1 (:), dp2(:,:) => null() ! output pointers to 1d and 2d fields
real(R8), pointer :: dpf1(:), dpf2(:,:) => null() ! intput pointers to 1d and 2d fields
real(R8), pointer :: dp1 (:) => null()
real(R8), pointer :: dp2(:,:) => null() ! output pointers to 1d and 2d fields
real(R8), pointer :: dpf1(:) => null()
real(R8), pointer :: dpf2(:,:) => null() ! intput pointers to 1d and 2d fields
real(R8), pointer :: dpw1(:) => null() ! weight pointer
character(len=*),parameter :: subname=' (med_merge_mod: med_merge)'
!---------------------------------------
Expand Down
142 changes: 82 additions & 60 deletions mediator/med_phases_aofluxes_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module med_phases_aofluxes_mod
!--------------------------------------------------------------------------

type aoflux_type
! input
integer , pointer :: mask (:) => null() ! ocn domain mask: 0 <=> inactive cell
real(R8) , pointer :: rmask (:) => null() ! ocn domain mask: 0 <=> inactive cell
real(R8) , pointer :: lats (:) => null() ! latitudes (degrees)
Expand All @@ -54,6 +55,7 @@ module med_phases_aofluxes_mod
real(R8) , pointer :: pbot (:) => null() ! atm bottom pressure
real(R8) , pointer :: dens (:) => null() ! atm bottom density
real(R8) , pointer :: tbot (:) => null() ! atm bottom surface T
! output
real(R8) , pointer :: sen (:) => null() ! heat flux: sensible
real(R8) , pointer :: lat (:) => null() ! heat flux: latent
real(R8) , pointer :: lwup (:) => null() ! lwup over ocean
Expand All @@ -67,7 +69,6 @@ module med_phases_aofluxes_mod
real(R8) , pointer :: qref (:) => null() ! diagnostic: 2m ref Q
real(R8) , pointer :: u10 (:) => null() ! diagnostic: 10m wind speed
real(R8) , pointer :: duu10n (:) => null() ! diagnostic: 10m wind speed squared
real(R8) , pointer :: lwdn (:) => null() ! long wave, downward
real(R8) , pointer :: ustar (:) => null() ! saved ustar
real(R8) , pointer :: re (:) => null() ! saved re
real(R8) , pointer :: ssq (:) => null() ! saved sq
Expand All @@ -78,6 +79,7 @@ module med_phases_aofluxes_mod
logical :: flds_wiso ! use case
logical :: compute_atm_dens
logical :: compute_atm_thbot
integer :: ocn_surface_flux_scheme ! use case
character(*), parameter :: u_FILE_u = &
__FILE__

Expand Down Expand Up @@ -187,6 +189,7 @@ subroutine med_aofluxes_init(gcomp, aoflux, FBAtm, FBOcn, FBFrac, FBMed_aoflux,
use ESMF , only : ESMF_Field, ESMF_FieldGet, ESMF_FieldBundle, ESMF_VMGet
use NUOPC , only : NUOPC_CompAttributeGet
use shr_flux_mod , only : shr_flux_adjust_constants
use esmFlds , only : coupling_mode
!-----------------------------------------------------------------------
! Initialize pointers to the module variables
!-----------------------------------------------------------------------
Expand All @@ -201,19 +204,19 @@ subroutine med_aofluxes_init(gcomp, aoflux, FBAtm, FBOcn, FBFrac, FBMed_aoflux,
integer , intent(out) :: rc

! local variables
integer :: iam
integer :: n
integer :: lsize
real(R8), pointer :: ofrac(:) => null()
real(R8), pointer :: ifrac(:) => null()
character(CL) :: cvalue
logical :: flds_wiso ! use case
character(len=CX) :: tmpstr
real(R8) :: flux_convergence ! convergence criteria for imlicit flux computation
integer :: iam
integer :: n
integer :: lsize
real(R8), pointer :: ofrac(:) => null()
real(R8), pointer :: ifrac(:) => null()
character(CL) :: cvalue
logical :: flds_wiso ! use case
character(len=CX) :: tmpstr
real(R8) :: flux_convergence ! convergence criteria for implicit flux computation
integer :: flux_max_iteration ! maximum number of iterations for convergence
logical :: coldair_outbreak_mod ! cold air outbreak adjustment (Mahrt & Sun 1995,MWR)
logical :: isPresent, isSet
character(*),parameter :: subName = '(med_aofluxes_init) '
character(*),parameter :: subName = '(med_aofluxes_init) '
!-----------------------------------------------------------------------

if (dbug_flag > 5) then
Expand All @@ -228,9 +231,50 @@ subroutine med_aofluxes_init(gcomp, aoflux, FBAtm, FBOcn, FBFrac, FBMed_aoflux,
! get attributes that are set as module variables
!----------------------------------

call NUOPC_CompAttributeGet(gcomp, name='flds_wiso', value=cvalue, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
read(cvalue,*) flds_wiso
call NUOPC_CompAttributeGet(gcomp, name='flds_wiso', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
read(cvalue,*) flds_wiso
else
flds_wiso = .false.
end if

call NUOPC_CompAttributeGet(gcomp, name='coldair_outbreak_mod', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
read(cvalue,*) coldair_outbreak_mod
else
coldair_outbreak_mod = .false.
end if

call NUOPC_CompAttributeGet(gcomp, name='flux_max_iteration', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
read(cvalue,*) flux_max_iteration
else
flux_max_iteration = 1
end if

call NUOPC_CompAttributeGet(gcomp, name='flux_convergence', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
read(cvalue,*) flux_convergence
else
flux_convergence = 0.0_r8
end if

call NUOPC_CompAttributeGet(gcomp, name='ocn_surface_flux_scheme', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
read(cvalue,*) ocn_surface_flux_scheme
else
ocn_surface_flux_scheme = 0
end if

call shr_flux_adjust_constants(&
flux_convergence_tolerance=flux_convergence, &
flux_convergence_max_iteration=flux_max_iteration, &
coldair_outbreak_mod=coldair_outbreak_mod)

!----------------------------------
! atm/ocn fields
Expand Down Expand Up @@ -310,12 +354,27 @@ subroutine med_aofluxes_init(gcomp, aoflux, FBAtm, FBOcn, FBFrac, FBMed_aoflux,

call FB_GetFldPtr(FBAtm, fldname='Sa_z', fldptr1=aoflux%zbot, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call FB_GetFldPtr(FBAtm, fldname='Sa_u', fldptr1=aoflux%ubot, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call FB_GetFldPtr(FBAtm, fldname='Sa_v', fldptr1=aoflux%vbot, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call FB_GetFldPtr(FBAtm, fldname='Sa_tbot', fldptr1=aoflux%tbot, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

! bulk formula quantities for nems_orig_data
if (trim(coupling_mode) == 'nems_orig_data' .and. ocn_surface_flux_scheme == -1) then
call FB_GetFldPtr(FBAtm, fldname='Sa_u10m', fldptr1=aoflux%ubot, rc=rc)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we are adding an option, when ocn_surface_flux_scheme == -1, the bulk formula will use the 10m wind and 2m tmp? Have we verified that model runs stably with this method in godas run experiment?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think we need verification from the godas team that it is implemented correctly and running stably.

if (chkerr(rc,__LINE__,u_FILE_u)) return
call FB_GetFldPtr(FBAtm, fldname='Sa_v10m', fldptr1=aoflux%vbot, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call FB_GetFldPtr(FBAtm, fldname='Sa_t2m', fldptr1=aoflux%tbot, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call FB_GetFldPtr(FBAtm, fldname='Sa_q2m', fldptr1=aoflux%shum, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
else
call FB_GetFldPtr(FBAtm, fldname='Sa_u', fldptr1=aoflux%ubot, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call FB_GetFldPtr(FBAtm, fldname='Sa_v', fldptr1=aoflux%vbot, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call FB_GetFldPtr(FBAtm, fldname='Sa_tbot', fldptr1=aoflux%tbot, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call FB_GetFldPtr(FBAtm, fldname='Sa_shum', fldptr1=aoflux%shum, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
end if

! bottom level potential temperature will need to be computed if not received from the atm
if (FB_fldchk(FBAtm, 'Sa_ptem', rc=rc)) then
Expand Down Expand Up @@ -343,8 +402,6 @@ subroutine med_aofluxes_init(gcomp, aoflux, FBAtm, FBOcn, FBFrac, FBMed_aoflux,
if (chkerr(rc,__LINE__,u_FILE_u)) return
end if

call FB_GetFldPtr(FBAtm, fldname='Sa_shum', fldptr1=aoflux%shum, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (flds_wiso) then
call FB_GetFldPtr(FBAtm, fldname='Sa_shum_16O', fldptr1=aoflux%shum_16O, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand Down Expand Up @@ -382,40 +439,6 @@ subroutine med_aofluxes_init(gcomp, aoflux, FBAtm, FBOcn, FBFrac, FBMed_aoflux,
! call FB_getFldPtr(FBFrac , fldname='ifrac' , fldptr1=ifrac, rc=rc)
! if (chkerr(rc,__LINE__,u_FILE_u)) return
! where (ofrac(:) + ifrac(:) <= 0.0_R8) mask(:) = 0
!----------------------------------
! Get config variables on first call
!----------------------------------

call NUOPC_CompAttributeGet(gcomp, name='coldair_outbreak_mod', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
read(cvalue,*) coldair_outbreak_mod
else
coldair_outbreak_mod = .false.
end if

call NUOPC_CompAttributeGet(gcomp, name='flux_max_iteration', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
read(cvalue,*) flux_max_iteration
else
flux_max_iteration = 1
end if

call NUOPC_CompAttributeGet(gcomp, name='flux_convergence', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
read(cvalue,*) flux_convergence
else
flux_convergence = 0.0_r8
end if

call shr_flux_adjust_constants(&
flux_convergence_tolerance=flux_convergence, &
flux_convergence_max_iteration=flux_max_iteration, &
coldair_outbreak_mod=coldair_outbreak_mod)



if (dbug_flag > 5) then
call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO)
Expand All @@ -430,7 +453,7 @@ subroutine med_aofluxes_run(gcomp, aoflux, rc)

use ESMF , only : ESMF_GridComp, ESMF_Clock, ESMF_Time, ESMF_TimeInterval
use ESMF , only : ESMF_GridCompGet, ESMF_ClockGet, ESMF_TimeGet, ESMF_TimeIntervalGet
use ESMF , only : ESMF_LogWrite, ESMF_LogMsg_Info
use ESMF , only : ESMF_LogWrite, ESMF_LogMsg_Info, ESMF_SUCCESS
use NUOPC , only : NUOPC_CompAttributeGet
use shr_flux_mod , only : shr_flux_atmocn

Expand All @@ -454,9 +477,9 @@ subroutine med_aofluxes_run(gcomp, aoflux, rc)
character(*),parameter :: subName = '(med_aofluxes_run) '
!-----------------------------------------------------------------------

rc = ESMF_SUCCESS
call t_startf('MED:'//subname)


!----------------------------------
! Determine the compute mask
!----------------------------------
Expand Down Expand Up @@ -504,7 +527,6 @@ subroutine med_aofluxes_run(gcomp, aoflux, rc)
end do
end if

! TODO(mvertens, 2019-10-30): remove the hard-wiring of minwind and replace it with namelist input
call shr_flux_atmocn (&
nMax=lsize, zbot=aoflux%zbot, ubot=aoflux%ubot, vbot=aoflux%vbot, thbot=aoflux%thbot, &
qbot=aoflux%shum, s16O=aoflux%shum_16O, sHDO=aoflux%shum_HDO, s18O=aoflux%shum_18O, rbot=aoflux%dens, &
Expand All @@ -514,7 +536,7 @@ subroutine med_aofluxes_run(gcomp, aoflux, rc)
r16O=aoflux%roce_16O, rhdo=aoflux%roce_HDO, r18O=aoflux%roce_18O, &
evap=aoflux%evap, evap_16O=aoflux%evap_16O, evap_HDO=aoflux%evap_HDO, evap_18O=aoflux%evap_18O, &
taux=aoflux%taux, tauy=aoflux%tauy, tref=aoflux%tref, qref=aoflux%qref, &
ocn_surface_flux_scheme=0, &
ocn_surface_flux_scheme=ocn_surface_flux_scheme, &
duu10n=aoflux%duu10n, ustar_sv=aoflux%ustar, re_sv=aoflux%re, ssq_sv=aoflux%ssq, &
missval = 0.0_r8)

Expand Down
3 changes: 2 additions & 1 deletion mediator/med_phases_prep_atm_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ subroutine med_phases_prep_atm(gcomp, rc)
type(ESMF_Field) :: lfield
character(len=64) :: timestr
type(InternalState) :: is_local
real(R8), pointer :: dataPtr1(:),dataPtr2(:) => null()
real(R8), pointer :: dataPtr1(:) => null()
real(R8), pointer :: dataPtr2(:) => null()
integer :: i, j, n, n1, ncnt
character(len=*),parameter :: subname='(med_phases_prep_atm)'
!-------------------------------------------------------------------------------
Expand Down
Loading