Skip to content

Only allocate MARBL coupled fields if MARBL is in use#345

Merged
alperaltuntas merged 1 commit into
NCAR:dev/ncar_main_candidate_25Febfrom
ACCESS-NRI:dev/ncar_main_candidate_25Feb
Apr 8, 2025
Merged

Only allocate MARBL coupled fields if MARBL is in use#345
alperaltuntas merged 1 commit into
NCAR:dev/ncar_main_candidate_25Febfrom
ACCESS-NRI:dev/ncar_main_candidate_25Feb

Conversation

@dougiesquire
Copy link
Copy Markdown

@dougiesquire dougiesquire commented Mar 24, 2025

This PR prevents allocation and advertisement of MARBL coupled fields when MARBL is not in use.

See mom-ocean#1653 (comment) for motivation.

@dougiesquire
Copy link
Copy Markdown
Author

Should the following block also be if (cesm_coupled .and. use_MARBL) then? The first comment suggests that when using CIME that is the behaviour.

if (cesm_coupled) then
! Note that flds_i2o_per_cat is set by the env_run.xml variable CPL_I2O_PER_CAT
! In CESM, this xml variable is set by MOM_interface's buildnml script and by
! default it is false unless ICE_NCAT>0 and USE_MARBL_TRACERS=True
call NUOPC_CompAttributeGet(gcomp, name='flds_i2o_per_cat', value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) i2o_per_cat
if (is_root_pe()) then
write(stdout,*) 'i2o_per_cat = ',i2o_per_cat
endif
! Note that ice_ncat is set by the env_run.xml variable ICE_NCAT which is set
! by the ice component (default is 1)
if (i2o_per_cat) then
call NUOPC_CompAttributeGet(gcomp, name='ice_ncat', value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) Ice_ocean_boundary%ice_ncat
endif
if (is_root_pe()) then
write(stdout,*) 'ice_ncat = ', Ice_ocean_boundary%ice_ncat
endif
end if

@mnlevy1981
Copy link
Copy Markdown
Collaborator

I ran tests with and without MARBL, and everything ran fine. The non-MARBL run reported the baseline comparison differences, because there are 19 fields that are no longer included in coupler history:

 Could not find match for file2 variable ocnImp_Faoo_fco2_ocn in file1
 Could not find match for file2 variable ocnExp_Faxa_bcph1 in file1
 Could not find match for file2 variable ocnExp_Faxa_bcph2 in file1
 Could not find match for file2 variable ocnExp_Faxa_bcph3 in file1
 Could not find match for file2 variable ocnExp_Faxa_dstdry1 in file1
 Could not find match for file2 variable ocnExp_Faxa_dstdry2 in file1
 Could not find match for file2 variable ocnExp_Faxa_dstdry3 in file1
 Could not find match for file2 variable ocnExp_Faxa_dstdry4 in file1
 Could not find match for file2 variable ocnExp_Faxa_dstwet1 in file1
 Could not find match for file2 variable ocnExp_Faxa_dstwet2 in file1
 Could not find match for file2 variable ocnExp_Faxa_dstwet3 in file1
 Could not find match for file2 variable ocnExp_Faxa_dstwet4 in file1
 Could not find match for file2 variable ocnExp_Faxa_ndep1 in file1
 Could not find match for file2 variable ocnExp_Faxa_ndep2 in file1
 Could not find match for file2 variable ocnExp_Fioi_bcphi in file1
 Could not find match for file2 variable ocnExp_Fioi_bcpho in file1
 Could not find match for file2 variable ocnExp_Fioi_flxdst in file1
 Could not find match for file2 variable ocnExp_Sa_co2diag in file1
 Could not find match for file2 variable ocnExp_Sa_co2prog in file1

The variables that were not removed are bit-for-bit, as expected (and the run with MARBL is bit-for-bit identical as well)

@mnlevy1981
Copy link
Copy Markdown
Collaborator

Should the following block also be if (cesm_coupled .and. use_MARBL) then? The first comment suggests that when using CIME that is the behaviour.

if (cesm_coupled) then
! Note that flds_i2o_per_cat is set by the env_run.xml variable CPL_I2O_PER_CAT
! In CESM, this xml variable is set by MOM_interface's buildnml script and by
! default it is false unless ICE_NCAT>0 and USE_MARBL_TRACERS=True
call NUOPC_CompAttributeGet(gcomp, name='flds_i2o_per_cat', value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) i2o_per_cat
if (is_root_pe()) then
write(stdout,*) 'i2o_per_cat = ',i2o_per_cat
endif
! Note that ice_ncat is set by the env_run.xml variable ICE_NCAT which is set
! by the ice component (default is 1)
if (i2o_per_cat) then
call NUOPC_CompAttributeGet(gcomp, name='ice_ncat', value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) Ice_ocean_boundary%ice_ncat
endif
if (is_root_pe()) then
write(stdout,*) 'ice_ncat = ', Ice_ocean_boundary%ice_ncat
endif
end if

That's a good question. Let's leave this block as-is for now, but I can create an issue on the NCAR fork to investigate. I don't think CESM does anything with multiple ice categories unless MARBL tracers are turned on, though.

Copy link
Copy Markdown
Collaborator

@mnlevy1981 mnlevy1981 left a comment

Choose a reason for hiding this comment

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

Test results are in my previous comment. I have two small suggestions for code changes, so I'll mark this as "Request changes" just to make sure they get seen. If it makes more sense to leave the cesm_coupled .and. use_MARBL, then I'll change my review to Approve.

Thanks so much for putting this together!

Comment thread config_src/drivers/nuopc_cap/mom_cap.F90
Comment thread config_src/drivers/nuopc_cap/mom_cap.F90
@alperaltuntas alperaltuntas merged commit 982b577 into NCAR:dev/ncar_main_candidate_25Feb Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants