<p><b>duda</b> 2013-03-26 17:03:26 -0600 (Tue, 26 Mar 2013)</p><p>BRANCH COMMIT<br>
<br>
Merge changes from the trunk, principally, the switch to an XML Registry file.<br>
</p><hr noshade><pre><font color="gray">Index: branches/atmos_physics
===================================================================
--- branches/atmos_physics        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics        2013-03-26 23:03:26 UTC (rev 2670)

Property changes on: branches/atmos_physics
___________________________________________________________________
Modified: svn:mergeinfo
## -2,15 +2,23 ##
 /branches/ocean_projects/ale_split_exp:1437-1483
 /branches/ocean_projects/ale_vert_coord:1225-1383
 /branches/ocean_projects/ale_vert_coord_new:1387-1428
+/branches/ocean_projects/cesm_coupling:2147-2344
+/branches/ocean_projects/comment_cleanup:2626-2630
+/branches/ocean_projects/diagnostics_revision:2439-2462
+/branches/ocean_projects/explicit_vmix_removal:2486-2490
 /branches/ocean_projects/gmvar:1214-1514,1517-1738
 /branches/ocean_projects/imp_vert_mix_error:1847-1887
 /branches/ocean_projects/imp_vert_mix_mrp:754-986
 /branches/ocean_projects/leith_mrp:2182-2241
+/branches/ocean_projects/linear_eos:2435-2437
 /branches/ocean_projects/monotonic_advection:1499-1640
 /branches/ocean_projects/monthly_forcing:1810-1867
+/branches/ocean_projects/namelist_cleanup:2319-2414
 /branches/ocean_projects/option3_b4b_test:2201-2231
 /branches/ocean_projects/partial_bottom_cells:2172-2226
+/branches/ocean_projects/remove_sw_test_cases:2539-2540
 /branches/ocean_projects/restart_reproducibility:2239-2272
+/branches/ocean_projects/sea_level_pressure:2488-2528
 /branches/ocean_projects/split_explicit_mrp:1134-1138
 /branches/ocean_projects/split_explicit_timestepping:1044-1097
 /branches/ocean_projects/vert_adv_mrp:704-745
## -21,6 +29,8 ##
 /branches/omp_blocks/halo:1570-1638
 /branches/omp_blocks/io:1639-1787
 /branches/omp_blocks/multiple_blocks:1803-2084
+/branches/scratch_indication:2555-2656
 /branches/source_renaming:1082-1113
 /branches/time_manager:924-962
-/trunk/mpas:1371-2274
+/branches/xml_registry:2610-2662
+/trunk/mpas:1371-2666
\ No newline at end of property
Modified: branches/atmos_physics/Makefile
===================================================================
--- branches/atmos_physics/Makefile        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/Makefile        2013-03-26 23:03:26 UTC (rev 2670)
@@ -353,12 +353,12 @@
         @cd src; ls -d core_* | grep &quot;.*&quot; | sed &quot;s/core_/    /g&quot;
         @echo &quot;&quot;
         @echo &quot;Available Options:&quot;
-        @echo &quot;    SERIAL=true   - builds serial version. Default is parallel version.&quot;
+#@echo &quot;    SERIAL=true   - builds serial version. Default is parallel version.&quot;
         @echo &quot;    DEBUG=true    - builds debug version. Default is optimized version.&quot;
         @echo &quot;    USE_PAPI=true - builds version using PAPI for timers. Default is off.&quot;
         @echo &quot;    TAU=true      - builds version using TAU hooks for profiling. Default is off.&quot;
         @echo &quot;&quot;
-        @echo &quot;Ensure that NETCDF (and PAPI if USE_PAPI=true) are environment variables&quot;
+        @echo &quot;Ensure that NETCDF, PNETCDF, PIO, and PAPI (if USE_PAPI=true) are environment variables&quot;
         @echo &quot;that point to the absolute paths for the libraries.&quot;
         @echo &quot;&quot;
 

Modified: branches/atmos_physics/namelist.input.ocean
===================================================================
--- branches/atmos_physics/namelist.input.ocean        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/namelist.input.ocean        2013-03-26 23:03:26 UTC (rev 2670)
@@ -1,110 +1,163 @@
-&amp;sw_model
-   config_test_case = 0
-   config_time_integration = 'split_explicit'
-   config_rk_filter_btr_mode = .false.
-   config_dt = 180.0
-   config_start_time = '0000-01-01_00:00:00'
-   config_run_duration = '1_00:00:00'
-   config_stats_interval = 480
+&amp;time_management
+        config_do_restart = .false.
+        config_start_time = '0000-01-01_00:00:00'
+        config_stop_time = 'none'
+        config_run_duration = '0_06:00:00'
+        config_calendar_type = '360day'
 /
 &amp;io
-   config_input_name = 'grid.nc'
-   config_output_name = 'output.nc'
-   config_restart_name = 'restart.nc'
-   config_output_interval = '1_00:00:00'
-   config_frames_per_outfile = 1000000
-   config_pio_num_iotasks = 0
-   config_pio_stride      = 1
-   config_write_output_on_startup = .true.
+        config_input_name = 'grid.nc'
+        config_output_name = 'output.nc'
+        config_restart_name = 'restart.nc'
+        config_restart_interval = '0_06:00:00'
+        config_output_interval = '0_06:00:00'
+        config_stats_interval = '0_01:00:00'
+        config_write_stats_on_startup = .true.
+        config_write_output_on_startup = .true.
+        config_frames_per_outfile = 1000
+        config_pio_num_iotasks = 0
+        config_pio_stride = 1
 /
+&amp;time_integration
+        config_dt = 3000.0
+        config_time_integrator = 'split_explicit'
+/
+&amp;grid
+        config_num_halos = 3
+        config_vert_coord_movement = 'uniform_stretching'
+        config_alter_ICs_for_pbcs = 'zlevel_pbcs_off'
+        config_min_pbc_fraction = 0.10
+        config_check_ssh_consistency = .true.
+/
 &amp;decomposition
-   config_number_of_blocks = 0
-   config_block_decomp_file_prefix = 'graph.info.part.'
-   config_explicit_proc_decomp = .false.
-   config_proc_decomp_file_prefix = 'graph.info.part.'
+        config_block_decomp_file_prefix = 'graph.info.part.'
+        config_number_of_blocks = 0
+        config_explicit_proc_decomp = .false.
+        config_proc_decomp_file_prefix = 'graph.info.part.'
 /
-&amp;restart
-   config_do_restart = .false.
-   config_restart_interval = '120_00:00:00'
+&amp;hmix
+        config_hmix_ScaleWithMesh = .false.
+        config_visc_vorticity_term = .true.
+        config_apvm_scale_factor = 0.0
 /
-&amp;grid
-   config_vert_grid_type = 'isopycnal'
-   config_pressure_type = 'pressure'
-   config_rho0 = 1014.65
+&amp;hmix_del2
+        config_use_mom_del2 = .false.
+        config_use_tracer_del2 = .false.
+        config_mom_del2 = 0.0
+        config_tracer_del2 = 0.0
+        config_vorticity_del2_scale = 1.0
 /
-&amp;partial_bottom_cells
-   config_alter_ICs_for_pbcs = 'off'
-   config_min_pbc_fraction = 0.10
-   config_check_ssh_consistency = .true.
-   config_check_zlevel_consistency = .false.
+&amp;hmix_del4
+        config_use_mom_del4 = .true.
+        config_use_tracer_del4 = .false.
+        config_mom_del4 = 5.0e13
+        config_tracer_del4 = 0.0
+        config_vorticity_del4_scale = 1.0
 /
-&amp;split_explicit_ts
-   config_n_ts_iter  =  2 
-   config_n_bcl_iter_beg =  1
-   config_n_bcl_iter_mid =  2
-   config_n_bcl_iter_end =  2
-   config_n_btr_subcycles = 10
-   config_n_btr_cor_iter = 2
-   config_u_correction = .true.
-   config_filter_btr_mode = .false.
-   config_btr_subcycle_loop_factor =  2
-   config_btr_gam1_uWt1   = 0.5
-   config_btr_gam2_SSHWt1 = 1.0
-   config_btr_gam3_uWt2   = 1.0
-   config_btr_solve_SSH2  = .false.
+&amp;hmix_Leith
+        config_use_Leith_del2 = .false.
+        config_Leith_parameter = 1.0
+        config_Leith_dx = 15000.0
+        config_Leith_visc2_max = 2.5e3
 /
-&amp;hmix
-   config_h_mom_eddy_visc2 = 100.0
-   config_h_mom_eddy_visc4 = 0.0
-   config_h_kappa = 0.0
-   config_h_kappa_q = 0.0
-   config_visc_vorticity_term = .true.
-   config_h_tracer_eddy_diff2 = 1.0e5
-   config_h_tracer_eddy_diff4 = 0.0
+&amp;standard_GM
+        config_h_kappa = 0.0
+        config_h_kappa_q = 0.0
 /
-&amp;hmix_leith
-   config_use_leith_del2 = .false.
-   config_leith_parameter = 1.0
-   config_leith_dx = 15000.0
-   config_leith_visc2_max = 2.5e3
+&amp;Rayleigh_damping
+        config_Rayleigh_friction = .false.
+        config_Rayleigh_damping_coeff = 0.0
 /
 &amp;vmix
-   config_vert_visc_type  = 'const'
-   config_vert_diff_type  = 'const'
-   config_implicit_vertical_mix = .true.
-   config_convective_visc       = 1.0
-   config_convective_diff       = 1.0
-   config_bottom_drag_coeff     = 1.0e-3
+        config_convective_visc = 1.0
+        config_convective_diff = 1.0
 /
 &amp;vmix_const
-   config_vert_visc       = 1.0e-5
-   config_vert_diff       = 1.0e-5 
+        config_use_const_visc = .false.
+        config_use_const_diff = .false.
+        config_vert_visc = 2.5e-4
+        config_vert_diff = 2.5e-5
 /
 &amp;vmix_rich
-   config_bkrd_vert_visc  = 1.0e-5
-   config_bkrd_vert_diff  = 1.0e-5
-   config_rich_mix        = 0.005
+        config_use_rich_visc = .true.
+        config_use_rich_diff = .true.
+        config_bkrd_vert_visc = 1.0e-4
+        config_bkrd_vert_diff = 1.0e-5
+        config_rich_mix = 0.005
 /
 &amp;vmix_tanh
-   config_max_visc_tanh = 2.5e-1
-   config_min_visc_tanh = 1.0e-4
-   config_max_diff_tanh = 2.5e-2
-   config_min_diff_tanh = 1.0e-5
-   config_zMid_tanh    = -100
-   config_zWidth_tanh  = 100
+        config_use_tanh_visc = .false.
+        config_use_tanh_diff = .false.
+        config_max_visc_tanh = 2.5e-1
+        config_min_visc_tanh = 1.0e-4
+        config_max_diff_tanh = 2.5e-2
+        config_min_diff_tanh = 1.0e-5
+        config_zMid_tanh = -100
+        config_zWidth_tanh = 100
 /
-&amp;eos
-   config_eos_type = 'linear'
+&amp;forcing
+        config_use_monthly_forcing = .false.
+        config_restoreTS = .false.
+        config_restoreT_timescale = 90.0
+        config_restoreS_timescale = 90.0
 /
 &amp;advection
-   config_vert_tracer_adv = 'stencil'
-   config_vert_tracer_adv_order = 2
-   config_horiz_tracer_adv_order = 2
-   config_thickness_adv_order = 2
-   config_monotonic = .false.
+        config_vert_tracer_adv = 'stencil'
+        config_vert_tracer_adv_order = 3
+        config_horiz_tracer_adv_order = 3
+        config_coef_3rd_order = 0.25
+        config_monotonic = .true.
 /
-&amp;restore
-   config_restoreTS = .false.
-   config_restoreT_timescale = 90.0
-   config_restoreS_timescale = 90.0
+&amp;bottom_drag
+        config_bottom_drag_coeff = 1.0e-3
 /
+&amp;pressure_gradient
+        config_pressure_gradient_type = 'pressure_and_zmid'
+        config_rho0 = 1014.65
+/
+&amp;eos
+        config_eos_type = 'jm'
+/
+&amp;eos_linear
+        config_eos_linear_alpha = 2.55e-1
+        config_eos_linear_beta = 7.64e-1
+        config_eos_linear_Tref = 19.0
+        config_eos_linear_Sref = 35.0
+        config_eos_linear_rhoref = 1025.022
+/
+&amp;split_explicit_ts
+        config_n_ts_iter = 2
+        config_n_bcl_iter_beg = 1
+        config_n_bcl_iter_mid = 2
+        config_n_bcl_iter_end = 2
+        config_n_btr_subcycles = 20
+        config_n_btr_cor_iter = 2
+        config_u_correction = .true.
+        config_btr_subcycle_loop_factor = 2
+        config_btr_gam1_uWt1 = 0.5
+        config_btr_gam2_SSHWt1 = 1.0
+        config_btr_gam3_uWt2 = 1.0
+        config_btr_solve_SSH2 = .false.
+/
+&amp;debug
+        config_check_zlevel_consistency = .false.
+        config_filter_btr_mode = .false.
+        config_prescribe_velocity = .false.
+        config_prescribe_thickness = .false.
+        config_include_KE_vertex = .false.
+        config_check_tracer_monotonicity = .false.
+        config_disable_h_all_tend = .false.
+        config_disable_h_hadv = .false.
+        config_disable_h_vadv = .false.
+        config_disable_u_all_tend = .false.
+        config_disable_u_coriolis = .false.
+        config_disable_u_pgrad = .false.
+        config_disable_u_hmix = .false.
+        config_disable_u_windstress = .false.
+        config_disable_u_vmix = .false.
+        config_disable_u_vadv = .false.
+        config_disable_tr_all_tend = .false.
+        config_disable_tr_adv = .false.
+        config_disable_tr_hmix = .false.
+        config_disable_tr_vmix = .false.
+/

Modified: branches/atmos_physics/src/Makefile
===================================================================
--- branches/atmos_physics/src/Makefile        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/Makefile        2013-03-26 23:03:26 UTC (rev 2670)
@@ -23,7 +23,7 @@
 
 reg_includes: 
         ( cd registry; $(MAKE) CC=&quot;$(SCC)&quot; )
-        ( cd inc; $(CPP) ../core_$(CORE)/Registry | ../registry/parse &gt; Registry.processed)
+        ( cd inc; $(CPP) ../core_$(CORE)/Registry.xml | ../registry/parse &gt; Registry.processed)
 
 frame: reg_includes externals
         ( cd framework; $(MAKE) CPPFLAGS=&quot;$(CPPFLAGS)&quot; CPPINCLUDES=&quot;$(CPPINCLUDES)&quot; all ) 

Copied: branches/atmos_physics/src/Makefile.in.CESM_OCN (from rev 2666, trunk/mpas/src/Makefile.in.CESM_OCN)
===================================================================
--- branches/atmos_physics/src/Makefile.in.CESM_OCN                                (rev 0)
+++ branches/atmos_physics/src/Makefile.in.CESM_OCN        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,32 @@
+include $(CASEROOT)/Macros
+RM = rm -f
+CPP = cpp -C -P -traditional
+FC=$(MPIFC)
+CC=$(MPICC)
+NETCDF=$(NETCDF_PATH)
+PNETCDF=$(PNETCDF_PATH)
+PIO=$(EXEROOT)/pio
+FILE_OFFSET = -DOFFSET64BIT
+CPPFLAGS += $(MODEL_FORMULATION) $(FILE_OFFSET) $(ZOLTAN_DEFINE) -DMPAS_CESM -D_MPI# -DUNDERSCORE
+CPPINCLUDES += -I$(EXEROOT)/ocn/source/inc -I$(NETCDF)/include -I$(PIO) -I$(PNETCDF)/include
+FCINCLUDES += -I$(EXEROOT)/ocn/source/inc -I$(EXEROOT)/csm_share -I$(EXEROOT)/gptl -I$(NETCDF)/include -I$(PIO) -I$(PNETCDF)/include
+LIBS += -L$(PIO) -L$(PNETCDF)/lib -L$(NETCDF)/lib -lpio -lpnetcdf -lnetcdf
+
+all:
+        @echo $(CPPINCLUDES)
+        @echo $(FCINCLUDES)
+        ( $(MAKE) mpas RM=&quot;$(RM)&quot; CPP=&quot;$(CPP)&quot; NETCDF=&quot;$(NETCDF)&quot; PNETCDF=&quot;$(PNETCDF)&quot; \
+          PIO=&quot;$(PIO)&quot; FC=&quot;$(FC)&quot; CC=&quot;$(CC)&quot; SFC=&quot;$(SFC)&quot; SCC=&quot;$(SCC)&quot; \
+          CPPFLAGS=&quot;$(CPPFLAGS)&quot; CPPINCLUDES=&quot;$(CPPINCLUDES)&quot; FCINCLUDES=&quot;$(FCINCLUDES)&quot; )
+
+mpas: reg_includes externals frame ops dycore drver
+        ar ru lib$(CORE).a framework/*.o
+        ar ru lib$(CORE).a operators/*.o
+        ar ru lib$(CORE).a core_$(CORE)/*.o
+        ar ru lib$(CORE).a $(CORE)_cesm_driver/*.o
+
+externals: 
+
+drver:  reg_includes externals frame ops dycore
+        ( cd $(CORE)_cesm_driver; $(MAKE) CPPFLAGS=&quot;$(CPPFLAGS)&quot; CPPINCLUDES=&quot;$(CPPINCLUDES)&quot; all ) 
+

Modified: branches/atmos_physics/src/core_hyd_atmos/Registry
===================================================================
--- branches/atmos_physics/src/core_hyd_atmos/Registry        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_hyd_atmos/Registry        2013-03-26 23:03:26 UTC (rev 2670)
@@ -96,7 +96,7 @@
 
 var persistent real    edgeNormalVectors ( R3 nEdges ) 0 o edgeNormalVectors mesh - -
 var persistent real    localVerticalUnitVectors ( R3 nCells ) 0 o localVerticalUnitVectors mesh - -
-var persistent real    cellTangentPlane ( R3 TWO nEdges ) 0 o cellTangentPlane mesh - -
+var persistent real    cellTangentPlane ( R3 TWO nCells ) 0 o cellTangentPlane mesh - -
 
 var persistent integer cellsOnCell ( maxEdges nCells ) 0 iro cellsOnCell mesh - -
 var persistent integer verticesOnCell ( maxEdges nCells ) 0 iro verticesOnCell mesh - -

Copied: branches/atmos_physics/src/core_hyd_atmos/Registry.xml (from rev 2666, trunk/mpas/src/core_hyd_atmos/Registry.xml)
===================================================================
--- branches/atmos_physics/src/core_hyd_atmos/Registry.xml                                (rev 0)
+++ branches/atmos_physics/src/core_hyd_atmos/Registry.xml        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,179 @@
+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;registry&gt;
+        &lt;dims&gt;
+                &lt;dim name=&quot;nCells&quot;/&gt;
+                &lt;dim name=&quot;nEdges&quot;/&gt;
+                &lt;dim name=&quot;maxEdges&quot;/&gt;
+                &lt;dim name=&quot;maxEdges2&quot;/&gt;
+                &lt;dim name=&quot;nVertices&quot;/&gt;
+                &lt;dim name=&quot;TWO&quot;                definition=&quot;2&quot;/&gt;
+                &lt;dim name=&quot;vertexDegree&quot;/&gt;
+                &lt;dim name=&quot;FIFTEEN&quot;            definition=&quot;15&quot;/&gt;
+                &lt;dim name=&quot;TWENTYONE&quot;          definition=&quot;21&quot;/&gt;
+                &lt;dim name=&quot;R3&quot;                 definition=&quot;3&quot;/&gt;
+                &lt;dim name=&quot;nVertLevels&quot;        definition=&quot;namelist:config_nvertlevels&quot;/&gt;
+                &lt;dim name=&quot;nVertLevelsP1&quot;      definition=&quot;nVertLevels+1&quot;/&gt;
+        &lt;/dims&gt;
+        &lt;nml_record name=&quot;sw_model&quot;&gt;
+                &lt;nml_option name=&quot;config_test_case&quot;                  type=&quot;integer&quot;       default_value=&quot;5&quot;/&gt;
+                &lt;nml_option name=&quot;config_time_integration&quot;           type=&quot;character&quot;     default_value=&quot;SRK3&quot;/&gt;
+                &lt;nml_option name=&quot;config_dt&quot;                         type=&quot;real&quot;          default_value=&quot;172.8&quot;/&gt;
+                &lt;nml_option name=&quot;config_calendar_type&quot;              type=&quot;character&quot;     default_value=&quot;360day&quot;/&gt;
+                &lt;nml_option name=&quot;config_start_time&quot;                 type=&quot;character&quot;     default_value=&quot;0000-01-01_00:00:00&quot;/&gt;
+                &lt;nml_option name=&quot;config_stop_time&quot;                  type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+                &lt;nml_option name=&quot;config_run_duration&quot;               type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+                &lt;nml_option name=&quot;config_h_mom_eddy_visc2&quot;           type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_h_mom_eddy_visc4&quot;           type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_v_mom_eddy_visc2&quot;           type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_h_theta_eddy_visc2&quot;         type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_h_theta_eddy_visc4&quot;         type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_v_theta_eddy_visc2&quot;         type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_number_of_sub_steps&quot;        type=&quot;integer&quot;       default_value=&quot;4&quot;/&gt;
+                &lt;nml_option name=&quot;config_theta_adv_order&quot;            type=&quot;integer&quot;       default_value=&quot;2&quot;/&gt;
+                &lt;nml_option name=&quot;config_scalar_adv_order&quot;           type=&quot;integer&quot;       default_value=&quot;2&quot;/&gt;
+                &lt;nml_option name=&quot;config_positive_definite&quot;          type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_monotonic&quot;                  type=&quot;logical&quot;       default_value=&quot;true&quot;/&gt;
+                &lt;nml_option name=&quot;config_mp_physics&quot;                 type=&quot;integer&quot;       default_value=&quot;0&quot;/&gt;
+                &lt;nml_option name=&quot;config_apvm_upwinding&quot;             type=&quot;real&quot;          default_value=&quot;0.5&quot;/&gt;
+                &lt;nml_option name=&quot;config_num_halos&quot;                  type=&quot;integer&quot;       default_value=&quot;2&quot;/&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;dimensions&quot;&gt;
+                &lt;nml_option name=&quot;config_nvertlevels&quot;                type=&quot;integer&quot;       default_value=&quot;26&quot;/&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;io&quot;&gt;
+                &lt;nml_option name=&quot;config_input_name&quot;                 type=&quot;character&quot;     default_value=&quot;grid.nc&quot;/&gt;
+                &lt;nml_option name=&quot;config_output_name&quot;                type=&quot;character&quot;     default_value=&quot;output.nc&quot;/&gt;
+                &lt;nml_option name=&quot;config_restart_name&quot;               type=&quot;character&quot;     default_value=&quot;restart.nc&quot;/&gt;
+                &lt;nml_option name=&quot;config_output_interval&quot;            type=&quot;character&quot;     default_value=&quot;06:00:00&quot;/&gt;
+                &lt;nml_option name=&quot;config_frames_per_outfile&quot;         type=&quot;integer&quot;       default_value=&quot;0&quot;/&gt;
+                &lt;nml_option name=&quot;config_pio_num_iotasks&quot;            type=&quot;integer&quot;       default_value=&quot;0&quot;/&gt;
+                &lt;nml_option name=&quot;config_pio_stride&quot;                 type=&quot;integer&quot;       default_value=&quot;1&quot;/&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;decomposition&quot;&gt;
+                &lt;nml_option name=&quot;config_block_decomp_file_prefix&quot;   type=&quot;character&quot;     default_value=&quot;graph.info.part.&quot;/&gt;
+                &lt;nml_option name=&quot;config_number_of_blocks&quot;           type=&quot;integer&quot;       default_value=&quot;0&quot;/&gt;
+                &lt;nml_option name=&quot;config_explicit_proc_decomp&quot;       type=&quot;logical&quot;       default_value=&quot;.false.&quot;/&gt;
+                &lt;nml_option name=&quot;config_proc_decomp_file_prefix&quot;    type=&quot;character&quot;     default_value=&quot;graph.info.part.&quot;/&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;restart&quot;&gt;
+                &lt;nml_option name=&quot;config_do_restart&quot;                 type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_restart_interval&quot;           type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+        &lt;/nml_record&gt;
+        &lt;var_struct name=&quot;state&quot; time_levs=&quot;2&quot;&gt;
+                &lt;var_array name=&quot;scalars&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot;&gt;
+                        &lt;var name=&quot;qv&quot;                 array_group=&quot;moist&quot;       streams=&quot;iro&quot;/&gt;
+                        &lt;var name=&quot;qc&quot;                 array_group=&quot;moist&quot;       streams=&quot;iro&quot;/&gt;
+                        &lt;var name=&quot;qr&quot;                 array_group=&quot;moist&quot;       streams=&quot;iro&quot;/&gt;
+                &lt;/var_array&gt;
+                &lt;var name=&quot;xtime&quot;                             type=&quot;text&quot;     dimensions=&quot;Time&quot;                        streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;u&quot;                                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;theta&quot;                             type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;surface_pressure&quot;                  type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;h&quot;                                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;ww&quot;                                type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;   streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;w&quot;                                 type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;   streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;pressure&quot;                          type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;   streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;geopotential&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;   streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;alpha&quot;                             type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;v&quot;                                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;divergence&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;vorticity&quot;                         type=&quot;real&quot;     dimensions=&quot;nVertLevels nVertices Time&quot;  streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;pv_edge&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;h_edge&quot;                            type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;ke&quot;                                type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;pv_vertex&quot;                         type=&quot;real&quot;     dimensions=&quot;nVertLevels nVertices Time&quot;  streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;pv_cell&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;vh&quot;                                type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;/&gt;
+                &lt;var name=&quot;circulation&quot;                       type=&quot;real&quot;     dimensions=&quot;nVertLevels nVertices Time&quot;/&gt;
+                &lt;var name=&quot;gradPVt&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;/&gt;
+                &lt;var name=&quot;gradPVn&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;/&gt;
+        &lt;/var_struct&gt;
+        &lt;var_struct name=&quot;mesh&quot; time_levs=&quot;0&quot;&gt;
+                &lt;var_array name=&quot;scalars_old&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells&quot;&gt;
+                        &lt;var name=&quot;qv_old&quot;             array_group=&quot;moist_old&quot;/&gt;
+                        &lt;var name=&quot;qc_old&quot;             array_group=&quot;moist_old&quot;/&gt;
+                        &lt;var name=&quot;qr_old&quot;             array_group=&quot;moist_old&quot;/&gt;
+                &lt;/var_array&gt;
+                &lt;var name=&quot;latCell&quot;                           type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;lonCell&quot;                           type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;xCell&quot;                             type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;yCell&quot;                             type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;zCell&quot;                             type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;indexToCellID&quot;                     type=&quot;integer&quot;  dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;latEdge&quot;                           type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;lonEdge&quot;                           type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;xEdge&quot;                             type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;yEdge&quot;                             type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;zEdge&quot;                             type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;indexToEdgeID&quot;                     type=&quot;integer&quot;  dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;latVertex&quot;                         type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;lonVertex&quot;                         type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;xVertex&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;yVertex&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;zVertex&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;indexToVertexID&quot;                   type=&quot;integer&quot;  dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;cellsOnEdge&quot;                       type=&quot;integer&quot;  dimensions=&quot;TWO nEdges&quot;                  streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;nEdgesOnCell&quot;                      type=&quot;integer&quot;  dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;nEdgesOnEdge&quot;                      type=&quot;integer&quot;  dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;edgesOnCell&quot;                       type=&quot;integer&quot;  dimensions=&quot;maxEdges nCells&quot;             streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;edgesOnEdge&quot;                       type=&quot;integer&quot;  dimensions=&quot;maxEdges2 nEdges&quot;            streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;weightsOnEdge&quot;                     type=&quot;real&quot;     dimensions=&quot;maxEdges2 nEdges&quot;            streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;dvEdge&quot;                            type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;dcEdge&quot;                            type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;angleEdge&quot;                         type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;areaCell&quot;                          type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;areaTriangle&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;edgeNormalVectors&quot;                 type=&quot;real&quot;     dimensions=&quot;R3 nEdges&quot;                   streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;localVerticalUnitVectors&quot;          type=&quot;real&quot;     dimensions=&quot;R3 nCells&quot;                   streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;cellTangentPlane&quot;                  type=&quot;real&quot;     dimensions=&quot;R3 TWO nCells&quot;               streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;cellsOnCell&quot;                       type=&quot;integer&quot;  dimensions=&quot;maxEdges nCells&quot;             streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;verticesOnCell&quot;                    type=&quot;integer&quot;  dimensions=&quot;maxEdges nCells&quot;             streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;verticesOnEdge&quot;                    type=&quot;integer&quot;  dimensions=&quot;TWO nEdges&quot;                  streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;edgesOnVertex&quot;                     type=&quot;integer&quot;  dimensions=&quot;vertexDegree nVertices&quot;      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;cellsOnVertex&quot;                     type=&quot;integer&quot;  dimensions=&quot;vertexDegree nVertices&quot;      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;kiteAreasOnVertex&quot;                 type=&quot;real&quot;     dimensions=&quot;vertexDegree nVertices&quot;      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;fEdge&quot;                             type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;fVertex&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;h_s&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;rdnu&quot;                              type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;rdnw&quot;                              type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;fnm&quot;                               type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;fnp&quot;                               type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;dbn&quot;                               type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;dnu&quot;                               type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;dnw&quot;                               type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;uhAvg&quot;                             type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges&quot;/&gt;
+                &lt;var name=&quot;wwAvg&quot;                             type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells&quot;/&gt;
+                &lt;var name=&quot;qtot&quot;                              type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells&quot;/&gt;
+                &lt;var name=&quot;cqu&quot;                               type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges&quot;/&gt;
+                &lt;var name=&quot;h_diabatic&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells&quot;/&gt;
+                &lt;var name=&quot;dpsdt&quot;                             type=&quot;real&quot;     dimensions=&quot;nCells&quot;/&gt;
+                &lt;var name=&quot;u_old&quot;                             type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges&quot;/&gt;
+                &lt;var name=&quot;ww_old&quot;                            type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells&quot;/&gt;
+                &lt;var name=&quot;theta_old&quot;                         type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells&quot;/&gt;
+                &lt;var name=&quot;h_edge_old&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges&quot;/&gt;
+                &lt;var name=&quot;h_old&quot;                             type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells&quot;/&gt;
+                &lt;var name=&quot;pressure_old&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells&quot;/&gt;
+                &lt;var name=&quot;deriv_two&quot;                         type=&quot;real&quot;     dimensions=&quot;FIFTEEN TWO nEdges&quot;          streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;advCells&quot;                          type=&quot;integer&quot;  dimensions=&quot;TWENTYONE nCells&quot;/&gt;
+                &lt;var name=&quot;coeffs_reconstruct&quot;                type=&quot;real&quot;     dimensions=&quot;R3 maxEdges nCells&quot;/&gt;
+        &lt;/var_struct&gt;
+        &lt;var_struct name=&quot;diag&quot; time_levs=&quot;1&quot;&gt;
+                &lt;var name=&quot;uReconstructX&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructY&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructZ&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructZonal&quot;                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructMeridional&quot;            type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+        &lt;/var_struct&gt;
+        &lt;var_struct name=&quot;tend&quot; time_levs=&quot;1&quot;&gt;
+                &lt;var_array name=&quot;scalars&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot;&gt;
+                        &lt;var name=&quot;tend_qv&quot;            array_group=&quot;moist&quot;        name_in_code=&quot;qv&quot;/&gt;
+                        &lt;var name=&quot;tend_qc&quot;            array_group=&quot;moist&quot;        name_in_code=&quot;qc&quot;/&gt;
+                        &lt;var name=&quot;tend_qr&quot;            array_group=&quot;moist&quot;        name_in_code=&quot;qr&quot;/&gt;
+                &lt;/var_array&gt;
+                &lt;var name=&quot;tend_h&quot;                            type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;    name_in_code=&quot;h&quot;/&gt;
+                &lt;var name=&quot;tend_u&quot;                            type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;    name_in_code=&quot;u&quot;/&gt;
+                &lt;var name=&quot;tend_vh&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;    name_in_code=&quot;vh&quot;/&gt;
+                &lt;var name=&quot;tend_theta&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;    name_in_code=&quot;theta&quot;/&gt;
+        &lt;/var_struct&gt;
+&lt;/registry&gt;

Copied: branches/atmos_physics/src/core_init_nhyd_atmos/Registry.xml (from rev 2666, trunk/mpas/src/core_init_nhyd_atmos/Registry.xml)
===================================================================
--- branches/atmos_physics/src/core_init_nhyd_atmos/Registry.xml                                (rev 0)
+++ branches/atmos_physics/src/core_init_nhyd_atmos/Registry.xml        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,297 @@
+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;registry&gt;
+
+&lt;!-- **************************************************************************************** --&gt;
+&lt;!-- ************************************** Dimensions ************************************** --&gt;
+&lt;!-- **************************************************************************************** --&gt;
+
+        &lt;dims&gt;
+                &lt;dim name=&quot;nCells&quot;/&gt;
+                &lt;dim name=&quot;nEdges&quot;/&gt;
+                &lt;dim name=&quot;maxEdges&quot;/&gt;
+                &lt;dim name=&quot;maxEdges2&quot;/&gt;
+                &lt;dim name=&quot;nVertices&quot;/&gt;
+                &lt;dim name=&quot;TWO&quot;                definition=&quot;2&quot;/&gt;
+                &lt;dim name=&quot;THREE&quot;              definition=&quot;3&quot;/&gt;
+                &lt;dim name=&quot;vertexDegree&quot;/&gt;
+                &lt;dim name=&quot;FIFTEEN&quot;            definition=&quot;15&quot;/&gt;
+                &lt;dim name=&quot;TWENTYONE&quot;          definition=&quot;21&quot;/&gt;
+                &lt;dim name=&quot;R3&quot;                 definition=&quot;3&quot;/&gt;
+                &lt;dim name=&quot;nVertLevels&quot;        definition=&quot;namelist:config_nvertlevels&quot;/&gt;
+                &lt;dim name=&quot;nSoilLevels&quot;        definition=&quot;namelist:config_nsoillevels&quot;/&gt;
+                &lt;dim name=&quot;nFGLevels&quot;          definition=&quot;namelist:config_nfglevels&quot;/&gt;
+                &lt;dim name=&quot;nFGSoilLevels&quot;      definition=&quot;namelist:config_nfgsoillevels&quot;/&gt;
+                &lt;dim name=&quot;nVertLevelsP1&quot;      definition=&quot;nVertLevels+1&quot;/&gt;
+                &lt;dim name=&quot;nMonths&quot;            definition=&quot;namelist:config_months&quot;/&gt;
+        &lt;/dims&gt;
+
+
+&lt;!-- **************************************************************************************** --&gt;
+&lt;!-- ************************************** Namelists *************************************** --&gt;
+&lt;!-- **************************************************************************************** --&gt;
+
+        &lt;nml_record name=&quot;nhyd_model&quot;&gt;
+                &lt;nml_option name=&quot;config_test_case&quot;             type=&quot;integer&quot;       default_value=&quot;7&quot;/&gt;
+                &lt;nml_option name=&quot;config_calendar_type&quot;         type=&quot;character&quot;     default_value=&quot;gregorian&quot;/&gt;
+                &lt;nml_option name=&quot;config_start_time&quot;            type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+                &lt;nml_option name=&quot;config_stop_time&quot;             type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+                &lt;nml_option name=&quot;config_theta_adv_order&quot;       type=&quot;integer&quot;       default_value=&quot;3&quot;/&gt;
+                &lt;nml_option name=&quot;config_coef_3rd_order&quot;        type=&quot;real&quot;          default_value=&quot;0.25&quot;/&gt;
+                &lt;nml_option name=&quot;config_num_halos&quot;             type=&quot;integer&quot;       default_value=&quot;2&quot;/&gt;
+        &lt;/nml_record&gt;
+
+        &lt;nml_record name=&quot;dcmip&quot;&gt;
+                &lt;nml_option name=&quot;config_dcmip_case&quot;            type=&quot;character&quot;     default_value=&quot;2-0-0&quot;/&gt;
+                &lt;nml_option name=&quot;config_planet_scale&quot;          type=&quot;real&quot;          default_value=&quot;1.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_rotation_rate_scale&quot;   type=&quot;real&quot;          default_value=&quot;1.0&quot;/&gt;
+        &lt;/nml_record&gt;
+
+        &lt;nml_record name=&quot;dimensions&quot;&gt;
+                &lt;nml_option name=&quot;config_nvertlevels&quot;           type=&quot;integer&quot;       default_value=&quot;26&quot;/&gt;
+                &lt;nml_option name=&quot;config_nsoillevels&quot;           type=&quot;integer&quot;       default_value=&quot;4&quot;/&gt;
+                &lt;nml_option name=&quot;config_nfglevels&quot;             type=&quot;integer&quot;       default_value=&quot;27&quot;/&gt;
+                &lt;nml_option name=&quot;config_nfgsoillevels&quot;         type=&quot;integer&quot;       default_value=&quot;4&quot;/&gt;
+                &lt;nml_option name=&quot;config_months&quot;                type=&quot;integer&quot;       default_value=&quot;12&quot;/&gt;
+        &lt;/nml_record&gt;
+
+        &lt;nml_record name=&quot;data_sources&quot;&gt;
+                &lt;nml_option name=&quot;config_geog_data_path&quot;        type=&quot;character&quot;     default_value=&quot;/mmm/users/wrfhelp/WPS_GEOG/&quot;/&gt;
+                &lt;nml_option name=&quot;config_met_prefix&quot;            type=&quot;character&quot;     default_value=&quot;FILE&quot;/&gt;
+                &lt;nml_option name=&quot;config_sfc_prefix&quot;            type=&quot;character&quot;     default_value=&quot;FILE&quot;/&gt;
+                &lt;nml_option name=&quot;config_fg_interval&quot;           type=&quot;integer&quot;       default_value=&quot;21600&quot;/&gt;
+        &lt;/nml_record&gt;
+
+        &lt;nml_record name=&quot;vertical_grid&quot;&gt;
+                &lt;nml_option name=&quot;config_ztop&quot;                  type=&quot;real&quot;          default_value=&quot;28000.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_nsmterrain&quot;            type=&quot;integer&quot;       default_value=&quot;2&quot;/&gt;
+                &lt;nml_option name=&quot;config_smooth_surfaces&quot;       type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+        &lt;/nml_record&gt;
+
+        &lt;nml_record name=&quot;preproc_stages&quot;&gt;
+                &lt;nml_option name=&quot;config_static_interp&quot;         type=&quot;logical&quot;       default_value=&quot;true&quot;/&gt;
+                &lt;nml_option name=&quot;config_vertical_grid&quot;         type=&quot;logical&quot;       default_value=&quot;true&quot;/&gt;
+                &lt;nml_option name=&quot;config_met_interp&quot;            type=&quot;logical&quot;       default_value=&quot;true&quot;/&gt;
+                &lt;nml_option name=&quot;config_input_sst&quot;             type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_frac_seaice&quot;           type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+        &lt;/nml_record&gt;
+
+        &lt;nml_record name=&quot;io&quot;&gt;
+                &lt;nml_option name=&quot;config_input_name&quot;            type=&quot;character&quot;     default_value=&quot;grid.nc&quot;/&gt;
+                &lt;nml_option name=&quot;config_sfc_update_name&quot;       type=&quot;character&quot;     default_value=&quot;sfc_update.nc&quot;/&gt;
+                &lt;nml_option name=&quot;config_output_name&quot;           type=&quot;character&quot;     default_value=&quot;init.nc&quot;/&gt;
+                &lt;nml_option name=&quot;config_restart_name&quot;          type=&quot;character&quot;     default_value=&quot;restart.nc&quot;/&gt;
+                &lt;nml_option name=&quot;config_frames_per_outfile&quot;    type=&quot;integer&quot;       default_value=&quot;0&quot;/&gt;
+                &lt;nml_option name=&quot;config_pio_num_iotasks&quot;       type=&quot;integer&quot;       default_value=&quot;0&quot;/&gt;
+                &lt;nml_option name=&quot;config_pio_stride&quot;            type=&quot;integer&quot;       default_value=&quot;1&quot;/&gt;
+        &lt;/nml_record&gt;
+
+        &lt;nml_record name=&quot;decomposition&quot;&gt;
+                &lt;nml_option name=&quot;config_block_decomp_file_prefix&quot;   type=&quot;character&quot;     default_value=&quot;graph.info.part.&quot;/&gt;
+                &lt;nml_option name=&quot;config_number_of_blocks&quot;           type=&quot;integer&quot;       default_value=&quot;0&quot;/&gt;
+                &lt;nml_option name=&quot;config_explicit_proc_decomp&quot;       type=&quot;logical&quot;       default_value=&quot;.false.&quot;/&gt;
+                &lt;nml_option name=&quot;config_proc_decomp_file_prefix&quot;    type=&quot;character&quot;     default_value=&quot;graph.info.part.&quot;/&gt;
+        &lt;/nml_record&gt;
+
+        &lt;nml_record name=&quot;restart&quot;&gt;
+                &lt;nml_option name=&quot;config_restart_interval&quot;      type=&quot;integer&quot;       default_value=&quot;0&quot;/&gt;
+                &lt;nml_option name=&quot;config_do_restart&quot;            type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_restart_time&quot;          type=&quot;real&quot;          default_value=&quot;172800.0&quot;/&gt;
+        &lt;/nml_record&gt;
+
+
+&lt;!-- **************************************************************************************** --&gt;
+&lt;!-- ************************************** Variables *************************************** --&gt;
+&lt;!-- **************************************************************************************** --&gt;
+
+        &lt;var_struct name=&quot;mesh&quot; time_levs=&quot;0&quot;&gt;
+                &lt;var name=&quot;latCell&quot;                      type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;lonCell&quot;                      type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;xCell&quot;                        type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;yCell&quot;                        type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;zCell&quot;                        type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;indexToCellID&quot;                type=&quot;integer&quot;  dimensions=&quot;nCells&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;latEdge&quot;                      type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;lonEdge&quot;                      type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;xEdge&quot;                        type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;yEdge&quot;                        type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;zEdge&quot;                        type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;indexToEdgeID&quot;                type=&quot;integer&quot;  dimensions=&quot;nEdges&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;latVertex&quot;                    type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;lonVertex&quot;                    type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;xVertex&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;yVertex&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;zVertex&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;indexToVertexID&quot;              type=&quot;integer&quot;  dimensions=&quot;nVertices&quot;                   streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;cellsOnEdge&quot;                  type=&quot;integer&quot;  dimensions=&quot;TWO nEdges&quot;                  streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;nEdgesOnCell&quot;                 type=&quot;integer&quot;  dimensions=&quot;nCells&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;nEdgesOnEdge&quot;                 type=&quot;integer&quot;  dimensions=&quot;nEdges&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;edgesOnCell&quot;                  type=&quot;integer&quot;  dimensions=&quot;maxEdges nCells&quot;             streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;edgesOnEdge&quot;                  type=&quot;integer&quot;  dimensions=&quot;maxEdges2 nEdges&quot;            streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;weightsOnEdge&quot;                type=&quot;real&quot;     dimensions=&quot;maxEdges2 nEdges&quot;            streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;dvEdge&quot;                       type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;dcEdge&quot;                       type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;angleEdge&quot;                    type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;areaCell&quot;                     type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;areaTriangle&quot;                 type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;edgeNormalVectors&quot;            type=&quot;real&quot;     dimensions=&quot;R3 nEdges&quot;                   streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;localVerticalUnitVectors&quot;     type=&quot;real&quot;     dimensions=&quot;R3 nCells&quot;                   streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;cellTangentPlane&quot;             type=&quot;real&quot;     dimensions=&quot;R3 TWO nCells&quot;               streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;cellsOnCell&quot;                  type=&quot;integer&quot;  dimensions=&quot;maxEdges nCells&quot;             streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;verticesOnCell&quot;               type=&quot;integer&quot;  dimensions=&quot;maxEdges nCells&quot;             streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;verticesOnEdge&quot;               type=&quot;integer&quot;  dimensions=&quot;TWO nEdges&quot;                  streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;edgesOnVertex&quot;                type=&quot;integer&quot;  dimensions=&quot;vertexDegree nVertices&quot;      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;cellsOnVertex&quot;                type=&quot;integer&quot;  dimensions=&quot;vertexDegree nVertices&quot;      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;kiteAreasOnVertex&quot;            type=&quot;real&quot;     dimensions=&quot;vertexDegree nVertices&quot;      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;fEdge&quot;                        type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;fVertex&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;meshDensity&quot;                  type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+
+                &lt;!-- coefficients for vertical extrapolation to the surface --&gt;
+                &lt;var name=&quot;cf1&quot;                          type=&quot;real&quot;     dimensions=&quot;&quot;                            streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;cf2&quot;                          type=&quot;real&quot;     dimensions=&quot;&quot;                            streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;cf3&quot;                          type=&quot;real&quot;     dimensions=&quot;&quot;                            streams=&quot;io&quot;/&gt;
+
+                &lt;!-- static terrestrial fields --&gt;
+                &lt;var name=&quot;ter&quot;                                  type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;landmask&quot;                             type=&quot;integer&quot;  dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;ivgtyp&quot;   name_in_code=&quot;lu_index&quot;     type=&quot;integer&quot;  dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;isltyp&quot;   name_in_code=&quot;soilcat_top&quot;  type=&quot;integer&quot;  dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;soilcat_bot&quot;                          type=&quot;integer&quot;  dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;snoalb&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;soiltemp&quot;                             type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;greenfrac&quot;                            type=&quot;real&quot;     dimensions=&quot;nMonths nCells&quot;      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;shdmin&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;shdmax&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;albedo12m&quot;                            type=&quot;real&quot;     dimensions=&quot;nMonths nCells&quot;      streams=&quot;io&quot;/&gt;
+
+                &lt;!-- GWDO fields --&gt;
+                &lt;var name=&quot;varsso&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;var2d&quot;                                type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;con&quot;                                  type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;oa1&quot;                                  type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;oa2&quot;                                  type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;oa3&quot;                                  type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;oa4&quot;                                  type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;ol1&quot;                                  type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;ol2&quot;                                  type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;ol3&quot;                                  type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;ol4&quot;                                  type=&quot;real&quot;     dimensions=&quot;nCells&quot;              streams=&quot;io&quot;/&gt;
+
+                &lt;!-- description of the vertical grid structure --&gt;
+                &lt;var name=&quot;hx&quot;                         type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells&quot;        streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;zgrid&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells&quot;        streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;rdzw&quot;                       type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;dzu&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;rdzu&quot;                       type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;fzm&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;fzp&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;zx&quot;                         type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nEdges&quot;        streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;zz&quot;                         type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells&quot;        streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;zb&quot;                         type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 TWO nEdges&quot;    streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;zb3&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 TWO nEdges&quot;    streams=&quot;io&quot;/&gt;
+
+                &lt;!-- W-Rayleigh damping coefficient --&gt;
+                &lt;var name=&quot;dss&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells&quot;          streams=&quot;io&quot;/&gt;
+
+                &lt;var name=&quot;u_init&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;t_init&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells&quot;          streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;qv_init&quot;                    type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;io&quot;/&gt;
+
+                &lt;!-- variables needed for advection --&gt;
+                &lt;var name=&quot;deriv_two&quot;                  type=&quot;real&quot;     dimensions=&quot;FIFTEEN TWO nEdges&quot;          streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;advCells&quot;                   type=&quot;integer&quot;  dimensions=&quot;TWENTYONE nCells&quot;            streams=&quot;io&quot;/&gt;
+
+                &lt;!-- deformation calculation weights --&gt;
+                &lt;var name=&quot;defc_a&quot;                     type=&quot;real&quot;     dimensions=&quot;maxEdges nCells&quot;             streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;defc_b&quot;                     type=&quot;real&quot;     dimensions=&quot;maxEdges nCells&quot;             streams=&quot;io&quot;/&gt;
+
+                &lt;!-- arrays required for reconstruction of velocity field --&gt;
+                &lt;var name=&quot;coeffs_reconstruct&quot;         type=&quot;real&quot;     dimensions=&quot;R3 maxEdges nCells&quot;          streams=&quot;io&quot;/&gt;
+        &lt;/var_struct&gt;
+
+        &lt;var_struct name=&quot;state&quot; time_levs=&quot;2&quot;&gt;
+                &lt;var name=&quot;xtime&quot;                      type=&quot;text&quot;     dimensions=&quot;Time&quot;                        streams=&quot;so&quot;/&gt;
+                &lt;var name=&quot;u&quot;                          type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;w&quot;                          type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;   streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;rho_zz&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;theta_m&quot;                    type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+
+                &lt;var_array name=&quot;scalars&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot;&gt;
+                        &lt;var name=&quot;qv&quot;      array_group=&quot;moist&quot;       streams=&quot;o&quot;/&gt;
+                        &lt;var name=&quot;qc&quot;      array_group=&quot;moist&quot;       streams=&quot;o&quot;/&gt;
+                        &lt;var name=&quot;qr&quot;      array_group=&quot;moist&quot;       streams=&quot;o&quot;/&gt;
+                &lt;/var_array&gt;
+        &lt;/var_struct&gt;
+
+        &lt;var_struct name=&quot;fg&quot; time_levs=&quot;1&quot;&gt;
+                
+                &lt;!-- horizontally interpolated from first-guess data --&gt;
+                &lt;var name=&quot;u_fg&quot;       name_in_code=&quot;u&quot;       type=&quot;real&quot;     dimensions=&quot;nFGLevels nEdges Time&quot;/&gt;
+                &lt;var name=&quot;v_fg&quot;       name_in_code=&quot;v&quot;       type=&quot;real&quot;     dimensions=&quot;nFGLevels nEdges Time&quot;/&gt;
+                &lt;var name=&quot;t_fg&quot;       name_in_code=&quot;t&quot;       type=&quot;real&quot;     dimensions=&quot;nFGLevels nCells Time&quot;       streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;p_fg&quot;       name_in_code=&quot;p&quot;       type=&quot;real&quot;     dimensions=&quot;nFGLevels nCells Time&quot;       streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;z_fg&quot;       name_in_code=&quot;z&quot;       type=&quot;real&quot;     dimensions=&quot;nFGLevels nCells Time&quot;       streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;rh_fg&quot;      name_in_code=&quot;rh&quot;      type=&quot;real&quot;     dimensions=&quot;nFGLevels nCells Time&quot;       streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;soilz_fg&quot;   name_in_code=&quot;soilz&quot;   type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;psfc_fg&quot;    name_in_code=&quot;psfc&quot;    type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;/&gt;
+                &lt;var name=&quot;pmsl_fg&quot;    name_in_code=&quot;pmsl&quot;    type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;/&gt;
+                &lt;var name=&quot;dz_fg&quot;                             type=&quot;real&quot;     dimensions=&quot;nFGSoilLevels nCells Time&quot;   streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;dzs_fg&quot;                            type=&quot;real&quot;     dimensions=&quot;nFGSoilLevels nCells Time&quot;   streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;zs_fg&quot;                             type=&quot;real&quot;     dimensions=&quot;nFGSoilLevels nCells Time&quot;   streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;st_fg&quot;                             type=&quot;real&quot;     dimensions=&quot;nFGSoilLevels nCells Time&quot;   streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;sm_fg&quot;                             type=&quot;real&quot;     dimensions=&quot;nFGSoilLevels nCells Time&quot;   streams=&quot;io&quot;/&gt;
+
+                &lt;!-- horizontally interpolated from first-guess data, and should be read in by model --&gt;
+                &lt;var name=&quot;dz&quot;                                type=&quot;real&quot;     dimensions=&quot;nSoilLevels nCells Time&quot;     streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;dzs&quot;                               type=&quot;real&quot;     dimensions=&quot;nSoilLevels nCells Time&quot;     streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;zs&quot;                                type=&quot;real&quot;     dimensions=&quot;nSoilLevels nCells Time&quot;     streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;sh2o&quot;                              type=&quot;real&quot;     dimensions=&quot;nSoilLevels nCells Time&quot;     streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;smois&quot;                             type=&quot;real&quot;     dimensions=&quot;nSoilLevels nCells Time&quot;     streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;tslb&quot;                              type=&quot;real&quot;     dimensions=&quot;nSoilLevels nCells Time&quot;     streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;smcrel&quot;                            type=&quot;real&quot;     dimensions=&quot;nSoilLevels nCells Time&quot;     streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;tmn&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;skintemp&quot;                          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;sst&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;iso&quot;/&gt;
+                &lt;var name=&quot;snow&quot;                              type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;snowc&quot;                             type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;snowh&quot;                             type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;xice&quot;                              type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;iso&quot;/&gt;
+                &lt;var name=&quot;seaice&quot;                            type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;gfs_z&quot;                             type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;vegfra&quot;                            type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;sfc_albbck&quot;                        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;xland&quot;                             type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;io&quot;/&gt;
+        &lt;/var_struct&gt;
+
+        &lt;var_struct name=&quot;diag&quot; time_levs=&quot;1&quot;&gt;
+                &lt;var name=&quot;pressure_p&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;rho&quot;                               type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;theta&quot;                             type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;v&quot;                                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;rh&quot;                                type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructX&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructY&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructZ&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructZonal&quot;                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructMeridional&quot;            type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;exner&quot;                             type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;exner_base&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;rtheta_base&quot;                       type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;pressure&quot;                          type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;pressure_base&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;rho_base&quot;                          type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;theta_base&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;cqw&quot;                               type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;surface_pressure&quot;                  type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;io&quot;/&gt;
+
+                &lt;!-- coupled variables needed by the solver, but not output --&gt;
+                &lt;var name=&quot;ru&quot;                                type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;/&gt;
+                &lt;var name=&quot;rw&quot;                                type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;/&gt;
+                &lt;var name=&quot;rtheta_p&quot;                          type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;rho_p&quot;                             type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+        &lt;/var_struct&gt;
+
+        &lt;var_struct name=&quot;diag_physics&quot; time_levs=&quot;1&quot;&gt;
+                &lt;var name=&quot;precipw&quot;                           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+        &lt;/var_struct&gt;
+&lt;/registry&gt;

Copied: branches/atmos_physics/src/core_nhyd_atmos/Registry.xml (from rev 2666, trunk/mpas/src/core_nhyd_atmos/Registry.xml)
===================================================================
--- branches/atmos_physics/src/core_nhyd_atmos/Registry.xml                                (rev 0)
+++ branches/atmos_physics/src/core_nhyd_atmos/Registry.xml        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,994 @@
+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;registry&gt;
+
+&lt;!-- **************************************************************************************** --&gt;
+&lt;!-- ************************************** Dimensions ************************************** --&gt;
+&lt;!-- **************************************************************************************** --&gt;
+
+        &lt;dims&gt;
+                &lt;dim name=&quot;nCells&quot;/&gt;
+                &lt;dim name=&quot;nEdges&quot;/&gt;
+                &lt;dim name=&quot;maxEdges&quot;/&gt;
+                &lt;dim name=&quot;maxEdges2&quot;/&gt;
+                &lt;dim name=&quot;nVertices&quot;/&gt;
+                &lt;dim name=&quot;TWO&quot;                definition=&quot;2&quot;/&gt;
+                &lt;dim name=&quot;THREE&quot;              definition=&quot;3&quot;/&gt;
+                &lt;dim name=&quot;vertexDegree&quot;/&gt;
+                &lt;dim name=&quot;FIFTEEN&quot;            definition=&quot;15&quot;/&gt;
+                &lt;dim name=&quot;TWENTYONE&quot;          definition=&quot;21&quot;/&gt;
+                &lt;dim name=&quot;R3&quot;                 definition=&quot;3&quot;/&gt;
+                &lt;dim name=&quot;nVertLevels&quot;/&gt;
+                &lt;dim name=&quot;nVertLevelsP1&quot;      definition=&quot;nVertLevels+1&quot;/&gt;
+                &lt;dim name=&quot;nMonths&quot;            definition=&quot;namelist:months&quot;/&gt;
+                &lt;dim name=&quot;nSoilLevels&quot;        definition=&quot;namelist:num_soil_layers&quot;/&gt;
+                &lt;dim name=&quot;nLags&quot;              definition=&quot;namelist:input_soil_temperature_lag&quot;/&gt;
+                &lt;dim name=&quot;nOznLevels&quot;         definition=&quot;namelist:noznlev&quot;/&gt;
+                &lt;dim name=&quot;nAerLevels&quot;         definition=&quot;namelist:naerlev&quot;/&gt;
+                &lt;dim name=&quot;cam_dim1&quot;           definition=&quot;namelist:camdim1&quot;/&gt;
+                &lt;dim name=&quot;nVertLevelsP2&quot;      definition=&quot;nVertLevels+2&quot;/&gt;
+        &lt;/dims&gt;
+
+
+&lt;!-- **************************************************************************************** --&gt;
+&lt;!-- ************************************** Namelists *************************************** --&gt;
+&lt;!-- **************************************************************************************** --&gt;
+
+        &lt;nml_record name=&quot;nhyd_model&quot;&gt;
+                &lt;nml_option name=&quot;config_time_integration&quot;           type=&quot;character&quot;     default_value=&quot;SRK3&quot;/&gt;
+                &lt;nml_option name=&quot;config_dt&quot;                         type=&quot;real&quot;          default_value=&quot;600.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_calendar_type&quot;              type=&quot;character&quot;     default_value=&quot;gregorian&quot;/&gt;
+                &lt;nml_option name=&quot;config_start_time&quot;                 type=&quot;character&quot;     default_value=&quot;0000-01-01_00:00:00&quot;/&gt;
+                &lt;nml_option name=&quot;config_stop_time&quot;                  type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+                &lt;nml_option name=&quot;config_run_duration&quot;               type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+                &lt;nml_option name=&quot;config_sfc_update_interval&quot;        type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+                &lt;nml_option name=&quot;config_horiz_mixing&quot;               type=&quot;character&quot;     default_value=&quot;2d_smagorinsky&quot;/&gt;
+                &lt;nml_option name=&quot;config_h_mom_eddy_visc2&quot;           type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_h_mom_eddy_visc4&quot;           type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_v_mom_eddy_visc2&quot;           type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_h_theta_eddy_visc2&quot;         type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_h_theta_eddy_visc4&quot;         type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_v_theta_eddy_visc2&quot;         type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_visc4_2dsmag&quot;               type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_number_of_sub_steps&quot;        type=&quot;integer&quot;       default_value=&quot;4&quot;/&gt;
+                &lt;nml_option name=&quot;config_w_adv_order&quot;                type=&quot;integer&quot;       default_value=&quot;3&quot;/&gt;
+                &lt;nml_option name=&quot;config_theta_adv_order&quot;            type=&quot;integer&quot;       default_value=&quot;3&quot;/&gt;
+                &lt;nml_option name=&quot;config_scalar_adv_order&quot;           type=&quot;integer&quot;       default_value=&quot;3&quot;/&gt;
+                &lt;nml_option name=&quot;config_u_vadv_order&quot;               type=&quot;integer&quot;       default_value=&quot;3&quot;/&gt;
+                &lt;nml_option name=&quot;config_w_vadv_order&quot;               type=&quot;integer&quot;       default_value=&quot;3&quot;/&gt;
+                &lt;nml_option name=&quot;config_theta_vadv_order&quot;           type=&quot;integer&quot;       default_value=&quot;3&quot;/&gt;
+                &lt;nml_option name=&quot;config_scalar_vadv_order&quot;          type=&quot;integer&quot;       default_value=&quot;3&quot;/&gt;
+                &lt;nml_option name=&quot;config_coef_3rd_order&quot;             type=&quot;real&quot;          default_value=&quot;0.25&quot;/&gt;
+                &lt;nml_option name=&quot;config_scalar_advection&quot;           type=&quot;logical&quot;       default_value=&quot;true&quot;/&gt;
+                &lt;nml_option name=&quot;config_positive_definite&quot;          type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_monotonic&quot;                  type=&quot;logical&quot;       default_value=&quot;true&quot;/&gt;
+                &lt;nml_option name=&quot;config_mix_full&quot;                   type=&quot;logical&quot;       default_value=&quot;true&quot;/&gt;
+                &lt;nml_option name=&quot;config_len_disp&quot;                   type=&quot;real&quot;          default_value=&quot;120000.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_epssm&quot;                      type=&quot;real&quot;          default_value=&quot;0.1&quot;/&gt;
+                &lt;nml_option name=&quot;config_smdiv&quot;                      type=&quot;real&quot;          default_value=&quot;0.1&quot;/&gt;
+                &lt;nml_option name=&quot;config_newpx&quot;                      type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_apvm_upwinding&quot;             type=&quot;real&quot;          default_value=&quot;0.5&quot;/&gt;
+                &lt;nml_option name=&quot;config_h_ScaleWithMesh&quot;            type=&quot;logical&quot;       default_value=&quot;true&quot;/&gt;
+                &lt;nml_option name=&quot;config_num_halos&quot;                  type=&quot;integer&quot;       default_value=&quot;2&quot;/&gt;
+        &lt;/nml_record&gt;
+
+        &lt;nml_record name=&quot;damping&quot;&gt;
+                &lt;nml_option name=&quot;config_zd&quot;                         type=&quot;real&quot;          default_value=&quot;22000.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_xnutr&quot;                      type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+        &lt;/nml_record&gt;
+
+        &lt;nml_record name=&quot;io&quot;&gt;
+                &lt;nml_option name=&quot;config_input_name&quot;                 type=&quot;character&quot;     default_value=&quot;init.nc&quot;/&gt;
+                &lt;nml_option name=&quot;config_sfc_update_name&quot;            type=&quot;character&quot;     default_value=&quot;sfc_update.nc&quot;/&gt;
+                &lt;nml_option name=&quot;config_output_name&quot;                type=&quot;character&quot;     default_value=&quot;output.nc&quot;/&gt;
+                &lt;nml_option name=&quot;config_restart_name&quot;               type=&quot;character&quot;     default_value=&quot;restart.nc&quot;/&gt;
+                &lt;nml_option name=&quot;config_output_interval&quot;            type=&quot;character&quot;     default_value=&quot;06:00:00&quot;/&gt;
+                &lt;nml_option name=&quot;config_frames_per_outfile&quot;         type=&quot;integer&quot;       default_value=&quot;0&quot;/&gt;
+                &lt;nml_option name=&quot;config_pio_num_iotasks&quot;            type=&quot;integer&quot;       default_value=&quot;0&quot;/&gt;
+                &lt;nml_option name=&quot;config_pio_stride&quot;                 type=&quot;integer&quot;       default_value=&quot;1&quot;/&gt;
+                &lt;nml_option name=&quot;config_pio_format&quot;                 type=&quot;character&quot;     default_value=&quot;pnetcdf&quot;/&gt;
+        &lt;/nml_record&gt;
+
+        &lt;nml_record name=&quot;decomposition&quot;&gt;
+                &lt;nml_option name=&quot;config_block_decomp_file_prefix&quot;   type=&quot;character&quot;     default_value=&quot;graph.info.part.&quot;/&gt;
+                &lt;nml_option name=&quot;config_number_of_blocks&quot;           type=&quot;integer&quot;       default_value=&quot;0&quot;/&gt;
+                &lt;nml_option name=&quot;config_explicit_proc_decomp&quot;       type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_proc_decomp_file_prefix&quot;    type=&quot;character&quot;     default_value=&quot;graph.info.part.&quot;/&gt;
+        &lt;/nml_record&gt;
+
+        &lt;nml_record name=&quot;restart&quot;&gt;
+                &lt;nml_option name=&quot;config_do_restart&quot;                 type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_do_DAcycling&quot;               type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_restart_interval&quot;           type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+        &lt;/nml_record&gt;
+
+
+&lt;!-- **************************************************************************************** --&gt;
+&lt;!-- ************************************** Variables *************************************** --&gt;
+&lt;!-- **************************************************************************************** --&gt;
+
+        &lt;var_struct name=&quot;mesh&quot; time_levs=&quot;0&quot;&gt;
+
+                &lt;!-- horizontal grid structure --&gt;
+                &lt;var name=&quot;latCell&quot;                   type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;lonCell&quot;                   type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;xCell&quot;                     type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;yCell&quot;                     type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;zCell&quot;                     type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;indexToCellID&quot;             type=&quot;integer&quot;  dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;latEdge&quot;                   type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;lonEdge&quot;                   type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;xEdge&quot;                     type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;yEdge&quot;                     type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;zEdge&quot;                     type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;indexToEdgeID&quot;             type=&quot;integer&quot;  dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;latVertex&quot;                 type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;lonVertex&quot;                 type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;xVertex&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;yVertex&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;zVertex&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;indexToVertexID&quot;           type=&quot;integer&quot;  dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;cellsOnEdge&quot;               type=&quot;integer&quot;  dimensions=&quot;TWO nEdges&quot;                  streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;nEdgesOnCell&quot;              type=&quot;integer&quot;  dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;nEdgesOnEdge&quot;              type=&quot;integer&quot;  dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;edgesOnCell&quot;               type=&quot;integer&quot;  dimensions=&quot;maxEdges nCells&quot;             streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;edgesOnEdge&quot;               type=&quot;integer&quot;  dimensions=&quot;maxEdges2 nEdges&quot;            streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;weightsOnEdge&quot;             type=&quot;real&quot;     dimensions=&quot;maxEdges2 nEdges&quot;            streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;dvEdge&quot;                    type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;dcEdge&quot;                    type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;angleEdge&quot;                 type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;areaCell&quot;                  type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;areaTriangle&quot;              type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;edgeNormalVectors&quot;         type=&quot;real&quot;     dimensions=&quot;R3 nEdges&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;localVerticalUnitVectors&quot;  type=&quot;real&quot;     dimensions=&quot;R3 nCells&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;cellTangentPlane&quot;          type=&quot;real&quot;     dimensions=&quot;R3 TWO nCells&quot;               streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;cellsOnCell&quot;               type=&quot;integer&quot;  dimensions=&quot;maxEdges nCells&quot;             streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;verticesOnCell&quot;            type=&quot;integer&quot;  dimensions=&quot;maxEdges nCells&quot;             streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;verticesOnEdge&quot;            type=&quot;integer&quot;  dimensions=&quot;TWO nEdges&quot;                  streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;edgesOnVertex&quot;             type=&quot;integer&quot;  dimensions=&quot;vertexDegree nVertices&quot;      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;cellsOnVertex&quot;             type=&quot;integer&quot;  dimensions=&quot;vertexDegree nVertices&quot;      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;kiteAreasOnVertex&quot;         type=&quot;real&quot;     dimensions=&quot;vertexDegree nVertices&quot;      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;fEdge&quot;                     type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;fVertex&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;meshDensity&quot;               type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;meshScalingDel2&quot;           type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;meshScalingDel4&quot;           type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;ro&quot;/&gt;
+
+                &lt;!-- coefficients for vertical extrapolation to the surface --&gt;
+                &lt;var name=&quot;cf1&quot;                       type=&quot;real&quot;     dimensions=&quot;&quot;                            streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;cf2&quot;                       type=&quot;real&quot;     dimensions=&quot;&quot;                            streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;cf3&quot;                       type=&quot;real&quot;     dimensions=&quot;&quot;                            streams=&quot;iro&quot;/&gt;
+
+                &lt;!-- coefficients used by &quot;newpx&quot; horizontal pressure gradient option --&gt;
+                &lt;var name=&quot;cpr&quot;                       type=&quot;real&quot;     dimensions=&quot;THREE nEdges&quot;                streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;cpl&quot;                       type=&quot;real&quot;     dimensions=&quot;THREE nEdges&quot;                streams=&quot;ro&quot;/&gt;
+
+                &lt;!-- description of the vertical grid structure --&gt;
+                &lt;var name=&quot;hx&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells&quot;        streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;zgrid&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells&quot;        streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;rdzw&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;dzu&quot;                       type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;rdzu&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;fzm&quot;                       type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;fzp&quot;                       type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;zx&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nEdges&quot;        streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;zz&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells&quot;        streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;zb&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 TWO nEdges&quot;    streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;zb3&quot;                       type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 TWO nEdges&quot;    streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;pzm&quot;                       type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells&quot;          streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;pzp&quot;                       type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells&quot;          streams=&quot;r&quot;/&gt;
+
+                &lt;!-- W-Rayleigh damping coefficients --&gt;
+                &lt;var name=&quot;dss&quot;                       type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells&quot;          streams=&quot;iro&quot;/&gt;
+
+                &lt;var name=&quot;u_init&quot;                    type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;t_init&quot;                    type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells&quot;          streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;qv_init&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertLevels&quot;                 streams=&quot;iro&quot;/&gt;
+
+                &lt;!-- Space needed for advection --&gt;
+                &lt;var name=&quot;deriv_two&quot;                 type=&quot;real&quot;     dimensions=&quot;FIFTEEN TWO nEdges&quot;          streams=&quot;ir&quot;/&gt;
+                &lt;var name=&quot;advCells&quot;                  type=&quot;integer&quot;  dimensions=&quot;TWENTYONE nCells&quot;            streams=&quot;ir&quot;/&gt;
+                &lt;var name=&quot;adv_coefs&quot;                 type=&quot;real&quot;     dimensions=&quot;FIFTEEN nEdges&quot;/&gt;
+                &lt;var name=&quot;adv_coefs_3rd&quot;             type=&quot;real&quot;     dimensions=&quot;FIFTEEN nEdges&quot;/&gt;
+                &lt;var name=&quot;advCellsForEdge&quot;           type=&quot;integer&quot;  dimensions=&quot;FIFTEEN nEdges&quot;/&gt;
+                &lt;var name=&quot;nAdvCellsForEdge&quot;          type=&quot;integer&quot;  dimensions=&quot;nEdges&quot;/&gt;
+
+                &lt;!-- Space needed for deformation calculation weights --&gt;
+                &lt;var name=&quot;defc_a&quot;                    type=&quot;real&quot;     dimensions=&quot;maxEdges nCells&quot;             streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;defc_b&quot;                    type=&quot;real&quot;     dimensions=&quot;maxEdges nCells&quot;             streams=&quot;iro&quot;/&gt;
+
+                &lt;!-- Arrays required for reconstruction of velocity field --&gt;
+                &lt;var name=&quot;coeffs_reconstruct&quot;        type=&quot;real&quot;     dimensions=&quot;R3 maxEdges nCells&quot;          streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;east&quot;                      type=&quot;real&quot;     dimensions=&quot;R3 nCells&quot;                   streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;north&quot;                     type=&quot;real&quot;     dimensions=&quot;R3 nCells&quot;                   streams=&quot;r&quot;/&gt;
+
+                &lt;!-- Arrays needed only in the CAM LW and SW radiation codes: Ozone --&gt;
+                &lt;var name=&quot;pin&quot;                       type=&quot;real&quot;     dimensions=&quot;nOznLevels nCells&quot;/&gt;
+                &lt;var name=&quot;ozmixm&quot;                    type=&quot;real&quot;     dimensions=&quot;nMonths nOznLevels nCells&quot;/&gt;
+
+                &lt;!-- Arrays needed only in the CAM LW and SW radiation codes: Aerosols --&gt;
+                &lt;var name=&quot;m_hybi&quot;                    type=&quot;real&quot;     dimensions=&quot;nAerLevels nCells&quot;/&gt;
+        &lt;/var_struct&gt;
+
+        &lt;var_struct name=&quot;state&quot; time_levs=&quot;2&quot;&gt;
+
+                &lt;var name=&quot;xtime&quot;     type=&quot;text&quot;     dimensions=&quot;Time&quot;                        streams=&quot;iro&quot;/&gt;
+
+                &lt;!-- Prognostic variables: read from input, saved in restart, and written to output --&gt;
+                &lt;var name=&quot;u&quot;         type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;w&quot;         type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;rho_zz&quot;    type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;theta_m&quot;   type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;m_ps&quot;      type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;/&gt;
+                &lt;var_array name=&quot;scalars&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot;&gt;
+                        &lt;var name=&quot;qv&quot;      array_group=&quot;moist&quot;       streams=&quot;iro&quot;/&gt;
+                        &lt;var name=&quot;qc&quot;      array_group=&quot;moist&quot;       streams=&quot;iro&quot;/&gt;
+                        &lt;var name=&quot;qr&quot;      array_group=&quot;moist&quot;       streams=&quot;iro&quot;/&gt;
+                        &lt;var name=&quot;qi&quot;      array_group=&quot;moist&quot;       streams=&quot;iro&quot;/&gt;
+                        &lt;var name=&quot;qs&quot;      array_group=&quot;moist&quot;       streams=&quot;iro&quot;/&gt;
+                        &lt;var name=&quot;qg&quot;      array_group=&quot;moist&quot;       streams=&quot;iro&quot;/&gt;
+                        &lt;var name=&quot;qnr&quot;     array_group=&quot;number&quot;      streams=&quot;iro&quot;/&gt;
+                        &lt;var name=&quot;qni&quot;     array_group=&quot;number&quot;      streams=&quot;iro&quot;/&gt;
+                &lt;/var_array&gt;
+
+                &lt;var_array name=&quot;aerosols&quot; type=&quot;real&quot; dimensions=&quot;nAerLevels nCells Time&quot;&gt;
+                        &lt;var name=&quot;sul&quot;     array_group=&quot;aer_cam&quot;/&gt;
+                        &lt;var name=&quot;sslt&quot;    array_group=&quot;aer_cam&quot;/&gt;
+                        &lt;var name=&quot;dust1&quot;   array_group=&quot;aer_cam&quot;/&gt;
+                        &lt;var name=&quot;dust2&quot;   array_group=&quot;aer_cam&quot;/&gt;
+                        &lt;var name=&quot;dust3&quot;   array_group=&quot;aer_cam&quot;/&gt;
+                        &lt;var name=&quot;dust4&quot;   array_group=&quot;aer_cam&quot;/&gt;
+                        &lt;var name=&quot;ocpho&quot;   array_group=&quot;aer_cam&quot;/&gt;
+                        &lt;var name=&quot;bcpho&quot;   array_group=&quot;aer_cam&quot;/&gt;
+                        &lt;var name=&quot;ocphi&quot;   array_group=&quot;aer_cam&quot;/&gt;
+                        &lt;var name=&quot;bcphi&quot;   array_group=&quot;aer_cam&quot;/&gt;
+                        &lt;var name=&quot;bg&quot;      array_group=&quot;aer_cam&quot;/&gt;
+                        &lt;var name=&quot;volc&quot;    array_group=&quot;aer_cam&quot;/&gt;
+                &lt;/var_array&gt;
+        &lt;/var_struct&gt;
+
+        &lt;var_struct name=&quot;diag&quot; time_levs=&quot;1&quot;&gt;
+
+                &lt;!-- coefficients for the vertical tridiagonal solve --&gt;
+                &lt;!-- Note:  these could be local but...              --&gt;
+                &lt;var name=&quot;cofrz&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertLevels Time&quot;/&gt;
+                &lt;var name=&quot;cofwr&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;cofwz&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;coftz&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;/&gt;
+                &lt;var name=&quot;cofwt&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;a_tri&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;alpha_tri&quot;               type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;gamma_tri&quot;               type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+
+                &lt;!-- state variables diagnosed from prognostic state --&gt;
+                &lt;var name=&quot;pressure_p&quot;              type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+
+                &lt;!-- Diagnostic fields: only written to output                                                           --&gt;
+                &lt;!-- NOTE: added the &quot;r&quot; option to rho,theta,uReconstructZonal,and uReconstructMeridional for use of the --&gt;
+                &lt;!-- non-hydrostatic dynamical core in a data assimilation framework. NOTE that the &quot;r&quot; option is not    --&gt;
+                &lt;!-- needed for those 4 variables to get bit for bit restart capabilities, otherwise.                    --&gt;
+                &lt;var name=&quot;rho&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;theta&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;rh&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;v&quot;                       type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;divergence&quot;              type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;vorticity&quot;               type=&quot;real&quot;     dimensions=&quot;nVertLevels nVertices Time&quot;  streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;pv_edge&quot;                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;rho_edge&quot;                type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;ke&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;pv_vertex&quot;               type=&quot;real&quot;     dimensions=&quot;nVertLevels nVertices Time&quot;  streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;pv_cell&quot;                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+
+                &lt;!-- reconstructed horizontal velocity vectors at cell centers --&gt;
+                &lt;var name=&quot;uReconstructX&quot;           type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructY&quot;           type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructZ&quot;           type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructZonal&quot;       type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;uReconstructMeridional&quot;  type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+
+                &lt;!-- Other diagnostic variables --&gt;
+                &lt;var name=&quot;rv&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;circulation&quot;             type=&quot;real&quot;     dimensions=&quot;nVertLevels nVertices Time&quot;  streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;gradPVt&quot;                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;/&gt;
+                &lt;var name=&quot;gradPVn&quot;                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;/&gt;
+                &lt;var name=&quot;h_divergence&quot;            type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+
+                &lt;var name=&quot;exner&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;exner_base&quot;              type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;rtheta_base&quot;             type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;pressure_base&quot;           type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;rho_base&quot;                type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;theta_base&quot;              type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;iro&quot;/&gt;
+
+                &lt;var name=&quot;ruAvg&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;/&gt;
+                &lt;var name=&quot;wwAvg&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;/&gt;
+                &lt;var name=&quot;cqu&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;/&gt;
+                &lt;var name=&quot;cqw&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+
+                &lt;!-- coupled variables needed by solver, but not output --&gt;
+                &lt;var name=&quot;ru&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;ru_p&quot;                    type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;ru_save&quot;                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;/&gt;
+
+                &lt;var name=&quot;rw&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;   streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;rw_p&quot;                    type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;   streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;rw_save&quot;                 type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;/&gt;
+
+                &lt;var name=&quot;rtheta_p&quot;                type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;rtheta_pp&quot;               type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;rtheta_p_save&quot;           type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;rtheta_pp_old&quot;           type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+
+                &lt;var name=&quot;rho_p&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;rho_pp&quot;                  type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;rho_p_save&quot;              type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+
+                &lt;var name=&quot;kdiff&quot;                   type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+
+                &lt;var name=&quot;surface_pressure&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;iro&quot;/&gt;
+
+                &lt;var name=&quot;temperature_200hPa&quot;     type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;temperature_500hPa&quot;     type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;temperature_850hPa&quot;     type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;height_200hPa&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;height_500hPa&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;height_850hPa&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uzonal_200hPa&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uzonal_500hPa&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uzonal_850hPa&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;umeridional_200hPa&quot;     type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;umeridional_500hPa&quot;     type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;umeridional_850hPa&quot;     type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;w_200hPa&quot;               type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;w_500hPa&quot;               type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;w_850hPa&quot;               type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;vorticity_200hPa&quot;       type=&quot;real&quot;     dimensions=&quot;nVertices Time&quot;              streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;vorticity_500hPa&quot;       type=&quot;real&quot;     dimensions=&quot;nVertices Time&quot;              streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;vorticity_850hPa&quot;       type=&quot;real&quot;     dimensions=&quot;nVertices Time&quot;              streams=&quot;o&quot;/&gt;
+        &lt;/var_struct&gt;
+
+        &lt;var_struct name=&quot;tend&quot; time_levs=&quot;1&quot;&gt;
+
+                
+                &lt;!-- tendencies for prognostic variables --&gt;
+                &lt;var name=&quot;tend_u&quot;             name_in_code=&quot;u&quot;           type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;tend_w&quot;             name_in_code=&quot;w&quot;           type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;   streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;tend_rho&quot;           name_in_code=&quot;rho_zz&quot;      type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;tend_theta&quot;         name_in_code=&quot;theta_m&quot;     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;rt_diabatic_tend&quot;                              type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;euler_tend_u&quot;       name_in_code=&quot;u_euler&quot;     type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;/&gt;
+                &lt;var name=&quot;euler_tend_w&quot;       name_in_code=&quot;w_euler&quot;     type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;/&gt;
+                &lt;var name=&quot;euler_tend_theta&quot;   name_in_code=&quot;theta_euler&quot; type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+
+                &lt;!-- scalar tendencies --&gt;
+                &lt;var_array name=&quot;scalars&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot;&gt;
+                        &lt;var name=&quot;tend_qv&quot;    name_in_code=&quot;qv&quot;        array_group=&quot;moist&quot;       streams=&quot;o&quot;/&gt;
+                        &lt;var name=&quot;tend_qc&quot;    name_in_code=&quot;qc&quot;        array_group=&quot;moist&quot;       streams=&quot;o&quot;/&gt;
+                        &lt;var name=&quot;tend_qr&quot;    name_in_code=&quot;qr&quot;        array_group=&quot;moist&quot;       streams=&quot;o&quot;/&gt;
+                        &lt;var name=&quot;tend_qi&quot;    name_in_code=&quot;qi&quot;        array_group=&quot;moist&quot;       streams=&quot;o&quot;/&gt;
+                        &lt;var name=&quot;tend_qs&quot;    name_in_code=&quot;qs&quot;        array_group=&quot;moist&quot;       streams=&quot;o&quot;/&gt;
+                        &lt;var name=&quot;tend_qg&quot;    name_in_code=&quot;qg&quot;        array_group=&quot;moist&quot;       streams=&quot;o&quot;/&gt;
+                        &lt;var name=&quot;tend_qnr&quot;   name_in_code=&quot;qnr&quot;       array_group=&quot;number&quot;      streams=&quot;o&quot;/&gt;
+                        &lt;var name=&quot;tend_qni&quot;   name_in_code=&quot;qni&quot;       array_group=&quot;number&quot;      streams=&quot;o&quot;/&gt;
+                &lt;/var_array&gt;
+        &lt;/var_struct&gt;
+
+
+
+&lt;!-- ================================================================================================== --&gt;
+&lt;!--  DECLARATIONS OF ALL PHYSICS VARIABLES (will need to be moved to a Physics Registry shared by the  --&gt;
+&lt;!--  hydrostatic and non-hydrostatic dynamical cores):                                                 --&gt;
+&lt;!-- ================================================================================================== --&gt;
+
+
+        &lt;nml_record name=&quot;physics&quot;&gt;
+                &lt;!-- NAMELIST VARIABLES ADDED FOR INITIALIZATION OF SURFACE CHARACTERISTICS: --&gt;
+                &lt;nml_option name=&quot;input_landuse_data&quot;                type=&quot;character&quot;     default_value=&quot;USGS&quot;/&gt;
+                &lt;nml_option name=&quot;input_soil_data&quot;                   type=&quot;character&quot;     default_value=&quot;STAS&quot;/&gt;
+                &lt;nml_option name=&quot;input_soil_temperature_lag&quot;        type=&quot;integer&quot;       default_value=&quot;140&quot;/&gt;
+                &lt;nml_option name=&quot;num_soil_layers&quot;                   type=&quot;integer&quot;       default_value=&quot;4&quot;/&gt;
+                &lt;nml_option name=&quot;months&quot;                            type=&quot;integer&quot;       default_value=&quot;12&quot;/&gt;
+
+                &lt;!-- ... DIMENSION NEEDED FOR OZONE AND AEROSOLS CONCENTRATIONS IN THE CAM LONGWAVE AND SHORTWAVE --&gt;
+                &lt;!-- ... RADIATION PARAMETERIZATIONS.                                                             --&gt;
+                &lt;nml_option name=&quot;noznlev&quot;                           type=&quot;integer&quot;       default_value=&quot;59&quot;/&gt;
+                &lt;nml_option name=&quot;naerlev&quot;                           type=&quot;integer&quot;       default_value=&quot;29&quot;/&gt;
+                &lt;nml_option name=&quot;camdim1&quot;                           type=&quot;integer&quot;       default_value=&quot;4&quot;/&gt;
+
+                &lt;!-- NAMELIST VARIABLES ADDED FOR PHYSICS CONFIGURATION: --&gt;
+                &lt;nml_option name=&quot;config_frac_seaice&quot;                type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_sfc_albedo&quot;                 type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_sfc_snowalbedo&quot;             type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_sst_update&quot;                 type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_sstdiurn_update&quot;            type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_deepsoiltemp_update&quot;        type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+
+                &lt;nml_option name=&quot;config_n_physics&quot;                  type=&quot;integer&quot;       default_value=&quot;1&quot;/&gt;
+                &lt;nml_option name=&quot;config_n_microp&quot;                   type=&quot;integer&quot;       default_value=&quot;1&quot;/&gt;
+                &lt;nml_option name=&quot;config_n_conv&quot;                     type=&quot;integer&quot;       default_value=&quot;1&quot;/&gt;
+                &lt;nml_option name=&quot;config_n_pbl&quot;                      type=&quot;integer&quot;       default_value=&quot;1&quot;/&gt;
+                &lt;nml_option name=&quot;config_n_lsm&quot;                      type=&quot;integer&quot;       default_value=&quot;1&quot;/&gt;
+                &lt;nml_option name=&quot;config_n_eddy&quot;                     type=&quot;integer&quot;       default_value=&quot;1&quot;/&gt;
+                &lt;nml_option name=&quot;config_n_radt_lw&quot;                  type=&quot;integer&quot;       default_value=&quot;1&quot;/&gt;
+                &lt;nml_option name=&quot;config_n_radt_sw&quot;                  type=&quot;integer&quot;       default_value=&quot;1&quot;/&gt;
+
+                &lt;nml_option name=&quot;config_radtlw_interval&quot;            type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+                &lt;nml_option name=&quot;config_radtsw_interval&quot;            type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+                &lt;nml_option name=&quot;config_conv_interval&quot;              type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+                &lt;nml_option name=&quot;config_pbl_interval&quot;               type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+                &lt;nml_option name=&quot;config_camrad_abs_update&quot;          type=&quot;character&quot;     default_value=&quot;06:00:00&quot;/&gt;
+                &lt;nml_option name=&quot;config_greeness_update&quot;            type=&quot;character&quot;     default_value=&quot;24:00:00&quot;/&gt;
+                &lt;nml_option name=&quot;config_bucket_update&quot;              type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+
+                &lt;nml_option name=&quot;config_microp_scheme&quot;              type=&quot;character&quot;     default_value=&quot;off&quot;/&gt;
+                &lt;nml_option name=&quot;config_conv_shallow_scheme&quot;        type=&quot;character&quot;     default_value=&quot;off&quot;/&gt;
+                &lt;nml_option name=&quot;config_conv_deep_scheme&quot;           type=&quot;character&quot;     default_value=&quot;off&quot;/&gt;
+                &lt;nml_option name=&quot;config_eddy_scheme&quot;                type=&quot;character&quot;     default_value=&quot;off&quot;/&gt;
+                &lt;nml_option name=&quot;config_lsm_scheme&quot;                 type=&quot;character&quot;     default_value=&quot;off&quot;/&gt;
+                &lt;nml_option name=&quot;config_pbl_scheme&quot;                 type=&quot;character&quot;     default_value=&quot;off&quot;/&gt;
+                &lt;nml_option name=&quot;config_gwdo_scheme&quot;                type=&quot;character&quot;     default_value=&quot;off&quot;/&gt;
+                &lt;nml_option name=&quot;config_radt_cld_scheme&quot;            type=&quot;character&quot;     default_value=&quot;off&quot;/&gt;
+                &lt;nml_option name=&quot;config_radt_lw_scheme&quot;             type=&quot;character&quot;     default_value=&quot;off&quot;/&gt;
+                &lt;nml_option name=&quot;config_radt_sw_scheme&quot;             type=&quot;character&quot;     default_value=&quot;off&quot;/&gt;
+                &lt;nml_option name=&quot;config_sfclayer_scheme&quot;            type=&quot;character&quot;     default_value=&quot;off&quot;/&gt;
+
+                &lt;nml_option name=&quot;config_bucket_radt&quot;                type=&quot;real&quot;          default_value=&quot;0.0_RKIND&quot;/&gt;
+                &lt;nml_option name=&quot;config_bucket_rainc&quot;               type=&quot;real&quot;          default_value=&quot;0.0_RKIND&quot;/&gt;
+                &lt;nml_option name=&quot;config_bucket_rainnc&quot;              type=&quot;real&quot;          default_value=&quot;0.0_RKIND&quot;/&gt;
+        &lt;/nml_record&gt;
+
+        &lt;var_struct name=&quot;diag_physics&quot; time_levs=&quot;1&quot;&gt;
+
+                &lt;!-- ================================================================================================= --&gt;
+                &lt;!-- ... ARRAYS AND VARIABLES FOR UPDATING THE DEEP SOIL TEMPERATURE:                                  --&gt;
+                &lt;!-- ================================================================================================= --&gt;
+                &lt;!-- nsteps_accum: number of accumulated time-step in a day.                                           --&gt;
+                &lt;!-- ndays_accum : number of accumulated days in a year.                                               --&gt;
+                &lt;!-- tlag        : daily mean surface temperature of prior days                                    [K] --&gt;
+                &lt;!-- tday_accum  : accumulated daily surface temperature for current day                           [K] --&gt;
+                &lt;!-- tyear_mean  : annual mean surface temperature                                                 [K] --&gt;
+                &lt;!-- tyear_accum : accumulated yearly surface temperature for current year                         [K] --&gt;
+
+                &lt;var name=&quot;nsteps_accum&quot;  type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;ndays_accum&quot;   type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;r&quot;/&gt;
+
+                &lt;var name=&quot;tlag&quot;          type=&quot;real&quot;     dimensions=&quot;nLags nCells Time&quot;           streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;tday_accum&quot;    type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;tyear_mean&quot;    type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;r&quot;/&gt;
+                &lt;var name=&quot;tyear_accum&quot;   type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;r&quot;/&gt;
+
+
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- ... PARAMETERIZATION OF CLOUD MICROPHYSICS:                                                        --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- i_rainnc  : counter related to how often rainnc is being reset relative to its bucket value   (-)  --&gt;
+                &lt;!-- rainnc    : accumulated total time-step grid-scale precipitation                             (mm)  --&gt;
+                &lt;!-- rainncv   : time-step total grid-scale precipitation                                         (mm)  --&gt;
+                &lt;!-- snownc    : accumulated grid-scale precipitation of snow                                     (mm)  --&gt;
+                &lt;!-- snowncv   : time-step grid-scale precipitation of snow                                       (mm)  --&gt;
+                &lt;!-- graupelnc : accumulated grid-scale precipitation of graupel                                  (mm)  --&gt;
+                &lt;!-- graupelncv: time-step grid-scale precipitation of graupel                                    (mm)  --&gt;
+                &lt;!-- sr        : time-step ratio of frozen versus total grid-scale precipitation                   (-)  --&gt;
+                &lt;!-- precipw   : precipitable water                                                            (kg/m2) --&gt;
+                &lt;!-- refl10cm_max: maximum column reflectivity                                                   (dBz) --&gt;
+
+                &lt;var name=&quot;refl10cm_max&quot;  type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+
+                &lt;var name=&quot;i_rainnc&quot;      type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;sr&quot;            type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rainncv&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;snowncv&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;graupelncv&quot;    type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+
+                &lt;var name=&quot;rainnc&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;snownc&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;graupelnc&quot;     type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+
+                &lt;var name=&quot;precipw&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;qsat&quot;          type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;relhum&quot;        type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- ... PARAMETERIZATION OF CONVECTION:                                                                --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- i_rainc   : counter related to how often rainc is begin reset relative to its bucket value    (-)  --&gt;
+                &lt;!-- cuprec    : convective precipitation rate                                                  (mm/s)  --&gt;
+                &lt;!-- rainc     : accumulated time-step convective precipitation                                   (mm)  --&gt;
+                &lt;!-- raincv    : time-step convective precipitation                                               (mm)  --&gt;
+
+                &lt;var name=&quot;i_rainc&quot;       type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;cuprec&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rainc&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;raincv&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+
+                &lt;!-- ... KAIN_FRITSCH:                                                                                 --&gt;
+                &lt;!-- cubot     : lowest level of convection                                                        (-) --&gt;
+                &lt;!-- cutop     : highest level of convection                                                       (-) --&gt;
+                &lt;!-- nca       : relaxation time for KF parameterization of convection                             (s) --&gt;
+                &lt;!-- wavg0     : average vertical velocity (KF scheme only)                                    (m s-1) --&gt;
+
+                &lt;var name=&quot;nca&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;cubot&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;cutop&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;w0avg&quot;         type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+
+
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- ... PARAMETERIZATION OF PLANETARY BOUNDARY LAYER PROCESSES:                                        --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- kpbl      : index of PBL top                                                                  (-)  --&gt;
+                &lt;!-- hpbl      : PBL height                                                                        (m)  --&gt;
+                &lt;!-- exch_h    : exchange coefficient                                                              (-)  --&gt;
+
+                &lt;var name=&quot;kpbl&quot;          type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;hpbl&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;exch_h&quot;        type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+
+                &lt;!-- TEMPORARY: --&gt;
+                &lt;var name=&quot;kzh&quot;                               type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;kzm&quot;                               type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;kzq&quot;                               type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+
+
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- ... PARAMETERIZATION OF SURFACE LAYER PROCESSES:                                                   --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!--  br        :bulk richardson number                                                             [-] --&gt;
+                &lt;!--  cd        :drag coefficient at 10m                                                            [-] --&gt;
+                &lt;!--  cda       :drag coefficient at lowest model level                                             [-] --&gt;
+                &lt;!--  chs       :???                                                                                    --&gt;
+                &lt;!--  chs2      :???                                                                                    --&gt;
+                &lt;!--  cqs2      :???                                                                                    --&gt;
+                &lt;!--  ck        :enthalpy exchange coefficient at 10 m                                              [-] --&gt;
+                &lt;!--  cka       :enthalpy exchange coefficient at lowest model level                                [-] --&gt;
+                &lt;!--  cpm       :???                                                                                    --&gt;
+                &lt;!--  flhc      :exchange coefficient for heat                                                      [-] --&gt;
+                &lt;!--  flqc      :exchange coefficient for moisture                                                  [-] --&gt;
+                &lt;!--  gz1oz0    :log of z1 over z0                                                                  [-] --&gt;
+                &lt;!--  hfx       :upward heat flux at the surface                                               [W/m2/s] --&gt;
+                &lt;!--  lh        :latent heat flux at the surface                                                 [W/m2] --&gt;
+                &lt;!--  mavail    :surface moisture availability                                                      [-] --&gt;
+                &lt;!--  mol       :T* in similarity theory                                                            [K] --&gt;
+                &lt;!--  psih      :similarity theory for heat                                                         [-] --&gt;
+                &lt;!--  psim      :similarity theory for momentum                                                     [-] --&gt;
+                &lt;!--  qfx       :upward moisture flux at the surface                                          [kg/m2/s] --&gt;
+                &lt;!--  qgh       :???                                                                                    --&gt;
+                &lt;!--  qsfc      :specific humidity at lower boundary                                            [kg/kg] --&gt;
+                &lt;!--  regime    :flag indicating PBL regime (stable_p,unstable_p,etc...)                            [-] --&gt;
+                &lt;!--  rmol      :1 / Monin Ob length                                                                [-] --&gt;
+                &lt;!--  ust       :u* in similarity theory                                                          [m/s] --&gt;
+                &lt;!--  ustm      :u* in similarity theory without vconv                                            [m/s] --&gt;
+                &lt;!--  zol       :z/L height over Monin-Obukhov length                                               [-] --&gt;
+                &lt;!--  znt       :time-varying roughness length                                                      [m] --&gt;
+                &lt;!--  wspd      :wind speed                                                                       [m/s] --&gt;
+                &lt;!--  DIAGNOSTICS:                                                                                      --&gt;
+                &lt;!--  q2        :specific humidity at 2m                                                        [kg/kg] --&gt;
+                &lt;!--  u10       :u at 10 m                                                                        [m/s] --&gt;
+                &lt;!--  v10       :v at 10 m                                                                        [m/s] --&gt;
+                &lt;!--  t2m       :temperature at 2m                                                                  [K] --&gt;
+                &lt;!--  th2m      :potential temperature at 2m                                                        [K] --&gt;
+                &lt;var name=&quot;hfx&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;mavail&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;mol&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;qfx&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;qsfc&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;ust&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;ustm&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;zol&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;znt&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+
+                &lt;var name=&quot;br&quot;            type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;cd&quot;            type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;cda&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;chs&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;chs2&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;cqs2&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;ck&quot;            type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;cka&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;cpm&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;flhc&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;flqc&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;gz1oz0&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;lh&quot;            type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;psim&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;psih&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;qgh&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;regime&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rmol&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;wspd&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+
+                &lt;!-- DIAGNOSTICS: --&gt;
+                &lt;var name=&quot;u10&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;v10&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;q2&quot;            type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;t2m&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;th2m&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+
+
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- ... PARAMETERIZATION OF GRAVITY WAVE DRAG OVER OROGRAPHY:                                          --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+
+                &lt;!--  dusfcg     : vertically-integrated gravity wave drag over orography u-stress           (Pa m s-1) --&gt;
+                &lt;!--  dvsfcg     : vertically-integrated gravity wave drag over orography v-stress           (Pa m s-1) --&gt;
+                &lt;!--  dtaux3d    : gravity wave drag over orography u-stress                                    (m s-1) --&gt;
+                &lt;!--  dtauy3d    : gravity wave drag over orography v-stress                                    (m s-1) --&gt;
+
+                &lt;var name=&quot;dusfcg&quot;                            type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;dvsfcg&quot;                            type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;dtaux3d&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;dtauy3d&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+
+                &lt;var name=&quot;rubldiff&quot;                          type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rvbldiff&quot;                          type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+
+
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- ... PARAMETERIZATION OF SHORTWAVE RADIATION:                                                       --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!--  coszr     :cosine of the solar zenith angle                                                   [-] --&gt;
+                &lt;!--  gsw       :net shortwave flux at surface                                                  [W m-2] --&gt;
+                &lt;!--  swcf      :shortwave cloud forcing at top-of-atmosphere                                   [W m-2] --&gt;
+                &lt;!--  swdnb     :all-sky downwelling shortwave flux at bottom-of-atmosphere                     [W m-2] --&gt;
+                &lt;!--  swdnbc    :clear-sky downwelling shortwave flux at bottom-of-atmosphere                   [W m-2] --&gt;
+                &lt;!--  swdnt     :all-sky downwelling shortwave flux at top-of-atmosphere                        [W m-2] --&gt;
+                &lt;!--  swdntc    :clear-sky downwelling shortwave flux at top-of-atmosphere                      [W m-2] --&gt;
+                &lt;!--  swupb     :all-sky upwelling shortwave flux at bottom-of-atmosphere                       [W m-2] --&gt;
+                &lt;!--  swupbc    :clear-sky upwelling shortwave flux at bottom-of-atmosphere                     [W m-2] --&gt;
+                &lt;!--  swupt     :all-sky upwelling shortwave flux at top-of-atmosphere                          [W m-2] --&gt;
+                &lt;!--  swuptc    :clear-sky upwelling shortwave flux at top-of-atmosphere                        [W m-2] --&gt;
+                &lt;!--  acswdnb   :accumulated all-sky downwelling shortwave flux at bottom-of-atmosphere         [J m-2] --&gt;
+                &lt;!--  acswdnbc  :accumulated clear-sky downwelling shortwave flux at bottom-of-atmosphere       [J m-2] --&gt;
+                &lt;!--  acswdnt   :accumulated all-sky downwelling shortwave flux at top-of-atmosphere            [J m-2] --&gt;
+                &lt;!--  acswdntc  :accumulated clear-sky downwelling shortwave flux at top-of-atmosphere          [J m-2] --&gt;
+                &lt;!--  acswupb   :accumulated all-sky upwelling shortwave flux at bottom-of-atmosphere           [J m-2] --&gt;
+                &lt;!--  acswupbc  :accumulated clear-sky upwelling shortwave flux at bottom-of-atmosphere         [J m-2] --&gt;
+                &lt;!--  acswupt   :accumulated all-sky upwelling shortwave flux at top-of-atmosphere              [J m-2] --&gt;
+                &lt;!--  acswuptc  :accumulated clear-sky upwelling shortwave flux at top-of-atmosphere            [J m-2] --&gt;
+                &lt;!--  swdnflx   :                                                                                       --&gt;
+                &lt;!--  swdnflxc  :                                                                                       --&gt;
+                &lt;!--  swupflx   :                                                                                       --&gt;
+                &lt;!--  swupflxc  :                                                                                       --&gt;
+
+                &lt;!--  i_acswdnb : counter related to how often swdnb is begin reset relative to its bucket value    (-) --&gt;
+                &lt;!--  i_acswdnbc: counter related to how often swdnbc is begin reset relative to its bucket value   (-) --&gt;
+                &lt;!--  i_acswdnt : counter related to how often swdnt is begin reset relative to its bucket value    (-) --&gt;
+                &lt;!--  i_acswdntc: counter related to how often swdntc is begin reset relative to its bucket value   (-) --&gt;
+                &lt;!--  i_acswupb : counter related to how often swupb is begin reset relative to its bucket value    (-) --&gt;
+                &lt;!--  i_acswupbc: counter related to how often swupbc is begin reset relative to its bucket value   (-) --&gt;
+                &lt;!--  i_acswupt : counter related to how often swupt is begin reset relative to its bucket value    (-) --&gt;
+                &lt;!--  i_acswuptc: counter related to how often swuptc is begin reset relative to its bucket value   (-) --&gt;
+
+                &lt;var name=&quot;i_acswdnb&quot;     type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;i_acswdnbc&quot;    type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;i_acswdnt&quot;     type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;i_acswdntc&quot;    type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;i_acswupb&quot;     type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;i_acswupbc&quot;    type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;i_acswupt&quot;     type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;i_acswuptc&quot;    type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+
+                &lt;var name=&quot;coszr&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;swcf&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;swdnb&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;swdnbc&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;swdnt&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;swdntc&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;swupb&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;swupbc&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;swupt&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;swuptc&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;acswdnb&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;acswdnbc&quot;      type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;acswdnt&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;acswdntc&quot;      type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;acswupb&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;acswupbc&quot;      type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;acswupt&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;acswuptc&quot;      type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;gsw&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+
+                &lt;!-- RRTMG SW ONLY: --&gt;
+                &lt;var name=&quot;swdnflx&quot;       type=&quot;real&quot;     dimensions=&quot;nVertLevelsP2 nCells Time&quot;   streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;swdnflxc&quot;      type=&quot;real&quot;     dimensions=&quot;nVertLevelsP2 nCells Time&quot;   streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;swupflx&quot;       type=&quot;real&quot;     dimensions=&quot;nVertLevelsP2 nCells Time&quot;   streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;swupflxc&quot;      type=&quot;real&quot;     dimensions=&quot;nVertLevelsP2 nCells Time&quot;   streams=&quot;o&quot;/&gt;
+
+
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- ... PARAMETERIZATION OF LONGWAVE RADIATION:                                                        --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+
+                &lt;!--  note: glw is the same diagnostic as lwdnb and is used in the land-surface scheme for the calcula- --&gt;
+                &lt;!--        tion of the surface budget. glw is always an output argument to the subroutine rrtmg_lwrad. --&gt;
+                &lt;!--        in contrast,lwdnb is an optional ouput argument to the subroutine rrtmg_lwrad depending on  --&gt;
+                &lt;!--        the presence of lwupt (or not).                                                             --&gt;
+
+                &lt;!--  glw       :all-sky downwelling longwave flux at bottom-of-atmosphere                      [W m-2] --&gt;
+                &lt;!--  lwcf      :longwave cloud forcing at top-of-atmosphere                                    [W m-2] --&gt;
+                &lt;!--  lwdnb     :all-sky downwelling longwave flux at bottom-of-atmosphere                      [W m-2] --&gt;
+                &lt;!--  lwdnbc    :clear-sky downwelling longwave flux at bottom-of-atmosphere                    [W m-2] --&gt;
+                &lt;!--  lwdnt     :all-sky downwelling longwave flux at top-of-atmosphere                         [W m-2] --&gt;
+                &lt;!--  lwdntc    :clear-sky downwelling longwave flux at top-of-atmosphere                       [W m-2] --&gt;
+                &lt;!--  lwupb     :all-sky upwelling longwave flux at bottom-of-atmosphere                        [W m-2] --&gt;
+                &lt;!--  lwupbc    :clear-sky upwelling longwave flux at bottom-of-atmosphere                      [W m-2] --&gt;
+                &lt;!--  lwupt     :all-sky upwelling longwave flux at top-of-atmosphere                           [W m-2] --&gt;
+                &lt;!--  lwuptc    :clear-sky upwelling longwave flux at top-of-atmosphere                         [W m-2] --&gt;
+                &lt;!--  aclwdnb   :accumulated all-sky downwelling longwave flux at bottom-of-atmosphere          [J m-2] --&gt;
+                &lt;!--  aclwdnbc  :accumulated clear-sky downwelling longwave flux at bottom-of-atmosphere        [J m-2] --&gt;
+                &lt;!--  aclwdnt   :accumulated all-sky downwelling longwave flux at top-of-atmosphere             [J m-2] --&gt;
+                &lt;!--  aclwdntc  :accumulated clear-sky downwelling longwave flux at top-of-atmosphere           [J m-2] --&gt;
+                &lt;!--  aclwupb   :accumulated all-sky upwelling longwave flux at bottom-of-atmosphere            [J m-2] --&gt;
+                &lt;!--  aclwupbc  :accumulated clear-sky upwelling longwave flux at bottom-of-atmosphere          [J m-2] --&gt;
+                &lt;!--  aclwupt   :accumulated all-sky upwelling longwave flux at top-of-atmosphere               [J m-2] --&gt;
+                &lt;!--  aclwuptc  :accumulated clear-sky upwelling longwave flux at top-of-atmosphere             [J m-2] --&gt;
+                &lt;!--  lwdnflx   :                                                                                       --&gt;
+                &lt;!--  lwdnflxc  :                                                                                       --&gt;
+                &lt;!--  lwupflx   :                                                                                       --&gt;
+                &lt;!--  lwupflxc  :                                                                                       --&gt;
+                &lt;!--  olrtoa    :outgoing longwave radiation at top-of-the-atmosphere                           [W m-2] --&gt;
+
+                &lt;!--  i_aclwdnb : counter related to how often lwdnb is begin reset relative to its bucket value    (-) --&gt;
+                &lt;!--  i_aclwdnbc: counter related to how often lwdnbc is begin reset relative to its bucket value   (-) --&gt;
+                &lt;!--  i_aclwdnt : counter related to how often lwdnt is begin reset relative to its bucket value    (-) --&gt;
+                &lt;!--  i_aclwdntc: counter related to how often lwdntc is begin reset relative to its bucket value   (-) --&gt;
+                &lt;!--  i_aclwupb : counter related to how often lwupb is begin reset relative to its bucket value    (-) --&gt;
+                &lt;!--  i_aclwupbc: counter related to how often lwupbc is begin reset relative to its bucket value   (-) --&gt;
+                &lt;!--  i_aclwupt : counter related to how often lwupt is begin reset relative to its bucket value    (-) --&gt;
+                &lt;!--  i_aclwuptc: counter related to how often lwuptc is begin reset relative to its bucket value   (-) --&gt;
+
+                &lt;var name=&quot;i_aclwdnb&quot;     type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;i_aclwdnbc&quot;    type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;i_aclwdnt&quot;     type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;i_aclwdntc&quot;    type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;i_aclwupb&quot;     type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;i_aclwupbc&quot;    type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;i_aclwupt&quot;     type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;i_aclwuptc&quot;    type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+
+                &lt;var name=&quot;lwcf&quot;          type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;lwdnb&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;lwdnbc&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;lwdnt&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;lwdntc&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;lwupb&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;lwupbc&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;lwupt&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;lwuptc&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;aclwdnb&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;aclwdnbc&quot;      type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;aclwdnt&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;aclwdntc&quot;      type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;aclwupb&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;aclwupbc&quot;      type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;aclwupt&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;aclwuptc&quot;      type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;olrtoa&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;glw&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+
+                &lt;!-- ... RRTMG LW ONLY: --&gt;
+                &lt;!-- var name=&quot;lwdnflx&quot;       type=&quot;real&quot;     dimensions=&quot;nVertLevelsP2 nCells Time&quot;   streams=&quot;o&quot; --&gt;
+                &lt;!-- var name=&quot;lwdnflxc&quot;      type=&quot;real&quot;     dimensions=&quot;nVertLevelsP2 nCells Time&quot;   streams=&quot;o&quot; --&gt;
+                &lt;!-- var name=&quot;lwupflx&quot;       type=&quot;real&quot;     dimensions=&quot;nVertLevelsP2 nCells Time&quot;   streams=&quot;o&quot; --&gt;
+                &lt;!-- var name=&quot;lwupflxc&quot;      type=&quot;real&quot;     dimensions=&quot;nVertLevelsP2 nCells Time&quot;   streams=&quot;o&quot; --&gt;
+
+
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- ... ADDITIONAL &quot;RADIATION&quot; ARRAYS NEEDED ONLY IN THE &quot;CAM&quot; LW AND SW RADIATION CODES:              --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+
+                &lt;!-- INFRARED ABSORPTION: --&gt;
+                &lt;var name=&quot;absnxt&quot;        type=&quot;real&quot;     dimensions=&quot;nVertLevels cam_dim1 nCells Time&quot;/&gt;
+                &lt;var name=&quot;abstot&quot;        type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nVertLevelsP1 nCells Time&quot;/&gt;
+                &lt;var name=&quot;emstot&quot;        type=&quot;real&quot;     dimensions=&quot;nVertLevelsP1 nCells Time&quot;/&gt;
+
+
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- ... PARAMERIZATION OF CLOUDINESS:                                                                  --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;var name=&quot;cldfrac&quot;       type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+
+
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- ... PARAMETERIZATION OF LAND-SURFACE SCHEME:                                                       --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+
+                &lt;!-- acsnom         :accumulated melted snow                                                   [kg m-2] --&gt;
+                &lt;!-- acsnow         :accumulated snow                                                          [kg m-2] --&gt;
+                &lt;!-- canwat         :canopy water                                                              [kg m-2] --&gt;
+                &lt;!-- chklowq        :surface saturation flag                                                        [-] --&gt;
+                &lt;!-- grdflx         :ground heat flux                                                           [W m-2] --&gt;
+                &lt;!-- lai            :leaf area index                                                                [-] --&gt;
+                &lt;!-- noahres        :residual of the noah land-surface scheme energy budget                     [W m-2] --&gt;
+                &lt;!-- potevp         :potential evaporation                                                      [W m-2] --&gt;
+                &lt;!-- qz0            :specific humidity at znt                                                 [kg kg-1] --&gt;
+                &lt;!-- sfc_albedo     :surface albedo                                                                 [-] --&gt;
+                &lt;!-- sfc_embck      :background emissivity                                                          [-] --&gt;
+                &lt;!-- sfc_emiss      :surface emissivity                                                             [-] --&gt;
+                &lt;!-- sfcrunoff      :surface runoff                                                             [m s-1] --&gt;
+                &lt;!-- smstav         :moisture availability                                                          [-] --&gt;
+                &lt;!-- smstot         :total moisture                                                            [m3 m-3] --&gt;
+                &lt;!-- snopcx         :snow phase change heat flux                                                [W m-2] --&gt;
+                &lt;!-- snotime        :??                                                                                 --&gt;
+                &lt;!-- sstsk          : skin sea-surface temperature                                                  [K] --&gt;
+                &lt;!-- sstsk_dtc      : skin sea-surface temperature cooling                                          [K] --&gt;
+                &lt;!-- sstsk_dtw      : skin sea-surface temperature warming                                          [K] --&gt;
+                &lt;!-- thc            :thermal inertia                                               [Cal cm-1 K-1 s-0.5] --&gt;
+                &lt;!-- udrunoff       :sub-surface runoff                                                         [m s-1] --&gt;
+                &lt;!-- xicem          :ice mask from previous time-step                                               [-] --&gt;
+                &lt;!-- z0             :background roughness length                                                    [m] --&gt;
+                &lt;!-- zs             :depth of centers of soil layers                                                [m] --&gt;
+
+                &lt;var name=&quot;acsnom&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;acsnow&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;canwat&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;chklowq&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;grdflx&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;lai&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;noahres&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;potevp&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;qz0&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;sfc_albedo&quot;    type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;sfc_emiss&quot;     type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;sfc_emibck&quot;    type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;sfcrunoff&quot;     type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;smstav&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;smstot&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;snopcx&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;snotime&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;sstsk&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;sstsk_dtc&quot;     type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;sstsk_dtw&quot;     type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;thc&quot;           type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;udrunoff&quot;      type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;xicem&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;z0&quot;            type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;zs&quot;            type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+        &lt;/var_struct&gt;
+
+        &lt;var_struct name=&quot;tend_physics&quot; time_levs=&quot;1&quot;&gt;

+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- TENDENCIES FROM PARAMETERIZATION OF CONVECTION:                                                    --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- rthcuten  : tendency of potential temperature due to cumulus convection                   (K s-1)  --&gt;
+                &lt;!-- rqvcuten  : tendency of water vapor mixing ratio due to cumulus convection            (kg/kg s-1)  --&gt;
+                &lt;!-- rqccuten  : tendency of cloud water mixing ratio due to cumulus convection            (kg/kg s-1)  --&gt;
+                &lt;!-- rqicuten  : tendency of cloud ice mixing ratio due to cumulus convection              (kg/kg s-1)  --&gt;
+
+                &lt;var name=&quot;rthcuten&quot;    type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rqvcuten&quot;    type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rqccuten&quot;    type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rqicuten&quot;    type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+
+                &lt;!-- KAIN_FRITSCH --&gt;
+                &lt;!-- rqrcuten  : tendency of rain mixing ratio due to cumulus convection                   (kg/kg s-1) --&gt;
+                &lt;!-- rqscuten  : tendency of snow mixing ratio due to cumulus convection                   (kg/kg s-1) --&gt;
+
+                &lt;var name=&quot;rqrcuten&quot;    type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rqscuten&quot;    type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+
+                &lt;!-- TIEDTKE --&gt;
+                &lt;!-- rucuten   : tendency of zonal wind due to cumulus convection                              (m/s-1) --&gt;
+                &lt;!-- rvcuten   : tendency of meridional wind due to cumulus convection                         (m/s-1) --&gt;
+                &lt;!-- rqvdynten : tendency of water vapor due to horizontal and vertical advections         (kg/kg/s-1) --&gt;
+                &lt;var name=&quot;rqvdynten&quot;   type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rucuten&quot;     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rvcuten&quot;     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+
+
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- ... TENDENCIES FROM PARAMETERIZATION OF PLANETARY BOUNDARY LAYER PROCESSES:                        --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- rublten   : tendency of zonal wind due to pbl processes                                   (m s-1)  --&gt;
+                &lt;!-- rvblten   : tendency of meridional wind due to pbl processes                              (m s-1)  --&gt;
+                &lt;!-- rthblten  : tendency of potential temperature due to pbl processes                        (K s-1)  --&gt;
+                &lt;!-- rqvblten  : tendency of water vapor mixing ratio due to pbl processes                 (kg/kg s-1)  --&gt;
+                &lt;!-- rqcblten  : tendency of cloud water mixing ratio due to pbl processes                 (kg/kg s-1)  --&gt;
+                &lt;!-- rqiblten  : tendency of cloud ice mixing ratio due to pbl processes                   (kg/kg s-1)  --&gt;
+
+                &lt;var name=&quot;rublten&quot;     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rvblten&quot;     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rthblten&quot;    type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rqvblten&quot;    type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rqcblten&quot;    type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rqiblten&quot;    type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+
+
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- ... TENDENCIES FROM PARAMETERIZATION OF LONGWAVE RADIATION:                                        --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!--  rthratensw:uncoupled theta tendency due to shortwave radiation                            [K s-1] --&gt;
+                &lt;!--  rthratenlw:uncoupled theta tendency due to longwave radiation                             [K s-1] --&gt;
+
+                &lt;var name=&quot;rthratensw&quot;  type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;rthratenlw&quot;  type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+        &lt;/var_struct&gt;
+
+        &lt;var_struct name=&quot;sfc_input&quot; time_levs=&quot;0&quot;&gt;
+
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- ... SURFACE CHARACTERISTICS THAT NEED TO BE READ FROM GRID.NC:                                     --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+
+                &lt;!--  albedo12m      :monthly climatological albedo                                                 [-] --&gt;
+                &lt;!--  greenfrac      :monthly climatological greeness fraction                                      [-] --&gt;
+                &lt;!--  isltyp         :dominant soil category                                                        [-] --&gt;
+                &lt;!--  ivgtyp         :dominant vegetation category                                                  [-] --&gt;
+                &lt;!--  landmask       :=0 for ocean;=1 for land                                                      [-] --&gt;
+                &lt;!--  sfc_albbck     :background albedo                                                             [-] --&gt;
+                &lt;!--  shdmin         :minimum areal fractional coverage of annual green vegetation                  [-] --&gt;
+                &lt;!--  shdmax         :maximum areal fractional coverage of annual green vegetation                  [-] --&gt;
+                &lt;!--  skintemp       :skin temperature                                                              [K] --&gt;
+                &lt;!--  snoalb         :annual max snow albedo                                                        [-] --&gt;
+                &lt;!--  snow           :snow water equivalent                                                    [kg m-2] --&gt;
+                &lt;!--  sst            :sea-surface temperature                                                       [K] --&gt;
+                &lt;!--  snowc          :flag indicating snow coverage (1 for snow cover)                              [-] --&gt;
+                &lt;!--  snowh          :physical snow depth                                                           [m] --&gt;
+                &lt;!--  ter            :terrain height                                                                [-] --&gt;
+                &lt;!--  tmn            :soil temperature at lower boundary                                            [K] --&gt;
+                &lt;!--  vegfra         :vegetation fraction                                                           [-] --&gt;
+                &lt;!--  seaice         :sea-ice mask (=1 when xice is greater than 0; =0 otherwise)                   [-] --&gt;
+                &lt;!--  xice           :fractional sea-ice coverage                                                   [-] --&gt;
+                &lt;!--  xland          :land mask    (1 for land; 2 for water)                                        [-] --&gt;
+
+                &lt;!--  dzs            :thickness of soil layers                                                      [m] --&gt;
+                &lt;!--  smcrel         :soil moisture threshold below which transpiration begins to stress            [-] --&gt;
+                &lt;!--  sh2o           :soil liquid water                                                        [m3 m-3] --&gt;
+                &lt;!--  smois          :soil moisture                                                            [m3 m-3] --&gt;
+                &lt;!--  tslb           :soil temperature                                                              [K] --&gt;
+
+                &lt;var name=&quot;isltyp&quot;      type=&quot;integer&quot;  dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;ivgtyp&quot;      type=&quot;integer&quot;  dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;landmask&quot;    type=&quot;integer&quot;  dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;shdmin&quot;      type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;shdmax&quot;      type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;snoalb&quot;      type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;ter&quot;         type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;io&quot;/&gt;
+                &lt;var name=&quot;albedo12m&quot;   type=&quot;real&quot;     dimensions=&quot;nMonths nCells&quot;              streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;greenfrac&quot;   type=&quot;real&quot;     dimensions=&quot;nMonths nCells&quot;              streams=&quot;iro&quot;/&gt;
+
+                &lt;var name=&quot;sfc_albbck&quot;  type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;skintemp&quot;    type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;snow&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;snowc&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;snowh&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;sst&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;isro&quot;/&gt;
+                &lt;var name=&quot;tmn&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;vegfra&quot;      type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;seaice&quot;      type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;xice&quot;        type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;isro&quot;/&gt;
+                &lt;var name=&quot;xland&quot;       type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;iro&quot;/&gt;
+
+                &lt;var name=&quot;dzs&quot;         type=&quot;real&quot;     dimensions=&quot;nSoilLevels nCells Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;smcrel&quot;      type=&quot;real&quot;     dimensions=&quot;nSoilLevels nCells Time&quot;     streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;sh2o&quot;        type=&quot;real&quot;     dimensions=&quot;nSoilLevels nCells Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;smois&quot;       type=&quot;real&quot;     dimensions=&quot;nSoilLevels nCells Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;tslb&quot;        type=&quot;real&quot;     dimensions=&quot;nSoilLevels nCells Time&quot;     streams=&quot;iro&quot;/&gt;
+
+                &lt;!-- ================================================================================================== --&gt;
+                &lt;!-- ... PARAMETERIZATION OF GRAVITY WAVE DRAG OVER OROGRAPHY:                                          --&gt;
+                &lt;!-- ================================================================================================== --&gt;
+
+                &lt;!--  var2d      : orographic variance                                                             (m2) --&gt;
+                &lt;!--  con        : orographic convexity                                                            (m2) --&gt;
+                &lt;!--  oa1        : orographic direction asymmetry function                                          (-) --&gt;
+                &lt;!--  oa2        : orographic direction asymmetry function                                          (-) --&gt;
+                &lt;!--  oa3        : orographic direction asymmetry function                                          (-) --&gt;
+                &lt;!--  oa4        : orographic direction asymmetry function                                          (-) --&gt;
+                &lt;!--  ol1        : orographic direction asymmetry function                                          (-) --&gt;
+                &lt;!--  ol2        : orographic direction asymmetry function                                          (-) --&gt;
+                &lt;!--  ol3        : orographic direction asymmetry function                                          (-) --&gt;
+                &lt;!--  ol4        : orographic direction asymmetry function                                          (-) --&gt;
+
+                &lt;var name=&quot;var2d&quot;                             type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;con&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;oa1&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;oa2&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;oa3&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;oa4&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;ol1&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;ol2&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;ol3&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;ol4&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+        &lt;/var_struct&gt;
+&lt;/registry&gt;

Index: branches/atmos_physics/src/core_ocean
===================================================================
--- branches/atmos_physics/src/core_ocean        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean        2013-03-26 23:03:26 UTC (rev 2670)

Property changes on: branches/atmos_physics/src/core_ocean
___________________________________________________________________
Modified: svn:mergeinfo
## -2,15 +2,23 ##
 /branches/ocean_projects/ale_split_exp/src/core_ocean:1437-1483
 /branches/ocean_projects/ale_vert_coord/src/core_ocean:1225-1383
 /branches/ocean_projects/ale_vert_coord_new/src/core_ocean:1387-1428
+/branches/ocean_projects/cesm_coupling/src/core_ocean:2147-2344
+/branches/ocean_projects/comment_cleanup/src/core_ocean:2626-2630
+/branches/ocean_projects/diagnostics_revision/src/core_ocean:2439-2462
+/branches/ocean_projects/explicit_vmix_removal/src/core_ocean:2486-2490
 /branches/ocean_projects/gmvar/src/core_ocean:1214-1514,1517-1738
 /branches/ocean_projects/imp_vert_mix_error/src/core_ocean:1847-1887
 /branches/ocean_projects/imp_vert_mix_mrp/src/core_ocean:754-986
 /branches/ocean_projects/leith_mrp/src/core_ocean:2182-2241
+/branches/ocean_projects/linear_eos/src/core_ocean:2435-2437
 /branches/ocean_projects/monotonic_advection/src/core_ocean:1499-1640
 /branches/ocean_projects/monthly_forcing/src/core_ocean:1810-1867
+/branches/ocean_projects/namelist_cleanup/src/core_ocean:2319-2414
 /branches/ocean_projects/option3_b4b_test/src/core_ocean:2201-2231
 /branches/ocean_projects/partial_bottom_cells/src/core_ocean:2172-2226
+/branches/ocean_projects/remove_sw_test_cases/src/core_ocean:2539-2540
 /branches/ocean_projects/restart_reproducibility/src/core_ocean:2239-2272
+/branches/ocean_projects/sea_level_pressure/src/core_ocean:2488-2528
 /branches/ocean_projects/split_explicit_mrp/src/core_ocean:1134-1138
 /branches/ocean_projects/split_explicit_timestepping/src/core_ocean:1044-1097
 /branches/ocean_projects/vert_adv_mrp/src/core_ocean:704-745
## -23,6 +31,8 ##
 /branches/omp_blocks/multiple_blocks/src/core_ocean:1803-2084
 /branches/omp_blocks/openmp_test/src/core_ocean:2107-2144
 /branches/omp_blocks/openmp_test/src/core_ocean_elements:2161-2201
+/branches/scratch_indication/src/core_ocean:2555-2656
 /branches/source_renaming/src/core_ocean:1082-1113
 /branches/time_manager/src/core_ocean:924-962
-/trunk/mpas/src/core_ocean:1371-2274
+/branches/xml_registry/src/core_ocean:2610-2662
+/trunk/mpas/src/core_ocean:1371-2666
\ No newline at end of property
Modified: branches/atmos_physics/src/core_ocean/Makefile
===================================================================
--- branches/atmos_physics/src/core_ocean/Makefile        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/Makefile        2013-03-26 23:03:26 UTC (rev 2670)
@@ -1,79 +1,79 @@
 .SUFFIXES: .F .o
 
 OBJS = mpas_ocn_mpas_core.o \
-       mpas_ocn_test_cases.o \
        mpas_ocn_advection.o \
-           mpas_ocn_thick_hadv.o \
-           mpas_ocn_thick_vadv.o \
-           mpas_ocn_gm.o \
-           mpas_ocn_vel_coriolis.o \
-           mpas_ocn_vel_vadv.o \
-           mpas_ocn_vel_hmix.o \
-           mpas_ocn_vel_hmix_del2.o \
-           mpas_ocn_vel_hmix_leith.o \
-           mpas_ocn_vel_hmix_del4.o \
-           mpas_ocn_vel_forcing.o \
-           mpas_ocn_vel_forcing_windstress.o \
-           mpas_ocn_vel_forcing_bottomdrag.o \
-           mpas_ocn_vel_forcing_rayleigh.o \
-           mpas_ocn_vel_pressure_grad.o \
-           mpas_ocn_tracer_vadv.o \
-           mpas_ocn_tracer_vadv_spline.o \
-           mpas_ocn_tracer_vadv_spline2.o \
-           mpas_ocn_tracer_vadv_spline3.o \
-           mpas_ocn_tracer_vadv_stencil.o \
-           mpas_ocn_tracer_vadv_stencil2.o \
-           mpas_ocn_tracer_vadv_stencil3.o \
-           mpas_ocn_tracer_vadv_stencil4.o \
-           mpas_ocn_tracer_hadv.o \
-           mpas_ocn_tracer_hadv2.o \
-           mpas_ocn_tracer_hadv3.o \
-           mpas_ocn_tracer_hadv4.o \
-           mpas_ocn_tracer_hmix.o \
-           mpas_ocn_tracer_hmix_del2.o \
-           mpas_ocn_tracer_hmix_del4.o \
-           mpas_ocn_vmix.o \
-           mpas_ocn_vmix_coefs_const.o \
-           mpas_ocn_vmix_coefs_rich.o \
-           mpas_ocn_vmix_coefs_tanh.o \
-           mpas_ocn_restoring.o \
-           mpas_ocn_tendency.o \
-           mpas_ocn_tracer_advection.o \
-           mpas_ocn_tracer_advection_std.o \
-           mpas_ocn_tracer_advection_std_hadv.o \
-           mpas_ocn_tracer_advection_std_vadv.o \
-           mpas_ocn_tracer_advection_std_vadv2.o \
-           mpas_ocn_tracer_advection_std_vadv3.o \
-           mpas_ocn_tracer_advection_std_vadv4.o \
-           mpas_ocn_tracer_advection_mono.o \
-           mpas_ocn_tracer_advection_helpers.o \
+       mpas_ocn_thick_hadv.o \
+       mpas_ocn_thick_vadv.o \
+       mpas_ocn_gm.o \
+       mpas_ocn_vel_coriolis.o \
+       mpas_ocn_vel_vadv.o \
+       mpas_ocn_vel_hmix.o \
+       mpas_ocn_vel_hmix_del2.o \
+       mpas_ocn_vel_hmix_leith.o \
+       mpas_ocn_vel_hmix_del4.o \
+       mpas_ocn_vel_forcing.o \
+       mpas_ocn_vel_forcing_windstress.o \
+       mpas_ocn_vel_forcing_rayleigh.o \
+       mpas_ocn_vel_pressure_grad.o \
+       mpas_ocn_tracer_vadv.o \
+       mpas_ocn_tracer_vadv_spline.o \
+       mpas_ocn_tracer_vadv_spline2.o \
+       mpas_ocn_tracer_vadv_spline3.o \
+       mpas_ocn_tracer_vadv_stencil.o \
+       mpas_ocn_tracer_vadv_stencil2.o \
+       mpas_ocn_tracer_vadv_stencil3.o \
+       mpas_ocn_tracer_vadv_stencil4.o \
+       mpas_ocn_tracer_hadv.o \
+       mpas_ocn_tracer_hadv2.o \
+       mpas_ocn_tracer_hadv3.o \
+       mpas_ocn_tracer_hadv4.o \
+       mpas_ocn_tracer_hmix.o \
+       mpas_ocn_tracer_hmix_del2.o \
+       mpas_ocn_tracer_hmix_del4.o \
+       mpas_ocn_vmix.o \
+       mpas_ocn_vmix_coefs_const.o \
+       mpas_ocn_vmix_coefs_rich.o \
+       mpas_ocn_vmix_coefs_tanh.o \
+       mpas_ocn_restoring.o \
+       mpas_ocn_tendency.o \
+       mpas_ocn_diagnostics.o \
+       mpas_ocn_tracer_advection.o \
+       mpas_ocn_tracer_advection_std.o \
+       mpas_ocn_tracer_advection_std_hadv.o \
+       mpas_ocn_tracer_advection_std_vadv.o \
+       mpas_ocn_tracer_advection_std_vadv2.o \
+       mpas_ocn_tracer_advection_std_vadv3.o \
+       mpas_ocn_tracer_advection_std_vadv4.o \
+       mpas_ocn_tracer_advection_mono.o \
+       mpas_ocn_tracer_advection_helpers.o \
        mpas_ocn_time_integration.o \
        mpas_ocn_time_integration_rk4.o \
        mpas_ocn_time_integration_split.o \
-           mpas_ocn_equation_of_state.o \
-           mpas_ocn_equation_of_state_jm.o \
-           mpas_ocn_equation_of_state_linear.o \
+       mpas_ocn_equation_of_state.o \
+       mpas_ocn_equation_of_state_jm.o \
+       mpas_ocn_equation_of_state_linear.o \
+       mpas_ocn_diagnostics.o \
        mpas_ocn_global_diagnostics.o \
-           mpas_ocn_time_average.o \
-           mpas_ocn_monthly_forcing.o
+       mpas_ocn_time_average.o \
+       mpas_ocn_monthly_forcing.o
 
 all: core_hyd
 
 core_hyd: $(OBJS)
         ar -ru libdycore.a $(OBJS)
 
-mpas_ocn_test_cases.o:
-
 mpas_ocn_advection.o:
 
 mpas_ocn_time_integration.o: mpas_ocn_time_integration_rk4.o mpas_ocn_time_integration_split.o
 
-mpas_ocn_time_integration_rk4.o:
+mpas_ocn_time_integration_rk4.o: mpas_ocn_tendency.o mpas_ocn_diagnostics.o
 
-mpas_ocn_time_integration_split.o:
+mpas_ocn_time_integration_split.o: mpas_ocn_tendency.o mpas_ocn_diagnostics.o
 
 mpas_ocn_tendency.o: mpas_ocn_time_average.o
 
+mpas_ocn_diagnostics.o: mpas_ocn_time_average.o
+
 mpas_ocn_global_diagnostics.o: 
 
 mpas_ocn_time_average.o:
@@ -96,12 +96,10 @@
 
 mpas_ocn_vel_hmix_del4.o:
 
-mpas_ocn_vel_forcing.o: mpas_ocn_vel_forcing_windstress.o mpas_ocn_vel_forcing_bottomdrag.o mpas_ocn_vel_forcing_rayleigh.o
+mpas_ocn_vel_forcing.o: mpas_ocn_vel_forcing_windstress.o mpas_ocn_vel_forcing_rayleigh.o
 
 mpas_ocn_vel_forcing_windstress.o:
 
-mpas_ocn_vel_forcing_bottomdrag.o:
-
 mpas_ocn_vel_forcing_rayleigh.o:
 
 mpas_ocn_vel_coriolis.o:
@@ -172,61 +170,59 @@
 
 mpas_ocn_monthly_forcing.o:
 
-mpas_ocn_mpas_core.o: mpas_ocn_mpas_core.o \
-                                  mpas_ocn_test_cases.o \
-                                          mpas_ocn_advection.o \
-                                          mpas_ocn_thick_hadv.o \
+mpas_ocn_mpas_core.o: mpas_ocn_advection.o \
+                      mpas_ocn_thick_hadv.o \
                       mpas_ocn_gm.o \
-                                          mpas_ocn_thick_vadv.o \
-                                          mpas_ocn_vel_coriolis.o \
-                                          mpas_ocn_vel_vadv.o \
-                                          mpas_ocn_vel_hmix.o \
-                                          mpas_ocn_vel_hmix_del2.o \
-                                          mpas_ocn_vel_hmix_leith.o \
-                                          mpas_ocn_vel_hmix_del4.o \
-                                          mpas_ocn_vel_forcing.o \
-                                          mpas_ocn_vel_forcing_windstress.o \
-                                          mpas_ocn_vel_forcing_bottomdrag.o \
-                                          mpas_ocn_vel_pressure_grad.o \
-                                          mpas_ocn_tracer_vadv.o \
-                                          mpas_ocn_tracer_vadv_spline.o \
-                                          mpas_ocn_tracer_vadv_spline2.o \
-                                          mpas_ocn_tracer_vadv_spline3.o \
-                                          mpas_ocn_tracer_vadv_stencil.o \
-                                          mpas_ocn_tracer_vadv_stencil2.o \
-                                          mpas_ocn_tracer_vadv_stencil3.o \
-                                          mpas_ocn_tracer_vadv_stencil4.o \
-                                          mpas_ocn_tracer_hadv.o \
-                                          mpas_ocn_tracer_hadv2.o \
-                                          mpas_ocn_tracer_hadv3.o \
-                                          mpas_ocn_tracer_hadv4.o \
-                                          mpas_ocn_tracer_hmix.o \
-                                          mpas_ocn_tracer_hmix_del2.o \
-                                          mpas_ocn_tracer_hmix_del4.o \
-                                          mpas_ocn_vmix.o \
-                                          mpas_ocn_vmix_coefs_const.o \
-                                          mpas_ocn_vmix_coefs_rich.o \
-                                          mpas_ocn_vmix_coefs_tanh.o \
-                                          mpas_ocn_restoring.o \
-                                          mpas_ocn_tracer_advection.o \
-                                          mpas_ocn_tracer_advection_std.o \
-                                          mpas_ocn_tracer_advection_std_hadv.o \
-                                          mpas_ocn_tracer_advection_std_vadv.o \
-                                          mpas_ocn_tracer_advection_std_vadv2.o \
-                                          mpas_ocn_tracer_advection_std_vadv3.o \
-                                          mpas_ocn_tracer_advection_std_vadv4.o \
-                                          mpas_ocn_tracer_advection_mono.o \
-                                          mpas_ocn_tracer_advection_helpers.o \
-                                          mpas_ocn_tendency.o \
-                                          mpas_ocn_time_integration.o \
-                                          mpas_ocn_time_integration_rk4.o \
-                                          mpas_ocn_time_integration_split.o \
-                                          mpas_ocn_equation_of_state.o \
-                                          mpas_ocn_equation_of_state_jm.o \
-                                          mpas_ocn_equation_of_state_linear.o \
-                                          mpas_ocn_global_diagnostics.o \
-                                          mpas_ocn_time_average.o \
-                                          mpas_ocn_monthly_forcing.o
+                      mpas_ocn_thick_vadv.o \
+                      mpas_ocn_vel_coriolis.o \
+                      mpas_ocn_vel_vadv.o \
+                      mpas_ocn_vel_hmix.o \
+                      mpas_ocn_vel_hmix_del2.o \
+                      mpas_ocn_vel_hmix_leith.o \
+                      mpas_ocn_vel_hmix_del4.o \
+                      mpas_ocn_vel_forcing.o \
+                      mpas_ocn_vel_forcing_windstress.o \
+                      mpas_ocn_vel_pressure_grad.o \
+                      mpas_ocn_tracer_vadv.o \
+                      mpas_ocn_tracer_vadv_spline.o \
+                      mpas_ocn_tracer_vadv_spline2.o \
+                      mpas_ocn_tracer_vadv_spline3.o \
+                      mpas_ocn_tracer_vadv_stencil.o \
+                      mpas_ocn_tracer_vadv_stencil2.o \
+                      mpas_ocn_tracer_vadv_stencil3.o \
+                      mpas_ocn_tracer_vadv_stencil4.o \
+                      mpas_ocn_tracer_hadv.o \
+                      mpas_ocn_tracer_hadv2.o \
+                      mpas_ocn_tracer_hadv3.o \
+                      mpas_ocn_tracer_hadv4.o \
+                      mpas_ocn_tracer_hmix.o \
+                      mpas_ocn_tracer_hmix_del2.o \
+                      mpas_ocn_tracer_hmix_del4.o \
+                      mpas_ocn_vmix.o \
+                      mpas_ocn_vmix_coefs_const.o \
+                      mpas_ocn_vmix_coefs_rich.o \
+                      mpas_ocn_vmix_coefs_tanh.o \
+                      mpas_ocn_restoring.o \
+                      mpas_ocn_tracer_advection.o \
+                      mpas_ocn_tracer_advection_std.o \
+                      mpas_ocn_tracer_advection_std_hadv.o \
+                      mpas_ocn_tracer_advection_std_vadv.o \
+                      mpas_ocn_tracer_advection_std_vadv2.o \
+                      mpas_ocn_tracer_advection_std_vadv3.o \
+                      mpas_ocn_tracer_advection_std_vadv4.o \
+                      mpas_ocn_tracer_advection_mono.o \
+                      mpas_ocn_tracer_advection_helpers.o \
+                      mpas_ocn_tendency.o \
+                      mpas_ocn_diagnostics.o \
+                      mpas_ocn_time_integration.o \
+                      mpas_ocn_time_integration_rk4.o \
+                      mpas_ocn_time_integration_split.o \
+                      mpas_ocn_equation_of_state.o \
+                      mpas_ocn_equation_of_state_jm.o \
+                      mpas_ocn_equation_of_state_linear.o \
+                      mpas_ocn_global_diagnostics.o \
+                      mpas_ocn_time_average.o \
+                      mpas_ocn_monthly_forcing.o
 
 clean:
         $(RM) *.o *.mod *.f90 libdycore.a

Modified: branches/atmos_physics/src/core_ocean/Registry
===================================================================
--- branches/atmos_physics/src/core_ocean/Registry        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/Registry        2013-03-26 23:03:26 UTC (rev 2670)
@@ -1,102 +1,146 @@
 %
 % namelist  type  namelist_record  name  default_value
 %
-namelist integer   sw_model config_test_case           5
-namelist character sw_model config_time_integration    RK4
-namelist logical   sw_model config_rk_filter_btr_mode  false
-namelist real      sw_model config_dt                  172.8
-namelist character sw_model config_calendar_type       360day
-namelist character sw_model config_start_time          0000-01-01_00:00:00
-namelist character sw_model config_stop_time           none
-namelist character sw_model config_run_duration        none
-namelist integer   sw_model config_stats_interval      100
-namelist logical   sw_model config_initial_stats       false
-namelist logical   sw_model config_prescribe_velocity  false
-namelist logical   sw_model config_prescribe_thickness false
-namelist integer   sw_model config_num_halos           3
-namelist character io       config_input_name          grid.nc
-namelist character io       config_output_name         output.nc
-namelist character io       config_restart_name        restart.nc
-namelist character io       config_output_interval     24:00:00
-namelist integer   io       config_frames_per_outfile  0
+namelist logical   time_management config_do_restart          .false.
+namelist character time_management config_start_time          '0000-01-01_00:00:00'
+namelist character time_management config_stop_time           'none'
+namelist character time_management config_run_duration        '0_06:00:00'
+namelist character time_management config_calendar_type       '360day'
+
+namelist character io       config_input_name          'grid.nc'
+namelist character io       config_output_name         'output.nc'
+namelist character io       config_restart_name        'restart.nc'
+namelist character io       config_restart_interval    '0_06:00:00'
+namelist character io       config_output_interval     '0_06:00:00'
+namelist character io       config_stats_interval      '0_01:00:00'
+namelist logical   io       config_write_stats_on_startup   .true.
+namelist logical   io       config_write_output_on_startup  .true.
+namelist integer   io       config_frames_per_outfile  1000
 namelist integer   io       config_pio_num_iotasks     0 
 namelist integer   io       config_pio_stride          1
-namelist logical   io       config_write_output_on_startup  true
-namelist character decomposition config_block_decomp_file_prefix  graph.info.part.
+
+namelist real      time_integration config_dt                  3000.0
+namelist character time_integration config_time_integrator    'split_explicit'
+
+namelist integer   grid config_num_halos                3
+namelist character grid config_vert_coord_movement      'uniform_stretching'
+namelist character grid config_alter_ICs_for_pbcs       'zlevel_pbcs_off'
+namelist real      grid config_min_pbc_fraction         0.10
+namelist logical   grid config_check_ssh_consistency    .true.
+
+namelist character decomposition config_block_decomp_file_prefix  'graph.info.part.'
 namelist integer   decomposition config_number_of_blocks          0
-namelist logical   decomposition config_explicit_proc_decomp      false
-namelist character decomposition config_proc_decomp_file_prefix   graph.info.part.
-namelist logical   restart  config_do_restart          false
-namelist character restart  config_restart_interval    none
-namelist character grid     config_vert_grid_type      isopycnal
-namelist character grid     config_pressure_type       pressure
-namelist real      grid     config_rho0                1028
-namelist logical   grid     config_enforce_zstar_at_restart false
-namelist character partial_bottom_cells config_alter_ICs_for_pbcs zlevel_pbcs_off
-namelist real      partial_bottom_cells config_min_pbc_fraction  0.10
-namelist logical   partial_bottom_cells config_check_ssh_consistency true
-namelist logical   partial_bottom_cells config_check_zlevel_consistency false
-namelist integer   split_explicit_ts config_n_ts_iter     2
-namelist integer   split_explicit_ts config_n_bcl_iter_beg   2
-namelist integer   split_explicit_ts config_n_bcl_iter_mid   2
-namelist integer   split_explicit_ts config_n_bcl_iter_end   2
-namelist integer   split_explicit_ts config_n_btr_subcycles  20
-namelist integer   split_explicit_ts config_n_btr_cor_iter  2
-namelist logical   split_explicit_ts config_u_correction true
-namelist logical   split_explicit_ts config_filter_btr_mode false
-namelist integer   split_explicit_ts config_btr_subcycle_loop_factor  2
-namelist real      split_explicit_ts config_btr_gam1_uWt1    0.5
-namelist real      split_explicit_ts config_btr_gam2_SSHWt1  1.0
-namelist real      split_explicit_ts config_btr_gam3_uWt2    1.0
-namelist logical   split_explicit_ts config_btr_solve_SSH2   false
-namelist logical   hmix     config_h_ScaleWithMesh     false
-namelist real      hmix     config_h_mom_eddy_visc2     0.0
-namelist real      hmix     config_h_mom_eddy_visc4     0.0
-namelist logical   hmix     config_visc_vorticity_term true
-namelist real      hmix     config_visc_vorticity_visc2_scale 1.0
-namelist real      hmix     config_visc_vorticity_visc4_scale 1.0
-namelist logical   hmix     config_include_KE_vertex false
-namelist real      hmix     config_h_tracer_eddy_diff2  0.0
-namelist real      hmix     config_h_tracer_eddy_diff4  0.0
-namelist real      hmix     config_h_kappa              0.0
-namelist real      hmix     config_h_kappa_q            0.0
-namelist logical   hmix     config_rayleigh_friction    false
-namelist real      hmix     config_rayleigh_damping_coeff 0.0
-namelist real      hmix     config_apvm_scale_factor      0.0
-namelist logical   hmix_leith  config_use_leith_del2         false
-namelist real      hmix_leith  config_leith_parameter        0.0
-namelist real      hmix_leith  config_leith_dx               0.0
-namelist real      hmix_leith  config_leith_visc2_max      1000000.0
-namelist character vmix     config_vert_visc_type       const
-namelist character vmix     config_vert_diff_type       const
-namelist logical   vmix     config_implicit_vertical_mix  true
+namelist logical   decomposition config_explicit_proc_decomp      .false.
+namelist character decomposition config_proc_decomp_file_prefix   'graph.info.part.'
+
+namelist logical   hmix          config_hmix_ScaleWithMesh  .false.
+namelist logical   hmix          config_visc_vorticity_term .true.
+namelist real      hmix          config_apvm_scale_factor      0.0
+
+namelist logical   hmix_del2     config_use_mom_del2        .false.
+namelist logical   hmix_del2     config_use_tracer_del2     .false.
+namelist real      hmix_del2     config_mom_del2             0.0
+namelist real      hmix_del2     config_tracer_del2          0.0
+namelist real      hmix_del2     config_vorticity_del2_scale 1.0
+
+namelist logical   hmix_del4     config_use_mom_del4        .true.
+namelist logical   hmix_del4     config_use_tracer_del4     .false.
+namelist real      hmix_del4     config_mom_del4             5.0e13
+namelist real      hmix_del4     config_tracer_del4          0.0
+namelist real      hmix_del4     config_vorticity_del4_scale 1.0
+
+namelist logical   hmix_Leith    config_use_Leith_del2      .false.
+namelist real      hmix_Leith    config_Leith_parameter      1.0
+namelist real      hmix_Leith    config_Leith_dx             15000.0
+namelist real      hmix_Leith    config_Leith_visc2_max      2.5e3
+
+namelist real      standard_GM     config_h_kappa              0.0
+namelist real      standard_GM     config_h_kappa_q            0.0
+
+namelist logical   Rayleigh_damping     config_Rayleigh_friction    .false.
+namelist real      Rayleigh_damping     config_Rayleigh_damping_coeff 0.0
+
 namelist real      vmix     config_convective_visc      1.0
 namelist real      vmix     config_convective_diff      1.0
-namelist real      vmix     config_bottom_drag_coeff    1.0e-3
+
+namelist logical   vmix_const   config_use_const_visc   .false.
+namelist logical   vmix_const   config_use_const_diff   .false.
 namelist real      vmix_const   config_vert_visc        2.5e-4
 namelist real      vmix_const   config_vert_diff        2.5e-5
+
+namelist logical   vmix_rich    config_use_rich_visc    .true.
+namelist logical   vmix_rich    config_use_rich_diff    .true.
 namelist real      vmix_rich    config_bkrd_vert_visc   1.0e-4
 namelist real      vmix_rich    config_bkrd_vert_diff   1.0e-5
 namelist real      vmix_rich    config_rich_mix         0.005
+
+namelist logical   vmix_tanh    config_use_tanh_visc    .false.
+namelist logical   vmix_tanh    config_use_tanh_diff    .false.
 namelist real      vmix_tanh    config_max_visc_tanh    2.5e-1
 namelist real      vmix_tanh    config_min_visc_tanh    1.0e-4
 namelist real      vmix_tanh    config_max_diff_tanh    2.5e-2
 namelist real      vmix_tanh    config_min_diff_tanh    1.0e-5
 namelist real      vmix_tanh    config_zMid_tanh        -100
 namelist real      vmix_tanh    config_zWidth_tanh      100
-namelist character eos       config_eos_type            linear
-namelist character advection config_vert_tracer_adv     stencil
-namelist integer   advection config_vert_tracer_adv_order  4
-namelist integer   advection config_horiz_tracer_adv_order 2
-namelist integer   advection config_thickness_adv_order 2
+
+namelist logical   forcing   config_use_monthly_forcing .false.
+namelist logical   forcing   config_restoreTS           .false.
+namelist real      forcing   config_restoreT_timescale  90.0
+namelist real      forcing   config_restoreS_timescale  90.0
+
+namelist character advection config_vert_tracer_adv     'stencil'
+namelist integer   advection config_vert_tracer_adv_order  3
+namelist integer   advection config_horiz_tracer_adv_order 3
 namelist real      advection config_coef_3rd_order      0.25
-namelist logical   advection config_monotonic           false
-namelist logical   advection config_check_monotonicity  false
-namelist logical   restore   config_restoreTS           false
-namelist real      restore   config_restoreT_timescale  90.0
-namelist real      restore   config_restoreS_timescale  90.0
-namelist logical   restore   config_use_monthly_forcing false
+namelist logical   advection config_monotonic           .true.
 
+namelist real      bottom_drag config_bottom_drag_coeff    1.0e-3
+
+namelist character pressure_gradient     config_pressure_gradient_type       'pressure_and_zmid'
+namelist real      pressure_gradient     config_rho0                1014.65
+
+namelist character eos       config_eos_type            'jm'
+
+namelist real      eos_linear config_eos_linear_alpha    2.55e-1
+namelist real      eos_linear config_eos_linear_beta     7.64e-1
+namelist real      eos_linear config_eos_linear_Tref     19.0
+namelist real      eos_linear config_eos_linear_Sref     35.0
+namelist real      eos_linear config_eos_linear_rhoref   1025.022
+
+namelist integer   split_explicit_ts config_n_ts_iter     2
+namelist integer   split_explicit_ts config_n_bcl_iter_beg   1
+namelist integer   split_explicit_ts config_n_bcl_iter_mid   2
+namelist integer   split_explicit_ts config_n_bcl_iter_end   2
+namelist integer   split_explicit_ts config_n_btr_subcycles  20
+namelist integer   split_explicit_ts config_n_btr_cor_iter  2
+namelist logical   split_explicit_ts config_u_correction .true.
+namelist integer   split_explicit_ts config_btr_subcycle_loop_factor  2
+namelist real      split_explicit_ts config_btr_gam1_uWt1    0.5
+namelist real      split_explicit_ts config_btr_gam2_SSHWt1  1.0
+namelist real      split_explicit_ts config_btr_gam3_uWt2    1.0
+namelist logical   split_explicit_ts config_btr_solve_SSH2   .false.
+
+namelist logical   debug config_check_zlevel_consistency .false.
+namelist logical   debug config_filter_btr_mode .false.
+namelist logical   debug config_prescribe_velocity  .false.
+namelist logical   debug config_prescribe_thickness .false.
+namelist logical   debug config_include_KE_vertex .false.
+namelist logical   debug config_check_tracer_monotonicity  .false.
+namelist logical   debug config_disable_h_all_tend .false.
+namelist logical   debug config_disable_h_hadv .false.
+namelist logical   debug config_disable_h_vadv .false.
+namelist logical   debug config_disable_u_all_tend .false.
+namelist logical   debug config_disable_u_coriolis .false.
+namelist logical   debug config_disable_u_pgrad .false.
+namelist logical   debug config_disable_u_hmix .false.
+namelist logical   debug config_disable_u_windstress .false.
+namelist logical   debug config_disable_u_vmix .false.
+namelist logical   debug config_disable_u_vadv .false.
+namelist logical   debug config_disable_tr_all_tend .false.
+namelist logical   debug config_disable_tr_adv .false.
+namelist logical   debug config_disable_tr_hmix .false.
+namelist logical   debug config_disable_tr_vmix .false.
+
 %
 % dim  type  name_in_file  name_in_code
 %
@@ -161,7 +205,7 @@
 
 var persistent real    edgeNormalVectors ( R3 nEdges ) 0 o edgeNormalVectors mesh - -
 var persistent real    localVerticalUnitVectors ( R3 nCells ) 0 o localVerticalUnitVectors mesh - -
-var persistent real    cellTangentPlane ( R3 TWO nEdges ) 0 o cellTangentPlane mesh - -
+var persistent real    cellTangentPlane ( R3 TWO nCells ) 0 o cellTangentPlane mesh - -
 
 var persistent integer cellsOnCell ( maxEdges nCells ) 0 iro cellsOnCell mesh - -
 var persistent integer verticesOnCell ( maxEdges nCells ) 0 iro verticesOnCell mesh - -
@@ -195,7 +239,7 @@
 % Arrays required for reconstruction of velocity field
 var persistent real    coeffs_reconstruct ( R3 maxEdges nCells ) 0 - coeffs_reconstruct mesh - -
 
-% Arrays for z-level version of mpas-ocean
+% Arrays for non-isopycnal version of mpas-ocean
 var persistent integer maxLevelCell ( nCells ) 0 iro maxLevelCell mesh - -
 var persistent integer maxLevelEdgeTop ( nEdges ) 0 - maxLevelEdgeTop mesh - -
 var persistent integer maxLevelEdgeBot ( nEdges ) 0 - maxLevelEdgeBot mesh - -
@@ -204,7 +248,7 @@
 var persistent real refBottomDepth ( nVertLevels ) 0 iro refBottomDepth mesh - -
 var persistent real refBottomDepthTopOfCell ( nVertLevelsP1 ) 0 - refBottomDepthTopOfCell mesh - -
 var persistent real hZLevel ( nVertLevels ) 0 iro hZLevel mesh - -
-var persistent real zstarWeight ( nVertLevels ) 0 - zstarWeight mesh - -
+var persistent real vertCoordMovementWeights ( nVertLevels ) 0 iro vertCoordMovementWeights mesh - -
 
 % Boundary conditions and masks
 var persistent integer boundaryEdge ( nVertLevels nEdges ) 0 - boundaryEdge mesh - -
@@ -239,7 +283,7 @@
 var persistent real    tend_tracer1 ( nVertLevels nCells Time ) 1 - tracer1 tend tracers testing
 
 % state variables for Split Explicit timesplitting
-var persistent real   uBtr ( nEdges Time )         2 ir uBtr state - -
+var persistent real   uBtr ( nEdges Time )         2 r  uBtr state - -
 var persistent real   ssh ( nCells Time )          2 o  ssh state - - 
 var persistent real   uBtrSubcycle ( nEdges Time ) 2 -  uBtrSubcycle state - -
 var persistent real   sshSubcycle ( nCells Time )  2 -  sshSubcycle state - - 
@@ -284,7 +328,9 @@
 var persistent real    MontPot ( nVertLevels nCells Time ) 2 - MontPot state - -
 var persistent real    pressure ( nVertLevels nCells Time ) 2 - pressure state - -
 var persistent real    wTop ( nVertLevelsP1 nCells Time ) 2 - wTop state - -
+var persistent real    vertVelocityTop ( nVertLevelsP1 nCells Time ) 2 - vertVelocityTop state - -
 var persistent real    rhoDisplaced ( nVertLevels nCells Time ) 2 - rhoDisplaced state - -
+var persistent real    BruntVaisalaFreqTop ( nVertLevels nCells Time ) 2 o BruntVaisalaFreqTop state - -
 var persistent real    viscosity ( nVertLevels nEdges Time ) 2 o viscosity state - -
 
 % Other diagnostic variables: neither read nor written to any files
@@ -317,8 +363,12 @@
 var persistent real    acc_uReconstructMeridionalVar ( nVertLevels nCells Time ) 2 o acc_uReconstructMeridionalVar state - -
 var persistent real    acc_u ( nVertLevels nEdges Time ) 2 o acc_u state - -
 var persistent real    acc_uVar ( nVertLevels nEdges Time ) 2 o acc_uVar state - -
+var persistent real    acc_vertVelocityTop ( nVertLevelsP1 nCells Time ) 2 o acc_vertVelocityTop state - -
 
 % Sign fields, for openmp and bit reproducibility without branching statements.
 var persistent integer edgeSignOnCell ( maxEdges nCells ) 0 - edgeSignOnCell mesh - -
 var persistent integer edgeSignOnVertex ( maxEdges nVertices ) 0 - edgeSignOnVertex mesh - -
 var persistent integer kiteIndexOnCell ( maxEdges nCells ) 0 - kiteIndexOnCell mesh - -
+
+% Sea surface pressure, for coupling
+var persistent real    seaSurfacePressure ( nCells Time ) 0 ir seaSurfacePressure mesh - -

Copied: branches/atmos_physics/src/core_ocean/Registry.xml (from rev 2666, trunk/mpas/src/core_ocean/Registry.xml)
===================================================================
--- branches/atmos_physics/src/core_ocean/Registry.xml                                (rev 0)
+++ branches/atmos_physics/src/core_ocean/Registry.xml        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,1071 @@
+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;registry&gt;
+        &lt;dims&gt;
+                &lt;dim name=&quot;nCells&quot; units=&quot;unitless&quot;
+                     description=&quot;The number of polygons in the primary grid.&quot;
+                /&gt;
+                &lt;dim name=&quot;nEdges&quot; units=&quot;unitless&quot;
+                     description=&quot;The number of edge midpoints in either the primary or dual grid.&quot;
+                /&gt;
+                &lt;dim name=&quot;maxEdges&quot; units=&quot;unitless&quot;
+                     description=&quot;The largest number of edges any polygon within the grid has.&quot;
+                /&gt;
+                &lt;dim name=&quot;maxEdges2&quot; units=&quot;unitless&quot;
+                     description=&quot;Two times the largest number of edges any polygon within the grid has.&quot;
+                /&gt;
+                &lt;dim name=&quot;nAdvectionCells&quot; definition=&quot;maxEdges2+0&quot; units=&quot;unitless&quot;
+                     description=&quot;The largest number of advection cells for any edge.&quot;
+                /&gt;
+                &lt;dim name=&quot;nVertices&quot; units=&quot;unitless&quot;
+                     description=&quot;The total number of cells in the dual grid. Also the number of corners in the primary grid.&quot;
+                /&gt;
+                &lt;dim name=&quot;TWO&quot; definition=&quot;2&quot; units=&quot;unitless&quot;
+                     description=&quot;The number two as a dimension.&quot;
+                /&gt;
+                &lt;dim name=&quot;R3&quot; definition=&quot;3&quot; units=&quot;unitless&quot;
+                     description=&quot;The number three as a dimension.&quot;
+                /&gt;
+                &lt;dim name=&quot;FIFTEEN&quot; definition=&quot;15&quot; units=&quot;unitless&quot;
+                     description=&quot;The number 15 as a dimension.&quot;
+                /&gt;
+                &lt;dim name=&quot;TWENTYONE&quot; definition=&quot;21&quot; units=&quot;unitless&quot;
+                     description=&quot;The number 21 as a dimension.&quot;
+                /&gt;
+                &lt;dim name=&quot;vertexDegree&quot; units=&quot;unitless&quot;
+                     description=&quot;The number of cells or edges touching each vertex.&quot;
+                /&gt;
+                &lt;dim name=&quot;nVertLevels&quot; units=&quot;unitless&quot;
+                     description=&quot;The number of levels in the vertical direction. All vertical levels share the same horizontal locations.&quot;
+                /&gt;
+                &lt;dim name=&quot;nVertLevelsP1&quot; definition=&quot;nVertLevels+1&quot; units=&quot;unitless&quot;
+                     description=&quot;The number of interfaces in the vertical direction.&quot;
+                /&gt;
+                &lt;dim name=&quot;nMonths&quot; units=&quot;unitless&quot;
+                         description=&quot;The number of forcing slices in the monthly forcing fields. {\bf \color{red} Deprecated. Should be removed.}&quot;
+                /&gt;
+        &lt;/dims&gt;
+        &lt;nml_record name=&quot;time_management&quot;&gt;
+                &lt;nml_option name=&quot;config_do_restart&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Determines if the initial conditions should be read from a restart file, or an input file.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_start_time&quot; type=&quot;character&quot; default_value=&quot;'0000-01-01_00:00:00'&quot; units=&quot;unitless&quot;
+                            description=&quot;Timestamp describing the initial time of the simulation. If it is set to 'file', the initial time is read from restart_timestamp.&quot;
+                            possible_values=&quot;'YYYY-MM-DD_HH:MM:SS' or 'file'&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_stop_time&quot; type=&quot;character&quot; default_value=&quot;'none'&quot; units=&quot;unitless&quot;
+                            description=&quot;Timestamp descriping the final time of the simulation. If it is set to 'none' the final time is determined from config_start_time and config_run_duration.&quot;
+                            possible_values=&quot;'YYYY-MM-DD_HH:MM:SS' or 'none'&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_run_duration&quot; type=&quot;character&quot; default_value=&quot;'0_06:00:00'&quot; units=&quot;unitless&quot;
+                            description=&quot;Timestamp describing the length of the simulation. If it is set to 'none' the duraction is determined from config_start_time and config_stop_time. config_run_duration overrides inconsistent values of config_stop_time.&quot;
+                            possible_values=&quot;'DDDD_HH:MM:SS' or 'none'&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_calendar_type&quot; type=&quot;character&quot; default_value=&quot;'360day'&quot; units=&quot;unitless&quot;
+                            description=&quot;Selection of the type of calendar that should be used in the simulation.&quot;
+                            possible_values=&quot;'gregorian', 'gregorian_noleap', or '360day'&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;io&quot;&gt;
+                &lt;nml_option name=&quot;config_input_name&quot; type=&quot;character&quot; default_value=&quot;'grid.nc'&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_output_name&quot; type=&quot;character&quot; default_value=&quot;'output.nc'&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_restart_name&quot; type=&quot;character&quot; default_value=&quot;'restart.nc'&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_restart_interval&quot; type=&quot;character&quot; default_value=&quot;'0_06:00:00'&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_output_interval&quot; type=&quot;character&quot; default_value=&quot;'0_06:00:00'&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_stats_interval&quot; type=&quot;character&quot; default_value=&quot;'0_01:00:00'&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_write_stats_on_startup&quot; type=&quot;logical&quot; default_value=&quot;.true.&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_write_output_on_startup&quot; type=&quot;logical&quot; default_value=&quot;.true.&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_frames_per_outfile&quot; type=&quot;integer&quot; default_value=&quot;1000&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_pio_num_iotasks&quot; type=&quot;integer&quot; default_value=&quot;0&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_pio_stride&quot; type=&quot;integer&quot; default_value=&quot;1&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;time_integration&quot;&gt;
+                &lt;nml_option name=&quot;config_dt&quot; type=&quot;real&quot; default_value=&quot;3000.0&quot; units=&quot;s&quot;
+                            description=&quot;Length of model time-step.&quot;
+                            possible_values=&quot;Any positive real value, but limited by CFL condition.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_time_integrator&quot; type=&quot;character&quot; default_value=&quot;'split_explicit'&quot; units=&quot;unitless&quot;
+                            description=&quot;Time integration method.&quot;
+                            possible_values=&quot;'split_explicit', 'RK4', 'unsplit_explicit'&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;grid&quot;&gt;
+                &lt;nml_option name=&quot;config_num_halos&quot; type=&quot;integer&quot; default_value=&quot;3&quot; units=&quot;unitless&quot;
+                            description=&quot;Determines the number of halo cells extending from a blocks owned cells (Called the 0-Halo). The default of 3 is the minimum that can be used with monotonic advection.&quot;
+                            possible_values=&quot;Any positive interger value.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_vert_coord_movement&quot; type=&quot;character&quot; default_value=&quot;'uniform_stretching'&quot; units=&quot;unitless&quot;
+                            description=&quot;Determines the vertical coordinate movement type. 'uniform_stretching' distrubtes SSH perturbations through all vertical levels, 'fixed' places them all in the top level, 'user_specified' allows the input file to determine the distribution, and 'isopycnal' causes levels to be pure isopycnal.&quot;
+                            possible_values=&quot;'uniform_stretching', 'fixed', 'user_specified', 'isopycnal'&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_alter_ICs_for_pbcs&quot; type=&quot;character&quot; default_value=&quot;'zlevel_pbcs_off'&quot; units=&quot;unitless&quot;
+                            description=&quot;Determines the method of alteration for partial bottom cells. 'zlevel_pbcs_on' alters the initial conditions for partial bottom cells, 'zlevel_pbcs_off' alters the initial conditions to have full cells everwhere, and 'off' does nothing to the initial conditions.&quot;
+                            possible_values=&quot;'zlevel_pbcs_on', 'zlevel_pbcs_off', 'off'&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_min_pbc_fraction&quot; type=&quot;real&quot; default_value=&quot;0.10&quot; units=&quot;unitless&quot;
+                            description=&quot;Determines the minimum fraction of a cell altering the initial conditions can create.&quot;
+                            possible_values=&quot;Any real between 0 and 1.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_check_ssh_consistency&quot; type=&quot;logical&quot; default_value=&quot;.true.&quot; units=&quot;&quot;
+                            description=&quot;Enables a check to determine if the SSH is consistent across relevant variables.&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;decomposition&quot;&gt;
+                &lt;nml_option name=&quot;config_block_decomp_file_prefix&quot; type=&quot;character&quot; default_value=&quot;'graph.info.part.'&quot; units=&quot;unitless&quot;
+                            description=&quot;Defines the prefix for the block decomposition file. Can include a path. The number of blocks is appended to the end of the prefix at run-time.&quot;
+                                        possible_values=&quot;Any path/prefix to a block decomposition file.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_number_of_blocks&quot; type=&quot;integer&quot; default_value=&quot;0&quot; units=&quot;unitless&quot;
+                            description=&quot;Determines the number of blocks a simulation should be run with. If it is set to 0, the number of blocks is the same as the number of MPI tasks at run-time.&quot;
+                                        possible_values=&quot;Any integer $&gt;=$ 0.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_explicit_proc_decomp&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Determines if an explicit processor decomposition should be used. This is only useful if multiple blocks per processor are used.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_proc_decomp_file_prefix&quot; type=&quot;character&quot; default_value=&quot;'graph.info.part.'&quot; units=&quot;unitless&quot;
+                            description=&quot;Defines the prefix for the processor decomposition file. This file is only read if config_explicit_proc_decomp is .true. The number of processors is appended to the end of the prefix at run-time.&quot;
+                                        possible_values=&quot;Any path/prefix to a processor decomposition file.&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;hmix&quot;&gt;
+                &lt;nml_option name=&quot;config_hmix_ScaleWithMesh&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;If false, del2 and del4 coefficients are constant throughout the mesh (equivalent to setting $\rho_m=1$ throughout the mesh).  If true, these coefficients scale as mesh density to the -3/4 power.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_visc_vorticity_term&quot; type=&quot;logical&quot; default_value=&quot;.true.&quot; units=&quot;unitless&quot;
+                            description=&quot;{\color{red} TO BE DELETED}&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_apvm_scale_factor&quot; type=&quot;real&quot; default_value=&quot;0.0&quot; units=&quot;unitless&quot;
+                            description=&quot;Anticipated potential vorticity (APV) method scale factor, $c_{apv}$.  When zero, APV is off.&quot;
+                            possible_values=&quot;Any non-negative number, typically between zero and one.&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;hmix_del2&quot;&gt;
+                &lt;nml_option name=&quot;config_use_mom_del2&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;If true, Laplacian horizontal mixing is used on the momentum equation.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_use_tracer_del2&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;If true, Laplacian horizontal mixing is used on the tracer equation.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_mom_del2&quot; type=&quot;real&quot; default_value=&quot;0.0&quot; units=&quot;m^2 s^{-1}&quot;
+                            description=&quot;Horizonal viscosity, $</font>
<font color="gray">u_h$.&quot;
+                            possible_values=&quot;any positive real&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_tracer_del2&quot; type=&quot;real&quot; default_value=&quot;0.0&quot; units=&quot;m^2 s^{-1}&quot;
+                            description=&quot;Horizonal diffusion, $\kappa_h$.&quot;
+                            possible_values=&quot;any positive real&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_vorticity_del2_scale&quot; type=&quot;real&quot; default_value=&quot;1.0&quot; units=&quot;unitless&quot;
+                            description=&quot;{\color{red} TO BE DELETED}&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;hmix_del4&quot;&gt;
+                &lt;nml_option name=&quot;config_use_mom_del4&quot; type=&quot;logical&quot; default_value=&quot;.true.&quot; units=&quot;unitless&quot;
+                            description=&quot;If true, biharmonic horizontal mixing is used on the momentum equation.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_use_tracer_del4&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;If true, biharmonic horizontal mixing is used on the tracer equation.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_mom_del4&quot; type=&quot;real&quot; default_value=&quot;5.0e13&quot; units=&quot;m^4 s^{-1}&quot;
+                            description=&quot;Coefficient for horizontal biharmonic operator on momentum.&quot;
+                            possible_values=&quot;any positive real&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_tracer_del4&quot; type=&quot;real&quot; default_value=&quot;0.0&quot; units=&quot;m^4 s^{-1}&quot;
+                            description=&quot;Coefficient for horizontal biharmonic operator on tracers.&quot;
+                            possible_values=&quot;any positive real&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_vorticity_del4_scale&quot; type=&quot;real&quot; default_value=&quot;1.0&quot; units=&quot;&quot;
+                            description=&quot;{\color{red} TO BE DELETED}&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;hmix_Leith&quot;&gt;
+                &lt;nml_option name=&quot;config_use_Leith_del2&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_Leith_parameter&quot; type=&quot;real&quot; default_value=&quot;1.0&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_Leith_dx&quot; type=&quot;real&quot; default_value=&quot;15000.0&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_Leith_visc2_max&quot; type=&quot;real&quot; default_value=&quot;2.5e3&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;standard_GM&quot;&gt;
+                &lt;nml_option name=&quot;config_h_kappa&quot; type=&quot;real&quot; default_value=&quot;0.0&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_h_kappa_q&quot; type=&quot;real&quot; default_value=&quot;0.0&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;Rayleigh_damping&quot;&gt;
+                &lt;nml_option name=&quot;config_Rayleigh_friction&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;If true, Rayleigh friction is included in the momentum equation.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_Rayleigh_damping_coeff&quot; type=&quot;real&quot; default_value=&quot;0.0&quot; units=&quot;s^{-1}&quot;
+                            description=&quot;Inverse-time coefficient for the Rayleigh damping term, $c_R$.&quot;
+                            possible_values=&quot;Any positive real value.&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;vmix&quot;&gt;
+                &lt;nml_option name=&quot;config_convective_visc&quot; type=&quot;real&quot; default_value=&quot;1.0&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_convective_diff&quot; type=&quot;real&quot; default_value=&quot;1.0&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;vmix_const&quot;&gt;
+                &lt;nml_option name=&quot;config_use_const_visc&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_use_const_diff&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_vert_visc&quot; type=&quot;real&quot; default_value=&quot;2.5e-4&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_vert_diff&quot; type=&quot;real&quot; default_value=&quot;2.5e-5&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;vmix_rich&quot;&gt;
+                &lt;nml_option name=&quot;config_use_rich_visc&quot; type=&quot;logical&quot; default_value=&quot;.true.&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_use_rich_diff&quot; type=&quot;logical&quot; default_value=&quot;.true.&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_bkrd_vert_visc&quot; type=&quot;real&quot; default_value=&quot;1.0e-4&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_bkrd_vert_diff&quot; type=&quot;real&quot; default_value=&quot;1.0e-5&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_rich_mix&quot; type=&quot;real&quot; default_value=&quot;0.005&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;vmix_tanh&quot;&gt;
+                &lt;nml_option name=&quot;config_use_tanh_visc&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_use_tanh_diff&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_max_visc_tanh&quot; type=&quot;real&quot; default_value=&quot;2.5e-1&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_min_visc_tanh&quot; type=&quot;real&quot; default_value=&quot;1.0e-4&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_max_diff_tanh&quot; type=&quot;real&quot; default_value=&quot;2.5e-2&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_min_diff_tanh&quot; type=&quot;real&quot; default_value=&quot;1.0e-5&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_zMid_tanh&quot; type=&quot;real&quot; default_value=&quot;-100&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_zWidth_tanh&quot; type=&quot;real&quot; default_value=&quot;100&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;forcing&quot;&gt;
+                &lt;nml_option name=&quot;config_use_monthly_forcing&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Controls time frequency of forcing.  If false, a constant forcing is used, provided by the input fields u_src, temperatureRestore, and salinityRestore.  If true, forcing is interpolated between monthly fields given by windStressMonthly, temperatureRestoreMonthly, and salinityRestoreMonthly.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_restoreTS&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;If true, the restoring term is activated in the tracer equation for temperature and salinity.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_restoreT_timescale&quot; type=&quot;real&quot; default_value=&quot;90.0&quot; units=&quot;days&quot;
+                            description=&quot;Restoring timescale for temperature, $\tau_r.$&quot;
+                            possible_values=&quot;any positive real value, but typically between 30 and 90 days.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_restoreS_timescale&quot; type=&quot;real&quot; default_value=&quot;90.0&quot; units=&quot;days&quot;
+                            description=&quot;Restoring timescale for salinity, $\tau_r$.&quot;
+                            possible_values=&quot;any positive real value, but typically between 30 and 90 days.&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;advection&quot;&gt;
+                &lt;nml_option name=&quot;config_vert_tracer_adv&quot; type=&quot;character&quot; default_value=&quot;'stencil'&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_vert_tracer_adv_order&quot; type=&quot;integer&quot; default_value=&quot;3&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_horiz_tracer_adv_order&quot; type=&quot;integer&quot; default_value=&quot;3&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_coef_3rd_order&quot; type=&quot;real&quot; default_value=&quot;0.25&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_monotonic&quot; type=&quot;logical&quot; default_value=&quot;.true.&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;bottom_drag&quot;&gt;
+                &lt;nml_option name=&quot;config_bottom_drag_coeff&quot; type=&quot;real&quot; default_value=&quot;1.0e-3&quot; units=&quot;unitless&quot;
+                            description=&quot;Dimensionless bottom drag coefficient, $c_{drag}$.&quot;
+                            possible_values=&quot;any positive real, typically 1.0e-3&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;pressure_gradient&quot;&gt;
+                &lt;nml_option name=&quot;config_pressure_gradient_type&quot; type=&quot;character&quot; default_value=&quot;'pressure_and_zmid'&quot; units=&quot;unitless&quot;
+                            description=&quot;Form of pressure gradient terms in momentum equation. For most applications, the gradient of pressure and layer mid-depth are appropriate.  For isopycnal coordinates, one may use the gradient of the Montgomery potential.&quot;
+                            possible_values=&quot;'pressure_and_zmid' or 'MontgomeryPotential'&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_rho0&quot; type=&quot;real&quot; default_value=&quot;1014.65&quot; units=&quot;kg m^{-3}&quot;
+                            description=&quot;Density used as a coefficient of the pressure gradient terms, $\rho_0$.  This is a constant due to the Boussinesq approximation.&quot;
+                            possible_values=&quot;any positive real, but typically 1000-1035&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;eos&quot;&gt;
+                &lt;nml_option name=&quot;config_eos_type&quot; type=&quot;character&quot; default_value=&quot;'jm'&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;eos_linear&quot;&gt;
+                &lt;nml_option name=&quot;config_eos_linear_alpha&quot; type=&quot;real&quot; default_value=&quot;2.55e-1&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_eos_linear_beta&quot; type=&quot;real&quot; default_value=&quot;7.64e-1&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_eos_linear_Tref&quot; type=&quot;real&quot; default_value=&quot;19.0&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_eos_linear_Sref&quot; type=&quot;real&quot; default_value=&quot;35.0&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_eos_linear_rhoref&quot; type=&quot;real&quot; default_value=&quot;1025.022&quot; units=&quot;&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;split_explicit_ts&quot;&gt;
+                &lt;nml_option name=&quot;config_n_ts_iter&quot; type=&quot;integer&quot; default_value=&quot;2&quot; units=&quot;unitless&quot;
+                            description=&quot;number of large iterations over stages 1-3&quot;
+                            possible_values=&quot;any positive integer, but typically 1, 2, or 3&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_n_bcl_iter_beg&quot; type=&quot;integer&quot; default_value=&quot;1&quot; units=&quot;unitless&quot;
+                            description=&quot;number of iterations of stage 1 (baroclinic solve) on the first split-explicit iteration&quot;
+                            possible_values=&quot;any positive integer, but typically 1, 2, or 3&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_n_bcl_iter_mid&quot; type=&quot;integer&quot; default_value=&quot;2&quot; units=&quot;unitless&quot;
+                            description=&quot;number of iterations of stage 1 (baroclinic solve) on any split-explicit iterations between first and last&quot;
+                            possible_values=&quot;any positive integer, but typically 1, 2, or 3&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_n_bcl_iter_end&quot; type=&quot;integer&quot; default_value=&quot;2&quot; units=&quot;unitless&quot;
+                            description=&quot;number of iterations of stage 1 (baroclinic solve) on the last split-explicit iteration&quot;
+                            possible_values=&quot;any positive integer, but typically 1, 2, or 3&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_n_btr_subcycles&quot; type=&quot;integer&quot; default_value=&quot;20&quot; units=&quot;unitless&quot;
+                            description=&quot;number of barotropic subcycles in stage 2&quot;
+                            possible_values=&quot;any positive integer, typically between 10 and 100&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_n_btr_cor_iter&quot; type=&quot;integer&quot; default_value=&quot;2&quot; units=&quot;unitless&quot;
+                            description=&quot;number of iterations of the velocity corrector step in stage 2&quot;
+                            possible_values=&quot;any positive integer, but typically 1, 2, or 3&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_u_correction&quot; type=&quot;logical&quot; default_value=&quot;.true.&quot; units=&quot;unitless&quot;
+                            description=&quot;If true, the velocity correction term is included in the horizontal advection of thickness and tracers&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_btr_subcycle_loop_factor&quot; type=&quot;integer&quot; default_value=&quot;2&quot; units=&quot;unitless&quot;
+                            description=&quot;Barotropic subcycles proceed from $t$ to $t+n\Delta t$, where $n$ is this configuration option.&quot;
+                            possible_values=&quot;Any positive integer, but typically 1 or 2&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_btr_gam1_uWt1&quot; type=&quot;real&quot; default_value=&quot;0.5&quot; units=&quot;unitless&quot;
+                            description=&quot;Weighting of velocity in the SSH predictor step in stage 2.  When zero, previous subcycle time is used; when one, new subcycle time is used.&quot;
+                            possible_values=&quot;between 0 and 1&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_btr_gam2_SSHWt1&quot; type=&quot;real&quot; default_value=&quot;1.0&quot; units=&quot;unitless&quot;
+                            description=&quot;Weighting of SSH in the velocity corrector step in stage 2.  When zero, previous subcycle time is used; when one, new subcycle time is used.&quot;
+                            possible_values=&quot;between 0 and 1&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_btr_gam3_uWt2&quot; type=&quot;real&quot; default_value=&quot;1.0&quot; units=&quot;unitless&quot;
+                            description=&quot;Weighting of velocity in the SSH corrector step in stage 2.  When zero, previous subcycle time is used; when one, new subcycle time is used.&quot;
+                            possible_values=&quot;between 0 and 1&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_btr_solve_SSH2&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;If true, execute the SSH corrector step in stage 2&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;debug&quot;&gt;
+                &lt;nml_option name=&quot;config_check_zlevel_consistency&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Enables a run-time check for consistency for a zlevel grid. Ensures relevant variables correctly define the bottom of the ocean.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_filter_btr_mode&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Enables filtering of the barotropic mode.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_prescribe_velocity&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Enables a prescribed velocity field. This velocity field is read on input, and remains constant through a simulation.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_prescribe_thickness&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Enables a prescribed thickness field. This thickness field is read on input, and remains constant through a simulation.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_include_KE_vertex&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_check_tracer_monotonicity&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Enables a change on tracer monotonicity at the end of the monotonic advection routine. Only used if config_monotonic is set to .true.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_disable_h_all_tend&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Disables all tendencies on the thickness field.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_disable_h_hadv&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Disable tendencies on the thickness field from horizontal advection.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_disable_h_vadv&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Disables tendencies on the thickness field from vertical advection.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_disable_u_all_tend&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Disables all tendencies on the velocity field.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_disable_u_coriolis&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Diables tendencies on the velocity field from the Coriolis force.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_disable_u_pgrad&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Disables tendencies on the velocity field from the horizontal pressure gradient.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_disable_u_hmix&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Disables tendencies on the velocity field from horizontal mixing.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_disable_u_windstress&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Disables tendencies on the velocity field from horizontal wind stress.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_disable_u_vmix&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Disables tendencies on the velocity field from vertical mixing.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_disable_u_vadv&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Disables tendencies on the velocity field from vertical advection.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_disable_tr_all_tend&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Disables all tendencies on tracer fields.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_disable_tr_adv&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Disables tendencies on tracer fields from advection, both horizontal and vertical.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_disable_tr_hmix&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Disables tendencies on tracer fields from horizontal mixing.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_disable_tr_vmix&quot; type=&quot;logical&quot; default_value=&quot;.false.&quot; units=&quot;unitless&quot;
+                            description=&quot;Disables tendencies on tracer fields from vertical mixing.&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+        &lt;/nml_record&gt;
+        &lt;var_struct name=&quot;state&quot; time_levs=&quot;2&quot;&gt;
+                &lt;var_array name=&quot;tracers&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot;&gt;
+                        &lt;var name=&quot;temperature&quot; array_group=&quot;dynamics&quot; streams=&quot;iro&quot; units=&quot;degrees Celsius&quot;
+                             description=&quot;potential temperature&quot;
+                        /&gt;
+                        &lt;var name=&quot;salinity&quot; array_group=&quot;dynamics&quot; streams=&quot;iro&quot; units=&quot;grams salt per kilogram seawater&quot;
+                             description=&quot;salinity&quot;
+                        /&gt;
+                        &lt;var name=&quot;tracer1&quot; array_group=&quot;testing&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                             description=&quot;A tracer with value 1.0 to test conservation.  {\color{red} REMOVE THIS VARIABLE}&quot;
+                        /&gt;
+                &lt;/var_array&gt;
+                &lt;var name=&quot;xtime&quot; type=&quot;text&quot; dimensions=&quot;Time&quot; streams=&quot;ro&quot; units=&quot;unitless&quot;
+                     description=&quot;model time, with format 'YYYY-MM-DD_HH:MM:SS'&quot;
+                /&gt;
+                &lt;var name=&quot;u&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; streams=&quot;ir&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;horizonal velocity, normal component to an edge&quot;
+                /&gt;
+                &lt;var name=&quot;h&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;iro&quot; units=&quot;m&quot;
+                     description=&quot;layer thickness&quot;
+                /&gt;
+                &lt;var name=&quot;rho&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;iro&quot; units=&quot;kg m^{-3}&quot;
+                     description=&quot;density&quot;
+                /&gt;
+                &lt;var name=&quot;uBtr&quot; type=&quot;real&quot; dimensions=&quot;nEdges Time&quot; streams=&quot;r&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;barotropic velocity, used in split-explicit time-stepping&quot;
+                /&gt;
+                &lt;var name=&quot;ssh&quot; type=&quot;real&quot; dimensions=&quot;nCells Time&quot; streams=&quot;o&quot; units=&quot;m&quot;
+                     description=&quot;sea surface height&quot;
+                /&gt;
+                &lt;var name=&quot;uBtrSubcycle&quot; type=&quot;real&quot; dimensions=&quot;nEdges Time&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;barotropic velocity, used in subcycling in stage 2 of split-explicit time-stepping&quot;
+                /&gt;
+                &lt;var name=&quot;sshSubcycle&quot; type=&quot;real&quot; dimensions=&quot;nCells Time&quot; units=&quot;m&quot;
+                     description=&quot;sea surface height, used in subcycling in stage 2 of split-explicit time-stepping&quot;
+                /&gt;
+                &lt;var name=&quot;FBtr&quot; type=&quot;real&quot; dimensions=&quot;nEdges Time&quot; units=&quot;m^2 s^{-1}&quot;
+                     description=&quot;Barotropic thickness flux at each edge, used to advance sea surface height in each subcycle of stage 2 of the split-explicit algorithm.&quot;
+                /&gt;
+                &lt;var name=&quot;GBtrForcing&quot; type=&quot;real&quot; dimensions=&quot;nEdges Time&quot; units=&quot;m s^{-2}&quot;
+                     description=&quot;Barotropic tendency computed from the baroclinic equations in stage 1 of the split-explicit algorithm.&quot;
+                /&gt;
+                &lt;var name=&quot;uBcl&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;baroclinic velocity, used in split-explicit time-stepping&quot;
+                /&gt;
+                &lt;var name=&quot;zMid&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; units=&quot;m&quot;
+                     description=&quot;z-coordinate of the mid-depth of the layer&quot;
+                /&gt;
+                &lt;var name=&quot;v&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;horizontal velocity, tangential to an edge&quot;
+                /&gt;
+                &lt;var name=&quot;uTransport&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;horizontal velocity used to transport mass and tracers&quot;
+                /&gt;
+                &lt;var name=&quot;uBolusGM&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;&quot;
+                     description=&quot;&quot;
+                /&gt;
+                &lt;var name=&quot;uBolusGMX&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;&quot;
+                     description=&quot;&quot;
+                /&gt;
+                &lt;var name=&quot;uBolusGMY&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;&quot;
+                     description=&quot;&quot;
+                /&gt;
+                &lt;var name=&quot;uBolusGMZ&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;&quot;
+                     description=&quot;&quot;
+                /&gt;
+                &lt;var name=&quot;uBolusGMZonal&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; streams=&quot;o&quot; units=&quot;&quot;
+                     description=&quot;&quot;
+                /&gt;
+                &lt;var name=&quot;uBolusGMMeridional&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; streams=&quot;o&quot; units=&quot;&quot;
+                     description=&quot;&quot;
+                /&gt;
+                &lt;var name=&quot;hEddyFlux&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;&quot;
+                     description=&quot;&quot;
+                /&gt;
+                &lt;var name=&quot;h_kappa&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;&quot;
+                     description=&quot;&quot;
+                /&gt;
+                &lt;var name=&quot;h_kappa_q&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;&quot;
+                     description=&quot;&quot;
+                /&gt;
+                &lt;var name=&quot;divergence&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;o&quot; units=&quot;s^{-1}&quot;
+                     description=&quot;divergence of horizonal velocity&quot;
+                /&gt;
+                &lt;var name=&quot;vorticity&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nVertices Time&quot; streams=&quot;o&quot; units=&quot;s^{-1}&quot;
+                     description=&quot;curl of horizontal velocity&quot;
+                /&gt;
+                &lt;var name=&quot;Vor_edge&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;s^{-1}&quot;
+                     description=&quot;vorticity averaged from vertices to edges&quot;
+                /&gt;
+                &lt;var name=&quot;h_edge&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;m&quot;
+                     description=&quot;layer thickness averaged from cell center to edges&quot;
+                /&gt;
+                &lt;var name=&quot;h_vertex&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nVertices Time&quot; units=&quot;m&quot;
+                     description=&quot;layer thickness averaged from cell center to vertices&quot;
+                /&gt;
+                &lt;var name=&quot;ke&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;o&quot; units=&quot;m^2 s^{-2}&quot;
+                     description=&quot;kinetic energy of horizonal velocity&quot;
+                /&gt;
+                &lt;var name=&quot;kev&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nVertices Time&quot; streams=&quot;o&quot; units=&quot;m^2 s^{-2}&quot;
+                     description=&quot;kinetic energy of horizonal velocity defined at vertices&quot;
+                /&gt;
+                &lt;var name=&quot;kevc&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;o&quot; units=&quot;m^2 s^{-2}&quot;
+                     description=&quot;kinetic energy of horizonal velocity defined at vertices&quot;
+                /&gt;
+                &lt;var name=&quot;ke_edge&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;m^2 s^{-2}&quot;
+                     description=&quot;kinetic energy of horizonal velocity defined at edges&quot;
+                /&gt;
+                &lt;var name=&quot;Vor_vertex&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nVertices Time&quot; units=&quot;s^{-1}&quot;
+                     description=&quot;curl of horizontal velocity defined at vertices&quot;
+                /&gt;
+                &lt;var name=&quot;Vor_cell&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;o&quot; units=&quot;s^{-1}&quot;
+                     description=&quot;curl of horizontal velocity defined at cell centers&quot;
+                /&gt;
+                &lt;var name=&quot;uReconstructX&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;component of horizontal velocity in the x-direction (cartesian)&quot;
+                /&gt;
+                &lt;var name=&quot;uReconstructY&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;component of horizontal velocity in the y-direction (cartesian)&quot;
+                /&gt;
+                &lt;var name=&quot;uReconstructZ&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;component of horizontal velocity in the z-direction (cartesian)&quot;
+                /&gt;
+                &lt;var name=&quot;uReconstructZonal&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;o&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;component of horizontal velocity in the eastward direction&quot;
+                /&gt;
+                &lt;var name=&quot;uReconstructMeridional&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;o&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;component of horizontal velocity in the northward&quot;
+                /&gt;
+                &lt;var name=&quot;uSrcReconstructX&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; units=&quot;N m^{-2}&quot;
+                     description=&quot;wind stress in the x-direction (cartesian)&quot;
+                /&gt;
+                &lt;var name=&quot;uSrcReconstructY&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; units=&quot;N m^{-2}&quot;
+                     description=&quot;wind stress in the y-direction (cartesian)&quot;
+                /&gt;
+                &lt;var name=&quot;uSrcReconstructZ&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; units=&quot;N m^{-2}&quot;
+                     description=&quot;wind stress in the z-direction (cartesian)&quot;
+                /&gt;
+                &lt;var name=&quot;uSrcReconstructZonal&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;o&quot; units=&quot;N m^{-2}&quot;
+                     description=&quot;wind stress in the eastward direction&quot;
+                /&gt;
+                &lt;var name=&quot;uSrcReconstructMeridional&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;o&quot; units=&quot;N m^{-2}&quot;
+                     description=&quot;wind stress in the northward direction&quot;
+                /&gt;
+                &lt;var name=&quot;MontPot&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; units=&quot;m^2 s^{-2}&quot;
+                     description=&quot;Montgomery potential, may be used as the pressure for isopycnal coordinates.&quot;
+                /&gt;
+                &lt;var name=&quot;pressure&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; units=&quot;N m^{-2}&quot;
+                     description=&quot;pressure used in the momentum equation&quot;
+                /&gt;
+                &lt;var name=&quot;wTop&quot; type=&quot;real&quot; dimensions=&quot;nVertLevelsP1 nCells Time&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;vertical transport through the layer interface at the top of the cell&quot;
+                /&gt;
+                &lt;var name=&quot;vertVelocityTop&quot; type=&quot;real&quot; dimensions=&quot;nVertLevelsP1 nCells Time&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;vertical velocity defined at center (horizonally) and top (vertically) of cell&quot;
+                /&gt;
+                &lt;var name=&quot;rhoDisplaced&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; units=&quot;kg m^{-3}&quot;
+                     description=&quot;potential density displaced to the mid-depth of top layer&quot;
+                /&gt;
+                &lt;var name=&quot;BruntVaisalaFreqTop&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;o&quot; units=&quot;s^{-2}&quot;
+                     description=&quot;Brunt Vaisala frequency defined at the center (horizontally) and top (vertically) of cell&quot;
+                /&gt;
+                &lt;var name=&quot;viscosity&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; streams=&quot;o&quot; units=&quot;m^2 s^{-1}&quot;
+                     description=&quot;horizontal viscosity&quot;
+                /&gt;
+                &lt;var name=&quot;vh&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;m^2 s^{-1}&quot;
+                     description=&quot;thickness flux in the tangent direction (from vertex1 to vertex2)&quot;
+                /&gt;
+                &lt;var name=&quot;circulation&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nVertices Time&quot; units=&quot;m^2 s^{-1}&quot;
+                     description=&quot;area-integrated vorticity&quot;
+                /&gt;
+                &lt;var name=&quot;gradVor_t&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;s^{-1} m^{-1}&quot;
+                     description=&quot;gradient of vorticity in the tangent direction (from vertex1 to vertex2)&quot;
+                /&gt;
+                &lt;var name=&quot;gradVor_n&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;s^{-1} m^{-1}&quot;
+                     description=&quot;gradient of vorticity in the normal direction (from cell1 to cell2)&quot;
+                /&gt;
+                &lt;var name=&quot;areaCellGlobal&quot; type=&quot;real&quot; dimensions=&quot;Time&quot; streams=&quot;o&quot; units=&quot;m^2&quot;
+                     description=&quot;sum of the areaCell variable over the full domain, used to normalize global statistics&quot;
+                /&gt;
+                &lt;var name=&quot;areaEdgeGlobal&quot; type=&quot;real&quot; dimensions=&quot;Time&quot; streams=&quot;o&quot; units=&quot;m^2&quot;
+                     description=&quot;sum of the areaEdge variable over the full domain, used to normalize global statistics&quot;
+                /&gt;
+                &lt;var name=&quot;areaTriangleGlobal&quot; type=&quot;real&quot; dimensions=&quot;Time&quot; streams=&quot;o&quot; units=&quot;m^2&quot;
+                     description=&quot;sum of the areaTriangle variable over the full domain, used to normalize global statistics&quot;
+                /&gt;
+                &lt;var name=&quot;volumeCellGlobal&quot; type=&quot;real&quot; dimensions=&quot;Time&quot; streams=&quot;o&quot; units=&quot;m^3&quot;
+                     description=&quot;sum of the volumeCell variable over the full domain, used to normalize global statistics&quot;
+                /&gt;
+                &lt;var name=&quot;volumeEdgeGlobal&quot; type=&quot;real&quot; dimensions=&quot;Time&quot; streams=&quot;o&quot; units=&quot;m^3&quot;
+                     description=&quot;sum of the volumeEdge variable over the full domain, used to normalize global statistics&quot;
+                /&gt;
+                &lt;var name=&quot;CFLNumberGlobal&quot; type=&quot;real&quot; dimensions=&quot;Time&quot; streams=&quot;o&quot; units=&quot;unitless&quot;
+                     description=&quot;maximum CFL number over the full domain&quot;
+                /&gt;
+                &lt;var name=&quot;nAccumulate&quot; type=&quot;real&quot; dimensions=&quot;Time&quot; streams=&quot;o&quot; units=&quot;unitless&quot;
+                     description=&quot;number of timesteps in time-averaged variables&quot;
+                /&gt;
+                &lt;var name=&quot;acc_ssh&quot; type=&quot;real&quot; dimensions=&quot;nCells Time&quot; streams=&quot;o&quot; units=&quot;m&quot;
+                     description=&quot;time-averaged sea surface height&quot;
+                /&gt;
+                &lt;var name=&quot;acc_sshVar&quot; type=&quot;real&quot; dimensions=&quot;nCells Time&quot; streams=&quot;o&quot; units=&quot;m&quot;
+                     description=&quot;variance of sea surface height&quot;
+                /&gt;
+                &lt;var name=&quot;acc_uReconstructZonal&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;o&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;time-averaged velocity in the eastward direction&quot;
+                /&gt;
+                &lt;var name=&quot;acc_uReconstructMeridional&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;o&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;time-averaged velocity in the northward direction&quot;
+                /&gt;
+                &lt;var name=&quot;acc_uReconstructZonalVar&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;o&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;variance of velocity in the eastward direction&quot;
+                /&gt;
+                &lt;var name=&quot;acc_uReconstructMeridionalVar&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; streams=&quot;o&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;variance of velocity in the northward direction&quot;
+                /&gt;
+                &lt;var name=&quot;acc_u&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; streams=&quot;o&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;time-averaged velocity, normal to cell edge&quot;
+                /&gt;
+                &lt;var name=&quot;acc_uVar&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; streams=&quot;o&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;variance of velocity, normal to cell edge&quot;
+                /&gt;
+                &lt;var name=&quot;acc_vertVelocityTop&quot; type=&quot;real&quot; dimensions=&quot;nVertLevelsP1 nCells Time&quot; streams=&quot;o&quot; units=&quot;m s^{-1}&quot;
+                     description=&quot;time-averaged vertical velocity at top of cell&quot;
+                /&gt;
+        &lt;/var_struct&gt;
+        &lt;var_struct name=&quot;mesh&quot; time_levs=&quot;0&quot;&gt;
+                &lt;var name=&quot;latCell&quot; type=&quot;real&quot; dimensions=&quot;nCells&quot; streams=&quot;iro&quot; units=&quot;radians&quot;
+                         description=&quot;Latitude location of cell centers in radians.&quot;
+                /&gt;
+                &lt;var name=&quot;lonCell&quot; type=&quot;real&quot; dimensions=&quot;nCells&quot; streams=&quot;iro&quot; units=&quot;radians&quot;
+                     description=&quot;Longitude location of cell centers in radians.&quot;
+                /&gt;
+                &lt;var name=&quot;xCell&quot; type=&quot;real&quot; dimensions=&quot;nCells&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;X Coordinate in cartesian space of cell centers.&quot;
+                /&gt;
+                &lt;var name=&quot;yCell&quot; type=&quot;real&quot; dimensions=&quot;nCells&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;Y Coordinate in cartesian space of cell centers.&quot;
+                /&gt;
+                &lt;var name=&quot;zCell&quot; type=&quot;real&quot; dimensions=&quot;nCells&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;Z Coordinate in cartesian space of cell centers.&quot;
+                /&gt;
+                &lt;var name=&quot;indexToCellID&quot; type=&quot;integer&quot; dimensions=&quot;nCells&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;List of global cell IDs.&quot;
+                /&gt;
+                &lt;var name=&quot;latEdge&quot; type=&quot;real&quot; dimensions=&quot;nEdges&quot; streams=&quot;iro&quot; units=&quot;radians&quot;
+                     description=&quot;Latitude location of edge midpoints in radians.&quot;
+                /&gt;
+                &lt;var name=&quot;lonEdge&quot; type=&quot;real&quot; dimensions=&quot;nEdges&quot; streams=&quot;iro&quot; units=&quot;radians&quot;
+                     description=&quot;Longitude location of edge midpoints in radians.&quot;
+                /&gt;
+                &lt;var name=&quot;xEdge&quot; type=&quot;real&quot; dimensions=&quot;nEdges&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;X Coordinate in cartesian space of edge midpoints.&quot;
+                /&gt;
+                &lt;var name=&quot;yEdge&quot; type=&quot;real&quot; dimensions=&quot;nEdges&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;Y Coordinate in cartesian space of edge midpoints.&quot;
+                /&gt;
+                &lt;var name=&quot;zEdge&quot; type=&quot;real&quot; dimensions=&quot;nEdges&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;Z Coordinate in cartesian space of edge midpoints.&quot;
+                /&gt;
+                &lt;var name=&quot;indexToEdgeID&quot; type=&quot;integer&quot; dimensions=&quot;nEdges&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;List of global edge IDs.&quot;
+                /&gt;
+                &lt;var name=&quot;latVertex&quot; type=&quot;real&quot; dimensions=&quot;nVertices&quot; streams=&quot;iro&quot; units=&quot;radians&quot;
+                     description=&quot;Latitude location of vertices in radians.&quot;
+                /&gt;
+                &lt;var name=&quot;lonVertex&quot; type=&quot;real&quot; dimensions=&quot;nVertices&quot; streams=&quot;iro&quot; units=&quot;radians&quot;
+                     description=&quot;Longitude location of vertices in radians.&quot;
+                /&gt;
+                &lt;var name=&quot;xVertex&quot; type=&quot;real&quot; dimensions=&quot;nVertices&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;X Coordinate in cartesian space of vertices.&quot;
+                /&gt;
+                &lt;var name=&quot;yVertex&quot; type=&quot;real&quot; dimensions=&quot;nVertices&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;Y Coordinate in cartesian space of vertices.&quot;
+                /&gt;
+                &lt;var name=&quot;zVertex&quot; type=&quot;real&quot; dimensions=&quot;nVertices&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;Z Coordinate in cartesian space of vertices.&quot;
+                /&gt;
+                &lt;var name=&quot;indexToVertexID&quot; type=&quot;integer&quot; dimensions=&quot;nVertices&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;List of global vertex IDs.&quot;
+                /&gt;
+                &lt;var name=&quot;meshDensity&quot; type=&quot;real&quot; dimensions=&quot;nCells&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;Value of density function used to generate a particular mesh at cell centers.&quot;
+                /&gt;
+                &lt;var name=&quot;meshScalingDel2&quot; type=&quot;real&quot; dimensions=&quot;nEdges&quot; streams=&quot;ro&quot; units=&quot;unitless&quot;
+                     description=&quot;Coefficient to Laplacian mixing terms in momentum and tracer equations, so that viscosity and diffusion scale with mesh.&quot;
+                /&gt;
+                &lt;var name=&quot;meshScalingDel4&quot; type=&quot;real&quot; dimensions=&quot;nEdges&quot; streams=&quot;ro&quot; units=&quot;unitless&quot;
+                     description=&quot;Coefficient to biharmonic mixing terms in momentum and tracer equations, so that biharmonic viscosity and diffusion coefficients scale with mesh.&quot;
+                /&gt;
+                &lt;var name=&quot;meshScaling&quot; type=&quot;real&quot; dimensions=&quot;nEdges&quot; streams=&quot;ro&quot; units=&quot;unitless&quot;
+                     description=&quot;Coefficient used for mesh scaling, such as the Leith parameter.&quot;
+                /&gt;
+                &lt;var name=&quot;cellsOnEdge&quot; type=&quot;integer&quot; dimensions=&quot;TWO nEdges&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;List of cells that straddle each edge.&quot;
+                /&gt;
+                &lt;var name=&quot;nEdgesOnCell&quot; type=&quot;integer&quot; dimensions=&quot;nCells&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;Number of edges that border each cell.&quot;
+                /&gt;
+                &lt;var name=&quot;nEdgesOnEdge&quot; type=&quot;integer&quot; dimensions=&quot;nEdges&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;Number of edges that surround each of the cells that straddle each edge. These edges are used to reconstruct the tangential velocities.&quot;
+                /&gt;
+                &lt;var name=&quot;edgesOnCell&quot; type=&quot;integer&quot; dimensions=&quot;maxEdges nCells&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;List of edges that border each cell.&quot;
+                /&gt;
+                &lt;var name=&quot;edgesOnEdge&quot; type=&quot;integer&quot; dimensions=&quot;maxEdges2 nEdges&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;List of edges that border each of the cells that straddle each edge.&quot;
+                /&gt;
+                &lt;var name=&quot;weightsOnEdge&quot; type=&quot;real&quot; dimensions=&quot;maxEdges2 nEdges&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;Reconstruction weights associated with each of the edgesOnEdge.&quot;
+                /&gt;
+                &lt;var name=&quot;dvEdge&quot; type=&quot;real&quot; dimensions=&quot;nEdges&quot; streams=&quot;iro&quot; units=&quot;m&quot;
+                     description=&quot;Length of each edge, computed as the distance between verticesOnEdge.&quot;
+                /&gt;
+                &lt;var name=&quot;dcEdge&quot; type=&quot;real&quot; dimensions=&quot;nEdges&quot; streams=&quot;iro&quot; units=&quot;m&quot;
+                     description=&quot;Length of each edge, computed as the distance between cellsOnEdge.&quot;
+                /&gt;
+                &lt;var name=&quot;angleEdge&quot; type=&quot;real&quot; dimensions=&quot;nEdges&quot; streams=&quot;iro&quot; units=&quot;radians&quot;
+                     description=&quot;Angle the edge normal makes with local eastward direction.&quot;
+                /&gt;
+                &lt;var name=&quot;areaCell&quot; type=&quot;real&quot; dimensions=&quot;nCells&quot; streams=&quot;iro&quot; units=&quot;m^2&quot;
+                     description=&quot;Area of each cell in the primary grid.&quot;
+                /&gt;
+                &lt;var name=&quot;areaTriangle&quot; type=&quot;real&quot; dimensions=&quot;nVertices&quot; streams=&quot;iro&quot; units=&quot;m^2&quot;
+                     description=&quot;Area of each cell (triangle) in the dual grid.&quot;
+                /&gt;
+                &lt;var name=&quot;edgeNormalVectors&quot; type=&quot;real&quot; dimensions=&quot;R3 nEdges&quot; streams=&quot;o&quot; units=&quot;unitless&quot;
+                     description=&quot;Normal vector defined at an edge.&quot;
+                /&gt;
+                &lt;var name=&quot;localVerticalUnitVectors&quot; type=&quot;real&quot; dimensions=&quot;R3 nCells&quot; streams=&quot;o&quot; units=&quot;unitless&quot;
+                     description=&quot;Unit surface normal vectors defined at cell centers.&quot;
+                /&gt;
+                &lt;var name=&quot;cellTangentPlane&quot; type=&quot;real&quot; dimensions=&quot;R3 TWO nCells&quot; streams=&quot;o&quot; units=&quot;unitless&quot;
+                     description=&quot;The two vectors that define a tangent plane at a cell center.&quot;
+                /&gt;
+                &lt;var name=&quot;cellsOnCell&quot; type=&quot;integer&quot; dimensions=&quot;maxEdges nCells&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;List of cells that neighbor each cell.&quot;
+                /&gt;
+                &lt;var name=&quot;verticesOnCell&quot; type=&quot;integer&quot; dimensions=&quot;maxEdges nCells&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;List of vertices that border each cell.&quot;
+                /&gt;
+                &lt;var name=&quot;verticesOnEdge&quot; type=&quot;integer&quot; dimensions=&quot;TWO nEdges&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;List of vertices that straddle each edge.&quot;
+                /&gt;
+                &lt;var name=&quot;edgesOnVertex&quot; type=&quot;integer&quot; dimensions=&quot;vertexDegree nVertices&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;List of edges that share a vertex as an endpoint.&quot;
+                /&gt;
+                &lt;var name=&quot;cellsOnVertex&quot; type=&quot;integer&quot; dimensions=&quot;vertexDegree nVertices&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;List of cells that share a vertex.&quot;
+                /&gt;
+                &lt;var name=&quot;kiteAreasOnVertex&quot; type=&quot;real&quot; dimensions=&quot;vertexDegree nVertices&quot; streams=&quot;iro&quot; units=&quot;m^2&quot;
+                     description=&quot;Area of the portions of each dual cell that are part of each cellsOnVertex.&quot;
+                /&gt;
+                &lt;var name=&quot;fEdge&quot; type=&quot;real&quot; dimensions=&quot;nEdges&quot; streams=&quot;iro&quot; units=&quot;s^{-1}&quot;
+                     description=&quot;Coriolis parameter at edges.&quot;
+                /&gt;
+                &lt;var name=&quot;fVertex&quot; type=&quot;real&quot; dimensions=&quot;nVertices&quot; streams=&quot;iro&quot; units=&quot;s^{-1}&quot;
+                     description=&quot;Coriolis parameter at vertices.&quot;
+                /&gt;
+                &lt;var name=&quot;bottomDepth&quot; type=&quot;real&quot; dimensions=&quot;nCells&quot; streams=&quot;iro&quot; units=&quot;m&quot;
+                     description=&quot;Depth of the bottom of the ocean. Given as a positive distance from sea level.&quot;
+                /&gt;
+                &lt;var name=&quot;deriv_two&quot; type=&quot;real&quot; dimensions=&quot;maxEdges2 TWO nEdges&quot; units=&quot;&quot;
+                     description=&quot;Value of the second derivative of the polynomial used for reconstruction of cell center quantities at edges.&quot;
+                /&gt;
+                &lt;var name=&quot;adv_coefs&quot; type=&quot;real&quot; dimensions=&quot;nAdvectionCells nEdges&quot; units=&quot;&quot;
+                     description=&quot;Weighting coefficients used for reconstruction of cell center quantities at edges. Used in advection routines.&quot;
+                /&gt;
+                &lt;var name=&quot;adv_coefs_2nd&quot; type=&quot;real&quot; dimensions=&quot;nAdvectionCells nEdges&quot; units=&quot;&quot;
+                     description=&quot;Weighting coefficients used for reconstruction of cell center quantities at edges. Used in advection routines.&quot;
+                /&gt;
+                &lt;var name=&quot;adv_coefs_3rd&quot; type=&quot;real&quot; dimensions=&quot;nAdvectionCells nEdges&quot; units=&quot;&quot;
+                        description=&quot;Wegihting coefficients used for reconstruction of cell center quantities at edges. Used in advection routines.&quot;
+                /&gt;
+                &lt;var name=&quot;advCellsForEdge&quot; type=&quot;integer&quot; dimensions=&quot;nAdvectionCells nEdges&quot; units=&quot;unitless&quot;
+                     description=&quot;List of cells used to reconstruct a cell quantity at an edge. Used in advection routines.&quot;
+                /&gt;
+                &lt;var name=&quot;nAdvCellsForEdge&quot; type=&quot;integer&quot; dimensions=&quot;nEdges&quot; units=&quot;unitless&quot;
+                     description=&quot;Number of cells used in reconstruction of cell center quantities at an edge. Used in advection routines.&quot;
+                /&gt;
+                &lt;var name=&quot;highOrderAdvectionMask&quot; type=&quot;integer&quot; dimensions=&quot;nVertLevels nEdges&quot; units=&quot;unitless&quot;
+                     description=&quot;Mask for high order advection. Values are 1 if high order is used, and 0 if not.&quot;
+                /&gt;
+                &lt;var name=&quot;lowOrderAdvectionMask&quot; type=&quot;integer&quot; dimensions=&quot;nVertLevels nEdges&quot; units=&quot;unitless&quot;
+                     description=&quot;Mask for low order advection. Values are 1 if low order is used, and 0 if not.&quot;
+                /&gt;
+                &lt;var name=&quot;defc_a&quot; type=&quot;real&quot; dimensions=&quot;maxEdges nCells&quot; units=&quot;&quot;
+                     description=&quot;Variable used with advection setup to compute advection coefficients. Deformation weight coefficients.&quot;
+                /&gt;
+                &lt;var name=&quot;defc_b&quot; type=&quot;real&quot; dimensions=&quot;maxEdges nCells&quot; units=&quot;&quot;
+                     description=&quot;Variable used with advection setup to compute advection coefficients. Deformation weight coefficients.&quot;
+                /&gt;
+                &lt;var name=&quot;kdiff&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; units=&quot;&quot;
+                         description=&quot;{\color{red} TO BE REMOVED}&quot;
+                /&gt;
+                &lt;var name=&quot;coeffs_reconstruct&quot; type=&quot;real&quot; dimensions=&quot;R3 maxEdges nCells&quot; units=&quot;&quot;
+                         description=&quot;{\color{red} TO BE REMOVED}&quot;
+                /&gt;
+                &lt;var name=&quot;maxLevelCell&quot; type=&quot;integer&quot; dimensions=&quot;nCells&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;Index to the last active ocean cell in each column.&quot;
+                /&gt;
+                &lt;var name=&quot;maxLevelEdgeTop&quot; type=&quot;integer&quot; dimensions=&quot;nEdges&quot; units=&quot;unitless&quot;
+                     description=&quot;Index to the last edge in a column with active ocean cells on both sides of it.&quot;
+                /&gt;
+                &lt;var name=&quot;maxLevelEdgeBot&quot; type=&quot;integer&quot; dimensions=&quot;nEdges&quot; units=&quot;unitless&quot;
+                     description=&quot;Index to the last edge in a column with at least one active ocean cell on either side of it.&quot;
+                /&gt;
+                &lt;var name=&quot;maxLevelVertexTop&quot; type=&quot;integer&quot; dimensions=&quot;nVertices&quot; units=&quot;unitless&quot;
+                     description=&quot;Index to the last vertex in a column with all active cells around it.&quot;
+                /&gt;
+                &lt;var name=&quot;maxLevelVertexBot&quot; type=&quot;integer&quot; dimensions=&quot;nVertices&quot; units=&quot;unitless&quot;
+                     description=&quot;Index to the last vertex in a column with at least one active ocean cell around it.&quot;
+                /&gt;
+                &lt;var name=&quot;refBottomDepth&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels&quot; streams=&quot;iro&quot; units=&quot;m&quot;
+                     description=&quot;Reference depth of ocean for each vertical level. Used in 'z-level' type runs.&quot;
+                /&gt;
+                &lt;var name=&quot;refBottomDepthTopOfCell&quot; type=&quot;real&quot; dimensions=&quot;nVertLevelsP1&quot; units=&quot;m&quot;
+                     description=&quot;Reference depth of ocean for each vertical interface. Used in 'z-level' type runs.&quot;
+                /&gt;
+                &lt;var name=&quot;hZLevel&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels&quot; streams=&quot;iro&quot; units=&quot;m&quot;
+                        description=&quot;{\color{red} TO BE REMOVED}&quot;
+                /&gt;
+                &lt;var name=&quot;vertCoordMovementWeights&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels&quot; streams=&quot;iro&quot; units=&quot;unitless&quot;
+                     description=&quot;Weights used for distribution of sea surface heigh purturbations through multiple vertical levels.&quot;
+                /&gt;
+                &lt;var name=&quot;boundaryEdge&quot; type=&quot;integer&quot; dimensions=&quot;nVertLevels nEdges&quot; units=&quot;unitless&quot;
+                     description=&quot;Mask for determining boundary edges. A boundary edge has only one active ocean cell neighboring it.&quot;
+                /&gt;
+                &lt;var name=&quot;boundaryVertex&quot; type=&quot;integer&quot; dimensions=&quot;nVertLevels nVertices&quot; units=&quot;unitless&quot;
+                     description=&quot;Mask for determining boundary vertices. A boundary vertex has at least one inactive cell neighboring it.&quot;
+                /&gt;
+                &lt;var name=&quot;boundaryCell&quot; type=&quot;integer&quot; dimensions=&quot;nVertLevels nCells&quot; units=&quot;unitless&quot;
+                     description=&quot;Mask for determining boundary cells. A boundary cell has at least one inactive cell neighboring it.&quot;
+                /&gt;
+                &lt;var name=&quot;edgeMask&quot; type=&quot;integer&quot; dimensions=&quot;nVertLevels nEdges&quot; streams=&quot;o&quot; units=&quot;unitless&quot;
+                     description=&quot;Mask on edges that determines if computations should be done on edge.&quot;
+                /&gt;
+                &lt;var name=&quot;vertexMask&quot; type=&quot;integer&quot; dimensions=&quot;nVertLevels nVertices&quot; streams=&quot;o&quot; units=&quot;unitless&quot;
+                     description=&quot;Mask on vertices that determines if computations should be done on vertice.&quot;
+                /&gt;
+                &lt;var name=&quot;cellMask&quot; type=&quot;integer&quot; dimensions=&quot;nVertLevels nCells&quot; streams=&quot;o&quot; units=&quot;unitless&quot;
+                     description=&quot;Mask on cells that determines if computations should be done on cell.&quot;
+                /&gt;
+                &lt;var name=&quot;u_src&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges&quot; streams=&quot;ir&quot; units=&quot;N m^{-2}&quot;
+                     description=&quot;Velocity forcing field. Defines a forcing at an edge.&quot;
+                /&gt;
+                &lt;var name=&quot;temperatureRestore&quot; type=&quot;real&quot; dimensions=&quot;nCells&quot; streams=&quot;ir&quot; units=&quot;^\circ C&quot;
+                     description=&quot;Temperature restoring field, for restoring temperature at the surface.&quot;
+                /&gt;
+                &lt;var name=&quot;salinityRestore&quot; type=&quot;real&quot; dimensions=&quot;nCells&quot; streams=&quot;ir&quot; units=&quot;PSU&quot;
+                     description=&quot;Salinity restoring field, for restoring salinity at the surface.&quot;
+                /&gt;
+                &lt;var name=&quot;windStressMonthly&quot; type=&quot;real&quot; dimensions=&quot;nMonths nEdges&quot; streams=&quot;ir&quot; units=&quot;N m^{-2}&quot;
+                     description=&quot;Monthly wind stress field, defined at the surface for use in monthly forcing.&quot;
+                /&gt;
+                &lt;var name=&quot;temperatureRestoreMonthly&quot; type=&quot;real&quot; dimensions=&quot;nMonths nCells&quot; streams=&quot;ir&quot; units=&quot;^\circ C&quot;
+                     description=&quot;Monthly temperature restorying field, defined at the surface for use in monthly forcing.&quot;
+                /&gt;
+                &lt;var name=&quot;salinityRestoreMonthly&quot; type=&quot;real&quot; dimensions=&quot;nMonths nCells&quot; streams=&quot;ir&quot; units=&quot;PSU&quot;
+                     description=&quot;Monthly salinity resotring field, defined at the surface, for use in monthly forcing.&quot;
+                /&gt;
+                &lt;var name=&quot;edgeSignOnCell&quot; type=&quot;integer&quot; dimensions=&quot;maxEdges nCells&quot; units=&quot;unitless&quot;
+                     description=&quot;Sign of edge contributions to a cell for each edge on cell. Used for bit-reproducible loops. Represents directionality of vector connecting cells.&quot;
+                /&gt;
+                &lt;var name=&quot;edgeSignOnVertex&quot; type=&quot;integer&quot; dimensions=&quot;maxEdges nVertices&quot; units=&quot;unitless&quot;
+                     description=&quot;Sign of edge contributions to a vertex for each edge on vertex. Used for bit-reproducible loops. Represents directionality of vector connecting vertices.&quot;
+                /&gt;
+                &lt;var name=&quot;kiteIndexOnCell&quot; type=&quot;integer&quot; dimensions=&quot;maxEdges nCells&quot; units=&quot;unitless&quot;
+                     description=&quot;Index of kite in dual grid, based on verticesOnCell.&quot;
+                /&gt;
+                &lt;var name=&quot;seaSurfacePressure&quot; type=&quot;real&quot; dimensions=&quot;nCells Time&quot; streams=&quot;ir&quot; units=&quot;Pa&quot;
+                     description=&quot;Pressure defined at the sea surface.&quot;
+                /&gt;
+        &lt;/var_struct&gt;
+        &lt;var_struct name=&quot;tend&quot; time_levs=&quot;1&quot;&gt;
+                &lt;var_array name=&quot;tracers&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot;&gt;
+                        &lt;var name=&quot;tend_temperature&quot; array_group=&quot;dynamics&quot; units=&quot;K s^{-1}&quot; name_in_code=&quot;temperature&quot;
+                             description=&quot;time tendency of potential temperature&quot;
+                        /&gt;
+                        &lt;var name=&quot;tend_salinity&quot; array_group=&quot;dynamics&quot; units=&quot;PSU s^{-1}&quot; name_in_code=&quot;salinity&quot;
+                             description=&quot;time tendency of salinity measured as change in practical salinity units per second&quot;
+                        /&gt;
+                        &lt;var name=&quot;tend_tracer1&quot; array_group=&quot;testing&quot; units=&quot;tracer s^{-1}&quot; name_in_code=&quot;tracer1&quot;
+                             description=&quot;time tendency of an arbitary tracer&quot;
+                        /&gt;
+                &lt;/var_array&gt;
+                &lt;var name=&quot;tend_u&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;m s^{-2}&quot; name_in_code=&quot;u&quot;
+                     description=&quot;time tendency of normal component of velocity&quot;
+                /&gt;
+                &lt;var name=&quot;tend_h&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; units=&quot;m s^{-1}&quot; name_in_code=&quot;h&quot;
+                     description=&quot;time tendency of layer thickness&quot;
+                /&gt;
+                &lt;var name=&quot;tend_ssh&quot; type=&quot;real&quot; dimensions=&quot;nCells Time&quot; units=&quot;m s^{-1}&quot; name_in_code=&quot;ssh&quot;
+                     description=&quot;time tendency of sea-surface height&quot;
+                /&gt;
+        &lt;/var_struct&gt;
+        &lt;var_struct name=&quot;diagnostics&quot; time_levs=&quot;1&quot;&gt;
+                &lt;var name=&quot;RiTopOfCell&quot; type=&quot;real&quot; dimensions=&quot;nVertLevelsP1 nCells Time&quot; units=&quot;nondimensional&quot;
+                     description=&quot;gradient Richardson number defined at the center (horizontally) and top (vertically)&quot;
+                /&gt;
+                &lt;var name=&quot;RiTopOfEdge&quot; type=&quot;real&quot; dimensions=&quot;nVertLevelsP1 nEdges Time&quot; units=&quot;nondimensional&quot;
+                     description=&quot;gradient Richardson number defined at the edge (horizontally) and top (vertically)&quot;
+                /&gt;
+                &lt;var name=&quot;vertViscTopOfEdge&quot; type=&quot;real&quot; dimensions=&quot;nVertLevelsP1 nEdges Time&quot; units=&quot;m^2 s^{-1}&quot;
+                     description=&quot;vertical viscosity defined at the edge (horizontally) and top (vertically)&quot;
+                /&gt;
+                &lt;var name=&quot;vertDiffTopOfCell&quot; type=&quot;real&quot; dimensions=&quot;nVertLevelsP1 nCells Time&quot; units=&quot;m^2 s^{-1}&quot;
+                     description=&quot;vertical diffusion defined at the edge (horizontally) and top (vertically)&quot;
+                /&gt;
+        &lt;/var_struct&gt;
+&lt;/registry&gt;

Copied: branches/atmos_physics/src/core_ocean/mpas_ocn_diagnostics.F (from rev 2666, trunk/mpas/src/core_ocean/mpas_ocn_diagnostics.F)
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_diagnostics.F                                (rev 0)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_diagnostics.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,834 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+!  ocn_diagnostics
+!
+!&gt; \brief MPAS ocean diagnostics driver
+!&gt; \author Mark Petersen
+!&gt; \date   23 September 2011
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This module contains the routines for computing
+!&gt;  diagnostic variables, and other quantities such as wTop.
+!
+!-----------------------------------------------------------------------
+
+module ocn_diagnostics
+
+   use mpas_grid_types
+   use mpas_configure
+   use mpas_constants
+   use mpas_timer
+
+   use ocn_gm
+   use ocn_equation_of_state
+
+   implicit none
+   private
+   save
+
+   type (timer_node), pointer :: diagEOSTimer
+
+   !--------------------------------------------------------------------
+   !
+   ! Public parameters
+   !
+   !--------------------------------------------------------------------
+
+   !--------------------------------------------------------------------
+   !
+   ! Public member functions
+   !
+   !--------------------------------------------------------------------
+
+   public :: ocn_diagnostic_solve, &amp;
+             ocn_wtop, &amp;
+             ocn_fuperp, &amp;
+             ocn_filter_btr_mode_u, &amp;
+             ocn_filter_btr_mode_tend_u, &amp;
+             ocn_diagnostics_init
+
+   !--------------------------------------------------------------------
+   !
+   ! Private module variables
+   !
+   !--------------------------------------------------------------------
+
+   integer :: ke_cell_flag, ke_vertex_flag
+   real (kind=RKIND) ::  coef_3rd_order, fCoef
+
+!***********************************************************************
+
+contains
+
+!***********************************************************************
+!
+!  routine ocn_diagnostic_solve
+!
+!&gt; \brief   Computes diagnostic variables
+!&gt; \author  Mark Petersen
+!&gt; \date    23 September 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes the diagnostic variables for the ocean
+!
+!-----------------------------------------------------------------------
+
+   subroutine ocn_diagnostic_solve(dt, s, grid)!{{{
+      implicit none
+
+      real (kind=RKIND), intent(in) :: dt !&lt; Input: Time step
+      type (state_type), intent(inout) :: s !&lt; Input/Output: State information
+      type (mesh_type), intent(in) :: grid !&lt; Input: Grid information
+
+
+      integer :: iEdge, iCell, iVertex, k, cell1, cell2, vertex1, vertex2, eoe, i, j
+      integer :: boundaryMask, velMask, nCells, nEdges, nVertices, nVertLevels, vertexDegree, err
+
+      integer, dimension(:), pointer :: nEdgesOnCell, nEdgesOnEdge, &amp;
+        maxLevelCell, maxLevelEdgeTop, maxLevelEdgeBot, &amp;
+        maxLevelVertexBot
+      integer, dimension(:,:), pointer :: cellsOnEdge, cellsOnVertex, &amp;
+        verticesOnEdge, edgesOnEdge, edgesOnVertex,boundaryCell, kiteIndexOnCell, &amp;
+        verticesOnCell, edgeSignOnVertex, edgeSignOnCell, edgesOnCell
+
+      real (kind=RKIND) :: d2fdx2_cell1, d2fdx2_cell2, coef_3rd_order, r_tmp, &amp;
+        invAreaCell1, invAreaCell2, invAreaTri1, invAreaTri2, invLength, h_vertex, coef
+
+      real (kind=RKIND), dimension(:), allocatable:: pTop, div_hu
+
+      real (kind=RKIND), dimension(:), pointer :: &amp;
+        bottomDepth, fVertex, dvEdge, dcEdge, areaCell, areaTriangle, ssh, seaSurfacePressure
+      real (kind=RKIND), dimension(:,:), pointer :: &amp;
+        weightsOnEdge, kiteAreasOnVertex, h_edge, h, u, v, pressure,&amp;
+        circulation, vorticity, ke, ke_edge, MontPot, wTop, zMid, &amp;
+        Vor_edge, Vor_vertex, Vor_cell, gradVor_n, gradVor_t, divergence, &amp;
+        rho, rhoDisplaced, temperature, salinity, kev, kevc, uBolusGM, uTransport, &amp;
+        vertVelocityTop, BruntVaisalaFreqTop
+      real (kind=RKIND), dimension(:,:,:), pointer :: tracers, deriv_two
+      character :: c1*6
+
+      h           =&gt; s % h % array
+      u           =&gt; s % u % array
+      uTransport  =&gt; s % uTransport % array
+      uBolusGM    =&gt; s % uBolusGM % array
+      v           =&gt; s % v % array
+      h_edge      =&gt; s % h_edge % array
+      circulation =&gt; s % circulation % array
+      vorticity   =&gt; s % vorticity % array
+      divergence  =&gt; s % divergence % array
+      ke          =&gt; s % ke % array
+      kev         =&gt; s % kev % array
+      kevc        =&gt; s % kevc % array
+      ke_edge     =&gt; s % ke_edge % array
+      Vor_edge    =&gt; s % Vor_edge % array
+      Vor_vertex  =&gt; s % Vor_vertex % array
+      Vor_cell    =&gt; s % Vor_cell % array
+      gradVor_n   =&gt; s % gradVor_n % array
+      gradVor_t   =&gt; s % gradVor_t % array
+      rho         =&gt; s % rho % array
+      rhoDisplaced=&gt; s % rhoDisplaced % array
+      MontPot     =&gt; s % MontPot % array
+      pressure    =&gt; s % pressure % array
+      zMid        =&gt; s % zMid % array
+      ssh         =&gt; s % ssh % array
+      tracers     =&gt; s % tracers % array
+      vertVelocityTop =&gt; s % vertVelocityTop % array
+      BruntVaisalaFreqTop =&gt; s % BruntVaisalaFreqTop % array
+
+      weightsOnEdge     =&gt; grid % weightsOnEdge % array
+      kiteAreasOnVertex =&gt; grid % kiteAreasOnVertex % array
+      cellsOnEdge       =&gt; grid % cellsOnEdge % array
+      cellsOnVertex     =&gt; grid % cellsOnVertex % array
+      verticesOnEdge    =&gt; grid % verticesOnEdge % array
+      nEdgesOnCell      =&gt; grid % nEdgesOnCell % array
+      nEdgesOnEdge      =&gt; grid % nEdgesOnEdge % array
+      edgesOnCell       =&gt; grid % edgesOnCell % array
+      edgesOnEdge       =&gt; grid % edgesOnEdge % array
+      edgesOnVertex     =&gt; grid % edgesOnVertex % array
+      dcEdge            =&gt; grid % dcEdge % array
+      dvEdge            =&gt; grid % dvEdge % array
+      areaCell          =&gt; grid % areaCell % array
+      areaTriangle      =&gt; grid % areaTriangle % array
+      bottomDepth       =&gt; grid % bottomDepth % array
+      fVertex           =&gt; grid % fVertex % array
+      deriv_two         =&gt; grid % deriv_two % array
+      maxLevelCell      =&gt; grid % maxLevelCell % array
+      maxLevelEdgeTop   =&gt; grid % maxLevelEdgeTop % array
+      maxLevelEdgeBot   =&gt; grid % maxLevelEdgeBot % array
+      maxLevelVertexBot =&gt; grid % maxLevelVertexBot % array
+      kiteIndexOnCell =&gt; grid % kiteIndexOnCell % array
+      verticesOnCell =&gt; grid % verticesOnCell % array
+
+      seaSurfacePressure =&gt; grid % seaSurfacePressure % array
+                  
+      nCells      = grid % nCells
+      nEdges      = grid % nEdges
+      nVertices   = grid % nVertices
+      nVertLevels = grid % nVertLevels
+      vertexDegree = grid % vertexDegree
+
+      boundaryCell =&gt; grid % boundaryCell % array
+
+      edgeSignOnVertex =&gt; grid % edgeSignOnVertex % array
+      edgeSignOnCell =&gt; grid % edgeSignOnCell % array
+
+      !
+      ! Compute height on cell edges at velocity locations
+      !   Namelist options control the order of accuracy of the reconstructed h_edge value
+      !
+
+      ! initialize h_edge to avoid divide by zero and NaN problems.
+      h_edge = -1.0e34
+      coef_3rd_order = config_coef_3rd_order
+
+      do iEdge=1,nEdges
+         cell1 = cellsOnEdge(1,iEdge)
+         cell2 = cellsOnEdge(2,iEdge)
+         do k=1,maxLevelEdgeTop(iEdge)
+            h_edge(k,iEdge) = 0.5 * (h(k,cell1) + h(k,cell2))
+         end do
+      end do
+
+      !
+      ! set the velocity and height at dummy address
+      !    used -1e34 so error clearly occurs if these values are used.
+      !
+      u(:,nEdges+1) = -1e34
+      h(:,nCells+1) = -1e34
+      tracers(s % index_temperature,:,nCells+1) = -1e34
+      tracers(s % index_salinity,:,nCells+1) = -1e34
+
+      circulation(:,:) = 0.0
+      vorticity(:,:) = 0.0
+      divergence(:,:) = 0.0
+      vertVelocityTop(:,:)=0.0
+      ke(:,:) = 0.0
+      v(:,:) = 0.0
+      do iVertex = 1, nVertices
+         invAreaTri1 = 1.0 / areaTriangle(iVertex)
+         do i = 1, vertexDegree
+            iEdge = edgesOnVertex(i, iVertex)
+            do k = 1, maxLevelVertexBot(iVertex)
+              r_tmp = dcEdge(iEdge) * u(k, iEdge)
+
+              circulation(k, iVertex) = circulation(k, iVertex) + edgeSignOnVertex(i, iVertex) * r_tmp 
+              vorticity(k, iVertex) = vorticity(k, iVertex) + edgeSignOnVertex(i, iVertex) * r_tmp * invAreaTri1
+            end do
+         end do
+      end do
+
+      allocate(div_hu(nVertLevels))
+      do iCell = 1, nCells
+         div_hu(:) = 0.0
+         invAreaCell1 = 1.0 / areaCell(iCell)
+         do i = 1, nEdgesOnCell(iCell)
+            iEdge = edgesOnCell(i, iCell)
+            do k = 1, maxLevelCell(iCell)
+               r_tmp = dvEdge(iEdge) * u(k, iEdge) * invAreaCell1
+
+               divergence(k, iCell) = divergence(k, iCell) - edgeSignOnCell(i, iCell) * r_tmp
+               div_hu(k)    = div_hu(k) - h_edge(k, iEdge) * edgeSignOnCell(i, iCell) * r_tmp 
+               ke(k, iCell) = ke(k, iCell) + 0.25 * r_tmp * dcEdge(iEdge) * u(k,iEdge)
+            end do
+         end do
+         ! Vertical velocity at bottom (maxLevelCell(iCell)+1) is zero, initialized above.
+         do k=maxLevelCell(iCell),1,-1
+            vertVelocityTop(k,iCell) = vertVelocityTop(k+1,iCell) - div_hu(k)
+         end do         
+      end do
+      deallocate(div_hu)
+
+      do iEdge=1,nEdges
+         ! Compute v (tangential) velocities
+         do i=1,nEdgesOnEdge(iEdge)
+            eoe = edgesOnEdge(i,iEdge)
+            do k = 1,maxLevelEdgeTop(iEdge) 
+               v(k,iEdge) = v(k,iEdge) + weightsOnEdge(i,iEdge) * u(k, eoe)
+            end do
+         end do
+      end do
+
+      !
+      ! Compute kinetic energy in each vertex
+      !
+      kev(:,:) = 0.0; kevc(:,:) = 0.0
+      do iVertex = 1, nVertices*ke_vertex_flag
+        do i = 1, vertexDegree
+          iEdge = edgesOnVertex(i, iVertex)
+          r_tmp = dcEdge(iEdge) * dvEdge(iEdge) * 0.25 / areaTriangle(iVertex)
+          do k = 1, nVertLevels
+            kev(k, iVertex) = kev(k, iVertex) + r_tmp * u(k, iEdge)**2
+          end do
+        end do
+      end do
+
+      do iCell = 1, nCells*ke_vertex_flag
+        invAreaCell1 = 1.0 / areaCell(iCell)
+        do i = 1, nEdgesOnCell(iCell)
+          j = kiteIndexOnCell(i, iCell)
+          iVertex = verticesOnCell(i, iCell)
+          do k = 1, nVertLevels
+            kevc(k, iCell) = kevc(k, iCell) + kiteAreasOnVertex(j, iVertex) * kev(k, iVertex) * invAreaCell1
+          end do
+        end do
+      end do
+
+      !
+      ! Compute kinetic energy in each cell by blending ke and kevc
+      !
+      do iCell=1,nCells*ke_vertex_flag
+         do k=1,nVertLevels
+            ke(k,iCell) = 5.0/8.0*ke(k,iCell) + 3.0/8.0*kevc(k,iCell)
+         end do
+      end do
+
+      !
+      ! Compute ke on cell edges at velocity locations for quadratic bottom drag. 
+      !
+      do iEdge=1,nEdges
+         cell1 = cellsOnEdge(1,iEdge)
+         cell2 = cellsOnEdge(2,iEdge)
+         do k=1,maxLevelEdgeTop(iEdge)
+            ke_edge(k,iEdge) = 0.5 * (ke(k,cell1) + ke(k,cell2))
+         end do
+      end do
+
+      !
+      ! Compute height at vertices, pv at vertices, and average pv to edge locations
+      !  ( this computes Vor_vertex at all vertices bounding real cells and distance-1 ghost cells )
+      !
+      do iVertex = 1,nVertices
+         invAreaTri1 = 1.0 / areaTriangle(iVertex)
+         do k=1,maxLevelVertexBot(iVertex)
+            h_vertex = 0.0
+            do i=1,vertexDegree
+               h_vertex = h_vertex + h(k,cellsOnVertex(i,iVertex)) * kiteAreasOnVertex(i,iVertex)
+            end do
+            h_vertex = h_vertex * invAreaTri1
+
+            Vor_vertex(k,iVertex) = (fCoef*fVertex(iVertex) + vorticity(k,iVertex)) / h_vertex
+         end do
+      end do
+
+      Vor_cell(:,:) = 0.0
+      Vor_edge(:,:) = 0.0
+      do iEdge = 1, nEdges
+        vertex1 = verticesOnEdge(1, iEdge)
+        vertex2 = verticesOnEdge(2, iEdge)
+        do k = 1, maxLevelEdgeBot(iEdge)
+          Vor_edge(k, iEdge) = 0.5 * (Vor_vertex(k, vertex1) + Vor_vertex(k, vertex2))
+        end do
+      end do
+
+      do iCell = 1, nCells
+        invAreaCell1 = 1.0 / areaCell(iCell)
+
+        do i = 1, nEdgesOnCell(iCell)
+          j = kiteIndexOnCell(i, iCell)
+          iVertex = verticesOnCell(i, iCell)
+          do k = 1, maxLevelCell(iCell)
+            Vor_cell(k, iCell) = Vor_cell(k, iCell) + kiteAreasOnVertex(j, iVertex) * Vor_vertex(k, iVertex) * invAreaCell1
+          end do
+        end do
+      end do
+
+      do iEdge = 1,nEdges
+         cell1 = cellsOnEdge(1, iEdge)
+         cell2 = cellsOnEdge(2, iEdge)
+         vertex1 = verticesOnedge(1, iEdge)
+         vertex2 = verticesOnedge(2, iEdge)
+
+         invLength = 1.0 / dcEdge(iEdge)
+         ! Compute gradient of PV in normal direction
+         !   ( this computes gradVor_n for all edges bounding real cells )
+         do k=1,maxLevelEdgeTop(iEdge)
+            gradVor_n(k,iEdge) = (Vor_cell(k,cell2) - Vor_cell(k,cell1)) * invLength
+         enddo
+
+         invLength = 1.0 / dvEdge(iEdge)
+         ! Compute gradient of PV in the tangent direction
+         !   ( this computes gradVor_t at all edges bounding real cells and distance-1 ghost cells )
+         do k = 1,maxLevelEdgeBot(iEdge)
+           gradVor_t(k,iEdge) = (Vor_vertex(k,vertex2) - Vor_vertex(k,vertex1)) * invLength
+         enddo
+
+      enddo
+
+      !
+      ! Modify PV edge with upstream bias.
+      !
+      do iEdge = 1,nEdges
+         do k = 1,maxLevelEdgeBot(iEdge)
+           Vor_edge(k,iEdge) = Vor_edge(k,iEdge) &amp;
+             - config_apvm_scale_factor * dt* (  u(k,iEdge) * gradVor_n(k,iEdge) &amp;
+                          + v(k,iEdge) * gradVor_t(k,iEdge) )
+         enddo
+      enddo
+
+      !
+      ! equation of state
+      !
+      ! For an isopycnal model, density should remain constant.
+      ! For zlevel, calculate in-situ density
+      if (config_vert_coord_movement.ne.'isopycnal') then
+         call mpas_timer_start(&quot;equation of state&quot;, .false., diagEOSTimer)
+
+         ! compute in-place density
+         call ocn_equation_of_state_rho(s, grid, 0, 'relative', err)
+
+         ! compute rhoDisplaced, the potential density referenced to the top layer
+         call ocn_equation_of_state_rho(s, grid, 1, 'relative', err)
+
+         call mpas_timer_stop(&quot;equation of state&quot;, diagEOSTimer)
+      endif
+
+      !
+      ! Pressure
+      ! This section must be after computing rho
+      !
+      if (config_pressure_gradient_type.eq.'MontgomeryPotential') then
+
+        ! For Isopycnal model.
+        ! Compute pressure at top of each layer, and then
+        ! Montgomery Potential.
+        allocate(pTop(nVertLevels))
+        do iCell=1,nCells
+
+           ! assume atmospheric pressure at the surface is zero for now.
+           pTop(1) = 0.0
+           ! For isopycnal mode, p is the Montgomery Potential.
+           ! At top layer it is g*SSH, where SSH may be off by a 
+           ! constant (ie, bottomDepth can be relative to top or bottom)
+           MontPot(1,iCell) = gravity &amp;
+              * (bottomDepth(iCell) + sum(h(1:nVertLevels,iCell)))
+
+           do k=2,nVertLevels
+              pTop(k) = pTop(k-1) + rho(k-1,iCell)*gravity* h(k-1,iCell)
+
+              ! from delta M = p delta / rho
+              MontPot(k,iCell) = MontPot(k-1,iCell) &amp;
+                 + pTop(k)*(1.0/rho(k,iCell) - 1.0/rho(k-1,iCell)) 
+           end do
+
+        end do
+        deallocate(pTop)
+
+      else
+
+        do iCell=1,nCells
+           ! Pressure for generalized coordinates.
+           ! Pressure at top surface may be due to atmospheric pressure
+           ! or an ice-shelf depression. 
+           pressure(1,iCell) = seaSurfacePressure(iCell) + rho(1,iCell)*gravity &amp;
+              * 0.5*h(1,iCell)
+
+           do k=2,maxLevelCell(iCell)
+              pressure(k,iCell) = pressure(k-1,iCell)  &amp;
+                + 0.5*gravity*(  rho(k-1,iCell)*h(k-1,iCell) &amp;
+                               + rho(k  ,iCell)*h(k  ,iCell))
+           end do
+
+           ! Compute zMid, the z-coordinate of the middle of the layer.
+           ! This is used for the rho g grad z momentum term.
+           ! Note the negative sign, since bottomDepth is positive
+           ! and z-coordinates are negative below the surface.
+           k = maxLevelCell(iCell)
+           zMid(k:nVertLevels,iCell) = -bottomDepth(iCell) + 0.5*h(k,iCell)
+
+           do k=maxLevelCell(iCell)-1, 1, -1
+              zMid(k,iCell) = zMid(k+1,iCell)  &amp;
+                + 0.5*(  h(k+1,iCell) &amp;
+                       + h(k  ,iCell))
+           end do
+
+        end do
+
+      endif
+
+      !
+      ! Brunt-Vaisala frequency
+      !
+      coef = -gravity/config_rho0
+      do iCell=1,nCells
+         BruntVaisalaFreqTop(1,iCell) = 0.0
+         do k=2,maxLevelCell(iCell)
+            BruntVaisalaFreqTop(k,iCell) = coef * (rhoDisplaced(k-1,iCell) - rhoDisplaced(k,iCell)) &amp; 
+              / (zMid(k-1,iCell) - zMid(k,iCell))
+          end do
+      end do
+
+      !
+      ! Sea Surface Height
+      !
+      do iCell=1,nCells
+         ! Start at the bottom where we know the depth, and go up.
+         ! The bottom depth for this cell is bottomDepth(iCell).
+         ! Note the negative sign, since bottomDepth is positive
+         ! and z-coordinates are negative below the surface.
+
+         ssh(iCell) = - bottomDepth(iCell) + sum(h(1:maxLevelCell(iCell),iCell))
+
+      end do
+
+      !
+      ! Apply the GM closure as a bolus velocity
+      !
+      if (config_h_kappa .GE. epsilon(0D0)) then
+         call ocn_gm_compute_uBolus(s,grid)
+      else
+         uBolusGM = 0.0
+      end if
+
+   end subroutine ocn_diagnostic_solve!}}}
+
+!***********************************************************************
+!
+!  routine ocn_wtop
+!
+!&gt; \brief   Computes vertical transport
+!&gt; \author  Mark Petersen
+!&gt; \date    23 September 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes the vertical transport through the top of each 
+!&gt;  cell.
+!
+!-----------------------------------------------------------------------
+   subroutine ocn_wtop(grid,h,h_edge,u,wTop, err)!{{{
+
+      !-----------------------------------------------------------------
+      !
+      ! input variables
+      !
+      !-----------------------------------------------------------------
+
+      type (mesh_type), intent(in) :: &amp;
+         grid          !&lt; Input: grid information
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         h    !&lt; Input: thickness
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         h_edge     !&lt; Input: h interpolated to an edge
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         u     !&lt; Input: transport
+
+      !-----------------------------------------------------------------
+      !
+      ! output variables
+      !
+      !-----------------------------------------------------------------
+
+      real (kind=RKIND), dimension(:,:), intent(out) :: &amp;
+         wTop     !&lt; Output: vertical transport at top of cell
+
+      integer, intent(out) :: err !&lt; Output: error flag
+
+      !-----------------------------------------------------------------
+      !
+      ! local variables
+      !
+      !-----------------------------------------------------------------
+
+      integer :: iEdge, iCell, iVertex, k, cell1, cell2, vertex1, vertex2, eoe, i, j, cov
+      real (kind=RKIND) :: flux, vorticity_abs, h_vertex, workpv, rho0Inv, hSum, invAreaCell
+
+      integer :: nCells, nEdges, nVertices, nVertLevels, vertexDegree
+
+
+      real (kind=RKIND), dimension(:), pointer :: &amp;
+        dvEdge, areaCell, vertCoordMovementWeights
+      real (kind=RKIND), dimension(:), allocatable:: div_hu, h_tend_col
+      real (kind=RKIND) :: div_hu_btr
+
+      integer, dimension(:,:), pointer :: cellsOnEdge, cellsOnVertex, &amp;
+        verticesOnEdge, edgesOnCell, edgesOnEdge, edgesOnVertex, &amp;
+        boundaryEdge, boundaryCell, edgeSignOnCell
+      integer, dimension(:), pointer :: nEdgesOnCell, nEdgesOnEdge, &amp;
+        maxLevelCell, maxLevelEdgeTop, maxLevelEdgeBot, &amp;
+        maxLevelVertexBot,  maxLevelVertexTop
+
+      err = 0
+
+      nEdgesOnCell      =&gt; grid % nEdgesOnCell % array
+      areaCell          =&gt; grid % areaCell % array
+      cellsOnEdge       =&gt; grid % cellsOnEdge % array
+      edgesOnCell       =&gt; grid % edgesOnCell % array
+      edgeSignOnCell    =&gt; grid % edgeSignOnCell % array
+      maxLevelCell      =&gt; grid % maxLevelCell % array
+      maxLevelEdgeBot   =&gt; grid % maxLevelEdgeBot % array
+      dvEdge            =&gt; grid % dvEdge % array
+      vertCoordMovementWeights =&gt; grid % vertCoordMovementWeights % array
+
+      nCells      = grid % nCells
+      nEdges      = grid % nEdges
+      nVertLevels = grid % nVertLevels
+
+
+      if (config_vert_coord_movement.eq.'isopycnal') then
+        ! set vertical transport to zero in isopycnal case
+        wTop=0.0
+        return
+      end if
+
+      allocate(div_hu(nVertLevels), h_tend_col(nVertLevels))
+
+      !
+      ! Compute div(h^{edge} u) for each cell
+      ! See Ringler et al. (2010) jcp paper, eqn 19, 21, and fig. 3.
+      !
+
+      do iCell=1,nCells
+        div_hu(:) = 0.0
+        div_hu_btr = 0.0
+        hSum = 0.0
+        invAreaCell = 1.0 / areaCell(iCell)
+
+        do i = 1, nEdgesOnCell(iCell)
+          iEdge = edgesOnCell(i, iCell)
+
+          do k = 1, maxLevelEdgeBot(iEdge)
+            flux = h_edge(k, iEdge) * u(k, iEdge) * dvEdge(iEdge) * edgeSignOnCell(i, iCell) * invAreaCell
+            div_hu(k) = div_hu(k) - flux
+            div_hu_btr = div_hu_btr - flux
+          end do
+        end do
+
+        do k = 1, maxLevelCell(iCell)
+           h_tend_col(k) = - vertCoordMovementWeights(k) * h(k, iCell) * div_hu_btr
+           hSum = hSum + vertCoordMovementWeights(k) * h(k, iCell)
+        end do
+
+        if(hSum &gt; 0.0) then
+           h_tend_col = h_tend_col / hSum
+        end if
+
+        ! Vertical transport through layer interface at top and bottom is zero.
+        wTop(1,iCell) = 0.0
+        wTop(maxLevelCell(iCell)+1,iCell) = 0.0
+        do k=maxLevelCell(iCell),2,-1
+           wTop(k,iCell) = wTop(k+1,iCell) - div_hu(k) - h_tend_col(k)
+        end do
+      end do
+
+      deallocate(div_hu, h_tend_col)
+
+   end subroutine ocn_wtop!}}}
+
+!***********************************************************************
+!
+!  routine ocn_fuperp
+!
+!&gt; \brief   Computes f u_perp
+!&gt; \author  Mark Petersen
+!&gt; \date    23 September 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes f u_perp for the ocean
+!
+!-----------------------------------------------------------------------
+
+   subroutine ocn_fuperp(s, grid)!{{{
+      implicit none
+
+      type (state_type), intent(inout) :: s !&lt; Input/Output: State information
+      type (mesh_type), intent(in) :: grid !&lt; Input: Grid information
+
+      integer :: iEdge, cell1, cell2, eoe, i, j, k
+      integer :: nEdgesSolve
+      real (kind=RKIND), dimension(:), pointer :: fEdge
+      real (kind=RKIND), dimension(:,:), pointer :: weightsOnEdge, u, uBcl
+      type (dm_info) :: dminfo
+
+      integer, dimension(:), pointer :: maxLevelEdgeTop, nEdgesOnEdge
+      integer, dimension(:,:), pointer :: cellsOnEdge, edgesOnEdge
+
+      call mpas_timer_start(&quot;ocn_fuperp&quot;)
+
+      u           =&gt; s % u % array
+      uBcl        =&gt; s % uBcl % array
+      weightsOnEdge     =&gt; grid % weightsOnEdge % array
+      fEdge             =&gt; grid % fEdge % array
+      maxLevelEdgeTop      =&gt; grid % maxLevelEdgeTop % array
+      cellsOnEdge       =&gt; grid % cellsOnEdge % array
+      nEdgesOnEdge      =&gt; grid % nEdgesOnEdge % array
+      edgesOnEdge       =&gt; grid % edgesOnEdge % array
+
+      fEdge       =&gt; grid % fEdge % array
+
+      nEdgesSolve = grid % nEdgesSolve
+
+      !
+      ! Put f*uBcl^{perp} in u as a work variable
+      !
+      do iEdge=1,nEdgesSolve
+         cell1 = cellsOnEdge(1,iEdge)
+         cell2 = cellsOnEdge(2,iEdge)
+
+         do k=1,maxLevelEdgeTop(iEdge)
+
+            u(k,iEdge) = 0.0
+            do j = 1,nEdgesOnEdge(iEdge)
+               eoe = edgesOnEdge(j,iEdge)
+               u(k,iEdge) = u(k,iEdge) + weightsOnEdge(j,iEdge) * uBcl(k,eoe) * fEdge(eoe) 
+            end do
+         end do
+      end do
+
+      call mpas_timer_stop(&quot;ocn_fuperp&quot;)
+
+   end subroutine ocn_fuperp!}}}
+
+!***********************************************************************
+!
+!  routine ocn_filter_btr_mode_u
+!
+!&gt; \brief   filters barotropic mode out of the velocity variable.
+!&gt; \author  Mark Petersen
+!&gt; \date    23 September 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine filters barotropic mode out of the velocity variable.
+!
+!-----------------------------------------------------------------------
+   subroutine ocn_filter_btr_mode_u(s, grid)!{{{
+      implicit none
+
+      type (state_type), intent(inout) :: s
+      type (mesh_type), intent(in) :: grid
+
+      integer :: iEdge, k, nEdges
+      real (kind=RKIND) :: vertSum, uhSum, hSum
+      real (kind=RKIND), dimension(:,:), pointer :: h_edge, u
+      integer, dimension(:), pointer :: maxLevelEdgeTop
+
+      call mpas_timer_start(&quot;ocn_filter_btr_mode_u&quot;)
+
+      u           =&gt; s % u % array
+      h_edge      =&gt; s % h_edge % array
+      maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
+      nEdges      = grid % nEdges
+
+      do iEdge=1,nEdges
+
+        ! hSum is initialized outside the loop because on land boundaries 
+        ! maxLevelEdgeTop=0, but I want to initialize hSum with a 
+        ! nonzero value to avoid a NaN.
+        uhSum = h_edge(1,iEdge) * u(1,iEdge)
+        hSum  = h_edge(1,iEdge)
+
+        do k=2,maxLevelEdgeTop(iEdge)
+          uhSum = uhSum + h_edge(k,iEdge) * u(k,iEdge)
+          hSum  =  hSum + h_edge(k,iEdge)
+        enddo
+
+        vertSum = uhSum/hSum
+        do k=1,maxLevelEdgeTop(iEdge)
+          u(k,iEdge) = u(k,iEdge) - vertSum
+        enddo
+      enddo ! iEdge
+
+      call mpas_timer_stop(&quot;ocn_filter_btr_mode_u&quot;)
+
+   end subroutine ocn_filter_btr_mode_u!}}}
+
+!***********************************************************************
+!
+!  routine ocn_filter_btr_mode_tend_u
+!
+!&gt; \brief   ocn_filters barotropic mode out of the u tendency
+!&gt; \author  Mark Petersen
+!&gt; \date    23 September 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine filters barotropic mode out of the u tendency.
+!
+!-----------------------------------------------------------------------
+   subroutine ocn_filter_btr_mode_tend_u(tend, s, grid)!{{{
+      implicit none
+
+      type (tend_type), intent(inout) :: tend
+      type (state_type), intent(in) :: s
+      type (mesh_type), intent(in) :: grid
+
+      integer :: iEdge, k, nEdges
+      real (kind=RKIND) :: vertSum, uhSum, hSum
+      real (kind=RKIND), dimension(:,:), pointer :: h_edge, tend_u
+
+      integer, dimension(:), pointer :: maxLevelEdgeTop
+
+      call mpas_timer_start(&quot;ocn_filter_btr_mode_tend_u&quot;)
+
+      tend_u      =&gt; tend % u % array
+      h_edge      =&gt; s % h_edge % array
+      maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
+      nEdges      = grid % nEdges
+
+      do iEdge=1,nEdges
+
+        ! hSum is initialized outside the loop because on land boundaries 
+        ! maxLevelEdgeTop=0, but I want to initialize hSum with a 
+        ! nonzero value to avoid a NaN.
+        uhSum = h_edge(1,iEdge) * tend_u(1,iEdge)
+        hSum  = h_edge(1,iEdge)
+
+        do k=2,maxLevelEdgeTop(iEdge)
+          uhSum = uhSum + h_edge(k,iEdge) * tend_u(k,iEdge)
+          hSum  =  hSum + h_edge(k,iEdge)
+        enddo
+
+        vertSum = uhSum/hSum
+        do k=1,maxLevelEdgeTop(iEdge)
+          tend_u(k,iEdge) = tend_u(k,iEdge) - vertSum
+        enddo
+      enddo ! iEdge
+
+      call mpas_timer_stop(&quot;ocn_filter_btr_mode_tend_u&quot;)
+
+   end subroutine ocn_filter_btr_mode_tend_u!}}}
+
+!***********************************************************************
+!
+!  routine ocn_diagnostics_init
+!
+!&gt; \brief   Initializes flags used within diagnostics routines.
+!&gt; \author  Mark Petersen
+!&gt; \date    4 November 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine initializes flags related to quantities computed within
+!&gt;  other diagnostics routines.
+!
+!-----------------------------------------------------------------------
+    subroutine ocn_diagnostics_init(err)!{{{
+        integer, intent(out) :: err !&lt; Output: Error flag
+
+        err = 0
+
+        if(config_include_KE_vertex) then
+            ke_vertex_flag = 1
+            ke_cell_flag = 0
+        else
+            ke_vertex_flag = 0
+            ke_cell_flag = 1
+        endif
+
+        if (trim(config_time_integrator) == 'RK4') then
+            ! For RK4, PV includes f: PV = (eta+f)/h.
+            fCoef = 1
+        elseif (trim(config_time_integrator) == 'split_explicit' &amp;
+          .or.trim(config_time_integrator) == 'unsplit_explicit') then
+            ! For split explicit, PV is eta/h because the Coriolis term 
+            ! is added separately to the momentum tendencies.
+            fCoef = 0
+        end if
+
+    end subroutine ocn_diagnostics_init!}}}
+
+!***********************************************************************
+
+end module ocn_diagnostics
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+! vim: foldmethod=marker

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_equation_of_state.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_equation_of_state.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_equation_of_state.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -158,7 +158,7 @@
       linearEos = .false.
       jmEos = .false.
 
-      if(config_vert_grid_type.ne.'isopycnal') then
+      if(config_vert_coord_movement.ne.'isopycnal') then
           eosON = .true.
 
           if (config_eos_type.eq.'linear') then

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_equation_of_state_linear.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_equation_of_state_linear.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_equation_of_state_linear.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -82,27 +82,21 @@
       integer, intent(in) :: indexT, indexS
       integer, intent(out) :: err
 
-      real (kind=RKIND), parameter :: rho_ref = 1025.022 ! kg / m^3
-      real (kind=RKIND), parameter :: alpha =  2.55e-1 ! kg / m^3 / K (dT/dRho)
-      real (kind=RKIND), parameter :: beta = 7.64e-1 ! kg / m^3 / psu (dS/dRho)
-      real (kind=RKIND), parameter :: T_ref = 19.0 ! K
-      real (kind=RKIND), parameter :: S_ref = 35.0 ! psu
-      real (kind=RKIND), parameter :: rho_prime_ref = rho_ref + alpha * T_ref - beta * S_ref
-
       integer, dimension(:), pointer :: maxLevelCell
       integer :: nCells, iCell, k
       type (dm_info) :: dminfo
 
-      maxLevelCell      =&gt; grid % maxLevelCell % array
-      nCells      = grid % nCells
+      maxLevelCell  =&gt; grid % maxLevelCell % array
+      nCells        =  grid % nCells
 
       err = 0
 
       do iCell=1,nCells
          do k=1,maxLevelCell(iCell)
             ! Linear equation of state
-            ! rho = rho_ref - alpha * (T - T_ref) + beta * (S - S_ref)
-            rho(k,iCell) = rho_prime_ref - alpha*tracers(indexT,k,iCell) + beta*tracers(indexS,k,iCell)
+            rho(k,iCell) =  config_eos_linear_rhoref &amp;
+                  - config_eos_linear_alpha * (tracers(indexT,k,iCell)-config_eos_linear_Tref) &amp;
+                  + config_eos_linear_beta  * (tracers(indexS,k,iCell)-config_eos_linear_Sref)
          end do
       end do
 

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_global_diagnostics.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_global_diagnostics.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_global_diagnostics.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -421,27 +421,27 @@
       ! write out the data to files
       if (dminfo % my_proc_id == IO_NODE) then
          fileID = getFreeUnit()
-         open(fileID,file='stats_min.txt',ACCESS='append')
+         open(fileID,file='stats_min.txt',STATUS='UNKNOWN', POSITION='append')
             write (fileID,'(100es24.14)') mins(1:nVariables)
          close (fileID)
-         open(fileID,file='stats_max.txt',ACCESS='append')
+         open(fileID,file='stats_max.txt',STATUS='UNKNOWN', POSITION='append')
             write (fileID,'(100es24.14)') maxes(1:nVariables)
          close (fileID)
-         open(fileID,file='stats_sum.txt',ACCESS='append')
+         open(fileID,file='stats_sum.txt',STATUS='UNKNOWN', POSITION='append')
             write (fileID,'(100es24.14)') sums(1:nVariables)
          close (fileID)
-         open(fileID,file='stats_avg.txt',ACCESS='append')
+         open(fileID,file='stats_avg.txt',STATUS='UNKNOWN', POSITION='append')
             write (fileID,'(100es24.14)') averages(1:nVariables)
          close (fileID)
-         open(fileID,file='stats_time.txt',ACCESS='append')
+         open(fileID,file='stats_time.txt',STATUS='UNKNOWN', POSITION='append')
             write (fileID,'(i10,10x,a,100es24.14)') timeIndex, &amp;
                state % xtime % scalar, dt, &amp;
                CFLNumberGlobal
          close (fileID)
-         open(fileID,file='stats_colmin.txt',ACCESS='append')
+         open(fileID,file='stats_colmin.txt',STATUS='UNKNOWN', POSITION='append')
             write (fileID,'(100es24.14)') verticalSumMins(1:nVariables)
          close (fileID)
-         open(fileID,file='stats_colmax.txt',ACCESS='append')
+         open(fileID,file='stats_colmax.txt',STATUS='UNKNOWN', POSITION='append')
             write (fileID,'(100es24.14)') verticalSumMaxes(1:nVariables)
          close (fileID)
       end if

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_gm.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_gm.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_gm.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -30,7 +30,7 @@
 
 contains
 
-   subroutine ocn_gm_compute_uBolus(s, grid)
+   subroutine ocn_gm_compute_uBolus(s, grid)!{{{
       implicit none
       type(state_type), intent(inout)        :: s
       type(mesh_type), intent(in)            :: grid
@@ -50,7 +50,7 @@
 
       call ocn_gm_compute_hEddyFlux(s, grid)
 
-      if (config_vert_grid_type .EQ. 'isopycnal') then
+      if (config_vert_coord_movement .EQ. 'isopycnal') then
 
          do iEdge = 1, nEdges
             do k = 1, maxLevelEdgeTop(iEdge)
@@ -65,10 +65,9 @@
 
       end if
 
-   end subroutine ocn_gm_compute_uBolus
+   end subroutine ocn_gm_compute_uBolus!}}}
 
-
-   subroutine ocn_gm_compute_hEddyFlux(s, grid)
+   subroutine ocn_gm_compute_hEddyFlux(s, grid)!{{{
       implicit none
       type(state_type), intent(inout)     :: s
       type(mesh_type), intent(in)         :: grid
@@ -90,7 +89,7 @@
 
       hEddyFlux(:,:) = 0.0
 
-      if (config_vert_grid_type .EQ. 'isopycnal') then
+      if (config_vert_coord_movement .EQ. 'isopycnal') then
             do iEdge = 1,nEdges
                cell1 = cellsOnEdge(1,iEdge)
                cell2 = cellsOnEdge(2,iEdge)
@@ -104,12 +103,10 @@
 
       end if
                   
-   end subroutine ocn_gm_compute_hEddyFlux
+   end subroutine ocn_gm_compute_hEddyFlux!}}}
 
+   subroutine ocn_get_h_kappa(s, grid)!{{{
 
-
-   subroutine ocn_get_h_kappa(s, grid)
-
       type (state_type), intent(inout) :: s
       type (mesh_type), intent(in) :: grid
 
@@ -121,11 +118,10 @@
       h_kappa(:,:) = config_h_kappa
 
 
-   end subroutine ocn_get_h_kappa
+   end subroutine ocn_get_h_kappa!}}}
 
+   subroutine ocn_get_h_kappa_q(s, grid)!{{{
 
-   subroutine ocn_get_h_kappa_q(s, grid)
-
       type (state_type), intent(inout) :: s
       type (mesh_type), intent(in) :: grid
 
@@ -137,6 +133,6 @@
       h_kappa_q(:,:) = config_h_kappa_q
 
 
-   end subroutine ocn_get_h_kappa_q
+   end subroutine ocn_get_h_kappa_q!}}}
 
 end module ocn_gm

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_mpas_core.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_mpas_core.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_mpas_core.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -7,16 +7,20 @@
    use mpas_timer
 
    use ocn_global_diagnostics
-   use ocn_test_cases
    use ocn_time_integration
    use ocn_tendency
+   use ocn_diagnostics
 
    use ocn_monthly_forcing
 
+   use ocn_thick_hadv
+   use ocn_thick_vadv
+
    use ocn_vel_pressure_grad
    use ocn_vel_vadv
    use ocn_vel_hmix
    use ocn_vel_forcing
+   use ocn_vel_coriolis
 
    use ocn_tracer_hadv
    use ocn_tracer_vadv
@@ -64,9 +68,16 @@
       ! Initialize submodules before initializing blocks.
       call ocn_timestep_init(err)
 
+      call ocn_thick_hadv_init(err_tmp)
+      err = ior(err, err_tmp)
+
+      call ocn_thick_vadv_init(err_tmp)
+      err = ior(err, err_tmp)
+
+      call ocn_vel_coriolis_init(err_tmp)
+      err = ior(err, err_tmp)
       call ocn_vel_pressure_grad_init(err_tmp)
       err = ior(err, err_tmp)
-
       call ocn_vel_vadv_init(err_tmp)
       err = ior(err, err_tmp)
       call ocn_vel_hmix_init(err_tmp)
@@ -91,6 +102,8 @@
 
       call ocn_tendency_init(err_tmp)
       err = ior(err,err_tmp)
+      call ocn_diagnostics_init(err_tmp)
+      err = ior(err,err_tmp)
 
       call mpas_ocn_tracer_advection_init(err_tmp)
       err = ior(err,err_tmp)
@@ -104,40 +117,38 @@
           call mpas_dmpar_abort(dminfo)
       endif
 
-      if (.not. config_do_restart) call setup_sw_test_case(domain)
+      if (config_vert_coord_movement.ne.'isopycnal') call ocn_init_vert_coord(domain)
 
-      if (config_vert_grid_type.ne.'isopycnal') call ocn_init_vert_coord(domain)
-
       call ocn_compute_max_level(domain)
 
-      if (config_enforce_zstar_at_restart) then
-         call ocn_init_h_zstar(domain)
-      endif
-
       if (.not.config_do_restart) call ocn_init_split_timestep(domain)
 
-      write (0,'(a,a10)'), ' Vertical grid type is: ',config_vert_grid_type
+      write (0,'(a,a)') ' Vertical coordinate movement is: ',trim(config_vert_coord_movement)
 
-      if (config_vert_grid_type.ne.'isopycnal'.and. &amp;
-          config_vert_grid_type.ne.'zlevel'.and. &amp;
-          config_vert_grid_type.ne.'zstar1'.and. &amp;
-          config_vert_grid_type.ne.'zstar'.and. &amp;
-          config_vert_grid_type.ne.'zstarWeights') then
-         write (0,*) ' Incorrect choice of config_vert_grid_type.'
+      if (config_vert_coord_movement.ne.'isopycnal'.and. &amp;
+          config_vert_coord_movement.ne.'fixed'.and. &amp;
+          config_vert_coord_movement.ne.'uniform_stretching'.and. &amp;
+          config_vert_coord_movement.ne.'user_specified') then
+         write (0,*) ' Incorrect choice of config_vert_coord_movement.'
          call mpas_dmpar_abort(dminfo)
       endif
 
-      write (0,'(a,a10)'), ' Pressure type is: ',config_pressure_type
-      if (config_pressure_type.ne.'pressure'.and. &amp;
-          config_pressure_type.ne.'MontgomeryPotential') then
-         write (0,*) ' Incorrect choice of config_pressure_type.'
+      write (0,'(a,a)') ' Pressure type is: ',trim(config_pressure_gradient_type)
+      if (config_pressure_gradient_type.ne.'pressure_and_zmid'.and. &amp;
+          config_pressure_gradient_type.ne.'MontgomeryPotential') then
+         write (0,*) ' Incorrect choice of config_pressure_gradient_type.'
          call mpas_dmpar_abort(dminfo)
       endif
 
+      if(config_vert_coord_movement .ne. 'isopycnal' .and. config_pressure_gradient_type .eq. 'MontgomeryPotential') then
+         write (0,*) ' Incorrect combination of config_vert_coord_movement and config_pressure_gradient_type'
+         call mpas_dmpar_abort(dminfo)
+      end if
+
       if (config_filter_btr_mode.and. &amp;
-          config_vert_grid_type.ne.'zlevel')then
+          config_vert_coord_movement.ne.'fixed')then
          write (0,*) 'filter_btr_mode has only been tested with'// &amp;
-            ' config_vert_grid_type=zlevel.'
+            ' config_vert_coord_movement=fixed.'
          call mpas_dmpar_abort(dminfo)
       endif
 
@@ -158,16 +169,10 @@
          block =&gt; block % next
       end do
 
-   ! mrp 100316 In order for this to work, we need to pass domain % dminfo as an 
-   ! input arguement into mpas_init.  Ask about that later.  For now, there will be
-   ! no initial statistics write.
-   
-      if (config_initial_stats) then
+      if (config_write_stats_on_startup) then
           call mpas_timer_start(&quot;global diagnostics&quot;, .false., globalDiagTimer)
           call ocn_compute_global_diagnostics(domain, 1 , 0, dt)
           call mpas_timer_stop(&quot;global diagnostics&quot;, globalDiagTimer)
-!         call mpas_output_state_init(output_obj, domain, &quot;OUTPUT&quot;)
-!         call ocn_write_output_frame(output_obj, output_frame, domain)
       endif
 
       current_outfile_frames = 0
@@ -184,11 +189,19 @@
 
       type (MPAS_Time_Type) :: startTime, stopTime, alarmStartTime
       type (MPAS_TimeInterval_type) :: runDuration, timeStep, alarmTimeStep
+      character(len=StrKIND) :: restartTimeStamp
       integer :: ierr
 
-      call mpas_set_time(curr_time=startTime, dateTimeString=config_start_time, ierr=ierr)
+      if(config_start_time == 'file') then
+        open(22,file='restart_timestamp',form='formatted',status='old')
+        read(22,*) restartTimeStamp
+        close(22)
+        call mpas_set_time(curr_time=startTime, dateTimeString=restartTimeStamp, ierr=ierr)
+      else
+        call mpas_set_time(curr_time=startTime, dateTimeString=config_start_time, ierr=ierr)
+      end if
+
       call mpas_set_timeInterval(timeStep, dt=dt, ierr=ierr)
-
       if (trim(config_run_duration) /= &quot;none&quot;) then
          call mpas_set_timeInterval(runDuration, timeString=config_run_duration, ierr=ierr)
          call mpas_create_clock(clock, startTime=startTime, timeStep=timeStep, runDuration=runDuration, ierr=ierr)
@@ -222,11 +235,11 @@
       !TODO: use this code if we desire to convert config_stats_interval to alarms 
       !(must also change config_stats_interval type to character) 
       ! set stats alarm, if necessary
-      !if (trim(config_stats_interval) /= &quot;none&quot;) then      
-      !   call mpas_set_timeInterval(alarmTimeStep, timeString=config_stats_interval, ierr=ierr)
-      !   alarmStartTime = startTime + alarmTimeStep
-      !   call mpas_add_clock_alarm(clock, statsAlarmID, alarmStartTime, alarmTimeStep, ierr=ierr)
-      !end if
+      if (trim(config_stats_interval) /= &quot;none&quot;) then      
+         call mpas_set_timeInterval(alarmTimeStep, timeString=config_stats_interval, ierr=ierr)
+         alarmStartTime = startTime + alarmTimeStep
+         call mpas_add_clock_alarm(clock, statsAlarmID, alarmStartTime, alarmTimeStep, ierr=ierr)
+      end if
 
       call mpas_get_time(curr_time=startTime, dateTimeString=startTimeStamp, ierr=ierr)
 
@@ -277,7 +290,6 @@
                        block % state % time_levs(1) % state % uReconstructMeridional % array    &amp;
                       )
 
-!TDR
       call mpas_reconstruct(mesh, mesh % u_src % array,                  &amp;
                        block % state % time_levs(1) % state % uSrcReconstructX % array,            &amp;
                        block % state % time_levs(1) % state % uSrcReconstructY % array,            &amp;
@@ -285,18 +297,12 @@
                        block % state % time_levs(1) % state % uSrcReconstructZonal % array,        &amp;
                        block % state % time_levs(1) % state % uSrcReconstructMeridional % array    &amp;
                       )
-!TDR
 
-      ! initialize velocities and tracers on land to be -1e34
-      ! The reconstructed velocity on land will have values not exactly
-      ! -1e34 due to the interpolation of reconstruction.
+      ! initialize velocities and tracers on land to be zero.
 
       block % mesh % areaCell % array(block % mesh % nCells+1) = -1.0e34
 
       do iEdge=1,block % mesh % nEdges
-         ! mrp 101115 note: in order to include flux boundary conditions, the following
-         ! line will need to change.  Right now, set boundary edges between land and 
-         ! water to have zero velocity.
          block % state % time_levs(1) % state % u % array( &amp;
              block % mesh % maxLevelEdgeTop % array(iEdge)+1 &amp;
             :block % mesh % maxLevelEdgeBot % array(iEdge), iEdge) = 0.0
@@ -304,15 +310,11 @@
          block % state % time_levs(1) % state % u % array( &amp;
              block % mesh % maxLevelEdgeBot % array(iEdge)+1: &amp;
              block % mesh % nVertLevels,iEdge) = 0.0
-! mrp changed to 0
-!             block % mesh % nVertLevels,iEdge) = -1e34
       end do
       do iCell=1,block % mesh % nCells
          block % state % time_levs(1) % state % tracers % array( &amp;
             :, block % mesh % maxLevelCell % array(iCell)+1 &amp;
               :block % mesh % nVertLevels,iCell) =  0.0
-! mrp changed to 0
-!              :block % mesh % nVertLevels,iCell) =  -1e34
       end do
 
       do i=2,nTimeLevs
@@ -506,30 +508,31 @@
    
       call ocn_timestep(domain, dt, timeStamp)
 
-      if (config_stats_interval &gt; 0) then
-          if (mod(itimestep, config_stats_interval) == 0) then
-             call mpas_timer_start(&quot;global diagnostics&quot;, .false., globalDiagTimer)
-             call ocn_compute_global_diagnostics(domain, 2, itimestep, dt);
-             call mpas_timer_stop(&quot;global diagnostics&quot;, globalDiagTimer)
-          end if
-      end if
+      !if (config_stats_interval &gt; 0) then
+      !    if (mod(itimestep, config_stats_interval) == 0) then
+      !       call mpas_timer_start(&quot;global diagnostics&quot;, .false., globalDiagTimer)
+      !       call ocn_compute_global_diagnostics(domain, 2, itimestep, dt);
+      !       call mpas_timer_stop(&quot;global diagnostics&quot;, globalDiagTimer)
+      !    end if
+      !end if
 
       !TODO: replace the above code block with this if we desire to convert config_stats_interval to use alarms
-      !if (mpas_is_alarm_ringing(clock, statsAlarmID, ierr=ierr)) then
-      !   call mpas_reset_clock_alarm(clock, statsAlarmID, ierr=ierr)
+      if (mpas_is_alarm_ringing(clock, statsAlarmID, ierr=ierr)) then
+         call mpas_reset_clock_alarm(clock, statsAlarmID, ierr=ierr)
 
-      !   block_ptr =&gt; domain % blocklist
-      !   if (associated(block_ptr % next)) then
-      !      write(0,*) 'Error: computeGlobalDiagnostics assumes ',&amp;
-      !                 'that there is only one block per processor.'
-      !   end if
+!        block_ptr =&gt; domain % blocklist
+!        if (associated(block_ptr % next)) then
+!           write(0,*) 'Error: computeGlobalDiagnostics assumes ',&amp;
+!                      'that there is only one block per processor.'
+!        end if
    
-      !   call mpas_timer_start(&quot;global diagnostics&quot;)
-      !   call ocn_compute_global_diagnostics(domain % dminfo, &amp;
-      !            block_ptr % state % time_levs(2) % state, block_ptr % mesh, &amp;
-      !            timeStamp, dt)
-      !   call mpas_timer_stop(&quot;global diagnostics&quot;)
-      !end if
+         call mpas_timer_start(&quot;global diagnostics&quot;)
+         call ocn_compute_global_diagnostics(domain, 2, itimestep, dt);
+      !  call ocn_compute_global_diagnostics(domain % dminfo, &amp;
+      !           block_ptr % state % time_levs(2) % state, block_ptr % mesh, &amp;
+      !           timeStamp, dt)
+         call mpas_timer_stop(&quot;global diagnostics&quot;)
+      end if
 
    end subroutine mpas_timestep!}}}
 
@@ -553,7 +556,7 @@
 
       integer, dimension(:), pointer :: maxLevelCell
       real (kind=RKIND), dimension(:), pointer :: refBottomDepth, &amp;
-         refBottomDepthTopOfCell, zstarWeight, hZLevel, bottomDepth
+         refBottomDepthTopOfCell, vertCoordMovementWeights, hZLevel, bottomDepth
       real (kind=RKIND), dimension(:), allocatable :: minBottomDepth, minBottomDepthMid, zMidZLevel
          
       real (kind=RKIND), dimension(:,:), pointer :: h
@@ -570,7 +573,7 @@
          refBottomDepth =&gt; block % mesh % refBottomDepth % array
          refBottomDepthTopOfCell =&gt; block % mesh % refBottomDepthTopOfCell % array
          bottomDepth =&gt; block % mesh % bottomDepth % array
-         zstarWeight =&gt; block % mesh % zstarWeight % array
+         vertCoordMovementWeights =&gt; block % mesh % vertCoordMovementWeights % array
          hZLevel =&gt; block % mesh % hZLevel % array
          maxLevelCell =&gt; block % mesh % maxLevelCell % array
 
@@ -578,11 +581,6 @@
          nVertLevels = block % mesh % nVertLevels
          num_tracers = size(tracers, dim=1)
 
-         ! mrp 120208 right now hZLevel is in the grid.nc file.
-         ! We would like to transition to using refBottomDepth
-         ! as the defining variable instead, and will transition soon.
-         ! When the transition is done, hZLevel can be removed from
-         ! registry and the following four lines deleted.
          refBottomDepth(1) = hZLevel(1)
          do k = 2,nVertLevels
             refBottomDepth(k) = refBottomDepth(k-1) + hZLevel(k)
@@ -594,28 +592,17 @@
             refBottomDepthTopOfCell(k+1) = refBottomDepth(k)
          end do
 
-         ! Initialization of zstarWeights.  This determines how SSH perturbations
+         ! Initialization of vertCoordMovementWeights. This determines how SSH perturbations
          ! are distributed throughout the column.
-         if (config_vert_grid_type.eq.'zlevel') then
+         if (config_vert_coord_movement.eq.'fixed') then
 
-           zstarWeight = 0.0
-           zstarWeight(1) = 1.0
+           vertCoordMovementWeights = 0.0
+           vertCoordMovementWeights(1) = 1.0
 
-         elseif (config_vert_grid_type.eq.'zstar') then
+         elseif (config_vert_coord_movement.eq.'uniform_stretching') then
 
-            zstarWeight = 1.0
+            vertCoordMovementWeights = 1.0
 
-         elseif (config_vert_grid_type.eq.'zstarWeights') then
-
-           ! This is a test with other weights, just to make sure zstar functions
-           ! using variable weights.
-   
-           zstarWeight = 0.0
-           zstarWeight(1:5) = 1.0
-           do k=1,10
-              zstarWeight(5+k) = 1.0-k*0.1
-           end do
-
          endif
 
          ! Initial condition files (ocean.nc, produced by basin) include a realistic
@@ -768,13 +755,13 @@
 
          ! Compute barotropic velocity at first timestep
          ! This is only done upon start-up.
-         if (trim(config_time_integration) == 'unsplit_explicit') then
+         if (trim(config_time_integrator) == 'unsplit_explicit') then
             block % state % time_levs(1) % state % uBtr % array(:) = 0.0
 
               block % state % time_levs(1) % state % uBcl % array(:,:) &amp;
             = block % state % time_levs(1) % state % u % array(:,:) 
 
-         elseif (trim(config_time_integration) == 'split_explicit') then
+         elseif (trim(config_time_integrator) == 'split_explicit') then
 
             if (config_filter_btr_mode) then
                do iCell=1,block % mesh % nCells
@@ -843,64 +830,6 @@
 
    end subroutine ocn_init_split_timestep!}}}
 
-   subroutine ocn_init_h_zstar(domain)!{{{
-   ! If changing from zlevel to zstar, compute h based on zstar weights,
-   ! where SSH is distributed through the layers.  We only change h.
-   ! We do not remap the tracer variables, so this breaks total global 
-   ! conservation.
-
-      use mpas_grid_types
-      use mpas_configure
-
-      implicit none
-
-      type (domain_type), intent(inout) :: domain
-
-      type (block_type), pointer :: block
-
-      integer :: i, iCell, iEdge, iVertex, k, nVertLevels
-      integer, dimension(:), pointer :: maxLevelCell
-
-      real (kind=RKIND) :: hSum, sumZstarWeights
-      real (kind=RKIND), dimension(:), pointer :: hZLevel, zstarWeight, &amp;
-         refBottomDepth
-      real (kind=RKIND), dimension(:,:), pointer :: h
-
-      ! Initialize z-level grid variables from h, read in from input file.
-      block =&gt; domain % blocklist
-      do while (associated(block))
-
-         h          =&gt; block % state % time_levs(1) % state % h % array
-         nVertLevels = block % mesh % nVertLevels
-         hZLevel =&gt; block % mesh % hZLevel % array
-         maxLevelCell =&gt; block % mesh % maxLevelCell % array
-         zstarWeight =&gt; block % mesh % zstarWeight % array
-         refBottomDepth =&gt; block % mesh % refBottomDepth % array
-
-         do iCell=1,block % mesh % nCells
-            ! Compute the total column thickness, hSum, and the sum of zstar weights.
-            hSum = 0.0
-            sumZstarWeights = 0.0
-            do k = 1,maxLevelCell(iCell)
-               hSum = hSum + h(k,iCell) 
-               sumZstarWeights = sumZstarWeights + zstarWeight(k)
-            enddo
-
-            ! h_k = h_k^{zlevel} + zeta * W_k/sum(W_k)
-            ! where zeta is SSH and W_k are weights
-            do k = 1,maxLevelCell(iCell)
-               h(k,iCell) = hZLevel(k) &amp;
-                 + (hSum - refBottomDepth(maxLevelCell(iCell))) &amp;
-                  * zstarWeight(k)/sumZstarWeights
-            enddo
-
-         enddo
-
-      block =&gt; block % next
-      end do
-
-   end subroutine ocn_init_h_zstar!}}}
-
 subroutine ocn_compute_max_level(domain)!{{{
 ! Initialize maxLevel and bouncary grid variables.
 
@@ -951,7 +880,7 @@
 
       ! for z-grids, maxLevelCell should be in input state
       ! Isopycnal grid uses all vertical cells
-      if (config_vert_grid_type.eq.'isopycnal') then
+      if (config_vert_coord_movement.eq.'isopycnal') then
          maxLevelCell(1:nCells) = nVertLevels
       endif
       maxLevelCell(nCells+1) = 0
@@ -1072,7 +1001,7 @@
       meshScalingDel2(:) = 1.0
       meshScalingDel4(:) = 1.0
       meshScaling(:)     = 1.0
-      if (config_h_ScaleWithMesh) then
+      if (config_hmix_ScaleWithMesh) then
          do iEdge=1,mesh%nEdges
             cell1 = mesh % cellsOnEdge % array(1,iEdge)
             cell2 = mesh % cellsOnEdge % array(2,iEdge)

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_tendency.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_tendency.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_tendency.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -8,9 +8,7 @@
 !&gt; \version SVN:$Id:$
 !&gt; \details
 !&gt;  This module contains the routines for computing
-!&gt;  various tendencies for the ocean. As well as routines
-!&gt;  for computing diagnostic variables, and other quantities
-!&gt;  such as wTop.
+!&gt;  tendency terms for the ocean primitive equations.
 !
 !-----------------------------------------------------------------------
 
@@ -25,32 +23,26 @@
 
    use ocn_thick_hadv
    use ocn_thick_vadv
-   use ocn_gm
 
    use ocn_vel_coriolis
    use ocn_vel_pressure_grad
    use ocn_vel_vadv
    use ocn_vel_hmix
    use ocn_vel_forcing
+   use ocn_vmix
 
    use ocn_tracer_hadv
    use ocn_tracer_vadv
    use ocn_tracer_hmix
    use ocn_restoring
 
-   use ocn_equation_of_state
-   use ocn_vmix
-
-   use ocn_time_average
-
    implicit none
    private
    save
 
-   type (timer_node), pointer :: diagEOSTimer
    type (timer_node), pointer :: thickHadvTimer, thickVadvTimer
-   type (timer_node), pointer :: velCorTimer, velVadvTimer, velPgradTimer, velHmixTimer, velForceTimer, velExpVmixTimer
-   type (timer_node), pointer :: tracerHadvTimer, tracerVadvTimer, tracerHmixTimer, tracerExpVmixTimer, tracerRestoringTimer
+   type (timer_node), pointer :: velCorTimer, velVadvTimer, velPgradTimer, velHmixTimer, velForceTimer
+   type (timer_node), pointer :: tracerHadvTimer, tracerVadvTimer, tracerHmixTimer, tracerRestoringTimer
 
    !--------------------------------------------------------------------
    !
@@ -66,13 +58,8 @@
 
    public :: ocn_tend_h, &amp;
              ocn_tend_u, &amp;
-             ocn_tend_scalar, &amp;
-             ocn_diagnostic_solve, &amp;
-             ocn_wtop, &amp;
-             ocn_fuperp, &amp;
-             ocn_tendency_init, &amp;
-             ocn_filter_btr_mode_u, &amp;
-             ocn_filter_btr_mode_tend_u
+             ocn_tend_tracer, &amp;
+             ocn_tendency_init
 
    !--------------------------------------------------------------------
    !
@@ -80,11 +67,6 @@
    !
    !--------------------------------------------------------------------
 
-   integer :: hadv2nd, hadv3rd, hadv4th
-   integer :: ke_cell_flag, ke_vertex_flag
-   real (kind=RKIND) ::  coef_3rd_order, fCoef
-
-
 !***********************************************************************
 
 contains
@@ -126,6 +108,8 @@
       !
       tend_h = 0.0
 
+      if(config_disable_h_all_tend) return
+
       !
       ! height tendency: horizontal advection term -</font>
<font color="gray">abla\cdot ( hu)
       !
@@ -203,9 +187,10 @@
       !
       ! velocity tendency: start accumulating tendency terms
       !
-      ! mrp 110516 efficiency: could remove next line and have first tend_u operation not be additive
       tend_u(:,:) = 0.0
 
+      if(config_disable_u_all_tend) return
+
       !
       ! velocity tendency: nonlinear Coriolis term and grad of kinetic energy
       !
@@ -225,7 +210,7 @@
       ! velocity tendency: pressure gradient
       !
       call mpas_timer_start(&quot;pressure grad&quot;, .false., velPgradTimer)
-      if (config_pressure_type.eq.'MontgomeryPotential') then
+      if (config_pressure_gradient_type.eq.'MontgomeryPotential') then
           call ocn_vel_pressure_grad_tend(grid, MontPot,  zMid, rho, tend_u, err)
       else
           call ocn_vel_pressure_grad_tend(grid, pressure, zMid, rho, tend_u, err)
@@ -235,7 +220,7 @@
       !
       ! velocity tendency: del2 dissipation, </font>
<font color="black">u_2 </font>
<font color="black">abla^2 u
       !   computed as </font>
<font color="black">u( </font>
<font color="black">abla divergence + k \times </font>
<font color="gray">abla vorticity )
-      !   strictly only valid for config_h_mom_eddy_visc2 == constant
+      !   strictly only valid for config_mom_del2 == constant
       !
       call mpas_timer_start(&quot;hmix&quot;, .false., velHmixTimer)
       call ocn_vel_hmix_tend(grid, divergence, vorticity, viscosity, tend_u, err)
@@ -244,8 +229,6 @@
       !
       ! velocity tendency: forcing and bottom drag
       !
-      ! mrp 101115 note: in order to include flux boundary conditions, we will need to 
-      ! know the bottom edge with nonzero velocity and place the drag there.
 
       call mpas_timer_start(&quot;forcings&quot;, .false., velForceTimer)
       call ocn_vel_forcing_tend(grid, u, u_src, ke_edge, h_edge, tend_u, err)
@@ -254,28 +237,23 @@
       !
       ! velocity tendency: vertical mixing d/dz( nu_v du/dz))
       !
-      if (.not.config_implicit_vertical_mix) then
-          call mpas_timer_start(&quot;explicit vmix&quot;, .false., velExpVmixTimer)
-          call ocn_vel_vmix_tend_explicit(grid, u, h_edge, vertvisctopofedge, tend_u, err)
-          call mpas_timer_stop(&quot;explicit vmix&quot;, velExpVmixTimer)
-      endif
       call mpas_timer_stop(&quot;ocn_tend_u&quot;)
 
    end subroutine ocn_tend_u!}}}
 
 !***********************************************************************
 !
-!  routine ocn_tendSalar
+!  routine ocn_tend_tracer
 !
-!&gt; \brief   Computes scalar tendency
+!&gt; \brief   Computes tracer tendency
 !&gt; \author  Doug Jacobsen
 !&gt; \date    23 September 2011
 !&gt; \version SVN:$Id$
 !&gt; \details 
-!&gt;  This routine computes the scalar (tracer) tendency for the ocean
+!&gt;  This routine computes tracer tendencies for the ocean
 !
 !-----------------------------------------------------------------------
-   subroutine ocn_tend_scalar(tend, s, d, grid, dt)!{{{
+   subroutine ocn_tend_tracer(tend, s, d, grid, dt)!{{{
       implicit none
 
       type (tend_type), intent(inout) :: tend !&lt; Input/Output: Tendency structure
@@ -291,7 +269,7 @@
 
       integer :: err, iEdge, k
 
-      call mpas_timer_start(&quot;ocn_tend_scalar&quot;)
+      call mpas_timer_start(&quot;ocn_tend_tracer&quot;)
 
       uTransport  =&gt; s % uTransport % array
       h           =&gt; s % h % array
@@ -303,6 +281,13 @@
       tend_tr     =&gt; tend % tracers % array
       tend_h      =&gt; tend % h % array
 
+      !
+      ! initialize tracer tendency (RHS of tracer equation) to zero.
+      !
+      tend_tr(:,:,:) = 0.0
+
+      if(config_disable_tr_all_tend) return
+
       allocate(uh(grid % nVertLevels, grid % nEdges+1))
       !
       ! QC Comment (3/15/12): need to make sure that uTransport is the right
@@ -314,17 +299,8 @@
       end do
 
       !
-      ! initialize tracer tendency (RHS of tracer equation) to zero.
-      !
-      tend_tr(:,:,:) = 0.0
-
-      !
       ! tracer tendency: horizontal advection term -div( h \phi u)
       !
-      ! mrp 101115 note: in order to include flux boundary conditions, we will need to 
-      ! assign h_edge for maxLevelEdgeTop:maxLevelEdgeBot in the compute_solve_diagnostics
-      ! and then change maxLevelEdgeTop to maxLevelEdgeBot in the following section.
-      ! tracer_edge at the boundary will also need to be defined for flux boundaries.
 
       ! Monotonoic Advection, or standard advection
       call mpas_timer_start(&quot;adv&quot;, .false., tracerHadvTimer)
@@ -338,30 +314,7 @@
       call ocn_tracer_hmix_tend(grid, h_edge, tracers, tend_tr, err)
       call mpas_timer_stop(&quot;hmix&quot;, tracerHmixTimer)
 
-! mrp 110516 printing
-!print *, 'tend_tr 1',minval(tend_tr(3,1,1:nCells)),&amp;
-!                   maxval(tend_tr(3,1,1:nCells))
-!print *, 'tracer  1',minval(tracers(3,1,1:nCells)),&amp;
-!                   maxval(tracers(3,1,1:nCells))
-! mrp 110516 printing end
-
       !
-      ! tracer tendency: vertical diffusion h d/dz( \kappa_v d\phi/dz)
-      !
-      if (.not.config_implicit_vertical_mix) then
-         call mpas_timer_start(&quot;explicit vmix&quot;, .false., tracerExpVmixTimer)
-
-         call ocn_tracer_vmix_tend_explicit(grid, h, vertdifftopofcell, tracers, tend_tr, err)
-
-         call mpas_timer_stop(&quot;explicit vmix&quot;, tracerExpVmixTimer)
-      endif
-
-! mrp 110516 printing
-!print *, 'tend_tr 2',minval(tend_tr(3,1,1:nCells)),&amp;
-!                   maxval(tend_tr(3,1,1:nCells))
-! mrp 110516 printing end
-
-      !
       ! add restoring to T and S in top model layer
       !
       call mpas_timer_start(&quot;restoring&quot;, .false., tracerRestoringTimer)
@@ -370,791 +323,14 @@
 
       call mpas_timer_stop(&quot;restoring&quot;, tracerRestoringTimer)
 
- 10   format(2i8,10e20.10)
-      call mpas_timer_stop(&quot;ocn_tend_scalar&quot;)
+      call mpas_timer_stop(&quot;ocn_tend_tracer&quot;)
 
       deallocate(uh)
 
-   end subroutine ocn_tend_scalar!}}}
+   end subroutine ocn_tend_tracer!}}}
 
 !***********************************************************************
 !
-!  routine ocn_diagnostic_solve
-!
-!&gt; \brief   Computes diagnostic variables
-!&gt; \author  Doug Jacobsen
-!&gt; \date    23 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the diagnostic variables for the ocean
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_diagnostic_solve(dt, s, grid)!{{{
-      implicit none
-
-      real (kind=RKIND), intent(in) :: dt !&lt; Input: Time step
-      type (state_type), intent(inout) :: s !&lt; Input/Output: State information
-      type (mesh_type), intent(in) :: grid !&lt; Input: Grid information
-
-
-      integer :: iEdge, iCell, iVertex, k, cell1, cell2, vertex1, vertex2, eoe, i, j
-      integer :: boundaryMask, velMask, nCells, nEdges, nVertices, nVertLevels, vertexDegree, err
-
-      integer, dimension(:), pointer :: nEdgesOnCell, nEdgesOnEdge, &amp;
-        maxLevelCell, maxLevelEdgeTop, maxLevelEdgeBot, &amp;
-        maxLevelVertexBot
-      integer, dimension(:,:), pointer :: cellsOnEdge, cellsOnVertex, &amp;
-        verticesOnEdge, edgesOnEdge, edgesOnVertex,boundaryCell, kiteIndexOnCell, verticesOnCell, edgeSignOnVertex, edgeSignOnCell, edgesOnCell
-
-      real (kind=RKIND) :: d2fdx2_cell1, d2fdx2_cell2, coef_3rd_order, r_tmp, invAreaCell1, invAreaCell2, invAreaTri1, invAreaTri2, invLength, h_vertex
-
-      real (kind=RKIND), dimension(:), allocatable:: pTop
-
-      real (kind=RKIND), dimension(:), pointer :: &amp;
-        bottomDepth, fVertex, dvEdge, dcEdge, areaCell, areaTriangle, ssh
-      real (kind=RKIND), dimension(:,:), pointer :: &amp;
-        weightsOnEdge, kiteAreasOnVertex, h_edge, h, u, v, pressure,&amp;
-        circulation, vorticity, ke, ke_edge, MontPot, wTop, zMid, &amp;
-        Vor_edge, Vor_vertex, Vor_cell, gradVor_n, gradVor_t, divergence, &amp;
-        rho, temperature, salinity, kev, kevc, uBolusGM, uTransport
-      real (kind=RKIND), dimension(:,:,:), pointer :: tracers, deriv_two
-      real (kind=RKIND), dimension(:,:), allocatable:: div_u
-      character :: c1*6
-
-      h           =&gt; s % h % array
-      u           =&gt; s % u % array
-      uTransport  =&gt; s % uTransport % array
-      uBolusGM    =&gt; s % uBolusGM % array
-      v           =&gt; s % v % array
-      h_edge      =&gt; s % h_edge % array
-      circulation =&gt; s % circulation % array
-      vorticity   =&gt; s % vorticity % array
-      divergence  =&gt; s % divergence % array
-      ke          =&gt; s % ke % array
-      kev         =&gt; s % kev % array
-      kevc        =&gt; s % kevc % array
-      ke_edge     =&gt; s % ke_edge % array
-      Vor_edge    =&gt; s % Vor_edge % array
-      Vor_vertex  =&gt; s % Vor_vertex % array
-      Vor_cell    =&gt; s % Vor_cell % array
-      gradVor_n   =&gt; s % gradVor_n % array
-      gradVor_t   =&gt; s % gradVor_t % array
-      rho         =&gt; s % rho % array
-      MontPot     =&gt; s % MontPot % array
-      pressure    =&gt; s % pressure % array
-      zMid        =&gt; s % zMid % array
-      ssh         =&gt; s % ssh % array
-      tracers     =&gt; s % tracers % array
-
-      weightsOnEdge     =&gt; grid % weightsOnEdge % array
-      kiteAreasOnVertex =&gt; grid % kiteAreasOnVertex % array
-      cellsOnEdge       =&gt; grid % cellsOnEdge % array
-      cellsOnVertex     =&gt; grid % cellsOnVertex % array
-      verticesOnEdge    =&gt; grid % verticesOnEdge % array
-      nEdgesOnCell      =&gt; grid % nEdgesOnCell % array
-      nEdgesOnEdge      =&gt; grid % nEdgesOnEdge % array
-      edgesOnCell       =&gt; grid % edgesOnCell % array
-      edgesOnEdge       =&gt; grid % edgesOnEdge % array
-      edgesOnVertex     =&gt; grid % edgesOnVertex % array
-      dcEdge            =&gt; grid % dcEdge % array
-      dvEdge            =&gt; grid % dvEdge % array
-      areaCell          =&gt; grid % areaCell % array
-      areaTriangle      =&gt; grid % areaTriangle % array
-      bottomDepth       =&gt; grid % bottomDepth % array
-      fVertex           =&gt; grid % fVertex % array
-      deriv_two         =&gt; grid % deriv_two % array
-      maxLevelCell      =&gt; grid % maxLevelCell % array
-      maxLevelEdgeTop   =&gt; grid % maxLevelEdgeTop % array
-      maxLevelEdgeBot   =&gt; grid % maxLevelEdgeBot % array
-      maxLevelVertexBot =&gt; grid % maxLevelVertexBot % array
-      kiteIndexOnCell =&gt; grid % kiteIndexOnCell % array
-      verticesOnCell =&gt; grid % verticesOnCell % array
-                  
-      nCells      = grid % nCells
-      nEdges      = grid % nEdges
-      nVertices   = grid % nVertices
-      nVertLevels = grid % nVertLevels
-      vertexDegree = grid % vertexDegree
-
-      boundaryCell =&gt; grid % boundaryCell % array
-
-      edgeSignOnVertex =&gt; grid % edgeSignOnVertex % array
-      edgeSignOnCell =&gt; grid % edgeSignOnCell % array
-
-
-      !
-      ! Compute height on cell edges at velocity locations
-      !   Namelist options control the order of accuracy of the reconstructed h_edge value
-      !
-      ! mrp 101115 note: in order to include flux boundary conditions, we will need to 
-      ! assign h_edge for maxLevelEdgeTop:maxLevelEdgeBot in the following section
-
-      ! initialize h_edge to avoid divide by zero and NaN problems.
-      h_edge = -1.0e34
-      coef_3rd_order = config_coef_3rd_order
-
-      do iEdge=1,nEdges*hadv2nd
-         cell1 = cellsOnEdge(1,iEdge)
-         cell2 = cellsOnEdge(2,iEdge)
-         do k=1,maxLevelEdgeTop(iEdge)
-            h_edge(k,iEdge) = 0.5 * (h(k,cell1) + h(k,cell2))
-         end do
-      end do
-
-      do iEdge=1,nEdges*hadv3rd
-         cell1 = cellsOnEdge(1,iEdge)
-         cell2 = cellsOnEdge(2,iEdge)
-
-         do k=1,maxLevelEdgeTop(iEdge)
-
-            d2fdx2_cell1 = 0.0
-            d2fdx2_cell2 = 0.0
-
-            boundaryMask = abs(transfer(.not.(boundaryCell(k,cell1) == 0 .and. boundaryCell(k,cell2) == 0), boundaryMask))
-
-            d2fdx2_cell1 = deriv_two(1,1,iEdge) * h(k,cell1) * boundaryMask
-            d2fdx2_cell2 = deriv_two(1,2,iEdge) * h(k,cell2) * boundaryMask
-
-            !-- all edges of cell 1
-            do i=1, nEdgesOnCell(cell1) * boundaryMask
-               d2fdx2_cell1 = d2fdx2_cell1 + &amp;
-               deriv_two(i+1,1,iEdge) * h(k,grid % CellsOnCell % array (i,cell1))
-            end do
-
-            !-- all edges of cell 2
-            do i=1, nEdgesOnCell(cell2) * boundaryMask
-               d2fdx2_cell2 = d2fdx2_cell2 + &amp;
-               deriv_two(i+1,2,iEdge) * h(k,grid % CellsOnCell % array (i,cell2))
-            end do
-
-            velMask = 2*(abs(transfer(u(k,iEdge) &lt;= 0, velMask))) - 1
-
-            h_edge(k,iEdge) = 0.5*(h(k,cell1) + h(k,cell2)) - (dcEdge(iEdge) **2) * (d2fdx2_cell1 + d2fdx2_cell2) / 12.          &amp;
-                            + velMask * (dcEdge(iEdge) **2) * coef_3rd_order*(d2fdx2_cell1 - d2fdx2_cell2) / 12.
-
-         end do   ! do k
-      end do         ! do iEdge
-
-      do iEdge=1,nEdges*hadv4th
-         cell1 = cellsOnEdge(1,iEdge)
-         cell2 = cellsOnEdge(2,iEdge)
-
-         do k=1,maxLevelEdgeTop(iEdge)
-
-            d2fdx2_cell1 = 0.0
-            d2fdx2_cell2 = 0.0
-
-            boundaryMask = abs(transfer(.not.(boundaryCell(k,cell1) == 0 .and. boundaryCell(k,cell2) == 0), boundaryMask))
-
-            d2fdx2_cell1 = deriv_two(1,1,iEdge) * h(k,cell1) * boundaryMask
-            d2fdx2_cell2 = deriv_two(1,2,iEdge) * h(k,cell2) * boundaryMask
-
-            !-- all edges of cell 1
-            do i=1, nEdgesOnCell(cell1) * boundaryMask
-               d2fdx2_cell1 = d2fdx2_cell1 + &amp;
-               deriv_two(i+1,1,iEdge) * h(k,grid % CellsOnCell % array (i,cell1))
-            end do
-
-            !-- all edges of cell 2
-            do i=1, nEdgesOnCell(cell2) * boundaryMask
-               d2fdx2_cell2 = d2fdx2_cell2 + &amp;
-               deriv_two(i+1,2,iEdge) * h(k,grid % CellsOnCell % array (i,cell2))
-            end do
-
-            h_edge(k,iEdge) =   &amp;
-                 0.5*(h(k,cell1) + h(k,cell2))      &amp;
-                    -(dcEdge(iEdge) **2) * (d2fdx2_cell1 + d2fdx2_cell2) / 12.
-
-         end do   ! do k
-      end do         ! do iEdge
-
-      !
-      ! set the velocity and height at dummy address
-      !    used -1e34 so error clearly occurs if these values are used.
-      !
-      u(:,nEdges+1) = -1e34
-      h(:,nCells+1) = -1e34
-      tracers(s % index_temperature,:,nCells+1) = -1e34
-      tracers(s % index_salinity,:,nCells+1) = -1e34
-
-      circulation(:,:) = 0.0
-      vorticity(:,:) = 0.0
-      divergence(:,:) = 0.0
-      ke(:,:) = 0.0
-      v(:,:) = 0.0
-      do iVertex = 1, nVertices
-         invAreaTri1 = 1.0 / areaTriangle(iVertex)
-         do i = 1, vertexDegree
-            iEdge = edgesOnVertex(i, iVertex)
-            do k = 1, maxLevelVertexBot(iVertex)
-              r_tmp = dcEdge(iEdge) * u(k, iEdge)
-
-              circulation(k, iVertex) = circulation(k, iVertex) + edgeSignOnVertex(i, iVertex) * r_tmp 
-              vorticity(k, iVertex) = vorticity(k, iVertex) + edgeSignOnVertex(i, iVertex) * r_tmp * invAreaTri1
-            end do
-         end do
-      end do
-
-      do iCell = 1, nCells
-         invAreaCell1 = 1.0 / areaCell(iCell)
-         do i = 1, nEdgesOnCell(iCell)
-            iEdge = edgesOnCell(i, iCell)
-            do k = 1, maxLevelCell(iCell)
-               r_tmp = dvEdge(iEdge) * u(k, iEdge) * invAreaCell1
-
-               divergence(k, iCell) = divergence(k, iCell) - edgeSignOnCell(i, iCell) * r_tmp
-               ke(k, iCell) = ke(k, iCell) + 0.25 * r_tmp * dcEdge(iEdge) * u(k,iEdge)
-            end do
-         end do
-      end do
-
-      do iEdge=1,nEdges
-         ! Compute v (tangential) velocities
-         do i=1,nEdgesOnEdge(iEdge)
-            eoe = edgesOnEdge(i,iEdge)
-            ! mrp 101115 note: in order to include flux boundary conditions,
-            ! the following loop may need to change to maxLevelEdgeBot
-            do k = 1,maxLevelEdgeTop(iEdge) 
-               v(k,iEdge) = v(k,iEdge) + weightsOnEdge(i,iEdge) * u(k, eoe)
-            end do
-         end do
-
-      end do
-
-      !
-      ! Compute kinetic energy in each vertex
-      !
-      kev(:,:) = 0.0; kevc(:,:) = 0.0
-      do iVertex = 1, nVertices*ke_vertex_flag
-        do i = 1, vertexDegree
-          iEdge = edgesOnVertex(i, iVertex)
-          r_tmp = dcEdge(iEdge) * dvEdge(iEdge) * 0.25 / areaTriangle(iVertex)
-          do k = 1, nVertLevels
-            kev(k, iVertex) = kev(k, iVertex) + r_tmp * u(k, iEdge)**2
-          end do
-        end do
-      end do
-
-      do iCell = 1, nCells*ke_vertex_flag
-        invAreaCell1 = 1.0 / areaCell(iCell)
-        do i = 1, nEdgesOnCell(iCell)
-          j = kiteIndexOnCell(i, iCell)
-          iVertex = verticesOnCell(i, iCell)
-          do k = 1, nVertLevels
-            kevc(k, iCell) = kevc(k, iCell) + kiteAreasOnVertex(j, iVertex) * kev(k, iVertex) * invAreaCell1
-          end do
-        end do
-      end do
-
-      !
-      ! Compute kinetic energy in each cell by blending ke and kevc
-      !
-      do iCell=1,nCells*ke_vertex_flag
-         do k=1,nVertLevels
-            ke(k,iCell) = 5.0/8.0*ke(k,iCell) + 3.0/8.0*kevc(k,iCell)
-         end do
-      end do
-
-      !
-      ! Compute ke on cell edges at velocity locations for quadratic bottom drag. 
-      !
-      ! mrp 101025 efficiency note: we could get rid of ke_edge completely by 
-      ! using sqrt(u(k,iEdge)**2 + v(k,iEdge)**2) in its place elsewhere.
-      do iEdge=1,nEdges
-         cell1 = cellsOnEdge(1,iEdge)
-         cell2 = cellsOnEdge(2,iEdge)
-         do k=1,maxLevelEdgeTop(iEdge)
-            ke_edge(k,iEdge) = 0.5 * (ke(k,cell1) + ke(k,cell2))
-         end do
-      end do
-
-      !
-      ! Compute height at vertices, pv at vertices, and average pv to edge locations
-      !  ( this computes Vor_vertex at all vertices bounding real cells and distance-1 ghost cells )
-      !
-      do iVertex = 1,nVertices
-         invAreaTri1 = 1.0 / areaTriangle(iVertex)
-         do k=1,maxLevelVertexBot(iVertex)
-            h_vertex = 0.0
-            do i=1,vertexDegree
-               h_vertex = h_vertex + h(k,cellsOnVertex(i,iVertex)) * kiteAreasOnVertex(i,iVertex)
-            end do
-            h_vertex = h_vertex * invAreaTri1
-
-            Vor_vertex(k,iVertex) = (fCoef*fVertex(iVertex) + vorticity(k,iVertex)) / h_vertex
-         end do
-      end do
-
-      Vor_cell(:,:) = 0.0
-      Vor_edge(:,:) = 0.0
-      do iEdge = 1, nEdges
-        vertex1 = verticesOnEdge(1, iEdge)
-        vertex2 = verticesOnEdge(2, iEdge)
-        do k = 1, maxLevelEdgeBot(iEdge)
-          Vor_edge(k, iEdge) = 0.5 * (Vor_vertex(k, vertex1) + Vor_vertex(k, vertex2))
-        end do
-      end do
-
-      do iCell = 1, nCells
-        invAreaCell1 = 1.0 / areaCell(iCell)
-
-        do i = 1, nEdgesOnCell(iCell)
-          j = kiteIndexOnCell(i, iCell)
-          iVertex = verticesOnCell(i, iCell)
-          do k = 1, maxLevelCell(iCell)
-            Vor_cell(k, iCell) = Vor_cell(k, iCell) + kiteAreasOnVertex(j, iVertex) * Vor_vertex(k, iVertex) * invAreaCell1
-          end do
-        end do
-      end do
-
-      do iEdge = 1,nEdges
-         cell1 = cellsOnEdge(1, iEdge)
-         cell2 = cellsOnEdge(2, iEdge)
-         vertex1 = verticesOnedge(1, iEdge)
-         vertex2 = verticesOnedge(2, iEdge)
-
-         invLength = 1.0 / dcEdge(iEdge)
-         ! Compute gradient of PV in normal direction
-         !   ( this computes gradVor_n for all edges bounding real cells )
-         do k=1,maxLevelEdgeTop(iEdge)
-            gradVor_n(k,iEdge) = (Vor_cell(k,cell2) - Vor_cell(k,cell1)) * invLength
-         enddo
-
-         invLength = 1.0 / dvEdge(iEdge)
-         ! Compute gradient of PV in the tangent direction
-         !   ( this computes gradVor_t at all edges bounding real cells and distance-1 ghost cells )
-         do k = 1,maxLevelEdgeBot(iEdge)
-           gradVor_t(k,iEdge) = (Vor_vertex(k,vertex2) - Vor_vertex(k,vertex1)) * invLength
-         enddo
-
-      enddo
-
-      !
-      ! Modify PV edge with upstream bias.
-      !
-      do iEdge = 1,nEdges
-         do k = 1,maxLevelEdgeBot(iEdge)
-           Vor_edge(k,iEdge) = Vor_edge(k,iEdge) &amp;
-             - config_apvm_scale_factor * dt* (  u(k,iEdge) * gradVor_n(k,iEdge) &amp;
-                          + v(k,iEdge) * gradVor_t(k,iEdge) )
-         enddo
-      enddo
-
-      !
-      ! equation of state
-      !
-      ! For an isopycnal model, density should remain constant.
-      ! For zlevel, calculate in-situ density
-      if (config_vert_grid_type.ne.'isopycnal') then
-         call mpas_timer_start(&quot;equation of state&quot;, .false., diagEOSTimer)
-         call ocn_equation_of_state_rho(s, grid, 0, 'relative', err)
-      ! mrp 110324 In order to visualize rhoDisplaced, include the following
-         call ocn_equation_of_state_rho(s, grid, 1, 'relative', err)
-         call mpas_timer_stop(&quot;equation of state&quot;, diagEOSTimer)
-      endif
-
-      !
-      ! Pressure
-      ! This section must be after computing rho
-      !
-      ! dwj: 10/25/2011 - Need to explore isopycnal vs zlevel flags
-      if (config_pressure_type.eq.'MontgomeryPotential') then
-
-        ! For Isopycnal model.
-        ! Compute pressure at top of each layer, and then
-        ! Montgomery Potential.
-        allocate(pTop(nVertLevels))
-        do iCell=1,nCells
-
-           ! assume atmospheric pressure at the surface is zero for now.
-           pTop(1) = 0.0
-           ! For isopycnal mode, p is the Montgomery Potential.
-           ! At top layer it is g*SSH, where SSH may be off by a 
-           ! constant (ie, bottomDepth can be relative to top or bottom)
-           MontPot(1,iCell) = gravity &amp;
-              * (bottomDepth(iCell) + sum(h(1:nVertLevels,iCell)))
-
-           do k=2,nVertLevels
-              pTop(k) = pTop(k-1) + rho(k-1,iCell)*gravity* h(k-1,iCell)
-
-              ! from delta M = p delta / rho
-              MontPot(k,iCell) = MontPot(k-1,iCell) &amp;
-                 + pTop(k)*(1.0/rho(k,iCell) - 1.0/rho(k-1,iCell)) 
-           end do
-
-        end do
-        deallocate(pTop)
-
-      else
-
-        do iCell=1,nCells
-           ! pressure for generalized coordinates
-           ! assume atmospheric pressure at the surface is zero for now.
-           pressure(1,iCell) = rho(1,iCell)*gravity &amp;
-              * 0.5*h(1,iCell)
-
-           do k=2,maxLevelCell(iCell)
-              pressure(k,iCell) = pressure(k-1,iCell)  &amp;
-                + 0.5*gravity*(  rho(k-1,iCell)*h(k-1,iCell) &amp;
-                               + rho(k  ,iCell)*h(k  ,iCell))
-           end do
-
-           ! Compute zMid, the z-coordinate of the middle of the layer.
-           ! This is used for the rho g grad z momentum term.
-           ! Note the negative sign, since bottomDepth is positive
-           ! and z-coordinates are negative below the surface.
-           k = maxLevelCell(iCell)
-           zMid(k:nVertLevels,iCell) = -bottomDepth(iCell) + 0.5*h(k,iCell)
-
-           do k=maxLevelCell(iCell)-1, 1, -1
-              zMid(k,iCell) = zMid(k+1,iCell)  &amp;
-                + 0.5*(  h(k+1,iCell) &amp;
-                       + h(k  ,iCell))
-           end do
-
-        end do
-
-      endif
-
-      !
-      ! Sea Surface Height
-      !
-      do iCell=1,nCells
-         ! Start at the bottom where we know the depth, and go up.
-         ! The bottom depth for this cell is bottomDepth(iCell).
-         ! Note the negative sign, since bottomDepth is positive
-         ! and z-coordinates are negative below the surface.
-
-         ssh(iCell) = - bottomDepth(iCell) + sum(h(1:maxLevelCell(iCell),iCell))
-
-      end do
-
-      !
-      ! Apply the GM closure as a bolus velocity
-      !
-      if (config_h_kappa .GE. epsilon(0D0)) then
-         call ocn_gm_compute_uBolus(s,grid)
-      else
-         ! mrp efficiency note: if uBolusGM is guaranteed to be zero, this can be removed.
-         uBolusGM = 0.0
-      end if
-
-   end subroutine ocn_diagnostic_solve!}}}
-
-!***********************************************************************
-!
-!  routine ocn_wtop
-!
-!&gt; \brief   Computes vertical velocity
-!&gt; \author  Doug Jacobsen
-!&gt; \date    23 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the vertical velocity in the top layer for the ocean
-!
-!-----------------------------------------------------------------------
-   subroutine ocn_wtop(grid,h,h_edge,u,wTop, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      type (mesh_type), intent(in) :: &amp;
-         grid          !&lt; Input: grid information
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h    !&lt; Input: thickness
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge     !&lt; Input: h interpolated to an edge
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         u     !&lt; Input: velocity
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(out) :: &amp;
-         wTop     !&lt; Output: vertical transport at top edge
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: iEdge, iCell, iVertex, k, cell1, cell2, vertex1, vertex2, eoe, i, j, cov
-      real (kind=RKIND) :: flux, vorticity_abs, h_vertex, workpv, rho0Inv, hSum, invAreaCell
-
-      integer :: nCells, nEdges, nVertices, nVertLevels, vertexDegree
-
-
-      real (kind=RKIND), dimension(:), pointer :: &amp;
-        dvEdge, areaCell, zstarWeight
-      real (kind=RKIND), dimension(:), allocatable:: div_hu, h_tend_col
-      real (kind=RKIND) :: div_hu_btr
-
-      integer, dimension(:,:), pointer :: cellsOnEdge, cellsOnVertex, &amp;
-        verticesOnEdge, edgesOnCell, edgesOnEdge, edgesOnVertex, &amp;
-        boundaryEdge, boundaryCell, edgeSignOnCell
-      integer, dimension(:), pointer :: nEdgesOnCell, nEdgesOnEdge, &amp;
-        maxLevelCell, maxLevelEdgeTop, maxLevelEdgeBot, &amp;
-        maxLevelVertexBot,  maxLevelVertexTop
-
-      err = 0
-
-      nEdgesOnCell      =&gt; grid % nEdgesOnCell % array
-      areaCell          =&gt; grid % areaCell % array
-      cellsOnEdge       =&gt; grid % cellsOnEdge % array
-      edgesOnCell       =&gt; grid % edgesOnCell % array
-      edgeSignOnCell    =&gt; grid % edgeSignOnCell % array
-      maxLevelCell      =&gt; grid % maxLevelCell % array
-      maxLevelEdgeBot   =&gt; grid % maxLevelEdgeBot % array
-      dvEdge            =&gt; grid % dvEdge % array
-      zstarWeight       =&gt; grid % zstarWeight % array
-
-      nCells      = grid % nCells
-      nEdges      = grid % nEdges
-      nVertLevels = grid % nVertLevels
-
-
-      if (config_vert_grid_type.eq.'isopycnal') then
-        ! set vertical velocity to zero in isopycnal case
-        wTop=0.0_RKIND
-        return
-      end if
-
-      allocate(div_hu(nVertLevels), h_tend_col(nVertLevels))
-
-      !
-      ! Compute div(h^{edge} u) for each cell
-      ! See Ringler et al. (2010) jcp paper, eqn 19, 21, and fig. 3.
-      !
-
-      do iCell=1,nCells
-        div_hu(:) = 0.0_RKIND
-        div_hu_btr = 0.0_RKIND
-        hSum = 0.0_RKIND
-        invAreaCell = 1.0_RKIND / areaCell(iCell)
-
-        do i = 1, nEdgesOnCell(iCell)
-          iEdge = edgesOnCell(i, iCell)
-
-          do k = 1, maxLevelEdgeBot(iEdge)
-            flux = u(k, iEdge) * dvEdge(iEdge) * h_edge(k, iEdge)
-            flux = edgeSignOnCell(i, iCell) * flux * invAreaCell
-            div_hu(k) = div_hu(k) - flux
-            div_hu_btr = div_hu_btr - flux
-          end do
-        end do
-
-        do k = 1, maxLevelCell(iCell)
-           h_tend_col(k) = - zstarWeight(k) * h(k, iCell) * div_hu_btr
-           hSum = hSum + zstarWeight(k) * h(k, iCell)
-        end do
-
-        if(hSum &gt; 0.0) then
-           h_tend_col = h_tend_col / hSum
-        end if
-
-        ! Vertical velocity through layer interface at top and 
-        ! bottom is zero.
-        wTop(1,iCell) = 0.0_RKIND
-        wTop(maxLevelCell(iCell)+1,iCell) = 0.0_RKIND
-        do k=maxLevelCell(iCell),2,-1
-           wTop(k,iCell) = wTop(k+1,iCell) - div_hu(k) - h_tend_col(k)
-        end do
-      end do
-
-      deallocate(div_hu, h_tend_col)
-
-   end subroutine ocn_wtop!}}}
-
-!***********************************************************************
-!
-!  routine ocn_fuperp
-!
-!&gt; \brief   Computes f u_perp
-!&gt; \author  Doug Jacobsen
-!&gt; \date    23 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes f u_perp for the ocean
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_fuperp(s, grid)!{{{
-      implicit none
-
-      type (state_type), intent(inout) :: s !&lt; Input/Output: State information
-      type (mesh_type), intent(in) :: grid !&lt; Input: Grid information
-
-! mrp 110512 I just split compute_tend into compute_tend_u and compute_tend_h.
-!  Some of these variables can be removed, but at a later time.
-      integer :: iEdge, cell1, cell2, eoe, i, j, k
-
-      integer :: nEdgesSolve
-      real (kind=RKIND), dimension(:), pointer :: fEdge
-      real (kind=RKIND), dimension(:,:), pointer :: weightsOnEdge, u, uBcl
-      type (dm_info) :: dminfo
-
-      integer, dimension(:), pointer :: maxLevelEdgeTop, nEdgesOnEdge
-      integer, dimension(:,:), pointer :: cellsOnEdge, edgesOnEdge
-
-      call mpas_timer_start(&quot;ocn_fuperp&quot;)
-
-      u           =&gt; s % u % array
-      uBcl        =&gt; s % uBcl % array
-      weightsOnEdge     =&gt; grid % weightsOnEdge % array
-      fEdge             =&gt; grid % fEdge % array
-      maxLevelEdgeTop      =&gt; grid % maxLevelEdgeTop % array
-      cellsOnEdge       =&gt; grid % cellsOnEdge % array
-      nEdgesOnEdge      =&gt; grid % nEdgesOnEdge % array
-      edgesOnEdge       =&gt; grid % edgesOnEdge % array
-
-      fEdge       =&gt; grid % fEdge % array
-
-      nEdgesSolve = grid % nEdgesSolve
-
-      !
-      ! Put f*uBcl^{perp} in u as a work variable
-      !
-      do iEdge=1,nEdgesSolve
-         cell1 = cellsOnEdge(1,iEdge)
-         cell2 = cellsOnEdge(2,iEdge)
-
-         do k=1,maxLevelEdgeTop(iEdge)
-
-            u(k,iEdge) = 0.0
-            do j = 1,nEdgesOnEdge(iEdge)
-               eoe = edgesOnEdge(j,iEdge)
-               u(k,iEdge) = u(k,iEdge) + weightsOnEdge(j,iEdge) * uBcl(k,eoe) * fEdge(eoe) 
-            end do
-         end do
-      end do
-
-      call mpas_timer_stop(&quot;ocn_fuperp&quot;)
-
-   end subroutine ocn_fuperp!}}}
-
-!***********************************************************************
-!
-!  routine ocn_filter_btr_mode_u
-!
-!&gt; \brief   filters barotropic mode out of the velocity variable.
-!&gt; \author  Mark Petersen
-!&gt; \date    23 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine filters barotropic mode out of the velocity variable.
-!
-!-----------------------------------------------------------------------
-   subroutine ocn_filter_btr_mode_u(s, grid)!{{{
-      implicit none
-
-      type (state_type), intent(inout) :: s
-      type (mesh_type), intent(in) :: grid
-
-      integer :: iEdge, k, nEdges
-      real (kind=RKIND) :: vertSum, uhSum, hSum
-      real (kind=RKIND), dimension(:,:), pointer :: h_edge, u
-      integer, dimension(:), pointer :: maxLevelEdgeTop
-
-      call mpas_timer_start(&quot;ocn_filter_btr_mode_u&quot;)
-
-      u           =&gt; s % u % array
-      h_edge      =&gt; s % h_edge % array
-      maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
-      nEdges      = grid % nEdges
-
-      do iEdge=1,nEdges
-
-        ! hSum is initialized outside the loop because on land boundaries 
-        ! maxLevelEdgeTop=0, but I want to initialize hSum with a 
-        ! nonzero value to avoid a NaN.
-        uhSum = h_edge(1,iEdge) * u(1,iEdge)
-        hSum  = h_edge(1,iEdge)
-
-        do k=2,maxLevelEdgeTop(iEdge)
-          uhSum = uhSum + h_edge(k,iEdge) * u(k,iEdge)
-          hSum  =  hSum + h_edge(k,iEdge)
-        enddo
-
-        vertSum = uhSum/hSum
-        do k=1,maxLevelEdgeTop(iEdge)
-          u(k,iEdge) = u(k,iEdge) - vertSum
-        enddo
-      enddo ! iEdge
-
-      call mpas_timer_stop(&quot;ocn_filter_btr_mode_u&quot;)
-
-   end subroutine ocn_filter_btr_mode_u!}}}
-
-!***********************************************************************
-!
-!  routine ocn_filter_btr_mode_tend_u
-!
-!&gt; \brief   ocn_filters barotropic mode out of the u tendency
-!&gt; \author  Mark Petersen
-!&gt; \date    23 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine filters barotropic mode out of the u tendency.
-!
-!-----------------------------------------------------------------------
-   subroutine ocn_filter_btr_mode_tend_u(tend, s, grid)!{{{
-      implicit none
-
-      type (tend_type), intent(inout) :: tend
-      type (state_type), intent(in) :: s
-      type (mesh_type), intent(in) :: grid
-
-      integer :: iEdge, k, nEdges
-      real (kind=RKIND) :: vertSum, uhSum, hSum
-      real (kind=RKIND), dimension(:,:), pointer :: h_edge, tend_u
-
-      integer, dimension(:), pointer :: maxLevelEdgeTop
-
-      call mpas_timer_start(&quot;ocn_filter_btr_mode_tend_u&quot;)
-
-      tend_u      =&gt; tend % u % array
-      h_edge      =&gt; s % h_edge % array
-      maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
-      nEdges      = grid % nEdges
-
-      do iEdge=1,nEdges
-
-        ! hSum is initialized outside the loop because on land boundaries 
-        ! maxLevelEdgeTop=0, but I want to initialize hSum with a 
-        ! nonzero value to avoid a NaN.
-        uhSum = h_edge(1,iEdge) * tend_u(1,iEdge)
-        hSum  = h_edge(1,iEdge)
-
-        do k=2,maxLevelEdgeTop(iEdge)
-          uhSum = uhSum + h_edge(k,iEdge) * tend_u(k,iEdge)
-          hSum  =  hSum + h_edge(k,iEdge)
-        enddo
-
-        vertSum = uhSum/hSum
-        do k=1,maxLevelEdgeTop(iEdge)
-          tend_u(k,iEdge) = tend_u(k,iEdge) - vertSum
-        enddo
-      enddo ! iEdge
-
-      call mpas_timer_stop(&quot;ocn_filter_btr_mode_tend_u&quot;)
-
-   end subroutine ocn_filter_btr_mode_tend_u!}}}
-
-!***********************************************************************
-!
 !  routine ocn_tendency_init
 !
 !&gt; \brief   Initializes flags used within tendency routines.
@@ -1171,49 +347,6 @@
 
         err = 0
 
-        coef_3rd_order = 0.
-
-        if (config_thickness_adv_order == 2) then
-            hadv2nd = 1
-            hadv3rd = 0
-            hadv4th = 0
-        else if (config_thickness_adv_order == 3) then
-            hadv2nd = 0
-            hadv3rd = 1
-            hadv4th = 0
-
-            if(config_monotonic) then
-                coef_3rd_order = 0.25
-            else
-                coef_3rd_order = 1.0
-            endif
-        else if (config_thickness_adv_order == 4) then
-            hadv2nd = 0
-            hadv3rd = 0
-            hadv4th = 1
-        end if
-
-
-        if(config_include_KE_vertex) then
-            ke_vertex_flag = 1
-            ke_cell_flag = 0
-        else
-            ke_vertex_flag = 0
-            ke_cell_flag = 1
-        endif
-
-        if (trim(config_time_integration) == 'RK4') then
-            ! for RK4, PV is really PV = (eta+f)/h
-            fCoef = 1
-        elseif (trim(config_time_integration) == 'split_explicit' &amp;
-          .or.trim(config_time_integration) == 'unsplit_explicit') then
-            ! for split explicit, PV is eta/h because f is added separately to the momentum forcing.
-            ! mrp temp, new should be:
-            fCoef = 0
-            ! old, for testing:
-            !         fCoef = 1
-        end if
-
     end subroutine ocn_tendency_init!}}}
 
 !***********************************************************************

Deleted: branches/atmos_physics/src/core_ocean/mpas_ocn_test_cases.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_test_cases.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_test_cases.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -1,526 +0,0 @@
- module ocn_test_cases
-
-   use mpas_grid_types
-   use mpas_configure
-   use mpas_constants
-
-
-   contains
-
-
-   subroutine setup_sw_test_case(domain)
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   ! Configure grid metadata and model state for the shallow water test case 
-   !   specified in the namelist
-   !
-   ! Output: block - a subset (not necessarily proper) of the model domain to be
-   !                 initialized
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      implicit none
-
-      type (domain_type), intent(inout) :: domain
-
-      integer :: i, iCell, iEdge, iVtx, iLevel
-      type (block_type), pointer :: block_ptr
-      type (dm_info) :: dminfo
-
-      if (config_test_case == 0) then
-         write(0,*) 'Using initial conditions supplied in input file'
-
-      else if (config_test_case == 1) then
-         write(0,*) ' Setting up shallow water test case 1:'
-         write(0,*) ' Advection of Cosine Bell over the Pole'
-
-         block_ptr =&gt; domain % blocklist
-         do while (associated(block_ptr))
-            call sw_test_case_1(block_ptr % mesh, block_ptr % state % time_levs(1) % state)
-            block_ptr =&gt; block_ptr % next
-         end do
-
-      else if (config_test_case == 2) then
-         write(0,*) ' Setup shallow water test case 2: '// &amp;
-           'Global Steady State Nonlinear Zonal Geostrophic Flow'
-
-         block_ptr =&gt; domain % blocklist
-         do while (associated(block_ptr))
-            call sw_test_case_2(block_ptr % mesh, block_ptr % state % time_levs(1) % state)
-            block_ptr =&gt; block_ptr % next
-         end do
-
-      else if (config_test_case == 5) then
-         write(0,*) ' Setup shallow water test case 5:'// &amp;
-           ' Zonal Flow over an Isolated Mountain'
-
-         block_ptr =&gt; domain % blocklist
-         do while (associated(block_ptr))
-            call sw_test_case_5(block_ptr % mesh, block_ptr % state % time_levs(1) % state)
-            block_ptr =&gt; block_ptr % next
-         end do
-
-      else if (config_test_case == 6) then
-         write(0,*) ' Set up shallow water test case 6:'
-         write(0,*) ' Rossby-Haurwitz Wave'
-
-         block_ptr =&gt; domain % blocklist
-         do while (associated(block_ptr))
-            call sw_test_case_6(block_ptr % mesh, block_ptr % state % time_levs(1) % state)
-            block_ptr =&gt; block_ptr % next
-         end do
-
-      else
-         write(0,*) 'Abort: config_test_case=',config_test_case
-         write(0,*) 'Only test case 1, 2, 5, and 6 ', &amp;
-           'are currently supported.  '
-           call mpas_dmpar_abort(dminfo)
-      end if
-
-      block_ptr =&gt; domain % blocklist
-      do while (associated(block_ptr))
-
-        do i=2,nTimeLevs
-           call mpas_copy_state(block_ptr % state % time_levs(i) % state, &amp;
-                           block_ptr % state % time_levs(1) % state)
-        end do
-
-        block_ptr =&gt; block_ptr % next
-      end do
-
-   end subroutine setup_sw_test_case
-
-
-   subroutine sw_test_case_1(grid, state)
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   ! Setup shallow water test case 1: Advection of Cosine Bell over the Pole
-   !
-   ! Reference: Williamson, D.L., et al., &quot;A Standard Test Set for Numerical 
-   !            Approximations to the Shallow Water Equations in Spherical 
-   !            Geometry&quot; J. of Comp. Phys., 102, pp. 211--224
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      implicit none
-
-      type (mesh_type), intent(inout) :: grid
-      type (state_type), intent(inout) :: state
-
-      real (kind=RKIND), parameter :: u0 = 2.0 * pii * a / (12.0 * 86400.0)
-      real (kind=RKIND), parameter :: h0 = 1000.0
-      real (kind=RKIND), parameter :: theta_c = 0.0
-      real (kind=RKIND), parameter :: lambda_c = 3.0*pii/2.0
-      real (kind=RKIND), parameter :: alpha = pii/4.0
-
-      integer :: iCell, iEdge, iVtx
-      real (kind=RKIND) :: r, u, v
-      real (kind=RKIND), allocatable, dimension(:) :: psiVertex
-
-      !
-      ! Scale all distances and areas from a unit sphere to one with radius a
-      !
-      grid % xCell % array = grid % xCell % array * a
-      grid % yCell % array = grid % yCell % array * a
-      grid % zCell % array = grid % zCell % array * a
-      grid % xVertex % array = grid % xVertex % array * a
-      grid % yVertex % array = grid % yVertex % array * a
-      grid % zVertex % array = grid % zVertex % array * a
-      grid % xEdge % array = grid % xEdge % array * a
-      grid % yEdge % array = grid % yEdge % array * a
-      grid % zEdge % array = grid % zEdge % array * a
-      grid % dvEdge % array = grid % dvEdge % array * a
-      grid % dcEdge % array = grid % dcEdge % array * a
-      grid % areaCell % array = grid % areaCell % array * a**2.0
-      grid % areaTriangle % array = grid % areaTriangle % array * a**2.0
-      grid % kiteAreasOnVertex % array = grid % kiteAreasOnVertex % array * a**2.0
-
-      !
-      ! Initialize wind field
-      !
-      allocate(psiVertex(grid % nVertices))
-      do iVtx=1,grid % nVertices
-         psiVertex(iVtx) = -a * u0 * ( &amp;
-                                       sin(grid%latVertex%array(iVtx)) * cos(alpha) - &amp;
-                                       cos(grid%lonVertex%array(iVtx)) * cos(grid%latVertex%array(iVtx)) * sin(alpha) &amp;
-                                     )
-      end do
-      do iEdge=1,grid % nEdges
-         state % u % array(1,iEdge) = -1.0 * ( &amp;
-                                               psiVertex(grid%verticesOnEdge%array(2,iEdge)) - &amp;
-                                               psiVertex(grid%verticesOnEdge%array(1,iEdge)) &amp;
-                                             ) / grid%dvEdge%array(iEdge)
-      end do
-      deallocate(psiVertex)
-
-      !
-      ! Initialize cosine bell at (theta_c, lambda_c)
-      !
-      do iCell=1,grid % nCells
-         r = sphere_distance(theta_c, lambda_c, grid % latCell % array(iCell), grid % lonCell % array(iCell), a) 
-         if (r &lt; a/3.0) then
-            state % h % array(1,iCell) = (h0 / 2.0) * (1.0 + cos(pii*r*3.0/a))
-         else
-            state % h % array(1,iCell) = 0.0
-         end if
-      end do
-
-   end subroutine sw_test_case_1
-
-
-   subroutine sw_test_case_2(grid, state)
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   ! Setup shallow water test case 2: Global Steady State Nonlinear Zonal 
-   !                                  Geostrophic Flow
-   !
-   ! Reference: Williamson, D.L., et al., &quot;A Standard Test Set for Numerical 
-   !            Approximations to the Shallow Water Equations in Spherical 
-   !            Geometry&quot; J. of Comp. Phys., 102, pp. 211--224
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      implicit none
-
-      type (mesh_type), intent(inout) :: grid
-      type (state_type), intent(inout) :: state
-
-      real (kind=RKIND), parameter :: u0 = 2.0 * pii * a / (12.0 * 86400.0)
-      real (kind=RKIND), parameter :: gh0 = 29400.0
-      real (kind=RKIND), parameter :: alpha = 0.0
-
-      integer :: iCell, iEdge, iVtx
-      real (kind=RKIND) :: u, v
-      real (kind=RKIND), allocatable, dimension(:) :: psiVertex
-
-
-      !
-      ! Scale all distances and areas from a unit sphere to one with radius a
-      !
-      grid % xCell % array = grid % xCell % array * a
-      grid % yCell % array = grid % yCell % array * a
-      grid % zCell % array = grid % zCell % array * a
-      grid % xVertex % array = grid % xVertex % array * a
-      grid % yVertex % array = grid % yVertex % array * a
-      grid % zVertex % array = grid % zVertex % array * a
-      grid % xEdge % array = grid % xEdge % array * a
-      grid % yEdge % array = grid % yEdge % array * a
-      grid % zEdge % array = grid % zEdge % array * a
-      grid % dvEdge % array = grid % dvEdge % array * a
-      grid % dcEdge % array = grid % dcEdge % array * a
-      grid % areaCell % array = grid % areaCell % array * a**2.0
-      grid % areaTriangle % array = grid % areaTriangle % array * a**2.0
-      grid % kiteAreasOnVertex % array = grid % kiteAreasOnVertex % array * a**2.0
-      
-
-      !
-      ! Initialize wind field
-      !
-      allocate(psiVertex(grid % nVertices))
-      do iVtx=1,grid % nVertices
-         psiVertex(iVtx) = -a * u0 * ( &amp;
-                                       sin(grid%latVertex%array(iVtx)) * cos(alpha) - &amp;
-                                       cos(grid%lonVertex%array(iVtx)) * cos(grid%latVertex%array(iVtx)) * sin(alpha) &amp;
-                                     )
-      end do
-      do iEdge=1,grid % nEdges
-         state % u % array(1,iEdge) = -1.0 * ( &amp;
-                                               psiVertex(grid%verticesOnEdge%array(2,iEdge)) - &amp;
-                                               psiVertex(grid%verticesOnEdge%array(1,iEdge)) &amp;
-                                             ) / grid%dvEdge%array(iEdge)
-      end do
-      deallocate(psiVertex)
-
-      !
-      ! Generate rotated Coriolis field
-      !
-      do iEdge=1,grid % nEdges
-         grid % fEdge % array(iEdge) = 2.0 * omega * &amp;
-                                       ( -cos(grid%lonEdge%array(iEdge)) * cos(grid%latEdge%array(iEdge)) * sin(alpha) + &amp;
-                                         sin(grid%latEdge%array(iEdge)) * cos(alpha) &amp;
-                                       )
-      end do
-      do iVtx=1,grid % nVertices
-         grid % fVertex % array(iVtx) = 2.0 * omega * &amp;
-                                         (-cos(grid%lonVertex%array(iVtx)) * cos(grid%latVertex%array(iVtx)) * sin(alpha) + &amp;
-                                          sin(grid%latVertex%array(iVtx)) * cos(alpha) &amp;
-                                         )
-      end do
-
-      !
-      ! Initialize height field (actually, fluid thickness field)
-      !
-      do iCell=1,grid % nCells
-         state % h % array(1,iCell) = (gh0 - (a * omega * u0 + 0.5 * u0**2.0) * &amp;
-                                             (-cos(grid%lonCell%array(iCell)) * cos(grid%latCell%array(iCell)) * sin(alpha) + &amp;
-                                              sin(grid%latCell%array(iCell)) * cos(alpha) &amp;
-                                             )**2.0 &amp;
-                                      ) / &amp;
-                                      gravity
-      end do
-
-   end subroutine sw_test_case_2
-
-
-   subroutine sw_test_case_5(grid, state)
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   ! Setup shallow water test case 5: Zonal Flow over an Isolated Mountain
-   !
-   ! Reference: Williamson, D.L., et al., &quot;A Standard Test Set for Numerical 
-   !            Approximations to the Shallow Water Equations in Spherical 
-   !            Geometry&quot; J. of Comp. Phys., 102, pp. 211--224
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      implicit none
-
-      type (mesh_type), intent(inout) :: grid
-      type (state_type), intent(inout) :: state
-
-      real (kind=RKIND), parameter :: u0 = 20.
-      real (kind=RKIND), parameter :: gh0 = 5960.0*gravity
-!      real (kind=RKIND), parameter :: hs0 = 2000. original
-      real (kind=RKIND), parameter :: hs0 = 250.  !mrp 100204
-      real (kind=RKIND), parameter :: theta_c = pii/6.0
-      real (kind=RKIND), parameter :: lambda_c = 3.0*pii/2.0
-      real (kind=RKIND), parameter :: rr = pii/9.0
-      real (kind=RKIND), parameter :: alpha = 0.0
-
-      integer :: iCell, iEdge, iVtx
-      real (kind=RKIND) :: r, u, v
-      real (kind=RKIND), allocatable, dimension(:) :: psiVertex
-
-
-      !
-      ! Scale all distances and areas from a unit sphere to one with radius a
-      !
-      grid % xCell % array = grid % xCell % array * a
-      grid % yCell % array = grid % yCell % array * a
-      grid % zCell % array = grid % zCell % array * a
-      grid % xVertex % array = grid % xVertex % array * a
-      grid % yVertex % array = grid % yVertex % array * a
-      grid % zVertex % array = grid % zVertex % array * a
-      grid % xEdge % array = grid % xEdge % array * a
-      grid % yEdge % array = grid % yEdge % array * a
-      grid % zEdge % array = grid % zEdge % array * a
-      grid % dvEdge % array = grid % dvEdge % array * a
-      grid % dcEdge % array = grid % dcEdge % array * a
-      grid % areaCell % array = grid % areaCell % array * a**2.0
-      grid % areaTriangle % array = grid % areaTriangle % array * a**2.0
-      grid % kiteAreasOnVertex % array = grid % kiteAreasOnVertex % array * a**2.0
-
-      !
-      ! Initialize wind field
-      !
-      allocate(psiVertex(grid % nVertices))
-      do iVtx=1,grid % nVertices
-         psiVertex(iVtx) = -a * u0 * ( &amp;
-                                       sin(grid%latVertex%array(iVtx)) * cos(alpha) - &amp;
-                                       cos(grid%lonVertex%array(iVtx)) * cos(grid%latVertex%array(iVtx)) * sin(alpha) &amp;
-                                     )
-      end do
-      do iEdge=1,grid % nEdges
-         state % u % array(1,iEdge) = -1.0 * ( &amp;
-                                               psiVertex(grid%verticesOnEdge%array(2,iEdge)) - &amp;
-                                               psiVertex(grid%verticesOnEdge%array(1,iEdge)) &amp;
-                                             ) / grid%dvEdge%array(iEdge)
-      end do
-      deallocate(psiVertex)
-
-      !
-      ! Generate rotated Coriolis field
-      !
-      do iEdge=1,grid % nEdges
-         grid % fEdge % array(iEdge) = 2.0 * omega * &amp;
-                                        (-cos(grid%lonEdge%array(iEdge)) * cos(grid%latEdge%array(iEdge)) * sin(alpha) + &amp;
-                                         sin(grid%latEdge%array(iEdge)) * cos(alpha) &amp;
-                                        )
-      end do
-      do iVtx=1,grid % nVertices
-         grid % fVertex % array(iVtx) = 2.0 * omega * &amp;
-                                         (-cos(grid%lonVertex%array(iVtx)) * cos(grid%latVertex%array(iVtx)) * sin(alpha) + &amp;
-                                          sin(grid%latVertex%array(iVtx)) * cos(alpha) &amp;
-                                         )
-      end do
-
-      !
-      ! Initialize mountain
-      !
-      do iCell=1,grid % nCells
-         if (grid % lonCell % array(iCell) &lt; 0.0) grid % lonCell % array(iCell) = grid % lonCell % array(iCell) + 2.0 * pii
-         r = sqrt(min(rr**2.0, (grid % lonCell % array(iCell) - lambda_c)**2.0 + (grid % latCell % array(iCell) - theta_c)**2.0))
-         grid % bottomDepth % array(iCell) = hs0 * (1.0 - r/rr)
-      end do
-! output about mountain
-print *, 'bottomDepth',minval(grid % bottomDepth % array),sum(grid % bottomDepth % array)/grid % nCells, maxval(grid % bottomDepth % array)
-
-      !
-      ! Initialize tracer fields
-      !
-      do iCell=1,grid % nCells
-         r = sqrt(min(rr**2.0, (grid % lonCell % array(iCell) - lambda_c)**2.0 + (grid % latCell % array(iCell) - theta_c)**2.0))
-         state % tracers % array(1,1,iCell) = 1.0 - r/rr
-      end do
-      do iCell=1,grid % nCells
-         r = sqrt(min(rr**2.0, (grid % lonCell % array(iCell) - lambda_c)**2.0 + &amp;
-                      (grid % latCell % array(iCell) - theta_c - pii/6.0)**2.0 &amp;
-                     ) &amp;
-                 )
-         state % tracers % array(2,1,iCell) = 1.0 - r/rr
-      end do
-
-      !
-      ! Initialize height field (actually, fluid thickness field)
-      !
-      do iCell=1,grid % nCells
-         state % h % array(1,iCell) = (gh0 - (a * omega * u0 + 0.5 * u0**2.0) * &amp;
-                                         (-cos(grid%lonCell%array(iCell)) * cos(grid%latCell%array(iCell)) * sin(alpha) + &amp;
-                                          sin(grid%latCell%array(iCell)) * cos(alpha) &amp;
-                                         )**2.0 &amp;
-                                      ) / &amp;
-                                      gravity
-         state % h % array(1,iCell) = state % h % array(1,iCell) - grid % bottomDepth % array(iCell)
-      end do
-
-   end subroutine sw_test_case_5
-
-
-   subroutine sw_test_case_6(grid, state)
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   ! Setup shallow water test case 6: Rossby-Haurwitz Wave
-   !
-   ! Reference: Williamson, D.L., et al., &quot;A Standard Test Set for Numerical 
-   !            Approximations to the Shallow Water Equations in Spherical 
-   !            Geometry&quot; J. of Comp. Phys., 102, pp. 211--224
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      implicit none
-
-      type (mesh_type), intent(inout) :: grid
-      type (state_type), intent(inout) :: state
-
-      real (kind=RKIND), parameter :: h0 = 8000.0
-      real (kind=RKIND), parameter :: w = 7.848e-6
-      real (kind=RKIND), parameter :: K = 7.848e-6
-      real (kind=RKIND), parameter :: R = 4.0
-
-      integer :: iCell, iEdge, iVtx
-      real (kind=RKIND) :: u, v
-      real (kind=RKIND), allocatable, dimension(:) :: psiVertex
-
-
-      !
-      ! Scale all distances and areas from a unit sphere to one with radius a
-      !
-      grid % xCell % array = grid % xCell % array * a
-      grid % yCell % array = grid % yCell % array * a
-      grid % zCell % array = grid % zCell % array * a
-      grid % xVertex % array = grid % xVertex % array * a
-      grid % yVertex % array = grid % yVertex % array * a
-      grid % zVertex % array = grid % zVertex % array * a
-      grid % xEdge % array = grid % xEdge % array * a
-      grid % yEdge % array = grid % yEdge % array * a
-      grid % zEdge % array = grid % zEdge % array * a
-      grid % dvEdge % array = grid % dvEdge % array * a
-      grid % dcEdge % array = grid % dcEdge % array * a
-      grid % areaCell % array = grid % areaCell % array * a**2.0
-      grid % areaTriangle % array = grid % areaTriangle % array * a**2.0
-      grid % kiteAreasOnVertex % array = grid % kiteAreasOnVertex % array * a**2.0
-
-      !
-      ! Initialize wind field
-      !
-      allocate(psiVertex(grid % nVertices))
-      do iVtx=1,grid % nVertices
-         psiVertex(iVtx) = -a * a * w * sin(grid%latVertex%array(iVtx)) + &amp;
-                            a *a * K * (cos(grid%latVertex%array(iVtx))**R) * &amp;
-                            sin(grid%latVertex%array(iVtx)) * cos(R * grid%lonVertex%array(iVtx))
-      end do
-      do iEdge=1,grid % nEdges
-         state % u % array(1,iEdge) = -1.0 * ( &amp;
-                                               psiVertex(grid%verticesOnEdge%array(2,iEdge)) - &amp;
-                                               psiVertex(grid%verticesOnEdge%array(1,iEdge)) &amp;
-                                             ) / grid%dvEdge%array(iEdge)
-      end do
-      deallocate(psiVertex)
-
-      !
-      ! Initialize height field (actually, fluid thickness field)
-      !
-      do iCell=1,grid % nCells
-         state % h % array(1,iCell) = (gravity * h0 + a*a*aa(grid%latCell%array(iCell)) + &amp;
-                                                      a*a*bb(grid%latCell%array(iCell)) * cos(R*grid%lonCell%array(iCell)) + &amp;
-                                                      a*a*cc(grid%latCell%array(iCell)) * cos(2.0*R*grid%lonCell%array(iCell)) &amp;
-                                      ) / gravity
-      end do
-
-   end subroutine sw_test_case_6
-
-
-   real function sphere_distance(lat1, lon1, lat2, lon2, radius)
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   ! Compute the great-circle distance between (lat1, lon1) and (lat2, lon2) on a
-   !   sphere with given radius.
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      implicit none
-
-      real (kind=RKIND), intent(in) :: lat1, lon1, lat2, lon2, radius
-
-      real (kind=RKIND) :: arg1
-
-      arg1 = sqrt( sin(0.5*(lat2-lat1))**2 +  &amp;
-                   cos(lat1)*cos(lat2)*sin(0.5*(lon2-lon1))**2 )
-      sphere_distance = 2.*radius*asin(arg1)
-
-   end function sphere_distance
-
-
-   real function aa(theta)
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   ! A, used in height field computation for Rossby-Haurwitz wave
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      implicit none
-
-      real (kind=RKIND), parameter :: w = 7.848e-6
-      real (kind=RKIND), parameter :: K = 7.848e-6
-      real (kind=RKIND), parameter :: R = 4.0
-
-      real (kind=RKIND), intent(in) :: theta
-
-      aa = 0.5 * w * (2.0 * omega + w) * cos(theta)**2.0 + &amp;
-          0.25 * K**2.0 * cos(theta)**(2.0*R) * ((R+1.0)*cos(theta)**2.0 + 2.0*R**2.0 - R - 2.0 - 2.0*R**2*cos(theta)**(-2.0))
-
-   end function aa
-
-   
-   real function bb(theta)
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   ! B, used in height field computation for Rossby-Haurwitz wave
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      implicit none
-
-      real (kind=RKIND), parameter :: w = 7.848e-6
-      real (kind=RKIND), parameter :: K = 7.848e-6
-      real (kind=RKIND), parameter :: R = 4.0
-
-      real (kind=RKIND), intent(in) :: theta
-
-      bb = (2.0*(omega + w)*K / ((R+1.0)*(R+2.0))) * cos(theta)**R * ((R**2.0 + 2.0*R + 2.0) - ((R+1.0)*cos(theta))**2.0)
-
-   end function bb
-
-
-   real function cc(theta)
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   ! C, used in height field computation for Rossby-Haurwitz wave
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      implicit none
-
-      real (kind=RKIND), parameter :: w = 7.848e-6
-      real (kind=RKIND), parameter :: K = 7.848e-6
-      real (kind=RKIND), parameter :: R = 4.0
-
-      real (kind=RKIND), intent(in) :: theta
-
-      cc = 0.25 * K**2.0 * cos(theta)**(2.0*R) * ((R+1.0)*cos(theta)**2.0 - R - 2.0)
-
-   end function cc
-
-end module ocn_test_cases

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_thick_hadv.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_thick_hadv.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_thick_hadv.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -41,8 +41,9 @@
    ! Private module variables
    !
    !--------------------------------------------------------------------
+   
+   logical :: thickHadvOn
 
-
 !***********************************************************************
 
 contains
@@ -120,6 +121,8 @@
 
       err = 0
 
+      if(.not.thickHadvOn) return
+
       nEdges = grid % nEdges
       nCells = grid % nCells
       nVertLevels = grid % nVertLevels
@@ -175,6 +178,10 @@
 
       integer, intent(out) :: err !&lt; Output: error flag
 
+      thickHadvOn = .true.
+
+      if(config_disable_h_hadv) thickHadvOn = .false.
+
       err = 0
 
    !--------------------------------------------------------------------

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_thick_vadv.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_thick_vadv.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_thick_vadv.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -42,6 +42,7 @@
    !
    !--------------------------------------------------------------------
 
+   logical :: thickVadvOn
 
 !***********************************************************************
 
@@ -111,6 +112,8 @@
 
       err = 0
 
+      if(.not.thickVadvOn) return
+
       maxLevelCell      =&gt; grid % maxLevelCell % array
 
       nCells = grid % nCells
@@ -151,6 +154,10 @@
       !-----------------------------------------------------------------
 
       integer, intent(out) :: err !&lt; Output: error flag
+
+      thickVadvOn = .true.
+
+      if(config_disable_h_vadv) thickVadvOn = .false.
       
       err = 0
 

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_time_average.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_time_average.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_time_average.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -11,11 +11,11 @@
     subroutine ocn_time_average_init(state)!{{{
         type (state_type), intent(inout) :: state
 
-        real, pointer :: nAccumulate
+        real (kind=RKIND), pointer :: nAccumulate
 
         real (kind=RKIND), dimension(:), pointer :: acc_ssh, acc_sshVar
         real (kind=RKIND), dimension(:,:), pointer :: acc_uReconstructZonal, acc_uReconstructMeridional, acc_uReconstructZonalVar, acc_uReconstructMeridionalVar
-        real (kind=RKIND), dimension(:,:), pointer :: acc_u, acc_uVar
+        real (kind=RKIND), dimension(:,:), pointer :: acc_u, acc_uVar, acc_vertVelocityTop
 
         nAccumulate =&gt; state % nAccumulate % scalar
 
@@ -27,6 +27,7 @@
         acc_uReconstructMeridionalVar =&gt; state % acc_uReconstructMeridionalVar % array
         acc_u =&gt; state % acc_u % array
         acc_uVar =&gt; state % acc_uVar % array
+        acc_vertVelocityTop =&gt; state % acc_vertVelocityTop % array
 
         nAccumulate = 0
 
@@ -38,6 +39,7 @@
         acc_uReconstructMeridionalVar = 0.0
         acc_u = 0.0
         acc_uVar = 0.0
+        acc_vertVelocityTop = 0.0
 
     end subroutine ocn_time_average_init!}}}
 
@@ -45,16 +47,16 @@
         type (state_type), intent(inout) :: state
         type (state_type), intent(in) :: old_state
 
-        real, pointer :: nAccumulate, old_nAccumulate
+        real (kind=RKIND), pointer :: nAccumulate, old_nAccumulate
 
         real (kind=RKIND), dimension(:), pointer :: ssh
-        real (kind=RKIND), dimension(:,:), pointer :: uReconstructZonal, uReconstructMeridional, u
+        real (kind=RKIND), dimension(:,:), pointer :: uReconstructZonal, uReconstructMeridional, u, vertVelocityTop
 
-        real (kind=RKIND), dimension(:,:), pointer :: acc_u, acc_uVar
+        real (kind=RKIND), dimension(:,:), pointer :: acc_u, acc_uVar, acc_vertVelocityTop
         real (kind=RKIND), dimension(:,:), pointer :: acc_uReconstructZonal, acc_uReconstructMeridional, acc_uReconstructZonalVar, acc_uReconstructMeridionalVar
         real (kind=RKIND), dimension(:), pointer :: acc_ssh, acc_sshVar
 
-        real (kind=RKIND), dimension(:,:), pointer :: old_acc_u, old_acc_uVar
+        real (kind=RKIND), dimension(:,:), pointer :: old_acc_u, old_acc_uVar, old_acc_vertVelocityTop
         real (kind=RKIND), dimension(:,:), pointer :: old_acc_uReconstructZonal, old_acc_uReconstructMeridional, old_acc_uReconstructZonalVar, old_acc_uReconstructMeridionalVar
         real (kind=RKIND), dimension(:), pointer :: old_acc_ssh, old_acc_sshVar
 
@@ -65,6 +67,7 @@
         uReconstructZonal =&gt; state % uReconstructZonal % array
         uReconstructMeridional =&gt; state % uReconstructMeridional % array
         u =&gt; state % u % array
+        vertVelocityTop =&gt; state % vertVelocityTop % array
 
         acc_ssh =&gt; state % acc_ssh % array
         acc_sshVar =&gt; state % acc_sshVar % array
@@ -74,6 +77,7 @@
         acc_uReconstructMeridionalVar =&gt; state % acc_uReconstructMeridionalVar % array
         acc_u =&gt; state % acc_u % array
         acc_uVar =&gt; state % acc_uVar % array
+        acc_vertVelocityTop =&gt; state % acc_vertVelocityTop % array
 
         old_acc_ssh =&gt; old_state % acc_ssh % array
         old_acc_sshVar =&gt; old_state % acc_sshVar % array
@@ -83,6 +87,7 @@
         old_acc_uReconstructMeridionalVar =&gt; old_state % acc_uReconstructMeridionalVar % array
         old_acc_u =&gt; old_state % acc_u % array
         old_acc_uVar =&gt; old_state % acc_uVar % array
+        old_acc_vertVelocityTop =&gt; old_state % acc_vertVelocityTop % array
 
         acc_ssh = old_acc_ssh + ssh
         acc_sshVar = old_acc_sshVar + ssh**2
@@ -92,6 +97,7 @@
         acc_uReconstructMeridionalVar = old_acc_uReconstructMeridionalVar + uReconstructMeridional**2
         acc_u = old_acc_u + u
         acc_uVar = old_acc_uVar + u**2
+        acc_vertVelocityTop = old_acc_vertVelocityTop + vertVelocityTop
 
         nAccumulate = old_nAccumulate + 1
     end subroutine ocn_time_average_accumulate!}}}
@@ -99,11 +105,11 @@
     subroutine ocn_time_average_normalize(state)!{{{
         type (state_type), intent(inout) :: state
 
-        real, pointer :: nAccumulate
+        real (kind=RKIND), pointer :: nAccumulate
 
         real (kind=RKIND), dimension(:), pointer :: acc_ssh, acc_sshVar
         real (kind=RKIND), dimension(:,:), pointer :: acc_uReconstructZonal, acc_uReconstructMeridional, acc_uReconstructZonalVar, acc_uReconstructMeridionalVar
-        real (kind=RKIND), dimension(:,:), pointer :: acc_u, acc_uVar
+        real (kind=RKIND), dimension(:,:), pointer :: acc_u, acc_uVar, acc_vertVelocityTop
 
         nAccumulate =&gt; state % nAccumulate  % scalar
 
@@ -115,6 +121,7 @@
         acc_uReconstructMeridionalVar =&gt; state % acc_uReconstructMeridionalVar % array
         acc_u =&gt; state % acc_u % array
         acc_uVar =&gt; state % acc_uVar % array
+        acc_vertVelocityTop =&gt; state % acc_vertVelocityTop % array
 
         if(nAccumulate &gt; 0) then
           acc_ssh = acc_ssh / nAccumulate
@@ -125,6 +132,7 @@
           acc_uReconstructMeridionalVar = acc_uReconstructMeridionalVar / nAccumulate
           acc_u = acc_u / nAccumulate
           acc_uVar = acc_uVar / nAccumulate
+          acc_vertVelocityTop = acc_vertVelocityTop / nAccumulate
         end if
     end subroutine ocn_time_average_normalize!}}}
 

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_time_integration.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_time_integration.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_time_integration.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -85,6 +85,8 @@
       real (kind=RKIND), intent(in) :: dt
       character(len=*), intent(in) :: timeStamp
 
+      real (kind=RKIND) :: nanCheck
+
       type (dm_info) :: dminfo
       type (block_type), pointer :: block
 
@@ -98,7 +100,9 @@
      do while (associated(block))
         block % state % time_levs(2) % state % xtime % scalar = timeStamp
 
-        if (isNaN(sum(block % state % time_levs(2) % state % u % array))) then
+        nanCheck = sum(block % state % time_levs(2) % state % u % array)
+
+        if (nanCheck /= nanCheck) then
            write(0,*) 'Abort: NaN detected'
            call mpas_dmpar_abort(dminfo)
         endif
@@ -117,14 +121,14 @@
       rk4On = .false.
       splitOn = .false.
 
-      if (trim(config_time_integration) == 'RK4') then
+      if (trim(config_time_integrator) == 'RK4') then
           rk4On = .true.
-      elseif (trim(config_time_integration) == 'split_explicit' &amp;
-          .or.trim(config_time_integration) == 'unsplit_explicit') then
+      elseif (trim(config_time_integrator) == 'split_explicit' &amp;
+          .or.trim(config_time_integrator) == 'unsplit_explicit') then
           splitOn = .true.
       else
           err = 1
-          write(*,*) 'Incorrect choice for config_time_integration:', trim(config_time_integration)
+          write(*,*) 'Incorrect choice for config_time_integrator:', trim(config_time_integrator)
           write(*,*) '   choices are: RK4, split_explicit, unsplit_explicit'
       endif
 

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_time_integration_rk4.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_time_integration_rk4.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_time_integration_rk4.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -22,6 +22,7 @@
    use mpas_timer
 
    use ocn_tendency
+   use ocn_diagnostics
 
    use ocn_equation_of_state
    use ocn_vmix
@@ -137,7 +138,7 @@
 
         call mpas_timer_start(&quot;RK4-diagnostic halo update&quot;)
         call mpas_dmpar_exch_halo_field(domain % blocklist % provis % Vor_edge)
-        if (config_h_mom_eddy_visc4 &gt; 0.0) then
+        if (config_mom_del4 &gt; 0.0) then
            call mpas_dmpar_exch_halo_field(domain % blocklist % provis % divergence)
            call mpas_dmpar_exch_halo_field(domain % blocklist % provis % vorticity)
         end if
@@ -148,11 +149,6 @@
         call mpas_timer_start(&quot;RK4-tendency computations&quot;)
         block =&gt; domain % blocklist
         do while (associated(block))
-
-           if (.not.config_implicit_vertical_mix) then
-              call ocn_vmix_coefs(block % mesh, block % provis, block % diagnostics, err)
-           end if
-
            ! advection of u uses u, while advection of h and tracers use uTransport.
            call ocn_wtop(block % mesh, block % provis % h % array, block % provis % h_edge % array, &amp;
               block % provis % u % array, block % provis % wTop % array, err)
@@ -162,11 +158,11 @@
               block % provis % uTransport % array, block % provis % wTop % array, err)
            call ocn_tend_h(block % tend, block % provis, block % mesh)
 
-           if (config_rk_filter_btr_mode) then
+           if (config_filter_btr_mode) then
                call ocn_filter_btr_mode_tend_u(block % tend, block % provis, block % mesh)
            endif
 
-           call ocn_tend_scalar(block % tend, block % provis, block % diagnostics, block % mesh, dt)
+           call ocn_tend_tracer(block % tend, block % provis, block % diagnostics, block % mesh, dt)
            block =&gt; block % next
         end do
         call mpas_timer_stop(&quot;RK4-tendency computations&quot;)
@@ -200,10 +196,6 @@
                  end do
 
               end do
-              if (config_test_case == 1) then    ! For case 1, wind field should be fixed
-                 block % provis % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
-              end if
-
               if (config_prescribe_velocity) then
                  block % provis % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
               end if
@@ -254,7 +246,7 @@
       call mpas_timer_stop(&quot;RK4-main loop&quot;)
 
       !
-      !  A little clean up at the end: decouple new scalar fields and compute diagnostics for new state
+      !  A little clean up at the end: rescale tracer fields and compute diagnostics for new state
       !
       call mpas_timer_start(&quot;RK4-cleaup phase&quot;)
 
@@ -270,42 +262,35 @@
         block =&gt; block % next
       end do
 
+      call mpas_timer_start(&quot;RK4-implicit vert mix&quot;)
+      block =&gt; domain % blocklist
+      do while(associated(block))
 
-      if (config_implicit_vertical_mix) then
-        call mpas_timer_start(&quot;RK4-implicit vert mix&quot;)
-        block =&gt; domain % blocklist
-        do while(associated(block))
+        ! Call ocean diagnostic solve in preparation for vertical mixing.  Note 
+        ! it is called again after vertical mixing, because u and tracers change.
+        ! For Richardson vertical mixing, only rho, h_edge, and ke_edge need to 
+        ! be computed.  For kpp, more variables may be needed.  Either way, this
+        ! could be made more efficient by only computing what is needed for the
+        ! implicit vmix routine that follows. 
+        call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
 
-          ! Call ocean diagnostic solve in preparation for vertical mixing.  Note 
-          ! it is called again after vertical mixing, because u and tracers change.
-          ! For Richardson vertical mixing, only rho, h_edge, and ke_edge need to 
-          ! be computed.  For kpp, more variables may be needed.  Either way, this
-          ! could be made more efficient by only computing what is needed for the
-          ! implicit vmix routine that follows. mrp 121023.
-          call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
+        call ocn_vmix_implicit(dt, block % mesh, block % diagnostics, block % state % time_levs(2) % state, err)
+        block =&gt; block % next
+      end do
 
-          call ocn_vmix_implicit(dt, block % mesh, block % diagnostics, block % state % time_levs(2) % state, err)
-          block =&gt; block % next
-        end do
+      ! Update halo on u and tracers, which were just updated for implicit vertical mixing.  If not done, 
+      ! this leads to lack of volume conservation.  It is required because halo updates in RK4 are only
+      ! conducted on tendencies, not on the velocity and tracer fields.  So this update is required to 
+      ! communicate the change due to implicit vertical mixing across the boundary.
+      call mpas_timer_start(&quot;RK4-implicit vert mix halos&quot;)
+      call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % u)
+      call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % tracers)
+      call mpas_timer_stop(&quot;RK4-implicit vert mix halos&quot;)
 
-        ! Update halo on u and tracers, which were just updated for implicit vertical mixing.  If not done, 
-        ! this leads to lack of volume conservation.  It is required because halo updates in RK4 are only
-        ! conducted on tendencies, not on the velocity and tracer fields.  So this update is required to 
-        ! communicate the change due to implicit vertical mixing across the boundary.
-        call mpas_timer_start(&quot;RK4-implicit vert mix halos&quot;)
-        call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % u)
-        call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % tracers)
-        call mpas_timer_stop(&quot;RK4-implicit vert mix halos&quot;)
+      call mpas_timer_stop(&quot;RK4-implicit vert mix&quot;)
 
-        call mpas_timer_stop(&quot;RK4-implicit vert mix&quot;)
-      end if
-
       block =&gt; domain % blocklist
       do while (associated(block))
-         if (config_test_case == 1) then    ! For case 1, wind field should be fixed
-            block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
-         end if
-
          if (config_prescribe_velocity) then
             block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
          end if
@@ -329,7 +314,6 @@
                           block % state % time_levs(2) % state % uReconstructMeridional % array    &amp;
                          )
 
-!TDR
          call mpas_reconstruct(block % mesh, block % mesh % u_src % array,          &amp;
                           block % state % time_levs(2) % state % uSrcReconstructX % array,            &amp;
                           block % state % time_levs(2) % state % uSrcReconstructY % array,            &amp;
@@ -337,7 +321,6 @@
                           block % state % time_levs(2) % state % uSrcReconstructZonal % array,        &amp;
                           block % state % time_levs(2) % state % uSrcReconstructMeridional % array    &amp;
                          )
-!TDR
 
          call ocn_time_average_accumulate(block % state % time_levs(2) % state, block % state % time_levs(1) % state)
 

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_time_integration_split.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_time_integration_split.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_time_integration_split.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -24,6 +24,7 @@
    use mpas_timer
 
    use ocn_tendency
+   use ocn_diagnostics
 
    use ocn_equation_of_state
    use ocn_vmix
@@ -167,7 +168,7 @@
 
          call mpas_timer_start(&quot;se halo diag&quot;, .false., timer_halo_diagnostic)
          call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % Vor_edge)
-         if (config_h_mom_eddy_visc4 &gt; 0.0) then
+         if (config_mom_del4 &gt; 0.0) then
            call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % divergence)
            call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % vorticity)
          end if
@@ -187,10 +188,6 @@
 
             stage1_tend_time = min(split_explicit_step,2)
 
-            if (.not.config_implicit_vertical_mix) then
-               call ocn_vmix_coefs(block % mesh, block % state % time_levs(stage1_tend_time) % state, block % diagnostics, err)
-            end if
-
            ! compute wTop.  Use u (rather than uTransport) for momentum advection.
            ! Use the most recent time level available.
            call ocn_wtop(block % mesh, block % state % time_levs(stage1_tend_time) % state % h % array, &amp;
@@ -209,9 +206,9 @@
          do j=1,n_bcl_iter(split_explicit_step)
 
             ! Use this G coefficient to avoid an if statement within the iEdge loop.
-            if (trim(config_time_integration) == 'unsplit_explicit') then
+            if (trim(config_time_integrator) == 'unsplit_explicit') then
                split = 0
-            elseif (trim(config_time_integration) == 'split_explicit') then
+            elseif (trim(config_time_integrator) == 'split_explicit') then
                split = 1
             endif
 
@@ -294,7 +291,7 @@
          oldBtrSubcycleTime = 1
          newBtrSubcycleTime = 2
 
-         if (trim(config_time_integration) == 'unsplit_explicit') then
+         if (trim(config_time_integrator) == 'unsplit_explicit') then
 
             block =&gt; domain % blocklist
             do while (associated(block))
@@ -321,7 +318,7 @@
                block =&gt; block % next
             end do  ! block
 
-         elseif (trim(config_time_integration) == 'split_explicit') then
+         elseif (trim(config_time_integrator) == 'split_explicit') then
 
             ! Initialize variables for barotropic subcycling
             block =&gt; domain % blocklist
@@ -423,7 +420,6 @@
                 ! config_btr_gam1_uWt1=  1     flux = uBtrNew*H
                 ! config_btr_gam1_uWt1=0.5     flux = 1/2*(uBtrNew+uBtrOld)*H
                 ! config_btr_gam1_uWt1=  0     flux = uBtrOld*H
-                ! mrp 120201 efficiency: could we combine the following edge and cell loops?
 
                 do iCell = 1, block % mesh % nCells
                   do i = 1, block % mesh % nEdgesOnCell % array(iCell)
@@ -563,7 +559,6 @@
                   ! config_btr_gam3_uWt2=  1     flux = uBtrNew*H
                   ! config_btr_gam3_uWt2=0.5     flux = 1/2*(uBtrNew+uBtrOld)*H
                   ! config_btr_gam3_uWt2=  0     flux = uBtrOld*H
-                  ! mrp 120201 efficiency: could we combine the following edge and cell loops?
 
                   do iCell = 1, block % mesh % nCells
                     do i = 1, block % mesh % nEdgesOnCell % array(iCell)
@@ -774,13 +769,8 @@
          !
          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-         !TDR: it seems almost trivial to hold off on doing T, S and rho updates until the 
-         !TDR: dycore time step is complete. we might want to take this opportunity to clean-up
-         !TDR: Stage3 in order to faciliate the testing of not doing tracer updates after this code is committed to trunk.
-         !TDR: at this point, I am suggesting just pushing some of this code into subroutines. 
-         !TDR: see comments farther down
-
-         ! dwj: 02/22/12 splitting thickness and tracer tendency computations and halo updates to allow monotonic advection.
+         ! Thickness tendency computations and thickness halo updates are completed before tracer 
+         ! tendency computations to allow monotonic advection.
          block =&gt; domain % blocklist
          do while (associated(block))
 
@@ -802,7 +792,7 @@
 
          block =&gt; domain % blocklist
          do while (associated(block))
-            call ocn_tend_scalar(block % tend, block % state % time_levs(2) % state, block % diagnostics, block % mesh, dt)
+            call ocn_tend_tracer(block % tend, block % state % time_levs(2) % state, block % diagnostics, block % mesh, dt)
 
             block =&gt; block % next
          end do
@@ -822,9 +812,6 @@
             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
             if (split_explicit_step &lt; config_n_ts_iter) then
 
-            !TDR: should we move this code into a subroutine called &quot;compute_intermediate_value_at_midtime&quot;
-            !TDR: this could be within a contains statement in this routine
-
                ! Only need T &amp; S for earlier iterations,
                ! then all the tracers needed the last time through.
                do iCell=1,block % mesh % nCells
@@ -875,8 +862,8 @@
 
                end do ! iEdge
 
-               ! mrp 110512  I really only need this to compute h_edge, density, pressure, and SSH
-               ! I can par this down later.
+               ! Efficiency note: We really only need this to compute h_edge, density, pressure, and SSH 
+               ! in this diagnostics solve.
                call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
 
             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -886,9 +873,6 @@
             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
             elseif (split_explicit_step == config_n_ts_iter) then
 
-            !TDR: should we move this code into a subroutine called &quot;compute_final_values_at_nplus1&quot;?
-            !TDR: this could be within a contains statement in this routine
-
                do iCell=1,block % mesh % nCells
                   do k=1,block % mesh % maxLevelCell % array(iCell)
 
@@ -939,43 +923,37 @@
       ! END large iteration loop 
       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-      if (config_implicit_vertical_mix) then
-        call mpas_timer_start(&quot;se implicit vert mix&quot;)
-        block =&gt; domain % blocklist
-        do while(associated(block))
+      call mpas_timer_start(&quot;se implicit vert mix&quot;)
+      block =&gt; domain % blocklist
+      do while(associated(block))
 
-          ! Call ocean diagnostic solve in preparation for vertical mixing.  Note 
-          ! it is called again after vertical mixing, because u and tracers change.
-          ! For Richardson vertical mixing, only rho, h_edge, and ke_edge need to 
-          ! be computed.  For kpp, more variables may be needed.  Either way, this
-          ! could be made more efficient by only computing what is needed for the
-          ! implicit vmix routine that follows. mrp 121023.
-          call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
+        ! Call ocean diagnostic solve in preparation for vertical mixing.  Note 
+        ! it is called again after vertical mixing, because u and tracers change.
+        ! For Richardson vertical mixing, only rho, h_edge, and ke_edge need to 
+        ! be computed.  For kpp, more variables may be needed.  Either way, this
+        ! could be made more efficient by only computing what is needed for the
+        ! implicit vmix routine that follows.
+        call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
 
-          call ocn_vmix_implicit(dt, block % mesh, block % diagnostics, block % state % time_levs(2) % state, err)
+        call ocn_vmix_implicit(dt, block % mesh, block % diagnostics, block % state % time_levs(2) % state, err)
 
-          block =&gt; block % next
-        end do
+        block =&gt; block % next
+      end do
 
-        ! Update halo on u and tracers, which were just updated for implicit vertical mixing.  If not done, 
-        ! this leads to lack of volume conservation.  It is required because halo updates in stage 3 are only
-        ! conducted on tendencies, not on the velocity and tracer fields.  So this update is required to 
-        ! communicate the change due to implicit vertical mixing across the boundary.
-        call mpas_timer_start(&quot;se implicit vert mix halos&quot;)
-        call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % u)
-        call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % tracers)
-        call mpas_timer_stop(&quot;se implicit vert mix halos&quot;)
+      ! Update halo on u and tracers, which were just updated for implicit vertical mixing.  If not done, 
+      ! this leads to lack of volume conservation.  It is required because halo updates in stage 3 are only
+      ! conducted on tendencies, not on the velocity and tracer fields.  So this update is required to 
+      ! communicate the change due to implicit vertical mixing across the boundary.
+      call mpas_timer_start(&quot;se implicit vert mix halos&quot;)
+      call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % u)
+      call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % tracers)
+      call mpas_timer_stop(&quot;se implicit vert mix halos&quot;)
 
-        call mpas_timer_stop(&quot;se implicit vert mix&quot;)
-      end if
+      call mpas_timer_stop(&quot;se implicit vert mix&quot;)
 
       block =&gt; domain % blocklist
       do while (associated(block))
 
-         if (config_test_case == 1) then    ! For case 1, wind field should be fixed
-            block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
-         end if
-
          if (config_prescribe_velocity) then
             block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
          end if
@@ -991,12 +969,6 @@
           = block % state % time_levs(2) % state % u % array(:,:) &amp;
           + block % state % time_levs(2) % state % uBolusGM % array(:,:)
 
-!!!!!!!!!!!!!!!!!!!!!!!!!! mrp
-         ! Recompute wTop with all updated information.  The wTop in stage 3 used 
-         ! the previous h and u before implicit vertical mixing.
-!!!!!!
-! remove:         call ocn_wtop(block % state % time_levs(2) % state,block % state % time_levs(2) % state, block % mesh)
-
          call mpas_reconstruct(block % mesh, block % state % time_levs(2) % state % u % array,          &amp;
                           block % state % time_levs(2) % state % uReconstructX % array,            &amp;
                           block % state % time_levs(2) % state % uReconstructY % array,            &amp;
@@ -1005,7 +977,6 @@
                           block % state % time_levs(2) % state % uReconstructMeridional % array    &amp;
                          )
 
-!TDR
          call mpas_reconstruct(block % mesh, block % mesh % u_src % array,          &amp;
                           block % state % time_levs(2) % state % uSrcReconstructX % array,            &amp;
                           block % state % time_levs(2) % state % uSrcReconstructY % array,            &amp;
@@ -1013,7 +984,6 @@
                           block % state % time_levs(2) % state % uSrcReconstructZonal % array,        &amp;
                           block % state % time_levs(2) % state % uSrcReconstructMeridional % array    &amp;
                          )
-!TDR
 
          call ocn_time_average_accumulate(block % state % time_levs(2) % state, block % state % time_levs(1) % state)
 

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_advection.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_advection.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_advection.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -32,6 +32,7 @@
              mpas_ocn_tracer_advection_coefficients, &amp;
              mpas_ocn_tracer_advection_tend
 
+   logical :: tracerAdvOn
    logical :: monotonicOn
 
    contains
@@ -251,6 +252,8 @@
       type (mesh_type), intent(in) :: grid !&lt; Input: grid information
       real (kind=RKIND), dimension(:,:), intent(in) :: tend_h !&lt; Input: Thickness tendency information
 
+      if(.not. tracerAdvOn) return
+
       if(monotonicOn) then
          call mpas_ocn_tracer_advection_mono_tend(tracers, uh, w, h, verticalCellSize, dt, grid, tend_h, tend)
       else
@@ -279,6 +282,10 @@
 
       err = 0
 
+      tracerAdvOn = .true.
+
+      if(config_disable_tr_adv) tracerAdvOn = .false.
+
       call mpas_ocn_tracer_advection_std_init(err_tmp)
       call mpas_ocn_tracer_advection_mono_init(err_tmp)
 

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_advection_mono.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_advection_mono.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_advection_mono.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -147,7 +147,7 @@
             upwind_tendency(k, iCell) = 0.0
 
             !tracer_new is supposed to be the &quot;new&quot; tracer state. This allows bounds checks.
-            if (config_check_monotonicity) then
+            if (config_check_tracer_monotonicity) then
               tracer_new(k,iCell) = 0.0
             end if
           end do ! k loop
@@ -199,7 +199,7 @@
             iCell = advCellsForEdge(i,iEdge)
             do k = 1, maxLevelCell(iCell)
               tracer_weight = lowOrderAdvectionMask(k, iEdge) * adv_coefs_2nd(i,iEdge) &amp; 
-                            + highOrderAdvectionMask(k, iEdge) * (adv_coefs(i,iEdge) + coef_3rd_order*sign(1.,uh(k,iEdge))*adv_coefs_3rd(i,iEdge))
+                            + highOrderAdvectionMask(k, iEdge) * (adv_coefs(i,iEdge) + coef_3rd_order*sign(1.0_RKIND,uh(k,iEdge))*adv_coefs_3rd(i,iEdge))
 
               tracer_weight = uh(k,iEdge)*tracer_weight
               high_order_horiz_flux(k,iEdge) = high_order_horiz_flux(k,iEdge) + tracer_weight* tracer_cur(k,iCell)
@@ -207,8 +207,6 @@
           end do ! i loop over nAdvCellsForEdge
         end do ! iEdge loop
 
-        call mpas_dmpar_exch_halo_field(high_order_horiz_flux_field)
-
         !  low order upwind vertical flux (monotonic and diffused)
         !  Remove low order flux from the high order flux.
         !  Store left over high order flux in high_order_vert_flux array.
@@ -216,8 +214,8 @@
         do iCell = 1, nCells
           do k = 2, maxLevelCell(iCell)
             ! dwj 02/03/12 Ocean and Atmosphere are different in vertical
-!           flux_upwind = max(0.,w(k,iCell))*tracer_cur(k-1,iCell) + min(0.,w(k,iCell))*tracer_cur(k,iCell)
-            flux_upwind = min(0.,w(k,iCell))*tracer_cur(k-1,iCell) + max(0.,w(k,iCell))*tracer_cur(k,iCell)
+!           flux_upwind = max(0.0_RKIND,w(k,iCell))*tracer_cur(k-1,iCell) + min(0.0_RKIND,w(k,iCell))*tracer_cur(k,iCell)
+            flux_upwind = min(0.0_RKIND,w(k,iCell))*tracer_cur(k-1,iCell) + max(0.0_RKIND,w(k,iCell))*tracer_cur(k,iCell)
             upwind_tendency(k-1,iCell) = upwind_tendency(k-1,iCell) + flux_upwind
             upwind_tendency(k  ,iCell) = upwind_tendency(k  ,iCell) - flux_upwind
             high_order_vert_flux(k,iCell) = high_order_vert_flux(k,iCell) - flux_upwind
@@ -229,8 +227,8 @@
           !           it is negative
           do k = 1, maxLevelCell(iCell)
             ! dwj 02/03/12 Ocean and Atmosphere are different in vertical
-!           flux_incoming (k,iCell) = -(min(0.,high_order_vert_flux(k+1,iCell))-max(0.,high_order_vert_flux(k,iCell)))
-!           flux_outgoing(k,iCell) = -(max(0.,high_order_vert_flux(k+1,iCell))-min(0.,high_order_vert_flux(k,iCell)))
+!           flux_incoming (k,iCell) = -(min(0.0_RKIND,high_order_vert_flux(k+1,iCell))-max(0.0_RKIND,high_order_vert_flux(k,iCell)))
+!           flux_outgoing(k,iCell) = -(max(0.0_RKIND,high_order_vert_flux(k+1,iCell))-min(0.0_RKIND,high_order_vert_flux(k,iCell)))
 
             flux_incoming (k, iCell) = max(0.0_RKIND, high_order_vert_flux(k+1, iCell)) - min(0.0_RKIND, high_order_vert_flux(k, iCell))
             flux_outgoing(k, iCell) = min(0.0_RKIND, high_order_vert_flux(k+1, iCell)) - max(0.0_RKIND, high_order_vert_flux(k, iCell))
@@ -249,7 +247,7 @@
           invAreaCell2 = 1.0 / areaCell(cell2)
 
           do k = 1, maxLevelEdgeTop(iEdge)
-            flux_upwind = dvEdge(iEdge) * (max(0.,uh(k,iEdge))*tracer_cur(k,cell1) + min(0.,uh(k,iEdge))*tracer_cur(k,cell2))
+            flux_upwind = dvEdge(iEdge) * (max(0.0_RKIND,uh(k,iEdge))*tracer_cur(k,cell1) + min(0.0_RKIND,uh(k,iEdge))*tracer_cur(k,cell2))
             high_order_horiz_flux(k,iEdge) = high_order_horiz_flux(k,iEdge) - flux_upwind
           end do ! k loop
         end do ! iEdge loop
@@ -266,8 +264,8 @@
               upwind_tendency(k,iCell) = upwind_tendency(k,iCell) + edgeSignOncell(i, iCell) * flux_upwind * invAreaCell1
 
               ! Accumulate remaining high order fluxes
-              flux_outgoing(k,iCell) = flux_outgoing(k,iCell) + edgeSignOnCell(i, iCell) * high_order_horiz_flux(k, iEdge) * invAreaCell1
-              flux_incoming(k,iCell) = flux_incoming(k,iCell) - edgeSignOnCell(i, iCell) * high_order_horiz_flux(k, iEdge) * invAreaCell1
+              flux_outgoing(k,iCell) = flux_outgoing(k,iCell) + min(0.0_RKIND, edgeSignOnCell(i, iCell) * high_order_horiz_flux(k, iEdge)) * invAreaCell1
+              flux_incoming(k,iCell) = flux_incoming(k,iCell) + max(0.0_RKIND, edgeSignOnCell(i, iCell) * high_order_horiz_flux(k, iEdge)) * invAreaCell1
             end do
           end do
         end do
@@ -282,10 +280,10 @@
             tracer_upwind_new = (tracer_cur(k,iCell)*h(k,iCell) + dt*upwind_tendency(k,iCell)) * inv_h_new(k,iCell)
            
             scale_factor = (tracer_max(k,iCell)-tracer_upwind_new)/(tracer_max_new-tracer_upwind_new+eps)
-            flux_incoming(k,iCell) = min( 1.0, max( 0.0, scale_factor) )
+            flux_incoming(k,iCell) = min( 1.0_RKIND, max( 0.0_RKIND, scale_factor) )
 
             scale_factor = (tracer_upwind_new-tracer_min(k,iCell))/(tracer_upwind_new-tracer_min_new+eps)
-            flux_outgoing(k,iCell) = min( 1.0, max( 0.0, scale_factor) )
+            flux_outgoing(k,iCell) = min( 1.0_RKIND, max( 0.0_RKIND, scale_factor) )
           end do ! k loop
         end do ! iCell loop
 
@@ -295,8 +293,8 @@
           cell2 = cellsOnEdge(2,iEdge)
           do k = 1, maxLevelEdgeTop(iEdge)
             flux = high_order_horiz_flux(k,iEdge)
-            flux = max(0.,flux) * min(flux_outgoing(k,cell1), flux_incoming(k,cell2)) &amp;
-                 + min(0.,flux) * min(flux_incoming(k,cell1), flux_outgoing(k,cell2))
+            flux = max(0.0_RKIND,flux) * min(flux_outgoing(k,cell1), flux_incoming(k,cell2)) &amp;
+                 + min(0.0_RKIND,flux) * min(flux_incoming(k,cell1), flux_outgoing(k,cell2))
             high_order_horiz_flux(k,iEdge) = flux
           end do ! k loop
         end do ! iEdge loop
@@ -306,10 +304,10 @@
           do k = 2, maxLevelCell(iCell)
             flux =  high_order_vert_flux(k,iCell)
             ! dwj 02/03/12 Ocean and Atmosphere are different in vertical.
-!           flux = max(0.,flux) * min(flux_outgoing(k-1,iCell), flux_incoming(k  ,iCell)) &amp;
-!                + min(0.,flux) * min(flux_outgoing(k  ,iCell), flux_incoming(k-1,iCell))
-            flux = max(0.,flux) * min(flux_outgoing(k  ,iCell), flux_incoming(k-1,iCell)) &amp;
-                 + min(0.,flux) * min(flux_outgoing(k-1,iCell), flux_incoming(k  ,iCell))
+!           flux = max(0.0_RKIND,flux) * min(flux_outgoing(k-1,iCell), flux_incoming(k  ,iCell)) &amp;
+!                + min(0.0_RKIND,flux) * min(flux_outgoing(k  ,iCell), flux_incoming(k-1,iCell))
+            flux = max(0.0_RKIND,flux) * min(flux_outgoing(k  ,iCell), flux_incoming(k-1,iCell)) &amp;
+                 + min(0.0_RKIND,flux) * min(flux_outgoing(k-1,iCell), flux_incoming(k  ,iCell))
             high_order_vert_flux(k,iCell) = flux
           end do ! k loop
         end do ! iCell loop
@@ -322,7 +320,7 @@
             do k = 1, maxLevelEdgeTop(iEdge)
               tend(iTracer, k, iCell) = tend(iTracer, k, iCell) + edgeSignOnCell(i, iCell) * high_order_horiz_flux(k, iEdge) * invAreaCell1
 
-              if(config_check_monotonicity) then
+              if(config_check_tracer_monotonicity) then
                 tracer_new(k, iCell) = tracer_new(k, iCell) + edgeSignOnCell(i, iCell) * high_order_horiz_flux(k, iEdge) * invAreaCell1
               end if
             end do
@@ -334,7 +332,7 @@
           do k = 1,maxLevelCell(iCell)
             tend(iTracer, k, iCell) = tend(iTracer, k, iCell) + (high_order_vert_flux(k+1, iCell) - high_order_vert_flux(k, iCell)) + upwind_tendency(k,iCell)
 
-            if (config_check_monotonicity) then
+            if (config_check_tracer_monotonicity) then
               !tracer_new holds a tendency for now. Only for a check on monotonicity
               tracer_new(k, iCell) = tracer_new(k, iCell) + (high_order_vert_flux(k+1, iCell) - high_order_vert_flux(k, iCell)) + upwind_tendency(k,iCell)
 
@@ -344,7 +342,7 @@
           end do ! k loop
         end do ! iCell loop
 
-        if (config_check_monotonicity) then
+        if (config_check_tracer_monotonicity) then
           !build min and max bounds on old and new tracer for check on monotonicity.
           do iCell = 1, nCellsSolve
             do k = 1, maxLevelCell(iCell)

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_advection_std.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_advection_std.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_advection_std.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -51,7 +51,7 @@
    ! Input: s - current model state
    !        grid - grid metadata
    !
-   ! Output: tend - computed scalar tendencies
+   ! Output: tend - computed tracer tendencies
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
 
       real (kind=RKIND), dimension(:,:,:), intent(inout) :: tend !&lt; Input/Output: Tracer tendency

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_advection_std_hadv.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_advection_std_hadv.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_advection_std_hadv.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -91,7 +91,7 @@
               iCell = advCellsForEdge(i,iEdge)
               do k=1,grid % nVertLevels
               tracer_weight = lowOrderAdvectionMask(k, iEdge) * adv_coefs_2nd(i,iEdge) &amp; 
-                            + highOrderAdvectionMask(k, iEdge) * (adv_coefs(i,iEdge) + coef_3rd_order*sign(1.,uh(k,iEdge))*adv_coefs_3rd(i,iEdge))
+                            + highOrderAdvectionMask(k, iEdge) * (adv_coefs(i,iEdge) + coef_3rd_order*sign(1.0_RKIND,uh(k,iEdge))*adv_coefs_3rd(i,iEdge))
                 do iTracer=1,num_tracers
                   flux_arr(iTracer,k) = flux_arr(iTracer,k) + tracer_weight* tracers(iTracer,k,iCell)
                 end do

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_hmix.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_hmix.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_hmix.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -47,6 +47,7 @@
    !
    !--------------------------------------------------------------------
 
+   logical :: tracerHmixOn
    type (timer_node), pointer :: del2Timer, del4Timer
 
 
@@ -122,6 +123,8 @@
       !
       !-----------------------------------------------------------------
 
+      if(.not.tracerHmixOn) return
+
       call mpas_timer_start(&quot;del2&quot;, .false., del2Timer)
       call ocn_tracer_hmix_del2_tend(grid, h_edge, tracers, tend, err1)
       call mpas_timer_stop(&quot;del2&quot;, del2Timer)
@@ -165,6 +168,9 @@
 
       integer :: err1, err2
 
+      tracerHmixOn = .true.
+
+      if(config_disable_tr_hmix) tracerHmixOn = .false.
       call ocn_tracer_hmix_del2_init(err1)
       call ocn_tracer_hmix_del4_init(err2)
 

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_hmix_del2.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_hmix_del2.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_hmix_del2.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -211,11 +211,13 @@
 
       del2on = .false.
 
-      if ( config_h_tracer_eddy_diff2 &gt; 0.0 ) then
+      if ( config_tracer_del2 &gt; 0.0 ) then
           del2On = .true.
-          eddyDiff2 = config_h_tracer_eddy_diff2
+          eddyDiff2 = config_tracer_del2
       endif
 
+      if(.not.config_use_tracer_del2) del2on = .false.
+
    !--------------------------------------------------------------------
 
    end subroutine ocn_tracer_hmix_del2_init!}}}

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_hmix_del4.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_hmix_del4.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_hmix_del4.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -193,7 +193,7 @@
                 
               flux = tracer_turb_flux * invdcEdge
 
-              tend(iTracer, k, iCell) = tend(iTracer, k, iCell) + edgeSignOnCell(i, iCell) * invAreaCell1
+              tend(iTracer, k, iCell) = tend(iTracer, k, iCell) + edgeSignOnCell(i, iCell) * flux * invAreaCell1
             end do
           end do
         end do
@@ -233,11 +233,13 @@
       err = 0
       del4on = .false.
 
-      if ( config_h_tracer_eddy_diff4 &gt; 0.0 ) then
+      if ( config_tracer_del4 &gt; 0.0 ) then
           del4On = .true.
-          eddyDiff4 = config_h_tracer_eddy_diff4
+          eddyDiff4 = config_tracer_del4
       endif
 
+      if(.not.config_use_tracer_del4) del4on = .false.
+
    !--------------------------------------------------------------------
 
    end subroutine ocn_tracer_hmix_del4_init!}}}

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_vadv.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_vadv.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_vadv.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -123,11 +123,6 @@
 
       err = 0
 
-      ! mrp 120202 efficiency note:
-      ! The following if statement is not needed, since wTop is set to 
-      ! zero for isopycnal coordinates.  This if statment saves flops
-      ! for isopycnal coordinates.  However, if the loops are pushed
-      ! out, we could get rid of this if statement.
       if(.not.vadvOn) return
 
       call ocn_tracer_vadv_stencil_tend(grid, h, wTop, tracers, tend, err1)
@@ -172,7 +167,7 @@
       err = 0
       vadvOn = .false.
 
-      if (config_vert_grid_type.ne.'isopycnal') then
+      if (config_vert_coord_movement.ne.'isopycnal') then
           vadvOn = .true.
           call ocn_tracer_vadv_stencil_init(err1)
           call ocn_tracer_vadv_spline_init(err2)

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_vadv_spline3.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_vadv_spline3.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_tracer_vadv_spline3.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -150,8 +150,6 @@
             depthTop(k+1) = depthTop(k) +     h(k,iCell)
          enddo
 
-         ! mrp 110201 efficiency note: push tracer loop down
-         ! into spline subroutines to improve efficiency
          do iTracer=1,num_tracers
 
             ! Place data in arrays to avoid creating new temporary arrays for every 

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_vel_coriolis.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_vel_coriolis.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_vel_coriolis.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -43,6 +43,7 @@
    !
    !--------------------------------------------------------------------
 
+   logical :: coriolisOn
 
 !***********************************************************************
 
@@ -116,6 +117,8 @@
 
       err = 0
 
+      if(.not.coriolisOn) return
+
       maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
       nEdgesOnEdge =&gt; grid % nEdgesOnEdge % array
       cellsOnEdge =&gt; grid % cellsOnEdge % array
@@ -181,6 +184,10 @@
 
       err = 0
 
+      coriolisOn = .true.
+
+      if(config_disable_u_coriolis) coriolisOn = .false.
+
    !--------------------------------------------------------------------
 
    end subroutine ocn_vel_coriolis_init!}}}

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_vel_forcing.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_vel_forcing.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_vel_forcing.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -18,7 +18,6 @@
    use mpas_configure
 
    use ocn_vel_forcing_windstress
-   use ocn_vel_forcing_bottomdrag
    use ocn_vel_forcing_rayleigh
 
    implicit none
@@ -115,7 +114,7 @@
       !
       !-----------------------------------------------------------------
 
-      integer :: err1, err2, err3
+      integer :: err1, err2
 
       !-----------------------------------------------------------------
       !
@@ -126,11 +125,9 @@
       !-----------------------------------------------------------------
 
       call ocn_vel_forcing_windstress_tend(grid, u_src, h_edge, tend, err1)
-      call ocn_vel_forcing_bottomdrag_tend(grid, u, ke_edge, h_edge, tend, err2)
-      call ocn_vel_forcing_rayleigh_tend(grid, u, tend, err3)
+      call ocn_vel_forcing_rayleigh_tend(grid, u, tend, err2)
 
       err = ior(err1, err2)
-      err = ior(err, err3)
 
    !--------------------------------------------------------------------
 
@@ -164,14 +161,12 @@
 
       integer, intent(out) :: err !&lt; Output: error flag
 
-      integer :: err1, err2, err3
+      integer :: err1, err2
 
       call ocn_vel_forcing_windstress_init(err1)
-      call ocn_vel_forcing_bottomdrag_init(err2)
-      call ocn_vel_forcing_rayleigh_init(err3)
+      call ocn_vel_forcing_rayleigh_init(err2)
 
       err = ior(err1, err2)
-      err = ior(err, err3)
 
    !--------------------------------------------------------------------
 

Deleted: branches/atmos_physics/src/core_ocean/mpas_ocn_vel_forcing_bottomdrag.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_vel_forcing_bottomdrag.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_vel_forcing_bottomdrag.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -1,193 +0,0 @@
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-!
-!  ocn_vel_forcing_bottomdrag
-!
-!&gt; \brief MPAS ocean bottom drag
-!&gt; \author Doug Jacobsen
-!&gt; \date   16 September 2011
-!&gt; \version SVN:$Id:$
-!&gt; \details
-!&gt;  This module contains the routine for computing 
-!&gt;  tendencies from bottom drag.  
-!
-!-----------------------------------------------------------------------
-
-module ocn_vel_forcing_bottomdrag
-
-   use mpas_grid_types
-   use mpas_configure
-
-   implicit none
-   private
-   save
-
-   !--------------------------------------------------------------------
-   !
-   ! Public parameters
-   !
-   !--------------------------------------------------------------------
-
-   !--------------------------------------------------------------------
-   !
-   ! Public member functions
-   !
-   !--------------------------------------------------------------------
-
-   public :: ocn_vel_forcing_bottomdrag_tend, &amp;
-             ocn_vel_forcing_bottomdrag_init
-
-   !--------------------------------------------------------------------
-   !
-   ! Private module variables
-   !
-   !--------------------------------------------------------------------
-
-   logical :: bottomDragOn
-   real (kind=RKIND) :: bottomDragCoef
-
-
-!***********************************************************************
-
-contains
-
-!***********************************************************************
-!
-!  routine ocn_vel_forcing_bottomdrag_tend
-!
-!&gt; \brief   Computes tendency term from bottom drag
-!&gt; \author  Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the bottom drag tendency for momentum
-!&gt;  based on current state.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_vel_forcing_bottomdrag_tend(grid, u, ke_edge, h_edge, tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         u    !&lt; Input: velocity 
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         ke_edge     !&lt; Input: kinetic energy at edge
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge     !&lt; Input: thickness at edge
-
-      type (mesh_type), intent(in) :: &amp;
-         grid          !&lt; Input: grid information
-
-      !-----------------------------------------------------------------
-      !
-      ! input/output variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(inout) :: &amp;
-         tend          !&lt; Input/Output: velocity tendency
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: iEdge, nEdgesSolve, k
-      integer, dimension(:), pointer :: maxLevelEdgeTop
-      integer, dimension(:,:), pointer :: edgeMask
-
-      !-----------------------------------------------------------------
-      !
-      ! call relevant routines for computing tendencies
-      ! note that the user can choose multiple options and the 
-      !   tendencies will be added together
-      !
-      !-----------------------------------------------------------------
-
-      err = 0
-
-      if(.not.bottomDragOn) return
-
-      nEdgesSolve = grid % nEdgesSolve
-      maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
-      edgeMask =&gt; grid % edgeMask % array
-
-      do iEdge=1,grid % nEdgesSolve
-
-        k = max(maxLevelEdgeTop(iEdge), 1)
-
-        ! bottom drag is the same as POP:
-        ! -c |u| u  where c is unitless and 1.0e-3.
-        ! see POP Reference guide, section 3.4.4.
-
-        tend(k,iEdge) = tend(k,iEdge)-edgeMask(k,iEdge)*(bottomDragCoef*u(k,iEdge)*sqrt(2.0*ke_edge(k,iEdge))/h_edge(k,iEdge))
-
-      enddo
-
-
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_vel_forcing_bottomdrag_tend!}}}
-
-!***********************************************************************
-!
-!  routine ocn_vel_forcing_bottomdrag_init
-!
-!&gt; \brief   Initializes ocean bottom drag
-!&gt; \author  Doug Jacobsen
-!&gt; \date    16 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine initializes quantities related to bottom drag 
-!&gt;  in the ocean. 
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_vel_forcing_bottomdrag_init(err)!{{{
-
-   !--------------------------------------------------------------------
-
-      !-----------------------------------------------------------------
-      !
-      ! call individual init routines for each parameterization
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-
-      err = 0
-
-      bottomDragOn = .false.
-
-      if (.not.config_implicit_vertical_mix) then
-          bottomDragOn = .true.
-          bottomDragCoef = config_bottom_drag_coeff
-      endif
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_vel_forcing_bottomdrag_init!}}}
-
-!***********************************************************************
-
-end module ocn_vel_forcing_bottomdrag
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-! vim: foldmethod=marker

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_vel_forcing_windstress.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_vel_forcing_windstress.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_vel_forcing_windstress.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -168,6 +168,8 @@
 
       windStressOn = .true.
 
+      if(config_disable_u_windstress) windStressOn = .false.
+
       err = 0
 
    !--------------------------------------------------------------------

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_vel_hmix.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_vel_hmix.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_vel_hmix.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -48,6 +48,7 @@
    !
    !--------------------------------------------------------------------
 
+   logical :: hmixOn
    type (timer_node), pointer :: del2Timer, leithTimer, del4Timer
 
 
@@ -126,6 +127,8 @@
       !
       !-----------------------------------------------------------------
 
+      if(.not.hmixOn) return
+
       viscosity = 0.0
 
       call mpas_timer_start(&quot;del2&quot;, .false., del2Timer)
@@ -176,12 +179,16 @@
 
       integer :: err1, err2, err3
 
+      hmixOn = .true.
+
       call ocn_vel_hmix_del2_init(err1)
       call ocn_vel_hmix_leith_init(err2)
       call ocn_vel_hmix_del4_init(err3)
 
       err = ior(ior(err1, err2),err3)
 
+      if(config_disable_u_hmix) hmixOn = .false.
+
    !--------------------------------------------------------------------
 
    end subroutine ocn_vel_hmix_init!}}}

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_vel_hmix_del2.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_vel_hmix_del2.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_vel_hmix_del2.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -201,19 +201,20 @@
 
    hmixDel2On = .false.
 
-   if ( config_h_mom_eddy_visc2 &gt; 0.0 ) then
+   if ( config_mom_del2 &gt; 0.0 ) then
       hmixDel2On = .true.
-      eddyVisc2 = config_h_mom_eddy_visc2
+      eddyVisc2 = config_mom_del2
 
-
       if (config_visc_vorticity_term) then
-         viscVortCoef = config_visc_vorticity_visc2_scale
+         viscVortCoef = config_vorticity_del2_scale
       else
          viscVortCoef = 0.0
       endif
    endif
 
+   if(.not.config_use_mom_del2) hmixDel2On = .false.
 
+
    !--------------------------------------------------------------------
 
    end subroutine ocn_vel_hmix_del2_init!}}}

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_vel_hmix_del4.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_vel_hmix_del4.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_vel_hmix_del4.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -116,7 +116,7 @@
       integer :: iCell, iVertex
       integer :: nVertices, nVertLevels, nCells, nEdges, nEdgesSolve, vertexDegree
 
-      integer, dimension(:), pointer :: maxLevelEdgeTop, maxLevelVertexBot, &amp;
+      integer, dimension(:), pointer :: maxLevelEdgeTop, maxLevelVertexTop, &amp;
             maxLevelCell, nEdgesOnCell
       integer, dimension(:,:), pointer :: cellsOnEdge, verticesOnEdge, edgeMask, edgesOnVertex, edgesOnCell, edgeSignOnVertex, edgeSignOnCell
 
@@ -141,7 +141,7 @@
       vertexDegree = grid % vertexDegree
 
       maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
-      maxLevelVertexBot =&gt; grid % maxLevelVertexBot % array
+      maxLevelVertexTop =&gt; grid % maxLevelVertexTop % array
       maxLevelCell =&gt; grid % maxLevelCell % array
       cellsOnEdge =&gt; grid % cellsOnEdge % array
       verticesOnEdge =&gt; grid % verticesOnEdge % array
@@ -179,7 +179,7 @@
          do k=1,maxLevelEdgeTop(iEdge)
             ! Compute </font>
<font color="black">abla^2 u = </font>
<font color="black">abla divergence + k \times </font>
<font color="gray">abla vorticity
             delsq_u(k, iEdge) =          ( divergence(k,cell2)  - divergence(k,cell1) ) * invDcEdge  &amp;
-                -viscVortCoef *( vorticity(k,vertex2) - vorticity(k,vertex1)) * invDcEdge * sqrt(3.0)   ! TDR
+                -viscVortCoef *( vorticity(k,vertex2) - vorticity(k,vertex1)) * invDcEdge * sqrt(3.0)   
          end do
       end do
 
@@ -188,7 +188,7 @@
          invAreaTri1 = 1.0 / areaTriangle(iVertex)
          do i = 1, vertexDegree
             iEdge = edgesOnVertex(i, iVertex)
-            do k = 1, maxLevelVertexBot(iVertex)
+            do k = 1, maxLevelVertexTop(iVertex)
                delsq_vorticity(k, iVertex) = delsq_vorticity(k, iVertex) + edgeSignOnVertex(i, iVertex) * dcEdge(iEdge) * delsq_u(k, iEdge) * invAreaTri1
             end do
          end do
@@ -219,7 +219,7 @@
 
          do k=1,maxLevelEdgeTop(iEdge)
             u_diffusion = (delsq_divergence(k,cell2) - delsq_divergence(k,cell1)) * invDcEdge  &amp;
-                -viscVortCoef * (delsq_vorticity(k,vertex2) - delsq_vorticity(k,vertex1) ) * invDcEdge * sqrt(3.0) ! TDR
+                -viscVortCoef * (delsq_vorticity(k,vertex2) - delsq_vorticity(k,vertex1) ) * invDcEdge * sqrt(3.0) 
 
             tend(k,iEdge) = tend(k,iEdge) - edgeMask(k, iEdge) * u_diffusion * r_tmp
          end do
@@ -261,17 +261,19 @@
 
    hmixDel4On = .false.
 
-   if ( config_h_mom_eddy_visc4 &gt; 0.0 ) then
+   if ( config_mom_del4 &gt; 0.0 ) then
       hmixDel4On = .true.
-      eddyVisc4 = config_h_mom_eddy_visc4
+      eddyVisc4 = config_mom_del4
       if (config_visc_vorticity_term) then
-         viscVortCoef = config_visc_vorticity_visc4_scale
+         viscVortCoef = config_vorticity_del4_scale
       else
          viscVortCoef = 0.0
       endif
 
    endif
 
+   if(.not.config_use_mom_del4) hmixDel4On = .false.
+
    !--------------------------------------------------------------------
 
    end subroutine ocn_vel_hmix_del4_init!}}}

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_vel_hmix_leith.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_vel_hmix_leith.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_vel_hmix_leith.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -216,7 +216,7 @@
       hmixLeithOn = .true.
 
       if (config_visc_vorticity_term) then
-         viscVortCoef = config_visc_vorticity_visc2_scale
+         viscVortCoef = config_vorticity_del2_scale
       else
          viscVortCoef = 0.0
       endif

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_vel_pressure_grad.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_vel_pressure_grad.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_vel_pressure_grad.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -44,6 +44,7 @@
    !
    !--------------------------------------------------------------------
 
+   logical :: pgradOn
    real (kind=RKIND) :: rho0Inv, grho0Inv
 
 
@@ -113,6 +114,8 @@
 
       err = 0
 
+      if(.not.pgradOn) return
+
       nEdgesSolve = grid % nEdgesSolve
       maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
       cellsOnEdge =&gt; grid % cellsOnEdge % array
@@ -186,7 +189,9 @@
 
       err = 0
 
-      if (config_pressure_type.eq.'MontgomeryPotential') then
+      pgradOn = .true.
+
+      if (config_pressure_gradient_type.eq.'MontgomeryPotential') then
         rho0Inv = 1.0
         grho0Inv = 0.0
       else 
@@ -194,8 +199,10 @@
         grho0Inv = gravity/config_rho0
       end if
 
+      if(config_disable_u_pgrad) pgradOn = .false.
 
 
+
    !--------------------------------------------------------------------
 
    end subroutine ocn_vel_pressure_grad_init!}}}

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_vel_vadv.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_vel_vadv.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_vel_vadv.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -112,11 +112,6 @@
       real (kind=RKIND) :: wTopEdge
       real (kind=RKIND), dimension(:), allocatable :: w_dudzTopEdge
 
-      ! mrp 120202 efficiency note:
-      ! The following if statement is not needed, since wTop is set to 
-      ! zero for isopycnal coordinates.  This if statment saves flops
-      ! for isopycnal coordinates.  However, if the loops are pushed
-      ! out, we could get rid of this if statement.
       if(.not.velVadvOn) return
 
       err = 0
@@ -183,10 +178,12 @@
       err = 0
       velVadvOn = .false.
 
-      if (config_vert_grid_type.ne.'isopycnal') then
+      if (config_vert_coord_movement.ne.'isopycnal') then
           velVadvOn = .true.
       end if
 
+      if(config_disable_u_vadv) velVadvOn = .false.
+
    !--------------------------------------------------------------------
 
    end subroutine ocn_vel_vadv_init!}}}

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_vmix.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_vmix.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_vmix.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -15,6 +15,7 @@
 
 module ocn_vmix
 
+   use mpas_kind_types
    use mpas_grid_types
    use mpas_configure
    use mpas_timer
@@ -43,8 +44,6 @@
               tridiagonal_solve_mult
 
    public :: ocn_vmix_coefs, &amp;
-             ocn_vel_vmix_tend_explicit, &amp;
-             ocn_tracer_vmix_tend_explicit, &amp;
              ocn_vel_vmix_tend_implicit, &amp;
              ocn_tracer_vmix_tend_implicit, &amp;
              ocn_vmix_init, &amp;
@@ -56,7 +55,7 @@
    !
    !--------------------------------------------------------------------
 
-   logical :: explicitOn, implicitOn
+   logical :: velVmixOn, tracerVmixOn
 
 !***********************************************************************
 
@@ -123,6 +122,9 @@
 
       err = 0
 
+      d % vertViscTopOfEdge % array = 0.0_RKIND
+      d % vertDiffTopOfCell % array = 0.0_RKIND
+
       call ocn_vmix_coefs_const_build(grid, s, d, err1)
       call ocn_vmix_coefs_tanh_build(grid, s, d, err2)
       call ocn_vmix_coefs_rich_build(grid, s, d, err3)
@@ -135,99 +137,6 @@
 
 !***********************************************************************
 !
-!  routine ocn_vel_vmix_tendExplict
-!
-!&gt; \brief   Computes tendencies for explict momentum vertical mixing
-!&gt; \author  Doug Jacobsen
-!&gt; \date    19 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the tendencies for explicit vertical mixing for momentum
-!&gt;  using computed coefficients.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_vel_vmix_tend_explicit(grid, u, h_edge, vertViscTopOfEdge, tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      type (mesh_type), intent(in) :: &amp;
-         grid          !&lt; Input: grid information
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         u             !&lt; Input: velocity
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge        !&lt; Input: thickness at edge
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         vertViscTopOfEdge !&lt; Input: vertical mixing coefficients
-
-      !-----------------------------------------------------------------
-      !
-      ! input/output variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(inout) :: &amp;
-         tend          !&lt; Input/Output: tendency information
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: iEdge, nEdgesSolve, k, nVertLevels
-
-      integer, dimension(:), pointer :: maxLevelEdgeTop
-
-      real (kind=RKIND), dimension(:), allocatable :: fluxVertTop
-
-      err = 0
-
-      if(implicitOn) return
-
-      nEdgessolve = grid % nEdgesSolve
-      nVertLevels = grid % nVertLevels
-      maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
-
-      allocate(fluxVertTop(nVertLevels+1))
-      fluxVertTop(1) = 0.0
-      do iEdge=1,nEdgesSolve
-         do k=2,maxLevelEdgeTop(iEdge)
-           fluxVertTop(k) = vertViscTopOfEdge(k,iEdge) &amp;
-              * ( u(k-1,iEdge) - u(k,iEdge) ) &amp;
-              * 2 / (h_edge(k-1,iEdge) + h_edge(k,iEdge))
-         enddo
-         fluxVertTop(maxLevelEdgeTop(iEdge)+1) = 0.0
-
-         do k=1,maxLevelEdgeTop(iEdge)
-           tend(k,iEdge) = tend(k,iEdge) &amp;
-             + (fluxVertTop(k) - fluxVertTop(k+1)) &amp;
-             / h_edge(k,iEdge)
-         enddo
-
-      end do
-      deallocate(fluxVertTop)
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_vel_vmix_tend_explicit!}}}
-
-!***********************************************************************
-!
 !  routine ocn_vel_vmix_tend_implicit
 !
 !&gt; \brief   Computes tendencies for implicit momentum vertical mixing
@@ -299,7 +208,7 @@
 
       err = 0
 
-      if(explicitOn) return
+      if(.not.velVmixOn) return
 
       nEdges = grid % nEdges
       nVertLevels = grid % nVertLevels
@@ -362,110 +271,6 @@
 
 !***********************************************************************
 !
-!  routine ocn_tracer_vmix_tendExplict
-!
-!&gt; \brief   Computes tendencies for explict tracer vertical mixing
-!&gt; \author  Doug Jacobsen
-!&gt; \date    19 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the tendencies for explicit vertical mixing for
-!&gt;  tracers using computed coefficients.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vmix_tend_explicit(grid, h, vertDiffTopOfCell, tracers, tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      type (mesh_type), intent(in) :: &amp;
-         grid          !&lt; Input: grid information
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h        !&lt; Input: thickness at cell center
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         vertDiffTopOfCell !&lt; Input: vertical mixing coefficients
-
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: &amp;
-         tracers             !&lt; Input: tracers
-
-      !-----------------------------------------------------------------
-      !
-      ! input/output variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:,:), intent(inout) :: &amp;
-         tend          !&lt; Input/Output: tendency information
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: iCell, nCellsSolve, k, iTracer, num_tracers, nVertLevels
-
-      integer, dimension(:), pointer :: maxLevelCell
-
-      real (kind=RKIND), dimension(:,:), allocatable :: fluxVertTop
-
-      err = 0
-
-      if(implicitOn) return
-
-      nCellsSolve = grid % nCellsSolve
-      nVertLevels = grid % nVertLevels
-      num_tracers = size(tracers, dim=1)
-
-      maxLevelCell =&gt; grid % maxLevelCell % array
-
-      allocate(fluxVertTop(num_tracers,nVertLevels+1))
-      fluxVertTop(:,1) = 0.0
-      do iCell=1,nCellsSolve 
-
-         do k=2,maxLevelCell(iCell)
-           do iTracer=1,num_tracers
-             ! compute \kappa_v d\phi/dz
-             fluxVertTop(iTracer,k) = vertDiffTopOfCell(k,iCell) &amp;
-                * (   tracers(iTracer,k-1,iCell)    &amp;
-                    - tracers(iTracer,k  ,iCell) )  &amp;
-                * 2 / (h(k-1,iCell) + h(k,iCell))
-
-           enddo
-         enddo
-         fluxVertTop(:,maxLevelCell(iCell)+1) = 0.0
-
-         do k=1,maxLevelCell(iCell)
-           do iTracer=1,num_tracers
-             ! This is h d/dz( fluxVertTop) but h and dz cancel, so 
-             ! reduces to delta( fluxVertTop)
-             tend(iTracer,k,iCell) = tend(iTracer,k,iCell) &amp;
-               + fluxVertTop(iTracer,k) - fluxVertTop(iTracer,k+1)
-           enddo
-         enddo
-
-      enddo ! iCell loop
-      deallocate(fluxVertTop)
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vmix_tend_explicit!}}}
-
-!***********************************************************************
-!
 !  routine ocn_tracer_vmix_tend_implicit
 !
 !&gt; \brief   Computes tendencies for implicit tracer vertical mixing
@@ -530,7 +335,7 @@
 
       err = 0
 
-      if(explicitOn) return
+      if(.not.tracerVmixOn) return
 
       nCells = grid % nCells
       nVertLevels = grid % nVertLevels
@@ -640,8 +445,7 @@
 !&gt; \version SVN:$Id$
 !&gt; \details 
 !&gt;  This routine initializes a variety of quantities related to 
-!&gt;  vertical mixing in the ocean. This primarily determines if
-!&gt;  explicit or implicit vertical mixing is to be used.
+!&gt;  vertical mixing in the ocean. 
 !
 !-----------------------------------------------------------------------
 
@@ -662,13 +466,11 @@
 
       err = 0
 
-      explicitOn = .true.
-      implicitOn = .false.
+      velVmixOn = .true.
+      tracerVmixOn = .true.
 
-      if(config_implicit_vertical_mix) then
-          explicitOn = .false.
-          implicitOn = .true.
-      end if
+      if(config_disable_u_vmix) velVmixOn = .false.
+      if(config_disable_tr_vmix) tracerVmixOn = .false.
 
       call ocn_vmix_coefs_const_init(err1)
       call ocn_vmix_coefs_tanh_init(err2)

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_vmix_coefs_const.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_vmix_coefs_const.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_vmix_coefs_const.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -121,7 +121,6 @@
       !-----------------------------------------------------------------
 
       err = 0
-      if((.not.constViscOn) .and. (.not.constDiffOn)) return
 
       vertViscTopOfEdge =&gt; d % vertViscTopOfEdge % array
       vertDiffTopOfCell =&gt; d % vertDiffTopOfCell % array
@@ -185,7 +184,7 @@
 
       if(.not.constViscOn) return
 
-      vertViscTopOfEdge = constVisc
+      vertViscTopOfEdge = vertViscTopOfEdge + constVisc
 
    !--------------------------------------------------------------------
 
@@ -241,7 +240,7 @@
 
       if(.not.constDiffOn) return
 
-      vertDiffTopOfCell = constDiff
+      vertDiffTopOfCell = vertDiffTopOfCell + constDiff
 
    !--------------------------------------------------------------------
 
@@ -279,18 +278,20 @@
 
       err = 0
 
-      constViscOn = .false.
-      constDiffOn = .false.
+      constViscOn = config_use_const_visc
+      constDiffOn = config_use_const_diff
+      constVisc = config_vert_visc
+      constDiff = config_vert_diff
 
-      if (config_vert_visc_type.eq.'const') then
-          constViscOn = .true.
-          constVisc = config_vert_visc
-      endif
+!     if (config_vert_visc_type.eq.'const') then
+!         constViscOn = .true.
+!         constVisc = config_vert_visc
+!     endif
 
-      if (config_vert_diff_type.eq.'const') then
-          constDiffOn = .true.
-          constDiff = config_vert_diff
-      endif
+!     if (config_vert_diff_type.eq.'const') then
+!         constDiffOn = .true.
+!         constDiff = config_vert_diff
+!     endif
 
 
    !--------------------------------------------------------------------

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_vmix_coefs_rich.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_vmix_coefs_rich.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_vmix_coefs_rich.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -124,7 +124,6 @@
       !-----------------------------------------------------------------
 
       err = 0
-      if((.not.richViscOn) .and. (.not.richDiffOn)) return
 
       indexT = s%index_temperature
       indexS = s%index_salinity
@@ -222,35 +221,19 @@
 
       maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
 
-      vertViscTopOfEdge = 0.0
       do iEdge = 1,nEdges
          do k = 2,maxLevelEdgeTop(iEdge)
-            ! mrp 110324 efficiency note: this if is inside iEdge and k loops.
+            ! efficiency note: these if statements are inside iEdge and k loops.
             ! Perhaps there is a more efficient way to do this.
             if (RiTopOfEdge(k,iEdge)&gt;0.0) then
-               vertViscTopOfEdge(k,iEdge) = config_bkrd_vert_visc &amp;
+               vertViscTopOfEdge(k,iEdge) = vertViscTopOfEdge(k, iEdge) + config_bkrd_vert_visc &amp;
                   + config_rich_mix / (1.0 + 5.0*RiTopOfEdge(k,iEdge))**2
-            ! maltrud do limiting of coefficient--should not be necessary
-            ! also probably better logic could be found
                if (vertViscTopOfEdge(k,iEdge) &gt; config_convective_visc) then
-                   if( config_implicit_vertical_mix) then
-                      vertViscTopOfEdge(k,iEdge) = config_convective_visc
-                   else
-                      vertViscTopOfEdge(k,iEdge) = &amp;
-                      ((h_edge(k-1,iEdge)+h_edge(k,iEdge))/2.0)**2/config_dt/4.0
-                   end if
+                  vertViscTopOfEdge(k,iEdge) = config_convective_visc
                end if
             else
-               ! mrp 110324 efficiency note: this if is inside iCell and k loops.
-               if (config_implicit_vertical_mix) then
-                  ! for Ri&lt;0 and implicit mix, use convective diffusion
-                  vertViscTopOfEdge(k,iEdge) = config_convective_visc
-               else
-                  ! for Ri&lt;0 and explicit vertical mix, 
-                  ! use maximum diffusion allowed by CFL criterion
-                  vertViscTopOfEdge(k,iEdge) = &amp;
-                      ((h_edge(k-1,iEdge)+h_edge(k,iEdge))/2.0)**2/config_dt/4.0
-               end if
+               ! for Ri&lt;0 use the convective value for the viscosity
+               vertViscTopOfEdge(k,iEdge) = config_convective_visc
             end if
          end do
       end do
@@ -326,38 +309,22 @@
 
       maxLevelCell =&gt; grid % maxLevelCell % array
 
-      vertDiffTopOfCell = 0.0
       coef = -gravity/config_rho0/2.0
       do iCell = 1,nCells
          do k = 2,maxLevelCell(iCell)
-            ! mrp 110324 efficiency note: this if is inside iCell and k loops.
+            ! efficiency note: these if statements are inside iEdge and k loops.
             ! Perhaps there is a more efficient way to do this.
             if (RiTopOfCell(k,iCell)&gt;0.0) then
-               vertDiffTopOfCell(k,iCell) = config_bkrd_vert_diff &amp;
+               vertDiffTopOfCell(k,iCell) = vertDiffTopOfCell(k, iCell) + config_bkrd_vert_diff &amp;
                   + (config_bkrd_vert_visc &amp; 
                      + config_rich_mix / (1.0 + 5.0*RiTopOfCell(k,iCell))**2) &amp;
                   / (1.0 + 5.0*RiTopOfCell(k,iCell))
-            ! maltrud do limiting of coefficient--should not be necessary
-            ! also probably better logic could be found
                if (vertDiffTopOfCell(k,iCell) &gt; config_convective_diff) then
-                  if (config_implicit_vertical_mix) then
-                     vertDiffTopOfCell(k,iCell) = config_convective_diff
-                  else
-                     vertDiffTopOfCell(k,iCell) = &amp;
-                        ((h(k-1,iCell)+h(k,iCell))/2.0)**2/config_dt/4.0
-                  end if
+                  vertDiffTopOfCell(k,iCell) = config_convective_diff
                end if
              else
-               ! mrp 110324 efficiency note: this if is inside iCell and k loops.
-               if (config_implicit_vertical_mix) then
-                  ! for Ri&lt;0 and implicit mix, use convective diffusion
-                  vertDiffTopOfCell(k,iCell) = config_convective_diff
-               else
-                  ! for Ri&lt;0 and explicit vertical mix, 
-                  ! use maximum diffusion allowed by CFL criterion
-                  vertDiffTopOfCell(k,iCell) = &amp;
-                     ((h(k-1,iCell)+h(k,iCell))/2.0)**2/config_dt/4.0
-               end if
+               ! for Ri&lt;0 use the convective value for the diffusion
+               vertDiffTopOfCell(k,iCell) = config_convective_diff
             end if
          end do
       end do
@@ -461,16 +428,6 @@
          drhoTopOfCell(nVertLevels+1,nCells+1), drhoTopOfEdge(nVertLevels+1,nEdges), &amp;
          du2TopOfCell(nVertLevels+1,nCells+1), du2TopOfEdge(nVertLevels+1,nEdges))
 
-      ! compute density of parcel displaced to next deeper z-level,
-      ! in state % rhoDisplaced
-!maltrud make sure rho is current--check this for redundancy
-!     call OcnEquationOfStateRho(grid, 'relative', 0, indexT, indexS, &amp;
-!              tracers, rho, err) 
-      ! mrp 110324 In order to visualize rhoDisplaced, include the following
-!     call OcnEquationOfStateRho(grid, 'relative', 1, indexT, indexS, &amp;
-!              tracers, rhoDisplaced, err) 
-
-
       ! drhoTopOfCell(k) = $\rho^*_{k-1}-\rho^*_k$
       drhoTopOfCell = 0.0
       do iCell=1,nCells
@@ -573,16 +530,16 @@
 
       err = 0
 
-      richViscOn = .false.
-      richDiffOn = .false.
+      richViscOn = config_use_rich_visc
+      richDiffOn = config_use_rich_diff
 
-      if (config_vert_visc_type.eq.'rich') then
-          richViscOn = .true.
-      endif
+!     if (config_vert_visc_type.eq.'rich') then
+!         richViscOn = .true.
+!     endif
 
-      if (config_vert_diff_type.eq.'rich') then
-          richDiffOn = .true.
-      endif
+!     if (config_vert_diff_type.eq.'rich') then
+!         richDiffOn = .true.
+!     endif
 
 
    !--------------------------------------------------------------------

Modified: branches/atmos_physics/src/core_ocean/mpas_ocn_vmix_coefs_tanh.F
===================================================================
--- branches/atmos_physics/src/core_ocean/mpas_ocn_vmix_coefs_tanh.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_ocean/mpas_ocn_vmix_coefs_tanh.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -115,7 +115,6 @@
       !-----------------------------------------------------------------
 
       err = 0
-      if((.not.tanhViscOn) .and. (.not.tanhDiffOn)) return
 
       vertViscTopOfEdge =&gt; d % vertViscTopOfEdge % array
       vertDiffTopOfCell =&gt; d % vertDiffTopOfCell % array
@@ -189,9 +188,8 @@
       ! refBottomDepth is used here for simplicity.  Using zMid and h, which 
       ! vary in time, would give the exact location of the top, but it
       ! would only change the diffusion value very slightly.
-      vertViscTopOfEdge = 0.0
       do k=2,nVertLevels
-         vertViscTopOfEdge(k,:) = -(config_max_visc_tanh-config_min_visc_tanh)/2.0 &amp;
+         vertViscTopOfEdge(k,:) = vertViscTopOfEdge(k,:)-(config_max_visc_tanh-config_min_visc_tanh)/2.0 &amp;
             *tanh((refBottomDepth(k-1)+config_ZMid_tanh) &amp;
                   /config_zWidth_tanh) &amp;
             + (config_max_visc_tanh+config_min_visc_tanh)/2
@@ -262,9 +260,8 @@
       ! refBottomDepth is used here for simplicity.  Using zMid and h, which 
       ! vary in time, would give the exact location of the top, but it
       ! would only change the diffusion value very slightly.
-      vertDiffTopOfCell = 0.0
       do k=2,nVertLevels
-         vertDiffTopOfCell(k,:) = -(config_max_diff_tanh-config_min_diff_tanh)/2.0 &amp;
+         vertDiffTopOfCell(k,:) = vertDiffTopOfCell(k,:)-(config_max_diff_tanh-config_min_diff_tanh)/2.0 &amp;
             *tanh((refBottomDepth(k-1)+config_ZMid_tanh) &amp;
                   /config_zWidth_tanh) &amp;
             + (config_max_diff_tanh+config_min_diff_tanh)/2
@@ -305,16 +302,16 @@
 
       err = 0
 
-      tanhViscOn = .false.
-      tanhDiffOn = .false.
+      tanhViscOn = config_use_tanh_visc
+      tanhDiffOn = config_use_tanh_diff
 
-      if (config_vert_visc_type.eq.'tanh') then
-          tanhViscOn = .true.
-      endif
+!     if (config_vert_visc_type.eq.'tanh') then
+!         tanhViscOn = .true.
+!     endif
 
-      if (config_vert_diff_type.eq.'tanh') then
-          tanhDiffOn = .true.
-      endif
+!     if (config_vert_diff_type.eq.'tanh') then
+!         tanhDiffOn = .true.
+!     endif
 
    !--------------------------------------------------------------------
 

Modified: branches/atmos_physics/src/core_sw/Registry
===================================================================
--- branches/atmos_physics/src/core_sw/Registry        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/core_sw/Registry        2013-03-26 23:03:26 UTC (rev 2670)
@@ -97,7 +97,7 @@
 
 var persistent real    edgeNormalVectors ( R3 nEdges ) 0 o edgeNormalVectors mesh - -
 var persistent real    localVerticalUnitVectors ( R3 nCells ) 0 o localVerticalUnitVectors mesh - -
-var persistent real    cellTangentPlane ( R3 TWO nEdges ) 0 o cellTangentPlane mesh - -
+var persistent real    cellTangentPlane ( R3 TWO nCells ) 0 o cellTangentPlane mesh - -
 
 var persistent integer cellsOnCell ( maxEdges nCells ) 0 iro cellsOnCell mesh - -
 var persistent integer verticesOnCell ( maxEdges nCells ) 0 iro verticesOnCell mesh - -

Copied: branches/atmos_physics/src/core_sw/Registry.xml (from rev 2666, trunk/mpas/src/core_sw/Registry.xml)
===================================================================
--- branches/atmos_physics/src/core_sw/Registry.xml                                (rev 0)
+++ branches/atmos_physics/src/core_sw/Registry.xml        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,146 @@
+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;registry&gt;
+        &lt;dims&gt;
+                &lt;dim name=&quot;nCells&quot;/&gt;
+                &lt;dim name=&quot;nEdges&quot;/&gt;
+                &lt;dim name=&quot;maxEdges&quot;/&gt;
+                &lt;dim name=&quot;maxEdges2&quot;/&gt;
+                &lt;dim name=&quot;nVertices&quot;/&gt;
+                &lt;dim name=&quot;TWO&quot;                definition=&quot;2&quot;/&gt;
+                &lt;dim name=&quot;R3&quot;                 definition=&quot;3&quot;/&gt;
+                &lt;dim name=&quot;FIFTEEN&quot;            definition=&quot;15&quot;/&gt;
+                &lt;dim name=&quot;TWENTYONE&quot;          definition=&quot;21&quot;/&gt;
+                &lt;dim name=&quot;vertexDegree&quot;/&gt;
+                &lt;dim name=&quot;nVertLevels&quot;/&gt;
+                &lt;dim name=&quot;nTracers&quot;/&gt;
+        &lt;/dims&gt;
+        &lt;nml_record name=&quot;sw_model&quot;&gt;
+                &lt;nml_option name=&quot;config_test_case&quot;                  type=&quot;integer&quot;       default_value=&quot;5&quot;/&gt;
+                &lt;nml_option name=&quot;config_time_integration&quot;           type=&quot;character&quot;     default_value=&quot;RK4&quot;/&gt;
+                &lt;nml_option name=&quot;config_dt&quot;                         type=&quot;real&quot;          default_value=&quot;172.8&quot;/&gt;
+                &lt;nml_option name=&quot;config_calendar_type&quot;              type=&quot;character&quot;     default_value=&quot;360day&quot;/&gt;
+                &lt;nml_option name=&quot;config_start_time&quot;                 type=&quot;character&quot;     default_value=&quot;0000-01-01_00:00:00&quot;/&gt;
+                &lt;nml_option name=&quot;config_stop_time&quot;                  type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+                &lt;nml_option name=&quot;config_run_duration&quot;               type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+                &lt;nml_option name=&quot;config_stats_interval&quot;             type=&quot;integer&quot;       default_value=&quot;100&quot;/&gt;
+                &lt;nml_option name=&quot;config_h_ScaleWithMesh&quot;            type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_h_mom_eddy_visc2&quot;           type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_h_mom_eddy_visc4&quot;           type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_h_tracer_eddy_diff2&quot;        type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_h_tracer_eddy_diff4&quot;        type=&quot;real&quot;          default_value=&quot;0.0&quot;/&gt;
+                &lt;nml_option name=&quot;config_thickness_adv_order&quot;        type=&quot;integer&quot;       default_value=&quot;2&quot;/&gt;
+                &lt;nml_option name=&quot;config_tracer_adv_order&quot;           type=&quot;integer&quot;       default_value=&quot;2&quot;/&gt;
+                &lt;nml_option name=&quot;config_positive_definite&quot;          type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_monotonic&quot;                  type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_wind_stress&quot;                type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_bottom_drag&quot;                type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_apvm_upwinding&quot;             type=&quot;real&quot;          default_value=&quot;0.5&quot;/&gt;
+                &lt;nml_option name=&quot;config_num_halos&quot;                  type=&quot;integer&quot;       default_value=&quot;2&quot;/&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;io&quot;&gt;
+                &lt;nml_option name=&quot;config_input_name&quot;                 type=&quot;character&quot;     default_value=&quot;grid.nc&quot;/&gt;
+                &lt;nml_option name=&quot;config_output_name&quot;                type=&quot;character&quot;     default_value=&quot;output.nc&quot;/&gt;
+                &lt;nml_option name=&quot;config_restart_name&quot;               type=&quot;character&quot;     default_value=&quot;restart.nc&quot;/&gt;
+                &lt;nml_option name=&quot;config_output_interval&quot;            type=&quot;character&quot;     default_value=&quot;06:00:00&quot;/&gt;
+                &lt;nml_option name=&quot;config_frames_per_outfile&quot;         type=&quot;integer&quot;       default_value=&quot;0&quot;/&gt;
+                &lt;nml_option name=&quot;config_pio_num_iotasks&quot;            type=&quot;integer&quot;       default_value=&quot;0&quot;/&gt;
+                &lt;nml_option name=&quot;config_pio_stride&quot;                 type=&quot;integer&quot;       default_value=&quot;1&quot;/&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;decomposition&quot;&gt;
+                &lt;nml_option name=&quot;config_block_decomp_file_prefix&quot;   type=&quot;character&quot;     default_value=&quot;graph.info.part.&quot;/&gt;
+                &lt;nml_option name=&quot;config_number_of_blocks&quot;           type=&quot;integer&quot;       default_value=&quot;0&quot;/&gt;
+                &lt;nml_option name=&quot;config_explicit_proc_decomp&quot;       type=&quot;logical&quot;       default_value=&quot;.false.&quot;/&gt;
+                &lt;nml_option name=&quot;config_proc_decomp_file_prefix&quot;    type=&quot;character&quot;     default_value=&quot;graph.info.part.&quot;/&gt;
+        &lt;/nml_record&gt;
+        &lt;nml_record name=&quot;restart&quot;&gt;
+                &lt;nml_option name=&quot;config_do_restart&quot;                 type=&quot;logical&quot;       default_value=&quot;false&quot;/&gt;
+                &lt;nml_option name=&quot;config_restart_interval&quot;           type=&quot;character&quot;     default_value=&quot;none&quot;/&gt;
+        &lt;/nml_record&gt;
+        &lt;var_struct name=&quot;state&quot; time_levs=&quot;2&quot;&gt;
+                &lt;var name=&quot;xtime&quot;                             type=&quot;text&quot;     dimensions=&quot;Time&quot;                        streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;u&quot;                                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;h&quot;                                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;tracers&quot;                           type=&quot;real&quot;     dimensions=&quot;nTracers nVertLevels nCells Time&quot; streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;v&quot;                                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;divergence&quot;                        type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;vorticity&quot;                         type=&quot;real&quot;     dimensions=&quot;nVertLevels nVertices Time&quot;  streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;vorticity_cell&quot;                    type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;pv_edge&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;h_edge&quot;                            type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;ke&quot;                                type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;pv_vertex&quot;                         type=&quot;real&quot;     dimensions=&quot;nVertLevels nVertices Time&quot;  streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;pv_cell&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructX&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructY&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructZ&quot;                     type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructZonal&quot;                 type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;uReconstructMeridional&quot;            type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;     streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;vh&quot;                                type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;/&gt;
+                &lt;var name=&quot;circulation&quot;                       type=&quot;real&quot;     dimensions=&quot;nVertLevels nVertices Time&quot;/&gt;
+                &lt;var name=&quot;gradPVt&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;/&gt;
+                &lt;var name=&quot;gradPVn&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;/&gt;
+                &lt;var name=&quot;h_vertex&quot;                          type=&quot;real&quot;     dimensions=&quot;nVertLevels nVertices Time&quot;/&gt;
+        &lt;/var_struct&gt;
+        &lt;var_struct name=&quot;mesh&quot; time_levs=&quot;0&quot;&gt;
+                &lt;var name=&quot;latCell&quot;                           type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;lonCell&quot;                           type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;xCell&quot;                             type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;yCell&quot;                             type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;zCell&quot;                             type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;indexToCellID&quot;                     type=&quot;integer&quot;  dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;latEdge&quot;                           type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;lonEdge&quot;                           type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;xEdge&quot;                             type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;yEdge&quot;                             type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;zEdge&quot;                             type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;indexToEdgeID&quot;                     type=&quot;integer&quot;  dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;latVertex&quot;                         type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;lonVertex&quot;                         type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;xVertex&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;yVertex&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;zVertex&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;indexToVertexID&quot;                   type=&quot;integer&quot;  dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;meshDensity&quot;                       type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;meshScalingDel2&quot;                   type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;meshScalingDel4&quot;                   type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;cellsOnEdge&quot;                       type=&quot;integer&quot;  dimensions=&quot;TWO nEdges&quot;                  streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;nEdgesOnCell&quot;                      type=&quot;integer&quot;  dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;nEdgesOnEdge&quot;                      type=&quot;integer&quot;  dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;edgesOnCell&quot;                       type=&quot;integer&quot;  dimensions=&quot;maxEdges nCells&quot;             streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;edgesOnEdge&quot;                       type=&quot;integer&quot;  dimensions=&quot;maxEdges2 nEdges&quot;            streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;weightsOnEdge&quot;                     type=&quot;real&quot;     dimensions=&quot;maxEdges2 nEdges&quot;            streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;dvEdge&quot;                            type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;dcEdge&quot;                            type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;angleEdge&quot;                         type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;areaCell&quot;                          type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;areaTriangle&quot;                      type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;edgeNormalVectors&quot;                 type=&quot;real&quot;     dimensions=&quot;R3 nEdges&quot;                   streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;localVerticalUnitVectors&quot;          type=&quot;real&quot;     dimensions=&quot;R3 nCells&quot;                   streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;cellTangentPlane&quot;                  type=&quot;real&quot;     dimensions=&quot;R3 TWO nCells&quot;               streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;cellsOnCell&quot;                       type=&quot;integer&quot;  dimensions=&quot;maxEdges nCells&quot;             streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;verticesOnCell&quot;                    type=&quot;integer&quot;  dimensions=&quot;maxEdges nCells&quot;             streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;verticesOnEdge&quot;                    type=&quot;integer&quot;  dimensions=&quot;TWO nEdges&quot;                  streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;edgesOnVertex&quot;                     type=&quot;integer&quot;  dimensions=&quot;vertexDegree nVertices&quot;      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;cellsOnVertex&quot;                     type=&quot;integer&quot;  dimensions=&quot;vertexDegree nVertices&quot;      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;kiteAreasOnVertex&quot;                 type=&quot;real&quot;     dimensions=&quot;vertexDegree nVertices&quot;      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;fEdge&quot;                             type=&quot;real&quot;     dimensions=&quot;nEdges&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;fVertex&quot;                           type=&quot;real&quot;     dimensions=&quot;nVertices&quot;                   streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;fCell&quot;                             type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;h_s&quot;                               type=&quot;real&quot;     dimensions=&quot;nCells&quot;                      streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;deriv_two&quot;                         type=&quot;real&quot;     dimensions=&quot;FIFTEEN TWO nEdges&quot;          streams=&quot;o&quot;/&gt;
+                &lt;var name=&quot;advCells&quot;                          type=&quot;integer&quot;  dimensions=&quot;TWENTYONE nCells&quot;/&gt;
+                &lt;var name=&quot;defc_a&quot;                            type=&quot;real&quot;     dimensions=&quot;maxEdges nCells&quot;/&gt;
+                &lt;var name=&quot;defc_b&quot;                            type=&quot;real&quot;     dimensions=&quot;maxEdges nCells&quot;/&gt;
+                &lt;var name=&quot;kdiff&quot;                             type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;/&gt;
+                &lt;var name=&quot;coeffs_reconstruct&quot;                type=&quot;real&quot;     dimensions=&quot;R3 maxEdges nCells&quot;/&gt;
+                &lt;var name=&quot;boundaryEdge&quot;                      type=&quot;integer&quot;  dimensions=&quot;nVertLevels nEdges&quot;          streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;boundaryVertex&quot;                    type=&quot;integer&quot;  dimensions=&quot;nVertLevels nVertices&quot;       streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;boundaryCell&quot;                      type=&quot;integer&quot;  dimensions=&quot;nVertLevels nCells&quot;          streams=&quot;iro&quot;/&gt;
+                &lt;var name=&quot;u_src&quot;                             type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges&quot;          streams=&quot;iro&quot;/&gt;
+        &lt;/var_struct&gt;
+        &lt;var_struct name=&quot;tend&quot; time_levs=&quot;1&quot;&gt;
+                &lt;var name=&quot;tend_u&quot;                            type=&quot;real&quot;     dimensions=&quot;nVertLevels nEdges Time&quot;           name_in_code=&quot;u&quot;/&gt;
+                &lt;var name=&quot;tend_h&quot;                            type=&quot;real&quot;     dimensions=&quot;nVertLevels nCells Time&quot;           name_in_code=&quot;h&quot;/&gt;
+                &lt;var name=&quot;tend_tracers&quot;                      type=&quot;real&quot;     dimensions=&quot;nTracers nVertLevels nCells Time&quot;  name_in_code=&quot;tracers&quot;/&gt;
+        &lt;/var_struct&gt;
+&lt;/registry&gt;

Modified: branches/atmos_physics/src/framework/mpas_dmpar.F
===================================================================
--- branches/atmos_physics/src/framework/mpas_dmpar.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/framework/mpas_dmpar.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -2825,12 +2825,13 @@
      integer, dimension(:), pointer, optional :: haloLayersIn
 
      type (field4dReal), pointer :: fieldInPtr, fieldOutPtr
-     type (mpas_exchange_list), pointer :: exchListPtr
+     type (mpas_exchange_list), pointer :: exchListPtr, exchListPtr2
      type (mpas_communication_list), pointer :: sendList, recvList, commListPtr, commListPtr2
      type (dm_info), pointer :: dminfo
 
      logical :: comm_list_found
 
+     integer :: lastPackedIdx, lastUnpackedIdx, nPacked, nUnpacked
      integer :: nAdded, bufferOffset
      integer :: mpi_ierr
      integer :: iHalo, iBuffer, i, j, k, l
@@ -3122,12 +3123,13 @@
      integer, dimension(:), pointer, optional :: haloLayersIn
 
      type (field5dReal), pointer :: fieldInPtr, fieldOutPtr
-     type (mpas_exchange_list), pointer :: exchListPtr
+     type (mpas_exchange_list), pointer :: exchListPtr, exchListPtr2
      type (mpas_communication_list), pointer :: sendList, recvList, commListPtr, commListPtr2
      type (dm_info), pointer :: dminfo
 
      logical :: comm_list_found
 
+     integer :: lastPackedIdx, lastUnpackedIdx, nPacked, nUnpacked
      integer :: nAdded, bufferOffset
      integer :: mpi_ierr
      integer :: iHalo, iBuffer, i, j, k, l, m

Modified: branches/atmos_physics/src/framework/mpas_grid_types.F
===================================================================
--- branches/atmos_physics/src/framework/mpas_grid_types.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/framework/mpas_grid_types.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -37,6 +37,7 @@
       integer, dimension(5) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -66,6 +67,7 @@
       integer, dimension(4) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -96,6 +98,7 @@
       integer, dimension(3) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -125,6 +128,7 @@
       integer, dimension(2) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -154,6 +158,7 @@
       integer, dimension(1) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -210,6 +215,7 @@
       integer, dimension(3) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -239,6 +245,7 @@
       integer, dimension(2) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -268,6 +275,7 @@
       integer, dimension(1) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -324,6 +332,7 @@
       integer, dimension(1) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -534,6 +543,10 @@
        logical :: single_block
        type (field1dInteger), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -562,6 +575,10 @@
        logical :: single_block
        type (field2dInteger), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -590,6 +607,10 @@
        logical :: single_block
        type (field3dInteger), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -618,6 +639,10 @@
        logical :: single_block
        type (field1dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -646,6 +671,10 @@
        logical :: single_block
        type (field2dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -674,6 +703,10 @@
        logical :: single_block
        type (field3dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -702,6 +735,10 @@
        logical :: single_block
        type (field4dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -730,6 +767,10 @@
        logical :: single_block
        type (field5dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -758,6 +799,10 @@
        logical :: single_block
        type (field1dChar), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -786,6 +831,10 @@
        logical :: single_block
        type (field1dInteger), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -815,6 +864,10 @@
        logical :: single_block
        type (field2dInteger), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -844,6 +897,10 @@
        logical :: single_block
        type (field3dInteger), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -873,6 +930,10 @@
        logical :: single_block
        type (field1dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -902,6 +963,10 @@
        logical :: single_block
        type (field2dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -931,6 +996,10 @@
        logical :: single_block
        type (field3dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -960,6 +1029,10 @@
        logical :: single_block
        type (field4dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -989,6 +1062,10 @@
        logical :: single_block
        type (field5dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -1018,6 +1095,10 @@
        logical :: single_block
        type (field1dChar), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else

Modified: branches/atmos_physics/src/framework/mpas_io.F
===================================================================
--- branches/atmos_physics/src/framework/mpas_io.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/framework/mpas_io.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -1489,6 +1489,8 @@
       real (kind=RKIND), dimension(:,:,:,:,:), intent(out) :: array
       integer, intent(out), optional :: ierr
 
+      integer :: pio_ierr
+      type (fieldlist_type), pointer :: field_cursor
 
 !      write(0,*) 'Called MPAS_io_get_var_real5d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR
@@ -1849,6 +1851,8 @@
       real (kind=RKIND), dimension(:,:,:,:,:), intent(in) :: array
       integer, intent(out), optional :: ierr
 
+      integer :: pio_ierr
+      type (fieldlist_type), pointer :: field_cursor
 
 !      write(0,*) 'Called MPAS_io_put_var_real5d()'
       if (present(ierr)) ierr = MPAS_IO_NOERR

Modified: branches/atmos_physics/src/framework/mpas_io_streams.F
===================================================================
--- branches/atmos_physics/src/framework/mpas_io_streams.F        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/framework/mpas_io_streams.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -993,7 +993,10 @@
       logical :: isDecomposed
       integer :: ndims
       type (field4dReal), pointer :: field_ptr
+      character (len=StrKIND), dimension(5) :: dimNames
+      character (len=StrKIND), dimension(:), pointer :: dimNamesInq
       integer, dimension(:), pointer :: indices
+      type (field_list_type), pointer :: field_list_cursor
       type (field_list_type), pointer :: new_field_list_node
       logical :: any_success
       logical, dimension(:), pointer :: isAvailable
@@ -1091,7 +1094,10 @@
       logical :: isDecomposed
       integer :: ndims
       type (field5dReal), pointer :: field_ptr
+      character (len=StrKIND), dimension(5) :: dimNames
+      character (len=StrKIND), dimension(:), pointer :: dimNamesInq
       integer, dimension(:), pointer :: indices
+      type (field_list_type), pointer :: field_list_cursor
       type (field_list_type), pointer :: new_field_list_node
       logical :: any_success
       logical, dimension(:), pointer :: isAvailable

Deleted: branches/atmos_physics/src/ocean_cesm_driver/Makefile
===================================================================
--- trunk/mpas/src/ocean_cesm_driver/Makefile        2013-03-25 16:55:55 UTC (rev 2666)
+++ branches/atmos_physics/src/ocean_cesm_driver/Makefile        2013-03-26 23:03:26 UTC (rev 2670)
@@ -1,24 +0,0 @@
-.SUFFIXES: .F .o
-
-OBJS = ocn_comp_mct.o \
-       ocn_communicator.o \
-       mpaso_cpl_indices.o \
-           mpaso_mct_vars.o
-
-all: $(OBJS)
-
-ocn_comp_mct.o: ocn_communicator.o mpaso_cpl_indices.o mpaso_mct_vars.o
-
-ocn_communicator.o:
-
-mpaso_cpl_indices.o:
-
-mpaso_mct_vars.o:
-
-clean:
-        $(RM) *.o *.mod *.f90
-
-.F.o:
-        $(RM) $@ $*.mod
-        $(CPP) $(CPPFLAGS) $(CPPINCLUDES) $&lt; &gt; $*.f90
-        $(FC) $(FFLAGS) -c $*.f90 $(FCINCLUDES) -I../framework -I../core_$(CORE) -I../external/esmf_time_f90

Copied: branches/atmos_physics/src/ocean_cesm_driver/Makefile (from rev 2666, trunk/mpas/src/ocean_cesm_driver/Makefile)
===================================================================
--- branches/atmos_physics/src/ocean_cesm_driver/Makefile                                (rev 0)
+++ branches/atmos_physics/src/ocean_cesm_driver/Makefile        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,24 @@
+.SUFFIXES: .F .o
+
+OBJS = ocn_comp_mct.o \
+       ocn_communicator.o \
+       mpaso_cpl_indices.o \
+           mpaso_mct_vars.o
+
+all: $(OBJS)
+
+ocn_comp_mct.o: ocn_communicator.o mpaso_cpl_indices.o mpaso_mct_vars.o
+
+ocn_communicator.o:
+
+mpaso_cpl_indices.o:
+
+mpaso_mct_vars.o:
+
+clean:
+        $(RM) *.o *.mod *.f90
+
+.F.o:
+        $(RM) $@ $*.mod
+        $(CPP) $(CPPFLAGS) $(CPPINCLUDES) $&lt; &gt; $*.f90
+        $(FC) $(FFLAGS) -c $*.f90 $(FCINCLUDES) -I../framework -I../core_$(CORE) -I../external/esmf_time_f90

Deleted: branches/atmos_physics/src/ocean_cesm_driver/mpaso_cpl_indices.F
===================================================================
--- trunk/mpas/src/ocean_cesm_driver/mpaso_cpl_indices.F        2013-03-25 16:55:55 UTC (rev 2666)
+++ branches/atmos_physics/src/ocean_cesm_driver/mpaso_cpl_indices.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -1,125 +0,0 @@
-module mpaso_cpl_indices
-  
-  use seq_flds_mod
-  use mct_mod
-
-  implicit none
-
-  SAVE
-  public                               ! By default make data private
-
-  ! ocn -&gt; drv
-
-  integer :: index_o2x_So_t      
-  integer :: index_o2x_So_u
-  integer :: index_o2x_So_v
-  integer :: index_o2x_So_s
-  integer :: index_o2x_So_dhdx
-  integer :: index_o2x_So_dhdy
-  integer :: index_o2x_Fioo_q
-  integer :: index_o2x_Faoo_fco2_ocn
-  integer :: index_o2x_Faoo_fdms_ocn
-
-  ! drv -&gt; ocn
-
-  integer :: index_x2o_Si_ifrac        ! fractional ice wrt ocean
-  integer :: index_x2o_So_duu10n       ! 10m wind speed squared           (m^2/s^2)
-  integer :: index_x2o_Sa_pslv         ! sea-level pressure               (Pa)
-  integer :: index_x2o_Sa_co2prog      ! bottom atm level prognostic CO2
-  integer :: index_x2o_Sa_co2diag      ! bottom atm level diagnostic CO2
-  integer :: index_x2o_Foxx_taux       ! zonal wind stress (taux)         (W/m2   )
-  integer :: index_x2o_Foxx_tauy       ! meridonal wind stress (tauy)     (W/m2   )
-  integer :: index_x2o_Foxx_swnet      ! net short-wave heat flux         (W/m2   )
-  integer :: index_x2o_Foxx_sen        ! sensible heat flux               (W/m2   )
-  integer :: index_x2o_Foxx_lat        
-  integer :: index_x2o_Foxx_lwup       ! longwave radiation (up)          (W/m2   )
-  integer :: index_x2o_Faxa_lwdn       ! longwave radiation (down)        (W/m2   )
-  integer :: index_x2o_Fioi_melth      ! heat flux from snow &amp; ice melt   (W/m2   )
-  integer :: index_x2o_Fioi_meltw      ! snow melt flux                   (kg/m2/s)
-  integer :: index_x2o_Fioi_salt       ! salt                             (kg(salt)/m2/s)
-  integer :: index_x2o_Foxx_evap       ! evaporation flux                 (kg/m2/s)
-  integer :: index_x2o_Faxa_prec         
-  integer :: index_x2o_Faxa_snow       ! water flux due to snow           (kg/m2/s)
-  integer :: index_x2o_Faxa_rain       ! water flux due to rain           (kg/m2/s)
-  integer :: index_x2o_Faxa_bcphidry   ! flux: Black   Carbon hydrophilic dry deposition
-  integer :: index_x2o_Faxa_bcphodry   ! flux: Black   Carbon hydrophobic dry deposition
-  integer :: index_x2o_Faxa_bcphiwet   ! flux: Black   Carbon hydrophilic wet deposition
-  integer :: index_x2o_Faxa_ocphidry   ! flux: Organic Carbon hydrophilic dry deposition
-  integer :: index_x2o_Faxa_ocphodry   ! flux: Organic Carbon hydrophobic dry deposition
-  integer :: index_x2o_Faxa_ocphiwet   ! flux: Organic Carbon hydrophilic dry deposition
-  integer :: index_x2o_Faxa_dstwet1    ! flux: Size 1 dust -- wet deposition
-  integer :: index_x2o_Faxa_dstwet2    ! flux: Size 2 dust -- wet deposition
-  integer :: index_x2o_Faxa_dstwet3    ! flux: Size 3 dust -- wet deposition
-  integer :: index_x2o_Faxa_dstwet4    ! flux: Size 4 dust -- wet deposition
-  integer :: index_x2o_Faxa_dstdry1    ! flux: Size 1 dust -- dry deposition
-  integer :: index_x2o_Faxa_dstdry2    ! flux: Size 2 dust -- dry deposition
-  integer :: index_x2o_Faxa_dstdry3    ! flux: Size 3 dust -- dry deposition
-  integer :: index_x2o_Faxa_dstdry4    ! flux: Size 4 dust -- dry deposition
-  integer :: index_x2o_Forr_roff       ! river runoff flux                (kg/m2/s)
-  integer :: index_x2o_Forr_ioff       ! ice runoff flux                  (kg/m2/s)
-
-contains
-
-  subroutine mpaso_cpl_indices_set( )
-
-    type(mct_aVect) :: o2x      ! temporary
-    type(mct_aVect) :: x2o      ! temporary
-
-    ! Determine attribute vector indices
-
-    ! create temporary attribute vectors
-    call mct_aVect_init(x2o, rList=seq_flds_x2o_fields, lsize=1)
-    call mct_aVect_init(o2x, rList=seq_flds_o2x_fields, lsize=1)
-
-    index_o2x_So_t          = mct_avect_indexra(o2x,'So_t')
-    index_o2x_So_u          = mct_avect_indexra(o2x,'So_u')
-    index_o2x_So_v          = mct_avect_indexra(o2x,'So_v')
-    index_o2x_So_s          = mct_avect_indexra(o2x,'So_s')
-    index_o2x_So_dhdx       = mct_avect_indexra(o2x,'So_dhdx')
-    index_o2x_So_dhdy       = mct_avect_indexra(o2x,'So_dhdy')
-    index_o2x_Fioo_q        = mct_avect_indexra(o2x,'Fioo_q')
-    index_o2x_Faoo_fco2_ocn = mct_avect_indexra(o2x,'Faoo_fco2_ocn',perrWith='quiet')
-    index_o2x_Faoo_fdms_ocn = mct_avect_indexra(o2x,'Faoo_fdms_ocn',perrWith='quiet')
-    index_x2o_Si_ifrac      = mct_avect_indexra(x2o,'Si_ifrac')
-    index_x2o_Sa_pslv       = mct_avect_indexra(x2o,'Sa_pslv')
-    index_x2o_So_duu10n     = mct_avect_indexra(x2o,'So_duu10n')
-
-    index_x2o_Foxx_tauy     = mct_avect_indexra(x2o,'Foxx_tauy')
-    index_x2o_Foxx_taux     = mct_avect_indexra(x2o,'Foxx_taux')
-    index_x2o_Foxx_swnet    = mct_avect_indexra(x2o,'Foxx_swnet')
-    index_x2o_Foxx_lat      = mct_avect_indexra(x2o,'Foxx_lat')
-    index_x2o_Foxx_sen      = mct_avect_indexra(x2o,'Foxx_sen')
-    index_x2o_Foxx_lwup     = mct_avect_indexra(x2o,'Foxx_lwup')
-    index_x2o_Faxa_lwdn     = mct_avect_indexra(x2o,'Faxa_lwdn')
-    index_x2o_Fioi_melth    = mct_avect_indexra(x2o,'Fioi_melth')   
-    index_x2o_Fioi_meltw    = mct_avect_indexra(x2o,'Fioi_meltw')
-    index_x2o_Fioi_salt     = mct_avect_indexra(x2o,'Fioi_salt')   
-    index_x2o_Faxa_prec     = mct_avect_indexra(x2o,'Faxa_prec')   
-    index_x2o_Faxa_snow     = mct_avect_indexra(x2o,'Faxa_snow')   
-    index_x2o_Faxa_rain     = mct_avect_indexra(x2o,'Faxa_rain')   
-    index_x2o_Foxx_evap     = mct_avect_indexra(x2o,'Foxx_evap')
-    index_x2o_Forr_roff     = mct_avect_indexra(x2o,'Forr_roff')
-    index_x2o_Forr_ioff     = mct_avect_indexra(x2o,'Forr_ioff')
-    index_x2o_Faxa_bcphidry = mct_avect_indexra(x2o,'Faxa_bcphidry')
-    index_x2o_Faxa_bcphodry = mct_avect_indexra(x2o,'Faxa_bcphodry')
-    index_x2o_Faxa_bcphiwet = mct_avect_indexra(x2o,'Faxa_bcphiwet')
-    index_x2o_Faxa_ocphidry = mct_avect_indexra(x2o,'Faxa_ocphidry')
-    index_x2o_Faxa_ocphodry = mct_avect_indexra(x2o,'Faxa_ocphodry')
-    index_x2o_Faxa_ocphiwet = mct_avect_indexra(x2o,'Faxa_ocphiwet')
-    index_x2o_Faxa_dstdry1  = mct_avect_indexra(x2o,'Faxa_dstdry1')
-    index_x2o_Faxa_dstdry2  = mct_avect_indexra(x2o,'Faxa_dstdry2')
-    index_x2o_Faxa_dstdry3  = mct_avect_indexra(x2o,'Faxa_dstdry3')
-    index_x2o_Faxa_dstdry4  = mct_avect_indexra(x2o,'Faxa_dstdry4')
-    index_x2o_Faxa_dstwet1  = mct_avect_indexra(x2o,'Faxa_dstwet1')
-    index_x2o_Faxa_dstwet2  = mct_avect_indexra(x2o,'Faxa_dstwet2')
-    index_x2o_Faxa_dstwet3  = mct_avect_indexra(x2o,'Faxa_dstwet3')
-    index_x2o_Faxa_dstwet4  = mct_avect_indexra(x2o,'Faxa_dstwet4')
-    index_x2o_Sa_co2prog    = mct_avect_indexra(x2o,'Sa_co2prog',perrWith='quiet')
-    index_x2o_Sa_co2diag    = mct_avect_indexra(x2o,'Sa_co2diag',perrWith='quiet')
-
-    call mct_aVect_clean(x2o)
-    call mct_aVect_clean(o2x)
-
-  end subroutine mpaso_cpl_indices_set
-
-end module mpaso_cpl_indices

Copied: branches/atmos_physics/src/ocean_cesm_driver/mpaso_cpl_indices.F (from rev 2666, trunk/mpas/src/ocean_cesm_driver/mpaso_cpl_indices.F)
===================================================================
--- branches/atmos_physics/src/ocean_cesm_driver/mpaso_cpl_indices.F                                (rev 0)
+++ branches/atmos_physics/src/ocean_cesm_driver/mpaso_cpl_indices.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,125 @@
+module mpaso_cpl_indices
+  
+  use seq_flds_mod
+  use mct_mod
+
+  implicit none
+
+  SAVE
+  public                               ! By default make data private
+
+  ! ocn -&gt; drv
+
+  integer :: index_o2x_So_t      
+  integer :: index_o2x_So_u
+  integer :: index_o2x_So_v
+  integer :: index_o2x_So_s
+  integer :: index_o2x_So_dhdx
+  integer :: index_o2x_So_dhdy
+  integer :: index_o2x_Fioo_q
+  integer :: index_o2x_Faoo_fco2_ocn
+  integer :: index_o2x_Faoo_fdms_ocn
+
+  ! drv -&gt; ocn
+
+  integer :: index_x2o_Si_ifrac        ! fractional ice wrt ocean
+  integer :: index_x2o_So_duu10n       ! 10m wind speed squared           (m^2/s^2)
+  integer :: index_x2o_Sa_pslv         ! sea-level pressure               (Pa)
+  integer :: index_x2o_Sa_co2prog      ! bottom atm level prognostic CO2
+  integer :: index_x2o_Sa_co2diag      ! bottom atm level diagnostic CO2
+  integer :: index_x2o_Foxx_taux       ! zonal wind stress (taux)         (W/m2   )
+  integer :: index_x2o_Foxx_tauy       ! meridonal wind stress (tauy)     (W/m2   )
+  integer :: index_x2o_Foxx_swnet      ! net short-wave heat flux         (W/m2   )
+  integer :: index_x2o_Foxx_sen        ! sensible heat flux               (W/m2   )
+  integer :: index_x2o_Foxx_lat        
+  integer :: index_x2o_Foxx_lwup       ! longwave radiation (up)          (W/m2   )
+  integer :: index_x2o_Faxa_lwdn       ! longwave radiation (down)        (W/m2   )
+  integer :: index_x2o_Fioi_melth      ! heat flux from snow &amp; ice melt   (W/m2   )
+  integer :: index_x2o_Fioi_meltw      ! snow melt flux                   (kg/m2/s)
+  integer :: index_x2o_Fioi_salt       ! salt                             (kg(salt)/m2/s)
+  integer :: index_x2o_Foxx_evap       ! evaporation flux                 (kg/m2/s)
+  integer :: index_x2o_Faxa_prec         
+  integer :: index_x2o_Faxa_snow       ! water flux due to snow           (kg/m2/s)
+  integer :: index_x2o_Faxa_rain       ! water flux due to rain           (kg/m2/s)
+  integer :: index_x2o_Faxa_bcphidry   ! flux: Black   Carbon hydrophilic dry deposition
+  integer :: index_x2o_Faxa_bcphodry   ! flux: Black   Carbon hydrophobic dry deposition
+  integer :: index_x2o_Faxa_bcphiwet   ! flux: Black   Carbon hydrophilic wet deposition
+  integer :: index_x2o_Faxa_ocphidry   ! flux: Organic Carbon hydrophilic dry deposition
+  integer :: index_x2o_Faxa_ocphodry   ! flux: Organic Carbon hydrophobic dry deposition
+  integer :: index_x2o_Faxa_ocphiwet   ! flux: Organic Carbon hydrophilic dry deposition
+  integer :: index_x2o_Faxa_dstwet1    ! flux: Size 1 dust -- wet deposition
+  integer :: index_x2o_Faxa_dstwet2    ! flux: Size 2 dust -- wet deposition
+  integer :: index_x2o_Faxa_dstwet3    ! flux: Size 3 dust -- wet deposition
+  integer :: index_x2o_Faxa_dstwet4    ! flux: Size 4 dust -- wet deposition
+  integer :: index_x2o_Faxa_dstdry1    ! flux: Size 1 dust -- dry deposition
+  integer :: index_x2o_Faxa_dstdry2    ! flux: Size 2 dust -- dry deposition
+  integer :: index_x2o_Faxa_dstdry3    ! flux: Size 3 dust -- dry deposition
+  integer :: index_x2o_Faxa_dstdry4    ! flux: Size 4 dust -- dry deposition
+  integer :: index_x2o_Forr_roff       ! river runoff flux                (kg/m2/s)
+  integer :: index_x2o_Forr_ioff       ! ice runoff flux                  (kg/m2/s)
+
+contains
+
+  subroutine mpaso_cpl_indices_set( )
+
+    type(mct_aVect) :: o2x      ! temporary
+    type(mct_aVect) :: x2o      ! temporary
+
+    ! Determine attribute vector indices
+
+    ! create temporary attribute vectors
+    call mct_aVect_init(x2o, rList=seq_flds_x2o_fields, lsize=1)
+    call mct_aVect_init(o2x, rList=seq_flds_o2x_fields, lsize=1)
+
+    index_o2x_So_t          = mct_avect_indexra(o2x,'So_t')
+    index_o2x_So_u          = mct_avect_indexra(o2x,'So_u')
+    index_o2x_So_v          = mct_avect_indexra(o2x,'So_v')
+    index_o2x_So_s          = mct_avect_indexra(o2x,'So_s')
+    index_o2x_So_dhdx       = mct_avect_indexra(o2x,'So_dhdx')
+    index_o2x_So_dhdy       = mct_avect_indexra(o2x,'So_dhdy')
+    index_o2x_Fioo_q        = mct_avect_indexra(o2x,'Fioo_q')
+    index_o2x_Faoo_fco2_ocn = mct_avect_indexra(o2x,'Faoo_fco2_ocn',perrWith='quiet')
+    index_o2x_Faoo_fdms_ocn = mct_avect_indexra(o2x,'Faoo_fdms_ocn',perrWith='quiet')
+    index_x2o_Si_ifrac      = mct_avect_indexra(x2o,'Si_ifrac')
+    index_x2o_Sa_pslv       = mct_avect_indexra(x2o,'Sa_pslv')
+    index_x2o_So_duu10n     = mct_avect_indexra(x2o,'So_duu10n')
+
+    index_x2o_Foxx_tauy     = mct_avect_indexra(x2o,'Foxx_tauy')
+    index_x2o_Foxx_taux     = mct_avect_indexra(x2o,'Foxx_taux')
+    index_x2o_Foxx_swnet    = mct_avect_indexra(x2o,'Foxx_swnet')
+    index_x2o_Foxx_lat      = mct_avect_indexra(x2o,'Foxx_lat')
+    index_x2o_Foxx_sen      = mct_avect_indexra(x2o,'Foxx_sen')
+    index_x2o_Foxx_lwup     = mct_avect_indexra(x2o,'Foxx_lwup')
+    index_x2o_Faxa_lwdn     = mct_avect_indexra(x2o,'Faxa_lwdn')
+    index_x2o_Fioi_melth    = mct_avect_indexra(x2o,'Fioi_melth')   
+    index_x2o_Fioi_meltw    = mct_avect_indexra(x2o,'Fioi_meltw')
+    index_x2o_Fioi_salt     = mct_avect_indexra(x2o,'Fioi_salt')   
+    index_x2o_Faxa_prec     = mct_avect_indexra(x2o,'Faxa_prec')   
+    index_x2o_Faxa_snow     = mct_avect_indexra(x2o,'Faxa_snow')   
+    index_x2o_Faxa_rain     = mct_avect_indexra(x2o,'Faxa_rain')   
+    index_x2o_Foxx_evap     = mct_avect_indexra(x2o,'Foxx_evap')
+    index_x2o_Forr_roff     = mct_avect_indexra(x2o,'Forr_roff')
+    index_x2o_Forr_ioff     = mct_avect_indexra(x2o,'Forr_ioff')
+    index_x2o_Faxa_bcphidry = mct_avect_indexra(x2o,'Faxa_bcphidry')
+    index_x2o_Faxa_bcphodry = mct_avect_indexra(x2o,'Faxa_bcphodry')
+    index_x2o_Faxa_bcphiwet = mct_avect_indexra(x2o,'Faxa_bcphiwet')
+    index_x2o_Faxa_ocphidry = mct_avect_indexra(x2o,'Faxa_ocphidry')
+    index_x2o_Faxa_ocphodry = mct_avect_indexra(x2o,'Faxa_ocphodry')
+    index_x2o_Faxa_ocphiwet = mct_avect_indexra(x2o,'Faxa_ocphiwet')
+    index_x2o_Faxa_dstdry1  = mct_avect_indexra(x2o,'Faxa_dstdry1')
+    index_x2o_Faxa_dstdry2  = mct_avect_indexra(x2o,'Faxa_dstdry2')
+    index_x2o_Faxa_dstdry3  = mct_avect_indexra(x2o,'Faxa_dstdry3')
+    index_x2o_Faxa_dstdry4  = mct_avect_indexra(x2o,'Faxa_dstdry4')
+    index_x2o_Faxa_dstwet1  = mct_avect_indexra(x2o,'Faxa_dstwet1')
+    index_x2o_Faxa_dstwet2  = mct_avect_indexra(x2o,'Faxa_dstwet2')
+    index_x2o_Faxa_dstwet3  = mct_avect_indexra(x2o,'Faxa_dstwet3')
+    index_x2o_Faxa_dstwet4  = mct_avect_indexra(x2o,'Faxa_dstwet4')
+    index_x2o_Sa_co2prog    = mct_avect_indexra(x2o,'Sa_co2prog',perrWith='quiet')
+    index_x2o_Sa_co2diag    = mct_avect_indexra(x2o,'Sa_co2diag',perrWith='quiet')
+
+    call mct_aVect_clean(x2o)
+    call mct_aVect_clean(o2x)
+
+  end subroutine mpaso_cpl_indices_set
+
+end module mpaso_cpl_indices

Deleted: branches/atmos_physics/src/ocean_cesm_driver/mpaso_mct_vars.F
===================================================================
--- trunk/mpas/src/ocean_cesm_driver/mpaso_mct_vars.F        2013-03-25 16:55:55 UTC (rev 2666)
+++ branches/atmos_physics/src/ocean_cesm_driver/mpaso_mct_vars.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -1,15 +0,0 @@
-module mpaso_mct_vars
-  
-  use seq_flds_mod
-  use mct_mod
-
-  implicit none
-
-  save
-  public                               ! By default make data private
-
-  integer :: MPASO_MCT_OCNID
-  type(mct_gsMap), pointer :: MPASO_MCT_gsMap_o
-  type(mct_gGrid), pointer :: MPASO_MCT_dom_o

-end module mpaso_mct_vars

Copied: branches/atmos_physics/src/ocean_cesm_driver/mpaso_mct_vars.F (from rev 2666, trunk/mpas/src/ocean_cesm_driver/mpaso_mct_vars.F)
===================================================================
--- branches/atmos_physics/src/ocean_cesm_driver/mpaso_mct_vars.F                                (rev 0)
+++ branches/atmos_physics/src/ocean_cesm_driver/mpaso_mct_vars.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,15 @@
+module mpaso_mct_vars
+  
+  use seq_flds_mod
+  use mct_mod
+
+  implicit none
+
+  save
+  public                               ! By default make data private
+
+  integer :: MPASO_MCT_OCNID
+  type(mct_gsMap), pointer :: MPASO_MCT_gsMap_o
+  type(mct_gGrid), pointer :: MPASO_MCT_dom_o

+end module mpaso_mct_vars

Deleted: branches/atmos_physics/src/ocean_cesm_driver/ocn_communicator.F
===================================================================
--- trunk/mpas/src/ocean_cesm_driver/ocn_communicator.F        2013-03-25 16:55:55 UTC (rev 2666)
+++ branches/atmos_physics/src/ocean_cesm_driver/ocn_communicator.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -1,5 +0,0 @@
-module ocn_communicator
-
-  integer, public :: mpi_communicator_ocn
-
-end module ocn_communicator

Copied: branches/atmos_physics/src/ocean_cesm_driver/ocn_communicator.F (from rev 2666, trunk/mpas/src/ocean_cesm_driver/ocn_communicator.F)
===================================================================
--- branches/atmos_physics/src/ocean_cesm_driver/ocn_communicator.F                                (rev 0)
+++ branches/atmos_physics/src/ocean_cesm_driver/ocn_communicator.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,5 @@
+module ocn_communicator
+
+  integer, public :: mpi_communicator_ocn
+
+end module ocn_communicator

Deleted: branches/atmos_physics/src/ocean_cesm_driver/ocn_comp_mct.F
===================================================================
--- trunk/mpas/src/ocean_cesm_driver/ocn_comp_mct.F        2013-03-25 16:55:55 UTC (rev 2666)
+++ branches/atmos_physics/src/ocean_cesm_driver/ocn_comp_mct.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -1,1633 +0,0 @@
-module ocn_comp_mct
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-!BOP
-! !MODULE: ocn_comp_mct
-! !INTERFACE:
-
-! !DESCRIPTION:
-!  This is the main driver for the Model for Predication Across Scales Ocean Model (MPAS-O).
-!
-! !REVISION HISTORY:
-!  SVN:$Id:
-!
-! !USES:
-   use mct_mod
-   use esmf
-   use seq_flds_mod
-   use seq_cdata_mod
-   use seq_infodata_mod
-   use seq_timemgr_mod
-   use seq_comm_mct,      only : seq_comm_suffix, seq_comm_inst, seq_comm_name
-   use shr_file_mod 
-   use shr_cal_mod,       only : shr_cal_date2ymd
-   use shr_sys_mod
-   use shr_pio_mod
-   use perf_mod
-   use ocn_communicator,  only: mpi_communicator_ocn
-
-   use mpaso_cpl_indices
-   use mpaso_mct_vars
-
-   use mpas_framework
-   use mpas_core
-   use mpas_kind_types
-
-!
-! !PUBLIC MEMBER FUNCTIONS:
-  implicit none
-  public :: ocn_init_mct
-  public :: ocn_run_mct
-  public :: ocn_final_mct
-  SAVE
-  private                              ! By default make data private
-
-!
-! ! PUBLIC DATA:
-!
-! !REVISION HISTORY:
-! Author: Mariana Vertenstein
-!
-!EOP
-! !PRIVATE MODULE FUNCTIONS:
-  private :: ocn_export_mct
-  private :: ocn_import_mct
-  private :: ocn_SetGSMap_mct
-  private :: ocn_domain_mct
-!
-! !PRIVATE MODULE VARIABLES
-
-  logical :: ldiag_cpl = .false.
-
-  integer, private ::   &amp;
-      cpl_write_restart,   &amp;! flag id for write restart
-      cpl_write_history,   &amp;! flag id for write history
-      cpl_write_tavg,      &amp;! flag id for write tavg      
-      cpl_diag_global,     &amp;! flag id for computing diagnostics
-      cpl_diag_transp,     &amp;! flag id for computing diagnostics
-      my_task
-
-  real (kind=RKIND), dimension(:,:,:,:), allocatable ::  SBUFF_SUM           ! accumulated sum of send buffer quantities
-                                                                             ! for averaging before being sent
-   real (kind=RKIND) :: tlast_coupled
-
-   integer  :: nsend, nrecv
-
-   character(len=StrKIND) :: runtype         
-
-   type(seq_infodata_type), pointer :: infodata   
-   type (iosystem_desc_t), pointer :: io_system 
-
-   !! MPAS-O Datatypes
-   type (dm_info), pointer :: dminfo
-   type (domain_type), pointer :: domain
-   type (io_output_object), save :: output_obj
-   integer :: output_frame
-!  type (MPAS_Clock_type) :: clock
-
-!=======================================================================
-
-contains
-
-!***********************************************************************
-!BOP
-!
-! !IROUTINE: ocn_init_mct
-!
-! !INTERFACE:
-  subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )!{{{
-!
-! !DESCRIPTION:
-! Initialize POP 
-!
-! !INPUT/OUTPUT PARAMETERS:
-
-    type(ESMF_Clock), intent(in) :: EClock
-    type(seq_cdata), intent(inout) :: cdata_o
-    type(mct_aVect), intent(inout) :: x2o_o, o2x_o
-    character(len=*), optional, intent(in) :: NLFilename ! Namelist filename
-!
-! !REVISION HISTORY:
-! Author: Mariana Vertenstein
-!EOP
-!-----------------------------------------------------------------------
-!
-!  local variables
-!
-!-----------------------------------------------------------------------
-
-    integer :: OCNID, mpicom_o, lsize, start_ymd, start_tod, start_year, start_day,   &amp;
-       start_month, start_hour, iyear, ocn_cpl_dt, mpas_o_cpl_dt, shrlogunit, shrloglev  
-
-    type(mct_gsMap), pointer :: gsMap_o
-
-    type(mct_gGrid), pointer :: dom_o
-
-    integer :: errorCode  ! error code
-
-    integer :: nThreads
-
-    real (kind=RKIND) :: precadj
-
-    type (MPAS_Time_Type) :: currTime
-    integer :: iam,ierr 
-    integer :: iyear0, imonth0
-    character(len=StrKIND)  :: starttype          ! infodata start type
-    character(len=StrKIND)  :: timeStamp
-    character(len=StrKIND)  :: nml_filename
-
-    integer :: lbnum
-
-!-----------------------------------------------------------------------
-!
-!  set cdata pointers
-!
-!-----------------------------------------------------------------------
-
-   errorCode = 0
-
-   call seq_cdata_setptrs(cdata_o, ID=OCNID, mpicom=mpicom_o, &amp;
-        gsMap=gsMap_o, dom=dom_o, infodata=infodata)
-
-   MPASO_MCT_OCNID =  OCNID
-   MPASO_MCT_gsMap_o =&gt; gsMap_o
-   MPASO_MCT_dom_o   =&gt; dom_o
-
-#if (defined _MEMTRACE)
-    call MPI_comm_rank(mpicom_o,iam,ierr)
-    if(iam == 0) then
-        lbnum=1
-        call memmon_dump_fort('memmon.out','ocn_init_mct:start::',lbnum) 
-    endif
-#endif
-
-
-    ! The following communicator module variable will be utilized in init_communicate that
-    ! is called by initial - this is done to make the code backwards compatible
-
-    mpi_communicator_ocn = mpicom_o
-
-!-----------------------------------------------------------------------
-!
-!  initialize the model run 
-!
-!-----------------------------------------------------------------------
-
-    call mpaso_cpl_indices_set()
-
-!   call seq_infodata_GetData( infodata, case_name=runid )
-    call seq_infodata_GetData( infodata, start_type=starttype)
-
-
-    if (     trim(starttype) == trim(seq_infodata_start_type_start)) then
-       runtype = &quot;initial&quot;
-    else if (trim(starttype) == trim(seq_infodata_start_type_cont) ) then
-       runtype = &quot;continue&quot;
-    else if (trim(starttype) == trim(seq_infodata_start_type_brnch)) then
-       runtype = &quot;branch&quot;
-    else
-       call mpas_dmpar_global_abort(' ocn_comp_mct ERROR: unknown starttype')
-    end if
-   
-!-----------------------------------------------------------------------
-!
-!  first initializaiton phase of mpas-o
-!  initialize mpas-o because grid information is needed for
-!  creation of GSMap_ocn.
-!  call mpas-o initialization routines
-!
-!-----------------------------------------------------------------------
-
-!  inst_name   = seq_comm_name(OCNID)
-!  inst_index  = seq_comm_inst(OCNID)
-!  inst_suffix = seq_comm_suffix(OCNID)
-
-   call t_startf('mpas-o_init')
-   nml_filename = &quot;mpaso.in&quot;
-
-   io_system =&gt; shr_pio_getiosys(ocnid)
-
-   call mpas_framework_init(dminfo, domain, mpi_communicator_ocn, nml_filename, io_system)
-
-   my_task = dminfo % my_proc_id
-   call mpas_timer_start(&quot;total time&quot;)
-
-   call mpas_input_state_for_domain(domain)
-
-   call mpas_core_init(domain, timeStamp)
-
-!-----------------------------------------------------------------------
-!
-!  initialize time-stamp information
-!
-!-----------------------------------------------------------------------
-
-   call t_stopf ('mpas-o_init')
-
-!----------------------------------------------------------------------------
-!
-! reset shr logging to my log file
-!
-!----------------------------------------------------------------------------
-
-   call shr_file_getLogUnit (shrlogunit)
-   call shr_file_getLogLevel(shrloglev)
-!  call shr_file_setLogUnit (stdout)
-   
-!-----------------------------------------------------------------------
-!
-!  check for consistency of mpas-o and sync clock initial time
-!
-!-----------------------------------------------------------------------
-
-  if (runtype == 'initial') then
-     currTime = mpas_get_clock_time(clock, MPAS_NOW, ierr)
-     call mpas_get_time(curr_time=currTime, YYYY=iyear0, MM=imonth0, ierr=ierr)
-     call seq_timemgr_EClockGetData(EClock, start_ymd=start_ymd, start_tod=start_tod)
-     call shr_cal_date2ymd(start_ymd,start_year,start_month,start_day)
-
-     if (iyear0 /= start_year) then
-        call mpas_dmpar_global_abort(' iyear0 does not match start_year')
-     end if
-     if (imonth0 /= start_month) then
-        call mpas_dmpar_global_abort(' imonth0 does not match start_year')
-     end if
-  end if
-
-!-----------------------------------------------------------------------
-!
-!  initialize MCT attribute vectors and indices
-!
-!-----------------------------------------------------------------------
-
-   call t_startf ('mpas-o_mct_init')
-
-   call ocn_SetGSMap_mct( mpicom_o, OCNID, GSMap_o )
-   lsize = mct_gsMap_lsize(gsMap_o, mpicom_o)
-
-   ! Initialize mct ocn domain (needs ocn initialization info)
-   
-   call ocn_domain_mct( lsize, gsMap_o, dom_o )
-   
-   ! Inialize mct attribute vectors
-   
-   call mct_aVect_init(x2o_o, rList=seq_flds_x2o_fields, lsize=lsize)
-   call mct_aVect_zero(x2o_o)
-   
-   call mct_aVect_init(o2x_o, rList=seq_flds_o2x_fields, lsize=lsize) 
-   call mct_aVect_zero(o2x_o)
-   
-   nsend = mct_avect_nRattr(o2x_o)
-   nrecv = mct_avect_nRattr(x2o_o)
-
-!-----------------------------------------------------------------------
-!
-!   initialize necessary  coupling info
-!
-!-----------------------------------------------------------------------
-
-    call seq_timemgr_EClockGetData(EClock, dtime=ocn_cpl_dt)
-    mpas_o_cpl_dt = 86400 / config_ncouple_per_day
-    if (mpas_o_cpl_dt /= ocn_cpl_dt) then
-       write(0,*)'mpas-o_cpl_dt= ',mpas_o_cpl_dt, &amp;
-                     ' ocn_cpl_dt= ',ocn_cpl_dt   
-       call mpas_dmpar_global_abort('ERROR mpas-o_cpl_dt and ocn_cpl_dt must be identical')
-    end if
-
-!-----------------------------------------------------------------------
-!
-!  send intial state to driver
-!
-!-----------------------------------------------------------------------
-
-!  if ( lsend_precip_fact )  then
-!     precadj = precip_fact * 1.0e6_r8  
-!     call seq_infodata_PutData( infodata, precip_fact=precadj)
-!  end if
-
-   call ocn_export_mct(o2x_o, errorCode)  
-   if (errorCode /= 0) then
-      call mpas_dmpar_global_abort('ERROR in ocn_export_mct')
-   endif
-
-   call t_stopf ('mpas-o_mct_init')
-
-!  call seq_infodata_PutData( infodata, ocn_nx = nx_global , ocn_ny = ny_global)
-   call seq_infodata_PutData( infodata, ocn_prognostic=.true., ocnrof_prognostic=.true.)
-
-!----------------------------------------------------------------------------
-!
-! Reset shr logging to original values
-!
-!----------------------------------------------------------------------------
-
-    call shr_file_setLogUnit (shrlogunit)
-    call shr_file_setLogLevel(shrloglev)
-
-#if (defined _MEMTRACE)
-    if(iam  == 0) then
-        lbnum=1
-        call memmon_dump_fort('memmon.out','ocn_init_mct:end::',lbnum) 
-        call memmon_reset_addr()
-    endif
-#endif
-
-!-----------------------------------------------------------------------
-!
-!  output delimiter to log file
-!
-!-----------------------------------------------------------------------
-
-   !DWJ IO Units
-!  if (my_task == master_task) then
-!     write(stdout,blank_fmt)
-!     write(stdout,'(&quot; End of initialization&quot;)')
-!     write(stdout,blank_fmt)
-!     write(stdout,ndelim_fmt)
-!     call POP_IOUnitsFlush(POP_stdout)
-#ifdef CCSMCOUPLED
-!     call POP_IOUnitsFlush(stdout)
-#endif
-!  endif
-
-      !
-      ! Set up output streams to be written to by the MPAS core
-      !
-      output_frame = 1
-
-      if(config_frames_per_outfile &gt; 0) then
-         call mpas_output_state_init(output_obj, domain, &quot;OUTPUT&quot;, trim(timeStamp))
-      else
-         call mpas_output_state_init(output_obj, domain, &quot;OUTPUT&quot;)         
-      end if
-
-!-----------------------------------------------------------------------
-!EOC
-
- end subroutine ocn_init_mct!}}}
-
-!***********************************************************************
-!BOP
-!
-! !IROUTINE: ocn_run_mct
-!
-! !INTERFACE:
-  subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)!{{{
-
-    use mpas_kind_types
-    use mpas_grid_types
-    use mpas_io_output
-    use mpas_timer
-
-    implicit none
-!
-! !DESCRIPTION:
-! Run POP for a coupling interval
-!
-! !INPUT/OUTPUT PARAMETERS:
-    type(ESMF_Clock)            , intent(in)    :: EClock
-    type(seq_cdata)             , intent(inout) :: cdata_o
-    type(mct_aVect)             , intent(inout) :: x2o_o
-    type(mct_aVect)             , intent(inout) :: o2x_o
-
-!!
-!! !REVISION HISTORY:
-!! Author: Mariana Vertenstein
-!!EOP
-!!-----------------------------------------------------------------------
-!!
-!!  local variables
-!!
-!!-----------------------------------------------------------------------
-!
-!    integer :: errorCode           ! error flag
-!
-!    integer :: itimestep
-!
-!    integer :: &amp;
-!         ymd, &amp;          ! POP2 current date (YYYYMMDD)
-!         tod, &amp;          ! POP2 current time of day (sec)
-!         ymd_sync, &amp;     ! Sync clock current date (YYYYMMDD)
-!         tod_sync, &amp;     ! Sync clcok current time of day (sec)
-!         shrlogunit,  &amp;  ! old values
-!         shrloglev       ! old values
-!
-!    character(len=char_len_long) :: &amp;
-!         fname
-!
-!    type(seq_infodata_type), pointer :: &amp;
-!       infodata   ! Input init object
-!
-!    real (kind=RKIND) ::  &amp;
-!         precadj
-!
-!    logical :: &amp;
-!         lcoupled,   &amp;  ! temporary
-!         rstwr,      &amp;  ! true =&gt; write restart at end of day
-!         first_time = .true.
-!
-!    character (char_len)  :: message
-!
-!    integer(int_kind) :: info_debug
-!
-!    integer :: lbnum
-
-      integer :: itimestep
-      real (kind=RKIND) :: dt
-      type (block_type), pointer :: block_ptr
-
-      type (MPAS_Time_Type) :: currTime
-      character(len=StrKIND) :: timeStamp
-      integer :: ierr
-   
-      ! Eventually, dt should be domain specific
-      dt = config_dt
-
-      currTime = mpas_get_clock_time(clock, MPAS_NOW, ierr)
-      call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr)
-      write(0,*) 'Initial time ', trim(timeStamp)
-
-      call ocn_write_output_frame(output_obj, output_frame, domain)
-      block_ptr =&gt; domain % blocklist
-
-      do while(associated(block_ptr))
-        call ocn_time_average_init(block_ptr % state % time_levs(1) % state)
-        block_ptr =&gt; block_ptr % next
-      end do
-
-      ! During integration, time level 1 stores the model state at the beginning of the
-      !   time step, and time level 2 stores the state advanced dt in time by timestep(...)
-      itimestep = 0
-      do while (.not. mpas_is_clock_stop_time(clock))
-
-         itimestep = itimestep + 1
-         call mpas_advance_clock(clock)
-
-         currTime = mpas_get_clock_time(clock, MPAS_NOW, ierr)
-         call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr)
-         write(0,*) 'Doing timestep ', trim(timeStamp)
-   
-         block_ptr =&gt; domain % blocklist
-         do while(associated(block_ptr))
-           call ocn_build_forcing_arrays(currTime, block_ptr % mesh, ierr)
-           block_ptr =&gt; block_ptr % next
-         end do
-
-         call mpas_timer_start(&quot;time integration&quot;, .false., timeIntTimer)
-         call mpas_timestep(domain, itimestep, dt, timeStamp)
-         call mpas_timer_stop(&quot;time integration&quot;, timeIntTimer)
-   
-         ! Move time level 2 fields back into time level 1 for next time step
-         block_ptr =&gt; domain % blocklist
-         do while(associated(block_ptr))
-            call mpas_shift_time_levels_state(block_ptr % state)
-            block_ptr =&gt; block_ptr % next
-         end do
-      
-         if (mpas_is_alarm_ringing(clock, outputAlarmID, ierr=ierr)) then
-            call mpas_reset_clock_alarm(clock, outputAlarmID, ierr=ierr)
-            ! output_frame will always be &gt; 1 here unless it was reset after the maximum number of frames per outfile was reached
-            if(output_frame == 1) then
-               call mpas_output_state_finalize(output_obj, domain % dminfo)
-               call mpas_output_state_init(output_obj, domain, &quot;OUTPUT&quot;, trim(timeStamp))
-            end if
-
-            block_ptr =&gt; domain % blocklist
-            do while (associated(block_ptr))
-                call ocn_time_average_normalize(block_ptr % state % time_levs(1) % state)
-                block_ptr =&gt; block_ptr % next
-            end do
-
-            call ocn_write_output_frame(output_obj, output_frame, domain)
-
-            block_ptr =&gt; domain % blocklist
-            do while (associated(block_ptr))
-                call ocn_time_average_init(block_ptr % state % time_levs(1) % state)
-                block_ptr =&gt; block_ptr % next
-            end do
-         end if
-
-         if (mpas_is_alarm_ringing(clock, restartAlarmID, ierr=ierr)) then
-            call mpas_reset_clock_alarm(clock, restartAlarmID, ierr=ierr)
-
-            ! Write one restart time per file
-            call mpas_output_state_init(restart_obj, domain, &quot;RESTART&quot;, trim(timeStamp))
-            call mpas_output_state_for_domain(restart_obj, domain, 1)
-            call mpas_output_state_finalize(restart_obj, domain % dminfo)
-         end if
-
-      end do
-!
-!#if (defined _MEMTRACE)
-!    if(my_task == 0 ) then
-!       lbnum=1
-!       call memmon_dump_fort('memmon.out',SubName//':start::',lbnum) 
-!    endif
-!#endif
-!
-!!-----------------------------------------------------------------------
-!!
-!!  start up the main timer
-!!
-!!-----------------------------------------------------------------------
-!
-!   call mpas_timer_start('total time')
-!
-!
-!!-----------------------------------------------------------------------
-!!
-!! reset shr logging to my log file
-!!
-!!----------------------------------------------------------------------------
-!
-!    errorCode = POP_Success
-!
-!    call shr_file_getLogUnit (shrlogunit)
-!    call shr_file_getLogLevel(shrloglev)
-!    call shr_file_setLogUnit (stdout)
-!
-!    call seq_cdata_setptrs(cdata_o, infodata=infodata)
-!
-!!----------------------------------------------------------------------------
-!!
-!! restart flag (rstwr) will assume only an eod restart for now
-!!
-!!----------------------------------------------------------------------------
-!
-!    call seq_infodata_GetData( infodata, info_debug=info_debug)
-!    if (info_debug &gt;= 2) then
-!       ldiag_cpl = .true. 
-!    else
-!       ldiag_cpl = .false.
-!    endif
-!
-!    rstwr = seq_timemgr_RestartAlarmIsOn(EClock)
-!
-!!-----------------------------------------------------------------------
-!!
-!!  advance the model in time over coupling interval
-!!  write restart dumps and archiving
-!!
-!!-----------------------------------------------------------------------
-!
-!    ! Note that all ocean time flags are evaluated each timestep in time_manager
-!    ! ocn_import_mct is analogous to pop_unpack_fluxes_from_coupler in cpl6 
-!    ! ocn_export_mct is analogous to prepare_send_to_coupler in cpl6
-!    ! tlast_coupled is set to zero at the end of ocn_export_mct
-!
-!    itimestep = 0
-!    timestep: do
-!       ! obtain import state from driver
-!       if (check_time_flag(cpl_ts) .or. nsteps_run == 0) then
-!          call ocn_import_mct(x2o_o, errorCode)   
-!
-!          if (errorCode /= POP_Success) then
-!             call POP_ErrorPrint(errorCode)
-!             call exit_POP(sigAbort, 'ERROR in step')
-!          endif
-!
-!          !DWJ Need to write on mpas side
-!!         call pop_set_coupled_forcing 
-!       end if
-!
-!
-!    end do timestep
-!
-!    advance: do 
-!
-!       call step(errorCode)
-!
-!       if (errorCode /= POP_Success) then
-!          call POP_ErrorPrint(errorCode)
-!          call exit_POP(sigAbort, 'ERROR in step')
-!       endif
-!
-!       if (check_KE(100.0_r8)) then
-!          !*** exit if energy is blowing
-!          call output_driver
-!          call exit_POP(sigAbort,'ERROR: k.e. &gt; 100 ')
-!       endif
-!       call output_driver
-!       
-!       ! return export state to driver
-!       call pop_sum_buffer()  
-!       if (check_time_flag(cpl_ts)) then
-!          call ocn_export_mct(o2x_o, errorCode)
-!          if (errorCode /= POP_Success) then
-!             call POP_ErrorPrint(errorCode)
-!             call exit_POP(sigAbort, 'ERROR in ocn_export_mct')
-!          endif
-!
-!          exit advance
-!       end if
-!       
-!    enddo advance
-!
-!    if ( lsend_precip_fact ) then
-!       precadj = precip_fact * 1.0e6_r8  
-!       call seq_infodata_PutData( infodata, precip_fact=precadj )
-!    end if
-!    
-!!--------------------------------------------------------------------
-!!
-!! check that internal clock is in sync with master clock
-!!
-!!--------------------------------------------------------------------
-!
-!    ymd = iyear*10000 + imonth*100 + iday
-!    tod = ihour*seconds_in_hour + iminute*seconds_in_minute + isecond
-!    if ( .not. seq_timemgr_EClockDateInSync( EClock, ymd, tod ) )then
-!       call seq_timemgr_EClockGetData( EClock, curr_ymd=ymd_sync, &amp;
-!          curr_tod=tod_sync )
-!       write(stdout,*)' pop2 ymd=',ymd     ,'  pop2 tod= ',tod
-!       write(stdout,*)' sync ymd=',ymd_sync,'  sync tod= ',tod_sync
-!       write(stdout,*)' Internal pop2 clock not in sync with Sync Clock'
-!       call shr_sys_abort( SubName// &amp;
-!          &quot;:: Internal pop2 clock not in sync with Sync Clock&quot;)
-!    end if
-!   
-!!----------------------------------------------------------------------------
-!!
-!! Reset shr logging to original values
-!!
-!!----------------------------------------------------------------------------
-!
-!   call shr_file_setLogUnit (shrlogunit)
-!   call shr_file_setLogLevel(shrloglev)
-!
-!   call mpas_timer_stop('total time')
-!
-!#if (defined _MEMTRACE)
-!    if(my_task == 0) then
-!       lbnum=1
-!       call memmon_dump_fort('memmon.out',SubName//':end::',lbnum) 
-!       call memmon_reset_addr()
-!    endif
-!#endif
-!-----------------------------------------------------------------------
-!EOC
-
-  end subroutine ocn_run_mct!}}}
-
-!***********************************************************************
-!BOP
-!
-! !IROUTINE: ocn_final_mct
-!
-! !INTERFACE:
-  subroutine ocn_final_mct( EClock, cdata_o, x2o_o, o2x_o)!{{{
-!
-! !DESCRIPTION:
-! Finalize POP
-!
-! !USES:
-! !ARGUMENTS:
-    type(ESMF_Clock)            , intent(in)    :: EClock
-    type(seq_cdata)             , intent(inout) :: cdata_o
-    type(mct_aVect)             , intent(inout) :: x2o_o
-    type(mct_aVect)             , intent(inout) :: o2x_o
-!
-! !REVISION HISTORY:
-! Author: Fei Liu
-!EOP
-!BOC
-!-----------------------------------------------------------------------
-!
-!  local variables
-!
-!-----------------------------------------------------------------------
-
-   integer :: &amp;
-      errorCode         ! error code
-
-!-----------------------------------------------------------------------
-
-
-
-    call mpas_output_state_finalize(output_obj, domain % dminfo)
-    call mpas_timer_stop(&quot;total time&quot;)
-    call mpas_timer_write()
-        write(0,*) 'core finalize'
-    call mpas_core_finalize(domain)
-        write(0,*) 'framework finalize'
-    call mpas_framework_finalize(dminfo, domain, io_system)
-        write(0,*) 'done in final mct'
-
-  end subroutine ocn_final_mct!}}}
-
-!***********************************************************************
-!BOP
-!IROUTINE: ocn_SetGSMap_mct
-! !INTERFACE:
-
- subroutine ocn_SetGSMap_mct( mpicom_ocn, OCNID, gsMap_ocn )!{{{
-
-   use mpas_dmpar
-
-! !DESCRIPTION:
-!  This routine mct global seg maps for the pop decomposition
-!
-! !REVISION HISTORY:
-!  same as module
-
-! !INPUT/OUTPUT PARAMETERS:
-
-    implicit none
-    integer        , intent(in)    :: mpicom_ocn
-    integer        , intent(in)    :: OCNID
-    type(mct_gsMap), intent(inout) :: gsMap_ocn
-
-!EOP
-!BOC
-!-----------------------------------------------------------------------
-!
-!  local variables
-!
-!-----------------------------------------------------------------------
-
-    integer,allocatable :: &amp;
-      gindex(:)
-
-    integer ::   &amp;
-      i,j, k, n, iblock, &amp;
-      lsize, gsize,   &amp;
-      ier
-
-    type (block_type), pointer :: block_ptr 
-
-!-----------------------------------------------------------------------
-!  Build the POP grid numbering for MCT
-!  NOTE:  Numbering scheme is: West to East and South to North starting
-!  at the south pole.  Should be the same as what's used in SCRIP
-!-----------------------------------------------------------------------
-
-    n = 0
-    block_ptr =&gt; domain % blocklist
-    do while(associated(block_ptr))
-      n = n + block_ptr % mesh % nCellsSolve
-      block_ptr =&gt; block_ptr % next
-    end do
-
-    lsize = n
-    call mpas_dmpar_sum_int(dminfo, lsize, gsize)
-    allocate(gindex(lsize),stat=ier)
-
-    n = 0
-    block_ptr =&gt; domain % blocklist
-    do while(associated(block_ptr))
-      do i = 1, block_ptr % mesh % nCellsSolve
-        n = n + 1
-        gindex(n) = block_ptr % mesh % indexToCellID % array(i)
-      end do
-      block_ptr =&gt; block_ptr % next
-    end do
-
-    call mct_gsMap_init( gsMap_ocn, gindex, mpicom_ocn, OCNID, lsize, gsize )
-
-    deallocate(gindex)
-
-!-----------------------------------------------------------------------
-!EOC
-
-  end subroutine ocn_SetGSMap_mct!}}}
-
-!***********************************************************************
-!BOP
-! !IROUTINE: ocn_domain_mct
-! !INTERFACE:
-
- subroutine ocn_domain_mct( lsize, gsMap_o, dom_o )!{{{
-
-! !DESCRIPTION:
-!  This routine mct global seg maps for the pop decomposition
-!
-! !REVISION HISTORY:
-!  same as module
-!
-! !INPUT/OUTPUT PARAMETERS:
-
-    implicit none
-    integer        , intent(in)    :: lsize
-    type(mct_gsMap), intent(in)    :: gsMap_o
-    type(mct_ggrid), intent(inout) :: dom_o     
-
-!EOP
-!BOC
-!-----------------------------------------------------------------------
-!
-!  local variables
-!
-!-----------------------------------------------------------------------
-
-    integer, pointer :: idata(:)
-
-    real(kind=RKIND), pointer :: data(:)
-    real(kind=RKIND) :: r2d
-
-    integer :: i,j, k, n, ier
-
-    type (block_type), pointer :: block_ptr
-
-    r2d = 180.0/pii
-
-!-------------------------------------------------------------------
-!
-!  initialize mct domain type, lat/lon in degrees,
-!  area in radians^2, mask is 1 (ocean), 0 (non-ocean)
-!
-!-------------------------------------------------------------------
-
-    call mct_gGrid_init( GGrid=dom_o, CoordChars=trim(seq_flds_dom_coord), &amp;
-       OtherChars=trim(seq_flds_dom_other), lsize=lsize )
-    call mct_aVect_zero(dom_o%data)
-    allocate(data(lsize))
-
-!-------------------------------------------------------------------
-!
-! Determine global gridpoint number attribute, GlobGridNum, which is set automatically by MCT
-!
-!-------------------------------------------------------------------
-
-    call mct_gsMap_orderedPoints(gsMap_o, my_task, idata)
-    call mct_gGrid_importIAttr(dom_o,'GlobGridNum',idata,lsize)
-
-!-------------------------------------------------------------------
-!
-! Determine domain (numbering scheme is: West to East and South to North to South pole)
-! Initialize attribute vector with special value
-!
-!-------------------------------------------------------------------
-
-    data(:) = -9999.0_R8 
-    call mct_gGrid_importRAttr(dom_o,&quot;lat&quot;  ,data,lsize) 
-    call mct_gGrid_importRAttr(dom_o,&quot;lon&quot;  ,data,lsize) 
-    call mct_gGrid_importRAttr(dom_o,&quot;area&quot; ,data,lsize) 
-    call mct_gGrid_importRAttr(dom_o,&quot;aream&quot;,data,lsize) 
-    data(:) = 0.0_R8     
-    call mct_gGrid_importRAttr(dom_o,&quot;mask&quot;,data,lsize) 
-    call mct_gGrid_importRAttr(dom_o,&quot;frac&quot;,data,lsize) 
-
-!-------------------------------------------------------------------
-!
-! Fill in correct values for domain components
-!
-!-------------------------------------------------------------------
-
-    n = 0
-    block_ptr =&gt; domain % blocklist
-    do while(associated(block_ptr))
-      do i = 1, block_ptr % mesh % nCellsSolve
-        n = n + 1
-        data(n) = block_ptr % mesh % lonCell % array(i) * r2d
-      end do
-      
-      block_ptr =&gt; block_ptr % next
-    end do
-    call mct_gGrid_importRattr(dom_o,&quot;lon&quot;,data,lsize) 
-
-    n = 0
-    block_ptr =&gt; domain % blocklist
-    do while(associated(block_ptr))
-      do i = 1, block_ptr % mesh % nCellsSolve
-        n = n + 1
-        data(n) = block_ptr % mesh % latCell % array(i) * r2d
-      end do
-      block_ptr =&gt; block_ptr % next
-    end do
-    call mct_gGrid_importRattr(dom_o,&quot;lat&quot;,data,lsize) 
-
-    n = 0
-    block_ptr =&gt; domain % blocklist
-    do while(associated(block_ptr))
-      do i = 1, block_ptr % mesh % nCellsSolve
-        n = n + 1
-        data(n) = block_ptr % mesh % areaCell % array(i) / (block_ptr % mesh % sphere_radius * block_ptr % mesh % sphere_radius)
-      end do
-      block_ptr =&gt; block_ptr % next
-    end do
-    call mct_gGrid_importRattr(dom_o,&quot;area&quot;,data,lsize) 
-
-    data(:) = 1.0_RKIND ! No land cells in MPAS-O, only Ocean cells
-    call mct_gGrid_importRattr(dom_o,&quot;mask&quot;,data,lsize) 
-    call mct_gGrid_importRattr(dom_o,&quot;frac&quot;,data,lsize) 
-
-    deallocate(data)
-    deallocate(idata)
-
-!-----------------------------------------------------------------------
-!EOC
-
-  end subroutine ocn_domain_mct!}}}
-
-
-!***********************************************************************
-!BOP
-! !IROUTINE: ocn_import_mct
-! !INTERFACE:
-
- subroutine ocn_import_mct(x2o_o, errorCode)!{{{
-
-! !DESCRIPTION:
-!-----------------------------------------------------------------------
-!  This routine receives message from cpl7 driver
-!
-!    The following fields are always received from the coupler:
-! 
-!    o  taux   -- zonal wind stress (taux)                 (W/m2   )
-!    o  tauy   -- meridonal wind stress (tauy)             (W/m2   )
-!    o  snow   -- water flux due to snow                   (kg/m2/s)
-!    o  rain   -- water flux due to rain                   (kg/m2/s)
-!    o  evap   -- evaporation flux                         (kg/m2/s)
-!    o  meltw  -- snow melt flux                           (kg/m2/s)
-!    o  salt   -- salt                                     (kg(salt)/m2/s)
-!    o  swnet  -- net short-wave heat flux                 (W/m2   )
-!    o  sen    -- sensible heat flux                       (W/m2   )
-!    o  lwup   -- longwave radiation (up)                  (W/m2   )
-!    o  lwdn   -- longwave radiation (down)                (W/m2   )
-!    o  melth  -- heat flux from snow&amp;ice melt             (W/m2   )
-!    o  ifrac  -- ice fraction
-!    o  roff   -- river runoff flux                        (kg/m2/s)
-!    o  ioff   -- ice runoff flux                          (kg/m2/s)
-! 
-!    The following fields are sometimes received from the coupler,
-!      depending on model options:
-! 
-!    o  pslv   -- sea-level pressure                       (Pa)
-!    o  duu10n -- 10m wind speed squared                   (m^2/s^2)
-!    o  co2prog-- bottom atm level prognostic co2
-!    o  co2diag-- bottom atm level diagnostic co2
-! 
-!-----------------------------------------------------------------------
-!
-! !REVISION HISTORY:
-!  same as module
-
-! !INPUT/OUTPUT PARAMETERS:
-
-    type(mct_aVect)   , intent(inout) :: x2o_o
-
-! !OUTPUT PARAMETERS:
-
-   integer, intent(out) :: &amp;
-      errorCode              ! returned error code
-
-!EOP
-!BOC
-!-----------------------------------------------------------------------
-!
-!  local variables
-!
-!-----------------------------------------------------------------------
-
-!   character (len=StrKIND) ::   &amp;
-!      label,                 &amp;
-!      message
-! 
-!   integer ::  &amp;
-!      i,j,k,n,iblock
-!
-!   real (kind=RKIND), dimension(nx_block,ny_block) ::  &amp;
-!      WORKB
-!
-!   real (kind=RKIND), dimension(nx_block,ny_block,max_blocks_clinic) ::   &amp;
-!      WORK1, WORK2        ! local work space
-!
-!   real (r8) ::  &amp;
-!      m2percm2,  &amp;
-!      gsum
-!
-!   type (block) :: this_block ! local block info
-!
-!!-----------------------------------------------------------------------
-!!
-!!  zero out padded cells 
-!!
-!!-----------------------------------------------------------------------
-!
-!   errorCode = POP_Success
-!
-!   WORK1 = c0
-!   WORK2 = c0
-!
-!!-----------------------------------------------------------------------
-!!
-!!  unpack and distribute wind stress, then convert to correct units
-!!  and rotate components to local coordinates
-!!
-!!-----------------------------------------------------------------------
-!
-!   n = 0
-!   do iblock = 1, nblocks_clinic
-!      this_block = get_block(blocks_clinic(iblock),iblock)
-!
-!      do j=this_block%jb,this_block%je
-!      do i=this_block%ib,this_block%ie
-!         n = n + 1
-!         WORK1(i,j,iblock) = x2o_o%rAttr(index_x2o_Foxx_taux,n)
-!         WORK2(i,j,iblock) = x2o_o%rAttr(index_x2o_Foxx_tauy,n)
-!      enddo
-!      enddo
-!   enddo ! iblock
-!
-!   !***
-!   !*** do NOT perform halo updates now, because vector updates must
-!   !***   be done after the rotation is completed.
-!   !***
-!
-!!-----------------------------------------------------------------------
-!!
-!!  rotate true zonal/meridional wind stress into local coordinates,
-!!  convert to dyne/cm**2, and shift SMFT to U grid
-!!
-!!  halo updates are performed in subroutine rotate_wind_stress, 
-!!  following the rotation
-!!
-!!-----------------------------------------------------------------------
-!
-!      call rotate_wind_stress(WORK1, WORK2)
-!
-!   n = 0
-!   do iblock = 1, nblocks_clinic
-!      this_block = get_block(blocks_clinic(iblock),iblock)
-!
-!!-----------------------------------------------------------------------
-!!
-!!  unpack and distribute fresh water flux and salt flux
-!!
-!!  NOTE: if there are code changes associated with changing the names or
-!!        the number of fluxes received from the coupler, then subroutine
-!!        update_ghost_cells_coupler_fluxes will need to be modified also
-!!
-!!-----------------------------------------------------------------------
-!
-!
-!      do j=this_block%jb,this_block%je
-!      do i=this_block%ib,this_block%ie
-!         n = n + 1
-!         SNOW_F(i,j,iblock) = x2o_o%rAttr(index_x2o_Faxa_snow,n)
-!         WORKB (i,j       ) = x2o_o%rAttr(index_x2o_Faxa_rain,n)
-!         EVAP_F(i,j,iblock) = x2o_o%rAttr(index_x2o_Foxx_evap,n)
-!         MELT_F(i,j,iblock) = x2o_o%rAttr(index_x2o_Fioi_meltw,n)
-!         ROFF_F(i,j,iblock) = x2o_o%rAttr(index_x2o_Forr_roff,n)
-!         IOFF_F(i,j,iblock) = x2o_o%rAttr(index_x2o_Forr_ioff,n)
-!         SALT_F(i,j,iblock) = x2o_o%rAttr(index_x2o_Fioi_salt,n)
-!
-!         PREC_F(i,j,iblock) = WORKB(i,j) + SNOW_F(i,j,iblock)    ! rain + snow
-!
-!         WORKB(i,j        ) = x2o_o%rAttr(index_x2o_Foxx_swnet,n)
-!         SHF_QSW(i,j,iblock) = WORKB(i,j)*  &amp;
-!            RCALCT(i,j,iblock)*hflux_factor  !  convert from W/m**2
-!         SENH_F(i,j,iblock)  = x2o_o%rAttr(index_x2o_Foxx_sen,n)
-!         LWUP_F(i,j,iblock)  = x2o_o%rAttr(index_x2o_Foxx_lwup,n)
-!         LWDN_F(i,j,iblock)  = x2o_o%rAttr(index_x2o_Faxa_lwdn,n)
-!         MELTH_F(i,j,iblock) = x2o_o%rAttr(index_x2o_Fioi_melth,n)
-!
-!         WORKB(i,j       ) = x2o_o%rAttr(index_x2o_Si_ifrac,n)
-!         IFRAC(i,j,iblock) = WORKB(i,j) * RCALCT(i,j,iblock)
-!
-!         !***  converting from Pa to dynes/cm**2
-!         WORKB(i,j       ) = x2o_o%rAttr(index_x2o_Sa_pslv,n)
-!         ATM_PRESS(i,j,iblock) = c10 * WORKB(i,j) * RCALCT(i,j,iblock)
-!
-!         !***  converting from m**2/s**2 to cm**2/s**2
-!         WORKB(i,j       ) = x2o_o%rAttr(index_x2o_So_duu10n,n)
-!         U10_SQR(i,j,iblock) = cmperm * cmperm * WORKB(i,j) * RCALCT(i,j,iblock)
-!
-!      enddo
-!      enddo
-!
-!   enddo
-!
-!!-----------------------------------------------------------------------
-!!
-!!  incoming data quality control
-!!
-!!-----------------------------------------------------------------------
-!#ifdef CCSMCOUPLED
-!      if ( any(IOFF_F &lt; c0) ) then
-!        call shr_sys_abort ('Error: incoming IOFF_F is negative')
-!      endif
-!#endif
-!
-!
-!!-----------------------------------------------------------------------
-!!
-!!  update ghost cells for fluxes received from the coupler
-!!
-!!-----------------------------------------------------------------------
-!
-!   call update_ghost_cells_coupler_fluxes(errorCode)
-!
-!   if (errorCode /= POP_Success) then
-!      call POP_ErrorSet(errorCode, &amp;
-!         'ocn_import_mct: error in update_ghost_cells_coupler_fluxes')
-!      return
-!   endif
-!
-!!-----------------------------------------------------------------------
-!!
-!!  unpack atmospheric CO2
-!!
-!!-----------------------------------------------------------------------
-!
-!   if (index_x2o_Sa_co2prog &gt; 0) then
-!      n = 0
-!      do iblock = 1, nblocks_clinic
-!         this_block = get_block(blocks_clinic(iblock),iblock)
-!
-!         do j=this_block%jb,this_block%je
-!         do i=this_block%ib,this_block%ie
-!            n = n + 1
-!            WORK1(i,j,iblock) = x2o_o%rAttr(index_x2o_Sa_co2prog,n)
-!         enddo
-!         enddo
-!      enddo
-!
-!      call POP_HaloUpdate(WORK1,POP_haloClinic,          &amp;
-!                       POP_gridHorzLocCenter,          &amp;
-!                       POP_fieldKindScalar, errorCode, &amp;
-!                       fillValue = 0.0_POP_r8)
-!
-!      if (errorCode /= POP_Success) then
-!         call POP_ErrorSet(errorCode, &amp;
-!            'ocn_import_mct: error updating PROG CO2 halo')
-!         return
-!      endif
-!
-!      call named_field_set(ATM_CO2_PROG_nf_ind, WORK1)
-!   endif
-!
-!   if (index_x2o_Sa_co2diag &gt; 0) then
-!      n = 0
-!      do iblock = 1, nblocks_clinic
-!         this_block = get_block(blocks_clinic(iblock),iblock)
-!
-!         do j=this_block%jb,this_block%je
-!         do i=this_block%ib,this_block%ie
-!            n = n + 1
-!            WORK1(i,j,iblock) = x2o_o%rAttr(index_x2o_Sa_co2diag,n)
-!         enddo
-!         enddo
-!      enddo
-!
-!      call POP_HaloUpdate(WORK1,POP_haloClinic,          &amp;
-!                       POP_gridHorzLocCenter,          &amp;
-!                       POP_fieldKindScalar, errorCode, &amp;
-!                       fillValue = 0.0_POP_r8)
-!
-!      if (errorCode /= POP_Success) then
-!         call POP_ErrorSet(errorCode, &amp;
-!            'ocn_import_mct: error updating DIAG CO2 halo')
-!         return
-!      endif
-!
-!      call named_field_set(ATM_CO2_DIAG_nf_ind, WORK1)
-!   endif
-! 
-!!-----------------------------------------------------------------------
-!!
-!!  receive orbital parameters
-!!
-!!-----------------------------------------------------------------------
-!
-!   call seq_infodata_GetData(infodata, &amp;
-!      orb_eccen=orb_eccen, orb_mvelpp=orb_mvelpp, orb_lambm0=orb_lambm0, orb_obliqr=orb_obliqr)
-!
-!
-!!-----------------------------------------------------------------------
-!!
-!!  diagnostics
-!!
-!!-----------------------------------------------------------------------
-!
-!   if (ldiag_cpl) then
-!
-!     write(message,'(6a,1x,5a)')  &amp;
-!         ' Global averages of fluxes received from cpl at ',  &amp;
-!           cyear,'/',cmonth ,'/',cday,  chour,':',cminute,':',csecond
-!     call document ('pop_recv_from_coupler', trim(message))
-! 
-!     m2percm2  = mpercm*mpercm
-!     do k = 1,nrecv
-!
-!         n = 0
-!         do iblock = 1, nblocks_clinic
-!            this_block = get_block(blocks_clinic(iblock),iblock)
-!
-!            do j=this_block%jb,this_block%je
-!            do i=this_block%ib,this_block%ie
-!               n = n + 1
-!               WORK1(i,j,iblock) = x2o_o%rAttr(k,n)  ! mult. by TAREA in global_sum_prod
-!            enddo
-!            enddo
-!         enddo
-!
-!         gsum = global_sum_prod(WORK1 , TAREA, distrb_clinic, &amp;
-!                                 field_loc_center, RCALCT)*m2percm2
-!         if (my_task == master_task) then
-!            call seq_flds_getField(label,k,seq_flds_x2o_fields)
-!            write(stdout,1100)'ocn','recv', label ,gsum
-!            call shr_sys_flush(stdout)
-!         endif
-!      enddo
-!   endif
-!
-!
-!1100  format ('comm_diag ', a3, 1x, a4, 1x, a8, 1x, es26.19:, 1x, a6)
-
-!-----------------------------------------------------------------------
-!EOC
-
- end subroutine ocn_import_mct!}}}
-!***********************************************************************
-!BOP
-! !IROUTINE: ocn_export_mct
-! !INTERFACE:
-
- subroutine ocn_export_mct(o2x_o, errorCode)   !{{{
-
-! !DESCRIPTION:
-!  This routine calls the routines necessary to send pop fields to
-!  the CCSM cpl7 driver
-!
-! !REVISION HISTORY:
-!  same as module
-!
-! !INPUT/OUTPUT PARAMETERS:
-
-   type(mct_aVect)   , intent(inout) :: o2x_o
-
-! !OUTPUT PARAMETERS:
-
-   integer, intent(out) :: &amp;
-      errorCode              ! returned error code
-
-!EOP
-!BOC
-!!-----------------------------------------------------------------------
-!!
-!!  local variables
-!!
-!!-----------------------------------------------------------------------
-!
-!   integer (int_kind) :: n, iblock
-!           
-!   character (char_len)    :: label
-! 
-!   integer (int_kind) ::  &amp;
-!      i,j,k
-!
-!   real (r8), dimension(nx_block,ny_block) ::   &amp;
-!      WORK1, WORK2,      &amp;! local work space
-!      WORK3, WORK4
-!
-!   real (r8), dimension(nx_block,ny_block,max_blocks_clinic) ::   &amp;
-!        WORKA               ! local work space with full block dimension
-!
-!   real (r8) ::   &amp;
-!      m2percm2,   &amp;
-!      gsum
-!
-!   type (block) :: this_block ! local block info
-!
-!!-----------------------------------------------------------------------
-!
-!!-----------------------------------------------------------------------
-!!
-!!  initialize control buffer
-!!
-!!-----------------------------------------------------------------------
-!
-!   errorCode = POP_Success
-!
-!!-----------------------------------------------------------------------
-!!
-!!     interpolate onto T-grid points and rotate on T grid
-!!
-!!-----------------------------------------------------------------------
-!
-!   n = 0
-!   do iblock = 1, nblocks_clinic
-!     this_block = get_block(blocks_clinic(iblock),iblock)
-!
-!     call ugrid_to_tgrid(WORK3,SBUFF_SUM(:,:,iblock,index_o2x_So_u),iblock)
-!     call ugrid_to_tgrid(WORK4,SBUFF_SUM(:,:,iblock,index_o2x_So_v),iblock)
-!
-!     WORK1 = (WORK3*cos(ANGLET(:,:,iblock))+WORK4*sin(-ANGLET(:,:,iblock)))  &amp;
-!            * mpercm/tlast_coupled
-!     WORK2 = (WORK4*cos(ANGLET(:,:,iblock))-WORK3*sin(-ANGLET(:,:,iblock)))  &amp;
-!            * mpercm/tlast_coupled
-!
-!     do j=this_block%jb,this_block%je
-!     do i=this_block%ib,this_block%ie
-!        n = n + 1
-!        o2x_o%rAttr(index_o2x_So_u,n) = WORK1(i,j)
-!        o2x_o%rAttr(index_o2x_So_v,n) = WORK2(i,j)
-!     enddo
-!     enddo
-!  enddo
-!
-!!-----------------------------------------------------------------------
-!!
-!!     convert and pack surface temperature
-!!
-!!-----------------------------------------------------------------------
-!
-!   n = 0
-!   do iblock = 1, nblocks_clinic
-!      this_block = get_block(blocks_clinic(iblock),iblock)
-!      do j=this_block%jb,this_block%je
-!      do i=this_block%ib,this_block%ie
-!         n = n + 1
-!         o2x_o%rAttr(index_o2x_So_t,n) =   &amp;
-!             SBUFF_SUM(i,j,iblock,index_o2x_So_t)/tlast_coupled + T0_Kelvin
-!      enddo
-!      enddo
-!   enddo
-!
-!!-----------------------------------------------------------------------
-!!
-!!     convert and pack salinity
-!!
-!!-----------------------------------------------------------------------
-!
-!   n = 0
-!   do iblock = 1, nblocks_clinic
-!      this_block = get_block(blocks_clinic(iblock),iblock)
-!      do j=this_block%jb,this_block%je
-!      do i=this_block%ib,this_block%ie
-!         n = n + 1
-!         o2x_o%rAttr(index_o2x_So_s,n) =   &amp;
-!             SBUFF_SUM(i,j,iblock,index_o2x_So_s)*salt_to_ppt/tlast_coupled
-!      enddo
-!      enddo
-!   enddo
-!
-!!-----------------------------------------------------------------------
-!!
-!!     interpolate onto T-grid points, then rotate on T grid
-!!
-!!-----------------------------------------------------------------------
-!
-!   n = 0
-!   do iblock = 1, nblocks_clinic
-!      this_block = get_block(blocks_clinic(iblock),iblock)
-!      call ugrid_to_tgrid(WORK3,SBUFF_SUM(:,:,iblock,index_o2x_So_dhdx),iblock)
-!      call ugrid_to_tgrid(WORK4,SBUFF_SUM(:,:,iblock,index_o2x_So_dhdy),iblock)
-! 
-!      WORK1 = (WORK3*cos(ANGLET(:,:,iblock)) + WORK4*sin(-ANGLET(:,:,iblock)))  &amp;
-!              /grav/tlast_coupled
-!      WORK2 = (WORK4*cos(ANGLET(:,:,iblock)) - WORK3*sin(-ANGLET(:,:,iblock)))  &amp;
-!              /grav/tlast_coupled
-!
-!      do j=this_block%jb,this_block%je
-!      do i=this_block%ib,this_block%ie
-!         n = n + 1
-!         o2x_o%rAttr(index_o2x_So_dhdx,n) = WORK1(i,j)
-!         o2x_o%rAttr(index_o2x_So_dhdy,n) = WORK2(i,j)
-!      enddo
-!      enddo
-!   enddo
-!
-!!-----------------------------------------------------------------------
-!!
-!!     pack heat flux due to freezing/melting (W/m^2)
-!!     QFLUX computation and units conversion occurs in ice.F
-!!
-!!-----------------------------------------------------------------------
-!
-!   n = 0
-!   do iblock = 1, nblocks_clinic
-!      this_block = get_block(blocks_clinic(iblock),iblock)
-!      do j=this_block%jb,this_block%je
-!      do i=this_block%ib,this_block%ie
-!         n = n + 1
-!         o2x_o%rAttr(index_o2x_Fioo_q,n) = QFLUX(i,j,iblock)
-!      enddo
-!      enddo
-!   enddo
-!
-!   tlast_ice = c0
-!   AQICE     = c0
-!   QICE      = c0
-!
-!!-----------------------------------------------------------------------
-!!
-!!     pack co2 flux, if requested (kg CO2/m^2/s)
-!!     units conversion occurs where co2 flux is computed
-!!
-!!-----------------------------------------------------------------------
-!
-!   if (index_o2x_Faoo_fco2_ocn &gt; 0) then
-!      n = 0
-!      do iblock = 1, nblocks_clinic
-!         this_block = get_block(blocks_clinic(iblock),iblock)
-!         do j=this_block%jb,this_block%je
-!         do i=this_block%ib,this_block%ie
-!            n = n + 1
-!            o2x_o%rAttr(index_o2x_Faoo_fco2_ocn,n) = &amp;
-!               SBUFF_SUM(i,j,iblock,index_o2x_Faoo_fco2_ocn)/tlast_coupled
-!         enddo
-!         enddo
-!      enddo
-!   endif
-!
-!!-----------------------------------------------------------------------
-!!
-!!     diagnostics
-!!
-!!-----------------------------------------------------------------------
-!
-!   if (ldiag_cpl) then
-!      call ccsm_char_date_and_time
-!!DEBUG      write(message,'(6a,1x,5a)')' Global averages of fluxes sent to cpl at ', &amp;
-!!DEBUG           cyear,'/',cmonth, '/',cday,  chour,':',cminute,':',csecond
-!!DEBUG      call document ('pop_send_to_coupler', message)
-!      write(stdout,*)'pop_send_to_coupler'
-!
-!      m2percm2  = mpercm*mpercm
-!      do k = 1,nsend
-!        n = 0
-!        do iblock = 1, nblocks_clinic
-!           this_block = get_block(blocks_clinic(iblock),iblock)
-!           do j=this_block%jb,this_block%je
-!           do i=this_block%ib,this_block%ie
-!              n = n + 1
-!              WORKA(i,j,iblock) = o2x_o%rAttr(k,n)
-!           enddo
-!           enddo
-!        enddo
-!
-!        call POP_HaloUpdate(WORKA,POP_haloClinic,          &amp;
-!                       POP_gridHorzLocCenter,          &amp;
-!                       POP_fieldKindScalar, errorCode, &amp;
-!                       fillValue = 0.0_POP_r8)
-!       
-!         if (errorCode /= POP_Success) then
-!            call POP_ErrorSet(errorCode, &amp;
-!               'ocn_export_mct: error updating halo for state')
-!            return
-!         endif
-!
-!        gsum = global_sum_prod(WORKA , TAREA, distrb_clinic, &amp;
-!                                   field_loc_center, RCALCT)*m2percm2
-!        if (my_task == master_task) then
-!           call seq_flds_getField(label,k,seq_flds_o2x_fields)
-!           write(stdout,1100)'ocn','send', label ,gsum
-!        endif
-!      enddo ! k
-!      if (my_task == master_task) call shr_sys_flush(stdout)
-!   endif
-!
-!1100 format ('comm_diag ', a3, 1x, a4, 1x, a8, 1x, es26.19:, 1x, a6)
-!    
-!    tlast_coupled = c0
-
-!-----------------------------------------------------------------------
-!EOC
-
- end subroutine ocn_export_mct!}}}
-
-!***********************************************************************
-
-!BOP
-! !IROUTINE: pop_sum_buffer
-! !INTERFACE:
-
- subroutine pop_sum_buffer!{{{
-
-! !DESCRIPTION:
-!  This routine accumulates sums for averaging fields to
-!  be sent to the coupler
-!
-! !REVISION HISTORY:
-!  same as module
-! 
-!EOP
-!BOC
-
-!#ifdef CCSMCOUPLED
-!!-----------------------------------------------------------------------
-!!
-!!  local variables
-!!
-!!-----------------------------------------------------------------------
-!
-!   real (r8), dimension(nx_block,ny_block,max_blocks_clinic) ::  &amp;
-!      WORK                ! local work arrays
-!
-!   real (r8) ::   &amp;
-!      delt,             &amp; ! time interval since last step
-!      delt_last           ! time interval for previous step
-!
-!   integer (int_kind) :: &amp;
-!      iblock,           &amp; ! block index
-!      sflux_co2_nf_ind = 0! named field index of fco2
-!
-!   logical (log_kind) :: &amp;
-!      first = .true.      ! only true for first call
-!
-!   save first
-!
-!!-----------------------------------------------------------------------
-!!
-!!  zero buffer if this is the first time after a coupling interval
-!!
-!!-----------------------------------------------------------------------
-!
-!   if (tlast_coupled == c0) SBUFF_SUM = c0
-!   WORK = c0
-!
-!!-----------------------------------------------------------------------
-!!
-!!  update time since last coupling
-!!
-!!-----------------------------------------------------------------------
-!
-!   if (avg_ts .or. back_to_back) then
-!      delt = p5*dtt
-!   else
-!      delt =    dtt
-!   endif
-!   tlast_coupled = tlast_coupled + delt
-!
-!!-----------------------------------------------------------------------
-!!
-!!  allow for fco2 field to not be registered on first call
-!!     because init_forcing is called before init_passive_tracers
-!!  use weight from previous timestep because flux used here is that
-!!     computed during the previous timestep
-!!
-!!-----------------------------------------------------------------------
-!
-!   if (index_o2x_Faoo_fco2_ocn &gt; 0) then
-!      if (sflux_co2_nf_ind == 0) then
-!         call named_field_get_index('SFLUX_CO2', sflux_co2_nf_ind, &amp;
-!                                    exit_on_err=.not. first)
-!      endif
-!
-!      if (avg_ts .or. back_to_back) then
-!         delt_last = p5*dtt
-!      else
-!         delt_last =    dtt
-!      endif
-!   endif
-!
-!!-----------------------------------------------------------------------
-!!
-!!  accumulate sums of U,V,T,S and GRADP
-!!  accumulate sum of co2 flux, if requested
-!!     implicitly use zero flux if fco2 field not registered yet
-!!  ice formation flux is handled separately in ice routine
-!!
-!!-----------------------------------------------------------------------
-!
-!   !$OMP PARALLEL DO PRIVATE(iblock)
-!   do iblock = 1, nblocks_clinic
-!   SBUFF_SUM(:,:,iblock,index_o2x_So_u) =   &amp;
-!      SBUFF_SUM(:,:,iblock,index_o2x_So_u) + delt*  &amp;
-!                                   UVEL(:,:,1,curtime,iblock)
-!
-!   SBUFF_SUM(:,:,iblock,index_o2x_So_v) =   &amp;
-!      SBUFF_SUM(:,:,iblock,index_o2x_So_v) + delt*  &amp;
-!                                   VVEL(:,:,1,curtime,iblock)
-!
-!   SBUFF_SUM(:,:,iblock,index_o2x_So_t ) =   &amp;
-!      SBUFF_SUM(:,:,iblock,index_o2x_So_t ) + delt*  &amp;
-!                                   TRACER(:,:,1,1,curtime,iblock)
-!
-!   SBUFF_SUM(:,:,iblock,index_o2x_So_s ) =   &amp;
-!      SBUFF_SUM(:,:,iblock,index_o2x_So_s ) + delt*  &amp;
-!                                   TRACER(:,:,1,2,curtime,iblock)
-!
-!   SBUFF_SUM(:,:,iblock,index_o2x_So_dhdx) =   &amp;
-!      SBUFF_SUM(:,:,iblock,index_o2x_So_dhdx) + delt*  &amp;
-!                                   GRADPX(:,:,curtime,iblock)
-!
-!   SBUFF_SUM(:,:,iblock,index_o2x_So_dhdy) =   &amp;
-!      SBUFF_SUM(:,:,iblock,index_o2x_So_dhdy) + delt*  &amp;
-!                                   GRADPY(:,:,curtime,iblock)
-!
-!   if (index_o2x_Faoo_fco2_ocn &gt; 0 .and. sflux_co2_nf_ind &gt; 0) then
-!      call named_field_get(sflux_co2_nf_ind, iblock, WORK(:,:,iblock))
-!      SBUFF_SUM(:,:,iblock,index_o2x_Faoo_fco2_ocn) = &amp;
-!         SBUFF_SUM(:,:,iblock,index_o2x_Faoo_fco2_ocn) + delt_last*WORK(:,:,iblock)
-!   endif
-!
-!   enddo
-!   !$OMP END PARALLEL DO
-!
-!   first = .false.
-!
-!#endif
-!
-!-----------------------------------------------------------------------
-!EOC
-
- end subroutine pop_sum_buffer!}}}

-!***********************************************************************
-
-end module ocn_comp_mct
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Copied: branches/atmos_physics/src/ocean_cesm_driver/ocn_comp_mct.F (from rev 2666, trunk/mpas/src/ocean_cesm_driver/ocn_comp_mct.F)
===================================================================
--- branches/atmos_physics/src/ocean_cesm_driver/ocn_comp_mct.F                                (rev 0)
+++ branches/atmos_physics/src/ocean_cesm_driver/ocn_comp_mct.F        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,1633 @@
+module ocn_comp_mct
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!BOP
+! !MODULE: ocn_comp_mct
+! !INTERFACE:
+
+! !DESCRIPTION:
+!  This is the main driver for the Model for Predication Across Scales Ocean Model (MPAS-O).
+!
+! !REVISION HISTORY:
+!  SVN:$Id:
+!
+! !USES:
+   use mct_mod
+   use esmf
+   use seq_flds_mod
+   use seq_cdata_mod
+   use seq_infodata_mod
+   use seq_timemgr_mod
+   use seq_comm_mct,      only : seq_comm_suffix, seq_comm_inst, seq_comm_name
+   use shr_file_mod 
+   use shr_cal_mod,       only : shr_cal_date2ymd
+   use shr_sys_mod
+   use shr_pio_mod
+   use perf_mod
+   use ocn_communicator,  only: mpi_communicator_ocn
+
+   use mpaso_cpl_indices
+   use mpaso_mct_vars
+
+   use mpas_framework
+   use mpas_core
+   use mpas_kind_types
+
+!
+! !PUBLIC MEMBER FUNCTIONS:
+  implicit none
+  public :: ocn_init_mct
+  public :: ocn_run_mct
+  public :: ocn_final_mct
+  SAVE
+  private                              ! By default make data private
+
+!
+! ! PUBLIC DATA:
+!
+! !REVISION HISTORY:
+! Author: Mariana Vertenstein
+!
+!EOP
+! !PRIVATE MODULE FUNCTIONS:
+  private :: ocn_export_mct
+  private :: ocn_import_mct
+  private :: ocn_SetGSMap_mct
+  private :: ocn_domain_mct
+!
+! !PRIVATE MODULE VARIABLES
+
+  logical :: ldiag_cpl = .false.
+
+  integer, private ::   &amp;
+      cpl_write_restart,   &amp;! flag id for write restart
+      cpl_write_history,   &amp;! flag id for write history
+      cpl_write_tavg,      &amp;! flag id for write tavg      
+      cpl_diag_global,     &amp;! flag id for computing diagnostics
+      cpl_diag_transp,     &amp;! flag id for computing diagnostics
+      my_task
+
+  real (kind=RKIND), dimension(:,:,:,:), allocatable ::  SBUFF_SUM           ! accumulated sum of send buffer quantities
+                                                                             ! for averaging before being sent
+   real (kind=RKIND) :: tlast_coupled
+
+   integer  :: nsend, nrecv
+
+   character(len=StrKIND) :: runtype         
+
+   type(seq_infodata_type), pointer :: infodata   
+   type (iosystem_desc_t), pointer :: io_system 
+
+   !! MPAS-O Datatypes
+   type (dm_info), pointer :: dminfo
+   type (domain_type), pointer :: domain
+   type (io_output_object), save :: output_obj
+   integer :: output_frame
+!  type (MPAS_Clock_type) :: clock
+
+!=======================================================================
+
+contains
+
+!***********************************************************************
+!BOP
+!
+! !IROUTINE: ocn_init_mct
+!
+! !INTERFACE:
+  subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )!{{{
+!
+! !DESCRIPTION:
+! Initialize POP 
+!
+! !INPUT/OUTPUT PARAMETERS:
+
+    type(ESMF_Clock), intent(in) :: EClock
+    type(seq_cdata), intent(inout) :: cdata_o
+    type(mct_aVect), intent(inout) :: x2o_o, o2x_o
+    character(len=*), optional, intent(in) :: NLFilename ! Namelist filename
+!
+! !REVISION HISTORY:
+! Author: Mariana Vertenstein
+!EOP
+!-----------------------------------------------------------------------
+!
+!  local variables
+!
+!-----------------------------------------------------------------------
+
+    integer :: OCNID, mpicom_o, lsize, start_ymd, start_tod, start_year, start_day,   &amp;
+       start_month, start_hour, iyear, ocn_cpl_dt, mpas_o_cpl_dt, shrlogunit, shrloglev  
+
+    type(mct_gsMap), pointer :: gsMap_o
+
+    type(mct_gGrid), pointer :: dom_o
+
+    integer :: errorCode  ! error code
+
+    integer :: nThreads
+
+    real (kind=RKIND) :: precadj
+
+    type (MPAS_Time_Type) :: currTime
+    integer :: iam,ierr 
+    integer :: iyear0, imonth0
+    character(len=StrKIND)  :: starttype          ! infodata start type
+    character(len=StrKIND)  :: timeStamp
+    character(len=StrKIND)  :: nml_filename
+
+    integer :: lbnum
+
+!-----------------------------------------------------------------------
+!
+!  set cdata pointers
+!
+!-----------------------------------------------------------------------
+
+   errorCode = 0
+
+   call seq_cdata_setptrs(cdata_o, ID=OCNID, mpicom=mpicom_o, &amp;
+        gsMap=gsMap_o, dom=dom_o, infodata=infodata)
+
+   MPASO_MCT_OCNID =  OCNID
+   MPASO_MCT_gsMap_o =&gt; gsMap_o
+   MPASO_MCT_dom_o   =&gt; dom_o
+
+#if (defined _MEMTRACE)
+    call MPI_comm_rank(mpicom_o,iam,ierr)
+    if(iam == 0) then
+        lbnum=1
+        call memmon_dump_fort('memmon.out','ocn_init_mct:start::',lbnum) 
+    endif
+#endif
+
+
+    ! The following communicator module variable will be utilized in init_communicate that
+    ! is called by initial - this is done to make the code backwards compatible
+
+    mpi_communicator_ocn = mpicom_o
+
+!-----------------------------------------------------------------------
+!
+!  initialize the model run 
+!
+!-----------------------------------------------------------------------
+
+    call mpaso_cpl_indices_set()
+
+!   call seq_infodata_GetData( infodata, case_name=runid )
+    call seq_infodata_GetData( infodata, start_type=starttype)
+
+
+    if (     trim(starttype) == trim(seq_infodata_start_type_start)) then
+       runtype = &quot;initial&quot;
+    else if (trim(starttype) == trim(seq_infodata_start_type_cont) ) then
+       runtype = &quot;continue&quot;
+    else if (trim(starttype) == trim(seq_infodata_start_type_brnch)) then
+       runtype = &quot;branch&quot;
+    else
+       call mpas_dmpar_global_abort(' ocn_comp_mct ERROR: unknown starttype')
+    end if
+   
+!-----------------------------------------------------------------------
+!
+!  first initializaiton phase of mpas-o
+!  initialize mpas-o because grid information is needed for
+!  creation of GSMap_ocn.
+!  call mpas-o initialization routines
+!
+!-----------------------------------------------------------------------
+
+!  inst_name   = seq_comm_name(OCNID)
+!  inst_index  = seq_comm_inst(OCNID)
+!  inst_suffix = seq_comm_suffix(OCNID)
+
+   call t_startf('mpas-o_init')
+   nml_filename = &quot;mpaso.in&quot;
+
+   io_system =&gt; shr_pio_getiosys(ocnid)
+
+   call mpas_framework_init(dminfo, domain, mpi_communicator_ocn, nml_filename, io_system)
+
+   my_task = dminfo % my_proc_id
+   call mpas_timer_start(&quot;total time&quot;)
+
+   call mpas_input_state_for_domain(domain)
+
+   call mpas_core_init(domain, timeStamp)
+
+!-----------------------------------------------------------------------
+!
+!  initialize time-stamp information
+!
+!-----------------------------------------------------------------------
+
+   call t_stopf ('mpas-o_init')
+
+!----------------------------------------------------------------------------
+!
+! reset shr logging to my log file
+!
+!----------------------------------------------------------------------------
+
+   call shr_file_getLogUnit (shrlogunit)
+   call shr_file_getLogLevel(shrloglev)
+!  call shr_file_setLogUnit (stdout)
+   
+!-----------------------------------------------------------------------
+!
+!  check for consistency of mpas-o and sync clock initial time
+!
+!-----------------------------------------------------------------------
+
+  if (runtype == 'initial') then
+     currTime = mpas_get_clock_time(clock, MPAS_NOW, ierr)
+     call mpas_get_time(curr_time=currTime, YYYY=iyear0, MM=imonth0, ierr=ierr)
+     call seq_timemgr_EClockGetData(EClock, start_ymd=start_ymd, start_tod=start_tod)
+     call shr_cal_date2ymd(start_ymd,start_year,start_month,start_day)
+
+     if (iyear0 /= start_year) then
+        call mpas_dmpar_global_abort(' iyear0 does not match start_year')
+     end if
+     if (imonth0 /= start_month) then
+        call mpas_dmpar_global_abort(' imonth0 does not match start_year')
+     end if
+  end if
+
+!-----------------------------------------------------------------------
+!
+!  initialize MCT attribute vectors and indices
+!
+!-----------------------------------------------------------------------
+
+   call t_startf ('mpas-o_mct_init')
+
+   call ocn_SetGSMap_mct( mpicom_o, OCNID, GSMap_o )
+   lsize = mct_gsMap_lsize(gsMap_o, mpicom_o)
+
+   ! Initialize mct ocn domain (needs ocn initialization info)
+   
+   call ocn_domain_mct( lsize, gsMap_o, dom_o )
+   
+   ! Inialize mct attribute vectors
+   
+   call mct_aVect_init(x2o_o, rList=seq_flds_x2o_fields, lsize=lsize)
+   call mct_aVect_zero(x2o_o)
+   
+   call mct_aVect_init(o2x_o, rList=seq_flds_o2x_fields, lsize=lsize) 
+   call mct_aVect_zero(o2x_o)
+   
+   nsend = mct_avect_nRattr(o2x_o)
+   nrecv = mct_avect_nRattr(x2o_o)
+
+!-----------------------------------------------------------------------
+!
+!   initialize necessary  coupling info
+!
+!-----------------------------------------------------------------------
+
+    call seq_timemgr_EClockGetData(EClock, dtime=ocn_cpl_dt)
+    mpas_o_cpl_dt = 86400 / config_ncouple_per_day
+    if (mpas_o_cpl_dt /= ocn_cpl_dt) then
+       write(0,*)'mpas-o_cpl_dt= ',mpas_o_cpl_dt, &amp;
+                     ' ocn_cpl_dt= ',ocn_cpl_dt   
+       call mpas_dmpar_global_abort('ERROR mpas-o_cpl_dt and ocn_cpl_dt must be identical')
+    end if
+
+!-----------------------------------------------------------------------
+!
+!  send intial state to driver
+!
+!-----------------------------------------------------------------------
+
+!  if ( lsend_precip_fact )  then
+!     precadj = precip_fact * 1.0e6_r8  
+!     call seq_infodata_PutData( infodata, precip_fact=precadj)
+!  end if
+
+   call ocn_export_mct(o2x_o, errorCode)  
+   if (errorCode /= 0) then
+      call mpas_dmpar_global_abort('ERROR in ocn_export_mct')
+   endif
+
+   call t_stopf ('mpas-o_mct_init')
+
+!  call seq_infodata_PutData( infodata, ocn_nx = nx_global , ocn_ny = ny_global)
+   call seq_infodata_PutData( infodata, ocn_prognostic=.true., ocnrof_prognostic=.true.)
+
+!----------------------------------------------------------------------------
+!
+! Reset shr logging to original values
+!
+!----------------------------------------------------------------------------
+
+    call shr_file_setLogUnit (shrlogunit)
+    call shr_file_setLogLevel(shrloglev)
+
+#if (defined _MEMTRACE)
+    if(iam  == 0) then
+        lbnum=1
+        call memmon_dump_fort('memmon.out','ocn_init_mct:end::',lbnum) 
+        call memmon_reset_addr()
+    endif
+#endif
+
+!-----------------------------------------------------------------------
+!
+!  output delimiter to log file
+!
+!-----------------------------------------------------------------------
+
+   !DWJ IO Units
+!  if (my_task == master_task) then
+!     write(stdout,blank_fmt)
+!     write(stdout,'(&quot; End of initialization&quot;)')
+!     write(stdout,blank_fmt)
+!     write(stdout,ndelim_fmt)
+!     call POP_IOUnitsFlush(POP_stdout)
+#ifdef CCSMCOUPLED
+!     call POP_IOUnitsFlush(stdout)
+#endif
+!  endif
+
+      !
+      ! Set up output streams to be written to by the MPAS core
+      !
+      output_frame = 1
+
+      if(config_frames_per_outfile &gt; 0) then
+         call mpas_output_state_init(output_obj, domain, &quot;OUTPUT&quot;, trim(timeStamp))
+      else
+         call mpas_output_state_init(output_obj, domain, &quot;OUTPUT&quot;)         
+      end if
+
+!-----------------------------------------------------------------------
+!EOC
+
+ end subroutine ocn_init_mct!}}}
+
+!***********************************************************************
+!BOP
+!
+! !IROUTINE: ocn_run_mct
+!
+! !INTERFACE:
+  subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)!{{{
+
+    use mpas_kind_types
+    use mpas_grid_types
+    use mpas_io_output
+    use mpas_timer
+
+    implicit none
+!
+! !DESCRIPTION:
+! Run POP for a coupling interval
+!
+! !INPUT/OUTPUT PARAMETERS:
+    type(ESMF_Clock)            , intent(in)    :: EClock
+    type(seq_cdata)             , intent(inout) :: cdata_o
+    type(mct_aVect)             , intent(inout) :: x2o_o
+    type(mct_aVect)             , intent(inout) :: o2x_o
+
+!!
+!! !REVISION HISTORY:
+!! Author: Mariana Vertenstein
+!!EOP
+!!-----------------------------------------------------------------------
+!!
+!!  local variables
+!!
+!!-----------------------------------------------------------------------
+!
+!    integer :: errorCode           ! error flag
+!
+!    integer :: itimestep
+!
+!    integer :: &amp;
+!         ymd, &amp;          ! POP2 current date (YYYYMMDD)
+!         tod, &amp;          ! POP2 current time of day (sec)
+!         ymd_sync, &amp;     ! Sync clock current date (YYYYMMDD)
+!         tod_sync, &amp;     ! Sync clcok current time of day (sec)
+!         shrlogunit,  &amp;  ! old values
+!         shrloglev       ! old values
+!
+!    character(len=char_len_long) :: &amp;
+!         fname
+!
+!    type(seq_infodata_type), pointer :: &amp;
+!       infodata   ! Input init object
+!
+!    real (kind=RKIND) ::  &amp;
+!         precadj
+!
+!    logical :: &amp;
+!         lcoupled,   &amp;  ! temporary
+!         rstwr,      &amp;  ! true =&gt; write restart at end of day
+!         first_time = .true.
+!
+!    character (char_len)  :: message
+!
+!    integer(int_kind) :: info_debug
+!
+!    integer :: lbnum
+
+      integer :: itimestep
+      real (kind=RKIND) :: dt
+      type (block_type), pointer :: block_ptr
+
+      type (MPAS_Time_Type) :: currTime
+      character(len=StrKIND) :: timeStamp
+      integer :: ierr
+   
+      ! Eventually, dt should be domain specific
+      dt = config_dt
+
+      currTime = mpas_get_clock_time(clock, MPAS_NOW, ierr)
+      call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr)
+      write(0,*) 'Initial time ', trim(timeStamp)
+
+      call ocn_write_output_frame(output_obj, output_frame, domain)
+      block_ptr =&gt; domain % blocklist
+
+      do while(associated(block_ptr))
+        call ocn_time_average_init(block_ptr % state % time_levs(1) % state)
+        block_ptr =&gt; block_ptr % next
+      end do
+
+      ! During integration, time level 1 stores the model state at the beginning of the
+      !   time step, and time level 2 stores the state advanced dt in time by timestep(...)
+      itimestep = 0
+      do while (.not. mpas_is_clock_stop_time(clock))
+
+         itimestep = itimestep + 1
+         call mpas_advance_clock(clock)
+
+         currTime = mpas_get_clock_time(clock, MPAS_NOW, ierr)
+         call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr)
+         write(0,*) 'Doing timestep ', trim(timeStamp)
+   
+         block_ptr =&gt; domain % blocklist
+         do while(associated(block_ptr))
+           call ocn_build_forcing_arrays(currTime, block_ptr % mesh, ierr)
+           block_ptr =&gt; block_ptr % next
+         end do
+
+         call mpas_timer_start(&quot;time integration&quot;, .false., timeIntTimer)
+         call mpas_timestep(domain, itimestep, dt, timeStamp)
+         call mpas_timer_stop(&quot;time integration&quot;, timeIntTimer)
+   
+         ! Move time level 2 fields back into time level 1 for next time step
+         block_ptr =&gt; domain % blocklist
+         do while(associated(block_ptr))
+            call mpas_shift_time_levels_state(block_ptr % state)
+            block_ptr =&gt; block_ptr % next
+         end do
+      
+         if (mpas_is_alarm_ringing(clock, outputAlarmID, ierr=ierr)) then
+            call mpas_reset_clock_alarm(clock, outputAlarmID, ierr=ierr)
+            ! output_frame will always be &gt; 1 here unless it was reset after the maximum number of frames per outfile was reached
+            if(output_frame == 1) then
+               call mpas_output_state_finalize(output_obj, domain % dminfo)
+               call mpas_output_state_init(output_obj, domain, &quot;OUTPUT&quot;, trim(timeStamp))
+            end if
+
+            block_ptr =&gt; domain % blocklist
+            do while (associated(block_ptr))
+                call ocn_time_average_normalize(block_ptr % state % time_levs(1) % state)
+                block_ptr =&gt; block_ptr % next
+            end do
+
+            call ocn_write_output_frame(output_obj, output_frame, domain)
+
+            block_ptr =&gt; domain % blocklist
+            do while (associated(block_ptr))
+                call ocn_time_average_init(block_ptr % state % time_levs(1) % state)
+                block_ptr =&gt; block_ptr % next
+            end do
+         end if
+
+         if (mpas_is_alarm_ringing(clock, restartAlarmID, ierr=ierr)) then
+            call mpas_reset_clock_alarm(clock, restartAlarmID, ierr=ierr)
+
+            ! Write one restart time per file
+            call mpas_output_state_init(restart_obj, domain, &quot;RESTART&quot;, trim(timeStamp))
+            call mpas_output_state_for_domain(restart_obj, domain, 1)
+            call mpas_output_state_finalize(restart_obj, domain % dminfo)
+         end if
+
+      end do
+!
+!#if (defined _MEMTRACE)
+!    if(my_task == 0 ) then
+!       lbnum=1
+!       call memmon_dump_fort('memmon.out',SubName//':start::',lbnum) 
+!    endif
+!#endif
+!
+!!-----------------------------------------------------------------------
+!!
+!!  start up the main timer
+!!
+!!-----------------------------------------------------------------------
+!
+!   call mpas_timer_start('total time')
+!
+!
+!!-----------------------------------------------------------------------
+!!
+!! reset shr logging to my log file
+!!
+!!----------------------------------------------------------------------------
+!
+!    errorCode = POP_Success
+!
+!    call shr_file_getLogUnit (shrlogunit)
+!    call shr_file_getLogLevel(shrloglev)
+!    call shr_file_setLogUnit (stdout)
+!
+!    call seq_cdata_setptrs(cdata_o, infodata=infodata)
+!
+!!----------------------------------------------------------------------------
+!!
+!! restart flag (rstwr) will assume only an eod restart for now
+!!
+!!----------------------------------------------------------------------------
+!
+!    call seq_infodata_GetData( infodata, info_debug=info_debug)
+!    if (info_debug &gt;= 2) then
+!       ldiag_cpl = .true. 
+!    else
+!       ldiag_cpl = .false.
+!    endif
+!
+!    rstwr = seq_timemgr_RestartAlarmIsOn(EClock)
+!
+!!-----------------------------------------------------------------------
+!!
+!!  advance the model in time over coupling interval
+!!  write restart dumps and archiving
+!!
+!!-----------------------------------------------------------------------
+!
+!    ! Note that all ocean time flags are evaluated each timestep in time_manager
+!    ! ocn_import_mct is analogous to pop_unpack_fluxes_from_coupler in cpl6 
+!    ! ocn_export_mct is analogous to prepare_send_to_coupler in cpl6
+!    ! tlast_coupled is set to zero at the end of ocn_export_mct
+!
+!    itimestep = 0
+!    timestep: do
+!       ! obtain import state from driver
+!       if (check_time_flag(cpl_ts) .or. nsteps_run == 0) then
+!          call ocn_import_mct(x2o_o, errorCode)   
+!
+!          if (errorCode /= POP_Success) then
+!             call POP_ErrorPrint(errorCode)
+!             call exit_POP(sigAbort, 'ERROR in step')
+!          endif
+!
+!          !DWJ Need to write on mpas side
+!!         call pop_set_coupled_forcing 
+!       end if
+!
+!
+!    end do timestep
+!
+!    advance: do 
+!
+!       call step(errorCode)
+!
+!       if (errorCode /= POP_Success) then
+!          call POP_ErrorPrint(errorCode)
+!          call exit_POP(sigAbort, 'ERROR in step')
+!       endif
+!
+!       if (check_KE(100.0_r8)) then
+!          !*** exit if energy is blowing
+!          call output_driver
+!          call exit_POP(sigAbort,'ERROR: k.e. &gt; 100 ')
+!       endif
+!       call output_driver
+!       
+!       ! return export state to driver
+!       call pop_sum_buffer()  
+!       if (check_time_flag(cpl_ts)) then
+!          call ocn_export_mct(o2x_o, errorCode)
+!          if (errorCode /= POP_Success) then
+!             call POP_ErrorPrint(errorCode)
+!             call exit_POP(sigAbort, 'ERROR in ocn_export_mct')
+!          endif
+!
+!          exit advance
+!       end if
+!       
+!    enddo advance
+!
+!    if ( lsend_precip_fact ) then
+!       precadj = precip_fact * 1.0e6_r8  
+!       call seq_infodata_PutData( infodata, precip_fact=precadj )
+!    end if
+!    
+!!--------------------------------------------------------------------
+!!
+!! check that internal clock is in sync with master clock
+!!
+!!--------------------------------------------------------------------
+!
+!    ymd = iyear*10000 + imonth*100 + iday
+!    tod = ihour*seconds_in_hour + iminute*seconds_in_minute + isecond
+!    if ( .not. seq_timemgr_EClockDateInSync( EClock, ymd, tod ) )then
+!       call seq_timemgr_EClockGetData( EClock, curr_ymd=ymd_sync, &amp;
+!          curr_tod=tod_sync )
+!       write(stdout,*)' pop2 ymd=',ymd     ,'  pop2 tod= ',tod
+!       write(stdout,*)' sync ymd=',ymd_sync,'  sync tod= ',tod_sync
+!       write(stdout,*)' Internal pop2 clock not in sync with Sync Clock'
+!       call shr_sys_abort( SubName// &amp;
+!          &quot;:: Internal pop2 clock not in sync with Sync Clock&quot;)
+!    end if
+!   
+!!----------------------------------------------------------------------------
+!!
+!! Reset shr logging to original values
+!!
+!!----------------------------------------------------------------------------
+!
+!   call shr_file_setLogUnit (shrlogunit)
+!   call shr_file_setLogLevel(shrloglev)
+!
+!   call mpas_timer_stop('total time')
+!
+!#if (defined _MEMTRACE)
+!    if(my_task == 0) then
+!       lbnum=1
+!       call memmon_dump_fort('memmon.out',SubName//':end::',lbnum) 
+!       call memmon_reset_addr()
+!    endif
+!#endif
+!-----------------------------------------------------------------------
+!EOC
+
+  end subroutine ocn_run_mct!}}}
+
+!***********************************************************************
+!BOP
+!
+! !IROUTINE: ocn_final_mct
+!
+! !INTERFACE:
+  subroutine ocn_final_mct( EClock, cdata_o, x2o_o, o2x_o)!{{{
+!
+! !DESCRIPTION:
+! Finalize POP
+!
+! !USES:
+! !ARGUMENTS:
+    type(ESMF_Clock)            , intent(in)    :: EClock
+    type(seq_cdata)             , intent(inout) :: cdata_o
+    type(mct_aVect)             , intent(inout) :: x2o_o
+    type(mct_aVect)             , intent(inout) :: o2x_o
+!
+! !REVISION HISTORY:
+! Author: Fei Liu
+!EOP
+!BOC
+!-----------------------------------------------------------------------
+!
+!  local variables
+!
+!-----------------------------------------------------------------------
+
+   integer :: &amp;
+      errorCode         ! error code
+
+!-----------------------------------------------------------------------
+
+
+
+    call mpas_output_state_finalize(output_obj, domain % dminfo)
+    call mpas_timer_stop(&quot;total time&quot;)
+    call mpas_timer_write()
+        write(0,*) 'core finalize'
+    call mpas_core_finalize(domain)
+        write(0,*) 'framework finalize'
+    call mpas_framework_finalize(dminfo, domain, io_system)
+        write(0,*) 'done in final mct'
+
+  end subroutine ocn_final_mct!}}}
+
+!***********************************************************************
+!BOP
+!IROUTINE: ocn_SetGSMap_mct
+! !INTERFACE:
+
+ subroutine ocn_SetGSMap_mct( mpicom_ocn, OCNID, gsMap_ocn )!{{{
+
+   use mpas_dmpar
+
+! !DESCRIPTION:
+!  This routine mct global seg maps for the pop decomposition
+!
+! !REVISION HISTORY:
+!  same as module
+
+! !INPUT/OUTPUT PARAMETERS:
+
+    implicit none
+    integer        , intent(in)    :: mpicom_ocn
+    integer        , intent(in)    :: OCNID
+    type(mct_gsMap), intent(inout) :: gsMap_ocn
+
+!EOP
+!BOC
+!-----------------------------------------------------------------------
+!
+!  local variables
+!
+!-----------------------------------------------------------------------
+
+    integer,allocatable :: &amp;
+      gindex(:)
+
+    integer ::   &amp;
+      i,j, k, n, iblock, &amp;
+      lsize, gsize,   &amp;
+      ier
+
+    type (block_type), pointer :: block_ptr 
+
+!-----------------------------------------------------------------------
+!  Build the POP grid numbering for MCT
+!  NOTE:  Numbering scheme is: West to East and South to North starting
+!  at the south pole.  Should be the same as what's used in SCRIP
+!-----------------------------------------------------------------------
+
+    n = 0
+    block_ptr =&gt; domain % blocklist
+    do while(associated(block_ptr))
+      n = n + block_ptr % mesh % nCellsSolve
+      block_ptr =&gt; block_ptr % next
+    end do
+
+    lsize = n
+    call mpas_dmpar_sum_int(dminfo, lsize, gsize)
+    allocate(gindex(lsize),stat=ier)
+
+    n = 0
+    block_ptr =&gt; domain % blocklist
+    do while(associated(block_ptr))
+      do i = 1, block_ptr % mesh % nCellsSolve
+        n = n + 1
+        gindex(n) = block_ptr % mesh % indexToCellID % array(i)
+      end do
+      block_ptr =&gt; block_ptr % next
+    end do
+
+    call mct_gsMap_init( gsMap_ocn, gindex, mpicom_ocn, OCNID, lsize, gsize )
+
+    deallocate(gindex)
+
+!-----------------------------------------------------------------------
+!EOC
+
+  end subroutine ocn_SetGSMap_mct!}}}
+
+!***********************************************************************
+!BOP
+! !IROUTINE: ocn_domain_mct
+! !INTERFACE:
+
+ subroutine ocn_domain_mct( lsize, gsMap_o, dom_o )!{{{
+
+! !DESCRIPTION:
+!  This routine mct global seg maps for the pop decomposition
+!
+! !REVISION HISTORY:
+!  same as module
+!
+! !INPUT/OUTPUT PARAMETERS:
+
+    implicit none
+    integer        , intent(in)    :: lsize
+    type(mct_gsMap), intent(in)    :: gsMap_o
+    type(mct_ggrid), intent(inout) :: dom_o     
+
+!EOP
+!BOC
+!-----------------------------------------------------------------------
+!
+!  local variables
+!
+!-----------------------------------------------------------------------
+
+    integer, pointer :: idata(:)
+
+    real(kind=RKIND), pointer :: data(:)
+    real(kind=RKIND) :: r2d
+
+    integer :: i,j, k, n, ier
+
+    type (block_type), pointer :: block_ptr
+
+    r2d = 180.0/pii
+
+!-------------------------------------------------------------------
+!
+!  initialize mct domain type, lat/lon in degrees,
+!  area in radians^2, mask is 1 (ocean), 0 (non-ocean)
+!
+!-------------------------------------------------------------------
+
+    call mct_gGrid_init( GGrid=dom_o, CoordChars=trim(seq_flds_dom_coord), &amp;
+       OtherChars=trim(seq_flds_dom_other), lsize=lsize )
+    call mct_aVect_zero(dom_o%data)
+    allocate(data(lsize))
+
+!-------------------------------------------------------------------
+!
+! Determine global gridpoint number attribute, GlobGridNum, which is set automatically by MCT
+!
+!-------------------------------------------------------------------
+
+    call mct_gsMap_orderedPoints(gsMap_o, my_task, idata)
+    call mct_gGrid_importIAttr(dom_o,'GlobGridNum',idata,lsize)
+
+!-------------------------------------------------------------------
+!
+! Determine domain (numbering scheme is: West to East and South to North to South pole)
+! Initialize attribute vector with special value
+!
+!-------------------------------------------------------------------
+
+    data(:) = -9999.0_R8 
+    call mct_gGrid_importRAttr(dom_o,&quot;lat&quot;  ,data,lsize) 
+    call mct_gGrid_importRAttr(dom_o,&quot;lon&quot;  ,data,lsize) 
+    call mct_gGrid_importRAttr(dom_o,&quot;area&quot; ,data,lsize) 
+    call mct_gGrid_importRAttr(dom_o,&quot;aream&quot;,data,lsize) 
+    data(:) = 0.0_R8     
+    call mct_gGrid_importRAttr(dom_o,&quot;mask&quot;,data,lsize) 
+    call mct_gGrid_importRAttr(dom_o,&quot;frac&quot;,data,lsize) 
+
+!-------------------------------------------------------------------
+!
+! Fill in correct values for domain components
+!
+!-------------------------------------------------------------------
+
+    n = 0
+    block_ptr =&gt; domain % blocklist
+    do while(associated(block_ptr))
+      do i = 1, block_ptr % mesh % nCellsSolve
+        n = n + 1
+        data(n) = block_ptr % mesh % lonCell % array(i) * r2d
+      end do
+      
+      block_ptr =&gt; block_ptr % next
+    end do
+    call mct_gGrid_importRattr(dom_o,&quot;lon&quot;,data,lsize) 
+
+    n = 0
+    block_ptr =&gt; domain % blocklist
+    do while(associated(block_ptr))
+      do i = 1, block_ptr % mesh % nCellsSolve
+        n = n + 1
+        data(n) = block_ptr % mesh % latCell % array(i) * r2d
+      end do
+      block_ptr =&gt; block_ptr % next
+    end do
+    call mct_gGrid_importRattr(dom_o,&quot;lat&quot;,data,lsize) 
+
+    n = 0
+    block_ptr =&gt; domain % blocklist
+    do while(associated(block_ptr))
+      do i = 1, block_ptr % mesh % nCellsSolve
+        n = n + 1
+        data(n) = block_ptr % mesh % areaCell % array(i) / (block_ptr % mesh % sphere_radius * block_ptr % mesh % sphere_radius)
+      end do
+      block_ptr =&gt; block_ptr % next
+    end do
+    call mct_gGrid_importRattr(dom_o,&quot;area&quot;,data,lsize) 
+
+    data(:) = 1.0_RKIND ! No land cells in MPAS-O, only Ocean cells
+    call mct_gGrid_importRattr(dom_o,&quot;mask&quot;,data,lsize) 
+    call mct_gGrid_importRattr(dom_o,&quot;frac&quot;,data,lsize) 
+
+    deallocate(data)
+    deallocate(idata)
+
+!-----------------------------------------------------------------------
+!EOC
+
+  end subroutine ocn_domain_mct!}}}
+
+
+!***********************************************************************
+!BOP
+! !IROUTINE: ocn_import_mct
+! !INTERFACE:
+
+ subroutine ocn_import_mct(x2o_o, errorCode)!{{{
+
+! !DESCRIPTION:
+!-----------------------------------------------------------------------
+!  This routine receives message from cpl7 driver
+!
+!    The following fields are always received from the coupler:
+! 
+!    o  taux   -- zonal wind stress (taux)                 (W/m2   )
+!    o  tauy   -- meridonal wind stress (tauy)             (W/m2   )
+!    o  snow   -- water flux due to snow                   (kg/m2/s)
+!    o  rain   -- water flux due to rain                   (kg/m2/s)
+!    o  evap   -- evaporation flux                         (kg/m2/s)
+!    o  meltw  -- snow melt flux                           (kg/m2/s)
+!    o  salt   -- salt                                     (kg(salt)/m2/s)
+!    o  swnet  -- net short-wave heat flux                 (W/m2   )
+!    o  sen    -- sensible heat flux                       (W/m2   )
+!    o  lwup   -- longwave radiation (up)                  (W/m2   )
+!    o  lwdn   -- longwave radiation (down)                (W/m2   )
+!    o  melth  -- heat flux from snow&amp;ice melt             (W/m2   )
+!    o  ifrac  -- ice fraction
+!    o  roff   -- river runoff flux                        (kg/m2/s)
+!    o  ioff   -- ice runoff flux                          (kg/m2/s)
+! 
+!    The following fields are sometimes received from the coupler,
+!      depending on model options:
+! 
+!    o  pslv   -- sea-level pressure                       (Pa)
+!    o  duu10n -- 10m wind speed squared                   (m^2/s^2)
+!    o  co2prog-- bottom atm level prognostic co2
+!    o  co2diag-- bottom atm level diagnostic co2
+! 
+!-----------------------------------------------------------------------
+!
+! !REVISION HISTORY:
+!  same as module
+
+! !INPUT/OUTPUT PARAMETERS:
+
+    type(mct_aVect)   , intent(inout) :: x2o_o
+
+! !OUTPUT PARAMETERS:
+
+   integer, intent(out) :: &amp;
+      errorCode              ! returned error code
+
+!EOP
+!BOC
+!-----------------------------------------------------------------------
+!
+!  local variables
+!
+!-----------------------------------------------------------------------
+
+!   character (len=StrKIND) ::   &amp;
+!      label,                 &amp;
+!      message
+! 
+!   integer ::  &amp;
+!      i,j,k,n,iblock
+!
+!   real (kind=RKIND), dimension(nx_block,ny_block) ::  &amp;
+!      WORKB
+!
+!   real (kind=RKIND), dimension(nx_block,ny_block,max_blocks_clinic) ::   &amp;
+!      WORK1, WORK2        ! local work space
+!
+!   real (r8) ::  &amp;
+!      m2percm2,  &amp;
+!      gsum
+!
+!   type (block) :: this_block ! local block info
+!
+!!-----------------------------------------------------------------------
+!!
+!!  zero out padded cells 
+!!
+!!-----------------------------------------------------------------------
+!
+!   errorCode = POP_Success
+!
+!   WORK1 = c0
+!   WORK2 = c0
+!
+!!-----------------------------------------------------------------------
+!!
+!!  unpack and distribute wind stress, then convert to correct units
+!!  and rotate components to local coordinates
+!!
+!!-----------------------------------------------------------------------
+!
+!   n = 0
+!   do iblock = 1, nblocks_clinic
+!      this_block = get_block(blocks_clinic(iblock),iblock)
+!
+!      do j=this_block%jb,this_block%je
+!      do i=this_block%ib,this_block%ie
+!         n = n + 1
+!         WORK1(i,j,iblock) = x2o_o%rAttr(index_x2o_Foxx_taux,n)
+!         WORK2(i,j,iblock) = x2o_o%rAttr(index_x2o_Foxx_tauy,n)
+!      enddo
+!      enddo
+!   enddo ! iblock
+!
+!   !***
+!   !*** do NOT perform halo updates now, because vector updates must
+!   !***   be done after the rotation is completed.
+!   !***
+!
+!!-----------------------------------------------------------------------
+!!
+!!  rotate true zonal/meridional wind stress into local coordinates,
+!!  convert to dyne/cm**2, and shift SMFT to U grid
+!!
+!!  halo updates are performed in subroutine rotate_wind_stress, 
+!!  following the rotation
+!!
+!!-----------------------------------------------------------------------
+!
+!      call rotate_wind_stress(WORK1, WORK2)
+!
+!   n = 0
+!   do iblock = 1, nblocks_clinic
+!      this_block = get_block(blocks_clinic(iblock),iblock)
+!
+!!-----------------------------------------------------------------------
+!!
+!!  unpack and distribute fresh water flux and salt flux
+!!
+!!  NOTE: if there are code changes associated with changing the names or
+!!        the number of fluxes received from the coupler, then subroutine
+!!        update_ghost_cells_coupler_fluxes will need to be modified also
+!!
+!!-----------------------------------------------------------------------
+!
+!
+!      do j=this_block%jb,this_block%je
+!      do i=this_block%ib,this_block%ie
+!         n = n + 1
+!         SNOW_F(i,j,iblock) = x2o_o%rAttr(index_x2o_Faxa_snow,n)
+!         WORKB (i,j       ) = x2o_o%rAttr(index_x2o_Faxa_rain,n)
+!         EVAP_F(i,j,iblock) = x2o_o%rAttr(index_x2o_Foxx_evap,n)
+!         MELT_F(i,j,iblock) = x2o_o%rAttr(index_x2o_Fioi_meltw,n)
+!         ROFF_F(i,j,iblock) = x2o_o%rAttr(index_x2o_Forr_roff,n)
+!         IOFF_F(i,j,iblock) = x2o_o%rAttr(index_x2o_Forr_ioff,n)
+!         SALT_F(i,j,iblock) = x2o_o%rAttr(index_x2o_Fioi_salt,n)
+!
+!         PREC_F(i,j,iblock) = WORKB(i,j) + SNOW_F(i,j,iblock)    ! rain + snow
+!
+!         WORKB(i,j        ) = x2o_o%rAttr(index_x2o_Foxx_swnet,n)
+!         SHF_QSW(i,j,iblock) = WORKB(i,j)*  &amp;
+!            RCALCT(i,j,iblock)*hflux_factor  !  convert from W/m**2
+!         SENH_F(i,j,iblock)  = x2o_o%rAttr(index_x2o_Foxx_sen,n)
+!         LWUP_F(i,j,iblock)  = x2o_o%rAttr(index_x2o_Foxx_lwup,n)
+!         LWDN_F(i,j,iblock)  = x2o_o%rAttr(index_x2o_Faxa_lwdn,n)
+!         MELTH_F(i,j,iblock) = x2o_o%rAttr(index_x2o_Fioi_melth,n)
+!
+!         WORKB(i,j       ) = x2o_o%rAttr(index_x2o_Si_ifrac,n)
+!         IFRAC(i,j,iblock) = WORKB(i,j) * RCALCT(i,j,iblock)
+!
+!         !***  converting from Pa to dynes/cm**2
+!         WORKB(i,j       ) = x2o_o%rAttr(index_x2o_Sa_pslv,n)
+!         ATM_PRESS(i,j,iblock) = c10 * WORKB(i,j) * RCALCT(i,j,iblock)
+!
+!         !***  converting from m**2/s**2 to cm**2/s**2
+!         WORKB(i,j       ) = x2o_o%rAttr(index_x2o_So_duu10n,n)
+!         U10_SQR(i,j,iblock) = cmperm * cmperm * WORKB(i,j) * RCALCT(i,j,iblock)
+!
+!      enddo
+!      enddo
+!
+!   enddo
+!
+!!-----------------------------------------------------------------------
+!!
+!!  incoming data quality control
+!!
+!!-----------------------------------------------------------------------
+!#ifdef CCSMCOUPLED
+!      if ( any(IOFF_F &lt; c0) ) then
+!        call shr_sys_abort ('Error: incoming IOFF_F is negative')
+!      endif
+!#endif
+!
+!
+!!-----------------------------------------------------------------------
+!!
+!!  update ghost cells for fluxes received from the coupler
+!!
+!!-----------------------------------------------------------------------
+!
+!   call update_ghost_cells_coupler_fluxes(errorCode)
+!
+!   if (errorCode /= POP_Success) then
+!      call POP_ErrorSet(errorCode, &amp;
+!         'ocn_import_mct: error in update_ghost_cells_coupler_fluxes')
+!      return
+!   endif
+!
+!!-----------------------------------------------------------------------
+!!
+!!  unpack atmospheric CO2
+!!
+!!-----------------------------------------------------------------------
+!
+!   if (index_x2o_Sa_co2prog &gt; 0) then
+!      n = 0
+!      do iblock = 1, nblocks_clinic
+!         this_block = get_block(blocks_clinic(iblock),iblock)
+!
+!         do j=this_block%jb,this_block%je
+!         do i=this_block%ib,this_block%ie
+!            n = n + 1
+!            WORK1(i,j,iblock) = x2o_o%rAttr(index_x2o_Sa_co2prog,n)
+!         enddo
+!         enddo
+!      enddo
+!
+!      call POP_HaloUpdate(WORK1,POP_haloClinic,          &amp;
+!                       POP_gridHorzLocCenter,          &amp;
+!                       POP_fieldKindScalar, errorCode, &amp;
+!                       fillValue = 0.0_POP_r8)
+!
+!      if (errorCode /= POP_Success) then
+!         call POP_ErrorSet(errorCode, &amp;
+!            'ocn_import_mct: error updating PROG CO2 halo')
+!         return
+!      endif
+!
+!      call named_field_set(ATM_CO2_PROG_nf_ind, WORK1)
+!   endif
+!
+!   if (index_x2o_Sa_co2diag &gt; 0) then
+!      n = 0
+!      do iblock = 1, nblocks_clinic
+!         this_block = get_block(blocks_clinic(iblock),iblock)
+!
+!         do j=this_block%jb,this_block%je
+!         do i=this_block%ib,this_block%ie
+!            n = n + 1
+!            WORK1(i,j,iblock) = x2o_o%rAttr(index_x2o_Sa_co2diag,n)
+!         enddo
+!         enddo
+!      enddo
+!
+!      call POP_HaloUpdate(WORK1,POP_haloClinic,          &amp;
+!                       POP_gridHorzLocCenter,          &amp;
+!                       POP_fieldKindScalar, errorCode, &amp;
+!                       fillValue = 0.0_POP_r8)
+!
+!      if (errorCode /= POP_Success) then
+!         call POP_ErrorSet(errorCode, &amp;
+!            'ocn_import_mct: error updating DIAG CO2 halo')
+!         return
+!      endif
+!
+!      call named_field_set(ATM_CO2_DIAG_nf_ind, WORK1)
+!   endif
+! 
+!!-----------------------------------------------------------------------
+!!
+!!  receive orbital parameters
+!!
+!!-----------------------------------------------------------------------
+!
+!   call seq_infodata_GetData(infodata, &amp;
+!      orb_eccen=orb_eccen, orb_mvelpp=orb_mvelpp, orb_lambm0=orb_lambm0, orb_obliqr=orb_obliqr)
+!
+!
+!!-----------------------------------------------------------------------
+!!
+!!  diagnostics
+!!
+!!-----------------------------------------------------------------------
+!
+!   if (ldiag_cpl) then
+!
+!     write(message,'(6a,1x,5a)')  &amp;
+!         ' Global averages of fluxes received from cpl at ',  &amp;
+!           cyear,'/',cmonth ,'/',cday,  chour,':',cminute,':',csecond
+!     call document ('pop_recv_from_coupler', trim(message))
+! 
+!     m2percm2  = mpercm*mpercm
+!     do k = 1,nrecv
+!
+!         n = 0
+!         do iblock = 1, nblocks_clinic
+!            this_block = get_block(blocks_clinic(iblock),iblock)
+!
+!            do j=this_block%jb,this_block%je
+!            do i=this_block%ib,this_block%ie
+!               n = n + 1
+!               WORK1(i,j,iblock) = x2o_o%rAttr(k,n)  ! mult. by TAREA in global_sum_prod
+!            enddo
+!            enddo
+!         enddo
+!
+!         gsum = global_sum_prod(WORK1 , TAREA, distrb_clinic, &amp;
+!                                 field_loc_center, RCALCT)*m2percm2
+!         if (my_task == master_task) then
+!            call seq_flds_getField(label,k,seq_flds_x2o_fields)
+!            write(stdout,1100)'ocn','recv', label ,gsum
+!            call shr_sys_flush(stdout)
+!         endif
+!      enddo
+!   endif
+!
+!
+!1100  format ('comm_diag ', a3, 1x, a4, 1x, a8, 1x, es26.19:, 1x, a6)
+
+!-----------------------------------------------------------------------
+!EOC
+
+ end subroutine ocn_import_mct!}}}
+!***********************************************************************
+!BOP
+! !IROUTINE: ocn_export_mct
+! !INTERFACE:
+
+ subroutine ocn_export_mct(o2x_o, errorCode)   !{{{
+
+! !DESCRIPTION:
+!  This routine calls the routines necessary to send pop fields to
+!  the CCSM cpl7 driver
+!
+! !REVISION HISTORY:
+!  same as module
+!
+! !INPUT/OUTPUT PARAMETERS:
+
+   type(mct_aVect)   , intent(inout) :: o2x_o
+
+! !OUTPUT PARAMETERS:
+
+   integer, intent(out) :: &amp;
+      errorCode              ! returned error code
+
+!EOP
+!BOC
+!!-----------------------------------------------------------------------
+!!
+!!  local variables
+!!
+!!-----------------------------------------------------------------------
+!
+!   integer (int_kind) :: n, iblock
+!           
+!   character (char_len)    :: label
+! 
+!   integer (int_kind) ::  &amp;
+!      i,j,k
+!
+!   real (r8), dimension(nx_block,ny_block) ::   &amp;
+!      WORK1, WORK2,      &amp;! local work space
+!      WORK3, WORK4
+!
+!   real (r8), dimension(nx_block,ny_block,max_blocks_clinic) ::   &amp;
+!        WORKA               ! local work space with full block dimension
+!
+!   real (r8) ::   &amp;
+!      m2percm2,   &amp;
+!      gsum
+!
+!   type (block) :: this_block ! local block info
+!
+!!-----------------------------------------------------------------------
+!
+!!-----------------------------------------------------------------------
+!!
+!!  initialize control buffer
+!!
+!!-----------------------------------------------------------------------
+!
+!   errorCode = POP_Success
+!
+!!-----------------------------------------------------------------------
+!!
+!!     interpolate onto T-grid points and rotate on T grid
+!!
+!!-----------------------------------------------------------------------
+!
+!   n = 0
+!   do iblock = 1, nblocks_clinic
+!     this_block = get_block(blocks_clinic(iblock),iblock)
+!
+!     call ugrid_to_tgrid(WORK3,SBUFF_SUM(:,:,iblock,index_o2x_So_u),iblock)
+!     call ugrid_to_tgrid(WORK4,SBUFF_SUM(:,:,iblock,index_o2x_So_v),iblock)
+!
+!     WORK1 = (WORK3*cos(ANGLET(:,:,iblock))+WORK4*sin(-ANGLET(:,:,iblock)))  &amp;
+!            * mpercm/tlast_coupled
+!     WORK2 = (WORK4*cos(ANGLET(:,:,iblock))-WORK3*sin(-ANGLET(:,:,iblock)))  &amp;
+!            * mpercm/tlast_coupled
+!
+!     do j=this_block%jb,this_block%je
+!     do i=this_block%ib,this_block%ie
+!        n = n + 1
+!        o2x_o%rAttr(index_o2x_So_u,n) = WORK1(i,j)
+!        o2x_o%rAttr(index_o2x_So_v,n) = WORK2(i,j)
+!     enddo
+!     enddo
+!  enddo
+!
+!!-----------------------------------------------------------------------
+!!
+!!     convert and pack surface temperature
+!!
+!!-----------------------------------------------------------------------
+!
+!   n = 0
+!   do iblock = 1, nblocks_clinic
+!      this_block = get_block(blocks_clinic(iblock),iblock)
+!      do j=this_block%jb,this_block%je
+!      do i=this_block%ib,this_block%ie
+!         n = n + 1
+!         o2x_o%rAttr(index_o2x_So_t,n) =   &amp;
+!             SBUFF_SUM(i,j,iblock,index_o2x_So_t)/tlast_coupled + T0_Kelvin
+!      enddo
+!      enddo
+!   enddo
+!
+!!-----------------------------------------------------------------------
+!!
+!!     convert and pack salinity
+!!
+!!-----------------------------------------------------------------------
+!
+!   n = 0
+!   do iblock = 1, nblocks_clinic
+!      this_block = get_block(blocks_clinic(iblock),iblock)
+!      do j=this_block%jb,this_block%je
+!      do i=this_block%ib,this_block%ie
+!         n = n + 1
+!         o2x_o%rAttr(index_o2x_So_s,n) =   &amp;
+!             SBUFF_SUM(i,j,iblock,index_o2x_So_s)*salt_to_ppt/tlast_coupled
+!      enddo
+!      enddo
+!   enddo
+!
+!!-----------------------------------------------------------------------
+!!
+!!     interpolate onto T-grid points, then rotate on T grid
+!!
+!!-----------------------------------------------------------------------
+!
+!   n = 0
+!   do iblock = 1, nblocks_clinic
+!      this_block = get_block(blocks_clinic(iblock),iblock)
+!      call ugrid_to_tgrid(WORK3,SBUFF_SUM(:,:,iblock,index_o2x_So_dhdx),iblock)
+!      call ugrid_to_tgrid(WORK4,SBUFF_SUM(:,:,iblock,index_o2x_So_dhdy),iblock)
+! 
+!      WORK1 = (WORK3*cos(ANGLET(:,:,iblock)) + WORK4*sin(-ANGLET(:,:,iblock)))  &amp;
+!              /grav/tlast_coupled
+!      WORK2 = (WORK4*cos(ANGLET(:,:,iblock)) - WORK3*sin(-ANGLET(:,:,iblock)))  &amp;
+!              /grav/tlast_coupled
+!
+!      do j=this_block%jb,this_block%je
+!      do i=this_block%ib,this_block%ie
+!         n = n + 1
+!         o2x_o%rAttr(index_o2x_So_dhdx,n) = WORK1(i,j)
+!         o2x_o%rAttr(index_o2x_So_dhdy,n) = WORK2(i,j)
+!      enddo
+!      enddo
+!   enddo
+!
+!!-----------------------------------------------------------------------
+!!
+!!     pack heat flux due to freezing/melting (W/m^2)
+!!     QFLUX computation and units conversion occurs in ice.F
+!!
+!!-----------------------------------------------------------------------
+!
+!   n = 0
+!   do iblock = 1, nblocks_clinic
+!      this_block = get_block(blocks_clinic(iblock),iblock)
+!      do j=this_block%jb,this_block%je
+!      do i=this_block%ib,this_block%ie
+!         n = n + 1
+!         o2x_o%rAttr(index_o2x_Fioo_q,n) = QFLUX(i,j,iblock)
+!      enddo
+!      enddo
+!   enddo
+!
+!   tlast_ice = c0
+!   AQICE     = c0
+!   QICE      = c0
+!
+!!-----------------------------------------------------------------------
+!!
+!!     pack co2 flux, if requested (kg CO2/m^2/s)
+!!     units conversion occurs where co2 flux is computed
+!!
+!!-----------------------------------------------------------------------
+!
+!   if (index_o2x_Faoo_fco2_ocn &gt; 0) then
+!      n = 0
+!      do iblock = 1, nblocks_clinic
+!         this_block = get_block(blocks_clinic(iblock),iblock)
+!         do j=this_block%jb,this_block%je
+!         do i=this_block%ib,this_block%ie
+!            n = n + 1
+!            o2x_o%rAttr(index_o2x_Faoo_fco2_ocn,n) = &amp;
+!               SBUFF_SUM(i,j,iblock,index_o2x_Faoo_fco2_ocn)/tlast_coupled
+!         enddo
+!         enddo
+!      enddo
+!   endif
+!
+!!-----------------------------------------------------------------------
+!!
+!!     diagnostics
+!!
+!!-----------------------------------------------------------------------
+!
+!   if (ldiag_cpl) then
+!      call ccsm_char_date_and_time
+!!DEBUG      write(message,'(6a,1x,5a)')' Global averages of fluxes sent to cpl at ', &amp;
+!!DEBUG           cyear,'/',cmonth, '/',cday,  chour,':',cminute,':',csecond
+!!DEBUG      call document ('pop_send_to_coupler', message)
+!      write(stdout,*)'pop_send_to_coupler'
+!
+!      m2percm2  = mpercm*mpercm
+!      do k = 1,nsend
+!        n = 0
+!        do iblock = 1, nblocks_clinic
+!           this_block = get_block(blocks_clinic(iblock),iblock)
+!           do j=this_block%jb,this_block%je
+!           do i=this_block%ib,this_block%ie
+!              n = n + 1
+!              WORKA(i,j,iblock) = o2x_o%rAttr(k,n)
+!           enddo
+!           enddo
+!        enddo
+!
+!        call POP_HaloUpdate(WORKA,POP_haloClinic,          &amp;
+!                       POP_gridHorzLocCenter,          &amp;
+!                       POP_fieldKindScalar, errorCode, &amp;
+!                       fillValue = 0.0_POP_r8)
+!       
+!         if (errorCode /= POP_Success) then
+!            call POP_ErrorSet(errorCode, &amp;
+!               'ocn_export_mct: error updating halo for state')
+!            return
+!         endif
+!
+!        gsum = global_sum_prod(WORKA , TAREA, distrb_clinic, &amp;
+!                                   field_loc_center, RCALCT)*m2percm2
+!        if (my_task == master_task) then
+!           call seq_flds_getField(label,k,seq_flds_o2x_fields)
+!           write(stdout,1100)'ocn','send', label ,gsum
+!        endif
+!      enddo ! k
+!      if (my_task == master_task) call shr_sys_flush(stdout)
+!   endif
+!
+!1100 format ('comm_diag ', a3, 1x, a4, 1x, a8, 1x, es26.19:, 1x, a6)
+!    
+!    tlast_coupled = c0
+
+!-----------------------------------------------------------------------
+!EOC
+
+ end subroutine ocn_export_mct!}}}
+
+!***********************************************************************
+
+!BOP
+! !IROUTINE: pop_sum_buffer
+! !INTERFACE:
+
+ subroutine pop_sum_buffer!{{{
+
+! !DESCRIPTION:
+!  This routine accumulates sums for averaging fields to
+!  be sent to the coupler
+!
+! !REVISION HISTORY:
+!  same as module
+! 
+!EOP
+!BOC
+
+!#ifdef CCSMCOUPLED
+!!-----------------------------------------------------------------------
+!!
+!!  local variables
+!!
+!!-----------------------------------------------------------------------
+!
+!   real (r8), dimension(nx_block,ny_block,max_blocks_clinic) ::  &amp;
+!      WORK                ! local work arrays
+!
+!   real (r8) ::   &amp;
+!      delt,             &amp; ! time interval since last step
+!      delt_last           ! time interval for previous step
+!
+!   integer (int_kind) :: &amp;
+!      iblock,           &amp; ! block index
+!      sflux_co2_nf_ind = 0! named field index of fco2
+!
+!   logical (log_kind) :: &amp;
+!      first = .true.      ! only true for first call
+!
+!   save first
+!
+!!-----------------------------------------------------------------------
+!!
+!!  zero buffer if this is the first time after a coupling interval
+!!
+!!-----------------------------------------------------------------------
+!
+!   if (tlast_coupled == c0) SBUFF_SUM = c0
+!   WORK = c0
+!
+!!-----------------------------------------------------------------------
+!!
+!!  update time since last coupling
+!!
+!!-----------------------------------------------------------------------
+!
+!   if (avg_ts .or. back_to_back) then
+!      delt = p5*dtt
+!   else
+!      delt =    dtt
+!   endif
+!   tlast_coupled = tlast_coupled + delt
+!
+!!-----------------------------------------------------------------------
+!!
+!!  allow for fco2 field to not be registered on first call
+!!     because init_forcing is called before init_passive_tracers
+!!  use weight from previous timestep because flux used here is that
+!!     computed during the previous timestep
+!!
+!!-----------------------------------------------------------------------
+!
+!   if (index_o2x_Faoo_fco2_ocn &gt; 0) then
+!      if (sflux_co2_nf_ind == 0) then
+!         call named_field_get_index('SFLUX_CO2', sflux_co2_nf_ind, &amp;
+!                                    exit_on_err=.not. first)
+!      endif
+!
+!      if (avg_ts .or. back_to_back) then
+!         delt_last = p5*dtt
+!      else
+!         delt_last =    dtt
+!      endif
+!   endif
+!
+!!-----------------------------------------------------------------------
+!!
+!!  accumulate sums of U,V,T,S and GRADP
+!!  accumulate sum of co2 flux, if requested
+!!     implicitly use zero flux if fco2 field not registered yet
+!!  ice formation flux is handled separately in ice routine
+!!
+!!-----------------------------------------------------------------------
+!
+!   !$OMP PARALLEL DO PRIVATE(iblock)
+!   do iblock = 1, nblocks_clinic
+!   SBUFF_SUM(:,:,iblock,index_o2x_So_u) =   &amp;
+!      SBUFF_SUM(:,:,iblock,index_o2x_So_u) + delt*  &amp;
+!                                   UVEL(:,:,1,curtime,iblock)
+!
+!   SBUFF_SUM(:,:,iblock,index_o2x_So_v) =   &amp;
+!      SBUFF_SUM(:,:,iblock,index_o2x_So_v) + delt*  &amp;
+!                                   VVEL(:,:,1,curtime,iblock)
+!
+!   SBUFF_SUM(:,:,iblock,index_o2x_So_t ) =   &amp;
+!      SBUFF_SUM(:,:,iblock,index_o2x_So_t ) + delt*  &amp;
+!                                   TRACER(:,:,1,1,curtime,iblock)
+!
+!   SBUFF_SUM(:,:,iblock,index_o2x_So_s ) =   &amp;
+!      SBUFF_SUM(:,:,iblock,index_o2x_So_s ) + delt*  &amp;
+!                                   TRACER(:,:,1,2,curtime,iblock)
+!
+!   SBUFF_SUM(:,:,iblock,index_o2x_So_dhdx) =   &amp;
+!      SBUFF_SUM(:,:,iblock,index_o2x_So_dhdx) + delt*  &amp;
+!                                   GRADPX(:,:,curtime,iblock)
+!
+!   SBUFF_SUM(:,:,iblock,index_o2x_So_dhdy) =   &amp;
+!      SBUFF_SUM(:,:,iblock,index_o2x_So_dhdy) + delt*  &amp;
+!                                   GRADPY(:,:,curtime,iblock)
+!
+!   if (index_o2x_Faoo_fco2_ocn &gt; 0 .and. sflux_co2_nf_ind &gt; 0) then
+!      call named_field_get(sflux_co2_nf_ind, iblock, WORK(:,:,iblock))
+!      SBUFF_SUM(:,:,iblock,index_o2x_Faoo_fco2_ocn) = &amp;
+!         SBUFF_SUM(:,:,iblock,index_o2x_Faoo_fco2_ocn) + delt_last*WORK(:,:,iblock)
+!   endif
+!
+!   enddo
+!   !$OMP END PARALLEL DO
+!
+!   first = .false.
+!
+!#endif
+!
+!-----------------------------------------------------------------------
+!EOC
+
+ end subroutine pop_sum_buffer!}}}

+!***********************************************************************
+
+end module ocn_comp_mct
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Modified: branches/atmos_physics/src/registry/Makefile
===================================================================
--- branches/atmos_physics/src/registry/Makefile        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/registry/Makefile        2013-03-26 23:03:26 UTC (rev 2670)
@@ -1,9 +1,12 @@
 .SUFFIXES: .c .o
 
-OBJS = parse.o dictionary.o gen_inc.o fortprintf.o
+OBJS = parse.o dictionary.o gen_inc.o fortprintf.o ezxml/ezxml.o
 
 all: parse
 
+ezxml/ezxml.o:
+        (cd ezxml; $(CC) -c ezxml.c)
+
 parse: $(OBJS)
         $(CC) -o $@ $(OBJS)
 

Copied: branches/atmos_physics/src/registry/Registry.xsd (from rev 2666, trunk/mpas/src/registry/Registry.xsd)
===================================================================
--- branches/atmos_physics/src/registry/Registry.xsd                                (rev 0)
+++ branches/atmos_physics/src/registry/Registry.xsd        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,119 @@
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
+&lt;xs:schema xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;  elementFormDefault=&quot;qualified&quot;  attributeFormDefault=&quot;unqualified&quot; &gt;
+        &lt;xs:element name=&quot;registry&quot; &gt;
+                &lt;xs:complexType&gt;
+                        &lt;xs:sequence&gt;
+                                &lt;!-- The dims element contains all dimensions --&gt;
+                                &lt;xs:element name=&quot;dims&quot; &gt;
+                                        &lt;xs:complexType&gt;
+                                                &lt;xs:sequence&gt;
+                                                        &lt;!-- Each dimension is an independent child of the &lt;dims&gt;&lt;/dims&gt; element. --&gt;
+                                                        &lt;xs:element name=&quot;dim&quot;  maxOccurs=&quot;unbounded&quot; &gt;
+                                                                &lt;xs:complexType&gt;
+                                                                        &lt;!-- The name attribute should specify the name of the dimension. --&gt;
+                                                                        &lt;xs:attribute name=&quot;name&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                                                        &lt;!-- The definition attribute is used to define a dimension based on other pre-defined dimensions --&gt;
+                                                                        &lt;xs:attribute name=&quot;definition&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                        &lt;!-- The units attribute defines the units of the dimension. --&gt;
+                                                                        &lt;xs:attribute name=&quot;units&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                        &lt;!-- The description attribute describes the dimensions. --&gt;
+                                                                        &lt;xs:attribute name=&quot;description&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                &lt;/xs:complexType&gt;
+                                                        &lt;/xs:element&gt;
+                                                &lt;/xs:sequence&gt;
+                                        &lt;/xs:complexType&gt;
+                                &lt;/xs:element&gt;
+                                &lt;!-- The nml_record element contains all namelist options for a particular namelist record --&gt;
+                                &lt;xs:element name=&quot;nml_record&quot;  maxOccurs=&quot;unbounded&quot; &gt;
+                                        &lt;xs:complexType&gt;
+                                                &lt;xs:sequence&gt;
+                                                        &lt;!-- The nml_option element defines a particular namelist option that lives within the defined nml_record --&gt;
+                                                        &lt;xs:element name=&quot;nml_option&quot;  maxOccurs=&quot;unbounded&quot; &gt;
+                                                                &lt;xs:complexType&gt;
+                                                                        &lt;!-- The name attribute defines the name of the namelist option. This is how it would look in a namelist file. --&gt;
+                                                                        &lt;xs:attribute name=&quot;name&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                                                        &lt;!-- The type attribute defines the type of the particular namelist option. Options are real, integer, character, and logical. --&gt;
+                                                                        &lt;xs:attribute name=&quot;type&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                                                        &lt;!-- The default_value attribute defines the default value of the namelist option. This is used if the option is omitted from a namelist file. --&gt;
+                                                                        &lt;xs:attribute name=&quot;default_value&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                                                        &lt;!-- The units attribute defines the units for the particular namelist option. --&gt;
+                                                                        &lt;xs:attribute name=&quot;units&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                        &lt;!-- The description attribute describes the namelist option. --&gt;
+                                                                        &lt;xs:attribute name=&quot;description&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                        &lt;!-- The possible_values attribute defines what values are allowable for the namelist option. --&gt;
+                                                                        &lt;xs:attribute name=&quot;possible_values&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                &lt;/xs:complexType&gt;
+                                                        &lt;/xs:element&gt;
+                                                &lt;/xs:sequence&gt;
+                                                &lt;!-- The name attribute defines the name of the namelist record. This would be seen as &amp;name in the actual namelist. --&gt;
+                                                &lt;xs:attribute name=&quot;name&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                        &lt;/xs:complexType&gt;
+                                &lt;/xs:element&gt;
+                                &lt;!-- The var_struct element defines a grouping of variables. This is similar to mesh, or state and lives at the domain % blocklist level. --&gt;
+                                &lt;xs:element name=&quot;var_struct&quot;  maxOccurs=&quot;unbounded&quot; &gt;
+                                        &lt;xs:complexType&gt;
+                                                &lt;xs:sequence&gt;
+                                                        &lt;!-- The var_array element defines an array of variables. 
+                                                                 Within the code all constituent variables are merged into a one higher dimension array, for ease of use.
+                                                                 When written to the output file, they will be named their individual names. --&gt;
+                                                        &lt;xs:element name=&quot;var_array&quot; maxOccurs=&quot;unbounded&quot; minOccurs=&quot;0&quot; &gt;
+                                                                &lt;xs:complexType&gt;
+                                                                        &lt;xs:sequence&gt;
+                                                                                &lt;!-- This specific var element defines a variable that is a constituent to a particular var_array group. --&gt;
+                                                                                &lt;xs:element name=&quot;var&quot;  maxOccurs=&quot;unbounded&quot; minOccurs=&quot;0&quot; &gt;
+                                                                                        &lt;xs:complexType&gt;
+                                                                                                &lt;!-- The name attribute is the name of the variable. This how it will be displayed in the output file. --&gt;
+                                                                                                &lt;xs:attribute name=&quot;name&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                                                                                &lt;!-- The array_group attribute is used to group variables within the var_array for ease of use. --&gt;
+                                                                                                &lt;xs:attribute name=&quot;array_group&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                                                                                &lt;!-- The streams attribute defines the streams this variable is included in. Allowable values are omitted, i, r, o and any combination of i, r, and o. --&gt;
+                                                                                                &lt;xs:attribute name=&quot;streams&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                                                &lt;!-- The name_in_code attribute defines the name of the variable in the code, if it should be different then in the input/output/restart streams. --&gt;
+                                                                                                &lt;xs:attribute name=&quot;name_in_code&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                                                &lt;!-- The units attribute defines the units of the particular variable --&gt;
+                                                                                                &lt;xs:attribute name=&quot;units&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                                                &lt;!-- The description attribute describes the particular variable --&gt;
+                                                                                                &lt;xs:attribute name=&quot;description&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                                        &lt;/xs:complexType&gt;
+                                                                                &lt;/xs:element&gt;
+                                                                        &lt;/xs:sequence&gt;
+                                                                        &lt;!-- The name attribute is the name of the var_array that will be seen in the code. --&gt;
+                                                                        &lt;xs:attribute name=&quot;name&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                                                        &lt;!-- The type attribute defines the type of all constituents for the var_array. Valid options are real, integer, logical, and character --&gt;
+                                                                        &lt;xs:attribute name=&quot;type&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                                                        &lt;!-- The dimensions attribute defines the dimensions of each individual constituent. This does not include the collapsed dimension. --&gt;
+                                                                        &lt;xs:attribute name=&quot;dimensions&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                                                        &lt;!-- The persistence attribute determines if the var_array is persistence or scratch. Valid options are persistent, and scratch. --&gt;
+                                                                        &lt;xs:attribute name=&quot;persistence&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                &lt;/xs:complexType&gt;
+                                                        &lt;/xs:element&gt;
+                                                        &lt;!-- This var element defines a variable that does not live within a var_array group. --&gt;
+                                                        &lt;xs:element name=&quot;var&quot;  maxOccurs=&quot;unbounded&quot; minOccurs=&quot;0&quot; &gt;
+                                                                &lt;xs:complexType&gt;
+                                                                        &lt;!-- The name attribute defines the name in the NetCDF files of this variable. --&gt;
+                                                                        &lt;xs:attribute name=&quot;name&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                                                        &lt;!-- The type attribute defines the type within MPAS of the variable. --&gt;
+                                                                        &lt;xs:attribute name=&quot;type&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                                                        &lt;!-- The dimensions attribute defines the dimensions of the variable. --&gt;
+                                                                        &lt;xs:attribute name=&quot;dimensions&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                                                        &lt;!-- The streams attribute defines the streams this variable is included in. --&gt;
+                                                                        &lt;xs:attribute name=&quot;streams&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                        &lt;!-- The name_in_code attribute defines the name of the variable within MPAS (if different from name). --&gt;
+                                                                        &lt;xs:attribute name=&quot;name_in_code&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                        &lt;!-- The units attribute defines the units of the variable. --&gt;
+                                                                        &lt;xs:attribute name=&quot;units&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                        &lt;!-- The description attribute provides a brief description of the variable. --&gt;
+                                                                        &lt;xs:attribute name=&quot;description&quot;  type=&quot;xs:string&quot; use=&quot;optional&quot;/&gt;
+                                                                &lt;/xs:complexType&gt;
+                                                        &lt;/xs:element&gt;
+                                                &lt;/xs:sequence&gt;
+                                                &lt;!-- The name attribute defines the name of the var_struct. This would be similar to mesh, or state. --&gt;
+                                                &lt;xs:attribute name=&quot;name&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                                &lt;!-- The time_levs attribute defines the number of time levels this var_struct contains. --&gt;
+                                                &lt;xs:attribute name=&quot;time_levs&quot;  type=&quot;xs:int&quot; use=&quot;required&quot;/&gt;
+                                        &lt;/xs:complexType&gt;
+                                &lt;/xs:element&gt;
+                        &lt;/xs:sequence&gt;
+                &lt;/xs:complexType&gt;
+        &lt;/xs:element&gt;
+&lt;/xs:schema&gt;

Deleted: branches/atmos_physics/src/registry/ezxml/ezxml.c
===================================================================
--- trunk/mpas/src/registry/ezxml/ezxml.c        2013-03-25 16:55:55 UTC (rev 2666)
+++ branches/atmos_physics/src/registry/ezxml/ezxml.c        2013-03-26 23:03:26 UTC (rev 2670)
@@ -1,1015 +0,0 @@
-/* ezxml.c
- *
- * Copyright 2004-2006 Aaron Voisine &lt;aaron@voisine.org&gt;
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * &quot;Software&quot;), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include &lt;stdlib.h&gt;
-#include &lt;stdio.h&gt;
-#include &lt;stdarg.h&gt;
-#include &lt;string.h&gt;
-#include &lt;ctype.h&gt;
-#include &lt;unistd.h&gt;
-#include &lt;sys/types.h&gt;
-#ifndef EZXML_NOMMAP
-#include &lt;sys/mman.h&gt;
-#endif // EZXML_NOMMAP
-#include &lt;sys/stat.h&gt;
-#include &quot;ezxml.h&quot;
-
-#define EZXML_WS   &quot;\t\r</font>
<font color="red"> &quot;  // whitespace
-#define EZXML_ERRL 128        // maximum error string length
-
-typedef struct ezxml_root *ezxml_root_t;
-struct ezxml_root {       // additional data for the root tag
-    struct ezxml xml;     // is a super-struct built on top of ezxml struct
-    ezxml_t cur;          // current xml tree insertion point
-    char *m;              // original xml string
-    size_t len;           // length of allocated memory for mmap, -1 for malloc
-    char *u;              // UTF-8 conversion of string if original was UTF-16
-    char *s;              // start of work area
-    char *e;              // end of work area
-    char **ent;           // general entities (ampersand sequences)
-    char ***attr;         // default attributes
-    char ***pi;           // processing instructions
-    short standalone;     // non-zero if &lt;?xml standalone=&quot;yes&quot;?&gt;
-    char err[EZXML_ERRL]; // error string
-};
-
-char *EZXML_NIL[] = { NULL }; // empty, null terminated array of strings
-
-// returns the first child tag with the given name or NULL if not found
-ezxml_t ezxml_child(ezxml_t xml, const char *name)
-{
-    xml = (xml) ? xml-&gt;child : NULL;
-    while (xml &amp;&amp; strcmp(name, xml-&gt;name)) xml = xml-&gt;sibling;
-    return xml;
-}
-
-// returns the Nth tag with the same name in the same subsection or NULL if not
-// found
-ezxml_t ezxml_idx(ezxml_t xml, int idx)
-{
-    for (; xml &amp;&amp; idx; idx--) xml = xml-&gt;next;
-    return xml;
-}
-
-// returns the value of the requested tag attribute or NULL if not found
-const char *ezxml_attr(ezxml_t xml, const char *attr)
-{
-    int i = 0, j = 1;
-    ezxml_root_t root = (ezxml_root_t)xml;
-
-    if (! xml || ! xml-&gt;attr) return NULL;
-    while (xml-&gt;attr[i] &amp;&amp; strcmp(attr, xml-&gt;attr[i])) i += 2;
-    if (xml-&gt;attr[i]) return xml-&gt;attr[i + 1]; // found attribute
-
-    while (root-&gt;xml.parent) root = (ezxml_root_t)root-&gt;xml.parent; // root tag
-    for (i = 0; root-&gt;attr[i] &amp;&amp; strcmp(xml-&gt;name, root-&gt;attr[i][0]); i++);
-    if (! root-&gt;attr[i]) return NULL; // no matching default attributes
-    while (root-&gt;attr[i][j] &amp;&amp; strcmp(attr, root-&gt;attr[i][j])) j += 3;
-    return (root-&gt;attr[i][j]) ? root-&gt;attr[i][j + 1] : NULL; // found default
-}
-
-// same as ezxml_get but takes an already initialized va_list
-ezxml_t ezxml_vget(ezxml_t xml, va_list ap)
-{
-    char *name = va_arg(ap, char *);
-    int idx = -1;
-
-    if (name &amp;&amp; *name) {
-        idx = va_arg(ap, int);    
-        xml = ezxml_child(xml, name);
-    }
-    return (idx &lt; 0) ? xml : ezxml_vget(ezxml_idx(xml, idx), ap);
-}
-
-// Traverses the xml tree to retrieve a specific subtag. Takes a variable
-// length list of tag names and indexes. The argument list must be terminated
-// by either an index of -1 or an empty string tag name. Example: 
-// title = ezxml_get(library, &quot;shelf&quot;, 0, &quot;book&quot;, 2, &quot;title&quot;, -1);
-// This retrieves the title of the 3rd book on the 1st shelf of library.
-// Returns NULL if not found.
-ezxml_t ezxml_get(ezxml_t xml, ...)
-{
-    va_list ap;
-    ezxml_t r;
-
-    va_start(ap, xml);
-    r = ezxml_vget(xml, ap);
-    va_end(ap);
-    return r;
-}
-
-// returns a null terminated array of processing instructions for the given
-// target
-const char **ezxml_pi(ezxml_t xml, const char *target)
-{
-    ezxml_root_t root = (ezxml_root_t)xml;
-    int i = 0;
-
-    if (! root) return (const char **)EZXML_NIL;
-    while (root-&gt;xml.parent) root = (ezxml_root_t)root-&gt;xml.parent; // root tag
-    while (root-&gt;pi[i] &amp;&amp; strcmp(target, root-&gt;pi[i][0])) i++; // find target
-    return (const char **)((root-&gt;pi[i]) ? root-&gt;pi[i] + 1 : EZXML_NIL);
-}
-
-// set an error string and return root
-ezxml_t ezxml_err(ezxml_root_t root, char *s, const char *err, ...)
-{
-    va_list ap;
-    int line = 1;
-    char *t, fmt[EZXML_ERRL];
-    
-    for (t = root-&gt;s; t &lt; s; t++) if (*t == '</font>
<font color="red">') line++;
-    snprintf(fmt, EZXML_ERRL, &quot;[error near line %d]: %s&quot;, line, err);
-
-    va_start(ap, err);
-    vsnprintf(root-&gt;err, EZXML_ERRL, fmt, ap);
-    va_end(ap);
-
-    return &amp;root-&gt;xml;
-}
-
-// Recursively decodes entity and character references and normalizes new lines
-// ent is a null terminated array of alternating entity names and values. set t
-// to '&amp;' for general entity decoding, '%' for parameter entity decoding, 'c'
-// for cdata sections, ' ' for attribute normalization, or '*' for non-cdata
-// attribute normalization. Returns s, or if the decoded string is longer than
-// s, returns a malloced string that must be freed.
-char *ezxml_decode(char *s, char **ent, char t)
-{
-    char *e, *r = s, *m = s;
-    long b, c, d, l;
-
-    for (; *s; s++) { // normalize line endings
-        while (*s == '\r') {
-            *(s++) = '</font>
<font color="red">';
-            if (*s == '</font>
<font color="red">') memmove(s, (s + 1), strlen(s));
-        }
-    }
-    
-    for (s = r; ; ) {
-        while (*s &amp;&amp; *s != '&amp;' &amp;&amp; (*s != '%' || t != '%') &amp;&amp; !isspace(*s)) s++;
-
-        if (! *s) break;
-        else if (t != 'c' &amp;&amp; ! strncmp(s, &quot;&amp;#&quot;, 2)) { // character reference
-            if (s[2] == 'x') c = strtol(s + 3, &amp;e, 16); // base 16
-            else c = strtol(s + 2, &amp;e, 10); // base 10
-            if (! c || *e != ';') { s++; continue; } // not a character ref
-
-            if (c &lt; 0x80) *(s++) = c; // US-ASCII subset
-            else { // multi-byte UTF-8 sequence
-                for (b = 0, d = c; d; d /= 2) b++; // number of bits in c
-                b = (b - 2) / 5; // number of bytes in payload
-                *(s++) = (0xFF &lt;&lt; (7 - b)) | (c &gt;&gt; (6 * b)); // head
-                while (b) *(s++) = 0x80 | ((c &gt;&gt; (6 * --b)) &amp; 0x3F); // payload
-            }
-
-            memmove(s, strchr(s, ';') + 1, strlen(strchr(s, ';')));
-        }
-        else if ((*s == '&amp;' &amp;&amp; (t == '&amp;' || t == ' ' || t == '*')) ||
-                 (*s == '%' &amp;&amp; t == '%')) { // entity reference
-            for (b = 0; ent[b] &amp;&amp; strncmp(s + 1, ent[b], strlen(ent[b]));
-                 b += 2); // find entity in entity list
-
-            if (ent[b++]) { // found a match
-                if ((c = strlen(ent[b])) - 1 &gt; (e = strchr(s, ';')) - s) {
-                    l = (d = (s - r)) + c + strlen(e); // new length
-                    r = (r == m) ? strcpy(malloc(l), r) : realloc(r, l);
-                    e = strchr((s = r + d), ';'); // fix up pointers
-                }
-
-                memmove(s + c, e + 1, strlen(e)); // shift rest of string
-                strncpy(s, ent[b], c); // copy in replacement text
-            }
-            else s++; // not a known entity
-        }
-        else if ((t == ' ' || t == '*') &amp;&amp; isspace(*s)) *(s++) = ' ';
-        else s++; // no decoding needed
-    }
-
-    if (t == '*') { // normalize spaces for non-cdata attributes
-        for (s = r; *s; s++) {
-            if ((l = strspn(s, &quot; &quot;))) memmove(s, s + l, strlen(s + l) + 1);
-            while (*s &amp;&amp; *s != ' ') s++;
-        }
-        if (--s &gt;= r &amp;&amp; *s == ' ') *s = '\0'; // trim any trailing space
-    }
-    return r;
-}
-
-// called when parser finds start of new tag
-void ezxml_open_tag(ezxml_root_t root, char *name, char **attr)
-{
-    ezxml_t xml = root-&gt;cur;
-    
-    if (xml-&gt;name) xml = ezxml_add_child(xml, name, strlen(xml-&gt;txt));
-    else xml-&gt;name = name; // first open tag
-
-    xml-&gt;attr = attr;
-    root-&gt;cur = xml; // update tag insertion point
-}
-
-// called when parser finds character content between open and closing tag
-void ezxml_char_content(ezxml_root_t root, char *s, size_t len, char t)
-{
-    ezxml_t xml = root-&gt;cur;
-    char *m = s;
-    size_t l;
-
-    if (! xml || ! xml-&gt;name || ! len) return; // sanity check
-
-    s[len] = '\0'; // null terminate text (calling functions anticipate this)
-    len = strlen(s = ezxml_decode(s, root-&gt;ent, t)) + 1;
-
-    if (! *(xml-&gt;txt)) xml-&gt;txt = s; // initial character content
-    else { // allocate our own memory and make a copy
-        xml-&gt;txt = (xml-&gt;flags &amp; EZXML_TXTM) // allocate some space
-                   ? realloc(xml-&gt;txt, (l = strlen(xml-&gt;txt)) + len)
-                   : strcpy(malloc((l = strlen(xml-&gt;txt)) + len), xml-&gt;txt);
-        strcpy(xml-&gt;txt + l, s); // add new char content
-        if (s != m) free(s); // free s if it was malloced by ezxml_decode()
-    }
-
-    if (xml-&gt;txt != m) ezxml_set_flag(xml, EZXML_TXTM);
-}
-
-// called when parser finds closing tag
-ezxml_t ezxml_close_tag(ezxml_root_t root, char *name, char *s)
-{
-    if (! root-&gt;cur || ! root-&gt;cur-&gt;name || strcmp(name, root-&gt;cur-&gt;name))
-        return ezxml_err(root, s, &quot;unexpected closing tag &lt;/%s&gt;&quot;, name);
-
-    root-&gt;cur = root-&gt;cur-&gt;parent;
-    return NULL;
-}
-
-// checks for circular entity references, returns non-zero if no circular
-// references are found, zero otherwise
-int ezxml_ent_ok(char *name, char *s, char **ent)
-{
-    int i;
-
-    for (; ; s++) {
-        while (*s &amp;&amp; *s != '&amp;') s++; // find next entity reference
-        if (! *s) return 1;
-        if (! strncmp(s + 1, name, strlen(name))) return 0; // circular ref.
-        for (i = 0; ent[i] &amp;&amp; strncmp(ent[i], s + 1, strlen(ent[i])); i += 2);
-        if (ent[i] &amp;&amp; ! ezxml_ent_ok(name, ent[i + 1], ent)) return 0;
-    }
-}
-
-// called when the parser finds a processing instruction
-void ezxml_proc_inst(ezxml_root_t root, char *s, size_t len)
-{
-    int i = 0, j = 1;
-    char *target = s;
-
-    s[len] = '\0'; // null terminate instruction
-    if (*(s += strcspn(s, EZXML_WS))) {
-        *s = '\0'; // null terminate target
-        s += strspn(s + 1, EZXML_WS) + 1; // skip whitespace after target
-    }
-
-    if (! strcmp(target, &quot;xml&quot;)) { // &lt;?xml ... ?&gt;
-        if ((s = strstr(s, &quot;standalone&quot;)) &amp;&amp; ! strncmp(s + strspn(s + 10,
-            EZXML_WS &quot;='\&quot;&quot;) + 10, &quot;yes&quot;, 3)) root-&gt;standalone = 1;
-        return;
-    }
-
-    if (! root-&gt;pi[0]) *(root-&gt;pi = malloc(sizeof(char **))) = NULL; //first pi
-
-    while (root-&gt;pi[i] &amp;&amp; strcmp(target, root-&gt;pi[i][0])) i++; // find target
-    if (! root-&gt;pi[i]) { // new target
-        root-&gt;pi = realloc(root-&gt;pi, sizeof(char **) * (i + 2));
-        root-&gt;pi[i] = malloc(sizeof(char *) * 3);
-        root-&gt;pi[i][0] = target;
-        root-&gt;pi[i][1] = (char *)(root-&gt;pi[i + 1] = NULL); // terminate pi list
-        root-&gt;pi[i][2] = strdup(&quot;&quot;); // empty document position list
-    }
-
-    while (root-&gt;pi[i][j]) j++; // find end of instruction list for this target
-    root-&gt;pi[i] = realloc(root-&gt;pi[i], sizeof(char *) * (j + 3));
-    root-&gt;pi[i][j + 2] = realloc(root-&gt;pi[i][j + 1], j + 1);
-    strcpy(root-&gt;pi[i][j + 2] + j - 1, (root-&gt;xml.name) ? &quot;&gt;&quot; : &quot;&lt;&quot;);
-    root-&gt;pi[i][j + 1] = NULL; // null terminate pi list for this target
-    root-&gt;pi[i][j] = s; // set instruction
-}
-
-// called when the parser finds an internal doctype subset
-short ezxml_internal_dtd(ezxml_root_t root, char *s, size_t len)
-{
-    char q, *c, *t, *n = NULL, *v, **ent, **pe;
-    int i, j;
-    
-    pe = memcpy(malloc(sizeof(EZXML_NIL)), EZXML_NIL, sizeof(EZXML_NIL));
-
-    for (s[len] = '\0'; s; ) {
-        while (*s &amp;&amp; *s != '&lt;' &amp;&amp; *s != '%') s++; // find next declaration
-
-        if (! *s) break;
-        else if (! strncmp(s, &quot;&lt;!ENTITY&quot;, 8)) { // parse entity definitions
-            c = s += strspn(s + 8, EZXML_WS) + 8; // skip white space separator
-            n = s + strspn(s, EZXML_WS &quot;%&quot;); // find name
-            *(s = n + strcspn(n, EZXML_WS)) = ';'; // append ; to name
-
-            v = s + strspn(s + 1, EZXML_WS) + 1; // find value
-            if ((q = *(v++)) != '&quot;' &amp;&amp; q != '\'') { // skip externals
-                s = strchr(s, '&gt;');
-                continue;
-            }
-
-            for (i = 0, ent = (*c == '%') ? pe : root-&gt;ent; ent[i]; i++);
-            ent = realloc(ent, (i + 3) * sizeof(char *)); // space for next ent
-            if (*c == '%') pe = ent;
-            else root-&gt;ent = ent;
-
-            *(++s) = '\0'; // null terminate name
-            if ((s = strchr(v, q))) *(s++) = '\0'; // null terminate value
-            ent[i + 1] = ezxml_decode(v, pe, '%'); // set value
-            ent[i + 2] = NULL; // null terminate entity list
-            if (! ezxml_ent_ok(n, ent[i + 1], ent)) { // circular reference
-                if (ent[i + 1] != v) free(ent[i + 1]);
-                ezxml_err(root, v, &quot;circular entity declaration &amp;%s&quot;, n);
-                break;
-            }
-            else ent[i] = n; // set entity name
-        }
-        else if (! strncmp(s, &quot;&lt;!ATTLIST&quot;, 9)) { // parse default attributes
-            t = s + strspn(s + 9, EZXML_WS) + 9; // skip whitespace separator
-            if (! *t) { ezxml_err(root, t, &quot;unclosed &lt;!ATTLIST&quot;); break; }
-            if (*(s = t + strcspn(t, EZXML_WS &quot;&gt;&quot;)) == '&gt;') continue;
-            else *s = '\0'; // null terminate tag name
-            for (i = 0; root-&gt;attr[i] &amp;&amp; strcmp(n, root-&gt;attr[i][0]); i++);
-
-            while (*(n = ++s + strspn(s, EZXML_WS)) &amp;&amp; *n != '&gt;') {
-                if (*(s = n + strcspn(n, EZXML_WS))) *s = '\0'; // attr name
-                else { ezxml_err(root, t, &quot;malformed &lt;!ATTLIST&quot;); break; }
-
-                s += strspn(s + 1, EZXML_WS) + 1; // find next token
-                c = (strncmp(s, &quot;CDATA&quot;, 5)) ? &quot;*&quot; : &quot; &quot;; // is it cdata?
-                if (! strncmp(s, &quot;NOTATION&quot;, 8))
-                    s += strspn(s + 8, EZXML_WS) + 8;
-                s = (*s == '(') ? strchr(s, ')') : s + strcspn(s, EZXML_WS);
-                if (! s) { ezxml_err(root, t, &quot;malformed &lt;!ATTLIST&quot;); break; }
-
-                s += strspn(s, EZXML_WS &quot;)&quot;); // skip white space separator
-                if (! strncmp(s, &quot;#FIXED&quot;, 6))
-                    s += strspn(s + 6, EZXML_WS) + 6;
-                if (*s == '#') { // no default value
-                    s += strcspn(s, EZXML_WS &quot;&gt;&quot;) - 1;
-                    if (*c == ' ') continue; // cdata is default, nothing to do
-                    v = NULL;
-                }
-                else if ((*s == '&quot;' || *s == '\'')  &amp;&amp;  // default value
-                         (s = strchr(v = s + 1, *s))) *s = '\0';
-                else { ezxml_err(root, t, &quot;malformed &lt;!ATTLIST&quot;); break; }
-
-                if (! root-&gt;attr[i]) { // new tag name
-                    root-&gt;attr = (! i) ? malloc(2 * sizeof(char **))
-                                       : realloc(root-&gt;attr,
-                                                 (i + 2) * sizeof(char **));
-                    root-&gt;attr[i] = malloc(2 * sizeof(char *));
-                    root-&gt;attr[i][0] = t; // set tag name
-                    root-&gt;attr[i][1] = (char *)(root-&gt;attr[i + 1] = NULL);
-                }
-
-                for (j = 1; root-&gt;attr[i][j]; j += 3); // find end of list
-                root-&gt;attr[i] = realloc(root-&gt;attr[i],
-                                        (j + 4) * sizeof(char *));
-
-                root-&gt;attr[i][j + 3] = NULL; // null terminate list
-                root-&gt;attr[i][j + 2] = c; // is it cdata?
-                root-&gt;attr[i][j + 1] = (v) ? ezxml_decode(v, root-&gt;ent, *c)
-                                           : NULL;
-                root-&gt;attr[i][j] = n; // attribute name 
-            }
-        }
-        else if (! strncmp(s, &quot;&lt;!--&quot;, 4)) s = strstr(s + 4, &quot;--&gt;&quot;); // comments
-        else if (! strncmp(s, &quot;&lt;?&quot;, 2)) { // processing instructions
-            if ((s = strstr(c = s + 2, &quot;?&gt;&quot;)))
-                ezxml_proc_inst(root, c, s++ - c);
-        }
-        else if (*s == '&lt;') s = strchr(s, '&gt;'); // skip other declarations
-        else if (*(s++) == '%' &amp;&amp; ! root-&gt;standalone) break;
-    }
-
-    free(pe);
-    return ! *root-&gt;err;
-}
-
-// Converts a UTF-16 string to UTF-8. Returns a new string that must be freed
-// or NULL if no conversion was needed.
-char *ezxml_str2utf8(char **s, size_t *len)
-{
-    char *u;
-    size_t l = 0, sl, max = *len;
-    long c, d;
-    int b, be = (**s == '\xFE') ? 1 : (**s == '\xFF') ? 0 : -1;
-
-    if (be == -1) return NULL; // not UTF-16
-
-    u = malloc(max);
-    for (sl = 2; sl &lt; *len - 1; sl += 2) {
-        c = (be) ? (((*s)[sl] &amp; 0xFF) &lt;&lt; 8) | ((*s)[sl + 1] &amp; 0xFF)  //UTF-16BE
-                 : (((*s)[sl + 1] &amp; 0xFF) &lt;&lt; 8) | ((*s)[sl] &amp; 0xFF); //UTF-16LE
-        if (c &gt;= 0xD800 &amp;&amp; c &lt;= 0xDFFF &amp;&amp; (sl += 2) &lt; *len - 1) { // high-half
-            d = (be) ? (((*s)[sl] &amp; 0xFF) &lt;&lt; 8) | ((*s)[sl + 1] &amp; 0xFF)
-                     : (((*s)[sl + 1] &amp; 0xFF) &lt;&lt; 8) | ((*s)[sl] &amp; 0xFF);
-            c = (((c &amp; 0x3FF) &lt;&lt; 10) | (d &amp; 0x3FF)) + 0x10000;
-        }
-
-        while (l + 6 &gt; max) u = realloc(u, max += EZXML_BUFSIZE);
-        if (c &lt; 0x80) u[l++] = c; // US-ASCII subset
-        else { // multi-byte UTF-8 sequence
-            for (b = 0, d = c; d; d /= 2) b++; // bits in c
-            b = (b - 2) / 5; // bytes in payload
-            u[l++] = (0xFF &lt;&lt; (7 - b)) | (c &gt;&gt; (6 * b)); // head
-            while (b) u[l++] = 0x80 | ((c &gt;&gt; (6 * --b)) &amp; 0x3F); // payload
-        }
-    }
-    return *s = realloc(u, *len = l);
-}
-
-// frees a tag attribute list
-void ezxml_free_attr(char **attr) {
-    int i = 0;
-    char *m;
-    
-    if (! attr || attr == EZXML_NIL) return; // nothing to free
-    while (attr[i]) i += 2; // find end of attribute list
-    m = attr[i + 1]; // list of which names and values are malloced
-    for (i = 0; m[i]; i++) {
-        if (m[i] &amp; EZXML_NAMEM) free(attr[i * 2]);
-        if (m[i] &amp; EZXML_TXTM) free(attr[(i * 2) + 1]);
-    }
-    free(m);
-    free(attr);
-}
-
-// parse the given xml string and return an ezxml structure
-ezxml_t ezxml_parse_str(char *s, size_t len)
-{
-    ezxml_root_t root = (ezxml_root_t)ezxml_new(NULL);
-    char q, e, *d, **attr, **a = NULL; // initialize a to avoid compile warning
-    int l, i, j;
-
-    root-&gt;m = s;
-    if (! len) return ezxml_err(root, NULL, &quot;root tag missing&quot;);
-    root-&gt;u = ezxml_str2utf8(&amp;s, &amp;len); // convert utf-16 to utf-8
-    root-&gt;e = (root-&gt;s = s) + len; // record start and end of work area
-    
-    e = s[len - 1]; // save end char
-    s[len - 1] = '\0'; // turn end char into null terminator
-
-    while (*s &amp;&amp; *s != '&lt;') s++; // find first tag
-    if (! *s) return ezxml_err(root, s, &quot;root tag missing&quot;);
-
-    for (; ; ) {
-        attr = (char **)EZXML_NIL;
-        d = ++s;
-        
-        if (isalpha(*s) || *s == '_' || *s == ':' || *s &lt; '\0') { // new tag
-            if (! root-&gt;cur)
-                return ezxml_err(root, d, &quot;markup outside of root element&quot;);
-
-            s += strcspn(s, EZXML_WS &quot;/&gt;&quot;);
-            while (isspace(*s)) *(s++) = '\0'; // null terminate tag name
-  
-            if (*s &amp;&amp; *s != '/' &amp;&amp; *s != '&gt;') // find tag in default attr list
-                for (i = 0; (a = root-&gt;attr[i]) &amp;&amp; strcmp(a[0], d); i++);
-
-            for (l = 0; *s &amp;&amp; *s != '/' &amp;&amp; *s != '&gt;'; l += 2) { // new attrib
-                attr = (l) ? realloc(attr, (l + 4) * sizeof(char *))
-                           : malloc(4 * sizeof(char *)); // allocate space
-                attr[l + 3] = (l) ? realloc(attr[l + 1], (l / 2) + 2)
-                                  : malloc(2); // mem for list of maloced vals
-                strcpy(attr[l + 3] + (l / 2), &quot; &quot;); // value is not malloced
-                attr[l + 2] = NULL; // null terminate list
-                attr[l + 1] = &quot;&quot;; // temporary attribute value
-                attr[l] = s; // set attribute name
-
-                s += strcspn(s, EZXML_WS &quot;=/&gt;&quot;);
-                if (*s == '=' || isspace(*s)) { 
-                    *(s++) = '\0'; // null terminate tag attribute name
-                    q = *(s += strspn(s, EZXML_WS &quot;=&quot;));
-                    if (q == '&quot;' || q == '\'') { // attribute value
-                        attr[l + 1] = ++s;
-                        while (*s &amp;&amp; *s != q) s++;
-                        if (*s) *(s++) = '\0'; // null terminate attribute val
-                        else {
-                            ezxml_free_attr(attr);
-                            return ezxml_err(root, d, &quot;missing %c&quot;, q);
-                        }
-
-                        for (j = 1; a &amp;&amp; a[j] &amp;&amp; strcmp(a[j], attr[l]); j +=3);
-                        attr[l + 1] = ezxml_decode(attr[l + 1], root-&gt;ent, (a
-                                                   &amp;&amp; a[j]) ? *a[j + 2] : ' ');
-                        if (attr[l + 1] &lt; d || attr[l + 1] &gt; s)
-                            attr[l + 3][l / 2] = EZXML_TXTM; // value malloced
-                    }
-                }
-                while (isspace(*s)) s++;
-            }
-
-            if (*s == '/') { // self closing tag
-                *(s++) = '\0';
-                if ((*s &amp;&amp; *s != '&gt;') || (! *s &amp;&amp; e != '&gt;')) {
-                    if (l) ezxml_free_attr(attr);
-                    return ezxml_err(root, d, &quot;missing &gt;&quot;);
-                }
-                ezxml_open_tag(root, d, attr);
-                ezxml_close_tag(root, d, s);
-            }
-            else if ((q = *s) == '&gt;' || (! *s &amp;&amp; e == '&gt;')) { // open tag
-                *s = '\0'; // temporarily null terminate tag name
-                ezxml_open_tag(root, d, attr);
-                *s = q;
-            }
-            else {
-                if (l) ezxml_free_attr(attr);
-                return ezxml_err(root, d, &quot;missing &gt;&quot;); 
-            }
-        }
-        else if (*s == '/') { // close tag
-            s += strcspn(d = s + 1, EZXML_WS &quot;&gt;&quot;) + 1;
-            if (! (q = *s) &amp;&amp; e != '&gt;') return ezxml_err(root, d, &quot;missing &gt;&quot;);
-            *s = '\0'; // temporarily null terminate tag name
-            if (ezxml_close_tag(root, d, s)) return &amp;root-&gt;xml;
-            if (isspace(*s = q)) s += strspn(s, EZXML_WS);
-        }
-        else if (! strncmp(s, &quot;!--&quot;, 3)) { // xml comment
-            if (! (s = strstr(s + 3, &quot;--&quot;)) || (*(s += 2) != '&gt;' &amp;&amp; *s) ||
-                (! *s &amp;&amp; e != '&gt;')) return ezxml_err(root, d, &quot;unclosed &lt;!--&quot;);
-        }
-        else if (! strncmp(s, &quot;![CDATA[&quot;, 8)) { // cdata
-            if ((s = strstr(s, &quot;]]&gt;&quot;)))
-                ezxml_char_content(root, d + 8, (s += 2) - d - 10, 'c');
-            else return ezxml_err(root, d, &quot;unclosed &lt;![CDATA[&quot;);
-        }
-        else if (! strncmp(s, &quot;!DOCTYPE&quot;, 8)) { // dtd
-            for (l = 0; *s &amp;&amp; ((! l &amp;&amp; *s != '&gt;') || (l &amp;&amp; (*s != ']' || 
-                 *(s + strspn(s + 1, EZXML_WS) + 1) != '&gt;')));
-                 l = (*s == '[') ? 1 : l) s += strcspn(s + 1, &quot;[]&gt;&quot;) + 1;
-            if (! *s &amp;&amp; e != '&gt;')
-                return ezxml_err(root, d, &quot;unclosed &lt;!DOCTYPE&quot;);
-            d = (l) ? strchr(d, '[') + 1 : d;
-            if (l &amp;&amp; ! ezxml_internal_dtd(root, d, s++ - d)) return &amp;root-&gt;xml;
-        }
-        else if (*s == '?') { // &lt;?...?&gt; processing instructions
-            do { s = strchr(s, '?'); } while (s &amp;&amp; *(++s) &amp;&amp; *s != '&gt;');
-            if (! s || (! *s &amp;&amp; e != '&gt;')) 
-                return ezxml_err(root, d, &quot;unclosed &lt;?&quot;);
-            else ezxml_proc_inst(root, d + 1, s - d - 2);
-        }
-        else return ezxml_err(root, d, &quot;unexpected &lt;&quot;);
-        
-        if (! s || ! *s) break;
-        *s = '\0';
-        d = ++s;
-        if (*s &amp;&amp; *s != '&lt;') { // tag character content
-            while (*s &amp;&amp; *s != '&lt;') s++;
-            if (*s) ezxml_char_content(root, d, s - d, '&amp;');
-            else break;
-        }
-        else if (! *s) break;
-    }
-
-    if (! root-&gt;cur) return &amp;root-&gt;xml;
-    else if (! root-&gt;cur-&gt;name) return ezxml_err(root, d, &quot;root tag missing&quot;);
-    else return ezxml_err(root, d, &quot;unclosed tag &lt;%s&gt;&quot;, root-&gt;cur-&gt;name);
-}
-
-// Wrapper for ezxml_parse_str() that accepts a file stream. Reads the entire
-// stream into memory and then parses it. For xml files, use ezxml_parse_file()
-// or ezxml_parse_fd()
-ezxml_t ezxml_parse_fp(FILE *fp)
-{
-    ezxml_root_t root;
-    size_t l, len = 0;
-    char *s;
-
-    if (! (s = malloc(EZXML_BUFSIZE))) return NULL;
-    do {
-        len += (l = fread((s + len), 1, EZXML_BUFSIZE, fp));
-        if (l == EZXML_BUFSIZE) s = realloc(s, len + EZXML_BUFSIZE);
-    } while (s &amp;&amp; l == EZXML_BUFSIZE);
-
-    if (! s) return NULL;
-    root = (ezxml_root_t)ezxml_parse_str(s, len);
-    root-&gt;len = -1; // so we know to free s in ezxml_free()
-    return &amp;root-&gt;xml;
-}
-
-// A wrapper for ezxml_parse_str() that accepts a file descriptor. First
-// attempts to mem map the file. Failing that, reads the file into memory.
-// Returns NULL on failure.
-ezxml_t ezxml_parse_fd(int fd)
-{
-    ezxml_root_t root;
-    struct stat st;
-    size_t l;
-    void *m;
-
-    if (fd &lt; 0) return NULL;
-    fstat(fd, &amp;st);
-
-#ifndef EZXML_NOMMAP
-    l = (st.st_size + sysconf(_SC_PAGESIZE) - 1) &amp; ~(sysconf(_SC_PAGESIZE) -1);
-    if ((m = mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0)) !=
-        MAP_FAILED) {
-        madvise(m, l, MADV_SEQUENTIAL); // optimize for sequential access
-        root = (ezxml_root_t)ezxml_parse_str(m, st.st_size);
-        madvise(m, root-&gt;len = l, MADV_NORMAL); // put it back to normal
-    }
-    else { // mmap failed, read file into memory
-#endif // EZXML_NOMMAP
-        l = read(fd, m = malloc(st.st_size), st.st_size);
-        root = (ezxml_root_t)ezxml_parse_str(m, l);
-        root-&gt;len = -1; // so we know to free s in ezxml_free()
-#ifndef EZXML_NOMMAP
-    }
-#endif // EZXML_NOMMAP
-    return &amp;root-&gt;xml;
-}
-
-// a wrapper for ezxml_parse_fd that accepts a file name
-ezxml_t ezxml_parse_file(const char *file)
-{
-    int fd = open(file, O_RDONLY, 0);
-    ezxml_t xml = ezxml_parse_fd(fd);
-    
-    if (fd &gt;= 0) close(fd);
-    return xml;
-}
-
-// Encodes ampersand sequences appending the results to *dst, reallocating *dst
-// if length excedes max. a is non-zero for attribute encoding. Returns *dst
-char *ezxml_ampencode(const char *s, size_t len, char **dst, size_t *dlen,
-                      size_t *max, short a)
-{
-    const char *e;
-    
-    for (e = s + len; s != e; s++) {
-        while (*dlen + 10 &gt; *max) *dst = realloc(*dst, *max += EZXML_BUFSIZE);
-
-        switch (*s) {
-        case '\0': return *dst;
-        case '&amp;': *dlen += sprintf(*dst + *dlen, &quot;&amp;amp;&quot;); break;
-        case '&lt;': *dlen += sprintf(*dst + *dlen, &quot;&amp;lt;&quot;); break;
-        case '&gt;': *dlen += sprintf(*dst + *dlen, &quot;&amp;gt;&quot;); break;
-        case '&quot;': *dlen += sprintf(*dst + *dlen, (a) ? &quot;&amp;quot;&quot; : &quot;\&quot;&quot;); break;
-        case '</font>
<font color="black">': *dlen += sprintf(*dst + *dlen, (a) ? &quot;&amp;#xA;&quot; : &quot;</font>
<font color="red">&quot;); break;
-        case '\t': *dlen += sprintf(*dst + *dlen, (a) ? &quot;&amp;#x9;&quot; : &quot;\t&quot;); break;
-        case '\r': *dlen += sprintf(*dst + *dlen, &quot;&amp;#xD;&quot;); break;
-        default: (*dst)[(*dlen)++] = *s;
-        }
-    }
-    return *dst;
-}
-
-// Recursively converts each tag to xml appending it to *s. Reallocates *s if
-// its length excedes max. start is the location of the previous tag in the
-// parent tag's character content. Returns *s.
-char *ezxml_toxml_r(ezxml_t xml, char **s, size_t *len, size_t *max,
-                    size_t start, char ***attr)
-{
-    int i, j;
-    char *txt = (xml-&gt;parent) ? xml-&gt;parent-&gt;txt : &quot;&quot;;
-    size_t off = 0;
-
-    // parent character content up to this tag
-    *s = ezxml_ampencode(txt + start, xml-&gt;off - start, s, len, max, 0);
-
-    while (*len + strlen(xml-&gt;name) + 4 &gt; *max) // reallocate s
-        *s = realloc(*s, *max += EZXML_BUFSIZE);
-
-    *len += sprintf(*s + *len, &quot;&lt;%s&quot;, xml-&gt;name); // open tag
-    for (i = 0; xml-&gt;attr[i]; i += 2) { // tag attributes
-        if (ezxml_attr(xml, xml-&gt;attr[i]) != xml-&gt;attr[i + 1]) continue;
-        while (*len + strlen(xml-&gt;attr[i]) + 7 &gt; *max) // reallocate s
-            *s = realloc(*s, *max += EZXML_BUFSIZE);
-
-        *len += sprintf(*s + *len, &quot; %s=\&quot;&quot;, xml-&gt;attr[i]);
-        ezxml_ampencode(xml-&gt;attr[i + 1], -1, s, len, max, 1);
-        *len += sprintf(*s + *len, &quot;\&quot;&quot;);
-    }
-
-    for (i = 0; attr[i] &amp;&amp; strcmp(attr[i][0], xml-&gt;name); i++);
-    for (j = 1; attr[i] &amp;&amp; attr[i][j]; j += 3) { // default attributes
-        if (! attr[i][j + 1] || ezxml_attr(xml, attr[i][j]) != attr[i][j + 1])
-            continue; // skip duplicates and non-values
-        while (*len + strlen(attr[i][j]) + 7 &gt; *max) // reallocate s
-            *s = realloc(*s, *max += EZXML_BUFSIZE);
-
-        *len += sprintf(*s + *len, &quot; %s=\&quot;&quot;, attr[i][j]);
-        ezxml_ampencode(attr[i][j + 1], -1, s, len, max, 1);
-        *len += sprintf(*s + *len, &quot;\&quot;&quot;);
-    }
-    *len += sprintf(*s + *len, &quot;&gt;&quot;);
-
-    *s = (xml-&gt;child) ? ezxml_toxml_r(xml-&gt;child, s, len, max, 0, attr) //child
-                      : ezxml_ampencode(xml-&gt;txt, -1, s, len, max, 0);  //data
-    
-    while (*len + strlen(xml-&gt;name) + 4 &gt; *max) // reallocate s
-        *s = realloc(*s, *max += EZXML_BUFSIZE);
-
-    *len += sprintf(*s + *len, &quot;&lt;/%s&gt;&quot;, xml-&gt;name); // close tag
-
-    while (txt[off] &amp;&amp; off &lt; xml-&gt;off) off++; // make sure off is within bounds
-    return (xml-&gt;ordered) ? ezxml_toxml_r(xml-&gt;ordered, s, len, max, off, attr)
-                          : ezxml_ampencode(txt + off, -1, s, len, max, 0);
-}
-
-// Converts an ezxml structure back to xml. Returns a string of xml data that
-// must be freed.
-char *ezxml_toxml(ezxml_t xml)
-{
-    ezxml_t p = (xml) ? xml-&gt;parent : NULL, o = (xml) ? xml-&gt;ordered : NULL;
-    ezxml_root_t root = (ezxml_root_t)xml;
-    size_t len = 0, max = EZXML_BUFSIZE;
-    char *s = strcpy(malloc(max), &quot;&quot;), *t, *n;
-    int i, j, k;
-
-    if (! xml || ! xml-&gt;name) return realloc(s, len + 1);
-    while (root-&gt;xml.parent) root = (ezxml_root_t)root-&gt;xml.parent; // root tag
-
-    for (i = 0; ! p &amp;&amp; root-&gt;pi[i]; i++) { // pre-root processing instructions
-        for (k = 2; root-&gt;pi[i][k - 1]; k++);
-        for (j = 1; (n = root-&gt;pi[i][j]); j++) {
-            if (root-&gt;pi[i][k][j - 1] == '&gt;') continue; // not pre-root
-            while (len + strlen(t = root-&gt;pi[i][0]) + strlen(n) + 7 &gt; max)
-                s = realloc(s, max += EZXML_BUFSIZE);
-            len += sprintf(s + len, &quot;&lt;?%s%s%s?&gt;</font>
<font color="red">&quot;, t, *n ? &quot; &quot; : &quot;&quot;, n);
-        }
-    }
-
-    xml-&gt;parent = xml-&gt;ordered = NULL;
-    s = ezxml_toxml_r(xml, &amp;s, &amp;len, &amp;max, 0, root-&gt;attr);
-    xml-&gt;parent = p;
-    xml-&gt;ordered = o;
-
-    for (i = 0; ! p &amp;&amp; root-&gt;pi[i]; i++) { // post-root processing instructions
-        for (k = 2; root-&gt;pi[i][k - 1]; k++);
-        for (j = 1; (n = root-&gt;pi[i][j]); j++) {
-            if (root-&gt;pi[i][k][j - 1] == '&lt;') continue; // not post-root
-            while (len + strlen(t = root-&gt;pi[i][0]) + strlen(n) + 7 &gt; max)
-                s = realloc(s, max += EZXML_BUFSIZE);
-            len += sprintf(s + len, &quot;</font>
<font color="red">&lt;?%s%s%s?&gt;&quot;, t, *n ? &quot; &quot; : &quot;&quot;, n);
-        }
-    }
-    return realloc(s, len + 1);
-}
-
-// free the memory allocated for the ezxml structure
-void ezxml_free(ezxml_t xml)
-{
-    ezxml_root_t root = (ezxml_root_t)xml;
-    int i, j;
-    char **a, *s;
-
-    if (! xml) return;
-    ezxml_free(xml-&gt;child);
-    ezxml_free(xml-&gt;ordered);
-
-    if (! xml-&gt;parent) { // free root tag allocations
-        for (i = 10; root-&gt;ent[i]; i += 2) // 0 - 9 are default entites (&lt;&gt;&amp;&quot;')
-            if ((s = root-&gt;ent[i + 1]) &lt; root-&gt;s || s &gt; root-&gt;e) free(s);
-        free(root-&gt;ent); // free list of general entities
-
-        for (i = 0; (a = root-&gt;attr[i]); i++) {
-            for (j = 1; a[j++]; j += 2) // free malloced attribute values
-                if (a[j] &amp;&amp; (a[j] &lt; root-&gt;s || a[j] &gt; root-&gt;e)) free(a[j]);
-            free(a);
-        }
-        if (root-&gt;attr[0]) free(root-&gt;attr); // free default attribute list
-
-        for (i = 0; root-&gt;pi[i]; i++) {
-            for (j = 1; root-&gt;pi[i][j]; j++);
-            free(root-&gt;pi[i][j + 1]);
-            free(root-&gt;pi[i]);
-        }            
-        if (root-&gt;pi[0]) free(root-&gt;pi); // free processing instructions
-
-        if (root-&gt;len == -1) free(root-&gt;m); // malloced xml data
-#ifndef EZXML_NOMMAP
-        else if (root-&gt;len) munmap(root-&gt;m, root-&gt;len); // mem mapped xml data
-#endif // EZXML_NOMMAP
-        if (root-&gt;u) free(root-&gt;u); // utf8 conversion
-    }
-
-    ezxml_free_attr(xml-&gt;attr); // tag attributes
-    if ((xml-&gt;flags &amp; EZXML_TXTM)) free(xml-&gt;txt); // character content
-    if ((xml-&gt;flags &amp; EZXML_NAMEM)) free(xml-&gt;name); // tag name
-    free(xml);
-}
-
-// return parser error message or empty string if none
-const char *ezxml_error(ezxml_t xml)
-{
-    while (xml &amp;&amp; xml-&gt;parent) xml = xml-&gt;parent; // find root tag
-    return (xml) ? ((ezxml_root_t)xml)-&gt;err : &quot;&quot;;
-}
-
-// returns a new empty ezxml structure with the given root tag name
-ezxml_t ezxml_new(const char *name)
-{
-    static char *ent[] = { &quot;lt;&quot;, &quot;&amp;#60;&quot;, &quot;gt;&quot;, &quot;&amp;#62;&quot;, &quot;quot;&quot;, &quot;&amp;#34;&quot;,
-                           &quot;apos;&quot;, &quot;&amp;#39;&quot;, &quot;amp;&quot;, &quot;&amp;#38;&quot;, NULL };
-    ezxml_root_t root = (ezxml_root_t)memset(malloc(sizeof(struct ezxml_root)), 
-                                             '\0', sizeof(struct ezxml_root));
-    root-&gt;xml.name = (char *)name;
-    root-&gt;cur = &amp;root-&gt;xml;
-    strcpy(root-&gt;err, root-&gt;xml.txt = &quot;&quot;);
-    root-&gt;ent = memcpy(malloc(sizeof(ent)), ent, sizeof(ent));
-    root-&gt;attr = root-&gt;pi = (char ***)(root-&gt;xml.attr = EZXML_NIL);
-    return &amp;root-&gt;xml;
-}
-
-// inserts an existing tag into an ezxml structure
-ezxml_t ezxml_insert(ezxml_t xml, ezxml_t dest, size_t off)
-{
-    ezxml_t cur, prev, head;
-
-    xml-&gt;next = xml-&gt;sibling = xml-&gt;ordered = NULL;
-    xml-&gt;off = off;
-    xml-&gt;parent = dest;
-
-    if ((head = dest-&gt;child)) { // already have sub tags
-        if (head-&gt;off &lt;= off) { // not first subtag
-            for (cur = head; cur-&gt;ordered &amp;&amp; cur-&gt;ordered-&gt;off &lt;= off;
-                 cur = cur-&gt;ordered);
-            xml-&gt;ordered = cur-&gt;ordered;
-            cur-&gt;ordered = xml;
-        }
-        else { // first subtag
-            xml-&gt;ordered = head;
-            dest-&gt;child = xml;
-        }
-
-        for (cur = head, prev = NULL; cur &amp;&amp; strcmp(cur-&gt;name, xml-&gt;name);
-             prev = cur, cur = cur-&gt;sibling); // find tag type
-        if (cur &amp;&amp; cur-&gt;off &lt;= off) { // not first of type
-            while (cur-&gt;next &amp;&amp; cur-&gt;next-&gt;off &lt;= off) cur = cur-&gt;next;
-            xml-&gt;next = cur-&gt;next;
-            cur-&gt;next = xml;
-        }
-        else { // first tag of this type
-            if (prev &amp;&amp; cur) prev-&gt;sibling = cur-&gt;sibling; // remove old first
-            xml-&gt;next = cur; // old first tag is now next
-            for (cur = head, prev = NULL; cur &amp;&amp; cur-&gt;off &lt;= off;
-                 prev = cur, cur = cur-&gt;sibling); // new sibling insert point
-            xml-&gt;sibling = cur;
-            if (prev) prev-&gt;sibling = xml;
-        }
-    }
-    else dest-&gt;child = xml; // only sub tag
-
-    return xml;
-}
-
-// Adds a child tag. off is the offset of the child tag relative to the start
-// of the parent tag's character content. Returns the child tag.
-ezxml_t ezxml_add_child(ezxml_t xml, const char *name, size_t off)
-{
-    ezxml_t child;
-
-    if (! xml) return NULL;
-    child = (ezxml_t)memset(malloc(sizeof(struct ezxml)), '\0',
-                            sizeof(struct ezxml));
-    child-&gt;name = (char *)name;
-    child-&gt;attr = EZXML_NIL;
-    child-&gt;txt = &quot;&quot;;
-
-    return ezxml_insert(child, xml, off);
-}
-
-// sets the character content for the given tag and returns the tag
-ezxml_t ezxml_set_txt(ezxml_t xml, const char *txt)
-{
-    if (! xml) return NULL;
-    if (xml-&gt;flags &amp; EZXML_TXTM) free(xml-&gt;txt); // existing txt was malloced
-    xml-&gt;flags &amp;= ~EZXML_TXTM;
-    xml-&gt;txt = (char *)txt;
-    return xml;
-}
-
-// Sets the given tag attribute or adds a new attribute if not found. A value
-// of NULL will remove the specified attribute. Returns the tag given.
-ezxml_t ezxml_set_attr(ezxml_t xml, const char *name, const char *value)
-{
-    int l = 0, c;
-
-    if (! xml) return NULL;
-    while (xml-&gt;attr[l] &amp;&amp; strcmp(xml-&gt;attr[l], name)) l += 2;
-    if (! xml-&gt;attr[l]) { // not found, add as new attribute
-        if (! value) return xml; // nothing to do
-        if (xml-&gt;attr == EZXML_NIL) { // first attribute
-            xml-&gt;attr = malloc(4 * sizeof(char *));
-            xml-&gt;attr[1] = strdup(&quot;&quot;); // empty list of malloced names/vals
-        }
-        else xml-&gt;attr = realloc(xml-&gt;attr, (l + 4) * sizeof(char *));
-
-        xml-&gt;attr[l] = (char *)name; // set attribute name
-        xml-&gt;attr[l + 2] = NULL; // null terminate attribute list
-        xml-&gt;attr[l + 3] = realloc(xml-&gt;attr[l + 1],
-                                   (c = strlen(xml-&gt;attr[l + 1])) + 2);
-        strcpy(xml-&gt;attr[l + 3] + c, &quot; &quot;); // set name/value as not malloced
-        if (xml-&gt;flags &amp; EZXML_DUP) xml-&gt;attr[l + 3][c] = EZXML_NAMEM;
-    }
-    else if (xml-&gt;flags &amp; EZXML_DUP) free((char *)name); // name was strduped
-
-    for (c = l; xml-&gt;attr[c]; c += 2); // find end of attribute list
-    if (xml-&gt;attr[c + 1][l / 2] &amp; EZXML_TXTM) free(xml-&gt;attr[l + 1]); //old val
-    if (xml-&gt;flags &amp; EZXML_DUP) xml-&gt;attr[c + 1][l / 2] |= EZXML_TXTM;
-    else xml-&gt;attr[c + 1][l / 2] &amp;= ~EZXML_TXTM;
-
-    if (value) xml-&gt;attr[l + 1] = (char *)value; // set attribute value
-    else { // remove attribute
-        if (xml-&gt;attr[c + 1][l / 2] &amp; EZXML_NAMEM) free(xml-&gt;attr[l]);
-        memmove(xml-&gt;attr + l, xml-&gt;attr + l + 2, (c - l + 2) * sizeof(char*));
-        xml-&gt;attr = realloc(xml-&gt;attr, (c + 2) * sizeof(char *));
-        memmove(xml-&gt;attr[c + 1] + (l / 2), xml-&gt;attr[c + 1] + (l / 2) + 1,
-                (c / 2) - (l / 2)); // fix list of which name/vals are malloced
-    }
-    xml-&gt;flags &amp;= ~EZXML_DUP; // clear strdup() flag
-    return xml;
-}
-
-// sets a flag for the given tag and returns the tag
-ezxml_t ezxml_set_flag(ezxml_t xml, short flag)
-{
-    if (xml) xml-&gt;flags |= flag;
-    return xml;
-}
-
-// removes a tag along with its subtags without freeing its memory
-ezxml_t ezxml_cut(ezxml_t xml)
-{
-    ezxml_t cur;
-
-    if (! xml) return NULL; // nothing to do
-    if (xml-&gt;next) xml-&gt;next-&gt;sibling = xml-&gt;sibling; // patch sibling list
-
-    if (xml-&gt;parent) { // not root tag
-        cur = xml-&gt;parent-&gt;child; // find head of subtag list
-        if (cur == xml) xml-&gt;parent-&gt;child = xml-&gt;ordered; // first subtag
-        else { // not first subtag
-            while (cur-&gt;ordered != xml) cur = cur-&gt;ordered;
-            cur-&gt;ordered = cur-&gt;ordered-&gt;ordered; // patch ordered list
-
-            cur = xml-&gt;parent-&gt;child; // go back to head of subtag list
-            if (strcmp(cur-&gt;name, xml-&gt;name)) { // not in first sibling list
-                while (strcmp(cur-&gt;sibling-&gt;name, xml-&gt;name))
-                    cur = cur-&gt;sibling;
-                if (cur-&gt;sibling == xml) { // first of a sibling list
-                    cur-&gt;sibling = (xml-&gt;next) ? xml-&gt;next
-                                               : cur-&gt;sibling-&gt;sibling;
-                }
-                else cur = cur-&gt;sibling; // not first of a sibling list
-            }
-
-            while (cur-&gt;next &amp;&amp; cur-&gt;next != xml) cur = cur-&gt;next;
-            if (cur-&gt;next) cur-&gt;next = cur-&gt;next-&gt;next; // patch next list
-        }        
-    }
-    xml-&gt;ordered = xml-&gt;sibling = xml-&gt;next = NULL;
-    return xml;
-}
-
-#ifdef EZXML_TEST // test harness
-int main(int argc, char **argv)
-{
-    ezxml_t xml;
-    char *s;
-    int i;
-
-    if (argc != 2) return fprintf(stderr, &quot;usage: %s xmlfile</font>
<font color="red">&quot;, argv[0]);
-
-    xml = ezxml_parse_file(argv[1]);
-    printf(&quot;%s</font>
<font color="gray">&quot;, (s = ezxml_toxml(xml)));
-    free(s);
-    i = fprintf(stderr, &quot;%s&quot;, ezxml_error(xml));
-    ezxml_free(xml);
-    return (i) ? 1 : 0;
-}
-#endif // EZXML_TEST

Copied: branches/atmos_physics/src/registry/ezxml/ezxml.c (from rev 2666, trunk/mpas/src/registry/ezxml/ezxml.c)
===================================================================
--- branches/atmos_physics/src/registry/ezxml/ezxml.c                                (rev 0)
+++ branches/atmos_physics/src/registry/ezxml/ezxml.c        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,1015 @@
+/* ezxml.c
+ *
+ * Copyright 2004-2006 Aaron Voisine &lt;aaron@voisine.org&gt;
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * &quot;Software&quot;), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include &lt;stdlib.h&gt;
+#include &lt;stdio.h&gt;
+#include &lt;stdarg.h&gt;
+#include &lt;string.h&gt;
+#include &lt;ctype.h&gt;
+#include &lt;unistd.h&gt;
+#include &lt;sys/types.h&gt;
+#ifndef EZXML_NOMMAP
+#include &lt;sys/mman.h&gt;
+#endif // EZXML_NOMMAP
+#include &lt;sys/stat.h&gt;
+#include &quot;ezxml.h&quot;
+
+#define EZXML_WS   &quot;\t\r</font>
<font color="blue"> &quot;  // whitespace
+#define EZXML_ERRL 128        // maximum error string length
+
+typedef struct ezxml_root *ezxml_root_t;
+struct ezxml_root {       // additional data for the root tag
+    struct ezxml xml;     // is a super-struct built on top of ezxml struct
+    ezxml_t cur;          // current xml tree insertion point
+    char *m;              // original xml string
+    size_t len;           // length of allocated memory for mmap, -1 for malloc
+    char *u;              // UTF-8 conversion of string if original was UTF-16
+    char *s;              // start of work area
+    char *e;              // end of work area
+    char **ent;           // general entities (ampersand sequences)
+    char ***attr;         // default attributes
+    char ***pi;           // processing instructions
+    short standalone;     // non-zero if &lt;?xml standalone=&quot;yes&quot;?&gt;
+    char err[EZXML_ERRL]; // error string
+};
+
+char *EZXML_NIL[] = { NULL }; // empty, null terminated array of strings
+
+// returns the first child tag with the given name or NULL if not found
+ezxml_t ezxml_child(ezxml_t xml, const char *name)
+{
+    xml = (xml) ? xml-&gt;child : NULL;
+    while (xml &amp;&amp; strcmp(name, xml-&gt;name)) xml = xml-&gt;sibling;
+    return xml;
+}
+
+// returns the Nth tag with the same name in the same subsection or NULL if not
+// found
+ezxml_t ezxml_idx(ezxml_t xml, int idx)
+{
+    for (; xml &amp;&amp; idx; idx--) xml = xml-&gt;next;
+    return xml;
+}
+
+// returns the value of the requested tag attribute or NULL if not found
+const char *ezxml_attr(ezxml_t xml, const char *attr)
+{
+    int i = 0, j = 1;
+    ezxml_root_t root = (ezxml_root_t)xml;
+
+    if (! xml || ! xml-&gt;attr) return NULL;
+    while (xml-&gt;attr[i] &amp;&amp; strcmp(attr, xml-&gt;attr[i])) i += 2;
+    if (xml-&gt;attr[i]) return xml-&gt;attr[i + 1]; // found attribute
+
+    while (root-&gt;xml.parent) root = (ezxml_root_t)root-&gt;xml.parent; // root tag
+    for (i = 0; root-&gt;attr[i] &amp;&amp; strcmp(xml-&gt;name, root-&gt;attr[i][0]); i++);
+    if (! root-&gt;attr[i]) return NULL; // no matching default attributes
+    while (root-&gt;attr[i][j] &amp;&amp; strcmp(attr, root-&gt;attr[i][j])) j += 3;
+    return (root-&gt;attr[i][j]) ? root-&gt;attr[i][j + 1] : NULL; // found default
+}
+
+// same as ezxml_get but takes an already initialized va_list
+ezxml_t ezxml_vget(ezxml_t xml, va_list ap)
+{
+    char *name = va_arg(ap, char *);
+    int idx = -1;
+
+    if (name &amp;&amp; *name) {
+        idx = va_arg(ap, int);    
+        xml = ezxml_child(xml, name);
+    }
+    return (idx &lt; 0) ? xml : ezxml_vget(ezxml_idx(xml, idx), ap);
+}
+
+// Traverses the xml tree to retrieve a specific subtag. Takes a variable
+// length list of tag names and indexes. The argument list must be terminated
+// by either an index of -1 or an empty string tag name. Example: 
+// title = ezxml_get(library, &quot;shelf&quot;, 0, &quot;book&quot;, 2, &quot;title&quot;, -1);
+// This retrieves the title of the 3rd book on the 1st shelf of library.
+// Returns NULL if not found.
+ezxml_t ezxml_get(ezxml_t xml, ...)
+{
+    va_list ap;
+    ezxml_t r;
+
+    va_start(ap, xml);
+    r = ezxml_vget(xml, ap);
+    va_end(ap);
+    return r;
+}
+
+// returns a null terminated array of processing instructions for the given
+// target
+const char **ezxml_pi(ezxml_t xml, const char *target)
+{
+    ezxml_root_t root = (ezxml_root_t)xml;
+    int i = 0;
+
+    if (! root) return (const char **)EZXML_NIL;
+    while (root-&gt;xml.parent) root = (ezxml_root_t)root-&gt;xml.parent; // root tag
+    while (root-&gt;pi[i] &amp;&amp; strcmp(target, root-&gt;pi[i][0])) i++; // find target
+    return (const char **)((root-&gt;pi[i]) ? root-&gt;pi[i] + 1 : EZXML_NIL);
+}
+
+// set an error string and return root
+ezxml_t ezxml_err(ezxml_root_t root, char *s, const char *err, ...)
+{
+    va_list ap;
+    int line = 1;
+    char *t, fmt[EZXML_ERRL];
+    
+    for (t = root-&gt;s; t &lt; s; t++) if (*t == '</font>
<font color="blue">') line++;
+    snprintf(fmt, EZXML_ERRL, &quot;[error near line %d]: %s&quot;, line, err);
+
+    va_start(ap, err);
+    vsnprintf(root-&gt;err, EZXML_ERRL, fmt, ap);
+    va_end(ap);
+
+    return &amp;root-&gt;xml;
+}
+
+// Recursively decodes entity and character references and normalizes new lines
+// ent is a null terminated array of alternating entity names and values. set t
+// to '&amp;' for general entity decoding, '%' for parameter entity decoding, 'c'
+// for cdata sections, ' ' for attribute normalization, or '*' for non-cdata
+// attribute normalization. Returns s, or if the decoded string is longer than
+// s, returns a malloced string that must be freed.
+char *ezxml_decode(char *s, char **ent, char t)
+{
+    char *e, *r = s, *m = s;
+    long b, c, d, l;
+
+    for (; *s; s++) { // normalize line endings
+        while (*s == '\r') {
+            *(s++) = '</font>
<font color="blue">';
+            if (*s == '</font>
<font color="blue">') memmove(s, (s + 1), strlen(s));
+        }
+    }
+    
+    for (s = r; ; ) {
+        while (*s &amp;&amp; *s != '&amp;' &amp;&amp; (*s != '%' || t != '%') &amp;&amp; !isspace(*s)) s++;
+
+        if (! *s) break;
+        else if (t != 'c' &amp;&amp; ! strncmp(s, &quot;&amp;#&quot;, 2)) { // character reference
+            if (s[2] == 'x') c = strtol(s + 3, &amp;e, 16); // base 16
+            else c = strtol(s + 2, &amp;e, 10); // base 10
+            if (! c || *e != ';') { s++; continue; } // not a character ref
+
+            if (c &lt; 0x80) *(s++) = c; // US-ASCII subset
+            else { // multi-byte UTF-8 sequence
+                for (b = 0, d = c; d; d /= 2) b++; // number of bits in c
+                b = (b - 2) / 5; // number of bytes in payload
+                *(s++) = (0xFF &lt;&lt; (7 - b)) | (c &gt;&gt; (6 * b)); // head
+                while (b) *(s++) = 0x80 | ((c &gt;&gt; (6 * --b)) &amp; 0x3F); // payload
+            }
+
+            memmove(s, strchr(s, ';') + 1, strlen(strchr(s, ';')));
+        }
+        else if ((*s == '&amp;' &amp;&amp; (t == '&amp;' || t == ' ' || t == '*')) ||
+                 (*s == '%' &amp;&amp; t == '%')) { // entity reference
+            for (b = 0; ent[b] &amp;&amp; strncmp(s + 1, ent[b], strlen(ent[b]));
+                 b += 2); // find entity in entity list
+
+            if (ent[b++]) { // found a match
+                if ((c = strlen(ent[b])) - 1 &gt; (e = strchr(s, ';')) - s) {
+                    l = (d = (s - r)) + c + strlen(e); // new length
+                    r = (r == m) ? strcpy(malloc(l), r) : realloc(r, l);
+                    e = strchr((s = r + d), ';'); // fix up pointers
+                }
+
+                memmove(s + c, e + 1, strlen(e)); // shift rest of string
+                strncpy(s, ent[b], c); // copy in replacement text
+            }
+            else s++; // not a known entity
+        }
+        else if ((t == ' ' || t == '*') &amp;&amp; isspace(*s)) *(s++) = ' ';
+        else s++; // no decoding needed
+    }
+
+    if (t == '*') { // normalize spaces for non-cdata attributes
+        for (s = r; *s; s++) {
+            if ((l = strspn(s, &quot; &quot;))) memmove(s, s + l, strlen(s + l) + 1);
+            while (*s &amp;&amp; *s != ' ') s++;
+        }
+        if (--s &gt;= r &amp;&amp; *s == ' ') *s = '\0'; // trim any trailing space
+    }
+    return r;
+}
+
+// called when parser finds start of new tag
+void ezxml_open_tag(ezxml_root_t root, char *name, char **attr)
+{
+    ezxml_t xml = root-&gt;cur;
+    
+    if (xml-&gt;name) xml = ezxml_add_child(xml, name, strlen(xml-&gt;txt));
+    else xml-&gt;name = name; // first open tag
+
+    xml-&gt;attr = attr;
+    root-&gt;cur = xml; // update tag insertion point
+}
+
+// called when parser finds character content between open and closing tag
+void ezxml_char_content(ezxml_root_t root, char *s, size_t len, char t)
+{
+    ezxml_t xml = root-&gt;cur;
+    char *m = s;
+    size_t l;
+
+    if (! xml || ! xml-&gt;name || ! len) return; // sanity check
+
+    s[len] = '\0'; // null terminate text (calling functions anticipate this)
+    len = strlen(s = ezxml_decode(s, root-&gt;ent, t)) + 1;
+
+    if (! *(xml-&gt;txt)) xml-&gt;txt = s; // initial character content
+    else { // allocate our own memory and make a copy
+        xml-&gt;txt = (xml-&gt;flags &amp; EZXML_TXTM) // allocate some space
+                   ? realloc(xml-&gt;txt, (l = strlen(xml-&gt;txt)) + len)
+                   : strcpy(malloc((l = strlen(xml-&gt;txt)) + len), xml-&gt;txt);
+        strcpy(xml-&gt;txt + l, s); // add new char content
+        if (s != m) free(s); // free s if it was malloced by ezxml_decode()
+    }
+
+    if (xml-&gt;txt != m) ezxml_set_flag(xml, EZXML_TXTM);
+}
+
+// called when parser finds closing tag
+ezxml_t ezxml_close_tag(ezxml_root_t root, char *name, char *s)
+{
+    if (! root-&gt;cur || ! root-&gt;cur-&gt;name || strcmp(name, root-&gt;cur-&gt;name))
+        return ezxml_err(root, s, &quot;unexpected closing tag &lt;/%s&gt;&quot;, name);
+
+    root-&gt;cur = root-&gt;cur-&gt;parent;
+    return NULL;
+}
+
+// checks for circular entity references, returns non-zero if no circular
+// references are found, zero otherwise
+int ezxml_ent_ok(char *name, char *s, char **ent)
+{
+    int i;
+
+    for (; ; s++) {
+        while (*s &amp;&amp; *s != '&amp;') s++; // find next entity reference
+        if (! *s) return 1;
+        if (! strncmp(s + 1, name, strlen(name))) return 0; // circular ref.
+        for (i = 0; ent[i] &amp;&amp; strncmp(ent[i], s + 1, strlen(ent[i])); i += 2);
+        if (ent[i] &amp;&amp; ! ezxml_ent_ok(name, ent[i + 1], ent)) return 0;
+    }
+}
+
+// called when the parser finds a processing instruction
+void ezxml_proc_inst(ezxml_root_t root, char *s, size_t len)
+{
+    int i = 0, j = 1;
+    char *target = s;
+
+    s[len] = '\0'; // null terminate instruction
+    if (*(s += strcspn(s, EZXML_WS))) {
+        *s = '\0'; // null terminate target
+        s += strspn(s + 1, EZXML_WS) + 1; // skip whitespace after target
+    }
+
+    if (! strcmp(target, &quot;xml&quot;)) { // &lt;?xml ... ?&gt;
+        if ((s = strstr(s, &quot;standalone&quot;)) &amp;&amp; ! strncmp(s + strspn(s + 10,
+            EZXML_WS &quot;='\&quot;&quot;) + 10, &quot;yes&quot;, 3)) root-&gt;standalone = 1;
+        return;
+    }
+
+    if (! root-&gt;pi[0]) *(root-&gt;pi = malloc(sizeof(char **))) = NULL; //first pi
+
+    while (root-&gt;pi[i] &amp;&amp; strcmp(target, root-&gt;pi[i][0])) i++; // find target
+    if (! root-&gt;pi[i]) { // new target
+        root-&gt;pi = realloc(root-&gt;pi, sizeof(char **) * (i + 2));
+        root-&gt;pi[i] = malloc(sizeof(char *) * 3);
+        root-&gt;pi[i][0] = target;
+        root-&gt;pi[i][1] = (char *)(root-&gt;pi[i + 1] = NULL); // terminate pi list
+        root-&gt;pi[i][2] = strdup(&quot;&quot;); // empty document position list
+    }
+
+    while (root-&gt;pi[i][j]) j++; // find end of instruction list for this target
+    root-&gt;pi[i] = realloc(root-&gt;pi[i], sizeof(char *) * (j + 3));
+    root-&gt;pi[i][j + 2] = realloc(root-&gt;pi[i][j + 1], j + 1);
+    strcpy(root-&gt;pi[i][j + 2] + j - 1, (root-&gt;xml.name) ? &quot;&gt;&quot; : &quot;&lt;&quot;);
+    root-&gt;pi[i][j + 1] = NULL; // null terminate pi list for this target
+    root-&gt;pi[i][j] = s; // set instruction
+}
+
+// called when the parser finds an internal doctype subset
+short ezxml_internal_dtd(ezxml_root_t root, char *s, size_t len)
+{
+    char q, *c, *t, *n = NULL, *v, **ent, **pe;
+    int i, j;
+    
+    pe = memcpy(malloc(sizeof(EZXML_NIL)), EZXML_NIL, sizeof(EZXML_NIL));
+
+    for (s[len] = '\0'; s; ) {
+        while (*s &amp;&amp; *s != '&lt;' &amp;&amp; *s != '%') s++; // find next declaration
+
+        if (! *s) break;
+        else if (! strncmp(s, &quot;&lt;!ENTITY&quot;, 8)) { // parse entity definitions
+            c = s += strspn(s + 8, EZXML_WS) + 8; // skip white space separator
+            n = s + strspn(s, EZXML_WS &quot;%&quot;); // find name
+            *(s = n + strcspn(n, EZXML_WS)) = ';'; // append ; to name
+
+            v = s + strspn(s + 1, EZXML_WS) + 1; // find value
+            if ((q = *(v++)) != '&quot;' &amp;&amp; q != '\'') { // skip externals
+                s = strchr(s, '&gt;');
+                continue;
+            }
+
+            for (i = 0, ent = (*c == '%') ? pe : root-&gt;ent; ent[i]; i++);
+            ent = realloc(ent, (i + 3) * sizeof(char *)); // space for next ent
+            if (*c == '%') pe = ent;
+            else root-&gt;ent = ent;
+
+            *(++s) = '\0'; // null terminate name
+            if ((s = strchr(v, q))) *(s++) = '\0'; // null terminate value
+            ent[i + 1] = ezxml_decode(v, pe, '%'); // set value
+            ent[i + 2] = NULL; // null terminate entity list
+            if (! ezxml_ent_ok(n, ent[i + 1], ent)) { // circular reference
+                if (ent[i + 1] != v) free(ent[i + 1]);
+                ezxml_err(root, v, &quot;circular entity declaration &amp;%s&quot;, n);
+                break;
+            }
+            else ent[i] = n; // set entity name
+        }
+        else if (! strncmp(s, &quot;&lt;!ATTLIST&quot;, 9)) { // parse default attributes
+            t = s + strspn(s + 9, EZXML_WS) + 9; // skip whitespace separator
+            if (! *t) { ezxml_err(root, t, &quot;unclosed &lt;!ATTLIST&quot;); break; }
+            if (*(s = t + strcspn(t, EZXML_WS &quot;&gt;&quot;)) == '&gt;') continue;
+            else *s = '\0'; // null terminate tag name
+            for (i = 0; root-&gt;attr[i] &amp;&amp; strcmp(n, root-&gt;attr[i][0]); i++);
+
+            while (*(n = ++s + strspn(s, EZXML_WS)) &amp;&amp; *n != '&gt;') {
+                if (*(s = n + strcspn(n, EZXML_WS))) *s = '\0'; // attr name
+                else { ezxml_err(root, t, &quot;malformed &lt;!ATTLIST&quot;); break; }
+
+                s += strspn(s + 1, EZXML_WS) + 1; // find next token
+                c = (strncmp(s, &quot;CDATA&quot;, 5)) ? &quot;*&quot; : &quot; &quot;; // is it cdata?
+                if (! strncmp(s, &quot;NOTATION&quot;, 8))
+                    s += strspn(s + 8, EZXML_WS) + 8;
+                s = (*s == '(') ? strchr(s, ')') : s + strcspn(s, EZXML_WS);
+                if (! s) { ezxml_err(root, t, &quot;malformed &lt;!ATTLIST&quot;); break; }
+
+                s += strspn(s, EZXML_WS &quot;)&quot;); // skip white space separator
+                if (! strncmp(s, &quot;#FIXED&quot;, 6))
+                    s += strspn(s + 6, EZXML_WS) + 6;
+                if (*s == '#') { // no default value
+                    s += strcspn(s, EZXML_WS &quot;&gt;&quot;) - 1;
+                    if (*c == ' ') continue; // cdata is default, nothing to do
+                    v = NULL;
+                }
+                else if ((*s == '&quot;' || *s == '\'')  &amp;&amp;  // default value
+                         (s = strchr(v = s + 1, *s))) *s = '\0';
+                else { ezxml_err(root, t, &quot;malformed &lt;!ATTLIST&quot;); break; }
+
+                if (! root-&gt;attr[i]) { // new tag name
+                    root-&gt;attr = (! i) ? malloc(2 * sizeof(char **))
+                                       : realloc(root-&gt;attr,
+                                                 (i + 2) * sizeof(char **));
+                    root-&gt;attr[i] = malloc(2 * sizeof(char *));
+                    root-&gt;attr[i][0] = t; // set tag name
+                    root-&gt;attr[i][1] = (char *)(root-&gt;attr[i + 1] = NULL);
+                }
+
+                for (j = 1; root-&gt;attr[i][j]; j += 3); // find end of list
+                root-&gt;attr[i] = realloc(root-&gt;attr[i],
+                                        (j + 4) * sizeof(char *));
+
+                root-&gt;attr[i][j + 3] = NULL; // null terminate list
+                root-&gt;attr[i][j + 2] = c; // is it cdata?
+                root-&gt;attr[i][j + 1] = (v) ? ezxml_decode(v, root-&gt;ent, *c)
+                                           : NULL;
+                root-&gt;attr[i][j] = n; // attribute name 
+            }
+        }
+        else if (! strncmp(s, &quot;&lt;!--&quot;, 4)) s = strstr(s + 4, &quot;--&gt;&quot;); // comments
+        else if (! strncmp(s, &quot;&lt;?&quot;, 2)) { // processing instructions
+            if ((s = strstr(c = s + 2, &quot;?&gt;&quot;)))
+                ezxml_proc_inst(root, c, s++ - c);
+        }
+        else if (*s == '&lt;') s = strchr(s, '&gt;'); // skip other declarations
+        else if (*(s++) == '%' &amp;&amp; ! root-&gt;standalone) break;
+    }
+
+    free(pe);
+    return ! *root-&gt;err;
+}
+
+// Converts a UTF-16 string to UTF-8. Returns a new string that must be freed
+// or NULL if no conversion was needed.
+char *ezxml_str2utf8(char **s, size_t *len)
+{
+    char *u;
+    size_t l = 0, sl, max = *len;
+    long c, d;
+    int b, be = (**s == '\xFE') ? 1 : (**s == '\xFF') ? 0 : -1;
+
+    if (be == -1) return NULL; // not UTF-16
+
+    u = malloc(max);
+    for (sl = 2; sl &lt; *len - 1; sl += 2) {
+        c = (be) ? (((*s)[sl] &amp; 0xFF) &lt;&lt; 8) | ((*s)[sl + 1] &amp; 0xFF)  //UTF-16BE
+                 : (((*s)[sl + 1] &amp; 0xFF) &lt;&lt; 8) | ((*s)[sl] &amp; 0xFF); //UTF-16LE
+        if (c &gt;= 0xD800 &amp;&amp; c &lt;= 0xDFFF &amp;&amp; (sl += 2) &lt; *len - 1) { // high-half
+            d = (be) ? (((*s)[sl] &amp; 0xFF) &lt;&lt; 8) | ((*s)[sl + 1] &amp; 0xFF)
+                     : (((*s)[sl + 1] &amp; 0xFF) &lt;&lt; 8) | ((*s)[sl] &amp; 0xFF);
+            c = (((c &amp; 0x3FF) &lt;&lt; 10) | (d &amp; 0x3FF)) + 0x10000;
+        }
+
+        while (l + 6 &gt; max) u = realloc(u, max += EZXML_BUFSIZE);
+        if (c &lt; 0x80) u[l++] = c; // US-ASCII subset
+        else { // multi-byte UTF-8 sequence
+            for (b = 0, d = c; d; d /= 2) b++; // bits in c
+            b = (b - 2) / 5; // bytes in payload
+            u[l++] = (0xFF &lt;&lt; (7 - b)) | (c &gt;&gt; (6 * b)); // head
+            while (b) u[l++] = 0x80 | ((c &gt;&gt; (6 * --b)) &amp; 0x3F); // payload
+        }
+    }
+    return *s = realloc(u, *len = l);
+}
+
+// frees a tag attribute list
+void ezxml_free_attr(char **attr) {
+    int i = 0;
+    char *m;
+    
+    if (! attr || attr == EZXML_NIL) return; // nothing to free
+    while (attr[i]) i += 2; // find end of attribute list
+    m = attr[i + 1]; // list of which names and values are malloced
+    for (i = 0; m[i]; i++) {
+        if (m[i] &amp; EZXML_NAMEM) free(attr[i * 2]);
+        if (m[i] &amp; EZXML_TXTM) free(attr[(i * 2) + 1]);
+    }
+    free(m);
+    free(attr);
+}
+
+// parse the given xml string and return an ezxml structure
+ezxml_t ezxml_parse_str(char *s, size_t len)
+{
+    ezxml_root_t root = (ezxml_root_t)ezxml_new(NULL);
+    char q, e, *d, **attr, **a = NULL; // initialize a to avoid compile warning
+    int l, i, j;
+
+    root-&gt;m = s;
+    if (! len) return ezxml_err(root, NULL, &quot;root tag missing&quot;);
+    root-&gt;u = ezxml_str2utf8(&amp;s, &amp;len); // convert utf-16 to utf-8
+    root-&gt;e = (root-&gt;s = s) + len; // record start and end of work area
+    
+    e = s[len - 1]; // save end char
+    s[len - 1] = '\0'; // turn end char into null terminator
+
+    while (*s &amp;&amp; *s != '&lt;') s++; // find first tag
+    if (! *s) return ezxml_err(root, s, &quot;root tag missing&quot;);
+
+    for (; ; ) {
+        attr = (char **)EZXML_NIL;
+        d = ++s;
+        
+        if (isalpha(*s) || *s == '_' || *s == ':' || *s &lt; '\0') { // new tag
+            if (! root-&gt;cur)
+                return ezxml_err(root, d, &quot;markup outside of root element&quot;);
+
+            s += strcspn(s, EZXML_WS &quot;/&gt;&quot;);
+            while (isspace(*s)) *(s++) = '\0'; // null terminate tag name
+  
+            if (*s &amp;&amp; *s != '/' &amp;&amp; *s != '&gt;') // find tag in default attr list
+                for (i = 0; (a = root-&gt;attr[i]) &amp;&amp; strcmp(a[0], d); i++);
+
+            for (l = 0; *s &amp;&amp; *s != '/' &amp;&amp; *s != '&gt;'; l += 2) { // new attrib
+                attr = (l) ? realloc(attr, (l + 4) * sizeof(char *))
+                           : malloc(4 * sizeof(char *)); // allocate space
+                attr[l + 3] = (l) ? realloc(attr[l + 1], (l / 2) + 2)
+                                  : malloc(2); // mem for list of maloced vals
+                strcpy(attr[l + 3] + (l / 2), &quot; &quot;); // value is not malloced
+                attr[l + 2] = NULL; // null terminate list
+                attr[l + 1] = &quot;&quot;; // temporary attribute value
+                attr[l] = s; // set attribute name
+
+                s += strcspn(s, EZXML_WS &quot;=/&gt;&quot;);
+                if (*s == '=' || isspace(*s)) { 
+                    *(s++) = '\0'; // null terminate tag attribute name
+                    q = *(s += strspn(s, EZXML_WS &quot;=&quot;));
+                    if (q == '&quot;' || q == '\'') { // attribute value
+                        attr[l + 1] = ++s;
+                        while (*s &amp;&amp; *s != q) s++;
+                        if (*s) *(s++) = '\0'; // null terminate attribute val
+                        else {
+                            ezxml_free_attr(attr);
+                            return ezxml_err(root, d, &quot;missing %c&quot;, q);
+                        }
+
+                        for (j = 1; a &amp;&amp; a[j] &amp;&amp; strcmp(a[j], attr[l]); j +=3);
+                        attr[l + 1] = ezxml_decode(attr[l + 1], root-&gt;ent, (a
+                                                   &amp;&amp; a[j]) ? *a[j + 2] : ' ');
+                        if (attr[l + 1] &lt; d || attr[l + 1] &gt; s)
+                            attr[l + 3][l / 2] = EZXML_TXTM; // value malloced
+                    }
+                }
+                while (isspace(*s)) s++;
+            }
+
+            if (*s == '/') { // self closing tag
+                *(s++) = '\0';
+                if ((*s &amp;&amp; *s != '&gt;') || (! *s &amp;&amp; e != '&gt;')) {
+                    if (l) ezxml_free_attr(attr);
+                    return ezxml_err(root, d, &quot;missing &gt;&quot;);
+                }
+                ezxml_open_tag(root, d, attr);
+                ezxml_close_tag(root, d, s);
+            }
+            else if ((q = *s) == '&gt;' || (! *s &amp;&amp; e == '&gt;')) { // open tag
+                *s = '\0'; // temporarily null terminate tag name
+                ezxml_open_tag(root, d, attr);
+                *s = q;
+            }
+            else {
+                if (l) ezxml_free_attr(attr);
+                return ezxml_err(root, d, &quot;missing &gt;&quot;); 
+            }
+        }
+        else if (*s == '/') { // close tag
+            s += strcspn(d = s + 1, EZXML_WS &quot;&gt;&quot;) + 1;
+            if (! (q = *s) &amp;&amp; e != '&gt;') return ezxml_err(root, d, &quot;missing &gt;&quot;);
+            *s = '\0'; // temporarily null terminate tag name
+            if (ezxml_close_tag(root, d, s)) return &amp;root-&gt;xml;
+            if (isspace(*s = q)) s += strspn(s, EZXML_WS);
+        }
+        else if (! strncmp(s, &quot;!--&quot;, 3)) { // xml comment
+            if (! (s = strstr(s + 3, &quot;--&quot;)) || (*(s += 2) != '&gt;' &amp;&amp; *s) ||
+                (! *s &amp;&amp; e != '&gt;')) return ezxml_err(root, d, &quot;unclosed &lt;!--&quot;);
+        }
+        else if (! strncmp(s, &quot;![CDATA[&quot;, 8)) { // cdata
+            if ((s = strstr(s, &quot;]]&gt;&quot;)))
+                ezxml_char_content(root, d + 8, (s += 2) - d - 10, 'c');
+            else return ezxml_err(root, d, &quot;unclosed &lt;![CDATA[&quot;);
+        }
+        else if (! strncmp(s, &quot;!DOCTYPE&quot;, 8)) { // dtd
+            for (l = 0; *s &amp;&amp; ((! l &amp;&amp; *s != '&gt;') || (l &amp;&amp; (*s != ']' || 
+                 *(s + strspn(s + 1, EZXML_WS) + 1) != '&gt;')));
+                 l = (*s == '[') ? 1 : l) s += strcspn(s + 1, &quot;[]&gt;&quot;) + 1;
+            if (! *s &amp;&amp; e != '&gt;')
+                return ezxml_err(root, d, &quot;unclosed &lt;!DOCTYPE&quot;);
+            d = (l) ? strchr(d, '[') + 1 : d;
+            if (l &amp;&amp; ! ezxml_internal_dtd(root, d, s++ - d)) return &amp;root-&gt;xml;
+        }
+        else if (*s == '?') { // &lt;?...?&gt; processing instructions
+            do { s = strchr(s, '?'); } while (s &amp;&amp; *(++s) &amp;&amp; *s != '&gt;');
+            if (! s || (! *s &amp;&amp; e != '&gt;')) 
+                return ezxml_err(root, d, &quot;unclosed &lt;?&quot;);
+            else ezxml_proc_inst(root, d + 1, s - d - 2);
+        }
+        else return ezxml_err(root, d, &quot;unexpected &lt;&quot;);
+        
+        if (! s || ! *s) break;
+        *s = '\0';
+        d = ++s;
+        if (*s &amp;&amp; *s != '&lt;') { // tag character content
+            while (*s &amp;&amp; *s != '&lt;') s++;
+            if (*s) ezxml_char_content(root, d, s - d, '&amp;');
+            else break;
+        }
+        else if (! *s) break;
+    }
+
+    if (! root-&gt;cur) return &amp;root-&gt;xml;
+    else if (! root-&gt;cur-&gt;name) return ezxml_err(root, d, &quot;root tag missing&quot;);
+    else return ezxml_err(root, d, &quot;unclosed tag &lt;%s&gt;&quot;, root-&gt;cur-&gt;name);
+}
+
+// Wrapper for ezxml_parse_str() that accepts a file stream. Reads the entire
+// stream into memory and then parses it. For xml files, use ezxml_parse_file()
+// or ezxml_parse_fd()
+ezxml_t ezxml_parse_fp(FILE *fp)
+{
+    ezxml_root_t root;
+    size_t l, len = 0;
+    char *s;
+
+    if (! (s = malloc(EZXML_BUFSIZE))) return NULL;
+    do {
+        len += (l = fread((s + len), 1, EZXML_BUFSIZE, fp));
+        if (l == EZXML_BUFSIZE) s = realloc(s, len + EZXML_BUFSIZE);
+    } while (s &amp;&amp; l == EZXML_BUFSIZE);
+
+    if (! s) return NULL;
+    root = (ezxml_root_t)ezxml_parse_str(s, len);
+    root-&gt;len = -1; // so we know to free s in ezxml_free()
+    return &amp;root-&gt;xml;
+}
+
+// A wrapper for ezxml_parse_str() that accepts a file descriptor. First
+// attempts to mem map the file. Failing that, reads the file into memory.
+// Returns NULL on failure.
+ezxml_t ezxml_parse_fd(int fd)
+{
+    ezxml_root_t root;
+    struct stat st;
+    size_t l;
+    void *m;
+
+    if (fd &lt; 0) return NULL;
+    fstat(fd, &amp;st);
+
+#ifndef EZXML_NOMMAP
+    l = (st.st_size + sysconf(_SC_PAGESIZE) - 1) &amp; ~(sysconf(_SC_PAGESIZE) -1);
+    if ((m = mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0)) !=
+        MAP_FAILED) {
+        madvise(m, l, MADV_SEQUENTIAL); // optimize for sequential access
+        root = (ezxml_root_t)ezxml_parse_str(m, st.st_size);
+        madvise(m, root-&gt;len = l, MADV_NORMAL); // put it back to normal
+    }
+    else { // mmap failed, read file into memory
+#endif // EZXML_NOMMAP
+        l = read(fd, m = malloc(st.st_size), st.st_size);
+        root = (ezxml_root_t)ezxml_parse_str(m, l);
+        root-&gt;len = -1; // so we know to free s in ezxml_free()
+#ifndef EZXML_NOMMAP
+    }
+#endif // EZXML_NOMMAP
+    return &amp;root-&gt;xml;
+}
+
+// a wrapper for ezxml_parse_fd that accepts a file name
+ezxml_t ezxml_parse_file(const char *file)
+{
+    int fd = open(file, O_RDONLY, 0);
+    ezxml_t xml = ezxml_parse_fd(fd);
+    
+    if (fd &gt;= 0) close(fd);
+    return xml;
+}
+
+// Encodes ampersand sequences appending the results to *dst, reallocating *dst
+// if length excedes max. a is non-zero for attribute encoding. Returns *dst
+char *ezxml_ampencode(const char *s, size_t len, char **dst, size_t *dlen,
+                      size_t *max, short a)
+{
+    const char *e;
+    
+    for (e = s + len; s != e; s++) {
+        while (*dlen + 10 &gt; *max) *dst = realloc(*dst, *max += EZXML_BUFSIZE);
+
+        switch (*s) {
+        case '\0': return *dst;
+        case '&amp;': *dlen += sprintf(*dst + *dlen, &quot;&amp;amp;&quot;); break;
+        case '&lt;': *dlen += sprintf(*dst + *dlen, &quot;&amp;lt;&quot;); break;
+        case '&gt;': *dlen += sprintf(*dst + *dlen, &quot;&amp;gt;&quot;); break;
+        case '&quot;': *dlen += sprintf(*dst + *dlen, (a) ? &quot;&amp;quot;&quot; : &quot;\&quot;&quot;); break;
+        case '</font>
<font color="black">': *dlen += sprintf(*dst + *dlen, (a) ? &quot;&amp;#xA;&quot; : &quot;</font>
<font color="blue">&quot;); break;
+        case '\t': *dlen += sprintf(*dst + *dlen, (a) ? &quot;&amp;#x9;&quot; : &quot;\t&quot;); break;
+        case '\r': *dlen += sprintf(*dst + *dlen, &quot;&amp;#xD;&quot;); break;
+        default: (*dst)[(*dlen)++] = *s;
+        }
+    }
+    return *dst;
+}
+
+// Recursively converts each tag to xml appending it to *s. Reallocates *s if
+// its length excedes max. start is the location of the previous tag in the
+// parent tag's character content. Returns *s.
+char *ezxml_toxml_r(ezxml_t xml, char **s, size_t *len, size_t *max,
+                    size_t start, char ***attr)
+{
+    int i, j;
+    char *txt = (xml-&gt;parent) ? xml-&gt;parent-&gt;txt : &quot;&quot;;
+    size_t off = 0;
+
+    // parent character content up to this tag
+    *s = ezxml_ampencode(txt + start, xml-&gt;off - start, s, len, max, 0);
+
+    while (*len + strlen(xml-&gt;name) + 4 &gt; *max) // reallocate s
+        *s = realloc(*s, *max += EZXML_BUFSIZE);
+
+    *len += sprintf(*s + *len, &quot;&lt;%s&quot;, xml-&gt;name); // open tag
+    for (i = 0; xml-&gt;attr[i]; i += 2) { // tag attributes
+        if (ezxml_attr(xml, xml-&gt;attr[i]) != xml-&gt;attr[i + 1]) continue;
+        while (*len + strlen(xml-&gt;attr[i]) + 7 &gt; *max) // reallocate s
+            *s = realloc(*s, *max += EZXML_BUFSIZE);
+
+        *len += sprintf(*s + *len, &quot; %s=\&quot;&quot;, xml-&gt;attr[i]);
+        ezxml_ampencode(xml-&gt;attr[i + 1], -1, s, len, max, 1);
+        *len += sprintf(*s + *len, &quot;\&quot;&quot;);
+    }
+
+    for (i = 0; attr[i] &amp;&amp; strcmp(attr[i][0], xml-&gt;name); i++);
+    for (j = 1; attr[i] &amp;&amp; attr[i][j]; j += 3) { // default attributes
+        if (! attr[i][j + 1] || ezxml_attr(xml, attr[i][j]) != attr[i][j + 1])
+            continue; // skip duplicates and non-values
+        while (*len + strlen(attr[i][j]) + 7 &gt; *max) // reallocate s
+            *s = realloc(*s, *max += EZXML_BUFSIZE);
+
+        *len += sprintf(*s + *len, &quot; %s=\&quot;&quot;, attr[i][j]);
+        ezxml_ampencode(attr[i][j + 1], -1, s, len, max, 1);
+        *len += sprintf(*s + *len, &quot;\&quot;&quot;);
+    }
+    *len += sprintf(*s + *len, &quot;&gt;&quot;);
+
+    *s = (xml-&gt;child) ? ezxml_toxml_r(xml-&gt;child, s, len, max, 0, attr) //child
+                      : ezxml_ampencode(xml-&gt;txt, -1, s, len, max, 0);  //data
+    
+    while (*len + strlen(xml-&gt;name) + 4 &gt; *max) // reallocate s
+        *s = realloc(*s, *max += EZXML_BUFSIZE);
+
+    *len += sprintf(*s + *len, &quot;&lt;/%s&gt;&quot;, xml-&gt;name); // close tag
+
+    while (txt[off] &amp;&amp; off &lt; xml-&gt;off) off++; // make sure off is within bounds
+    return (xml-&gt;ordered) ? ezxml_toxml_r(xml-&gt;ordered, s, len, max, off, attr)
+                          : ezxml_ampencode(txt + off, -1, s, len, max, 0);
+}
+
+// Converts an ezxml structure back to xml. Returns a string of xml data that
+// must be freed.
+char *ezxml_toxml(ezxml_t xml)
+{
+    ezxml_t p = (xml) ? xml-&gt;parent : NULL, o = (xml) ? xml-&gt;ordered : NULL;
+    ezxml_root_t root = (ezxml_root_t)xml;
+    size_t len = 0, max = EZXML_BUFSIZE;
+    char *s = strcpy(malloc(max), &quot;&quot;), *t, *n;
+    int i, j, k;
+
+    if (! xml || ! xml-&gt;name) return realloc(s, len + 1);
+    while (root-&gt;xml.parent) root = (ezxml_root_t)root-&gt;xml.parent; // root tag
+
+    for (i = 0; ! p &amp;&amp; root-&gt;pi[i]; i++) { // pre-root processing instructions
+        for (k = 2; root-&gt;pi[i][k - 1]; k++);
+        for (j = 1; (n = root-&gt;pi[i][j]); j++) {
+            if (root-&gt;pi[i][k][j - 1] == '&gt;') continue; // not pre-root
+            while (len + strlen(t = root-&gt;pi[i][0]) + strlen(n) + 7 &gt; max)
+                s = realloc(s, max += EZXML_BUFSIZE);
+            len += sprintf(s + len, &quot;&lt;?%s%s%s?&gt;</font>
<font color="blue">&quot;, t, *n ? &quot; &quot; : &quot;&quot;, n);
+        }
+    }
+
+    xml-&gt;parent = xml-&gt;ordered = NULL;
+    s = ezxml_toxml_r(xml, &amp;s, &amp;len, &amp;max, 0, root-&gt;attr);
+    xml-&gt;parent = p;
+    xml-&gt;ordered = o;
+
+    for (i = 0; ! p &amp;&amp; root-&gt;pi[i]; i++) { // post-root processing instructions
+        for (k = 2; root-&gt;pi[i][k - 1]; k++);
+        for (j = 1; (n = root-&gt;pi[i][j]); j++) {
+            if (root-&gt;pi[i][k][j - 1] == '&lt;') continue; // not post-root
+            while (len + strlen(t = root-&gt;pi[i][0]) + strlen(n) + 7 &gt; max)
+                s = realloc(s, max += EZXML_BUFSIZE);
+            len += sprintf(s + len, &quot;</font>
<font color="blue">&lt;?%s%s%s?&gt;&quot;, t, *n ? &quot; &quot; : &quot;&quot;, n);
+        }
+    }
+    return realloc(s, len + 1);
+}
+
+// free the memory allocated for the ezxml structure
+void ezxml_free(ezxml_t xml)
+{
+    ezxml_root_t root = (ezxml_root_t)xml;
+    int i, j;
+    char **a, *s;
+
+    if (! xml) return;
+    ezxml_free(xml-&gt;child);
+    ezxml_free(xml-&gt;ordered);
+
+    if (! xml-&gt;parent) { // free root tag allocations
+        for (i = 10; root-&gt;ent[i]; i += 2) // 0 - 9 are default entites (&lt;&gt;&amp;&quot;')
+            if ((s = root-&gt;ent[i + 1]) &lt; root-&gt;s || s &gt; root-&gt;e) free(s);
+        free(root-&gt;ent); // free list of general entities
+
+        for (i = 0; (a = root-&gt;attr[i]); i++) {
+            for (j = 1; a[j++]; j += 2) // free malloced attribute values
+                if (a[j] &amp;&amp; (a[j] &lt; root-&gt;s || a[j] &gt; root-&gt;e)) free(a[j]);
+            free(a);
+        }
+        if (root-&gt;attr[0]) free(root-&gt;attr); // free default attribute list
+
+        for (i = 0; root-&gt;pi[i]; i++) {
+            for (j = 1; root-&gt;pi[i][j]; j++);
+            free(root-&gt;pi[i][j + 1]);
+            free(root-&gt;pi[i]);
+        }            
+        if (root-&gt;pi[0]) free(root-&gt;pi); // free processing instructions
+
+        if (root-&gt;len == -1) free(root-&gt;m); // malloced xml data
+#ifndef EZXML_NOMMAP
+        else if (root-&gt;len) munmap(root-&gt;m, root-&gt;len); // mem mapped xml data
+#endif // EZXML_NOMMAP
+        if (root-&gt;u) free(root-&gt;u); // utf8 conversion
+    }
+
+    ezxml_free_attr(xml-&gt;attr); // tag attributes
+    if ((xml-&gt;flags &amp; EZXML_TXTM)) free(xml-&gt;txt); // character content
+    if ((xml-&gt;flags &amp; EZXML_NAMEM)) free(xml-&gt;name); // tag name
+    free(xml);
+}
+
+// return parser error message or empty string if none
+const char *ezxml_error(ezxml_t xml)
+{
+    while (xml &amp;&amp; xml-&gt;parent) xml = xml-&gt;parent; // find root tag
+    return (xml) ? ((ezxml_root_t)xml)-&gt;err : &quot;&quot;;
+}
+
+// returns a new empty ezxml structure with the given root tag name
+ezxml_t ezxml_new(const char *name)
+{
+    static char *ent[] = { &quot;lt;&quot;, &quot;&amp;#60;&quot;, &quot;gt;&quot;, &quot;&amp;#62;&quot;, &quot;quot;&quot;, &quot;&amp;#34;&quot;,
+                           &quot;apos;&quot;, &quot;&amp;#39;&quot;, &quot;amp;&quot;, &quot;&amp;#38;&quot;, NULL };
+    ezxml_root_t root = (ezxml_root_t)memset(malloc(sizeof(struct ezxml_root)), 
+                                             '\0', sizeof(struct ezxml_root));
+    root-&gt;xml.name = (char *)name;
+    root-&gt;cur = &amp;root-&gt;xml;
+    strcpy(root-&gt;err, root-&gt;xml.txt = &quot;&quot;);
+    root-&gt;ent = memcpy(malloc(sizeof(ent)), ent, sizeof(ent));
+    root-&gt;attr = root-&gt;pi = (char ***)(root-&gt;xml.attr = EZXML_NIL);
+    return &amp;root-&gt;xml;
+}
+
+// inserts an existing tag into an ezxml structure
+ezxml_t ezxml_insert(ezxml_t xml, ezxml_t dest, size_t off)
+{
+    ezxml_t cur, prev, head;
+
+    xml-&gt;next = xml-&gt;sibling = xml-&gt;ordered = NULL;
+    xml-&gt;off = off;
+    xml-&gt;parent = dest;
+
+    if ((head = dest-&gt;child)) { // already have sub tags
+        if (head-&gt;off &lt;= off) { // not first subtag
+            for (cur = head; cur-&gt;ordered &amp;&amp; cur-&gt;ordered-&gt;off &lt;= off;
+                 cur = cur-&gt;ordered);
+            xml-&gt;ordered = cur-&gt;ordered;
+            cur-&gt;ordered = xml;
+        }
+        else { // first subtag
+            xml-&gt;ordered = head;
+            dest-&gt;child = xml;
+        }
+
+        for (cur = head, prev = NULL; cur &amp;&amp; strcmp(cur-&gt;name, xml-&gt;name);
+             prev = cur, cur = cur-&gt;sibling); // find tag type
+        if (cur &amp;&amp; cur-&gt;off &lt;= off) { // not first of type
+            while (cur-&gt;next &amp;&amp; cur-&gt;next-&gt;off &lt;= off) cur = cur-&gt;next;
+            xml-&gt;next = cur-&gt;next;
+            cur-&gt;next = xml;
+        }
+        else { // first tag of this type
+            if (prev &amp;&amp; cur) prev-&gt;sibling = cur-&gt;sibling; // remove old first
+            xml-&gt;next = cur; // old first tag is now next
+            for (cur = head, prev = NULL; cur &amp;&amp; cur-&gt;off &lt;= off;
+                 prev = cur, cur = cur-&gt;sibling); // new sibling insert point
+            xml-&gt;sibling = cur;
+            if (prev) prev-&gt;sibling = xml;
+        }
+    }
+    else dest-&gt;child = xml; // only sub tag
+
+    return xml;
+}
+
+// Adds a child tag. off is the offset of the child tag relative to the start
+// of the parent tag's character content. Returns the child tag.
+ezxml_t ezxml_add_child(ezxml_t xml, const char *name, size_t off)
+{
+    ezxml_t child;
+
+    if (! xml) return NULL;
+    child = (ezxml_t)memset(malloc(sizeof(struct ezxml)), '\0',
+                            sizeof(struct ezxml));
+    child-&gt;name = (char *)name;
+    child-&gt;attr = EZXML_NIL;
+    child-&gt;txt = &quot;&quot;;
+
+    return ezxml_insert(child, xml, off);
+}
+
+// sets the character content for the given tag and returns the tag
+ezxml_t ezxml_set_txt(ezxml_t xml, const char *txt)
+{
+    if (! xml) return NULL;
+    if (xml-&gt;flags &amp; EZXML_TXTM) free(xml-&gt;txt); // existing txt was malloced
+    xml-&gt;flags &amp;= ~EZXML_TXTM;
+    xml-&gt;txt = (char *)txt;
+    return xml;
+}
+
+// Sets the given tag attribute or adds a new attribute if not found. A value
+// of NULL will remove the specified attribute. Returns the tag given.
+ezxml_t ezxml_set_attr(ezxml_t xml, const char *name, const char *value)
+{
+    int l = 0, c;
+
+    if (! xml) return NULL;
+    while (xml-&gt;attr[l] &amp;&amp; strcmp(xml-&gt;attr[l], name)) l += 2;
+    if (! xml-&gt;attr[l]) { // not found, add as new attribute
+        if (! value) return xml; // nothing to do
+        if (xml-&gt;attr == EZXML_NIL) { // first attribute
+            xml-&gt;attr = malloc(4 * sizeof(char *));
+            xml-&gt;attr[1] = strdup(&quot;&quot;); // empty list of malloced names/vals
+        }
+        else xml-&gt;attr = realloc(xml-&gt;attr, (l + 4) * sizeof(char *));
+
+        xml-&gt;attr[l] = (char *)name; // set attribute name
+        xml-&gt;attr[l + 2] = NULL; // null terminate attribute list
+        xml-&gt;attr[l + 3] = realloc(xml-&gt;attr[l + 1],
+                                   (c = strlen(xml-&gt;attr[l + 1])) + 2);
+        strcpy(xml-&gt;attr[l + 3] + c, &quot; &quot;); // set name/value as not malloced
+        if (xml-&gt;flags &amp; EZXML_DUP) xml-&gt;attr[l + 3][c] = EZXML_NAMEM;
+    }
+    else if (xml-&gt;flags &amp; EZXML_DUP) free((char *)name); // name was strduped
+
+    for (c = l; xml-&gt;attr[c]; c += 2); // find end of attribute list
+    if (xml-&gt;attr[c + 1][l / 2] &amp; EZXML_TXTM) free(xml-&gt;attr[l + 1]); //old val
+    if (xml-&gt;flags &amp; EZXML_DUP) xml-&gt;attr[c + 1][l / 2] |= EZXML_TXTM;
+    else xml-&gt;attr[c + 1][l / 2] &amp;= ~EZXML_TXTM;
+
+    if (value) xml-&gt;attr[l + 1] = (char *)value; // set attribute value
+    else { // remove attribute
+        if (xml-&gt;attr[c + 1][l / 2] &amp; EZXML_NAMEM) free(xml-&gt;attr[l]);
+        memmove(xml-&gt;attr + l, xml-&gt;attr + l + 2, (c - l + 2) * sizeof(char*));
+        xml-&gt;attr = realloc(xml-&gt;attr, (c + 2) * sizeof(char *));
+        memmove(xml-&gt;attr[c + 1] + (l / 2), xml-&gt;attr[c + 1] + (l / 2) + 1,
+                (c / 2) - (l / 2)); // fix list of which name/vals are malloced
+    }
+    xml-&gt;flags &amp;= ~EZXML_DUP; // clear strdup() flag
+    return xml;
+}
+
+// sets a flag for the given tag and returns the tag
+ezxml_t ezxml_set_flag(ezxml_t xml, short flag)
+{
+    if (xml) xml-&gt;flags |= flag;
+    return xml;
+}
+
+// removes a tag along with its subtags without freeing its memory
+ezxml_t ezxml_cut(ezxml_t xml)
+{
+    ezxml_t cur;
+
+    if (! xml) return NULL; // nothing to do
+    if (xml-&gt;next) xml-&gt;next-&gt;sibling = xml-&gt;sibling; // patch sibling list
+
+    if (xml-&gt;parent) { // not root tag
+        cur = xml-&gt;parent-&gt;child; // find head of subtag list
+        if (cur == xml) xml-&gt;parent-&gt;child = xml-&gt;ordered; // first subtag
+        else { // not first subtag
+            while (cur-&gt;ordered != xml) cur = cur-&gt;ordered;
+            cur-&gt;ordered = cur-&gt;ordered-&gt;ordered; // patch ordered list
+
+            cur = xml-&gt;parent-&gt;child; // go back to head of subtag list
+            if (strcmp(cur-&gt;name, xml-&gt;name)) { // not in first sibling list
+                while (strcmp(cur-&gt;sibling-&gt;name, xml-&gt;name))
+                    cur = cur-&gt;sibling;
+                if (cur-&gt;sibling == xml) { // first of a sibling list
+                    cur-&gt;sibling = (xml-&gt;next) ? xml-&gt;next
+                                               : cur-&gt;sibling-&gt;sibling;
+                }
+                else cur = cur-&gt;sibling; // not first of a sibling list
+            }
+
+            while (cur-&gt;next &amp;&amp; cur-&gt;next != xml) cur = cur-&gt;next;
+            if (cur-&gt;next) cur-&gt;next = cur-&gt;next-&gt;next; // patch next list
+        }        
+    }
+    xml-&gt;ordered = xml-&gt;sibling = xml-&gt;next = NULL;
+    return xml;
+}
+
+#ifdef EZXML_TEST // test harness
+int main(int argc, char **argv)
+{
+    ezxml_t xml;
+    char *s;
+    int i;
+
+    if (argc != 2) return fprintf(stderr, &quot;usage: %s xmlfile</font>
<font color="blue">&quot;, argv[0]);
+
+    xml = ezxml_parse_file(argv[1]);
+    printf(&quot;%s</font>
<font color="gray">&quot;, (s = ezxml_toxml(xml)));
+    free(s);
+    i = fprintf(stderr, &quot;%s&quot;, ezxml_error(xml));
+    ezxml_free(xml);
+    return (i) ? 1 : 0;
+}
+#endif // EZXML_TEST

Deleted: branches/atmos_physics/src/registry/ezxml/ezxml.h
===================================================================
--- trunk/mpas/src/registry/ezxml/ezxml.h        2013-03-25 16:55:55 UTC (rev 2666)
+++ branches/atmos_physics/src/registry/ezxml/ezxml.h        2013-03-26 23:03:26 UTC (rev 2670)
@@ -1,167 +0,0 @@
-/* ezxml.h
- *
- * Copyright 2004-2006 Aaron Voisine &lt;aaron@voisine.org&gt;
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * &quot;Software&quot;), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef _EZXML_H
-#define _EZXML_H
-
-#include &lt;stdlib.h&gt;
-#include &lt;stdio.h&gt;
-#include &lt;stdarg.h&gt;
-#include &lt;fcntl.h&gt;
-
-#ifdef __cplusplus
-extern &quot;C&quot; {
-#endif
-
-#define EZXML_BUFSIZE 1024 // size of internal memory buffers
-#define EZXML_NAMEM   0x80 // name is malloced
-#define EZXML_TXTM    0x40 // txt is malloced
-#define EZXML_DUP     0x20 // attribute name and value are strduped
-
-typedef struct ezxml *ezxml_t;
-struct ezxml {
-    char *name;      // tag name
-    char **attr;     // tag attributes { name, value, name, value, ... NULL }
-    char *txt;       // tag character content, empty string if none
-    size_t off;      // tag offset from start of parent tag character content
-    ezxml_t next;    // next tag with same name in this section at this depth
-    ezxml_t sibling; // next tag with different name in same section and depth
-    ezxml_t ordered; // next tag, same section and depth, in original order
-    ezxml_t child;   // head of sub tag list, NULL if none
-    ezxml_t parent;  // parent tag, NULL if current tag is root tag
-    short flags;     // additional information
-};
-
-// Given a string of xml data and its length, parses it and creates an ezxml
-// structure. For efficiency, modifies the data by adding null terminators
-// and decoding ampersand sequences. If you don't want this, copy the data and
-// pass in the copy. Returns NULL on failure.
-ezxml_t ezxml_parse_str(char *s, size_t len);
-
-// A wrapper for ezxml_parse_str() that accepts a file descriptor. First
-// attempts to mem map the file. Failing that, reads the file into memory.
-// Returns NULL on failure.
-ezxml_t ezxml_parse_fd(int fd);
-
-// a wrapper for ezxml_parse_fd() that accepts a file name
-ezxml_t ezxml_parse_file(const char *file);
-    
-// Wrapper for ezxml_parse_str() that accepts a file stream. Reads the entire
-// stream into memory and then parses it. For xml files, use ezxml_parse_file()
-// or ezxml_parse_fd()
-ezxml_t ezxml_parse_fp(FILE *fp);
-
-// returns the first child tag (one level deeper) with the given name or NULL
-// if not found
-ezxml_t ezxml_child(ezxml_t xml, const char *name);
-
-// returns the next tag of the same name in the same section and depth or NULL
-// if not found
-#define ezxml_next(xml) ((xml) ? xml-&gt;next : NULL)
-
-// Returns the Nth tag with the same name in the same section at the same depth
-// or NULL if not found. An index of 0 returns the tag given.
-ezxml_t ezxml_idx(ezxml_t xml, int idx);
-
-// returns the name of the given tag
-#define ezxml_name(xml) ((xml) ? xml-&gt;name : NULL)
-
-// returns the given tag's character content or empty string if none
-#define ezxml_txt(xml) ((xml) ? xml-&gt;txt : &quot;&quot;)
-
-// returns the value of the requested tag attribute, or NULL if not found
-const char *ezxml_attr(ezxml_t xml, const char *attr);
-
-// Traverses the ezxml sturcture to retrieve a specific subtag. Takes a
-// variable length list of tag names and indexes. The argument list must be
-// terminated by either an index of -1 or an empty string tag name. Example: 
-// title = ezxml_get(library, &quot;shelf&quot;, 0, &quot;book&quot;, 2, &quot;title&quot;, -1);
-// This retrieves the title of the 3rd book on the 1st shelf of library.
-// Returns NULL if not found.
-ezxml_t ezxml_get(ezxml_t xml, ...);
-
-// Converts an ezxml structure back to xml. Returns a string of xml data that
-// must be freed.
-char *ezxml_toxml(ezxml_t xml);
-
-// returns a NULL terminated array of processing instructions for the given
-// target
-const char **ezxml_pi(ezxml_t xml, const char *target);
-
-// frees the memory allocated for an ezxml structure
-void ezxml_free(ezxml_t xml);
-    
-// returns parser error message or empty string if none
-const char *ezxml_error(ezxml_t xml);
-
-// returns a new empty ezxml structure with the given root tag name
-ezxml_t ezxml_new(const char *name);
-
-// wrapper for ezxml_new() that strdup()s name
-#define ezxml_new_d(name) ezxml_set_flag(ezxml_new(strdup(name)), EZXML_NAMEM)
-
-// Adds a child tag. off is the offset of the child tag relative to the start
-// of the parent tag's character content. Returns the child tag.
-ezxml_t ezxml_add_child(ezxml_t xml, const char *name, size_t off);
-
-// wrapper for ezxml_add_child() that strdup()s name
-#define ezxml_add_child_d(xml, name, off) \
-    ezxml_set_flag(ezxml_add_child(xml, strdup(name), off), EZXML_NAMEM)
-
-// sets the character content for the given tag and returns the tag
-ezxml_t ezxml_set_txt(ezxml_t xml, const char *txt);
-
-// wrapper for ezxml_set_txt() that strdup()s txt
-#define ezxml_set_txt_d(xml, txt) \
-    ezxml_set_flag(ezxml_set_txt(xml, strdup(txt)), EZXML_TXTM)
-
-// Sets the given tag attribute or adds a new attribute if not found. A value
-// of NULL will remove the specified attribute. Returns the tag given.
-ezxml_t ezxml_set_attr(ezxml_t xml, const char *name, const char *value);
-
-// Wrapper for ezxml_set_attr() that strdup()s name/value. Value cannot be NULL
-#define ezxml_set_attr_d(xml, name, value) \
-    ezxml_set_attr(ezxml_set_flag(xml, EZXML_DUP), strdup(name), strdup(value))
-
-// sets a flag for the given tag and returns the tag
-ezxml_t ezxml_set_flag(ezxml_t xml, short flag);
-
-// removes a tag along with its subtags without freeing its memory
-ezxml_t ezxml_cut(ezxml_t xml);
-
-// inserts an existing tag into an ezxml structure
-ezxml_t ezxml_insert(ezxml_t xml, ezxml_t dest, size_t off);
-
-// Moves an existing tag to become a subtag of dest at the given offset from
-// the start of dest's character content. Returns the moved tag.
-#define ezxml_move(xml, dest, off) ezxml_insert(ezxml_cut(xml), dest, off)
-
-// removes a tag along with all its subtags
-#define ezxml_remove(xml) ezxml_free(ezxml_cut(xml))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _EZXML_H

Copied: branches/atmos_physics/src/registry/ezxml/ezxml.h (from rev 2666, trunk/mpas/src/registry/ezxml/ezxml.h)
===================================================================
--- branches/atmos_physics/src/registry/ezxml/ezxml.h                                (rev 0)
+++ branches/atmos_physics/src/registry/ezxml/ezxml.h        2013-03-26 23:03:26 UTC (rev 2670)
@@ -0,0 +1,167 @@
+/* ezxml.h
+ *
+ * Copyright 2004-2006 Aaron Voisine &lt;aaron@voisine.org&gt;
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * &quot;Software&quot;), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _EZXML_H
+#define _EZXML_H
+
+#include &lt;stdlib.h&gt;
+#include &lt;stdio.h&gt;
+#include &lt;stdarg.h&gt;
+#include &lt;fcntl.h&gt;
+
+#ifdef __cplusplus
+extern &quot;C&quot; {
+#endif
+
+#define EZXML_BUFSIZE 1024 // size of internal memory buffers
+#define EZXML_NAMEM   0x80 // name is malloced
+#define EZXML_TXTM    0x40 // txt is malloced
+#define EZXML_DUP     0x20 // attribute name and value are strduped
+
+typedef struct ezxml *ezxml_t;
+struct ezxml {
+    char *name;      // tag name
+    char **attr;     // tag attributes { name, value, name, value, ... NULL }
+    char *txt;       // tag character content, empty string if none
+    size_t off;      // tag offset from start of parent tag character content
+    ezxml_t next;    // next tag with same name in this section at this depth
+    ezxml_t sibling; // next tag with different name in same section and depth
+    ezxml_t ordered; // next tag, same section and depth, in original order
+    ezxml_t child;   // head of sub tag list, NULL if none
+    ezxml_t parent;  // parent tag, NULL if current tag is root tag
+    short flags;     // additional information
+};
+
+// Given a string of xml data and its length, parses it and creates an ezxml
+// structure. For efficiency, modifies the data by adding null terminators
+// and decoding ampersand sequences. If you don't want this, copy the data and
+// pass in the copy. Returns NULL on failure.
+ezxml_t ezxml_parse_str(char *s, size_t len);
+
+// A wrapper for ezxml_parse_str() that accepts a file descriptor. First
+// attempts to mem map the file. Failing that, reads the file into memory.
+// Returns NULL on failure.
+ezxml_t ezxml_parse_fd(int fd);
+
+// a wrapper for ezxml_parse_fd() that accepts a file name
+ezxml_t ezxml_parse_file(const char *file);
+    
+// Wrapper for ezxml_parse_str() that accepts a file stream. Reads the entire
+// stream into memory and then parses it. For xml files, use ezxml_parse_file()
+// or ezxml_parse_fd()
+ezxml_t ezxml_parse_fp(FILE *fp);
+
+// returns the first child tag (one level deeper) with the given name or NULL
+// if not found
+ezxml_t ezxml_child(ezxml_t xml, const char *name);
+
+// returns the next tag of the same name in the same section and depth or NULL
+// if not found
+#define ezxml_next(xml) ((xml) ? xml-&gt;next : NULL)
+
+// Returns the Nth tag with the same name in the same section at the same depth
+// or NULL if not found. An index of 0 returns the tag given.
+ezxml_t ezxml_idx(ezxml_t xml, int idx);
+
+// returns the name of the given tag
+#define ezxml_name(xml) ((xml) ? xml-&gt;name : NULL)
+
+// returns the given tag's character content or empty string if none
+#define ezxml_txt(xml) ((xml) ? xml-&gt;txt : &quot;&quot;)
+
+// returns the value of the requested tag attribute, or NULL if not found
+const char *ezxml_attr(ezxml_t xml, const char *attr);
+
+// Traverses the ezxml sturcture to retrieve a specific subtag. Takes a
+// variable length list of tag names and indexes. The argument list must be
+// terminated by either an index of -1 or an empty string tag name. Example: 
+// title = ezxml_get(library, &quot;shelf&quot;, 0, &quot;book&quot;, 2, &quot;title&quot;, -1);
+// This retrieves the title of the 3rd book on the 1st shelf of library.
+// Returns NULL if not found.
+ezxml_t ezxml_get(ezxml_t xml, ...);
+
+// Converts an ezxml structure back to xml. Returns a string of xml data that
+// must be freed.
+char *ezxml_toxml(ezxml_t xml);
+
+// returns a NULL terminated array of processing instructions for the given
+// target
+const char **ezxml_pi(ezxml_t xml, const char *target);
+
+// frees the memory allocated for an ezxml structure
+void ezxml_free(ezxml_t xml);
+    
+// returns parser error message or empty string if none
+const char *ezxml_error(ezxml_t xml);
+
+// returns a new empty ezxml structure with the given root tag name
+ezxml_t ezxml_new(const char *name);
+
+// wrapper for ezxml_new() that strdup()s name
+#define ezxml_new_d(name) ezxml_set_flag(ezxml_new(strdup(name)), EZXML_NAMEM)
+
+// Adds a child tag. off is the offset of the child tag relative to the start
+// of the parent tag's character content. Returns the child tag.
+ezxml_t ezxml_add_child(ezxml_t xml, const char *name, size_t off);
+
+// wrapper for ezxml_add_child() that strdup()s name
+#define ezxml_add_child_d(xml, name, off) \
+    ezxml_set_flag(ezxml_add_child(xml, strdup(name), off), EZXML_NAMEM)
+
+// sets the character content for the given tag and returns the tag
+ezxml_t ezxml_set_txt(ezxml_t xml, const char *txt);
+
+// wrapper for ezxml_set_txt() that strdup()s txt
+#define ezxml_set_txt_d(xml, txt) \
+    ezxml_set_flag(ezxml_set_txt(xml, strdup(txt)), EZXML_TXTM)
+
+// Sets the given tag attribute or adds a new attribute if not found. A value
+// of NULL will remove the specified attribute. Returns the tag given.
+ezxml_t ezxml_set_attr(ezxml_t xml, const char *name, const char *value);
+
+// Wrapper for ezxml_set_attr() that strdup()s name/value. Value cannot be NULL
+#define ezxml_set_attr_d(xml, name, value) \
+    ezxml_set_attr(ezxml_set_flag(xml, EZXML_DUP), strdup(name), strdup(value))
+
+// sets a flag for the given tag and returns the tag
+ezxml_t ezxml_set_flag(ezxml_t xml, short flag);
+
+// removes a tag along with its subtags without freeing its memory
+ezxml_t ezxml_cut(ezxml_t xml);
+
+// inserts an existing tag into an ezxml structure
+ezxml_t ezxml_insert(ezxml_t xml, ezxml_t dest, size_t off);
+
+// Moves an existing tag to become a subtag of dest at the given offset from
+// the start of dest's character content. Returns the moved tag.
+#define ezxml_move(xml, dest, off) ezxml_insert(ezxml_cut(xml), dest, off)
+
+// removes a tag along with all its subtags
+#define ezxml_remove(xml) ezxml_free(ezxml_cut(xml))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _EZXML_H

Modified: branches/atmos_physics/src/registry/gen_inc.c
===================================================================
--- branches/atmos_physics/src/registry/gen_inc.c        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/registry/gen_inc.c        2013-03-26 23:03:26 UTC (rev 2670)
@@ -822,8 +822,10 @@
             fortprintf(fd, &quot;      %s %% %s %% isSuperArray = .false.</font>
<font color="blue">&quot;, group_ptr-&gt;name, var_ptr-&gt;name_in_code);
             if (var_ptr-&gt;ndims &gt; 0) {
                             if(var_ptr-&gt;persistence == SCRATCH){
+                                  fortprintf(fd, &quot;      %s %% %s %% isPersistent = .false.</font>
<font color="black">&quot;, group_ptr-&gt;name, var_ptr-&gt;name_in_code);
                                   fortprintf(fd, &quot;      nullify(%s %% %s %% array)</font>
<font color="blue">&quot;, group_ptr-&gt;name, var_ptr-&gt;name_in_code); 
                           } else if(var_ptr-&gt;persistence == PERSISTENT){
+                                  fortprintf(fd, &quot;      %s %% %s %% isPersistent = .true.</font>
<font color="gray">&quot;, group_ptr-&gt;name, var_ptr-&gt;name_in_code);
                fortprintf(fd, &quot;      allocate(%s %% %s %% array(&quot;, group_ptr-&gt;name, var_ptr-&gt;name_in_code);
                dimlist_ptr = var_ptr-&gt;dimlist;
                if (!strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nCells&quot;, 1024) ||
@@ -1159,7 +1161,10 @@
             for(i=1; i&lt;=ntime_levs; i++) 
             {
                                 fortprintf(fd, &quot;         if(associated(next) .and. associated(prev)) then</font>
<font color="red">&quot;);        
-                                fortprintf(fd, &quot;           call mpas_create_%s_links(b %% %s %% time_levs(%i) %% %s, prev = prev %% %s %% time_levs(%i) %% %s, next = next %% %s %% time_levs(%i) %% %s)</font>
<font color="blue">&quot;, group_ptr-&gt;name, group_ptr-&gt;name, i, group_ptr-&gt;name, i, group_ptr-&gt;name, group_ptr-&gt;name, i, group_ptr-&gt;name);
+//                                fortprintf(fd, &quot;           call mpas_create_%s_links(b %% %s %% time_levs(%i) %% %s, prev = prev %% %s %% time_levs(%i) %% %s, next = next %% %s %% time_levs(%i) %% %s)</font>
<font color="blue">&quot;, group_ptr-&gt;name, group_ptr-&gt;name, i, group_ptr-&gt;name, i, group_ptr-&gt;name, group_ptr-&gt;name, i, group_ptr-&gt;name);
+                                fortprintf(fd, &quot;           call mpas_create_%s_links(b %% %s %% time_levs(%i) %% %s, &quot;, group_ptr-&gt;name, group_ptr-&gt;name, i, group_ptr-&gt;name, i);
+                                fortprintf(fd, &quot; prev = prev %% %s %% time_levs(%i) %% %s,&quot;, group_ptr-&gt;name, i, group_ptr-&gt;name);
+                                fortprintf(fd, &quot; next = next %% %s %% time_levs(%i) %% %s)</font>
<font color="black">&quot;, group_ptr-&gt;name, i, group_ptr-&gt;name);
                                 fortprintf(fd, &quot;         else if(associated(next)) then</font>
<font color="black">&quot;);        
                                 fortprintf(fd, &quot;           call mpas_create_%s_links(b %% %s %% time_levs(%i) %% %s, next = next %% %s %% time_levs(%i) %% %s)</font>
<font color="black">&quot;, group_ptr-&gt;name, group_ptr-&gt;name, i, group_ptr-&gt;name, group_ptr-&gt;name, i, group_ptr-&gt;name);
                                 fortprintf(fd, &quot;         else if(associated(prev)) then</font>
<font color="gray">&quot;);        
@@ -1387,7 +1392,7 @@
 void gen_reads(struct group_list * groups, struct variable * vars, struct dimension * dims)
 {
    struct variable * var_ptr;
-   struct variable_list * var_list_ptr;
+   struct variable_list * var_list_ptr, *var_list_ptr2;
    struct dimension * dim_ptr;
    struct dimension_list * dimlist_ptr, * lastdim;
    struct group_list * group_ptr;
@@ -2117,8 +2122,10 @@
 /*            fortprintf(fd, &quot;         write(0,*) \'adding input field %s\'</font>
<font color="black">&quot;, var_ptr-&gt;super_array); */
             fortprintf(fd, &quot;         call MPAS_streamAddField(input_obj %% io_stream, %s %% %s, nferr)</font>
<font color="blue">&quot;, struct_deref, var_ptr-&gt;super_array);
             while (var_list_ptr &amp;&amp; strncmp(super_array, var_list_ptr-&gt;var-&gt;super_array, 1024) == 0) {
+                           var_list_ptr2 = var_list_ptr;
                var_list_ptr = var_list_ptr-&gt;next;
             }
+                        var_list_ptr = var_list_ptr2;
          }
          else {
             fortprintf(fd, &quot;      if ((%s %% %s %% ioinfo %% input .and. input_obj %% stream == STREAM_INPUT) .or. &amp;</font>
<font color="gray">&quot;, struct_deref, var_ptr-&gt;name_in_code);
@@ -2174,8 +2181,10 @@
 /*                     fortprintf(fd, &quot;         write(0,*) \'exchange halo for %s\'</font>
<font color="black">&quot;, var_ptr-&gt;super_array); */
                      fortprintf(fd, &quot;         call mpas_dmpar_exch_halo_field(%s %% %s)</font>
<font color="blue">&quot;, struct_deref, var_ptr-&gt;super_array);
                      while (var_list_ptr &amp;&amp; strncmp(super_array, var_list_ptr-&gt;var-&gt;super_array, 1024) == 0) {
+                                                var_list_ptr2 = var_list_ptr;
                         var_list_ptr = var_list_ptr-&gt;next;
                      }
+                                         var_list_ptr = var_list_ptr2;
                   }
                   else {
                      fortprintf(fd, &quot;      if ((%s %% %s %% ioinfo %% input .and. input_obj %% stream == STREAM_INPUT) .or. &amp;</font>
<font color="gray">&quot;, struct_deref, var_ptr-&gt;name_in_code);
@@ -2381,7 +2390,7 @@
 void gen_writes(struct group_list * groups, struct variable * vars, struct dimension * dims, struct namelist * namelists)
 {
    struct variable * var_ptr;
-   struct variable_list * var_list_ptr;
+   struct variable_list * var_list_ptr, *var_list_ptr2;
    struct dimension * dim_ptr;
    struct dimension_list * dimlist_ptr, * lastdim;
    struct group_list * group_ptr;
@@ -2563,8 +2572,10 @@
             memcpy(super_array, var_ptr-&gt;super_array, 1024);
             fortprintf(fd, &quot;         call MPAS_streamAddField(output_obj %% io_stream, %s %% %s, ierr)</font>
<font color="blue">&quot;, struct_deref, super_array);
             while (var_list_ptr &amp;&amp; strncmp(super_array, var_list_ptr-&gt;var-&gt;super_array, 1024) == 0) {
+                           var_list_ptr2 = var_list_ptr;
                var_list_ptr = var_list_ptr-&gt;next;
             }
+                        var_list_ptr = var_list_ptr2;
          }
          else {
             fortprintf(fd, &quot;      if ((%s %% %s %% ioinfo %% output .and. output_obj %% stream == OUTPUT) .or. &amp;</font>
<font color="gray">&quot;, struct_deref, var_ptr-&gt;name_in_code);

Modified: branches/atmos_physics/src/registry/parse.c
===================================================================
--- branches/atmos_physics/src/registry/parse.c        2013-03-26 21:36:57 UTC (rev 2669)
+++ branches/atmos_physics/src/registry/parse.c        2013-03-26 23:03:26 UTC (rev 2670)
@@ -3,6 +3,7 @@
 #include &lt;string.h&gt;
 #include &quot;registry_types.h&quot;
 #include &quot;gen_inc.h&quot;
+#include &quot;ezxml/ezxml.h&quot;
 
 int parse_reg(FILE *, struct namelist **, struct dimension **, struct variable **, struct group_list **);
 int getword(FILE *, char *);
@@ -30,9 +31,16 @@
    nls = NULL;
    dims = NULL;
    vars = NULL;
+  
+   if (parse_reg_xml(regfile, &amp;nls, &amp;dims, &amp;vars, &amp;groups)) {
+      return 1;
+   }
+  
+/* Old Parser
    if (parse_reg(regfile, &amp;nls, &amp;dims, &amp;vars, &amp;groups)) {
       return 1;
    }
+*/
 
    sort_vars(vars);
    sort_group_vars(groups);
@@ -45,7 +53,391 @@
    return 0;
 }
 
+int parse_reg_xml(FILE * regfile, struct namelist **nls, struct dimension ** dims, struct variable ** vars, struct group_list ** groups)
+{
+        struct namelist * nls_ptr, *nls_ptr2;
+        struct namelist * nls_chk_ptr;
+        struct dimension * dim_ptr, *dim_ptr2;
+        struct variable * var_ptr, *var_ptr2;
+        struct dimension_list * dimlist_ptr;
+        struct dimension * dimlist_cursor;
+        struct group_list * grouplist_ptr;
+        struct variable_list * vlist_cursor;
 
+        ezxml_t registry = ezxml_parse_fp(regfile);
+        ezxml_t dims_xml, dim_xml;
+        ezxml_t structs_xml, var_arr_xml, var_xml;
+        ezxml_t nmlrecs_xml, nmlopt_xml;
+
+        const char *dimname, *dimunits, *dimdesc, *dimdef;
+        const char *nmlrecname, *nmloptname, *nmlopttype, *nmloptval, *nmloptunits, *nmloptdesc, *nmloptposvals;
+        const char *structname, *structlevs;
+        const char *vararrname, *vararrtype, *vararrdims, *vararrpersistence;
+        const char *varname, *varpersistence, *vartype, *vardims, *varunits, *vardesc, *vararrgroup, *varstreams;
+        const char *varname_in_code;
+
+        char dimensions[2048];
+        char *dimension_list;
+        char dimension_buffer[128];
+        char streams_buffer[128];
+
+        NEW_NAMELIST(nls_ptr)
+        NEW_DIMENSION(dim_ptr)
+        NEW_VARIABLE(var_ptr)
+        NEW_GROUP_LIST(grouplist_ptr);
+        *nls = nls_ptr;
+        *dims = dim_ptr;
+        *vars = var_ptr;
+        *groups = grouplist_ptr;
+
+        // Parse Namelist Records
+        for (nmlrecs_xml = ezxml_child(registry, &quot;nml_record&quot;); nmlrecs_xml; nmlrecs_xml = nmlrecs_xml-&gt;next){
+                nmlrecname = ezxml_attr(nmlrecs_xml, &quot;name&quot;);
+                for (nmlopt_xml = ezxml_child(nmlrecs_xml, &quot;nml_option&quot;); nmlopt_xml; nmlopt_xml = nmlopt_xml-&gt;next){
+                        nmloptname = ezxml_attr(nmlopt_xml, &quot;name&quot;);
+                        nmlopttype = ezxml_attr(nmlopt_xml, &quot;type&quot;);
+                        nmloptval = ezxml_attr(nmlopt_xml, &quot;default_value&quot;);
+                        nmloptunits = ezxml_attr(nmlopt_xml, &quot;units&quot;);
+                        nmloptdesc = ezxml_attr(nmlopt_xml, &quot;description&quot;);
+                        nmloptposvals = ezxml_attr(nmlopt_xml, &quot;possible_values&quot;);
+
+                        snprintf(nls_ptr-&gt;record, 1024, &quot;%s&quot;, nmlrecname);
+                        snprintf(nls_ptr-&gt;name, 1024, &quot;%s&quot;, nmloptname);
+
+                        if(strncmp(nmlopttype, &quot;real&quot;, 1024) == 0){
+                                nls_ptr-&gt;vtype = REAL;
+                        } else if(strncmp(nmlopttype, &quot;integer&quot;, 1024) == 0){
+                                nls_ptr-&gt;vtype = INTEGER;
+                        } else if(strncmp(nmlopttype, &quot;logical&quot;, 1024) == 0){
+                                nls_ptr-&gt;vtype = LOGICAL;
+                        } else if(strncmp(nmlopttype, &quot;character&quot;, 1024) == 0){
+                                nls_ptr-&gt;vtype = CHARACTER;
+                        }
+
+                        switch(nls_ptr-&gt;vtype){
+                                case REAL:
+                                        nls_ptr-&gt;defval.rval = (float)atof(nmloptval);
+                                        break;
+                                case INTEGER:
+                                        nls_ptr-&gt;defval.ival = atoi(nmloptval);
+                                        break;
+                                case LOGICAL:
+                                        if(strncmp(nmloptval, &quot;true&quot;, 1024) ==0){
+                                                nls_ptr-&gt;defval.lval = 1;
+                                        } else if (strncmp(nmloptval, &quot;false&quot;, 1024) == 0){
+                                                nls_ptr-&gt;defval.lval = 0;
+                                        }
+                                        break;
+                                case CHARACTER:
+                                        snprintf(nls_ptr-&gt;defval.cval, 32, &quot;%s&quot;, nmloptval);
+                                        break;
+                        }
+
+                        NEW_NAMELIST(nls_ptr-&gt;next)
+                        nls_ptr2 = nls_ptr;
+                        nls_ptr = nls_ptr-&gt;next;
+                }
+        }
+
+        if(nls_ptr2-&gt;next) free(nls_ptr2-&gt;next);
+        nls_ptr2-&gt;next = NULL;
+
+        // Parse Dimensions
+        for (dims_xml = ezxml_child(registry, &quot;dims&quot;); dims_xml; dims_xml = dims_xml-&gt;next){
+                for (dim_xml = ezxml_child(dims_xml, &quot;dim&quot;); dim_xml; dim_xml = dim_xml-&gt;next){
+                        dimname = ezxml_attr(dim_xml, &quot;name&quot;);
+                        dimdef = ezxml_attr(dim_xml, &quot;definition&quot;);        
+                        dimunits = ezxml_attr(dim_xml, &quot;units&quot;);
+                        dimdesc = ezxml_attr(dim_xml, &quot;description&quot;);
+
+                        dim_ptr-&gt;namelist_defined = 0;
+
+                        snprintf(dim_ptr-&gt;name_in_file, 1024, &quot;%s&quot;, dimname);
+                        if(dimdef == NULL){
+                                snprintf(dim_ptr-&gt;name_in_code, 1024, &quot;%s&quot;, dimname);
+                                dim_ptr-&gt;constant_value = -1;
+                        } else {
+                                snprintf(dim_ptr-&gt;name_in_code, 1024, &quot;%s&quot;, dimdef);
+                                // Check namelist defined ??
+                                dim_ptr-&gt;constant_value = is_integer_constant(dim_ptr-&gt;name_in_code);
+                                if(strncmp(dim_ptr-&gt;name_in_code, &quot;namelist:&quot;, 9) == 0) {
+                                        dim_ptr-&gt;namelist_defined = 1;
+                                        snprintf(dim_ptr-&gt;name_in_code, 1024, &quot;%s&quot;, (dim_ptr-&gt;name_in_code)+9);
+
+                                        /* Check that the referenced namelist variable is defined as an integer variable */
+                                        nls_chk_ptr = (*nls)-&gt;next;
+                                        while (nls_chk_ptr) {
+                                                if (strncmp(nls_chk_ptr-&gt;name, dim_ptr-&gt;name_in_code, 1024) == 0) {
+                                                        if (nls_chk_ptr-&gt;vtype != INTEGER) {
+                                                                printf(&quot;</font>
<font color="black">Registry error: Namelist variable %s must be an integer for namelist-derived dimension %s</font>
<font color="black"></font>
<font color="blue">&quot;, nls_chk_ptr-&gt;name, dim_ptr-&gt;name_in_file);
+                                                                return 1;
+                                                        }
+                                                        break;
+                                                } 
+                                                nls_chk_ptr = nls_chk_ptr-&gt;next;
+                                        }
+                                        if (!nls_chk_ptr) {
+                                                printf(&quot;</font>
<font color="black">Registry error: Namelist variable %s not defined for namelist-derived dimension %s</font>
<font color="black"></font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code, dim_ptr-&gt;name_in_file);
+                                                return 1;
+                                        }
+
+                                }
+                        }
+
+                        NEW_DIMENSION(dim_ptr-&gt;next)
+                        dim_ptr2 = dim_ptr;
+                        dim_ptr = dim_ptr-&gt;next;
+                }   
+        }
+
+        if(dim_ptr2-&gt;next) free(dim_ptr2-&gt;next);
+        dim_ptr2-&gt;next = NULL;
+
+        // Parse Variable Structures
+        for(structs_xml = ezxml_child(registry, &quot;var_struct&quot;); structs_xml; structs_xml = structs_xml-&gt;next){
+                structname = ezxml_attr(structs_xml, &quot;name&quot;);
+                structlevs = ezxml_attr(structs_xml, &quot;time_levs&quot;);
+
+                grouplist_ptr = *groups;
+                while(grouplist_ptr-&gt;next) grouplist_ptr = grouplist_ptr-&gt;next;
+                NEW_GROUP_LIST(grouplist_ptr-&gt;next);
+                grouplist_ptr = grouplist_ptr-&gt;next;
+                snprintf(grouplist_ptr-&gt;name, 1024, &quot;%s&quot;, structname);
+                vlist_cursor = NULL;
+
+                // Parse variable arrays
+                for(var_arr_xml = ezxml_child(structs_xml, &quot;var_array&quot;); var_arr_xml; var_arr_xml = var_arr_xml-&gt;next){
+                        vararrname = ezxml_attr(var_arr_xml, &quot;name&quot;);
+                        vararrtype = ezxml_attr(var_arr_xml, &quot;type&quot;);
+                        vararrdims = ezxml_attr(var_arr_xml, &quot;dimensions&quot;);
+                        vararrpersistence = ezxml_attr(var_arr_xml, &quot;persistence&quot;);
+
+                        //Parse variables in variable arrays
+                        for(var_xml = ezxml_child(var_arr_xml, &quot;var&quot;); var_xml; var_xml = var_xml-&gt;next){
+                                varname = ezxml_attr(var_xml, &quot;name&quot;);
+                                varunits = ezxml_attr(var_xml, &quot;units&quot;);
+                                vardesc = ezxml_attr(var_xml, &quot;description&quot;);
+                                varstreams = ezxml_attr(var_xml, &quot;streams&quot;);
+                                vararrgroup = ezxml_attr(var_xml, &quot;array_group&quot;);
+                                varname_in_code = ezxml_attr(var_xml, &quot;name_in_code&quot;);
+
+                                if(vlist_cursor == NULL){
+                                        NEW_VARIABLE_LIST(grouplist_ptr-&gt;vlist);
+                                        vlist_cursor = grouplist_ptr-&gt;vlist;
+                                } else {
+                                        NEW_VARIABLE_LIST(vlist_cursor-&gt;next);
+                                        vlist_cursor-&gt;next-&gt;prev = vlist_cursor;
+                                        vlist_cursor = vlist_cursor-&gt;next;
+                                }
+                                vlist_cursor-&gt;var = var_ptr;
+                                vlist_cursor-&gt;next = NULL;
+
+                                var_ptr-&gt;ndims = 0;
+                                var_ptr-&gt;timedim = 0;
+                                var_ptr-&gt;iostreams = 0;
+
+                                snprintf(var_ptr-&gt;name_in_file, 1024, &quot;%s&quot;, varname);
+
+                                if(vararrpersistence == NULL){
+                                        var_ptr-&gt;persistence = PERSISTENT;
+                                } else {
+                                        if(strncmp(vararrpersistence, &quot;persistent&quot;, 1024) == 0){
+                                                var_ptr-&gt;persistence = PERSISTENT;
+                                        } else if(strncmp(vararrpersistence, &quot;scratch&quot;, 1024) == 0){
+                                                var_ptr-&gt;persistence = SCRATCH;
+                                        }
+                                }
+
+                                if(strncmp(vararrtype, &quot;real&quot;, 1024) == 0){
+                                        var_ptr-&gt;vtype = REAL;
+                                } else if(strncmp(vararrtype, &quot;integer&quot;, 1024) == 0){
+                                        var_ptr-&gt;vtype = INTEGER;
+                                } else if(strncmp(vararrtype, &quot;logical&quot;, 1024) == 0){
+                                        var_ptr-&gt;vtype = LOGICAL;
+                                } else if(strncmp(vararrtype, &quot;text&quot;, 1024) == 0){
+                                        var_ptr-&gt;vtype = CHARACTER;
+                                }
+
+                                NEW_DIMENSION_LIST(dimlist_ptr)
+                                var_ptr-&gt;dimlist = dimlist_ptr;
+
+                                snprintf(dimensions,2048, &quot;%s&quot;, vararrdims);
+                                dimension_list = strtok(dimensions, &quot; &quot;);
+                                while(dimension_list != NULL){
+                                        snprintf(dimension_buffer, 128, &quot;%s&quot;, dimension_list);
+                                        if(strncmp(dimension_buffer, &quot;Time&quot;, 1024) == 0){
+                                                var_ptr-&gt;timedim = 1;
+                                        } else {
+                                                NEW_DIMENSION_LIST(dimlist_ptr-&gt;next)
+                                                dimlist_ptr-&gt;next-&gt;prev = dimlist_ptr;
+                                                dimlist_ptr = dimlist_ptr-&gt;next;
+
+                                                dimlist_cursor = (*dims);
+                                                while(dimlist_cursor &amp;&amp; (strncmp(dimension_buffer, dimlist_cursor-&gt;name_in_file, 1024) != 0)){
+                                                        dimlist_cursor = dimlist_cursor-&gt;next;
+                                                }
+                                                if (dimlist_cursor) {
+                                                        dimlist_ptr-&gt;dim = dimlist_cursor;
+                                                } else {
+                                                        fprintf(stderr, &quot;Error: Unknown dimension %s for variable %s</font>
<font color="blue">&quot;, dimension_buffer, var_ptr-&gt;name_in_file);
+                                                        return 1;
+                                                }
+                                                var_ptr-&gt;ndims++;
+                                        }
+                                        dimension_list = strtok(NULL, &quot; &quot;);
+                                }
+                                dimlist_ptr = var_ptr-&gt;dimlist;
+                                if(var_ptr-&gt;dimlist) var_ptr-&gt;dimlist = var_ptr-&gt;dimlist-&gt;next;
+                                free(dimlist_ptr);
+
+                                var_ptr-&gt;ntime_levs = atoi(structlevs);
+
+                                if(varstreams != NULL){
+                                        snprintf(streams_buffer, 128, &quot;%s&quot;, varstreams);
+                                        if(strchr(streams_buffer, (int)'i')) var_ptr-&gt;iostreams |= INPUT0;
+                                        if(strchr(streams_buffer, (int)'s')) var_ptr-&gt;iostreams |= SFC0;
+                                        if(strchr(streams_buffer, (int)'r')) var_ptr-&gt;iostreams |= RESTART0;
+                                        if(strchr(streams_buffer, (int)'o')) var_ptr-&gt;iostreams |= OUTPUT0;
+                                }
+
+                                if(varname_in_code == NULL){
+                                        snprintf(var_ptr-&gt;name_in_code, 1024, &quot;%s&quot;, varname);
+                                } else {
+                                        snprintf(var_ptr-&gt;name_in_code, 1024, &quot;%s&quot;, varname_in_code);
+                                }
+
+                                snprintf(var_ptr-&gt;super_array, 1024, &quot;%s&quot;, vararrname);
+                                snprintf(var_ptr-&gt;array_class, 1024, &quot;%s&quot;, vararrgroup);
+
+                                NEW_VARIABLE(var_ptr-&gt;next);
+                                var_ptr2 = var_ptr;
+                                var_ptr = var_ptr-&gt;next;
+                        }
+                }
+
+                for(var_xml = ezxml_child(structs_xml, &quot;var&quot;); var_xml; var_xml = var_xml-&gt;next){
+                        varname = ezxml_attr(var_xml, &quot;name&quot;);
+                        varpersistence = ezxml_attr(var_xml, &quot;persistence&quot;);
+                        vartype = ezxml_attr(var_xml, &quot;type&quot;);
+                        vardims = ezxml_attr(var_xml, &quot;dimensions&quot;);
+                        varunits = ezxml_attr(var_xml, &quot;units&quot;);
+                        vardesc = ezxml_attr(var_xml, &quot;description&quot;);
+                        varstreams = ezxml_attr(var_xml, &quot;streams&quot;);
+                        varname_in_code = ezxml_attr(var_xml, &quot;name_in_code&quot;);
+
+                        if(vlist_cursor == NULL){
+                                NEW_VARIABLE_LIST(grouplist_ptr-&gt;vlist);
+                                vlist_cursor = grouplist_ptr-&gt;vlist;
+                        } else {
+                                NEW_VARIABLE_LIST(vlist_cursor-&gt;next);
+                                vlist_cursor-&gt;next-&gt;prev = vlist_cursor;
+                                vlist_cursor = vlist_cursor-&gt;next;
+                        }
+                        vlist_cursor-&gt;var = var_ptr;
+                        vlist_cursor-&gt;next = NULL;
+
+                        var_ptr-&gt;ndims = 0;
+                        var_ptr-&gt;timedim = 0;
+                        var_ptr-&gt;iostreams = 0;
+
+                        snprintf(var_ptr-&gt;name_in_file, 1024, &quot;%s&quot;, varname);
+
+                        if(varpersistence == NULL){
+                                var_ptr-&gt;persistence = PERSISTENT;
+                        } else {
+                                if(strncmp(varpersistence, &quot;persistent&quot;, 1024) == 0){
+                                        var_ptr-&gt;persistence = PERSISTENT;
+                                } else if(strncmp(varpersistence, &quot;scratch&quot;, 1024) == 0){
+                                        var_ptr-&gt;persistence = SCRATCH;
+                                }
+                        }
+
+                        if(strncmp(vartype, &quot;real&quot;, 1024) == 0){
+                                var_ptr-&gt;vtype = REAL;
+                        } else if(strncmp(vartype, &quot;integer&quot;, 1024) == 0){
+                                var_ptr-&gt;vtype = INTEGER;
+                        } else if(strncmp(vartype, &quot;logical&quot;, 1024) == 0){
+                                var_ptr-&gt;vtype = LOGICAL;
+                        } else if(strncmp(vartype, &quot;text&quot;, 1024) == 0){
+                                var_ptr-&gt;vtype = CHARACTER;
+                        }
+
+                        NEW_DIMENSION_LIST(dimlist_ptr)
+                        var_ptr-&gt;dimlist = dimlist_ptr;
+
+                        snprintf(dimensions, 2048, &quot;%s&quot;, vardims);
+                        dimension_list = strtok(dimensions, &quot; &quot;);
+                        while(dimension_list != NULL){
+                                snprintf(dimension_buffer, 128, &quot;%s&quot;, dimension_list);
+                                if(strncmp(dimension_buffer, &quot;Time&quot;, 1024) == 0){
+                                        var_ptr-&gt;timedim = 1;
+                                } else {
+                                        NEW_DIMENSION_LIST(dimlist_ptr-&gt;next)
+                                        dimlist_ptr-&gt;next-&gt;prev = dimlist_ptr;
+                                        dimlist_ptr = dimlist_ptr-&gt;next;
+
+                                        dimlist_cursor = (*dims);
+                                        while(dimlist_cursor &amp;&amp; (strncmp(dimension_buffer, dimlist_cursor-&gt;name_in_file, 1024) != 0) )
+                                                dimlist_cursor = dimlist_cursor-&gt;next;
+                                        if (dimlist_cursor) {
+                                                dimlist_ptr-&gt;dim = dimlist_cursor;
+                                        } else {
+                                                fprintf(stderr, &quot;Error: Unknown dimension %s for variable %s</font>
<font color="gray">&quot;, dimension_buffer, var_ptr-&gt;name_in_file);
+                                                return 1;
+                                        }
+                                        var_ptr-&gt;ndims++;
+                                }
+                                dimension_list = strtok(NULL, &quot; &quot;);
+                        }
+
+                        dimlist_ptr = var_ptr-&gt;dimlist;
+                        if(var_ptr-&gt;dimlist) var_ptr-&gt;dimlist = var_ptr-&gt;dimlist-&gt;next;
+                        free(dimlist_ptr);
+
+                        var_ptr-&gt;ntime_levs = atoi(structlevs);
+
+                        if(varstreams != NULL){
+                                snprintf(streams_buffer, 128, &quot;%s&quot;, varstreams);
+                                if(strchr(streams_buffer, (int)'i')) {
+                                        var_ptr-&gt;iostreams |= INPUT0;
+                                }
+                                if(strchr(streams_buffer, (int)'s')) {
+                                        var_ptr-&gt;iostreams |= SFC0;
+                                }
+                                if(strchr(streams_buffer, (int)'r')) {
+                                        var_ptr-&gt;iostreams |= RESTART0;
+                                }
+                                if(strchr(streams_buffer, (int)'o')) {
+                                        var_ptr-&gt;iostreams |= OUTPUT0;
+                                }
+                        }
+
+                        if(varname_in_code == NULL){
+                                snprintf(var_ptr-&gt;name_in_code, 1024, &quot;%s&quot;, varname);
+                        } else {
+                                snprintf(var_ptr-&gt;name_in_code, 1024, &quot;%s&quot;, varname_in_code);
+                        }
+
+                        snprintf(var_ptr-&gt;super_array, 1024, &quot;-&quot;);
+                        snprintf(var_ptr-&gt;array_class, 1024, &quot;-&quot;);
+
+                        NEW_VARIABLE(var_ptr-&gt;next);
+                        var_ptr2 = var_ptr;
+                        var_ptr = var_ptr-&gt;next;
+                }
+        }
+
+        if(var_ptr2-&gt;next) free(var_ptr2-&gt;next);
+        var_ptr2-&gt;next = NULL;
+
+        grouplist_ptr = *groups;
+        if ((*groups)-&gt;next) *groups = (*groups)-&gt;next;
+        if (grouplist_ptr) free(grouplist_ptr);
+
+        return 0;
+}
+
+
 int parse_reg(FILE * regfile, struct namelist ** nls, struct dimension ** dims, struct variable ** vars, struct group_list ** groups)
 {
    char word[1024];
@@ -228,7 +620,6 @@
             vlist_cursor-&gt;var = var_ptr;
          }
 
-
          getword(regfile, var_ptr-&gt;super_array);
          getword(regfile, var_ptr-&gt;array_class);
 
@@ -402,7 +793,7 @@
          memcpy(super_array, var_ptr-&gt;var-&gt;super_array, 1024);
          var_ptr2_prev = var_ptr;
          var_ptr2 = var_ptr-&gt;next;
-         if (var_ptr2 &amp;&amp; strncmp(super_array, var_ptr2-&gt;var-&gt;super_array, 1024) != 0) {
+         if (var_ptr2 != NULL &amp;&amp; strncmp(super_array, var_ptr2-&gt;var-&gt;super_array, 1024) != 0) {
             while (var_ptr2) {
                if (strncmp(super_array, var_ptr2-&gt;var-&gt;super_array, 1024) == 0) {
                   var_ptr2_prev-&gt;next = var_ptr2-&gt;next;

</font>
</pre>