Skip to content

Conversation

iulian787
Copy link
Contributor

@iulian787 iulian787 commented Jul 8, 2025

Refactor MOAB mapping infrastructure to support more map types and specific area reads.

Restructure the MOAB mapping system to use distinct weight identifiers
for scalar and flux mappings across all component interactions. Also allow specifying which areas to read from the map
for setting aream in the coupler.

No longer need to copy MCT area correction factors mdl2drv/drv2mdl to MOAB. Now that areams are set
correctly, can calculate them with MOAB data.

Key changes:

  • Replace single conservative weight IDs with separate scalar/flux IDs
  • Add proper area reading controls for different map types
  • Reorganize map initialization order and communication graph setup
  • Clean up commented code and improve error messages
  • Add support for vector mappings in atmosphere-ocean interactions
  • Enhance ROF-to-ocean mapping with liquid/ice/flood distinctions
  • Improve map file loading logic with better area handling

Components affected:

  • ATM-OCN: scalar_o2a/flux_o2a, bilinear_a2o/flux_a2o/vector_a2o
  • ICE-ATM: scalar_i2a/flux_i2a
  • LND-ATM: scalar_l2a/flux_l2a, scalar_a2l/flux_a2l
  • ROF-OCN: flux_r2o_liq/flux_r2o_ice/flux_r2o
  • ROF-ICE: scalar_r2i
  • General cleanup of mdl2drv/drv2mdl area correction logic

This is in coordination with
https://bitbucket.org/fathomteam/moab/pull-requests/745 from MOAB

@iulian787 iulian787 requested review from vijaysm and rljacob July 8, 2025 21:21
@iulian787 iulian787 force-pushed the iulian787/load_map_areas branch from 1c85bfc to 890f1c2 Compare July 10, 2025 03:58
!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 ')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are all commented out, delete them. They serve no value.

fact = factors(i,1) ! mdl2drv tag
! do nt use what we computed; use the values from mct driver
fact = comp(1)%mdl2drv(i)
! fact = comp(1)%mdl2drv(i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove 887-888

call moab_map_init_rcfile(mbrxid, mboxid, mbintxro, type_grid, &
'seq_maps.rc', 'rof2ocn_liq_rmapname:', 'rof2ocn_liq_rmaptype:',samegrid_ro, &
wgtIdr2o_conservative, 'mapper_Rr2o_liq moab initialization',esmf_map_flag)
arearead, wgtIdr2o_conservative, 'mapper_Rr2o_liq moab initialization',esmf_map_flag)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rljacob The code in https://github.com/E3SM-Project/E3SM/blob/master/driver-moab/main/component_mod.F90#L585 is confusing. Is the ROF aream essentially overwritten by rof2ocn_ice_rmapname ? Why is area loaded from both rof2ocn_liq_rmapname and rof2ocn_ice_rmapname?

Do we need to also modify the moab_map_init_rcfile call for rof2ocn_ice_rmapname?

@iulian787
Copy link
Contributor Author

@vijaysm were you able to merge / cherry-pick changes from vijaysm/add-more-read-maps ?

iulian787 and others added 10 commits July 22, 2025 21:03
change the MOAB api, and read areas from map files
if directed so
to get to 0 differences with MOABCOMP we had to set correction
factors from MCT;
reverse that, because we are using now the same sources for aream and
area, that are needed for correction factors
no functional difference
change from iMOAB_FromMappingFile to iMOAB_LoadMapFile
and from iMOAB_WriteMappingWeightsFile to iMOAB_WriteMapFile
change the MOAB api, and read areas from map files
if directed so
to get to 0 differences with MOABCOMP we had to set correction
factors from MCT;
reverse that, because we are using now the same sources for aream and
area, that are needed for correction factors
no functional difference
change from iMOAB_FromMappingFile to iMOAB_LoadMapFile
and from iMOAB_WriteMappingWeightsFile to iMOAB_WriteMapFile
if moab coupler instance active, create mct grid too,
in debug mode
@iulian787 iulian787 force-pushed the iulian787/load_map_areas branch from 1f9fb29 to 3b6ef9e Compare July 23, 2025 14:53
@rljacob rljacob self-assigned this Jul 24, 2025
@rljacob rljacob added Coupler Related to code in driver-mct or driver-moab or component connections to the coupler. MOAB Involves the MOAB library labels Jul 24, 2025
@rljacob rljacob changed the title add readarea argument to moab loading of a map Refactor MOAB mapping infrastructure to support more map types and specific area reads. Jul 25, 2025
rljacob added a commit that referenced this pull request Jul 25, 2025
Refactor MOAB mapping infrastructure to support more map types and specific area reads.

Restructure the MOAB mapping system to use distinct weight identifiers
for scalar and flux mappings across all component interactions. Also allow specifying which areas to read from the map
for setting aream in the coupler.

No longer need to copy MCT area correction factors mdl2drv/drv2mdl to MOAB. Now that areams are set
correctly, can calculate them with MOAB data.

Key changes:

Replace single conservative weight IDs with separate scalar/flux IDs
Add proper area reading controls for different map types
Reorganize map initialization order and communication graph setup
Clean up commented code and improve error messages
Add support for vector mappings in atmosphere-ocean interactions
Enhance ROF-to-ocean mapping with liquid/ice/flood distinctions
Improve map file loading logic with better area handling
Components affected:

ATM-OCN: scalar_o2a/flux_o2a, bilinear_a2o/flux_a2o/vector_a2o
ICE-ATM: scalar_i2a/flux_i2a
LND-ATM: scalar_l2a/flux_l2a, scalar_a2l/flux_a2l
ROF-OCN: flux_r2o_liq/flux_r2o_ice/flux_r2o
ROF-ICE: scalar_r2i
General cleanup of mdl2drv/drv2mdl area correction logic
@rljacob rljacob merged commit 3654b88 into master Jul 28, 2025
6 checks passed
@rljacob rljacob deleted the iulian787/load_map_areas branch July 28, 2025 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Coupler Related to code in driver-mct or driver-moab or component connections to the coupler. MOAB Involves the MOAB library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants