Skip to content

Commit ffcdf1c

Browse files
authored
Merge pull request #2 from DeniseWorthen/feature/cmepsaccum
fixes for ufs error in completeFieldInitialization
2 parents 1b3ae0f + a2ed0c7 commit ffcdf1c

12 files changed

+137
-126
lines changed

mediator/esmFldsExchange_hafs_mod.F90

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ subroutine esmFldsExchange_hafs_advt(gcomp, phase, rc)
230230
!=====================================================================
231231

232232
! ---------------------------------------------------------------------
233-
! to wav: 10-m wind components
233+
! to wav: 10-m wind components
234234
! ---------------------------------------------------------------------
235235
if (hafs_attr%atm_present .and. hafs_attr%wav_present) then
236236
allocate(S_flds(2))
@@ -510,7 +510,7 @@ subroutine esmFldsExchange_hafs_attr(gcomp, hafs_attr, rc)
510510
if (chkerr(rc,__LINE__,u_FILE_u)) return
511511

512512
!----------------------------------------------------------
513-
! Component active or not?
513+
! Component active or not?
514514
!----------------------------------------------------------
515515

516516
call NUOPC_CompAttributeGet(gcomp, name='ATM_model', &

mediator/esmFldsExchange_nems_mod.F90

+12-4
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
106106
end if
107107

108108
! unused fields from ice - but that are needed to be realized by the cice cap
109-
call addfld(fldListFr(compice)%flds, 'Si_avsdf')
110-
call addfld(fldListFr(compice)%flds, 'Si_avsdr')
111-
call addfld(fldListFr(compice)%flds, 'Si_anidf')
112-
call addfld(fldListFr(compice)%flds, 'Si_anidr')
113109
call addfld(fldListFr(compice)%flds, 'Faii_evap')
114110
call addfld(fldListFr(compice)%flds, 'mean_sw_pen_to_ocn')
115111

@@ -145,6 +141,18 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
145141
end do
146142
deallocate(flds)
147143

144+
allocate(flds(4))
145+
flds = (/'avsdr ', 'avsdf ', &
146+
'anidr ', 'anidf '/)
147+
do n = 1,size(flds)
148+
fldname = 'Si_'//trim(flds(n))
149+
call addfld(fldListFr(compice)%flds, trim(fldname))
150+
call addfld(fldListTo(compatm)%flds, trim(fldname))
151+
call addmap(fldListFr(compice)%flds, trim(fldname), compatm, maptype, 'ifrac', 'unset')
152+
call addmrg(fldListTo(compatm)%flds, trim(fldname), mrg_from=compice, mrg_fld=trim(fldname), mrg_type='copy')
153+
end do
154+
deallocate(flds)
155+
148156
! to atm: unmerged surface temperatures from ocn
149157
call addfld(fldListFr(compocn)%flds, 'So_t')
150158
call addfld(fldListTo(compatm)%flds, 'So_t')

mediator/med.F90

+95-98
Large diffs are not rendered by default.

mediator/med_fraction_mod.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ subroutine med_fraction_init(gcomp, rc)
224224
(ESMF_StateIsCreated(is_local%wrap%NStateImp(n1),rc=rc) .or. &
225225
ESMF_StateIsCreated(is_local%wrap%NStateExp(n1),rc=rc))) then
226226
! Check number of fields in the state
227-
call State_GetNumFields(is_local%wrap%NStateImp(n1), fieldCount, rc=rc)
227+
call State_GetNumFields(is_local%wrap%NStateImp(n1), fieldCount, rc=rc)
228228
if (ChkErr(rc,__LINE__,u_FILE_u)) return
229229

230230
! create FBFrac

mediator/med_internalstate_mod.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module med_internalstate_mod
7171
type(ESMF_FieldBundle) :: FBImp(ncomps,ncomps) ! Import data from various components interpolated to various grids
7272
type(ESMF_FieldBundle) :: FBExp(ncomps) ! Export data for various components, on their grid
7373

74-
! Mediator field bundles for ocean albedo
74+
! Mediator field bundles for ocean albedo
7575
type(ESMF_FieldBundle) :: FBMed_ocnalb_o ! Ocn albedo on ocn grid
7676
type(ESMF_FieldBundle) :: FBMed_ocnalb_a ! Ocn albedo on atm grid
7777
type(packed_data_type) :: packed_data_ocnalb_o2a(nmappers) ! packed data for mapping ocn->atm

mediator/med_map_mod.F90

+7-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ module med_map_mod
4646
subroutine med_map_RouteHandles_initfrom_esmflds(gcomp, flds_scalar_name, llogunit, rc)
4747

4848
!---------------------------------------------
49-
! Initialize route handles in the mediator and also
49+
! Initialize route handles in the mediator and also
5050
! nitialize unity normalization fields and do the mapping for
5151
! unity normalization up front
52-
!
52+
!
5353
! Assumptions:
5454
! - Route handles are created per target field bundles NOT
5555
! per individual fields in the bundle
@@ -138,7 +138,7 @@ subroutine med_map_RouteHandles_initfrom_esmflds(gcomp, flds_scalar_name, llogun
138138
if (chkerr(rc,__LINE__,u_FILE_u)) return
139139

140140
! Check number of fields in source FB on destination mesh and get destination field
141-
if (.not. ESMF_FieldBundleIsCreated(is_local%wrap%FBImp(n1,n2))) then
141+
if (.not. ESMF_FieldBundleIsCreated(is_local%wrap%FBImp(n1,n2))) then
142142
call ESMF_LogWrite(trim(subname)//'FBImp('//trim(compname(n1))//','//trim(compname(n2))//')'// &
143143
' has not been created', ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u)
144144
rc = ESMF_FAILURE
@@ -213,7 +213,7 @@ subroutine med_map_RouteHandles_initfrom_esmflds(gcomp, flds_scalar_name, llogun
213213
allocate(fieldlist(fieldcount))
214214
call ESMF_FieldBundleGet(is_local%wrap%FBExp(n1), fieldlist=fieldlist, rc=rc)
215215
if (ChkErr(rc,__LINE__,u_FILE_u)) return
216-
else
216+
else
217217
allocate(fieldlist(fieldcount))
218218
call ESMF_FieldBundleGet(is_local%wrap%FBImp(n1,n1), fieldlist=fieldlist, rc=rc)
219219
if (ChkErr(rc,__LINE__,u_FILE_u)) return
@@ -893,8 +893,10 @@ subroutine med_map_packed_field_create(destcomp, flds_scalar_name, &
893893

894894
packed_data(mapindex)%field_fracsrc = ESMF_FieldCreate(lmesh_src, ESMF_TYPEKIND_R8, &
895895
meshloc=ESMF_MESHLOC_ELEMENT, rc=rc)
896+
if (chkerr(rc,__LINE__,u_FILE_u)) return
896897
packed_data(mapindex)%field_fracdst = ESMF_FieldCreate(lmesh_dst, ESMF_TYPEKIND_R8, &
897898
meshloc=ESMF_MESHLOC_ELEMENT, rc=rc)
899+
if (chkerr(rc,__LINE__,u_FILE_u)) return
898900
end if
899901
end do ! end loop over mapindex
900902

@@ -1047,6 +1049,7 @@ subroutine med_map_field_packed(FBSrc, FBDst, FBFracSrc, field_normOne, packed_d
10471049
maptype=mapindex, &
10481050
field_normsrc=field_fracsrc, &
10491051
field_normdst=packed_data(mapindex)%field_fracdst, rc=rc)
1052+
if (chkerr(rc,__LINE__,u_FILE_u)) return
10501053

10511054
else if ( trim(packed_data(mapindex)%mapnorm) == 'one' .or. trim(packed_data(mapindex)%mapnorm) == 'none') then
10521055

mediator/med_methods_mod.F90

+4-1
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,10 @@ subroutine med_methods_FB_init_pointer(StateIn, FBout, flds_scalar_name, name, r
168168
! set ungridded dimensions and GridToFieldMap for field
169169
call ESMF_AttributeGet(lfield, name="UngriddedLBound", convention="NUOPC", &
170170
purpose="Instance", valueList=ungriddedLBound, rc=rc)
171+
if (chkerr(rc,__LINE__,u_FILE_u)) return
171172
call ESMF_AttributeGet(lfield, name="UngriddedUBound", convention="NUOPC", &
172173
purpose="Instance", valueList=ungriddedUBound, rc=rc)
174+
if (chkerr(rc,__LINE__,u_FILE_u)) return
173175
call ESMF_AttributeGet(lfield, name="GridToFieldMap", convention="NUOPC", &
174176
purpose="Instance", valueList=gridToFieldMap, rc=rc)
175177
if (chkerr(rc,__LINE__,u_FILE_u)) return
@@ -464,8 +466,10 @@ subroutine med_methods_FB_init(FBout, flds_scalar_name, fieldNameList, FBgeom, S
464466
allocate(ungriddedLBound(ungriddedCount), ungriddedUBound(ungriddedCount))
465467
call ESMF_AttributeGet(lfield, name="UngriddedLBound", convention="NUOPC", &
466468
purpose="Instance", valueList=ungriddedLBound, rc=rc)
469+
if (chkerr(rc,__LINE__,u_FILE_u)) return
467470
call ESMF_AttributeGet(lfield, name="UngriddedUBound", convention="NUOPC", &
468471
purpose="Instance", valueList=ungriddedUBound, rc=rc)
472+
if (chkerr(rc,__LINE__,u_FILE_u)) return
469473

470474
call ESMF_AttributeGet(lfield, name="GridToFieldMap", convention="NUOPC", &
471475
purpose="Instance", itemCount=gridToFieldMapCount, rc=rc)
@@ -667,7 +671,6 @@ subroutine med_methods_State_getNumFields(State, fieldnum, rc)
667671
! local variables
668672
integer :: n,itemCount
669673
type(ESMF_Field), pointer :: fieldList(:) => null()
670-
type(ESMF_StateItem_Flag), pointer :: itemTypeList(:) => null()
671674
character(len=*),parameter :: subname='(med_methods_State_getNumFields)'
672675
! ----------------------------------------------
673676

mediator/med_phases_aofluxes_mod.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ subroutine med_phases_aofluxes_init_fldbuns(gcomp, rc)
189189
end do
190190
end if
191191

192-
! Create required field bundles
192+
! Create required field bundles
193193
if (is_local%wrap%aoflux_grid == 'ogrid' .or. is_local%wrap%aoflux_grid == 'agrid') then
194194

195195
! Create the field bundle is_local%wrap%FBImp(compatm,compocn) if needed

mediator/med_phases_prep_atm_mod.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ subroutine med_phases_prep_atm(gcomp, rc)
198198
end if
199199

200200
! Note - the following needs a custom merge since Faoo_fco2_ocn is scaled by (ifrac+ofrac)
201-
! in the merge to the atm
201+
! in the merge to the atm
202202
if ( FB_FldChk(is_local%wrap%FBExp(compatm) , 'Faoo_fco2_ocn', rc=rc) .and. &
203203
FB_FldChk(is_local%wrap%FBImp(compocn,compocn), 'Faoo_fco2_ocn', rc=rc)) then
204204
call ESMF_FieldGet(lfield, farrayPtr=dataptr1, rc=rc)

mediator/med_phases_prep_ice_mod.F90

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ subroutine med_phases_prep_ice(gcomp, rc)
2929
use ESMF , only : ESMF_FieldBundleGet, ESMF_FieldGet, ESMF_Field
3030
use ESMF , only : ESMF_LOGMSG_ERROR, ESMF_FAILURE
3131
use ESMF , only : ESMF_StateItem_Flag, ESMF_STATEITEM_NOTFOUND
32-
use ESMF , only : ESMF_VMBroadCast
32+
use ESMF , only : ESMF_VMBroadCast
3333
use med_utils_mod , only : chkerr => med_utils_ChkErr
3434
use med_methods_mod , only : FB_fldchk => med_methods_FB_FldChk
3535
use med_methods_mod , only : FB_diagnose => med_methods_FB_diagnose
@@ -91,12 +91,12 @@ subroutine med_phases_prep_ice(gcomp, rc)
9191
! Apply precipitation factor from ocean (that scales atm rain and snow to ice) if appropriate
9292
if (trim(coupling_mode) == 'cesm' .and. is_local%wrap%flds_scalar_index_precip_factor /= 0) then
9393

94-
! Note that in med_internal_mod.F90 all is_local%wrap%flds_scalar_index_precip_factor
94+
! Note that in med_internal_mod.F90 all is_local%wrap%flds_scalar_index_precip_factor
9595
! is initialized to 0.
96-
! In addition, in med.F90, if this attribute is not present as a mediator component attribute,
97-
! it is set to 0.
96+
! In addition, in med.F90, if this attribute is not present as a mediator component attribute,
97+
! it is set to 0.
9898
if (mastertask) then
99-
call ESMF_StateGet(is_local%wrap%NstateImp(compocn), &
99+
call ESMF_StateGet(is_local%wrap%NstateImp(compocn), &
100100
itemName=trim(is_local%wrap%flds_scalar_name), field=lfield, rc=rc)
101101
if (chkerr(rc,__LINE__,u_FILE_u)) return
102102
call ESMF_FieldGet(lfield, farrayPtr=dataptr_scalar_ocn, rc=rc)
@@ -111,7 +111,7 @@ subroutine med_phases_prep_ice(gcomp, rc)
111111
end if
112112
call ESMF_VMBroadCast(is_local%wrap%vm, precip_fact, 1, 0, rc=rc)
113113
if (chkerr(rc,__LINE__,u_FILE_u)) return
114-
is_local%wrap%flds_scalar_precip_factor = precip_fact(1)
114+
is_local%wrap%flds_scalar_precip_factor = precip_fact(1)
115115
if (dbug_flag > 5) then
116116
write(cvalue,*) precip_fact(1)
117117
call ESMF_LogWrite(trim(subname)//" precip_fact is "//trim(cvalue), ESMF_LOGMSG_INFO)

mediator/med_phases_prep_ocn_mod.F90

+5-5
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,12 @@ subroutine med_phases_prep_ocn_custom_cesm(gcomp, rc)
472472
! Apply precipitation factor from ocean (that scales atm rain and snow back to ocn ) if appropriate
473473
if (trim(coupling_mode) == 'cesm' .and. is_local%wrap%flds_scalar_index_precip_factor /= 0) then
474474

475-
! Note that in med_internal_mod.F90 all is_local%wrap%flds_scalar_index_precip_factor
475+
! Note that in med_internal_mod.F90 all is_local%wrap%flds_scalar_index_precip_factor
476476
! is initialized to 0.
477-
! In addition, in med.F90, if this attribute is not present as a mediator component attribute,
478-
! it is set to 0.
477+
! In addition, in med.F90, if this attribute is not present as a mediator component attribute,
478+
! it is set to 0.
479479
if (mastertask) then
480-
call ESMF_StateGet(is_local%wrap%NstateImp(compocn), &
480+
call ESMF_StateGet(is_local%wrap%NstateImp(compocn), &
481481
itemName=trim(is_local%wrap%flds_scalar_name), field=lfield, rc=rc)
482482
if (chkerr(rc,__LINE__,u_FILE_u)) return
483483
call ESMF_FieldGet(lfield, farrayPtr=dataptr_scalar_ocn, rc=rc)
@@ -492,7 +492,7 @@ subroutine med_phases_prep_ocn_custom_cesm(gcomp, rc)
492492
end if
493493
call ESMF_VMBroadCast(is_local%wrap%vm, precip_fact, 1, 0, rc=rc)
494494
if (chkerr(rc,__LINE__,u_FILE_u)) return
495-
is_local%wrap%flds_scalar_precip_factor = precip_fact(1)
495+
is_local%wrap%flds_scalar_precip_factor = precip_fact(1)
496496
if (dbug_flag > 5) then
497497
write(cvalue,*) precip_fact(1)
498498
call ESMF_LogWrite(trim(subname)//" precip_fact is "//trim(cvalue), ESMF_LOGMSG_INFO)

mediator/med_phases_restart_mod.F90

+2-2
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ subroutine med_phases_restart_write(gcomp, rc)
273273

274274
call ESMF_ClockGetAlarm(clock, alarmname='alarm_stop', alarm=alarm, rc=rc)
275275
if (ChkErr(rc,__LINE__,u_FILE_u)) return
276-
if (ESMF_AlarmIsRinging(alarm, rc=rc).and.write_restart_at_endofrun) then
276+
if (ESMF_AlarmIsRinging(alarm, rc=rc).and.write_restart_at_endofrun) then
277277
AlarmIsOn = .true.
278278
else
279279
AlarmIsOn = .false.
@@ -480,7 +480,7 @@ subroutine med_phases_restart_write(gcomp, rc)
480480

481481
end subroutine med_phases_restart_write
482482

483-
!===============================================================================
483+
!===============================================================================
484484
subroutine med_phases_restart_read(gcomp, rc)
485485

486486
! Read mediator restart

0 commit comments

Comments
 (0)