Skip to content

Commit

Permalink
Merge pull request #169 from DeniseWorthen/feature/dstmapbilnPR
Browse files Browse the repository at this point in the history
Retrieval of dstStatusField and optionally writing to file; add mapbilnr_nstod mapping
### Description of changes
Adds ability to write dstStatusField from RegridStore. Adds bilinear mapping with NSTOD extrapolation.
### Specific notes
A flag is added (dststatus_print, default false) in med_map_mod.F90 to write the dstStatusField from the RegridStore operation. Since ESMF_FieldWrite does not order the written field correctly, a field containing the index order is also retrieved and written. This can be used off-line to re-order the data in the dststatus file. 
A bilinear mapping type with NSTOD extrapolation is added. This is currently unused but will be implemented in the ufs-model system for mapping the ATM states (bottom T,P,Q,U,V) using bilinear instead of conservative mapping.
A small change is added to abort if coupling_mode is not supported. 

Trailing white space cleanup, primarily in fd_nems.yaml

CMEPS Issues Fixed (include github issue #):
NOAA-EMC#38

Are changes expected to change answers?
 - [X] bit for bit
 - [ ] different at roundoff level
 - [ ] more substantial 

Any User Interface Changes (namelist or namelist defaults changes)?
 - [ ] Yes
 - [X] No

Testing performed if application target is CESM:(either UFS-S2S or CESM testing is required):
- [ ] (recommended) CIME_DRIVER=nuopc scripts_regression_tests.py
   - machines:
   - details (e.g. failed tests):
- [ ] (recommended) CESM testlist_drv.xml
   - machines and compilers:
   - details (e.g. failed tests):
- [ ] (optional) CESM prealpha test
   - machines and compilers
   - details (e.g. failed tests):
- [ ] (other) please described in detail
   - machines and compilers
   - details (e.g. failed tests):

Testing performed if application target is UFS-coupled:
- [X] (recommended) UFS-coupled testing
   - description: ufs-weather-model (3e46f5b) switched to this branch for CMEPS with shr_mod_pio.F90 from CMakeLists.txt in CMEPS-interface
   - details (e.g. failed tests): All ufs-coupled and ufs-datm tests pass current baselines
 CESM - verified that SMS_Vnuopc_Ld1.f09_g17.B1850.cheyenne_intel was bfb with these changes
  • Loading branch information
mvertens authored Mar 28, 2021
2 parents 33b10f0 + c6a10fd commit df76314
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 66 deletions.
8 changes: 6 additions & 2 deletions mediator/esmFlds.F90
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ module esmflds
integer, public :: num_icesheets = 1
logical, public :: ocn2glc_coupling ! obtained from attribute

logical, public :: dststatus_print = .false.

!-----------------------------------------------
! Set mappers
!-----------------------------------------------
Expand All @@ -54,7 +56,8 @@ module esmflds
integer , public, parameter :: map_glc2ocn_liq = 13 ! custom smoothing map to map liq from glc->ocn (cesm only)
integer , public, parameter :: map_glc2ocn_ice = 14 ! custom smoothing map to map ice from glc->ocn (cesm only)
integer , public, parameter :: mapfillv_bilnr = 15 ! fill value followed by bilinear
integer , public, parameter :: nmappers = 15
integer , public, parameter :: mapbilnr_nstod = 16 ! bilinear with nstod extrapolation
integer , public, parameter :: nmappers = 16

character(len=*) , public, parameter :: mapnames(nmappers) = &
(/'bilnr ',&
Expand All @@ -71,7 +74,8 @@ module esmflds
'rof2ocn_liq',&
'glc2ocn_ice',&
'glc2ocn_liq',&
'fillv_bilnr'/)
'fillv_bilnr',&
'bilnr_nstod'/)

!-----------------------------------------------
! Set coupling mode
Expand Down
2 changes: 1 addition & 1 deletion mediator/esmFldsExchange_hafs_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ subroutine esmFldsExchange_hafs_advt(gcomp, phase, rc)
call addfld(fldListTo(compatm)%flds, 'So_ofrac')

!----------------------------------------------------------
! to atm: surface temperatures from ocn
! to atm: surface temperatures from ocn
!----------------------------------------------------------
call addfld(fldListFr(compocn)%flds, 'So_t')
call addfld(fldListTo(compatm)%flds, 'So_t')
Expand Down
52 changes: 26 additions & 26 deletions mediator/fd_nems.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@
description: atmosphere export - latent heat flux conversion
- alias: Faox_evap
standard_name : mean_evap_rate
description: mediator calculation - atm/ocn specific humidity flux
description: mediator calculation - atm/ocn specific humidity flux
#
#-----------------------------------
# section: atmosphere fields that need to be defined but are not used
Expand Down Expand Up @@ -694,8 +694,8 @@
#-----------------------------------
#
- standard_name: sea_surface_height_above_sea_level
canonical_units: m
description: ww3 import
canonical_units: m
description: ww3 import
#
- standard_name: sea_surface_salinity
alias: s_surf
Expand All @@ -705,22 +705,22 @@
- standard_name: surface_eastward_sea_water_velocity
alias: ocn_current_zonal
canonical_units: m s-1
description: ww3 import
description: ww3 import
#
- standard_name: surface_northward_sea_water_velocity
alias: ocn_current_merid
canonical_units: m s-1
description: ww3 import
description: ww3 import
#
- standard_name: eastward_wind_at_10m_height
alias: inst_zonal_wind_height10m
canonical_units: m s-1
description: ww3 import
description: ww3 import
#
- standard_name: northward_wind_at_10m_height
alias: inst_merid_wind_height10m
canonical_units: m s-1
description: ww3 import
description: ww3 import
#
- standard_name: sea_ice_concentration
alias: ice_fraction
Expand All @@ -732,77 +732,77 @@
#
- standard_name: wave_induced_charnock_parameter
canonical_units: 1
description: ww3 export
description: ww3 export
#
- standard_name: wave_z0_roughness_length
canonical_units: 1
description: ww3 export
description: ww3 export
#
- standard_name: northward_stokes_drift_current
canonical_units: m s-1
description: ww3 export
description: ww3 export
#
- standard_name: eastward_stokes_drift_current
canonical_units: m s-1
description: ww3 export
description: ww3 export
#
- standard_name: eastward_partitioned_stokes_drift_1
canonical_units: m s-1
description: ww3 export
description: ww3 export
#
- standard_name: eastward_partitioned_stokes_drift_2
canonical_units: m s-1
description: ww3 export
description: ww3 export
#
- standard_name: eastward_partitioned_stokes_drift_3
canonical_units: m s-1
description: ww3 export
description: ww3 export
#
- standard_name: northward_partitioned_stokes_drift_1
canonical_units: m s-1
description: ww3 export
description: ww3 export
#
- standard_name: northward_partitioned_stokes_drift_2
canonical_units: m s-1
description: ww3 export
description: ww3 export
#
- standard_name: northward_partitioned_stokes_drift_3
canonical_units: m s-1
description: ww3 export
description: ww3 export
#
- standard_name: eastward_wave_bottom_current
canonical_units: m s-1
description: ww3 export
description: ww3 export
#
- standard_name: northward_wave_bottom_current
canonical_units: m s-1
description: ww3 export
description: ww3 export
#
- standard_name: wave_bottom_current_radian_frequency
canonical_units: rad s-1
description: ww3 export
description: ww3 export
#
- standard_name: eastward_wave_radiation_stress_gradient
canonical_units: Pa
description: ww3 export
description: ww3 export
#
- standard_name: northward_wave_radiation_stress_gradient
canonical_units: Pa
description: ww3 export
description: ww3 export
#
- standard_name: eastward_wave_radiation_stress
canonical_units: N m-1
description: ww3 export
description: ww3 export
#
- standard_name: eastward_northward_wave_radiation_stress
canonical_units: N m-1
description: ww3 export
description: ww3 export
#
- standard_name: wave_bottom_current_period
canonical_units: s
description: ww3 export
description: ww3 export
#
- standard_name: northward_wave_radiation_stress
canonical_units: Pa
description: ww3 export
description: ww3 export
#
17 changes: 15 additions & 2 deletions mediator/med.F90
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,8 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc)
use ESMF , only : ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_METHOD_INITIALIZE
use NUOPC , only : NUOPC_CompFilterPhaseMap, NUOPC_CompAttributeGet
use med_internalstate_mod, only : mastertask, logunit

use esmFlds, only : dststatus_print

type(ESMF_GridComp) :: gcomp
type(ESMF_State) :: importState, exportState
type(ESMF_Clock) :: clock
Expand Down Expand Up @@ -626,6 +627,13 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc)
write(msgString,'(A,i6)') trim(subname)//': Mediator dbug_flag is ',dbug_flag
call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO)

! Obtain dststatus_print setting if present
call NUOPC_CompAttributeGet(gcomp, name='dststatus_print', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) dststatus_print=(trim(cvalue)=="true")
write(msgString,*) trim(subname)//': Mediator dststatus_print is ',dststatus_print
call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO)

! Switch to IPDv03 by filtering all other phaseMap entries
call NUOPC_CompFilterPhaseMap(gcomp, ESMF_METHOD_INITIALIZE, acceptStringList=(/"IPDv03p"/), rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand All @@ -644,6 +652,7 @@ subroutine InitializeIPDv03p1(gcomp, importState, exportState, clock, rc)

use ESMF , only : ESMF_GridComp, ESMF_State, ESMF_Clock, ESMF_SUCCESS, ESMF_LogFoundAllocError
use ESMF , only : ESMF_LogMsg_Info, ESMF_LogWrite
use ESMF , only : ESMF_END_ABORT, ESMF_Finalize
use NUOPC , only : NUOPC_AddNamespace, NUOPC_Advertise, NUOPC_AddNestedState
use NUOPC , only : NUOPC_CompAttributeGet, NUOPC_CompAttributeSet, NUOPC_CompAttributeAdd

Expand Down Expand Up @@ -749,12 +758,16 @@ subroutine InitializeIPDv03p1(gcomp, importState, exportState, clock, rc)
if (trim(coupling_mode) == 'cesm') then
call esmFldsExchange_cesm(gcomp, phase='advertise', rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
else if (trim(coupling_mode(1:4)) == 'nems') then
else if (trim(coupling_mode) == 'nems_orig' .or. trim(coupling_mode) == 'nems_frac' &
.or. trim(coupling_mode) == 'nems_orig_data') then
call esmFldsExchange_nems(gcomp, phase='advertise', rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
else if (trim(coupling_mode(1:4)) == 'hafs') then
call esmFldsExchange_hafs(gcomp, phase='advertise', rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
else
call ESMF_LogWrite(trim(coupling_mode)//' is not a valid coupling_mode', ESMF_LOGMSG_INFO)
call ESMF_Finalize(endflag=ESMF_END_ABORT)
end if

!------------------
Expand Down
14 changes: 7 additions & 7 deletions mediator/med_diag_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module med_diag_mod
use ESMF , only : ESMF_GridComp, ESMF_Clock, ESMF_Time
use ESMF , only : ESMF_VM, ESMF_VMReduce, ESMF_REDUCE_SUM
use ESMF , only : ESMF_GridCompGet, ESMF_ClockGet, ESMF_TimeGet
use ESMF , only : ESMF_Alarm, ESMF_ClockGetAlarm, ESMF_AlarmIsRinging, ESMF_AlarmRingerOff
use ESMF , only : ESMF_Alarm, ESMF_ClockGetAlarm, ESMF_AlarmIsRinging, ESMF_AlarmRingerOff
use ESMF , only : ESMF_FieldBundle, ESMF_Field, ESMF_FieldGet
use shr_const_mod , only : shr_const_rearth, shr_const_pi, shr_const_latice
use shr_const_mod , only : shr_const_ice_ref_sal, shr_const_ocn_ref_sal, shr_const_isspval
Expand Down Expand Up @@ -800,7 +800,7 @@ subroutine diag_atm_wiso_recv(FB, fldname, nf_16O, nf_18O, nf_HDO, areas, lats,
integer , intent(out) :: rc
! local variables
integer :: n, ip
type(ESMF_Field) :: lfield
type(ESMF_Field) :: lfield
real(r8), pointer :: data(:,:) => null()
! ------------------------------------------------------------------
rc = ESMF_SUCCESS
Expand Down Expand Up @@ -857,7 +857,7 @@ subroutine diag_atm_wiso_send(FB, fldname, nf_16O, nf_18O, nf_HDO, areas, lats,
integer , intent(out) :: rc
! local variables
integer :: n, ip
type(ESMF_Field) :: lfield
type(ESMF_Field) :: lfield
real(r8), pointer :: data(:,:) => null()
! ------------------------------------------------------------------
rc = ESMF_SUCCESS
Expand Down Expand Up @@ -1575,7 +1575,7 @@ subroutine diag_ice_recv(FB, fldname, nf, areas, lats, ifrac, budget, minus, sca
integer , intent(out) :: rc
! local variables
integer :: n, ip
type(ESMF_Field) :: lfield
type(ESMF_Field) :: lfield
real(r8), pointer :: data(:) => null()
! ------------------------------------------------------------------
rc = ESMF_SUCCESS
Expand Down Expand Up @@ -1621,7 +1621,7 @@ subroutine diag_ice_recv_wiso(FB, fldname, nf_16O, nf_18O, nf_HDO, areas, lats,
integer , intent(out) :: rc
! local variables
integer :: n, ip
type(ESMF_Field) :: lfield
type(ESMF_Field) :: lfield
real(r8), pointer :: data(:,:) => null()
! ------------------------------------------------------------------
rc = ESMF_SUCCESS
Expand Down Expand Up @@ -1754,7 +1754,7 @@ subroutine diag_ice_send(FB, fldname, nf, areas, lats, ifrac, budget, rc)
integer , intent(out) :: rc
! local variables
integer :: n, ip
type(ESMF_Field) :: lfield
type(ESMF_Field) :: lfield
real(r8), pointer :: data(:) => null()
! ------------------------------------------------------------------
rc = ESMF_SUCCESS
Expand Down Expand Up @@ -1788,7 +1788,7 @@ subroutine diag_ice_send_wiso(FB, fldname, nf_16O, nf_18O, nf_HDO, areas, lats,

! local variables
integer :: n, ip
type(ESMF_Field) :: lfield
type(ESMF_Field) :: lfield
real(r8), pointer :: data(:,:) => null()
! ------------------------------------------------------------------
rc = ESMF_SUCCESS
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 @@ -295,7 +295,7 @@ subroutine med_fraction_init(gcomp, rc)
end if

!---------------------------------------
! Set 'ofrac' in FBFrac(compocn)
! Set 'ofrac' in FBFrac(compocn)
!---------------------------------------

if (is_local%wrap%comp_present(compocn)) then
Expand Down Expand Up @@ -681,7 +681,7 @@ subroutine med_fraction_set(gcomp, rc)
! The model mask is normally assumed to be an selected ocean mask from a fully coupled run
! So in it is (1-land fraction) on the atm grid

! set ifrac
! set ifrac
if (associated(ifrac)) then
ifrac(:) = Si_ifrac(:) * Si_imask(:)
endif
Expand Down
16 changes: 8 additions & 8 deletions mediator/med_io_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ subroutine med_io_init(gcomp, rc)
call ESMF_VMGet(vm, mpiCommunicator=comm, localPet=localPet, petCount=petCount, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

! query component specific PIO attributes
! query component specific PIO attributes
! pio_netcdf_format
call NUOPC_CompAttributeGet(gcomp, name='pio_netcdf_format', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down Expand Up @@ -212,9 +212,9 @@ subroutine med_io_init(gcomp, rc)
if (isPresent .and. isSet) then
cvalue = ESMF_UtilStringUpperCase(cvalue)
if (trim(cvalue) .eq. 'NETCDF') then
pio_iotype = PIO_IOTYPE_NETCDF
pio_iotype = PIO_IOTYPE_NETCDF
else if (trim(cvalue) .eq. 'PNETCDF') then
pio_iotype = PIO_IOTYPE_PNETCDF
pio_iotype = PIO_IOTYPE_PNETCDF
else if (trim(cvalue) .eq. 'NETCDF4C') then
pio_iotype = PIO_IOTYPE_NETCDF4C
else if (trim(cvalue) .eq. 'NETCDF4P') then
Expand Down Expand Up @@ -276,7 +276,7 @@ subroutine med_io_init(gcomp, rc)
write(logunit,*) ' parallel io requires at least two io pes - following parameters are updated:'
write(logunit,*) trim(subname), ' : pio_stride = ', pio_stride
write(logunit,*) trim(subname), ' : pio_numiotasks = ', pio_numiotasks
end if
end if
endif

! check/set/correct io pio parameters
Expand All @@ -294,7 +294,7 @@ subroutine med_io_init(gcomp, rc)
end if
if (pio_stride == 1) then
pio_root = 0
endif
endif

if (pio_root + (pio_stride)*(pio_numiotasks-1) >= petCount .or. &
pio_stride <= 0 .or. pio_numiotasks <= 0 .or. pio_root < 0 .or. pio_root > petCount-1) then
Expand Down Expand Up @@ -366,8 +366,8 @@ subroutine med_io_init(gcomp, rc)
! set PIO debug level
call pio_setdebuglevel(pio_debug_level)

! query shared PIO rearranger attributes
! pio_rearr_comm_type
! query shared PIO rearranger attributes
! pio_rearr_comm_type
call NUOPC_CompAttributeGet(gcomp, name='pio_rearr_comm_type', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand All @@ -386,7 +386,7 @@ subroutine med_io_init(gcomp, rc)
cvalue = 'P2P'
pio_rearr_comm_type = PIO_REARR_COMM_P2P
end if
if (localPet == 0) write(logunit,*) trim(subname), ' : pio_rearr_comm_type = ', trim(cvalue), pio_rearr_comm_type
if (localPet == 0) write(logunit,*) trim(subname), ' : pio_rearr_comm_type = ', trim(cvalue), pio_rearr_comm_type

! pio_rearr_comm_fcd
call NUOPC_CompAttributeGet(gcomp, name='pio_rearr_comm_fcd', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
Expand Down
Loading

0 comments on commit df76314

Please sign in to comment.