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
36 changes: 32 additions & 4 deletions driver-moab/main/component_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ subroutine component_init_aream(infodata, rof_c2_ocn, samegrid_ao, samegrid_al,
use iso_c_binding
! 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: mbixid ! iMOAB id for MPAS sea-ice migrated mesh to coupler pes
use seq_comm_mct, only: mblxid ! iMOAB id for lnd 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
Expand Down Expand Up @@ -658,6 +659,14 @@ subroutine component_init_aream(infodata, rof_c2_ocn, samegrid_ao, samegrid_al,
call shr_sys_abort(subname//' ERROR in writing ocn mesh coupler ')
endif
endif
if(mbixid >=0 ) then
ierr = iMOAB_WriteMesh(mbixid, trim('cplIceWithAream.h5m'//C_NULL_CHAR), &
trim(';PARALLEL=WRITE_PART'//C_NULL_CHAR))
if (ierr .ne. 0) then
write(logunit,*) subname,' error in writing ice mesh coupler '
call shr_sys_abort(subname//' ERROR in writing ice mesh coupler ')
endif
endif
if(mbrxid >=0 ) then
ierr = iMOAB_WriteMesh(mbrxid, trim('cplRofWithAream.h5m'//C_NULL_CHAR), &
trim(';PARALLEL=WRITE_PART'//C_NULL_CHAR))
Expand Down Expand Up @@ -776,8 +785,10 @@ subroutine component_init_areacor_moab (comp, mbccid, mbcxid, seq_flds_c2x_fluxe

! For only component pes
if (comp(1)%iamin_compid) then
! Allocate and initialize area correction factors on component processes
! Allocate and initialize area correction factors on component processes
! get areas, first allocate memory
! Side Note:: !!! TODO mblsize on component side is always the size of comp domain for mct, too
! that is the whole point, we are using the same order, and the same grid size as mct driver
lsize = comp(1)%mblsize
allocate(areas (lsize, 3)) ! lsize is along grid; read mask too
allocate(factors (lsize, 2))
Expand Down Expand Up @@ -847,7 +858,22 @@ subroutine component_init_areacor_moab (comp, mbccid, mbcxid, seq_flds_c2x_fluxe
nfields=mct_list_nitem (temp_list)
call mct_list_clean(temp_list)

! above aream work is irrelevant with this:
! as a quick fix, set the correction factors on component side, on MOAB tags mdl2drv and drv2mdl
! exactly as those from mct; hopefully, we will see zero differences with MOABCOMP

lsize = comp(1)%mblsize
tagname = 'mdl2drv'//C_NULL_CHAR
ierr = iMOAB_SetDoubleTagStorage(mbccid , tagname, lsize , comp(1)%mbGridType, comp(1)%mdl2drv)
if (ierr .ne. 0) then
call shr_sys_abort(subname//' cannot set new mdl2drv values for moab like those for mct ')
endif
tagname = 'drv2mdl'//C_NULL_CHAR
ierr = iMOAB_SetDoubleTagStorage(mbccid , tagname, lsize , comp(1)%mbGridType, comp(1)%drv2mdl)
if (ierr .ne. 0) then
call shr_sys_abort(subname//' cannot set new mdldrv2mdl2drv values for moab like those for mct ')
endif

allocate(vals(lsize, nfields))
tagname = trim(seq_flds_c2x_fluxes)//C_NULL_CHAR
arrsize = lsize * nfields
Expand All @@ -859,9 +885,11 @@ subroutine component_init_areacor_moab (comp, mbccid, mbcxid, seq_flds_c2x_fluxe
do i=1,lsize
rmask = areas(i,3)
if ( abs(rmask) >= 1.0e-06) then
fact = factors(i,1) ! mdl2drv tag
! fact = factors(i,1) ! mdl2drv tag
! do nt use what we computed; use the values from mct driver
fact = comp(1)%mdl2drv(i)
do j=1,nfields
vals(i,j) = fact*vals(i,j)
vals(i,j) = vals(i,j) * fact
enddo
endif
enddo
Expand Down Expand Up @@ -1271,7 +1299,7 @@ subroutine factor_moab_comp(comp, type, seq_flds_fluxes)
endif
do i=1,comp%mblsize
do j=1,nfields
vals(i,j) = factors(i) * vals(i,j)
vals(i,j) = vals(i,j) * factors(i)
enddo
enddo

Expand Down
19 changes: 0 additions & 19 deletions driver-moab/main/cplcomp_exchange_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1914,30 +1914,11 @@ subroutine component_exch_moab(comp, mbAPPid1, mbAppid2, direction, fields, cont
target_id = target_id + 200
endif
if (mbAPPid1 .ge. 0) then ! we are on the sending pes
#ifdef MOABDEBUG
if (direction .eq. 0 ) then
dir = 'c2x'
else
dir = 'x2c'
endif
write(lnum,"(I0.2)") num_moab_exports
if (present(context_exch)) then
outfile = comp%ntype//'_src_'//trim(context_exch)//'_'//trim(dir)//'_'//trim(lnum)//'.h5m'//C_NULL_CHAR
else
outfile = comp%ntype//'_src_'//trim(dir)//'_'//trim(lnum)//'.h5m'//C_NULL_CHAR
endif
wopts = ';PARALLEL=WRITE_PART'//C_NULL_CHAR !
ierr = iMOAB_WriteMesh(mbAPPid1, trim(outfile), trim(wopts))
if (ierr .ne. 0) then
call shr_sys_abort(subname//' cannot write file '// outfile)
endif
#endif
! basically, use the initial partitioning
ierr = iMOAB_SendElementTag(mbAPPid1, tagName, mpicom_join, target_id)
if (ierr .ne. 0) then
call shr_sys_abort(subname//' cannot send element tag: '//trim(tagName))
endif

endif
if ( mbAPPid2 .ge. 0 ) then ! we are on receiving end
ierr = iMOAB_ReceiveElementTag(mbAPPid2, tagName, mpicom_join, source_id)
Expand Down
5 changes: 5 additions & 0 deletions driver-moab/main/seq_frac_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ subroutine seq_frac_init( infodata, &
integer id_join ! used for example for atm%cplcompid
integer :: mpicom ! we are on coupler PES here
integer :: my_task !
#ifdef MOABDEBUG
integer :: mbix2id ! just for debugging to expose ice mct to compare with ocn mct
! are they the same or not?
#endif
character(30) :: outfile, wopts


Expand Down Expand Up @@ -467,6 +471,7 @@ subroutine seq_frac_init( infodata, &
#ifdef MOABDEBUG
! mblx2id is the id for moab app exposing land cpl
call expose_mct_grid_moab(lnd, mblx2id)
call expose_mct_grid_moab(ice, mbix2id)
#endif

kk = mct_aVect_indexRA(fractions_l,"lfrin",perrWith=subName)
Expand Down