Skip to content

Commit

Permalink
use unity normalization; add error catch if more than one normalizati…
Browse files Browse the repository at this point in the history
…on type is specified (#41)


* switch to using unityone normalization in ufs for all fields
* add model abort if more than one normalization type is specified for a single n1:n2:maptype
  • Loading branch information
DeniseWorthen authored Apr 27, 2021
1 parent d5b270c commit 037cbe9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
23 changes: 12 additions & 11 deletions mediator/esmFldsExchange_nems_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
do n = 1,size(flds)
fldname = trim(flds(n))
call addfld(fldListFr(compatm)%flds, trim(fldname))
call addmap(fldListFr(compatm)%flds, trim(fldname), compocn, maptype, 'none', 'unset')
call addmap(fldListFr(compatm)%flds, trim(fldname), compocn, maptype, 'one', 'unset')
end do
deallocate(flds)

Expand Down Expand Up @@ -155,7 +155,7 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
! to ocn: sea level pressure from atm
call addfld(fldListTo(compocn)%flds, 'Sa_pslv')
call addfld(fldListFr(compatm)%flds, 'Sa_pslv')
call addmap(fldListFr(compatm)%flds, 'Sa_pslv', compocn, maptype, 'none', 'unset')
call addmap(fldListFr(compatm)%flds, 'Sa_pslv', compocn, maptype, 'one', 'unset')
call addmrg(fldListTo(compocn)%flds, 'Sa_pslv', mrg_from=compatm, mrg_fld='Sa_pslv', mrg_type='copy')

! to ocn: from atm (custom merge in med_phases_prep_ocn)
Expand All @@ -169,7 +169,7 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
fldname = trim(flds(n))
call addfld(fldListTo(compocn)%flds, trim(fldname))
call addfld(fldListFr(compatm)%flds, trim(fldname))
call addmap(fldListFr(compatm)%flds, trim(fldname), compocn, maptype, 'none', 'unset')
call addmap(fldListFr(compatm)%flds, trim(fldname), compocn, maptype, 'one', 'unset')
end do
deallocate(flds)

Expand All @@ -194,7 +194,7 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
fldname = trim(flds(n))
call addfld(fldListTo(compocn)%flds, trim(fldname))
call addfld(fldListFr(compatm)%flds, trim(fldname))
call addmap(fldListFr(compatm)%flds, trim(fldname), compocn, maptype, 'none', 'unset')
call addmap(fldListFr(compatm)%flds, trim(fldname), compocn, maptype, 'one', 'unset')
call addmrg(fldListTo(compocn)%flds, trim(fldname), &
mrg_from=compatm, mrg_fld=trim(fldname), mrg_type='copy_with_weights', mrg_fracname='ofrac')
end do
Expand All @@ -208,28 +208,29 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
call addfld(fldListTo(compocn)%flds, 'Foxx_'//trim(flds(n)))
call addfld(fldListFr(compice)%flds, 'Fioi_'//trim(flds(n)))
call addfld(fldListFr(compatm)%flds, 'Faxa_'//trim(flds(n)))
call addmap(fldListFr(compatm)%flds, 'Faxa_'//trim(flds(n)), compocn, maptype, 'none', 'unset')
call addmap(fldListFr(compatm)%flds, 'Faxa_'//trim(flds(n)), compocn, maptype, 'one', 'unset')
call addmap(fldListFr(compice)%flds, 'Fioi_'//trim(flds(n)), compocn, mapfcopy, 'unset', 'unset')
end do
deallocate(flds)

! to ocn: net long wave via auto merge
call addfld(fldListTo(compocn)%flds, 'Faxa_lwnet')
call addfld(fldListFr(compatm)%flds, 'Faxa_lwnet')
call addmap(fldListFr(compatm)%flds, 'Faxa_lwnet', compocn, maptype, 'none', 'unset')
call addmap(fldListFr(compatm)%flds, 'Faxa_lwnet', compocn, maptype, 'one', 'unset')
call addmrg(fldListTo(compocn)%flds, 'Faxa_lwnet', &
mrg_from=compatm, mrg_fld='Faxa_lwnet', mrg_type='copy_with_weights', mrg_fracname='ofrac')

! to ocn: merged sensible heat flux (custom merge in med_phases_prep_ocn)
call addfld(fldListTo(compocn)%flds, 'Faxa_sen')
call addfld(fldListFr(compatm)%flds, 'Faxa_sen')
call addmap(fldListFr(compatm)%flds, 'Faxa_sen', compocn, maptype, 'none', 'unset')
call addmap(fldListFr(compatm)%flds, 'Faxa_sen', compocn, maptype, 'one', 'unset')

! to ocn: evaporation water flux (custom merge in med_phases_prep_ocn)
call addfld(fldListTo(compocn)%flds, 'Faxa_evap')
call addfld(fldListFr(compatm)%flds, 'Faxa_lat')
call addmap(fldListFr(compatm)%flds, 'Faxa_lat', compocn, maptype, 'none', 'unset')
call addmap(fldListFr(compatm)%flds, 'Faxa_lat', compocn, maptype, 'one', 'unset')
else
! nems_orig_data
! to ocn: surface stress from mediator and ice stress via auto merge
allocate(flds(2))
flds = (/'taux', 'tauy'/)
Expand All @@ -247,7 +248,7 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
! 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')
call addmap(fldListFr(compatm)%flds, 'Faxa_lwdn', compocn, maptype, 'one', 'unset')
call addmrg(fldListTo(compocn)%flds, 'Foxx_lwnet', &
mrg_from=compmed, mrg_fld='Faox_lwup', mrg_type='merge', mrg_fracname='ofrac')
call addmrg(fldListTo(compocn)%flds, 'Foxx_lwnet', &
Expand Down Expand Up @@ -299,7 +300,7 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
fldname = trim(flds(n))
call addfld(fldListFr(compatm)%flds, trim(fldname))
call addfld(fldListTo(compice)%flds, trim(fldname))
call addmap(fldListFr(compatm)%flds, trim(fldname), compice, maptype, 'none', 'unset')
call addmap(fldListFr(compatm)%flds, trim(fldname), compice, maptype, 'one', 'unset')
call addmrg(fldListTo(compice)%flds, trim(fldname), mrg_from=compatm, mrg_fld=trim(fldname), mrg_type='copy')
end do
deallocate(flds)
Expand All @@ -317,7 +318,7 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
fldname = trim(flds(n))
call addfld(fldListTo(compice)%flds, trim(fldname))
call addfld(fldListFr(compatm)%flds, trim(fldname))
call addmap(fldListFr(compatm)%flds, trim(fldname), compice, maptype, 'none', 'unset')
call addmap(fldListFr(compatm)%flds, trim(fldname), compice, maptype, 'one', 'unset')
call addmrg(fldListTo(compice)%flds, trim(fldname), mrg_from=compatm, mrg_fld=trim(fldname), mrg_type='copy')
end do
deallocate(flds)
Expand Down
24 changes: 21 additions & 3 deletions mediator/med_map_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ subroutine med_map_routehandles_initfrom_field(n1, n2, fldsrc, flddst, mapindex,
use esmFlds , only : mapnstod, mapnstod_consd, mapnstod_consf, mapnstod_consd
use esmFlds , only : mapfillv_bilnr, mapbilnr_nstod
use esmFlds , only : ncomps, compatm, compice, compocn, compname
use esmFlds , only : mapfcopy, mapconsd, mapconsf, mapnstod
use esmFlds , only : coupling_mode, dststatus_print
use esmFlds , only : atm_name
use med_constants_mod , only : ispval_mask => med_constants_ispval_mask
Expand Down Expand Up @@ -590,7 +589,6 @@ subroutine med_map_mapnorm_init(gcomp, rc)
! local variables
type(InternalState) :: is_local
integer :: n1, n2, m
character(len=1) :: cn1,cn2,cm
real(R8), pointer :: dataptr(:) => null()
integer :: fieldCount
type(ESMF_Field), pointer :: fieldlist(:) => null()
Expand Down Expand Up @@ -661,7 +659,6 @@ subroutine med_map_mapnorm_init(gcomp, rc)
maptype=m, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (mastertask) then
write(cn1,'(i1)') n1; write(cn2,'(i1)') n2; write(cm ,'(i1)') m
write(logunit,'(a)') trim(subname)//' created field_NormOne for '&
//compname(n1)//'->'//compname(n2)//' with mapping '//mapnames(m)
endif
Expand Down Expand Up @@ -719,6 +716,8 @@ subroutine med_map_packed_field_create(destcomp, flds_scalar_name, &
type(ESMF_Field), pointer :: fieldlist_src(:) => null()
type(ESMF_Field), pointer :: fieldlist_dst(:) => null()
character(CL), allocatable :: fieldNameList(:)
character(CS) :: mapnorm_mapindex
character(len=CX) :: tmpstr
character(len=*), parameter :: subname=' (module_MED_map:med_packed_field_create) '
!-----------------------------------------------------------

Expand Down Expand Up @@ -765,6 +764,7 @@ subroutine med_map_packed_field_create(destcomp, flds_scalar_name, &
! Determine the normalization type for each packed_data mapping element
! Loop over mapping types
do mapindex = 1,nmappers
mapnorm_mapindex = 'not_set'
! Loop over source field bundle
do nf = 1, fieldCount
! Loop over the fldsSrc types
Expand All @@ -776,6 +776,24 @@ subroutine med_map_packed_field_create(destcomp, flds_scalar_name, &
trim(fldsSrc(ns)%shortname) == trim(fieldnamelist(nf))) then
! Set the normalization to the input
packed_data(mapindex)%mapnorm = fldsSrc(ns)%mapnorm(destcomp)
if (mapnorm_mapindex == 'not_set') then
mapnorm_mapindex = packed_data(mapindex)%mapnorm
write(tmpstr,*)'Map type '//trim(mapnames(mapindex)) &
//', destcomp '//trim(compname(destcomp)) &
//', mapnorm '//trim(mapnorm_mapindex) &
//' '//trim(fieldnamelist(nf))
call ESMF_LogWrite(trim(tmpstr), ESMF_LOGMSG_INFO)
else
if (mapnorm_mapindex /= packed_data(mapindex)%mapnorm) then
write(tmpstr,*)'Map type '//trim(mapnames(mapindex)) &
//', destcomp '//trim(compname(destcomp)) &
//', mapnorm '//trim(mapnorm_mapindex) &
//' set; cannot set mapnorm to '//trim(packed_data(mapindex)%mapnorm) &
//' '//trim(fieldnamelist(nf))
call ESMF_LogWrite(trim(tmpstr), ESMF_LOGMSG_INFO)
call ESMF_Finalize(endflag=ESMF_END_ABORT)
end if
end if
end if
end do
end do
Expand Down
2 changes: 1 addition & 1 deletion mediator/med_phases_ocnalb_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,9 @@ subroutine med_phases_ocnalb_orbital_update(clock, logunit, mastertask, eccen,
character(len=*) , parameter :: subname = "(med_phases_ocnalb_orbital_update)"
!-------------------------------------------

#ifdef CESMCOUPLED
rc = ESMF_SUCCESS

#ifdef CESMCOUPLED
if (trim(orb_mode) == trim(orb_variable_year)) then
call ESMF_ClockGet(clock, CurrTime=CurrTime, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
Expand Down

0 comments on commit 037cbe9

Please sign in to comment.