Skip to content

Commit b8fd8b5

Browse files
authored
Merge branch 'iulian787/fix_r2o_maps' (PR #7559)
move map mesh migrate out of flood block. map mesh migrate for r2o maps should happen always, even if flood is not present.
2 parents 717c0cb + c2d5812 commit b8fd8b5

File tree

1 file changed

+60
-71
lines changed

1 file changed

+60
-71
lines changed

driver-moab/main/prep_ocn_mod.F90

Lines changed: 60 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ subroutine prep_ocn_init(infodata, atm_c2_ocn, atm_c2_ice, ice_c2_ocn, rof_c2_oc
420420
'seq_maps.rc','atm2ocn_fmapname:','atm2ocn_fmaptype:',samegrid_ao, &
421421
'mapper_Fa2o initialization', esmf_map_flag, no_match)
422422
call shr_sys_flush(logunit)
423-
#ifdef HAVE_MOAB
424423
! Call moab intx only if atm and ocn are init in moab
425424
if ((mbaxid .ge. 0) .and. (mboxid .ge. 0)) then
426425
if (iamroot_CPLID) then
@@ -605,8 +604,7 @@ subroutine prep_ocn_init(infodata, atm_c2_ocn, atm_c2_ice, ice_c2_ocn, rof_c2_oc
605604
endif ! if (.not. samegrid_ao)
606605

607606
endif ! if ((mbaxid .ge. 0) .and. (mboxid .ge. 0))
608-
! endif HAVE_MOAB
609-
#endif
607+
610608
end if ! if (atm_present)
611609

612610
! atm_c2_ice flag is here because ICE and OCN are constrained to be on the same
@@ -694,7 +692,6 @@ subroutine prep_ocn_init(infodata, atm_c2_ocn, atm_c2_ice, ice_c2_ocn, rof_c2_oc
694692
write(logunit,F00) 'Initializing mapper_SFi2o'
695693
end if
696694
call seq_map_init_rearrolap(mapper_SFi2o, ice(1), ocn(1), 'mapper_SFi2o')
697-
#ifdef HAVE_MOAB
698695
if ( (mbixid .ge. 0) .and. (mboxid .ge. 0)) then
699696
if (iamroot_CPLID) then
700697
write(logunit,*) ' '
@@ -737,7 +734,6 @@ subroutine prep_ocn_init(infodata, atm_c2_ocn, atm_c2_ice, ice_c2_ocn, rof_c2_oc
737734
mapper_SFi2o%intx_context = ocn(1)%cplcompid
738735
mapper_SFi2o%mbname = 'mapper_SFi2o'
739736
endif
740-
#endif
741737
endif ! if (ice_present)
742738
call shr_sys_flush(logunit)
743739

@@ -754,7 +750,6 @@ subroutine prep_ocn_init(infodata, atm_c2_ocn, atm_c2_ice, ice_c2_ocn, rof_c2_oc
754750
call seq_comm_getData(CPLID, mpicom=mpicom_CPLID, iamroot=iamroot_CPLID)
755751
call seq_comm_getData(CPLID, mpigrp=mpigrp_CPLID) ! second group, the coupler group CPLID is global variable
756752

757-
#ifdef HAVE_MOAB
758753
appname = "ROF_OCN_COU"//CHAR(0)
759754
! rmapid is a unique external number of MOAB app that takes care of map between rof and ocn mesh
760755
rmapid = 100*rof(1)%cplcompid + ocn(1)%cplcompid ! something different, to differentiate it
@@ -835,87 +830,81 @@ subroutine prep_ocn_init(infodata, atm_c2_ocn, atm_c2_ice, ice_c2_ocn, rof_c2_oc
835830
mapper_Rr2o_liq%weight_identifier = wgtIdFr2ol
836831
mapper_Rr2o_liq%mbname = 'mapper_Rr2o_liq'
837832

838-
#endif
839833

840-
if (iamroot_CPLID) then
841-
write(logunit,*) ' '
842-
write(logunit,F00) 'Initializing mapper_Rr2o_ice'
843-
end if
844-
! is this the same map as above ?
845-
call seq_map_init_rcfile(mapper_Rr2o_ice, rof(1), ocn(1), &
846-
'seq_maps.rc', 'rof2ocn_ice_rmapname:', 'rof2ocn_ice_rmaptype:',samegrid_ro, &
847-
'mapper_Rr2o_ice initialization', esmf_map_flag, no_match )
834+
if (iamroot_CPLID) then
835+
write(logunit,*) ' '
836+
write(logunit,F00) 'Initializing mapper_Rr2o_ice'
837+
end if
838+
! is this the same map as above ?
839+
call seq_map_init_rcfile(mapper_Rr2o_ice, rof(1), ocn(1), &
840+
'seq_maps.rc', 'rof2ocn_ice_rmapname:', 'rof2ocn_ice_rmaptype:',samegrid_ro, &
841+
'mapper_Rr2o_ice initialization', esmf_map_flag, no_match )
848842
! us the same one for mapper_Rr2o_ice and mapper_Fr2o
849-
#ifdef HAVE_MOAB
850843
! now take care of the mapper for MOAB mapper_Rr2o_ice
844+
if (iamroot_CPLID) then
845+
write(logunit,*) ' '
846+
write(logunit,F00) 'Initializing MOAB mapper_Rr2o_ice same as mapper_Rr2o_liq'
847+
end if
848+
849+
! If loading map from disk, then load the R2O_ice map
850+
if (.not. compute_maps_online_r2o) then
851+
type_grid = 3 ! this is type of grid
852+
arearead = 0 ! no need for areas
853+
call moab_map_init_rcfile( mbrxid, mboxid, mbintxro, type_grid, &
854+
'seq_maps.rc', 'rof2ocn_ice_rmapname:', 'rof2ocn_ice_rmaptype:', samegrid_ro, &
855+
arearead, wgtIdFr2oi, 'mapper_Rr2o_ice moab initialization', esmf_map_flag, wgtIdFr2ol )
856+
end if
857+
mapper_Rr2o_ice%src_mbid = mbrxid
858+
mapper_Rr2o_ice%tgt_mbid = mboxid
859+
mapper_Rr2o_ice%intx_mbid = mbintxro
860+
mapper_Rr2o_ice%src_context = rof(1)%cplcompid
861+
mapper_Rr2o_ice%intx_context = rmapid ! read map is the same context as intersection now
862+
mapper_Rr2o_ice%weight_identifier = wgtIdFr2oi
863+
mapper_Rr2o_ice%mbname = 'mapper_Rr2o_ice'
864+
if (flood_present) then
851865
if (iamroot_CPLID) then
852866
write(logunit,*) ' '
853-
write(logunit,F00) 'Initializing MOAB mapper_Rr2o_ice same as mapper_Rr2o_liq'
867+
write(logunit,F00) 'Initializing mapper_Fr2o'
854868
end if
855-
856-
! If loading map from disk, then load the R2O_ice map
857-
if (.not. compute_maps_online_r2o) then
858-
type_grid = 3 ! this is type of grid
859-
arearead = 0 ! no need for areas
860-
call moab_map_init_rcfile( mbrxid, mboxid, mbintxro, type_grid, &
861-
'seq_maps.rc', 'rof2ocn_ice_rmapname:', 'rof2ocn_ice_rmaptype:', samegrid_ro, &
862-
arearead, wgtIdFr2oi, 'mapper_Rr2o_ice moab initialization', esmf_map_flag, wgtIdFr2ol )
863-
end if
864-
mapper_Rr2o_ice%src_mbid = mbrxid
865-
mapper_Rr2o_ice%tgt_mbid = mboxid
866-
mapper_Rr2o_ice%intx_mbid = mbintxro
867-
mapper_Rr2o_ice%src_context = rof(1)%cplcompid
868-
mapper_Rr2o_ice%intx_context = rmapid ! read map is the same context as intersection now
869-
mapper_Rr2o_ice%weight_identifier = wgtIdFr2oi
870-
mapper_Rr2o_ice%mbname = 'mapper_Rr2o_ice'
871-
#endif
872-
if (flood_present) then
873-
if (iamroot_CPLID) then
874-
write(logunit,*) ' '
875-
write(logunit,F00) 'Initializing mapper_Fr2o'
876-
end if
877-
no_match = .true. ! force to create a new mapper object
878-
call seq_map_init_rcfile( mapper_Fr2o, rof(1), ocn(1), &
869+
no_match = .true. ! force to create a new mapper object
870+
call seq_map_init_rcfile( mapper_Fr2o, rof(1), ocn(1), &
879871
'seq_maps.rc', 'rof2ocn_fmapname:', 'rof2ocn_fmaptype:',samegrid_ro, &
880872
string='mapper_Fr2o initialization', esmf_map=esmf_map_flag, no_match=no_match )
881-
882-
#ifdef HAVE_MOAB
883-
! now take care of the mapper for MOAB mapper_Fr2o
884-
if (iamroot_CPLID) then
885-
write(logunit,*) ' '
886-
write(logunit,F00) 'Initializing MOAB mapper_Fr2o'
887-
end if
888-
! If loading map from disk, then load the scalar map as well
873+
! now take care of the mapper for MOAB mapper_Fr2o
874+
if (iamroot_CPLID) then
875+
write(logunit,*) ' '
876+
write(logunit,F00) 'Initializing MOAB mapper_Fr2o'
877+
end if
878+
! If loading map from disk, then load the scalar map as well
889879
if (.not. compute_maps_online_r2o) then
890880
type_grid = 3 ! this is type of grid
891881
arearead = 0 ! no need for areas
892882
call moab_map_init_rcfile( mbrxid, mboxid, mbintxro, type_grid, &
893883
'seq_maps.rc', 'rof2ocn_fmapname:', 'rof2ocn_fmaptype:', samegrid_ro, &
894884
arearead, wgtIdFr2o, 'mapper_Fr2o MOAB initialization', esmf_map_flag, wgtIdFr2ol )
895-
896-
context_id = rmapid ! ocn(1)%cplcompid
897-
! this creates a parallel communication graph between mbrxid and mbintxro,
898-
! with ids rof(1)%cplcompid, rmapid (rmapid is 100*src+tgt)
899-
! this will be used in send/receive mappers
900-
ierr = iMOAB_MigrateMapMesh ( mbrxid, mbintxro, mpicom_CPLID, mpigrp_CPLID, &
901-
mpigrp_CPLID, type_grid, rof(1)%cplcompid, context_id )
902-
if (ierr .ne. 0) then
903-
write(logunit,*) subname,' error in migrating rof mesh for map rof c2 ocn '
904-
call shr_sys_abort(subname//' ERROR in migrating rof mesh for map rof c2 ocn ')
905-
endif
906-
907885
end if
886+
mapper_Fr2o%src_mbid = mbrxid
887+
mapper_Fr2o%tgt_mbid = mboxid ! special
888+
mapper_Fr2o%intx_mbid = mbintxro
889+
mapper_Fr2o%src_context = rof(1)%cplcompid
890+
mapper_Fr2o%intx_context = rmapid ! read map is the same context as intersection now
891+
mapper_Fr2o%weight_identifier = wgtIdFr2o
892+
mapper_Fr2o%mbname = 'mapper_Fr2o'
893+
endif
908894

909-
mapper_Fr2o%src_mbid = mbrxid
910-
mapper_Fr2o%tgt_mbid = mboxid ! special
911-
mapper_Fr2o%intx_mbid = mbintxro
912-
mapper_Fr2o%src_context = rof(1)%cplcompid
913-
mapper_Fr2o%intx_context = rmapid ! read map is the same context as intersection now
914-
mapper_Fr2o%weight_identifier = wgtIdFr2o
915-
mapper_Fr2o%mbname = 'mapper_Fr2o'
916-
#endif
917-
endif
918-
895+
context_id = rmapid ! ocn(1)%cplcompid*100+rof(1)%cplcompid
896+
type_grid = 3 ! this is type of grid
897+
if (.not. compute_maps_online_r2o) then
898+
ierr = iMOAB_MigrateMapMesh ( mbrxid, mbintxro, mpicom_CPLID, mpigrp_CPLID, &
899+
mpigrp_CPLID, type_grid, rof(1)%cplcompid, context_id )
900+
if (ierr .ne. 0) then
901+
write(logunit,*) subname,' error in migrating rof mesh for map rof c2 ocn '
902+
call shr_sys_abort(subname//' ERROR in migrating rof mesh for map rof c2 ocn ')
903+
endif
904+
endif
905+
! this creates a parallel communication graph between mbrxid and mbintxro,
906+
! with ids rof(1)%cplcompid, rmapid (rmapid is 100*src+tgt)
907+
! this will be used in send/receive mappers
919908
ierr = iMOAB_ComputeCommGraph( mbrxid, mbintxro, mpicom_CPLID, mpigrp_CPLID, mpigrp_CPLID, &
920909
type_grid, type_grid, rof(1)%cplcompid, rmapid )
921910
if (ierr .ne. 0) then

0 commit comments

Comments
 (0)