Skip to content

Commit 067316d

Browse files
authored
Merge branch 'iulian787/correction_factors_from_mct' (PR #7476)
Copy correction factors from mct to moab which eliminates differences between the two within the combined coupler in driver-moab (when reading maps). Ignore for the time being the correction factors computed by moab. Also add and remove a mesh write in MOABDEBUG.
2 parents d2e0273 + ee6c7f7 commit 067316d

File tree

3 files changed

+37
-23
lines changed

3 files changed

+37
-23
lines changed

driver-moab/main/component_mod.F90

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ subroutine component_init_aream(infodata, rof_c2_ocn, samegrid_ao, samegrid_al,
470470
use iso_c_binding
471471
! character(1024) :: domain_file ! file containing domain info (set my input)
472472
use seq_comm_mct, only: mboxid ! iMOAB id for MPAS ocean migrated mesh to coupler pes
473+
use seq_comm_mct, only: mbixid ! iMOAB id for MPAS sea-ice migrated mesh to coupler pes
473474
use seq_comm_mct, only: mblxid ! iMOAB id for lnd migrated mesh to coupler pes
474475
use seq_comm_mct, only: mbaxid ! iMOAB id for atm migrated mesh to coupler pes
475476
use seq_comm_mct, only: mbrxid ! iMOAB id for rof migrated mesh to coupler pes
@@ -658,6 +659,14 @@ subroutine component_init_aream(infodata, rof_c2_ocn, samegrid_ao, samegrid_al,
658659
call shr_sys_abort(subname//' ERROR in writing ocn mesh coupler ')
659660
endif
660661
endif
662+
if(mbixid >=0 ) then
663+
ierr = iMOAB_WriteMesh(mbixid, trim('cplIceWithAream.h5m'//C_NULL_CHAR), &
664+
trim(';PARALLEL=WRITE_PART'//C_NULL_CHAR))
665+
if (ierr .ne. 0) then
666+
write(logunit,*) subname,' error in writing ice mesh coupler '
667+
call shr_sys_abort(subname//' ERROR in writing ice mesh coupler ')
668+
endif
669+
endif
661670
if(mbrxid >=0 ) then
662671
ierr = iMOAB_WriteMesh(mbrxid, trim('cplRofWithAream.h5m'//C_NULL_CHAR), &
663672
trim(';PARALLEL=WRITE_PART'//C_NULL_CHAR))
@@ -776,8 +785,10 @@ subroutine component_init_areacor_moab (comp, mbccid, mbcxid, seq_flds_c2x_fluxe
776785

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

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

865+
lsize = comp(1)%mblsize
866+
tagname = 'mdl2drv'//C_NULL_CHAR
867+
ierr = iMOAB_SetDoubleTagStorage(mbccid , tagname, lsize , comp(1)%mbGridType, comp(1)%mdl2drv)
868+
if (ierr .ne. 0) then
869+
call shr_sys_abort(subname//' cannot set new mdl2drv values for moab like those for mct ')
870+
endif
871+
tagname = 'drv2mdl'//C_NULL_CHAR
872+
ierr = iMOAB_SetDoubleTagStorage(mbccid , tagname, lsize , comp(1)%mbGridType, comp(1)%drv2mdl)
873+
if (ierr .ne. 0) then
874+
call shr_sys_abort(subname//' cannot set new mdldrv2mdl2drv values for moab like those for mct ')
875+
endif
876+
851877
allocate(vals(lsize, nfields))
852878
tagname = trim(seq_flds_c2x_fluxes)//C_NULL_CHAR
853879
arrsize = lsize * nfields
@@ -859,9 +885,11 @@ subroutine component_init_areacor_moab (comp, mbccid, mbcxid, seq_flds_c2x_fluxe
859885
do i=1,lsize
860886
rmask = areas(i,3)
861887
if ( abs(rmask) >= 1.0e-06) then
862-
fact = factors(i,1) ! mdl2drv tag
888+
! fact = factors(i,1) ! mdl2drv tag
889+
! do nt use what we computed; use the values from mct driver
890+
fact = comp(1)%mdl2drv(i)
863891
do j=1,nfields
864-
vals(i,j) = fact*vals(i,j)
892+
vals(i,j) = vals(i,j) * fact
865893
enddo
866894
endif
867895
enddo
@@ -1271,7 +1299,7 @@ subroutine factor_moab_comp(comp, type, seq_flds_fluxes)
12711299
endif
12721300
do i=1,comp%mblsize
12731301
do j=1,nfields
1274-
vals(i,j) = factors(i) * vals(i,j)
1302+
vals(i,j) = vals(i,j) * factors(i)
12751303
enddo
12761304
enddo
12771305

driver-moab/main/cplcomp_exchange_mod.F90

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,30 +1914,11 @@ subroutine component_exch_moab(comp, mbAPPid1, mbAppid2, direction, fields, cont
19141914
target_id = target_id + 200
19151915
endif
19161916
if (mbAPPid1 .ge. 0) then ! we are on the sending pes
1917-
#ifdef MOABDEBUG
1918-
if (direction .eq. 0 ) then
1919-
dir = 'c2x'
1920-
else
1921-
dir = 'x2c'
1922-
endif
1923-
write(lnum,"(I0.2)") num_moab_exports
1924-
if (present(context_exch)) then
1925-
outfile = comp%ntype//'_src_'//trim(context_exch)//'_'//trim(dir)//'_'//trim(lnum)//'.h5m'//C_NULL_CHAR
1926-
else
1927-
outfile = comp%ntype//'_src_'//trim(dir)//'_'//trim(lnum)//'.h5m'//C_NULL_CHAR
1928-
endif
1929-
wopts = ';PARALLEL=WRITE_PART'//C_NULL_CHAR !
1930-
ierr = iMOAB_WriteMesh(mbAPPid1, trim(outfile), trim(wopts))
1931-
if (ierr .ne. 0) then
1932-
call shr_sys_abort(subname//' cannot write file '// outfile)
1933-
endif
1934-
#endif
19351917
! basically, use the initial partitioning
19361918
ierr = iMOAB_SendElementTag(mbAPPid1, tagName, mpicom_join, target_id)
19371919
if (ierr .ne. 0) then
19381920
call shr_sys_abort(subname//' cannot send element tag: '//trim(tagName))
19391921
endif
1940-
19411922
endif
19421923
if ( mbAPPid2 .ge. 0 ) then ! we are on receiving end
19431924
ierr = iMOAB_ReceiveElementTag(mbAPPid2, tagName, mpicom_join, source_id)

driver-moab/main/seq_frac_mct.F90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ subroutine seq_frac_init( infodata, &
337337
integer id_join ! used for example for atm%cplcompid
338338
integer :: mpicom ! we are on coupler PES here
339339
integer :: my_task !
340+
#ifdef MOABDEBUG
341+
integer :: mbix2id ! just for debugging to expose ice mct to compare with ocn mct
342+
! are they the same or not?
343+
#endif
340344
character(30) :: outfile, wopts
341345

342346

@@ -467,6 +471,7 @@ subroutine seq_frac_init( infodata, &
467471
#ifdef MOABDEBUG
468472
! mblx2id is the id for moab app exposing land cpl
469473
call expose_mct_grid_moab(lnd, mblx2id)
474+
call expose_mct_grid_moab(ice, mbix2id)
470475
#endif
471476

472477
kk = mct_aVect_indexRA(fractions_l,"lfrin",perrWith=subName)

0 commit comments

Comments
 (0)