From b45cc58fd12b92f97466072072e135e6728492f0 Mon Sep 17 00:00:00 2001 From: Joseph Smith Date: Wed, 2 Jul 2025 20:05:48 -0500 Subject: [PATCH 1/4] updated hash --- mediator/esmFldsExchange_coastal_mod.F90 | 285 +++++++++++++++++++++++ 1 file changed, 285 insertions(+) diff --git a/mediator/esmFldsExchange_coastal_mod.F90 b/mediator/esmFldsExchange_coastal_mod.F90 index b7fb79d5..0b234c64 100644 --- a/mediator/esmFldsExchange_coastal_mod.F90 +++ b/mediator/esmFldsExchange_coastal_mod.F90 @@ -11,6 +11,7 @@ module esmFldsExchange_coastal_mod use med_internalstate_mod , only : compatm use med_internalstate_mod , only : compocn use med_internalstate_mod , only : compwav + use med_internalstate_mod , only : compice use med_internalstate_mod , only : ncomps use med_internalstate_mod , only : coupling_mode @@ -38,10 +39,17 @@ module esmFldsExchange_coastal_mod character(len=CX) :: ocn2wav_smap = 'unset' character(len=CX) :: wav2ocn_smap = 'unset' character(len=CX) :: wav2atm_smap = 'unset' + + character(len=CX) :: atm2ice_smap = 'unset' + character(len=CX) :: ocn2ice_smap = 'unset' + character(len=CX) :: ice2ocn_smap = 'unset' + character(len=CX) :: ice2atm_smap = 'unset' + character(len=CS) :: mapnorm = 'one' logical :: atm_present = .false. logical :: ocn_present = .false. logical :: wav_present = .false. + logical :: ice_present = .false. end type !=============================================================================== @@ -140,11 +148,23 @@ subroutine esmFldsExchange_coastal_advt(gcomp, phase, rc) ! to med: masks from components !---------------------------------------------------------- call addfld_from(compocn, 'So_omask') + call addfld_from(compice, 'Si_imask') !---------------------------------------------------------- ! to med: frac from components !---------------------------------------------------------- call addfld_to(compatm, 'So_ofrac') + + if (coastal_attr%ice_present .and. coastal_attr%atm_present) then + call addfld_from(compice , 'Si_ifrac') + call addfld_to(compatm , 'Si_ifrac') + + end if + + if (coastal_attr%ice_present .and. coastal_attr%ocn_present) then + call addfld_from(compice , 'Si_ifrac') + call addfld_to(compocn , 'Si_ifrac') + end if !===================================================================== ! FIELDS TO OCEAN (compocn) @@ -236,6 +256,84 @@ subroutine esmFldsExchange_coastal_advt(gcomp, phase, rc) deallocate(S_flds) end if + ! --------------------------------------------------------------------- + ! to ice: atm fields + ! --------------------------------------------------------------------- + if (coastal_attr%atm_present .and. coastal_attr%ice_present) then + allocate(S_flds(14)) + S_flds = (/'Sa_u ', & ! inst_zonalv_wind_height10m + 'Sa_v ', & ! inst_merid_wind_height10m + 'Sa_z ', & ! lowest atmospheric height + 'Sa_tbot ', & ! tenperature at lowest atm level + 'Sa_shum ', & ! Specific Humidity + 'Sa_pbot ', & ! pressure bottom + 'Faxa_snow ', & ! Snow + 'Faxa_rain ', & ! Rain + 'Faxa_swvdr', & ! Short-wave + 'Faxa_swvdf', & ! Short-wave + 'Faxa_swndr', & ! Short-wave + 'Faxa_swndf', & ! Short-wave + 'Faxa_swnet', & ! Short-wave net + 'Faxa_lwdn ' /) ! Long-wave + + do n = 1,size(S_flds) + fldname = trim(S_flds(n)) + call addfld_from(compatm, trim(fldname)) + call addfld_to(compice, trim(fldname)) + end do + deallocate(S_flds) + end if + + ! --------------------------------------------------------------------- + ! to ice: ocean fields + ! --------------------------------------------------------------------- + if (coastal_attr%ocn_present .and. coastal_attr%ice_present) then + allocate(S_flds(8)) + S_flds = (/'So_u ', & ! ocn_current_zonal + 'So_v ', & ! ocn_current_merid + 'So_t ', & ! SST + 'So_s ', & ! SSS + 'So_hmix', & ! depth of ml + 'So_dhdx', & ! tilt-x + 'So_dhdy', & ! tilt-y + 'Fioo_q '/) ! heat flux + do n = 1,size(S_flds) + fldname = trim(S_flds(n)) + call addfld_from(compocn, trim(fldname)) + call addfld_to(compice, trim(fldname)) + end do + deallocate(S_flds) + end if + + ! --------------------------------------------------------------------- + ! to ocean: ice fields + ! --------------------------------------------------------------------- + if (coastal_attr%ocn_present .and. coastal_attr%ice_present) then + allocate(S_flds(13)) + S_flds = (/'Si_ifrac ', & ! Ice area fraction aice + 'Si_vice ', & ! Ice volume + 'Si_vsno ', & ! Snow volume + 'Si_uvel ', & ! Ice u-velocity + 'Si_vvel ', & ! Ice v-velocity + 'Fioi_meltw', & ! Fresh water flux due to melting/freeze + 'Fioi_melth', & ! Ice-to-ocean heat flux at base of ice + 'Fioi_taux ', & ! Ice-to-ocean surface stress in x-dir + 'Fioi_tauy ', & ! Ice-to-ocean surface stress in y-dir + 'Fioi_salt ', & ! Salinity flux due to melting/freeze + 'Fioi_swpen', & ! Penatrive SW radiation flux + 'Si_frzmlt ', & ! Energy used to create ice (all energy sst-tfrz) + 'Si_CdnIO ' /) ! ice drag coeff + + do n = 1,size(S_flds) + fldname = trim(S_flds(n)) + call addfld_from(compice, trim(fldname)) + call addfld_to(compocn, trim(fldname)) + end do + deallocate(S_flds) + end if + + + call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO) end subroutine esmFldsExchange_coastal_advt @@ -458,8 +556,161 @@ subroutine esmFldsExchange_coastal_init(gcomp, phase, rc) end do deallocate(S_flds) end if + + + !====================================================================== + ! BEGIN FIELDS TO ICE (compice) + !====================================================================== + ! --------------------------------------------------------------------- + ! To ice from atm + ! --------------------------------------------------------------------- + ! ---------------------------------------- + ! | Atmospheric Fields: | + ! ---------------------------------------- + ! - zonal wind height 10m [m/s] + ! - merid wind height 10m [m/s] + ! - lowest atmospheric height [m] (defualt in CICE is 10m see model comp) + ! - Temperature at 10m [k] + ! - Specific Humidity [kg/kg] + ! - Pressure at 10m [Pa] + ! - Rainfall rate [kg/m/m/s] + ! - Snowfall rate [kg/m/m/s] + ! - Net shortwave rad [W/m/m] Other bands are derived from this + ! - Net longwave rad [W/m/m] + ! --------------------------------------- + if (coastal_attr%atm_present .and. coastal_attr%ice_present) then + allocate(S_flds(14)) + S_flds = (/'Sa_u ', & ! inst_zonal_wind_height10m + 'Sa_v ', & ! inst_merid_wind_height10m + 'Sa_z ', & ! lowest atmospheric height + 'Sa_tbot ', & ! tenperature at lowest atm level + 'Sa_shum ', & ! Specific Humidity + 'Sa_pbot ', & ! pressure bottom + 'Faxa_rain ', & ! Rain + 'Faxa_snow ', & ! Snow + 'Faxa_swvdr', & ! Short-wave + 'Faxa_swvdf', & ! Short-wave + 'Faxa_swndr', & ! Short-wave + 'Faxa_swndf', & ! Short-wave + 'Faxa_swnet', & ! Short-wave net + 'Faxa_lwdn '/) ! long-wave + do n = 1,size(S_flds) + fldname = trim(S_flds(n)) + if (fldchk(is_local%wrap%FBExp(compice),trim(fldname),rc=rc) .and. & + fldchk(is_local%wrap%FBImp(compatm,compatm),trim(fldname),rc=rc) & + ) then + call addmap_from(compatm, trim(fldname), compice, & + mapnstod_consf, coastal_attr%mapnorm, coastal_attr%atm2ice_smap) !!mapnstod_consf conservative interp + call addmrg_to(compice, trim(fldname), & + mrg_from=compatm, mrg_fld=trim(fldname), mrg_type='copy') + end if + end do + deallocate(S_flds) + end if + + ! --------------------------------------------------------------------- + ! To ice from ocn fields + ! --------------------------------------------------------------------- + ! ---------------------------------------- + ! | Oceanic fields: | + ! ---------------------------------------- + ! - zonal current [m/s] + ! - merid current [m/s] + ! - Sea Surface temperature [K] + ! - Sea surface salinity [psu. (g/kg)] + ! - Mixed layer depth [m] + ! - Zonal sea surface tilt [1] + ! - Merid sea surface tilt [1] + ! - deep ocean heatflux [W/m/m] + ! --------------------------------------- + + if (coastal_attr%ocn_present .and. coastal_attr%ice_present) then + allocate(S_flds(8)) + S_flds = (/'So_u ', & ! ocn_current_zonal + 'So_v ', & ! ocn_current_merid + 'So_t ', & ! SST + 'So_s ', & ! SSS + 'So_hmix', & ! Mixed layer depth + 'So_dhdx', & ! tilt-x + 'So_dhdy', & ! tilt-y + 'Fioo_qi'/) ! heat flux call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO) + do n = 1,size(S_flds) + fldname = trim(S_flds(n)) + if (fldchk(is_local%wrap%FBExp(compice),trim(fldname),rc=rc) .and. & + fldchk(is_local%wrap%FBImp(compocn,compocn),trim(fldname),rc=rc) & + ) then + call addmap_from(compocn, trim(fldname), compice, & + mapbilnr_nstod, coastal_attr%mapnorm, coastal_attr%ocn2ice_smap) + call addmrg_to(compice, trim(fldname), & + mrg_from=compocn, mrg_fld=trim(fldname), mrg_type='copy') + end if + end do + deallocate(S_flds) + end if + + !====================================================================== + ! END FIELDS TO ICE (compice) + !====================================================================== + + !====================================================================== + ! BEGIN FIELDS FROM ICE (compice) + !====================================================================== + ! --------------------------------------------------------------------- + ! To ocn from ice fields + ! --------------------------------------------------------------------- + ! ---------------------------------------- + ! | Ice fields: | + ! ---------------------------------------- + ! - Ice area fraction [1] + ! - Ice volume [m^3] + ! - Snow volume [m^3] + ! - Ice merid vel. [m/s] + ! - Ice Zonal vel. [m/s] + ! - Fresh water flux [kg/m/m/s] + ! - Heat flux at base of ice [W/m/m] + ! - Ice-to-Ocn merid stress [N/m/m] + ! - Ice-to-Ocn zonal stress [N/m/m] + ! - Salinity flux [kg/m/m/s] + ! - Shortwave pen. rad [W/m/m] + ! - Freeze melt potential [W/m/m] (Internal energy mixed layer) + ! - Ice ocean drag [1] (Computed by ice component) + + if (coastal_attr%ocn_present .and. coastal_attr%ice_present) then + allocate(S_flds(13)) + S_flds = (/'Si_ifrac ', & ! Ice area fraction aice + 'Si_vice ', & ! Ice volume + 'Si_vsno ', & ! Snow volume + 'Si_uvel ', & ! Ice u-velocity + 'Si_vvel ', & ! Ice v-velocity + 'Fioi_meltw', & ! Fresh water flux due to melting/freeze + 'Fioi_melth', & ! Ice-to-ocean heat flux at base of ice + 'Fioi_taux ', & ! Ice-to-ocean surface stress in x-dir + 'Fioi_tauy ', & ! Ice-to-ocean surface stress in y-dir + 'Fioi_salt ', & ! Salinity flux due to melting/freeze + 'Fioi_swpen', & ! Penatrive SW radiation flux + 'Si_frzmlt ', & ! Energy used to create ice (all energy sst-tfrz) + 'Si_CdnIO ' /) ! ice drag + + call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO) + do n = 1,size(S_flds) + fldname = trim(S_flds(n)) + if (fldchk(is_local%wrap%FBExp(compocn),trim(fldname),rc=rc) .and. & + fldchk(is_local%wrap%FBImp(compice,compice),trim(fldname),rc=rc) & + ) then + call addmap_from(compice, trim(fldname), compocn, & + mapnstod_consf, coastal_attr%mapnorm, coastal_attr%ice2ocn_smap) + call addmrg_to(compocn, trim(fldname), & + mrg_from=compice, mrg_fld=trim(fldname), mrg_type='copy') + end if + end do + deallocate(S_flds) + end if + + !====================================================================== + ! END FIELDS FROM ICE (compice) + !====================================================================== end subroutine esmFldsExchange_coastal_init @@ -513,6 +764,13 @@ subroutine esmFldsExchange_coastal_attr(gcomp, coastal_attr, rc) if (trim(cvalue) /= 'swav') coastal_attr%wav_present = .true. end if + call NUOPC_CompAttributeGet(gcomp, name='ICE_model', & + value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + if (trim(cvalue) /= 'sice') coastal_attr%ice_present = .true. + end if + !---------------------------------------------------------- ! Normalization type !---------------------------------------------------------- @@ -592,6 +850,33 @@ subroutine esmFldsExchange_coastal_attr(gcomp, coastal_attr, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return end if + ! to ice + call NUOPC_CompAttributeGet(gcomp, name='atm2ice_smapname', & + isPresent=isPresent, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (isPresent) then + call NUOPC_CompAttributeGet(gcomp, name='atm2ice_smapname', & + value=coastal_attr%atm2ice_smap, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end if + call NUOPC_CompAttributeGet(gcomp, name='ocn2ice_smapname', & + isPresent=isPresent, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (isPresent) then + call NUOPC_CompAttributeGet(gcomp, name='ocn2ice_smapname', & + value=coastal_attr%ocn2ice_smap, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end if + + call NUOPC_CompAttributeGet(gcomp, name='ice2ocn_smapname', & + isPresent=isPresent, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (isPresent) then + call NUOPC_CompAttributeGet(gcomp, name='ice2ocn_smapname', & + value=coastal_attr%ice2ocn_smap, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end if + ! Log Attribute Settings if (btest(verbosity,16)) then write(cvalue,"(I0)") verbosity From bf3ebbc4eae8fa163827952a737aa94e1d2a86a0 Mon Sep 17 00:00:00 2001 From: Joseph Smith Date: Thu, 4 Sep 2025 20:04:53 -0500 Subject: [PATCH 2/4] fixed bug in standalone --- mediator/esmFldsExchange_coastal_mod.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mediator/esmFldsExchange_coastal_mod.F90 b/mediator/esmFldsExchange_coastal_mod.F90 index 0b234c64..70a9b89f 100644 --- a/mediator/esmFldsExchange_coastal_mod.F90 +++ b/mediator/esmFldsExchange_coastal_mod.F90 @@ -293,7 +293,7 @@ subroutine esmFldsExchange_coastal_advt(gcomp, phase, rc) 'So_v ', & ! ocn_current_merid 'So_t ', & ! SST 'So_s ', & ! SSS - 'So_hmix', & ! depth of ml + 'So_h', & ! depth of ml 'So_dhdx', & ! tilt-x 'So_dhdy', & ! tilt-y 'Fioo_q '/) ! heat flux @@ -630,7 +630,7 @@ subroutine esmFldsExchange_coastal_init(gcomp, phase, rc) 'So_v ', & ! ocn_current_merid 'So_t ', & ! SST 'So_s ', & ! SSS - 'So_hmix', & ! Mixed layer depth + 'So_h', & ! Mixed layer depth 'So_dhdx', & ! tilt-x 'So_dhdy', & ! tilt-y 'Fioo_qi'/) ! heat flux From b9529b6e85010fe27b0a1cc61c90409e373daf74 Mon Sep 17 00:00:00 2001 From: Joseph Smith Date: Fri, 5 Sep 2025 13:53:46 -0500 Subject: [PATCH 3/4] updated CESM --- mediator/esmFldsExchange_coastal_mod.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mediator/esmFldsExchange_coastal_mod.F90 b/mediator/esmFldsExchange_coastal_mod.F90 index 70a9b89f..a94493a6 100644 --- a/mediator/esmFldsExchange_coastal_mod.F90 +++ b/mediator/esmFldsExchange_coastal_mod.F90 @@ -293,7 +293,7 @@ subroutine esmFldsExchange_coastal_advt(gcomp, phase, rc) 'So_v ', & ! ocn_current_merid 'So_t ', & ! SST 'So_s ', & ! SSS - 'So_h', & ! depth of ml + 'So_h ', & ! depth of ml 'So_dhdx', & ! tilt-x 'So_dhdy', & ! tilt-y 'Fioo_q '/) ! heat flux @@ -630,7 +630,7 @@ subroutine esmFldsExchange_coastal_init(gcomp, phase, rc) 'So_v ', & ! ocn_current_merid 'So_t ', & ! SST 'So_s ', & ! SSS - 'So_h', & ! Mixed layer depth + 'So_h ', & ! depth of ml 'So_dhdx', & ! tilt-x 'So_dhdy', & ! tilt-y 'Fioo_qi'/) ! heat flux From bcf1f25738c4aa8cf98519cab6fe8ce1a728c070 Mon Sep 17 00:00:00 2001 From: Joseph Smith Date: Fri, 5 Sep 2025 13:56:30 -0500 Subject: [PATCH 4/4] updated CMEPS --- mediator/esmFldsExchange_coastal_mod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediator/esmFldsExchange_coastal_mod.F90 b/mediator/esmFldsExchange_coastal_mod.F90 index a94493a6..1e81951e 100644 --- a/mediator/esmFldsExchange_coastal_mod.F90 +++ b/mediator/esmFldsExchange_coastal_mod.F90 @@ -306,7 +306,7 @@ subroutine esmFldsExchange_coastal_advt(gcomp, phase, rc) end if ! --------------------------------------------------------------------- - ! to ocean: ice fields + ! to ocean: ice fields ! --------------------------------------------------------------------- if (coastal_attr%ocn_present .and. coastal_attr%ice_present) then allocate(S_flds(13))