Skip to content

Commit

Permalink
+Add CPP macro _USE_OCEAN_BGC_PR20 to avoid bug
Browse files Browse the repository at this point in the history
  Added the new CPP macro _USE_OCEAN_BGC_PR20 to deal with the fact that the
recently added element runoff_added_to_stf does not yet exist within the
ocean_BGC version of the g_tracer_type, although it was added to the version in
confic_src/external/GFDL_ocean_BGC/generic_tracer_utils.F90 as a part of
PR#246.  This caused the latest version of MOM6 to be unable to compile with the
ocean_BGC code.  With this new CPP macro, the code will once again compile, and
these bits of code can be enabled once the ocean_BGC code has this new element
in its version of the g_tracer_type.  Once there is sufficiently widespread
adoption of newer versions of the ocean_BGC code, these newly added macros can
be eliminated altogether.  This commit should address the issued documented
under github.com/NOAA-GFDL/issues/278.  Note that the use of CPP macros in
this way is generally strongly discouraged in MOM6, but it does seem like a
viable solution for addressing an interface change across two separately managed
code repositories.
  • Loading branch information
Hallberg-NOAA committed Nov 27, 2023
1 parent 11759d6 commit 46fee6c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/tracer/MOM_generic_tracer.F90
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,12 @@ subroutine MOM_generic_tracer_column_physics(h_old, h_new, ea, eb, fluxes, Hml,
!
g_tracer=>CS%g_tracer_list
do
! After ocean_BGC PR #20 has been merged in for a while, the following CPP macro can be removed.
#ifdef _USE_OCEAN_BGC_PR20
if (_ALLOCATED(g_tracer%trunoff) .and. (.NOT. g_tracer%runoff_added_to_stf)) then
#else
if (_ALLOCATED(g_tracer%trunoff)) then
#endif
call g_tracer_get_alias(g_tracer,g_tracer_name)
call g_tracer_get_pointer(g_tracer,g_tracer_name,'stf', stf_array)
call g_tracer_get_pointer(g_tracer,g_tracer_name,'trunoff',trunoff_array)
Expand All @@ -521,7 +526,10 @@ subroutine MOM_generic_tracer_column_physics(h_old, h_new, ea, eb, fluxes, Hml,
runoff_tracer_flux_array(:,:) = trunoff_array(:,:) * &
US%RZ_T_to_kg_m2s*fluxes%lrunoff(:,:)
stf_array = stf_array + runoff_tracer_flux_array
! After ocean_BGC PR #20 has been merged in for a while, the following CPP macro can be removed.
#ifdef _USE_OCEAN_BGC_PR20
g_tracer%runoff_added_to_stf = .true.
#endif
endif

!traverse the linked list till hit NULL
Expand Down

0 comments on commit 46fee6c

Please sign in to comment.