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

if (trim(coupling_mode) == 'nems_orig' .or. trim(coupling_mode) == 'nems_frac' .or. &
trim(coupling_mode) == 'nems_frac_aoflux_sbs') then
! to ocn: merge surface stress (custom merge calculation in med_phases_prep_ocn)
! to ocn: merge surface stress
allocate(oflds(2))
allocate(aflds(2))
allocate(iflds(2))
Expand All @@ -415,6 +415,10 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
fldchk(is_local%wrap%FBImp(compatm,compatm), trim(aflds(n)), rc=rc)) then
call addmap_from(compice, trim(iflds(n)), compocn, mapfcopy, 'unset', 'unset')
call addmap_from(compatm, trim(aflds(n)), compocn, mapconsf_aofrac, 'aofrac', 'unset')
call addmrg_to(compocn, trim(oflds(n)), &
mrg_from=compice, mrg_fld=trim(iflds(n)), mrg_type='merge', mrg_fracname='ifrac')
call addmrg_to(compocn, trim(oflds(n)), &
mrg_from=compatm, mrg_fld=trim(aflds(n)), mrg_type='merge', mrg_fracname='ofrac')
end if
end if
end do
Expand All @@ -437,7 +441,7 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
end if
end if

! to ocn: merged sensible heat flux (custom merge in med_phases_prep_ocn)
! to ocn: sensible heat flux
if (phase == 'advertise') then
if (is_local%wrap%comp_present(compatm) .and. is_local%wrap%comp_present(compocn)) then
call addfld_from(compatm, 'Faxa_sen')
Expand All @@ -447,10 +451,12 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
if ( fldchk(is_local%wrap%FBexp(compocn) , 'Faxa_sen', rc=rc) .and. &
fldchk(is_local%wrap%FBImp(compatm,compatm), 'Faxa_sen', rc=rc)) then
call addmap_from(compatm, 'Faxa_sen', compocn, mapconsf_aofrac, 'aofrac', 'unset')
call addmrg_to(compocn, 'Faxa_sen', &
mrg_from=compatm, mrg_fld='Faxa_sen', mrg_type='copy_with_weights', mrg_fracname='ofrac')
end if
end if

! to ocn: evaporation water flux (custom merge in med_phases_prep_ocn)
! to ocn: evaporation water flux
if (phase == 'advertise') then
if (is_local%wrap%comp_present(compatm) .and. is_local%wrap%comp_present(compocn)) then
call addfld_from(compatm, 'Faxa_evap')
Expand All @@ -460,6 +466,8 @@ subroutine esmFldsExchange_nems(gcomp, phase, rc)
if ( fldchk(is_local%wrap%FBexp(compocn) , 'Faxa_evap', rc=rc) .and. &
fldchk(is_local%wrap%FBImp(compatm,compatm), 'Faxa_evap' , rc=rc)) then
call addmap_from(compatm, 'Faxa_evap', compocn, mapconsf_aofrac, 'aofrac', 'unset')
call addmrg_to(compocn, 'Faxa_evap', &
mrg_from=compatm, mrg_fld='Faxa_evap', mrg_type='copy_with_weights', mrg_fracname='ofrac')
end if
end if
else if (trim(coupling_mode) == 'nems_orig_data' .or. trim(coupling_mode) == 'nems_frac_aoflux') then
Expand Down
6 changes: 3 additions & 3 deletions mediator/med.F90
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ subroutine AdvertiseFields(gcomp, importState, exportState, clock, rc)
use NUOPC , only : NUOPC_CompAttributeGet, NUOPC_CompAttributeSet, NUOPC_CompAttributeAdd
use esmFlds, only : med_fldlist_init1, med_fld_GetFldInfo, med_fldList_entry_type
use med_phases_history_mod, only : med_phases_history_init
use med_methods_mod , only : mediator_checkfornans
use med_methods_mod , only : mediator_checkfornans

! input/output variables
type(ESMF_GridComp) :: gcomp
Expand Down Expand Up @@ -921,7 +921,7 @@ subroutine AdvertiseFields(gcomp, importState, exportState, clock, rc)
call NUOPC_CompAttributeGet(gcomp, name="check_for_nans", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if(isPresent .and. isSet) then
read(cvalue, *) mediator_checkfornans
read(cvalue, *) mediator_checkfornans
else
mediator_checkfornans = .false.
endif
Expand Down Expand Up @@ -1942,7 +1942,7 @@ subroutine DataInitialize(gcomp, rc)
! Initialize ocean albedos (this is needed for cesm and hafs)
!----------------------------------------------------------

if (trim(coupling_mode(1:5)) /= 'nems_') then
if (trim(coupling_mode(1:5)) == 'cesm_') then
if (is_local%wrap%comp_present(compocn) .or. is_local%wrap%comp_present(compatm)) then
call med_phases_ocnalb_run(gcomp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down
5 changes: 2 additions & 3 deletions mediator/med_phases_prep_atm_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ subroutine med_phases_prep_atm(gcomp, rc)
!--- map atm/ocn fluxes from ocn to atm grid if appropriate
!---------------------------------------
if (trim(coupling_mode) == 'cesm' .or. &
trim(coupling_mode) == 'hafs' .or. &
trim(coupling_mode) == 'nems_frac_aoflux' .or. &
trim(coupling_mode) == 'nems_frac_aoflux_sbs') then
if (is_local%wrap%aoflux_grid == 'ogrid') then
Expand All @@ -134,8 +133,7 @@ subroutine med_phases_prep_atm(gcomp, rc)
!---------------------------------------
fldList => med_fldList_GetfldListTo(compatm)
if (trim(coupling_mode) == 'cesm' .or. &
trim(coupling_mode) == 'nems_frac_aoflux' .or. &
trim(coupling_mode) == 'hafs') then
trim(coupling_mode) == 'nems_frac_aoflux') then
call med_merge_auto(&
is_local%wrap%med_coupling_active(:,compatm), &
is_local%wrap%FBExp(compatm), &
Expand All @@ -147,6 +145,7 @@ subroutine med_phases_prep_atm(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
else if (trim(coupling_mode) == 'nems_frac' .or. &
trim(coupling_mode) == 'nems_orig' .or. &
trim(coupling_mode) == 'hafs' .or. &
trim(coupling_mode) == 'nems_frac_aoflux_sbs') then
call med_merge_auto(&
is_local%wrap%med_coupling_active(:,compatm), &
Expand Down
28 changes: 2 additions & 26 deletions mediator/med_phases_prep_ocn_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ subroutine med_phases_prep_ocn_accum(gcomp, rc)
! auto merges to ocn
if ( trim(coupling_mode) == 'cesm' .or. &
trim(coupling_mode) == 'nems_orig_data' .or. &
trim(coupling_mode) == 'nems_frac_aoflux' .or. &
trim(coupling_mode) == 'hafs') then
trim(coupling_mode) == 'nems_frac_aoflux') then
call med_merge_auto(&
is_local%wrap%med_coupling_active(:,compocn), &
is_local%wrap%FBExp(compocn), &
Expand All @@ -131,6 +130,7 @@ subroutine med_phases_prep_ocn_accum(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
else if (trim(coupling_mode) == 'nems_frac' .or. &
trim(coupling_mode) == 'nems_orig' .or. &
trim(coupling_mode) == 'hafs' .or. &
trim(coupling_mode) == 'nems_frac_aoflux_sbs') then
call med_merge_auto(&
is_local%wrap%med_coupling_active(:,compocn), &
Expand Down Expand Up @@ -668,30 +668,6 @@ subroutine med_phases_prep_ocn_custom_nems(gcomp, rc)
lsize = size(ofrac)
allocate(customwgt(lsize))

if (trim(coupling_mode) == 'nems_orig' .or. &
trim(coupling_mode) == 'nems_frac' .or. &
trim(coupling_mode) == 'nems_frac_aoflux_sbs') then
customwgt(:) = -ofrac(:)
call med_merge_field(is_local%wrap%FBExp(compocn), 'Faxa_evap', &
FBinA=is_local%wrap%FBImp(compatm,compocn), fnameA='Faxa_evap' , wgtA=customwgt, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

customwgt(:) = -ofrac(:)
call med_merge_field(is_local%wrap%FBExp(compocn), 'Faxa_sen', &
FBinA=is_local%wrap%FBImp(compatm,compocn), fnameA='Faxa_sen', wgtA=customwgt, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

customwgt(:) = -ofrac(:)
call med_merge_field(is_local%wrap%FBExp(compocn), 'Foxx_taux', &
FBinA=is_local%wrap%FBImp(compice,compocn), fnameA='Fioi_taux', wgtA=ifrac, &
FBinB=is_local%wrap%FBImp(compatm,compocn), fnameB='Faxa_taux', wgtB=customwgt, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call med_merge_field(is_local%wrap%FBExp(compocn), 'Foxx_tauy', &
FBinA=is_local%wrap%FBImp(compice,compocn), fnameA='Fioi_tauy', wgtA=ifrac, &
FBinB=is_local%wrap%FBImp(compatm,compocn), fnameB='Faxa_tauy', wgtB=customwgt, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

! netsw_for_ocn = [downsw_from_atm*(1-ice_fraction)*(1-ocn_albedo)] + [pensw_from_ice*(ice_fraction)]
customwgt(:) = ofrac(:) * (1.0_R8 - 0.06_R8)
call med_merge_field(is_local%wrap%FBExp(compocn), 'Foxx_swnet_vdr', &
Expand Down