Skip to content

Commit df76314

Browse files
authored
Merge pull request #169 from DeniseWorthen/feature/dstmapbilnPR
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
2 parents 33b10f0 + c6a10fd commit df76314

12 files changed

+160
-66
lines changed

mediator/esmFlds.F90

+6-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ module esmflds
3434
integer, public :: num_icesheets = 1
3535
logical, public :: ocn2glc_coupling ! obtained from attribute
3636

37+
logical, public :: dststatus_print = .false.
38+
3739
!-----------------------------------------------
3840
! Set mappers
3941
!-----------------------------------------------
@@ -54,7 +56,8 @@ module esmflds
5456
integer , public, parameter :: map_glc2ocn_liq = 13 ! custom smoothing map to map liq from glc->ocn (cesm only)
5557
integer , public, parameter :: map_glc2ocn_ice = 14 ! custom smoothing map to map ice from glc->ocn (cesm only)
5658
integer , public, parameter :: mapfillv_bilnr = 15 ! fill value followed by bilinear
57-
integer , public, parameter :: nmappers = 15
59+
integer , public, parameter :: mapbilnr_nstod = 16 ! bilinear with nstod extrapolation
60+
integer , public, parameter :: nmappers = 16
5861

5962
character(len=*) , public, parameter :: mapnames(nmappers) = &
6063
(/'bilnr ',&
@@ -71,7 +74,8 @@ module esmflds
7174
'rof2ocn_liq',&
7275
'glc2ocn_ice',&
7376
'glc2ocn_liq',&
74-
'fillv_bilnr'/)
77+
'fillv_bilnr',&
78+
'bilnr_nstod'/)
7579

7680
!-----------------------------------------------
7781
! Set coupling mode

mediator/esmFldsExchange_hafs_mod.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ subroutine esmFldsExchange_hafs_advt(gcomp, phase, rc)
187187
call addfld(fldListTo(compatm)%flds, 'So_ofrac')
188188

189189
!----------------------------------------------------------
190-
! to atm: surface temperatures from ocn
190+
! to atm: surface temperatures from ocn
191191
!----------------------------------------------------------
192192
call addfld(fldListFr(compocn)%flds, 'So_t')
193193
call addfld(fldListTo(compatm)%flds, 'So_t')

mediator/fd_nems.yaml

+26-26
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@
575575
description: atmosphere export - latent heat flux conversion
576576
- alias: Faox_evap
577577
standard_name : mean_evap_rate
578-
description: mediator calculation - atm/ocn specific humidity flux
578+
description: mediator calculation - atm/ocn specific humidity flux
579579
#
580580
#-----------------------------------
581581
# section: atmosphere fields that need to be defined but are not used
@@ -694,8 +694,8 @@
694694
#-----------------------------------
695695
#
696696
- standard_name: sea_surface_height_above_sea_level
697-
canonical_units: m
698-
description: ww3 import
697+
canonical_units: m
698+
description: ww3 import
699699
#
700700
- standard_name: sea_surface_salinity
701701
alias: s_surf
@@ -705,22 +705,22 @@
705705
- standard_name: surface_eastward_sea_water_velocity
706706
alias: ocn_current_zonal
707707
canonical_units: m s-1
708-
description: ww3 import
708+
description: ww3 import
709709
#
710710
- standard_name: surface_northward_sea_water_velocity
711711
alias: ocn_current_merid
712712
canonical_units: m s-1
713-
description: ww3 import
713+
description: ww3 import
714714
#
715715
- standard_name: eastward_wind_at_10m_height
716716
alias: inst_zonal_wind_height10m
717717
canonical_units: m s-1
718-
description: ww3 import
718+
description: ww3 import
719719
#
720720
- standard_name: northward_wind_at_10m_height
721721
alias: inst_merid_wind_height10m
722722
canonical_units: m s-1
723-
description: ww3 import
723+
description: ww3 import
724724
#
725725
- standard_name: sea_ice_concentration
726726
alias: ice_fraction
@@ -732,77 +732,77 @@
732732
#
733733
- standard_name: wave_induced_charnock_parameter
734734
canonical_units: 1
735-
description: ww3 export
735+
description: ww3 export
736736
#
737737
- standard_name: wave_z0_roughness_length
738738
canonical_units: 1
739-
description: ww3 export
739+
description: ww3 export
740740
#
741741
- standard_name: northward_stokes_drift_current
742742
canonical_units: m s-1
743-
description: ww3 export
743+
description: ww3 export
744744
#
745745
- standard_name: eastward_stokes_drift_current
746746
canonical_units: m s-1
747-
description: ww3 export
747+
description: ww3 export
748748
#
749749
- standard_name: eastward_partitioned_stokes_drift_1
750750
canonical_units: m s-1
751-
description: ww3 export
751+
description: ww3 export
752752
#
753753
- standard_name: eastward_partitioned_stokes_drift_2
754754
canonical_units: m s-1
755-
description: ww3 export
755+
description: ww3 export
756756
#
757757
- standard_name: eastward_partitioned_stokes_drift_3
758758
canonical_units: m s-1
759-
description: ww3 export
759+
description: ww3 export
760760
#
761761
- standard_name: northward_partitioned_stokes_drift_1
762762
canonical_units: m s-1
763-
description: ww3 export
763+
description: ww3 export
764764
#
765765
- standard_name: northward_partitioned_stokes_drift_2
766766
canonical_units: m s-1
767-
description: ww3 export
767+
description: ww3 export
768768
#
769769
- standard_name: northward_partitioned_stokes_drift_3
770770
canonical_units: m s-1
771-
description: ww3 export
771+
description: ww3 export
772772
#
773773
- standard_name: eastward_wave_bottom_current
774774
canonical_units: m s-1
775-
description: ww3 export
775+
description: ww3 export
776776
#
777777
- standard_name: northward_wave_bottom_current
778778
canonical_units: m s-1
779-
description: ww3 export
779+
description: ww3 export
780780
#
781781
- standard_name: wave_bottom_current_radian_frequency
782782
canonical_units: rad s-1
783-
description: ww3 export
783+
description: ww3 export
784784
#
785785
- standard_name: eastward_wave_radiation_stress_gradient
786786
canonical_units: Pa
787-
description: ww3 export
787+
description: ww3 export
788788
#
789789
- standard_name: northward_wave_radiation_stress_gradient
790790
canonical_units: Pa
791-
description: ww3 export
791+
description: ww3 export
792792
#
793793
- standard_name: eastward_wave_radiation_stress
794794
canonical_units: N m-1
795-
description: ww3 export
795+
description: ww3 export
796796
#
797797
- standard_name: eastward_northward_wave_radiation_stress
798798
canonical_units: N m-1
799-
description: ww3 export
799+
description: ww3 export
800800
#
801801
- standard_name: wave_bottom_current_period
802802
canonical_units: s
803-
description: ww3 export
803+
description: ww3 export
804804
#
805805
- standard_name: northward_wave_radiation_stress
806806
canonical_units: Pa
807-
description: ww3 export
807+
description: ww3 export
808808
#

mediator/med.F90

+15-2
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,8 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc)
557557
use ESMF , only : ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_METHOD_INITIALIZE
558558
use NUOPC , only : NUOPC_CompFilterPhaseMap, NUOPC_CompAttributeGet
559559
use med_internalstate_mod, only : mastertask, logunit
560-
560+
use esmFlds, only : dststatus_print
561+
561562
type(ESMF_GridComp) :: gcomp
562563
type(ESMF_State) :: importState, exportState
563564
type(ESMF_Clock) :: clock
@@ -626,6 +627,13 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc)
626627
write(msgString,'(A,i6)') trim(subname)//': Mediator dbug_flag is ',dbug_flag
627628
call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO)
628629

630+
! Obtain dststatus_print setting if present
631+
call NUOPC_CompAttributeGet(gcomp, name='dststatus_print', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
632+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
633+
if (isPresent .and. isSet) dststatus_print=(trim(cvalue)=="true")
634+
write(msgString,*) trim(subname)//': Mediator dststatus_print is ',dststatus_print
635+
call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO)
636+
629637
! Switch to IPDv03 by filtering all other phaseMap entries
630638
call NUOPC_CompFilterPhaseMap(gcomp, ESMF_METHOD_INITIALIZE, acceptStringList=(/"IPDv03p"/), rc=rc)
631639
if (ChkErr(rc,__LINE__,u_FILE_u)) return
@@ -644,6 +652,7 @@ subroutine InitializeIPDv03p1(gcomp, importState, exportState, clock, rc)
644652

645653
use ESMF , only : ESMF_GridComp, ESMF_State, ESMF_Clock, ESMF_SUCCESS, ESMF_LogFoundAllocError
646654
use ESMF , only : ESMF_LogMsg_Info, ESMF_LogWrite
655+
use ESMF , only : ESMF_END_ABORT, ESMF_Finalize
647656
use NUOPC , only : NUOPC_AddNamespace, NUOPC_Advertise, NUOPC_AddNestedState
648657
use NUOPC , only : NUOPC_CompAttributeGet, NUOPC_CompAttributeSet, NUOPC_CompAttributeAdd
649658

@@ -749,12 +758,16 @@ subroutine InitializeIPDv03p1(gcomp, importState, exportState, clock, rc)
749758
if (trim(coupling_mode) == 'cesm') then
750759
call esmFldsExchange_cesm(gcomp, phase='advertise', rc=rc)
751760
if (ChkErr(rc,__LINE__,u_FILE_u)) return
752-
else if (trim(coupling_mode(1:4)) == 'nems') then
761+
else if (trim(coupling_mode) == 'nems_orig' .or. trim(coupling_mode) == 'nems_frac' &
762+
.or. trim(coupling_mode) == 'nems_orig_data') then
753763
call esmFldsExchange_nems(gcomp, phase='advertise', rc=rc)
754764
if (ChkErr(rc,__LINE__,u_FILE_u)) return
755765
else if (trim(coupling_mode(1:4)) == 'hafs') then
756766
call esmFldsExchange_hafs(gcomp, phase='advertise', rc=rc)
757767
if (ChkErr(rc,__LINE__,u_FILE_u)) return
768+
else
769+
call ESMF_LogWrite(trim(coupling_mode)//' is not a valid coupling_mode', ESMF_LOGMSG_INFO)
770+
call ESMF_Finalize(endflag=ESMF_END_ABORT)
758771
end if
759772

760773
!------------------

mediator/med_diag_mod.F90

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module med_diag_mod
2222
use ESMF , only : ESMF_GridComp, ESMF_Clock, ESMF_Time
2323
use ESMF , only : ESMF_VM, ESMF_VMReduce, ESMF_REDUCE_SUM
2424
use ESMF , only : ESMF_GridCompGet, ESMF_ClockGet, ESMF_TimeGet
25-
use ESMF , only : ESMF_Alarm, ESMF_ClockGetAlarm, ESMF_AlarmIsRinging, ESMF_AlarmRingerOff
25+
use ESMF , only : ESMF_Alarm, ESMF_ClockGetAlarm, ESMF_AlarmIsRinging, ESMF_AlarmRingerOff
2626
use ESMF , only : ESMF_FieldBundle, ESMF_Field, ESMF_FieldGet
2727
use shr_const_mod , only : shr_const_rearth, shr_const_pi, shr_const_latice
2828
use shr_const_mod , only : shr_const_ice_ref_sal, shr_const_ocn_ref_sal, shr_const_isspval
@@ -800,7 +800,7 @@ subroutine diag_atm_wiso_recv(FB, fldname, nf_16O, nf_18O, nf_HDO, areas, lats,
800800
integer , intent(out) :: rc
801801
! local variables
802802
integer :: n, ip
803-
type(ESMF_Field) :: lfield
803+
type(ESMF_Field) :: lfield
804804
real(r8), pointer :: data(:,:) => null()
805805
! ------------------------------------------------------------------
806806
rc = ESMF_SUCCESS
@@ -857,7 +857,7 @@ subroutine diag_atm_wiso_send(FB, fldname, nf_16O, nf_18O, nf_HDO, areas, lats,
857857
integer , intent(out) :: rc
858858
! local variables
859859
integer :: n, ip
860-
type(ESMF_Field) :: lfield
860+
type(ESMF_Field) :: lfield
861861
real(r8), pointer :: data(:,:) => null()
862862
! ------------------------------------------------------------------
863863
rc = ESMF_SUCCESS
@@ -1575,7 +1575,7 @@ subroutine diag_ice_recv(FB, fldname, nf, areas, lats, ifrac, budget, minus, sca
15751575
integer , intent(out) :: rc
15761576
! local variables
15771577
integer :: n, ip
1578-
type(ESMF_Field) :: lfield
1578+
type(ESMF_Field) :: lfield
15791579
real(r8), pointer :: data(:) => null()
15801580
! ------------------------------------------------------------------
15811581
rc = ESMF_SUCCESS
@@ -1621,7 +1621,7 @@ subroutine diag_ice_recv_wiso(FB, fldname, nf_16O, nf_18O, nf_HDO, areas, lats,
16211621
integer , intent(out) :: rc
16221622
! local variables
16231623
integer :: n, ip
1624-
type(ESMF_Field) :: lfield
1624+
type(ESMF_Field) :: lfield
16251625
real(r8), pointer :: data(:,:) => null()
16261626
! ------------------------------------------------------------------
16271627
rc = ESMF_SUCCESS
@@ -1754,7 +1754,7 @@ subroutine diag_ice_send(FB, fldname, nf, areas, lats, ifrac, budget, rc)
17541754
integer , intent(out) :: rc
17551755
! local variables
17561756
integer :: n, ip
1757-
type(ESMF_Field) :: lfield
1757+
type(ESMF_Field) :: lfield
17581758
real(r8), pointer :: data(:) => null()
17591759
! ------------------------------------------------------------------
17601760
rc = ESMF_SUCCESS
@@ -1788,7 +1788,7 @@ subroutine diag_ice_send_wiso(FB, fldname, nf_16O, nf_18O, nf_HDO, areas, lats,
17881788

17891789
! local variables
17901790
integer :: n, ip
1791-
type(ESMF_Field) :: lfield
1791+
type(ESMF_Field) :: lfield
17921792
real(r8), pointer :: data(:,:) => null()
17931793
! ------------------------------------------------------------------
17941794
rc = ESMF_SUCCESS

mediator/med_fraction_mod.F90

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ subroutine med_fraction_init(gcomp, rc)
295295
end if
296296

297297
!---------------------------------------
298-
! Set 'ofrac' in FBFrac(compocn)
298+
! Set 'ofrac' in FBFrac(compocn)
299299
!---------------------------------------
300300

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

684-
! set ifrac
684+
! set ifrac
685685
if (associated(ifrac)) then
686686
ifrac(:) = Si_ifrac(:) * Si_imask(:)
687687
endif

mediator/med_io_mod.F90

+8-8
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ subroutine med_io_init(gcomp, rc)
181181
call ESMF_VMGet(vm, mpiCommunicator=comm, localPet=localPet, petCount=petCount, rc=rc)
182182
if (chkerr(rc,__LINE__,u_FILE_u)) return
183183

184-
! query component specific PIO attributes
184+
! query component specific PIO attributes
185185
! pio_netcdf_format
186186
call NUOPC_CompAttributeGet(gcomp, name='pio_netcdf_format', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
187187
if (ChkErr(rc,__LINE__,u_FILE_u)) return
@@ -212,9 +212,9 @@ subroutine med_io_init(gcomp, rc)
212212
if (isPresent .and. isSet) then
213213
cvalue = ESMF_UtilStringUpperCase(cvalue)
214214
if (trim(cvalue) .eq. 'NETCDF') then
215-
pio_iotype = PIO_IOTYPE_NETCDF
215+
pio_iotype = PIO_IOTYPE_NETCDF
216216
else if (trim(cvalue) .eq. 'PNETCDF') then
217-
pio_iotype = PIO_IOTYPE_PNETCDF
217+
pio_iotype = PIO_IOTYPE_PNETCDF
218218
else if (trim(cvalue) .eq. 'NETCDF4C') then
219219
pio_iotype = PIO_IOTYPE_NETCDF4C
220220
else if (trim(cvalue) .eq. 'NETCDF4P') then
@@ -276,7 +276,7 @@ subroutine med_io_init(gcomp, rc)
276276
write(logunit,*) ' parallel io requires at least two io pes - following parameters are updated:'
277277
write(logunit,*) trim(subname), ' : pio_stride = ', pio_stride
278278
write(logunit,*) trim(subname), ' : pio_numiotasks = ', pio_numiotasks
279-
end if
279+
end if
280280
endif
281281

282282
! check/set/correct io pio parameters
@@ -294,7 +294,7 @@ subroutine med_io_init(gcomp, rc)
294294
end if
295295
if (pio_stride == 1) then
296296
pio_root = 0
297-
endif
297+
endif
298298

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

369-
! query shared PIO rearranger attributes
370-
! pio_rearr_comm_type
369+
! query shared PIO rearranger attributes
370+
! pio_rearr_comm_type
371371
call NUOPC_CompAttributeGet(gcomp, name='pio_rearr_comm_type', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
372372
if (ChkErr(rc,__LINE__,u_FILE_u)) return
373373

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

391391
! pio_rearr_comm_fcd
392392
call NUOPC_CompAttributeGet(gcomp, name='pio_rearr_comm_fcd', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)

0 commit comments

Comments
 (0)