Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
609fe84
Scripting and xml changes for flexible water tracers/isotopes
billsacks Oct 20, 2025
3b0470a
Use '-' rather than empty string for tracers of bulk water
billsacks Nov 6, 2025
59b1110
Correctly handle empty WATER_TRACERS
billsacks Nov 6, 2025
52c8265
Initialize water tracers
billsacks Nov 12, 2025
1493db2
Merge remote-tracking branch 'origin/main' into water_tracers
billsacks Nov 12, 2025
78a8921
Add wtracer versions of necessary fields to fd_cesm.yaml
billsacks Nov 13, 2025
0f793bd
Remove some fields from fd_cesm.yaml that no longer exist
billsacks Nov 13, 2025
e908b10
Add checks of water tracers
billsacks Dec 3, 2025
1fb3288
Merge remote-tracking branch 'origin/main' into water_tracers
billsacks Dec 23, 2025
0d290e8
Merge branch 'refactor_med_methods_fb_init' into water_tracers
billsacks Dec 23, 2025
55a889b
Merge branch 'refactor_med_methods_fb_init' into water_tracers
billsacks Dec 24, 2025
af4fc3d
Revert "For now, hard-code n_tracers = 0"
billsacks Dec 24, 2025
a7c7bbb
Add first set of water tracer fields (for evap fields)
billsacks Dec 26, 2025
864926a
Merge branch 'remove_duplicate_flds_exchange' into water_tracers
billsacks Dec 29, 2025
4cfb22a
Add qref water tracer fields
billsacks Dec 30, 2025
0adffa2
Add Sa_shum water tracer fields
billsacks Dec 30, 2025
859d299
Merge branch 'refactor_med_methods_fb_init' into water_tracers
billsacks Dec 30, 2025
b3e351c
Move fetch of n_tracers into is_tracer conditional
billsacks Dec 31, 2025
5d7defb
Merge branch 'refactor_med_methods_fb_init' into water_tracers
billsacks Jan 2, 2026
16d28d7
Wrap shr_wtracers_get_num_tracers
billsacks Jan 2, 2026
a371620
Merge branch 'main' into water_tracers
billsacks Jan 2, 2026
dc7da27
Wrap / stub more things from shr_wtracers to break dependencies
billsacks Jan 24, 2026
2ac4d2f
Merge branch 'main' into water_tracers
billsacks Jan 24, 2026
bb60780
Put code for water tracers in a loop over bulk & tracers
billsacks Jan 26, 2026
5c7b931
Rename some variables
billsacks Jan 28, 2026
f0beaf9
Make some things private
billsacks Jan 28, 2026
04e3c3f
Add So_roce_wtracers field
billsacks Jan 28, 2026
5946090
Add water tracer fields for rain and snow fields
billsacks Jan 28, 2026
24096a5
Add water tracer field for Fioi_meltw
billsacks Jan 28, 2026
a3857ad
Add water tracer field for Flrl_irrig
billsacks Jan 28, 2026
71b32ab
Merge branch 'refactor_field_creation' into HEAD
billsacks Jan 29, 2026
99fc8c7
Merge branch 'refactor_field_creation' into water_tracers
billsacks Jan 31, 2026
1c0674b
Add water tracers for remaining Flrl fields
billsacks Feb 3, 2026
cdcc907
Add tracer fields for Fgrg fields
billsacks Feb 3, 2026
143e653
Merge remote-tracking branch 'origin/main' into water_tracers
billsacks Feb 6, 2026
5619722
Add tracer versions of some runoff fields
billsacks Feb 6, 2026
daaeada
Merge branch 'post_rof_fields_with_ungridded_dims' into water_tracers
billsacks Feb 6, 2026
4f4fe7a
Add water tracer fields for Flrr_volr and Flrr_volrmch
billsacks Feb 7, 2026
daa5764
Add tracer fields for Flgl_qice and Flgl_qice_elev
billsacks Feb 9, 2026
53f76b3
Extend med_methods_FB_check_wtracers to work with rank-2 fields
billsacks Feb 11, 2026
e40197b
Add a testmod to test glc coupling
billsacks Feb 21, 2026
ea82f1c
Merge branch 'main' into water_tracers
billsacks Feb 22, 2026
c6bd408
Merge branch 'handle_rank3_fields' into water_tracers
billsacks Feb 22, 2026
7457f7e
Add interfaces to some shr_wtracer things that we'll need in prep_glc
billsacks Feb 25, 2026
bf58f92
Remove unnecessary duplicate resetting of FBlndAccum2glc_g
billsacks Feb 25, 2026
df3676e
Use med_methods_FB_accum in med_phases_prep_glc_accum_lnd
billsacks Feb 25, 2026
af43baf
Use med_methods in med_phases_prep_glc_avg
billsacks Feb 25, 2026
4ca7bcd
Handle water tracers in most of med_phases_prep_glc_mod
billsacks Feb 26, 2026
8aaa908
Turn on glc_renormalize_smb even for X compsets
billsacks Feb 26, 2026
5952845
Change dimension order convention for rank-3 tracer fields
billsacks Feb 26, 2026
7a3598a
Extract routines to calculate sums in renormalize_smb
billsacks Feb 27, 2026
b418781
Do SMB renormalization on tracers as well as bulk
billsacks Mar 1, 2026
9695e26
Merge branch 'handle_rank3_fields' into water_tracers
billsacks Mar 1, 2026
bd6235a
Merge branch 'main' into water_tracers
billsacks Mar 1, 2026
8b259ae
Merge branch 'add_x_comps' into water_tracers
billsacks Mar 3, 2026
0d05065
Remove an xrof coupling field that no longer exists
billsacks Nov 14, 2025
74627eb
Change xcomp logic for including field number
billsacks Nov 27, 2025
26c554e
Make a shared routine, set_all_export_fields
billsacks Nov 29, 2025
ad7e058
Add code to nuopc xcomps to create and set water tracer fields
billsacks Nov 30, 2025
c1dba82
xcpl_comps_nuopc: Add first set of water tracer fields (for evap fields)
billsacks Dec 26, 2025
38543e0
xcpl_comps_nuopc: Add qref water tracer fields
billsacks Dec 30, 2025
07a6873
xcpl_comps_nuopc: Add Sa_shum water tracer fields
billsacks Dec 30, 2025
03c49fd
Add So_roce_wtracers
billsacks Jan 28, 2026
8e01401
In X comps, add water tracer fields for rain and snow
billsacks Jan 28, 2026
c3d37a6
X comps: add water tracer field for Fioi_meltw
billsacks Jan 28, 2026
208919c
X comps: add water tracer field for Flrl_irrig
billsacks Jan 28, 2026
0ff0963
Add water tracers for remaining Flrl fields
billsacks Feb 3, 2026
f685f74
Xcomps: add Fgrg fields
billsacks Feb 3, 2026
6566dab
X comps: add Fioi_meltw to ocn
billsacks Feb 3, 2026
94b2ed0
X comps: add water tracer fields for Flrr_flood
billsacks Feb 5, 2026
739030a
X comps: add water tracer fields for some runoff fields
billsacks Feb 5, 2026
8a1e7c6
X comps: add tracer fields for Flrr_volr and Flrr_volrmch
billsacks Feb 7, 2026
f1e51c1
X comps: add water tracer fields for Flgl_qice and Flgl_qice_elev
billsacks Feb 7, 2026
6e5ca91
XGLC: Improve logic for ice_covered and topo
billsacks Feb 20, 2026
1199901
XGLC: Export Sg_area
billsacks Feb 26, 2026
a0238ee
Change dimension order convention for rank-3 tracer fields
billsacks Feb 26, 2026
002beed
X comps: change some lnd and glc values to better test lnd->glc mapping
billsacks Mar 1, 2026
d11c256
Merge remote-tracking branch 'origin/main' into water_tracers
billsacks Mar 3, 2026
b95d74c
Add a comment
billsacks Mar 10, 2026
3da6da8
Extract subroutine to remove duplication in med_io_write_FB
billsacks Mar 26, 2026
e07c439
Extract subroutine to remove duplication in med_io_read_FB
billsacks Mar 26, 2026
419e27f
Use shr_wtracers_get_bulk_fieldname instead of shr_string_withoutSuffix
billsacks Mar 26, 2026
efc9898
Correct documentation
billsacks Mar 26, 2026
49c35eb
Merge remote-tracking branch 'origin/main' into water_tracers
billsacks Mar 30, 2026
00e41c5
Restore Figg_rofi in fd_cesm.yaml
billsacks Mar 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cesm/driver/esm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ subroutine InitAttributes(driver, rc)
use shr_wv_sat_mod , only : shr_wv_sat_make_tables, ShrWVSatTableSpec
use shr_wv_sat_mod , only : shr_wv_sat_get_scheme_idx, shr_wv_sat_valid_idx
use glc_elevclass_mod, only : glc_elevclass_init
use shr_wtracers_mod , only : shr_wtracers_init
!use shr_scam_mod , only : shr_scam_checkSurface

! input/output variables
Expand Down Expand Up @@ -544,6 +545,13 @@ subroutine InitAttributes(driver, rc)
call shr_wv_sat_make_tables(liquid_spec, ice_spec, mixed_spec)
end if

!----------------------------------------------------------
! Initialize water tracer info
!----------------------------------------------------------

call shr_wtracers_init(driver, maintask, rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

end subroutine InitAttributes

!================================================================================
Expand Down
19 changes: 17 additions & 2 deletions cesm/share_wrappers/wtracers_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,30 @@ module wtracers_mod
! This module wraps shr_wtracers_mod from the CESM_share repository to avoid direct
! dependencies on this share code from CMEPS.
!
! It is acceptable for CESM-specific CMEPS code (e.g., in the cesm directory) to call
! directly into shr_wtracers_mod, but CMEPS code shared between CESM and other modeling
! systems (e.g., UFS) should go through this module.
!
! See also the version of wtracers_mod in the ufs directory for when we do not have
! access to the CESM_share library.
!-----------------------------------------------------------------------------

use shr_wtracers_mod, only : wtracers_is_wtracer_field => shr_wtracers_is_wtracer_field
use shr_wtracers_mod, only : wtracers_present => shr_wtracers_present
use shr_wtracers_mod, only : wtracers_get_num_tracers => shr_wtracers_get_num_tracers
use shr_wtracers_mod, only : wtracers_is_wtracer_field => shr_wtracers_is_wtracer_field
use shr_wtracers_mod, only : wtracers_get_bulk_fieldname => shr_wtracers_get_bulk_fieldname
use shr_wtracers_mod, only : wtracers_check_tracer_ratios => shr_wtracers_check_tracer_ratios
use shr_wtracers_mod, only : WTRACERS_SUFFIX

implicit none
private

public :: wtracers_is_wtracer_field ! return true if the given field name is a water tracer field
public :: wtracers_present ! return true if there are water tracers in this simulation
public :: wtracers_get_num_tracers ! get number of water tracers in this simulation
public :: wtracers_is_wtracer_field ! return true if the given field name is a water tracer field
public :: wtracers_get_bulk_fieldname ! return the name of the equivalent bulk field corresponding to a water tracer field
public :: wtracers_check_tracer_ratios ! check tracer ratios against expectations

public :: WTRACERS_SUFFIX ! suffix for water tracer field names

end module wtracers_mod
43 changes: 43 additions & 0 deletions cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
nmlgen.set_value("esp_cpl_dt", value=esp_time)
# End if pause is active

# --------------------------------
# Overwrite: set water tracers
# --------------------------------
_add_water_tracers(case.get_value("WATER_TRACERS"), nmlgen)

# --------------------------------
# Specify input data list file
# --------------------------------
Expand Down Expand Up @@ -553,6 +558,44 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
nmlgen.write_output_file(drv_flds_in)


###############################################################################
def _add_water_tracers(water_tracers_xml, nmlgen):
###############################################################################

if not water_tracers_xml.strip():
water_tracers = []
else:
water_tracers = water_tracers_xml.split(":")
tracer_names = []
tracer_species = []
tracer_initial_ratios = []

for tracer in water_tracers:
# Each item in the list consists of a name and then, optionally, a '%' followed by
# the isotope species for this tracer. For standard water tracers (i.e., tracers
# of bulk water), the list item will only contain the name (without a '%').
expect(
tracer.count("%") <= 1,
f"Invalid WATER_TRACERS element, '{tracer}': Each element of WATER_TRACERS must contain at most 1 '%' separator",
)
parts = tracer.split("%")
tracer_names.append(parts[0])
if len(parts) > 1:
tracer_species.append(parts[1])
# We could check the validity of the species name here (confirming that it's
# one of the handled species), but that would lead to this allowed list being
# replicated in multiple places (here as well as in the Fortran), which would
# make it more difficult to add new species later. So we're deferring this
# check to runtime.
else:
tracer_species.append("-")
tracer_initial_ratios.append("1.0")

nmlgen.add_default("water_tracer_names", ":".join(tracer_names))
nmlgen.add_default("water_tracer_species", ":".join(tracer_species))
nmlgen.add_default("water_tracer_initial_ratios", ":".join(tracer_initial_ratios))


###############################################################################
def _create_runseq(case, coupling_times, valid_comps):
###############################################################################
Expand Down
27 changes: 26 additions & 1 deletion cime_config/config_component_cesm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@
</entry>

<!-- ===================================================================== -->
<!-- averaged history frequencies -->
<!-- controls over various other options -->
<!-- ===================================================================== -->

<entry id="BUDGETS">
Expand Down Expand Up @@ -581,5 +581,30 @@
<desc>Freezing point calculation for salt water.</desc>
</entry>

<entry id="WATER_TRACERS">
<type>char</type>
<default_value></default_value>
<group>run_coupling</group>
<file>env_run.xml</file>
<desc>
Colon-delimited list of water tracers enabled in this run.

Each item in the list consists of a name and then, optionally, a '%' followed by the
isotope species for this tracer. For standard water tracers (i.e., tracers of bulk
water), the list item will only contain the name (without a '%'). The name can be
anything; if an isotope species is specified, it must match one of the implemented
water isotopes: H218O, H217O or HDO. By convention, a tracer that is the full
quantity of a given isotope will have a name that is identical to the species (e.g.,
H218O:H218O).

For example, this list could be:
MyRegularTracer:HDO%HDO:H218O%H218O:SomeOtherTracer:MyHdoTracer%HDO:YetAnotherTracer

This specifies three standard (bulk water) tracers (MyRegularTracer, SomeOtherTracer
and YetAnotherTracer), two isotopes (HDO and H218O), and a tracer that is a subset
of HDO (MyHdoTracer). (Note that the ordering in the list is not important.)
</desc>
</entry>


</entry_id>
61 changes: 60 additions & 1 deletion cime_config/namelist_definition_drv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,6 @@
</desc>
<values>
<value>on</value>
<value COMP_LND="xlnd">off</value>
</values>
</entry>
<entry id="remove_negative_runoff_lnd">
Expand Down Expand Up @@ -2595,6 +2594,66 @@
</values>
</entry>

<entry id="water_tracer_names" modify_via_xml="WATER_TRACERS" skip_default_entry="true">
<type>char</type>
<category>water_tracers</category>
<group>ALLCOMP_attributes</group>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm putting the new variables in ALLCOMP_attributes. I'm not sure if this is right, or if these should go in DRIVER_attributes. I chose ALLCOMP_attributes just because there was more stuff (and more relevant stuff) there, but I'm not sure why I'd choose one over the other.

But actually, maybe ALLCOMP_attributes is needed given that MOM may need to access these rather than going through the share code??

@mvertens do you have guidance here?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@billsacks - if any component needs this variable - then it should belong in ALLCOMP_attributes. I think I envisioned the DRIVER_attributes as having variables that are available on all processors but are specific to the driver itself (e.g. pio, etc).
I am not sure why the following variables

     reprosum_diffmax
     reprosum_recompute, 
     reprosum_use_ddpdd
     wv_sat_scheme
     wv_sat_table_spacing
     wv_sat_transition_start
     wv_sat_use_tables

are in the DRIVER_attributes and not in the ALLCOMP_attributes.
@jedwards4b - what are your thoughts on this?

<desc>
Colon-delimited list of names of water tracers in this run.
</desc>
<values>
<value></value>
</values>
</entry>

<entry id="water_tracer_species" modify_via_xml="WATER_TRACERS" skip_default_entry="true">
<type>char</type>
<category>water_tracers</category>
<group>ALLCOMP_attributes</group>
<desc>
Colon-delimited list of species of water tracers in this run.

Each element in the list corresponds to an element in water_tracer_names. A value of
'-' for a given element indicates a standard water tracer (i.e., a tracer of bulk
water).
</desc>
<values>
<value></value>
</values>
</entry>

<entry id="water_tracer_initial_ratios" skip_default_entry="true">
<type>char</type>
<category>water_tracers</category>
<group>ALLCOMP_attributes</group>
<desc>
Colon-delimited list of initial water tracer ratios (as a fraction of total water).

Each element in the list corresponds to an element in water_tracer_names.

For water isotopes, this ratio is typically set to 1 for numerical reasons; the
actual isotopic ratios can then be determined via reference to standard global
ratios.
</desc>
<values>
<value></value>
</values>
</entry>

<entry id="water_tracers_do_checks">
<type>logical</type>
<category>water_tracers</category>
<group>ALLCOMP_attributes</group>
<desc>
Check consistency between water tracer fields and their corresponding bulk fields.

This should only be used with artificial tracers that maintain a fixed ratio.
</desc>
<values>
<value>.false.</value>
</values>
</entry>

<!-- =========================== -->
<!-- CLOCK Attributes -->
<!-- =========================== -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This testmod turns on more frequent averaging of the fields sent to glc so that the
mapping of these fields can be tested in a run shorter than a year.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./xmlchange GLC_AVG_PERIOD=glc_coupling_period
57 changes: 42 additions & 15 deletions med_test_comps/xatm/src/atm_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ module atm_comp_nuopc
use shr_sys_mod , only : shr_sys_abort
use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs
use shr_log_mod , only : shr_log_getlogunit, shr_log_setlogunit
use shr_wtracers_mod , only : WTRACERS_SUFFIX
use shr_wtracers_mod , only : shr_wtracers_present, shr_wtracers_get_num_tracers
use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck
use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance
use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock
use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type
use dead_nuopc_mod , only : set_all_export_fields

implicit none
private ! except
Expand All @@ -39,7 +42,6 @@ module atm_comp_nuopc
integer :: fldsFrAtm_num = 0
type (fld_list_type) :: fldsToAtm(fldsMax)
type (fld_list_type) :: fldsFrAtm(fldsMax)
integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost

type(ESMF_Mesh) :: mesh
integer :: nxg ! global dim i-direction
Expand Down Expand Up @@ -121,6 +123,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
character(CL) :: cvalue
character(len=CL) :: logmsg
logical :: isPresent, isSet
logical :: flds_wtracers
integer :: num_wtracers
character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) '
!-------------------------------------------------------------------------------

Expand Down Expand Up @@ -202,6 +206,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)

if (nxg /= 0 .and. nyg /= 0) then

flds_wtracers = shr_wtracers_present()
num_wtracers = shr_wtracers_get_num_tracers()

call fld_list_add(fldsFrAtm_num, fldsFrAtm, trim(flds_scalar_name))
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_topo' )
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_z' )
Expand All @@ -210,13 +217,27 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_tbot' )
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_ptem' )
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_shum' )
if (flds_wtracers) then
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_shum'//WTRACERS_SUFFIX, &
num_wtracers=num_wtracers)
end if
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_pbot' )
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_dens' )
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_pslv' )
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainc' )
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainl' )
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowc' )
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowl' )
if (flds_wtracers) then
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainc'//WTRACERS_SUFFIX, &
num_wtracers=num_wtracers)
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainl'//WTRACERS_SUFFIX, &
num_wtracers=num_wtracers)
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowc'//WTRACERS_SUFFIX, &
num_wtracers=num_wtracers)
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowl'//WTRACERS_SUFFIX, &
num_wtracers=num_wtracers)
end if
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_lwdn' )
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swndr' )
call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swvdr' )
Expand All @@ -238,6 +259,10 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_ofrac' )
call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_tref' )
call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_qref' )
if (flds_wtracers) then
call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_qref'//WTRACERS_SUFFIX, &
num_wtracers=num_wtracers)
end if
call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_t' )
call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_t' )
call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_fv' )
Expand All @@ -253,6 +278,10 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_sen' )
call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_lwup' )
call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_evap' )
if (flds_wtracers) then
call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_evap'//WTRACERS_SUFFIX, &
num_wtracers=num_wtracers)
end if

do n = 1,fldsFrAtm_num
if(mastertask) write(logunit,*)'Advertising From Xatm ',trim(fldsFrAtm(n)%stdname)
Expand Down Expand Up @@ -417,7 +446,7 @@ subroutine state_setexport(exportState, rc)
integer, intent(out) :: rc

! local variables
integer :: n, nf, nind
integer :: n
real(r8), pointer :: lat(:)
real(r8), pointer :: lon(:)
integer :: spatialDim
Expand All @@ -440,19 +469,16 @@ subroutine state_setexport(exportState, rc)
lat(n) = ownedElemCoords(2*n)
end do

! Start from index 2 in order to Skip the scalar field here
do nf = 2,fldsFrAtm_num
if (fldsFrAtm(nf)%ungridded_ubound == 0) then
call field_setexport(exportState, trim(fldsFrAtm(nf)%stdname), lon, lat, nf=nf, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
else
do nind = 1,fldsFrAtm(nf)%ungridded_ubound
call field_setexport(exportState, trim(fldsFrAtm(nf)%stdname), lon, lat, nf=nf+nind-1, &
ungridded_index=nind, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
end do
end if
end do
call set_all_export_fields( &
exportState = exportState, &
flds = fldsFrAtm, &
fld_min = 2, & ! Start from index 2 in order to skip the scalar field here
fld_max = fldsFrAtm_num, &
lon = lon, &
lat = lat, &
field_setexport = field_setexport, &
rc = rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

deallocate(lon)
deallocate(lat)
Expand All @@ -478,6 +504,7 @@ subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index,
type(ESMF_Field) :: lfield
real(r8), pointer :: data1d(:)
real(r8), pointer :: data2d(:,:)
integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost
!--------------------------------------------------

rc = ESMF_SUCCESS
Expand Down
Loading
Loading