Skip to content

Commit

Permalink
set aream for rof when it is not computed by us
Browse files Browse the repository at this point in the history
it should be better to compute ourselves, if we have the
mesh information
this could be a performance sink
  • Loading branch information
iulian787 committed Nov 7, 2024
1 parent 04b66a0 commit 3742c43
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
33 changes: 32 additions & 1 deletion driver-moab/main/component_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ subroutine component_init_aream(infodata, rof_c2_ocn, samegrid_ao, samegrid_al,
! character(1024) :: domain_file ! file containing domain info (set my input)
use seq_comm_mct, only: mboxid ! iMOAB id for MPAS ocean migrated mesh to coupler pes
use seq_comm_mct, only: mbaxid ! iMOAB id for atm migrated mesh to coupler pes
use seq_comm_mct, only: mbrxid ! iMOAB id for rof migrated mesh to coupler pes
use seq_comm_mct, only: mb_rof_aream_computed
#endif
!
! Arguments
Expand Down Expand Up @@ -527,6 +529,9 @@ subroutine component_init_aream(infodata, rof_c2_ocn, samegrid_ao, samegrid_al,
dom_s%data%rAttr(km,:) = dom_s%data%rAttr(ka,:)

#ifdef HAVE_MOAB
! TODO should actually compute aream from mesh model
! we do a lot of unnecessary gymnastics, and very inefficient, because we have a
! different distribution compared to mct source grid atm
tagtype = 1 ! dense, double
tagname='aream'//C_NULL_CHAR
nloc = mct_avect_lsize(dom_s%data)
Expand All @@ -542,6 +547,8 @@ subroutine component_init_aream(infodata, rof_c2_ocn, samegrid_ao, samegrid_al,
write(logunit,*) subname,' error in setting the aream tag on atm '
call shr_sys_abort(subname//' ERROR in setting aream tag on atm ')
endif
deallocate(gids)
deallocate(data1)
! project now aream on ocean (from atm)
#endif
call seq_map_map(mapper_Fa2o, av_s=dom_s%data, av_d=dom_d%data, fldlist='aream')
Expand Down Expand Up @@ -597,7 +604,31 @@ subroutine component_init_aream(infodata, rof_c2_ocn, samegrid_ao, samegrid_al,
gsmap_s=gsmap_s, av_s=dom_s%data, avfld_s='aream', filefld_s='area_a', &
string='rof2ocn ice aream initialization')
call t_stopf('CPL:seq_map_readdata-rof2ocn_ice')

! this should be more efficient if we just compute aream on coupler side, from actual mesh that we have
! we need to expose that method in iMOAB, which is local
! what we do here, we get aream from the domain dom_rx, we just filled it above, with readdata
if(.not. mb_rof_aream_computed) then

! we do a lot of unnecessary gymnastics, and very inefficient, because we have a
! different distribution compared to mct source grid atm
tagtype = 1 ! dense, double
tagname='aream'//C_NULL_CHAR
nloc = mct_avect_lsize(dom_s%data)
allocate(data1(nloc))
data1 = dom_s%data%rAttr(ka,:)
ent_type = 1 ! element dense double tags
allocate(gids(nloc))
gids = dom_s%data%iAttr(mct_aVect_indexIA(dom_s%data,"GlobGridNum"),:)
! ! now set data on the coupler side too
ierr = iMOAB_SetDoubleTagStorageWithGid ( mbrxid, tagname, nloc, ent_type, &
data1, gids)
if (ierr .ne. 0) then
write(logunit,*) subname,' error in setting the aream tag on rof '
call shr_sys_abort(subname//' ERROR in setting aream tag on rof ')
endif
deallocate(gids)
deallocate(data1)
endif
endif
end if

Expand Down
4 changes: 4 additions & 0 deletions driver-moab/main/prep_lnd_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module prep_lnd_mod
use seq_comm_mct, only: mbrxid ! iMOAB id of moab rof on coupler pes (FV now)
use seq_comm_mct, only: mbintxal ! iMOAB id for intx mesh between atm and lnd
use seq_comm_mct, only: mbintxrl ! iMOAB id for intx mesh between river and land
use seq_comm_mct, only: mb_rof_aream_computed ! signal

use seq_comm_mct, only: mbaxid ! iMOAB id for atm migrated mesh to coupler pes
use seq_comm_mct, only: atm_pg_active ! whether the atm uses FV mesh or not ; made true if fv_nphys > 0
Expand Down Expand Up @@ -327,6 +328,9 @@ subroutine prep_lnd_init(infodata, atm_c2_lnd, rof_c2_lnd, glc_c2_lnd, iac_c2_ln
fNoBubble, monotonicity, volumetric, fInverseDistanceMap, &
noConserve, validate, &
trim(dofnameS), trim(dofnameT) )

! signal that the aream for rof has been computed
mb_rof_aream_computed = .true.
if (ierr .ne. 0) then
write(logunit,*) subname,' error in computing rl weights '
call shr_sys_abort(subname//' ERROR in computing rl weights ')
Expand Down
2 changes: 2 additions & 0 deletions driver-moab/main/prep_rof_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module prep_rof_mod
use component_type_mod, only: ocn ! used for context for projection towards ocean from rof !
use prep_lnd_mod, only: prep_lnd_get_mapper_Fr2l
use map_lnd2rof_irrig_mod, only: map_lnd2rof_irrig
use seq_comm_mct, only: mb_rof_aream_computed ! signal

use iso_c_binding
#ifdef MOABCOMP
Expand Down Expand Up @@ -417,6 +418,7 @@ subroutine prep_rof_init(infodata, lnd_c2_rof, atm_c2_rof, ocn_c2_rof)
fNoBubble, monotonicity, volumetric, fInverseDistanceMap, &
noConserve, validate, &
trim(dofnameS), trim(dofnameT) )
mb_rof_aream_computed = .true. ! signal
if (ierr .ne. 0) then
write(logunit,*) subname,' error in computing lr weights '
call shr_sys_abort(subname//' ERROR in computing lr weights ')
Expand Down
1 change: 1 addition & 0 deletions driver-moab/shr/seq_comm_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ module seq_comm_mct
integer, public :: mbintxrl ! iMOAB id for intx mesh between river and land

integer, public :: num_moab_exports ! iMOAB id for atm phys grid, on atm pes
logical, public :: mb_rof_aream_computed = .false. ! whether the aream for rof has been set or not

!=======================================================================
contains
Expand Down

0 comments on commit 3742c43

Please sign in to comment.