Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion mediator/esmFldsExchange_cesm_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc)
call addfld(fldListFr(compocn)%flds, 'Faoo_fco2_ocn')
call addfld(fldListTo(compatm)%flds, 'Faoo_fco2_ocn')
else
call addmap(fldListFr(compocn)%flds, 'Faoo_fco2_ocn', compatm, mapconsf, 'one', ocn2atm_fmap)
call addmap(fldListFr(compocn)%flds, 'Faoo_fco2_ocn', compatm, mapconsd, 'one', ocn2atm_fmap)
! custom merge in med_phases_prep_atm
end if
endif
Expand Down
4 changes: 4 additions & 0 deletions mediator/fd_cesm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
canonical_units: N m-2
description: mediator export
#
- standard_name: area
canonical_units: radians**2
description: mediator area for component
#
#-----------------------------------
# section: land export
#-----------------------------------
Expand Down
17 changes: 15 additions & 2 deletions mediator/med.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,7 @@ subroutine DataInitialize(gcomp, rc)

! Create mesh info data
call med_meshinfo_create(is_local%wrap%FBImp(n1,n1), &
is_local%wrap%mesh_info(n1), rc=rc)
is_local%wrap%mesh_info(n1), is_local%wrap%FBArea(n1), rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

Expand Down Expand Up @@ -2568,17 +2568,19 @@ end subroutine SetRunClock

!-----------------------------------------------------------------------------

subroutine med_meshinfo_create(FB, mesh_info, rc)
subroutine med_meshinfo_create(FB, mesh_info, FBArea, rc)

use ESMF , only : ESMF_Array, ESMF_ArrayCreate, ESMF_ArrayDestroy, ESMF_Field, ESMF_FieldGet
use ESMF , only : ESMF_DistGrid, ESMF_FieldBundle, ESMF_FieldRegridGetArea, ESMF_FieldBundleGet
use ESMF , only : ESMF_Mesh, ESMF_MeshGet, ESMF_MESHLOC_ELEMENT, ESMF_TYPEKIND_R8
use ESMF , only : ESMF_SUCCESS, ESMF_FAILURE, ESMF_LogWrite, ESMF_LOGMSG_INFO
use ESMF , only : ESMF_FieldCreate, ESMF_FieldBundleCreate, ESMF_FieldBundleAdd
use med_internalstate_mod , only : mesh_info_type

! input/output variables
type(ESMF_FieldBundle) , intent(in) :: FB
type(mesh_info_type) , intent(inout) :: mesh_info
type(ESMF_FieldBundle) , intent(inout) :: FBArea
integer , intent(out) :: rc

! local variables
Expand Down Expand Up @@ -2629,6 +2631,17 @@ subroutine med_meshinfo_create(FB, mesh_info, rc)
end do
deallocate(ownedElemCoords)

! Create field bundle with areas so that this can be output to mediator history file
lfield = ESMF_FieldCreate(lmesh, ESMF_TYPEKIND_r8, name='area', meshloc=ESMF_MESHLOC_ELEMENT, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
FBArea = ESMF_FieldBundleCreate(rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldBundleAdd(FBArea, (/lfield/), rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldGet(lfield, farrayPtr=dataptr, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
dataptr(:) = mesh_info%areas(:)

end subroutine med_meshinfo_create

!-----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions mediator/med_internalstate_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ module med_internalstate_mod

! Component Mesh info
type(mesh_info_type) :: mesh_info(ncomps)
type(ESMF_FieldBundle) :: FBArea(ncomps) ! needed for mediator history writes

end type InternalStateStruct

Expand Down
8 changes: 7 additions & 1 deletion mediator/med_phases_history_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,20 @@ subroutine med_phases_history_write(gcomp, rc)
nx=nx, ny=ny, nt=1, whead=whead, wdata=wdata, pre=trim(compname(n))//'Exp', rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
endif
! write component mediator fractions
if (ESMF_FieldBundleIsCreated(is_local%wrap%FBFrac(n),rc=rc)) then
nx = is_local%wrap%nx(n)
ny = is_local%wrap%ny(n)
call med_io_write(hist_file, iam, is_local%wrap%FBFrac(n), &
nx=nx, ny=ny, nt=1, whead=whead, wdata=wdata, pre='Med_frac_'//trim(compname(n)), rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
endif
! write component mediator areas
nx = is_local%wrap%nx(n)
ny = is_local%wrap%ny(n)
call med_io_write(hist_file, iam, is_local%wrap%FBArea(n), &
nx=nx, ny=ny, nt=1, whead=whead, wdata=wdata, pre='MED_'//trim(compname(n)), rc=rc)
end if
enddo
if (ESMF_FieldBundleIsCreated(is_local%wrap%FBMed_ocnalb_o,rc=rc)) then
nx = is_local%wrap%nx(compocn)
Expand Down
29 changes: 29 additions & 0 deletions mediator/med_phases_prep_atm_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ subroutine med_phases_prep_atm(gcomp, rc)
type(InternalState) :: is_local
real(R8), pointer :: dataPtr1(:) => null()
real(R8), pointer :: dataPtr2(:) => null()
real(R8), pointer :: ifrac(:) => null()
real(R8), pointer :: ofrac(:) => null()
integer :: i, j, n, n1, ncnt
character(len=*),parameter :: subname='(med_phases_prep_atm)'
!-------------------------------------------------------------------------------
Expand Down Expand Up @@ -190,6 +192,33 @@ subroutine med_phases_prep_atm(gcomp, rc)
end do
end if

! Note - the following needs a custom merge since Faoo_fco2_ocn is scaled by (ifrac+ofrac)
! in the merge to the atm
if ( FB_FldChk(is_local%wrap%FBExp(compatm) , 'Faoo_fco2_ocn', rc=rc) .and. &
FB_FldChk(is_local%wrap%FBImp(compocn,compocn), 'Faoo_fco2_ocn', rc=rc)) then
call ESMF_FieldGet(lfield, farrayPtr=dataptr1, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldBundleGet(is_local%wrap%FBFrac(compatm), fieldName='ifrac', field=lfield, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldGet(lfield, farrayPtr=ifrac, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldBundleGet(is_local%wrap%FBFrac(compatm), fieldName='ofrac', field=lfield, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldGet(lfield, farrayPtr=ofrac, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldBundleGet(is_local%wrap%FBImp(compocn,compatm), fieldName='Faoo_fco2_ocn', 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='Faoo_fco2_ocn', 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

if (dbug_flag > 5) then
call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO)
end if
Expand Down