Skip to content

Commit

Permalink
fixes for problems found in UFS
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariana Vertenstein committed Jun 25, 2024
1 parent 2d3c1a7 commit 5624c70
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
9 changes: 6 additions & 3 deletions mediator/med_internalstate_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ subroutine med_internalstate_init(gcomp, rc)
integer :: num_icesheets
character(len=CL) :: atm_mesh_name
character(len=CL) :: lnd_mesh_name
logical :: isPresent, isSet
logical :: isPresent_lnd, isSet_lnd
logical :: isPresent_atm, isSet_atm
character(len=*),parameter :: subname=' (internalstate init) '
!-----------------------------------------------------------

Expand All @@ -243,12 +244,14 @@ subroutine med_internalstate_init(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! determine if atm and lnd have the same mesh
call NUOPC_CompAttributeGet(gcomp, name='mesh_atm', value=atm_mesh_name, rc=rc)
call NUOPC_CompAttributeGet(gcomp, name='mesh_atm', value=atm_mesh_name, &
isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompAttributeGet(gcomp, name='mesh_lnd', value=lnd_mesh_name, &
isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then

if ((isPresent_lnd .and. isSet_lnd) .and. (isPresent_atm .and. isSet_atm)) then
if (trim(atm_mesh_name) == trim(lnd_mesh_name)) then
samegrid_atmlnd = .true.
else
Expand Down
36 changes: 19 additions & 17 deletions mediator/med_phases_prep_atm_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ module med_phases_prep_atm_mod

real(r8), public :: global_htot_corr(1) = 0._r8 ! enthalpy correction from med_phases_prep_ocn

character(len=14) :: fldnames_to_ocn(5) = (/'Faoo_fbrf_ocn','Faoo_fdms_ocn ','Faoo_fco2_ocn ',&
'Faoo_fn2o_ocn','Faoo_fnh3_ocn'/)
character(len=14) :: fldnames_from_ocn(5) = (/'Faoo_fbrf_ocn','Faoo_fdms_ocn ','Faoo_fco2_ocn ',&
'Faoo_fn2o_ocn','Faoo_fnh3_ocn'/)

character(*), parameter :: u_FILE_u = &
__FILE__
Expand Down Expand Up @@ -211,21 +211,23 @@ subroutine med_phases_prep_atm(gcomp, rc)
call ESMF_FieldGet(lfield, farrayPtr=ofrac, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

do nf = 1,len(fldnames_to_ocn)
if ( FB_FldChk(is_local%wrap%FBExp(compatm) , trim(fldnames_to_ocn(nf)), rc=rc) .and. &
FB_FldChk(is_local%wrap%FBImp(compocn,compocn), trim(fldnames_to_ocn(nf)), rc=rc)) then
call ESMF_FieldBundleGet(is_local%wrap%FBImp(compocn,compatm), fieldName=trim(fldnames_to_ocn(nf)), field=lfield, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldGet(lfield, farrayPtr=dataptr1, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldBundleGet(is_local%wrap%FBExp(compatm), fieldName=trim(fldnames_to_ocn(nf)), field=lfield, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldGet(lfield, farrayPtr=dataptr2, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
do n = 1,size(dataptr2)
dataptr2(n) = (ifrac(n) + ofrac(n)) * dataptr1(n)
end do
end if
do nf = 1,len(fldnames_from_ocn)
if ( FB_FldChk(is_local%wrap%FBExp(compatm) , trim(fldnames_from_ocn(nf)), rc=rc) .and. &
FB_FldChk(is_local%wrap%FBImp(compocn,compocn), trim(fldnames_from_ocn(nf)), rc=rc)) then
call ESMF_FieldBundleGet(is_local%wrap%FBImp(compocn,compatm), &
fieldName=trim(fldnames_from_ocn(nf)), field=lfield, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldGet(lfield, farrayPtr=dataptr1, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldBundleGet(is_local%wrap%FBExp(compatm), &
fieldName=trim(fldnames_from_ocn(nf)), field=lfield, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldGet(lfield, farrayPtr=dataptr2, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
do n = 1,size(dataptr2)
dataptr2(n) = (ifrac(n) + ofrac(n)) * dataptr1(n)
end do
end if
end do

! Add enthalpy correction to sensible heat if appropriate
Expand Down

0 comments on commit 5624c70

Please sign in to comment.