<p><b>lowrie@lanl.gov</b> 2013-04-21 19:31:32 -0600 (Sun, 21 Apr 2013)</p><p><br>
Merge in trunk changes.<br>
</p><hr noshade><pre><font color="gray">Index: branches/mpas_cdg_advection
===================================================================
--- branches/mpas_cdg_advection        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection        2013-04-22 01:31:32 UTC (rev 2783)

Property changes on: branches/mpas_cdg_advection
___________________________________________________________________
Modified: svn:mergeinfo
## -1,9 +1,11 ##
 /branches/atmos_physics:1672-1846
 /branches/cam_mpas_nh:1260-1270
+/branches/history_attribute:2698-2745
 /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
## -21,6 +23,7 ##
 /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/variable_name_change:2689-2767
 /branches/ocean_projects/vert_adv_mrp:704-745
 /branches/ocean_projects/vol_cons_RK_imp_mix:1965-1992
 /branches/ocean_projects/zstar_restart_new:1762-1770
## -29,6 +32,9 ##
 /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:2390-2599
+/branches/xml_registry:2610-2662
+/branches/zoltan_cleaning:2753-2760
+/trunk/mpas:2390-2782
\ No newline at end of property
Modified: branches/mpas_cdg_advection/Makefile
===================================================================
--- branches/mpas_cdg_advection/Makefile        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/Makefile        2013-04-22 01:31:32 UTC (rev 2783)
@@ -4,15 +4,7 @@
 # This flag must be off for nersc hopper:
 FILE_OFFSET = -DOFFSET64BIT
 
-#########################
-# Section for Zoltan TPL
-#########################
-ifdef ZOLTAN_HOME
-   ZOLTAN_DEFINE = -DHAVE_ZOLTAN
-endif
-#########################
 
-
 dummy:
         ( $(MAKE) error )
 
@@ -32,7 +24,7 @@
         &quot;DEBUG = $(DEBUG)&quot; \
         &quot;SERIAL = $(SERIAL)&quot; \
         &quot;USE_PAPI = $(USE_PAPI)&quot; \
-        &quot;CPPFLAGS = $(MODEL_FORMULATION) $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
+        &quot;CPPFLAGS = $(MODEL_FORMULATION) $(FILE_OFFSET)&quot; )
  
 ftn:
         ( $(MAKE) all \
@@ -47,7 +39,7 @@
         &quot;DEBUG = $(DEBUG)&quot; \
         &quot;SERIAL = $(SERIAL)&quot; \
         &quot;USE_PAPI = $(USE_PAPI)&quot; \
-        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
+        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET)&quot; )
 
 pgi:
         ( $(MAKE) all \
@@ -65,7 +57,7 @@
         &quot;DEBUG = $(DEBUG)&quot; \
         &quot;SERIAL = $(SERIAL)&quot; \
         &quot;USE_PAPI = $(USE_PAPI)&quot; \
-        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
+        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET)&quot; )
 
 pgi-nersc:
         ( $(MAKE) all \
@@ -80,7 +72,7 @@
         &quot;DEBUG = $(DEBUG)&quot; \
         &quot;SERIAL = $(SERIAL)&quot; \
         &quot;USE_PAPI = $(USE_PAPI)&quot; \
-        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
+        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET)&quot; )
 
 pgi-llnl:
         ( $(MAKE) all \
@@ -95,7 +87,7 @@
         &quot;DEBUG = $(DEBUG)&quot; \
         &quot;SERIAL = $(SERIAL)&quot; \
         &quot;USE_PAPI = $(USE_PAPI)&quot; \
-        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
+        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET)&quot; )
 
 ifort:
         ( $(MAKE) all \
@@ -113,7 +105,7 @@
         &quot;DEBUG = $(DEBUG)&quot; \
         &quot;SERIAL = $(SERIAL)&quot; \
         &quot;USE_PAPI = $(USE_PAPI)&quot; \
-        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE -m64 $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
+        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE -m64 $(FILE_OFFSET)&quot; )
 
 gfortran:
         ( $(MAKE) all \
@@ -131,7 +123,7 @@
         &quot;DEBUG = $(DEBUG)&quot; \
         &quot;SERIAL = $(SERIAL)&quot; \
         &quot;USE_PAPI = $(USE_PAPI)&quot; \
-        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE -m64 $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
+        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE -m64 $(FILE_OFFSET)&quot; )
 
 g95:
         ( $(MAKE) all \
@@ -146,7 +138,7 @@
         &quot;DEBUG = $(DEBUG)&quot; \
         &quot;SERIAL = $(SERIAL)&quot; \
         &quot;USE_PAPI = $(USE_PAPI)&quot; \
-        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
+        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET)&quot; )
 
 pathscale-nersc:
         ( $(MAKE) all \
@@ -161,7 +153,7 @@
         &quot;DEBUG = $(DEBUG)&quot; \
         &quot;SERIAL = $(SERIAL)&quot; \
         &quot;USE_PAPI = $(USE_PAPI)&quot; \
-        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
+        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET)&quot; )
 
 cray-nersc:
         ( $(MAKE) all \
@@ -176,7 +168,7 @@
         &quot;DEBUG = $(DEBUG)&quot; \
         &quot;SERIAL = $(SERIAL)&quot; \
         &quot;USE_PAPI = $(USE_PAPI)&quot; \
-        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
+        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET)&quot; )
 
 intel-nersc:
         ( $(MAKE) all \
@@ -191,11 +183,20 @@
         &quot;DEBUG = $(DEBUG)&quot; \
         &quot;SERIAL = $(SERIAL)&quot; \
         &quot;USE_PAPI = $(USE_PAPI)&quot; \
-        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
+        &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET)&quot; )
 
-CPPINCLUDES = -I../inc -I$(NETCDF)/include -I$(PIO) -I$(PNETCDF)/include
-FCINCLUDES = -I../inc -I$(NETCDF)/include -I$(PIO) -I$(PNETCDF)/include
-LIBS = -L$(PIO) -L$(PNETCDF)/lib -L$(NETCDF)/lib -lpio -lpnetcdf
+CPPINCLUDES = 
+FCINCLUDES = 
+LIBS = 
+ifneq ($(wildcard $(PIO)/lib), ) # Check for newer PIO version
+        CPPINCLUDES = -I../inc -I$(NETCDF)/include -I$(PIO)/include -I$(PNETCDF)/include
+        FCINCLUDES = -I../inc -I$(NETCDF)/include -I$(PIO)/include -I$(PNETCDF)/include
+        LIBS = -L$(PIO)/lib -L$(PNETCDF)/lib -L$(NETCDF)/lib -lpio -lpnetcdf
+else
+        CPPINCLUDES = -I../inc -I$(NETCDF)/include -I$(PIO) -I$(PNETCDF)/include
+        FCINCLUDES = -I../inc -I$(NETCDF)/include -I$(PIO) -I$(PNETCDF)/include
+        LIBS = -L$(PIO) -L$(PNETCDF)/lib -L$(NETCDF)/lib -lpio -lpnetcdf
+endif
 
 NCLIB = -lnetcdf
 NCLIBF = -lnetcdff
@@ -208,25 +209,7 @@
 CPP = cpp -C -P -traditional
 RANLIB = ranlib
 
-#########################
-# Section for Zoltan TPL
-#########################
-ifdef ZOLTAN_HOME
-   ifdef ZOLTAN_INC_PATH
-      FCINCLUDES += -I$(ZOLTAN_INC_PATH)
-   else
-      FCINCLUDES += -I$(ZOLTAN_HOME)/include
-   endif
 
-   ifdef ZOLTAN_LIB_PATH
-      LIBS += -L$(ZOLTAN_LIB_PATH) -lzoltan
-   else
-      LIBS += -L$(ZOLTAN_HOME)/lib -lzoltan
-   endif
-endif
-#########################
-
-
 ifdef CORE
 
 ifeq &quot;$(DEBUG)&quot; &quot;true&quot;
@@ -353,12 +336,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/mpas_cdg_advection/namelist.input.nhyd_atmos
===================================================================
--- branches/mpas_cdg_advection/namelist.input.nhyd_atmos        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/namelist.input.nhyd_atmos        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,56 +1,56 @@
 &amp;nhyd_model
    config_time_integration = 'SRK3'
    config_dt = 450.0
-   config_start_time = '2010-10-23_00:00:00'
+   config_start_time   = '2010-10-23_00:00:00'
    config_run_duration = '5_00:00:00'
    config_number_of_sub_steps = 6
-   config_h_mom_eddy_visc2 = 0.0
-   config_h_mom_eddy_visc4 = 0.0
-   config_v_mom_eddy_visc2 = 0.0
-   config_h_theta_eddy_visc2 = 0.0
-   config_h_theta_eddy_visc4 = 0.0
-   config_v_theta_eddy_visc2 = 0.0
-   config_horiz_mixing = '2d_smagorinsky'
-   config_len_disp = 120000.0
-   config_theta_adv_order = 3
-   config_scalar_adv_order = 3
-   config_w_adv_order = 3
-   config_u_vadv_order = 3
-   config_w_vadv_order = 3
-   config_theta_vadv_order = 3
-   config_scalar_vadv_order = 3
-   config_coef_3rd_order = 0.25
-   config_positive_definite = .true.
-   config_monotonic = .false.
-   config_epssm = 0.1
-   config_smdiv = 0.1
-   config_h_ScaleWithMesh = .false.
-   config_sfc_update_interval = &quot;none&quot;
-   config_newpx = .false.
+   config_h_mom_eddy_visc2    = 0.0
+   config_h_mom_eddy_visc4    = 0.0
+   config_v_mom_eddy_visc2    = 0.0
+   config_h_theta_eddy_visc2  = 0.0
+   config_h_theta_eddy_visc4  = 0.0
+   config_v_theta_eddy_visc2  = 0.0
+   config_horiz_mixing        = '2d_smagorinsky'
+   config_len_disp            = 120000.0
+   config_visc4_2dsmag        = 0.05
+   config_u_vadv_order        = 3
+   config_w_vadv_order        = 3
+   config_theta_vadv_order    = 3
+   config_scalar_vadv_order   = 3
+   config_w_adv_order         = 3
+   config_theta_adv_order     = 3
+   config_scalar_adv_order    = 3
+   config_scalar_advection    = .true.
+   config_positive_definite   = .false.
+   config_monotonic           = .true.
+   config_coef_3rd_order      = 0.25
+   config_epssm               = 0.1
+   config_smdiv               = 0.1
+   config_h_ScaleWithMesh     = .false.
+   config_newpx               = .false.
+   config_sfc_update_interval = 'none'
 /
    config_stop_time  = '0000-01-16_00:00:00'
 
 &amp;damping
    config_zd = 22000.0
-   config_xnutr = 0.0
+   config_xnutr = 0.2
 /
 
 &amp;io
-   config_input_name = 'x1.40962.init.nc'
-   config_output_name = 'x1.40962.output.nc'
-   config_restart_name = 'restart.nc'
-   config_output_interval = '1_00:00:00'
+   config_input_name         = 'x1.40962.init.nc'
+   config_output_name        = 'x1.40962.output.nc'
+   config_restart_name       = 'x1.40962.restart.nc'
+   config_output_interval    = '1_00:00:00'
    config_frames_per_outfile = 1
-   config_pio_num_iotasks = 0
-   config_pio_stride      = 1
+   config_pio_num_iotasks    = 0
+   config_pio_stride         = 1
 /
-   config_sfc_update_name = 'sfc_update.nc'
+   config_sfc_update_name    = 'x1.40962.sfc_update.nc'
 
 &amp;decomposition
-   config_number_of_blocks = 0
+   config_number_of_blocks         = 0
    config_block_decomp_file_prefix = 'x1.40962.graph.info.part.'
-   config_explicit_proc_decomp = .false.
-   config_proc_decomp_file_prefix = 'graph.info.part.'
 /
 
 &amp;restart
@@ -59,27 +59,30 @@
 /
 
 &amp;physics
-  config_frac_seaice         =  .false.
-  config_sfc_albedo          =  .true.
-  config_sst_update          =  .false.
-  config_sstdiurn_update     =  .false.
-  config_deepsoiltemp_update =  .false.
-
-  config_n_microp            =   5
-
-  config_radtlw_interval     = '00:30:00'
-  config_radtsw_interval     = '00:30:00'
-  config_conv_interval       = 'none'
-  config_pbl_interval        = 'none'
-
-  config_microp_scheme       =  'wsm6'
-  config_conv_shallow_scheme =  'off'
-  config_conv_deep_scheme    =  'kain_fritsch'
-  config_eddy_scheme         =  'off'
-  config_lsm_scheme          =  'noah'
-  config_pbl_scheme          =  'ysu'
-  config_radt_cld_scheme     =  'off'
-  config_radt_lw_scheme      =  'rrtmg_lw'
-  config_radt_sw_scheme      =  'rrtmg_sw'
-  config_sfclayer_scheme     =  'monin_obukhov'
+   config_frac_seaice         = .false.
+   config_sfc_albedo          = .true.
+   config_sfc_snowalbedo      = .true.
+   config_sst_update          = .false.
+   config_sstdiurn_update     = .false.
+   config_deepsoiltemp_update = .false.
+   config_bucket_update       = 'none'
+   config_bucket_rainc        = 100.0
+   config_bucket_rainnc       = 100.0
+   config_bucket_radt         = 1.0e9
+   config_radtlw_interval     = '00:30:00'
+   config_radtsw_interval     = '00:30:00'
+   config_conv_interval       = 'none'
+   config_pbl_interval        = 'none'
+   config_n_microp            = 5
+   config_microp_scheme       = 'wsm6'
+   config_conv_shallow_scheme = 'off'
+   config_conv_deep_scheme    = 'kain_fritsch'
+   config_eddy_scheme         = 'off'
+   config_lsm_scheme          = 'noah'
+   config_pbl_scheme          = 'ysu'
+   config_gwdo_scheme         = 'off'
+   config_radt_cld_scheme     = 'off'
+   config_radt_lw_scheme      = 'rrtmg_lw'
+   config_radt_sw_scheme      = 'rrtmg_sw'
+   config_sfclayer_scheme     = 'monin_obukhov'
 /

Modified: branches/mpas_cdg_advection/namelist.input.ocean
===================================================================
--- branches/mpas_cdg_advection/namelist.input.ocean        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/namelist.input.ocean        2013-04-22 01:31:32 UTC (rev 2783)
@@ -113,7 +113,7 @@
 /
 &amp;pressure_gradient
         config_pressure_gradient_type = 'pressure_and_zmid'
-        config_rho0 = 1014.65
+        config_density0 = 1014.65
 /
 &amp;eos
         config_eos_type = 'jm'
@@ -123,7 +123,7 @@
         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
+        config_eos_linear_densityref = 1025.022
 /
 &amp;split_explicit_ts
         config_n_ts_iter = 2
@@ -132,11 +132,11 @@
         config_n_bcl_iter_end = 2
         config_n_btr_subcycles = 20
         config_n_btr_cor_iter = 2
-        config_u_correction = .true.
+        config_vel_correction = .true.
         config_btr_subcycle_loop_factor = 2
-        config_btr_gam1_uWt1 = 0.5
+        config_btr_gam1_velWt1 = 0.5
         config_btr_gam2_SSHWt1 = 1.0
-        config_btr_gam3_uWt2 = 1.0
+        config_btr_gam3_velWt2 = 1.0
         config_btr_solve_SSH2 = .false.
 /
 &amp;debug
@@ -146,16 +146,16 @@
         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_thick_all_tend = .false.
+        config_disable_thick_hadv = .false.
+        config_disable_thick_vadv = .false.
+        config_disable_vel_all_tend = .false.
+        config_disable_vel_coriolis = .false.
+        config_disable_vel_pgrad = .false.
+        config_disable_vel_hmix = .false.
+        config_disable_vel_windstress = .false.
+        config_disable_vel_vmix = .false.
+        config_disable_vel_vadv = .false.
         config_disable_tr_all_tend = .false.
         config_disable_tr_adv = .false.
         config_disable_tr_hmix = .false.

Modified: branches/mpas_cdg_advection/src/Makefile
===================================================================
--- branches/mpas_cdg_advection/src/Makefile        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/Makefile        2013-04-22 01:31:32 UTC (rev 2783)
@@ -10,7 +10,6 @@
 
 all: mpas
 
-
 mpas: reg_includes externals frame ops dycore drver
         $(LINKER) $(LDFLAGS) -o $(CORE)_model.exe driver/*.o -L. -ldycore -lops -lframework $(LIBS) -I./external/esmf_time_f90 -L./external/esmf_time_f90 -lesmf_time
 
@@ -23,7 +22,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 ) 

Modified: branches/mpas_cdg_advection/src/Makefile.in.CESM_OCN
===================================================================
--- branches/mpas_cdg_advection/src/Makefile.in.CESM_OCN        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/Makefile.in.CESM_OCN        2013-04-22 01:31:32 UTC (rev 2783)
@@ -7,7 +7,7 @@
 PNETCDF=$(PNETCDF_PATH)
 PIO=$(EXEROOT)/pio
 FILE_OFFSET = -DOFFSET64BIT
-CPPFLAGS += $(MODEL_FORMULATION) $(FILE_OFFSET) $(ZOLTAN_DEFINE) -DMPAS_CESM -D_MPI# -DUNDERSCORE
+CPPFLAGS += $(MODEL_FORMULATION) $(FILE_OFFSET) -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

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/Makefile
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/Makefile        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/Makefile        2013-04-22 01:31:32 UTC (rev 2783)
@@ -6,6 +6,8 @@
 ifeq ($(CORE),nhyd_atmos)
 COREDEF = -Dnon_hydrostatic_core 
 endif
+HYDROSTATIC = -Ddo_hydrostatic_pressure
+#HYDROSTATIC =
 
 dummy:
         echo &quot;****** make non-hydrostatic core ******&quot;
@@ -17,16 +19,17 @@
 OBJS = \
         mpas_atmphys_driver_cloudiness.o      \
         mpas_atmphys_driver_convection_deep.o \
+        mpas_atmphys_driver_gwdo.o            \
         mpas_atmphys_driver_lsm.o             \
         mpas_atmphys_driver_microphysics.o    \
         mpas_atmphys_driver_radiation_lw.o    \
         mpas_atmphys_driver_radiation_sw.o    \
         mpas_atmphys_driver_sfclayer.o        \
         mpas_atmphys_driver_pbl.o             \
+        mpas_atmphys_driver.o                 \
         mpas_atmphys_camrad_init.o            \
         mpas_atmphys_control.o                \
         mpas_atmphys_date_time.o              \
-        mpas_atmphys_driver.o                 \
         mpas_atmphys_init.o                   \
         mpas_atmphys_landuse.o                \
         mpas_atmphys_lsm_noahinit.o           \
@@ -73,6 +76,10 @@
         ./physics_wrf/module_cu_kfeta.o     \
         ./physics_wrf/module_cu_tiedtke.o
 
+mpas_atmphys_driver_gwdo.o: \
+        mpas_atmphys_vars.o                 \
+        ./physics_wrf/module_bl_gwdo.o
+
 mpas_atmphys_driver_lsm.o: \
         mpas_atmphys_constants.o            \
         mpas_atmphys_landuse.o              \
@@ -203,6 +210,7 @@
 
 mpas_atmphys_driver.o: \
         mpas_atmphys_driver_convection_deep.o \
+        mpas_atmphys_driver_gwdo.o            \
         mpas_atmphys_driver_pbl.o             \
         mpas_atmphys_driver_radiation_lw.o    \
         mpas_atmphys_driver_radiation_sw.o    \
@@ -225,5 +233,5 @@
 
 .F.o:
         $(RM) $@ $*.mod
-        $(CPP) $(CPPFLAGS) $(COREDEF) $(CPPINCLUDES)  -DIWORDSIZE=4 -DRWORDSIZE=8 $&lt; &gt; $*.f90
+        $(CPP) $(CPPFLAGS) $(COREDEF) $(HYDROSTATIC) $(CPPINCLUDES)  -DIWORDSIZE=4 -DRWORDSIZE=8 $&lt; &gt; $*.f90
         $(FC) $(FFLAGS) -c $*.f90 $(FCINCLUDES) -I../framework -I../operators -I./physics_wrf -I./physics_eaung -I../external/esmf_time_f90

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_control.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_control.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_control.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -35,16 +35,17 @@
 
  write(0,*)
  write(0,*) '--- enter subroutine physics_namelist_check:'
- write(0,*) '    config_microp_scheme       = ', config_microp_scheme
- write(0,*) '    config_conv_shallow_scheme = ', config_conv_shallow_scheme
- write(0,*) '    config_conv_deep_scheme    = ', config_conv_deep_scheme
- write(0,*) '    config_eddy_scheme         = ', config_eddy_scheme
- write(0,*) '    config_lsm_scheme          = ', config_lsm_scheme
- write(0,*) '    config_pbl_scheme          = ', config_pbl_scheme
- write(0,*) '    config_radt_cld_scheme     = ', config_radt_cld_scheme
- write(0,*) '    config_radt_lw_scheme      = ', config_radt_lw_scheme
- write(0,*) '    config_radt_sw_scheme      = ', config_radt_sw_scheme
- write(0,*) '    config_sfclayer_scheme     = ', config_sfclayer_scheme
+ write(0,*) '    config_microp_scheme       = ', trim(config_microp_scheme)
+ write(0,*) '    config_conv_shallow_scheme = ', trim(config_conv_shallow_scheme)
+ write(0,*) '    config_conv_deep_scheme    = ', trim(config_conv_deep_scheme)
+ write(0,*) '    config_eddy_scheme         = ', trim(config_eddy_scheme)
+ write(0,*) '    config_lsm_scheme          = ', trim(config_lsm_scheme)
+ write(0,*) '    config_pbl_scheme          = ', trim(config_pbl_scheme)
+ write(0,*) '    config_gwdo_scheme         = ', trim(config_gwdo_scheme)
+ write(0,*) '    config_radt_cld_scheme     = ', trim(config_radt_cld_scheme)
+ write(0,*) '    config_radt_lw_scheme      = ', trim(config_radt_lw_scheme)
+ write(0,*) '    config_radt_sw_scheme      = ', trim(config_radt_sw_scheme)
+ write(0,*) '    config_sfclayer_scheme     = ', trim(config_sfclayer_scheme)
 
 !cloud microphysics scheme:
  if(.not. (config_microp_scheme .eq. 'off'      .or. &amp;
@@ -93,6 +94,22 @@
 
  endif
 
+!gravity wave drag over orography scheme:
+ if(.not. (config_gwdo_scheme .eq. 'off' .or. &amp;
+           config_gwdo_scheme .eq. 'ysu_gwdo')) then
+
+    write(mpas_err_message,'(A,A10)') 'illegal value for gwdo_scheme: ', &amp;
+          trim(config_gwdo_scheme)
+    call physics_error_fatal(mpas_err_message)
+
+ elseif(config_gwdo_scheme .eq. 'ysu_gwdo' .and. config_pbl_scheme .ne. 'ysu') then
+
+    write(mpas_err_message,'(A,A10)') 'turn YSU PBL scheme on with config_gwdo = ysu_gwdo:', &amp;
+          trim(config_gwdo_scheme)
+    call physics_error_fatal(mpas_err_message)
+
+ endif
+
 !diffusion scheme:
  if(.not. (config_eddy_scheme .eq. 'off')) then
  

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_date_time.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_date_time.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_date_time.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -85,7 +85,6 @@
 
 !local variables:
  character(len=StrKIND):: day15,mon
- character(len=StrKIND):: yr
 
  integer:: l,n
  integer:: julyr,julday,int_month,month1,month2
@@ -144,7 +143,7 @@
     endif
  enddo find_month
  
- 201 format(i6,3(1x,e15.8))
+! 201 format(i6,3(1x,e15.8))
 
  end subroutine monthly_interp_to_date
 

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -5,6 +5,7 @@
 
  use mpas_atmphys_driver_cloudiness
  use mpas_atmphys_driver_convection_deep
+ use mpas_atmphys_driver_gwdo
  use mpas_atmphys_driver_pbl
  use mpas_atmphys_driver_lsm
  use mpas_atmphys_driver_radiation_sw 
@@ -59,7 +60,8 @@
 
     !physics prep step:
 #ifdef non_hydrostatic_core
-    call MPAS_to_physics(block%mesh,block%state%time_levs(1)%state,block%diag)
+    call MPAS_to_physics(block%mesh,block%state%time_levs(1)%state,block%diag, &amp;
+                         block%diag_physics)
 #elif hydrostatic_core
     call MPAS_to_physics(block%state%time_levs(1)%state,block%diag)
 #endif
@@ -118,6 +120,14 @@
        call deallocate_pbl
     endif
 
+    !call to gravity wave drag over orography scheme:
+    if(config_gwdo_scheme .ne. 'off') then
+       call allocate_gwdo
+       call driver_gwdo(itimestep,block%mesh,block%sfc_input,block%diag_physics, &amp;
+                        block%tend_physics)
+       call deallocate_gwdo
+    endif
+
     !call to convection scheme:
     call update_convection_step1(block%mesh,block%diag_physics,block%tend_physics)
     if(l_conv) then

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_convection_deep.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_convection_deep.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_convection_deep.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -290,7 +290,10 @@
        else
           ktau = itimestep + 1
        endif
+#if defined(do_hydrostatic_pressure)
+!... REARRANGED CALL USING HYDROSTATIC PRESSURE:
        call  kf_eta_cps ( &amp;
+             pcps      = pres_hyd_p , t               = t_p             ,            &amp;
 !            dt        = dt_dyn     , ktau            = itimestep       ,            &amp;
              dt        = dt_dyn     , ktau            = ktau            ,            &amp;
              areaCell  = area_p     , cudt            = cudt            ,            &amp;
@@ -298,9 +301,8 @@
              rho       = rho_p      , raincv          = raincv_p        ,            &amp;
              pratec    = pratec_p   , nca             = nca_p           ,            &amp;
              u         = u_p        , v               = v_p             ,            &amp;
-             th        = th_p       , t               = t_p             ,            &amp;
+             th        = th_p       , pi              = pi_p            ,            &amp;
              w         = w_p        , dz8w            = dz_p            ,            &amp;
-             pcps      = pres_p     , pi              = pi_p            ,            &amp;
              w0avg     = w0avg_p    , xlv0            = xlv0            ,            &amp;
              xlv1      = xlv1       , xls0            = xls0            ,            &amp;
              xls1      = xls1       , cp              = cp              ,            &amp;
@@ -320,22 +322,90 @@
              ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde , &amp;
              ims = ims , ime = ime , jms = jms , jme = jme , kms = kds , kme = kme , &amp;
              its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte   &amp;
-                    )
+                        )
+#else
+!... REARRANGED CALL:
+       call  kf_eta_cps ( &amp;
+             pcps      = pres_p     , t               = t_p             ,            &amp;
+!            dt        = dt_dyn     , ktau            = itimestep       ,            &amp;
+             dt        = dt_dyn     , ktau            = ktau            ,            &amp;
+             areaCell  = area_p     , cudt            = cudt            ,            &amp;
+             curr_secs = curr_secs  , adapt_step_flag = adapt_step_flag ,            &amp;
+             rho       = rho_p      , raincv          = raincv_p        ,            &amp;
+             pratec    = pratec_p   , nca             = nca_p           ,            &amp;
+             u         = u_p        , v               = v_p             ,            &amp;
+             th        = th_p       , pi              = pi_p            ,            &amp;
+             w         = w_p        , dz8w            = dz_p            ,            &amp;
+             w0avg     = w0avg_p    , xlv0            = xlv0            ,            &amp;
+             xlv1      = xlv1       , xls0            = xls0            ,            &amp;
+             xls1      = xls1       , cp              = cp              ,            &amp;
+             r         = r_d        , g               = g               ,            &amp;
+             ep1       = ep_1       , ep2             = ep_2            ,            &amp;
+             svp1      = svp1       , svp2            = svp2            ,            &amp;
+             svp3      = svp3       , svpt0           = svpt0           ,            &amp;
+             stepcu    = n_cu       , cu_act_flag     = cu_act_flag     ,            &amp;
+             warm_rain = warm_rain  , cutop           = cutop_p         ,            &amp;
+             cubot     = cubot_p    , qv              = qv_p            ,            &amp;
+             f_qv      = f_qv       , f_qc            = f_qc            ,            &amp;
+             f_qr      = f_qr       , f_qi            = f_qi            ,            &amp;
+             f_qs      = f_qs       , rthcuten        = rthcuten_p      ,            &amp;
+             rqvcuten  = rqvcuten_p , rqccuten        = rqccuten_p      ,            &amp;
+             rqrcuten  = rqrcuten_p , rqicuten        = rqicuten_p      ,            &amp;
+             rqscuten  = rqscuten_p ,                                                &amp;
+             ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde , &amp;
+             ims = ims , ime = ime , jms = jms , jme = jme , kms = kds , kme = kme , &amp;
+             its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte   &amp;
+                        )
+#endif
+!... CALL FROM REVISION 1721:
+!      call  kf_eta_cps ( &amp;
+!            dt        = dt_dyn     , ktau            = itimestep       ,            &amp;
+!            dt        = dt_dyn     , ktau            = ktau            ,            &amp;
+!            areaCell  = area_p     , cudt            = cudt            ,            &amp;
+!            curr_secs = curr_secs  , adapt_step_flag = adapt_step_flag ,            &amp;
+!            rho       = rho_p      , raincv          = raincv_p        ,            &amp;
+!            pratec    = pratec_p   , nca             = nca_p           ,            &amp;
+!            u         = u_p        , v               = v_p             ,            &amp;
+!            th        = th_p       , t               = t_p             ,            &amp;
+!            w         = w_p        , dz8w            = dz_p            ,            &amp;
+!            pcps      = pres_p     , pi              = pi_p            ,            &amp;
+!            w0avg     = w0avg_p    , xlv0            = xlv0            ,            &amp;
+!            xlv1      = xlv1       , xls0            = xls0            ,            &amp;
+!            xls1      = xls1       , cp              = cp              ,            &amp;
+!            r         = r_d        , g               = g               ,            &amp;
+!            ep1       = ep_1       , ep2             = ep_2            ,            &amp;
+!            svp1      = svp1       , svp2            = svp2            ,            &amp;
+!            svp3      = svp3       , svpt0           = svpt0           ,            &amp;
+!            stepcu    = n_cu       , cu_act_flag     = cu_act_flag     ,            &amp;
+!            warm_rain = warm_rain  , cutop           = cutop_p         ,            &amp;
+!            cubot     = cubot_p    , qv              = qv_p            ,            &amp;
+!            f_qv      = f_qv       , f_qc            = f_qc            ,            &amp;
+!            f_qr      = f_qr       , f_qi            = f_qi            ,            &amp;
+!            f_qs      = f_qs       , rthcuten        = rthcuten_p      ,            &amp;
+!            rqvcuten  = rqvcuten_p , rqccuten        = rqccuten_p      ,            &amp;
+!            rqrcuten  = rqrcuten_p , rqicuten        = rqicuten_p      ,            &amp;
+!            rqscuten  = rqscuten_p ,                                                &amp;
+!            ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde , &amp;
+!            ims = ims , ime = ime , jms = jms , jme = jme , kms = kds , kme = kme , &amp;
+!            its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte   &amp;
+!                   )
 
     case(&quot;tiedtke&quot;)
        write(0,*) '--- enter subroutine cu_tiedtke:'
+#if defined(do_hydrostatic_pressure)
+!... REARRANGED CALL USING HYDROSTATIC PRESSURE:
        call cu_tiedtke ( &amp;
+             pcps        = pres_hyd_p  , p8w             = pres2_hyd_p     ,         &amp;
+             znu         = znu_hyd_p   , t3d             = t_p             ,         &amp;              
              dt          = dt_dyn      , itimestep       = itimestep       ,         &amp;
              stepcu      = n_cu        , raincv          = raincv_p        ,         &amp;
              pratec      = pratec_p    , qfx             = qfx_p           ,         &amp;
-             znu         = znu_p       , u3d             = u_p             ,         &amp;
-             v3d         = v_p         , w               = w_p             ,         &amp;
-             t3d         = t_p         , qv3d            = qv_p            ,         &amp;
+             u3d         = u_p         , v3d             = v_p             ,         &amp; 
+             w           = w_p         , qv3d            = qv_p            ,         &amp;
              qc3d        = qc_p        , qi3d            = qi_p            ,         &amp;
              pi3d        = pi_p        , rho3d           = rho_p           ,         &amp;
              qvften      = rqvdynten_p , qvpblten        = rqvdynblten_p   ,         &amp;
-             dz8w        = dz_p        , pcps            = pres_p          ,         &amp;
-             p8w         = pres2_p     , xland           = xland_p         ,         &amp;
+             dz8w        = dz_p        , xland           = xland_p         ,         &amp;
              cu_act_flag = cu_act_flag , cudt            = dt_cu           ,         &amp;
 !            curr_secs   = curr_secs   , adapt_step_flag = adapt_step_flag ,         &amp;
 !            cudtacttime = cudtacttime , f_qv            = f_qv            ,         &amp;
@@ -349,6 +419,60 @@
              ims = ims , ime = ime , jms = jms , jme = jme , kms = kds , kme = kme , &amp;
              its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte   &amp;
                     )
+#else
+!... REARRANGED CALL:
+       call cu_tiedtke ( &amp;
+             pcps        = pres_p      , p8w             = pres2_p         ,         &amp;
+             znu         = znu_p       , t3d             = t_p             ,         &amp;              
+             dt          = dt_dyn      , itimestep       = itimestep       ,         &amp;
+             stepcu      = n_cu        , raincv          = raincv_p        ,         &amp;
+             pratec      = pratec_p    , qfx             = qfx_p           ,         &amp;
+             u3d         = u_p         , v3d             = v_p             ,         &amp; 
+             w           = w_p         , qv3d            = qv_p            ,         &amp;
+             qc3d        = qc_p        , qi3d            = qi_p            ,         &amp;
+             pi3d        = pi_p        , rho3d           = rho_p           ,         &amp;
+             qvften      = rqvdynten_p , qvpblten        = rqvdynblten_p   ,         &amp;
+             dz8w        = dz_p        , xland           = xland_p         ,         &amp;
+             cu_act_flag = cu_act_flag , cudt            = dt_cu           ,         &amp;
+!            curr_secs   = curr_secs   , adapt_step_flag = adapt_step_flag ,         &amp;
+!            cudtacttime = cudtacttime , f_qv            = f_qv            ,         &amp;
+             f_qv        = f_qv        ,                                             &amp;
+             f_qc        = f_qc        , f_qr            = f_qr            ,         &amp;
+             f_qi        = f_qi        , f_qs            = f_qs            ,         &amp;        
+             rthcuten    = rthcuten_p  , rqvcuten        = rqvcuten_p      ,         &amp;
+             rqccuten    = rqccuten_p  , rqicuten        = rqicuten_p      ,         &amp;
+             rucuten     = rucuten_p   , rvcuten         = rvcuten_p       ,         &amp;
+             ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde , &amp;
+             ims = ims , ime = ime , jms = jms , jme = jme , kms = kds , kme = kme , &amp;
+             its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte   &amp;
+                    )
+#endif
+!... CALL FROM REVISION 1721:
+!      call cu_tiedtke ( &amp;
+!            dt          = dt_dyn      , itimestep       = itimestep       ,         &amp;
+!            stepcu      = n_cu        , raincv          = raincv_p        ,         &amp;
+!            pratec      = pratec_p    , qfx             = qfx_p           ,         &amp;
+!            znu         = znu_p       , u3d             = u_p             ,         &amp;
+!            v3d         = v_p         , w               = w_p             ,         &amp;
+!            t3d         = t_p         , qv3d            = qv_p            ,         &amp;
+!            qc3d        = qc_p        , qi3d            = qi_p            ,         &amp;
+!            pi3d        = pi_p        , rho3d           = rho_p           ,         &amp;
+!            qvften      = rqvdynten_p , qvpblten        = rqvdynblten_p   ,         &amp;
+!            dz8w        = dz_p        , pcps            = pres_p          ,         &amp;
+!            p8w         = pres2_p     , xland           = xland_p         ,         &amp;
+!            cu_act_flag = cu_act_flag , cudt            = dt_cu           ,         &amp;
+!            curr_secs   = curr_secs   , adapt_step_flag = adapt_step_flag ,         &amp;
+!            cudtacttime = cudtacttime , f_qv            = f_qv            ,         &amp;
+!            f_qv        = f_qv        ,                                             &amp;
+!            f_qc        = f_qc        , f_qr            = f_qr            ,         &amp;
+!            f_qi        = f_qi        , f_qs            = f_qs            ,         &amp;        
+!            rthcuten    = rthcuten_p  , rqvcuten        = rqvcuten_p      ,         &amp;
+!            rqccuten    = rqccuten_p  , rqicuten        = rqicuten_p      ,         &amp;
+!            rucuten     = rucuten_p   , rvcuten         = rvcuten_p       ,         &amp;
+!            ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde , &amp;
+!            ims = ims , ime = ime , jms = jms , jme = jme , kms = kds , kme = kme , &amp;
+!            its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte   &amp;
+!                   )
 
     case default
 

Copied: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_gwdo.F (from rev 2782, trunk/mpas/src/core_atmos_physics/mpas_atmphys_driver_gwdo.F)
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_gwdo.F                                (rev 0)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_gwdo.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -0,0 +1,236 @@
+!=============================================================================================
+ module mpas_atmphys_driver_gwdo
+ use mpas_configure, only: len_disp =&gt; config_len_disp
+ use mpas_grid_types
+
+ use mpas_atmphys_constants
+ use mpas_atmphys_vars
+
+!from wrf physics:
+ use module_bl_gwdo
+
+ implicit none
+ private
+ public:: allocate_gwdo,   &amp;
+          deallocate_gwdo, &amp;
+          driver_gwdo
+
+ integer,private:: i,j,k
+
+ contains
+
+!=============================================================================================
+ subroutine allocate_gwdo
+!=============================================================================================
+
+ if(.not.allocated(dx_p)    ) allocate(dx_p(ims:ime,jms:jme)    )
+ if(.not.allocated(var2d_p) ) allocate(var2d_p(ims:ime,jms:jme) )
+ if(.not.allocated(con_p)   ) allocate(con_p(ims:ime,jms:jme)   )
+ if(.not.allocated(oa1_p)   ) allocate(oa1_p(ims:ime,jms:jme)   )
+ if(.not.allocated(oa2_p)   ) allocate(oa2_p(ims:ime,jms:jme)   )
+ if(.not.allocated(oa3_p)   ) allocate(oa3_p(ims:ime,jms:jme)   )
+ if(.not.allocated(oa4_p)   ) allocate(oa4_p(ims:ime,jms:jme)   )
+ if(.not.allocated(ol1_p)   ) allocate(ol1_p(ims:ime,jms:jme)   )
+ if(.not.allocated(ol2_p)   ) allocate(ol2_p(ims:ime,jms:jme)   )
+ if(.not.allocated(ol3_p)   ) allocate(ol3_p(ims:ime,jms:jme)   )
+ if(.not.allocated(ol4_p)   ) allocate(ol4_p(ims:ime,jms:jme)   )
+ if(.not.allocated(kpbl_p  )) allocate(kpbl_p(ims:ime,jms:jme)  )
+ if(.not.allocated(dusfcg_p)) allocate(dusfcg_p(ims:ime,jms:jme))
+ if(.not.allocated(dvsfcg_p)) allocate(dvsfcg_p(ims:ime,jms:jme))

+ if(.not.allocated(dtaux3d_p)) allocate(dtaux3d_p(ims:ime,kms:kme,jms:jme))
+ if(.not.allocated(dtauy3d_p)) allocate(dtauy3d_p(ims:ime,kms:kme,jms:jme))
+ if(.not.allocated(rublten_p)) allocate(rublten_p(ims:ime,kms:kme,jms:jme))
+ if(.not.allocated(rvblten_p)) allocate(rvblten_p(ims:ime,kms:kme,jms:jme))
+
+ end subroutine allocate_gwdo
+
+!=============================================================================================
+ subroutine deallocate_gwdo
+!=============================================================================================
+
+ if(allocated(dx_p)    ) deallocate(dx_p    )
+ if(allocated(var2d_p) ) deallocate(var2d_p )
+ if(allocated(con_p)   ) deallocate(con_p   )
+ if(allocated(oa1_p)   ) deallocate(oa1_p   )
+ if(allocated(oa2_p)   ) deallocate(oa2_p   )
+ if(allocated(oa3_p)   ) deallocate(oa3_p   )
+ if(allocated(oa4_p)   ) deallocate(oa4_p   )
+ if(allocated(ol1_p)   ) deallocate(ol1_p   )
+ if(allocated(ol2_p)   ) deallocate(ol2_p   )
+ if(allocated(ol3_p)   ) deallocate(ol3_p   )
+ if(allocated(ol4_p)   ) deallocate(ol4_p   )
+ if(allocated(kpbl_p  )) deallocate(kpbl_p  )
+ if(allocated(dusfcg_p)) deallocate(dusfcg_p)
+ if(allocated(dvsfcg_p)) deallocate(dvsfcg_p)

+ if(allocated(dtaux3d_p)) deallocate(dtaux3d_p)
+ if(allocated(dtauy3d_p)) deallocate(dtauy3d_p)
+ if(allocated(rublten_p)) deallocate(rublten_p)
+ if(allocated(rvblten_p)) deallocate(rvblten_p)
+
+ end subroutine deallocate_gwdo
+
+!=============================================================================================
+ subroutine gwdo_from_MPAS(mesh,sfc_input,diag_physics,tend_physics)
+!=============================================================================================
+
+!input arguments:
+ type(mesh_type),intent(in):: mesh
+ type(sfc_input_type),intent(in)   :: sfc_input
+ type(diag_physics_type),intent(in):: diag_physics
+ type(tend_physics_type),intent(in):: tend_physics
+
+!local variables:
+ integer:: iEdge
+
+!---------------------------------------------------------------------------------------------
+
+ do j = jts,jte
+ do i = its,ite
+    iEdge = mesh%nEdgesOnCell%array(i)
+    dx_p(i,j) = maxval(mesh%dcEdge%array(mesh%edgesOnCell%array(1:iEdge,i)))
+ enddo
+ enddo
+
+ do j = jts,jte
+ do i = its,ite
+    var2d_p(i,j) = sfc_input % var2d % array(i)
+    con_p(i,j)   = sfc_input % con   % array(i)
+    oa1_p(i,j)   = sfc_input % oa1   % array(i)
+    oa2_p(i,j)   = sfc_input % oa2   % array(i)
+    oa3_p(i,j)   = sfc_input % oa3   % array(i)
+    oa4_p(i,j)   = sfc_input % oa4   % array(i)
+    ol1_p(i,j)   = sfc_input % ol1   % array(i)
+    ol2_p(i,j)   = sfc_input % ol2   % array(i)
+    ol3_p(i,j)   = sfc_input % ol3   % array(i)
+    ol4_p(i,j)   = sfc_input % ol4   % array(i)
+ enddo
+ enddo
+
+ do j = jts,jte
+ do i = its,ite
+    kpbl_p(i,j)   = diag_physics % kpbl   % array(i)
+    dusfcg_p(i,j) = diag_physics % dusfcg % array(i)
+    dvsfcg_p(i,j) = diag_physics % dvsfcg % array(i)
+ enddo
+ enddo
+
+ do j = jts,jte
+ do k = kts,kte
+ do i = its,ite
+    dtaux3d_p(i,k,j) = diag_physics % dtaux3d % array(k,i)
+    dtauy3d_p(i,k,j) = diag_physics % dtauy3d % array(k,i)
+    rublten_p(i,k,j) = tend_physics % rublten % array(k,i)
+    rvblten_p(i,k,j) = tend_physics % rvblten % array(k,i)
+ enddo
+ enddo
+ enddo
+
+ end subroutine gwdo_from_MPAS

+!=============================================================================================
+ subroutine gwdo_to_MPAS(diag_physics,tend_physics)
+!=============================================================================================
+
+!inout arguments:
+ type(diag_physics_type),intent(inout):: diag_physics
+ type(tend_physics_type),intent(inout):: tend_physics
+
+!---------------------------------------------------------------------------------------------
+
+ do j = jts,jte
+ do i = its,ite
+    diag_physics % dusfcg % array(i) = dusfcg_p(i,j) 
+    diag_physics % dvsfcg % array(i) = dvsfcg_p(i,j)
+ enddo
+ enddo
+
+ do j = jts,jte
+ do k = kts,kte
+ do i = its,ite
+    diag_physics % dtaux3d % array(k,i) = dtaux3d_p(i,k,j)
+    diag_physics % dtauy3d % array(k,i) = dtauy3d_p(i,k,j)
+    diag_physics % rubldiff % array(k,i) = rublten_p(i,k,j)-tend_physics%rublten%array(k,i)
+    diag_physics % rvbldiff % array(k,i) = rvblten_p(i,k,j)-tend_physics%rvblten%array(k,i) 
+
+    tend_physics % rublten % array(k,i) = rublten_p(i,k,j)
+    tend_physics % rvblten % array(k,i) = rvblten_p(i,k,j)
+ enddo
+ enddo
+ enddo
+
+!write(0,*)
+!write(0,*) '--- end subroutine gwdo_to_MPAS:'
+!do i = its,ite
+!   write(0,101) i,diag_physics%dusfcg%array(i),diag_physics%dvsfcg%array(i)
+!enddo
+!101 format(i8,2(1x,e15.8))
+
+ end subroutine gwdo_to_MPAS

+!=============================================================================================
+ subroutine driver_gwdo(itimestep,mesh,sfc_input,diag_physics,tend_physics)
+!=============================================================================================
+
+!input arguments:
+ type(mesh_type),intent(in):: mesh
+ type(sfc_input_type),intent(in):: sfc_input
+ integer,intent(in):: itimestep
+
+!inout arguments:
+ type(diag_physics_type),intent(inout):: diag_physics
+ type(tend_physics_type),intent(inout):: tend_physics
+
+!local variables:
+ integer:: i,iCell,iEdge
+ real(kind=RKIND),dimension(:),allocatable:: dx_max
+
+!--------------------------------------------------------------------------------------------- 
+ write(0,*)
+ write(0,*) '--- enter subroutine driver_gwdo: dt_pbl=',dt_pbl
+
+!copy all MPAS arrays to rectanguler grid arrays:
+ call gwdo_from_MPAS(mesh,sfc_input,diag_physics,tend_physics)
+
+ gwdo_select: select case (trim(gwdo_scheme))
+
+    case(&quot;ysu_gwdo&quot;)
+#if defined(do_hydrostatic_pressure)
+!... REARRANGED CALL USING HYDROSTATIC PRESSURE:
+       call gwdo ( &amp;
+                  p3d       = pres_hydd_p , p3di      = pres2_hydd_p , pi3d    = pi_p      , &amp;
+                  u3d       = u_p         , v3d       = v_p          , t3d     = t_p       , &amp; 
+                  qv3d      = qv_p        , z         = z_p          , rublten = rublten_p , &amp;
+                  rvblten   = rvblten_p   , dtaux3d   = dtaux3d_p    , dtauy3d = dtauy3d_p , &amp;
+                  dusfcg    = dusfcg_p    , dvsfcg    = dvsfcg_p     , kpbl2d  = kpbl_p    , &amp;
+                  itimestep = itimestep   , dt        = dt_pbl       , dx      = dx_p      , &amp; 
+                  cp        = cp          , g         = g            , rd      = R_d       , &amp; 
+                  rv        = R_v         , ep1       = ep_1         , pi      = pii       , &amp; 
+                  var2d     = var2d_p     , oc12d     = con_p        , oa2d1   = oa1_p     , &amp; 
+                  oa2d2     = oa2_p       , oa2d3     = oa3_p        , oa2d4   = oa4_p     , &amp;
+                  ol2d1     = ol1_p       , ol2d2     = ol2_p        , ol2d3   = ol3_p     , &amp; 
+                  ol2d4     = ol4_p       ,                                                  &amp;
+                  ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde ,    &amp;
+                  ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,    &amp;
+                  its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte      &amp;
+                 )
+#else
+!... REARRANGED CALL:
+       call gwdo ( &amp;
+                 )
+#endif
+
+     case default
+
+ end select gwdo_select
+
+!copy all arrays back to the MPAS grid:
+ call gwdo_to_MPAS(diag_physics,tend_physics)
+ write(0,*) '--- end subroutine driver_gwdo'
+
+ end subroutine driver_gwdo
+
+!=============================================================================================
+ end module mpas_atmphys_driver_gwdo
+!=============================================================================================

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_lsm.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_lsm.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_lsm.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -75,7 +75,7 @@
  if(.not.allocated(qsfc_p)       ) allocate(qsfc_p(ims:ime,jms:jme)         )
  if(.not.allocated(qz0_p)        ) allocate(qz0_p(ims:ime,jms:jme)          )
  if(.not.allocated(rainbl_p)     ) allocate(rainbl_p(ims:ime,jms:jme)       )
- if(.not.allocated(rib_p)        ) allocate(rib_p(ims:ime,jms:jme)          )
+ if(.not.allocated(br_p)         ) allocate(br_p(ims:ime,jms:jme)          )
  if(.not.allocated(sfc_albbck_p) ) allocate(sfc_albbck_p(ims:ime,jms:jme)   )
  if(.not.allocated(sfc_albedo_p) ) allocate(sfc_albedo_p(ims:ime,jms:jme)   )
  if(.not.allocated(sfc_emibck_p) ) allocate(sfc_emibck_p(ims:ime,jms:jme)   )
@@ -139,7 +139,7 @@
  if(allocated(qsfc_p)       ) deallocate(qsfc_p       )
  if(allocated(qz0_p)        ) deallocate(qz0_p        )
  if(allocated(rainbl_p)     ) deallocate(rainbl_p     )
- if(allocated(rib_p)        ) deallocate(rib_p        )
+ if(allocated(br_p)         ) deallocate(br_p         )
  if(allocated(sfc_albbck_p) ) deallocate(sfc_albbck_p )
  if(allocated(sfc_albedo_p) ) deallocate(sfc_albedo_p )
  if(allocated(sfc_emibck_p) ) deallocate(sfc_emibck_p )
@@ -221,7 +221,7 @@
     qgh_p(i,j)        = diag_physics % qgh        % array(i)
     qsfc_p(i,j)       = diag_physics % qsfc       % array(i)
     qz0_p(i,j)        = diag_physics % qz0        % array(i)
-    rib_p(i,j)        = diag_physics % rib        % array(i)
+    br_p(i,j)         = diag_physics % br         % array(i)
     sfc_albedo_p(i,j) = diag_physics % sfc_albedo % array(i)
     sfc_emibck_p(i,j) = diag_physics % sfc_emibck % array(i)
     sfc_emiss_p(i,j)  = diag_physics % sfc_emiss  % array(i)
@@ -309,7 +309,7 @@
     diag_physics % qgh        % array(i) = qgh_p(i,j)
     diag_physics % qsfc       % array(i) = qsfc_p(i,j)
     diag_physics % qz0        % array(i) = qz0_p(i,j)
-    diag_physics % rib        % array(i) = rib_p(i,j)
+    diag_physics % br         % array(i) = br_p(i,j)
     diag_physics % sfc_albedo % array(i) = sfc_albedo_p(i,j)
     diag_physics % sfc_emibck % array(i) = sfc_emibck_p(i,j)
     diag_physics % sfc_emiss  % array(i) = sfc_emiss_p(i,j)
@@ -405,7 +405,46 @@
  lsm_select: select case (trim(lsm_scheme))
 
     case(&quot;noah&quot;)
+#if defined(do_hydrostatic_pressure)
+!... REARRANGED CALL USING HYDROSTATIC PRESSURE:
        call lsm( &amp;
+                dz8w      = dz_p      , p8w3d     = pres2_hyd_p  , t3d       = t_p          , &amp;  
+                qv3d      = qv_p      , xland     = xland_p      , xice      = xice_p       , &amp;
+                ivgtyp    = ivgtyp_p  , isltyp    = isltyp_p     , tmn       = tmn_p        , &amp;
+                vegfra    = vegfra_p  , shdmin    = shdmin_p     , shdmax    = shdmax_p     , &amp;
+                snoalb    = snoalb_p  , glw       = glw_p        , gsw       = gsw_p        , &amp;
+                swdown    = swdown_p  , rainbl    = rainbl_p     , embck     = sfc_emibck_p , &amp; 
+                sr        = sr_p      , qgh       = qgh_p        , cpm       = cpm_p        , &amp;
+                qz0       = qz0_p     , tsk       = tsk_p        , hfx       = hfx_p        , &amp; 
+                qfx       = qfx_p     , lh        = lh_p         , grdflx    = grdflx_p     , &amp;
+                qsfc      = qsfc_p    , cqs2      = cqs2_p       , chs       = chs_p        , &amp;
+                chs2      = chs2_p    , snow      = snow_p       , snowc     = snowc_p      , &amp;
+                snowh     = snowh_p   , canwat    = canwat_p     , smstav    = smstav_p     , &amp;
+                smstot    = smstot_p  , sfcrunoff = sfcrunoff_p  , udrunoff  = udrunoff_p   , &amp;               
+                acsnom    = acsnom_p  , acsnow    = acsnow_p     , snotime   = snotime_p    , &amp;
+                snopcx    = snopcx_p  , emiss     = sfc_emiss_p  , rib       = br_p         , &amp;
+                potevp    = potevp_p  , albedo    = sfc_albedo_p , albbck    = sfc_albbck_p , &amp;
+                z0        = z0_p      , znt       = znt_p        , lai       = lai_p        , &amp;
+                noahres   = noahres_p , chklowq   = chklowq_p    , sh2o      = sh2o_p       , &amp;
+                smois     = smois_p   , tslb      = tslb_p       , smcrel    = smcrel_p     , &amp;
+                dzs       = dzs_p     , isurban   = isurban      , isice     = isice        , &amp;                
+                rovcp     = rcp       , dt        = dt_pbl       , myj       = myj          , &amp;
+                itimestep = itimestep , frpcpn    = frpcpn       , rdlai2d   = rdlai2d      , &amp;
+                xice_threshold   = xice_threshold     ,                                       &amp;
+                usemonalb        = config_sfc_albedo  ,                                       &amp;
+                mminlu           = input_landuse_data ,                                       &amp;
+                num_soil_layers  = num_soil_layers    ,                                       &amp;         
+                num_roof_layers  = num_soil_layers    ,                                       &amp;
+                num_wall_layers  = num_soil_layers    ,                                       &amp;
+                num_road_layers  = num_soil_layers    ,                                       &amp;
+                num_urban_layers = num_soil_layers    ,                                       &amp;
+                sf_urban_physics = sf_urban_physics   ,                                       &amp;
+                ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde ,       &amp;
+                ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,       &amp;
+                its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte         &amp;
+               )
+#else
+       call lsm( &amp;
                 dz8w      = dz_p      , p8w3d     = pres2_p      , t3d       = t_p          , &amp;  
                 qv3d      = qv_p      , xland     = xland_p      , xice      = xice_p       , &amp;
                 ivgtyp    = ivgtyp_p  , isltyp    = isltyp_p     , tmn       = tmn_p        , &amp;
@@ -420,7 +459,7 @@
                 snowh     = snowh_p   , canwat    = canwat_p     , smstav    = smstav_p     , &amp;
                 smstot    = smstot_p  , sfcrunoff = sfcrunoff_p  , udrunoff  = udrunoff_p   , &amp;               
                 acsnom    = acsnom_p  , acsnow    = acsnow_p     , snotime   = snotime_p    , &amp;
-                snopcx    = snopcx_p  , emiss     = sfc_emiss_p  , rib       = rib_p        , &amp;
+                snopcx    = snopcx_p  , emiss     = sfc_emiss_p  , rib       = br_p         , &amp;
                 potevp    = potevp_p  , albedo    = sfc_albedo_p , albbck    = sfc_albbck_p , &amp;
                 z0        = z0_p      , znt       = znt_p        , lai       = lai_p        , &amp;
                 noahres   = noahres_p , chklowq   = chklowq_p    , sh2o      = sh2o_p       , &amp;
@@ -441,6 +480,7 @@
                 ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,       &amp;
                 its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte         &amp;
                )
+#endif
 
     case default
 

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_microphysics.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_microphysics.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_microphysics.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -294,6 +294,9 @@
     
  end do
 
+!... calculate the 10cm radar reflectivity, if needed:
+ if(l_diags) call compute_radar_reflectivity(diag_physics)
+
 !... copy updated precipitation from the wrf-physics grid back to the geodesic-dynamics grid:
 
  call precip_to_MPAS(config_bucket_rainnc,diag_physics)
@@ -382,7 +385,8 @@
  type(diag_physics_type),intent(inout):: diag_physics
 
 !local variables:
- integer:: i,j
+ integer:: i,j,k
+ real(kind=RKIND):: rho_a
 
 !---------------------------------------------------------------------------------------------
 
@@ -391,6 +395,14 @@
  do j = jts,jte
  do i = its,ite
 
+    !precipitable water:
+    diag_physics % precipw % array(i) = 0._RKIND
+    do k = kts,kte
+       rho_a = rho_p(i,k,j) / (1._RKIND + qv_p(i,k,j))
+       diag_physics % precipw % array(i) = &amp;
+            diag_physics % precipw % array(i) + qv_p(i,k,j) * rho_a * dz_p(i,k,j)
+    enddo
+
     !time-step precipitation:
     diag_physics % rainncv % array(i) = rainnc_p(i,j)
     
@@ -438,5 +450,81 @@
  end subroutine precip_to_MPAS
 
 !=============================================================================================
+ subroutine compute_radar_reflectivity(diag_physics)
+!=============================================================================================
+
+!inout arguments:
+ type(diag_physics_type),intent(inout):: diag_physics
+
+!local variables:
+ integer:: i,j,k
+ real(kind=RKIND),dimension(:),allocatable:: qv1d,qr1d,qs1d,qg1d,t1d,p1d,dBZ1d
+
+!---------------------------------------------------------------------------------------------
+!write(0,*)
+!write(0,*) '--- enter subroutine COMPUTE_RADAR_REFLECTIVITY:'
+
+ microp_select: select case(microp_scheme)
+
+    case (&quot;kessler&quot;)
+       call physics_error_fatal('--- calculation of radar reflectivity is not available' // &amp;
+                                 'with kessler cloud microphysics')
+
+    case (&quot;thompson&quot;)
+       call physics_error_fatal('--- calculation of radar reflectivity is not available' // &amp;
+                                 'with thompson cloud microphysics')
+
+    case (&quot;wsm6&quot;)
+
+       if(.not.allocated(p1d)  ) allocate(p1d(kts:kte)  )
+       if(.not.allocated(t1d)  ) allocate(t1d(kts:kte)  )
+       if(.not.allocated(qv1d) ) allocate(qv1d(kts:kte) )
+       if(.not.allocated(qr1d) ) allocate(qr1d(kts:kte) )
+       if(.not.allocated(qs1d) ) allocate(qs1d(kts:kte) )
+       if(.not.allocated(qg1d) ) allocate(qg1d(kts:kte) )
+       if(.not.allocated(dBz1d)) allocate(dBZ1d(kts:kte))
+
+       do j = jts,jte
+       do i = its,ite
+          do k = kts,kte
+             p1d(k) = pres_p(i,k,j)
+             t1d(k) = th_p(i,k,j) * pi_p(i,k,j)
+             qv1d(k)  = qv_p(i,k,j)
+             qr1d(k)  = qr_p(i,k,j)
+             qs1d(k)  = qs_p(i,k,j)
+             qg1d(k)  = qg_p(i,k,j)
+             dBZ1d(k) = -35._RKIND
+          enddo
+
+          call refl10cm_wsm6(qv1d,qr1d,qs1d,qg1d,t1d,p1d,dBZ1d,kts,kte,i,j)
+
+          do k = kts,kte
+             dBZ1d(k) = max(-35._RKIND,dBZ1d(k))
+!            write(0,201) i,k,dBZ1d(k)
+          enddo
+          diag_physics % refl10cm_max % array(i) = maxval(dBZ1d(:))
+!         if(diag_physics % refl10cm_max % array(i) .gt. 0.) &amp;
+!            write(0,201) j,i,diag_physics % refl10cm_max % array(i)
+       enddo
+       enddo
+
+       if(allocated(p1d)  ) deallocate(p1d  )
+       if(allocated(t1d)  ) deallocate(t1d  )
+       if(allocated(qv1d) ) deallocate(qv1d )
+       if(allocated(qr1d) ) deallocate(qr1d )
+       if(allocated(qs1d) ) deallocate(qs1d )
+       if(allocated(qg1d) ) deallocate(qg1d )
+       if(allocated(dBz1d)) deallocate(dBZ1d)
+
+    case default
+
+ end select microp_select
+!write(0,*) '--- end subroutine COMPUTE_RADAR_REFLECTIVITY'
+
+ 201 format(2i6,e15.8)
+
+ end subroutine compute_radar_reflectivity
+
+!=============================================================================================
  end module mpas_atmphys_driver_microphysics
 !=============================================================================================

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_pbl.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_pbl.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_pbl.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -24,11 +24,14 @@
 
 !from surface-layer model:
  if(.not.allocated(br_p)      ) allocate(br_p(ims:ime,jms:jme)               )
+ if(.not.allocated(ctopo_p)   ) allocate(ctopo_p(ims:ime,jms:jme)            )
+ if(.not.allocated(ctopo2_p)  ) allocate(ctopo2_p(ims:ime,jms:jme)           )
  if(.not.allocated(gz1oz0_p)  ) allocate(gz1oz0_p(ims:ime,jms:jme)           )
  if(.not.allocated(hfx_p)     ) allocate(hfx_p(ims:ime,jms:jme)              )
  if(.not.allocated(psih_p)    ) allocate(psih_p(ims:ime,jms:jme)             )
  if(.not.allocated(psim_p)    ) allocate(psim_p(ims:ime,jms:jme)             )
  if(.not.allocated(qfx_p)     ) allocate(qfx_p(ims:ime,jms:jme)              )
+ if(.not.allocated(regime_p)  ) allocate(regime_p(ims:ime,jms:jme)           )
  if(.not.allocated(u10_p)     ) allocate(u10_p(ims:ime,jms:jme)              )
  if(.not.allocated(ust_p)     ) allocate(ust_p(ims:ime,jms:jme)              )
  if(.not.allocated(v10_p)     ) allocate(v10_p(ims:ime,jms:jme)              )
@@ -46,6 +49,10 @@
  if(.not.allocated(rqvblten_p)) allocate(rqvblten_p(ims:ime,kms:kme,jms:jme) )
  if(.not.allocated(rqcblten_p)) allocate(rqcblten_p(ims:ime,kms:kme,jms:jme) )
  if(.not.allocated(rqiblten_p)) allocate(rqiblten_p(ims:ime,kms:kme,jms:jme) )
+!temporary for debugging the YSU PBL scheme:
+ if(.not.allocated(kzh_p)     ) allocate(kzh_p(ims:ime,kms:kme,jms:jme)      )
+ if(.not.allocated(kzm_p)     ) allocate(kzm_p(ims:ime,kms:kme,jms:jme)      )
+ if(.not.allocated(kzq_p)     ) allocate(kzq_p(ims:ime,kms:kme,jms:jme)      )
 
  end subroutine allocate_pbl
 
@@ -55,11 +62,14 @@
 
 !from surface-layer model:
  if(allocated(br_p)      ) deallocate(br_p       )
+ if(allocated(ctopo_p)   ) deallocate(ctopo_p    )
+ if(allocated(ctopo2_p)  ) deallocate(ctopo2_p   )
  if(allocated(gz1oz0_p)  ) deallocate(gz1oz0_p   )
  if(allocated(hfx_p)     ) deallocate(hfx_p      )
  if(allocated(psih_p)    ) deallocate(psih_p     )
  if(allocated(psim_p)    ) deallocate(psim_p     )
  if(allocated(qfx_p)     ) deallocate(qfx_p      )
+ if(allocated(regime_p)  ) deallocate(regime_p   )
  if(allocated(u10_p)     ) deallocate(u10_p      )
  if(allocated(ust_p)     ) deallocate(ust_p      )
  if(allocated(v10_p)     ) deallocate(v10_p      )
@@ -77,6 +87,10 @@
  if(allocated(rqvblten_p)) deallocate(rqvblten_p )
  if(allocated(rqcblten_p)) deallocate(rqcblten_p )
  if(allocated(rqiblten_p)) deallocate(rqiblten_p )
+!temporary for debugging the YSU PBL scheme:
+ if(allocated(kzh_p)     ) deallocate(kzh_p      )
+ if(allocated(kzm_p)     ) deallocate(kzm_p      )
+ if(allocated(kzq_p)     ) deallocate(kzq_p      )
 
  end subroutine deallocate_pbl
 
@@ -100,6 +114,7 @@
     psim_p(i,j)   = diag_physics % psim   % array(i)
     psih_p(i,j)   = diag_physics % psih   % array(i)
     qfx_p(i,j)    = diag_physics % qfx    % array(i)
+    regime_p(i,j) = diag_physics % regime % array(i)
     u10_p(i,j)    = diag_physics % u10    % array(i)
     ust_p(i,j)    = diag_physics % ust    % array(i)
     v10_p(i,j)    = diag_physics % v10    % array(i)
@@ -108,6 +123,8 @@
 
     xland_p(i,j)  = sfc_input % xland  % array(i)       
 !initialization for YSU PBL scheme:
+    ctopo_p(i,j)  = 1._RKIND
+    ctopo2_p(i,j) = 1._RKIND
     kpbl_p(i,j)   = 1
  enddo
  enddo
@@ -122,9 +139,12 @@
     rqvblten_p(i,k,j) = 0.
     rqcblten_p(i,k,j) = 0.
     rqiblten_p(i,k,j) = 0.
+!temporary for debugging the YSU PBL scheme:
+    kzh_p(i,k,j)    = 0._RKIND
+    kzm_p(i,k,j)    = 0._RKIND
+    kzq_p(i,k,j)    = 0._RKIND
  enddo
  enddo
-
  enddo
 
  end subroutine pbl_from_MPAS
@@ -156,6 +176,10 @@
     tend_physics % rqvblten % array(k,i) = rqvblten_p(i,k,j)
     tend_physics % rqcblten % array(k,i) = rqcblten_p(i,k,j)
     tend_physics % rqiblten % array(k,i) = rqiblten_p(i,k,j)
+!temporary for debugging the YSU PBL scheme:
+    diag_physics % kzh % array(k,i) = kzh_p(i,k,j)
+    diag_physics % kzm % array(k,i) = kzm_p(i,k,j)
+    diag_physics % kzq % array(k,i) = kzq_p(i,k,j)
  enddo
  enddo
  enddo
@@ -182,26 +206,55 @@
  pbl_select: select case (trim(pbl_scheme))
 
     case(&quot;ysu&quot;)
+#if defined(do_hydrostatic_pressure)
+!... REARRANGED CALL USING HYDROSTATIC PRESSURE:
        call ysu ( &amp;
-                 u3d      = u_p        , v3d      = v_p         , th3d     = th_p       , &amp;
-                 t3d      = t_p        , qv3d     = qv_p        , qc3d     = qc_p       , &amp;
-                 qi3d     = qi_p       , p3d      = pres_p      , p3di     = pres2_p    , &amp;
-                 pi3d     = pi_p       , rublten  = rublten_p   , rvblten  = rvblten_p  , &amp;
-                 rthblten = rthblten_p , rqvblten = rqvblten_p  , rqcblten = rqcblten_p , &amp;
-                 rqiblten = rqiblten_p , flag_qi  = f_qi        , cp       = cp         , &amp;
-                 g        = g          , rovcp    = rcp         , rd       = R_d        , &amp;
-                 rovg     = rdg        , ep1      = ep_1        , ep2      = ep_2       , &amp;
-                 karman   = karman     , xlv      = xlv         , rv       = R_v        , &amp;
-                 dz8w     = dz_p       , psfc     = psfc_p      , znt      = znt_p      , &amp;
+                 p3d      = pres_hyd_p , p3di     = pres2_hyd_p , psfc     = psfc_p     , &amp;
+                 th3d     = th_p       , t3d      = t_p         , dz8w     = dz_p       , &amp;
+                 pi3d     = pi_p       , u3d      = u_p         , v3d      = v_p        , &amp;
+                 qv3d     = qv_p       , qc3d     = qc_p        , qi3d     = qi_p       , &amp;
+                 rublten  = rublten_p  , rvblten  = rvblten_p   , rthblten = rthblten_p , &amp;
+                 rqvblten = rqvblten_p , rqcblten = rqcblten_p  , rqiblten = rqiblten_p , &amp; 
+                 flag_qi  = f_qi       , cp       = cp          , g        = g          , &amp;
+                 rovcp    = rcp        , rd       = R_d         , rovg     = rdg        , &amp; 
+                 ep1      = ep_1       , ep2      = ep_2        , karman   = karman     , &amp;
+                 xlv      = xlv        , rv       = R_v         , znt      = znt_p      , &amp;
                  ust      = ust_p      , hpbl     = hpbl_p      , psim     = psim_p     , &amp;
                  psih     = psih_p     , xland    = xland_p     , hfx      = hfx_p      , &amp;
-                 qfx      = qfx_p      , gz1oz0   = gz1oz0_p    , wspd     = wspd_p     , &amp;
-                 br       = br_p       , dt       = dt_pbl      , kpbl2d   = kpbl_p     , &amp;
-                 exch_h   = exch_p     , u10      = u10_p       , v10      = v10_p      , &amp;
+                 qfx      = qfx_p      , wspd     = wspd_p      , br       = br_p       , &amp;
+                 dt       = dt_pbl     , kpbl2d   = kpbl_p      , exch_h   = exch_p     , &amp;
+                 u10      = u10_p      , v10      = v10_p       , ctopo    = ctopo_p    , &amp; 
+                 ctopo2   = ctopo2_p   , regime   = regime_p    , rho      = rho_p      , &amp;
+                 kzhout   = kzh_p      , kzmout   = kzm_p       , kzqout   = kzq_p      , &amp;
                  ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde  , &amp;
                  ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme  , &amp;
                  its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte    &amp;
                 )
+#else
+!... REARRANGED CALL:
+       call ysu ( &amp;
+                 p3d      = pres_p     , p3di     = pres2_p     , psfc     = psfc_p     , &amp;
+                 th3d     = th_p       , t3d      = t_p         , dz8w     = dz_p       , &amp;
+                 pi3d     = pi_p       , u3d      = u_p         , v3d      = v_p        , &amp;
+                 qv3d     = qv_p       , qc3d     = qc_p        , qi3d     = qi_p       , &amp;
+                 rublten  = rublten_p  , rvblten  = rvblten_p   , rthblten = rthblten_p , &amp;
+                 rqvblten = rqvblten_p , rqcblten = rqcblten_p  , rqiblten = rqiblten_p , &amp; 
+                 flag_qi  = f_qi       , cp       = cp          , g        = g          , &amp;
+                 rovcp    = rcp        , rd       = R_d         , rovg     = rdg        , &amp; 
+                 ep1      = ep_1       , ep2      = ep_2        , karman   = karman     , &amp;
+                 xlv      = xlv        , rv       = R_v         , znt      = znt_p      , &amp;
+                 ust      = ust_p      , hpbl     = hpbl_p      , psim     = psim_p     , &amp;
+                 psih     = psih_p     , xland    = xland_p     , hfx      = hfx_p      , &amp;
+                 qfx      = qfx_p      , wspd     = wspd_p      , br       = br_p       , &amp;
+                 dt       = dt_pbl     , kpbl2d   = kpbl_p      , exch_h   = exch_p     , &amp;
+                 u10      = u10_p      , v10      = v10_p       , ctopo    = ctopo_p    , &amp; 
+                 ctopo2   = ctopo2_p   , regime   = regime_p    , rho      = rho_p      , &amp;
+                 kzhout   = kzh_p      , kzmout   = kzm_p       , kzqout   = kzq_p      , &amp;
+                 ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde  , &amp;
+                 ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme  , &amp;
+                 its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte    &amp;
+                )
+#endif
 
      case default
 
@@ -209,7 +262,7 @@
 
 !copy all arrays back to the MPAS grid:
  call pbl_to_MPAS(diag_physics,tend_physics)
- write(0,*) '--- enter subroutine driver_pbl'
+ write(0,*) '--- end subroutine driver_pbl'
 
  end subroutine driver_pbl
 

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_radiation_lw.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_radiation_lw.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_radiation_lw.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -524,14 +524,42 @@
 
     case (&quot;rrtmg_lw&quot;)
        write(0,*) '--- enter subroutine rrtmg_lwrad:'
+#if defined(do_hydrostatic_pressure)
+!... REARRANGED CALL USING HYDROSTATIC PRESSURE:
        call rrtmg_lwrad( &amp;
+                p3d        = pres_hyd_p   , p8w       = pres2_hyd_p , pi3d      = pi_p      , &amp;
+                t3d        = t_p          , t8w       = t2_p        , rho3d     = rho_p     , &amp;
+                rthratenlw = rthratenlw_p , lwupt     = lwupt_p     , lwuptc    = lwuptc_p  , &amp;
+                lwdnt      = lwdnt_p      , lwdntc    = lwdntc_p    , lwupb     = lwupb_p   , &amp;
+                lwupbc     = lwupbc_p     , lwdnb     = lwdnb_p     , lwdnbc    = lwdnbc_p  , &amp;
+                lwcf       = lwcf_p       , glw       = glw_p       , olr       = olrtoa_p  , &amp;
+                emiss      = sfc_emiss_p  , tsk       = tsk_p       , dz8w      = dz_p      , &amp;
+                cldfra3d   = cldfrac_p    , r         = R_d         , g         = g         , &amp;
+                icloud     = icloud       , warm_rain = warm_rain   , f_ice_phy = f_ice     , &amp;
+                f_rain_phy = f_rain       , xland     = xland_p     , xice      = xice_p    , &amp;
+                snow       = snow_p       , qv3d      = qv_p        , qc3d      = qc_p      , &amp;
+                qr3d       = qr_p         , qi3d      = qi_p        , qs3d      = qs_p      , &amp;
+                qg3d       = qg_p         , f_qv      = f_qv        , f_qc      = f_qc      , &amp;
+                f_qr       = f_qr         , f_qi      = f_qi        , f_qs      = f_qs      , &amp;
+                f_qg       = f_qg         ,                                                   &amp;
+                !begin optional arguments:
+                !lwupflx   = lwupflx_p    , lwupflxc  = lwupflxc_p  , lwdnflx   = lwdnflx_p , &amp;
+                !lwdnflxc  = lwdnflxc_p   ,                                                   &amp;
+                !end optional arguments.
+                ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde ,       &amp;
+                ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,       &amp;
+                its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte         &amp;
+                       )
+#else
+!... REARRANGED CALL:
+       call rrtmg_lwrad( &amp;
+                p3d        = pres_p       , p8w       = pres2_p    , pi3d      = pi_p      , &amp;
+                t3d        = t_p          , t8w       = t2_p       , rho3d     = rho_p     , &amp;
                 rthratenlw = rthratenlw_p , lwupt     = lwupt_p    , lwuptc    = lwuptc_p  , &amp;
                 lwdnt      = lwdnt_p      , lwdntc    = lwdntc_p   , lwupb     = lwupb_p   , &amp;
                 lwupbc     = lwupbc_p     , lwdnb     = lwdnb_p    , lwdnbc    = lwdnbc_p  , &amp;
                 lwcf       = lwcf_p       , glw       = glw_p      , olr       = olrtoa_p  , &amp;
-                emiss      = sfc_emiss_p  , t3d       = t_p        , t8w       = t2_p      , &amp;
-                tsk        = tsk_p        , p3d       = pres_p     , p8w       = pres2_p   , &amp;
-                pi3d       = pi_p         , rho3d     = rho_p      , dz8w      = dz_p      , &amp;
+                emiss      = sfc_emiss_p  , tsk       = tsk_p      , dz8w      = dz_p      , &amp;
                 cldfra3d   = cldfrac_p    , r         = R_d        , g         = g         , &amp;
                 icloud     = icloud       , warm_rain = warm_rain  , f_ice_phy = f_ice     , &amp;
                 f_rain_phy = f_rain       , xland     = xland_p    , xice      = xice_p    , &amp;
@@ -541,13 +569,39 @@
                 f_qr       = f_qr         , f_qi      = f_qi       , f_qs      = f_qs      , &amp;
                 f_qg       = f_qg         ,                                                  &amp;
                 !begin optional arguments:
-                !lwupflx    = lwupflx_p    , lwupflxc  = lwupflxc_p , lwdnflx   = lwdnflx_p, &amp;
-                !lwdnflxc   = lwdnflxc_p   ,                                                 &amp;
+                !lwupflx   = lwupflx_p    , lwupflxc  = lwupflxc_p , lwdnflx   = lwdnflx_p,  &amp;
+                !lwdnflxc  = lwdnflxc_p   ,                                                  &amp;
                 !end optional arguments.
                 ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde ,      &amp;
                 ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,      &amp;
                 its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte        &amp;
                        )
+#endif
+!... CALL FROM REVISION 1721:
+!      call rrtmg_lwrad( &amp;
+!               rthratenlw = rthratenlw_p , lwupt     = lwupt_p    , lwuptc    = lwuptc_p  , &amp;
+!               lwdnt      = lwdnt_p      , lwdntc    = lwdntc_p   , lwupb     = lwupb_p   , &amp;
+!               lwupbc     = lwupbc_p     , lwdnb     = lwdnb_p    , lwdnbc    = lwdnbc_p  , &amp;
+!               lwcf       = lwcf_p       , glw       = glw_p      , olr       = olrtoa_p  , &amp;
+!               emiss      = sfc_emiss_p  , t3d       = t_p        , t8w       = t2_p      , &amp;
+!               tsk        = tsk_p        , p3d       = pres_p     , p8w       = pres2_p   , &amp;
+!               pi3d       = pi_p         , rho3d     = rho_p      , dz8w      = dz_p      , &amp;
+!               cldfra3d   = cldfrac_p    , r         = R_d        , g         = g         , &amp;
+!               icloud     = icloud       , warm_rain = warm_rain  , f_ice_phy = f_ice     , &amp;
+!               f_rain_phy = f_rain       , xland     = xland_p    , xice      = xice_p    , &amp;
+!               snow       = snow_p       , qv3d      = qv_p       , qc3d      = qc_p      , &amp;
+!               qr3d       = qr_p         , qi3d      = qi_p       , qs3d      = qs_p      , &amp;
+!               qg3d       = qg_p         , f_qv      = f_qv       , f_qc      = f_qc      , &amp;
+!               f_qr       = f_qr         , f_qi      = f_qi       , f_qs      = f_qs      , &amp;
+!               f_qg       = f_qg         ,                                                  &amp;
+!               !begin optional arguments:
+!               !lwupflx    = lwupflx_p    , lwupflxc  = lwupflxc_p , lwdnflx   = lwdnflx_p, &amp;
+!               !lwdnflxc   = lwdnflxc_p   ,                                                 &amp;
+!               !end optional arguments.
+!               ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde ,      &amp;
+!               ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,      &amp;
+!               its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte        &amp;
+!                      )
        write(0,*) '--- exit subroutine rrtmg_lwrad'
 
     case (&quot;cam_lw&quot;)
@@ -562,7 +616,12 @@
        call mpas_timer_start(&quot;camrad&quot;)
        write(0,*) '--- enter subroutine camrad_lw: doabsems=',doabsems
        call mpas_timer_start(&quot;camrad&quot;)
+#if defined(do_hydrostatic_pressure)
+!... REARRANGED CALL USING HYDROSTATIC PRESSURE:
        call camrad( dolw = .true. , dosw = .false. ,                                         &amp;
+                p_phy         = pres_hyd_p    , p8w           = pres2_hyd_p   ,              &amp;
+                pi_phy        = pi_p          , t_phy         = t_p           ,              &amp;
+                z             = zmid_p        , dz8w          = dz_p          ,              &amp;            
                 rthratenlw    = rthratenlw_p  , rthratensw    = rthratensw_p  ,              &amp;
                 swupt         = swupt_p       , swuptc        = swuptc_p      ,              &amp;
                 swdnt         = swdnt_p       , swdntc        = swdntc_p      ,              &amp;
@@ -579,9 +638,56 @@
                 coszr         = coszr_p       , albedo        = sfc_albedo_p  ,              &amp; 
                 emiss         = sfc_emiss_p   , tsk           = tsk_p         ,              &amp; 
                 xlat          = xlat_p        , xlong         = xlon_p        ,              &amp;
-                t_phy         = t_p           , pi_phy        = pi_p          ,              &amp;
+                rho_phy       = rho_p         , qv3d          = qv_p          ,              &amp; 
+                qc3d          = qc_p          , qr3d          = qr_p          ,              &amp;
+                qi3d          = qi_p          , qs3d          = qs_p          ,              &amp;
+                qg3d          = qg_p          , f_qv          = f_qv          ,              &amp;
+                f_qc          = f_qc          , f_qr          = f_qr          ,              &amp;
+                f_qi          = f_qi          , f_qs          = f_qs          ,              &amp;
+                f_qg          = f_qg          , f_ice_phy     = f_ice         ,              &amp;
+                f_rain_phy    = f_rain        , cldfra        = cldfrac_p     ,              &amp;
+                xland         = xland_p       , xice          = xice_p        ,              &amp;
+                num_months    = num_months    , levsiz        = num_oznlevels ,              &amp; 
+                pin0          = pin_p         , ozmixm        = ozmixm_p      ,              &amp;
+                paerlev       = num_aerlevels , naer_c        = num_aerosols  ,              &amp;
+                m_psp         = m_psp_p       , m_psn         = m_psn_p       ,              &amp;
+                aerosolcp     = aerosolcp_p   , aerosolcn     = aerosolcn_p   ,              &amp;
+                m_hybi0       = m_hybi_p      , snow          = snow_p        ,              &amp;
+                cam_abs_dim1  = cam_abs_dim1  , cam_abs_dim2  = cam_abs_dim2  ,              &amp;
+                gmt           = gmt           , yr            = year          ,              &amp;
+                julday        = julday        , julian        = curr_julday   ,              &amp;
+                dt            = dt_dyn        , xtime         = xtime_m       ,              &amp;
+                declin        = declin        , solcon        = solcon        ,              &amp;
+                radt          = radt          , degrad        = degrad        ,              &amp;
+                n_cldadv      = 3             , abstot_3d     = abstot_p      ,              &amp;
+                absnxt_3d     = absnxt_p      , emstot_3d     = emstot_p      ,              &amp;
+                doabsems      = doabsems      ,                                              &amp;
+                ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde ,      &amp;
+                ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,      &amp;
+                its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte        &amp;
+                  )
+#else
+!... REARRANGED CALL:
+       call camrad( dolw = .true. , dosw = .false. ,                                         &amp;
                 p_phy         = pres_p        , p8w           = pres2_p       ,              &amp;
+                pi_phy        = pi_p          , t_phy         = t_p           ,              &amp;
                 z             = zmid_p        , dz8w          = dz_p          ,              &amp;            
+                rthratenlw    = rthratenlw_p  , rthratensw    = rthratensw_p  ,              &amp;
+                swupt         = swupt_p       , swuptc        = swuptc_p      ,              &amp;
+                swdnt         = swdnt_p       , swdntc        = swdntc_p      ,              &amp;
+                lwupt         = lwupt_p       , lwuptc        = lwuptc_p      ,              &amp;
+                lwdnt         = lwdnt_p       , lwdntc        = lwdntc_p      ,              &amp;
+                swupb         = swupb_p       , swupbc        = swupbc_p      ,              &amp;
+                swdnb         = swdnb_p       , swdnbc        = swdnbc_p      ,              &amp;
+                lwupb         = lwupb_p       , lwupbc        = lwupbc_p      ,              &amp;
+                lwdnb         = lwdnb_p       , lwdnbc        = lwdnbc_p      ,              &amp;
+                swcf          = swcf_p        , lwcf          = lwcf_p        ,              &amp;
+                gsw           = gsw_p         , glw           = glw_p         ,              &amp;
+                olr           = olrtoa_p      , cemiss        = cemiss_p      ,              &amp;
+                taucldc       = taucldc_p     , taucldi       = taucldi_p     ,              &amp; 
+                coszr         = coszr_p       , albedo        = sfc_albedo_p  ,              &amp; 
+                emiss         = sfc_emiss_p   , tsk           = tsk_p         ,              &amp; 
+                xlat          = xlat_p        , xlong         = xlon_p        ,              &amp;
                 rho_phy       = rho_p         , qv3d          = qv_p          ,              &amp; 
                 qc3d          = qc_p          , qr3d          = qr_p          ,              &amp;
                 qi3d          = qi_p          , qs3d          = qs_p          ,              &amp;
@@ -610,6 +716,56 @@
                 ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,      &amp;
                 its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte        &amp;
                   )
+#endif
+!... CALL FROM REVISION 1721:
+!      call camrad( dolw = .true. , dosw = .false. ,                                         &amp;
+!               rthratenlw    = rthratenlw_p  , rthratensw    = rthratensw_p  ,              &amp;
+!               swupt         = swupt_p       , swuptc        = swuptc_p      ,              &amp;
+!               swdnt         = swdnt_p       , swdntc        = swdntc_p      ,              &amp;
+!               lwupt         = lwupt_p       , lwuptc        = lwuptc_p      ,              &amp;
+!               lwdnt         = lwdnt_p       , lwdntc        = lwdntc_p      ,              &amp;
+!               swupb         = swupb_p       , swupbc        = swupbc_p      ,              &amp;
+!               swdnb         = swdnb_p       , swdnbc        = swdnbc_p      ,              &amp;
+!               lwupb         = lwupb_p       , lwupbc        = lwupbc_p      ,              &amp;
+!               lwdnb         = lwdnb_p       , lwdnbc        = lwdnbc_p      ,              &amp;
+!               swcf          = swcf_p        , lwcf          = lwcf_p        ,              &amp;
+!               gsw           = gsw_p         , glw           = glw_p         ,              &amp;
+!               olr           = olrtoa_p      , cemiss        = cemiss_p      ,              &amp;
+!               taucldc       = taucldc_p     , taucldi       = taucldi_p     ,              &amp; 
+!               coszr         = coszr_p       , albedo        = sfc_albedo_p  ,              &amp; 
+!               emiss         = sfc_emiss_p   , tsk           = tsk_p         ,              &amp; 
+!               xlat          = xlat_p        , xlong         = xlon_p        ,              &amp;
+!               t_phy         = t_p           , pi_phy        = pi_p          ,              &amp;
+!               p_phy         = pres_p        , p8w           = pres2_p       ,              &amp;
+!               z             = zmid_p        , dz8w          = dz_p          ,              &amp;            
+!               rho_phy       = rho_p         , qv3d          = qv_p          ,              &amp; 
+!               qc3d          = qc_p          , qr3d          = qr_p          ,              &amp;
+!               qi3d          = qi_p          , qs3d          = qs_p          ,              &amp;
+!               qg3d          = qg_p          , f_qv          = f_qv          ,              &amp;
+!               f_qc          = f_qc          , f_qr          = f_qr          ,              &amp;
+!               f_qi          = f_qi          , f_qs          = f_qs          ,              &amp;
+!               f_qg          = f_qg          , f_ice_phy     = f_ice         ,              &amp;
+!               f_rain_phy    = f_rain        , cldfra        = cldfrac_p     ,              &amp;
+!               xland         = xland_p       , xice          = xice_p        ,              &amp;
+!               num_months    = num_months    , levsiz        = num_oznlevels ,              &amp; 
+!               pin0          = pin_p         , ozmixm        = ozmixm_p      ,              &amp;
+!               paerlev       = num_aerlevels , naer_c        = num_aerosols  ,              &amp;
+!               m_psp         = m_psp_p       , m_psn         = m_psn_p       ,              &amp;
+!               aerosolcp     = aerosolcp_p   , aerosolcn     = aerosolcn_p   ,              &amp;
+!               m_hybi0       = m_hybi_p      , snow          = snow_p        ,              &amp;
+!               cam_abs_dim1  = cam_abs_dim1  , cam_abs_dim2  = cam_abs_dim2  ,              &amp;
+!               gmt           = gmt           , yr            = year          ,              &amp;
+!               julday        = julday        , julian        = curr_julday   ,              &amp;
+!               dt            = dt_dyn        , xtime         = xtime_m       ,              &amp;
+!               declin        = declin        , solcon        = solcon        ,              &amp;
+!               radt          = radt          , degrad        = degrad        ,              &amp;
+!               n_cldadv      = 3             , abstot_3d     = abstot_p      ,              &amp;
+!               absnxt_3d     = absnxt_p      , emstot_3d     = emstot_p      ,              &amp;
+!               doabsems      = doabsems      ,                                              &amp;
+!               ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde ,      &amp;
+!               ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,      &amp;
+!               its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte        &amp;
+!                 )
        call mpas_timer_stop(&quot;camrad&quot;)
 !      write(0,*) 'max lwupb      =',maxval(lwupb_p(its:ite,jms:jme))
 !      write(0,*) 'max lwupbc     =',maxval(lwupbc_p(its:ite,jms:jme))

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_radiation_sw.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_radiation_sw.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_radiation_sw.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -21,6 +21,14 @@
           init_radiation_sw,       &amp;
           radconst
 
+!add-ons and modifications to sourcecode:
+! * removed commented out sourcecode left from revision 1721. removed commented out calls to
+!   subroutines rrtmg_swrad and camrad.
+! * updated call to subroutine rrtmg_swrad in order to use module_ra_rrtmg_sw.F from WRF 3.4.1
+!   instead of WRF 3.2.1. Results are unchanged.
+!   Laura D. Fowler (birch.ucar.edu) / 2013-03-13.
+
+
  integer,private:: i,j,k,n
 
  contains
@@ -63,6 +71,15 @@
  radiation_sw_select: select case (trim(radt_sw_scheme))
 
     case(&quot;rrtmg_sw&quot;)
+       if(.not.allocated(alswvisdir_p) ) allocate(alswvisdir_p(ims:ime,jms:jme)         )
+       if(.not.allocated(alswvisdif_p) ) allocate(alswvisdif_p(ims:ime,jms:jme)         )
+       if(.not.allocated(alswnirdir_p) ) allocate(alswnirdir_p(ims:ime,jms:jme)         )
+       if(.not.allocated(alswnirdif_p) ) allocate(alswnirdif_p(ims:ime,jms:jme)         )
+       if(.not.allocated(swvisdir_p)   ) allocate(swvisdir_p(ims:ime,jms:jme)           )
+       if(.not.allocated(swvisdif_p)   ) allocate(swvisdif_p(ims:ime,jms:jme)           )
+       if(.not.allocated(swnirdir_p)   ) allocate(swnirdir_p(ims:ime,jms:jme)           )
+       if(.not.allocated(swnirdif_p)   ) allocate(swnirdif_p(ims:ime,jms:jme)           )
+
        if(.not.allocated(swdnflx_p)    ) allocate(swdnflx_p(ims:ime,kms:kme+1,jms:jme)  )
        if(.not.allocated(swdnflxc_p)   ) allocate(swdnflxc_p(ims:ime,kms:kme+1,jms:jme) )
        if(.not.allocated(swupflx_p)    ) allocate(swupflx_p(ims:ime,kms:kme+1,jms:jme)  )
@@ -146,6 +163,11 @@
  radiation_sw_select: select case (trim(radt_sw_scheme))
 
     case(&quot;rrtmg_sw&quot;)
+       if(allocated(alswvisdir_p) ) deallocate(alswvisdir_p )
+       if(allocated(alswvisdif_p) ) deallocate(alswvisdif_p )
+       if(allocated(alswnirdir_p) ) deallocate(alswnirdir_p )
+       if(allocated(alswnirdif_p) ) deallocate(alswnirdif_p )
+
        if(allocated(swdnflx_p)    ) deallocate(swdnflx_p    )
        if(allocated(swdnflxc_p)   ) deallocate(swdnflxc_p   )
        if(allocated(swupflx_p)    ) deallocate(swupflx_p    )
@@ -497,39 +519,78 @@
     case (&quot;rrtmg_sw&quot;)
 
        write(0,*) '--- enter subroutine rrtmg_swrad:'
+#if defined(do_hydrostatic_pressure)
+!... REARRANGED CALL USING HYDROSTATIC PRESSURE:
        call rrtmg_swrad( &amp;
-                rthratensw = rthratensw_p , swupt     = swupt_p    , swuptc    = swuptc_p  , &amp;
-                swdnt      = swdnt_p      , swdntc    = swdntc_p   , swupb     = swupb_p   , &amp;
-                swupbc     = swupbc_p     , swdnb     = swdnb_p    , swdnbc    = swdnbc_p  , &amp;
-                swcf       = swcf_p       , gsw       = gsw_p      , xtime     = xtime_m   , &amp;
-                gmt        = gmt          , xlat      = xlat_p     , xlong     = xlon_p    , &amp;
-                radt       = radt         , degrad    = degrad     , declin    = declin    , &amp;
-                coszr      = coszr_p      , julday    = julday     , solcon    = solcon    , &amp;
-                albedo     = sfc_albedo_p , t3d       = t_p        , t8w       = t2_p      , &amp;
-                tsk        = tsk_p        , p3d       = pres_p     , p8w       = pres2_p   , &amp;
-                pi3d       = pi_p         , rho3d     = rho_p      , dz8w      = dz_p      , &amp;
-                cldfra3d   = cldfrac_p    , r         = R_d        , g         = g         , &amp;
-                icloud     = icloud       , warm_rain = warm_rain  , f_ice_phy = f_ice     , &amp;
-                f_rain_phy = f_rain       , xland     = xland_p    , xice      = xice_p    , &amp;
-                snow       = snow_p       , qv3d      = qv_p       , qc3d      = qc_p      , &amp;
-                qr3d       = qr_p         , qi3d      = qi_p       , qs3d      = qs_p      , &amp;
-                qg3d       = qg_p         , f_qv      = f_qv       , f_qc      = f_qc      , &amp;
-                f_qr       = f_qr         , f_qi      = f_qi       , f_qs      = f_qs      , &amp;
-                f_qg       = f_qg         ,                                                  &amp;
+                p3d        = pres_hyd_p   , p8w        = pres2_hyd_p  , pi3d       = pi_p        ,&amp;
+                t3d        = t_p          , t8w        = t2_p         , rho3d      = rho_p       ,&amp;
+                rthratensw = rthratensw_p , swupt      = swupt_p      , swuptc     = swuptc_p    ,&amp;
+                swdnt      = swdnt_p      , swdntc     = swdntc_p     , swupb      = swupb_p     ,&amp;
+                swupbc     = swupbc_p     , swdnb      = swdnb_p      , swdnbc     = swdnbc_p    ,&amp;
+                swcf       = swcf_p       , gsw        = gsw_p        , xtime      = xtime_m     ,&amp;
+                gmt        = gmt          , xlat       = xlat_p       , xlong      = xlon_p      ,&amp;
+                radt       = radt         , degrad     = degrad       , declin     = declin      ,&amp;
+                coszr      = coszr_p      , julday     = julday       , solcon     = solcon      ,&amp;
+                albedo     = sfc_albedo_p , tsk        = tsk_p        , dz8w       = dz_p        ,&amp;
+                cldfra3d   = cldfrac_p    , r          = R_d          , g          = g           ,&amp;
+                icloud     = icloud       , warm_rain  = warm_rain    , f_ice_phy  = f_ice       ,&amp;
+                f_rain_phy = f_rain       , xland      = xland_p      , xice       = xice_p      ,&amp;
+                snow       = snow_p       , qv3d       = qv_p         , qc3d       = qc_p        ,&amp;
+                qr3d       = qr_p         , qi3d       = qi_p         , qs3d       = qs_p        ,&amp;
+                qg3d       = qg_p         , sf_surface_physics = sf_surface_physics ,             &amp; 
                 !begin optional arguments:
-                swupflx    = swupflx_p    , swupflxc  = swupflxc_p , swdnflx   = swdnflx_p , &amp;
-                swdnflxc   = swdnflxc_p   ,                                                  &amp;
+                f_qv       = f_qv         , f_qc       = f_qc         , f_qr       = f_qr        ,&amp;
+                f_qi       = f_qi         , f_qs       = f_qs         , f_qg       = f_qg        ,&amp;
+                alswvisdir = alswvisdir_p , alswvisdif = alswvisdif_p , alswnirdir = alswnirdir_p,&amp;
+                alswnirdif = alswnirdif_p , swvisdir   = swvisdir_p   , swvisdif   = swvisdif_p  ,&amp;
+                swnirdir   = swnirdir_p   , swnirdif   = swnirdif_p   ,                           &amp;
                 !end optional arguments.
-                ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde ,      &amp;
-                ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,      &amp;
-                its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte        &amp;
+                ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde ,&amp;
+                ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,&amp;
+                its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte  &amp;
                        )
+#else
+!... REARRANGED CALL:
+       call rrtmg_swrad( &amp;
+                p3d        = pres_p       , p8w       = pres2_p    , pi3d      = pi_p            ,&amp;
+                t3d        = t_p          , t8w       = t2_p       , rho3d     = rho_p           ,&amp;
+                rthratensw = rthratensw_p , swupt     = swupt_p    , swuptc    = swuptc_p        ,&amp;
+                swdnt      = swdnt_p      , swdntc    = swdntc_p   , swupb     = swupb_p         ,&amp;
+                swupbc     = swupbc_p     , swdnb     = swdnb_p    , swdnbc    = swdnbc_p        ,&amp;
+                swcf       = swcf_p       , gsw       = gsw_p      , xtime     = xtime_m         ,&amp;
+                gmt        = gmt          , xlat      = xlat_p     , xlong     = xlon_p          ,&amp;
+                radt       = radt         , degrad    = degrad     , declin    = declin          ,&amp;
+                coszr      = coszr_p      , julday    = julday     , solcon    = solcon          ,&amp;
+                albedo     = sfc_albedo_p , tsk       = tsk_p      , dz8w      = dz_p            ,&amp;
+                cldfra3d   = cldfrac_p    , r         = R_d        , g         = g               ,&amp;
+                icloud     = icloud       , warm_rain = warm_rain  , f_ice_phy = f_ice           ,&amp;
+                f_rain_phy = f_rain       , xland     = xland_p    , xice      = xice_p          ,&amp;
+                snow       = snow_p       , qv3d      = qv_p       , qc3d      = qc_p            ,&amp;
+                qr3d       = qr_p         , qi3d      = qi_p       , qs3d      = qs_p            ,&amp;
+                qg3d       = qg_p         , sf_surface_physics = sf_surface_physics ,             &amp; 
+                !begin optional arguments:
+                f_qv       = f_qv         , f_qc       = f_qc         , f_qr       = f_qr        ,&amp;
+                f_qi       = f_qi         , f_qs       = f_qs         , f_qg       = f_qg        ,&amp;
+                alswvisdir = alswvisdir_p , alswvisdif = alswvisdif_p , alswnirdir = alswnirdir_p,&amp;
+                alswnirdif = alswnirdif_p , swvisdir   = swvisdir_p   , swvisdif   = swvisdif_p  ,&amp;
+                swnirdir   = swnirdir_p   , swnirdif   = swnirdif_p   ,                           &amp;
+                !end optional arguments.
+                ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde ,&amp;
+                ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,&amp;
+                its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte  &amp;
+                       )
+#endif
        write(0,*) '--- exit subroutine rrtmg_swrad'
 
     case (&quot;cam_sw&quot;)
 
        write(0,*) '--- enter subroutine camrad_sw:'
+#if defined(do_hydrostatic_pressure)
+!... REARRANGED CALL USING HYDROSTATIC PRESSURE:
        call camrad( dolw = .false. , dosw = .true. ,                                         &amp;
+                p_phy         = pres_hyd_p    , p8w           = pres2_hyd_p   ,              &amp;
+                pi_phy        = pi_p          , t_phy         = t_p           ,              &amp;
+                z             = zmid_p        , dz8w          = dz_p          ,              &amp;            
                 rthratenlw    = rthratenlw_p  , rthratensw    = rthratensw_p  ,              &amp;
                 swupt         = swupt_p       , swuptc        = swuptc_p      ,              &amp;
                 swdnt         = swdnt_p       , swdntc        = swdntc_p      ,              &amp;
@@ -546,9 +607,61 @@
                 coszr         = coszr_p       , albedo        = sfc_albedo_p  ,              &amp; 
                 emiss         = sfc_emiss_p   , tsk           = tsk_p         ,              &amp; 
                 xlat          = xlat_p        , xlong         = xlon_p        ,              &amp;
-                t_phy         = t_p           , pi_phy        = pi_p          ,              &amp;
+                rho_phy       = rho_p         , qv3d          = qv_p          ,              &amp; 
+                qc3d          = qc_p          , qr3d          = qr_p          ,              &amp;
+                qi3d          = qi_p          , qs3d          = qs_p          ,              &amp;
+                qg3d          = qg_p          , f_qv          = f_qv          ,              &amp;
+                f_qc          = f_qc          , f_qr          = f_qr          ,              &amp;
+                f_qi          = f_qi          , f_qs          = f_qs          ,              &amp;
+                f_qg          = f_qg          , f_ice_phy     = f_ice         ,              &amp;
+                f_rain_phy    = f_rain        , cldfra        = cldfrac_p     ,              &amp;
+                xland         = xland_p       , xice          = xice_p        ,              &amp;
+                num_months    = num_months    , levsiz        = num_oznlevels ,              &amp; 
+                pin0          = pin_p         , ozmixm        = ozmixm_p      ,              &amp;
+                paerlev       = num_aerlevels , naer_c        = num_aerosols  ,              &amp;
+                m_psp         = m_psp_p       , m_psn         = m_psn_p       ,              &amp;
+                aerosolcp     = aerosolcp_p   , aerosolcn     = aerosolcn_p   ,              &amp;
+                m_hybi0       = m_hybi_p      , snow          = snow_p        ,              &amp;
+                cam_abs_dim1  = cam_abs_dim1  , cam_abs_dim2  = cam_abs_dim2  ,              &amp;
+                gmt           = gmt           , yr            = year          ,              &amp;
+                julday        = julday        , julian        = curr_julday   ,              &amp;
+                dt            = dt_dyn        , xtime         = xtime_m       ,              &amp;
+                declin        = declin        , solcon        = solcon        ,              &amp;
+                radt          = radt          , degrad        = degrad        ,              &amp;
+                n_cldadv      = 3             , abstot_3d     = abstot_p      ,              &amp;
+                absnxt_3d     = absnxt_p      , emstot_3d     = emstot_p      ,              &amp;
+                doabsems      = doabsems      ,                                              &amp;
+                ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde ,      &amp;
+                ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,      &amp;
+                its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte        &amp;
+                  )
+!               do j = jts,jte
+!               do i = its,ite
+!                 write(0,200) j,i,swdnt_p(i,j),swdnb_p(i,j),swupt_p(i,j),swupb_p(i,j)
+!              enddo
+!              enddo
+#else
+!... REARRANGED CALL:
+       call camrad( dolw = .false. , dosw = .true. ,                                         &amp;
                 p_phy         = pres_p        , p8w           = pres2_p       ,              &amp;
+                pi_phy        = pi_p          , t_phy         = t_p           ,              &amp;
                 z             = zmid_p        , dz8w          = dz_p          ,              &amp;            
+                rthratenlw    = rthratenlw_p  , rthratensw    = rthratensw_p  ,              &amp;
+                swupt         = swupt_p       , swuptc        = swuptc_p      ,              &amp;
+                swdnt         = swdnt_p       , swdntc        = swdntc_p      ,              &amp;
+                lwupt         = lwupt_p       , lwuptc        = lwuptc_p      ,              &amp;
+                lwdnt         = lwdnt_p       , lwdntc        = lwdntc_p      ,              &amp;
+                swupb         = swupb_p       , swupbc        = swupbc_p      ,              &amp;
+                swdnb         = swdnb_p       , swdnbc        = swdnbc_p      ,              &amp;
+                lwupb         = lwupb_p       , lwupbc        = lwupbc_p      ,              &amp;
+                lwdnb         = lwdnb_p       , lwdnbc        = lwdnbc_p      ,              &amp;
+                swcf          = swcf_p        , lwcf          = lwcf_p        ,              &amp;
+                gsw           = gsw_p         , glw           = glw_p         ,              &amp;
+                olr           = olrtoa_p      , cemiss        = cemiss_p      ,              &amp;
+                taucldc       = taucldc_p     , taucldi       = taucldi_p     ,              &amp; 
+                coszr         = coszr_p       , albedo        = sfc_albedo_p  ,              &amp; 
+                emiss         = sfc_emiss_p   , tsk           = tsk_p         ,              &amp; 
+                xlat          = xlat_p        , xlong         = xlon_p        ,              &amp;
                 rho_phy       = rho_p         , qv3d          = qv_p          ,              &amp; 
                 qc3d          = qc_p          , qr3d          = qr_p          ,              &amp;
                 qi3d          = qi_p          , qs3d          = qs_p          ,              &amp;
@@ -577,6 +690,7 @@
                 ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme ,      &amp;
                 its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte        &amp;
                   )
+#endif
 !      write(0,*) 'doabsems =',doabsems
 !      write(0,*) 'max swupb      =',maxval(swupb_p(its:ite,jms:jme))
 !      write(0,*) 'max swupbc     =',maxval(swupbc_p(its:ite,jms:jme))

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_sfclayer.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_sfclayer.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_driver_sfclayer.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,4 +1,4 @@
-!=============================================================================================
+!==================================================================================================
  module mpas_atmphys_driver_sfclayer
  use mpas_grid_types
 
@@ -17,15 +17,17 @@
 
  integer,parameter,private:: isfflx   = 1        !=1 for surface heat and moisture fluxes.
  integer,parameter,private:: isftcflx = 0        !=0,(Charnock and Carlson-Boland).
- integer,parameter,private:: iz0tlnd  = 0        !=0,(Carlson-Boland)
+ integer,parameter,private:: iz0tlnd  = 0        !=0,(Carlson-Boland).
+ integer,parameter,private:: scm_force_flux = 0  !SCM surface forcing by surface fluxes.
+                                                 !0=no 1=yes (WRF single column model option only).
 
  integer,private:: i,j
 
  contains
 
-!=============================================================================================
+!==================================================================================================
  subroutine allocate_sfclayer
-!=============================================================================================
+!==================================================================================================
 
  if(.not.allocated(area_p)   ) allocate(area_p(ims:ime,jms:jme)   )
  if(.not.allocated(br_p)     ) allocate(br_p(ims:ime,jms:jme)     )
@@ -33,13 +35,15 @@
  if(.not.allocated(cda_p)    ) allocate(cda_p(ims:ime,jms:jme)    )
  if(.not.allocated(chs_p)    ) allocate(chs_p(ims:ime,jms:jme)    )
  if(.not.allocated(chs2_p)   ) allocate(chs2_p(ims:ime,jms:jme)   )
+ if(.not.allocated(ck_p)     ) allocate(ck_p(ims:ime,jms:jme)     )
+ if(.not.allocated(cka_p)    ) allocate(cka_p(ims:ime,jms:jme)    )
  if(.not.allocated(cpm_p)    ) allocate(cpm_p(ims:ime,jms:jme)    )
  if(.not.allocated(cqs2_p)   ) allocate(cqs2_p(ims:ime,jms:jme)   )
- if(.not.allocated(ck_p)     ) allocate(ck_p(ims:ime,jms:jme)     )
- if(.not.allocated(cka_p)    ) allocate(cka_p(ims:ime,jms:jme)    )
  if(.not.allocated(gz1oz0_p) ) allocate(gz1oz0_p(ims:ime,jms:jme) )
  if(.not.allocated(flhc_p)   ) allocate(flhc_p(ims:ime,jms:jme)   )
  if(.not.allocated(flqc_p)   ) allocate(flqc_p(ims:ime,jms:jme)   )
+ if(.not.allocated(fh_p)     ) allocate(fh_p(ims:ime,jms:jme)     )
+ if(.not.allocated(fm_p)     ) allocate(fm_p(ims:ime,jms:jme)     )
  if(.not.allocated(hfx_p)    ) allocate(hfx_p(ims:ime,jms:jme)    )
  if(.not.allocated(hpbl_p)   ) allocate(hpbl_p(ims:ime,jms:jme)   )
  if(.not.allocated(lh_p)     ) allocate(lh_p(ims:ime,jms:jme)     )
@@ -67,9 +71,9 @@
 
  end subroutine allocate_sfclayer
 
-!=============================================================================================
+!==================================================================================================
  subroutine deallocate_sfclayer
-!=============================================================================================
+!==================================================================================================
 
  if(allocated(area_p)   ) deallocate(area_p   )
  if(allocated(br_p)     ) deallocate(br_p     )
@@ -77,13 +81,15 @@
  if(allocated(cda_p)    ) deallocate(cda_p    )
  if(allocated(chs_p)    ) deallocate(chs_p    )
  if(allocated(chs2_p)   ) deallocate(chs2_p   )
+ if(allocated(ck_p)     ) deallocate(ck_p     )
+ if(allocated(cka_p)    ) deallocate(cka_p    )
  if(allocated(cpm_p)    ) deallocate(cpm_p    )
  if(allocated(cqs2_p)   ) deallocate(cqs2_p   )
- if(allocated(ck_p)     ) deallocate(ck_p     )
- if(allocated(cka_p)    ) deallocate(cka_p    )
  if(allocated(gz1oz0_p) ) deallocate(gz1oz0_p )
  if(allocated(flhc_p)   ) deallocate(flhc_p   )
  if(allocated(flqc_p)   ) deallocate(flqc_p   )
+ if(allocated(fh_p)     ) deallocate(fh_p     )
+ if(allocated(fm_p)     ) deallocate(fm_p     )
  if(allocated(hfx_p)    ) deallocate(hfx_p    )
  if(allocated(hpbl_p)   ) deallocate(hpbl_p   )
  if(allocated(lh_p)     ) deallocate(lh_p     )
@@ -111,16 +117,16 @@
 
  end subroutine deallocate_sfclayer
 
-!=============================================================================================
+!==================================================================================================
  subroutine sfclayer_from_MPAS(mesh,diag_physics,sfc_input)
-!=============================================================================================
+!==================================================================================================
 
 !input arguments:
  type(mesh_type),intent(in):: mesh
  type(sfc_input_type),intent(in):: sfc_input
  type(diag_physics_type),intent(inout):: diag_physics
 
-!---------------------------------------------------------------------------------------------
+!--------------------------------------------------------------------------------------------------
 
  do j = jts,jte
  do i = its,ite
@@ -131,64 +137,59 @@
     tsk_p(i,j)    = sfc_input    % skintemp % array(i)
     xland_p(i,j)  = sfc_input    % xland    % array(i)       
     !inout variables:
+    br_p(i,j)     = diag_physics % br     % array(i)
+    cpm_p(i,j)    = diag_physics % cpm    % array(i)
+    chs_p(i,j)    = diag_physics % chs    % array(i)
+    chs2_p(i,j)   = diag_physics % chs2   % array(i)
+    cqs2_p(i,j)   = diag_physics % cqs2   % array(i)
+    fh_p(i,j)     = diag_physics % fh     % array(i)
+    fm_p(i,j)     = diag_physics % fm     % array(i)
+    flhc_p(i,j)   = diag_physics % flhc   % array(i)
+    flqc_p(i,j)   = diag_physics % flqc   % array(i)
+    gz1oz0_p(i,j) = diag_physics % gz1oz0 % array(i)
     hfx_p(i,j)    = diag_physics % hfx    % array(i)
     qfx_p(i,j)    = diag_physics % qfx    % array(i)
+    qgh_p(i,j)    = diag_physics % qgh    % array(i)
     qsfc_p(i,j)   = diag_physics % qsfc   % array(i) 
+    lh_p(i,j)     = diag_physics % lh     % array(i)
     mol_p(i,j)    = diag_physics % mol    % array(i) 
+    psim_p(i,j)   = diag_physics % psim   % array(i)
+    psih_p(i,j)   = diag_physics % psih   % array(i)
+    regime_p(i,j) = diag_physics % regime % array(i)
+    rmol_p(i,j)   = diag_physics % rmol   % array(i)
     ust_p(i,j)    = diag_physics % ust    % array(i)
-    ustm_p(i,j)   = diag_physics % ustm   % array(i)
+    wspd_p(i,j)   = diag_physics % wspd   % array(i)
     znt_p(i,j)    = diag_physics % znt    % array(i) 
     zol_p(i,j)    = diag_physics % zol    % array(i) 
     !output variables:
-    br_p(i,j)     = 0.
-    cpm_p(i,j)    = cp
-    cd_p(i,j)     = 0.
-    cda_p(i,j)    = 0.
-    chs_p(i,j)    = 0.
-    chs2_p(i,j)   = 0.
-    ck_p(i,j)     = 0.
-    cka_p(i,j)    = 0.
-    cqs2_p(i,j)   = 0.
-    flhc_p(i,j)   = 0.
-    flqc_p(i,j)   = 0.
-    gz1oz0_p(i,j) = 0.
-    lh_p(i,j)     = 0.
-    psim_p(i,j)   = 0. 
-    psih_p(i,j)   = 0.
-    qgh_p(i,j)    = 0.
-    regime_p(i,j) = 0.
-    rmol_p(i,j)   = 0.
-    wspd_p(i,j)   = 0.
-    q2_p(i,j)     = 0.
-    t2m_p(i,j)    = 0.
-    th2m_p(i,j)   = 0.
-    u10_p(i,j)    = 0.
-    v10_p(i,j)    = 0.
+    q2_p(i,j)     = 0._RKIND
+    t2m_p(i,j)    = 0._RKIND
+    th2m_p(i,j)   = 0._RKIND
+    u10_p(i,j)    = 0._RKIND
+    v10_p(i,j)    = 0._RKIND
  enddo
  enddo
 
  end subroutine sfclayer_from_MPAS
 
-!=============================================================================================
+!==================================================================================================
  subroutine sfclayer_to_MPAS(diag_physics)
-!=============================================================================================
+!==================================================================================================
 
 !inout arguments:
  type(diag_physics_type),intent(inout):: diag_physics
 
-!---------------------------------------------------------------------------------------------
+!--------------------------------------------------------------------------------------------------
 
  do j = jts,jte
  do i = its,ite
     diag_physics % br     % array(i) = br_p(i,j)
     diag_physics % cpm    % array(i) = cpm_p(i,j)
-    diag_physics % cd     % array(i) = cd_p(i,j)
-    diag_physics % cda    % array(i) = cda_p(i,j)
     diag_physics % chs    % array(i) = chs_p(i,j)
     diag_physics % chs2   % array(i) = chs2_p(i,j)
-    diag_physics % ck     % array(i) = ck_p(i,j)
-    diag_physics % cka    % array(i) = cka_p(i,j)
     diag_physics % cqs2   % array(i) = cqs2_p(i,j)
+    diag_physics % fh     % array(i) = fh_p(i,j)
+    diag_physics % fm     % array(i) = fm_p(i,j)
     diag_physics % flhc   % array(i) = flhc_p(i,j)
     diag_physics % flqc   % array(i) = flqc_p(i,j)
     diag_physics % gz1oz0 % array(i) = gz1oz0_p(i,j)
@@ -203,7 +204,6 @@
     diag_physics % regime % array(i) = regime_p(i,j)
     diag_physics % rmol   % array(i) = rmol_p(i,j)
     diag_physics % ust    % array(i) = ust_p(i,j)
-    diag_physics % ustm   % array(i) = ustm_p(i,j)
     diag_physics % wspd   % array(i) = wspd_p(i,j)
     diag_physics % zol    % array(i) = zol_p(i,j)
     diag_physics % znt    % array(i) = znt_p(i,j)
@@ -218,14 +218,14 @@
 
  end subroutine sfclayer_to_MPAS
 
-!=============================================================================================
+!==================================================================================================
  subroutine init_sfclayer
-!=============================================================================================
+!==================================================================================================
 
 !local variables:
  logical:: allowed_to_read
 
-!---------------------------------------------------------------------------------------------
+!--------------------------------------------------------------------------------------------------
  write(0,*)
  write(0,*) '--- enter sfclayer_initialization:'
  sfclayer_select: select case (trim(sfclayer_scheme))
@@ -242,9 +242,9 @@
 
  end subroutine init_sfclayer
 
-!=============================================================================================
+!==================================================================================================
  subroutine driver_sfclayer(mesh,diag_physics,sfc_input)
-!=============================================================================================
+!==================================================================================================
 
 !input and inout arguments:
 !--------------------------
@@ -256,7 +256,7 @@
 !----------------
  real(kind=RKIND):: dx
 
-!---------------------------------------------------------------------------------------------
+!--------------------------------------------------------------------------------------------------
  write(0,*)
  write(0,*) '--- enter subroutine driver_sfclayer:'
 
@@ -267,32 +267,67 @@
 
     case(&quot;monin_obukhov&quot;)
        dx = sqrt(maxval(mesh % areaCell % array))
+#if defined(do_hydrostatic_pressure)
+!... REARRANGED CALL USING HYDROSTATIC PRESSURE:
        call sfclay( &amp;
-                   u3d      = u_p      , v3d     = v_p      , t3d      = t_p     , &amp;
-                   qv3d     = qv_p     , p3d     = pres_p   , dz8w     = dz_p    , &amp;
-                   cp       = cp       , g       = g        , rovcp    = rcp     , &amp;
-                   R        = R_d      , xlv     = xlv      , psfc     = psfc_p  , &amp;
-                   chs      = chs_p    , chs2    = chs2_p   , cqs2     = cqs2_p  , &amp;
-                   cpm      = cpm_p    , znt     = znt_p    , ust      = ust_p   , &amp;
-                   pblh     = hpbl_p   , mavail  = mavail_p , zol      = zol_p   , &amp;
-                   mol      = mol_p    , regime  = regime_p , psim     = psim_p  , &amp;
-                   psih     = psih_p   , xland   = xland_p  , hfx      = hfx_p   , &amp;
-                   qfx      = qfx_p    , lh      = lh_p     , tsk      = tsk_p   , &amp;
-                   flhc     = flhc_p   , flqc    = flqc_p   , qgh      = qgh_p   , &amp;
-                   qsfc     = qsfc_p   , rmol    = rmol_p   , u10      = u10_p   , &amp;
-                   v10      = v10_p    , th2     = th2m_p   , t2       = t2m_p   , &amp;
-                   q2       = q2_p     , gz1oz0  = gz1oz0_p , wspd     = wspd_p  , &amp;
-                   br       = br_p     , isfflx  = isfflx   , dx       = dx      , &amp;
-                   svp1     = svp1     , svp2    = svp2     , svp3     = svp3    , &amp;
-                   svpt0    = svpt0    , ep1     = ep_1     , ep2      = ep_2    , &amp;
-                   karman   = karman   , eomeg   = eomeg    , stbolt   = stbolt  , &amp;
-                   P1000mb  = P0       , ustm    = ustm_p   , ck       = ck_p    , &amp;
-                   cka      = cka_p    , cd      = cd_p     , cda      = cda_p   , &amp;
-                   isftcflx = isftcflx , iz0tlnd = iz0tlnd  , areaCell = area_p  , &amp; 
+                   p3d      = pres_hyd_p , psfc     = psfc_p     , t3d      = t_p        , &amp;
+                   u3d      = u_p        , v3d      = v_p        , qv3d     = qv_p       , &amp;
+                   dz8w     = dz_p       , cp       = cp         , g        = g          , &amp;
+                   rovcp    = rcp        , R        = R_d        , xlv      = xlv        , &amp; 
+                   chs      = chs_p      , chs2     = chs2_p     , cqs2     = cqs2_p     , &amp;
+                   cpm      = cpm_p      , znt      = znt_p      , ust      = ust_p      , &amp;
+                   pblh     = hpbl_p     , mavail   = mavail_p   , zol      = zol_p      , &amp;
+                   mol      = mol_p      , regime   = regime_p   , psim     = psim_p     , &amp;
+                   psih     = psih_p     , fm       = fm_p       , fh       = fh_p       , &amp;
+                   xland    = xland_p    , hfx      = hfx_p      , qfx      = qfx_p      , &amp;
+                   lh       = lh_p       , tsk      = tsk_p      , flhc     = flhc_p     , &amp;
+                   flqc     = flqc_p     , qgh      = qgh_p      , qsfc     = qsfc_p     , &amp;
+                   rmol     = rmol_p     , u10      = u10_p      , v10      = v10_p      , &amp;
+                   th2      = th2m_p     , t2       = t2m_p      , q2       = q2_p       , &amp;
+                   gz1oz0   = gz1oz0_p   , wspd     = wspd_p     , br       = br_p       , &amp;
+                   isfflx   = isfflx     , dx       = dx         , svp1     = svp1       , &amp;
+                   svp2     = svp2       , svp3     = svp3       , svpt0    = svpt0      , &amp;
+                   ep1      = ep_1       , ep2      = ep_2       , karman   = karman     , &amp;
+                   eomeg    = eomeg      , stbolt   = stbolt     , P1000mb  = P0         , &amp;
+                   areaCell = area_p     , ustm     = ustm_p     , ck       = ck_p       , &amp; 
+                   cka      = cka_p      , cd       = cd_p       , cda      = cda_p      , &amp; 
+                   isftcflx = isftcflx   , iz0tlnd  = iz0tlnd    ,                         &amp;
+                   scm_force_flux = scm_force_flux               ,                         &amp; 
                    ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde , &amp;
                    ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme , &amp;
                    its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte   &amp;
                  )
+#else
+!... REARRANGED CALL:
+       call sfclay( &amp;
+                   p3d      = pres_p     , psfc     = psfc_p     , t3d      = t_p        , &amp;
+                   u3d      = u_p        , v3d      = v_p        , qv3d     = qv_p       , &amp;
+                   dz8w     = dz_p       , cp       = cp         , g        = g          , &amp;
+                   rovcp    = rcp        , R        = R_d        , xlv      = xlv        , &amp; 
+                   chs      = chs_p      , chs2     = chs2_p     , cqs2     = cqs2_p     , &amp;
+                   cpm      = cpm_p      , znt      = znt_p      , ust      = ust_p      , &amp;
+                   pblh     = hpbl_p     , mavail   = mavail_p   , zol      = zol_p      , &amp;
+                   mol      = mol_p      , regime   = regime_p   , psim     = psim_p     , &amp;
+                   psih     = psih_p     , fm       = fm_p       , fh       = fh_p       , &amp;
+                   xland    = xland_p    , hfx      = hfx_p      , qfx      = qfx_p      , &amp;
+                   lh       = lh_p       , tsk      = tsk_p      , flhc     = flhc_p     , &amp;
+                   flqc     = flqc_p     , qgh      = qgh_p      , qsfc     = qsfc_p     , &amp;
+                   rmol     = rmol_p     , u10      = u10_p      , v10      = v10_p      , &amp;
+                   th2      = th2m_p     , t2       = t2m_p      , q2       = q2_p       , &amp;
+                   gz1oz0   = gz1oz0_p   , wspd     = wspd_p     , br       = br_p       , &amp;
+                   isfflx   = isfflx     , dx       = dx         , svp1     = svp1       , &amp;
+                   svp2     = svp2       , svp3     = svp3       , svpt0    = svpt0      , &amp;
+                   ep1      = ep_1       , ep2      = ep_2       , karman   = karman     , &amp;
+                   eomeg    = eomeg      , stbolt   = stbolt     , P1000mb  = P0         , &amp;
+                   areaCell = area_p     , ustm     = ustm_p     , ck       = ck_p       , &amp; 
+                   cka      = cka_p      , cd       = cd_p       , cda      = cda_p      , &amp; 
+                   isftcflx = isftcflx   , iz0tlnd  = iz0tlnd    ,                         &amp;
+                   scm_force_flux = scm_force_flux               ,                         &amp; 
+                   ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde , &amp;
+                   ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme , &amp;
+                   its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte   &amp;
+                 )
+#endif
         
     case default
 
@@ -305,6 +340,6 @@
 
  end subroutine driver_sfclayer
 
-!=============================================================================================
+!==================================================================================================
  end module mpas_atmphys_driver_sfclayer
-!=============================================================================================
+!==================================================================================================

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_initialize_real.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_initialize_real.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_initialize_real.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,4 +1,4 @@
-!=============================================================================================
+!==================================================================================================
  module mpas_atmphys_initialize_real
  use mpas_kind_types
  use mpas_configure, only: config_met_prefix,  &amp;
@@ -7,11 +7,9 @@
                            config_nsoillevels, &amp;
                            config_start_time,  &amp;
                            config_sfc_prefix
+ use mpas_dmpar
  use mpas_grid_types
- use init_atm_hinterp
- use init_atm_llxy
- use init_atm_read_met
-
+ use mpas_init_atm_surface
  use mpas_atmphys_date_time
  use mpas_atmphys_utilities
 
@@ -21,140 +19,17 @@
 
  contains
 
-!=============================================================================================
- subroutine physics_initialize_sst(mesh,fg)
-!=============================================================================================
-
+!==================================================================================================
+ subroutine physics_initialize_real(mesh,fg,dminfo)
+!==================================================================================================
 !input arguments:
- type(mesh_type),intent(in) :: mesh
+ type(mesh_type),intent(in):: mesh
+ type(dm_info),intent(in)  :: dminfo
 
 !inout arguments:
  type(fg_type),intent(inout):: fg 
 
 !local variables:
- character(len=StrKIND):: timeString
- integer:: i,j,iCell,istatus
- integer,dimension(5) :: interp_list
-
- type(met_data) :: field
- type(proj_info):: proj
-
- real(kind=RKIND):: lat, lon, x, y
- real(kind=RKIND),allocatable,dimension(:,:):: slab_r8
-
-!---------------------------------------------------------------------------------------------
-
- write(0,*) '--- enter subroutine physics_initialize_sst:'
-
-!set interpolation sequence to be used for SST/SEAICE field:
- interp_list(1) = FOUR_POINT
- interp_list(2) = SEARCH
- interp_list(3) = 0
-
-!open intermediate file:
- call read_met_init(trim(config_sfc_prefix),.false.,config_start_time(1:13),istatus)
- if(istatus /= 0) &amp;
-    write(0,*) 'Error reading ',trim(config_sfc_prefix)//':'//config_start_time(1:13)
- write(0,*) 'Processing ',trim(config_sfc_prefix)//':'//config_start_time(1:13)
-
-!scan through all the fields in the file:
- call read_next_met_field(field,istatus)
- do while (istatus == 0)
-
-    !initialization of the sea-surface temperature (SST) and sea-ice fraction (XICE) arrays,
-    !prior to reading the input data:
-    fg % sst  % array (1:mesh%nCells) = 0.0_RKIND
-    fg % xice % array (1:mesh%nCells) = 0.0_RKIND
-
-    if(index(field % field,'SKINTEMP') /= 0 .or. &amp;
-       index(field % field,'SST'     ) /= 0 .or. &amp;
-       index(field % field,'SEAICE'  ) /= 0 ) then
-
-       !Interpolation routines use real(kind=RKIND), so copy from default real array
-       allocate(slab_r8(field % nx, field % ny))
-       do j=1,field % ny
-       do i=1,field % nx 
-          slab_r8(i,j) = field % slab(i,j)
-       end do
-       end do
-
-       !
-       !Set up map projection
-       !
-       call map_init(proj)
-             
-       if(field % iproj == PROJ_LATLON) then
-          call map_set(PROJ_LATLON, proj, &amp;
-                       latinc = real(field % deltalat,RKIND), &amp;
-                       loninc = real(field % deltalon,RKIND), &amp;
-                       knowni = 1.0_RKIND, &amp;
-                       knownj = 1.0_RKIND, &amp;
-                       lat1 = real(field % startlat,RKIND), &amp;
-                       lon1 = real(field % startlon,RKIND))
-       else if (field % iproj == PROJ_GAUSS) then
-          call map_set(PROJ_GAUSS, proj, &amp;
-                       nlat = nint(field % deltalat), &amp;
-                       loninc = real(field % deltalon,RKIND), &amp;
-                       lat1 = real(field % startlat,RKIND), &amp;
-                       lon1 = real(field % startlon,RKIND))
-!                       nxmax = nint(360.0 / field % deltalon), &amp;
-       else if (field % iproj == PROJ_PS) then
-          call map_set(PROJ_PS, proj, &amp;
-                       dx = real(field % dx,RKIND), &amp;
-                       truelat1 = real(field % truelat1,RKIND), &amp;
-                       stdlon = real(field % xlonc,RKIND), &amp;
-                       knowni = real(field % nx / 2.0,RKIND), &amp;
-                       knownj = real(field % ny / 2.0,RKIND), &amp;
-                       lat1 = real(field % startlat,RKIND), &amp;
-                       lon1 = real(field % startlon,RKIND))
-       end if

-       !Interpolate field to each MPAS grid cell:
-       do iCell=1,mesh % nCells
-          lat = mesh % latCell % array(iCell) * DEG_PER_RAD
-          lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
-          call latlon_to_ij(proj, lat, lon, x, y)
-          if (y &lt; 0.5) then
-              y = 1.0
-          else if (y &gt;= real(field%ny)+0.5) then
-              y = real(field % ny)
-          endif 
-          if (x &lt; 0.5) then
-              lon = lon + 360.0
-              call latlon_to_ij(proj, lat, lon, x, y)
-          else if (x &gt;= real(field%nx)+0.5) then
-              lon = lon - 360.0
-              call latlon_to_ij(proj, lat, lon, x, y)
-          end if

-          if(index(field % field,'SST') /= 0) then
-             fg % sst % array(iCell) = interp_sequence(x,y,1,slab_r8,1,field%nx, &amp;
-                                              1,field%ny,1,1,-1.e30_RKIND,interp_list,1)
-          elseif(index(field % field,'SEAICE') /= 0) then
-             fg % xice % array(iCell) = interp_sequence(x,y,1,slab_r8,1,field%nx, &amp;
-                                              1,field%ny,1,1,-1.e30_RKIND,interp_list,1)
-          endif          
-       end do
-
-       deallocate(slab_r8)
-       deallocate(field % slab)
-!      exit
-    end if
-    call read_next_met_field(field,istatus)
- enddo
-
- end subroutine physics_initialize_sst
-
-!=============================================================================================
- subroutine physics_initialize_real(mesh,fg)
-!=============================================================================================
-!input arguments:
- type(mesh_type),intent(in) :: mesh
-
-!inout arguments:
- type(fg_type),intent(inout):: fg 
-
-!local variables:
  character(len=StrKIND):: initial_date
 
  integer:: iCell,nCellsSolve
@@ -171,19 +46,19 @@
 
  real(kind=RKIND),dimension(:),pointer:: skintemp,sst
  
-!---------------------------------------------------------------------------------------------
+!--------------------------------------------------------------------------------------------------
 
  write(0,*)
  write(0,*) '--- enter physics_initialize_real:'
 
  nCellsSolve = mesh % nCellsSolve
 
- landmask   =&gt; mesh % landmask   % array
- albedo12m  =&gt; mesh % albedo12m  % array
- greenfrac  =&gt; mesh % greenfrac  % array
- shdmin     =&gt; mesh % shdmin     % array
- shdmax     =&gt; mesh % shdmax     % array
- snoalb     =&gt; mesh % snoalb     % array
+ landmask   =&gt; mesh % landmask  % array
+ albedo12m  =&gt; mesh % albedo12m % array
+ greenfrac  =&gt; mesh % greenfrac % array
+ shdmin     =&gt; mesh % shdmin    % array
+ shdmax     =&gt; mesh % shdmax    % array
+ snoalb     =&gt; mesh % snoalb    % array
 
  sfc_albbck =&gt; fg % sfc_albbck % array
  vegfra     =&gt; fg % vegfra     % array
@@ -200,32 +75,9 @@
 !input file. calling this subroutine will overwrite the arrays sst and seaice already read
 !in the file defined by config_input_name:
  if(config_input_sst) then
-    call physics_initialize_sst(mesh,fg)
-
-    if(maxval(xice(1:nCellsSolve)) == 0._RKIND .and. minval(xice(1:nCellsSolve)) == 0._RKIND) then
-       write(0,*)
-       write(0,*) &quot;The input file does not contain sea-ice data. We freeze the really cold ocean instead&quot;
-       do iCell = 1, nCellsSolve
-          if(landmask(iCell).eq.0 .and. sst(iCell).lt.271._RKIND) xice(iCell) = 1._RKIND
-       enddo
-    endif
-    write(0,*) 'max sst  =',maxval(fg % sst  % array(1:mesh%nCells))
-    write(0,*) 'min sst  =',minval(fg % sst  % array(1:mesh%nCells))
-    write(0,*) 'max xice =',maxval(fg % xice % array(1:mesh%nCells))
-    write(0,*) 'min xice =',minval(fg % xice % array(1:mesh%nCells))
-
-    do iCell = 1, nCellsSolve
-       !recalculate the sea-ice flag:
-       if(xice(iCell) .gt. 0._RKIND) then
-          seaice(iCell) = 1._RKIND
-       else
-          seaice(iCell) = 0._RKIND
-       endif
-
-       !set the skin temperature to the sea-surface temperature over the oceans:
-       if(landmask(iCell).eq.0 .and. sst(iCell).gt.170._RKIND .and. sst(iCell).lt.400._RKIND) &amp;
-          skintemp(iCell) = sst(iCell)
-    enddo
+    write(0,*) '--- read sea-surface temperature from auxillary file:'
+    call interp_sfc_to_MPAS(config_start_time(1:13),mesh,fg,dminfo)
+    call physics_init_sst(mesh,fg)
  endif
 
 !initialization of the surface background albedo: interpolation of the monthly values to the
@@ -269,10 +121,10 @@
  enddo
 
 !initialization of soil layers properties:
- call init_soil_layers(mesh,fg)
+ call init_soil_layers(mesh,fg,dminfo)
 
-!adjustment of all surface fields for seaice points:
- call init_seaice_points(mesh,fg)
+!initialize seaice points:
+ call physics_init_seaice(mesh,fg)
 
 !define xland over land and ocean:
  do iCell = 1, nCellsSolve
@@ -287,17 +139,18 @@
 
  end subroutine physics_initialize_real
 
-!=============================================================================================
- subroutine init_soil_layers(mesh,fg)
-!=============================================================================================
+!==================================================================================================
+ subroutine init_soil_layers(mesh,fg,dminfo)
+!==================================================================================================
 
 !input arguments:
  type(mesh_type),intent(in):: mesh
+ type(dm_info),intent(in)  :: dminfo
 
 !inout arguments:
  type(fg_type),intent(inout):: fg
 
-!---------------------------------------------------------------------------------------------
+!--------------------------------------------------------------------------------------------------
 
 !adjust the annual mean deep soil temperature:
  call adjust_input_soiltemps(mesh,fg)
@@ -306,13 +159,13 @@
  call init_soil_layers_depth(mesh,fg)
  
 !initialize the temperature, moisture, and liquid water of the individual soil layers:
- call init_soil_layers_properties(mesh,fg)
+ call init_soil_layers_properties(mesh,fg,dminfo)
 
  end subroutine init_soil_layers
 
-!=============================================================================================
+!==================================================================================================
  subroutine adjust_input_soiltemps(mesh,fg)
-!=============================================================================================
+!==================================================================================================
 
 !input arguments:
  type(mesh_type),intent(in) :: mesh
@@ -329,7 +182,7 @@
  real(kind=RKIND),dimension(:),pointer  :: skintemp,soiltemp,tmn
  real(kind=RKIND),dimension(:,:),pointer:: st_fg
 
-!---------------------------------------------------------------------------------------------
+!--------------------------------------------------------------------------------------------------
 
  nCellsSolve   = mesh % nCellsSolve
  nFGSoilLevels = mesh % nFGSoilLevels
@@ -347,12 +200,12 @@
     if(landmask(iCell) .eq. 1) then
 
        !adjust the annual deep mean soil temperature and skin temperatures over land: 
-       tmn(iCell) = soiltemp(iCell) - 0.0065 * ter(iCell)
-       skintemp(iCell) = skintemp(iCell) - 0.0065 * (ter(iCell)-soilz(iCell))
+       tmn(iCell) = soiltemp(iCell) - 0.0065_RKIND * ter(iCell)
+       skintemp(iCell) = skintemp(iCell) - 0.0065_RKIND * (ter(iCell)-soilz(iCell))
 
        !adjust the soil layer temperatures:
        do ifgSoil = 1, nFGSoilLevels
-          st_fg(ifgSoil,iCell) = st_fg(ifgSoil,iCell) - 0.0065 * (ter(iCell)-soilz(iCell))
+          st_fg(ifgSoil,iCell) = st_fg(ifgSoil,iCell) - 0.0065_RKIND * (ter(iCell)-soilz(iCell))
        enddo
 
     elseif(landmask(iCell) .eq. 0) then
@@ -364,12 +217,12 @@
 
  end subroutine adjust_input_soiltemps
 
-!=============================================================================================
+!==================================================================================================
  subroutine init_soil_layers_depth(mesh,fg)
-!=============================================================================================
+!==================================================================================================
 
 !input arguments:
- type(mesh_type),intent(in) :: mesh
+ type(mesh_type),intent(in):: mesh
 
 !inout arguments:
  type(fg_type),intent(inout):: fg 
@@ -377,7 +230,7 @@
 !local variables:
  integer:: iCell,iSoil
 
-!---------------------------------------------------------------------------------------------
+!--------------------------------------------------------------------------------------------------
 
  write(0,*)
  write(0,*) '--- enter subroutine init_soil_layers_depth:'
@@ -388,65 +241,57 @@
  do iCell = 1, mesh % nCells
 
     iSoil = 1
-    fg % zs_fg % array(iSoil,iCell) = 0.5 * fg % dzs_fg % array(iSoil,iCell)
-!   if(iCell .eq. 1) write(0,101) iSoil,fg % dzs_fg % array(iSoil,iCell), &amp;
-!                                 fg % zs_fg % array(iSoil,iCell)
+    fg % zs_fg % array(iSoil,iCell) = 0.5_RKIND * fg % dzs_fg % array(iSoil,iCell)
     do iSoil = 2, mesh % nFGSoilLevels
        fg % zs_fg % array(iSoil,iCell) = fg % zs_fg % array(iSoil-1,iCell)        &amp;
-                                       + 0.5 * fg % dzs_fg % array(iSoil-1,iCell) &amp;
-                                       + 0.5 * fg % dzs_fg % array(iSoil,iCell)
-!      if(iCell .eq. 1) write(0,101) iSoil,fg % dzs_fg % array(iSoil,iCell), &amp;
-!                                    fg % zs_fg % array(iSoil,iCell)
+                                 + 0.5_RKIND * fg % dzs_fg % array(iSoil-1,iCell) &amp;
+                                 + 0.5_RKIND * fg % dzs_fg % array(iSoil,iCell)
     enddo
 
  enddo
- 101 format(i4,2(1x,e15.8))
 
  do iCell = 1, mesh % nCells
-    fg % dzs % array(1,iCell) = 0.10
-    fg % dzs % array(2,iCell) = 0.30
-    fg % dzs % array(3,iCell) = 0.60
-    fg % dzs % array(4,iCell) = 1.00
+    fg % dzs % array(1,iCell) = 0.10_RKIND
+    fg % dzs % array(2,iCell) = 0.30_RKIND
+    fg % dzs % array(3,iCell) = 0.60_RKIND
+    fg % dzs % array(4,iCell) = 1.00_RKIND
 
     iSoil = 1
-    fg % zs % array(iSoil,iCell)  = 0.5 * fg % dzs % array(iSoil,iCell)
-!   if(iCell .eq. 1) write(0,101) iSoil,fg % dzs % array(iSoil,iCell), &amp;
-!                                 fg % zs % array(iSoil,iCell)
-
+    fg % zs % array(iSoil,iCell)  = 0.5_RKIND * fg % dzs % array(iSoil,iCell)
     do iSoil = 2, mesh % nSoilLevels
-       fg % zs % array(iSoil,iCell) = fg % zs % array(iSoil-1,iCell)        &amp;
-                                    + 0.5 * fg % dzs % array(iSoil-1,iCell) &amp;
-                                    + 0.5 * fg % dzs % array(iSoil,iCell)
-!      if(iCell .eq. 1) write(0,101) iSoil,fg % dzs % array(iSoil,iCell),   &amp;
-!                                    fg % zs % array(iSoil,iCell)
+       fg % zs % array(iSoil,iCell) = fg % zs % array(iSoil-1,iCell)              &amp;
+                                    + 0.5_RKIND * fg % dzs % array(iSoil-1,iCell) &amp;
+                                    + 0.5_RKIND * fg % dzs % array(iSoil,iCell)
     enddo
 
  enddo
 
  end subroutine init_soil_layers_depth
 
-!=============================================================================================
- subroutine init_soil_layers_properties(mesh,fg)
-!=============================================================================================
+!==================================================================================================
+ subroutine init_soil_layers_properties(mesh,fg,dminfo)
+!==================================================================================================
 
 !input arguments:
- type(mesh_type),intent(in) :: mesh
+ type(mesh_type),intent(in):: mesh
+ type(dm_info),intent(in)  :: dminfo
 
 !inout arguments:
  type(fg_type),intent(inout):: fg 
 
 !local variables:
- integer:: iCell,ifgSoil,iSoil,is
+ integer:: iCell,ifgSoil,iSoil
  integer:: nCells,nFGSoilLevels,nSoilLevels
+ integer:: num_sm,num_st
  integer,dimension(:),pointer:: landmask
  
  real(kind=RKIND),dimension(:,:),allocatable:: zhave,sm_input,st_input
 
  real(kind=RKIND),dimension(:),pointer  :: skintemp,tmn
- real(kind=RKIND),dimension(:,:),pointer:: dzs,zs,tslb,smois,sh2o
+ real(kind=RKIND),dimension(:,:),pointer:: dzs,zs,tslb,smois,sh2o,smcrel
  real(kind=RKIND),dimension(:,:),pointer:: sm_fg,st_fg,zs_fg
 
-!---------------------------------------------------------------------------------------------
+!--------------------------------------------------------------------------------------------------
 
 !write(0,*)
  write(0,*) '--- enter subroutine init_soil_layers_properties:'
@@ -463,14 +308,33 @@
  st_fg =&gt; fg % st_fg % array
  sm_fg =&gt; fg % sm_fg % array
 
- zs    =&gt; fg % zs  % array
- dzs   =&gt; fg % dzs % array 
- sh2o  =&gt; fg % sh2o  % array
- smois =&gt; fg % smois % array 
- tslb  =&gt; fg % tslb  % array
+ zs     =&gt; fg % zs  % array
+ dzs    =&gt; fg % dzs % array 
+ sh2o   =&gt; fg % sh2o    % array
+ smcrel =&gt; fg % smcrel % array
+ smois  =&gt; fg % smois   % array 
+ tslb   =&gt; fg % tslb    % array
  skintemp =&gt; fg % skintemp % array
  tmn      =&gt; fg % tmn      % array
 
+!check that interpolation of the meteorological data to the MPAS grid did not create negative
+!values for the first-guess soil temperatures and soil moistures.
+ num_sm = 0
+ num_st = 0
+ do iCell = 1, nCells
+    do ifgSoil = 1, nFGSoilLevels
+       if(st_fg(ifgSoil,iCell) .le. 0._RKIND) num_st = num_st + 1
+       if(sm_fg(ifgSoil,iCell) .lt. 0._RKIND) num_sm = num_sm + 1
+    enddo
+ enddo
+ if(num_st .gt. 0) then
+    write(0,*) 'Error in interpolation of st_fg to MPAS grid: num_st =', num_st
+    call mpas_dmpar_abort(dminfo)
+ elseif(num_sm .gt. 0) then
+    write(0,*) 'Error in interpolation of sm_fg to MPAS grid: num_sm =', num_sm
+    call mpas_dmpar_abort(dminfo)
+ endif 
+
  if(config_nsoillevels .ne. 4) &amp;
     call physics_error_fatal('NOAH lsm uses 4 soil layers. Correct config_nsoillevels.')
 
@@ -481,17 +345,17 @@
  do iCell = 1, nCells
 
     ifgSoil = 1
-    zhave(ifgSoil,iCell)    = 0.
+    zhave(ifgSoil,iCell)    = 0._RKIND
     st_input(ifgSoil,iCell) = skintemp(iCell)
     sm_input(ifgSoil,iCell) = sm_fg(ifgSoil+1,iCell)
 
     do ifgSoil = 1, nFGSoilLevels
-       zhave(ifgSoil+1,iCell) = zs_fg(ifgSoil,iCell) / 100.
+       zhave(ifgSoil+1,iCell) = zs_fg(ifgSoil,iCell) / 100._RKIND
        st_input(ifgSoil+1,iCell) = st_fg(ifgSoil,iCell)
        sm_input(ifgSoil+1,iCell) = sm_fg(ifgSoil,iCell)
     enddo
 
-    zhave(nFGSoilLevels+2,iCell) = 300./100.
+    zhave(nFGSoilLevels+2,iCell) = 300._RKIND/100._RKIND
     st_input(nFGSoilLevels+2,iCell) = tmn(iCell)
     sm_input(nFGSoilLevels+2,iCell) = sm_input(nFGSoilLevels,iCell)
 
@@ -530,7 +394,8 @@
                     +  sm_input(ifgSoil+1,iCell) * (zs(iSoil,iCell)-zhave(ifgSoil,iCell)))   &amp;
                     / (zhave(ifgSoil+1,iCell)-zhave(ifgSoil,iCell))
 
-                sh2o(iSoil,iCell)  = 0.
+                sh2o(iSoil,iCell)   = 0._RKIND
+                smcrel(iSoil,iCell) = 0._RKIND
 
                 exit input
              endif
@@ -542,9 +407,10 @@
 
        !fill the soil temperatures with the skin temperatures over oceans:
        do iSoil = 1, nSoilLevels
-          tslb(iSoil,iCell)  = skintemp(iCell)
-          smois(iSoil,iCell) = 1.0
-          sh2o(iSoil,iCell)  = 1.0
+          tslb(iSoil,iCell)    = skintemp(iCell)
+          smois(iSoil,iCell)   = 1._RKIND
+          sh2o(iSoil,iCell)    = 1._RKIND
+          smcrel(iSoil,iCell)  = 0._RKIND
        enddo
 
     endif
@@ -555,10 +421,10 @@
 
  do iCell = 1, nCells
 
-    if(landmask(iCell).eq. 1 .and. tslb(1,iCell).gt.170. .and. tslb(1,iCell).lt.400. .and. &amp;
-       smois(1,iCell).lt.0.005) then
+    if(landmask(iCell).eq. 1 .and. tslb(1,iCell).gt.170._RKIND .and. tslb(1,iCell).lt.400._RKIND &amp;
+       .and. smois(1,iCell).lt.0.005_RKIND) then
        do iSoil = 1, nSoilLevels
-          smois(iSoil,iCell) = 0.005
+          smois(iSoil,iCell) = 0.005_RKIND
        enddo
     endif
 
@@ -574,19 +440,78 @@
 
  end subroutine init_soil_layers_properties
 
-!=============================================================================================
- subroutine init_seaice_points(mesh,fg)
-!=============================================================================================
+!==================================================================================================
+ subroutine physics_init_sst(mesh,input)
+!==================================================================================================
 
+!input arguments: 
+ type(mesh_type),intent(in):: mesh
+
+#if !defined(non_hydrostatic_core)
+!inout arguments: this subroutine is called from the MPAS initialization side.
+ type(fg_type),intent(inout):: input
+#else
+!inout arguments: this subroutine is called from the MPAS model side.
+ type(sfc_input_type),intent(inout):: input
+#endif
+
+!local variables:
+ integer:: iCell,nCells
+ integer,dimension(:),pointer:: landmask
+
+ real(kind=RKIND),dimension(:),pointer  :: sst,tsk,xice
+ real(kind=RKIND),dimension(:,:),pointer:: tslb
+
+!--------------------------------------------------------------------------------------------------
+ write(0,*)
+ write(0,*) '--- enter subroutine physics_update_sst:'
+
+!initialization:
+ nCells = mesh % nCells
+
+ landmask =&gt; mesh % landmask % array
+ sst  =&gt; input % sst      % array
+ tsk  =&gt; input % skintemp % array
+ tslb =&gt; input % tslb     % array
+ xice =&gt; input % xice     % array
+
+!update the skin temperature and the soil temperature of the first soil layer with the updated
+!sea-surface temperatures:
+!change made so that the SSTs read for the surface update file are the same as the skin temperature
+!over the oceans.
+!do iCell = 1, nCells
+!   if(landmask(iCell) == 0 .and. xice(iCell) == 0) then
+!      tsk(iCell) = sst(iCell)
+!   endif
+!enddo
+ do iCell = 1, nCells
+    if(landmask(iCell) == 0) then
+       tsk(iCell) = sst(iCell)
+    endif
+ enddo
+
+ write(0,*) '--- end subroutine physics_update_sst:'
+
+ end subroutine physics_init_sst
+
+!==================================================================================================
+ subroutine physics_init_seaice(mesh,input)
+!==================================================================================================
+
 !input arguments:
  type(mesh_type),intent(in) :: mesh
 
-!inout arguments:
- type(fg_type),intent(inout):: fg 
+#if !defined(non_hydrostatic_core)
+!inout arguments: this subroutine is called from the MPAS initialization side.
+ type(fg_type),intent(inout):: input
+#else
+!inout arguments: this subroutine is called from the MPAS model side.
+ type(sfc_input_type),intent(inout):: input
+#endif
 
 !local variables:
  character(len=StrKIND):: mess
- integer:: iCell,iSoil,nCellsSolve,nSoilLevels
+ integer:: iCell,iSoil,nCells,nSoilLevels
  integer:: num_seaice_changes
  integer,dimension(:),pointer:: landmask,isltyp,ivgtyp
 
@@ -594,8 +519,8 @@
  real(kind=RKIND):: mid_point_depth
  real(kind=RKIND),dimension(:),pointer  :: vegfra
  real(kind=RKIND),dimension(:),pointer  :: seaice,xice
- real(kind=RKIND),dimension(:),pointer  :: skintemp,sst,tmn
- real(kind=RKIND),dimension(:,:),pointer:: tslb,smois,sh2o
+ real(kind=RKIND),dimension(:),pointer  :: skintemp,tmn
+ real(kind=RKIND),dimension(:,:),pointer:: tslb,smois,sh2o,smcrel
 
 !note that this threshold is also defined in module_physics_vars.F.It is defined here to avoid
 !adding &quot;use module_physics_vars&quot; since this subroutine is only used for the initialization of
@@ -603,85 +528,108 @@
  real(kind=RKIND),parameter:: xice_tsk_threshold = 271.
  real(kind=RKIND),parameter:: total_depth        = 3.   ! 3-meter soil depth.
 
-!---------------------------------------------------------------------------------------------
-
+!--------------------------------------------------------------------------------------------------
  write(0,*)
- write(0,*) '--- enter init_seaice_points:'
- write(0,*) '--- config_frac_seaice      :', config_frac_seaice
+ write(0,*) '--- enter physics_init_seaice:'
 
- nCellsSolve = mesh % nCellsSolve
+ nCells     = mesh % nCells
  nSoilLevels = mesh % nSoilLevels
 
  landmask =&gt; mesh % landmask    % array
  isltyp   =&gt; mesh % soilcat_top % array
  ivgtyp   =&gt; mesh % lu_index    % array
 
- seaice   =&gt; fg   % seaice      % array
- xice     =&gt; fg   % xice        % array
- vegfra   =&gt; fg   % vegfra      % array
+ seaice   =&gt; input % seaice     % array
+ xice     =&gt; input % xice       % array
+ vegfra   =&gt; input % vegfra     % array
 
- skintemp =&gt; fg   % skintemp    % array
- sst      =&gt; fg   % sst         % array
- tmn      =&gt; fg   % tmn         % array
+ skintemp =&gt; input % skintemp   % array
+ tmn      =&gt; input % tmn        % array
 
- tslb     =&gt; fg   % tslb        % array
- smois    =&gt; fg   % smois       % array
- sh2o     =&gt; fg   % sh2o        % array
+ tslb     =&gt; input % tslb       % array
+ smois    =&gt; input % smois      % array
+ sh2o     =&gt; input % sh2o       % array
+ smcrel   =&gt; input % smcrel     % array
 
- if(.not. config_frac_seaice) then
-    xice_threshold = 0.5
- elseif(config_frac_seaice) then
-    xice_threshold = 0.02
- endif
+ do iCell = 1, nCells
+    seaice(iCell) = 0._RKIND
+ enddo
 
 !make sure that all the cells flagged as sea-ice cells are defined as ocean cells:
  num_seaice_changes = 0
- do iCell = 1, nCellsSolve
-    if((landmask(iCell).eq.1 .and. xice(iCell).gt.0.) .or. xice(iCell).gt.200.) then
+ do iCell = 1, nCells
+    if((landmask(iCell).eq.1 .and. xice(iCell).gt.0._RKIND) .or. xice(iCell).gt.200._RKIND) then
        num_seaice_changes = num_seaice_changes + 1
-       seaice(iCell) = 0.
-       xice(iCell)   = 0.
+       seaice(iCell) = 0._RKIND
+       xice(iCell)   = 0._RKIND
     endif
  enddo
- write(mess,fmt='(A,i12)') 'number of seaice cells converted to land cells=', &amp;
+ write(mess,fmt='(A,i12)') 'number of seaice cells converted to land cells 1 =', &amp;
        num_seaice_changes
  call physics_message(mess)
 
+!assign the threshold value for xice as a function of config_frac_seaice:
+ if(.not. config_frac_seaice) then
+    xice_threshold = 0.5_RKIND
+    do iCell = 1,nCells
+       if(xice(iCell) &gt;= xice_threshold) then
+          xice(iCell) = 1._RKIND
+       else
+          xice(iCell) = 0._RKIND
+       endif
+    enddo
+ elseif(config_frac_seaice) then
+    xice_threshold = 0.02
+ endif
+ write(0,*) '--- config_frac_seaice      :', config_frac_seaice
+ write(0,*) '--- xice_threshold          :', xice_threshold
+
+!convert seaice points to land points:
  num_seaice_changes = 0
- do iCell =1 , nCellsSolve
+ do iCell = 1, nCells
 
     if(xice(iCell) .ge. xice_threshold .or. &amp;
-       (landmask(iCell).eq.0 .and. skintemp(iCell).lt.xice_tsk_threshold)) then
+      (landmask(iCell).eq.0 .and. skintemp(iCell).lt.xice_tsk_threshold)) then
 
        num_seaice_changes = num_seaice_changes + 1
        !sea-ice points are converted to land points:
-       if(.not. config_frac_seaice) xice(iCell) = 1.0
-       if(landmask(iCell) .eq. 0) tmn(iCell) = 271.4
+       if(.not. config_frac_seaice) xice(iCell) = 1._RKIND
+       if(landmask(iCell) .eq. 0) tmn(iCell) = 271.4_RKIND
 
        ivgtyp(iCell)   = 24 ! (isice = 24)
        isltyp(iCell)   = 16
-       vegfra(iCell)   = 0.
-       landmask(iCell) = 1.
+       vegfra(iCell)   = 0._RKIND
+       landmask(iCell) = 1._RKIND
 
        do iSoil = 1, nSoilLevels
           mid_point_depth = total_depth/nSoilLevels/2. &amp;
                           + (iSoil-1)*(total_depth/nSoilLevels)
           tslb(iSoil,iCell) = ((total_depth-mid_point_depth) * skintemp(iCell) &amp;
                             +  mid_point_depth * tmn(iCell)) / total_depth
-          smois(iSoil,iCell) = 1.0
-          sh2o(iSoil,iCell)  = 0.0
+          smois(iSoil,iCell)  = 1._RKIND
+          sh2o(iSoil,iCell)   = 0._RKIND
+          smcrel(iSoil,iCell) = 0._RKIND
        enddo
        
     elseif(xice(iCell) .lt. xice_threshold) then
-       xice(iCell) = 0.
+       xice(iCell) = 0._RKIND
 
     endif
 
  enddo
+ write(mess,fmt='(A,i12)') 'number of seaice cells converted to land cells 2 =', &amp;
+       num_seaice_changes
+ call physics_message(mess)
 
- end subroutine init_seaice_points
+!finally, update the sea-ice flag:
+ do iCell = 1, nCells
+    if(xice(iCell) &gt; 0._RKIND) seaice(iCell) = 1._RKIND
+ enddo
+ write(0,*) '--- end physics_init_seaice:'
 
-!=============================================================================================
+ end subroutine physics_init_seaice
+
+!==================================================================================================
  end module mpas_atmphys_initialize_real
-!=============================================================================================
+!==================================================================================================
 

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_interface_nhyd.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_interface_nhyd.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_interface_nhyd.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -54,6 +54,15 @@
  if(.not.allocated(qs_p)   ) allocate(qs_p(ims:ime,kms:kme,jms:jme)   )
  if(.not.allocated(qg_p)   ) allocate(qg_p(ims:ime,kms:kme,jms:jme)   )
 
+!... arrays used for calculating the hydrostatic pressure and exner function:
+ if(.not.allocated(psfc_hyd_p)  ) allocate(psfc_hyd_p(ims:ime,jms:jme)          )
+ if(.not.allocated(psfc_hydd_p) ) allocate(psfc_hydd_p(ims:ime,jms:jme)         )
+ if(.not.allocated(pres_hyd_p)  ) allocate(pres_hyd_p(ims:ime,kms:kme,jms:jme)  )
+ if(.not.allocated(pres_hydd_p) ) allocate(pres_hydd_p(ims:ime,kms:kme,jms:jme) )
+ if(.not.allocated(pres2_hyd_p) ) allocate(pres2_hyd_p(ims:ime,kms:kme,jms:jme) )
+ if(.not.allocated(pres2_hydd_p)) allocate(pres2_hydd_p(ims:ime,kms:kme,jms:jme))
+ if(.not.allocated(znu_hyd_p)   ) allocate(znu_hyd_p(ims:ime,kms:kme,jms:jme)   )

  end subroutine allocate_forall_physics
 
 !=============================================================================================
@@ -91,10 +100,18 @@
  if(allocated(qs_p)    ) deallocate(qs_p    )
  if(allocated(qg_p)    ) deallocate(qg_p    )
 
+ if(allocated(psfc_hyd_p)  ) deallocate(psfc_hyd_p  )
+ if(allocated(psfc_hydd_p) ) deallocate(psfc_hydd_p )
+ if(allocated(pres_hyd_p)  ) deallocate(pres_hyd_p  )
+ if(allocated(pres_hydd_p) ) deallocate(pres_hydd_p )
+ if(allocated(pres2_hyd_p) ) deallocate(pres2_hyd_p )
+ if(allocated(pres2_hydd_p)) deallocate(pres2_hydd_p)
+ if(allocated(znu_hyd_p)   ) deallocate(znu_hyd_p   )

  end subroutine deallocate_forall_physics
 
 !=============================================================================================
- subroutine MPAS_to_physics(mesh,state,diag)
+ subroutine MPAS_to_physics(mesh,state,diag,diag_physics)
 !=============================================================================================
 
 !input variables:
@@ -102,6 +119,9 @@
  type(state_type),intent(in):: state
  type(diag_type) ,intent(in):: diag
 
+!inout variables:
+ type(diag_physics_type),intent(inout):: diag_physics
+
 !local variables:
  integer:: i,k,j
  real(kind=RKIND):: z0,z1,z2,w1,w2
@@ -114,7 +134,7 @@
  real(kind=RKIND),dimension(:,:),pointer:: rho_zz,theta_m,qv,pressure_p,u,v,w
  real(kind=RKIND),dimension(:,:),pointer:: qvs,rh
 
- real(kind=RKIND):: rho1,rho2,tem1,tem2
+ real(kind=RKIND):: rho_a,rho1,rho2,tem1,tem2
 
 !---------------------------------------------------------------------------------------------
 
@@ -152,18 +172,7 @@
  u =&gt; diag  % uReconstructZonal % array
  v =&gt; diag  % uReconstructMeridional % array
 
-!ldf (2012-01-06): updates the surface pressure as is done in subroutine microphysics_to_MPAS.
-!do j = jts,jte
-!do i = its,ite
-!   sfc_pressure(i) = 0.5*g*(zgrid(2,i)-zgrid(1,i)) &amp;
-!                   * (1.25 * rho_zz(1,i) * zz(1,i) * (1. + qv(1,i))  &amp;
-!                   -  0.25 * rho_zz(2,i) * zz(2,i) * (1. + qv(1,i)))
-!   sfc_pressure(i) = sfc_pressure(i) + pressure_p(1,i) + pressure_b(1,i)
-!enddo
-!enddo
-!ldf end.
-!ldf (2012-01-09): updates the surface pressure using zgrid.
-!do j = jts,jte
+!calculation of the surface pressure using hydrostatic assumption down to the surface::
  do i = its,ite
     tem1 = zgrid(2,i)-zgrid(1,i)
     tem2 = zgrid(3,i)-zgrid(2,i)
@@ -173,17 +182,15 @@
                     * (rho1 + 0.5*(rho2-rho1)*tem1/(tem1+tem2))
     sfc_pressure(i) = sfc_pressure(i) + pressure_p(1,i) + pressure_b(1,i)
  enddo
+
+!arrays located at theta points:
+!do j = jts, jte
+!do i = its, ite
+!   psfc_p(i,j) = diag % surface_pressure % array(i)
 !enddo
-!ldf end.
+!enddo
 
-!copy sounding variables from the geodesic grid to the rectangular grid:
  do j = jts, jte
- do i = its, ite
-    psfc_p(i,j) = diag % surface_pressure % array(i)
- enddo
- enddo
-
- do j = jts, jte
  do k = kts, kte
  do i = its, ite
 
@@ -216,6 +223,7 @@
  enddo
  enddo
 
+!arrays located at w points:
  do j = jts, jte
  do k = kts,kte+1
  do i = its,ite
@@ -225,38 +233,26 @@
  enddo
  enddo
 
+!check that the pressure in the layer above the surface is greater than that in the layer
+!above it:
  do j = jts,jte
  do i = its,ite
-    if(pres_p(i,1,j) .lt. pres_p(i,2,j)) then
+    if(pres_p(i,1,j) .le. pres_p(i,2,j)) then
        write(0,*)
-       write(0,*) '--- subroutine MPAS_to_phys: pres:',j,i
-       write(0,*) 'latCell=', latCell(i)
-       write(0,*) 'lonCell=', lonCell(i)
+       write(0,*) '--- subroutine MPAS_to_phys - pressure(1) &lt; pressure(2):'
+       write(0,*) 'i      =', i
+       write(0,*) 'latCell=', latCell(i)/degrad
+       write(0,*) 'lonCell=', lonCell(i)/degrad
        do k = kts,kte
-          write(0,201) j,i,k,pressure_b(k,i),pressure_p(k,i),pres_p(i,k,j),zz(k,i), &amp;
+          write(0,201) j,i,k,dz_p(i,k,j),pressure_b(k,i),pressure_p(k,i),pres_p(i,k,j), &amp;
              rho_p(i,k,j),th_p(i,k,j),t_p(i,k,j),qv_p(i,k,j)
        enddo
-       write(0,*)
-       do k = kts,kte
-          write(0,201) j,i,k,qv_p(i,k,j),qc_p(i,k,j),qr_p(i,k,j),qi_p(i,k,j),qs_p(i,k,j), &amp;
-                       qg_p(i,k,j)
-       enddo
-       write(0,*)
-       stop
+!      stop
     endif
  enddo
  enddo
 
 !interpolation of pressure and temperature from theta points to w points:
-!do j = jts,jte
-!do k = kts+1,kte
-!do i = its,ite
-!   t2_p(i,k,j)    = fzm(k)*t_p(i,k,j) + fzp(k)*t_p(i,k-1,j)
-!   pres2_p(i,k,j) = fzm(k)*pres_p(i,k,j) + fzp(k)*pres_p(i,k-1,j)
-!enddo
-!enddo
-!enddo
-!ldf(2011-01-10):
  do j = jts,jte
  do k = kts+1,kte
  do i = its,ite
@@ -286,7 +282,8 @@
  enddo
  enddo
 
-!interpolation of pressure and temperature from theta points to the surface:
+!ldf (2012-06-22): recalculates the pressure at the surface as an extrapolation of the
+!pressures in the 2 layers above the surface, as was originally done:
  k = kts
  do j = jts,jte
  do i = its,ite
@@ -296,34 +293,45 @@
     w1 = (z0-z2)/(z1-z2)
     w2 = 1.-w1
     t2_p(i,k,j)    = w1*t_p(i,k,j)+w2*t_p(i,k+1,j)
-    !use surface pressure calculated in subroutine recover_large_step_variables.
-    !pres2_p(i,k,j) = w1*pres_p(i,k,j)+w2*pres_p(i,k+1,j)
-    pres2_p(i,k,j) = psfc_p(i,j)
+    pres2_p(i,k,j) = w1*pres_p(i,k,j)+w2*pres_p(i,k+1,j)
+    psfc_p(i,j) = pres2_p(i,k,j)
  enddo
- enddo 
+ enddo
+
+!calculation of the hydrostatic pressure:
  do j = jts,jte
  do i = its,ite
-    if(pres2_p(i,1,j) .lt. pres2_p(i,2,j)) then
-       write(0,*)
-       write(0,*) '--- subroutine MPAS_to_phys: pres2:',j,i
-       do k = kts,kte+1
-          write(0,201) j,i,k,pres2_p(i,k,j)
-      enddo
-!      write(0,*)
-!      do k = kts,kte
-!         write(0,201) j,i,k,pressure_b(k,i),pressure_p(k,i),pres_p(i,k,j),zz(k,i), &amp;
-!            rho_p(i,k,j),th_p(i,k,j),t_p(i,k,j),qv_p(i,k,j)
-!      enddo
-!      write(0,*)
-!      do k = kts,kte
-!         write(0,201) j,i,k,qv_p(i,k,j),qc_p(i,k,j),qr_p(i,k,j),qi_p(i,k,j),qs_p(i,k,j), &amp;
-!                     qg_p(i,k,j)
-!      enddo
-       stop
-    endif
+    !pressure at w-points:
+    k = kte+1
+    pres2_hyd_p(i,k,j)  = pres2_p(i,k,j)
+    pres2_hydd_p(i,k,j) = pres2_p(i,k,j)
+    do k = kte,1,-1
+       rho_a = rho_p(i,k,j) / (1.+qv_p(i,k,j))
+       pres2_hyd_p(i,k,j)  = pres2_hyd_p(i,k+1,j)  + g*rho_p(i,k,j)*dz_p(i,k,j)
+       pres2_hydd_p(i,k,j) = pres2_hydd_p(i,k+1,j) + g*rho_a*dz_p(i,k,j)
+    enddo
+    !pressure at theta-points:
+    do k = kte,1,-1
+       pres_hyd_p(i,k,j)  = 0.5*(pres2_hyd_p(i,k+1,j)+pres2_hyd_p(i,k,j))
+       pres_hydd_p(i,k,j) = 0.5*(pres2_hydd_p(i,k+1,j)+pres2_hydd_p(i,k,j))
+    enddo
+    !surface pressure:
+    psfc_hyd_p(i,j) = pres2_hyd_p(i,1,j)
+    psfc_hydd_p(i,j) = pres2_hydd_p(i,1,j)
+    !znu:
+    do k = kte,1,-1
+       znu_hyd_p(i,k,j) = pres_hyd_p(i,k,j) / psfc_hyd_p(i,j) 
+    enddo
  enddo
  enddo
 
+!save the model-top pressure:
+ do j = jts,jte
+ do i = its,ite
+    diag_physics % plrad % array(i) = pres2_p(i,kte+1,j) 
+ enddo
+ enddo
+
 !formats: 
  201 format(3i8,10(1x,e15.8))
  202 format(2i6,10(1x,e15.8))
@@ -546,15 +554,6 @@
  enddo
 
 !updates the surface pressure.
-!do j = jts,jte
-!do i = its,ite
-!   sfc_pressure(i) = 0.5*g*(zgrid(2,i)-zgrid(1,i)) &amp;
-!                   * (1.25 * rho_zz(1,i) * zz(1,i) * (1. + qv_p(i,1,j))  &amp;
-!                   -  0.25 * rho_zz(2,i) * zz(2,i) * (1. + qv_p(i,2,j)))
-!   sfc_pressure(i) = sfc_pressure(i) + pressure_p(1,i) + pressure_b(1,i)
-!enddo
-!enddo
-!ldf (2012-01-09):
  do j = jts,jte
  do i = its,ite
     tem1 = zgrid(2,i)-zgrid(1,i)

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_manager.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_manager.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_manager.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -14,6 +14,12 @@
  private
  public:: physics_timetracker,physics_run_init
 
+!add-ons and modifications to sourcecode:
+!* added initialization of variable sf_surface_physics in subroutine physics_run_init. see
+!  definition of sf_surface_physics in mpas_atmphys_vars.F
+!  Laura D. Fowler (birch.ucar.edu) / 2013-03-11.

+
  integer, public:: year                 !Current year.
  integer, public:: julday               !Initial Julian day.
  real(kind=RKIND), public:: curr_julday !Current Julian day (= 0.0 at 0Z on January 1st).
@@ -55,6 +61,9 @@
  integer, parameter:: acradtAlarmID   = 20
  type(MPAS_TimeInterval_Type):: acradtTimeStep
 
+!defines alarm to compute some physics diagnostics, such as radar reflectivity:
+ integer, parameter:: diagAlarmID     = 21
+
  integer :: h, m, s, s_n, s_d, DoY, yr
  real(kind=RKIND) :: utc_h
 
@@ -229,6 +238,14 @@
     write(0,*) '--- time to apply limit to accumulated radiation diags. L_ACRADT   =',l_acradt
  endif
 
+!check to see if it is time to calculate additional physics diagnostics:
+ l_diags = .false.
+ if(mpas_is_alarm_ringing(clock,diagAlarmID,ierr=ierr)) then
+    call mpas_reset_clock_alarm(clock,diagAlarmID,ierr=ierr)
+    l_diags = .true.
+ endif
+ write(0,*) '--- time to calculate additional physics_diagnostics               =',l_diags
+
  end subroutine physics_timetracker
 
 !=============================================================================================
@@ -419,6 +436,11 @@
           call physics_error_fatal('subroutine physics_init: error creating alarm radiation limit')
  endif
 
+!set alarm to calculate physics diagnostics on IO outpt only:
+ call mpas_set_timeInterval(alarmTimeStep,timeString=config_output_interval,ierr=ierr)
+ alarmStartTime = startTime
+ call mpas_add_clock_alarm(clock,diagAlarmID,alarmStartTime,alarmTimeStep,ierr=ierr)
+
  write(0,102) dt_radtlw,dt_radtsw,dt_cu,dt_pbl
 
 !initialization of physics dimensions to mimic a rectangular grid:
@@ -447,11 +469,14 @@
  lsm_scheme          = trim(config_lsm_scheme)
  microp_scheme       = trim(config_microp_scheme)
  pbl_scheme          = trim(config_pbl_scheme)
+ gwdo_scheme         = trim(config_gwdo_scheme)
  radt_cld_scheme     = trim(config_radt_cld_scheme)
  radt_lw_scheme      = trim(config_radt_lw_scheme)
  radt_sw_scheme      = trim(config_radt_sw_scheme)
  sfclayer_scheme     = trim(config_sfclayer_scheme)
 
+ if(trim(config_lsm_scheme) .eq. &quot;noah&quot;) sf_surface_physics = 2 
+
 !initialization of local physics time-steps:
 !... dynamics:
  dt_dyn     = config_dt
@@ -466,6 +491,7 @@
  l_radtlw = .false.
  l_radtsw = .false.
 !... others:
+ l_diags  = .false.
  l_camlw  = .false.
  l_acrain = .false.
  l_acradt = .false.

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_todynamics.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_todynamics.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_todynamics.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -12,15 +12,16 @@
  contains
  
 !=============================================================================================
-subroutine physics_addtend(mesh, state, diag, tend, tend_physics, mass, mass_edge)
+subroutine physics_addtend(mesh, state, diag, tend, tend_physics, mass, mass_edge, rk_step)
 !=============================================================================================
 
 !input variables:
 !----------------
-type(mesh_type),intent(in):: mesh
+ type(mesh_type),intent(in):: mesh
  type(state_type),intent(in):: state
  type(diag_type),intent(in):: diag
  type(tend_physics_type),intent(inout):: tend_physics
+ integer, intent(in):: rk_step
  real(kind=RKIND),dimension(:,:),intent(in):: mass
  real(kind=RKIND),dimension(:,:),intent(in):: mass_edge
 
@@ -54,9 +55,6 @@
 !ldf end.
 
 !=============================================================================================
-!write(0,*)
-!write(0,*) '--- enter subroutine physics_add_tend:'
-
  block =&gt; mesh % block
  
  nCells      = mesh % nCells
@@ -120,13 +118,6 @@
     enddo
     enddo
  endif
-write(0,*) 'max rthblten = ',maxval(rthblten(:,1:nCellsSolve))
-write(0,*) 'min rthblten = ',minval(rthblten(:,1:nCellsSolve))
-!write(0,*) 'max rqvblten = ',maxval(rqvblten(:,1:nCellsSolve))
-!write(0,*) 'min rqvblten = ',minval(rqvblten(:,1:nCellsSolve))
-!write(0,*) 'max tend     = ',maxval(tend_scalars(tend%index_qv,:,1:nCellsSolve))
-!write(0,*) 'min tend     = ',minval(tend_scalars(tend%index_qv,:,1:nCellsSolve))
-!write(0,*)
 
 !add coupled tendencies due to convection:
  if(config_conv_deep_scheme .ne. 'off') then
@@ -154,13 +145,6 @@
     enddo
     enddo
  endif
-write(0,*) 'max rthcuten = ',maxval(rthcuten(:,1:nCellsSolve))
-write(0,*) 'min rthcuten = ',minval(rthcuten(:,1:nCellsSolve))
-!write(0,*) 'max rqvcuten = ',maxval(rqvcuten(:,1:nCellsSolve))
-!write(0,*) 'min rqvcuten = ',minval(rqvcuten(:,1:nCellsSolve))
-!write(0,*) 'max tend     = ',maxval(tend_scalars(tend%index_qv,:,1:nCellsSolve))
-!write(0,*) 'min tend     = ',minval(tend_scalars(tend%index_qv,:,1:nCellsSolve))
-!write(0,*)
 
 !add coupled tendencies due to longwave radiation:
  if(config_radt_lw_scheme .ne. 'off') then
@@ -170,8 +154,6 @@
     enddo
     enddo
  endif
-write(0,*) 'max rthratenlw = ',maxval(rthratenlw(:,1:nCellsSolve))
-write(0,*) 'min rthratenlw = ',minval(rthratenlw(:,1:nCellsSolve))
     
 !add coupled tendencies due to shortwave radiation:
  if(config_radt_sw_scheme .ne. 'off') then
@@ -181,8 +163,6 @@
     enddo
     enddo
  endif
-write(0,*) 'max rthratensw = ',maxval(rthratensw(:,1:nCellsSolve))
-write(0,*) 'min rthratensw = ',minval(rthratensw(:,1:nCellsSolve))
 
 !if non-hydrostatic core, convert the tendency for the potential temperature to a
 !tendency for the modified potential temperature:
@@ -205,6 +185,21 @@
  deallocate(theta)
  deallocate(tend_th)
 
+ if(rk_step .eq. 3) then
+    write(0,*)
+    write(0,*) '--- enter subroutine physics_addtend:'
+    write(0,*) 'max rthblten   = ',maxval(rthblten(:,1:nCellsSolve))
+    write(0,*) 'min rthblten   = ',minval(rthblten(:,1:nCellsSolve))
+    write(0,*) 'max rthcuten   = ',maxval(rthcuten(:,1:nCellsSolve))
+    write(0,*) 'min rthcuten   = ',minval(rthcuten(:,1:nCellsSolve))
+    write(0,*) 'max rthratenlw = ',maxval(rthratenlw(:,1:nCellsSolve))
+    write(0,*) 'min rthratenlw = ',minval(rthratenlw(:,1:nCellsSolve))
+    write(0,*) 'max rthratensw = ',maxval(rthratensw(:,1:nCellsSolve))
+    write(0,*) 'min rthratensw = ',minval(rthratensw(:,1:nCellsSolve))
+    write(0,*) '--- end subroutine physics_addtend'
+    write(0,*)
+ endif
+
 !formats:
  201 format(2i6,10(1x,e15.8))
  202 format(3i6,10(1x,e15.8))

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_update_surface.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_update_surface.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_update_surface.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -54,7 +54,7 @@
  shdmax     =&gt; sfc_input % shdmax     % array
 
 !updates the surface background albedo for the current date as a function of the monthly-mean
-!surface background albedo valid on the 15th day of the month, if input_sfc_albedo is true:
+!surface background albedo valid on the 15th day of the month, if config_sfc_albedo is true:
  if(config_sfc_albedo) then
 
     call monthly_interp_to_date(nCellsSolve,current_date,albedo12m,sfc_albbck)
@@ -146,6 +146,9 @@
     if(config_frac_seaice) then
 
        if(xice(iCell).ne.xicem(iCell) .and. xicem(iCell).gt.xice_threshold) then
+          !Fractional values of sfc_albedo and sfc_emiss are valid according to the earlier
+          !fractional sea-ice fraction, xicem. We recompute them for the new sea-ice fraction,
+          !xice.
           sfc_albedo(iCell) = 0.08 + (sfc_albedo(iCell) -0.08) * xice(iCell)/xicem(iCell)
           sfc_emiss(iCell)  = 0.98 + (sfc_emiss(iCell)-0.98) * xice(iCell)/xicem(iCell)
        endif
@@ -178,12 +181,12 @@
        sfc_emibck(iCell) = 0.98
 
     elseif(xland(iCell).lt.1.5 .and. xice(iCell).lt.xice_threshold .and. &amp;
-       xicem(iCell).lt.xice_threshold) then
+       xicem(iCell).ge.xice_threshold) then
 
        !sea-ice points turn to water points:
        xicem(iCell)  = xice(iCell)
        xland(iCell)  = 2.
-       isltyp(iCell) = 16
+       isltyp(iCell) = 14
        ivgtyp(iCell) = iswater
        vegfra(iCell) = 0.
        tmn(iCell)    = sst(iCell)
@@ -236,22 +239,25 @@
  real(kind=RKIND):: fs, con1, con2, con3, con4, con5, zlan, q2, ts, phi, qn1
  real(kind=RKIND):: usw, qo, swo, us, tb, dtc, dtw, alw, dtwo, delt, f1
 
- real(kind=RKIND),dimension(:),pointer:: tsk,xland
+ real(kind=RKIND),dimension(:),pointer:: sst,tsk,xland
  real(kind=RKIND),dimension(:),pointer:: glw,gsw
- real(kind=RKIND),dimension(:),pointer:: hfx,qfx,sstsk
- real(kind=RKIND),dimension(:),pointer:: dtw1,emiss,ust
+ real(kind=RKIND),dimension(:),pointer:: hfx,qfx
+ real(kind=RKIND),dimension(:),pointer:: emiss,ust
+ real(kind=RKIND),dimension(:),pointer:: sstsk,dtc1,dtw1
 
 !---------------------------------------------------------------------------------------------
-!write(0,*)
-!write(0,*) '--- enter subroutine physics_update_sstskin:'
+ write(0,*)
+ write(0,*) '--- enter subroutine physics_update_sstskin:'
 
  nCellsSolve = mesh % nCellsSolve
 
  tsk   =&gt; sfc_input % skintemp % array
+ sst   =&gt; sfc_input % sst      % array
  xland =&gt; sfc_input % xland    % array
 
- dtw1  =&gt; diag_physics % sstsk_diur % array
  sstsk =&gt; diag_physics % sstsk      % array
+ dtc1  =&gt; diag_physics % sstsk_dtc  % array
+ dtw1  =&gt; diag_physics % sstsk_dtw  % array
  emiss =&gt; diag_physics % sfc_emiss  % array
  glw   =&gt; diag_physics % glw        % array
  gsw   =&gt; diag_physics % gsw        % array
@@ -262,8 +268,14 @@
  skinmax = -9999.
  skinmin =  9999.
 
+!first, restore the surface temperature to the sea-surface temperature:
  do iCell = 1, nCellsSolve
+    if(xland(iCell) .ge. 1.5) tsk(iCell) = sst(iCell)
+ enddo
 
+!calculate the skin sea-surface temperature: 
+ do iCell = 1, nCellsSolve
+
     if(xland(iCell) .ge. 1.5) then
 
        qo   = glw(iCell)-emiss(iCell)*stbolt*(sstsk(iCell)**4)-2.5e6*qfx(iCell)-hfx(iCell)
@@ -324,19 +336,20 @@
        skinmax = amax1(skinmax,ts-tb)
        skinmin = amin1(skinmin,ts-tb)
        sstsk(iCell) = ts+273.15                ! convert ts (in C) to sstsk (in K)
+       dtc1(iCell)  = dtc                      ! dtc always in C
        dtw1(iCell)  = dtw                      ! dtw always in C
 
     endif
 
  enddo
 
-!update the skin temperature:
+!update the surface temperature over the oceans:
  do iCell = 1, nCellsSolve
     if(xland(iCell) .gt. 1.5) tsk(iCell) = sstsk(iCell)
  enddo
 
- write(0,*) 'check skin sst skinmax = ', skinmax, '  skinmin = ', skinmin

+ write(0,*) 'check skin sst skinmax = ', skinmax
+ write(0,*) 'check skin sst skinmin = ', skinmin
 
  end subroutine physics_update_sstskin
 

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_vars.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_vars.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/mpas_atmphys_vars.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -7,6 +7,12 @@
  public
  save
 
+!add-ons and modifications to sourcecode:
+!* added the variables sf_surface_physics,alswvisdir_p,alswvisdif_p,alswnirdir_p,alswnirdif_p,
+!  swvisdir_p,swvisdif_p,swnirdir_p,and swnirdif_p to upgrade the RRTMG short wave radiation
+!  code to WRF version 3.4.1. see definition of each individual variables below.
+!  Laura D. Fowler (birch.ucar.edu) / 2013-03-11.
+
 !=============================================================================================
 !list of physics parameterizations:
 !=============================================================================================
@@ -14,6 +20,7 @@
  character(len=StrKIND),public:: microp_scheme
  character(len=StrKIND),public:: conv_deep_scheme
  character(len=StrKIND),public:: conv_shallow_scheme
+ character(len=StrKIND),public:: gwdo_scheme
  character(len=StrKIND),public:: lsm_scheme
  character(len=StrKIND),public:: pbl_scheme
  character(len=StrKIND),public:: radt_cld_scheme
@@ -30,12 +37,14 @@
  logical:: l_radtsw                   !controls call to shortwave radiation parameterization.
  logical:: l_conv                     !controls call to convective parameterization.
  logical:: l_camlw                    !controls when to save local CAM LW abs and ems arrays.
+ logical:: l_diags                    !controls when to calculate physics diagnostics.
  logical:: l_acrain                   !when .true., limit to accumulated rain is applied.
  logical:: l_acradt                   !when .true., limit to lw and sw radiation is applied.
 
  integer,public:: ids,ide,jds,jde,kds,kde
  integer,public:: ims,ime,jms,jme,kms,kme
  integer,public:: its,ite,jts,jte,kts,kte
+ integer,public:: iall
  integer,public:: n_microp
 
  integer,public:: num_months          !number of months                                    [-]
@@ -96,6 +105,17 @@
     pres2_p,          &amp;!pressure                                                         [hPa]
     t2_p               !temperature                                                        [K]
 
+!... arrays used for calculating the hydrostatic pressure and exner function:
+ real(kind=RKIND),dimension(:,:),allocatable:: &amp;
+    psfc_hyd_p,       &amp;!surface pressure                                                 [hPa]
+    psfc_hydd_p        !&quot;dry&quot; surface pressure                                           [hPa]
+ real(kind=RKIND),dimension(:,:,:),allocatable:: &amp;
+    pres_hyd_p,       &amp;!pressure located at theta levels                                 [hPa]
+    pres_hydd_p,      &amp;!&quot;dry&quot; pressure located at theta levels                           [hPa]
+    pres2_hyd_p,      &amp;!pressure located at w-velocity levels                            [hPa]
+    pres2_hydd_p,     &amp;!&quot;dry&quot; pressure located at w-velocity levels                      [hPa]
+    znu_hyd_p          !(pres_hyd_p / P0) needed in the Tiedtke convection scheme        [hPa]
+
 !=============================================================================================
 !... variables and arrays related to parameterization of cloud microphysics:
 !    warm_phase: logical that determines if we want to run warm-phase cloud microphysics only.
@@ -164,6 +184,18 @@
     rqrcuten_p,       &amp;!
     rqscuten_p         !
 
+!... kain fritsch (trigger option) specific arrays:
+ real(kind=RKIND),dimension(:,:),allocatable:: &amp;
+    area_kf_p          !as area_p but using nCells instead of nCellsSolve                  [m2]
+ real(kind=RKIND),dimension(:,:,:),allocatable:: &amp;
+    rqvdynten_havg_p, &amp;!
+    rqvdynten_vavg_p, &amp;!
+    t_kf_p,           &amp;!as t_p but using nCells instead of nCellsSolve to compute t_havg_p [K]
+    t_havg_p,         &amp;!
+    t_vavg_p,         &amp;!
+    t_htrigger_p,     &amp;!
+    t_vtrigger_p       !
+
 !... tiedtke specific arrays:
  real(kind=RKIND),dimension(:,:,:),allocatable:: &amp;
     znu_p,            &amp;!
@@ -184,6 +216,8 @@
  real(kind=RKIND),public:: dt_pbl
 
  real(kind=RKIND),dimension(:,:),allocatable:: &amp;
+    ctopo_p,          &amp;!correction to topography                                           [-]
+    ctopo2_p,         &amp;!correction to topography 2                                         [-]                  
     hpbl_p             !PBL height                                                         [m]
 
  real(kind=RKIND),dimension(:,:,:),allocatable:: &amp;
@@ -197,23 +231,57 @@
     rqcblten_p,       &amp;!
     rqiblten_p         !
 
+ real(kind=RKIND),dimension(:,:,:),allocatable:: &amp;
+    kzh_p,            &amp;!
+    kzm_p,            &amp;!
+    kzq_p              !
+
 !=============================================================================================
+!... variables and arrays related to parameterization of gravity wave drag over orography:
+!=============================================================================================
+
+ real(kind=RKIND),dimension(:,:),allocatable:: &amp;
+    var2d_p,          &amp;!orographic variance                                               (m2)
+    con_p,            &amp;!orographic convexity                                              (m2)
+    oa1_p,            &amp;!orographic direction asymmetry function                            (-)
+    oa2_p,            &amp;!orographic direction asymmetry function                            (-)
+    oa3_p,            &amp;!orographic direction asymmetry function                            (-)
+    oa4_p,            &amp;!orographic direction asymmetry function                            (-)
+    ol1_p,            &amp;!orographic direction asymmetry function                            (-)
+    ol2_p,            &amp;!orographic direction asymmetry function                            (-)
+    ol3_p,            &amp;!orographic direction asymmetry function                            (-)
+    ol4_p              !orographic direction asymmetry function                            (-)
+
+ real(kind=RKIND),dimension(:,:),allocatable:: &amp;
+    dx_p               !maximum distance between cell centers                              (m)
+
+ real(kind=RKIND),dimension(:,:),allocatable:: &amp;
+    dusfcg_p,         &amp;!vertically-integrated gwdo u-stress                         (Pa m s-1)
+    dvsfcg_p           !vertically-integrated gwdo v -stress                        (Pa m s-1)
+
+ real(kind=RKIND),dimension(:,:,:),allocatable:: &amp;
+    dtaux3d_p,        &amp;!gravity wave drag over orography u-stress                      (m s-1)
+    dtauy3d_p          !gravity wave drag over orography u-stress                      (m s-1)
+
+!=============================================================================================
 !... variables and arrays related to parameterization of surface layer:
 !=============================================================================================
  real(kind=RKIND),dimension(:,:),allocatable:: &amp;
     br_p,             &amp;!bulk richardson number                                             [-]
-    cd_p,             &amp;!
-    cda_p,            &amp;!
-    ck_p,             &amp;!
-    cka_p,            &amp;!
+    cd_p,             &amp;!momentum exchange coeff at 10 meters                               [?]
+    cda_p,            &amp;!momentum exchange coeff at the lowest model level                  [?]
     cpm_p,            &amp;!
     chs_p,            &amp;!
     chs2_p,           &amp;!
+    ck_p,             &amp;!enthalpy exchange coeff at 10 meters                               [?]
+    cka_p,            &amp;!enthalpy exchange coeff at the lowest model level                  [?]
     cqs2_p,           &amp;!
     gz1oz0_p,         &amp;!log of z1 over z0                                                  [-]
     flhc_p,           &amp;!exchange coefficient for heat                                      [-]
     flqc_p,           &amp;!exchange coefficient for moisture                                  [-]
     hfx_p,            &amp;!upward heat flux at the surface                                 [W/m2]
+    fh_p,             &amp;!integrated stability function for heat                             [-]
+    fm_p,             &amp;!integrated stability function for momentum                         [-]             
     lh_p,             &amp;!latent heat flux at the surface                                 [W/m2]
     mavail_p,         &amp;!surface moisture availability                                      [-]
     mol_p,            &amp;!T* in similarity theory                                            [K]
@@ -230,12 +298,13 @@
     th2m_p,           &amp;!potential temperature at 2m                                        [K]
     u10_p,            &amp;!u at 10 m                                                        [m/s]
     ust_p,            &amp;!u* in similarity theory                                          [m/s]
-    ustm_p,           &amp;!u* in similarity theory without vconv                            [m/s]
+    ustm_p,           &amp;!u* in similarity theory       without vconv correction           [m/s]
     v10_p,            &amp;!v at 10 m                                                        [m/s]
     wspd_p,           &amp;!wind speed                                                       [m/s]
     znt_p,            &amp;!time-varying roughness length                                      [m]
     zol_p              !
 
+
 !=============================================================================================
 !... variables and arrays related to parameterization of short-wave radiation:
 !=============================================================================================
@@ -257,6 +326,12 @@
     swupt_p,          &amp;!all-sky upwelling shortwave flux at top-of-atmosphere          [J m-2]
     swuptc_p           !clear-sky upwelling shortwave flux at top-of-atmosphere        [J m-2]
 
+ real(kind=RKIND),dimension(:,:),allocatable:: &amp;
+    swvisdir_p,       &amp;!visible direct downward flux                                   [W m-2]
+    swvisdif_p,       &amp;!visible diffuse downward flux                                  [W m-2]
+    swnirdir_p,       &amp;!near-IR direct downward flux                                   [W m-2]
+    swnirdif_p         !near-IR diffuse downward flux                                  [W m-2]
+
  real(kind=RKIND),dimension(:,:,:),allocatable:: &amp;
     swdnflx_p,        &amp;!
     swdnflxc_p,       &amp;!
@@ -270,7 +345,12 @@
 !... variables and arrays related to parameterization of long-wave radiation:
 !=============================================================================================
 
+ integer,dimension(:,:),allocatable:: &amp;
+    nlrad_p            !number of layers added above the model top                         [-]
  real(kind=RKIND),dimension(:,:),allocatable:: &amp;
+    plrad_p            !pressure at model_top                                             [Pa]
+
+ real(kind=RKIND),dimension(:,:),allocatable:: &amp;
     glw_p,            &amp;!net longwave flux at surface                                   [W m-2]
     lwcf_p,           &amp;!longwave cloud forcing at top-of-atmosphere                    [W m-2]
     lwdnb_p,          &amp;!all-sky downwelling longwave flux at bottom-of-atmosphere      [J m-2]
@@ -344,6 +424,11 @@
 !=============================================================================================
 
  integer,public:: &amp;
+    sf_surface_physics !used to define the land surface scheme by a number instead of name. It
+                       !is only needed in module_ra_rrtmg_sw.F to define the spectral surface
+                       !albedos as functions of the land surface scheme.
+
+ integer,public:: &amp;
     num_soils          !number of soil layers                                              [-]
     
  integer,dimension(:,:),allocatable:: &amp;
@@ -369,7 +454,6 @@
     potevp_p,         &amp;!potential evaporation                                          [W m-2]
     qz0_p,            &amp;!specific humidity at znt                                     [kg kg-1]
     rainbl_p,         &amp;!
-    rib_p,            &amp;!?
     sfcrunoff_p,      &amp;!surface runoff                                                 [m s-1]
     shdmin_p,         &amp;!minimum areal fractional coverage of annual green vegetation       [-]
     shdmax_p,         &amp;!maximum areal fractional coverage of annual green vegetation       [-]
@@ -385,6 +469,12 @@
     vegfra_p,         &amp;!vegetation fraction                                                [-]
     z0_p               !background roughness length                                        [m]
 
+ real(kind=RKIND),dimension(:,:),allocatable:: &amp;
+    alswvisdir_p,     &amp;!direct-beam surface albedo in visible spectrum                     [-]
+    alswvisdif_p,     &amp;!diffuse-beam surface albedo in visible spectrum                    [-]
+    alswnirdir_p,     &amp;!direct-beam surface albedo in near-IR spectrum                     [-]
+    alswnirdif_p       !diffuse-beam surface albedo in near-IR spectrum                    [-]
+
 !=============================================================================================
 !.. variables and arrays related to surface characteristics:
 !=============================================================================================

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/Makefile
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/Makefile        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/Makefile        2013-04-22 01:31:32 UTC (rev 2783)
@@ -7,6 +7,7 @@
 
 OBJS = \
         libmassv.o                 \
+        module_bl_gwdo.o           \
         module_bl_ysu.o            \
         module_cam_shr_kind_mod.o  \
         module_cam_support.o       \
@@ -14,6 +15,7 @@
         module_cu_kfeta_wrf3.3.1.o \
         module_cu_tiedtke.o        \
         module_mp_kessler.o        \
+        module_mp_radar.o          \
         module_mp_thompson.o       \
         module_mp_wsm6.o           \
         module_ra_cam.o            \
@@ -36,11 +38,15 @@
         module_cam_shr_kind_mod.o  \
         ../mpas_atmphys_utilities.o
 
+module_mp_radar.o: \
+        ../mpas_atmphys_utilities.o
+
 module_mp_thompson.o: \
         ../mpas_atmphys_utilities.o
 
 module_mp_wsm6.o: \
-        libmassv.o
+        libmassv.o \
+        module_mp_radar.o
 
 module_ra_cam.o: \
         module_cam_support.o \

Copied: branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_bl_gwdo.F (from rev 2782, trunk/mpas/src/core_atmos_physics/physics_wrf/module_bl_gwdo.F)
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_bl_gwdo.F                                (rev 0)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_bl_gwdo.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -0,0 +1,743 @@
+! WRf:model_layer:physics
+!
+!
+!
+!
+!
+module module_bl_gwdo
+contains
+!
+!-------------------------------------------------------------------
+!
+   subroutine gwdo(u3d,v3d,t3d,qv3d,p3d,p3di,pi3d,z, &amp;
+                  rublten,rvblten, &amp;
+                  dtaux3d,dtauy3d,dusfcg,dvsfcg, &amp;
+                  var2d,oc12d,oa2d1,oa2d2,oa2d3,oa2d4,ol2d1,ol2d2,ol2d3,ol2d4, &amp;
+                  znu,znw,mut,p_top, &amp;
+                  cp,g,rd,rv,ep1,pi, &amp;
+                  dt,dx,kpbl2d,itimestep, &amp;
+                  ids,ide, jds,jde, kds,kde, &amp;
+                  ims,ime, jms,jme, kms,kme, &amp;
+                  its,ite, jts,jte, kts,kte)
+!-------------------------------------------------------------------
+      implicit none
+!------------------------------------------------------------------------------
+!
+!-- u3d 3d u-velocity interpolated to theta points (m/s)
+!-- v3d 3d v-velocity interpolated to theta points (m/s)
+!-- t3d temperature (k)
+!-- qv3d 3d water vapor mixing ratio (kg/kg)
+!-- p3d 3d pressure (pa)
+!-- p3di 3d pressure (pa) at interface level
+!-- pi3d 3d exner function (dimensionless)
+!-- rublten u tendency due to
+! pbl parameterization (m/s/s)
+!-- rvblten v tendency due to
+!-- cp heat capacity at constant pressure for dry air (j/kg/k)
+!-- g acceleration due to gravity (m/s^2)
+!-- rd gas constant for dry air (j/kg/k)
+!-- z height above sea level (m)
+!-- rv gas constant for water vapor (j/kg/k)
+!-- dt time step (s)
+!-- dx model grid interval (m)
+!-- ep1 constant for virtual temperature (r_v/r_d - 1) (dimensionless)
+!-- ids start index for i in domain
+!-- ide end index for i in domain
+!-- jds start index for j in domain
+!-- jde end index for j in domain
+!-- kds start index for k in domain
+!-- kde end index for k in domain
+!-- ims start index for i in memory
+!-- ime end index for i in memory
+!-- jms start index for j in memory
+!-- jme end index for j in memory
+!-- kms start index for k in memory
+!-- kme end index for k in memory
+!-- its start index for i in tile
+!-- ite end index for i in tile
+!-- jts start index for j in tile
+!-- jte end index for j in tile
+!-- kts start index for k in tile
+!-- kte end index for k in tile
+!-------------------------------------------------------------------
+!
+  integer, intent(in ) :: ids,ide, jds,jde, kds,kde, &amp;
+                                     ims,ime, jms,jme, kms,kme, &amp;
+                                     its,ite, jts,jte, kts,kte
+  integer, intent(in ) :: itimestep
+!
+!MPAS specific (Laura D. Fowler 2013-02-12):
+#if defined(non_hydrostatic_core)
+  real, intent(in ) :: dt,cp,g,rd,rv,ep1,pi
+  real, intent(in), dimension(ims:ime,jms:jme):: dx
+#else
+  real, intent(in ) :: dt,dx,cp,g,rd,rv,ep1,pi
+#endif
+!MPAS  specific end.
+!
+  real, dimension( ims:ime, kms:kme, jms:jme ) , &amp;
+            intent(in ) :: qv3d, &amp;
+                                                                          p3d, &amp;
+                                                                         pi3d, &amp;
+                                                                          t3d, &amp;
+                                                                             z
+  real, dimension( ims:ime, kms:kme, jms:jme ) , &amp;
+            intent(in ) :: p3di
+!
+  real, dimension( ims:ime, kms:kme, jms:jme ) , &amp;
+            intent(inout) :: rublten, &amp;
+                                                                      rvblten
+  real, dimension( ims:ime, kms:kme, jms:jme ) , &amp;
+            intent(inout) :: dtaux3d, &amp;
+                                                                      dtauy3d
+!
+  real, dimension( ims:ime, kms:kme, jms:jme ) , &amp;
+             intent(in ) :: u3d, &amp;
+                                                                          v3d
+!
+  integer, dimension( ims:ime, jms:jme ) , &amp;
+             intent(in ) :: kpbl2d
+  real, dimension( ims:ime, jms:jme ) , &amp;
+             intent(inout ) :: dusfcg, &amp;
+                                                                       dvsfcg
+!
+  real, dimension( ims:ime, jms:jme ) , &amp;
+             intent(in ) :: var2d, &amp;
+                                                                        oc12d, &amp;
+                                                      oa2d1,oa2d2,oa2d3,oa2d4, &amp;
+                                                      ol2d1,ol2d2,ol2d3,ol2d4
+!
+  real, dimension( ims:ime, jms:jme ) , &amp;
+             optional , &amp;
+             intent(in ) :: mut
+!
+  real, dimension( kms:kme ) , &amp;
+             optional , &amp;
+             intent(in ) :: znu, &amp;
+                                                                          znw
+!
+  real, optional, intent(in ) :: p_top
+!
+!local
+!
+  real, dimension( its:ite, kts:kte ) :: delprsi, &amp;
+                                                                          pdh
+  real, dimension( its:ite, kts:kte+1 ) :: pdhi
+  real, dimension( its:ite, 4 ) :: oa4, &amp;
+                                                                          ol4
+  integer :: i,j,k,kdt
+!
+   do j = jts,jte
+      if(present(mut))then
+! For ARW we will replace p and p8w with dry hydrostatic pressure
+        do k = kts,kte+1
+          do i = its,ite
+             if(k.le.kte)pdh(i,k) = mut(i,j)*znu(k) + p_top
+             pdhi(i,k) = mut(i,j)*znw(k) + p_top
+          enddo
+        enddo
+      else
+        do k = kts,kte+1
+          do i = its,ite
+             if(k.le.kte)pdh(i,k) = p3d(i,k,j)
+             pdhi(i,k) = p3di(i,k,j)
+          enddo
+        enddo
+      endif
+!
+      do k = kts,kte
+        do i = its,ite
+          delprsi(i,k) = pdhi(i,k)-pdhi(i,k+1)
+        enddo
+      enddo
+        do i = its,ite
+            oa4(i,1) = oa2d1(i,j)
+            oa4(i,2) = oa2d2(i,j)
+            oa4(i,3) = oa2d3(i,j)
+            oa4(i,4) = oa2d4(i,j)
+            ol4(i,1) = ol2d1(i,j)
+            ol4(i,2) = ol2d2(i,j)
+            ol4(i,3) = ol2d3(i,j)
+            ol4(i,4) = ol2d4(i,j)
+        enddo
+      call gwdo2d(dudt=rublten(ims,kms,j),dvdt=rvblten(ims,kms,j) &amp;
+              ,dtaux2d=dtaux3d(ims,kms,j),dtauy2d=dtauy3d(ims,kms,j) &amp;
+              ,u1=u3d(ims,kms,j),v1=v3d(ims,kms,j) &amp;
+              ,t1=t3d(ims,kms,j),q1=qv3d(ims,kms,j) &amp;
+              ,prsi=pdhi(its,kts),del=delprsi(its,kts) &amp;
+              ,prsl=pdh(its,kts),prslk=pi3d(ims,kms,j) &amp;
+              ,zl=z(ims,kms,j),rcl=1.0 &amp;
+              ,dusfc=dusfcg(ims,j),dvsfc=dvsfcg(ims,j) &amp;
+              ,var=var2d(ims,j),oc1=oc12d(ims,j) &amp;
+              ,oa4=oa4,ol4=ol4 &amp;
+              ,g=g,cp=cp,rd=rd,rv=rv,fv=ep1,pi=pi &amp;
+!MPAS specific (Laura D. Fowler 2013-02-12): 
+#if defined(non_hydrostatic_core)
+              ,dxmeter=dx(ims,j),deltim=dt &amp;
+#else
+              ,dxmeter=dx,deltim=dt &amp;
+#endif
+!MPAS specific end. 
+              ,kpbl=kpbl2d(ims,j),kdt=itimestep,lat=j &amp;
+              ,ids=ids,ide=ide, jds=jds,jde=jde, kds=kds,kde=kde &amp;
+              ,ims=ims,ime=ime, jms=jms,jme=jme, kms=kms,kme=kme &amp;
+              ,its=its,ite=ite, jts=jts,jte=jte, kts=kts,kte=kte )
+   enddo
+!
+!
+   end subroutine gwdo
+!
+!-------------------------------------------------------------------
+!
+!
+!
+!
+   subroutine gwdo2d(dudt,dvdt,dtaux2d,dtauy2d, &amp;
+                    u1,v1,t1,q1, &amp;
+                    prsi,del,prsl,prslk,zl,rcl, &amp;
+                    var,oc1,oa4,ol4,dusfc,dvsfc, &amp;
+                    g,cp,rd,rv,fv,pi,dxmeter,deltim,kpbl,kdt,lat, &amp;
+                    ids,ide, jds,jde, kds,kde, &amp;
+                    ims,ime, jms,jme, kms,kme, &amp;
+                    its,ite, jts,jte, kts,kte)
+!-------------------------------------------------------------------
+!
+! this code handles the time tendencies of u v due to the effect of mountain
+! induced gravity wave drag from sub-grid scale orography. this routine
+! not only treats the traditional upper-level wave breaking due to mountain
+! variance (alpert 1988), but also the enhanced lower-tropospheric wave
+! breaking due to mountain convexity and asymmetry (kim and arakawa 1995).
+! thus, in addition to the terrain height data in a model grid gox,
+! additional 10-2d topographic statistics files are needed, including
+! orographic standard deviation (var), convexity (oc1), asymmetry (oa4)
+! and ol (ol4). these data sets are prepared based on the 30 sec usgs orography
+! hong (1999). the current scheme was implmented as in hong et al.(2008)
+!
+! coded by song-you hong and young-joon kim and implemented by song-you hong
+!
+! references:
+! hong et al. (2008), wea. and forecasting
+! kim and arakawa (1995), j. atmos. sci.
+! alpet et al. (1988), NWP conference.
+! hong (1999), NCEP office note 424.
+!
+! notice : comparible or lower resolution orography files than model resolution
+! are desirable in preprocess (wps) to prevent weakening of the drag
+!-------------------------------------------------------------------
+!
+! input
+! dudt (ims:ime,kms:kme) non-lin tendency for u wind component
+! dvdt (ims:ime,kms:kme) non-lin tendency for v wind component
+! u1(ims:ime,kms:kme) zonal wind / sqrt(rcl) m/sec at t0-dt
+! v1(ims:ime,kms:kme) meridional wind / sqrt(rcl) m/sec at t0-dt
+! t1(ims:ime,kms:kme) temperature deg k at t0-dt
+! q1(ims:ime,kms:kme) specific humidity at t0-dt
+!
+! rcl a scaling factor = reciprocal of square of cos(lat)
+! for mrf gsm. rcl=1 if u1 and v1 are wind components.
+! deltim time step secs
+! del(kts:kte) positive increment of pressure across layer (pa)
+!
+! output
+! dudt, dvdt wind tendency due to gwdo
+!
+!-------------------------------------------------------------------
+   implicit none
+!-------------------------------------------------------------------
+   integer :: kdt,lat,latd,lond, &amp;
+                            ids,ide, jds,jde, kds,kde, &amp;
+                            ims,ime, jms,jme, kms,kme, &amp;
+                            its,ite, jts,jte, kts,kte
+!
+!MPAS specific (Laura D. Fowler 2013-02-12):
+#if defined(non_hydrostatic_core)
+   real :: g,rd,rv,fv,cp,pi,deltim,rcl
+   real, dimension(ims:ime):: dxmeter
+#else
+   real :: g,rd,rv,fv,cp,pi,dxmeter,deltim,rcl
+#endif
+!MPAS specific end.
+
+   real :: dudt(ims:ime,kms:kme),dvdt(ims:ime,kms:kme), &amp;
+                            dtaux2d(ims:ime,kms:kme),dtauy2d(ims:ime,kms:kme), &amp;
+                            u1(ims:ime,kms:kme),v1(ims:ime,kms:kme), &amp;
+                            t1(ims:ime,kms:kme),q1(ims:ime,kms:kme), &amp;
+                            zl(ims:ime,kms:kme),prslk(ims:ime,kms:kme)
+   real :: prsl(its:ite,kts:kte),prsi(its:ite,kts:kte+1), &amp;
+                            del(its:ite,kts:kte)
+   real :: oa4(its:ite,4),ol4(its:ite,4)
+!
+   integer :: kpbl(ims:ime)
+   real :: var(ims:ime),oc1(ims:ime), &amp;
+                            dusfc(ims:ime),dvsfc(ims:ime)
+! critical richardson number for wave breaking : ! larger drag with larger value
+!
+   real,parameter :: ric = 0.25
+!
+   real,parameter :: dw2min = 1.
+   real,parameter :: rimin = -100.
+   real,parameter :: bnv2min = 1.0e-5
+   real,parameter :: efmin = 0.0
+   real,parameter :: efmax = 10.0
+   real,parameter :: xl = 4.0e4
+   real,parameter :: critac = 1.0e-5
+   real,parameter :: gmax = 1.
+   real,parameter :: veleps = 1.0
+   real,parameter :: factop = 0.5
+   real,parameter :: frc = 1.0
+   real,parameter :: ce = 0.8
+   real,parameter :: cg = 0.5
+!
+! local variables
+!
+   integer :: i,k,lcap,lcapp1,nwd,idir,kpblmin,kpblmax, &amp;
+                            klcap,kp1,ikount,kk
+!
+!MPAS specific (Laura D. Fowler 2013-02-12):
+#if defined(non_hydrostatic_core)
+   real :: rcs,rclcs,csg,fdir,cs,rcsks, &amp;
+                            wdir,ti,rdz,temp,tem2,dw2,shr2,bvf2,rdelks, &amp;
+                            wtkbj,coefm,tem,gfobnv,hd,fro,rim,temc,tem1,efact, &amp;
+                            temv,dtaux,dtauy
+   real, dimension(its:ite):: cleff
+#else
+   real :: rcs,rclcs,csg,fdir,cleff,cs,rcsks, &amp;
+                            wdir,ti,rdz,temp,tem2,dw2,shr2,bvf2,rdelks, &amp;
+                            wtkbj,coefm,tem,gfobnv,hd,fro,rim,temc,tem1,efact, &amp;
+                            temv,dtaux,dtauy
+#endif        
+!
+   logical :: ldrag(its:ite),icrilv(its:ite), &amp;
+                            flag(its:ite),kloop1(its:ite)
+!
+   real :: taub(its:ite),taup(its:ite,kts:kte+1), &amp;
+                            xn(its:ite),yn(its:ite), &amp;
+                            ubar(its:ite),vbar(its:ite), &amp;
+                            fr(its:ite),ulow(its:ite), &amp;
+                            rulow(its:ite),bnv(its:ite), &amp;
+                            oa(its:ite),ol(its:ite), &amp;
+                            roll(its:ite),dtfac(its:ite), &amp;
+                            brvf(its:ite),xlinv(its:ite), &amp;
+                            delks(its:ite),delks1(its:ite), &amp;
+                            bnv2(its:ite,kts:kte),usqj(its:ite,kts:kte), &amp;
+                            taud(its:ite,kts:kte),ro(its:ite,kts:kte), &amp;
+                            vtk(its:ite,kts:kte),vtj(its:ite,kts:kte), &amp;
+                            zlowtop(its:ite),velco(its:ite,kts:kte-1)
+!
+   integer :: kbl(its:ite),klowtop(its:ite), &amp;
+                            lowlv(its:ite)
+!
+   logical :: iope
+   integer,parameter :: mdir=8
+   integer :: nwdir(mdir)
+   data nwdir/6,7,5,8,2,3,1,4/
+!
+! initialize local variables
+!
+   kbl=0 ; klowtop=0 ; lowlv=0
+!
+!---- constants
+!
+   rcs = sqrt(rcl)
+   cs = 1. / sqrt(rcl)
+   csg = cs * g
+   lcap = kte
+   lcapp1 = lcap + 1
+   fdir = mdir / (2.0*pi)
+!
+!
+!!!!!!! cleff (subgrid mountain scale ) is highly tunable parameter
+!!!!!!! the bigger (smaller) value produce weaker (stronger) wave drag
+!
+!MPAS specific (Laura D. Fowler 2013-02-13):
+#if defined(non_hydrostatic_core)
+   do i = its, ite
+      cleff(i) = max(dxmeter(i),50.e3)
+   enddo
+#else
+   cleff = max(dxmeter,50.e3)
+#endif
+!MPAS specific end.
+!
+! initialize!!
+!
+   dtaux = 0.0
+   dtauy = 0.0
+   do k = kts,kte
+     do i = its,ite
+       usqj(i,k) = 0.0
+       bnv2(i,k) = 0.0
+       vtj(i,k) = 0.0
+       vtk(i,k) = 0.0
+       taup(i,k) = 0.0
+       taud(i,k) = 0.0
+       dtaux2d(i,k)= 0.0
+       dtauy2d(i,k)= 0.0
+     enddo
+   enddo
+   do i = its,ite
+     taup(i,kte+1) = 0.0
+     xlinv(i) = 1.0/xl
+   enddo
+!
+   do k = kts,kte
+     do i = its,ite
+       vtj(i,k) = t1(i,k) * (1.+fv*q1(i,k))
+       vtk(i,k) = vtj(i,k) / prslk(i,k)
+       ro(i,k) = 1./rd * prsl(i,k) / vtj(i,k) ! density kg/m**3
+     enddo
+   enddo
+!
+   do i = its,ite
+     zlowtop(i) = 2. * var(i)
+   enddo
+!
+!--- determine new reference level &gt; 2*var
+!
+   do i = its,ite
+     kloop1(i) = .true.
+   enddo
+   do k = kts+1,kte
+     do i = its,ite
+       if(kloop1(i).and.zl(i,k)-zl(i,1).ge.zlowtop(i)) then
+         klowtop(i) = k+1
+         kloop1(i) = .false.
+       endif
+     enddo
+   enddo
+!
+   kpblmax = 2
+   do i = its,ite
+     kbl(i) = max(2, kpbl(i))
+     kbl(i) = max(kbl(i), klowtop(i))
+     delks(i) = 1.0 / (prsi(i,1) - prsi(i,kbl(i)))
+     ubar (i) = 0.0
+     vbar (i) = 0.0
+     taup(i,1) = 0.0
+     oa(i) = 0.0
+     kpblmax = max(kpblmax,kbl(i))
+     flag(i) = .true.
+     lowlv(i) = 2
+   enddo
+   kpblmax = min(kpblmax+1,kte-1)
+!
+! compute low level averages within pbl
+!
+   do k = kts,kpblmax
+     do i = its,ite
+       if (k.lt.kbl(i)) then
+         rcsks = rcs * del(i,k) * delks(i)
+         ubar(i) = ubar(i) + rcsks * u1(i,k) ! pbl u mean
+         vbar(i) = vbar(i) + rcsks * v1(i,k) ! pbl v mean
+       endif
+     enddo
+   enddo
+!
+! figure out low-level horizontal wind direction
+!
+! nwd 1 2 3 4 5 6 7 8
+! wd w s sw nw e n ne se
+!
+   do i = its,ite
+     wdir = atan2(ubar(i),vbar(i)) + pi
+     idir = mod(nint(fdir*wdir),mdir) + 1
+     nwd = nwdir(idir)
+     oa(i) = (1-2*int( (nwd-1)/4 )) * oa4(i,mod(nwd-1,4)+1)
+     ol(i) = ol4(i,mod(nwd-1,4)+1)
+   enddo
+!
+   kpblmin = kte
+   do i = its,ite
+     kpblmin = min(kpblmin, kbl(i))
+   enddo
+!
+   do i = its,ite
+     if (oa(i).le.0.0) kbl(i) = kpbl(i) + 1
+   enddo
+!
+   do i = its,ite
+     delks(i) = 1.0 / (prsi(i,1) - prsi(i,kbl(i)))
+     delks1(i) = 1.0 / (prsl(i,1) - prsl(i,kbl(i)))
+   enddo
+!
+!--- saving richardson number in usqj for migwdi
+!
+   do k = kts,kte-1
+     do i = its,ite
+       ti = 2.0 / (t1(i,k)+t1(i,k+1))
+       rdz = 1./(zl(i,k+1) - zl(i,k))
+       tem1 = u1(i,k) - u1(i,k+1)
+       tem2 = v1(i,k) - v1(i,k+1)
+       dw2 = rcl*(tem1*tem1 + tem2*tem2)
+       shr2 = max(dw2,dw2min) * rdz * rdz
+       bvf2 = g*(g/cp+rdz*(vtj(i,k+1)-vtj(i,k))) * ti
+       usqj(i,k) = max(bvf2/shr2,rimin)
+       bnv2(i,k) = 2*g*rdz*(vtk(i,k+1)-vtk(i,k))/(vtk(i,k+1)+vtk(i,k))
+       bnv2(i,k) = max( bnv2(i,k), bnv2min )
+     enddo
+   enddo
+!
+!-----initialize arrays
+!
+   do i = its,ite
+     xn(i) = 0.0
+     yn(i) = 0.0
+     ubar (i) = 0.0
+     vbar (i) = 0.0
+     roll (i) = 0.0
+     taub (i) = 0.0
+     ulow (i) = 0.0
+     dtfac(i) = 1.0
+     ldrag(i) = .false.
+     icrilv(i) = .false. ! initialize critical level control vector
+   enddo
+!
+!---- compute low level averages
+!---- (u,v)*cos(lat) use uv=(u1,v1) which is wind at t0-1
+!---- use rcs=1/cos(lat) to get wind field
+!
+   do k = 1,kpblmax
+     do i = its,ite
+       if (k .lt. kbl(i)) then
+         rdelks = del(i,k) * delks(i)
+         rcsks = rcs * rdelks
+         ubar(i) = ubar(i) + rcsks * u1(i,k) ! u mean
+         vbar(i) = vbar(i) + rcsks * v1(i,k) ! v mean
+         roll(i) = roll(i) + rdelks * ro(i,k) ! ro mean
+       endif
+     enddo
+   enddo
+!
+!----compute the &quot;low level&quot; or 1/3 wind magnitude (m/s)
+!
+   do i = its,ite
+     ulow(i) = max(sqrt(ubar(i)*ubar(i) + vbar(i)*vbar(i)), 1.0)
+     rulow(i) = 1./ulow(i)
+   enddo
+!
+   do k = kts,kte-1
+     do i = its,ite
+       velco(i,k) = (0.5*rcs) * ((u1(i,k)+u1(i,k+1)) * ubar(i) &amp;
+                                + (v1(i,k)+v1(i,k+1)) * vbar(i))
+       velco(i,k) = velco(i,k) * rulow(i)
+       if ((velco(i,k).lt.veleps) .and. (velco(i,k).gt.0.)) then
+         velco(i,k) = veleps
+       endif
+     enddo
+   enddo
+!
+! no drag when critical level in the base layer
+!
+   do i = its,ite
+     ldrag(i) = velco(i,1).le.0.
+   enddo
+!
+   do k = kts+1,kpblmax-1
+     do i = its,ite
+       if (k .lt. kbl(i)) ldrag(i) = ldrag(i).or. velco(i,k).le.0.
+     enddo
+   enddo
+!
+! no drag when bnv2.lt.0
+!
+   do k = kts,kpblmax-1
+     do i = its,ite
+       if (k .lt. kbl(i)) ldrag(i) = ldrag(i).or. bnv2(i,k).lt.0.
+     enddo
+   enddo
+!
+!-----the low level weighted average ri is stored in usqj(1,1; im)
+!-----the low level weighted average n**2 is stored in bnv2(1,1; im)
+!---- this is called bnvl2 in phys_gwd_alpert_sub not bnv2
+!---- rdelks (del(k)/delks) vert ave factor so we can * instead of /
+!
+   do i = its,ite
+     wtkbj = (prsl(i,1)-prsl(i,2)) * delks1(i)
+     bnv2(i,1) = wtkbj * bnv2(i,1)
+     usqj(i,1) = wtkbj * usqj(i,1)
+   enddo
+!
+   do k = kts+1,kpblmax-1
+     do i = its,ite
+       if (k .lt. kbl(i)) then
+         rdelks = (prsl(i,k)-prsl(i,k+1)) * delks1(i)
+         bnv2(i,1) = bnv2(i,1) + bnv2(i,k) * rdelks
+         usqj(i,1) = usqj(i,1) + usqj(i,k) * rdelks
+       endif
+     enddo
+   enddo
+!
+   do i = its,ite
+     ldrag(i) = ldrag(i) .or. bnv2(i,1).le.0.0
+     ldrag(i) = ldrag(i) .or. ulow(i).eq.1.0
+     ldrag(i) = ldrag(i) .or. var(i) .le. 0.0
+   enddo
+!
+! ----- set all ri low level values to the low level value
+!
+   do k = kts+1,kpblmax-1
+     do i = its,ite
+       if (k .lt. kbl(i)) usqj(i,k) = usqj(i,1)
+     enddo
+   enddo
+!
+   do i = its,ite
+     if (.not.ldrag(i)) then
+       bnv(i) = sqrt( bnv2(i,1) )
+       fr(i) = bnv(i) * rulow(i) * var(i)
+       xn(i) = ubar(i) * rulow(i)
+       yn(i) = vbar(i) * rulow(i)
+     endif
+   enddo
+!
+! compute the base level stress and store it in taub
+! calculate enhancement factor, number of mountains &amp; aspect
+! ratio const. use simplified relationship between standard
+! deviation &amp; critical hgt
+!
+   do i = its,ite
+     if (.not. ldrag(i)) then
+       efact = (oa(i) + 2.) ** (ce*fr(i)/frc)
+       efact = min( max(efact,efmin), efmax )
+       coefm = (1. + ol(i)) ** (oa(i)+1.)
+!MPAS specific (Laura D. Fowler 2013-02-12):
+#if defined (non_hydrostatic_core)
+       xlinv(i) = coefm / cleff(i)
+#else
+       xlinv(i) = coefm / cleff
+#endif
+       tem = fr(i) * fr(i) * oc1(i)
+       gfobnv = gmax * tem / ((tem + cg)*bnv(i))
+       taub(i) = xlinv(i) * roll(i) * ulow(i) * ulow(i) &amp;
+                * ulow(i) * gfobnv * efact
+     else
+       taub(i) = 0.0
+       xn(i) = 0.0
+       yn(i) = 0.0
+     endif
+   enddo
+!
+! now compute vertical structure of the stress.
+!
+!----set up bottom values of stress
+!
+   do k = kts,kpblmax
+     do i = its,ite
+       if (k .le. kbl(i)) taup(i,k) = taub(i)
+     enddo
+   enddo
+!
+   do k = kpblmin, kte-1 ! vertical level k loop!
+     kp1 = k + 1
+     do i = its,ite
+!
+!-----unstablelayer if ri &lt; ric
+!-----unstable layer if upper air vel comp along surf vel &lt;=0 (crit lay)
+!---- at (u-c)=0. crit layer exists and bit vector should be set (.le.)
+!
+       if (k .ge. kbl(i)) then
+         icrilv(i) = icrilv(i) .or. ( usqj(i,k) .lt. ric) &amp;
+                               .or. (velco(i,k) .le. 0.0)
+         brvf(i) = max(bnv2(i,k),bnv2min) ! brunt-vaisala frequency squared
+         brvf(i) = sqrt(brvf(i)) ! brunt-vaisala frequency
+       endif
+     enddo
+!
+     do i = its,ite
+       if (k .ge. kbl(i) .and. (.not. ldrag(i))) then
+         if (.not.icrilv(i) .and. taup(i,k) .gt. 0.0 ) then
+           temv = 1.0 / velco(i,k)
+           tem1 = xlinv(i)*(ro(i,kp1)+ro(i,k))*brvf(i)*velco(i,k)*0.5
+           hd = sqrt(taup(i,k) / tem1)
+           fro = brvf(i) * hd * temv
+!
+! rim is the minimum-richardson number by shutts (1985)
+!
+           tem2 = sqrt(usqj(i,k))
+           tem = 1. + tem2 * fro
+           rim = usqj(i,k) * (1.-fro) / (tem * tem)
+!
+! check stability to employ the 'saturation hypothesis'
+! of lindzen (1981) except at tropospheric downstream regions
+!
+           if (rim .le. ric) then ! saturation hypothesis!
+             if ((oa(i) .le. 0. .or. kp1 .ge. lowlv(i) )) then
+               temc = 2.0 + 1.0 / tem2
+               hd = velco(i,k) * (2.*sqrt(temc)-temc) / brvf(i)
+               taup(i,kp1) = tem1 * hd * hd
+             endif
+           else ! no wavebreaking!
+             taup(i,kp1) = taup(i,k)
+           endif
+         endif
+       endif
+     enddo
+   enddo
+!
+   if(lcap.lt.kte) then
+     do klcap = lcapp1,kte
+       do i = its,ite
+         taup(i,klcap) = prsi(i,klcap) / prsi(i,lcap) * taup(i,lcap)
+       enddo
+     enddo
+   endif
+!
+! calculate - (g)*d(tau)/d(pressure) and deceleration terms dtaux, dtauy
+!
+   do k = kts,kte
+     do i = its,ite
+       taud(i,k) = 1. * (taup(i,k+1) - taup(i,k)) * csg / del(i,k)
+     enddo
+   enddo
+!
+!------limit de-acceleration (momentum deposition ) at top to 1/2 value
+!------the idea is some stuff must go out the 'top'
+!
+   do klcap = lcap,kte
+     do i = its,ite
+       taud(i,klcap) = taud(i,klcap) * factop
+     enddo
+   enddo
+!
+!------if the gravity wave drag would force a critical line
+!------in the lower ksmm1 layers during the next deltim timestep,
+!------then only apply drag until that critical line is reached.
+!
+   do k = kts,kpblmax-1
+     do i = its,ite
+       if (k .le. kbl(i)) then
+         if(taud(i,k).ne.0.) &amp;
+         dtfac(i) = min(dtfac(i),abs(velco(i,k) &amp;
+                   /(deltim*rcs*taud(i,k))))
+       endif
+     enddo
+   enddo
+!
+   do i = its,ite
+     dusfc(i) = 0.
+     dvsfc(i) = 0.
+   enddo
+!
+   do k = kts,kte
+     do i = its,ite
+       taud(i,k) = taud(i,k) * dtfac(i)
+       dtaux = taud(i,k) * xn(i)
+       dtauy = taud(i,k) * yn(i)
+       dtaux2d(i,k) = dtaux
+       dtauy2d(i,k) = dtauy
+       dudt(i,k) = dtaux + dudt(i,k)
+       dvdt(i,k) = dtauy + dvdt(i,k)
+       dusfc(i) = dusfc(i) + dtaux * del(i,k)
+       dvsfc(i) = dvsfc(i) + dtauy * del(i,k)
+     enddo
+   enddo
+!
+   do i = its,ite
+     dusfc(i) = (-1./g*rcs) * dusfc(i)
+     dvsfc(i) = (-1./g*rcs) * dvsfc(i)
+   enddo
+!
+   return
+   end subroutine gwdo2d
+!-------------------------------------------------------------------
+end module module_bl_gwdo

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_bl_ysu.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_bl_ysu.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_bl_ysu.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,4 +1,4 @@
-!WRf:model_layer:physics
+!WRF:model_layer:physics
 !
 !
 !
@@ -19,15 +19,21 @@
                   dz8w,psfc,                                                   &amp;
                   znu,znw,mut,p_top,                                           &amp;
                   znt,ust,hpbl,psim,psih,                                      &amp;
-                  xland,hfx,qfx,gz1oz0,wspd,br,                                &amp;
+                  xland,hfx,qfx,wspd,br,                                       &amp;
                   dt,kpbl2d,                                                   &amp;
                   exch_h,                                                      &amp;
                   u10,v10,                                                     &amp;
+                  ctopo,ctopo2,                                                &amp;
                   ids,ide, jds,jde, kds,kde,                                   &amp;
                   ims,ime, jms,jme, kms,kme,                                   &amp;
                   its,ite, jts,jte, kts,kte,                                   &amp;
                 !optional
-                  regime                                           )
+                  regime                                                       &amp;
+#if defined(non_hydrostatic_core) || defined(hydrostatic_core)
+                !MPAS specific optional arguments for additional diagnostics:
+                  ,rho,kzhout,kzmout,kzqout                                    &amp;
+#endif
+                 )
 !-------------------------------------------------------------------
       implicit none
 !-------------------------------------------------------------------
@@ -72,7 +78,6 @@
 !-- xland        land mask (1 for land, 2 for water)
 !-- hfx                upward heat flux at the surface (w/m^2)
 !-- qfx                upward moisture flux at the surface (kg/m^2/s)
-!-- gz1oz0      log(z/z0) where z0 is roughness length
 !-- wspd        wind speed at lowest model level (m/s)
 !-- u10         u-wind speed at 10 m (m/s)
 !-- v10         v-wind speed at 10 m (m/s)
@@ -115,40 +120,39 @@
 !
    real,     dimension( ims:ime, kms:kme, jms:jme )                          , &amp;
              intent(in   )   ::                                          qv3d, &amp;
-                                                                          qc3d, &amp;
-                                                                          qi3d, &amp;
-                                                                             p3d, &amp;
-                                                                             pi3d, &amp;
-                                                                               th3d, &amp;
-                                                                          t3d, &amp;
-                                                                         dz8w
+                                                                         qc3d, &amp;
+                                                                         qi3d, &amp;
+                                                                          p3d, &amp;
+                                                                         pi3d, &amp;
+                                                                         th3d, &amp;
+                                                                          t3d, &amp;
+                                                                         dz8w
    real,     dimension( ims:ime, kms:kme, jms:jme )                          , &amp;
              intent(in   )   ::                                          p3di
 !
    real,     dimension( ims:ime, kms:kme, jms:jme )                          , &amp;
              intent(inout)   ::                                       rublten, &amp;
-                                                                            rvblten, &amp;
-                                                                            rthblten, &amp;
-                                                                      rqvblten, &amp;
+                                                                      rvblten, &amp;
+                                                                     rthblten, &amp;
+                                                                     rqvblten, &amp;
                                                                      rqcblten
 !
    real,     dimension( ims:ime, kms:kme, jms:jme )                          , &amp;
              intent(inout)   ::                                        exch_h
    real,     dimension( ims:ime, jms:jme )                                   , &amp;
-             intent(in   )   ::                                           u10, &amp;
+             intent(inout)   ::                                           u10, &amp;
                                                                           v10
 !
    real,     dimension( ims:ime, jms:jme )                                   , &amp;
              intent(in   )   ::                                         xland, &amp;
-                                                                               hfx, &amp;
+                                                                          hfx, &amp;
                                                                           qfx, &amp;
                                                                            br, &amp;
                                                                          psfc
    real,     dimension( ims:ime, jms:jme )                                   , &amp;
              intent(in   )   ::                                                &amp;
                                                                          psim, &amp;
-                                                                         psih, &amp;
-                                                                       gz1oz0
+                                                                         psih
    real,     dimension( ims:ime, jms:jme )                                   , &amp;
              intent(inout)   ::                                           znt, &amp;
                                                                           ust, &amp;
@@ -182,6 +186,10 @@
 !
    real,     optional, intent(in   )   ::                               p_top
 !
+   real,     dimension( ims:ime, jms:jme )                                   , &amp;
+             optional                                                        , &amp;
+             intent(in   )   ::                                         ctopo, &amp;
+                                                                       ctopo2
 !local
    integer ::  i,j,k
    real,     dimension( its:ite, kts:kte*ndiff )  ::                 rqvbl2dt, &amp;
@@ -193,6 +201,23 @@
                                                                         dvsfc, &amp;
                                                                         dtsfc, &amp;
                                                                         dqsfc
+#if defined(non_hydrostatic_core) || defined(hydrostatic_core)
+!MPAS specific optional arguments for additional diagnostics (Laura Fowler = 2013-03-06):
+   real,intent(in),dimension(ims:ime,kms:kme,jms:jme),optional:: rho
+   real:: rho_d
+   real,intent(out),dimension(ims:ime,kms:kme,jms:jme),optional:: kzhout,kzmout,kzqout
+   do j = jts,jte
+   do k = kts,kte
+   do i = its,ite
+      kzhout(i,k,j) = 0.
+      kzmout(i,k,j) = 0.
+      kzqout(i,k,j) = 0.
+   enddo
+   enddo
+   enddo
+!MPAS specific end.
+#endif
+
 !
    qv2d(:,:) = 0.0
    do j = jts,jte
@@ -204,6 +229,26 @@
              pdhi(i,k) = mut(i,j)*znw(k) + p_top
           enddo
         enddo
+      elseif(present(rho)) then
+  203 format(1x,i4,1x,i2,10(1x,e15.8))
+!For MPAS, we replace the hydrostatic pressures defined at theta and w points by
+!the dry hydrostatic pressures (Laura D. Fowler):
+        k = kte+1
+        do i = its,ite
+           pdhi(i,k) = p3di(i,k,j)
+        enddo
+        do k = kte,kts,-1
+        do i = its,ite
+           rho_d = rho(i,k,j) / (1. + qv3d(i,k,j))
+           if(k.le.kte) pdhi(i,k) = pdhi(i,k+1) + g*rho_d*dz8w(i,k,j)
+        enddo
+        enddo
+        do k = kts,kte
+        do i = its,ite
+           pdh(i,k) = 0.5*(pdhi(i,k) + pdhi(i,k+1))
+        enddo
+        enddo
+!MPAS specific end.
       else
         do k = kts,kte+1
           do i = its,ite
@@ -241,7 +286,15 @@
               ,dt=dt,rcl=1.0,kpbl1d=kpbl2d(ims,j)                              &amp;
               ,exch_hx=exch_h(ims,kms,j)                                       &amp;
               ,u10=u10(ims,j),v10=v10(ims,j)                                   &amp;
-              ,gz1oz0=gz1oz0(ims,j)                                            &amp;
+#if defined(non_hydrostatic_core) || defined(hydrostatic_core)
+!MPAS specific optional arguments for additional diagnostics:
+              ,kzh=kzhout(ims,kms,j)                                           &amp; 
+              ,kzm=kzmout(ims,kms,j)                                           &amp;
+              ,kzq=kzqout(ims,kms,j)                                           &amp;
+#endif
+#if ( ! NMM_CORE == 1 )
+              ,ctopo=ctopo(ims,j),ctopo2=ctopo2(ims,j)                         &amp;
+#endif
               ,ids=ids,ide=ide, jds=jds,jde=jde, kds=kds,kde=kde               &amp;
               ,ims=ims,ime=ime, jms=jms,jme=jme, kms=kms,kme=kme               &amp;
               ,its=its,ite=ite, jts=jts,jte=jte, kts=kts,kte=kte   )
@@ -270,12 +323,17 @@
                   dt,rcl,kpbl1d,                                               &amp;
                   exch_hx,                                                     &amp;
                   u10,v10,                                                     &amp;
-                  gz1oz0,                                                      &amp;
+                  ctopo,ctopo2,                                                &amp;
                   ids,ide, jds,jde, kds,kde,                                   &amp;
                   ims,ime, jms,jme, kms,kme,                                   &amp;
                   its,ite, jts,jte, kts,kte,                                   &amp;
                 !optional
-                  regime                                           )
+                  regime                                                       &amp;
+#if defined(non_hydrostatic_core) || defined(hydrostatic_core)
+                !MPAS specific optional arguments for additional diagnostics:
+                 ,kzh,kzm,kzq                                                  &amp;
+#endif
+                   )
 !-------------------------------------------------------------------
    implicit none
 !-------------------------------------------------------------------
@@ -307,11 +365,24 @@
 !              pressure-level diffusion, april 2009
 !               ==&gt; negligible differences
 !              implicit forcing for momentum with clean up, july 2009
-!               ==&gt; prevents model blownup when sfc layer is too low
-!              increase of lamda, 30 &lt; 0.1 x del z &lt; 300, feb 2010
+!               ==&gt; prevents model blowup when sfc layer is too low
+!              incresea of lamda, maximum (30, 0.1 x del z) feb 2010
 !               ==&gt; prevents model blowup when delz is extremely large
 !              revised prandtl number at surface, peggy lemone, feb 2010
 !               ==&gt; increase kh, decrease mixing due to counter-gradient term
+!              revised thermal, shin et al. mon. wea. rev. , songyou hong, aug 2011
+!               ==&gt; reduce the thermal strength when z1 &lt; 0.1 h  
+!              revised prandtl number for free convection, dudhia, mar 2012
+!               ==&gt; pr0 = 1 + bke (=0.272) when newtral, kh is reduced
+!              minimum kzo = 0.01, lo = min (30m,delz), hong, mar 2012
+!               ==&gt; weaker mixing when stable, and les resolution in vertical
+!              gz1oz0 is removed, and phim phih are ln(z1/z0)-phim,h, hong, mar 2012
+!               ==&gt; consider thermal z0 when differs from mechanical z0
+!              a bug fix in wscale computation in stable bl, sukanta basu, jun 2012
+!               ==&gt; wscale becomes small with height, and less mixing in stable bl
+!               ==&gt; ri = max(ri,rimin). limits the richardson number to -100 in
+!               unstable layers, following Hong et al. 2006.
+!               Laura D. Fowler (2013-04-18).
 !
 !     references:
 !
@@ -324,7 +395,8 @@
 !-------------------------------------------------------------------
 !
    real,parameter    ::  xkzmin = 0.01,xkzmax = 1000.,rimin = -100.
-   real,parameter    ::  rlam = 30.,prmin = 0.25,prmax = 4.
+   real,parameter    ::  rlam = 150.,prmin = 0.25,prmax = 4.
+!  real,parameter    ::  rlam = 30.,prmin = 0.25,prmax = 4.
    real,parameter    ::  brcr_ub = 0.0,brcr_sb = 0.25,cori = 1.e-4
    real,parameter    ::  afac = 6.8,bfac = 6.8,pfac = 2.0,pfac_q = 2.0
    real,parameter    ::  phifac = 8.,sfcfrac = 0.1
@@ -382,7 +454,7 @@
 !
    real,     dimension( ims:ime ), intent(in   )   ::                    psim, &amp;
                                                                          psih
-   real,     dimension( ims:ime ), intent(in   )   ::                  gz1oz0
+
 !
    real,     dimension( ims:ime ), intent(in   )   ::                  psfcpa
    integer,  dimension( ims:ime ), intent(out  )   ::                  kpbl1d
@@ -390,9 +462,12 @@
    real,     dimension( ims:ime, kms:kme )                                   , &amp;
              intent(in   )   ::                                            ux, &amp;
                                                                            vx
-!optional
    real,     dimension( ims:ime )                                            , &amp;
              optional                                                        , &amp;
+             intent(in   )   ::                                         ctopo, &amp;
+                                                                       ctopo2
+   real,     dimension( ims:ime )                                            , &amp;
+             optional                                                        , &amp;
              intent(inout)   ::                                        regime
 !
 ! local vars
@@ -400,29 +475,30 @@
    real,     dimension( its:ite )            ::                           hol
    real,     dimension( its:ite, kts:kte+1 ) ::                            zq
 !
-   real,     dimension( its:ite, kts:kte )   ::                                       &amp;
+   real,     dimension( its:ite, kts:kte )   ::                                &amp;
                                                                      thx,thvx, &amp;
                                                                           del, &amp;
                                                                           dza, &amp;
                                                                           dzq, &amp;
+                                                                         xkzo, &amp;
                                                                            za
 !
    real,    dimension( its:ite )             ::                                &amp;
                                                                          rhox, &amp;
                                                                        govrth, &amp;
                                                                   zl1,thermal, &amp;
-                                                                 wscale,hgamt, &amp;
-                                                                   hgamq,brdn, &amp;
-                                                                    brup,phim, &amp;
-                                                                         phih, &amp;
+                                                                       wscale, &amp;
+                                                                  hgamt,hgamq, &amp;
+                                                                    brdn,brup, &amp;
+                                                                    phim,phih, &amp;
                                                                   dusfc,dvsfc, &amp;
                                                                   dtsfc,dqsfc, &amp;
                                                                         prpbl, &amp;
                                                                         wspd1
 !
    real,    dimension( its:ite, kts:kte )    ::                     xkzm,xkzh, &amp;
-                                                                             f1,f2, &amp;
-                                                                             r1,r2, &amp;
+                                                                        f1,f2, &amp;
+                                                                        r1,r2, &amp;
                                                                         ad,au, &amp;
                                                                            cu, &amp;
                                                                            al, &amp;
@@ -433,8 +509,8 @@
    real,    dimension( ims:ime, kms:kme )                                    , &amp;
             intent(inout)   ::                                        exch_hx
 !
-   real,    dimension( ims:ime )                                             , &amp; 
-            intent(in  )    ::                                            u10, &amp;
+   real,    dimension( ims:ime )                                             , &amp;
+            intent(inout)    ::                                           u10, &amp;
                                                                           v10
    real,    dimension( its:ite )    ::                                         &amp;
                                                                          brcr, &amp;
@@ -453,14 +529,15 @@
 !
 !
    real    ::  dt2,rdt,spdk2,fm,fh,hol1,gamfac,vpert,prnum,prnum0
-   real    ::  xkzo,ss,ri,qmean,tmean,alph,chi,zk,rl2,dk,sri
+   real    ::  ss,ri,qmean,tmean,alph,chi,zk,rl2,dk,sri
    real    ::  brint,dtodsd,dtodsu,rdz,dsdzt,dsdzq,dsdz2,rlamdz
    real    ::  utend,vtend,ttend,qtend
    real    ::  dtstep,govrthv
    real    ::  cont, conq, conw, conwrc 
 !
-   real, dimension( its:ite, kts:kte )     ::                         wscalek, &amp;
-                                                                  xkzml,xkzhl, &amp;
+   real, dimension( its:ite, kts:kte )     ::                         wscalek
+   real, dimension( its:ite )              ::                         delta
+   real, dimension( its:ite, kts:kte )     ::                     xkzml,xkzhl, &amp;
                                                                zfacent,entfac
    real, dimension( its:ite )              ::                            ust3, &amp;
                                                                  wstar3,wstar, &amp;
@@ -469,10 +546,18 @@
                                                                        bfxpbl, &amp;
                                                                 hfxpbl,qfxpbl, &amp;
                                                                 ufxpbl,vfxpbl, &amp;
-                                                                  delta,dthvx
+                                                                        dthvx, &amp;
+                                                                         zol1
    real    ::  prnumfac,bfx0,hfx0,qfx0,delb,dux,dvx,                           &amp;
-               dsdzu,dsdzv,wm3,dthx,dqx,wspd10,ross,tem1,dsig,tvcon,conpr,prfac
+               dsdzu,dsdzv,wm3,dthx,dqx,wspd10,ross,tem1,dsig,tvcon,conpr,     &amp;
+               prfac,prfac2,phim8z
 !
+#if defined (non_hydrostatic_core) || defined(hydrostatic_core)
+!MPAS specific begin (Laura Fowler - 2013-03-01):
+   real,intent(out),dimension(ims:ime,kms:kme),optional::kzh,kzm,kzq
+!MPAS specific end.
+#endif
+
 !----------------------------------------------------------------------
 !
    klpbl = kte
@@ -571,6 +656,20 @@
      delta(i)  = 0.0
    enddo
 !
+!MPAS specific begin (Laura Fowler - 2013-03-01): Added initialization of local
+!vertical diffusion coefficients:
+   if(present(kzh) .and. present(kzm) .and. present(kzq)) then
+      do k = kts,kte
+      do i = its,ite
+         xkzh(i,k)  = 0.0
+         xkzm(i,k)  = 0.0
+         xkzhl(i,k) = 0.0
+         xkzml(i,k) = 0.0
+      enddo
+      enddo
+   endif
+!MPAS specific end.
+!
    do k = kts,klpbl
      do i = its,ite
        wscalek(i,k) = 0.0
@@ -582,6 +681,11 @@
        zfac(i,k) = 0.0
      enddo
    enddo
+   do k = kts,klpbl-1
+     do i = its,ite
+       xkzo(i,k) = ckz*dza(i,k+1)
+     enddo
+   enddo
 !
    do i = its,ite
      dusfc(i) = 0.
@@ -639,16 +743,15 @@
    enddo
 !
    do i = its,ite
-     fm = gz1oz0(i)-psim(i)
-     fh = gz1oz0(i)-psih(i)
-     hol(i) = max(br(i)*fm*fm/fh,rimin)
+     fm = psim(i)
+     fh = psih(i)
+     zol1(i) = max(br(i)*fm*fm/fh,rimin)
      if(sfcflg(i))then
-       hol(i) = min(hol(i),-zfmin)
+       zol1(i) = min(zol1(i),-zfmin)
      else
-       hol(i) = max(hol(i),zfmin)
+       zol1(i) = max(zol1(i),zfmin)
      endif
-     hol1 = hol(i)*hpbl(i)/zl1(i)*sfcfrac
-     hol(i) = -hol(i)*hpbl(i)/zl1(i)
+     hol1 = zol1(i)*hpbl(i)/zl1(i)*sfcfrac
      if(sfcflg(i))then
        phim(i) = (1.-aphi16*hol1)**(-1./4.)
        phih(i) = (1.-aphi16*hol1)**(-1./2.)
@@ -678,7 +781,7 @@
        hgamt(i) = min(gamfac*hfx(i)/cp,gamcrt)
        hgamq(i) = min(gamfac*qfx(i),gamcrq)
        vpert = (hgamt(i)+ep1*thx(i,1)*hgamq(i))/bfac*afac
-       thermal(i) = thermal(i)+max(vpert,0.)
+       thermal(i) = thermal(i)+max(vpert,0.)*min(za(i,1)/(sfcfrac*hpbl(i)),1.0)
        hgamt(i) = max(hgamt(i),0.0)
        hgamq(i) = max(hgamq(i),0.0)
        brint    = -15.9*ust(i)*ust(i)/wspd(i)*wstar3(i)/(wscale(i)**4.)
@@ -844,31 +947,34 @@
      do i = its,ite
        if(k.lt.kpbl(i)) then
          zfac(i,k) = min(max((1.-(zq(i,k+1)-zl1(i))/(hpbl(i)-zl1(i))),zfmin),1.)
-         xkzo = ckz*dza(i,k+1)
          zfacent(i,k) = (1.-zfac(i,k))**3.
+         wscalek(i,k) = (ust3(i)+phifac*karman*wstar3(i)*(1.-zfac(i,k)))**h1
          if(sfcflg(i)) then 
-           prfac = conpr/phim(i)/(1.+4.*karman*wstar3(i)/ust3(i))
+           prfac = conpr
+           prfac2 = 15.9*wstar3(i)/ust3(i)/(1.+4.*karman*wstar3(i)/ust3(i))
            prnumfac = -3.*(max(zq(i,k+1)-sfcfrac*hpbl(i),0.))**2./hpbl(i)**2.
          else
            prfac = 0.
+           prfac2 = 0.
            prnumfac = 0.
+           phim8z = 1.+aphi5*zol1(i)*zq(i,k+1)/zl1(i)
+           wscalek(i,k) = ust(i)/phim8z
+           wscalek(i,k) = max(wscalek(i,k),0.001)
          endif
          prnum0 = (phih(i)/phim(i)+prfac)
-         prnum0 = min(prnum0,prmax)
-         prnum0 = max(prnum0,prmin)
-         wscalek(i,k) = (ust3(i)+phifac*karman*wstar3(i)*(1.-zfac(i,k)))**h1
-         xkzm(i,k) = xkzo+wscalek(i,k)*karman*zq(i,k+1)*zfac(i,k)**pfac
+         prnum0 = max(min(prnum0,prmax),prmin)
+         xkzm(i,k) = wscalek(i,k)*karman*zq(i,k+1)*zfac(i,k)**pfac
          prnum =  1. + (prnum0-1.)*exp(prnumfac)
          xkzq(i,k) = xkzm(i,k)/prnum*zfac(i,k)**(pfac_q-pfac)
-         prnum0 = prnum0/(1.+prfac)
+         prnum0 = prnum0/(1.+prfac2*karman*sfcfrac)
          prnum =  1. + (prnum0-1.)*exp(prnumfac)
          xkzh(i,k) = xkzm(i,k)/prnum
          xkzm(i,k) = min(xkzm(i,k),xkzmax)
-         xkzm(i,k) = max(xkzm(i,k),xkzmin)
+         xkzm(i,k) = max(xkzm(i,k),xkzo(i,k))
          xkzh(i,k) = min(xkzh(i,k),xkzmax)
-         xkzh(i,k) = max(xkzh(i,k),xkzmin)
+         xkzh(i,k) = max(xkzh(i,k),xkzo(i,k))
          xkzq(i,k) = min(xkzq(i,k),xkzmax)
-         xkzq(i,k) = max(xkzq(i,k),xkzmin)
+         xkzq(i,k) = max(xkzq(i,k),xkzo(i,k))
        endif
      enddo
    enddo
@@ -877,7 +983,6 @@
 !
    do k = kts,kte-1
      do i = its,ite
-       xkzo = ckz*dza(i,k+1)
        if(k.ge.kpbl(i)) then
          ss = ((ux(i,k+1)-ux(i,k))*(ux(i,k+1)-ux(i,k))                         &amp;
               +(vx(i,k+1)-vx(i,k))*(vx(i,k+1)-vx(i,k)))                        &amp;
@@ -897,25 +1002,27 @@
          endif
          zk = karman*zq(i,k+1)
          rlamdz = min(max(0.1*dza(i,k+1),rlam),300.)
+         rlamdz = min(dza(i,k+1),rlamdz)
          rl2 = (zk*rlamdz/(rlamdz+zk))**2
          dk = rl2*sqrt(ss)
+         ri = max(ri,rimin)
          if(ri.lt.0.)then
 ! unstable regime
            sri = sqrt(-ri)
-           xkzm(i,k) = xkzo+dk*(1+8.*(-ri)/(1+1.746*sri))
-           xkzh(i,k) = xkzo+dk*(1+8.*(-ri)/(1+1.286*sri))
+           xkzm(i,k) = dk*(1+8.*(-ri)/(1+1.746*sri))
+           xkzh(i,k) = dk*(1+8.*(-ri)/(1+1.286*sri))
          else
 ! stable regime
-           xkzh(i,k) = xkzo+dk/(1+5.*ri)**2
+           xkzh(i,k) = dk/(1+5.*ri)**2
            prnum = 1.0+2.1*ri
            prnum = min(prnum,prmax)
-           xkzm(i,k) = (xkzh(i,k)-xkzo)*prnum+xkzo
+           xkzm(i,k) = xkzh(i,k)*prnum
          endif
 !
          xkzm(i,k) = min(xkzm(i,k),xkzmax)
-         xkzm(i,k) = max(xkzm(i,k),xkzmin)
+         xkzm(i,k) = max(xkzm(i,k),xkzo(i,k))
          xkzh(i,k) = min(xkzh(i,k),xkzmax)
-         xkzh(i,k) = max(xkzh(i,k),xkzmin)
+         xkzh(i,k) = max(xkzh(i,k),xkzo(i,k))
          xkzml(i,k) = xkzm(i,k)
          xkzhl(i,k) = xkzh(i,k)
        endif
@@ -953,7 +1060,7 @@
          xkzh(i,k) = -we(i)*dza(i,kpbl(i))*exp(-entfac(i,k))
          xkzh(i,k) = sqrt(xkzh(i,k)*xkzhl(i,k))
          xkzh(i,k) = min(xkzh(i,k),xkzmax)
-         xkzh(i,k) = max(xkzh(i,k),xkzmin)
+         xkzh(i,k) = max(xkzh(i,k),xkzo(i,k))
          f1(i,k+1) = thx(i,k+1)-300.
        else
          f1(i,k+1) = thx(i,k+1)-300.
@@ -989,7 +1096,7 @@
      enddo
    enddo
 !
-!     compute tridiagonal matrix elements for moisture, clouds, and tracers
+!     compute tridiagonal matrix elements for moisture, clouds, and gases
 !
    do k = kts,kte
      do i = its,ite
@@ -1044,7 +1151,7 @@
          xkzq(i,k) = -we(i)*dza(i,kpbl(i))*exp(-entfac(i,k))
          xkzq(i,k) = sqrt(xkzq(i,k)*xkzhl(i,k))
          xkzq(i,k) = min(xkzq(i,k),xkzmax)
-         xkzq(i,k) = max(xkzq(i,k),xkzmin)
+         xkzq(i,k) = max(xkzq(i,k),xkzo(i,k))
          f3(i,k+1,1) = qx(i,k+1)
        else
          f3(i,k+1,1) = qx(i,k+1)
@@ -1086,7 +1193,7 @@
      enddo
    enddo
 !
-!     solve tridiagonal problem for moisture, clouds, and tracers
+!     solve tridiagonal problem for moisture, clouds, and gases
 !
    call tridin_ysu(al,ad,cu,r3,au,f3,its,ite,kts,kte,ndiff)
 !
@@ -1125,8 +1232,15 @@
    enddo
 !
    do i = its,ite
-     ad(i,1) = 1.+ust(i)**2/wspd1(i)*rhox(i)*g/del(i,1)*dt2                    &amp;
-              *(wspd1(i)/wspd(i))**2
+! paj: ctopo=1 if topo_wind=0 (default)
+! mchen  add this line to make sure NMM can still work with YSU PBL
+     if(present(ctopo)) then 
+       ad(i,1) = 1.+ctopo(i)*ust(i)**2/wspd1(i)*rhox(i)*g/del(i,1)*dt2         &amp;
+        *(wspd1(i)/wspd(i))**2
+     else               
+       ad(i,1) = 1.+ust(i)**2/wspd1(i)*rhox(i)*g/del(i,1)*dt2                  &amp;
+        *(wspd1(i)/wspd(i))**2
+     endif 
      f1(i,1) = ux(i,1)
      f2(i,1) = vx(i,1)
    enddo
@@ -1149,7 +1263,7 @@
        xkzm(i,k) = prpbl(i)*xkzh(i,k)
        xkzm(i,k) = sqrt(xkzm(i,k)*xkzml(i,k))
        xkzm(i,k) = min(xkzm(i,k),xkzmax)
-       xkzm(i,k) = max(xkzm(i,k),xkzmin)
+       xkzm(i,k) = max(xkzm(i,k),xkzo(i,k))
        f1(i,k+1) = ux(i,k+1)
        f2(i,k+1) = vx(i,k+1)
      else
@@ -1192,12 +1306,33 @@
      enddo
    enddo
 !
+! paj: ctopo2=1 if topo_wind=0 (default)
+!
+   do i = its,ite
+     if(present(ctopo).and.present(ctopo2)) then   ! mchen for NMM
+     u10(i) = ctopo2(i)*u10(i)+(1-ctopo2(i))*ux(i,1)
+     v10(i) = ctopo2(i)*v10(i)+(1-ctopo2(i))*vx(i,1)
+     endif  !mchen
+   enddo
+!
 !---- end of vertical diffusion
 !
    do i = its,ite
      kpbl1d(i) = kpbl(i)
    enddo
 !
+!MPAS specific begin (Laura D. Fowler - 2013-03-01)::
+   if(present(kzh) .and. present(kzm) .and. present(kzq)) then
+      do i = its,ite
+      do k = kts,kte
+         kzh(i,k) = xkzh(i,k)
+         kzm(i,k) = xkzm(i,k)
+         kzq(i,k) = xkzq(i,k)
+      enddo
+      enddo
+   endif
+!MPAS specific end.
+
    end subroutine ysu2d
 !
    subroutine tridi1n(cl,cm,cu,r1,r2,au,f1,f2,its,ite,kts,kte,nt)

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_cu_tiedtke.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_cu_tiedtke.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_cu_tiedtke.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -63,7 +63,7 @@
       VTMPC1=RV/RD-1.0,             &amp;
       VTMPC2=CPV/CPD-1.0,           &amp;
       CVDIFTS=1.0,                  &amp;
-      CEVAPCU1=1.93E-6*261.,        &amp; 
+      CEVAPCU1=1.93E-6*261.0*0.5/G, &amp; ! Correction from WRFV3.4.1 sourcecode.
       CEVAPCU2=1.E3/(38.3*0.293) )
 
      

Copied: branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_mp_radar.F (from rev 2782, trunk/mpas/src/core_atmos_physics/physics_wrf/module_mp_radar.F)
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_mp_radar.F                                (rev 0)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_mp_radar.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -0,0 +1,685 @@
+!+---+-----------------------------------------------------------------+
+!..This set of routines facilitates computing radar reflectivity.
+!.. This module is more library code whereas the individual microphysics
+!.. schemes contains specific details needed for the final computation,
+!.. so refer to location within each schemes calling the routine named
+!.. rayleigh_soak_wetgraupel.
+!.. The bulk of this code originated from Ulrich Blahak (Germany) and
+!.. was adapted to WRF by G. Thompson.  This version of code is only
+!.. intended for use when Rayleigh scattering principles dominate and
+!.. is not intended for wavelengths in which Mie scattering is a
+!.. significant portion.  Therefore, it is well-suited to use with
+!.. 5 or 10 cm wavelength like USA NEXRAD radars.
+!.. This code makes some rather simple assumptions about water
+!.. coating on outside of frozen species (snow/graupel).  Fraction of
+!.. meltwater is simply the ratio of mixing ratio below melting level
+!.. divided by mixing ratio at level just above highest T&gt;0C.  Also,
+!.. immediately 90% of the melted water exists on the ice's surface
+!.. and 10% is embedded within ice.  No water is &quot;shed&quot; at all in these
+!.. assumptions. The code is quite slow because it does the reflectivity
+!.. calculations based on 50 individual size bins of the distributions.
+!+---+-----------------------------------------------------------------+
+
+MODULE module_mp_radar
+
+#if defined(non_hydrostatic_core) || defined(hydrostatic_core)
+      USE mpas_atmphys_utilities
+#else
+      USE module_wrf_error
+#endif
+
+      PUBLIC :: rayleigh_soak_wetgraupel
+      PUBLIC :: radar_init
+      PRIVATE :: m_complex_water_ray
+      PRIVATE :: m_complex_ice_maetzler
+      PRIVATE :: m_complex_maxwellgarnett
+      PRIVATE :: get_m_mix_nested
+      PRIVATE :: get_m_mix
+      PRIVATE :: WGAMMA
+      PRIVATE :: GAMMLN
+
+
+      INTEGER, PARAMETER, PUBLIC:: nrbins = 50
+      DOUBLE PRECISION, DIMENSION(nrbins+1), PUBLIC:: xxDx
+      DOUBLE PRECISION, DIMENSION(nrbins), PUBLIC:: xxDs,xdts,xxDg,xdtg
+      DOUBLE PRECISION, PARAMETER, PUBLIC:: lamda_radar = 0.10           ! in meters
+      DOUBLE PRECISION, PUBLIC:: K_w, PI5, lamda4
+      COMPLEX*16, PUBLIC:: m_w_0, m_i_0
+      DOUBLE PRECISION, DIMENSION(nrbins+1), PUBLIC:: simpson
+      DOUBLE PRECISION, DIMENSION(3), PARAMETER, PUBLIC:: basis =       &amp;
+                           (/1.d0/3.d0, 4.d0/3.d0, 1.d0/3.d0/)
+      REAL, DIMENSION(4), PUBLIC:: xcre, xcse, xcge, xcrg, xcsg, xcgg
+      REAL, PUBLIC:: xam_r, xbm_r, xmu_r, xobmr
+      REAL, PUBLIC:: xam_s, xbm_s, xmu_s, xoams, xobms, xocms
+      REAL, PUBLIC:: xam_g, xbm_g, xmu_g, xoamg, xobmg, xocmg
+      REAL, PUBLIC:: xorg2, xosg2, xogg2
+
+      INTEGER, PARAMETER, PUBLIC:: slen = 20
+      CHARACTER(len=slen), PUBLIC::                                     &amp;
+              mixingrulestring_s, matrixstring_s, inclusionstring_s,    &amp;
+              hoststring_s, hostmatrixstring_s, hostinclusionstring_s,  &amp;
+              mixingrulestring_g, matrixstring_g, inclusionstring_g,    &amp;
+              hoststring_g, hostmatrixstring_g, hostinclusionstring_g
+
+!..Single melting snow/graupel particle 90% meltwater on external sfc
+      DOUBLE PRECISION, PARAMETER:: melt_outside_s = 0.9d0
+      DOUBLE PRECISION, PARAMETER:: melt_outside_g = 0.9d0
+
+      CHARACTER*256:: radar_debug
+
+CONTAINS
+
+!+---+-----------------------------------------------------------------+
+!+---+-----------------------------------------------------------------+
+!+---+-----------------------------------------------------------------+
+
+      subroutine radar_init
+
+      IMPLICIT NONE
+      INTEGER:: n
+      PI5 = 3.14159*3.14159*3.14159*3.14159*3.14159
+      lamda4 = lamda_radar*lamda_radar*lamda_radar*lamda_radar
+      m_w_0 = m_complex_water_ray (lamda_radar, 0.0d0)
+      m_i_0 = m_complex_ice_maetzler (lamda_radar, 0.0d0)
+      K_w = (ABS( (m_w_0*m_w_0 - 1.0) /(m_w_0*m_w_0 + 2.0) ))**2
+
+      do n = 1, nrbins+1
+         simpson(n) = 0.0d0
+      enddo
+      do n = 1, nrbins-1, 2
+         simpson(n) = simpson(n) + basis(1)
+         simpson(n+1) = simpson(n+1) + basis(2)
+         simpson(n+2) = simpson(n+2) + basis(3)
+      enddo
+
+      do n = 1, slen
+         mixingrulestring_s(n:n) = char(0)
+         matrixstring_s(n:n) = char(0)
+         inclusionstring_s(n:n) = char(0)
+         hoststring_s(n:n) = char(0)
+         hostmatrixstring_s(n:n) = char(0)
+         hostinclusionstring_s(n:n) = char(0)
+         mixingrulestring_g(n:n) = char(0)
+         matrixstring_g(n:n) = char(0)
+         inclusionstring_g(n:n) = char(0)
+         hoststring_g(n:n) = char(0)
+         hostmatrixstring_g(n:n) = char(0)
+         hostinclusionstring_g(n:n) = char(0)
+      enddo
+
+      mixingrulestring_s = 'maxwellgarnett'
+      hoststring_s = 'air'
+      matrixstring_s = 'water'
+      inclusionstring_s = 'spheroidal'
+      hostmatrixstring_s = 'icewater'
+      hostinclusionstring_s = 'spheroidal'
+
+      mixingrulestring_g = 'maxwellgarnett'
+      hoststring_g = 'air'
+      matrixstring_g = 'water'
+      inclusionstring_g = 'spheroidal'
+      hostmatrixstring_g = 'icewater'
+      hostinclusionstring_g = 'spheroidal'
+
+!..Create bins of snow (from 100 microns up to 2 cm).
+      xxDx(1) = 100.D-6
+      xxDx(nrbins+1) = 0.02d0
+      do n = 2, nrbins
+         xxDx(n) = DEXP(DFLOAT(n-1)/DFLOAT(nrbins) &amp;
+                  *DLOG(xxDx(nrbins+1)/xxDx(1)) +DLOG(xxDx(1)))
+      enddo
+      do n = 1, nrbins
+         xxDs(n) = DSQRT(xxDx(n)*xxDx(n+1))
+         xdts(n) = xxDx(n+1) - xxDx(n)
+      enddo
+
+!..Create bins of graupel (from 100 microns up to 5 cm).
+      xxDx(1) = 100.D-6
+      xxDx(nrbins+1) = 0.05d0
+      do n = 2, nrbins
+         xxDx(n) = DEXP(DFLOAT(n-1)/DFLOAT(nrbins) &amp;
+                  *DLOG(xxDx(nrbins+1)/xxDx(1)) +DLOG(xxDx(1)))
+      enddo
+      do n = 1, nrbins
+         xxDg(n) = DSQRT(xxDx(n)*xxDx(n+1))
+         xdtg(n) = xxDx(n+1) - xxDx(n)
+      enddo
+
+
+!..The calling program must set the m(D) relations and gamma shape
+!.. parameter mu for rain, snow, and graupel.  Easily add other types
+!.. based on the template here.  For majority of schemes with simpler
+!.. exponential number distribution, mu=0.
+
+      xcre(1) = 1. + xbm_r
+      xcre(2) = 1. + xmu_r
+      xcre(3) = 4. + xmu_r
+      xcre(4) = 7. + xmu_r
+      do n = 1, 4
+         xcrg(n) = WGAMMA(xcre(n))
+      enddo
+      xorg2 = 1./xcrg(2)
+
+      xcse(1) = 1. + xbm_s
+      xcse(2) = 1. + xmu_s
+      xcse(3) = 4. + xmu_s
+      xcse(4) = 7. + xmu_s
+      do n = 1, 4
+         xcsg(n) = WGAMMA(xcse(n))
+      enddo
+      xosg2 = 1./xcsg(2)
+
+      xcge(1) = 1. + xbm_g
+      xcge(2) = 1. + xmu_g
+      xcge(3) = 4. + xmu_g
+      xcge(4) = 7. + xmu_g
+      do n = 1, 4
+         xcgg(n) = WGAMMA(xcge(n))
+      enddo
+      xogg2 = 1./xcgg(2)
+
+      xobmr = 1./xbm_r
+      xoams = 1./xam_s
+      xobms = 1./xbm_s
+      xocms = xoams**xobms
+      xoamg = 1./xam_g
+      xobmg = 1./xbm_g
+      xocmg = xoamg**xobmg
+
+
+      end subroutine radar_init
+
+!+---+-----------------------------------------------------------------+
+!+---+-----------------------------------------------------------------+
+
+      COMPLEX*16 FUNCTION m_complex_water_ray(lambda,T)
+
+!      Complex refractive Index of Water as function of Temperature T
+!      [deg C] and radar wavelength lambda [m]; valid for
+!      lambda in [0.001,1.0] m; T in [-10.0,30.0] deg C
+!      after Ray (1972)
+
+      IMPLICIT NONE
+      DOUBLE PRECISION, INTENT(IN):: T,lambda
+      DOUBLE PRECISION:: epsinf,epss,epsr,epsi
+      DOUBLE PRECISION:: alpha,lambdas,sigma,nenner
+      COMPLEX*16, PARAMETER:: i = (0d0,1d0)
+      DOUBLE PRECISION, PARAMETER:: PIx=3.1415926535897932384626434d0
+
+      epsinf  = 5.27137d0 + 0.02164740d0 * T - 0.00131198d0 * T*T
+      epss    = 78.54d+0 * (1.0 - 4.579d-3 * (T - 25.0)                 &amp;
+              + 1.190d-5 * (T - 25.0)*(T - 25.0)                        &amp;
+              - 2.800d-8 * (T - 25.0)*(T - 25.0)*(T - 25.0))
+      alpha   = -16.8129d0/(T+273.16) + 0.0609265d0
+      lambdas = 0.00033836d0 * exp(2513.98d0/(T+273.16)) * 1e-2
+
+      nenner = 1.d0+2.d0*(lambdas/lambda)**(1d0-alpha)*sin(alpha*PIx*0.5) &amp;
+             + (lambdas/lambda)**(2d0-2d0*alpha)
+      epsr = epsinf + ((epss-epsinf) * ((lambdas/lambda)**(1d0-alpha)   &amp;
+           * sin(alpha*PIx*0.5)+1d0)) / nenner
+      epsi = ((epss-epsinf) * ((lambdas/lambda)**(1d0-alpha)            &amp;
+           * cos(alpha*PIx*0.5)+0d0)) / nenner                           &amp;
+           + lambda*1.25664/1.88496
+      
+      m_complex_water_ray = SQRT(CMPLX(epsr,-epsi))
+      
+      END FUNCTION m_complex_water_ray
+
+!+---+-----------------------------------------------------------------+
+      
+      COMPLEX*16 FUNCTION m_complex_ice_maetzler(lambda,T)
+      
+!      complex refractive index of ice as function of Temperature T
+!      [deg C] and radar wavelength lambda [m]; valid for
+!      lambda in [0.0001,30] m; T in [-250.0,0.0] C
+!      Original comment from the Matlab-routine of Prof. Maetzler:
+!      Function for calculating the relative permittivity of pure ice in
+!      the microwave region, according to C. Maetzler, &quot;Microwave
+!      properties of ice and snow&quot;, in B. Schmitt et al. (eds.) Solar
+!      System Ices, Astrophys. and Space Sci. Library, Vol. 227, Kluwer
+!      Academic Publishers, Dordrecht, pp. 241-257 (1998). Input:
+!      TK = temperature (K), range 20 to 273.15
+!      f = frequency in GHz, range 0.01 to 3000
+         
+      IMPLICIT NONE
+      DOUBLE PRECISION, INTENT(IN):: T,lambda
+      DOUBLE PRECISION:: f,c,TK,B1,B2,b,deltabeta,betam,beta,theta,alfa
+
+      c = 2.99d8
+      TK = T + 273.16
+      f = c / lambda * 1d-9
+
+      B1 = 0.0207
+      B2 = 1.16d-11
+      b = 335.0d0
+      deltabeta = EXP(-10.02 + 0.0364*(TK-273.16))
+      betam = (B1/TK) * ( EXP(b/TK) / ((EXP(b/TK)-1)**2) ) + B2*f*f
+      beta = betam + deltabeta
+      theta = 300. / TK - 1.
+      alfa = (0.00504d0 + 0.0062d0*theta) * EXP(-22.1d0*theta)
+      m_complex_ice_maetzler = 3.1884 + 9.1e-4*(TK-273.16)
+      m_complex_ice_maetzler = m_complex_ice_maetzler                   &amp;
+                             + CMPLX(0.0d0, (alfa/f + beta*f)) 
+      m_complex_ice_maetzler = SQRT(CONJG(m_complex_ice_maetzler))
+      
+      END FUNCTION m_complex_ice_maetzler
+
+!+---+-----------------------------------------------------------------+
+
+      subroutine rayleigh_soak_wetgraupel (x_g, a_geo, b_geo, fmelt,    &amp;
+                     meltratio_outside, m_w, m_i, lambda, C_back,       &amp;
+                     mixingrule,matrix,inclusion,                       &amp;
+                     host,hostmatrix,hostinclusion)
+
+      IMPLICIT NONE
+
+      DOUBLE PRECISION, INTENT(in):: x_g, a_geo, b_geo, fmelt, lambda,  &amp;
+                                     meltratio_outside
+      DOUBLE PRECISION, INTENT(out):: C_back
+      COMPLEX*16, INTENT(in):: m_w, m_i
+      CHARACTER(len=*), INTENT(in):: mixingrule, matrix, inclusion,     &amp;
+                                     host, hostmatrix, hostinclusion
+
+      COMPLEX*16:: m_core, m_air
+      DOUBLE PRECISION:: D_large, D_g, rhog, x_w, xw_a, fm, fmgrenz,    &amp;
+                         volg, vg, volair, volice, volwater,            &amp;
+                         meltratio_outside_grenz, mra
+      INTEGER:: error
+      DOUBLE PRECISION, PARAMETER:: PIx=3.1415926535897932384626434d0
+
+!     refractive index of air:
+      m_air = (1.0d0,0.0d0)
+
+!     Limiting the degree of melting --- for safety: 
+      fm = DMAX1(DMIN1(fmelt, 1.0d0), 0.0d0)
+!     Limiting the ratio of (melting on outside)/(melting on inside):
+      mra = DMAX1(DMIN1(meltratio_outside, 1.0d0), 0.0d0)
+
+!    ! The relative portion of meltwater melting at outside should increase
+!    ! from the given input value (between 0 and 1)
+!    ! to 1 as the degree of melting approaches 1,
+!    ! so that the melting particle &quot;converges&quot; to a water drop.
+!    ! Simplest assumption is linear:
+      mra = mra + (1.0d0-mra)*fm
+
+      x_w = x_g * fm
+
+      D_g = a_geo * x_g**b_geo
+
+      if (D_g .ge. 1d-12) then
+
+       vg = PIx/6. * D_g**3
+       rhog = DMAX1(DMIN1(x_g / vg, 900.0d0), 10.0d0)
+       vg = x_g / rhog
+      
+       meltratio_outside_grenz = 1.0d0 - rhog / 1000.
+
+       if (mra .le. meltratio_outside_grenz) then
+        !..In this case, it cannot happen that, during melting, all the
+        !.. air inclusions within the ice particle get filled with
+        !.. meltwater. This only happens at the end of all melting.
+        volg = vg * (1.0d0 - mra * fm)

+       else
+        !..In this case, at some melting degree fm, all the air
+        !.. inclusions get filled with meltwater.
+        fmgrenz=(900.0-rhog)/(mra*900.0-rhog+900.0*rhog/1000.)
+
+        if (fm .le. fmgrenz) then
+         !.. not all air pockets are filled:
+         volg = (1.0 - mra * fm) * vg
+        else
+         !..all air pockets are filled with meltwater, now the
+         !.. entire ice sceleton melts homogeneously:
+         volg = (x_g - x_w) / 900.0 + x_w / 1000.
+        endif
+
+       endif
+
+       D_large  = (6.0 / PIx * volg) ** (1./3.)
+       volice = (x_g - x_w) / (volg * 900.0)
+       volwater = x_w / (1000. * volg)
+       volair = 1.0 - volice - volwater
+      
+       !..complex index of refraction for the ice-air-water mixture
+       !.. of the particle:
+       m_core = get_m_mix_nested (m_air, m_i, m_w, volair, volice,      &amp;
+                         volwater, mixingrule, host, matrix, inclusion, &amp;
+                         hostmatrix, hostinclusion, error)
+       if (error .ne. 0) then
+        C_back = 0.0d0
+        return
+       endif
+
+       !..Rayleigh-backscattering coefficient of melting particle: 
+       C_back = (ABS((m_core**2-1.0d0)/(m_core**2+2.0d0)))**2           &amp;
+                * PI5 * D_large**6 / lamda4
+
+      else
+       C_back = 0.0d0
+      endif
+
+      end subroutine rayleigh_soak_wetgraupel
+
+!+---+-----------------------------------------------------------------+
+
+      complex*16 function get_m_mix_nested (m_a, m_i, m_w, volair,      &amp;
+                     volice, volwater, mixingrule, host, matrix,        &amp;
+                     inclusion, hostmatrix, hostinclusion, cumulerror)
+
+      IMPLICIT NONE
+
+      DOUBLE PRECISION, INTENT(in):: volice, volair, volwater
+      COMPLEX*16, INTENT(in):: m_a, m_i, m_w
+      CHARACTER(len=*), INTENT(in):: mixingrule, host, matrix,          &amp;
+                     inclusion, hostmatrix, hostinclusion
+      INTEGER, INTENT(out):: cumulerror
+
+      DOUBLE PRECISION:: vol1, vol2
+      COMPLEX*16:: mtmp
+      INTEGER:: error
+
+      !..Folded: ( (m1 + m2) + m3), where m1,m2,m3 could each be
+      !.. air, ice, or water
+
+      cumulerror = 0
+      get_m_mix_nested = CMPLX(1.0d0,0.0d0)
+
+      if (host .eq. 'air') then
+
+       if (matrix .eq. 'air') then
+        write(radar_debug,*) 'GET_M_MIX_NESTED: bad matrix: ', matrix
+#if defined(non_hydrostatic_core) | defined(hydrostatic_core)
+        call physics_message(radar_debug)
+#else
+        CALL wrf_debug(150, radar_debug)
+#endif
+        cumulerror = cumulerror + 1
+       else
+        vol1 = volice / MAX(volice+volwater,1d-10)
+        vol2 = 1.0d0 - vol1
+        mtmp = get_m_mix (m_a, m_i, m_w, 0.0d0, vol1, vol2,             &amp;
+                         mixingrule, matrix, inclusion, error)
+        cumulerror = cumulerror + error
+          
+        if (hostmatrix .eq. 'air') then
+         get_m_mix_nested = get_m_mix (m_a, mtmp, 2.0*m_a,              &amp;
+                         volair, (1.0d0-volair), 0.0d0, mixingrule,     &amp;
+                         hostmatrix, hostinclusion, error)
+         cumulerror = cumulerror + error
+        elseif (hostmatrix .eq. 'icewater') then
+         get_m_mix_nested = get_m_mix (m_a, mtmp, 2.0*m_a,              &amp;
+                         volair, (1.0d0-volair), 0.0d0, mixingrule,     &amp;
+                         'ice', hostinclusion, error)
+         cumulerror = cumulerror + error
+        else
+         write(radar_debug,*) 'GET_M_MIX_NESTED: bad hostmatrix: ',        &amp;
+                           hostmatrix
+#if defined(non_hydrostatic_core) | defined(hydrostatic_core)
+        call physics_message(radar_debug)
+#else
+         CALL wrf_debug(150, radar_debug)
+#endif
+         cumulerror = cumulerror + 1
+        endif
+       endif
+
+      elseif (host .eq. 'ice') then
+
+       if (matrix .eq. 'ice') then
+        write(radar_debug,*) 'GET_M_MIX_NESTED: bad matrix: ', matrix
+#if defined(non_hydrostatic_core) | defined(hydrostatic_core)
+        call physics_message(radar_debug)
+#else
+        CALL wrf_debug(150, radar_debug)
+#endif
+        cumulerror = cumulerror + 1
+       else
+        vol1 = volair / MAX(volair+volwater,1d-10)
+        vol2 = 1.0d0 - vol1
+        mtmp = get_m_mix (m_a, m_i, m_w, vol1, 0.0d0, vol2,             &amp;
+                         mixingrule, matrix, inclusion, error)
+        cumulerror = cumulerror + error
+
+        if (hostmatrix .eq. 'ice') then
+         get_m_mix_nested = get_m_mix (mtmp, m_i, 2.0*m_a,              &amp;
+                         (1.0d0-volice), volice, 0.0d0, mixingrule,     &amp;
+                         hostmatrix, hostinclusion, error)
+         cumulerror = cumulerror + error
+        elseif (hostmatrix .eq. 'airwater') then
+         get_m_mix_nested = get_m_mix (mtmp, m_i, 2.0*m_a,              &amp;
+                         (1.0d0-volice), volice, 0.0d0, mixingrule,     &amp;
+                         'air', hostinclusion, error)
+         cumulerror = cumulerror + error          
+        else
+         write(radar_debug,*) 'GET_M_MIX_NESTED: bad hostmatrix: ',        &amp;
+                           hostmatrix
+#if defined(non_hydrostatic_core) | defined(hydrostatic_core)
+        call physics_message(radar_debug)
+#else
+         CALL wrf_debug(150, radar_debug)
+#endif
+         cumulerror = cumulerror + 1
+        endif
+       endif
+
+      elseif (host .eq. 'water') then
+
+       if (matrix .eq. 'water') then
+        write(radar_debug,*) 'GET_M_MIX_NESTED: bad matrix: ', matrix
+#if defined(non_hydrostatic_core) | defined(hydrostatic_core)
+        call physics_message(radar_debug)
+#else
+        CALL wrf_debug(150, radar_debug)
+#endif
+        cumulerror = cumulerror + 1
+       else
+        vol1 = volair / MAX(volice+volair,1d-10)
+        vol2 = 1.0d0 - vol1
+        mtmp = get_m_mix (m_a, m_i, m_w, vol1, vol2, 0.0d0,             &amp;
+                         mixingrule, matrix, inclusion, error)
+        cumulerror = cumulerror + error
+
+        if (hostmatrix .eq. 'water') then
+         get_m_mix_nested = get_m_mix (2*m_a, mtmp, m_w,                &amp;
+                         0.0d0, (1.0d0-volwater), volwater, mixingrule, &amp;
+                         hostmatrix, hostinclusion, error)
+         cumulerror = cumulerror + error
+        elseif (hostmatrix .eq. 'airice') then
+         get_m_mix_nested = get_m_mix (2*m_a, mtmp, m_w,                &amp;
+                         0.0d0, (1.0d0-volwater), volwater, mixingrule, &amp;
+                         'ice', hostinclusion, error)
+         cumulerror = cumulerror + error          
+        else
+         write(radar_debug,*) 'GET_M_MIX_NESTED: bad hostmatrix: ',         &amp;
+                           hostmatrix
+#if defined(non_hydrostatic_core) | defined(hydrostatic_core)
+        call physics_message(radar_debug)
+#else
+         CALL wrf_debug(150, radar_debug)
+#endif
+         cumulerror = cumulerror + 1
+        endif
+       endif
+
+      elseif (host .eq. 'none') then
+
+       get_m_mix_nested = get_m_mix (m_a, m_i, m_w,                     &amp;
+                       volair, volice, volwater, mixingrule,            &amp;
+                       matrix, inclusion, error)
+       cumulerror = cumulerror + error
+        
+      else
+       write(radar_debug,*) 'GET_M_MIX_NESTED: unknown matrix: ', host
+#if defined(non_hydrostatic_core) | defined(hydrostatic_core)
+        call physics_message(radar_debug)
+#else
+       CALL wrf_debug(150, radar_debug)
+#endif
+       cumulerror = cumulerror + 1
+      endif
+
+      IF (cumulerror .ne. 0) THEN
+       write(radar_debug,*) 'GET_M_MIX_NESTED: error encountered'
+#if defined(non_hydrostatic_core) | defined(hydrostatic_core)
+        call physics_message(radar_debug)
+#else
+       CALL wrf_debug(150, radar_debug)
+#endif
+       get_m_mix_nested = CMPLX(1.0d0,0.0d0)    
+      endif
+
+      end function get_m_mix_nested
+
+!+---+-----------------------------------------------------------------+
+
+      COMPLEX*16 FUNCTION get_m_mix (m_a, m_i, m_w, volair, volice,     &amp;
+                     volwater, mixingrule, matrix, inclusion, error)
+
+      IMPLICIT NONE
+
+      DOUBLE PRECISION, INTENT(in):: volice, volair, volwater
+      COMPLEX*16, INTENT(in):: m_a, m_i, m_w
+      CHARACTER(len=*), INTENT(in):: mixingrule, matrix, inclusion
+      INTEGER, INTENT(out):: error
+
+      error = 0
+      get_m_mix = CMPLX(1.0d0,0.0d0)
+
+      if (mixingrule .eq. 'maxwellgarnett') then
+       if (matrix .eq. 'ice') then
+        get_m_mix = m_complex_maxwellgarnett(volice, volair, volwater,  &amp;
+                           m_i, m_a, m_w, inclusion, error)
+       elseif (matrix .eq. 'water') then
+        get_m_mix = m_complex_maxwellgarnett(volwater, volair, volice,  &amp;
+                           m_w, m_a, m_i, inclusion, error)
+       elseif (matrix .eq. 'air') then
+        get_m_mix = m_complex_maxwellgarnett(volair, volwater, volice,  &amp;
+                           m_a, m_w, m_i, inclusion, error)
+       else
+        write(radar_debug,*) 'GET_M_MIX: unknown matrix: ', matrix
+#if defined(non_hydrostatic_core) | defined(hydrostatic_core)
+        call physics_message(radar_debug)
+#else
+        CALL wrf_debug(150, radar_debug)
+#endif
+        error = 1
+       endif
+
+      else
+       write(radar_debug,*) 'GET_M_MIX: unknown mixingrule: ', mixingrule
+#if defined(non_hydrostatic_core) | defined(hydrostatic_core)
+        call physics_message(radar_debug)
+#else
+       CALL wrf_debug(150, radar_debug)
+#endif
+       error = 2
+      endif
+
+      if (error .ne. 0) then
+       write(radar_debug,*) 'GET_M_MIX: error encountered'
+#if defined(non_hydrostatic_core) | defined(hydrostatic_core)
+        call physics_message(radar_debug)
+#else
+       CALL wrf_debug(150, radar_debug)
+#endif
+      endif
+
+      END FUNCTION get_m_mix
+
+!+---+-----------------------------------------------------------------+
+
+      COMPLEX*16 FUNCTION m_complex_maxwellgarnett(vol1, vol2, vol3,    &amp;
+                     m1, m2, m3, inclusion, error)
+
+      IMPLICIT NONE
+
+      COMPLEX*16 :: m1, m2, m3
+      DOUBLE PRECISION :: vol1, vol2, vol3
+      CHARACTER(len=*) :: inclusion
+
+      COMPLEX*16 :: beta2, beta3, m1t, m2t, m3t
+      INTEGER, INTENT(out) :: error
+
+      error = 0
+
+      if (DABS(vol1+vol2+vol3-1.0d0) .gt. 1d-6) then
+       write(radar_debug,*) 'M_COMPLEX_MAXWELLGARNETT: sum of the ',       &amp;
+              'partial volume fractions is not 1...ERROR'
+#if defined(non_hydrostatic_core) | defined(hydrostatic_core)
+        call physics_message(radar_debug)
+#else
+       CALL wrf_debug(150, radar_debug)
+#endif
+       m_complex_maxwellgarnett=CMPLX(-999.99d0,-999.99d0)
+       error = 1
+       return
+      endif
+
+      m1t = m1**2
+      m2t = m2**2
+      m3t = m3**2
+
+      if (inclusion .eq. 'spherical') then
+       beta2 = 3.0d0*m1t/(m2t+2.0d0*m1t)
+       beta3 = 3.0d0*m1t/(m3t+2.0d0*m1t)
+      elseif (inclusion .eq. 'spheroidal') then
+       beta2 = 2.0d0*m1t/(m2t-m1t) * (m2t/(m2t-m1t)*LOG(m2t/m1t)-1.0d0)
+       beta3 = 2.0d0*m1t/(m3t-m1t) * (m3t/(m3t-m1t)*LOG(m3t/m1t)-1.0d0)
+      else
+       write(radar_debug,*) 'M_COMPLEX_MAXWELLGARNETT: ',                  &amp;
+                         'unknown inclusion: ', inclusion
+#if defined(non_hydrostatic_core) | defined(hydrostatic_core)
+        call physics_message(radar_debug)
+#else
+       CALL wrf_debug(150, radar_debug)
+#endif
+       m_complex_maxwellgarnett=DCMPLX(-999.99d0,-999.99d0)
+       error = 1
+       return
+      endif
+
+      m_complex_maxwellgarnett = &amp;
+       SQRT(((1.0d0-vol2-vol3)*m1t + vol2*beta2*m2t + vol3*beta3*m3t) / &amp;
+       (1.0d0-vol2-vol3+vol2*beta2+vol3*beta3))
+
+      END FUNCTION m_complex_maxwellgarnett
+
+!+---+-----------------------------------------------------------------+
+      REAL FUNCTION GAMMLN(XX)
+!     --- RETURNS THE VALUE LN(GAMMA(XX)) FOR XX &gt; 0.
+      IMPLICIT NONE
+      REAL, INTENT(IN):: XX
+      DOUBLE PRECISION, PARAMETER:: STP = 2.5066282746310005D0
+      DOUBLE PRECISION, DIMENSION(6), PARAMETER:: &amp;
+               COF = (/76.18009172947146D0, -86.50532032941677D0, &amp;
+                       24.01409824083091D0, -1.231739572450155D0, &amp;
+                      .1208650973866179D-2, -.5395239384953D-5/)
+      DOUBLE PRECISION:: SER,TMP,X,Y
+      INTEGER:: J
+
+      X=XX
+      Y=X
+      TMP=X+5.5D0
+      TMP=(X+0.5D0)*LOG(TMP)-TMP
+      SER=1.000000000190015D0
+      DO 11 J=1,6
+        Y=Y+1.D0
+        SER=SER+COF(J)/Y
+11    CONTINUE
+      GAMMLN=TMP+LOG(STP*SER/X)
+      END FUNCTION GAMMLN
+!  (C) Copr. 1986-92 Numerical Recipes Software 2.02
+!+---+-----------------------------------------------------------------+
+      REAL FUNCTION WGAMMA(y)
+
+      IMPLICIT NONE
+      REAL, INTENT(IN):: y
+
+      WGAMMA = EXP(GAMMLN(y))
+
+      END FUNCTION WGAMMA
+
+!+---+-----------------------------------------------------------------+
+END MODULE module_mp_radar
+!+---+-----------------------------------------------------------------+

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_mp_wsm6.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_mp_wsm6.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_mp_wsm6.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -8,6 +8,13 @@
 
 MODULE module_mp_wsm6
 !
+!#if defined(non_hydrostatic_core) || defined(hydrostatic_code)
+!   USE mpas_atmphys_utilities
+!#else
+!   USE module_utility, ONLY: WRFU_Clock, WRFU_Alarm
+!   USE module_domain, ONLY : HISTORY_ALARM, Is_alarm_tstep
+!#endif
+   USE module_mp_radar
 !
    REAL, PARAMETER, PRIVATE :: dtcldcr     = 120. ! maximum time step for minor loops
    REAL, PARAMETER, PRIVATE :: n0r = 8.e6         ! intercept parameter rain
@@ -64,6 +71,7 @@
                  ,rain, rainncv                                    &amp;
                  ,snow, snowncv                                    &amp;
                  ,sr                                               &amp;
+                 ,refl_10cm, diagflag, do_radar_ref                &amp;
                  ,graupel, graupelncv                              &amp;
                  ,ids,ide, jds,jde, kds,kde                        &amp;
                  ,ims,ime, jms,jme, kms,kme                        &amp;
@@ -112,6 +120,16 @@
         INTENT(INOUT) ::                                    rain, &amp;
                                                          rainncv, &amp;
                                                               sr
+
+!+---+-----------------------------------------------------------------+
+#if defined(non_hydrostatic_core) | defined(hydrostatic_core)
+  REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT),optional:: &amp;  ! GT
+                                                       refl_10cm
+#else
+  REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT)::     &amp;  ! GT
+#endif
+!+---+-----------------------------------------------------------------+
+
   REAL, DIMENSION( ims:ime , jms:jme ), OPTIONAL,                 &amp;
         INTENT(INOUT) ::                                    snow, &amp;
                                                          snowncv
@@ -123,7 +141,13 @@
   REAL, DIMENSION( its:ite , kts:kte, 2 ) ::   qci
   REAL, DIMENSION( its:ite , kts:kte, 3 ) ::   qrs
   INTEGER ::               i,j,k
-!-------------------------------------------------------------------
+
+!+---+-----------------------------------------------------------------+
+      REAL, DIMENSION(kts:kte):: qv1d, t1d, p1d, qr1d, qs1d, qg1d, dBZ
+      LOGICAL, OPTIONAL, INTENT(IN) :: diagflag
+      INTEGER, OPTIONAL, INTENT(IN) :: do_radar_ref
+!+---+-----------------------------------------------------------------+
+
       DO j=jts,jte
          DO k=kts,kte
          DO i=its,ite
@@ -163,6 +187,29 @@
             qg(i,k,j) = qrs(i,k,3)
          ENDDO
          ENDDO
+
+!+---+-----------------------------------------------------------------+
+         IF ( PRESENT (diagflag) ) THEN
+         if (diagflag .and. do_radar_ref == 1) then
+            DO I=its,ite
+               DO K=kts,kte
+                  t1d(k)=th(i,k,j)*pii(i,k,j)
+                  p1d(k)=p(i,k,j)
+                  qv1d(k)=q(i,k,j)
+                  qr1d(k)=qr(i,k,j)
+                  qs1d(k)=qs(i,k,j)
+                  qg1d(k)=qg(i,k,j)
+               ENDDO
+               call refl10cm_wsm6 (qv1d, qr1d, qs1d, qg1d,              &amp;
+                       t1d, p1d, dBZ, kts, kte, i, j)
+               do k = kts, kte
+                  refl_10cm(i,k,j) = MAX(-35., dBZ(k))
+               enddo
+            ENDDO
+         endif
+         ENDIF
+!+---+-----------------------------------------------------------------+
+
       ENDDO
   END SUBROUTINE wsm6
 !===================================================================
@@ -1489,6 +1536,24 @@
    rsloper3max = rsloper2max * rslopermax
    rslopes3max = rslopes2max * rslopesmax
    rslopeg3max = rslopeg2max * rslopegmax
+
+!+---+-----------------------------------------------------------------+
+!..Set these variables needed for computing radar reflectivity.  These
+!.. get used within radar_init to create other variables used in the
+!.. radar module.
+   xam_r = PI*denr/6.
+   xbm_r = 3.
+   xmu_r = 0.
+   xam_s = PI*dens/6.
+   xbm_s = 3.
+   xmu_s = 0.
+   xam_g = PI*deng/6.
+   xbm_g = 3.
+   xmu_g = 0.
+
+   call radar_init
+!+---+-----------------------------------------------------------------+
+
 !
   END SUBROUTINE wsm6init
 !------------------------------------------------------------------------------
@@ -2215,4 +2280,182 @@
       enddo i_loop
 !
   END SUBROUTINE nislfv_rain_plm6
+
+!+---+-----------------------------------------------------------------+
+
+      subroutine refl10cm_wsm6 (qv1d, qr1d, qs1d, qg1d,                 &amp;
+                       t1d, p1d, dBZ, kts, kte, ii, jj)
+
+      IMPLICIT NONE
+
+!..Sub arguments
+      INTEGER, INTENT(IN):: kts, kte, ii, jj
+      REAL, DIMENSION(kts:kte), INTENT(IN)::                            &amp;
+                      qv1d, qr1d, qs1d, qg1d, t1d, p1d
+      REAL, DIMENSION(kts:kte), INTENT(INOUT):: dBZ
+
+!..Local variables
+      REAL, DIMENSION(kts:kte):: temp, pres, qv, rho
+      REAL, DIMENSION(kts:kte):: rr, rs, rg
+      REAL:: temp_C
+
+      DOUBLE PRECISION, DIMENSION(kts:kte):: ilamr, ilams, ilamg
+      DOUBLE PRECISION, DIMENSION(kts:kte):: N0_r, N0_s, N0_g
+      DOUBLE PRECISION:: lamr, lams, lamg
+      LOGICAL, DIMENSION(kts:kte):: L_qr, L_qs, L_qg
+
+      REAL, DIMENSION(kts:kte):: ze_rain, ze_snow, ze_graupel
+      DOUBLE PRECISION:: fmelt_s, fmelt_g
+
+      INTEGER:: i, k, k_0, kbot, n
+      LOGICAL:: melti
+
+      DOUBLE PRECISION:: cback, x, eta, f_d
+      REAL, PARAMETER:: R=287.
+
+!+---+
+
+      do k = kts, kte
+         dBZ(k) = -35.0
+      enddo
+
+!+---+-----------------------------------------------------------------+
+!..Put column of data into local arrays.
+!+---+-----------------------------------------------------------------+
+      do k = kts, kte
+         temp(k) = t1d(k)
+         temp_C = min(-0.001, temp(K)-273.15)
+         qv(k) = MAX(1.E-10, qv1d(k))
+         pres(k) = p1d(k)
+         rho(k) = 0.622*pres(k)/(R*temp(k)*(qv(k)+0.622))
+
+         if (qr1d(k) .gt. 1.E-9) then
+            rr(k) = qr1d(k)*rho(k)
+            N0_r(k) = n0r
+            lamr = (xam_r*xcrg(3)*N0_r(k)/rr(k))**(1./xcre(1))
+            ilamr(k) = 1./lamr
+            L_qr(k) = .true.
+         else
+            rr(k) = 1.E-12
+            L_qr(k) = .false.
+         endif
+
+         if (qs1d(k) .gt. 1.E-9) then
+            rs(k) = qs1d(k)*rho(k)
+            N0_s(k) = min(n0smax, n0s*exp(-alpha*temp_C))
+            lams = (xam_s*xcsg(3)*N0_s(k)/rs(k))**(1./xcse(1))
+            ilams(k) = 1./lams
+            L_qs(k) = .true.
+         else
+            rs(k) = 1.E-12
+            L_qs(k) = .false.
+         endif
+
+         if (qg1d(k) .gt. 1.E-9) then
+            rg(k) = qg1d(k)*rho(k)
+            N0_g(k) = n0g
+            lamg = (xam_g*xcgg(3)*N0_g(k)/rg(k))**(1./xcge(1))
+            ilamg(k) = 1./lamg
+            L_qg(k) = .true.
+         else
+            rg(k) = 1.E-12
+            L_qg(k) = .false.
+         endif
+      enddo
+
+!+---+-----------------------------------------------------------------+
+!..Locate K-level of start of melting (k_0 is level above).
+!+---+-----------------------------------------------------------------+
+      melti = .false.
+      k_0 = kts
+      do k = kte-1, kts, -1
+         if ( (temp(k).gt.273.15) .and. L_qr(k)                         &amp;
+                                  .and. (L_qs(k+1).or.L_qg(k+1)) ) then
+            k_0 = MAX(k+1, k_0)
+            melti=.true.
+            goto 195
+         endif
+      enddo
+ 195  continue
+
+!+---+-----------------------------------------------------------------+
+!..Assume Rayleigh approximation at 10 cm wavelength. Rain (all temps)
+!.. and non-water-coated snow and graupel when below freezing are
+!.. simple. Integrations of m(D)*m(D)*N(D)*dD.
+!+---+-----------------------------------------------------------------+
+
+      do k = kts, kte
+         ze_rain(k) = 1.e-22
+         ze_snow(k) = 1.e-22
+         ze_graupel(k) = 1.e-22
+         if (L_qr(k)) ze_rain(k) = N0_r(k)*xcrg(4)*ilamr(k)**xcre(4)
+         if (L_qs(k)) ze_snow(k) = (0.176/0.93) * (6.0/PI)*(6.0/PI)     &amp;
+                                 * (xam_s/900.0)*(xam_s/900.0)          &amp;
+                                 * N0_s(k)*xcsg(4)*ilams(k)**xcse(4)
+         if (L_qg(k)) ze_graupel(k) = (0.176/0.93) * (6.0/PI)*(6.0/PI)  &amp;
+                                    * (xam_g/900.0)*(xam_g/900.0)       &amp;
+                                    * N0_g(k)*xcgg(4)*ilamg(k)**xcge(4)
+      enddo
+
+
+!+---+-----------------------------------------------------------------+
+!..Special case of melting ice (snow/graupel) particles.  Assume the
+!.. ice is surrounded by the liquid water.  Fraction of meltwater is
+!.. extremely simple based on amount found above the melting level.
+!.. Uses code from Uli Blahak (rayleigh_soak_wetgraupel and supporting
+!.. routines).
+!+---+-----------------------------------------------------------------+
+
+      if (melti .and. k_0.ge.kts+1) then
+       do k = k_0-1, kts, -1
+
+!..Reflectivity contributed by melting snow
+          if (L_qs(k) .and. L_qs(k_0) ) then
+           fmelt_s = MAX(0.005d0, MIN(1.0d0-rs(k)/rs(k_0), 0.99d0))
+           eta = 0.d0
+           lams = 1./ilams(k)
+           do n = 1, nrbins
+              x = xam_s * xxDs(n)**xbm_s
+              call rayleigh_soak_wetgraupel (x,DBLE(xocms),DBLE(xobms), &amp;
+                    fmelt_s, melt_outside_s, m_w_0, m_i_0, lamda_radar, &amp;
+                    CBACK, mixingrulestring_s, matrixstring_s,          &amp;
+                    inclusionstring_s, hoststring_s,                    &amp;
+                    hostmatrixstring_s, hostinclusionstring_s)
+              f_d = N0_s(k)*xxDs(n)**xmu_s * DEXP(-lams*xxDs(n))
+              eta = eta + f_d * CBACK * simpson(n) * xdts(n)
+           enddo
+           ze_snow(k) = SNGL(lamda4 / (pi5 * K_w) * eta)
+          endif
+
+
+!..Reflectivity contributed by melting graupel
+
+          if (L_qg(k) .and. L_qg(k_0) ) then
+           fmelt_g = MAX(0.005d0, MIN(1.0d0-rg(k)/rg(k_0), 0.99d0))
+           eta = 0.d0
+           lamg = 1./ilamg(k)
+           do n = 1, nrbins
+              x = xam_g * xxDg(n)**xbm_g
+              call rayleigh_soak_wetgraupel (x,DBLE(xocmg),DBLE(xobmg), &amp;
+                    fmelt_g, melt_outside_g, m_w_0, m_i_0, lamda_radar, &amp;
+                    CBACK, mixingrulestring_g, matrixstring_g,          &amp;
+                    inclusionstring_g, hoststring_g,                    &amp;
+                    hostmatrixstring_g, hostinclusionstring_g)
+              f_d = N0_g(k)*xxDg(n)**xmu_g * DEXP(-lamg*xxDg(n))
+              eta = eta + f_d * CBACK * simpson(n) * xdtg(n)
+           enddo
+           ze_graupel(k) = SNGL(lamda4 / (pi5 * K_w) * eta)
+          endif
+
+       enddo
+      endif
+
+      do k = kte, kts, -1
+         dBZ(k) = 10.*log10((ze_rain(k)+ze_snow(k)+ze_graupel(k))*1.d18)
+      enddo
+
+
+      end subroutine refl10cm_wsm6
+!+---+-----------------------------------------------------------------+
+
 END MODULE module_mp_wsm6

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_ra_rrtmg_sw.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_ra_rrtmg_sw.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_ra_rrtmg_sw.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -8544,8 +8544,14 @@
              taucmcl ,ssacmcl ,asmcmcl ,fsfcmcl , &amp;
              ciwpmcl ,clwpmcl ,reicmcl ,relqmcl , &amp;
              tauaer  ,ssaaer  ,asmaer  ,ecaer   , &amp;
-             swuflx  ,swdflx  ,swhr    ,swuflxc ,swdflxc ,swhrc)
+             swuflx  ,swdflx  ,swhr    ,swuflxc ,swdflxc ,swhrc,  &amp;
+! --------- Add the following four compenants for ssib shortwave down radiation ---!
+! -------------------      by Zhenxin 2011-06-20      --------------------------------!
+             sibvisdir, sibvisdif, sibnirdir, sibnirdif          &amp;
+                                                                )
+! ----------------------  End,  Zhenxin 2011-06-20    --------------------------------!
 
+
 ! ------- Description -------
 
 ! This program is the driver for RRTMG_SW, the AER SW radiation model for 
@@ -8743,6 +8749,14 @@
                                                       !    Dimensions: (ncol,nlay+1)
       real(kind=rb), intent(out) :: swdflx(:,:)       ! Total sky shortwave downward flux (W/m2)
                                                       !    Dimensions: (ncol,nlay+1)
+      real(kind=rb), intent(out) :: sibvisdir(:,:)    ! visible direct downward flux  (W/m2)
+                                                      !    Dimensions: (ncol,nlay+1) Zhenxin (2011/06/20)
+      real(kind=rb), intent(out) :: sibvisdif(:,:)    ! visible diffusion downward flux  (W/m2)
+                                                      !    Dimensions: (ncol,nlay+1) Zhenxin (2011/06/20)
+      real(kind=rb), intent(out) :: sibnirdir(:,:)    ! Near IR direct downward flux  (W/m2)
+                                                      !    Dimensions: (ncol,nlay+1)  Zhenxin (2011/06/20)
+      real(kind=rb), intent(out) :: sibnirdif(:,:)    ! Near IR diffusion downward flux  (W/m2)
+                                                      !    Dimensions: (ncol,nlay+1) Zhenxin (2011/06/20)
       real(kind=rb), intent(out) :: swhr(:,:)         ! Total sky shortwave radiative heating rate (K/d)
                                                       !    Dimensions: (ncol,nlay)
       real(kind=rb), intent(out) :: swuflxc(:,:)      ! Clear sky shortwave upward flux (W/m2)
@@ -9070,7 +9084,7 @@
                do ib = 1, nbndsw
                   ztaua(i,ib) = 0._rb
                   zasya(i,ib) = 0._rb
-                  zomga(i,ib) = 1._rb
+                  zomga(i,ib) = 0._rb
                   do ia = 1, naerec
                      ztaua(i,ib) = ztaua(i,ib) + rsrtaua(ib,ia) * ecaer(iplon,i,ia)
                      zomga(i,ib) = zomga(i,ib) + rsrtaua(ib,ia) * ecaer(iplon,i,ia) * &amp;
@@ -9142,15 +9156,24 @@
             swdflx(iplon,i) = zbbfd(i)
             uvdflx(i) = zuvfd(i)
             nidflx(i) = znifd(i)
+
 !  Direct/diffuse fluxes
             dirdflux(i) = zbbfddir(i)
             difdflux(i) = swdflx(iplon,i) - dirdflux(i)
 !  UV/visible direct/diffuse fluxes
             dirdnuv(i) = zuvfddir(i)
             difdnuv(i) = zuvfd(i) - dirdnuv(i)
+!  ------- Zhenxin add vis/uv downwards dir or dif here --!
+            sibvisdir(iplon,i) = dirdnuv(i)
+            sibvisdif(iplon,i) = difdnuv(i)
+!  ----- End of Zhenxin addition  ------------!
 !  Near-IR direct/diffuse fluxes
             dirdnir(i) = znifddir(i)
             difdnir(i) = znifd(i) - dirdnir(i)
+!  ---------Zhenxin add nir downwards dir and dif here --!
+            sibnirdir(iplon,i) = dirdnir(i)
+            sibnirdif(iplon,i) = difdnir(i)
+!  --------    End of Zhenxin addition 2011-05  ---------!
          enddo
 
 !  Total and clear sky net fluxes
@@ -9546,12 +9569,12 @@
 MODULE module_ra_rrtmg_sw
 
 #if defined(non_hydrostatic_core) || defined(hydrostatic_core)
-!MPAS specific (Laura D. Fowler):
+!MPAS specific (Laura D. Fowler - 2013-03-11):
 use mpas_atmphys_constants,only: cp
 #else
 use module_model_constants, only : cp
-use module_wrf_error
-!use module_dm
+USE module_wrf_error
+!USE module_dm
 #endif
 !MPAS specific end.
 
@@ -9584,7 +9607,19 @@
                        xland, xice, snow,                         &amp;
                        qv3d, qc3d, qr3d,                          &amp;
                        qi3d, qs3d, qg3d,                          &amp;
+                       alswvisdir, alswvisdif,                    &amp;  !Zhenxin ssib alb comp (06/20/2011)
+                       alswnirdir, alswnirdif,                    &amp;  !Zhenxin ssib alb comp (06/20/2011)
+                       swvisdir, swvisdif,                        &amp;  !Zhenxin ssib swr comp (06/20/2011)
+                       swnirdir, swnirdif,                        &amp;  !Zhenxin ssib swi comp (06/20/2011)
+                       sf_surface_physics,                        &amp;  !Zhenxin
                        f_qv, f_qc, f_qr, f_qi, f_qs, f_qg,        &amp;
+                       tauaer300,tauaer400,tauaer600,tauaer999,   &amp; ! czhao 
+                       gaer300,gaer400,gaer600,gaer999,           &amp; ! czhao 
+                       waer300,waer400,waer600,waer999,           &amp; ! czhao 
+                       aer_ra_feedback,                           &amp;
+!jdfcz                 progn,prescribe,                           &amp;
+                       progn,                                     &amp;
+                       qndrop3d,f_qndrop,                         &amp; !czhao
                        ids,ide, jds,jde, kds,kde,                 &amp; 
                        ims,ime, jms,jme, kms,kme,                 &amp;
                        its,ite, jts,jte, kts,kte,                 &amp;
@@ -9631,6 +9666,24 @@
                                                              TSK, &amp;
                                                           ALBEDO
 !
+!!! -------------------  Zhenxin (2011-06/20) ------------------
+   REAL, DIMENSION( ims:ime, jms:jme )                         , &amp;
+         OPTIONAL                                               , &amp;
+         INTENT(IN)     ::                            ALSWVISDIR, &amp;     ! ssib albedo of sw and lw
+                                                      ALSWVISDIF, &amp;
+                                                      ALSWNIRDIR, &amp;
+                                                      ALSWNIRDIF
+
+   REAL, DIMENSION( ims:ime, jms:jme )                         , &amp;
+         OPTIONAL                                               , &amp;
+         INTENT(OUT)    ::                              SWVISDIR, &amp;
+                                                        SWVISDIF, &amp;
+                                                        SWNIRDIR, &amp;
+                                                        SWNIRDIF        ! ssib sw dir and diff rad
+   INTEGER, INTENT(IN) :: sf_surface_physics                            ! ssib para
+
+!  ----------------------- end Zhenxin --------------------------
+!
    REAL, INTENT(IN  )   ::                                   R,G
 !
 ! Optional
@@ -9644,8 +9697,11 @@
                                                             QR3D, &amp;
                                                             QI3D, &amp;
                                                             QS3D, &amp;
-                                                            QG3D
+                                                            QG3D, &amp;
+                                                        QNDROP3D
 
+   real pi,third,relconst,lwpmin,rhoh2o
+
    REAL, DIMENSION( ims:ime, kms:kme, jms:jme )                 , &amp;
          OPTIONAL                                               , &amp;
          INTENT(IN   ) ::                                         &amp;
@@ -9653,8 +9709,30 @@
                                                       F_RAIN_PHY
 
    LOGICAL, OPTIONAL, INTENT(IN)   ::                             &amp;
-                                   F_QV,F_QC,F_QR,F_QI,F_QS,F_QG
+                                F_QV,F_QC,F_QR,F_QI,F_QS,F_QG,F_QNDROP
 
+! Optional
+   REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), OPTIONAL ,       &amp;
+         INTENT(IN    ) :: tauaer300,tauaer400,tauaer600,tauaer999, &amp; ! czhao 
+                                 gaer300,gaer400,gaer600,gaer999, &amp; ! czhao 
+                                 waer300,waer400,waer600,waer999    ! czhao 
+
+   INTEGER,    INTENT(IN  ), OPTIONAL   ::       aer_ra_feedback
+!jdfcz   INTEGER,    INTENT(IN  ), OPTIONAL   ::       progn,prescribe
+   INTEGER,    INTENT(IN  ), OPTIONAL   ::       progn
+
+      !wavelength corresponding to wavenum1 and wavenum2 (cm-1)
+      real, save :: wavemin(nbndsw) ! Min wavelength (um) of 14 intervals
+      data wavemin /3.077,2.500,2.150,1.942,1.626,1.299, &amp;
+      1.242,0.778,0.625,0.442,0.345,0.263,0.200,3.846/
+      real, save :: wavemax(nbndsw) ! Max wavelength (um) of interval
+      data wavemax/3.846,3.077,2.500,2.150,1.942,1.626, &amp;
+      1.299,1.242,0.778,0.625,0.442,0.345,0.263,12.195/
+      real wavemid(nbndsw) ! Mid wavelength (um) of interval
+      real, parameter :: thresh=1.e-9
+      real ang,slope
+      character(len=200) :: msg
+
 ! Top of atmosphere and surface shortwave fluxes (W m-2)
    REAL, DIMENSION( ims:ime, jms:jme ),                           &amp;
          OPTIONAL, INTENT(INOUT) ::                               &amp;
@@ -9663,8 +9741,7 @@
 
 ! Layer shortwave fluxes (including extra layer above model top)
 ! Vertical ordering is from bottom to top (W m-2)
-!  REAL, DIMENSION( ims:ime, kms:kme+2, jms:jme ),                &amp;
-   REAL, DIMENSION( ims:ime, kms:kme+1, jms:jme ),                &amp;
+   REAL, DIMENSION( ims:ime, kms:kme+2, jms:jme ),                &amp;
          OPTIONAL, INTENT(OUT) ::                                 &amp;
                                SWUPFLX,SWUPFLXC,SWDNFLX,SWDNFLXC
 
@@ -9683,7 +9760,8 @@
                                                             QR1D, &amp;
                                                             QI1D, &amp;
                                                             QS1D, &amp;
-                                                            QG1D
+                                                            QG1D, &amp;
+                                                          qndrop1d 
 
 ! Added local arrays for RRTMG
     integer ::                                              ncol, &amp;
@@ -9739,7 +9817,11 @@
     real, dimension( 1, kts:kte+2 )  ::                   swuflx, &amp;
                                                           swdflx, &amp;
                                                          swuflxc, &amp;
-                                                         swdflxc
+                                                         swdflxc, &amp;
+                                                       sibvisdir, &amp;  ! Zhenxin 2011-06-20
+                                                       sibvisdif, &amp;
+                                                       sibnirdir, &amp;
+                                                       sibnirdif     ! Zhenxin 2011-06-20
     real, dimension( 1, kts:kte+1 )  ::                     swhr, &amp;
                                                            swhrc
 
@@ -9822,6 +9904,26 @@
     LOGICAL :: predicate
 
 !------------------------------------------------------------------
+#ifdef WRF_CHEM
+      IF ( aer_ra_feedback == 1) then
+      IF ( .NOT. &amp;
+      ( PRESENT(tauaer300) .AND. &amp;
+        PRESENT(tauaer400) .AND. &amp;
+        PRESENT(tauaer600) .AND. &amp;
+        PRESENT(tauaer999) .AND. &amp;
+        PRESENT(gaer300) .AND. &amp;
+        PRESENT(gaer400) .AND. &amp;
+        PRESENT(gaer600) .AND. &amp;
+        PRESENT(gaer999) .AND. &amp;
+        PRESENT(waer300) .AND. &amp;
+        PRESENT(waer400) .AND. &amp;
+        PRESENT(waer600) .AND. &amp;
+        PRESENT(waer999) ) ) THEN
+      CALL wrf_error_fatal  &amp;
+      ('Warning: missing fields required for aerosol radiation' )
+      ENDIF
+      ENDIF
+#endif
 
 !-----CALCULATE SHORT WAVE RADIATION
 !                                                              
@@ -9850,6 +9952,7 @@
 !         clat(i) = xxlat
          coszrs = sin(xxlat) * sin(declin) + cos(xxlat) * cos(declin) * cos(hrang)
          coszr(i,j) = coszrs
+
 ! Set flag to prevent shortwave calculation when sun below horizon
          if (coszrs.le.0.0) dorrsw = .false.
 ! Perform shortwave calculation if sun above horizon
@@ -9867,6 +9970,7 @@
             QI1D(K)=0.
             QS1D(K)=0.
             CLDFRA1D(k)=0.
+            QNDROP1D(k)=0.
          ENDDO
 
          DO K=kts,kte
@@ -9908,6 +10012,14 @@
               ENDIF
             ENDIF
 
+            IF ( PRESENT(F_QNDROP).AND.PRESENT(QNDROP3D)) THEN
+             IF (F_QNDROP) THEN
+              DO K=kts,kte
+               qndrop1d(K)=qndrop3d(I,K,J)
+              ENDDO
+             ENDIF
+            ENDIF
+
 ! This logic is tortured because cannot test F_QI unless
 ! it is present, and order of evaluation of expressions
 ! is not specified in Fortran
@@ -10053,11 +10165,31 @@
 
 ! Set surface albedo for direct and diffuse radiation in UV/visible and
 ! near-IR spectral regions
+! -------------- Zhenxin 2011-06-20 ----------- !
+
+! ------- 1.  Commented by Zhenxin 2011-06-20 for SSiB coupling modified ---- !
+!         asdir(ncol) = albedo(i,j)
+!         asdif(ncol) = albedo(i,j)
+!         aldir(ncol) = albedo(i,j)
+!         aldif(ncol) = albedo(i,j)
+! -------    End of Comments    ------ !
+
+! ------- 2. New Addiation  ------ !
+    IF ( sf_surface_physics .eq. 8 .AND. XLAND(i,j) .LT. 1.5) THEN
+         asdir(ncol) = ALSWVISDIR(I,J)
+         asdif(ncol) = ALSWVISDIF(I,J)
+         aldir(ncol) = ALSWNIRDIR(I,J)
+         aldif(ncol) = ALSWNIRDIF(I,J)
+    ELSE
          asdir(ncol) = albedo(i,j)
          asdif(ncol) = albedo(i,j)
          aldir(ncol) = albedo(i,j)
          aldif(ncol) = albedo(i,j)
+    ENDIF
 
+! ---------- End of Addiation ------!
+! ----------  End of fds_Zhenxin 2011-06-20   --------------!
+
 ! Define cloud optical properties for radiation (inflgsw = 0)
 ! This option is not currently active
 ! Cloud and precipitation paths in g/m2 
@@ -10114,12 +10246,59 @@
                cliqwp(ncol,k) = gliqwp / max(0.01,cldfrac(ncol,k))               ! In-cloud liquid water path.
             end do
 
+!link the aerosol feedback to cloud  -czhao
+  if( PRESENT( progn ) ) then
+    if (progn == 1) then
+!jdfcz     if(prescribe==0) then
+
+      pi = 4.*atan(1.0)
+      third=1./3.
+      rhoh2o=1.e3
+      relconst=3/(4.*pi*rhoh2o)
+!     minimun liquid water path to calculate rel
+!     corresponds to optical depth of 1.e-3 for radius 4 microns.
+      lwpmin=3.e-5
+      do k = kts, kte
+         reliq(ncol,k) = 10.
+         if( PRESENT( F_QNDROP ) ) then
+            if( F_QNDROP ) then
+              if ( qc1d(k)*pdel(ncol,k).gt.lwpmin.and. &amp;
+                   qndrop1d(k).gt.1000. ) then
+               reliq(ncol,k)=(relconst*qc1d(k)/qndrop1d(k))**third ! effective radius in m
+!           apply scaling from Martin et al., JAS 51, 1830.
+               reliq(ncol,k)=1.1*reliq(ncol,k)
+               reliq(ncol,k)=reliq(ncol,k)*1.e6 ! convert from m to microns
+               reliq(ncol,k)=max(reliq(ncol,k),4.)
+               reliq(ncol,k)=min(reliq(ncol,k),20.)
+              end if
+            end if
+         end if
+      end do
+!jdfcz     else ! prescribe 
 ! following Kiehl
-            call relcalc(ncol, pcols, pver, tlay, landfrac, landm, icefrac, reliq, snowh)
+      call relcalc(ncol, pcols, pver, tlay, landfrac, landm, icefrac, reliq, snowh)
+!      write(0,*) 'sw prescribe aerosol',maxval(qndrop3d)
+!jdfcz     endif
+    else  ! progn   
+      call relcalc(ncol, pcols, pver, tlay, landfrac, landm, icefrac, reliq, snowh)
+    endif
+  else   !progn 
+      call relcalc(ncol, pcols, pver, tlay, landfrac, landm, icefrac, reliq, snowh)
+  endif
 
 ! following Kristjansson and Mitchell
-            call reicalc(ncol, pcols, pver, tlay, reice)
+      call reicalc(ncol, pcols, pver, tlay, reice)
 
+#if 0
+      if (i==80.and.j==30) then
+#if defined( DM_PARALLEL ) &amp;&amp; ! defined( STUBMPI) 
+      if( PRESENT( progn ) ) write(0,*) 'aerosol indirect',progn
+      write(0,*)'sw water eff radius',reliq(ncol,10),reliq(ncol,20),reliq(ncol,25)
+      write(0,*)'sw ice eff radius',reice(ncol,10),reice(ncol,20),reice(ncol,25)
+#endif
+      endif
+#endif
+
 ! Limit upper bound of reice for Fu ice parameterization and convert
 ! from effective radius to generalized effective size (*1.0315; Fu, 1996)
             if (iceflgsw .eq. 3) then
@@ -10172,17 +10351,111 @@
                        cldfmcl, ciwpmcl, clwpmcl, reicmcl, relqmcl, &amp;
                        taucmcl, ssacmcl, asmcmcl, fsfcmcl)
 
-! Aerosol optical depth, single scattering albedo and asymmetry parameter
+!--------------------------------------------------------------------------
+! Aerosol optical depth, single scattering albedo and asymmetry parameter -czhao 03/2010
+!--------------------------------------------------------------------------
 ! by layer for each RRTMG shortwave band
 ! No aerosols in top layer above model top (kte+1).
-         do nb = 1, nbndsw
-            do k = kts, kte+1
-               tauaer(ncol,k,nb) = 0.
-               ssaaer(ncol,k,nb) = 1.
-               asmaer(ncol,k,nb) = 0.
-            enddo
-         enddo
+!cz        do nb = 1, nbndsw
+!cz           do k = kts, kte+1
+!cz              tauaer(ncol,k,nb) = 0.
+!cz              ssaaer(ncol,k,nb) = 1.
+!cz              asmaer(ncol,k,nb) = 0.
+!cz           enddo
+!cz        enddo
 
+! ... Aerosol effects. Added aerosol feedbacks from Chem , 03/2010 -czhao
+!
+      do nb = 1, nbndsw
+      do k = kts,kte+1
+         tauaer(ncol,k,nb) = 0.
+         ssaaer(ncol,k,nb) = 1.
+         asmaer(ncol,k,nb) = 0.
+      end do
+      end do
+
+#ifdef WRF_CHEM
+   IF ( AER_RA_FEEDBACK == 1) then
+      do nb = 1, nbndsw
+         wavemid(nb)=0.5*(wavemin(nb)+wavemax(nb))  ! um
+      do k = kts,kte      !wig
+
+! convert optical properties at 300,400,600, and 999 to conform to the band wavelengths
+! tauaer - use angstrom exponent
+        if(tauaer300(i,k,j).gt.thresh .and. tauaer999(i,k,j).gt.thresh) then
+           ang=alog(tauaer300(i,k,j)/tauaer999(i,k,j))/alog(999./300.)
+           tauaer(ncol,k,nb)=tauaer400(i,k,j)*(0.4/wavemid(nb))**ang
+           !tauaer(ncol,k,nb)=tauaer600(i,k,j)*(0.6/wavemid(nb))**ang 
+           if (i==30.and.j==49.and.k==2.and.nb==12) then
+            write(0,*) 'TAU from 600 vs 400 in RRTMG',tauaer600(i,k,j),tauaer400(i,k,j)
+            print*, 'TAU from 600 vs 400 in RRTMG',tauaer600(i,k,j),tauaer400(i,k,j)
+            write(0,*) tauaer600(i,k,j)*(0.6/wavemid(nb))**ang,tauaer400(i,k,j)*(0.4/wavemid(nb))**ang
+            print*, tauaer600(i,k,j)*(0.6/wavemid(nb))**ang,tauaer400(i,k,j)*(0.4/wavemid(nb))**ang
+           endif
+! ssa - linear interpolation; extrapolation
+           slope=(waer600(i,k,j)-waer400(i,k,j))/.2
+           ssaaer(ncol,k,nb) = slope*(wavemid(nb)-.6)+waer600(i,k,j)
+           if(ssaaer(ncol,k,nb).lt.0.4) ssaaer(ncol,k,nb)=0.4
+           if(ssaaer(ncol,k,nb).ge.1.0) ssaaer(ncol,k,nb)=1.0
+! g - linear interpolation;extrapolation
+           slope=(gaer600(i,k,j)-gaer400(i,k,j))/.2
+           asmaer(ncol,k,nb) = slope*(wavemid(nb)-.6)+gaer600(i,k,j) ! notice reversed varaibles
+           if(asmaer(ncol,k,nb).lt.0.5) asmaer(ncol,k,nb)=0.5
+           if(asmaer(ncol,k,nb).ge.1.0) asmaer(ncol,k,nb)=1.0
+        endif
+      end do ! k
+      end do ! nb
+
+!wig beg
+      do nb = 1, nbndsw
+         slope = 0.  !use slope as a sum holder
+         do k = kts,kte
+            slope = slope + tauaer(ncol,k,nb)
+         end do
+         if( slope &lt; 0. ) then
+            write(msg,'(&quot;ERROR: Negative total optical depth of &quot;,f8.2,&quot; at point i,j,nb=&quot;,3i5)') slope,i,j,nb
+            call wrf_error_fatal(msg)
+         else if( slope &gt; 6. ) then
+            call wrf_message(&quot;-------------------------&quot;)
+            write(msg,'(&quot;WARNING: Large total sw optical depth of &quot;,f8.2,&quot; at point i,j,nb=&quot;,3i5)') slope,i,j,nb
+            call wrf_message(msg)
+
+            call wrf_message(&quot;Diagnostics 1: k, tauaer300, tauaer400, tauaer600, tauaer999, tauaer&quot;)
+            do k=kts,kte
+               write(msg,'(i4,5f8.2)') k, tauaer300(i,k,j), tauaer400(i,k,j), &amp;
+                    tauaer600(i,k,j), tauaer999(i,k,j),tauaer(ncol,k,nb)
+               call wrf_message(msg)
+               !czhao set an up-limit here to avoid segmentation fault 
+               !from extreme AOD
+               tauaer(ncol,k,nb)=tauaer(ncol,k,nb)*6.0/slope 
+            end do
+
+            call wrf_message(&quot;Diagnostics 2: k, gaer300, gaer400, gaer600, gaer999&quot;)
+            do k=kts,kte
+               write(msg,'(i4,4f8.2)') k, gaer300(i,k,j), gaer400(i,k,j), &amp;
+                    gaer600(i,k,j), gaer999(i,k,j)
+               call wrf_message(msg)
+            end do
+
+            call wrf_message(&quot;Diagnostics 3: k, waer300, waer400, waer600, waer999&quot;)
+            do k=kts,kte
+               write(msg,'(i4,4f8.2)') k, waer300(i,k,j), waer400(i,k,j), &amp;
+                    waer600(i,k,j), waer999(i,k,j)
+               call wrf_message(msg)
+            end do
+
+            call wrf_message(&quot;Diagnostics 4: k, ssaal, asyal, taual&quot;)
+            do k=kts-1,kte
+               write(msg,'(i4,3f8.2)') k, ssaaer(i,k,nb), asmaer(i,k,nb), tauaer(i,k,nb)
+               call wrf_message(msg)
+            end do
+            call wrf_message(&quot;-------------------------&quot;)
+         endif
+      enddo  ! nb
+      endif  ! aer_ra_feedback
+#endif
+
+
 ! Zero array for input of aerosol optical thickness for use with
 ! ECMWF aerosol types (not used)
          do na = 1, naerec
@@ -10203,7 +10476,11 @@
              taucmcl ,ssacmcl ,asmcmcl ,fsfcmcl , &amp;
              ciwpmcl ,clwpmcl ,reicmcl ,relqmcl , &amp;
              tauaer  ,ssaaer  ,asmaer  ,ecaer   , &amp;
-             swuflx  ,swdflx  ,swhr    ,swuflxc ,swdflxc ,swhrc)
+             swuflx  ,swdflx  ,swhr    ,swuflxc ,swdflxc ,swhrc, &amp;
+! -----          Zhenxin added for ssib coupiling 2011-06-20 --------!
+             sibvisdir, sibvisdif, sibnirdir, sibnirdif          &amp;
+                                                        )
+! --------------------   End of addiation by Zhenxin 2011-06-20 ------!
 
 ! Output net absorbed shortwave surface flux and shortwave cloud forcing
 ! at the top of atmosphere (W/m2)
@@ -10220,6 +10497,12 @@
             swupb(i,j)     = swuflx(1,1)
             swupbc(i,j)    = swuflxc(1,1)
             swdnb(i,j)     = swdflx(1,1)
+! Added by Zhenxin for 4 compenants of swdown radiation
+            swvisdir(i,j)  = sibvisdir(1,1)
+            swvisdif(i,j)  = sibvisdif(1,1)
+            swnirdir(i,j)  = sibnirdir(1,1)
+            swnirdif(i,j)  = sibnirdif(1,1)
+!  Ended, Zhenxin (2011/06/20)
             swdnbc(i,j)    = swdflxc(1,1)
          endif
 
@@ -10252,6 +10535,10 @@
             swupbc(i,j)    = 0.
             swdnb(i,j)     = 0.
             swdnbc(i,j)    = 0.
+            swvisdir(i,j)  = 0.  ! Add by Zhenxin (2011/06/20)
+            swvisdif(i,j)  = 0.
+            swnirdir(i,j)  = 0.
+            swnirdif(i,j)  = 0.  ! Add by Zhenxin (2011/06/20)
          endif
 
       endif
@@ -10264,15 +10551,14 @@
 
    END SUBROUTINE RRTMG_SWRAD
 

-!ldf (12-20-2010): This section of the module is moved to module_physics_rrtmg_swinit.F in
+!ldf (2013-03-11): This section of the module is moved to module_physics_rrtmg_swinit.F in
 !./../core_physics to accomodate differences in the mpi calls between WRF and MPAS.I thought
 !that it would be cleaner to do this instead of adding a lot of #ifdef statements throughout
 !the initialization of the shortwave radiation code. Initialization is handled the same way
 !for the longwave radiation code.
 
 #if !(defined(non_hydrostatic_core) || defined(hydrostatic_core))
-

 !====================================================================
    SUBROUTINE rrtmg_swinit(                                         &amp;
                        allowed_to_read ,                            &amp;
@@ -10325,11 +10611,7 @@
         rrtmg_unit = -1
  2010   CONTINUE
       ENDIF
-!ldf (11-08-2010): changed wrf_dm_bcast_bytes to wrf_dm_bcast_integer to avoid warning at
-!compilation time:
-!     CALL wrf_dm_bcast_bytes ( rrtmg_unit , IWORDSIZE )
-      CALL wrf_dm_bcast_integer ( rrtmg_unit , IWORDSIZE )
-!ldf end.
+      CALL wrf_dm_bcast_bytes ( rrtmg_unit , IWORDSIZE )
       IF ( rrtmg_unit &lt; 0 ) THEN
         CALL wrf_error_fatal ( 'module_ra_rrtmg_sw: rrtm_swlookuptable: Can not '// &amp;
                                'find unused fortran unit to read in lookup table.' )
@@ -11454,6 +11736,6 @@
 !------------------------------------------------------------------
 
 #endif
-!ldf end (12-20-2010).
+!ldf end (2013-03-11).
 
 END MODULE module_ra_rrtmg_sw

Modified: branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_sf_sfclay.F
===================================================================
--- branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_sf_sfclay.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_atmos_physics/physics_wrf/module_sf_sfclay.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -14,6 +14,7 @@
    SUBROUTINE SFCLAY(U3D,V3D,T3D,QV3D,P3D,dz8w,                    &amp;
                      CP,G,ROVCP,R,XLV,PSFC,CHS,CHS2,CQS2,CPM,      &amp;
                      ZNT,UST,PBLH,MAVAIL,ZOL,MOL,REGIME,PSIM,PSIH, &amp;
+                     FM,FH,                                        &amp;
                      XLAND,HFX,QFX,LH,TSK,FLHC,FLQC,QGH,QSFC,RMOL, &amp;
                      U10,V10,TH2,T2,Q2,                            &amp;
                      GZ1OZ0,WSPD,BR,ISFFLX,DX,                     &amp;
@@ -23,7 +24,11 @@
                      ids,ide, jds,jde, kds,kde,                    &amp;
                      ims,ime, jms,jme, kms,kme,                    &amp;
                      its,ite, jts,jte, kts,kte,                    &amp;
-                     ustm,ck,cka,cd,cda,isftcflx,iz0tlnd,areaCell  )
+                     ustm,ck,cka,cd,cda,isftcflx,iz0tlnd,scm_force_flux &amp;
+#if defined(non_hydrostatic_core) || defined(hydrostatic_core)
+                    ,areaCell                                      &amp;
+#endif
+                    )
 !-------------------------------------------------------------------
       IMPLICIT NONE
 !-------------------------------------------------------------------
@@ -50,6 +55,8 @@
 !-- REGIME      flag indicating PBL regime (stable, unstable, etc.)
 !-- PSIM        similarity stability function for momentum
 !-- PSIH        similarity stability function for heat
+!-- FM          integrated stability function for momentum
+!-- FH          integrated stability function for heat
 !-- XLAND       land mask (1 for land, 2 for water)
 !-- HFX         upward heat flux at the surface (W/m^2)
 !-- QFX         upward moisture flux at the surface (kg/m^2/s)
@@ -146,7 +153,7 @@
 !
       REAL,     DIMENSION( ims:ime, jms:jme )                    , &amp;
                 INTENT(INOUT)   ::                 GZ1OZ0,WSPD,BR, &amp;
-                                                        PSIM,PSIH
+                                                  PSIM,PSIH,FM,FH
 
       REAL,     DIMENSION( ims:ime, kms:kme, jms:jme )           , &amp;
                 INTENT(IN   )   ::                            U3D, &amp;
@@ -175,16 +182,18 @@
                                     
       REAL,     INTENT(IN   )               ::   CP,G,ROVCP,R,XLV,DX
  
-!MPAS specific (Laura D. Fowler):
-!     REAL, OPTIONAL, DIMENSION( ims:ime, jms:jme )              , &amp;
-!               INTENT(OUT)     ::              ck,cka,cd,cda,ustm
-      real, optional, dimension( ims:ime, jms:jme )              , &amp;
-                intent(inout)     ::              ck,cka,cd,cda,ustm
+      REAL, OPTIONAL, DIMENSION( ims:ime, jms:jme )              , &amp;
+                INTENT(OUT)     ::              ck,cka,cd,cda,ustm
+
+      INTEGER,  OPTIONAL,  INTENT(IN )   ::     ISFTCFLX, IZ0TLND
+      INTEGER,  OPTIONAL,  INTENT(IN )   ::     SCM_FORCE_FLUX
+
+#if defined(non_hydrostatic_core) || defined(hydrostatic_core)
+!MPAS specific (Laura D. Fowler - 2013-03-06):
       real,intent(in),dimension(ims:ime,jms:jme),optional:: areaCell
 !MPAS specific end.
+#endif
 
-      INTEGER,  OPTIONAL,  INTENT(IN )   ::     ISFTCFLX, IZ0TLND
-
 ! LOCAL VARS
 
       REAL,     DIMENSION( its:ite ) ::                       U1D, &amp;
@@ -218,6 +227,7 @@
                 CQS2(ims,j),CPM(ims,j),PBLH(ims,j), RMOL(ims,j),   &amp;
                 ZNT(ims,j),UST(ims,j),MAVAIL(ims,j),ZOL(ims,j),    &amp;
                 MOL(ims,j),REGIME(ims,j),PSIM(ims,j),PSIH(ims,j),  &amp;
+                FM(ims,j),FH(ims,j),                               &amp;
                 XLAND(ims,j),HFX(ims,j),QFX(ims,j),TSK(ims,j),     &amp;
                 U10(ims,j),V10(ims,j),TH2(ims,j),T2(ims,j),        &amp;
                 Q2(ims,j),FLHC(ims,j),FLQC(ims,j),QGH(ims,j),      &amp;
@@ -229,26 +239,26 @@
                 ims,ime, jms,jme, kms,kme,                         &amp;
                 its,ite, jts,jte, kts,kte                          &amp;
 #if defined(non_hydrostatic_core) || defined(hydrostatic_core)
-!MPAS specific (Laura D. Fowler):
-               ,isftcflx,iz0tlnd,                                  &amp;
+!MPAS specific (Laura D. Fowler - 2013-03-06):
+               ,isftcflx,iz0tlnd,scm_force_flux,                   &amp;
                USTM(ims,j),CK(ims,j),CKA(ims,j),                   &amp;
                CD(ims,j),CDA(ims,j),areaCell(ims,j)                &amp;
-!#elseif ( EM_CORE == 1 )
-!               ,isftcflx,iz0tlnd,                                 &amp;
-!               USTM(ims,j),CK(ims,j),CKA(ims,j),                  &amp;
-!               CD(ims,j),CDA(ims,j)                               &amp;
+#elif ( EM_CORE == 1 )
+                ,isftcflx,iz0tlnd,scm_force_flux,                  &amp;
+                USTM(ims,j),CK(ims,j),CKA(ims,j),                  &amp;
+                CD(ims,j),CDA(ims,j)                               &amp;
 #endif
                                                                    )
       ENDDO
 
-

    END SUBROUTINE SFCLAY
 
 
 !-------------------------------------------------------------------
    SUBROUTINE SFCLAY1D(J,UX,VX,T1D,QV1D,P1D,dz8w1d,                &amp;
                      CP,G,ROVCP,R,XLV,PSFCPA,CHS,CHS2,CQS2,CPM,PBLH,RMOL, &amp;
-                     ZNT,UST,MAVAIL,ZOL,MOL,REGIME,PSIM,PSIH,      &amp;
+                     ZNT,UST,MAVAIL,ZOL,MOL,REGIME,PSIM,PSIH,FM,FH,&amp;
                      XLAND,HFX,QFX,TSK,                            &amp;
                      U10,V10,TH2,T2,Q2,FLHC,FLQC,QGH,              &amp;
                      QSFC,LH,GZ1OZ0,WSPD,BR,ISFFLX,DX,             &amp;
@@ -258,9 +268,14 @@
                      ids,ide, jds,jde, kds,kde,                    &amp;
                      ims,ime, jms,jme, kms,kme,                    &amp;
                      its,ite, jts,jte, kts,kte,                    &amp;
-                     isftcflx, iz0tlnd,                            &amp;
-                     ustm,ck,cka,cd,cda,                           &amp;
-                     areaCell)
+                     isftcflx, iz0tlnd, scm_force_flux,            &amp;
+#if defined(non_hydrostatic_core) || defined(hydrostatic_core)
+!MPAS specific (Laura D. Fowler - 2013-03-06):
+                     ustm,ck,cka,cd,cda,areaCell                   )
+#else
+                     ustm,ck,cka,cd,cda                            )
+#endif
+
 !-------------------------------------------------------------------
       IMPLICIT NONE
 !-------------------------------------------------------------------
@@ -296,7 +311,7 @@
 !
       REAL,     DIMENSION( ims:ime )                             , &amp;
                 INTENT(INOUT)   ::                 GZ1OZ0,WSPD,BR, &amp;
-                                                        PSIM,PSIH
+                                                  PSIM,PSIH,FM,FH
 
       REAL,     DIMENSION( ims:ime )                             , &amp;
                 INTENT(INOUT)   ::                            ZNT, &amp;
@@ -334,11 +349,14 @@
                 INTENT(OUT)     ::              ck,cka,cd,cda,ustm
 
       INTEGER,  OPTIONAL,  INTENT(IN )   ::     ISFTCFLX, IZ0TLND
+      INTEGER,  OPTIONAL,  INTENT(IN )   ::     SCM_FORCE_FLUX
 
-!MPAS specific (Laura D. Fowler): We take into accound the actual size of individual
-!grid-boxes:
+#if defined(non_hydrostatic_core) || defined(hydrostatic_core)
+!MPAS specific (Laura D. Fowler - 2013-03-06):
       real,intent(in),dimension(ims:ime),optional:: areaCell
 !MPAS specific end.
+#endif
+      
 
 ! LOCAL VARS
 
@@ -372,6 +390,7 @@
       REAL    ::  ZL,TSKV,DTHVDZ,DTHVM,VCONV,RZOL,RZOL2,RZOL10,ZOL2,ZOL10
       REAL    ::  DTG,PSIX,DTTHX,PSIX10,PSIT,PSIT2,PSIQ,PSIQ2,PSIQ10
       REAL    ::  FLUXC,VSGD,Z0Q,VISC,RESTAR,CZIL,RESTAR2
+      REAL    ::  ZW, ZN1, ZN2
 !-------------------------------------------------------------------
       KL=kte
 
@@ -511,8 +530,6 @@
         else
            VSGD = 0.32 * (max(dx/5000.-1.,0.))**.33
         endif
-!       write(0,201) i,areaCell(i),vsgd
-!       201 format(i8,2(1x,e15.8))
 !MPAS specific end.
         WSPD(I)=SQRT(WSPD(I)*WSPD(I)+VCONV*VCONV+vsgd*vsgd)
         WSPD(I)=AMAX1(WSPD(I),0.1)
@@ -523,7 +540,7 @@
         RMOL(I)=-GOVRTH(I)*DTHVDZ*ZA(I)*KARMAN
 !jdf
 
-  260 CONTINUE
+  260 CONTINUE                                                                   
 
 !                                                                                
 !-----DIAGNOSE BASIC PARAMETERS FOR THE APPROPRIATED STABILITY CLASS:            
@@ -782,20 +799,25 @@
         DENOMQ(I)=PSIQ
         DENOMQ2(I)=PSIQ2
         DENOMT2(I)=PSIT2
+        FM(I)=PSIX
+        FH(I)=PSIT
   330 CONTINUE                                                                   
 !                                                                                
   335 CONTINUE                                                                   
                                                                                   
 !-----COMPUTE THE SURFACE SENSIBLE AND LATENT HEAT FLUXES:                       
-                                                                                 
+      IF ( PRESENT(SCM_FORCE_FLUX) ) THEN
+         IF (SCM_FORCE_FLUX.EQ.1) GOTO 350              
+      ENDIF
       DO i=its,ite
         QFX(i)=0.                                                              
         HFX(i)=0.                                                              
       ENDDO
+  350 CONTINUE
 
       IF (ISFFLX.EQ.0) GOTO 410                                                
                                                                                  
-!-----OVER WATER, ALTER ROUGHNESS LENGTH (ZNT) ACCORDING TO WIND (UST).          
+!-----OVER WATER, ALTER ROUGHNESS LENGTH (ZNT) ACCORDING TO WIND (UST).
                                                                                  
       DO 360 I=its,ite
         IF((XLAND(I)-1.5).GE.0)THEN                                            
@@ -804,8 +826,16 @@
           IF ( PRESENT(ISFTCFLX) ) THEN
              IF ( ISFTCFLX.NE.0 ) THEN
 !               ZNT(I)=10.*exp(-9.*UST(I)**(-.3333))
-                ZNT(I)=10.*exp(-9.5*UST(I)**(-.3333))
-                ZNT(I)=ZNT(I) + 0.11*1.5E-5/AMAX1(UST(I),0.01)
+!               ZNT(I)=10.*exp(-9.5*UST(I)**(-.3333))
+!               ZNT(I)=ZNT(I) + 0.11*1.5E-5/AMAX1(UST(I),0.01)
+!               ZNT(I)=0.011*UST(I)*UST(I)/G+OZO
+!               ZNT(I)=MAX(ZNT(I),3.50e-5)
+! AHW 2012:
+                ZW  = MIN((UST(I)/1.06)**(0.3),1.0)
+                ZN1 = 0.011*UST(I)*UST(I)/G + OZO
+                ZN2 = 10.*exp(-9.5*UST(I)**(-.3333)) + &amp;
+                       0.11*1.5E-5/AMAX1(UST(I),0.01)
+                ZNT(I)=(1.0-ZW) * ZN1 + ZW * ZN2
                 ZNT(I)=MIN(ZNT(I),2.85e-3)
                 ZNT(I)=MAX(ZNT(I),1.27e-7)
              ENDIF
@@ -825,13 +855,16 @@
         ELSE                                                                     
           FLHC(I)=0.                                                             
         ENDIF                                                                    
-  360 CONTINUE                                                                   
+  360 CONTINUE
 
 !                                                                                
-!-----COMPUTE SURFACE MOIST FLUX:                                                
-!                                                                                
-!     IF(IDRY.EQ.1)GOTO 390                                                
-!                                                                                
+!-----COMPUTE SURFACE MOIST FLUX:                                               
+!
+!     IF(IDRY.EQ.1)GOTO 390
+     IF ( PRESENT(SCM_FORCE_FLUX) ) THEN
+        IF (SCM_FORCE_FLUX.EQ.1) GOTO 405                                     
+     ENDIF
+!                                                                               
       DO 370 I=its,ite
         QFX(I)=FLQC(I)*(QSFC(I)-QX(I))                                     
         QFX(I)=AMAX1(QFX(I),0.)                                            
@@ -855,6 +888,8 @@
           HFX(I)=AMAX1(HFX(I),-250.)                                       
         ENDIF                                                                  
   400 CONTINUE                                                                 
+
+  405 CONTINUE                                                                 
          
       DO I=its,ite
          IF((XLAND(I)-1.5).GE.0)THEN

Deleted: branches/mpas_cdg_advection/src/core_hyd_atmos/Registry
===================================================================
--- branches/mpas_cdg_advection/src/core_hyd_atmos/Registry        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_hyd_atmos/Registry        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,191 +0,0 @@
-%
-% namelist  type  namelist_record  name  default_value
-%
-namelist integer   sw_model config_test_case            5
-namelist character sw_model config_time_integration     SRK3
-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 real      sw_model config_h_mom_eddy_visc2     0.0
-namelist real      sw_model config_h_mom_eddy_visc4     0.0
-namelist real      sw_model config_v_mom_eddy_visc2     0.0
-namelist real      sw_model config_h_theta_eddy_visc2   0.0
-namelist real      sw_model config_h_theta_eddy_visc4   0.0
-namelist real      sw_model config_v_theta_eddy_visc2   0.0
-namelist integer   sw_model config_number_of_sub_steps  4
-namelist integer   sw_model config_theta_adv_order      2
-namelist integer   sw_model config_scalar_adv_order     2
-namelist logical   sw_model config_positive_definite    false
-namelist logical   sw_model config_monotonic            true
-namelist integer   sw_model config_mp_physics           0
-namelist real      sw_model config_apvm_upwinding       0.5
-namelist integer   sw_model config_num_halos            2
-namelist integer   dimensions config_nvertlevels        26
-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      06:00:00
-namelist integer   io       config_frames_per_outfile   0
-namelist integer   io       config_pio_num_iotasks      0 
-namelist integer   io       config_pio_stride           1
-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
-
-%
-% dim  type  name_in_file  name_in_code
-%
-dim nCells nCells
-dim nEdges nEdges
-dim maxEdges maxEdges
-dim maxEdges2 maxEdges2
-dim nVertices nVertices
-dim TWO 2
-dim vertexDegree vertexDegree
-dim FIFTEEN 15
-dim TWENTYONE 21
-dim R3 3
-%dim nVertLevels nVertLevels
-dim nVertLevels namelist:config_nvertlevels
-%dim nTracers nTracers
-dim nVertLevelsP1 nVertLevels+1
-
-%
-% var persistence type  name_in_file  ( dims )  time_levs iro-  name_in_code struct super-array array_class
-%
-var persistent text    xtime ( Time ) 2 ro xtime state - -
-
-var persistent real    latCell ( nCells ) 0 iro latCell mesh - -
-var persistent real    lonCell ( nCells ) 0 iro lonCell mesh - -
-var persistent real    xCell ( nCells ) 0 iro xCell mesh - -
-var persistent real    yCell ( nCells ) 0 iro yCell mesh - -
-var persistent real    zCell ( nCells ) 0 iro zCell mesh - -
-var persistent integer indexToCellID ( nCells ) 0 iro indexToCellID mesh - -
-
-var persistent real    latEdge ( nEdges ) 0 iro latEdge mesh - -
-var persistent real    lonEdge ( nEdges ) 0 iro lonEdge mesh - -
-var persistent real    xEdge ( nEdges ) 0 iro xEdge mesh - -
-var persistent real    yEdge ( nEdges ) 0 iro yEdge mesh - -
-var persistent real    zEdge ( nEdges ) 0 iro zEdge mesh - -
-var persistent integer indexToEdgeID ( nEdges ) 0 iro indexToEdgeID mesh - -
-
-var persistent real    latVertex ( nVertices ) 0 iro latVertex mesh - -
-var persistent real    lonVertex ( nVertices ) 0 iro lonVertex mesh - -
-var persistent real    xVertex ( nVertices ) 0 iro xVertex mesh - -
-var persistent real    yVertex ( nVertices ) 0 iro yVertex mesh - -
-var persistent real    zVertex ( nVertices ) 0 iro zVertex mesh - -
-var persistent integer indexToVertexID ( nVertices ) 0 iro indexToVertexID mesh - -
-
-var persistent integer cellsOnEdge ( TWO nEdges ) 0 iro cellsOnEdge mesh - -
-var persistent integer nEdgesOnCell ( nCells ) 0 iro nEdgesOnCell mesh - -
-var persistent integer nEdgesOnEdge ( nEdges ) 0 iro nEdgesOnEdge mesh - -
-var persistent integer edgesOnCell ( maxEdges nCells ) 0 iro edgesOnCell mesh - -
-var persistent integer edgesOnEdge ( maxEdges2 nEdges ) 0 iro edgesOnEdge mesh - -
-
-var persistent real    weightsOnEdge ( maxEdges2 nEdges ) 0 iro weightsOnEdge mesh - -
-var persistent real    dvEdge ( nEdges ) 0 iro dvEdge mesh - -
-var persistent real    dcEdge ( nEdges ) 0 iro dcEdge mesh - -
-var persistent real    angleEdge ( nEdges ) 0 iro angleEdge mesh - -
-var persistent real    areaCell ( nCells ) 0 iro areaCell mesh - -
-var persistent real    areaTriangle ( nVertices ) 0 iro areaTriangle mesh - -
-
-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 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 - -
-var persistent integer verticesOnEdge ( TWO nEdges ) 0 iro verticesOnEdge mesh - -
-var persistent integer edgesOnVertex ( vertexDegree nVertices ) 0 iro edgesOnVertex mesh - -
-var persistent integer cellsOnVertex ( vertexDegree nVertices ) 0 iro cellsOnVertex mesh - -
-var persistent real    kiteAreasOnVertex ( vertexDegree nVertices ) 0 iro kiteAreasOnVertex mesh - -
-var persistent real    fEdge ( nEdges ) 0 iro fEdge mesh - -
-var persistent real    fVertex ( nVertices ) 0 iro fVertex mesh - -
-var persistent real    h_s ( nCells ) 0 iro h_s mesh - -
-
-% description of the vertical grid structure
-var persistent real    rdnu ( nVertLevels ) 0 iro rdnu mesh - -
-var persistent real    rdnw ( nVertLevels ) 0 iro rdnw mesh - -
-var persistent real    fnm ( nVertLevels ) 0 iro fnm mesh - -
-var persistent real    fnp ( nVertLevels ) 0 iro fnp mesh - -
-var persistent real    dbn ( nVertLevels ) 0 iro dbn mesh - -
-var persistent real    dnu ( nVertLevels ) 0 iro dnu mesh - -
-var persistent real    dnw ( nVertLevels ) 0 iro dnw mesh - -
-
-% Prognostic variables: read from input, saved in restart, and written to output
-var persistent real    u ( nVertLevels nEdges Time ) 2 iro u state - -
-var persistent real    theta ( nVertLevels nCells Time ) 2 iro theta state - -
-var persistent real    surface_pressure ( nCells Time ) 2 iro surface_pressure state - -
-var persistent real    qv ( nVertLevels nCells Time ) 2 iro qv state scalars moist
-var persistent real    qc ( nVertLevels nCells Time ) 2 iro qc state scalars moist
-var persistent real    qr ( nVertLevels nCells Time ) 2 iro qr state scalars moist
-%var persistent real    tracers ( nTracers nVertLevels nCells Time ) 2 iro state tracers - -
-
-% state variables diagnosed from prognostic state
-var persistent real    h ( nVertLevels nCells Time ) 2 ro h state - -
-var persistent real    ww ( nVertLevelsP1 nCells Time ) 2 ro ww state - -
-var persistent real    w ( nVertLevelsP1 nCells Time ) 2 ro w state - -
-var persistent real    pressure ( nVertLevelsP1 nCells Time ) 2 ro pressure state - -
-var persistent real    geopotential ( nVertLevelsP1 nCells Time ) 2 ro geopotential state - -
-var persistent real    alpha ( nVertLevels nCells Time ) 2 iro alpha state - -
-
-% Diagnostic fields: only written to output
-var persistent real    v ( nVertLevels nEdges Time ) 2 o v state - -
-var persistent real    divergence ( nVertLevels nCells Time ) 2 o divergence state - -
-var persistent real    vorticity ( nVertLevels nVertices Time ) 2 o vorticity state - -
-var persistent real    pv_edge ( nVertLevels nEdges Time ) 2 o pv_edge state - -
-var persistent real    h_edge ( nVertLevels nEdges Time ) 2 o h_edge state - -
-var persistent real    ke ( nVertLevels nCells Time ) 2 o ke state - -
-var persistent real    pv_vertex ( nVertLevels nVertices Time ) 2 o pv_vertex state - -
-var persistent real    pv_cell ( nVertLevels nCells Time ) 2 o pv_cell state - -
-var persistent real    uReconstructX ( nVertLevels nCells Time ) 1 o uReconstructX diag - -
-var persistent real    uReconstructY ( nVertLevels nCells Time ) 1 o uReconstructY diag - -
-var persistent real    uReconstructZ ( nVertLevels nCells Time ) 1 o uReconstructZ diag - -
-var persistent real    uReconstructZonal ( nVertLevels nCells Time ) 1 o uReconstructZonal diag - -
-var persistent real    uReconstructMeridional ( nVertLevels nCells Time ) 1 o uReconstructMeridional diag - -
-
-% Tendency variables
-var persistent real    tend_h ( nVertLevels nCells Time ) 1 - h tend - -
-var persistent real    tend_u ( nVertLevels nEdges Time ) 1 - u tend - -
-var persistent real    tend_vh ( nVertLevels nEdges Time ) 1 - vh tend - -
-var persistent real    tend_theta ( nVertLevels nCells Time ) 1 - theta tend - -
-var persistent real    tend_qv ( nVertLevels nCells Time ) 1 - qv tend scalars moist
-var persistent real    tend_qc ( nVertLevels nCells Time ) 1 - qc tend scalars moist
-var persistent real    tend_qr ( nVertLevels nCells Time ) 1 - qr tend scalars moist
-
-% Other diagnostic variables: neither read nor written to any files
-var persistent real    vh ( nVertLevels nEdges Time ) 2 - vh state - -
-var persistent real    circulation ( nVertLevels nVertices Time ) 2 - circulation state - -
-var persistent real    gradPVt ( nVertLevels nEdges Time ) 2 - gradPVt state - -
-var persistent real    gradPVn ( nVertLevels nEdges Time ) 2 - gradPVn state - -
-
-var persistent real    uhAvg ( nVertLevels nEdges ) 0 - uhAvg mesh - -
-var persistent real    wwAvg ( nVertLevelsP1 nCells ) 0 - wwAvg mesh - -
-var persistent real    qtot ( nVertLevels nCells ) 0 - qtot mesh - -
-var persistent real    cqu  ( nVertLevels nEdges ) 0 - cqu mesh - -
-var persistent real    h_diabatic  ( nVertLevels nCells ) 0 - h_diabatic mesh - -
-var persistent real    dpsdt ( nCells ) 0 - dpsdt mesh - -
-
-var persistent real    u_old ( nVertLevels nEdges ) 0 - u_old mesh - -
-var persistent real    ww_old ( nVertLevelsP1 nCells ) 0 - ww_old mesh - -
-var persistent real    theta_old ( nVertLevels nCells ) 0 - theta_old mesh - -
-var persistent real    h_edge_old ( nVertLevels nEdges ) 0 - h_edge_old mesh - -
-var persistent real    h_old ( nVertLevels nCells ) 0 - h_old mesh - -
-var persistent real    pressure_old ( nVertLevelsP1 nCells ) 0 - pressure_old mesh - -
-var persistent real    qv_old ( nVertLevels nCells ) 0 - qv_old mesh scalars_old moist_old
-var persistent real    qc_old ( nVertLevels nCells ) 0 - qc_old mesh scalars_old moist_old
-var persistent real    qr_old ( nVertLevels nCells ) 0 - qr_old mesh scalars_old moist_old
-%var persistent real    tracers_old ( nTracers nVertLevels nCells ) 0 - tracers_old mesh - -
-
-% Space needed for advection
-var persistent real    deriv_two ( FIFTEEN TWO nEdges ) 0 o deriv_two mesh - -
-var persistent integer advCells ( TWENTYONE nCells ) 0 - advCells mesh - -
-
-% Arrays required for reconstruction of velocity field
-var persistent real    coeffs_reconstruct ( R3 maxEdges nCells ) 0 - coeffs_reconstruct mesh - -
-

Copied: branches/mpas_cdg_advection/src/core_hyd_atmos/Registry.xml (from rev 2782, trunk/mpas/src/core_hyd_atmos/Registry.xml)
===================================================================
--- branches/mpas_cdg_advection/src/core_hyd_atmos/Registry.xml                                (rev 0)
+++ branches/mpas_cdg_advection/src/core_hyd_atmos/Registry.xml        2013-04-22 01:31:32 UTC (rev 2783)
@@ -0,0 +1,179 @@
+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;registry model=&quot;mpas&quot; core=&quot;hyd_atmos&quot; version=&quot;0.0.0&quot;&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;

Modified: branches/mpas_cdg_advection/src/core_init_nhyd_atmos/Makefile
===================================================================
--- branches/mpas_cdg_advection/src/core_init_nhyd_atmos/Makefile        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_init_nhyd_atmos/Makefile        2013-04-22 01:31:32 UTC (rev 2783)
@@ -8,6 +8,8 @@
        mpas_init_atm_bitarray.o \
        mpas_init_atm_queue.o \
        mpas_init_atm_hinterp.o \
+       mpas_init_atm_static.o \
+       mpas_init_atm_surface.o \
        read_geogrid.o \
        mpas_atmphys_date_time.o \
        mpas_atmphys_initialize_real.o \
@@ -18,8 +20,15 @@
 core_hyd: $(OBJS)
         ar -ru libdycore.a $(OBJS)
 
-mpas_init_atm_test_cases.o: mpas_atm_advection.o mpas_init_atm_read_met.o read_geogrid.o mpas_init_atm_llxy.o mpas_init_atm_hinterp.o \
-                                        mpas_atmphys_initialize_real.o
+mpas_init_atm_test_cases.o: \
+        read_geogrid.o \
+        mpas_atm_advection.o \
+        mpas_init_atm_read_met.o \
+        mpas_init_atm_llxy.o \
+        mpas_init_atm_hinterp.o \
+        mpas_init_atm_static.o \
+        mpas_init_atm_surface.o \
+        mpas_atmphys_initialize_real.o
 
 mpas_init_atm_hinterp.o: mpas_init_atm_queue.o mpas_init_atm_bitarray.o
 
@@ -33,10 +42,19 @@
 
 mpas_init_atm_mpas_core.o: mpas_advection.o mpas_init_atm_test_cases.o
 
+mpas_init_atm_static.o: \
+        mpas_atm_advection.o \
+        mpas_init_atm_hinterp.o \
+        mpas_init_atm_llxy.o \
+        mpas_atmphys_utilities.o
+
+mpas_init_atm_surface.o: \
+        mpas_init_atm_hinterp.o  \
+        mpas_init_atm_llxy.o     \
+        mpas_init_atm_read_met.o
+
 mpas_atmphys_initialize_real.o:  \
-        mpas_init_atm_hinterp.o           \
-        mpas_init_atm_llxy.o              \
-        mpas_init_atm_read_met.o          \
+        mpas_init_atm_surface.o  \
         mpas_atmphys_date_time.o \
         mpas_atmphys_utilities.o
 

Deleted: branches/mpas_cdg_advection/src/core_init_nhyd_atmos/Registry
===================================================================
--- branches/mpas_cdg_advection/src/core_init_nhyd_atmos/Registry        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_init_nhyd_atmos/Registry        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,256 +0,0 @@
-%
-% namelist  type  namelist_record  name  default_value
-%
-namelist integer   nhyd_model config_test_case            7
-namelist character nhyd_model config_calendar_type        gregorian
-namelist character nhyd_model config_start_time           none
-namelist character nhyd_model config_stop_time            none
-namelist integer   nhyd_model config_theta_adv_order      3
-namelist real      nhyd_model config_coef_3rd_order       0.25
-namelist integer   nhyd_model config_num_halos            2
-namelist character dcmip      config_dcmip_case           2-0-0
-namelist real      dcmip      config_planet_scale         1.0
-namelist real      dcmip      config_rotation_rate_scale  1.0
-namelist integer   dimensions config_nvertlevels          26
-namelist integer   dimensions config_nsoillevels          4
-namelist integer   dimensions config_nfglevels            27
-namelist integer   dimensions config_nfgsoillevels        4
-namelist integer   dimensions config_months               12
-namelist character data_sources config_geog_data_path     /mmm/users/wrfhelp/WPS_GEOG/
-namelist character data_sources config_met_prefix         FILE
-namelist character data_sources config_sfc_prefix         FILE
-namelist integer   data_sources config_fg_interval        21600
-namelist real      vertical_grid  config_ztop             28000.0
-namelist integer   vertical_grid  config_nsmterrain       2
-namelist logical   vertical_grid  config_smooth_surfaces  false
-namelist logical   preproc_stages config_static_interp    true
-namelist logical   preproc_stages config_vertical_grid    true
-namelist logical   preproc_stages config_met_interp       true
-namelist logical   preproc_stages config_input_sst        false
-namelist logical   preproc_stages config_frac_seaice      false
-namelist character io         config_input_name           grid.nc
-namelist character io         config_sfc_update_name      sfc_update.nc
-namelist character io         config_output_name          init.nc
-namelist character io         config_restart_name         restart.nc
-namelist integer   io         config_frames_per_outfile   0
-namelist integer   io         config_pio_num_iotasks      0 
-namelist integer   io         config_pio_stride           1
-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 integer   restart    config_restart_interval     0
-namelist logical   restart    config_do_restart           false
-namelist real      restart    config_restart_time         172800.0
-
-
-%
-% dim  type  name_in_file  name_in_code
-%
-dim nCells nCells
-dim nEdges nEdges
-dim maxEdges maxEdges
-dim maxEdges2 maxEdges2
-dim nVertices nVertices
-dim TWO 2
-dim THREE 3
-dim vertexDegree vertexDegree
-dim FIFTEEN 15
-dim TWENTYONE 21
-dim R3 3
-dim nVertLevels namelist:config_nvertlevels
-dim nSoilLevels namelist:config_nsoillevels
-dim nFGLevels namelist:config_nfglevels
-dim nFGSoilLevels namelist:config_nfgsoillevels
-dim nVertLevelsP1 nVertLevels+1
-dim nMonths namelist:config_months
-
-%
-% var  type  name_in_file  ( dims )  iro-  name_in_code super-array array_class
-%
-var persistent text    xtime ( Time ) 2 so xtime state - -
-
-%  horizontal grid structure
-
-var persistent real    latCell ( nCells ) 0 io latCell mesh - -
-var persistent real    lonCell ( nCells ) 0 io lonCell mesh - -
-var persistent real    xCell ( nCells ) 0 io xCell mesh - -
-var persistent real    yCell ( nCells ) 0 io yCell mesh - -
-var persistent real    zCell ( nCells ) 0 io zCell mesh - -
-var persistent integer indexToCellID ( nCells ) 0 io indexToCellID mesh - -
-
-var persistent real    latEdge ( nEdges ) 0 io latEdge mesh - -
-var persistent real    lonEdge ( nEdges ) 0 io lonEdge mesh - -
-var persistent real    xEdge ( nEdges ) 0 io xEdge mesh - -
-var persistent real    yEdge ( nEdges ) 0 io yEdge mesh - -
-var persistent real    zEdge ( nEdges ) 0 io zEdge mesh - -
-var persistent integer indexToEdgeID ( nEdges ) 0 io indexToEdgeID mesh - -
-
-var persistent real    latVertex ( nVertices ) 0 io latVertex mesh - -
-var persistent real    lonVertex ( nVertices ) 0 io lonVertex mesh - -
-var persistent real    xVertex ( nVertices ) 0 io xVertex mesh - -
-var persistent real    yVertex ( nVertices ) 0 io yVertex mesh - -
-var persistent real    zVertex ( nVertices ) 0 io zVertex mesh - -
-var persistent integer indexToVertexID ( nVertices ) 0 io indexToVertexID mesh - -
-
-var persistent integer cellsOnEdge ( TWO nEdges ) 0 io cellsOnEdge mesh - -
-var persistent integer nEdgesOnCell ( nCells ) 0 io nEdgesOnCell mesh - -
-var persistent integer nEdgesOnEdge ( nEdges ) 0 io nEdgesOnEdge mesh - -
-var persistent integer edgesOnCell ( maxEdges nCells ) 0 io edgesOnCell mesh - -
-var persistent integer edgesOnEdge ( maxEdges2 nEdges ) 0 io edgesOnEdge mesh - -
-
-var persistent real    weightsOnEdge ( maxEdges2 nEdges ) 0 io weightsOnEdge mesh - -
-var persistent real    dvEdge ( nEdges ) 0 io dvEdge mesh - -
-var persistent real    dcEdge ( nEdges ) 0 io dcEdge mesh - -
-var persistent real    angleEdge ( nEdges ) 0 io angleEdge mesh - -
-var persistent real    areaCell ( nCells ) 0 io areaCell mesh - -
-var persistent real    areaTriangle ( nVertices ) 0 io areaTriangle mesh - -
-
-var persistent real    edgeNormalVectors ( R3 nEdges ) 0 io edgeNormalVectors mesh - -
-var persistent real    localVerticalUnitVectors ( R3 nCells ) 0 io localVerticalUnitVectors mesh - -
-var persistent real    cellTangentPlane ( R3 TWO nCells ) 0 io cellTangentPlane mesh - -
-
-var persistent integer cellsOnCell ( maxEdges nCells ) 0 io cellsOnCell mesh - -
-var persistent integer verticesOnCell ( maxEdges nCells ) 0 io verticesOnCell mesh - -
-var persistent integer verticesOnEdge ( TWO nEdges ) 0 io verticesOnEdge mesh - -
-var persistent integer edgesOnVertex ( vertexDegree nVertices ) 0 io edgesOnVertex mesh - -
-var persistent integer cellsOnVertex ( vertexDegree nVertices ) 0 io cellsOnVertex mesh - -
-var persistent real    kiteAreasOnVertex ( vertexDegree nVertices ) 0 io kiteAreasOnVertex mesh - -
-var persistent real    fEdge ( nEdges ) 0 io fEdge mesh - -
-var persistent real    fVertex ( nVertices ) 0 io fVertex mesh - -

-var persistent real    meshDensity ( nCells ) 0 iro meshDensity mesh - -
-
-% some solver scalar coefficients
-
-% coefficients for vertical extrapolation to the surface
-var persistent real    cf1 ( ) 0 io cf1 mesh - -
-var persistent real    cf2 ( ) 0 io cf2 mesh - -
-var persistent real    cf3 ( ) 0 io cf3 mesh - -
-
-% static terrestrial fields
-var persistent real    ter         ( nCells ) 0 io ter      mesh - -
-var persistent integer landmask    ( nCells ) 0 io landmask mesh - -
-var persistent integer ivgtyp      ( nCells ) 0 io lu_index mesh - -
-var persistent integer isltyp      ( nCells ) 0 io soilcat_top mesh - -
-var persistent integer soilcat_bot ( nCells ) 0 io soilcat_bot mesh - -
-var persistent real    snoalb      ( nCells ) 0 io snoalb mesh - -
-var persistent real    soiltemp    ( nCells ) 0 io soiltemp mesh - -
-var persistent real    greenfrac   ( nMonths nCells ) 0 io greenfrac mesh - -
-var persistent real    shdmin      ( nCells ) 0 io shdmin mesh - -
-var persistent real    shdmax      ( nCells ) 0 io shdmax mesh - -
-var persistent real    albedo12m   ( nMonths nCells ) 0 io albedo12m mesh - -
-
-% description of the vertical grid structure
-
-var persistent real    hx ( nVertLevelsP1 nCells ) 0 io hx mesh - -
-var persistent real    zgrid ( nVertLevelsP1 nCells ) 0 io zgrid mesh - -
-var persistent real    rdzw ( nVertLevels ) 0 io rdzw mesh - -
-var persistent real    dzu ( nVertLevels ) 0 io dzu mesh - -
-var persistent real    rdzu ( nVertLevels ) 0 io rdzu mesh - -
-var persistent real    fzm ( nVertLevels ) 0 io fzm mesh - -
-var persistent real    fzp ( nVertLevels ) 0 io fzp mesh - -
-var persistent real    zx ( nVertLevelsP1 nEdges ) 0 io zx mesh - -
-var persistent real    zz ( nVertLevelsP1 nCells ) 0 io zz mesh - -
-var persistent real    zb ( nVertLevelsP1 TWO nEdges ) 0 io zb mesh - -
-var persistent real    zb3 ( nVertLevelsP1 TWO nEdges ) 0 io zb3 mesh - -
-
-%  W-Rayleigh-damping coefficient
-
-var persistent real    dss ( nVertLevels nCells ) 0 io dss mesh - -
-
-% Horizontally interpolated from first-guess data
-var persistent real    u_fg ( nFGLevels nEdges Time ) 1 - u fg - -
-var persistent real    v_fg ( nFGLevels nEdges Time ) 1 - v fg - -
-var persistent real    t_fg ( nFGLevels nCells Time ) 1 - t fg - -
-var persistent real    p_fg ( nFGLevels nCells Time ) 1 - p fg - -
-var persistent real    z_fg ( nFGLevels nCells Time ) 1 - z fg - -
-var persistent real    rh_fg ( nFGLevels nCells Time ) 1 - rh fg - -
-var persistent real    soilz_fg ( nCells Time ) 1 io soilz fg - -
-var persistent real    psfc_fg ( nCells Time ) 1 - psfc fg - -
-var persistent real    pmsl_fg ( nCells Time ) 1 - pmsl fg - -
-
-% Horizontally interpolated from first-guess data
-var persistent real    dz_fg  ( nFGSoilLevels nCells Time ) 1 io dz_fg  fg - -
-var persistent real    dzs_fg ( nFGSoilLevels nCells Time ) 1 io dzs_fg fg - -
-var persistent real    zs_fg  ( nFGSoilLevels nCells Time ) 1 io zs_fg  fg - -
-var persistent real    st_fg  ( nFGSoilLevels nCells Time ) 1 io st_fg  fg - -
-var persistent real    sm_fg  ( nFGSoilLevels nCells Time ) 1 io sm_fg  fg - -
-
-% Horizontally interpolated from first-guess data
-%    and should be read in by model
-var persistent real    dz ( nSoilLevels nCells Time ) 1 io dz fg - -
-var persistent real    dzs ( nSoilLevels nCells Time ) 1 io dzs fg - -
-var persistent real    zs ( nSoilLevels nCells Time ) 1 io zs fg - -
-var persistent real    sh2o ( nSoilLevels nCells Time ) 1 io sh2o fg - -
-var persistent real    smois ( nSoilLevels nCells Time ) 1 io smois fg - -
-var persistent real    tslb ( nSoilLevels nCells Time ) 1 io tslb fg - -
-var persistent real    smcrel ( nSoilLevels nCells Time ) 1 io smcrel fg - -
-var persistent real    tmn ( nCells Time ) 1 io tmn fg - -
-var persistent real    skintemp ( nCells Time ) 1 io skintemp fg - -
-var persistent real    sst ( nCells Time ) 1 iso sst fg - -
-var persistent real    snow ( nCells Time ) 1 io snow fg - -
-var persistent real    snowc ( nCells Time ) 1 io snowc fg - -
-var persistent real    snowh ( nCells Time ) 1 io snowh fg - -
-var persistent real    xice ( nCells Time ) 1 iso xice fg - -
-var persistent real    seaice ( nCells Time ) 1 io seaice fg - -
-var persistent real    gfs_z ( nVertLevels nCells Time ) 1 - gfs_z fg - -
-var persistent real    vegfra ( nCells Time ) 1 io vegfra fg - -
-var persistent real    sfc_albbck ( nCells Time ) 1 io sfc_albbck fg - -
-var persistent real    xland ( nCells Time ) 1 io xland fg - - 
-
-% Prognostic variables: read from input, saved in restart, and written to output
-var persistent real    u ( nVertLevels nEdges Time ) 2 o u state - -
-var persistent real    w ( nVertLevelsP1 nCells Time ) 2 o w state - -
-var persistent real    rho_zz ( nVertLevels nCells Time ) 2 o rho_zz state - -
-var persistent real    theta_m ( nVertLevels nCells Time ) 2 o theta_m state - -
-var persistent real    qv ( nVertLevels nCells Time ) 2 o qv state scalars moist
-var persistent real    qc ( nVertLevels nCells Time ) 2 o qc state scalars moist
-var persistent real    qr ( nVertLevels nCells Time ) 2 o qr state scalars moist
-
-% state variables diagnosed from prognostic state
-var persistent real    pressure_p ( nVertLevels nCells Time ) 1 - pressure_p diag - -
-
-var persistent real    u_init ( nVertLevels ) 0 io u_init mesh - -
-var persistent real    t_init ( nVertLevels nCells ) 0 io t_init mesh - -
-var persistent real    qv_init ( nVertLevels ) 0 io qv_init mesh - -
-
-% Diagnostic fields: only written to output
-var persistent real    rho ( nVertLevels nCells Time ) 1 o rho diag - -
-var persistent real    theta ( nVertLevels nCells Time ) 1 o theta diag - -
-var persistent real    v ( nVertLevels nEdges Time ) 1 o v diag - -
-var persistent real    uReconstructX ( nVertLevels nCells Time ) 1 o uReconstructX diag - -
-var persistent real    uReconstructY ( nVertLevels nCells Time ) 1 o uReconstructY diag - -
-var persistent real    uReconstructZ ( nVertLevels nCells Time ) 1 o uReconstructZ diag - -
-var persistent real    uReconstructZonal ( nVertLevels nCells Time ) 1 o uReconstructZonal diag - -
-var persistent real    uReconstructMeridional ( nVertLevels nCells Time ) 1 o uReconstructMeridional diag - -
-
-var persistent real    exner ( nVertLevels nCells Time ) 1 - exner diag - -
-var persistent real    exner_base ( nVertLevels nCells Time ) 1 io exner_base diag - -
-var persistent real    rtheta_base ( nVertLevels nCells Time ) 1 - rtheta_base diag - -
-var persistent real    pressure ( nVertLevels nCells Time ) 1 - pressure diag - -
-var persistent real    pressure_base ( nVertLevels nCells Time ) 1 io pressure_base diag - -
-var persistent real    rho_base ( nVertLevels nCells Time ) 1 io rho_base diag - -
-var persistent real    theta_base ( nVertLevels nCells Time ) 1 io theta_base diag - -
-
-var persistent real    cqw  ( nVertLevels nCells Time ) 1 - cqw diag - -
-
-var persistent real    surface_pressure    ( nCells Time    ) 1  io surface_pressure    diag - -
-
-%  coupled variables needed by the solver, but not output...
-var persistent real    ru ( nVertLevels nEdges Time ) 1 - ru diag - -
-var persistent real    rw ( nVertLevelsP1 nCells Time ) 1 - rw diag - -
-var persistent real    rtheta_p ( nVertLevels nCells Time ) 1 - rtheta_p diag - -
-var persistent real    rho_p ( nVertLevels nCells Time ) 1 - rho_p diag - -
-
-% Space needed for advection
-var persistent real    deriv_two ( FIFTEEN TWO nEdges ) 0 io deriv_two mesh - -
-var persistent integer advCells ( TWENTYONE nCells ) 0 io advCells mesh - -
-
-% Space needed for deformation calculation weights
-var persistent real    defc_a ( maxEdges nCells ) 0 io defc_a mesh - -
-var persistent real    defc_b ( maxEdges nCells ) 0 io defc_b mesh - -
-
-% Arrays required for reconstruction of velocity field
-var persistent real    coeffs_reconstruct ( R3 maxEdges nCells ) 0 io coeffs_reconstruct mesh - -
-

Copied: branches/mpas_cdg_advection/src/core_init_nhyd_atmos/Registry.xml (from rev 2782, trunk/mpas/src/core_init_nhyd_atmos/Registry.xml)
===================================================================
--- branches/mpas_cdg_advection/src/core_init_nhyd_atmos/Registry.xml                                (rev 0)
+++ branches/mpas_cdg_advection/src/core_init_nhyd_atmos/Registry.xml        2013-04-22 01:31:32 UTC (rev 2783)
@@ -0,0 +1,297 @@
+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;registry model=&quot;mpas&quot; core=&quot;init_nhyd_atmos&quot; version=&quot;0.0.0&quot;&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;

Modified: branches/mpas_cdg_advection/src/core_init_nhyd_atmos/mpas_init_atm_llxy.F
===================================================================
--- branches/mpas_cdg_advection/src/core_init_nhyd_atmos/mpas_init_atm_llxy.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_init_nhyd_atmos/mpas_init_atm_llxy.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1669,7 +1669,7 @@
       TYPE (proj_info), INTENT(IN) :: proj
       
       ! Local variables
-      INTEGER :: ii,imt,jj,jmt,k,krows,ncol,nrow,iri
+      INTEGER :: ii,imt,jj,jmt,ncol,nrow
       REAL(KIND=HIGH) :: dphd,dlmd !Grid increments, degrees
       REAL(KIND=HIGH) :: glatd  !Geographic latitude, positive north
       REAL(KIND=HIGH) :: glond  !Geographic longitude, positive west
@@ -1839,8 +1839,8 @@
       TYPE (proj_info), INTENT(IN) :: proj
       
       ! Local variables
-      INTEGER :: ih,jh
-      INTEGER :: midcol,midrow,ncol,iadd1,iadd2,imt,jh2,knrow,krem,kv,nrow
+      INTEGER :: jh
+      INTEGER :: midcol,midrow
       REAL (KIND=RKIND) :: i_work, j_work
       REAL (KIND=RKIND) :: dphd,dlmd !Grid increments, degrees
       REAL(KIND=HIGH) :: arg1,arg2,d2r,fctr,glatr,glatd,glond,pi, &amp;

Copied: branches/mpas_cdg_advection/src/core_init_nhyd_atmos/mpas_init_atm_static.F (from rev 2782, trunk/mpas/src/core_init_nhyd_atmos/mpas_init_atm_static.F)
===================================================================
--- branches/mpas_cdg_advection/src/core_init_nhyd_atmos/mpas_init_atm_static.F                                (rev 0)
+++ branches/mpas_cdg_advection/src/core_init_nhyd_atmos/mpas_init_atm_static.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -0,0 +1,1891 @@
+!==================================================================================================
+ module mpas_init_atm_static
+!==================================================================================================
+ use atm_advection
+ use mpas_configure
+ use mpas_dmpar
+ use init_atm_hinterp
+ use init_atm_llxy
+
+ use mpas_atmphys_utilities
+
+ implicit none
+ private
+ public:: init_atm_static,           &amp;
+          init_atm_static_orogwd,    &amp;
+          init_atm_check_read_error, &amp;
+          nearest_cell,              &amp;
+          sphere_distance
+
+ contains
+
+!==================================================================================================
+ subroutine init_atm_static(mesh)
+!==================================================================================================
+
+!inout arguments:
+ type(mesh_type),intent(inout):: mesh
+
+!local variables:
+ type(proj_info):: proj
+ type(dm_info),pointer :: dminfo
+
+ character(len=StrKIND):: fname
+
+ integer:: nx,ny,nz
+ integer:: endian,isigned,istatus,wordsize
+ integer:: i,j,k
+ integer:: iCell,iPoint,iTileStart,iTileEnd,jTileStart,jTileEnd
+ integer,dimension(5) :: interp_list
+ integer,dimension(:),allocatable  :: nhs
+ integer,dimension(:,:),allocatable:: ncat
+      
+ real(kind=4):: scalefactor
+ real(kind=4),dimension(:,:,:),allocatable:: rarray
+
+ real(kind=RKIND):: r_earth
+ real(kind=RKIND):: lat,lon,x,y
+ real(kind=RKIND):: lat_pt,lon_pt
+ real(kind=RKIND),dimension(:,:),allocatable  :: soiltemp_1deg
+ real(kind=RKIND),dimension(:,:),allocatable  :: maxsnowalb
+ real(kind=RKIND),dimension(:,:,:),allocatable:: vegfra
+
+!--------------------------------------------------------------------------------------------------
+ write(0,*)
+ write(0,*) '--- enter subroutine init_atm_static:'
+
+!
+! Scale all distances and areas from a unit sphere to one with radius sphere_radius
+!
+
+ r_earth = mesh % sphere_radius
+
+ mesh % xCell % array = mesh % xCell % array * r_earth
+ mesh % yCell % array = mesh % yCell % array * r_earth
+ mesh % zCell % array = mesh % zCell % array * r_earth
+ mesh % xVertex % array = mesh % xVertex % array * r_earth
+ mesh % yVertex % array = mesh % yVertex % array * r_earth
+ mesh % zVertex % array = mesh % zVertex % array * r_earth
+ mesh % xEdge % array = mesh % xEdge % array * r_earth
+ mesh % yEdge % array = mesh % yEdge % array * r_earth
+ mesh % zEdge % array = mesh % zEdge % array * r_earth
+ mesh % dvEdge % array = mesh % dvEdge % array * r_earth
+ mesh % dcEdge % array = mesh % dcEdge % array * r_earth
+ mesh % areaCell % array = mesh % areaCell % array * r_earth**2.0
+ mesh % areaTriangle % array = mesh % areaTriangle % array * r_earth**2.0
+ mesh % kiteAreasOnVertex % array = mesh % kiteAreasOnVertex % array * r_earth**2.0
+
+ call atm_initialize_advection_rk(mesh) 
+ call atm_initialize_deformation_weights(mesh) 
+
+!
+! Interpolate HGT
+!
+!nx = 126
+!ny = 126
+ nx = 1206
+ ny = 1206
+ nz = 1
+ isigned  = 1
+ endian   = 0
+ wordsize = 2
+ scalefactor = 1.0
+ allocate(rarray(nx,ny,nz))
+ allocate(nhs(mesh%nCells))
+ nhs(:) = 0
+ mesh%ter%array(:) = 0.0
+
+ do jTileStart = 1,20401,ny-6
+    jTileEnd = jTileStart + ny - 1 - 6
+
+    do iTileStart=1,42001,nx-6
+       iTileEnd = iTileStart + nx - 1 - 6
+       write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)// &amp;
+             'topo_30s/',iTileStart,'-',iTileEnd,'.',jTileStart,'-',jTileEnd
+       write(0,*) trim(fname)
+
+       call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                         scalefactor,wordsize,istatus)
+       call init_atm_check_read_error(istatus, fname, dminfo)
+
+       iPoint = 1
+       do j=4,ny-3
+       do i=4,nx-3
+          lat_pt = -89.99583  + (jTileStart + j - 5) * 0.0083333333
+          lon_pt = -179.99583 + (iTileStart + i - 5) * 0.0083333333
+          lat_pt = lat_pt * PI / 180.0
+          lon_pt = lon_pt * PI / 180.0
+
+          iPoint = nearest_cell(lat_pt,lon_pt,iPoint,mesh%nCells,mesh%maxEdges, &amp;
+                                mesh%nEdgesOnCell%array,mesh%cellsOnCell%array, &amp;
+                                mesh%latCell%array,mesh%lonCell%array)
+          mesh%ter%array(iPoint) = mesh%ter%array(iPoint) + rarray(i,j,1)
+          nhs(iPoint) = nhs(iPoint) + 1
+       end do
+       end do
+
+    end do
+ end do
+
+ do iCell = 1,mesh%nCells
+    mesh%ter%array(iCell) = mesh%ter%array(iCell) / real(nhs(iCell))
+ end do
+ deallocate(rarray)
+ deallocate(nhs)
+ write(0,*) '--- end interpolate TER'
+
+
+!
+! Interpolate LU_INDEX
+!
+ nx = 1200
+ ny = 1200
+ nz = 1
+ isigned  = 1
+ endian   = 0
+ wordsize = 1
+ scalefactor = 1.0
+ allocate(rarray(nx,ny,nz))
+ allocate(ncat(24,mesh%nCells))
+ ncat(:,:) = 0
+ mesh%lu_index%array(:) = 0.0
+
+ do jTileStart = 1,20401,ny
+    jTileEnd = jTileStart + ny - 1
+
+    do iTileStart = 1,42001,nx
+       iTileEnd = iTileStart + nx - 1
+       write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)// &amp;
+             '/landuse_30s/',iTileStart,'-',iTileEnd,'.',jTileStart,'-',jTileEnd
+       write(0,*) trim(fname)
+
+       call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                         scalefactor,wordsize,istatus)
+       call init_atm_check_read_error(istatus, fname, dminfo)
+
+       iPoint = 1
+       do j=1,ny
+       do i=1,nx
+          lat_pt = -89.99583  + (jTileStart + j - 2) * 0.0083333333
+          lon_pt = -179.99583 + (iTileStart + i - 2) * 0.0083333333
+          lat_pt = lat_pt * PI / 180.0
+          lon_pt = lon_pt * PI / 180.0
+
+          iPoint = nearest_cell(lat_pt,lon_pt,iPoint,mesh%nCells,mesh%maxEdges, &amp;
+                                mesh%nEdgesOnCell%array,mesh%cellsOnCell%array, &amp;
+                                mesh%latCell%array,mesh%lonCell%array)
+          ncat(int(rarray(i,j,1)),iPoint) = ncat(int(rarray(i,j,1)),iPoint) + 1
+       end do
+       end do
+
+    end do
+ end do
+
+ do iCell = 1,mesh%nCells
+    mesh%lu_index%array(iCell) = 1
+    do i = 2,24
+       if(ncat(i,iCell) &gt; ncat(mesh%lu_index%array(iCell),iCell)) then
+          mesh%lu_index%array(iCell) = i
+       end if
+    end do
+ end do
+ deallocate(rarray)
+ deallocate(ncat)
+ write(0,*) '--- end interpolate LU_INDEX'
+
+
+!
+! Interpolate SOILCAT_TOP
+!
+ nx = 1200
+ ny = 1200
+ nz = 1
+ isigned     = 1
+ endian      = 0
+ wordsize    = 1
+ scalefactor = 1.0
+ allocate(rarray(nx,ny,nz))
+ allocate(ncat(16,mesh%nCells))
+ ncat(:,:) = 0
+ mesh%soilcat_top%array(:) = 0.0
+
+ do jTileStart = 1,20401,ny
+    jTileEnd = jTileStart + ny - 1
+
+    do iTileStart = 1,42001,nx
+       iTileEnd = iTileStart + nx - 1
+       write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)// &amp;
+             '/soiltype_top_30s/',iTileStart,'-',iTileEnd,'.',jTileStart,'-',jTileEnd
+       write(0,*) trim(fname)
+
+       call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                         scalefactor,wordsize,istatus)
+       call init_atm_check_read_error(istatus, fname, dminfo)
+
+       iPoint = 1
+       do j=1,ny
+       do i=1,nx
+          lat_pt = -89.99583  + (jTileStart + j - 2) * 0.0083333333
+          lon_pt = -179.99583 + (iTileStart + i - 2) * 0.0083333333
+          lat_pt = lat_pt * PI / 180.0
+          lon_pt = lon_pt * PI / 180.0
+
+          iPoint = nearest_cell(lat_pt,lon_pt,iPoint,mesh%nCells,mesh%maxEdges, &amp;
+                                mesh%nEdgesOnCell%array,mesh%cellsOnCell%array, &amp;
+                                mesh%latCell%array,mesh%lonCell%array)
+          ncat(int(rarray(i,j,1)),iPoint) = ncat(int(rarray(i,j,1)),iPoint) + 1
+       end do
+       end do
+
+    end do
+ end do
+
+ do iCell = 1,mesh%nCells
+    mesh%soilcat_top%array(iCell) = 1
+    do i = 2,16
+       if(ncat(i,iCell) &gt; ncat(mesh%soilcat_top%array(iCell),iCell)) then
+          mesh%soilcat_top%array(iCell) = i
+       end if
+    end do
+ end do
+ deallocate(rarray)
+ deallocate(ncat)
+ write(0,*) '--- end interpolate SOILCAT_TOP'
+
+
+!
+! Interpolate SOILCAT_BOT
+!
+ nx = 1200
+ ny = 1200
+ nz = 1
+ isigned  = 1
+ endian   = 0
+ wordsize = 1
+ scalefactor = 1.0
+ allocate(rarray(nx,ny,nz))
+ allocate(ncat(16,mesh%nCells))
+ ncat(:,:) = 0
+ mesh%soilcat_bot%array(:) = 0.0
+
+ do jTileStart = 1,20401,ny
+    jTileEnd = jTileStart + ny - 1
+
+    do iTileStart = 1,42001,nx
+       iTileEnd = iTileStart + nx - 1
+       write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)// &amp;
+             '/soiltype_bot_30s/',iTileStart,'-',iTileEnd,'.',jTileStart,'-',jTileEnd
+       write(0,*) trim(fname)
+
+       call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                         scalefactor,wordsize,istatus)
+       call init_atm_check_read_error(istatus, fname, dminfo)
+
+       iPoint = 1
+       do j=1,ny
+       do i=1,nx
+          lat_pt = -89.99583  + (jTileStart + j - 2) * 0.0083333333
+          lon_pt = -179.99583 + (iTileStart + i - 2) * 0.0083333333
+          lat_pt = lat_pt * PI / 180.0
+          lon_pt = lon_pt * PI / 180.0
+
+          iPoint = nearest_cell(lat_pt,lon_pt,iPoint,mesh%nCells,mesh%maxEdges, &amp;
+                                mesh%nEdgesOnCell%array,mesh%cellsOnCell%array, &amp;
+                                mesh%latCell%array,mesh%lonCell%array)
+          ncat(int(rarray(i,j,1)),iPoint) = ncat(int(rarray(i,j,1)),iPoint) + 1
+       end do
+       end do
+
+    end do
+ end do
+
+ do iCell =1, mesh%nCells
+    mesh%soilcat_bot%array(iCell) = 1
+    do i = 2,16
+       if(ncat(i,iCell) &gt; ncat(mesh%soilcat_bot%array(iCell),iCell)) then
+          mesh%soilcat_bot%array(iCell) = i
+       end if
+    end do
+ end do
+ deallocate(rarray)
+ deallocate(ncat)
+ write(0,*) '--- end interpolate SOILCAT_BOT'
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! KLUDGE TO FIX SOIL TYPE OVER ANTARCTICA
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ where (mesh%lu_index%array == 24) mesh%soilcat_top%array = 16
+ where (mesh%lu_index%array == 24) mesh%soilcat_bot%array = 16
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! CORRECT INCONSISTENT SOIL AND LAND USE DATA
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ do iCell = 1,mesh%nCells
+    if (mesh%lu_index%array(iCell) == 16 .or. &amp;
+        mesh%soilcat_top%array(iCell) == 14 .or. &amp;
+        mesh%soilcat_bot%array(iCell) == 14) then
+        if (mesh%lu_index%array(iCell) /= 16) then
+            write(0,*) 'Turning lu_index into water at ', iCell
+            mesh%lu_index%array(iCell) = 16
+        end if
+        if (mesh%soilcat_top%array(iCell) /= 14) then
+            write(0,*) 'Turning soilcat_top into water at ', iCell
+            mesh%soilcat_top%array(iCell) = 14
+        end if
+        if (mesh%soilcat_bot%array(iCell) /= 14) then
+            write(0,*) 'Turning soilcat_bot into water at ', iCell
+            mesh%soilcat_bot%array(iCell) = 14
+        end if
+    end if
+ end do
+
+
+!
+! Derive LANDMASK
+!
+ mesh%landmask%array(:) = 0
+ do iCell=1, mesh%nCells
+    if (mesh%lu_index%array(iCell) /= 16) mesh%landmask%array(iCell) = 1
+ end do
+ write(0,*) '--- end interpolate LANDMASK'
+
+
+!
+! Interpolate SOILTEMP:
+!
+ nx = 186
+ ny = 186
+ nz = 1
+ isigned  = 0
+ endian   = 0
+ wordsize = 2
+ scalefactor = 0.01
+ allocate(rarray(nx,ny,nz))
+ allocate(soiltemp_1deg(-2:363,-2:183))
+ mesh%soiltemp%array(:) = 0.0
+
+ call map_set(PROJ_LATLON, proj,  &amp;
+              latinc = 1.0_RKIND, &amp;
+              loninc = 1.0_RKIND, &amp;
+              knowni = 1.0_RKIND, &amp;
+              knownj = 1.0_RKIND, &amp;
+              lat1 = -89.5_RKIND, &amp;
+              lon1 = -179.5_RKIND)
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)// &amp;
+       'soiltemp_1deg/',1,'-',180,'.',1,'-',180
+ write(0,*) trim(fname)
+
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned, endian, &amp;
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus, fname, dminfo)
+ soiltemp_1deg(-2:180,-2:183) = rarray(1:183,1:186,1)
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)// &amp;
+            'soiltemp_1deg/',181,'-',360,'.',1,'-',180
+ write(0,*) trim(fname)
+
+ call read_geogrid(fname, len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                        scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ soiltemp_1deg(181:363,-2:183) = rarray(4:186,1:186,1)
+
+ interp_list(1) = FOUR_POINT
+ interp_list(2) = W_AVERAGE4
+ interp_list(3) = W_AVERAGE16
+ interp_list(4) = SEARCH
+ interp_list(5) = 0
+
+ do iCell = 1,mesh%nCells
+  
+    if(mesh%landmask%array(iCell) == 1) then
+       lat = mesh % latCell % array(iCell) * DEG_PER_RAD
+       lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       if(x &lt; 0.5) then
+          lon = lon + 360.0
+          call latlon_to_ij(proj, lat, lon, x, y)
+       else if (x &gt;= 360.5) then
+          lon = lon - 360.0
+          call latlon_to_ij(proj, lat, lon, x, y)
+       end if
+       if (y &lt; 1.0) y = 1.0
+       if (y &gt; 179.0) y = 179.0
+       mesh%soiltemp%array(iCell) = interp_sequence(x,y,1,soiltemp_1deg,-2,363,-2,183, &amp;
+                                           1,1,0.0_RKIND,interp_list,1)
+    else
+       mesh%soiltemp%array(iCell) = 0.0
+    end if
+
+ end do
+ deallocate(rarray)
+ deallocate(soiltemp_1deg)
+ write(0,*) '--- end interpolate SOILTEMP'
+
+
+!
+! Interpolate SNOALB
+!
+ nx = 186
+ ny = 186
+ nz = 1
+ isigned     = 0
+ endian      = 0
+ wordsize    = 1
+ scalefactor = 1.0
+ allocate(rarray(nx,ny,nz))
+ allocate(maxsnowalb(-2:363,-2:183))
+ mesh%snoalb%array(:) = 0.0
+
+ call map_set(PROJ_LATLON, proj,  &amp;
+              latinc = 1.0_RKIND, &amp;
+              loninc = 1.0_RKIND, &amp;
+              knowni = 1.0_RKIND, &amp;
+              knownj = 1.0_RKIND, &amp;
+              lat1 = -89.5_RKIND, &amp;
+              lon1 = -179.5_RKIND)
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)// &amp;
+       'maxsnowalb/',1,'-',180,'.',1,'-',180
+ write(0,*) trim(fname)
+
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp; 
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ maxsnowalb(-2:180,-2:183) = rarray(1:183,1:186,1)
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)// &amp;
+       'maxsnowalb/',181,'-',360,'.',1,'-',180
+ write(0,*) trim(fname)
+
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus, fname, dminfo)
+ maxsnowalb(181:363,-2:183) = rarray(4:186,1:186,1)
+
+ interp_list(1) = FOUR_POINT
+ interp_list(2) = W_AVERAGE4
+ interp_list(3) = W_AVERAGE16
+ interp_list(4) = SEARCH
+ interp_list(5) = 0
+
+ do iCell = 1,mesh%nCells
+  
+    if(mesh%landmask%array(iCell) == 1) then
+       lat = mesh % latCell % array(iCell) * DEG_PER_RAD
+       lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       if(x &lt; 0.5) then
+          lon = lon + 360.0
+          call latlon_to_ij(proj, lat, lon, x, y)
+       else if (x &gt;= 360.5) then
+          lon = lon - 360.0
+          call latlon_to_ij(proj, lat, lon, x, y)
+       end if
+       if (y &lt; 1.0) y = 1.0
+       if (y &gt; 179.0) y = 179.0
+       mesh%snoalb%array(iCell) = interp_sequence(x,y,1,maxsnowalb,-2,363,-2,183, &amp;
+                                         1,1,0.0_RKIND,interp_list,1)
+    else
+       mesh%snoalb%array(iCell) = 0.0
+    end if
+
+ end do
+ mesh%snoalb%array(:) = mesh%snoalb%array(:) / 100.0
+ deallocate(rarray)
+ deallocate(maxsnowalb)
+ write(0,*) '--- end interpolate SNOALB'
+
+
+!
+! Interpolate GREENFRAC
+!
+ nx = 1256
+ ny = 1256
+ nz = 12
+ isigned     = 0
+ endian      = 0
+ wordsize    = 1
+ scalefactor = 1.0
+ allocate(rarray(nx,ny,nz))
+ allocate(vegfra(-2:2503,-2:1253,12))
+ mesh%greenfrac%array(:,:) = 0.0
+
+ call map_set(PROJ_LATLON, proj,    &amp;
+              latinc = 0.144_RKIND, &amp;
+              loninc = 0.144_RKIND, &amp;
+              knowni = 1.0_RKIND,   &amp;
+              knownj = 1.0_RKIND,   &amp;
+              lat1 = -89.928_RKIND, &amp;
+              lon1 = -179.928_RKIND)
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)// &amp;
+       'greenfrac/',1,'-',1250,'.',1,'-',1250
+ write(0,*) trim(fname)
+
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp; 
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ vegfra(-2:1250,-2:1253,1:12) = rarray(1:1253,1:1256,1:12)
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)// &amp;
+       'greenfrac/',1251,'-',2500,'.',1,'-',1250
+ write(0,*) trim(fname)
+
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ vegfra(1251:2503,-2:1253,1:12) = rarray(4:1256,1:1256,1:12)
+
+ do iCell = 1,mesh%nCells
+
+    if (mesh%landmask%array(iCell) == 1) then
+       lat = mesh % latCell % array(iCell) * DEG_PER_RAD
+       lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       if(x &lt; 0.5) then
+          lon = lon + 360.0
+          call latlon_to_ij(proj, lat, lon, x, y)
+       else if(x &gt;= 2500.5) then
+          lon = lon - 360.0
+          call latlon_to_ij(proj, lat, lon, x, y)
+       end if
+       if (y &lt; 1.0) y = 1.0
+       if (y &gt; 1249.0) y = 1249.0
+       do k = 1,12
+          mesh%greenfrac%array(k,iCell) = interp_sequence(x,y,k,vegfra,-2,2503,-2,1253, &amp;
+                                                 1,12,-1.e30_RKIND,interp_list,1)
+       end do
+    else
+       mesh%greenfrac%array(:,iCell) = 0.0
+    end if
+    mesh%shdmin%array(iCell) = minval(mesh%greenfrac%array(:,iCell))
+    mesh%shdmax%array(iCell) = maxval(mesh%greenfrac%array(:,iCell))
+      
+ end do
+ deallocate(rarray)
+ deallocate(vegfra)
+ write(0,*) '--- end interpolate GREENFRAC'
+
+
+!
+! Interpolate ALBEDO12M
+!
+ nx = 1256
+ ny = 1256
+ nz = 12
+ isigned     = 0
+ endian      = 0
+ wordsize    = 1
+ scalefactor = 1.0
+ allocate(rarray(nx,ny,nz))
+ allocate(vegfra(-2:2503,-2:1253,12))
+ mesh%albedo12m%array(:,:) = 0.0
+
+ call map_set(PROJ_LATLON, proj,    &amp;
+              latinc = 0.144_RKIND, &amp;
+              loninc = 0.144_RKIND, &amp;
+              knowni = 1.0_RKIND,   &amp;
+              knownj = 1.0_RKIND,   &amp;
+              lat1 = -89.928_RKIND, &amp;
+              lon1 = -179.928_RKIND)
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)// &amp;
+       'albedo_ncep/',1,'-',1250,'.',1,'-',1250
+ write(0,*) trim(fname)
+
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                   scalefactor, wordsize, istatus)
+ call init_atm_check_read_error(istatus,fname, dminfo)
+ vegfra(-2:1250,-2:1253,1:12) = rarray(1:1253,1:1256,1:12)
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)// &amp;
+       'albedo_ncep/',1251,'-',2500,'.',1,'-',1250
+ write(0,*) trim(fname)
+
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp; 
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ vegfra(1251:2503,-2:1253,1:12) = rarray(4:1256,1:1256,1:12)
+
+ do iCell = 1,mesh%nCells
+
+    if (mesh%landmask%array(iCell) == 1) then
+       lat = mesh % latCell % array(iCell) * DEG_PER_RAD
+       lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       if(x &lt; 0.5) then
+          lon = lon + 360.0
+          call latlon_to_ij(proj, lat, lon, x, y)
+       else if(x &gt;= 2500.5) then
+          lon = lon - 360.0
+          call latlon_to_ij(proj, lat, lon, x, y)
+       end if
+       if (y &lt; 1.0) y = 1.0
+       if (y &gt; 1249.0) y = 1249.0
+       do k = 1,12
+          mesh%albedo12m%array(k,iCell) = interp_sequence(x,y,k,vegfra,-2,2503,-2,1253, &amp;
+                                                 1,12,0.0_RKIND,interp_list,1)
+       end do
+    else
+       mesh%albedo12m%array(:,iCell) = 8.0
+    end if
+ end do
+ deallocate(rarray)
+ deallocate(vegfra)
+ write(0,*) '--- end interpolate ALBEDO12M'
+
+
+ end subroutine init_atm_static
+
+!==================================================================================================
+ subroutine init_atm_static_orogwd(mesh)
+!==================================================================================================
+
+!inout arguments:
+ type(mesh_type),intent(inout):: mesh
+
+!local variables:
+ type(proj_info):: proj
+ type(dm_info),pointer :: dminfo
+
+ character(len=StrKIND):: mess
+ character(len=StrKIND):: fname
+ character(len=StrKIND):: dir_gwdo
+
+ integer:: nx,ny,nz
+ integer:: endian,isigned,istatus,wordsize
+ integer:: i,j
+ integer:: iCell,iPoint,iTileStart,iTileEnd,jTileStart,jTileEnd
+ integer,dimension(5) :: interp_list
+ integer,dimension(:),allocatable:: nhs
+
+ real(kind=4):: scalefactor
+ real(kind=4),dimension(:,:,:),allocatable:: rarray
+
+ real(kind=RKIND):: lat,lon,x,y
+ real(kind=RKIND):: lat_pt,lon_pt
+ real(kind=RKIND):: dx,dy,known_lat,known_lon,known_x,known_y
+ real(kind=RKIND):: minMeshD,maxMeshD
+ real(kind=RKIND):: mindcEdge,maxdcEdge
+ real(kind=RKIND),dimension(:,:),allocatable:: xarray
+
+!--------------------------------------------------------------------------------------------------
+ write(0,*)
+ write(0,*) '--- enter subroutine init_atm_static_orogwd:'
+
+!goto 100
+!
+! Interpolate VARSSO:
+ mesh%varsso%array(:) = 0.0_RKIND
+ nx = 600
+ ny = 600
+ nz = 1
+ isigned     = 0
+ endian      = 0
+ wordsize    = 4
+ scalefactor = 1.0
+
+ dx = 0.00833333
+ dy = 0.00833333
+ known_x = 1.0
+ known_y = 1.0
+ known_lat = -59.99583
+ known_lon = -179.99583
+  
+ allocate(rarray(nx,ny,nz))
+ allocate(nhs(mesh%nCells))
+ nhs(:) = 0
+ rarray(:,:,:) = 0._RKIND
+ do jTileStart = 1,13801,ny
+    jTileEnd = jTileStart + ny - 1
+
+    do iTileStart = 1,42601,nx
+       iTileEnd = iTileStart + nx -1
+       write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)//'varsso/', &amp;
+             iTileStart,'-',iTileEnd,'.',jTileStart,'-',jTileEnd
+       write(0,*) trim(fname)
+
+       call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                         scalefactor,wordsize,istatus)
+       call init_atm_check_read_error(istatus,fname,dminfo)
+
+       iPoint = 1
+       do j = 1,ny
+       do i = 1,nx
+          lat_pt = known_lat + (jTileStart + j - 2) * dy
+          lon_pt = known_lon + (iTileStart + i - 2) * dx
+          lat_pt = lat_pt * PI / 180.0
+          lon_pt = lon_pt * PI / 180.0
+
+          iPoint = nearest_cell(lat_pt,lon_pt,iPoint,mesh%nCells,mesh%maxEdges, &amp;
+                                mesh%nEdgesOnCell%array,mesh%cellsOnCell%array, &amp;
+                                mesh%latCell%array,mesh%lonCell%array)
+          mesh%varsso%array(iPoint) = mesh%varsso%array(iPoint) + rarray(i,j,1)
+          nhs(iPoint) = nhs(iPoint) + 1
+       enddo
+       enddo
+
+    enddo
+ enddo
+
+ do iCell = 1,mesh%nCells
+    if(nhs(iCell) .gt. 0) &amp;
+       mesh%varsso%array(iCell) = mesh%varsso%array(iCell) / real(nhs(iCell))
+ enddo
+ deallocate(rarray)
+ deallocate(nhs)
+ write(0,*) '--- end interpolate VARSSO'
+
+! 100 continue
+!... statistic fields needed for the parameterization of gravity wavwe drag over orography. The
+!input directory depends on the mesh resolution, and the mesh must be a uniform mesh.
+ minMeshD  = minval(mesh%meshDensity%array(1:mesh%nCells))
+ maxMeshD  = maxval(mesh%meshDensity%array(1:mesh%nCells))
+ mindcEdge = minval(mesh%dcEdge%array(1:mesh%nEdges))
+ maxdcEdge = maxval(mesh%dcEdge%array(1:mesh%nEdges))
+
+ write(0,*)
+ write(0,*) 'BEGIN INTERPOLATION OF STATISTICAL FIELDS FOR GRAVITY WAVE DRAG OVER OROGRAPHY'
+ write(0,*) 'min MeshD  =', minMeshD
+ write(0,*) 'max MeshD  =', maxMeshD
+ write(0,*) 'min dcEdge =', mindcEdge
+ write(0,*) 'max dcEdge =', maxdcEdge
+
+ dir_gwdo = '   '
+ if(minMeshD == 1.0_RKIND .and. maxMeshD == 1.0_RKIND) then
+    !... uniform 10242 mesh:
+    if(mindcEdge .ge. 200000._RKIND .and. maxdcEdge .lt. 260000._RKIND) then
+       dir_gwdo = 'orogwd_2deg'
+    elseif(mindcEdge .ge. 90000._RKIND .and. maxdcEdge .lt. 150000_RKIND) then
+       dir_gwdo = 'orogwd_1deg'
+    elseif(mindcEdge .ge. 40000._RKIND .and. maxdcEdge .lt. 70000._RKIND) then
+       dir_gwdo = 'orogwd_30m'
+    else
+       write(0,*)
+!      write(mess,*) 'GWDO: Interpolation not available. The initialization will abort'
+!      call physics_error_fatal(mess)
+       write(mess,*) 'GWDO: Interpolation not available. Set config_gwdo_scheme = .false.'
+       return
+    endif
+ else
+    write(0,*)
+!   write(mess,*) 'GWDO: The input mesh must be a uniform mesh. The initialization will abort'
+!   call physics_error_fatal(mess)
+    write(mess,*) 'GWDO: The input mesh must be a uniform mesh. Set config_gwdo_scheme = .false.'
+    return
+ endif
+ write(0,*) 'dir_gwdo   =    ', trim(dir_gwdo)
+ write(0,*)
+
+!
+! Interpolate CON:
+!
+ mesh%con%array(:) = 0.0_RKIND
+
+ con_select: select case(dir_gwdo)
+    case(&quot;orogwd_2deg&quot;)
+       nx = 180
+       ny =  90
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.025
+       dx = 2.0
+       dy = 2.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.0
+       known_lon =   1.0
+    case(&quot;orogwd_1deg&quot;)
+       nx = 360
+       ny = 180
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.025
+       dx = 1.0
+       dy = 1.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.5
+       known_lon =   0.5
+    case(&quot;orogwd_30m&quot;)
+       nx = 720
+       ny = 360
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.025
+       dx = 0.5
+       dy = 0.5
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.75
+       known_lon = 0.25
+    case(&quot;orogwd_10m&quot;)
+       nx = 2160
+       ny = 1080
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.025
+       dx = 0.16666667
+       dy = 0.16666667
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.916667
+       known_lon = 0.0833333
+    case default
+ end select con_select
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') &amp;
+       trim(config_geog_data_path)//trim(dir_gwdo)//'/con/',1,'-',nx,'.',1,'-',ny
+ write(0,*) trim(fname)
+
+ allocate(xarray(nx,ny))
+ allocate(rarray(nx,ny,nz))
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ xarray(1:nx,1:ny) = rarray(1:nx,1:ny,1)
+
+ call map_set(PROJ_LATLON, proj,  &amp;
+              latinc = dy,        &amp;
+              loninc = dx,        &amp;
+              knowni = known_x,   &amp;
+              knownj = known_y,   &amp;
+              lat1   = known_lat, &amp;
+              lon1   = known_lon)
+
+ interp_list(1) = AVERAGE4
+ interp_list(2) = AVERAGE4
+ interp_list(3) = AVERAGE4
+ interp_list(4) = AVERAGE4
+ interp_list(5) = 0
+
+ do iCell = 1,mesh%nCells
+    if(mesh % landmask % array(iCell) == 1) then
+       lat = mesh % latCell % array(iCell) * DEG_PER_RAD
+       lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       mesh % con % array(iCell) = interp_sequence(x,y,1,xarray,1,nx,1,ny,1,1, &amp;
+                                          0.0_RKIND,interp_list,1)
+    endif
+ enddo
+ deallocate(rarray)
+ deallocate(xarray)
+ write(0,*) '--- end interpolate CON'
+
+!
+! Interpolate OA1:
+!
+ mesh%oa1%array(:) = 0.0_RKIND
+
+ oa1_select: select case(dir_gwdo)
+    case(&quot;orogwd_2deg&quot;)
+       nx = 180
+       ny =  90
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 2.0
+       dy = 2.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.0
+       known_lon =   1.0
+    case(&quot;orogwd_1deg&quot;)
+       nx = 360
+       ny = 180
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 1.0
+       dy = 1.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.5
+       known_lon =   0.5
+    case(&quot;orogwd_30m&quot;)
+       nx = 720
+       ny = 360
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.5
+       dy = 0.5
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.75
+       known_lon = 0.25
+    case(&quot;orogwd_10m&quot;)
+       nx = 2160
+       ny = 1080
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.16666667
+       dy = 0.16666667
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.916667
+       known_lon = 0.0833333
+    case default
+ end select oa1_select
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') &amp;
+       trim(config_geog_data_path)//trim(dir_gwdo)//'/oa1/',1,'-',nx,'.',1,'-',ny
+ write(0,*) trim(fname)
+
+ allocate(xarray(nx,ny))
+ allocate(rarray(nx,ny,nz))
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ xarray(1:nx,1:ny) = rarray(1:nx,1:ny,1)
+
+ call map_set(PROJ_LATLON, proj,  &amp;
+              latinc = dy,        &amp;
+              loninc = dx,        &amp;
+              knowni = known_x,   &amp;
+              knownj = known_y,   &amp;
+              lat1   = known_lat, &amp;
+              lon1   = known_lon)
+
+ interp_list(1) = AVERAGE4
+ interp_list(2) = AVERAGE4
+ interp_list(3) = AVERAGE4
+ interp_list(4) = AVERAGE4
+ interp_list(5) = 0
+
+ do iCell = 1,mesh%nCells
+    if(mesh % landmask % array(iCell) == 1) then
+       lat = mesh % latCell % array(iCell) * DEG_PER_RAD
+       lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       mesh % oa1 % array(iCell) = interp_sequence(x,y,1,xarray,1,nx,1,ny,1,1, &amp;
+                                          0.0_RKIND,interp_list,1)
+    endif
+ enddo
+ deallocate(rarray)
+ deallocate(xarray)
+ write(0,*) '--- end interpolate OA1'
+
+!
+! Interpolate OA2:
+ mesh%oa2%array(:) = 0.0_RKIND
+
+ oa2_select: select case(dir_gwdo)
+    case(&quot;orogwd_2deg&quot;)
+       nx = 180
+       ny =  90
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 2.0
+       dy = 2.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.0
+       known_lon =   1.0
+    case(&quot;orogwd_1deg&quot;)
+       nx = 360
+       ny = 180
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 1.0
+       dy = 1.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.5
+       known_lon =   0.5
+    case(&quot;orogwd_30m&quot;)
+       nx = 720
+       ny = 360
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.5
+       dy = 0.5
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.75
+       known_lon = 0.25
+    case(&quot;orogwd_10m&quot;)
+       nx = 2160
+       ny = 1080
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.16666667
+       dy = 0.16666667
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.916667
+       known_lon = 0.0833333
+    case default
+ end select oa2_select
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') &amp;
+       trim(config_geog_data_path)//trim(dir_gwdo)//'/oa2/',1,'-',nx,'.',1,'-',ny
+ write(0,*) trim(fname)
+
+ allocate(xarray(nx,ny))
+ allocate(rarray(nx,ny,nz))
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ xarray(1:nx,1:ny) = rarray(1:nx,1:ny,1)
+
+ call map_set(PROJ_LATLON, proj,  &amp;
+              latinc = dy,        &amp;
+              loninc = dx,        &amp;
+              knowni = known_x,   &amp;
+              knownj = known_y,   &amp;
+              lat1   = known_lat, &amp;
+              lon1   = known_lon)
+
+ interp_list(1) = AVERAGE4
+ interp_list(2) = AVERAGE4
+ interp_list(3) = AVERAGE4
+ interp_list(4) = AVERAGE4
+ interp_list(5) = 0
+
+ do iCell = 1,mesh%nCells
+    if(mesh % landmask % array(iCell) == 1) then
+       lat = mesh % latCell % array(iCell) * DEG_PER_RAD
+       lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       mesh % oa2 % array(iCell) = interp_sequence(x,y,1,xarray,1,nx,1,ny,1,1, &amp;
+                                          0.0_RKIND,interp_list,1)
+     endif
+ enddo
+ deallocate(rarray)
+ deallocate(xarray)
+ write(0,*) '--- end interpolate OA2'
+
+!
+! Interpolate OA3:
+!
+ mesh%oa3%array(:) = 0.0_RKIND
+
+ oa3_select: select case(dir_gwdo)
+    case(&quot;orogwd_2deg&quot;)
+       nx = 180
+       ny =  90
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 2.0
+       dy = 2.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.0
+       known_lon =   1.0
+    case(&quot;orogwd_1deg&quot;)
+       nx = 360
+       ny = 180
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 1.0
+       dy = 1.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.5
+       known_lon =   0.5
+    case(&quot;orogwd_30m&quot;)
+       nx = 720
+       ny = 360
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.5
+       dy = 0.5
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.75
+       known_lon = 0.25
+    case(&quot;orogwd_10m&quot;)
+       nx = 2160
+       ny = 1080
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.16666667
+       dy = 0.16666667
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.916667
+       known_lon = 0.0833333
+    case default
+ end select oa3_select
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') &amp;
+       trim(config_geog_data_path)//trim(dir_gwdo)//'/oa3/',1,'-',nx,'.',1,'-',ny
+ write(0,*) trim(fname)
+
+ allocate(xarray(nx,ny))
+ allocate(rarray(nx,ny,nz))
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ xarray(1:nx,1:ny) = rarray(1:nx,1:ny,1)
+
+ call map_set(PROJ_LATLON, proj,  &amp;
+              latinc = dy,        &amp;
+              loninc = dx,        &amp;
+              knowni = known_x,   &amp;
+              knownj = known_y,   &amp;
+              lat1   = known_lat, &amp;
+              lon1   = known_lon)
+
+ interp_list(1) = AVERAGE4
+ interp_list(2) = AVERAGE4
+ interp_list(3) = AVERAGE4
+ interp_list(4) = AVERAGE4
+ interp_list(5) = 0
+
+ do iCell = 1,mesh%nCells
+    if(mesh % landmask % array(iCell) == 1) then
+       lat = mesh % latCell % array(iCell) * DEG_PER_RAD
+       lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       mesh % oa3 % array(iCell) = interp_sequence(x,y,1,xarray,1,nx,1,ny,1,1, &amp;
+                                          0.0_RKIND,interp_list,1)
+    endif
+ enddo
+ deallocate(rarray)
+ deallocate(xarray)
+ write(0,*) '--- end interpolate OA3'
+
+!
+! Interpolate OA4:
+!
+ mesh%oa4%array(:) = 0.0_RKIND
+
+ oa4_select: select case(dir_gwdo)
+    case(&quot;orogwd_2deg&quot;)
+       nx = 180
+       ny =  90
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 2.0
+       dy = 2.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.0
+       known_lon =   1.0
+    case(&quot;orogwd_1deg&quot;)
+       nx = 360
+       ny = 180
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 1.0
+       dy = 1.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.5
+       known_lon =   0.5
+    case(&quot;orogwd_30m&quot;)
+       nx = 720
+       ny = 360
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.5
+       dy = 0.5
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.75
+       known_lon = 0.25
+    case(&quot;orogwd_10m&quot;)
+       nx = 2160
+       ny = 1080
+       nz = 1
+       isigned     = 1
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.16666667
+       dy = 0.16666667
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.916667
+       known_lon = 0.0833333
+    case default
+ end select oa4_select
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') &amp;
+       trim(config_geog_data_path)//trim(dir_gwdo)//'/oa4/',1,'-',nx,'.',1,'-',ny
+ write(0,*) trim(fname)
+
+ allocate(xarray(nx,ny))
+ allocate(rarray(nx,ny,nz))
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ xarray(1:nx,1:ny) = rarray(1:nx,1:ny,1)
+
+ call map_set(PROJ_LATLON, proj,  &amp;
+              latinc = dy,        &amp;
+              loninc = dx,        &amp;
+              knowni = known_x,   &amp;
+              knownj = known_y,   &amp;
+              lat1   = known_lat, &amp;
+              lon1   = known_lon)
+
+ interp_list(1) = AVERAGE4
+ interp_list(2) = AVERAGE4
+ interp_list(3) = AVERAGE4
+ interp_list(4) = AVERAGE4
+ interp_list(5) = 0
+
+ do iCell = 1,mesh%nCells
+    if(mesh % landmask % array(iCell) == 1) then
+       lat = mesh % latCell % array(iCell) * DEG_PER_RAD
+       lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       mesh % oa4 % array(iCell) = interp_sequence(x,y,1,xarray,1,nx,1,ny,1,1, &amp;
+                                          0.0_RKIND,interp_list,1)
+    endif
+ enddo
+ deallocate(rarray)
+ deallocate(xarray)
+ write(0,*) '--- end interpolate OA4'
+
+!
+! Interpolate OL1:
+!
+ mesh%ol1%array(:) = 0.0_RKIND
+
+ ol1_select: select case(dir_gwdo)
+    case(&quot;orogwd_2deg&quot;)
+       nx = 180
+       ny =  90
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 2.0
+       dy = 2.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.0
+       known_lon =   1.0
+    case(&quot;orogwd_1deg&quot;)
+       nx = 360
+       ny = 180
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 1.0
+       dy = 1.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.5
+       known_lon =   0.5
+    case(&quot;orogwd_30m&quot;)
+       nx = 720
+       ny = 360
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.5
+       dy = 0.5
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.75
+       known_lon = 0.25
+    case(&quot;orogwd_10m&quot;)
+       nx = 2160
+       ny = 1080
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.16666667
+       dy = 0.16666667
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.916667
+       known_lon = 0.0833333
+    case default
+ end select ol1_select
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') &amp;
+       trim(config_geog_data_path)//trim(dir_gwdo)//'/ol1/',1,'-',nx,'.',1,'-',ny
+ write(0,*) trim(fname)
+
+ allocate(xarray(nx,ny))
+ allocate(rarray(nx,ny,nz))
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ xarray(1:nx,1:ny) = rarray(1:nx,1:ny,1)
+
+ call map_set(PROJ_LATLON, proj,  &amp;
+              latinc = dy,        &amp;
+              loninc = dx,        &amp;
+              knowni = known_x,   &amp;
+              knownj = known_y,   &amp;
+              lat1   = known_lat, &amp;
+              lon1   = known_lon)
+
+ interp_list(1) = AVERAGE4
+ interp_list(2) = AVERAGE4
+ interp_list(3) = AVERAGE4
+ interp_list(4) = AVERAGE4
+ interp_list(5) = 0
+
+ do iCell = 1,mesh%nCells
+    if(mesh % landmask % array(iCell) == 1) then
+       lat = mesh % latCell % array(iCell) * DEG_PER_RAD
+       lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       mesh % ol1 % array(iCell) = interp_sequence(x,y,1,xarray,1,nx,1,ny,1,1, &amp;
+                                          0.0_RKIND,interp_list,1)
+    endif
+ enddo
+ deallocate(rarray)
+ deallocate(xarray)
+ write(0,*) '--- end interpolate OL1'
+
+!
+! Interpolate OL2:
+!
+ mesh%ol2%array(:) = 0.0_RKIND
+
+ ol2_select: select case(dir_gwdo)
+    case(&quot;orogwd_2deg&quot;)
+       nx = 180
+       ny =  90
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 2.0
+       dy = 2.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.0
+       known_lon =   1.0
+    case(&quot;orogwd_1deg&quot;)
+       nx = 360
+       ny = 180
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 1.0
+       dy = 1.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.5
+       known_lon =   0.5
+    case(&quot;orogwd_30m&quot;)
+       nx = 720
+       ny = 360
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.5
+       dy = 0.5
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.75
+       known_lon = 0.25
+    case(&quot;orogwd_10m&quot;)
+       nx = 2160
+       ny = 1080
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.16666667
+       dy = 0.16666667
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.916667
+       known_lon = 0.0833333
+    case default
+ end select ol2_select
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') &amp;
+       trim(config_geog_data_path)//trim(dir_gwdo)//'/ol2/',1,'-',nx,'.',1,'-',ny
+ write(0,*) trim(fname)
+
+ allocate(xarray(nx,ny))
+ allocate(rarray(nx,ny,nz))
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ xarray(1:nx,1:ny) = rarray(1:nx,1:ny,1)
+
+ call map_set(PROJ_LATLON, proj,  &amp;
+              latinc = dy,        &amp;
+              loninc = dx,        &amp;
+              knowni = known_x,   &amp;
+              knownj = known_y,   &amp;
+              lat1   = known_lat, &amp;
+              lon1   = known_lon)
+
+ interp_list(1) = AVERAGE4
+ interp_list(2) = AVERAGE4
+ interp_list(3) = AVERAGE4
+ interp_list(4) = AVERAGE4
+ interp_list(5) = 0
+
+ do iCell = 1,mesh%nCells
+    if(mesh % landmask % array(iCell) == 1) then
+       lat = mesh % latCell % array(iCell) * DEG_PER_RAD
+       lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       mesh % ol2 % array(iCell) = interp_sequence(x,y,1,xarray,1,nx,1,ny,1,1, &amp;
+                                          0.0_RKIND,interp_list,1)
+    endif
+ enddo
+ deallocate(rarray)
+ deallocate(xarray)
+ write(0,*) '--- end interpolate OL2'
+
+!
+! Interpolate OL3:
+!
+ mesh%ol3%array(:) = 0.0_RKIND
+
+ ol3_select: select case(dir_gwdo)
+    case(&quot;orogwd_2deg&quot;)
+       nx = 180
+       ny =  90
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 2.0
+       dy = 2.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.0
+       known_lon =   1.0
+    case(&quot;orogwd_1deg&quot;)
+       nx = 360
+       ny = 180
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 1.0
+       dy = 1.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.5
+       known_lon =   0.5
+    case(&quot;orogwd_30m&quot;)
+       nx = 720
+       ny = 360
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.5
+       dy = 0.5
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.75
+       known_lon = 0.25
+    case(&quot;orogwd_10m&quot;)
+       nx = 2160
+       ny = 1080
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.16666667
+       dy = 0.16666667
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.916667
+       known_lon = 0.0833333
+    case default
+ end select ol3_select
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') &amp;
+       trim(config_geog_data_path)//trim(dir_gwdo)//'/ol3/',1,'-',nx,'.',1,'-',ny
+ write(0,*) trim(fname)
+
+ allocate(xarray(nx,ny))
+ allocate(rarray(nx,ny,nz))
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ xarray(1:nx,1:ny) = rarray(1:nx,1:ny,1)
+
+ call map_set(PROJ_LATLON, proj,  &amp;
+              latinc = dy,        &amp;
+              loninc = dx,        &amp;
+              knowni = known_x,   &amp;
+              knownj = known_y,   &amp;
+              lat1   = known_lat, &amp;
+              lon1   = known_lon)
+
+ interp_list(1) = AVERAGE4
+ interp_list(2) = AVERAGE4
+ interp_list(3) = AVERAGE4
+ interp_list(4) = AVERAGE4
+ interp_list(5) = 0
+
+ do iCell = 1,mesh%nCells
+    if(mesh % landmask % array(iCell) == 1) then
+       lat = mesh % latCell % array(iCell) * DEG_PER_RAD
+       lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       mesh % ol3 % array(iCell) = interp_sequence(x,y,1,xarray,1,nx,1,ny,1,1, &amp;
+                                          0.0_RKIND,interp_list,1)
+    endif
+ enddo
+ deallocate(rarray)
+ deallocate(xarray)
+ write(0,*) '--- end interpolate OL3'
+
+!
+! Interpolate OL4:
+!
+ mesh%ol4%array(:) = 0.0_RKIND
+
+ ol4_select: select case(dir_gwdo)
+    case(&quot;orogwd_2deg&quot;)
+       nx = 180
+       ny =  90
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 2.0
+       dy = 2.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.0
+       known_lon =   1.0
+    case(&quot;orogwd_1deg&quot;)
+       nx = 360
+       ny = 180
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 1.0
+       dy = 1.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.5
+       known_lon =   0.5
+    case(&quot;orogwd_30m&quot;)
+       nx = 720
+       ny = 360
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.5
+       dy = 0.5
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.75
+       known_lon = 0.25
+    case(&quot;orogwd_10m&quot;)
+       nx = 2160
+       ny = 1080
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.0001
+       dx = 0.16666667
+       dy = 0.16666667
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.916667
+       known_lon = 0.0833333
+    case default
+ end select ol4_select
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') &amp;
+       trim(config_geog_data_path)//trim(dir_gwdo)//'/ol4/',1,'-',nx,'.',1,'-',ny
+ write(0,*) trim(fname)
+
+ allocate(xarray(nx,ny))
+ allocate(rarray(nx,ny,nz))
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ xarray(1:nx,1:ny) = rarray(1:nx,1:ny,1)
+
+ call map_set(PROJ_LATLON, proj,  &amp;
+              latinc = dy,        &amp;
+              loninc = dx,        &amp;
+              knowni = known_x,   &amp;
+              knownj = known_y,   &amp;
+              lat1   = known_lat, &amp;
+              lon1   = known_lon)
+
+ interp_list(1) = AVERAGE4
+ interp_list(2) = AVERAGE4
+ interp_list(3) = AVERAGE4
+ interp_list(4) = AVERAGE4
+ interp_list(5) = 0
+
+ do iCell = 1,mesh%nCells
+    if(mesh % landmask % array(iCell) == 1) then
+       lat = mesh % latCell % array(iCell) * DEG_PER_RAD
+       lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       mesh % ol4 % array(iCell) = interp_sequence(x,y,1,xarray,1,nx,1,ny,1,1, &amp;
+                                          0.0_RKIND,interp_list,1)
+    endif
+ enddo
+ deallocate(rarray)
+ deallocate(xarray)
+ write(0,*) '--- end interpolate OL4'
+
+!
+! Interpolate VAR2D:
+!
+ mesh%var2d%array(:) = 0.0_RKIND
+
+ var2d_select: select case(dir_gwdo)
+    case(&quot;orogwd_2deg&quot;)
+       nx = 180
+       ny = 90
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 4
+       scalefactor = 0.02
+       dx = 2.0
+       dy = 2.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.0
+       known_lon =   1.0
+    case(&quot;orogwd_1deg&quot;)
+       nx = 360
+       ny = 180
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 4
+       scalefactor = 0.02
+       dx = 1.0
+       dy = 1.0
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.5
+       known_lon =   0.5
+    case(&quot;orogwd_30m&quot;)
+       nx = 720
+       ny = 360
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 4
+       scalefactor = 0.02
+       dx = 0.5
+       dy = 0.5
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.75
+       known_lon = 0.25
+    case(&quot;orogwd_10m&quot;)
+       nx = 2160
+       ny = 1080
+       nz = 1
+       isigned     = 0
+       endian      = 0
+       wordsize    = 2
+       scalefactor = 0.02
+       dx = 0.16666667
+       dy = 0.16666667
+       known_x = 1.0
+       known_y = 1.0
+       known_lat = -89.916667
+       known_lon = 0.0833333
+    case default
+ end select var2d_select
+
+ write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') &amp;
+       trim(config_geog_data_path)//trim(dir_gwdo)//'/var/',1,'-',nx,'.',1,'-',ny
+ write(0,*) trim(fname)
+
+
+ allocate(xarray(nx,ny))
+ allocate(rarray(nx,ny,nz))
+ call read_geogrid(fname,len_trim(fname),rarray,nx,ny,nz,isigned,endian, &amp;
+                   scalefactor,wordsize,istatus)
+ call init_atm_check_read_error(istatus,fname,dminfo)
+ xarray(1:nx,1:ny) = rarray(1:nx,1:ny,1)
+
+ call map_set(PROJ_LATLON, proj,  &amp;
+              latinc = dy,        &amp;
+              loninc = dx,        &amp;
+              knowni = known_x,   &amp;
+              knownj = known_y,   &amp;
+              lat1   = known_lat, &amp;
+              lon1   = known_lon)
+
+ interp_list(1) = AVERAGE4
+ interp_list(2) = AVERAGE4
+ interp_list(3) = AVERAGE4
+ interp_list(4) = AVERAGE4
+ interp_list(5) = 0
+
+ do iCell = 1,mesh%nCells
+    if(mesh % landmask % array(iCell) == 1) then
+       lat = mesh % latCell % array(iCell) * DEG_PER_RAD
+       lon = mesh % lonCell % array(iCell) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       mesh % var2d % array(iCell) = interp_sequence(x,y,1,xarray,1,nx,1,ny,1,1, &amp;
+                                            0.0_RKIND,interp_list,1)
+    endif
+ enddo
+ deallocate(rarray)
+ deallocate(xarray)
+ write(0,*) '--- end interpolate VAR2D'
+
+ end subroutine init_atm_static_orogwd
+
+!==================================================================================================
+ subroutine init_atm_check_read_error(istatus, fname, dminfo)
+!==================================================================================================
+ implicit none
+
+ integer, intent(in) :: istatus
+ character (len=*), intent(in) :: fname
+ type (dm_info), intent(in) :: dminfo
+
+ if (istatus /= 0) then
+     write(0,*) 'ERROR: Could not read file '//trim(fname)
+     call mpas_dmpar_abort(dminfo)
+ end if
+
+ end subroutine init_atm_check_read_error
+
+!==================================================================================================
+ integer function nearest_cell(target_lat, target_lon, start_cell, nCells, maxEdges, &amp;
+                               nEdgesOnCell, cellsOnCell, latCell, lonCell)
+!==================================================================================================
+ implicit none
+
+ real (kind=RKIND), intent(in) :: target_lat, target_lon
+ integer, intent(in) :: start_cell
+ integer, intent(in) :: nCells, maxEdges
+ integer, dimension(nCells), intent(in) :: nEdgesOnCell
+ integer, dimension(maxEdges,nCells), intent(in) :: cellsOnCell
+ real (kind=RKIND), dimension(nCells), intent(in) :: latCell, lonCell
+
+ integer :: i
+ integer :: iCell
+ integer :: current_cell
+ real (kind=RKIND) :: current_distance, d
+ real (kind=RKIND) :: nearest_distance
+
+ nearest_cell = start_cell
+ current_cell = -1
+
+ do while (nearest_cell /= current_cell)
+    current_cell = nearest_cell
+    current_distance = sphere_distance(latCell(current_cell), lonCell(current_cell), target_lat, &amp;
+                                       target_lon, 1.0_RKIND)
+    nearest_cell = current_cell
+    nearest_distance = current_distance
+    do i = 1, nEdgesOnCell(current_cell)
+       iCell = cellsOnCell(i,current_cell)
+       if (iCell &lt;= nCells) then
+          d = sphere_distance(latCell(iCell), lonCell(iCell), target_lat, target_lon, 1.0_RKIND)
+          if (d &lt; nearest_distance) then
+             nearest_cell = iCell
+             nearest_distance = d
+          end if
+       end if
+    end do
+ end do
+
+ end function nearest_cell
+
+!==================================================================================================
+ real (kind=RKIND) 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
+
+!==================================================================================================
+ end module mpas_init_atm_static
+!==================================================================================================

Copied: branches/mpas_cdg_advection/src/core_init_nhyd_atmos/mpas_init_atm_surface.F (from rev 2782, trunk/mpas/src/core_init_nhyd_atmos/mpas_init_atm_surface.F)
===================================================================
--- branches/mpas_cdg_advection/src/core_init_nhyd_atmos/mpas_init_atm_surface.F                                (rev 0)
+++ branches/mpas_cdg_advection/src/core_init_nhyd_atmos/mpas_init_atm_surface.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -0,0 +1,315 @@
+!==================================================================================================
+ module mpas_init_atm_surface
+ use mpas_configure
+ use mpas_grid_types
+ use mpas_io_output
+ use mpas_timekeeping
+ use mpas_timer

+ use init_atm_hinterp
+ use init_atm_llxy
+ use init_atm_read_met
+
+ implicit none
+ private
+ public:: init_atm_test_case_sfc,interp_sfc_to_MPAS
+
+ contains
+
+!==================================================================================================
+ subroutine init_atm_test_case_sfc(domain,dminfo,mesh,fg,state)
+!==================================================================================================
+
+!input arguments:
+ type(domain_type), intent(inout):: domain
+ type(dm_info), intent(in)       :: dminfo
+ type(mesh_type), intent(inout)  :: mesh
+ type(fg_type), intent(inout)    :: fg
+ type (state_type), intent(inout):: state
+
+!local variables:
+ type(MPAS_Clock_type)       :: fg_clock
+ type(MPAS_Time_type)        :: start_time,stop_time,curr_time
+ type(MPAS_TimeInterval_type):: fg_interval
+
+ type(io_output_object):: sfc_update_obj
+
+ character(len=StrKIND) :: timeString
+
+!==================================================================================================
+
+!set up clock to step through all intermediate file dates to be processed:
+ call mpas_set_time(start_time, dateTimeString=trim(config_start_time))
+ call mpas_set_time(stop_time, dateTimeString=trim(config_stop_time))
+ call mpas_set_timeInterval(fg_interval, S=config_fg_interval)
+ call mpas_create_clock(fg_clock, start_time, fg_interval, stopTime=stop_time) 
+
+!initialize the output file
+ sfc_update_obj % time = 1
+ sfc_update_obj % filename = trim(config_sfc_update_name)
+
+ call mpas_output_state_init(sfc_update_obj, domain, &quot;SFC&quot;)
+
+!loop over all times:
+ curr_time = mpas_get_clock_time(fg_clock, MPAS_NOW) 
+
+ do while (curr_time &lt;= stop_time)
+    call mpas_get_time(curr_time, dateTimeString=timeString)
+!   write(0,*) 'Processing ',trim(config_sfc_prefix)//':'//timeString(1:13)
+
+    !read the sea-surface temperature and sea-ice data from the surface file, and interpolate the
+    !data to the MPAS grid:
+    call interp_sfc_to_MPAS(timeString(1:13),mesh,fg,dminfo)
+
+    !write the interpolated SST/SKINTEMP field as a new time slice in the MPAS output file:
+    call mpas_output_state_for_domain(sfc_update_obj, domain, sfc_update_obj % time)
+    sfc_update_obj % time = sfc_update_obj % time + 1
+
+    call mpas_advance_clock(fg_clock)
+    curr_time = mpas_get_clock_time(fg_clock, MPAS_NOW) 
+
+    call mpas_get_time(curr_time, dateTimeString=timeString)
+    state % xtime % scalar = timeString
+
+ enddo
+
+ call mpas_output_state_finalize(sfc_update_obj, dminfo)
+      
+ end subroutine init_atm_test_case_sfc
+
+!==================================================================================================
+ subroutine interp_sfc_to_MPAS(timeString,mesh,fg,dminfo)
+!==================================================================================================
+
+!input arguments:
+ character(len=*),intent(in):: timeString
+ type(mesh_type), intent(in):: mesh
+ type(dm_info),intent(in)   :: dminfo
+
+!inout arguments:
+ type(fg_type), intent(inout):: fg
+
+!local variables:
+ type(met_data) :: field !real*4 meteorological data.
+
+ integer:: istatus
+ integer:: masked
+ integer,dimension(5):: interp_list
+ integer,dimension(:),pointer:: mask_array
+
+ real(kind=RKIND):: fillval,maskval,msgval
+ real(kind=RKIND),dimension(:,:),allocatable:: maskslab
+
+ real(kind=RKIND), dimension(:), pointer:: destField1d
+
+!==================================================================================================
+ mask_array =&gt; mesh % landmask % array
+
+!open intermediate file:
+ call read_met_init(trim(config_sfc_prefix),.false.,timeString,istatus)
+ if(istatus /= 0) then
+    write(0,*) 'Error reading   ',trim(config_sfc_prefix)//':'//timeString(1:13)
+    call mpas_dmpar_abort(dminfo)
+ else
+    write(0,*) 'Processing file ',trim(config_sfc_prefix)//':'//timeString(1:13)
+ endif
+
+!scan through all fields in the file, looking for the LANDSEA field:
+ call read_next_met_field(field,istatus)
+ do while (istatus == 0)
+    if(index(field % field, 'LANDSEA') /= 0) then
+       if(.not.allocated(maskslab)) allocate(maskslab(-2:field % nx+3, field % ny))
+       maskslab(1:field % nx, 1:field % ny) = field % slab(1:field % nx, 1:field % ny)
+       maskslab(0, 1:field % ny)  = field % slab(field % nx, 1:field % ny)
+       maskslab(-1, 1:field % ny) = field % slab(field % nx-1, 1:field % ny)
+       maskslab(-2, 1:field % ny) = field % slab(field % nx-2, 1:field % ny)
+       maskslab(field % nx+1, 1:field % ny) = field % slab(1, 1:field % ny)
+       maskslab(field % nx+2, 1:field % ny) = field % slab(2, 1:field % ny)
+       maskslab(field % nx+3, 1:field % ny) = field % slab(3, 1:field % ny)
+!      write(0,*) 'minval, maxval of LANDSEA = ', minval(maskslab), maxval(maskslab)
+    endif
+    deallocate(field % slab)
+    call read_next_met_field(field,istatus)
+ enddo
+ call read_met_close()
+
+!read sea-surface temperatures and seaice data. open intermediate file:
+ call read_met_init(trim(config_sfc_prefix),.false.,timeString(1:13),istatus)
+ if(istatus /= 0) then
+    write(0,*) 'Error reading ',trim(config_sfc_prefix)//':'//timeString(1:13)
+    call mpas_dmpar_abort(dminfo)
+ endif
+
+!scan through all fields in the file, looking for the SST,SKINTEMP, or SEAICE field:
+ call read_next_met_field(field,istatus)
+ do while (istatus == 0)
+
+    !sea-surface data:
+    if(index(field % field, 'SKINTEMP') /= 0 .or. index(field % field, 'SST') /= 0) then
+!      write(0,*) '... Processing SST:'
+       fg % sst % array(1:mesh%nCells) = 0.0_RKIND
+       destField1d =&gt; fg % sst % array
+
+       !interpolation to the MPAS grid:
+       interp_list(1) = FOUR_POINT
+       interp_list(2) = SEARCH
+       interp_list(3) = 0
+       interp_list(4) = SEARCH
+       interp_list(5) = 0
+       msgval  = -1.0e30_RKIND !missing value
+       masked  = -1
+       maskval = -1.0_RKIND
+       fillval =  0.0_RKIND
+       call interp_to_MPAS(mesh,field,destField1d,interp_list,msgval,masked,maskval,fillval, &amp;
+                           maskslab,mask_array)
+
+       !field%slab was allocated in the subroutine read_next_met_field
+       deallocate(field%slab)
+
+    !sea-ice data:
+    elseif(index(field % field, 'SEAICE') /= 0) then
+!      write(0,*) '... Processing SEAICE:'
+       fg % xice % array(1:mesh%nCells) = 0.0_RKIND
+       destField1d =&gt; fg % xice % array
+
+       !interpolation to the MPAS grid:
+       !interp_list(1) = SIXTEEN_POINT
+       interp_list(1) = FOUR_POINT
+       interp_list(2) = FOUR_POINT
+       interp_list(3) = W_AVERAGE4
+       interp_list(4) = SEARCH
+       interp_list(5) = 0
+       msgval  = -1.0e30_RKIND  !missing value
+       masked  = 1
+       maskval = 1.0_RKIND
+       fillval = 0.0_RKIND
+       call interp_to_MPAS(mesh,field,destField1d,interp_list,msgval,masked,maskval,fillval, &amp;
+                           maskslab,mask_array)
+
+       !field%slab was allocated in the subroutine read_next_met_field
+       deallocate(field%slab)
+        
+    else
+       deallocate(field%slab)
+
+    endif
+
+    call read_next_met_field(field,istatus)
+ enddo
+
+!close intermediate file:
+ call read_met_close()
+ if(allocated(maskslab)) deallocate(maskslab)
+
+!freeze really cold oceans:
+ where(fg%sst%array.lt.271.0_RKIND .and. mesh%landmask%array.eq.0) fg%xice%array = 1.0_RKIND
+
+!limit XICE to values between 0 and 1. Although the input meteorological field is between 0. and 1.
+!interpolation to the MPAS grid can yield values of XiCE less than 0. and greater than 1.:
+ where (fg%xice%array &lt; 0._RKIND) fg%xice%array = 0._RKIND
+ where (fg%xice%array &gt; 1._RKIND) fg%xice%array = 1._RKIND
+
+ end subroutine interp_sfc_to_MPAS
+
+!==================================================================================================
+ subroutine interp_to_MPAS(mesh,field,destField1d,interp_list,msgval,masked,maskval,fillval, &amp;
+                           maskslab,mask_array)
+!==================================================================================================
+
+!input arguments:
+ type(mesh_type),intent(in):: mesh
+ type(met_data),intent(in) :: field !real*4 meteorological data.
+
+ integer,intent(in):: masked
+ integer,dimension(5),intent(in):: interp_list
+ integer,dimension(:),intent(in),pointer:: mask_array
+
+ real(kind=RKIND),intent(in):: fillval,maskval,msgval
+ real(kind=RKIND),intent(in),dimension(*):: maskslab
+
+!inout arguments:
+ real(kind=RKIND),intent(inout),dimension(:),pointer:: destField1d
+
+!local variables:
+ type(proj_info):: proj
+ integer:: i,nInterpPoints
+ real(kind=RKIND):: lat,lon,x,y
+ real(kind=RKIND),dimension(:,:),allocatable:: rslab
+
+ real(kind=RKIND),dimension(:),pointer:: latPoints,lonPoints

+!--------------------------------------------------------------------------------------------------
+
+ call map_init(proj)   
+ if(field % iproj == PROJ_LATLON) then
+    call map_set(PROJ_LATLON, proj, &amp;
+                 latinc = real(field % deltalat,RKIND), &amp;
+                 loninc = real(field % deltalon,RKIND), &amp;
+                 knowni = 1.0_RKIND, &amp;
+                 knownj = 1.0_RKIND, &amp;
+                 lat1 = real(field % startlat,RKIND), &amp;
+                 lon1 = real(field % startlon,RKIND))
+!   write(0,*) '--- The projection is PROJ_LATLON.'
+ elseif(field % iproj == PROJ_GAUSS) then
+    call map_set(PROJ_GAUSS, proj, &amp;
+                 nlat = nint(field % deltalat), &amp;
+                 loninc = real(field % deltalon,RKIND), &amp;
+                 lat1 = real(field % startlat,RKIND), &amp;
+                 lon1 = real(field % startlon,RKIND))
+!   write(0,*) '--- The projection is PROJ_GAUSS.'
+ elseif(field % iproj == PROJ_PS) then
+    call map_set(PROJ_PS, proj, &amp;
+                 dx = real(field % dx,RKIND), &amp;
+                 truelat1 = real(field % truelat1,RKIND), &amp;
+                 stdlon = real(field % xlonc,RKIND), &amp;
+                 knowni = real(field % nx / 2.0,RKIND), &amp;
+                 knownj = real(field % ny / 2.0,RKIND), &amp;
+                 lat1 = real(field % startlat,RKIND), &amp;
+                 lon1 = real(field % startlon,RKIND))
+!   write(0,*) '--- The projection is PROJ_PS.'
+ endif
+
+ nInterpPoints = mesh % nCells
+ latPoints =&gt; mesh % latCell % array
+ lonPoints =&gt; mesh % lonCell % array
+
+ allocate(rslab(-2:field % nx+3, field % ny))
+ rslab(1:field % nx, 1:field % ny) = field % slab(1:field % nx, 1:field % ny)
+ rslab( 0, 1:field % ny) = field % slab(field % nx  , 1:field % ny)
+ rslab(-1, 1:field % ny) = field % slab(field % nx-1, 1:field % ny)
+ rslab(-2, 1:field % ny) = field % slab(field % nx-2, 1:field % ny)
+ rslab(field % nx+1, 1:field % ny) = field % slab(1, 1:field % ny)
+ rslab(field % nx+2, 1:field % ny) = field % slab(2, 1:field % ny)
+ rslab(field % nx+3, 1:field % ny) = field % slab(3, 1:field % ny)
+
+ do i = 1,nInterpPoints
+    if(mask_array(i) /= masked) then
+       lat = latPoints(i) * DEG_PER_RAD
+       lon = lonPoints(i) * DEG_PER_RAD
+       call latlon_to_ij(proj, lat, lon, x, y)
+       if(y &lt; 0.5) then
+          y = 1.0
+       elseif(y &gt;= real(field%ny)+0.5) then
+          y = real(field % ny)
+       endif
+       if(x &lt; 0.5) then
+          lon = lon + 360.0
+          call latlon_to_ij(proj, lat, lon, x, y)
+       elseif (x &gt;= real(field%nx)+0.5) then
+          lon = lon - 360.0
+          call latlon_to_ij(proj, lat, lon, x, y)
+       endif
+       destField1d(i) = interp_sequence(x,y,1,rslab,-2,field%nx+3,1,field%ny,1,1, &amp;
+                        msgval,interp_list,1,maskval=maskval,mask_array=maskslab)
+    else
+       destField1d(i) = fillval
+    endif
+ enddo
+ deallocate(rslab)
+
+ end subroutine interp_to_MPAS
+
+!==================================================================================================
+ end module mpas_init_atm_surface
+!==================================================================================================
+

Modified: branches/mpas_cdg_advection/src/core_init_nhyd_atmos/mpas_init_atm_test_cases.F
===================================================================
--- branches/mpas_cdg_advection/src/core_init_nhyd_atmos/mpas_init_atm_test_cases.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_init_nhyd_atmos/mpas_init_atm_test_cases.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -10,6 +10,8 @@
    use mpas_RBF_interpolation
    use mpas_vector_reconstruction
    use mpas_timer
+   use mpas_init_atm_static
+   use mpas_init_atm_surface
 
    ! Added only clause to keep xlf90 from getting confused from the overloaded abs intrinsic in mpas_timekeeping
    use mpas_timekeeping !, only: MPAS_Time_type, MPAS_TimeInterval_type, MPAS_Clock_type, &amp;
@@ -104,20 +106,25 @@
          write(0,*) ' real-data GFS test case '
          block_ptr =&gt; domain % blocklist
          do while (associated(block_ptr))
+            if (config_static_interp) then
+               call init_atm_static(block_ptr % mesh)
+               call init_atm_static_orogwd(block_ptr % mesh)
+            endif
             call init_atm_test_case_gfs(block_ptr % mesh, block_ptr % fg, &amp; 
                                         block_ptr % state % time_levs(1) % state, block_ptr % diag, &amp;
-                                        config_test_case)
-            if (config_met_interp) call physics_initialize_real(block_ptr % mesh, block_ptr % fg)
+                                        block_ptr % diag_physics, config_test_case)
+            if (config_met_interp) call physics_initialize_real(block_ptr % mesh, block_ptr % fg, domain % dminfo)
+
             block_ptr =&gt; block_ptr % next
          end do
 
       else if (config_test_case == 8 ) then
 
-         write(0,*) ' real-data surface (SST) update test case '
+         write(0,*) 'real-data surface (SST) update test case '
          block_ptr =&gt; domain % blocklist
          do while (associated(block_ptr))
-            call init_atm_test_case_sfc(domain, domain % dminfo, block_ptr % mesh, block_ptr % fg, block_ptr % state % time_levs(1) % state, &amp;
-                                    block_ptr % diag, config_test_case, block_ptr % parinfo)
+            ! Defined in mpas_init_atm_surface.F
+            call init_atm_test_case_sfc(domain, domain % dminfo, block_ptr % mesh,block_ptr % fg, block_ptr % state % time_levs(1) % state)
             block_ptr =&gt; block_ptr % next
          end do
 
@@ -2231,7 +2238,7 @@
    end subroutine init_atm_test_case_mtn_wave
 
 
-   subroutine init_atm_test_case_gfs(grid, fg, state, diag, test_case)
+   subroutine init_atm_test_case_gfs(grid, fg, state, diag, diag_physics, test_case)
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ! Real-data test case using GFS data
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -2247,6 +2254,7 @@
       type (fg_type), intent(inout) :: fg
       type (state_type), intent(inout) :: state
       type (diag_type), intent(inout) :: diag
+      type (diag_physics_type), intent(inout):: diag_physics
       integer, intent(in) :: test_case
 
       type (block_type), pointer :: block
@@ -2291,10 +2299,9 @@
 
       !This is temporary variable here. It just need when calculate tangential velocity v.
       integer :: eoe, j
-      integer, dimension(:), pointer :: nEdgesOnEdge, nEdgesOnCell
+      integer, dimension(:), pointer :: nEdgesOnCell
       integer, dimension(:,:), pointer :: edgesOnEdge, cellsOnEdge, edgesOnCell, cellsOnCell
       real (kind=RKIND), dimension(:), pointer :: dvEdge, dcEdge, AreaCell 
-      real (kind=RKIND), dimension(:,:), pointer :: weightsOnEdge
       real (kind=RKIND), dimension(:,:), pointer :: v
       real (kind=RKIND), dimension(:,:), pointer :: sorted_arr
 
@@ -2302,7 +2309,7 @@
       type (field1DReal), target :: tempFieldTarget
 
       real(kind=RKIND), dimension(:), pointer :: hs, hs1
-      real(kind=RKIND) :: hm, zh, dzmin, dzmina, dzmina_global, dzminf, sm
+      real(kind=RKIND) :: hm, hm_global, zh, dzmin, dzmina, dzmina_global, dzminf, sm
       integer :: nsmterrain, kz, sfc_k
       logical :: hybrid, smooth
 
@@ -2310,19 +2317,10 @@
       real (kind=RKIND) :: p_check
 
       ! For interpolating terrain and land use
-      integer :: nx, ny, nzz, iPoint, subx, suby
-      integer :: isigned, endian, wordsize, istatus
-      integer :: iTileStart, iTileEnd
-      integer :: jTileStart, jTileEnd
-      integer, allocatable, dimension(:) :: nhs
-      integer, allocatable, dimension(:,:) :: ncat
-      real (kind=4) :: scalefactor   ! NB: this should be a single-precision real
-      real (kind=RKIND) :: lat_pt, lon_pt, lon_pt_o
-      real (kind=4), allocatable, dimension(:,:,:) :: rarray    ! NB: this should be a single-precision real array
+      integer :: nx, ny
+      integer :: istatus
+
       real (kind=RKIND), allocatable, dimension(:,:) :: rslab, maskslab
-      real (kind=RKIND), allocatable, dimension(:,:) :: maxsnowalb
-      real (kind=RKIND), allocatable, dimension(:,:) :: soiltemp_1deg
-      real (kind=RKIND), allocatable, dimension(:,:,:) :: vegfra
       integer, dimension(:), pointer :: mask_array
       integer, dimension(grid % nEdges), target :: edge_mask
       character (len=StrKIND) :: fname
@@ -2364,8 +2362,6 @@
       parinfo =&gt; block % parinfo
       dminfo =&gt; block % domain % dminfo
 
-      weightsOnEdge     =&gt; grid % weightsOnEdge % array
-      nEdgesOnEdge      =&gt; grid % nEdgesOnEdge % array
       nEdgesOnCell      =&gt; grid % nEdgesOnCell % array
       edgesOnEdge       =&gt; grid % edgesOnEdge % array
       edgesOnCell       =&gt; grid % edgesOnCell % array
@@ -2421,622 +2417,9 @@
       omega_e = omega
       p0 = 1.e+05
 
-      interp_list(1) = FOUR_POINT
-      interp_list(2) = SEARCH
-      interp_list(3) = 0
-
-
-      !
-      ! Scale all distances and areas from a unit sphere to one with radius sphere_radius
-      !
-
-      if (config_static_interp) then
-
-      grid % xCell % array = grid % xCell % array * r_earth
-      grid % yCell % array = grid % yCell % array * r_earth
-      grid % zCell % array = grid % zCell % array * r_earth
-      grid % xVertex % array = grid % xVertex % array * r_earth
-      grid % yVertex % array = grid % yVertex % array * r_earth
-      grid % zVertex % array = grid % zVertex % array * r_earth
-      grid % xEdge % array = grid % xEdge % array * r_earth
-      grid % yEdge % array = grid % yEdge % array * r_earth
-      grid % zEdge % array = grid % zEdge % array * r_earth
-      grid % dvEdge % array = grid % dvEdge % array * r_earth
-      grid % dcEdge % array = grid % dcEdge % array * r_earth
-      grid % areaCell % array = grid % areaCell % array * r_earth**2.0
-      grid % areaTriangle % array = grid % areaTriangle % array * r_earth**2.0
-      grid % kiteAreasOnVertex % array = grid % kiteAreasOnVertex % array * r_earth**2.0
-
       scalars(:,:,:) = 0.
 
-      call atm_initialize_advection_rk(grid) 
-      call atm_initialize_deformation_weights(grid) 
-
-
-      !
-      ! Interpolate HGT
-      !
-!     nx = 126
-!     ny = 126
-      nx = 1206
-      ny = 1206
-      nzz = 1
-      isigned = 1
-      endian = 0
-      wordsize = 2
-      scalefactor = 1.0
-      allocate(rarray(nx,ny,nzz))
-      allocate(nhs(grid % nCells))
-      nhs(:) = 0
-      ter(:) = 0.0
-
-      do jTileStart=1,20401,ny-6
-!     do jTileStart=1,961,ny-6
-         jTileEnd = jTileStart + ny - 1 - 6
-         do iTileStart=1,42001,nx-6
-!        do iTileStart=1,2041,nx-6
-            iTileEnd = iTileStart + nx - 1 - 6
-            write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)//'topo_30s/',iTileStart,'-',iTileEnd,'.',jTileStart,'-',jTileEnd
-!           write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)//'topo_10m/',iTileStart,'-',iTileEnd,'.',jTileStart,'-',jTileEnd
-write(0,*) trim(fname)
-
-            call read_geogrid(fname, len_trim(fname), &amp;
-                              rarray, &amp;
-                              nx, ny, nzz, &amp;
-                              isigned, endian, scalefactor, wordsize, istatus)
-            call init_atm_check_read_error(istatus, fname, dminfo)
-
-            iPoint = 1
-            do j=4,ny-3
-            do i=4,nx-3
-               lat_pt = -89.99583 + (jTileStart + j - 5) * 0.0083333333
-               lon_pt = -179.99583 + (iTileStart + i - 5) * 0.0083333333
-!              lat_pt = -89.91667 + (jTileStart + j - 5) * 0.166667
-!              lon_pt = -179.91667 + (iTileStart + i - 5) * 0.166667
-               lat_pt = lat_pt * pii / 180.0
-               lon_pt = lon_pt * pii / 180.0
-
-               iPoint = nearest_cell(lat_pt, lon_pt, &amp;
-                                     iPoint, &amp;
-                                     grid % nCells, grid % maxEdges, grid % nEdgesOnCell % array, grid % cellsOnCell % array, &amp;
-                                     grid % latCell % array, grid % lonCell % array)
-
-               ter(iPoint) = ter(iPoint) + rarray(i,j,1)
-               nhs(iPoint) = nhs(iPoint) + 1
-
-            end do
-            end do
-
-          end do
-       end do
-
-      do iCell=1, grid % nCells
-         ter(iCell) = ter(iCell) / real(nhs(iCell))
-      end do
-
-      deallocate(rarray)
-      deallocate(nhs)
-
-
-      !
-      ! Interpolate LU_INDEX
-      !
-      nx = 1200
-      ny = 1200
-      nzz = 1
-      isigned = 1
-      endian = 0
-      wordsize = 1
-      scalefactor = 1.0
-      allocate(rarray(nx,ny,nzz))
-      allocate(ncat(24,grid % nCells))
-      ncat(:,:) = 0
-      grid % lu_index % array(:) = 0.0
-
-      do jTileStart=1,20401,ny
-         jTileEnd = jTileStart + ny - 1
-         do iTileStart=1,42001,nx
-            iTileEnd = iTileStart + nx - 1
-            write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)//'/landuse_30s/',iTileStart,'-',iTileEnd,'.',jTileStart,'-',jTileEnd
-write(0,*) trim(fname)
-
-            call read_geogrid(fname, len_trim(fname), &amp;
-                              rarray, &amp;
-                              nx, ny, nzz, &amp;
-                              isigned, endian, scalefactor, wordsize, istatus)
-            call init_atm_check_read_error(istatus, fname, dminfo)
-
-            iPoint = 1
-            do j=1,ny
-            do i=1,nx
-               lat_pt = -89.99583 + (jTileStart + j - 2) * 0.0083333333
-               lon_pt = -179.99583 + (iTileStart + i - 2) * 0.0083333333
-               lat_pt = lat_pt * pii / 180.0
-               lon_pt = lon_pt * pii / 180.0
-
-               iPoint = nearest_cell(lat_pt, lon_pt, &amp;
-                                     iPoint, &amp;
-                                     grid % nCells, grid % maxEdges, grid % nEdgesOnCell % array, grid % cellsOnCell % array, &amp;
-                                     grid % latCell % array, grid % lonCell % array)
-
-               ncat(int(rarray(i,j,1)),iPoint) = ncat(int(rarray(i,j,1)),iPoint) + 1
-
-            end do
-            end do
-
-         end do
-      end do
-
-      do iCell=1, grid % nCells
-         grid % lu_index % array(iCell) = 1
-         do i=2,24
-            if (ncat(i,iCell) &gt; ncat(grid % lu_index % array(iCell),iCell)) then
-               grid % lu_index % array(iCell) = i
-            end if
-         end do
-      end do
-
-      deallocate(rarray)
-      deallocate(ncat)
-
-
-      !
-      ! Interpolate SOILCAT_TOP
-      !
-      nx = 1200
-      ny = 1200
-      nzz = 1
-      isigned = 1
-      endian = 0
-      wordsize = 1
-      scalefactor = 1.0
-      allocate(rarray(nx,ny,nzz))
-      allocate(ncat(16,grid % nCells))
-      ncat(:,:) = 0
-      grid % soilcat_top % array(:) = 0.0
-
-      do jTileStart=1,20401,ny
-         jTileEnd = jTileStart + ny - 1
-         do iTileStart=1,42001,nx
-            iTileEnd = iTileStart + nx - 1
-            write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)//'/soiltype_top_30s/',iTileStart,'-',iTileEnd,'.',jTileStart,'-',jTileEnd
-write(0,*) trim(fname)
-
-            call read_geogrid(fname, len_trim(fname), &amp;
-                              rarray, &amp;
-                              nx, ny, nzz, &amp;
-                              isigned, endian, scalefactor, wordsize, istatus)
-            call init_atm_check_read_error(istatus, fname, dminfo)
-
-            iPoint = 1
-            do j=1,ny
-            do i=1,nx
-               lat_pt = -89.99583 + (jTileStart + j - 2) * 0.0083333333
-               lon_pt = -179.99583 + (iTileStart + i - 2) * 0.0083333333
-               lat_pt = lat_pt * pii / 180.0
-               lon_pt = lon_pt * pii / 180.0
-
-               iPoint = nearest_cell(lat_pt, lon_pt, &amp;
-                                     iPoint, &amp;
-                                     grid % nCells, grid % maxEdges, grid % nEdgesOnCell % array, grid % cellsOnCell % array, &amp;
-                                     grid % latCell % array, grid % lonCell % array)
-
-               ncat(int(rarray(i,j,1)),iPoint) = ncat(int(rarray(i,j,1)),iPoint) + 1
-
-            end do
-            end do
-
-         end do
-      end do
-
-      do iCell=1, grid % nCells
-         grid % soilcat_top % array(iCell) = 1
-         do i=2,16
-            if (ncat(i,iCell) &gt; ncat(grid % soilcat_top % array(iCell),iCell)) then
-               grid % soilcat_top % array(iCell) = i
-            end if
-         end do
-      end do
-
-      deallocate(rarray)
-      deallocate(ncat)
-
-
-      !
-      ! Interpolate SOILCAT_BOT
-      !
-      nx = 1200
-      ny = 1200
-      nzz = 1
-      isigned = 1
-      endian = 0
-      wordsize = 1
-      scalefactor = 1.0
-      allocate(rarray(nx,ny,nzz))
-      allocate(ncat(16,grid % nCells))
-      ncat(:,:) = 0
-      grid % soilcat_bot % array(:) = 0.0
-
-      do jTileStart=1,20401,ny
-         jTileEnd = jTileStart + ny - 1
-         do iTileStart=1,42001,nx
-            iTileEnd = iTileStart + nx - 1
-            write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)//'/soiltype_bot_30s/',iTileStart,'-',iTileEnd,'.',jTileStart,'-',jTileEnd
-write(0,*) trim(fname)
-
-            call read_geogrid(fname, len_trim(fname), &amp;
-                              rarray, &amp;
-                              nx, ny, nzz, &amp;
-                              isigned, endian, scalefactor, wordsize, istatus)
-            call init_atm_check_read_error(istatus, fname, dminfo)
-
-            iPoint = 1
-            do j=1,ny
-            do i=1,nx
-               lat_pt = -89.99583 + (jTileStart + j - 2) * 0.0083333333
-               lon_pt = -179.99583 + (iTileStart + i - 2) * 0.0083333333
-               lat_pt = lat_pt * pii / 180.0
-               lon_pt = lon_pt * pii / 180.0
-
-               iPoint = nearest_cell(lat_pt, lon_pt, &amp;
-                                     iPoint, &amp;
-                                     grid % nCells, grid % maxEdges, grid % nEdgesOnCell % array, grid % cellsOnCell % array, &amp;
-                                     grid % latCell % array, grid % lonCell % array)
-
-               ncat(int(rarray(i,j,1)),iPoint) = ncat(int(rarray(i,j,1)),iPoint) + 1
-
-            end do
-            end do
-
-         end do
-      end do
-
-      do iCell=1, grid % nCells
-         grid % soilcat_bot % array(iCell) = 1
-         do i=2,16
-            if (ncat(i,iCell) &gt; ncat(grid % soilcat_bot % array(iCell),iCell)) then
-               grid % soilcat_bot % array(iCell) = i
-            end if
-         end do
-      end do
-
-      deallocate(rarray)
-      deallocate(ncat)
-
-
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! KLUDGE TO FIX SOIL TYPE OVER ANTARCTICA
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      where (grid % lu_index % array == 24) grid % soilcat_top % array = 16
-      where (grid % lu_index % array == 24) grid % soilcat_bot % array = 16
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! CORRECT INCONSISTENT SOIL AND LAND USE DATA
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      do iCell = 1,grid % nCells
-         if (grid % lu_index % array(iCell) == 16 .or. &amp;
-             grid % soilcat_top % array(iCell) == 14 .or. &amp;
-             grid % soilcat_bot % array(iCell) == 14) then
-            if (grid % lu_index % array(iCell) /= 16) then
-               write(0,*) 'Turning lu_index into water at ', iCell
-               grid % lu_index % array(iCell) = 16
-            end if
-            if (grid % soilcat_top % array(iCell) /= 14) then
-               write(0,*) 'Turning soilcat_top into water at ', iCell
-               grid % soilcat_top % array(iCell) = 14
-            end if
-            if (grid % soilcat_bot % array(iCell) /= 14) then
-               write(0,*) 'Turning soilcat_bot into water at ', iCell
-               grid % soilcat_bot % array(iCell) = 14
-            end if
-         end if
-      end do
-
-
-      !
-      ! Derive LANDMASK
-      !
-      grid % landmask % array(:) = 0
-      do iCell=1, grid % nCells
-         if (grid % lu_index % array(iCell) /= 16) grid % landmask % array(iCell) = 1
-      end do
-
-
-      !
-      ! Interpolate SOILTEMP:
-      !
-      nx = 186
-      ny = 186
-      nzz = 1
-      isigned = 0
-      endian = 0
-      wordsize = 2
-      scalefactor = 0.01
-      allocate(rarray(nx,ny,nzz))
-      allocate(soiltemp_1deg(360,180))
-      grid % soiltemp % array(:) = 0.0
-
-      call map_set(PROJ_LATLON, proj, &amp;
-                   latinc = 1.0_RKIND, &amp;
-                   loninc = 1.0_RKIND, &amp;
-                   knowni = 1.0_RKIND, &amp;
-                   knownj = 1.0_RKIND, &amp;
-                   lat1 = -89.5_RKIND, &amp;
-                   lon1 = -179.5_RKIND)
-
-      write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)//'soiltemp_1deg/',1,'-',180,'.',1,'-',180
-write(0,*) trim(fname)
-      call read_geogrid(fname, len_trim(fname), &amp;
-                        rarray, &amp;
-                        nx, ny, nzz, &amp;
-                        isigned, endian, scalefactor, wordsize, istatus)
-      call init_atm_check_read_error(istatus, fname, dminfo)
-
-      soiltemp_1deg(1:180,1:180) = rarray(4:183,4:183,1)
-
-      write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)//'soiltemp_1deg/',181,'-',360,'.',1,'-',180
-write(0,*) trim(fname)
-      call read_geogrid(fname, len_trim(fname), &amp;
-                        rarray, &amp;
-                        nx, ny, nzz, &amp;
-                        isigned, endian, scalefactor, wordsize, istatus)
-      call init_atm_check_read_error(istatus, fname, dminfo)
-
-      soiltemp_1deg(181:360,1:180) = rarray(4:183,4:183,1)
-
-      interp_list(1) = FOUR_POINT
-      interp_list(2) = W_AVERAGE4
-      interp_list(3) = W_AVERAGE16
-      interp_list(4) = SEARCH
-      interp_list(5) = 0
-
-      do iCell=1,grid%nCells
-  
-         if (grid % landmask % array(iCell) == 1) then
-            lat = grid % latCell % array(iCell)*DEG_PER_RAD
-            lon = grid % lonCell % array(iCell)*DEG_PER_RAD
-            call latlon_to_ij(proj, lat, lon, x, y)
-            if (x &lt; 0.5) then
-               lon = lon + 360.0
-               call latlon_to_ij(proj, lat, lon, x, y)
-            else if (x &gt;= 360.5) then
-               lon = lon - 360.0
-               call latlon_to_ij(proj, lat, lon, x, y)
-            end if
-if (y &lt; 1.0) y = 1.0
-if (y &gt; 179.0) y = 179.0
-!            grid % soiltemp % array(iCell) = interp_sequence(x, y, 1, soiltemp_1deg, 1, 360, 1, 180, 1, 1, -1.e30_RKIND, interp_list, 1)
-            grid % soiltemp % array(iCell) = interp_sequence(x, y, 1, soiltemp_1deg, 1, 360, 1, 180, 1, 1, 0.0_RKIND, interp_list, 1)
-         else
-            grid % soiltemp % array(iCell) = 0.0
-         end if
-
-      end do
-
-      deallocate(rarray)
-      deallocate(soiltemp_1deg)
-
-
-      !
-      ! Interpolate SNOALB
-      !
-      nx = 186
-      ny = 186
-      nzz = 1
-      isigned = 0
-      endian = 0
-      wordsize = 1
-      scalefactor = 1.0
-      allocate(rarray(nx,ny,nzz))
-      allocate(maxsnowalb(360,180))
-      grid % snoalb % array(:) = 0.0
-
-      call map_set(PROJ_LATLON, proj, &amp;
-                   latinc = 1.0_RKIND, &amp;
-                   loninc = 1.0_RKIND, &amp;
-                   knowni = 1.0_RKIND, &amp;
-                   knownj = 1.0_RKIND, &amp;
-                   lat1 = -89.5_RKIND, &amp;
-                   lon1 = -179.5_RKIND)
-
-      write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)//'maxsnowalb/',1,'-',180,'.',1,'-',180
-write(0,*) trim(fname)
-      call read_geogrid(fname, len_trim(fname), &amp;
-                        rarray, &amp;
-                        nx, ny, nzz, &amp;
-                        isigned, endian, scalefactor, wordsize, istatus)
-      call init_atm_check_read_error(istatus, fname, dminfo)
-
-      maxsnowalb(1:180,1:180) = rarray(4:183,4:183,1)
-
-      write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)//'maxsnowalb/',181,'-',360,'.',1,'-',180
-write(0,*) trim(fname)
-      call read_geogrid(fname, len_trim(fname), &amp;
-                        rarray, &amp;
-                        nx, ny, nzz, &amp;
-                        isigned, endian, scalefactor, wordsize, istatus)
-      call init_atm_check_read_error(istatus, fname, dminfo)
-
-      maxsnowalb(181:360,1:180) = rarray(4:183,4:183,1)
-
-      interp_list(1) = FOUR_POINT
-      interp_list(2) = W_AVERAGE4
-      interp_list(3) = W_AVERAGE16
-      interp_list(4) = SEARCH
-      interp_list(5) = 0
-
-      do iCell=1,grid%nCells
-  
-         if (grid % landmask % array(iCell) == 1) then
-            lat = grid % latCell % array(iCell)*DEG_PER_RAD
-            lon = grid % lonCell % array(iCell)*DEG_PER_RAD
-            call latlon_to_ij(proj, lat, lon, x, y)
-            if (x &lt; 0.5) then
-               lon = lon + 360.0
-               call latlon_to_ij(proj, lat, lon, x, y)
-            else if (x &gt;= 360.5) then
-               lon = lon - 360.0
-               call latlon_to_ij(proj, lat, lon, x, y)
-            end if
-if (y &lt; 1.0) y = 1.0
-if (y &gt; 179.0) y = 179.0
-!            grid % snoalb % array(iCell) = interp_sequence(x, y, 1, maxsnowalb, 1, 360, 1, 180, 1, 1, -1.e30_RKIND, interp_list, 1)
-            grid % snoalb % array(iCell) = interp_sequence(x, y, 1, maxsnowalb, 1, 360, 1, 180, 1, 1, 0.0_RKIND, interp_list, 1)
-         else
-            grid % snoalb % array(iCell) = 0.0
-         end if
-
-      end do
-
-      grid % snoalb % array(:) = grid % snoalb % array(:) / 100.0
-
-      deallocate(rarray)
-      deallocate(maxsnowalb)
-
-
-      !
-      ! Interpolate GREENFRAC
-      !
-      nx = 1256
-      ny = 1256
-      nzz = 12
-      isigned = 0
-      endian = 0
-      wordsize = 1
-      scalefactor = 1.0
-      allocate(rarray(nx,ny,nzz))
-      allocate(vegfra(2500,1250,12))
-!     grid % vegfra % array(:) = 0.0
-      grid % greenfrac % array(:,:) = 0.0
-
-      call map_set(PROJ_LATLON, proj, &amp;
-                   latinc = 0.144_RKIND, &amp;
-                   loninc = 0.144_RKIND, &amp;
-                   knowni = 1.0_RKIND, &amp;
-                   knownj = 1.0_RKIND, &amp;
-                   lat1 = -89.928_RKIND, &amp;
-                   lon1 = -179.928_RKIND)
-
-      write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)//'greenfrac/',1,'-',1250,'.',1,'-',1250
-write(0,*) trim(fname)
-      call read_geogrid(fname, len_trim(fname), &amp;
-                        rarray, &amp;
-                        nx, ny, nzz, &amp;
-                        isigned, endian, scalefactor, wordsize, istatus)
-      call init_atm_check_read_error(istatus, fname, dminfo)
-
-      vegfra(1:1250,1:1250,1:12) = rarray(4:1253,4:1253,1:12)
-
-      write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)//'greenfrac/',1251,'-',2500,'.',1,'-',1250
-write(0,*) trim(fname)
-      call read_geogrid(fname, len_trim(fname), &amp;
-                        rarray, &amp;
-                        nx, ny, nzz, &amp;
-                        isigned, endian, scalefactor, wordsize, istatus)
-      call init_atm_check_read_error(istatus, fname, dminfo)
-
-      vegfra(1251:2500,1:1250,1:12) = rarray(4:1253,4:1253,1:12)
-
-      do iCell=1,grid%nCells
-         if (grid % landmask % array(iCell) == 1) then
-            lat = grid % latCell % array(iCell)*DEG_PER_RAD
-            lon = grid % lonCell % array(iCell)*DEG_PER_RAD
-            call latlon_to_ij(proj, lat, lon, x, y)
-            if (x &lt; 0.5) then
-               lon = lon + 360.0
-               call latlon_to_ij(proj, lat, lon, x, y)
-            else if (x &gt;= 2500.5) then
-               lon = lon - 360.0
-               call latlon_to_ij(proj, lat, lon, x, y)
-            end if
-if (y &lt; 1.0) y = 1.0
-if (y &gt; 1249.0) y = 1249.0
-            do k=1,12
-               grid % greenfrac % array(k,iCell) = interp_sequence(x, y, k, vegfra, 1, 2500, 1, 1250, 1, 12, -1.e30_RKIND, interp_list, 1)
-            end do
-         else
-            grid % greenfrac % array(:,iCell) = 0.0
-         end if
-         grid % shdmin % array(iCell) = minval(grid % greenfrac % array(:,iCell))
-         grid % shdmax % array(iCell) = maxval(grid % greenfrac % array(:,iCell))
-      
-      end do
-
-      deallocate(rarray)
-      deallocate(vegfra)
-
-
-      !
-      ! Interpolate ALBEDO12M
-      !
-      nx = 1256
-      ny = 1256
-      nzz = 12
-      isigned = 0
-      endian = 0
-      wordsize = 1
-      scalefactor = 1.0
-      allocate(rarray(nx,ny,nzz))
-      allocate(vegfra(2500,1250,12))
-      grid % albedo12m % array(:,:) = 0.0
-
-      call map_set(PROJ_LATLON, proj, &amp;
-                   latinc = 0.144_RKIND, &amp;
-                   loninc = 0.144_RKIND, &amp;
-                   knowni = 1.0_RKIND, &amp;
-                   knownj = 1.0_RKIND, &amp;
-                   lat1 = -89.928_RKIND, &amp;
-                   lon1 = -179.928_RKIND)
-
-      write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)//'albedo_ncep/',1,'-',1250,'.',1,'-',1250
-write(0,*) trim(fname)
-      call read_geogrid(fname, len_trim(fname), &amp;
-                        rarray, &amp;
-                        nx, ny, nzz, &amp;
-                        isigned, endian, scalefactor, wordsize, istatus)
-      call init_atm_check_read_error(istatus, fname, dminfo)
-
-      vegfra(1:1250,1:1250,1:12) = rarray(4:1253,4:1253,1:12)
-
-      write(fname,'(a,i5.5,a1,i5.5,a1,i5.5,a1,i5.5)') trim(config_geog_data_path)//'albedo_ncep/',1251,'-',2500,'.',1,'-',1250
-write(0,*) trim(fname)
-      call read_geogrid(fname, len_trim(fname), &amp;
-                        rarray, &amp;
-                        nx, ny, nzz, &amp;
-                        isigned, endian, scalefactor, wordsize, istatus)
-      call init_atm_check_read_error(istatus, fname, dminfo)
-
-      vegfra(1251:2500,1:1250,1:12) = rarray(4:1253,4:1253,1:12)
-
-      do iCell=1,grid%nCells
-         if (grid % landmask % array(iCell) == 1) then
-            lat = grid % latCell % array(iCell)*DEG_PER_RAD
-            lon = grid % lonCell % array(iCell)*DEG_PER_RAD
-            call latlon_to_ij(proj, lat, lon, x, y)
-            if (x &lt; 0.5) then
-               lon = lon + 360.0
-               call latlon_to_ij(proj, lat, lon, x, y)
-            else if (x &gt;= 2500.5) then
-               lon = lon - 360.0
-               call latlon_to_ij(proj, lat, lon, x, y)
-            end if
-if (y &lt; 1.0) y = 1.0
-if (y &gt; 1249.0) y = 1249.0
-            do k=1,12
-               grid % albedo12m % array(k,iCell) = interp_sequence(x, y, k, vegfra, 1, 2500, 1, 1250, 1, 12, 0.0_RKIND, interp_list, 1)
-            end do
-         else
-            grid % albedo12m % array(:,iCell) = 8.0
-         end if
-      end do
-
-      deallocate(rarray)
-      deallocate(vegfra)
-

-      end if    ! config_static_interp
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 ! BEGIN ADOPT GFS TERRAIN HEIGHT
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
@@ -3120,22 +2503,27 @@
 
          do iCell=1,grid%nCells
             hs(iCell) = 0.
-            do j = 1,nEdgesOnCell(iCell)
-               hs(iCell) = hs(iCell) + dvEdge(edgesOnCell(j,iCell))    &amp;
-                                     / dcEdge(edgesOnCell(j,iCell))    &amp;
-                                     *   (ter(cellsOnCell(j,iCell))-ter(iCell))
-            end do
-            hs(iCell) = ter(iCell) + 0.25*hs(iCell)
+            if(ter(iCell) .ne. 0.) then
+               do j = 1,nEdgesOnCell(iCell)
+                  hs(iCell) = hs(iCell) + dvEdge(edgesOnCell(j,iCell))    &amp;
+                                        / dcEdge(edgesOnCell(j,iCell))    &amp;
+                                        * (ter(cellsOnCell(j,iCell))-ter(iCell))
+               end do
+            endif
+            hs(iCell) = ter(iCell) + 0.125*hs(iCell)
          end do
 
          do iCell=1,grid %nCells
             ter(iCell) = 0.
-            do j = 1,nEdgesOnCell(iCell)
-               ter(iCell) = ter(iCell) + dvEdge(edgesOnCell(j,iCell))    &amp;
-                                     / dcEdge(edgesOnCell(j,iCell))    &amp;
-                                     *    (hs(cellsOnCell(j,iCell))-hs(iCell))
-            end do
-            ter(iCell) = hs(iCell) - 0.25*ter(iCell)
+            if(hs(iCell) .ne. 0.) then
+               do j = 1,nEdgesOnCell(iCell)
+                  ter(iCell) = ter(iCell) + dvEdge(edgesOnCell(j,iCell))    &amp;
+                                          / dcEdge(edgesOnCell(j,iCell))    &amp;
+                                          * (hs(cellsOnCell(j,iCell))-hs(iCell))
+               end do
+            endif
+!           ter(iCell) = hs(iCell) - 0.25*ter(iCell)
+            ter(iCell) = hs(iCell) - 0.125*ter(iCell)
          end do
 
          ! note that ther variable ter used throughout this section is a pointer to grid % ter % array, here we are passing ter's parent field
@@ -3147,7 +2535,9 @@
          hx(:,iCell) = ter(iCell)
       end do
 
-      hm = maxval(ter(:))
+      hm = maxval(ter(1:nCellsSolve))
+      call mpas_dmpar_max_real(dminfo, hm, hm_global)
+      hm = hm_global
       write(0,*) &quot;max ter = &quot;, hm
 
 !     Metrics for hybrid coordinate and vertical stretching
@@ -3243,7 +2633,7 @@
 
       if (smooth) then
 
-         dzmin = 0.3
+         dzmin = 0.5
 
          do k=2,kz-1
             hx(k,:) = hx(k-1,:)
@@ -3251,9 +2641,9 @@
 
 !            dzmin = max(0.5_RKIND,1.-.5*zw(k)/hm)
 
-            sm = .05*min(0.5_RKIND*zw(k)/hm,1.0_RKIND)
+            sm = .02*min(0.5_RKIND*zw(k)/hm,1.0_RKIND)
           
-            do i=1,50
+            do i=1,30
                do iCell=1,grid % nCells
                   hs1(iCell) = 0.
                   do j = 1,nEdgesOnCell(iCell)
@@ -3287,7 +2677,7 @@
                call mpas_dmpar_exch_halo_field(tempField)
 
              !  dzmina = minval(hs(:)-hx(k-1,:))
-               dzmina = minval(zw(k)+ah(k)*hs(1:grid%nCellsSolve)-zw(k-1)-ah(k-1)*hx(k-1,1:grid%nCellsSolve))
+               dzmina = minval(zw(k)+ah(k)*hs(1:nCellsSolve)-zw(k-1)-ah(k-1)*hx(k-1,1:nCellsSolve))
                call mpas_dmpar_min_real(dminfo, dzmina, dzmina_global)
              !  write(0,*) ' k,i, dzmina, dzmin, zw(k)-zw(k-1) ', k,i, dzmina, dzmin, zw(k)-zw(k-1)
                if (dzmina_global &gt;= dzmin*(zw(k)-zw(k-1))) then
@@ -3428,7 +2818,7 @@
       do while (istatus == 0)
          if (index(field % field, 'LANDSEA') /= 0) then
 
-            allocate(maskslab(-3:field % nx+3, field % ny))
+            allocate(maskslab(-2:field % nx+3, field % ny))
             maskslab(1:field % nx, 1:field % ny) = field % slab(1:field % nx, 1:field % ny)
             maskslab(0, 1:field % ny)  = field % slab(field % nx, 1:field % ny)
             maskslab(-1, 1:field % ny) = field % slab(field % nx-1, 1:field % ny)
@@ -3849,7 +3239,8 @@
             else if (index(field % field, 'SEAICE') /= 0) then
 write(0,*) 'Interpolating SEAICE'
 
-               interp_list(1) = SIXTEEN_POINT
+               !interp_list(1) = SIXTEEN_POINT
+               interp_list(1) = FOUR_POINT
                interp_list(2) = FOUR_POINT
                interp_list(3) = W_AVERAGE4
                interp_list(4) = SEARCH
@@ -3873,7 +3264,7 @@
                ndims = 1
             end if
 
-            allocate(rslab(-3:field % nx+3, field % ny))
+            allocate(rslab(-2:field % nx+3, field % ny))
             rslab(1:field % nx, 1:field % ny) = field % slab(1:field % nx, 1:field % ny)
             rslab(0, 1:field % ny)  = field % slab(field % nx, 1:field % ny)
             rslab(-1, 1:field % ny) = field % slab(field % nx-1, 1:field % ny)
@@ -3892,9 +3283,9 @@
                      call latlon_to_ij(proj, lat, lon, x, y)
                   end if
                   if (ndims == 1) then
-                     destField1d(i) = interp_sequence(x, y, 1, rslab, -3, field % nx + 3, 1, field % ny, 1, 1, msgval, interp_list, 1, maskval=maskval, mask_array=maskslab)
+                     destField1d(i) = interp_sequence(x, y, 1, rslab, -2, field % nx + 3, 1, field % ny, 1, 1, msgval, interp_list, 1, maskval=maskval, mask_array=maskslab)
                   else if (ndims == 2) then
-                     destField2d(k,i) = interp_sequence(x, y, 1, rslab, -3, field % nx + 3, 1, field % ny, 1, 1, msgval, interp_list, 1, maskval=maskval, mask_array=maskslab)
+                     destField2d(k,i) = interp_sequence(x, y, 1, rslab, -2, field % nx + 3, 1, field % ny, 1, 1, msgval, interp_list, 1, maskval=maskval, mask_array=maskslab)
                   end if
                else
                   if (ndims == 1) then
@@ -4050,28 +3441,17 @@
       ! Freeze really cold ocean
       where (fg % sst % array &lt; 271.0 .and. grid % landmask % array == 0) fg % xice % array = 1.0
 
+      ! Limit XICE to values between 0 and 1. Although the input meteorological field is between 0.
+      ! and 1., interpolation to the MPAS grid can yield values of XiCE less than 0. and greater
+      ! than 1.:
+      where (fg % xice % array &lt; 0._RKIND) fg % xice % array = 0._RKIND
+      where (fg % xice % array &gt; 1._RKIND) fg % xice % array = 1._RKIND
+
       ! Set SEAICE (0/1 flag) based on XICE (fractional ice coverage)
       fg % seaice % array(:) = 0.0
       where (fg % xice % array &gt;= 0.5) fg % seaice % array = 1.0
 
 
-      !
-      ! For now, hard-wire soil layer depths and thicknesses
-      !
-
-      !LDF begin:
-      !fg % dzs % array(1,:) = 0.10
-      !fg % dzs % array(2,:) = 0.30
-      !fg % dzs % array(3,:) = 0.60
-      !fg % dzs % array(4,:) = 1.00
-
-      !fg % dz % array(1,:) = 0.05
-      !fg % dz % array(2,:) = 0.25
-      !fg % dz % array(3,:) = 0.70
-      !fg % dz % array(4,:) = 1.50
-      !LDF end.
-
-
       !  
       ! Compute normal wind component and store in fg%u
       !  
@@ -4101,7 +3481,9 @@
          call mpas_quicksort(config_nfglevels, sorted_arr)
          do k=1,grid%nVertLevels
             target_z = 0.5 * (grid % zgrid % array(k,iCell) + grid % zgrid % array(k+1,iCell))
-            state % theta_m % array(k,iCell) = vertical_interp(target_z, config_nfglevels, sorted_arr, order=1, extrap=1)
+!           state % theta_m % array(k,iCell) = vertical_interp(target_z, config_nfglevels, sorted_arr, order=1, extrap=1)
+            state % theta_m % array(k,iCell) = vertical_interp(target_z, config_nfglevels-1, &amp;
+                                      sorted_arr(:,1:config_nfglevels-1), order=1, extrap=1)
          end do
 
 
@@ -4116,7 +3498,10 @@
          call mpas_quicksort(config_nfglevels, sorted_arr)
          do k=1,grid%nVertLevels
             target_z = 0.5 * (grid % zgrid % array(k,iCell) + grid % zgrid % array(k+1,iCell))
-            state % scalars % array(state % index_qv,k,iCell) = vertical_interp(target_z, config_nfglevels, sorted_arr, order=1, extrap=0)
+!           state % scalars % array(state % index_qv,k,iCell) = vertical_interp(target_z, config_nfglevels, sorted_arr, order=1, extrap=0)
+            state % scalars % array(state % index_qv,k,iCell) = vertical_interp(target_z, config_nfglevels-1, &amp;
+                                                       sorted_arr(:,1:config_nfglevels-1), order=1, extrap=1)
+            diag % rh % array(k,iCell) = state % scalars % array(state % index_qv,k,iCell)
          end do
 
 
@@ -4131,7 +3516,9 @@
          call mpas_quicksort(config_nfglevels, sorted_arr)
          do k=1,grid%nVertLevels
             target_z = 0.5 * (grid % zgrid % array(k,iCell) + grid % zgrid % array(k+1,iCell))
-            fg % gfs_z % array(k,iCell) = vertical_interp(target_z, config_nfglevels, sorted_arr, order=1, extrap=1)
+!           fg % gfs_z % array(k,iCell) = vertical_interp(target_z, config_nfglevels, sorted_arr, order=1, extrap=1)
+            fg % gfs_z % array(k,iCell) = vertical_interp(target_z, config_nfglevels-1, &amp;
+                                 sorted_arr(:,1:config_nfglevels-1), order=1, extrap=1)
          end do
 
 
@@ -4149,7 +3536,9 @@
          call mpas_quicksort(config_nfglevels, sorted_arr)
          do k=1,grid%nVertLevels
             target_z = 0.5 * (grid % zgrid % array(k,iCell) + grid % zgrid % array(k+1,iCell))
-            diag % pressure % array(k,iCell) = exp(vertical_interp(target_z, config_nfglevels, sorted_arr, order=1, extrap=1))
+!           diag % pressure % array(k,iCell) = exp(vertical_interp(target_z, config_nfglevels, sorted_arr, order=1, extrap=1))
+            diag % pressure % array(k,iCell) = exp(vertical_interp(target_z, config_nfglevels-1, &amp;
+                                         sorted_arr(:,1:config_nfglevels-1), order=1, extrap=1))
          end do
 
 
@@ -4186,7 +3575,9 @@
          call mpas_quicksort(config_nfglevels, sorted_arr)
          do k=1,grid%nVertLevels
             target_z = 0.25 * (grid % zgrid % array(k,cellsOnEdge(1,iEdge)) + grid % zgrid % array(k+1,cellsOnEdge(1,iEdge)) + grid % zgrid % array(k,cellsOnEdge(2,iEdge)) + grid % zgrid % array(k+1,cellsOnEdge(2,iEdge)))
-            state % u % array(k,iEdge) = vertical_interp(target_z, config_nfglevels, sorted_arr, order=1, extrap=0)
+!           state % u % array(k,iEdge) = vertical_interp(target_z, config_nfglevels, sorted_arr, order=1, extrap=0)
+            state % u % array(k,iEdge) = vertical_interp(target_z, config_nfglevels-1, &amp; 
+                                sorted_arr(:,1:config_nfglevels-1), order=1, extrap=1)
          end do
 
       end do
@@ -4243,8 +3634,8 @@
 
             ! QV
             es = 6.112 * exp((17.27*(state % theta_m % array(k,iCell) - 273.16))/(state % theta_m % array(k,iCell) - 35.86))
-            rs = 0.622 * es / (diag % pressure % array(k,iCell) - es)
-            scalars(state % index_qv,k,iCell) = rs * scalars(state % index_qv,k,iCell)
+            rs = 0.622 * es * 100. / (diag % pressure % array(k,iCell) - es * 100.)
+            scalars(state % index_qv,k,iCell) = 0.01 * rs * scalars(state % index_qv,k,iCell)
 
             ! PI
             p(k,iCell) = (diag % pressure % array(k,iCell) / p0) ** (rgas / cp)
@@ -4261,6 +3652,17 @@
 
 
       !
+      ! Calculation of the initial precipitable water:
+      ! 
+      do iCell = 1,grid%nCells
+         diag_physics%precipw%array(iCell) = 0.0
+         do k = 1,grid%nVertLevels
+            diag_physics%precipw%array(iCell) = diag_physics%precipw%array(iCell) &amp;
+                         + rho_zz(k,iCell)*scalars(state%index_qv,k,iCell)*(zgrid(k+1,iCell)-zgrid(k,iCell))
+         enddo
+      enddo
+
+      !
       ! Reference state based on a dry isothermal atmosphere
       !
       do iCell=1,grid % nCells
@@ -4387,242 +3789,6 @@
    end subroutine init_atm_test_case_gfs
 
 
-   subroutine init_atm_test_case_sfc(domain, dminfo, grid, fg, state, diag, test_case, parinfo)
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   ! Real-data test case using SST data
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      use mpas_dmpar
-      use mpas_io_output
-      use init_atm_read_met
-      use init_atm_llxy
-      use init_atm_hinterp
-
-      implicit none
-
-      type (domain_type), intent(inout) :: domain
-      type (dm_info), intent(in) :: dminfo
-      type (mesh_type), intent(inout) :: grid
-      type (fg_type), intent(inout) :: fg
-      type (state_type), intent(inout) :: state
-      type (diag_type), intent(inout) :: diag
-      integer, intent(in) :: test_case
-      type (parallel_info), pointer :: parinfo
-
-      integer :: istatus
-      integer :: iCell, i, j
-      type (met_data) :: field
-      type (proj_info) :: proj
-      real (kind=RKIND) :: lat, lon, x, y
-      integer, dimension(5) :: interp_list
-      real (kind=RKIND), allocatable, dimension(:,:) :: slab_r8
-      type (io_output_object) :: sfc_update_obj
-      type (MPAS_Clock_type) :: fg_clock
-      type (MPAS_Time_type) :: start_time, stop_time, curr_time
-      type (MPAS_TimeInterval_type) :: fg_interval
-      character (len=StrKIND) :: timeString
-
-
-      ! Set interpolation sequence to be used for SST/SKINTEMP field
-      interp_list(1) = FOUR_POINT
-      interp_list(2) = SEARCH
-      interp_list(3) = 0
-
-
-      ! Set up clock to step through all intermediate file dates to be processed
-      call mpas_set_time(start_time, dateTimeString=trim(config_start_time))
-      call mpas_set_time(stop_time,  dateTimeString=trim(config_stop_time))
-      call mpas_set_timeInterval(fg_interval, S=config_fg_interval)
-
-      call mpas_create_clock(fg_clock, start_time, fg_interval, stopTime=stop_time) 
-
-
-      ! Initialize the output file
-      sfc_update_obj % time = 1
-      sfc_update_obj % filename = trim(config_sfc_update_name)
-
-      call mpas_output_state_init(sfc_update_obj, domain, &quot;SFC&quot;)
-
-      ! Loop over all times, interpolating the SST/SKINTEMP field from each intermediate file
-      curr_time = mpas_get_clock_time(fg_clock, MPAS_NOW) 
-      do while (curr_time &lt;= stop_time)
-         call mpas_get_time(curr_time, dateTimeString=timeString)
-         write(0,*) 'Processing ',trim(config_sfc_prefix)//':'//timeString(1:13)
-
-         ! Open intermediate file
-         call read_met_init(trim(config_sfc_prefix), .false., timeString(1:13), istatus)
-         if (istatus /= 0) then
-            write(0,*) 'Error reading ',trim(config_sfc_prefix)//':'//timeString(1:13)
-            exit
-         end if
-
-         ! Scan through all fields in the file, looking for the SST or SKINTEMP field
-         call read_next_met_field(field, istatus)
-         do while (istatus == 0)
-
-            !initialization of sea-surface temperature (SST) and sea-ice fraction (XICE) arrays,
-            !prior to reading the input data:
-            fg % sst  % array (1:grid%nCells) = 0.0
-            fg % xice % array (1:grid%nCells) = 0.0
-
-            if (index(field % field, 'SKINTEMP') /= 0 .or. index(field % field, 'SST') /= 0) then
-
-               ! Interpolation routines use real(kind=RKIND), so copy from default real array
-               allocate(slab_r8(field % nx, field % ny))
-               do j=1,field % ny
-               do i=1,field % nx
-                  slab_r8(i,j) = field % slab(i,j)
-               end do
-               end do
-
-               !
-               ! Set up map projection
-               !
-               call map_init(proj)
-             
-               if (field % iproj == PROJ_LATLON) then
-                  call map_set(PROJ_LATLON, proj, &amp;
-                               latinc = real(field % deltalat,RKIND), &amp;
-                               loninc = real(field % deltalon,RKIND), &amp;
-                               knowni = 1.0_RKIND, &amp;
-                               knownj = 1.0_RKIND, &amp;
-                               lat1 = real(field % startlat,RKIND), &amp;
-                               lon1 = real(field % startlon,RKIND))
-               else if (field % iproj == PROJ_GAUSS) then
-                  call map_set(PROJ_GAUSS, proj, &amp;
-                               nlat = nint(field % deltalat), &amp;
-                               loninc = real(field % deltalon,RKIND), &amp;
-                               lat1 = real(field % startlat,RKIND), &amp;
-                               lon1 = real(field % startlon,RKIND))
-!                               nxmax = nint(360.0 / field % deltalon), &amp;
-               else if (field % iproj == PROJ_PS) then
-                  call map_set(PROJ_PS, proj, &amp;
-                               dx = real(field % dx,RKIND), &amp;
-                               truelat1 = real(field % truelat1,RKIND), &amp;
-                               stdlon = real(field % xlonc,RKIND), &amp;
-                               knowni = real(field % nx / 2.0,RKIND), &amp;
-                               knownj = real(field % ny / 2.0,RKIND), &amp;
-                               lat1 = real(field % startlat,RKIND), &amp;
-                               lon1 = real(field % startlon,RKIND))
-               end if
-   
-               ! Interpolate SST/SKINTEMP field to each MPAS grid cell
-               do iCell=1,grid % nCells
-                  lat = grid % latCell % array(iCell) * DEG_PER_RAD
-                  lon = grid % lonCell % array(iCell) * DEG_PER_RAD
-                  call latlon_to_ij(proj, lat, lon, x, y)
-                  if (y &lt; 0.5) then
-                     y = 1.0
-                  else if (y &gt;= real(field%ny)+0.5) then
-                     y = real(field % ny)
-                  end if
-                  if (x &lt; 0.5) then
-                     lon = lon + 360.0
-                     call latlon_to_ij(proj, lat, lon, x, y)
-                  else if (x &gt;= real(field%nx)+0.5) then
-                     lon = lon - 360.0
-                     call latlon_to_ij(proj, lat, lon, x, y)
-                  end if
-                  fg % sst % array(iCell) = interp_sequence(x, y, 1, slab_r8, 1, field % nx, 1, field % ny, 1, 1, -1.e30_RKIND, interp_list, 1)
-               end do
-
-               deallocate(slab_r8)
-               deallocate(field % slab)
-
-            else if (index(field % field, 'SEAICE') /= 0) then
-
-               ! Interpolation routines use real(kind=RKIND), so copy from default real array
-               allocate(slab_r8(field % nx, field % ny))
-               do j=1,field % ny
-               do i=1,field % nx
-                  slab_r8(i,j) = field % slab(i,j)
-               end do
-               end do
-
-               !
-               ! Set up map projection
-               !
-               call map_init(proj)
-             
-               if (field % iproj == PROJ_LATLON) then
-                  call map_set(PROJ_LATLON, proj, &amp;
-                               latinc = real(field % deltalat,RKIND), &amp;
-                               loninc = real(field % deltalon,RKIND), &amp;
-                               knowni = 1.0_RKIND, &amp;
-                               knownj = 1.0_RKIND, &amp;
-                               lat1 = real(field % startlat,RKIND), &amp;
-                               lon1 = real(field % startlon,RKIND))
-               else if (field % iproj == PROJ_GAUSS) then
-                  call map_set(PROJ_GAUSS, proj, &amp;
-                               nlat = nint(field % deltalat), &amp;
-                               loninc = real(field % deltalon,RKIND), &amp;
-                               lat1 = real(field % startlat,RKIND), &amp;
-                               lon1 = real(field % startlon,RKIND))
-!                               nxmax = nint(360.0 / field % deltalon), &amp;
-               else if (field % iproj == PROJ_PS) then
-                  call map_set(PROJ_PS, proj, &amp;
-                               dx = real(field % dx,RKIND), &amp;
-                               truelat1 = real(field % truelat1,RKIND), &amp;
-                               stdlon = real(field % xlonc,RKIND), &amp;
-                               knowni = real(field % nx / 2.0,RKIND), &amp;
-                               knownj = real(field % ny / 2.0,RKIND), &amp;
-                               lat1 = real(field % startlat,RKIND), &amp;
-                               lon1 = real(field % startlon,RKIND))
-               end if
-   
-               ! Interpolate SEAICE/SKINTEMP field to each MPAS grid cell
-               do iCell=1,grid % nCells
-                  lat = grid % latCell % array(iCell) * DEG_PER_RAD
-                  lon = grid % lonCell % array(iCell) * DEG_PER_RAD
-                  call latlon_to_ij(proj, lat, lon, x, y)
-                  if (y &lt; 0.5) then
-                     y = 1.0
-                  else if (y &gt;= real(field%ny)+0.5) then
-                     y = real(field % ny)
-                  end if
-                  if (x &lt; 0.5) then
-                     lon = lon + 360.0
-                     call latlon_to_ij(proj, lat, lon, x, y)
-                  else if (x &gt;= real(field%nx)+0.5) then
-                     lon = lon - 360.0
-                     call latlon_to_ij(proj, lat, lon, x, y)
-                  end if
-                  fg % xice % array(iCell) = interp_sequence(x, y, 1, slab_r8, 1, field % nx, 1, field % ny, 1, 1, -1.e30_RKIND, interp_list, 1)
-                  if (fg % xice % array(iCell) == -1.e30_RKIND) fg % xice % array(iCell) = 0.0_RKIND
-
-               end do
-
-               deallocate(slab_r8)
-               deallocate(field % slab)
-
-            else
-
-               deallocate(field % slab)
-            end if
-
-            call read_next_met_field(field, istatus)
-         end do
-
-         ! Close intermediate file
-         call read_met_close()
-
-         ! Write the interpolated SST/SKINTEMP field as a new time slice in the MPAS output file
-         call mpas_output_state_for_domain(sfc_update_obj, domain, sfc_update_obj % time)
-         sfc_update_obj % time = sfc_update_obj % time + 1
-
-         call mpas_advance_clock(fg_clock)
-         curr_time = mpas_get_clock_time(fg_clock, MPAS_NOW) 
-
-         call mpas_get_time(curr_time, dateTimeString=timeString)
-         state % xtime % scalar = timeString
-
-      end do
-
-      call mpas_output_state_finalize(sfc_update_obj, dminfo)
-      
-   end subroutine init_atm_test_case_sfc
-
-
 !---------------------  TEST CASE 9 -----------------------------------------------
 
 
@@ -6200,48 +5366,6 @@
    end subroutine init_atm_test_case_resting_atmosphere
 
 
-   integer function nearest_cell(target_lat, target_lon, &amp;
-                                 start_cell, &amp;
-                                 nCells, maxEdges, nEdgesOnCell, cellsOnCell, latCell, lonCell)
-
-      implicit none
-
-      real (kind=RKIND), intent(in) :: target_lat, target_lon
-      integer, intent(in) :: start_cell
-      integer, intent(in) :: nCells, maxEdges
-      integer, dimension(nCells), intent(in) :: nEdgesOnCell
-      integer, dimension(maxEdges,nCells), intent(in) :: cellsOnCell
-      real (kind=RKIND), dimension(nCells), intent(in) :: latCell, lonCell
-
-      integer :: i
-      integer :: iCell
-      integer :: current_cell
-      real (kind=RKIND) :: current_distance, d
-      real (kind=RKIND) :: nearest_distance
-
-      nearest_cell = start_cell
-      current_cell = -1
-
-      do while (nearest_cell /= current_cell)
-         current_cell = nearest_cell
-         current_distance = sphere_distance(latCell(current_cell), lonCell(current_cell), target_lat, target_lon, 1.0_RKIND)
-         nearest_cell = current_cell
-         nearest_distance = current_distance
-         do i = 1, nEdgesOnCell(current_cell)
-            iCell = cellsOnCell(i,current_cell)
-            if (iCell &lt;= nCells) then
-               d = sphere_distance(latCell(iCell), lonCell(iCell), target_lat, target_lon, 1.0_RKIND)
-               if (d &lt; nearest_distance) then
-                  nearest_cell = iCell
-                  nearest_distance = d
-               end if
-            end if
-         end do
-      end do
-
-   end function nearest_cell
-
-
    integer function nearest_edge(target_lat, target_lon, &amp;
                                  start_edge, &amp;
                                  nCells, nEdges, maxEdges, nEdgesOnCell, edgesOnCell, cellsOnEdge, latCell, lonCell, latEdge, lonEdge)
@@ -6325,7 +5449,7 @@
       if (present(extrap)) then
          extrap_type = extrap
       else
-         interp_order = 1
+         extrap_type = 1
       end if
 
       if (present(surface_val)) then
@@ -6383,44 +5507,8 @@
    end function vertical_interp
 
 
-   subroutine init_atm_check_read_error(istatus, fname, dminfo)
-
-      implicit none
-
-      integer, intent(in) :: istatus
-      character (len=*), intent(in) :: fname
-      type (dm_info), intent(in) :: dminfo
-
-      if (istatus /= 0) then
-         write(0,*) 'ERROR: Could not read file '//trim(fname)
-         call mpas_dmpar_abort(dminfo)
-      end if
-
-   end subroutine init_atm_check_read_error
-
-
 !----------------------------------------------------------------------------------------------------------
 
-   real (kind=RKIND) 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 (kind=RKIND) function env_qv( z, temperature, pressure, rh_max )
 
       implicit none

Modified: branches/mpas_cdg_advection/src/core_nhyd_atmos/Makefile
===================================================================
--- branches/mpas_cdg_advection/src/core_nhyd_atmos/Makefile        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_nhyd_atmos/Makefile        2013-04-22 01:31:32 UTC (rev 2783)
@@ -5,7 +5,8 @@
 
 OBJS = mpas_atm_mpas_core.o \
        mpas_atm_time_integration.o \
-       mpas_atm_advection.o
+       mpas_atm_advection.o \
+       mpas_atm_interp_diagnostics.o
 
 all: physcore core_hyd
 
@@ -22,7 +23,7 @@
 
 mpas_atm_advection.o: 
 
-mpas_atm_mpas_core.o: mpas_atm_advection.o mpas_atm_time_integration.o
+mpas_atm_mpas_core.o: mpas_atm_advection.o mpas_atm_time_integration.o mpas_atm_interp_diagnostics.o
 
 clean:
         ( cd ../core_atmos_physics; make clean )

Deleted: branches/mpas_cdg_advection/src/core_nhyd_atmos/Registry
===================================================================
--- branches/mpas_cdg_advection/src/core_nhyd_atmos/Registry        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_nhyd_atmos/Registry        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,877 +0,0 @@
-%
-% namelist  type  namelist_record  name  default_value
-%
-namelist character nhyd_model config_time_integration     SRK3
-namelist real      nhyd_model config_dt                   600.0
-namelist character nhyd_model config_calendar_type        gregorian
-namelist character nhyd_model config_start_time           0000-01-01_00:00:00
-namelist character nhyd_model config_stop_time            none
-namelist character nhyd_model config_run_duration         none
-namelist character nhyd_model config_sfc_update_interval  none
-namelist character nhyd_model config_horiz_mixing         2d_smagorinsky
-namelist real      nhyd_model config_h_mom_eddy_visc2     0.0
-namelist real      nhyd_model config_h_mom_eddy_visc4     0.0
-namelist real      nhyd_model config_v_mom_eddy_visc2     0.0
-namelist real      nhyd_model config_h_theta_eddy_visc2   0.0
-namelist real      nhyd_model config_h_theta_eddy_visc4   0.0
-namelist real      nhyd_model config_v_theta_eddy_visc2   0.0
-namelist integer   nhyd_model config_number_of_sub_steps  4
-namelist integer   nhyd_model config_w_adv_order          3
-namelist integer   nhyd_model config_theta_adv_order      3
-namelist integer   nhyd_model config_scalar_adv_order     3
-namelist integer   nhyd_model config_u_vadv_order         3
-namelist integer   nhyd_model config_w_vadv_order         3
-namelist integer   nhyd_model config_theta_vadv_order     3
-namelist integer   nhyd_model config_scalar_vadv_order    3
-namelist real      nhyd_model config_coef_3rd_order       0.25
-namelist logical   nhyd_model config_scalar_advection     true
-namelist logical   nhyd_model config_positive_definite    false
-namelist logical   nhyd_model config_monotonic            true
-namelist logical   nhyd_model config_mix_full             true
-namelist real      nhyd_model config_len_disp             120000.0
-namelist real      nhyd_model config_epssm                0.1
-namelist real      nhyd_model config_smdiv                0.1
-namelist logical   nhyd_model config_newpx                false
-namelist real      nhyd_model config_apvm_upwinding       0.5
-namelist logical   nhyd_model config_h_ScaleWithMesh      false
-namelist integer   nhyd_model config_num_halos            2
-namelist real      damping    config_zd                   22000.0
-namelist real      damping    config_xnutr                0.0
-namelist character io         config_input_name           init.nc
-namelist character io         config_sfc_update_name      sfc_update.nc
-namelist character io         config_output_name          output.nc
-namelist character io         config_restart_name         restart.nc
-namelist character io         config_output_interval      06:00:00
-namelist integer   io         config_frames_per_outfile   0
-namelist integer   io         config_pio_num_iotasks      0 
-namelist integer   io         config_pio_stride           1
-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 logical   restart    config_do_DAcycling         false
-namelist character restart    config_restart_interval     none
-
-%
-% dim  type  name_in_file  name_in_code
-%
-dim nCells nCells
-dim nEdges nEdges
-dim maxEdges maxEdges
-dim maxEdges2 maxEdges2
-dim nVertices nVertices
-dim TWO 2
-dim THREE 3
-dim vertexDegree vertexDegree
-dim FIFTEEN 15
-dim TWENTYONE 21
-dim R3 3
-dim nVertLevels nVertLevels
-dim nVertLevelsP1 nVertLevels+1
-
-%
-% var  type  name_in_file  ( dims )  iro-  name_in_code super-array array_class
-%
-var persistent text    xtime ( Time ) 2 iro xtime state - -
-
-%  horizontal grid structure
-
-var persistent real    latCell ( nCells ) 0 iro latCell mesh - -
-var persistent real    lonCell ( nCells ) 0 iro lonCell mesh - -
-var persistent real    xCell ( nCells ) 0 iro xCell mesh - -
-var persistent real    yCell ( nCells ) 0 iro yCell mesh - -
-var persistent real    zCell ( nCells ) 0 iro zCell mesh - -
-var persistent integer indexToCellID ( nCells ) 0 iro indexToCellID mesh - -
-
-var persistent real    latEdge ( nEdges ) 0 iro latEdge mesh - -
-var persistent real    lonEdge ( nEdges ) 0 iro lonEdge mesh - -
-var persistent real    xEdge ( nEdges ) 0 iro xEdge mesh - -
-var persistent real    yEdge ( nEdges ) 0 iro yEdge mesh - -
-var persistent real    zEdge ( nEdges ) 0 iro zEdge mesh - -
-var persistent integer indexToEdgeID ( nEdges ) 0 iro indexToEdgeID mesh - -
-
-var persistent real    latVertex ( nVertices ) 0 iro latVertex mesh - -
-var persistent real    lonVertex ( nVertices ) 0 iro lonVertex mesh - -
-var persistent real    xVertex ( nVertices ) 0 iro xVertex mesh - -
-var persistent real    yVertex ( nVertices ) 0 iro yVertex mesh - -
-var persistent real    zVertex ( nVertices ) 0 iro zVertex mesh - -
-var persistent integer indexToVertexID ( nVertices ) 0 iro indexToVertexID mesh - -
-
-var persistent integer cellsOnEdge ( TWO nEdges ) 0 iro cellsOnEdge mesh - -
-var persistent integer nEdgesOnCell ( nCells ) 0 iro nEdgesOnCell mesh - -
-var persistent integer nEdgesOnEdge ( nEdges ) 0 iro nEdgesOnEdge mesh - -
-var persistent integer edgesOnCell ( maxEdges nCells ) 0 iro edgesOnCell mesh - -
-var persistent integer edgesOnEdge ( maxEdges2 nEdges ) 0 iro edgesOnEdge mesh - -
-
-var persistent real    weightsOnEdge ( maxEdges2 nEdges ) 0 iro weightsOnEdge mesh - -
-var persistent real    dvEdge ( nEdges ) 0 iro dvEdge mesh - -
-var persistent real    dcEdge ( nEdges ) 0 iro dcEdge mesh - -
-var persistent real    angleEdge ( nEdges ) 0 iro angleEdge mesh - -
-var persistent real    areaCell ( nCells ) 0 iro areaCell mesh - -
-var persistent real    areaTriangle ( nVertices ) 0 iro areaTriangle mesh - -
-
-var persistent real    edgeNormalVectors ( R3 nEdges ) 0 iro edgeNormalVectors mesh - -
-var persistent real    localVerticalUnitVectors ( R3 nCells ) 0 iro localVerticalUnitVectors mesh - -
-var persistent real    cellTangentPlane ( R3 TWO nCells ) 0 iro cellTangentPlane mesh - -
-
-var persistent integer cellsOnCell ( maxEdges nCells ) 0 iro cellsOnCell mesh - -
-var persistent integer verticesOnCell ( maxEdges nCells ) 0 iro verticesOnCell mesh - -
-var persistent integer verticesOnEdge ( TWO nEdges ) 0 iro verticesOnEdge mesh - -
-var persistent integer edgesOnVertex ( vertexDegree nVertices ) 0 iro edgesOnVertex mesh - -
-var persistent integer cellsOnVertex ( vertexDegree nVertices ) 0 iro cellsOnVertex mesh - -
-var persistent real    kiteAreasOnVertex ( vertexDegree nVertices ) 0 iro kiteAreasOnVertex mesh - -
-var persistent real    fEdge ( nEdges ) 0 iro fEdge mesh - -
-var persistent real    fVertex ( nVertices ) 0 iro fVertex mesh - -
-
-var persistent real    meshDensity ( nCells ) 0 iro meshDensity mesh - -
-var persistent real    meshScalingDel2 ( nEdges ) 0 ro meshScalingDel2 mesh - -
-var persistent real    meshScalingDel4 ( nEdges ) 0 ro meshScalingDel4 mesh - -
-
-% some solver scalar coefficients
-
-% coefficients for vertical extrapolation to the surface
-var persistent real    cf1 ( ) 0 iro cf1 mesh - -
-var persistent real    cf2 ( ) 0 iro cf2 mesh - -
-var persistent real    cf3 ( ) 0 iro cf3 mesh - -
-
-var persistent real    cpr ( THREE nEdges ) 0 ro cpr mesh - -
-var persistent real    cpl ( THREE nEdges ) 0 ro cpl mesh - -
-
-% description of the vertical grid structure
-
-var persistent real    hx ( nVertLevelsP1 nCells ) 0 iro hx mesh - -
-var persistent real    zgrid ( nVertLevelsP1 nCells ) 0 iro zgrid mesh - -
-var persistent real    rdzw ( nVertLevels ) 0 iro rdzw mesh - -
-var persistent real    dzu ( nVertLevels ) 0 iro dzu mesh - -
-var persistent real    rdzu ( nVertLevels ) 0 iro rdzu mesh - -
-var persistent real    fzm ( nVertLevels ) 0 iro fzm mesh - -
-var persistent real    fzp ( nVertLevels ) 0 iro fzp mesh - -
-var persistent real    zx ( nVertLevelsP1 nEdges ) 0 iro zx mesh - -
-var persistent real    zz ( nVertLevelsP1 nCells ) 0 iro zz mesh - -
-var persistent real    zb ( nVertLevelsP1 TWO nEdges ) 0 iro zb mesh - -
-var persistent real    zb3 ( nVertLevelsP1 TWO nEdges ) 0 iro zb3 mesh - -
-var persistent real    pzm ( nVertLevels nCells ) 0 r pzm mesh - -
-var persistent real    pzp ( nVertLevels nCells ) 0 r pzp mesh - -
-
-% coefficients for the vertical tridiagonal solve
-% Note:  these could be local but...
-
-var persistent real    cofrz ( nVertLevels Time ) 1 - cofrz diag - -
-var persistent real    cofwr ( nVertLevels nCells Time ) 1 - cofwr diag - -
-var persistent real    cofwz ( nVertLevels nCells Time ) 1 - cofwz diag - -
-var persistent real    coftz ( nVertLevelsP1 nCells Time ) 1 - coftz diag - -
-var persistent real    cofwt ( nVertLevels nCells Time ) 1 - cofwt diag - -
-var persistent real    a_tri ( nVertLevels nCells Time ) 1 - a_tri diag - -
-var persistent real    alpha_tri ( nVertLevels nCells Time ) 1 - alpha_tri diag - -
-var persistent real    gamma_tri ( nVertLevels nCells Time ) 1 - gamma_tri diag - -
-
-%  W-Rayleigh-damping coefficient
-
-var persistent real    dss ( nVertLevels nCells ) 0 iro dss mesh - -
-
-% Prognostic variables: read from input, saved in restart, and written to output
-var persistent real    u ( nVertLevels nEdges Time ) 2 iro u state - -
-var persistent real    w ( nVertLevelsP1 nCells Time ) 2 iro w state - -
-var persistent real    rho_zz ( nVertLevels nCells Time ) 2 r rho_zz state - -
-var persistent real    theta_m ( nVertLevels nCells Time ) 2 r theta_m state - -
-var persistent real    qv ( nVertLevels nCells Time ) 2 iro qv state scalars moist
-var persistent real    qc ( nVertLevels nCells Time ) 2 iro qc state scalars moist
-var persistent real    qr ( nVertLevels nCells Time ) 2 iro qr state scalars moist
-var persistent real    qi ( nVertLevels nCells Time ) 2 iro qi state scalars moist
-var persistent real    qs ( nVertLevels nCells Time ) 2 iro qs state scalars moist
-var persistent real    qg ( nVertLevels nCells Time ) 2 iro qg state scalars moist
-var persistent real    qnr ( nVertLevels nCells Time ) 2 iro qnr state scalars number
-var persistent real    qni ( nVertLevels nCells Time ) 2 iro qni state scalars number
-
-% Tendency variables
-var persistent real    tend_u ( nVertLevels nEdges Time ) 1 o u tend - -
-var persistent real    tend_w ( nVertLevelsP1 nCells Time ) 1 o w tend - -
-var persistent real    tend_rho ( nVertLevels nCells Time ) 1 o rho_zz tend - -
-var persistent real    tend_theta ( nVertLevels nCells Time ) 1 o theta_m tend - -
-var persistent real    tend_qv ( nVertLevels nCells Time ) 1 o qv tend scalars moist
-var persistent real    tend_qc ( nVertLevels nCells Time ) 1 o qc tend scalars moist
-var persistent real    tend_qr ( nVertLevels nCells Time ) 1 o qr tend scalars moist
-var persistent real    tend_qi ( nVertLevels nCells Time ) 1 o qi tend scalars moist
-var persistent real    tend_qs ( nVertLevels nCells Time ) 1 o qs tend scalars moist
-var persistent real    tend_qg ( nVertLevels nCells Time ) 1 o qg tend scalars moist
-var persistent real    tend_qnr ( nVertLevels nCells Time ) 1 o qnr tend scalars number
-var persistent real    tend_qni ( nVertLevels nCells Time ) 1 o qni tend scalars number
-var persistent real    rt_diabatic_tend ( nVertLevels nCells Time ) 1 r rt_diabatic_tend tend - -
-
-var persistent real    euler_tend_u ( nVertLevels nEdges Time ) 1 - u_euler tend - -
-var persistent real    euler_tend_w ( nVertLevelsP1 nCells Time ) 1 - w_euler tend - -
-var persistent real    euler_tend_theta ( nVertLevels nCells Time ) 1 - theta_euler tend - -
-
-% state variables diagnosed from prognostic state
-var persistent real    pressure_p ( nVertLevels nCells Time ) 1 ro pressure_p diag - -
-
-var persistent real    u_init ( nVertLevels ) 0 iro u_init mesh - -
-var persistent real    t_init ( nVertLevels nCells ) 0 iro t_init mesh - -
-var persistent real    qv_init ( nVertLevels ) 0 iro qv_init mesh - -
-
-% Diagnostic fields: only written to output
-% NOTE: added the &quot;r&quot; option to rho,theta,uReconstructZonal,and uReconstructMeridional for use of the
-% non-hydrostatic dynamical core in a data assimilation framework. NOTE that the &quot;r&quot; option is not
-% needed for those 4 variables to get bit for bit restart capabilities, otherwise. 
-var persistent real    rho ( nVertLevels nCells Time ) 1 iro rho diag - -
-var persistent real    theta ( nVertLevels nCells Time ) 1 iro theta diag - -
-var persistent real    rh ( nVertLevels nCells Time ) 1 iro rh diag - -
-var persistent real    v ( nVertLevels nEdges Time ) 1 o v diag - -
-var persistent real    divergence ( nVertLevels nCells Time ) 1 o divergence diag - -
-var persistent real    vorticity ( nVertLevels nVertices Time ) 1 o vorticity diag - -
-var persistent real    pv_edge ( nVertLevels nEdges Time ) 1 o pv_edge diag - -
-var persistent real    rho_edge ( nVertLevels nEdges Time ) 1 o rho_edge diag - -
-var persistent real    ke ( nVertLevels nCells Time ) 1 o ke diag - -
-var persistent real    pv_vertex ( nVertLevels nVertices Time ) 1 o pv_vertex diag - -
-var persistent real    pv_cell ( nVertLevels nCells Time ) 1 o pv_cell diag - -
-var persistent real    uReconstructX ( nVertLevels nCells Time ) 1 o uReconstructX diag - -
-var persistent real    uReconstructY ( nVertLevels nCells Time ) 1 o uReconstructY diag - -
-var persistent real    uReconstructZ ( nVertLevels nCells Time ) 1 o uReconstructZ diag - -
-var persistent real    uReconstructZonal ( nVertLevels nCells Time ) 1 ro uReconstructZonal diag - -
-var persistent real    uReconstructMeridional ( nVertLevels nCells Time ) 1 ro uReconstructMeridional diag - -
-
-% Other diagnostic variables: neither read nor written to any files
-var persistent real    rv ( nVertLevels nEdges Time ) 1 r rv diag - -
-var persistent real    circulation ( nVertLevels nVertices Time ) 1 r circulation diag - -
-var persistent real    gradPVt ( nVertLevels nEdges Time ) 1 - gradPVt diag - -
-var persistent real    gradPVn ( nVertLevels nEdges Time ) 1 - gradPVn diag - -
-var persistent real    h_divergence ( nVertLevels nCells Time ) 1 o h_divergence diag - -
-
-var persistent real    exner ( nVertLevels nCells Time ) 1 ro exner diag - -
-var persistent real    exner_base ( nVertLevels nCells Time ) 1 iro exner_base diag - -
-var persistent real    rtheta_base ( nVertLevels nCells Time ) 1 r rtheta_base diag - -
-var persistent real    pressure_base ( nVertLevels nCells Time ) 1 iro pressure_base diag - -
-var persistent real    rho_base ( nVertLevels nCells Time ) 1 iro rho_base diag - -
-var persistent real    theta_base ( nVertLevels nCells Time ) 1 iro theta_base diag - -
-
-
-var persistent real    ruAvg ( nVertLevels nEdges Time ) 1 - ruAvg diag - -
-var persistent real    wwAvg ( nVertLevelsP1 nCells Time ) 1 - wwAvg diag - -
-var persistent real    cqu  ( nVertLevels nEdges Time ) 1 - cqu diag - -
-var persistent real    cqw  ( nVertLevels nCells Time ) 1 - cqw diag - -
-
-%  coupled variables needed by the solver, but not output...
-
-var persistent real    ru ( nVertLevels nEdges Time ) 1 r ru diag - -
-var persistent real    ru_p ( nVertLevels nEdges Time ) 1 r ru_p diag - -
-var persistent real    ru_save ( nVertLevels nEdges Time ) 1 - ru_save diag - -
-
-
-var persistent real    rw ( nVertLevelsP1 nCells Time ) 1 r rw diag - -
-var persistent real    rw_p ( nVertLevelsP1 nCells Time ) 1 r rw_p diag - -
-var persistent real    rw_save ( nVertLevelsP1 nCells Time ) 1 - rw_save diag - -
-
-var persistent real    rtheta_p ( nVertLevels nCells Time ) 1 r rtheta_p diag - -
-var persistent real    rtheta_pp ( nVertLevels nCells Time ) 1 - rtheta_pp diag - -
-var persistent real    rtheta_p_save ( nVertLevels nCells Time ) 1 - rtheta_p_save diag - -
-var persistent real    rtheta_pp_old ( nVertLevels nCells Time ) 1 - rtheta_pp_old diag - -
-
-var persistent real    rho_p ( nVertLevels nCells Time ) 1 r rho_p diag - -
-var persistent real    rho_pp ( nVertLevels nCells Time ) 1 - rho_pp diag - -
-var persistent real    rho_p_save ( nVertLevels nCells Time ) 1 - rho_p_save diag - -
-
-% Space needed for advection
-var persistent real    deriv_two ( FIFTEEN TWO nEdges ) 0 ir deriv_two mesh - -
-var persistent integer advCells ( TWENTYONE nCells ) 0 ir advCells mesh - -
-var persistent real    adv_coefs ( FIFTEEN nEdges ) 0 - adv_coefs mesh - -
-var persistent real    adv_coefs_3rd ( FIFTEEN nEdges ) 0 - adv_coefs_3rd mesh - -
-var persistent integer advCellsForEdge ( FIFTEEN nEdges ) 0 - advCellsForEdge mesh - -
-var persistent integer nAdvCellsForEdge ( nEdges ) 0 - nAdvCellsForEdge mesh - -
-
-
-% Space needed for deformation calculation weights
-var persistent real    defc_a ( maxEdges nCells ) 0 iro defc_a mesh - -
-var persistent real    defc_b ( maxEdges nCells ) 0 iro defc_b mesh - -
-var persistent real    kdiff ( nVertLevels nCells Time ) 1 - kdiff diag - -
-
-% Arrays required for reconstruction of velocity field
-var persistent real    coeffs_reconstruct ( R3 maxEdges nCells ) 0 iro coeffs_reconstruct mesh - -
-
-% ADDED DECLARATIONS MADE BY LDF:
-var persistent real    surface_pressure    ( nCells Time    ) 1 iro surface_pressure    diag - -
-var persistent real    surface_temperature ( nCells Time    ) 1   o surface_temperature diag - -
-
-%==================================================================================================
-% DECLARATIONS OF ALL PHYSICS VARIABLES (will need to be moved to a Physics Registry shared by the
-% hydrostatic and non-hydrostatic dynamical cores):
-%==================================================================================================
-
-%... NAMELIST VARIABLES ADDED FOR INITIALIZATION OF SURFACE CHARACTERISTICS:
-namelist character physics  input_landuse_data          USGS
-namelist character physics  input_soil_data             STAS
-namelist integer   physics  input_soil_temperature_lag   140
-namelist integer   physics  num_soil_layers                4
-namelist integer   physics  months                        12
-
-%... NAMELIST VARIABLE NEEDED FOR THE TIME MANAGER:
-dim nMonths namelist:months
-
-%... DIMENSION NEEDED FOR NUMBER OF SOIL LAYERS:
-dim nSoilLevels namelist:num_soil_layers
-
-%... DIMENSION NEEDED FOR UPDATING THE DEEP SOIL TEMPERATURE:
-dim nLags namelist:input_soil_temperature_lag 
-
-%... DIMENSION NEEDED FOR OZONE AND AEROSOLS CONCENTRATIONS IN THE CAM LONGWAVE AND SHORTWAVE
-%... RADIATION PARAMETERIZATIONS.
-% noznlev : number of CAM radiation input ozone levels.
-% naerlev : number of CAM radiation input aerosol levels.
-
-namelist integer   physics  noznlev                       59
-namelist integer   physics  naerlev                       29
-namelist integer   physics  camdim1                       4
-dim nOznLevels     namelist:noznlev
-dim nAerLevels     namelist:naerlev
-dim cam_dim1       namelist:camdim1
-
-%... DIMENSION NEEDED FOR LONGWAVE AND SHORTWAVE RADIATION FLUXES TO INCLUDE AN ADDITIONAL LAYER
-%... BETWEEN THE TOP OF THE MODEL AND THE TOP OF THE ATMOSPHERE
-dim nVertLevelsP2 nVertLevels+2
-
-%... NAMELIST VARIABLES ADDED FOR PHYSICS CONFIGURATION:
-namelist logical   physics  config_frac_seaice          false
-namelist logical   physics  config_sfc_albedo           false
-namelist logical   physics  config_sfc_snowalbedo       false
-namelist logical   physics  config_sst_update           false
-namelist logical   physics  config_sstdiurn_update      false
-namelist logical   physics  config_deepsoiltemp_update  false
-
-namelist integer   physics  config_n_physics            1
-namelist integer   physics  config_n_microp             1
-namelist integer   physics  config_n_conv               1
-namelist integer   physics  config_n_pbl                1
-namelist integer   physics  config_n_lsm                1
-namelist integer   physics  config_n_eddy               1
-namelist integer   physics  config_n_radt_lw            1
-namelist integer   physics  config_n_radt_sw            1
-
-namelist character physics  config_radtlw_interval       none
-namelist character physics  config_radtsw_interval       none
-namelist character physics  config_conv_interval         none
-namelist character physics  config_pbl_interval          none
-namelist character physics  config_camrad_abs_update     06:00:00
-namelist character physics  config_greeness_update       24:00:00
-namelist character physics  config_bucket_update         none
-
-namelist character physics  config_microp_scheme          off
-namelist character physics  config_conv_shallow_scheme    off
-namelist character physics  config_conv_deep_scheme       off
-namelist character physics  config_eddy_scheme            off 
-namelist character physics  config_lsm_scheme             off
-namelist character physics  config_pbl_scheme             off
-namelist character physics  config_radt_cld_scheme        off
-namelist character physics  config_radt_lw_scheme         off
-namelist character physics  config_radt_sw_scheme         off
-namelist character physics  config_sfclayer_scheme        off
-
-namelist real      physics  config_bucket_radt            0.0_RKIND
-namelist real      physics  config_bucket_rainc           0.0_RKIND
-namelist real      physics  config_bucket_rainnc          0.0_RKIND
-
-var persistent real    east       ( R3 nCells               ) 0  r   east          mesh         - -
-var persistent real    north      ( R3 nCells               ) 0  r   north         mesh         - -
-
-%--------------------------------------------------------------------------------------------------
-%... ARRAYS AND VARIABLES FOR UPDATING THE DEEP SOIL TEMPERATURE:
-%--------------------------------------------------------------------------------------------------
-
-% nsteps_accum: number of accumulated time-step in a day.
-% ndays_accum : number of accumulated days in a year.
-% tlag        : daily mean surface temperature of prior days                                    [K]
-% tday_accum  : accumulated daily surface temperature for current day                           [K]
-% tyear_mean  : annual mean surface temperature                                                 [K]
-% tyear_accum : accumulated yearly surface temperature for current year                         [K]
-
-var persistent real    nsteps_accum ( nCells Time           ) 1  r  nsteps_accum   diag_physics - -
-var persistent real    ndays_accum  ( nCells Time           ) 1  r  ndays_accum    diag_physics - -
-
-var persistent real    tlag         ( nLags nCells Time     ) 1  r  tlag           diag_physics - -
-var persistent real    tday_accum   ( nCells Time           ) 1  r  tday_accum     diag_physics - -           
-var persistent real    tyear_mean   ( nCells Time           ) 1  r  tyear_mean     diag_physics - -
-var persistent real    tyear_accum  ( nCells Time           ) 1  r  tyear_accum    diag_physics - -
-
-%--------------------------------------------------------------------------------------------------
-%... PARAMETERIZATION OF CLOUD MICROPHYSICS:
-%--------------------------------------------------------------------------------------------------
-% i_rainnc  : counter related to how often rainnc is being reset relative to its bucket value   (-)
-% rainnc    : accumulated total time-step grid-scale precipitation                             (mm)
-% rainncv   : time-step total grid-scale precipitation                                         (mm)
-% snownc    : accumulated grid-scale precipitation of snow                                     (mm)
-% snowncv   : time-step grid-scale precipitation of snow                                       (mm)
-% graupelnc : accumulated grid-scale precipitation of graupel                                  (mm)
-% graupelncv: time-step grid-scale precipitation of graupel                                    (mm)
-% sr        : time-step ratio of frozen versus total grid-scale precipitation                   (-)
-
-var persistent integer i_rainnc   ( nCells Time             ) 1  ro i_rainnc       diag_physics - -
-var persistent real    sr         ( nCells Time             ) 1  ro sr             diag_physics - -
-var persistent real    rainncv    ( nCells Time             ) 1  ro rainncv        diag_physics - -
-var persistent real    snowncv    ( nCells Time             ) 1   o snowncv        diag_physics - -
-var persistent real    graupelncv ( nCells Time             ) 1   o graupelncv     diag_physics - -
-
-var persistent real    rainnc     ( nCells Time             ) 1  ro rainnc         diag_physics - -
-var persistent real    snownc     ( nCells Time             ) 1  ro snownc         diag_physics - -
-var persistent real    graupelnc  ( nCells Time             ) 1  ro graupelnc      diag_physics - -
-
-var persistent real    qsat       ( nVertLevels nCells Time ) 1  o  qsat           diag_physics - -
-var persistent real    relhum     ( nVertLevels nCells Time ) 1  o  relhum         diag_physics - -
-
-%--------------------------------------------------------------------------------------------------
-%... PARAMETERIZATION OF CONVECTION:
-%--------------------------------------------------------------------------------------------------
-% i_rainc   : counter related to how often rainc is begin reset relative to its bucket value    (-)
-% cuprec    : convective precipitation rate                                                  (mm/s)
-% rainc     : accumulated time-step convective precipitation                                   (mm)
-% raincv    : time-step convective precipitation                                               (mm)
-% rthcuten  : tendency of potential temperature due to cumulus convection                   (K s-1)
-% rqvcuten  : tendency of water vapor mixing ratio due to cumulus convection            (kg/kg s-1)
-% rqccuten  : tendency of cloud water mixing ratio due to cumulus convection            (kg/kg s-1)
-% rqicuten  : tendency of cloud ice mixing ratio due to cumulus convection              (kg/kg s-1)
-
-var persistent integer i_rainc  ( nCells Time              ) 1  ro i_rainc         diag_physics - -
-var persistent real    cuprec   ( nCells Time              ) 1  ro cuprec          diag_physics - -
-var persistent real    rainc    ( nCells Time              ) 1  ro rainc           diag_physics - -
-var persistent real    raincv   ( nCells Time              ) 1  ro raincv          diag_physics - -
-
-var persistent real   rthcuten  ( nVertLevels nCells Time  ) 1  ro rthcuten        tend_physics - -
-var persistent real   rqvcuten  ( nVertLevels nCells Time  ) 1  ro rqvcuten        tend_physics - -
-var persistent real   rqccuten  ( nVertLevels nCells Time  ) 1  ro rqccuten        tend_physics - -
-var persistent real   rqicuten  ( nVertLevels nCells Time  ) 1  ro rqicuten        tend_physics - -
-
-%... KAIN_FRITSCH:
-% cubot     : lowest level of convection                                                        (-)
-% cutop     : highest level of convection                                                       (-)
-% nca       : relaxation time for KF parameterization of convection                             (s)
-% wavg0     : average vertical velocity (KF scheme only)                                    (m s-1)
-% rqrcuten  : tendency of rain mixing ratio due to cumulus convection                   (kg/kg s-1)
-% rqscuten  : tendency of snow mixing ratio due to cumulus convection                   (kg/kg s-1)
-
-var persistent real   nca       ( nCells Time              ) 1  ro nca             diag_physics - -
-var persistent real   cubot     ( nCells Time              ) 1  ro cubot           diag_physics - -
-var persistent real   cutop     ( nCells Time              ) 1  ro cutop           diag_physics - -
-var persistent real   w0avg     ( nVertLevels nCells Time  ) 1  ro w0avg           diag_physics - -
-var persistent real   rqrcuten  ( nVertLevels nCells Time  ) 1  ro rqrcuten        tend_physics - -
-var persistent real   rqscuten  ( nVertLevels nCells Time  ) 1  ro rqscuten        tend_physics - -
-
-%... TIEDTKE:
-% rucuten   : tendency of zonal wind due to cumulus convection                              (m/s-1)
-% rvcuten   : tendency of meridional wind due to cumulus convection                         (m/s-1)
-% rqvdynten : tendency of water vapor due to horizontal and vertical advections         (kg/kg/s-1)
-
-var persistent real   rqvdynten ( nVertLevels nCells Time  ) 1  ro rqvdynten       tend_physics - -
-var persistent real   rucuten   ( nVertLevels nCells Time  ) 1  ro rucuten         tend_physics - -
-var persistent real   rvcuten   ( nVertLevels nCells Time  ) 1  ro rvcuten         tend_physics - -
-
-%--------------------------------------------------------------------------------------------------
-%... PARAMETERIZATION OF PLANETARY BOUNDARY LAYER PROCESSES:
-%--------------------------------------------------------------------------------------------------
-
-% kpbl      : index of PBL top                                                                  (-)
-% hpbl      : PBL height                                                                        (m)
-% exch_h    : exchange coefficient                                                              (-)
-% rublten   : tendency of zonal wind due to pbl processes                                   (m s-1)
-% rvblten   : tendency of meridional wind due to pbl processes                              (m s-1)
-% rthblten  : tendency of potential temperature due to pbl processes                        (K s-1)
-% rqvblten  : tendency of water vapor mixing ratio due to pbl processes                 (kg/kg s-1)
-% rqcblten  : tendency of cloud water mixing ratio due to pbl processes                 (kg/kg s-1)
-% rqiblten  : tendency of cloud ice mixing ratio due to pbl processes                   (kg/kg s-1)
-
-var persistent integer kpbl     ( nCells Time               ) 1  ro kpbl           diag_physics - - 
-var persistent real    hpbl     ( nCells Time               ) 1  ro hpbl           diag_physics - - 
-var persistent real    exch_h   ( nVertLevels nCells Time   ) 1   o exch_h         diag_physics - -
-
-%    TENDENCIES:
-var persistent real    rublten  ( nVertLevels nCells Time   ) 1  ro rublten        tend_physics - -
-var persistent real    rvblten  ( nVertLevels nCells Time   ) 1  ro rvblten        tend_physics - -
-var persistent real    rthblten ( nVertLevels nCells Time   ) 1  ro rthblten       tend_physics - -
-var persistent real    rqvblten ( nVertLevels nCells Time   ) 1  ro rqvblten       tend_physics - -
-var persistent real    rqcblten ( nVertLevels nCells Time   ) 1  ro rqcblten       tend_physics - -
-var persistent real    rqiblten ( nVertLevels nCells Time   ) 1  ro rqiblten       tend_physics - -
-
-%--------------------------------------------------------------------------------------------------
-%... PARAMETERIZATION OF SURFACE LAYER PROCESSES:
-%--------------------------------------------------------------------------------------------------
-
-% br        :bulk richardson number                                                             [-]
-% cd        :drag coefficient at 10m                                                            [-]
-% cda       :drag coefficient at lowest model level                                             [-]
-% chs       :???
-% chs2      :???
-% cqs2      :???
-% ck        :enthalpy exchange coefficient at 10 m                                              [-]
-% cka       :enthalpy exchange coefficient at lowest model level                                [-]
-% cpm       :???
-% flhc      :exchange coefficient for heat                                                      [-]
-% flqc      :exchange coefficient for moisture                                                  [-]
-% gz1oz0    :log of z1 over z0                                                                  [-]
-% hfx       :upward heat flux at the surface                                               [W/m2/s]
-% lh        :latent heat flux at the surface                                                 [W/m2]
-% mavail    :surface moisture availability                                                      [-]
-% mol       :T* in similarity theory                                                            [K]
-% psih      :similarity theory for heat                                                         [-]
-% psim      :similarity theory for momentum                                                     [-]
-% qfx       :upward moisture flux at the surface                                          [kg/m2/s]
-% qgh       :???
-% qsfc      :specific humidity at lower boundary                                            [kg/kg]
-% regime    :flag indicating PBL regime (stable_p,unstable_p,etc...)                            [-]
-% rmol      :1 / Monin Ob length                                                                [-]
-% ust       :u* in similarity theory                                                          [m/s]
-% ustm      :u* in similarity theory without vconv                                            [m/s]
-% zol       :z/L height over Monin-Obukhov length                                               [-]
-% znt       :time-varying roughness length                                                      [m]
-% wspd      :wind speed                                                                       [m/s]
-% DIAGNOSTICS:
-% q2        :specific humidity at 2m                                                        [kg/kg]
-% u10       :u at 10 m                                                                        [m/s]
-% v10       :v at 10 m                                                                        [m/s]
-% t2m       :temperature at 2m                                                                  [K]
-% th2m      :potential temperature at 2m                                                        [K]
-
-var persistent real    hfx      ( nCells Time               ) 1  ro hfx            diag_physics - -
-var persistent real    mavail   ( nCells Time               ) 1  ro mavail         diag_physics - -
-var persistent real    mol      ( nCells Time               ) 1  ro mol            diag_physics - -
-var persistent real    qfx      ( nCells Time               ) 1  ro qfx            diag_physics - -
-var persistent real    qsfc     ( nCells Time               ) 1  ro qsfc           diag_physics - -
-var persistent real    ust      ( nCells Time               ) 1  ro ust            diag_physics - -
-var persistent real    ustm     ( nCells Time               ) 1  ro ustm           diag_physics - -
-var persistent real    zol      ( nCells Time               ) 1  ro zol            diag_physics - -
-var persistent real    znt      ( nCells Time               ) 1  ro znt            diag_physics - -
-
-var persistent real    br       ( nCells Time               ) 1  ro br             diag_physics - -
-var persistent real    cd       ( nCells Time               ) 1  ro cd             diag_physics - -
-var persistent real    cda      ( nCells Time               ) 1  ro cda            diag_physics - -
-var persistent real    chs      ( nCells Time               ) 1  ro chs            diag_physics - -
-var persistent real    chs2     ( nCells Time               ) 1  ro chs2           diag_physics - -
-var persistent real    cqs2     ( nCells Time               ) 1  ro cqs2           diag_physics - -
-var persistent real    ck       ( nCells Time               ) 1  ro ck             diag_physics - -
-var persistent real    cka      ( nCells Time               ) 1  ro cka            diag_physics - -
-var persistent real    cpm      ( nCells Time               ) 1  ro cpm            diag_physics - -
-var persistent real    flhc     ( nCells Time               ) 1  ro flhc           diag_physics - -
-var persistent real    flqc     ( nCells Time               ) 1  ro flqc           diag_physics - -
-var persistent real    gz1oz0   ( nCells Time               ) 1  ro gz1oz0         diag_physics - -
-var persistent real    lh       ( nCells Time               ) 1  ro lh             diag_physics - -
-var persistent real    psim     ( nCells Time               ) 1  ro psim           diag_physics - -
-var persistent real    psih     ( nCells Time               ) 1  ro psih           diag_physics - -
-var persistent real    qgh      ( nCells Time               ) 1  ro qgh            diag_physics - -
-var persistent real    regime   ( nCells Time               ) 1  ro regime         diag_physics - -
-var persistent real    rmol     ( nCells Time               ) 1  ro rmol           diag_physics - -
-var persistent real    wspd     ( nCells Time               ) 1  ro wspd           diag_physics - -
-% DIAGNOSTICS:
-var persistent real    u10      ( nCells Time               ) 1  ro u10            diag_physics - -
-var persistent real    v10      ( nCells Time               ) 1  ro v10            diag_physics - -
-var persistent real    q2       ( nCells Time               ) 1  ro q2             diag_physics - -
-var persistent real    t2m      ( nCells Time               ) 1  ro t2m            diag_physics - -
-var persistent real    th2m     ( nCells Time               ) 1  ro th2m           diag_physics - -
-
-%--------------------------------------------------------------------------------------------------
-%... PARAMETERIZATION OF SHORTWAVE RADIATION:
-%--------------------------------------------------------------------------------------------------
-% coszr     :cosine of the solar zenith angle                                                   [-]
-% gsw       :net shortwave flux at surface                                                  [W m-2]
-% swcf      :shortwave cloud forcing at top-of-atmosphere                                   [W m-2]
-% swdnb     :all-sky downwelling shortwave flux at bottom-of-atmosphere                     [W m-2]
-% swdnbc    :clear-sky downwelling shortwave flux at bottom-of-atmosphere                   [W m-2]
-% swdnt     :all-sky downwelling shortwave flux at top-of-atmosphere                        [W m-2]
-% swdntc    :clear-sky downwelling shortwave flux at top-of-atmosphere                      [W m-2] 
-% swupb     :all-sky upwelling shortwave flux at bottom-of-atmosphere                       [W m-2]
-% swupbc    :clear-sky upwelling shortwave flux at bottom-of-atmosphere                     [W m-2]
-% swupt     :all-sky upwelling shortwave flux at top-of-atmosphere                          [W m-2]
-% swuptc    :clear-sky upwelling shortwave flux at top-of-atmosphere                        [W m-2]
-% acswdnb   :accumulated all-sky downwelling shortwave flux at bottom-of-atmosphere         [J m-2]
-% acswdnbc  :accumulated clear-sky downwelling shortwave flux at bottom-of-atmosphere       [J m-2]
-% acswdnt   :accumulated all-sky downwelling shortwave flux at top-of-atmosphere            [J m-2]
-% acswdntc  :accumulated clear-sky downwelling shortwave flux at top-of-atmosphere          [J m-2] 
-% acswupb   :accumulated all-sky upwelling shortwave flux at bottom-of-atmosphere           [J m-2]
-% acswupbc  :accumulated clear-sky upwelling shortwave flux at bottom-of-atmosphere         [J m-2]
-% acswupt   :accumulated all-sky upwelling shortwave flux at top-of-atmosphere              [J m-2]
-% acswuptc  :accumulated clear-sky upwelling shortwave flux at top-of-atmosphere            [J m-2]
-% swdnflx   :
-% swdnflxc  :
-% swupflx   :
-% swupflxc  :
-% rthratensw:uncoupled theta tendency due to shortwave radiation                            [K s-1]
-
-% i_acswdnb : counter related to how often swdnb is begin reset relative to its bucket value    (-)
-% i_acswdnbc: counter related to how often swdnbc is begin reset relative to its bucket value   (-)
-% i_acswdnt : counter related to how often swdnt is begin reset relative to its bucket value    (-)
-% i_acswdntc: counter related to how often swdntc is begin reset relative to its bucket value   (-)
-% i_acswupb : counter related to how often swupb is begin reset relative to its bucket value    (-)
-% i_acswupbc: counter related to how often swupbc is begin reset relative to its bucket value   (-)
-% i_acswupt : counter related to how often swupt is begin reset relative to its bucket value    (-)
-% i_acswuptc: counter related to how often swuptc is begin reset relative to its bucket value   (-)
-
-var persistent integer i_acswdnb  ( nCells Time               ) 1  ro i_acswdnb    diag_physics - -
-var persistent integer i_acswdnbc ( nCells Time               ) 1  ro i_acswdnbc   diag_physics - -
-var persistent integer i_acswdnt  ( nCells Time               ) 1  ro i_acswdnt    diag_physics - -
-var persistent integer i_acswdntc ( nCells Time               ) 1  ro i_acswdntc   diag_physics - -
-var persistent integer i_acswupb  ( nCells Time               ) 1  ro i_acswupb    diag_physics - -
-var persistent integer i_acswupbc ( nCells Time               ) 1  ro i_acswupbc   diag_physics - -
-var persistent integer i_acswupt  ( nCells Time               ) 1  ro i_acswupt    diag_physics - -
-var persistent integer i_acswuptc ( nCells Time               ) 1  ro i_acswuptc   diag_physics - -
-
-var persistent real    coszr      ( nCells Time               ) 1   o coszr        diag_physics - -
-var persistent real    swcf       ( nCells Time               ) 1   o swcf         diag_physics - -
-var persistent real    swdnb      ( nCells Time               ) 1   o swdnb        diag_physics - -
-var persistent real    swdnbc     ( nCells Time               ) 1   o swdnbc       diag_physics - -
-var persistent real    swdnt      ( nCells Time               ) 1   o swdnt        diag_physics - -
-var persistent real    swdntc     ( nCells Time               ) 1   o swdntc       diag_physics - -
-var persistent real    swupb      ( nCells Time               ) 1   o swupb        diag_physics - -
-var persistent real    swupbc     ( nCells Time               ) 1   o swupbc       diag_physics - -
-var persistent real    swupt      ( nCells Time               ) 1   o swupt        diag_physics - -
-var persistent real    swuptc     ( nCells Time               ) 1   o swuptc       diag_physics - -
-var persistent real    acswdnb    ( nCells Time               ) 1  ro acswdnb      diag_physics - -
-var persistent real    acswdnbc   ( nCells Time               ) 1  ro acswdnbc     diag_physics - -
-var persistent real    acswdnt    ( nCells Time               ) 1  ro acswdnt      diag_physics - -
-var persistent real    acswdntc   ( nCells Time               ) 1  ro acswdntc     diag_physics - -
-var persistent real    acswupb    ( nCells Time               ) 1  ro acswupb      diag_physics - -
-var persistent real    acswupbc   ( nCells Time               ) 1  ro acswupbc     diag_physics - -
-var persistent real    acswupt    ( nCells Time               ) 1  ro acswupt      diag_physics - -
-var persistent real    acswuptc   ( nCells Time               ) 1  ro acswuptc     diag_physics - -
-var persistent real    gsw        ( nCells Time               ) 1  ro gsw          diag_physics - -
-
-var persistent real    rthratensw ( nVertLevels nCells Time   ) 1  ro rthratensw   tend_physics - -
-
-%... RRTMG SW ONLY:
-var persistent real    swdnflx    ( nVertLevelsP2 nCells Time ) 1   o swdnflx      diag_physics - -
-var persistent real    swdnflxc   ( nVertLevelsP2 nCells Time ) 1   o swdnflxc     diag_physics - -
-var persistent real    swupflx    ( nVertLevelsP2 nCells Time ) 1   o swupflx      diag_physics - -
-var persistent real    swupflxc   ( nVertLevelsP2 nCells Time ) 1   o swupflxc     diag_physics - -
-
-%--------------------------------------------------------------------------------------------------
-%... PARAMETERIZATION OF LONGWAVE RADIATION:
-%--------------------------------------------------------------------------------------------------
-
-% note: glw is the same diagnostic as lwdnb and is used in the land-surface scheme for the calcula-
-%       tion of the surface budget. glw is always an output argument to the subroutine rrtmg_lwrad.
-%       in contrast,lwdnb is an optional ouput argument to the subroutine rrtmg_lwrad depending on
-%       the presence of lwupt (or not).
-
-% glw       :all-sky downwelling longwave flux at bottom-of-atmosphere                      [W m-2]
-% lwcf      :longwave cloud forcing at top-of-atmosphere                                    [W m-2]
-% lwdnb     :all-sky downwelling longwave flux at bottom-of-atmosphere                      [W m-2]
-% lwdnbc    :clear-sky downwelling longwave flux at bottom-of-atmosphere                    [W m-2]
-% lwdnt     :all-sky downwelling longwave flux at top-of-atmosphere                         [W m-2]
-% lwdntc    :clear-sky downwelling longwave flux at top-of-atmosphere                       [W m-2]
-% lwupb     :all-sky upwelling longwave flux at bottom-of-atmosphere                        [W m-2]
-% lwupbc    :clear-sky upwelling longwave flux at bottom-of-atmosphere                      [W m-2]
-% lwupt     :all-sky upwelling longwave flux at top-of-atmosphere                           [W m-2]
-% lwuptc    :clear-sky upwelling longwave flux at top-of-atmosphere                         [W m-2]
-% aclwdnb   :accumulated all-sky downwelling longwave flux at bottom-of-atmosphere          [J m-2]
-% aclwdnbc  :accumulated clear-sky downwelling longwave flux at bottom-of-atmosphere        [J m-2]
-% aclwdnt   :accumulated all-sky downwelling longwave flux at top-of-atmosphere             [J m-2]
-% aclwdntc  :accumulated clear-sky downwelling longwave flux at top-of-atmosphere           [J m-2]
-% aclwupb   :accumulated all-sky upwelling longwave flux at bottom-of-atmosphere            [J m-2]
-% aclwupbc  :accumulated clear-sky upwelling longwave flux at bottom-of-atmosphere          [J m-2]
-% aclwupt   :accumulated all-sky upwelling longwave flux at top-of-atmosphere               [J m-2]
-% aclwuptc  :accumulated clear-sky upwelling longwave flux at top-of-atmosphere             [J m-2]
-% lwdnflx   :
-% lwdnflxc  :
-% lwupflx   :
-% lwupflxc  :
-% olrtoa    :outgoing longwave radiation at top-of-the-atmosphere                           [W m-2]
-% rthratenlw:uncoupled theta tendency due to longwave radiation                             [K s-1]
-
-% i_aclwdnb : counter related to how often lwdnb is begin reset relative to its bucket value    (-)
-% i_aclwdnbc: counter related to how often lwdnbc is begin reset relative to its bucket value   (-)
-% i_aclwdnt : counter related to how often lwdnt is begin reset relative to its bucket value    (-)
-% i_aclwdntc: counter related to how often lwdntc is begin reset relative to its bucket value   (-)
-% i_aclwupb : counter related to how often lwupb is begin reset relative to its bucket value    (-)
-% i_aclwupbc: counter related to how often lwupbc is begin reset relative to its bucket value   (-)
-% i_aclwupt : counter related to how often lwupt is begin reset relative to its bucket value    (-)
-% i_aclwuptc: counter related to how often lwuptc is begin reset relative to its bucket value   (-)
-
-var persistent integer i_aclwdnb  ( nCells Time               ) 1  ro i_aclwdnb    diag_physics - -
-var persistent integer i_aclwdnbc ( nCells Time               ) 1  ro i_aclwdnbc   diag_physics - -
-var persistent integer i_aclwdnt  ( nCells Time               ) 1  ro i_aclwdnt    diag_physics - -
-var persistent integer i_aclwdntc ( nCells Time               ) 1  ro i_aclwdntc   diag_physics - -
-var persistent integer i_aclwupb  ( nCells Time               ) 1  ro i_aclwupb    diag_physics - -
-var persistent integer i_aclwupbc ( nCells Time               ) 1  ro i_aclwupbc   diag_physics - -
-var persistent integer i_aclwupt  ( nCells Time               ) 1  ro i_aclwupt    diag_physics - -
-var persistent integer i_aclwuptc ( nCells Time               ) 1  ro i_aclwuptc   diag_physics - -
-
-var persistent real    lwcf       ( nCells Time               ) 1   o lwcf         diag_physics - -
-var persistent real    lwdnb      ( nCells Time               ) 1   o lwdnb        diag_physics - -
-var persistent real    lwdnbc     ( nCells Time               ) 1   o lwdnbc       diag_physics - -
-var persistent real    lwdnt      ( nCells Time               ) 1   o lwdnt        diag_physics - -
-var persistent real    lwdntc     ( nCells Time               ) 1   o lwdntc       diag_physics - -
-var persistent real    lwupb      ( nCells Time               ) 1   o lwupb        diag_physics - -
-var persistent real    lwupbc     ( nCells Time               ) 1   o lwupbc       diag_physics - -
-var persistent real    lwupt      ( nCells Time               ) 1   o lwupt        diag_physics - -
-var persistent real    lwuptc     ( nCells Time               ) 1   o lwuptc       diag_physics - -
-var persistent real    aclwdnb    ( nCells Time               ) 1  ro aclwdnb      diag_physics - -
-var persistent real    aclwdnbc   ( nCells Time               ) 1  ro aclwdnbc     diag_physics - -
-var persistent real    aclwdnt    ( nCells Time               ) 1  ro aclwdnt      diag_physics - -
-var persistent real    aclwdntc   ( nCells Time               ) 1  ro aclwdntc     diag_physics - -
-var persistent real    aclwupb    ( nCells Time               ) 1  ro aclwupb      diag_physics - -
-var persistent real    aclwupbc   ( nCells Time               ) 1  ro aclwupbc     diag_physics - -
-var persistent real    aclwupt    ( nCells Time               ) 1  ro aclwupt      diag_physics - -
-var persistent real    aclwuptc   ( nCells Time               ) 1  ro aclwuptc     diag_physics - -
-var persistent real    olrtoa     ( nCells Time               ) 1   o olrtoa       diag_physics - -
-var persistent real    glw        ( nCells Time               ) 1  ro glw          diag_physics - -
-
-var persistent real    rthratenlw ( nVertLevels nCells Time   ) 1  ro rthratenlw   tend_physics - -
-
-%... RRTMG LW ONLY:
-%var persistent real   lwdnflx    ( nVertLevelsP2 nCells Time ) 1   o lwdnflx      diag_physics - -
-%var persistent real   lwdnflxc   ( nVertLevelsP2 nCells Time ) 1   o lwdnflxc     diag_physics - -
-%var persistent real   lwupflx    ( nVertLevelsP2 nCells Time ) 1   o lwupflx      diag_physics - -
-%var persistent real   lwupflxc   ( nVertLevelsP2 nCells Time ) 1   o lwupflxc     diag_physics - -
-
-%--------------------------------------------------------------------------------------------------
-%... ADDITIONAL &quot;RADIATION&quot; ARRAYS NEEDED ONLY IN THE &quot;CAM&quot; LW AND SW RADIATION CODES:
-%--------------------------------------------------------------------------------------------------
-
-%INFRARED ABSORPTION:
-var persistent real absnxt  ( nVertLevels   cam_dim1      nCells Time ) 1 - absnxt diag_physics - -
-var persistent real abstot  ( nVertLevelsP1 nVertLevelsP1 nCells Time ) 1 - abstot diag_physics - -
-var persistent real emstot  ( nVertLevelsP1 nCells Time               ) 1 - emstot diag_physics - -
-%var persistent real absnxt ( nVertLevels   cam_dim1      nCells Time ) 1 r absnxt diag_physics - -
-%var persistent real abstot ( nVertLevelsP1 nVertLevelsP1 nCells Time ) 1 r abstot diag_physics - -
-%var persistent real emstot ( nVertLevelsP1 nCells Time               ) 1 r emstot diag_physics - -
-
-% OZONE:
-var persistent real    pin      ( nOznLevels nCells         ) 0 -  pin       mesh  - -
-var persistent real    ozmixm   ( nMonths nOznLevels nCells ) 0 -  ozmixm    mesh  - -
-
-% AEROSOLS:
-var persistent real    m_hybi   ( nAerLevels nCells         ) 0 -  m_hybi    mesh  - -  
-
-var persistent real    m_ps     ( nCells Time               ) 2 -  m_ps      state - -
-%var persistent real   dummy    ( nAerLevels nCells Time    ) 2 -  dummy     state aerosols aer_cam
-var persistent real    sul      ( nAerLevels nCells Time    ) 2 -  sul       state aerosols aer_cam
-var persistent real    sslt     ( nAerLevels nCells Time    ) 2 -  sslt      state aerosols aer_cam
-var persistent real    dust1    ( nAerLevels nCells Time    ) 2 -  dust1     state aerosols aer_cam
-var persistent real    dust2    ( nAerLevels nCells Time    ) 2 -  dust2     state aerosols aer_cam
-var persistent real    dust3    ( nAerLevels nCells Time    ) 2 -  dust3     state aerosols aer_cam
-var persistent real    dust4    ( nAerLevels nCells Time    ) 2 -  dust4     state aerosols aer_cam
-var persistent real    ocpho    ( nAerLevels nCells Time    ) 2 -  ocpho     state aerosols aer_cam
-var persistent real    bcpho    ( nAerLevels nCells Time    ) 2 -  bcpho     state aerosols aer_cam
-var persistent real    ocphi    ( nAerLevels nCells Time    ) 2 -  ocphi     state aerosols aer_cam
-var persistent real    bcphi    ( nAerLevels nCells Time    ) 2 -  bcphi     state aerosols aer_cam
-var persistent real    bg       ( nAerLevels nCells Time    ) 2 -  bg        state aerosols aer_cam
-var persistent real    volc     ( nAerLevels nCells Time    ) 2 -  volc      state aerosols aer_cam
-
-%--------------------------------------------------------------------------------------------------
-%... PARAMERIZATION OF CLOUDINESS:
-%--------------------------------------------------------------------------------------------------
-
-% cldfrac   :cloud fraction                                                                     [-]
-
-var persistent real    cldfrac    ( nVertLevels nCells Time ) 1   o cldfrac        diag_physics - -
-
-%--------------------------------------------------------------------------------------------------
-%... PARAMETERIZATION OF LAND-SURFACE SCHEME:
-%--------------------------------------------------------------------------------------------------
-
-% acsnom         :accumulated melted snow                                                  [kg m-2]
-% acsnow         :accumulated snow                                                         [kg m-2]
-% canwat         :canopy water                                                             [kg m-2]
-% chklowq        :surface saturation flag                                                       [-]
-% grdflx         :ground heat flux                                                          [W m-2]
-% lai            :leaf area index                                                               [-]
-% noahres        :residual of the noah land-surface scheme energy budget                    [W m-2]
-% potevp         :potential evaporation                                                     [W m-2]
-% qz0            :specific humidity at znt                                                [kg kg-1]
-% rib            :??
-% sfc_albedo     :surface albedo                                                                [-]
-% sfc_embck      :background emissivity                                                         [-]
-% sfc_emiss      :surface emissivity                                                            [-]
-% sfcrunoff      :surface runoff                                                            [m s-1]
-% smstav         :moisture availability                                                         [-]
-% smstot         :total moisture                                                           [m3 m-3]
-% snopcx         :snow phase change heat flux                                               [W m-2]
-% snotime        :??
-% sstsk          : skin sea-surface temperature                                                [K]
-% sstsk_diur     : skin sea-surface temperature difference                                     [K]
-% thc            :thermal inertia                                              [Cal cm-1 K-1 s-0.5]
-% udrunoff       :sub-surface runoff                                                        [m s-1]
-% xicem          :ice mask from previous time-step                                              [-]
-% z0             :background roughness length                                                   [m]
-% zs             :depth of centers of soil layers                                               [m]
-
-var persistent real    acsnom     ( nCells Time             ) 1  ro acsnom         diag_physics - -
-var persistent real    acsnow     ( nCells Time             ) 1  ro acsnow         diag_physics - -
-var persistent real    canwat     ( nCells Time             ) 1  ro canwat         diag_physics - -
-var persistent real    chklowq    ( nCells Time             ) 1  ro chklowq        diag_physics - -
-var persistent real    grdflx     ( nCells Time             ) 1  ro grdflx         diag_physics - -
-var persistent real    lai        ( nCells Time             ) 1  ro lai            diag_physics - -
-var persistent real    noahres    ( nCells Time             ) 1  ro noahres        diag_physics - -
-var persistent real    potevp     ( nCells Time             ) 1  ro potevp         diag_physics - -
-var persistent real    qz0        ( nCells Time             ) 1  ro qz0            diag_physics - -
-var persistent real    rib        ( nCells Time             ) 1  ro rib            diag_physics - -
-var persistent real    sfc_albedo ( nCells Time             ) 1  ro sfc_albedo     diag_physics - -
-var persistent real    sfc_emiss  ( nCells Time             ) 1  ro sfc_emiss      diag_physics - -
-var persistent real    sfc_emibck ( nCells Time             ) 1  ro sfc_emibck     diag_physics - -
-var persistent real    sfcrunoff  ( nCells Time             ) 1  ro sfcrunoff      diag_physics - -   
-var persistent real    smstav     ( nCells Time             ) 1  ro smstav         diag_physics - -   
-var persistent real    smstot     ( nCells Time             ) 1  ro smstot         diag_physics - -   
-var persistent real    snopcx     ( nCells Time             ) 1  ro snopcx         diag_physics - -
-var persistent real    snotime    ( nCells Time             ) 1  ro snotime        diag_physics - -
-var persistent real    sstsk      ( nCells Time             ) 1  ro sstsk          diag_physics - -
-var persistent real    sstsk_diur ( nCells Time             ) 1  ro sstsk_diur     diag_physics - -
-var persistent real    thc        ( nCells Time             ) 1  ro thc            diag_physics - - 
-var persistent real    udrunoff   ( nCells Time             ) 1  ro udrunoff       diag_physics - -   
-var persistent real    xicem      ( nCells Time             ) 1  ro xicem          diag_physics - -
-var persistent real    z0         ( nCells Time             ) 1  ro z0             diag_physics - -   
-var persistent real    zs         ( nCells Time             ) 1  ro zs             diag_physics - -   
-
-%--------------------------------------------------------------------------------------------------
-%... SURFACE CHARACTERISTICS THAT NEED TO BE READ FROM GRID.NC:
-%--------------------------------------------------------------------------------------------------
-
-% albedo12m      :monthly climatological albedo                                                 [-]
-% greenfrac      :monthly climatological greeness fraction                                      [-]                             
-% isltyp         :dominant soil category                                                        [-]
-% ivgtyp         :dominant vegetation category                                                  [-]
-% landmask       :=0 for ocean;=1 for land                                                      [-]
-% sfc_albbck     :background albedo                                                             [-]
-% shdmin         :minimum areal fractional coverage of annual green vegetation                  [-]
-% shdmax         :maximum areal fractional coverage of annual green vegetation                  [-]
-% skintemp       :skin temperature                                                              [K]
-% snoalb         :annual max snow albedo                                                        [-]
-% snow           :snow water equivalent                                                    [kg m-2]
-% sst            :sea-surface temperature                                                       [K]
-% snowc          :flag indicating snow coverage (1 for snow cover)                              [-]
-% snowh          :physical snow depth                                                           [m]
-% ter            :terrain height                                                                [-]
-% tmn            :soil temperature at lower boundary                                            [K]
-% vegfra         :vegetation fraction                                                           [-]
-% seaice         :sea-ice mask (=1 when xice is greater than 0; =0 otherwise)                   [-]
-% xice           :fractional sea-ice coverage                                                   [-]
-% xland          :land mask    (1 for land; 2 for water)                                        [-]
-
-% dzs            :thickness of soil layers                                                      [m]
-% smcrel         :soil moisture threshold below which transpiration begins to stress            [-]
-% sh2o           :soil liquid water                                                        [m3 m-3]
-% smois          :soil moisture                                                            [m3 m-3]
-% tslb           :soil temperature                                                              [K]
-
-var persistent integer isltyp     ( nCells                   ) 0 iro isltyp        sfc_input    - -
-var persistent integer ivgtyp     ( nCells                   ) 0 iro ivgtyp        sfc_input    - -
-var persistent integer landmask   ( nCells                   ) 0 iro landmask      sfc_input    - -
-var persistent real    shdmin     ( nCells                   ) 0 iro shdmin        sfc_input    - -
-var persistent real    shdmax     ( nCells                   ) 0 iro shdmax        sfc_input    - -
-var persistent real    snoalb     ( nCells                   ) 0 iro snoalb        sfc_input    - -
-var persistent real    ter        ( nCells                   ) 0 io  ter           sfc_input    - -
-var persistent real    albedo12m  ( nMonths nCells           ) 0 iro albedo12m     sfc_input    - -
-var persistent real    greenfrac  ( nMonths nCells           ) 0 iro greenfrac     sfc_input    - -
-
-var persistent real    sfc_albbck ( nCells Time              ) 1 iro sfc_albbck    sfc_input    - -
-var persistent real    skintemp   ( nCells Time              ) 1 iro skintemp      sfc_input    - -
-var persistent real    snow       ( nCells Time              ) 1 iro snow          sfc_input    - -
-var persistent real    snowc      ( nCells Time              ) 1 iro snowc         sfc_input    - -
-var persistent real    snowh      ( nCells Time              ) 1 iro snowh         sfc_input    - -
-var persistent real    sst        ( nCells Time              ) 1 isro sst          sfc_input    - -
-var persistent real    tmn        ( nCells Time              ) 1 iro tmn           sfc_input    - -
-var persistent real    vegfra     ( nCells Time              ) 1 iro vegfra        sfc_input    - -   
-var persistent real    seaice     ( nCells Time              ) 1 iro seaice        sfc_input    - -
-var persistent real    xice       ( nCells Time              ) 1 isro xice         sfc_input    - -
-var persistent real    xland      ( nCells Time              ) 1 iro xland         sfc_input    - -
-
-var persistent real    dzs        ( nSoilLevels nCells Time  ) 1 iro dzs           sfc_input    - -
-var persistent real    smcrel     ( nSoilLevels nCells Time  ) 1  ro smcrel        sfc_input    - -
-var persistent real    sh2o       ( nSoilLevels nCells Time  ) 1 iro sh2o          sfc_input    - -
-var persistent real    smois      ( nSoilLevels nCells Time  ) 1 iro smois         sfc_input    - -
-var persistent real    tslb       ( nSoilLevels nCells Time  ) 1 iro tslb          sfc_input    - -
-
-%==================================================================================================

Copied: branches/mpas_cdg_advection/src/core_nhyd_atmos/Registry.xml (from rev 2782, trunk/mpas/src/core_nhyd_atmos/Registry.xml)
===================================================================
--- branches/mpas_cdg_advection/src/core_nhyd_atmos/Registry.xml                                (rev 0)
+++ branches/mpas_cdg_advection/src/core_nhyd_atmos/Registry.xml        2013-04-22 01:31:32 UTC (rev 2783)
@@ -0,0 +1,1005 @@
+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;registry model=&quot;mpas&quot; core=&quot;nhyd_atmos&quot; version=&quot;0.0.0&quot;&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_del4u_div_factor&quot;           type=&quot;real&quot;          default_value=&quot;1.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;!--  fh        :integrated function for heat                                                       [-] --&gt;
+                &lt;!--  fm        :integrated function for momentum                                                   [-] --&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;var name=&quot;fh&quot;            type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;ro&quot;/&gt;
+                &lt;var name=&quot;fm&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;!--  nlrad     :number of layers added above the model-top in the RRTMG lw radiation code          [-] --&gt;
+                &lt;!--  plrad     :pressure at model-top                                                             [Pa] --&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;nlrad&quot;         type=&quot;integer&quot;  dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot; /&gt;
+                &lt;var name=&quot;plrad&quot;         type=&quot;real&quot;     dimensions=&quot;nCells Time&quot;                 streams=&quot;o&quot; /&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;

Modified: branches/mpas_cdg_advection/src/core_nhyd_atmos/mpas_atm_advection.F
===================================================================
--- branches/mpas_cdg_advection/src/core_nhyd_atmos/mpas_atm_advection.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_nhyd_atmos/mpas_atm_advection.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -26,43 +26,33 @@
 !  local variables
 
       real (kind=RKIND), dimension(2, grid % nEdges) :: thetae
-      real (kind=RKIND), dimension(grid % nEdges) :: xe, ye
       real (kind=RKIND), dimension(grid % nCells) :: theta_abs
 
       real (kind=RKIND), dimension(25) :: xc, yc, zc ! cell center coordinates
       real (kind=RKIND), dimension(25) :: thetav, thetat, dl_sphere
-      real (kind=RKIND) :: xm, ym, zm, dl, xec, yec, zec
-      real (kind=RKIND) :: thetae_tmp, xe_tmp, ye_tmp
+      real (kind=RKIND) :: xec, yec, zec
+      real (kind=RKIND) :: thetae_tmp
       real (kind=RKIND) :: xv1, xv2, yv1, yv2, zv1, zv2
-      integer :: i, j, k, ip1, ip2, m, n, ip1a, ii
+      integer :: i, j, k, ip1, ip2, n
       integer :: iCell, iEdge
       real (kind=RKIND) :: pii
-      real (kind=RKIND) :: x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5
-      real (kind=RKIND) :: pdx1, pdx2, pdx3, pdy1, pdy2, pdy3, dx1, dx2, dy1, dy2
-      real (kind=RKIND) :: angv1, angv2, dl1, dl2
-      real (kind=RKIND), dimension(25) :: dxe, dye, x2v, y2v, xp, yp
+      real (kind=RKIND), dimension(25) :: xp, yp
       
       real (kind=RKIND) :: amatrix(25,25), bmatrix(25,25), wmatrix(25,25)
       real (kind=RKIND) :: length_scale
-      integer :: ma,na, cell_add, mw, nn
+      integer :: ma,na, cell_add, mw
       integer, dimension(25) :: cell_list
+      logical :: add_the_cell, do_the_cell
 
+      real (kind=RKIND) :: cos2t, costsint, sin2t
+      real (kind=RKIND), dimension(grid%maxEdges) :: angle_2d
 
-      integer :: cell1, cell2
       integer, parameter :: polynomial_order = 2
-!      logical, parameter :: debug = .true.
       logical, parameter :: debug = .false.
-!      logical, parameter :: least_squares = .false.
       logical, parameter :: least_squares = .true.
-      logical :: add_the_cell, do_the_cell
-
       logical, parameter :: reset_poly = .true.
 
-      real (kind=RKIND) :: rcell, cos2t, costsint, sin2t
-      real (kind=RKIND), dimension(grid%maxEdges) :: angle_2d
 
-!---
-
       pii = 2.*asin(1.0)
 
       advCells =&gt; grid % advCells % array
@@ -119,7 +109,7 @@
             theta_abs(iCell) =  pii/2. - sphere_angle( xc(1), yc(1), zc(1),  &amp;
                                                        xc(2), yc(2), zc(2),  &amp;
                                                        0.0_RKIND, 0.0_RKIND, 1.0_RKIND ) 
-
+  
 ! angles from cell center to neighbor centers (thetav)
 
             do i=1,n-1
@@ -130,7 +120,7 @@
                thetav(i) = sphere_angle( xc(1),   yc(1),   zc(1),    &amp;
                                          xc(i+1), yc(i+1), zc(i+1),  &amp;
                                          xc(ip2), yc(ip2), zc(ip2)   )
-
+  
                dl_sphere(i) = grid%sphere_radius*arc_length( xc(1),   yc(1),   zc(1),  &amp;
                                                              xc(i+1), yc(i+1), zc(i+1) )
             end do
@@ -159,10 +149,10 @@
                iEdge = grid % EdgesOnCell % array(i,iCell)
                if ( iCell .ne. grid % CellsOnEdge % array(1,iEdge)) &amp;
                   angle_2d(i) = angle_2d(i) - pii
+  
+!                 xp(i) = grid % xCell % array(cell_list(i)) - grid % xCell % array(iCell)
+!                 yp(i) = grid % yCell % array(cell_list(i)) - grid % yCell % array(iCell)
 
-!               xp(i) = grid % xCell % array(cell_list(i)) - grid % xCell % array(iCell)
-!               yp(i) = grid % yCell % array(cell_list(i)) - grid % yCell % array(iCell)
-
                xp(i) = grid % dcEdge % array(grid % EdgesOnCell % array(i,iCell)) * cos(angle_2d(i))
                yp(i) = grid % dcEdge % array(grid % EdgesOnCell % array(i,iCell)) * sin(angle_2d(i))
 
@@ -205,20 +195,20 @@
                amatrix(i,1) = 1.
                amatrix(i,2) = xp(i-1)
                amatrix(i,3) = yp(i-1)
-   
+     
                amatrix(i,4) = xp(i-1)**2
                amatrix(i,5) = xp(i-1) * yp(i-1)
                amatrix(i,6) = yp(i-1)**2
-   
+     
                amatrix(i,7) = xp(i-1)**3
                amatrix(i,8) = yp(i-1) * (xp(i-1)**2)
                amatrix(i,9) = xp(i-1) * (yp(i-1)**2)
                amatrix(i,10) = yp(i-1)**3
+     
+               wmatrix(i,i) = 1.
    
-               wmatrix(i,i) = 1.

             end do
-
+  
          else
             na = 15
             ma = ma+1
@@ -229,16 +219,16 @@
                amatrix(i,1) = 1.
                amatrix(i,2) = xp(i-1)
                amatrix(i,3) = yp(i-1)
-   
+     
                amatrix(i,4) = xp(i-1)**2
                amatrix(i,5) = xp(i-1) * yp(i-1)
                amatrix(i,6) = yp(i-1)**2
-   
+     
                amatrix(i,7) = xp(i-1)**3
                amatrix(i,8) = yp(i-1) * (xp(i-1)**2)
                amatrix(i,9) = xp(i-1) * (yp(i-1)**2)
                amatrix(i,10) = yp(i-1)**3
-   
+     
                amatrix(i,11) = xp(i-1)**4
                amatrix(i,12) = yp(i-1) * (xp(i-1)**3)
                amatrix(i,13) = (xp(i-1)**2)*(yp(i-1)**2)
@@ -248,11 +238,11 @@
                wmatrix(i,i) = 1.
   
             end do

+   
             do i=1,mw
                wmatrix(i,i) = 1.
             end do

+   
          end if
  
          call poly_fit_2( amatrix, bmatrix, wmatrix, ma, na, 25 )
@@ -363,7 +353,6 @@
 
       if (debug) stop
 
-
 !      write(0,*) ' check for deriv2 coefficients, iEdge 4 '
 !
 !      iEdge = 4
@@ -400,9 +389,7 @@
       real (kind=RKIND) :: a, b, c          ! Side lengths of spherical triangle ABC
    
       real (kind=RKIND) :: ABx, ABy, ABz    ! The components of the vector AB
-      real (kind=RKIND) :: mAB              ! The magnitude of AB
       real (kind=RKIND) :: ACx, ACy, ACz    ! The components of the vector AC
-      real (kind=RKIND) :: mAC              ! The magnitude of AC
    
       real (kind=RKIND) :: Dx               ! The i-components of the cross product AB x AC
       real (kind=RKIND) :: Dy               ! The j-components of the cross product AB x AC
@@ -571,16 +558,15 @@
       real (kind=RKIND), dimension(n,m)  :: b
       real (kind=RKIND), dimension(m,m)  :: w,wt,h
       real (kind=RKIND), dimension(n,m)  :: at, ath
-      real (kind=RKIND), dimension(n,n)  :: ata, ata_inv, atha, atha_inv
+      real (kind=RKIND), dimension(n,n)  :: ata, atha, atha_inv
+!      real (kind=RKIND), dimension(n,n)  :: ata_inv
       integer, dimension(n) :: indx
-      integer :: i,j
    
       if ( (ne&lt;n) .or. (ne&lt;m) ) then
          write(6,*) ' error in poly_fit_2 inversion ',m,n,ne
          stop
       end if
    
-!      a(1:m,1:n) = a_in(1:n,1:m) 
       a(1:m,1:n) = a_in(1:m,1:n)
       w(1:m,1:m) = weights_in(1:m,1:m) 
       b_out(:,:) = 0.   
@@ -615,134 +601,133 @@
    end subroutine poly_fit_2
 
 
-! Updated 10/24/2001.
-!
-!!!!!!!!!!!!!!!!!!!!!!!!!!!   Program 4.4   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!                                                                       !
-! Please Note:                                                          !
-!                                                                       !
-! (1) This computer program is written by Tao Pang in conjunction with  !
-!     his book, &quot;An Introduction to Computational Physics,&quot; published   !
-!     by Cambridge University Press in 1997.                            !
-!                                                                       !
-! (2) No warranties, express or implied, are made for this program.     !
-!                                                                       !
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!
-SUBROUTINE MIGS (A,N,X,INDX)
-!
-! Subroutine to invert matrix A(N,N) with the inverse stored
-! in X(N,N) in the output.  Copyright (c) Tao Pang 2001.
-!
-  IMPLICIT NONE
-  INTEGER, INTENT (IN) :: N
-  INTEGER :: I,J,K
-  INTEGER, INTENT (OUT), DIMENSION (N) :: INDX
-  REAL (kind=RKIND), INTENT (INOUT), DIMENSION (N,N):: A
-  REAL (kind=RKIND), INTENT (OUT), DIMENSION (N,N):: X
-  REAL (kind=RKIND), DIMENSION (N,N) :: B
-!
-  DO I = 1, N
-    DO J = 1, N
-      B(I,J) = 0.0
-    END DO
-  END DO
-  DO I = 1, N
-    B(I,I) = 1.0
-  END DO
-!
-  CALL ELGS (A,N,INDX)
-!
-  DO I = 1, N-1
-    DO J = I+1, N
-      DO K = 1, N
-        B(INDX(J),K) = B(INDX(J),K)-A(INDX(J),I)*B(INDX(I),K)
-      END DO
-    END DO
-  END DO
-!
-  DO I = 1, N
-    X(N,I) = B(INDX(N),I)/A(INDX(N),N)
-    DO J = N-1, 1, -1
-      X(J,I) = B(INDX(J),I)
-      DO K = J+1, N
-        X(J,I) = X(J,I)-A(INDX(J),K)*X(K,I)
-      END DO
-      X(J,I) =  X(J,I)/A(INDX(J),J)
-    END DO
-  END DO
-END SUBROUTINE MIGS
+   ! Updated 10/24/2001.
+   !
+   !!!!!!!!!!!!!!!!!!!!!!!!!!!   Program 4.4   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+   !
+   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+   !                                                                       !
+   ! Please Note:                                                          !
+   !                                                                       !
+   ! (1) This computer program is written by Tao Pang in conjunction with  !
+   !     his book, &quot;An Introduction to Computational Physics,&quot; published   !
+   !     by Cambridge University Press in 1997.                            !
+   !                                                                       !
+   ! (2) No warranties, express or implied, are made for this program.     !
+   !                                                                       !
+   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+   !
+   SUBROUTINE MIGS (A,N,X,INDX)
+   !
+   ! Subroutine to invert matrix A(N,N) with the inverse stored
+   ! in X(N,N) in the output.  Copyright (c) Tao Pang 2001.
+   !
+     IMPLICIT NONE
+     INTEGER, INTENT (IN) :: N
+     INTEGER :: I,J,K
+     INTEGER, INTENT (OUT), DIMENSION (N) :: INDX
+     REAL (kind=RKIND), INTENT (INOUT), DIMENSION (N,N):: A
+     REAL (kind=RKIND), INTENT (OUT), DIMENSION (N,N):: X
+     REAL (kind=RKIND), DIMENSION (N,N) :: B
+   !
+     DO I = 1, N
+       DO J = 1, N
+         B(I,J) = 0.0
+       END DO
+     END DO
+     DO I = 1, N
+       B(I,I) = 1.0
+     END DO
+   !
+     CALL ELGS (A,N,INDX)
+   !
+     DO I = 1, N-1
+       DO J = I+1, N
+         DO K = 1, N
+           B(INDX(J),K) = B(INDX(J),K)-A(INDX(J),I)*B(INDX(I),K)
+         END DO
+       END DO
+     END DO
+   !
+     DO I = 1, N
+       X(N,I) = B(INDX(N),I)/A(INDX(N),N)
+       DO J = N-1, 1, -1
+         X(J,I) = B(INDX(J),I)
+         DO K = J+1, N
+           X(J,I) = X(J,I)-A(INDX(J),K)*X(K,I)
+         END DO
+         X(J,I) =  X(J,I)/A(INDX(J),J)
+       END DO
+     END DO
+   END SUBROUTINE MIGS
 
 
-SUBROUTINE ELGS (A,N,INDX)
-!
-! Subroutine to perform the partial-pivoting Gaussian elimination.
-! A(N,N) is the original matrix in the input and transformed matrix
-! plus the pivoting element ratios below the diagonal in the output.
-! INDX(N) records the pivoting order.  Copyright (c) Tao Pang 2001.
-!
-  IMPLICIT NONE
-  INTEGER, INTENT (IN) :: N
-  INTEGER :: I,J,K,ITMP
-  INTEGER, INTENT (OUT), DIMENSION (N) :: INDX
-  REAL (kind=RKIND) :: C1,PI,PI1,PJ
-  REAL (kind=RKIND), INTENT (INOUT), DIMENSION (N,N) :: A
-  REAL (kind=RKIND), DIMENSION (N) :: C
-!
-! Initialize the index
-!
-  DO I = 1, N
-    INDX(I) = I
-  END DO
-!
-! Find the rescaling factors, one from each row
-!
-  DO I = 1, N
-    C1= 0.0
-    DO J = 1, N
-      C1 = MAX(C1,ABS(A(I,J)))
-    END DO
-    C(I) = C1
-  END DO
-!
-! Search the pivoting (largest) element from each column
-!
-  DO J = 1, N-1
-    PI1 = 0.0
-    DO I = J, N
-      PI = ABS(A(INDX(I),J))/C(INDX(I))
-      IF (PI.GT.PI1) THEN
-        PI1 = PI
-        K   = I
-      ENDIF
-    END DO
-!
-! Interchange the rows via INDX(N) to record pivoting order
-!
-    ITMP    = INDX(J)
-    INDX(J) = INDX(K)
-    INDX(K) = ITMP
-    DO I = J+1, N
-      PJ  = A(INDX(I),J)/A(INDX(J),J)
-!
-! Record pivoting ratios below the diagonal
-!
-      A(INDX(I),J) = PJ
-!
-! Modify other elements accordingly
-!
-      DO K = J+1, N
-        A(INDX(I),K) = A(INDX(I),K)-PJ*A(INDX(J),K)
-      END DO
-    END DO
-  END DO
-!
-END SUBROUTINE ELGS
+   SUBROUTINE ELGS (A,N,INDX)
+   !
+   ! Subroutine to perform the partial-pivoting Gaussian elimination.
+   ! A(N,N) is the original matrix in the input and transformed matrix
+   ! plus the pivoting element ratios below the diagonal in the output.
+   ! INDX(N) records the pivoting order.  Copyright (c) Tao Pang 2001.
+   !
+     IMPLICIT NONE
+     INTEGER, INTENT (IN) :: N
+     INTEGER :: I,J,K,ITMP
+     INTEGER, INTENT (OUT), DIMENSION (N) :: INDX
+     REAL (kind=RKIND) :: C1,PI,PI1,PJ
+     REAL (kind=RKIND), INTENT (INOUT), DIMENSION (N,N) :: A
+     REAL (kind=RKIND), DIMENSION (N) :: C
+   !
+   ! Initialize the index
+   !
+     DO I = 1, N
+       INDX(I) = I
+     END DO
+   !
+   ! Find the rescaling factors, one from each row
+   !
+     DO I = 1, N
+       C1= 0.0
+       DO J = 1, N
+         C1 = MAX(C1,ABS(A(I,J)))
+       END DO
+       C(I) = C1
+     END DO
+   !
+   ! Search the pivoting (largest) element from each column
+   !
+     DO J = 1, N-1
+       PI1 = 0.0
+       DO I = J, N
+         PI = ABS(A(INDX(I),J))/C(INDX(I))
+         IF (PI.GT.PI1) THEN
+           PI1 = PI
+           K   = I
+         ENDIF
+       END DO
+   !
+   ! Interchange the rows via INDX(N) to record pivoting order
+   !
+       ITMP    = INDX(J)
+       INDX(J) = INDX(K)
+       INDX(K) = ITMP
+       DO I = J+1, N
+         PJ  = A(INDX(I),J)/A(INDX(J),J)
+   !
+   ! Record pivoting ratios below the diagonal
+   !
+         A(INDX(I),J) = PJ
+   !
+   ! Modify other elements accordingly
+   !
+         DO K = J+1, N
+           A(INDX(I),K) = A(INDX(I),K)-PJ*A(INDX(J),K)
+         END DO
+       END DO
+     END DO
+   !
+   END SUBROUTINE ELGS
+   
 
-!-------------------------------------------------------------
-
    subroutine atm_initialize_deformation_weights( grid )
                                       
 !
@@ -758,30 +743,22 @@
 
 !  local variables
 
-      real (kind=RKIND), dimension(2, grid % nEdges) :: thetae
-      real (kind=RKIND), dimension(grid % nEdges) :: xe, ye
       real (kind=RKIND), dimension(grid % nCells) :: theta_abs
 
       real (kind=RKIND), dimension(25) :: xc, yc, zc ! cell center coordinates
       real (kind=RKIND), dimension(25) :: thetav, thetat, dl_sphere
-      real (kind=RKIND) :: xm, ym, zm, dl, xec, yec, zec
-      real (kind=RKIND) :: thetae_tmp, xe_tmp, ye_tmp
-      real (kind=RKIND) :: xv1, xv2, yv1, yv2, zv1, zv2
-      integer :: i, j, k, ip1, ip2, m, n, ip1a, ii
-      integer :: iCell, iEdge
+      real (kind=RKIND) :: dl
+      integer :: i, ip1, ip2, n
+      integer :: iCell
       real (kind=RKIND) :: pii
-      real (kind=RKIND) :: x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5
-      real (kind=RKIND) :: pdx1, pdx2, pdx3, pdy1, pdy2, pdy3, dx1, dx2, dy1, dy2
-      real (kind=RKIND) :: angv1, angv2, dl1, dl2
-      real (kind=RKIND), dimension(25) :: dxe, dye, x2v, y2v, xp, yp, xpt, ypt
+      real (kind=RKIND), dimension(25) :: xp, yp
       
       real (kind=RKIND) :: length_scale
-      integer :: ma,na, cell_add, mw, nn
       integer, dimension(25) :: cell_list
 
-      integer :: cell1, cell2, iv
+      integer :: iv
       logical :: do_the_cell
-      real (kind=RKIND) :: area_cell, sint2, cost2, sint_cost, sumw1, sumw2, xptt, area_cellt
+      real (kind=RKIND) :: area_cell, sint2, cost2, sint_cost, area_cellt
 
       logical, parameter :: debug = .false.
 

Copied: branches/mpas_cdg_advection/src/core_nhyd_atmos/mpas_atm_interp_diagnostics.F (from rev 2782, trunk/mpas/src/core_nhyd_atmos/mpas_atm_interp_diagnostics.F)
===================================================================
--- branches/mpas_cdg_advection/src/core_nhyd_atmos/mpas_atm_interp_diagnostics.F                                (rev 0)
+++ branches/mpas_cdg_advection/src/core_nhyd_atmos/mpas_atm_interp_diagnostics.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -0,0 +1,383 @@
+!==================================================================================================
+ module mpas_atm_interp_diagnostics
+ use mpas_kind_types
+ use mpas_grid_types
+ use mpas_constants
+
+ implicit none
+ private
+ public:: interp_diagnostics
+
+ contains
+
+!==================================================================================================
+ subroutine interp_diagnostics(mesh,state,diag)
+!==================================================================================================
+
+!input arguments:
+ type(mesh_type),intent(in) :: mesh
+ type(state_type),intent(in):: state
+
+!inout arguments:
+ type(diag_type),intent(inout):: diag
+
+!local variables:
+ integer:: iCell,iVert,iVertD,k,kk
+ integer:: nCells,nVertLevels,nVertLevelsP1,nVertices,VertexDegree
+ integer,dimension(:,:),pointer:: cellsOnVertex
+
+ real(kind=RKIND),dimension(:),pointer:: areaTriangle
+ real(kind=RKIND),dimension(:,:),pointer:: kiteAreasOnVertex

+ real(kind=RKIND),dimension(:,:),pointer:: exner,height
+ real(kind=RKIND),dimension(:,:),pointer:: pressure_b,pressure_p 
+ real(kind=RKIND),dimension(:,:),pointer:: qvapor,theta_m,vorticity
+ real(kind=RKIND),dimension(:,:),pointer:: umeridional,uzonal,vvel

+ real(kind=RKIND),dimension(:,:),allocatable:: pressure,pressureCp1,pressure2,pressure_v,temperature
+
+!local interpolated fields:
+ integer:: nIntP
+ real(kind=RKIND):: w1,w2,z0,z1,z2
+ real(kind=RKIND),dimension(:,:),allocatable:: field_in,press_in
+ real(kind=RKIND),dimension(:,:),allocatable:: field_interp,press_interp

+!--------------------------------------------------------------------------------------------------
+
+ write(0,*)
+ write(0,*) '--- enter subroutine interp_diagnostics:'
+
+ nCells        = mesh % nCells
+ nVertLevels   = mesh % nVertLevels
+!nVertLevelsP1 = mesh % nVertLevelsP1
+ nVertices     = mesh % nVertices
+ VertexDegree  = mesh % vertexDegree
+ nVertLevelsP1 = nVertLevels + 1
+
+ cellsOnVertex     =&gt; mesh % cellsOnVertex     % array
+ areaTriangle      =&gt; mesh % areaTriangle      % array
+ kiteAreasOnVertex =&gt; mesh % kiteAreasOnVertex % array
+
+ height  =&gt; mesh  % zgrid   % array
+ vvel    =&gt; state % w       % array
+ theta_m =&gt; state % theta_m % array
+ qvapor  =&gt; state % scalars % array(state%index_qv,:,:)

+ exner       =&gt; diag % exner         % array
+ pressure_b  =&gt; diag % pressure_base % array
+ pressure_p  =&gt; diag % pressure_p    % array
+ vorticity   =&gt; diag % vorticity     % array
+ umeridional =&gt; diag % uReconstructMeridional % array
+ uzonal      =&gt; diag % uReconstructZonal      % array
+
+ if(.not.allocated(pressure)    ) allocate(pressure(nVertLevels,nCells)      )
+ if(.not.allocated(pressureCp1) ) allocate(pressureCp1(nVertLevels,nCells+1) )
+ if(.not.allocated(pressure2)   ) allocate(pressure2(nVertLevelsP1,nCells)   )
+ if(.not.allocated(pressure_v)  ) allocate(pressure_v(nVertLevels,nVertices) )
+ if(.not.allocated(temperature) ) allocate(temperature(nVertLevels,nCells)   )
+
+!calculation of total pressure at cell centers (at mass points):
+ do iCell = 1, nCells
+ do k = 1, nVertLevels
+    pressure(k,iCell)    = (pressure_p(k,iCell) + pressure_b(k,iCell)) / 100._RKIND
+    pressureCp1(k,iCell) = pressure(k,iCell)
+ enddo
+ enddo
+ do iCell = nCells+1, nCells+1
+ do k = 1, nVertLevels
+    pressureCp1(k,iCell)   = (pressure_p(k,iCell) + pressure_b(k,iCell)) / 100._RKIND
+ enddo
+ enddo
+
+!calculation of total pressure at cell centers (at vertical velocity points):
+ k = nVertLevelsP1
+ do iCell = 1, nCells
+    z0 = height(k,iCell)
+    z1 = 0.5*(height(k,iCell)+height(k-1,iCell)) 
+    z2 = 0.5*(height(k-1,iCell)+height(k-2,iCell))
+    w1 = (z0-z2)/(z1-z2)
+    w2 = 1.-w1
+    !use log of pressure to avoid occurrences of negative top-of-the-model pressure.
+    pressure2(k,iCell) = exp(w1*log(pressure(k-1,iCell))+w2*log(pressure(k-2,iCell)))
+ enddo
+ do k = 2, nVertLevels
+ do iCell = 1, nCells
+    w1 = (height(k,iCell)-height(k-1,iCell)) / (height(k+1,iCell)-height(k-1,iCell))
+    w2 = (height(k+1,iCell)-height(k,iCell)) / (height(k+1,iCell)-height(k-1,iCell))
+    pressure2(k,iCell) = w1*pressure(k,iCell) + w2*pressure(k-1,iCell)
+ enddo
+ enddo
+ k = 1
+ do iCell = 1, nCells
+    z0 = height(k,iCell)
+    z1 = 0.5*(height(k,iCell)+height(k+1,iCell)) 
+    z2 = 0.5*(height(k+1,iCell)+height(k+2,iCell))
+    w1 = (z0-z2)/(z1-z2)
+    w2 = 1.-w1
+    pressure2(k,iCell) = w1*pressure(k,iCell)+w2*pressure(k+1,iCell)
+ enddo
+
+!calculation of total pressure at cell vertices (at mass points):
+ do iVert = 1, nVertices
+    pressure_v(:,iVert) = 0._RKIND
+
+    do k = 1, nVertLevels
+    do iVertD = 1, vertexDegree
+       pressure_v(k,iVert) = pressure_v(k,iVert) &amp;
+               + kiteAreasOnVertex(iVertD,iVert)*pressureCp1(k,cellsOnVertex(iVertD,iVert))
+    enddo
+    pressure_v(k,iVert) = pressure_v(k,iVert) / areaTriangle(iVert)
+    enddo
+ enddo
+
+!calculation of temperature at cell centers:
+ do iCell = 1,nCells
+ do k = 1,nVertLevels
+    temperature(k,iCell) = (theta_m(k,iCell)/(1._RKIND+rvord*qvapor(k,iCell)))*exner(k,iCell) 
+ enddo
+ enddo
+
+!interpolation to fixed pressure levels for fields located at cells centers and at mass points:
+ nIntP = 3
+ if(.not.allocated(field_interp)) allocate(field_interp(nCells,nIntP) )
+ if(.not.allocated(press_interp)) allocate(press_interp(nCells,nIntP) )
+ do iCell = 1, nCells
+    press_interp(iCell,1) = 200.0_RKIND
+    press_interp(iCell,2) = 500.0_RKIND
+    press_interp(iCell,3) = 850.0_RKIND
+ enddo
+
+ if(.not.allocated(press_in)) allocate(press_in(nCells,nVertLevels))
+ do iCell = 1, nCells
+ do k = 1, nVertLevels
+    kk = nVertLevels+1-k
+    press_in(iCell,kk) = pressure(k,iCell)
+ enddo
+ enddo
+
+ if(.not.allocated(field_in)) allocate(field_in(nCells,nVertLevels))
+!... temperature:
+ do iCell = 1, nCells
+ do k = 1, nVertLevels
+    kk = nVertLevels+1-k
+    field_in(iCell,kk) = temperature(k,iCell)
+ enddo
+ enddo
+ call interp_tofixed_pressure(nCells,nVertLevels,nIntP,press_in,field_in,press_interp,field_interp)
+ diag % temperature_200hPa % array(1:nCells) = field_interp(1:nCells,1)
+ diag % temperature_500hPa % array(1:nCells) = field_interp(1:nCells,2)
+ diag % temperature_850hPa % array(1:nCells) = field_interp(1:nCells,3)
+ write(0,*) '--- end interpolate temperature:'
+
+!... u zonal wind:
+ do iCell = 1, nCells
+ do k = 1, nVertLevels
+    kk = nVertLevels+1-k
+    field_in(iCell,kk) = uzonal(k,iCell)
+ enddo
+ enddo
+ call interp_tofixed_pressure(nCells,nVertLevels,nIntP,press_in,field_in,press_interp,field_interp)
+ diag % uzonal_200hPa % array(1:nCells) = field_interp(1:nCells,1)
+ diag % uzonal_500hPa % array(1:nCells) = field_interp(1:nCells,2)
+ diag % uzonal_850hPa % array(1:nCells) = field_interp(1:nCells,3)
+ write(0,*) '--- end interpolate zonal wind:'
+
+!... u meridional wind:
+ do iCell = 1, nCells
+ do k = 1, nVertLevels
+    kk = nVertLevels+1-k
+    field_in(iCell,kk) = umeridional(k,iCell)
+ enddo
+ enddo
+ call interp_tofixed_pressure(nCells,nVertLevels,nIntP,press_in,field_in,press_interp,field_interp)
+ diag % umeridional_200hPa % array(1:nCells) = field_interp(1:nCells,1)
+ diag % umeridional_500hPa % array(1:nCells) = field_interp(1:nCells,2)
+ diag % umeridional_850hPa % array(1:nCells) = field_interp(1:nCells,3)
+ write(0,*) '--- end interpolate meridional wind:'
+
+ if(allocated(field_in)) deallocate(field_in)
+ if(allocated(press_in)) deallocate(press_in)
+
+!interpolation to fixed pressure levels for fields located at cells centers and at vertical
+!velocity points:
+ if(.not.allocated(press_in)) allocate(press_in(nCells,nVertLevelsP1))
+ do iCell = 1, nCells
+ do k = 1, nVertLevelsP1
+    kk = nVertLevelsP1+1-k
+    press_in(iCell,kk) = pressure2(k,iCell)
+ enddo
+ enddo
+
+ if(.not.allocated(field_in)) allocate(field_in(nCells,nVertLevelsP1))
+ !... height:
+ do iCell = 1, nCells
+ do k = 1, nVertLevelsP1
+    kk = nVertLevelsP1+1-k
+    field_in(iCell,kk) = height(k,iCell)
+ enddo
+ enddo
+ call interp_tofixed_pressure(nCells,nVertLevelsP1,nIntP,press_in,field_in,press_interp,field_interp)
+ diag % height_200hPa % array(1:nCells) = field_interp(1:nCells,1)
+ diag % height_500hPa % array(1:nCells) = field_interp(1:nCells,2)
+ diag % height_850hPa % array(1:nCells) = field_interp(1:nCells,3)
+ write(0,*) '--- end interpolate height:'

+!... vertical velocity
+ do iCell = 1, nCells
+ do k = 1, nVertLevelsP1
+    kk = nVertLevelsP1+1-k
+    field_in(iCell,kk) = vvel(k,iCell)
+ enddo
+ enddo
+ call interp_tofixed_pressure(nCells,nVertLevelsP1,nIntP,press_in,field_in,press_interp,field_interp)
+ diag % w_200hPa % array(1:nCells) = field_interp(1:nCells,1)
+ diag % w_500hPa % array(1:nCells) = field_interp(1:nCells,2)
+ diag % w_850hPa % array(1:nCells) = field_interp(1:nCells,3)
+ write(0,*) '--- end interpolate vertical velocity:'

+ if(allocated(field_interp)) deallocate(field_interp)
+ if(allocated(press_interp)) deallocate(press_interp)
+
+!interpolation to fixed pressure levels for fields located at cell vertices and at mass points:
+ nIntP = 3
+ if(.not.allocated(field_interp)) allocate(field_interp(nVertices,nIntP) )
+ if(.not.allocated(press_interp)) allocate(press_interp(nVertices,nIntP) )
+ do iVert = 1, nVertices
+    press_interp(iVert,1) = 200.0_RKIND
+    press_interp(iVert,2) = 500.0_RKIND
+    press_interp(iVert,3) = 850.0_RKIND
+ enddo
+
+ if(allocated(field_in)) deallocate(field_in)
+ if(allocated(press_in)) deallocate(press_in)
+
+ if(.not.allocated(press_in)) allocate(press_in(nVertices,nVertLevels))
+ do iVert = 1, nVertices
+ do k = 1, nVertLevels
+    kk = nVertLevels+1-k
+    press_in(iVert,kk) = pressure_v(k,iVert)
+ enddo
+ enddo
+
+ if(.not.allocated(field_in)) allocate(field_in(nVertices,nVertLevels))
+!... relative vorticity:
+ do iVert = 1, nVertices
+ do k = 1, nVertLevels
+    kk = nVertLevels+1-k
+    field_in(iVert,kk) = vorticity(k,iVert)
+ enddo
+ enddo
+ call interp_tofixed_pressure(nVertices,nVertLevels,nIntP,press_in,field_in,press_interp,field_interp)
+ diag % vorticity_200hPa % array(1:nVertices) = field_interp(1:nVertices,1)
+ diag % vorticity_500hPa % array(1:nVertices) = field_interp(1:nVertices,2)
+ diag % vorticity_850hPa % array(1:nVertices) = field_interp(1:nVertices,3)
+ write(0,*) '--- end interpolate relative vorticity:'
+
+ if(allocated(field_interp)) deallocate(field_interp)
+ if(allocated(press_interp)) deallocate(press_interp)
+ if(allocated(pressure)    ) deallocate(pressure    )
+ if(allocated(pressureCp1) ) deallocate(pressureCp1 )
+ if(allocated(pressure2)   ) deallocate(pressure2   )
+ if(allocated(pressure_v)  ) deallocate(pressure_v  )
+ if(allocated(temperature) ) deallocate(temperature )
+
+!formats:
+! 201 format(i5,4(1x,e15.8))
+
+ end subroutine interp_diagnostics
+
+!==================================================================================================
+ subroutine interp_tofixed_pressure(ncol,nlev_in,nlev_out,pres_in,field_in,pres_out,field_out)
+!==================================================================================================
+
+!input arguments:
+ integer,intent(in):: ncol,nlev_in,nlev_out
+
+ real(kind=RKIND),intent(in),dimension(ncol,nlev_in) :: pres_in,field_in
+ real(kind=RKIND),intent(in),dimension(ncol,nlev_out):: pres_out
+
+!output arguments:
+ real(kind=RKIND),intent(out),dimension(ncol,nlev_out):: field_out
+
+!local variables:
+! integer:: i1,i2,icol,k,kk
+ integer:: icol,k,kk
+ integer:: kkstart,kount
+ integer,dimension(ncol):: kupper
+
+ real(kind=RKIND):: dpl,dpu
+
+!--------------------------------------------------------------------------------------------------
+
+!formats:
+! 201 format(i5,8(1x,e15.8))
+
+!write(0,*)
+!write(0,*) '--- enter subroutine interp_tofixed_pressure:'
+!write(0,*) '... ncol     = ',ncol
+!write(0,*) '... nlev_in  = ',nlev_in
+!write(0,*) '... nlev_out = ',nlev_out
+!i1=1 ; i2=ncol
+!do k = 1, nlev_in
+!   write(0,201) k,pres_in(i1,k),field_in(i1,k),pres_in(i2,k),field_in(i2,k)
+!enddo
+!write(0,*)
+
+ do icol = 1, ncol
+    kupper(icol) = 1
+ enddo
+
+ do k = 1, nlev_out 
+
+    kkstart = nlev_in
+    do icol = 1, ncol
+       kkstart = min0(kkstart,kupper(icol))
+    enddo
+    kount = 0
+
+    do kk = kkstart, nlev_in-1
+       do icol = 1, ncol
+          if(pres_out(icol,k).gt.pres_in(icol,kk).and.pres_out(icol,k).le.pres_in(icol,kk+1)) then
+             kupper(icol) = kk
+             kount = kount + 1
+!            write(0,201) kupper(icol),pres_out(icol,k),pres_in(icol,kk),pres_in(icol,kk+1)
+          endif
+       enddo
+
+       if(kount.eq.ncol) then
+          do icol = 1, ncol
+             dpu = pres_out(icol,k) - pres_in(icol,kupper(icol))
+             dpl = pres_in(icol,kupper(icol)+1) - pres_out(icol,k)
+             field_out(icol,k) = (field_in(icol,kupper(icol))*dpl &amp;
+                               + field_in(icol,kupper(icol)+1)*dpu)/(dpl + dpu)
+          end do
+          goto 35
+        end if
+    enddo
+
+    do icol = 1, ncol
+       if(pres_out(icol,k) .lt. pres_in(icol,1)) then
+          field_out(icol,k) = field_in(icol,1)*pres_out(icol,k)/pres_in(icol,1)
+       elseif(pres_out(icol,k) .gt. pres_in(icol,nlev_in)) then
+          field_out(icol,k) = field_in(icol,nlev_in)
+       else
+          dpu = pres_out(icol,k) - pres_in(icol,kupper(icol))
+          dpl = pres_in(icol,kupper(icol)+1) - pres_out(icol,k)
+          field_out(icol,k) = (field_in(icol,kupper(icol))*dpl &amp;
+                            + field_in(icol,kupper(icol)+1)*dpu)/(dpl + dpu)
+       endif
+    enddo
+
+ 35 continue
+!   write(0,201) kupper(i1),pres_out(i1,k),pres_in(i1,kupper(i1)),pres_in(i1,kupper(i1)+1), &amp;
+!                field_out(i1,k),field_in(i1,kupper(i1)),field_in(i1,kupper(i1)+1)
+!   write(0,201) kupper(i2),pres_out(i2,k),pres_in(i2,kupper(i2)),pres_in(i2,kupper(i2)+1), &amp;
+!                field_out(i2,k),field_in(i2,kupper(i2)),field_in(i2,kupper(i2)+1)
+
+ enddo
+
+ end subroutine interp_tofixed_pressure
+
+!==================================================================================================
+ end module mpas_atm_interp_diagnostics
+!==================================================================================================

Modified: branches/mpas_cdg_advection/src/core_nhyd_atmos/mpas_atm_mpas_core.F
===================================================================
--- branches/mpas_cdg_advection/src/core_nhyd_atmos/mpas_atm_mpas_core.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_nhyd_atmos/mpas_atm_mpas_core.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -29,16 +29,13 @@
       real (kind=RKIND) :: dt
       type (block_type), pointer :: block
 
-      type (field1DChar) :: xtime
-      type (MPAS_Time_type) :: startTime, sliceTime
-      type (MPAS_TimeInterval_type) :: timeDiff, minTimeDiff
       character(len=StrKIND) :: timeStamp
       integer :: i
       integer :: ierr
 
       if (.not. config_do_restart) then
 
-         ! Code that was previously handled by atm_setup_test_case()
+         ! Code that was previously in atm_setup_test_case()
 
          block =&gt; domain % blocklist
          do while (associated(block))
@@ -83,9 +80,9 @@
          !     
          ! We need to decide which time slice to read from the surface file - read the most recent time slice that falls before or on the start time
          !
-         sfc_update_obj % time = MPAS_seekStream(sfc_update_obj % io_stream, trim(config_start_time), MPAS_STREAM_LATEST_BEFORE, timeStamp, ierr)
+         sfc_update_obj % time = MPAS_seekStream(sfc_update_obj % io_stream, trim(startTimeStamp), MPAS_STREAM_LATEST_BEFORE, timeStamp, ierr)
          if (ierr == MPAS_IO_ERR) then
-            write(0,*) 'Error: surface update file '//trim(sfc_update_obj % filename)//' did not contain any times at or before '//trim(config_start_time)
+            write(0,*) 'Error: surface update file '//trim(sfc_update_obj % filename)//' did not contain any times at or before '//trim(startTimeStamp)
             call mpas_dmpar_abort(domain % dminfo)
          end if
 
@@ -108,7 +105,14 @@
       type (MPAS_TimeInterval_type) :: runDuration, timeStep, alarmTimeStep
       integer :: ierr
 
-      call mpas_set_time(curr_time=startTime, dateTimeString=config_start_time, ierr=ierr)
+      if(trim(config_start_time) == 'file') then
+         open(22,file='restart_timestamp',form='formatted',status='old')
+         read(22,*) startTimeStamp
+         close(22)
+      else
+        startTimeStamp = config_start_time
+      end if
+      call mpas_set_time(curr_time=startTime, dateTimeString=startTimeStamp, ierr=ierr)
       call mpas_set_timeInterval(timeStep, dt=dt, ierr=ierr)
 
       if (trim(config_run_duration) /= &quot;none&quot;) then
@@ -340,8 +344,6 @@
       type (domain_type), intent(inout) :: domain
       type (io_output_object), intent(inout) :: output_obj
    
-      integer :: i, j, k
-      integer :: eoe
       type (block_type), pointer :: block_ptr
    
       block_ptr =&gt; domain % blocklist
@@ -376,6 +378,8 @@
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    
       use mpas_grid_types
+      use mpas_constants
+      use mpas_atm_interp_diagnostics
    
       implicit none
    
@@ -383,15 +387,16 @@
       type (diag_type), intent(inout) :: diag
       type (mesh_type), intent(in) :: grid
    
-      integer :: i, eoe
       integer :: iCell, k
 
       do iCell=1,grid%nCells
          do k=1,grid%nVertLevels
-            diag % theta % array(k,iCell) = state % theta_m % array(k,iCell) / (1.0 + 1.61 * state % scalars % array(state % index_qv,k,iCell))
+            diag % theta % array(k,iCell) = state % theta_m % array(k,iCell) / (1._RKIND + rvord * state % scalars % array(state % index_qv,k,iCell))
             diag % rho % array(k,iCell) = state % rho_zz % array(k,iCell) * grid % zz % array(k,iCell)
          end do
       end do
+
+      call interp_diagnostics(grid,state,diag)
    
    end subroutine atm_compute_output_diagnostics
    
@@ -407,6 +412,7 @@
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    
       use mpas_grid_types
+      use mpas_constants
    
       implicit none
    
@@ -414,12 +420,11 @@
       type (diag_type), intent(inout) :: diag
       type (mesh_type), intent(in) :: grid
    
-      integer :: i, eoe
       integer :: iCell, k
 
       do iCell=1,grid%nCells
          do k=1,grid%nVertLevels
-            diag % theta % array(k,iCell) = state % theta_m % array(k,iCell) / (1.0 + 1.61 * state % scalars % array(state % index_qv,k,iCell))
+            diag % theta % array(k,iCell) = state % theta_m % array(k,iCell) / (1._RKIND + rvord * state % scalars % array(state % index_qv,k,iCell))
             diag % rho % array(k,iCell) = state % rho_zz % array(k,iCell) * grid % zz % array(k,iCell)
          end do
       end do

Modified: branches/mpas_cdg_advection/src/core_nhyd_atmos/mpas_atm_time_integration.F
===================================================================
--- branches/mpas_cdg_advection/src/core_nhyd_atmos/mpas_atm_time_integration.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_nhyd_atmos/mpas_atm_time_integration.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -68,12 +68,13 @@
    ! Advance model state forward in time by the specified time step using 
    !   time-split RK3 scheme
    !
-   ! Hydrostatic (primitive eqns.) solver
+   ! Nonhydrostatic atmospheric solver
    !
    ! Input: domain - current model state in time level 1 (e.g., time_levs(1)state%h(:,:)) 
-   !                 plus grid meta-data
+   !                 plus grid meta-data and some diagnostics of state.
    ! Output: domain - upon exit, time level 2 (e.g., time_levs(2)%state%h(:,:)) contains 
-   !                  model state advanced forward in time by dt seconds
+   !                  model state advanced forward in time by dt seconds,
+   !                  and some diagnostics in diag 
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
 
       implicit none
@@ -95,9 +96,8 @@
 !      logical, parameter :: debug = .true.
       logical, parameter :: debug_mass_conservation = .true.
 
-      integer :: index_qc
-      real (kind=RKIND) :: domain_mass, scalar_mass, scalar_min, scalar_max
-      real (kind=RKIND) :: global_domain_mass, global_scalar_mass, global_scalar_min, global_scalar_max
+      real (kind=RKIND) :: scalar_min, scalar_max
+      real (kind=RKIND) :: global_scalar_min, global_scalar_max
 
 
       !
@@ -119,14 +119,6 @@
 
       if(debug) write(0,*) ' copy step in rk solver '
 
-! WCS-parallel: it appears we have chosen to update all edges of nCellsSolve (to cut down on communications on acoustic steps).
-! Do our communications patterns and loops (specifically in compute_dyn_tend) reflect this?  Or do they assume we are only updating 
-! the so-called owned edges?
-
-
-
-! WCS-parallel: first three and rtheta_p arise from scalar transport and microphysics update (OK).  Others come from where?
-
 ! theta_m
       call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(1) % state % theta_m)
  
@@ -142,71 +134,71 @@
 
       block =&gt; domain % blocklist
       do while (associated(block))
-         ! We are setting values in the halo here, so no communications are needed.
-         ! Alternatively, we could just set owned cells and edge values and communicate after this block loop.
          call atm_rk_integration_setup( block % state % time_levs(2) % state, block % state % time_levs(1) % state, block % diag )
          block =&gt; block % next
       end do
 
       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-      ! BEGIN RK loop 
+      ! BEGIN Runge-Kutta loop 
       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
 
       do rk_step = 1, 3  ! Runge-Kutta loop
 
          if(debug) write(0,*) ' rk substep ', rk_step
 
-        block =&gt; domain % blocklist
-        do while (associated(block))
-           ! The coefficients are set for owned cells (cqw) and for all edges of owned cells, 
-           ! thus no communications should be needed after this call.  
-           ! We could consider combining this and the next block loop.
-           call atm_compute_moist_coefficients( block % state % time_levs(2) % state, block % diag, block % mesh )
-           block =&gt; block % next
-        end do
+         block =&gt; domain % blocklist
+         do while (associated(block))
+            ! The coefficients are set for owned cells (cqw) and for all edges of owned cells, 
+            call atm_compute_moist_coefficients( block % state % time_levs(2) % state, block % diag, block % mesh )
+            block =&gt; block % next
+         end do
 
 
-        if (debug) write(0,*) ' compute_dyn_tend '
-        block =&gt; domain % blocklist
-        do while (associated(block))
-           call atm_compute_dyn_tend( block % tend, block % state % time_levs(2) % state, block % diag, block % mesh, rk_step )
-           block =&gt; block % next
-        end do
-        if (debug) write(0,*) ' finished compute_dyn_tend '
+         if (debug) write(0,*) ' compute_dyn_tend '
+         block =&gt; domain % blocklist
+         do while (associated(block))
+            call atm_compute_dyn_tend( block % tend, block % state % time_levs(2) % state, block % diag, block % mesh, rk_step, dt )
+            block =&gt; block % next
+         end do
+         if (debug) write(0,*) ' finished compute_dyn_tend '
 
-
 #ifdef DO_PHYSICS
-        if (debug) write(0,*) ' add physics tendencies '
-        block =&gt; domain % blocklist
-        do while (associated(block))
-           call physics_addtend( block % mesh, &amp;
-                        block % state % time_levs(1) % state, &amp;
-                        block % diag, &amp;
-                        block % tend, &amp;
-                        block % tend_physics, &amp;
-                        block % state % time_levs(2) % state % rho_zz % array(:,:), &amp;
-                        block % diag % rho_edge % array(:,:) )
-           block =&gt; block % next
-        end do
-        if (debug) write(0,*) ' finished add physics tendencies '
+         if (debug) write(0,*) ' add physics tendencies '
+         block =&gt; domain % blocklist
+         do while (associated(block))
+            call physics_addtend( block % mesh, &amp;
+                         block % state % time_levs(1) % state, &amp;
+                         block % diag, &amp;
+                         block % tend, &amp;
+                         block % tend_physics, &amp;
+                         block % state % time_levs(2) % state % rho_zz % array(:,:), &amp;
+                         block % diag % rho_edge % array(:,:), &amp; 
+                         rk_step )
+            block =&gt; block % next
+         end do
+         if (debug) write(0,*) ' finished add physics tendencies '
 #endif
 
-!***********************************
-!  we will need to communicate the momentum tendencies here - we want tendencies for all edges of owned cells
-!  because we are solving for all edges of owned cells
-!***********************************
+         !***********************************
+         !  need tendencies at all edges of owned cells -
+         !  we are solving for all edges of owned cells to minimize communications
+         !  during the acoustic substeps
+         !***********************************
 
 ! tend_u
          call mpas_dmpar_exch_halo_field(domain % blocklist % tend % u, (/ 1 /))
 
          block =&gt; domain % blocklist
             do while (associated(block))
-               call atm_set_smlstep_pert_variables( block % state % time_levs(1) % state, block % state % time_levs(2) % state,  &amp;
-                                                block % tend, block % diag, block % mesh )
+               call atm_set_smlstep_pert_variables( block % tend, block % diag, block % mesh )
                call atm_compute_vert_imp_coefs( block % state % time_levs(2) % state, block % mesh, block % diag, rk_sub_timestep(rk_step) )
             block =&gt; block % next
          end do
 
+         !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+         ! begin acoustic steps loop
+         !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
          do small_step = 1, number_sub_steps(rk_step)
 
             if(debug) write(0,*) ' acoustic step ',small_step
@@ -220,42 +212,24 @@
 
             if(debug) write(0,*) ' acoustic step complete '
   
-            !  will need communications here for rtheta_pp
+! rtheta_pp
+! This is the only communications needed during the acoustic steps because we solve for u on all edges of owned cells
 
-!  WCS-parallel: is this a candidate for a smaller stencil?  we need only communicate cells that share edges with owned cells.
-
-! rtheta_pp
             call mpas_dmpar_exch_halo_field(domain % blocklist % diag % rtheta_pp, (/ 1 /))
  
-         end do  ! end of small stimestep loop
+         end do  ! end of acoustic steps loop
 
-         !  will need communications here for rho_pp
-
-! WCS-parallel: is communication of rw_p and rho_pp because of limiter (pd or mono scheme?),
-!  or is it needed for the large-step variable recovery (to get decoupled variables)?
-!  seems like only rho_pp needed...
-!
-!  or, do we need ru and u in the halo for diagnostics that are computed later in compute_solve_diagnostics?
-!
-!  rho_pp might be candidate for smaller stencil (same stencil as rtheta_pp above).
-
-! MGD seems necessary
-! rw_p
          !CR: SMALLER STENCIL?: call mpas_dmpar_exch_halo_field(block % diag % rw_p, (/ 1 /))
          call mpas_dmpar_exch_halo_field(domain % blocklist % diag % rw_p)
 
-! MGD seems necessary
-! ru_p
          !CR: SMALLER STENCIL?: call mpas_dmpar_exch_halo_field(block % diag % ru_p, (/ 2 /))
          call mpas_dmpar_exch_halo_field(domain % blocklist % diag % ru_p)
 
-! rho_pp
          call mpas_dmpar_exch_halo_field(domain % blocklist % diag % rho_pp)
 
          ! the second layer of halo cells must be exchanged before calling atm_recover_large_step_variables
          call mpas_dmpar_exch_halo_field(domain % blocklist % diag % rtheta_pp, (/ 2 /))
 
-
          block =&gt; domain % blocklist
          do while (associated(block))
             call atm_recover_large_step_variables( block % state % time_levs(2) % state,                 &amp;
@@ -264,12 +238,12 @@
             block =&gt; block % next
          end do
 
-!  ************  advection of moist variables here...
-
 ! u
          !CR: SMALLER STENCIL?: call mpas_dmpar_exch_halo_field(block % state % time_levs(2) % state % u, (/ 3 /))
          call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % u)
 
+         ! scalar advection: RK3 scheme of Skamarock and Gassmann (2011). 
+         ! PD or monotonicity constraints applied only on the final Runge-Kutta substep.
 
          if (config_scalar_advection) then
 
@@ -278,7 +252,7 @@
             !
             ! Note: The advance_scalars_mono routine can be used without limiting, and thus, encompasses 
             !       the functionality of the advance_scalars routine; however, it is noticeably slower, 
-            !       so we keep the advance_scalars routine as well
+            !       so we use the advance_scalars routine for the first two RK substeps.
             !
             if (rk_step &lt; 3 .or. (.not. config_monotonic .and. .not. config_positive_definite)) then
                call atm_advance_scalars( block % tend, &amp;
@@ -290,35 +264,17 @@
                call atm_advance_scalars_mono( block % tend, &amp;
                                               block % state % time_levs(1) % state, block % state % time_levs(2) % state, &amp;
                                               block % diag, block % mesh, &amp;
-                                              rk_timestep(rk_step), rk_step, 3 )
+                                              rk_timestep(rk_step))
             end if
             block =&gt; block % next
          end do
 
-! For now, we do scalar halo updates later on...
-!         block =&gt; domain % blocklist
-!         do while (associated(block))
-!            call mpas_dmpar_exch_halo_field3d_real(domain % dminfo, block % tend % scalars % array(:,:,:), &amp;
-!                                             block % tend % num_scalars, block % mesh % nVertLevels, block % mesh % nCells, &amp;
-!                                             block % parinfo % cellsToSend, block % parinfo % cellsToRecv)
-!            call mpas_dmpar_exch_halo_field3d_real(domain % dminfo, block % state % time_levs(2) % state % scalars % array(:,:,:), &amp;
-!                                             block % state % time_levs(2) % state % num_scalars, block % mesh % nVertLevels, block % mesh % nCells, &amp;
-!                                             block % parinfo % cellsToSend, block % parinfo % cellsToRecv)
-!            block =&gt; block % next
-!         end do
-
          else
  
             write(0,*) ' no scalar advection '
 
          end if
 
-! WCS-parallel: seems like we already use u and w (and other state variables) as if they were already correctly set in the halo,
-! but they are not (at least to the outer edges - see communications below? or are those communications redundent?).  
-! Perhaps we should communicate u, w, theta_m, rho_zz, etc after recover_large_step_variables),
-! cover it with the scalar communications, and then compute solve_diagnostics.  I do not think we need to communicate the stuff we compute
-! in compute_solve_diagnostics if we compute it out in the halo (and I think we do - the halos should be large enough).
-
          block =&gt; domain % blocklist
          do while (associated(block))
             call atm_compute_solve_diagnostics( dt, block % state % time_levs(2) % state, block % diag, block % mesh )
@@ -327,11 +283,6 @@
 
          if(debug) write(0,*) ' diagnostics complete '
 
-
-      ! need communications here to fill out u, w, theta_m, p, and pp, scalars, etc  
-      ! so that they are available for next RK step or the first rk substep of the next timestep
-
-!MGD seems necessary
 ! w
          call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % w)
 
@@ -341,30 +292,29 @@
 ! rho_edge
          call mpas_dmpar_exch_halo_field(domain % blocklist % diag % rho_edge)
 
-!  ****  this will always be needed - perhaps we can cover this with compute_solve_diagnostics
-
 ! scalars
-         if(rk_step &lt; 3) then
+         if (rk_step &lt; 3) then
             call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % scalars)
          end if
 
-       end do ! rk_step loop
+      end do ! rk_step loop
 
 !...  compute full velocity vectors at cell centers:
       block =&gt; domain % blocklist
-        do while (associated(block))
-           call mpas_reconstruct(block % mesh, block % state % time_levs(2) % state % u % array, &amp;
-                                 block % diag % uReconstructX % array,                           &amp;
-                                 block % diag % uReconstructY % array,                           &amp;
-                                 block % diag % uReconstructZ % array,                           &amp;
-                                 block % diag % uReconstructZonal % array,                       &amp;
-                                 block % diag % uReconstructMeridional % array                   &amp;
-                                )
-           block =&gt; block % next
-        end do
+      do while (associated(block))
+         call mpas_reconstruct(block % mesh, block % state % time_levs(2) % state % u % array, &amp;
+                               block % diag % uReconstructX % array,                           &amp;
+                               block % diag % uReconstructY % array,                           &amp;
+                               block % diag % uReconstructZ % array,                           &amp;
+                               block % diag % uReconstructZonal % array,                       &amp;
+                               block % diag % uReconstructMeridional % array                   &amp;
+                              )
+         block =&gt; block % next
+      end do
 
 !... call to parameterizations of cloud microphysics. calculation of the tendency of water vapor to horizontal and
 !... vertical advection needed for the Tiedtke parameterization of convection.
+
 #ifdef DO_PHYSICS
       block =&gt; domain % blocklist
       do while(associated(block))
@@ -372,21 +322,21 @@
          !NOTE: The calculation of the tendency due to horizontal and vertical advection for the water vapor mixing ratio
          !requires that the subroutine atm_advance_scalars_mono was called on the third Runge Kutta step, so that a halo
          !update for the scalars at time_levs(1) is applied. A halo update for the scalars at time_levs(2) is done above. 
-         if(config_monotonic) then
+         if (config_monotonic) then
             block % tend_physics % rqvdynten % array(:,:) = &amp;
                  ( block % state % time_levs(2) % state % scalars % array(block % state % time_levs(2) % state % index_qv,:,:)   &amp;
                  - block % state % time_levs(1) % state % scalars % array(block % state % time_levs(1) % state % index_qv,:,:) ) &amp;
                  / config_dt
          else
             block % tend_physics % rqvdynten % array(:,:) = 0._RKIND
-         endif
+         end if
 
          !simply set to zero negative mixing ratios of different water species (for now):
          where ( block % state % time_levs(2) % state % scalars % array(:,:,:) .lt. 0.) &amp;
             block % state % time_levs(2) % state % scalars % array(:,:,:) = 0.
 
          !call microphysics schemes:
-         if(config_microp_scheme .ne. 'off') &amp;
+         if (config_microp_scheme .ne. 'off') &amp;
             call microphysics_driver ( block % state % time_levs(2) % state, block % diag, block % diag_physics, &amp;
                                        block % tend, block % mesh, itimestep )
 
@@ -394,88 +344,84 @@
       end do
 #endif
 
+      102 format(' global min, max scalar',i4,2(1x,e17.10))
+      write(0,*)
+      block =&gt; domain % blocklist
+      do while (associated(block))
+         scalar_min = 0.
+         scalar_max = 0.
+         do iCell = 1, block % mesh % nCellsSolve
+         do k = 1, block % mesh % nVertLevels
+            scalar_min = min(scalar_min, block % state % time_levs(2) % state % w % array(k,iCell))
+            scalar_max = max(scalar_max, block % state % time_levs(2) % state % w % array(k,iCell))
+         end do
+         end do
+         call mpas_dmpar_min_real(domain%dminfo, scalar_min, global_scalar_min)
+         call mpas_dmpar_max_real(domain%dminfo, scalar_max, global_scalar_max)
+         write(0,*) 'global min, max w ',global_scalar_min, global_scalar_max
 
-!      if(debug) then
-        101 format(' local  min, max scalar',i4,2(1x,e17.10))
-        102 format(' global min, max scalar',i4,2(1x,e17.10))
-        write(0,*)
-        block =&gt; domain % blocklist
-          do while (associated(block))
-             scalar_min = 0.
-             scalar_max = 0.
-             do iCell = 1, block % mesh % nCellsSolve
-             do k = 1, block % mesh % nVertLevels
-               scalar_min = min(scalar_min, block % state % time_levs(2) % state % w % array(k,iCell))
-               scalar_max = max(scalar_max, block % state % time_levs(2) % state % w % array(k,iCell))
-             enddo
-             enddo
-             call mpas_dmpar_min_real(domain%dminfo, scalar_min, global_scalar_min)
-             call mpas_dmpar_max_real(domain%dminfo, scalar_max, global_scalar_max)
-!             write(0,*) 'local  min, max w ',scalar_min, scalar_max
-             write(0,*) 'global min, max w ',global_scalar_min, global_scalar_max
+         scalar_min = 0.
+         scalar_max = 0.
+         do iEdge = 1, block % mesh % nEdgesSolve
+         do k = 1, block % mesh % nVertLevels
+            scalar_min = min(scalar_min, block % state % time_levs(2) % state % u % array(k,iEdge))
+            scalar_max = max(scalar_max, block % state % time_levs(2) % state % u % array(k,iEdge))
+         end do
+         end do
+         call mpas_dmpar_min_real(domain%dminfo, scalar_min, global_scalar_min)
+         call mpas_dmpar_max_real(domain%dminfo, scalar_max, global_scalar_max)
+         write(0,*) 'global min, max u ',global_scalar_min, global_scalar_max
 
-             scalar_min = 0.
-             scalar_max = 0.
-             do iEdge = 1, block % mesh % nEdgesSolve
-             do k = 1, block % mesh % nVertLevels
-               scalar_min = min(scalar_min, block % state % time_levs(2) % state % u % array(k,iEdge))
-               scalar_max = max(scalar_max, block % state % time_levs(2) % state % u % array(k,iEdge))
-             enddo
-             enddo
-             call mpas_dmpar_min_real(domain%dminfo, scalar_min, global_scalar_min)
-             call mpas_dmpar_max_real(domain%dminfo, scalar_max, global_scalar_max)
-!             write(0,*) 'local  min, max u ',scalar_min, scalar_max
-             write(0,*) 'global min, max u ',global_scalar_min, global_scalar_max
+         do iScalar = 1, block % state % time_levs(2) % state % num_scalars
+            scalar_min = 0.
+            scalar_max = 0.
+            do iCell = 1, block % mesh % nCellsSolve
+            do k = 1, block % mesh % nVertLevels
+               scalar_min = min(scalar_min, block % state % time_levs(2) % state % scalars % array(iScalar,k,iCell))
+               scalar_max = max(scalar_max, block % state % time_levs(2) % state % scalars % array(iScalar,k,iCell))
+            end do
+            end do
+            call mpas_dmpar_min_real(domain%dminfo, scalar_min, global_scalar_min)
+            call mpas_dmpar_max_real(domain%dminfo, scalar_max, global_scalar_max)
+            write(0,102) iScalar,global_scalar_min,global_scalar_max
+         end do
 
-             do iScalar = 1, block % state % time_levs(2) % state % num_scalars
-                scalar_min = 0.
-                scalar_max = 0.
-                do iCell = 1, block % mesh % nCellsSolve
-                do k = 1, block % mesh % nVertLevels
-                  scalar_min = min(scalar_min, block % state % time_levs(2) % state % scalars % array(iScalar,k,iCell))
-                  scalar_max = max(scalar_max, block % state % time_levs(2) % state % scalars % array(iScalar,k,iCell))
-                enddo
-                enddo
-                call mpas_dmpar_min_real(domain%dminfo, scalar_min, global_scalar_min)
-                call mpas_dmpar_max_real(domain%dminfo, scalar_max, global_scalar_max)
-!                write(0,101) iScalar,scalar_min,scalar_max
-                write(0,102) iScalar,global_scalar_min,global_scalar_max
-             end do
-             block =&gt; block % next
+         block =&gt; block % next
+      end do
 
-          end do
-!      end if
-
-
    end subroutine atm_srk3
 
 !---
 
    subroutine atm_rk_integration_setup( s_old, s_new, diag )
 
-     implicit none
-     type (state_type) :: s_new, s_old
-     type (diag_type) :: diag
-     integer :: iCell, k
+      implicit none
 
-     diag % ru_save % array = diag % ru % array
-     diag % rw_save % array = diag % rw % array
-     diag % rtheta_p_save % array = diag % rtheta_p % array
-     diag % rho_p_save % array = diag % rho_p % array
+      type (state_type) :: s_new, s_old
+      type (diag_type) :: diag
 
-     s_old % u % array = s_new % u % array
-     s_old % w % array = s_new % w % array
-     s_old % theta_m % array = s_new % theta_m % array
-     s_old % rho_zz % array = s_new % rho_zz % array
-     s_old % scalars % array = s_new % scalars % array
+      diag % ru_save % array       = diag % ru % array
+      diag % rw_save % array       = diag % rw % array
+      diag % rtheta_p_save % array = diag % rtheta_p % array
+      diag % rho_p_save % array    = diag % rho_p % array
 
+      s_old % u % array       = s_new % u % array
+      s_old % w % array       = s_new % w % array
+      s_old % theta_m % array = s_new % theta_m % array
+      s_old % rho_zz % array  = s_new % rho_zz % array
+      s_old % scalars % array = s_new % scalars % array
+
    end subroutine atm_rk_integration_setup
 
 !-----
 
    subroutine atm_compute_moist_coefficients( state, diag, grid )
 
+      ! the moist coefficients cqu and cqw serve to transform the inverse dry density (1/rho_d) 
+      ! into the inverse full (moist) density (1/rho_m).
+
       implicit none
+
       type (state_type) :: state
       type (diag_type) :: diag
       type (mesh_type) :: grid
@@ -483,35 +429,38 @@
       integer :: iEdge, iCell, k, cell1, cell2, iq
       integer :: nCells, nEdges, nVertLevels, nCellsSolve
       real (kind=RKIND) :: qtot
+      integer, dimension(:,:), pointer :: cellsOnEdge
 
       nCells      = grid % nCells
       nEdges      = grid % nEdges
       nVertLevels = grid % nVertLevels
       nCellsSolve = grid % nCellsSolve
 
-        do iCell = 1, nCellsSolve
-          do k = 2, nVertLevels
+      cellsOnEdge =&gt; grid % cellsOnEdge % array
+
+      do iCell = 1, nCellsSolve
+         do k = 2, nVertLevels
             qtot = 0.
             do iq = state % moist_start, state % moist_end
-              qtot = qtot + 0.5 * (state % scalars % array (iq, k, iCell) + state % scalars % array (iq, k-1, iCell))
+               qtot = qtot + 0.5 * (state % scalars % array (iq, k, iCell) + state % scalars % array (iq, k-1, iCell))
             end do
             diag % cqw % array(k,iCell) = 1./(1.+qtot)
-          end do
-        end do
+         end do
+      end do
 
-        do iEdge = 1, nEdges
-          cell1 = grid % cellsOnEdge % array(1,iEdge)
-          cell2 = grid % cellsOnEdge % array(2,iEdge)
-          if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
+      do iEdge = 1, nEdges
+         cell1 = cellsOnEdge(1,iEdge)
+         cell2 = cellsOnEdge(2,iEdge)
+         if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
             do k = 1, nVertLevels
-              qtot = 0.
-              do iq = state % moist_start, state % moist_end
-                 qtot = qtot + 0.5 * ( state % scalars % array (iq, k, cell1) + state % scalars % array (iq, k, cell2) )
-              end do
-              diag % cqu % array(k,iEdge) = 1./( 1. + qtot)
+               qtot = 0.
+               do iq = state % moist_start, state % moist_end
+                  qtot = qtot + 0.5 * ( state % scalars % array (iq, k, cell1) + state % scalars % array (iq, k, cell2) )
+               end do
+               diag % cqu % array(k,iEdge) = 1./( 1. + qtot)
             end do
-          end if
-        end do
+         end if
+      end do
 
    end subroutine atm_compute_moist_coefficients
 
@@ -529,13 +478,14 @@
 
       implicit none
 
-      type (state_type), intent(in) :: s
-      type (mesh_type), intent(in) :: grid
+      type (state_type), intent(in)   :: s
+      type (mesh_type), intent(in)    :: grid
       type (diag_type), intent(inout) :: diag
-      real (kind=RKIND), intent(in) :: dts
+      real (kind=RKIND), intent(in)   :: dts
 
-      integer :: i, k, iq
 
+      integer :: iCell, k, iq
+
       integer :: nCells, nVertLevels, nCellsSolve
       real (kind=RKIND), dimension(:,:), pointer :: zz, cqw, p, t, rb, rtb, pb, rt
       real (kind=RKIND), dimension(:,:), pointer :: cofwr, cofwz, coftz, cofwt, a_tri, alpha_tri, gamma_tri
@@ -549,8 +499,6 @@
       nCells      = grid % nCells
       nCellsSolve = grid % nCellsSolve
       nVertLevels = grid % nVertLevels
-!      epssm = grid % epssm  !  this should come in through the namelist  ******************
-!      epssm = 0.1
       epssm = config_epssm
 
       rdzu =&gt; grid % rdzu % array
@@ -585,53 +533,53 @@
          cofrz(k) = dtseps*rdzw(k)
       end do
 
-      do i = 1, nCellsSolve  !  we only need to do cells we are solving for, not halo cells
+      do iCell = 1, nCellsSolve  !  we only need to do cells we are solving for, not halo cells
 
-        do k=2,nVertLevels
-          cofwr(k,i) =.5*dtseps*gravity*(fzm(k)*zz(k,i)+fzp(k)*zz(k-1,i))
-        end do
-        coftz(1,i) = 0.0
-        do k=2,nVertLevels
-           cofwz(k,i) = dtseps*c2*(fzm(k)*zz(k,i)+fzp(k)*zz(k-1,i))  &amp;
-                *rdzu(k)*cqw(k,i)*(fzm(k)*p (k,i)+fzp(k)*p (k-1,i))
-           coftz(k,i) = dtseps*   (fzm(k)*t (k,i)+fzp(k)*t (k-1,i))
-        end do
-        coftz(nVertLevels+1,i) = 0.0
-        do k=1,nVertLevels
+         do k=2,nVertLevels
+            cofwr(k,iCell) =.5*dtseps*gravity*(fzm(k)*zz(k,iCell)+fzp(k)*zz(k-1,iCell))
+         end do
+         coftz(1,iCell) = 0.0
+         do k=2,nVertLevels
+            cofwz(k,iCell) = dtseps*c2*(fzm(k)*zz(k,iCell)+fzp(k)*zz(k-1,iCell))  &amp;
+                 *rdzu(k)*cqw(k,iCell)*(fzm(k)*p (k,iCell)+fzp(k)*p (k-1,iCell))
+            coftz(k,iCell) = dtseps*   (fzm(k)*t (k,iCell)+fzp(k)*t (k-1,iCell))
+         end do
+         coftz(nVertLevels+1,iCell) = 0.0
+         do k=1,nVertLevels
 
-          qtot = 0.
-          do iq = s % moist_start, s % moist_end
-            qtot = qtot + s % scalars % array (iq, k, i)
-          end do
+            qtot = 0.
+            do iq = s % moist_start, s % moist_end
+               qtot = qtot + s % scalars % array (iq, k, iCell)
+            end do
 
-          cofwt(k,i) = .5*dtseps*rcv*zz(k,i)*gravity*rb(k,i)/(1.+qtot)  &amp;
-                              *p(k,i)/((rtb(k,i)+rt(k,i))*pb(k,i))
-        end do
+            cofwt(k,iCell) = .5*dtseps*rcv*zz(k,iCell)*gravity*rb(k,iCell)/(1.+qtot)  &amp;
+                                *p(k,iCell)/((rtb(k,iCell)+rt(k,iCell))*pb(k,iCell))
+         end do
 
-        a_tri(1,i) = 0.  ! note, this value is never used
-        b_tri(1) = 1.    ! note, this value is never used
-        c_tri(1) = 0.    ! note, this value is never used
-        gamma_tri(1,i) = 0.
-        alpha_tri(1,i) = 0.  ! note, this value is never used
+         a_tri(1,iCell) = 0.  ! note, this value is never used
+         b_tri(1) = 1.    ! note, this value is never used
+         c_tri(1) = 0.    ! note, this value is never used
+         gamma_tri(1,iCell) = 0.
+         alpha_tri(1,iCell) = 0.  ! note, this value is never used
 
-        do k=2,nVertLevels
-          a_tri(k,i) = -cofwz(k  ,i)* coftz(k-1,i)*rdzw(k-1)*zz(k-1,i)   &amp;
-                       +cofwr(k  ,i)* cofrz(k-1  )                       &amp;
-                       -cofwt(k-1,i)* coftz(k-1,i)*rdzw(k-1)
-          b_tri(k) = 1.                                                  &amp;
-                       +cofwz(k  ,i)*(coftz(k  ,i)*rdzw(k  )*zz(k  ,i)   &amp;
-                                    +coftz(k  ,i)*rdzw(k-1)*zz(k-1,i))   &amp;
-                       -coftz(k  ,i)*(cofwt(k  ,i)*rdzw(k  )             &amp;
-                                     -cofwt(k-1,i)*rdzw(k-1))            &amp;
-                       +cofwr(k,  i)*(cofrz(k    )-cofrz(k-1))
-          c_tri(k) =   -cofwz(k  ,i)* coftz(k+1,i)*rdzw(k  )*zz(k  ,i)   &amp;
-                       -cofwr(k  ,i)* cofrz(k    )                       &amp;
-                       +cofwt(k  ,i)* coftz(k+1,i)*rdzw(k  )
-        end do
-        do k=2,nVertLevels
-          alpha_tri(k,i) = 1./(b_tri(k)-a_tri(k,i)*gamma_tri(k-1,i))
-          gamma_tri(k,i) = c_tri(k)*alpha_tri(k,i)
-        end do
+         do k=2,nVertLevels
+            a_tri(k,iCell) = -cofwz(k  ,iCell)* coftz(k-1,iCell)*rdzw(k-1)*zz(k-1,iCell)   &amp;
+                         +cofwr(k  ,iCell)* cofrz(k-1  )                       &amp;
+                         -cofwt(k-1,iCell)* coftz(k-1,iCell)*rdzw(k-1)
+            b_tri(k) = 1.                                                  &amp;
+                         +cofwz(k  ,iCell)*(coftz(k  ,iCell)*rdzw(k  )*zz(k  ,iCell)   &amp;
+                                      +coftz(k  ,iCell)*rdzw(k-1)*zz(k-1,iCell))   &amp;
+                         -coftz(k  ,iCell)*(cofwt(k  ,iCell)*rdzw(k  )             &amp;
+                                       -cofwt(k-1,iCell)*rdzw(k-1))            &amp;
+                         +cofwr(k,  iCell)*(cofrz(k    )-cofrz(k-1))
+            c_tri(k) =   -cofwz(k  ,iCell)* coftz(k+1,iCell)*rdzw(k  )*zz(k  ,iCell)   &amp;
+                         -cofwr(k  ,iCell)* cofrz(k    )                       &amp;
+                         +cofwt(k  ,iCell)* coftz(k+1,iCell)*rdzw(k  )
+         end do
+         do k=2,nVertLevels
+            alpha_tri(k,iCell) = 1./(b_tri(k)-a_tri(k,iCell)*gamma_tri(k-1,iCell))
+            gamma_tri(k,iCell) = c_tri(k)*alpha_tri(k,iCell)
+         end do
 
       end do ! loop over cells
 
@@ -639,51 +587,69 @@
 
 !------------------------
 
-   subroutine atm_set_smlstep_pert_variables( s_old, s_new, tend, diag, grid )
+   subroutine atm_set_smlstep_pert_variables( tend, diag, grid )
 
+      ! following Klemp et al MWR 2007, we use preturbation variables
+      ! in the acoustic-step integration.  This routine computes those 
+      ! perturbation variables.  state variables are reconstituted after 
+      ! the acousstic steps in subroutine atm_recover_large_step_variables
+
+
       implicit none
-      type (state_type) :: s_new, s_old
+
       type (tend_type) :: tend
       type (diag_type) :: diag
       type (mesh_type) :: grid
-      !SHP-w
+
       integer :: iCell, iEdge, k, cell1, cell2, coef_3rd_order
+      integer :: nCellsSolve, nCells, nVertLevels, nEdges
       integer, dimension(:,:), pointer :: cellsOnEdge
       real (kind=RKIND), dimension(:), pointer :: fzm, fzp, dvEdge, areaCell
       real (kind=RKIND) :: flux
-      !SHP-w
+
       coef_3rd_order = config_coef_3rd_order
-      if(config_theta_adv_order /=3) coef_3rd_order = 0
+      if (config_theta_adv_order /=3) coef_3rd_order = 0
 
-      !SHP-w
+      nCellsSolve = grid % nCellsSolve
+      nCells      = grid % nCells
+      nEdges      = grid % nEdges
+      nVertLevels = grid % nVertLevels
+
       fzm =&gt; grid % fzm % array
       fzp =&gt; grid % fzp % array
       dvEdge =&gt; grid % dvEdge % array
       areaCell =&gt; grid % areaCell % array
       cellsOnEdge =&gt; grid % cellsOnEdge % array
 
+      ! set the acoustic step perturbation variables by subtracting the RK timestep variables
+      ! from their at the previous RK substep.
+
       diag % rho_pp % array = diag % rho_p_save % array - diag % rho_p % array
-
       diag % ru_p % array = diag % ru_save % array - diag % ru % array
       diag % rtheta_pp % array = diag % rtheta_p_save % array - diag % rtheta_p % array
       diag % rtheta_pp_old % array = diag % rtheta_pp % array
       diag % rw_p % array = diag % rw_save % array - diag % rw % array
 
-      do iCell = 1, grid % nCellsSolve
-      do k = 2, grid % nVertLevels
-        tend % w % array(k,iCell) = ( fzm(k) * grid % zz % array(k  ,iCell) +   &amp;
-                                      fzp(k) * grid % zz % array(k-1,iCell)   ) &amp;
-                                     * tend % w % array(k,iCell)
+      ! we solve for omega instead of w (see Klemp et al MWR 2007),
+      ! so here we change the w_p tendency to an omega_p tendency
+
+      do iCell = 1, nCellsSolve
+      do k = 2, nVertLevels
+         tend % w % array(k,iCell) = ( fzm(k) * grid % zz % array(k  ,iCell) +   &amp;
+                                       fzp(k) * grid % zz % array(k-1,iCell)   ) &amp;
+                                      * tend % w % array(k,iCell)
       end do
       end do
 
-      do iEdge = 1,grid % nEdges
+      ! here we need to compute the omega tendency in a manner consistent with our diagnosis of omega.
+      ! this requires us to use the same flux divergence as is used in the theta eqn - see Klemp et al MWR 2003.
 
+      do iEdge = 1, nEdges
+
          cell1 = cellsOnEdge(1,iEdge)
          cell2 = cellsOnEdge(2,iEdge)
 
-         !SHP-w
-         do k = 2, grid%nVertLevels
+         do k = 2, nVertLevels
             flux = fzm(k) * tend % u % array(k,iEdge) + fzp(k) * tend % u % array(k-1,iEdge)
             tend % w % array(k,cell2) = tend % w % array(k,cell2)   &amp;
                      + (grid % zb % array(k,2,iEdge) + coef_3rd_order*sign(1.0_RKIND,tend % u % array(k,iEdge))*grid %zb3 % array(k,2,iEdge))*flux   &amp;
@@ -695,6 +661,8 @@
 
       end do
 
+      !  ruAvg and wwAvg will store the mass fluxes averaged over the acoustic steps for the subsequent scalar transport.
+
       diag % ruAvg % array = 0.
       diag % wwAvg % array = 0.
 
@@ -704,6 +672,12 @@
 
    subroutine atm_advance_acoustic_step( s, diag, tend, grid, dts )
 
+      !  This subroutine performs the entire acoustic step update, following Klemp et al MWR 2007,
+      !  using forward-backward vertically implicit integration.  
+      !  The gravity-waves are included in the acoustic-step integration.
+      !  The input state variables that are updated are ru_p, rw_p (note that this is (rho*omega)_p here),
+      !  rtheta_p, and rho_pp.  The time averaged mass flux is accumulated in ruAvg and wwAvg
+
       implicit none
 
       type (state_type) :: s
@@ -712,15 +686,17 @@
       type (mesh_type) :: grid
       real (kind=RKIND), intent(in) :: dts
 
-      real (kind=RKIND), dimension(:,:), pointer :: rho_zz, theta_m, ru_p, rw_p, rtheta_pp,    &amp;
-                                                    rtheta_pp_old, zz, exner, cqu, ruAvg, &amp;
-                                                    wwAvg, rho_pp, cofwt, coftz, zx,      &amp;
-                                                    a_tri, alpha_tri, gamma_tri, dss,     &amp;
-                                                    tend_ru, tend_rho, tend_rt, tend_rw,  &amp;
+
+      real (kind=RKIND), dimension(:,:), pointer :: rho_zz, theta_m, ru_p, rw_p, rtheta_pp,  &amp;
+                                                    rtheta_pp_old, zz, exner, cqu, ruAvg,    &amp;
+                                                    wwAvg, rho_pp, cofwt, coftz, zx,         &amp;
+                                                    a_tri, alpha_tri, gamma_tri, dss,        &amp;
+                                                    tend_ru, tend_rho, tend_rt, tend_rw,     &amp;
                                                     zgrid, cofwr, cofwz, w, h_divergence
       real (kind=RKIND), dimension(:), pointer :: fzm, fzp, rdzw, dcEdge, AreaCell, cofrz, dvEdge
 
       real (kind=RKIND), dimension(:,:), pointer :: cpr, cpl, pzp, pzm
+      integer, dimension(:,:), pointer :: cellsOnEdge
 
       real (kind=RKIND) :: smdiv, c2, rcv
       real (kind=RKIND), dimension( grid % nVertLevels ) :: du
@@ -728,7 +704,7 @@
       real (kind=RKIND), dimension( grid % nVertLevels, grid % nCells+1 ) :: ts, rs
 
       integer :: cell1, cell2, iEdge, iCell, k
-      real (kind=RKIND) :: pgrad, flux1, flux2, flux, resm, epssm
+      real (kind=RKIND) :: pgrad, flux, resm, epssm
 
       real (kind=RKIND) :: cf1, cf2, cf3, pr, pl
       integer :: kr, kl
@@ -736,13 +712,11 @@
       integer :: nEdges, nCells, nCellsSolve, nVertLevels
 
       logical, parameter :: debug = .false.
-!      logical, parameter :: debug = .true.
       logical, parameter :: debug1 = .false.
-      real (kind=RKIND) :: wmax
-      integer :: iwmax, kwmax
       logical :: newpx
 
 !--
+      cellsOnEdge =&gt; grid % cellsOnEdge % array
 
       rho_zz =&gt; s % rho_zz % array
       theta_m =&gt; s % theta_m % array
@@ -786,8 +760,6 @@
       dvEdge =&gt; grid % dvEdge % array
       AreaCell =&gt; grid % AreaCell % array
 
-!  might these be pointers instead? **************************
-
       nEdges = grid % nEdges
       nCells = grid % nCells
       nCellsSolve = grid % nCellsSolve
@@ -801,6 +773,8 @@
       cpl         =&gt; grid % cpl % array
       newpx = config_newpx
 
+      ! epssm is the offcentering coefficient for the vertically implicit integration.
+      ! smdiv is the 3D divergence-damping coefficient.
       epssm = config_epssm
       smdiv = config_smdiv
 
@@ -811,18 +785,27 @@
       ts = 0.
       rs = 0.
 
-      ! acoustic step divergence damping - forward weight rtheta_pp
+      ! acoustic step divergence damping - forward weight rtheta_pp - see Klemp et al MWR 2007
       rtheta_pp_old = rtheta_pp + smdiv*(rtheta_pp - rtheta_pp_old)
 
-      if(debug) write(0,*) ' updating ru_p '
+      if (debug) write(0,*) ' updating ru_p '
 
+      ! forward-backward acoustic step integration.
+      ! begin by updating the horizontal velocity u, 
+      ! and accumulating the contribution from the updated u to the other tendencies.
+
+      ! we are looping over all edges, but only computing on edges of owned cells. This will include updates of
+      ! all owned edges plus some edges that are owned by other blocks.  We perform these redundant computations
+      ! so that we do not have to communicate updates of u to update the cell variables (rho, w, and theta). 
+
       do iEdge = 1, nEdges
  
-         cell1 = grid % cellsOnEdge % array (1,iEdge)
-         cell2 = grid % cellsOnEdge % array (2,iEdge)
-         ! update edge for block-owned cells
-         if (cell1 &lt;= grid % nCellsSolve .or. cell2 &lt;= grid % nCellsSolve ) then
+         cell1 = cellsOnEdge(1,iEdge)
+         cell2 = cellsOnEdge(2,iEdge)
 
+         ! update edges for block-owned cells
+         if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve ) then
+
             if (newpx) then
 
                k = 1
@@ -857,13 +840,6 @@
             else
 
                k = 1
-!               dpzx(k) = .5*zx(k,iEdge)*(cf1*(zz(k  ,cell2)*rtheta_pp_old(k  ,cell2)    &amp;
-!                                             +zz(k  ,cell1)*rtheta_pp_old(k  ,cell1))   &amp;
-!                                        +cf2*(zz(k+1,cell2)*rtheta_pp_old(k+1,cell2)    &amp;
-!                                             +zz(k+1,cell1)*rtheta_pp_old(k+1,cell1))   &amp;
-!                                        +cf3*(zz(k+2,cell2)*rtheta_pp_old(k+2,cell2)    &amp;
-!                                             +zz(k+2,cell1)*rtheta_pp_old(k+2,cell1)))
-
                dpzx(k) = .25*(zx(k,iEdge)+zx(k+1,iEdge))                               &amp;
                          *(pzm(k,cell2)*(zz(k+1,cell2)*rtheta_pp_old(k+1,cell2)        &amp;
                                         -zz(k  ,cell2)*rtheta_pp_old(k  ,cell2))       &amp;
@@ -874,11 +850,7 @@
                           +pzp(k,cell1)*(zz(k+2,cell1)*rtheta_pp_old(k+2,cell1)        &amp;
                                         -zz(k  ,cell1)*rtheta_pp_old(k  ,cell1)))
 
-               do k=2,grid % nVertLevels-1
-!                  dpzx(k)=.5*zx(k,iEdge)*(fzm(k)*(zz(k  ,cell2)*rtheta_pp_old(k  ,cell2)   &amp;
-!                                                 +zz(k  ,cell1)*rtheta_pp_old(k  ,cell1))  &amp;
-!                                         +fzp(k)*(zz(k-1,cell2)*rtheta_pp_old(k-1,cell2)   &amp;
-!                                                 +zz(k-1,cell1)*rtheta_pp_old(k-1,cell1)))
+               do k=2,nVertLevels-1
                   dpzx(k) = .25*(zx(k,iEdge)+zx(k+1,iEdge))                                   &amp;
                                    *(pzp(k,cell2)*(zz(k+1,cell2)*rtheta_pp_old(k+1,cell2)     &amp;
                                                   -zz(k  ,cell2)*rtheta_pp_old(k  ,cell2))    &amp;
@@ -890,38 +862,30 @@
                                                   -zz(k-1,cell1)*rtheta_pp_old(k-1,cell1)))
                end do
 
-               k=grid % nVertLevels
+               k = nVertLevels
                dpzx(k) = .25*(zx(k,iEdge)+zx(k+1,iEdge))                                   &amp;
                                 *(pzm(k,cell2)*(zz(k  ,cell2)*rtheta_pp_old(k  ,cell2)     &amp;
                                                -zz(k-1,cell2)*rtheta_pp_old(k-1,cell2))    &amp;
                                  +pzm(k,cell1)*(zz(k  ,cell1)*rtheta_pp_old(k  ,cell1)     &amp;
                                                -zz(k-1,cell1)*rtheta_pp_old(k-1,cell1)))
 
-!               dpzx(nVertLevels + 1) = 0.
-
                do k=1,nVertLevels
-!                  pgrad =  (rtheta_pp_old(k,cell2)-rtheta_pp_old(k,cell1))/dcEdge(iEdge)  &amp;
-!                               - rdzw(k)*(dpzx(k+1)-dpzx(k))
                   pgrad =     ((rtheta_pp_old(k,cell2)*zz(k,cell2)                    &amp;
                                -rtheta_pp_old(k,cell1)*zz(k,cell1))/dcEdge(iEdge)     &amp;
                             -dpzx(k))/(.5*(zz(k,cell2)+zz(k,cell1)))
                   pgrad = 0.5*c2*(exner(k,cell1)+exner(k,cell2))*pgrad
                   du(k) = dts*(tend_ru(k,iEdge) - cqu(k,iEdge) * pgrad) 
-!                          + (0.05/6.)*dcEdge(iEdge)*(h_divergence(k,cell2)-h_divergence(k,cell1))
                end do
             end if
 
             do k=1,nVertLevels
+
+               ! full update of ru_p
+
                ru_p(k,iEdge) = ru_p(k,iEdge) + du(k)
 
-               if(debug) then
-                 if(iEdge == 3750) then
-                   write(0,*) ' k, pgrad, tend_ru ',k,pgrad,tend_ru(k,3750)
-                 end if
-               end if
+               ! add horizontal fluxes using updated ru_p into density update, rtheta update and w update
 
-!  need to add horizontal fluxes into density update, rtheta update and w update
-
                flux = dts*dvEdge(iEdge)*ru_p(k,iEdge)
                rs(k,cell1) = rs(k,cell1)-flux/AreaCell(cell1)
                rs(k,cell2) = rs(k,cell2)+flux/AreaCell(cell2)
@@ -929,67 +893,82 @@
                flux = flux*0.5*(theta_m(k,cell2)+theta_m(k,cell1))
                ts(k,cell1) = ts(k,cell1)-flux/AreaCell(cell1)
                ts(k,cell2) = ts(k,cell2)+flux/AreaCell(cell2)
-   
+
+               ! accumulate ru_p for use later in scalar transport
+
                ruAvg(k,iEdge) = ruAvg(k,iEdge) + ru_p(k,iEdge)
 
             end do
 
-        end if ! end test for block-owned cells
+         end if ! end test for block-owned cells
 
       end do ! end loop over edges
 
       ! saving rtheta_pp before update for use in divergence damping in next acoustic step
+
       rtheta_pp_old(:,:) = rtheta_pp(:,:)
 
+      ! vertically implicit acoustic and gravity wave integration.
+      ! this follows Klemp et al MWR 2007, with the addition of an implicit Rayleigh damping of w
+      ! serves as a gravity-wave absorbing layer, from Klemp et al 2008.
+
       do iCell = 1, nCellsSolve
 
-        do k=1, nVertLevels
-          rs(k,iCell) = rho_pp(k,iCell) + dts*tend_rho(k,iCell) + rs(k,iCell)      &amp;
-                          - cofrz(k)*resm*(rw_p(k+1,iCell)-rw_p(k,iCell))
-          ts(k,iCell) = rtheta_pp(k,iCell) + dts*tend_rt(k,iCell) + ts(k,iCell)    &amp;
-                             - resm*rdzw(k)*(coftz(k+1,iCell)*rw_p(k+1,iCell)      &amp;
-                             -coftz(k,iCell)*rw_p(k,iCell))
-        enddo
+         do k=1, nVertLevels
+            rs(k,iCell) = rho_pp(k,iCell) + dts*tend_rho(k,iCell) + rs(k,iCell)      &amp;
+                            - cofrz(k)*resm*(rw_p(k+1,iCell)-rw_p(k,iCell))
+            ts(k,iCell) = rtheta_pp(k,iCell) + dts*tend_rt(k,iCell) + ts(k,iCell)    &amp;
+                               - resm*rdzw(k)*(coftz(k+1,iCell)*rw_p(k+1,iCell)      &amp;
+                               -coftz(k,iCell)*rw_p(k,iCell))
+         end do
 
-        do k=2, nVertLevels
+         do k=2, nVertLevels
 
-          wwavg(k,iCell) = wwavg(k,iCell) + 0.5*(1.-epssm)*rw_p(k,iCell)
+            wwavg(k,iCell) = wwavg(k,iCell) + 0.5*(1.-epssm)*rw_p(k,iCell)
 
-          rw_p(k,iCell) = rw_p(k,iCell) +  dts*tend_rw(k,iCell)                       &amp;
-                     - cofwz(k,iCell)*((zz(k  ,iCell)*ts (k  ,iCell)                  &amp;
-                                   -zz(k-1,iCell)*ts (k-1,iCell))                     &amp;
-                             +resm*(zz(k  ,iCell)*rtheta_pp(k  ,iCell)                &amp;
-                                   -zz(k-1,iCell)*rtheta_pp(k-1,iCell)))              &amp;
-                     - cofwr(k,iCell)*((rs (k,iCell)+rs (k-1,iCell))                  &amp;
-                             +resm*(rho_pp(k,iCell)+rho_pp(k-1,iCell)))               &amp;
-                     + cofwt(k  ,iCell)*(ts (k  ,iCell)+resm*rtheta_pp(k  ,iCell))    &amp;
-                     + cofwt(k-1,iCell)*(ts (k-1,iCell)+resm*rtheta_pp(k-1,iCell))
-        enddo
+            rw_p(k,iCell) = rw_p(k,iCell) +  dts*tend_rw(k,iCell)                       &amp;
+                       - cofwz(k,iCell)*((zz(k  ,iCell)*ts (k  ,iCell)                  &amp;
+                                     -zz(k-1,iCell)*ts (k-1,iCell))                     &amp;
+                               +resm*(zz(k  ,iCell)*rtheta_pp(k  ,iCell)                &amp;
+                                     -zz(k-1,iCell)*rtheta_pp(k-1,iCell)))              &amp;
+                       - cofwr(k,iCell)*((rs (k,iCell)+rs (k-1,iCell))                  &amp;
+                               +resm*(rho_pp(k,iCell)+rho_pp(k-1,iCell)))               &amp;
+                       + cofwt(k  ,iCell)*(ts (k  ,iCell)+resm*rtheta_pp(k  ,iCell))    &amp;
+                       + cofwt(k-1,iCell)*(ts (k-1,iCell)+resm*rtheta_pp(k-1,iCell))
+         end do
 
-        do k=2,nVertLevels
-          rw_p(k,iCell) = (rw_p(k,iCell)-a_tri(k,iCell)*rw_p(k-1,iCell))*alpha_tri(k,iCell)
-        end do
+         ! tridiagonal solve sweeping up and then down the column
 
-        do k=nVertLevels,1,-1
-          rw_p(k,iCell) = rw_p(k,iCell) - gamma_tri(k,iCell)*rw_p(k+1,iCell)                     
-        end do
+         do k=2,nVertLevels
+            rw_p(k,iCell) = (rw_p(k,iCell)-a_tri(k,iCell)*rw_p(k-1,iCell))*alpha_tri(k,iCell)
+         end do
 
-        do k=2,nVertLevels
-           rw_p(k,iCell) = (rw_p(k,iCell)-dts*dss(k,iCell)*               &amp;
-                       (fzm(k)*zz (k,iCell)+fzp(k)*zz (k-1,iCell))        &amp;
-                       *(fzm(k)*rho_zz(k,iCell)+fzp(k)*rho_zz(k-1,iCell))       &amp;
-                                *w(k,iCell)    )/(1.+dts*dss(k,iCell))
+         do k=nVertLevels,1,-1
+            rw_p(k,iCell) = rw_p(k,iCell) - gamma_tri(k,iCell)*rw_p(k+1,iCell)     
+         end do
 
-           wwAvg(k,iCell) = wwAvg(k,iCell) + 0.5*(1.+epssm)*rw_p(k,iCell)
+         ! the implicit Rayleigh damping on w (gravity-wave absorbing) 
 
-        end do
+         do k=2,nVertLevels
+            rw_p(k,iCell) = (rw_p(k,iCell)-dts*dss(k,iCell)*               &amp;
+                        (fzm(k)*zz (k,iCell)+fzp(k)*zz (k-1,iCell))        &amp;
+                        *(fzm(k)*rho_zz(k,iCell)+fzp(k)*rho_zz(k-1,iCell))       &amp;
+                                 *w(k,iCell)    )/(1.+dts*dss(k,iCell))

+            ! accumulate (rho*omega)' for use later in scalar transport
 
-        do k=1,nVertLevels
-          rho_pp(k,iCell) = rs(k,iCell) - cofrz(k) *(rw_p(k+1,iCell)-rw_p(k  ,iCell))
-          rtheta_pp(k,iCell) = ts(k,iCell) - rdzw(k)*(coftz(k+1,iCell)*rw_p(k+1,iCell)  &amp;
-                             -coftz(k  ,iCell)*rw_p(k  ,iCell))
-        end do
+            wwAvg(k,iCell) = wwAvg(k,iCell) + 0.5*(1.+epssm)*rw_p(k,iCell)

+         end do
 
+         ! update rho_pp and theta_pp given updated rw_p
+
+         do k=1,nVertLevels
+            rho_pp(k,iCell) = rs(k,iCell) - cofrz(k) *(rw_p(k+1,iCell)-rw_p(k  ,iCell))
+            rtheta_pp(k,iCell) = ts(k,iCell) - rdzw(k)*(coftz(k+1,iCell)*rw_p(k+1,iCell)  &amp;
+                               -coftz(k  ,iCell)*rw_p(k  ,iCell))
+         end do
+
       end do !  end of loop over cells
 
    end subroutine atm_advance_acoustic_step
@@ -998,7 +977,13 @@
 
    subroutine atm_recover_large_step_variables( s, diag, tend, grid, dt, ns, rk_step )
 
+      ! reconstitute state variables from acoustic-step perturbation variables 
+      ! after the acoustic steps.  The perturbation variables were originally set in
+      ! subroutine atm_set_smlstep_pert_variables prior to their acoustic-steps update.
+      ! we are also computing a few other state-derived variables here.
+
       implicit none
+
       type (state_type) :: s
       type (diag_type) :: diag
       type (tend_type) :: tend
@@ -1006,12 +991,13 @@
       integer, intent(in) :: ns, rk_step
       real (kind=RKIND), intent(in) :: dt
 
+
       real (kind=RKIND), dimension(:,:), pointer :: wwAvg, rw_save, w, rw, rw_p, rtheta_p, rtheta_pp,   &amp;
                                                     rtheta_p_save, rt_diabatic_tend, rho_p, rho_p_save, &amp;
                                                     rho_pp, rho_zz, rho_base, ruAvg, ru_save, ru_p, u, ru, &amp;
                                                     exner, exner_base, rtheta_base, pressure_p,         &amp;
                                                     zz, theta_m, pressure_b, qvapor
-      real (kind=RKIND), dimension(:), pointer :: fzm, fzp, dvEdge, AreaCell
+      real (kind=RKIND), dimension(:), pointer :: fzm, fzp, dvEdge, areaCell
       real (kind=RKIND), dimension(:,:,:), pointer :: zb, zb3 
       integer, dimension(:,:), pointer :: cellsOnEdge
 
@@ -1019,86 +1005,79 @@
       integer :: nVertLevels, nCells, nCellsSolve, nEdges, nEdgesSolve
       real (kind=RKIND) :: rcv, p0, cf1, cf2, cf3, flux, coef_3rd_order
 
-!      logical, parameter :: debug=.true.
       logical, parameter :: debug=.false.
 
-!---
-       wwAvg =&gt; diag % wwAvg % array
-       rw_save =&gt; diag % rw_save % array
-       rw =&gt; diag % rw % array
-       rw_p =&gt; diag % rw_p % array
-       w =&gt; s % w % array
 
-       rtheta_p =&gt; diag % rtheta_p % array
-       rtheta_p_save =&gt; diag % rtheta_p_save % array
-       rtheta_pp =&gt; diag % rtheta_pp % array
-       rtheta_base =&gt; diag % rtheta_base % array
-       rt_diabatic_tend =&gt; tend % rt_diabatic_tend % array
-       theta_m =&gt; s % theta_m % array
-       qvapor =&gt; s % scalars % array(s%index_qv,:,:)
+      wwAvg =&gt; diag % wwAvg % array
+      rw_save =&gt; diag % rw_save % array
+      rw =&gt; diag % rw % array
+      rw_p =&gt; diag % rw_p % array
+      w =&gt; s % w % array
 
-       rho_zz =&gt; s % rho_zz % array
-       rho_p =&gt; diag % rho_p % array
-       rho_p_save =&gt; diag % rho_p_save % array
-       rho_pp =&gt; diag % rho_pp % array
-       rho_base =&gt; diag % rho_base % array
+      rtheta_p =&gt; diag % rtheta_p % array
+      rtheta_p_save =&gt; diag % rtheta_p_save % array
+      rtheta_pp =&gt; diag % rtheta_pp % array
+      rtheta_base =&gt; diag % rtheta_base % array
+      rt_diabatic_tend =&gt; tend % rt_diabatic_tend % array
+      theta_m =&gt; s % theta_m % array
+      qvapor =&gt; s % scalars % array(s%index_qv,:,:)
 
-       ruAvg =&gt; diag % ruAvg % array
-       ru_save =&gt; diag % ru_save % array
-       ru_p =&gt; diag % ru_p % array
-       ru =&gt; diag % ru % array
-       u =&gt; s % u % array
+      rho_zz =&gt; s % rho_zz % array
+      rho_p =&gt; diag % rho_p % array
+      rho_p_save =&gt; diag % rho_p_save % array
+      rho_pp =&gt; diag % rho_pp % array
+      rho_base =&gt; diag % rho_base % array
 
-       exner =&gt; diag % exner % array
-       exner_base =&gt; diag % exner_base % array
+      ruAvg =&gt; diag % ruAvg % array
+      ru_save =&gt; diag % ru_save % array
+      ru_p =&gt; diag % ru_p % array
+      ru =&gt; diag % ru % array
+      u =&gt; s % u % array
 
-       pressure_p =&gt; diag % pressure_p % array
-       pressure_b =&gt; diag % pressure_base % array
+      exner =&gt; diag % exner % array
+      exner_base =&gt; diag % exner_base % array
 
-       zz =&gt; grid % zz % array
-       zb =&gt; grid % zb % array
-       zb3 =&gt; grid % zb3 % array
-       fzm =&gt; grid % fzm % array
-       fzp =&gt; grid % fzp % array
-       dvEdge =&gt; grid % dvEdge % array
-       AreaCell =&gt; grid % AreaCell % array
-       CellsOnEdge =&gt; grid % CellsOnEdge % array
+      pressure_p =&gt; diag % pressure_p % array
+      pressure_b =&gt; diag % pressure_base % array
 
-       nVertLevels = grid % nVertLevels
-       nCells = grid % nCells
-       nCellsSolve = grid % nCellsSolve
-       nEdges = grid % nEdges
-       nEdgesSolve = grid % nEdgesSolve
+      zz =&gt; grid % zz % array
+      zb =&gt; grid % zb % array
+      zb3 =&gt; grid % zb3 % array
+      fzm =&gt; grid % fzm % array
+      fzp =&gt; grid % fzp % array
+      dvEdge =&gt; grid % dvEdge % array
+      areaCell =&gt; grid % areaCell % array
+      cellsOnEdge =&gt; grid % cellsOnEdge % array
 
-       rcv = rgas/(cp-rgas)
-       p0 = 1.e+05  ! this should come from somewhere else...
+      nVertLevels = grid % nVertLevels
+      nCells = grid % nCells
+      nCellsSolve = grid % nCellsSolve
+      nEdges = grid % nEdges
+      nEdgesSolve = grid % nEdgesSolve
 
-       cf1 = grid % cf1 % scalar
-       cf2 = grid % cf2 % scalar
-       cf3 = grid % cf3 % scalar
-       coef_3rd_order = config_coef_3rd_order
-       if(config_theta_adv_order /=3) coef_3rd_order = 0
+      rcv = rgas/(cp-rgas)
+      p0 = 1.e+05  ! this should come from somewhere else...
 
+      cf1 = grid % cf1 % scalar
+      cf2 = grid % cf2 % scalar
+      cf3 = grid % cf3 % scalar
+      coef_3rd_order = config_coef_3rd_order
+      if (config_theta_adv_order /=3) coef_3rd_order = 0
+
       ! compute new density everywhere so we can compute u from ru.
       ! we will also need it to compute theta_m below
 
       do iCell = 1, nCells
 
-        do k = 1, nVertLevels
+         do k = 1, nVertLevels
 
-          rho_p(k,iCell) = rho_p(k,iCell) + rho_pp(k,iCell)
+            rho_p(k,iCell) = rho_p(k,iCell) + rho_pp(k,iCell)
 
-          rho_zz(k,iCell) = rho_p(k,iCell) + rho_base(k,iCell)
-        end do
+            rho_zz(k,iCell) = rho_p(k,iCell) + rho_base(k,iCell)
+         end do
 
-      !  recover owned-cell values in block
-
-!        if( iCell &lt;= nCellsSolve ) then    ! If using this test, more halo exchanges will be needed
-!  WCS-parallel: OK
-
-
-          w(1,iCell) = 0.
-          do k = 2, nVertLevels
+         w(1,iCell) = 0.
+         do k = 2, nVertLevels
             wwAvg(k,iCell) = rw(k,iCell) + (wwAvg(k,iCell) / float(ns))
 
             rw(k,iCell) = rw(k,iCell) + rw_p(k,iCell)
@@ -1107,27 +1086,27 @@
           ! pick up part of diagnosed w from omega
             w(k,iCell) = rw(k,iCell)/( (fzm(k)*zz (k,iCell)+fzp(k)*zz (k-1,iCell))   &amp;
                                       *(fzm(k)*rho_zz(k,iCell)+fzp(k)*rho_zz(k-1,iCell)) )
-          end do
-          w(nVertLevels+1,iCell) = 0.
+         end do
+         w(nVertLevels+1,iCell) = 0.
 
-          if(rk_step == 3) then
+         if (rk_step == 3) then
             do k = 1, nVertLevels
                rtheta_p(k,iCell) = rtheta_p(k,iCell) + rtheta_pp(k,iCell) &amp;
                                  - dt * rho_zz(k,iCell) * rt_diabatic_tend(k,iCell)
             end do
-          else
+         else
             do k = 1, nVertLevels
                rtheta_p(k,iCell) = rtheta_p(k,iCell) + rtheta_pp(k,iCell)
             end do
-          end if
+         end if
 
-          do k = 1, nVertLevels
+         do k = 1, nVertLevels
             theta_m(k,iCell) = (rtheta_p(k,iCell) + rtheta_base(k,iCell))/rho_zz(k,iCell)
             exner(k,iCell) = (zz(k,iCell)*(rgas/p0)*(rtheta_p(k,iCell)+rtheta_base(k,iCell)))**rcv
-             ! pressure below is perturbation pressure
+            ! pressure_p is perturbation pressure
             pressure_p(k,iCell) = zz(k,iCell) * rgas * (exner(k,iCell)*rtheta_p(k,iCell)+rtheta_base(k,iCell)  &amp;
                                                           * (exner(k,iCell)-exner_base(k,iCell)))
-          end do
+         end do
 
       end do
 
@@ -1137,45 +1116,35 @@
 
       do iEdge = 1, nEdges
 
-        cell1 = CellsOnEdge(1,iEdge)
-        cell2 = CellsOnEdge(2,iEdge)
+         cell1 = cellsOnEdge(1,iEdge)
+         cell2 = cellsOnEdge(2,iEdge)
 
-!        if( cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve ) then   ! If using this test, more halo exchanges will be needed,
-                                                                     ! though we can avoid division by zero, e.g., by rho_zz(:,cell2)
-          do k = 1, nVertLevels
-
-
-!  WCS-parallel: we could pick this up in the last acoustic step (ruAvg) because we solve for all edges of owned cells
-
+         do k = 1, nVertLevels
             ruAvg(k,iEdge) = ru(k,iEdge) + (ruAvg(k,iEdge) / float(ns))
-
             ru(k,iEdge) = ru(k,iEdge) + ru_p(k,iEdge)
-
             u(k,iEdge) = 2.*ru(k,iEdge)/(rho_zz(k,cell1)+rho_zz(k,cell2))
-          enddo
+         end do
 
+         !  finish recovering w from (rho*omega)_p.  as when we formed (rho*omega)_p from u and w, we need
+         !  to use the same flux-divergence operator as is used for the horizontal theta transport
+         !  (See Klemp et al 2003).
 
-! WCS-parallel: we likely only need this for owned cells
+         flux = cf1*ru(1,iEdge) + cf2*ru(2,iEdge) + cf3*ru(3,iEdge)
+         w(1,cell2) = w(1,cell2) - (zb(1,2,iEdge) + sign(1.0_RKIND,flux)*coef_3rd_order*zb3(1,2,iEdge))  &amp;
+                                *flux/(cf1*rho_zz(1,cell2)+cf2*rho_zz(2,cell2)+cf3*rho_zz(3,cell2))
+         w(1,cell1) = w(1,cell1) + (zb(1,1,iEdge) + sign(1.0_RKIND,flux)*coef_3rd_order*zb3(1,1,iEdge))  &amp;
+                                *flux/(cf1*rho_zz(1,cell1)+cf2*rho_zz(2,cell1)+cf3*rho_zz(3,cell1))
 
-          !SHP-mtn
-          flux = cf1*ru(1,iEdge) + cf2*ru(2,iEdge) + cf3*ru(3,iEdge)
-          w(1,cell2) = w(1,cell2) - (zb(1,2,iEdge) + sign(1.0_RKIND,flux)*coef_3rd_order*zb3(1,2,iEdge))  &amp;
-                                 *flux/(cf1*rho_zz(1,cell2)+cf2*rho_zz(2,cell2)+cf3*rho_zz(3,cell2))
-          w(1,cell1) = w(1,cell1) + (zb(1,1,iEdge) + sign(1.0_RKIND,flux)*coef_3rd_order*zb3(1,1,iEdge))  &amp;
-                                 *flux/(cf1*rho_zz(1,cell1)+cf2*rho_zz(2,cell1)+cf3*rho_zz(3,cell1))
-
-          do k = 2, nVertLevels
+         do k = 2, nVertLevels
             flux = (fzm(k)*ru(k,iEdge)+fzp(k)*ru(k-1,iEdge))
             w(k,cell2) = w(k,cell2) - (zb(k,2,iEdge)+sign(1.0_RKIND,flux)*coef_3rd_order*zb3(k,2,iEdge)) &amp;
                                  *flux/(fzm(k)*rho_zz(k,cell2)+fzp(k)*rho_zz(k-1,cell2))
             w(k,cell1) = w(k,cell1) + (zb(k,1,iEdge)+sign(1.0_RKIND,flux)*coef_3rd_order*zb3(k,1,iEdge)) &amp;
                                  *flux/(fzm(k)*rho_zz(k,cell1)+fzp(k)*rho_zz(k-1,cell1))
-          enddo
+         end do
 
-!        end if
+      end do
 
-      enddo
-
    end subroutine atm_recover_large_step_variables
 
 !---------------------------------------------------------------------------------------
@@ -1183,10 +1152,21 @@
    subroutine atm_advance_scalars( tend, s_old, s_new, diag, grid, dt)
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    !
-   ! Input: s - current model state
+   ! Integrate scalar equations - explicit transport plus other tendencies
+   !
+   ! Input: s - current model state, 
+   !            including tendencies from sources other than resolved transport.
    !        grid - grid metadata
    !
-   ! Output: tend - computed scalar tendencies
+   ! input scalars in state are uncoupled (i.e. not mulitplied by density)
+   ! 
+   ! Output: updated uncoupled scalars (scalars in s_new).
+   ! Note: scalar tendencies are also modified by this routine.
+   !
+   ! This routine DOES NOT apply any positive definite or monotonic renormalizations.
+   !
+   ! The transport scheme is from Skamarock and Gassmann MWR 2011.
+   !
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
 
       implicit none
@@ -1199,8 +1179,7 @@
       real (kind=RKIND) :: dt
 
       integer :: i, iCell, iEdge, k, iScalar, cell1, cell2
-      real (kind=RKIND) :: flux, scalar_edge, d2fdx2_cell1, d2fdx2_cell2, scalar_weight
-      real (kind=RKIND) :: scalar_weight_cell1, scalar_weight_cell2
+      real (kind=RKIND) :: scalar_weight
 
       real (kind=RKIND), dimension(:,:,:), pointer :: scalar_old, scalar_new, scalar_tend
       real (kind=RKIND), dimension(:,:,:), pointer :: deriv_two
@@ -1213,15 +1192,13 @@
       real (kind=RKIND), dimension(:,:), pointer :: adv_coefs, adv_coefs_3rd
       real (kind=RKIND), dimension( s_old % num_scalars, grid % nVertLevels ) :: flux_arr
 
-      real (kind=RKIND), dimension( s_old % num_scalars, grid % nVertLevels ) :: d2fdx2_cell1_arr, d2fdx2_cell2_arr
-
       real (kind=RKIND), dimension( s_old % num_scalars, grid % nVertLevels + 1 ) :: wdtn
-      integer :: nVertLevels
+      integer :: nCellsSolve, nEdges, nVertLevels
 
       real (kind=RKIND), dimension(:), pointer :: fnm, fnp, rdnw, meshScalingDel2, meshScalingDel4
       real (kind=RKIND) :: coef_3rd_order
 
-      real (kind=RKIND) :: h_theta_eddy_visc2, v_theta_eddy_visc2, scalar_turb_flux, z1,z2,z3,z4,zm,z0,zp
+      real (kind=RKIND) :: h_theta_eddy_visc2, v_theta_eddy_visc2
 
       real (kind=RKIND) :: flux3, flux4
       real (kind=RKIND) :: q_im2, q_im1, q_i, q_ip1, ua, coef3
@@ -1262,6 +1239,8 @@
       adv_coefs =&gt; grid % adv_coefs % array
       adv_coefs_3rd =&gt; grid % adv_coefs_3rd % array
 
+      nCellsSolve = grid % nCellsSolve
+      nEdges      = grid % nEdges
       nVertLevels = grid % nVertLevels
 
       h_theta_eddy_visc2 = config_h_theta_eddy_visc2
@@ -1276,138 +1255,159 @@
 #endif
 
       !
-      ! Runge Kutta integration, so we compute fluxes from scalar_new values, update starts form scalar_old
+      ! Runge Kutta integration, so we compute fluxes from scalar_new values, update starts from scalar_old
       !
-      !
       !  horizontal flux divergence, accumulate in scalar_tend
 
-         do iEdge=1,grid%nEdges
-            cell1 = cellsOnEdge(1,iEdge)
-            cell2 = cellsOnEdge(2,iEdge)
-            if (cell1 &lt;= grid%nCellsSolve .or. cell2 &lt;= grid%nCellsSolve) then  ! only for owned cells
+      do iEdge=1,nEdges
+         cell1 = cellsOnEdge(1,iEdge)
+         cell2 = cellsOnEdge(2,iEdge)
+         if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then  ! only for owned cells
   
-               flux_arr(:,:) = 0.
-               do i=1,nAdvCellsForEdge(iEdge)
-                 iCell = advCellsForEdge(i,iEdge)
-                 do k=1,grid % nVertLevels
-                   scalar_weight = adv_coefs(i,iEdge) + coef_3rd_order*sign(1.0_RKIND,uhAvg(k,iEdge))*adv_coefs_3rd(i,iEdge)
-                   do iScalar=1,s_old % num_scalars
+            !  flux_arr stores the value of the scalar at the edge.
+            !  a better name perhaps would be scalarEdge
+
+            flux_arr(:,:) = 0.
+            do i=1,nAdvCellsForEdge(iEdge)
+               iCell = advCellsForEdge(i,iEdge)
+               do k=1,nVertLevels
+                  scalar_weight = adv_coefs(i,iEdge) + coef_3rd_order*sign(1.0_RKIND,uhAvg(k,iEdge))*adv_coefs_3rd(i,iEdge)
+                  do iScalar=1,s_old % num_scalars
                      flux_arr(iScalar,k) = flux_arr(iScalar,k) + scalar_weight* scalar_new(iScalar,k,iCell)
-                   end do
-                 end do
+                  end do
                end do
+            end do
 
-               do k=1,grid % nVertLevels
-               do iScalar=1,s_old % num_scalars
-                     scalar_tend(iScalar,k,cell1) = scalar_tend(iScalar,k,cell1) &amp;
-                            - uhAvg(k,iEdge)*flux_arr(iScalar,k)/areaCell(cell1)
-                     scalar_tend(iScalar,k,cell2) = scalar_tend(iScalar,k,cell2) &amp;
-                            + uhAvg(k,iEdge)*flux_arr(iScalar,k)/areaCell(cell2)
-               end do
-               end do
+            ! here we add the horizontal flux divergence into the scalar tendency.
+            ! note that the scalar tendency is modified.
 
-            end if
-          end do
+            do k=1,nVertLevels
+            do iScalar=1,s_old % num_scalars
+                  scalar_tend(iScalar,k,cell1) = scalar_tend(iScalar,k,cell1) &amp;
+                         - uhAvg(k,iEdge)*flux_arr(iScalar,k)/areaCell(cell1)
+                  scalar_tend(iScalar,k,cell2) = scalar_tend(iScalar,k,cell2) &amp;
+                         + uhAvg(k,iEdge)*flux_arr(iScalar,k)/areaCell(cell2)
+            end do
+            end do
 
+         end if
+      end do
+
       !
-      !  vertical flux divergence
+      !  vertical flux divergence and update of the scalars
       !
 
       ! zero fluxes at top and bottom
 
-         wdtn(:,1) = 0.
-         wdtn(:,grid % nVertLevels+1) = 0.
+      wdtn(:,1) = 0.
+      wdtn(:,nVertLevels+1) = 0.
 
-         if (config_scalar_vadv_order == 2) then
+      if (config_scalar_vadv_order == 2) then
 
-           do iCell=1,grid % nCellsSolve
-             do k = 2, nVertLevels
-                do iScalar=1,s_old % num_scalars
+         do iCell=1,nCellsSolve
+            do k = 2, nVertLevels
+               do iScalar=1,s_old % num_scalars
                   wdtn(iScalar,k) = wwAvg(k,iCell)*(fnm(k)*scalar_new(iScalar,k,iCell)+fnp(k)*scalar_new(iScalar,k-1,iCell))
-                end do
-             end do
-             do k=1,grid % nVertLevels   ! Could be nVertLevelsSolve?
-                do iScalar=1,s_old % num_scalars
+               end do
+            end do
+            do k=1,nVertLevels
+               do iScalar=1,s_old % num_scalars
                   scalar_new(iScalar,k,iCell) = (   scalar_old(iScalar,k,iCell)*h_old(k,iCell) &amp;
                         + dt*( scalar_tend(iScalar,k,iCell) -rdnw(k)*(wdtn(iScalar,k+1)-wdtn(iScalar,k)) ) )/h_new(k,iCell)
-                end do
-             end do
-           end do
+               end do
+            end do
+         end do
 
-         else if ( config_scalar_vadv_order == 3 ) then
+      else if ( config_scalar_vadv_order == 3 ) then
 
-           do iCell=1,grid % nCellsSolve
+         do iCell=1,nCellsSolve
 
-             k = 2
-             do iScalar=1,s_old % num_scalars
+            k = 2
+            do iScalar=1,s_old % num_scalars
                wdtn(iScalar,k) = wwAvg(k,iCell)*(fnm(k)*scalar_new(iScalar,k,iCell)+fnp(k)*scalar_new(iScalar,k-1,iCell))
-             enddo
+            end do
              
-             do k=3,nVertLevels-1
+            do k=3,nVertLevels-1
                do iScalar=1,s_old % num_scalars
-                 wdtn(iScalar,k) = flux3( scalar_new(iScalar,k-2,iCell),scalar_new(iScalar,k-1,iCell),  &amp;
-                                          scalar_new(iScalar,k  ,iCell),scalar_new(iScalar,k+1,iCell),  &amp;
-                                          wwAvg(k,iCell), coef_3rd_order )
+                  wdtn(iScalar,k) = flux3( scalar_new(iScalar,k-2,iCell),scalar_new(iScalar,k-1,iCell),  &amp;
+                                           scalar_new(iScalar,k  ,iCell),scalar_new(iScalar,k+1,iCell),  &amp;
+                                           wwAvg(k,iCell), coef_3rd_order )
                end do
-             end do
-             k = nVertLevels
-             do iScalar=1,s_old % num_scalars
+            end do
+            k = nVertLevels
+            do iScalar=1,s_old % num_scalars
                wdtn(iScalar,k) = wwAvg(k,iCell)*(fnm(k)*scalar_new(iScalar,k,iCell)+fnp(k)*scalar_new(iScalar,k-1,iCell))
-             enddo
+            end do
 
-             do k=1,grid % nVertLevels   ! Could be nVertLevelsSolve?
-                do iScalar=1,s_old % num_scalars
+            do k=1,nVertLevels
+               do iScalar=1,s_old % num_scalars
                   scalar_new(iScalar,k,iCell) = (   scalar_old(iScalar,k,iCell)*h_old(k,iCell) &amp;
                         + dt*( scalar_tend(iScalar,k,iCell) -rdnw(k)*(wdtn(iScalar,k+1)-wdtn(iScalar,k)) ) )/h_new(k,iCell)
-                end do
-             end do
+               end do
+            end do
 
-           end do
+         end do
 
-         else if ( config_scalar_vadv_order == 4 ) then
+      else if ( config_scalar_vadv_order == 4 ) then
 
-           do iCell=1,grid % nCellsSolve
+         do iCell=1,nCellsSolve
 
-             k = 2
-             do iScalar=1,s_old % num_scalars
+            k = 2
+            do iScalar=1,s_old % num_scalars
                wdtn(iScalar,k) = wwAvg(k,iCell)*(fnm(k)*scalar_new(iScalar,k,iCell)+fnp(k)*scalar_new(iScalar,k-1,iCell))
-             enddo
-             do k=3,nVertLevels-1
+            end do
+            do k=3,nVertLevels-1
                do iScalar=1,s_old % num_scalars
-                 wdtn(iScalar,k) = flux4( scalar_new(iScalar,k-2,iCell),scalar_new(iScalar,k-1,iCell),  &amp;
-                                          scalar_new(iScalar,k  ,iCell),scalar_new(iScalar,k+1,iCell), wwAvg(k,iCell) )
+                  wdtn(iScalar,k) = flux4( scalar_new(iScalar,k-2,iCell),scalar_new(iScalar,k-1,iCell),  &amp;
+                                           scalar_new(iScalar,k  ,iCell),scalar_new(iScalar,k+1,iCell), wwAvg(k,iCell) )
                end do
-             end do
-             k = nVertLevels
-             do iScalar=1,s_old % num_scalars
+            end do
+            k = nVertLevels
+            do iScalar=1,s_old % num_scalars
                wdtn(iScalar,k) = wwAvg(k,iCell)*(fnm(k)*scalar_new(iScalar,k,iCell)+fnp(k)*scalar_new(iScalar,k-1,iCell))
-             enddo
+            end do
 
-             do k=1,grid % nVertLevels   ! Could be nVertLevelsSolve?
-                do iScalar=1,s_old % num_scalars
+            do k=1,nVertLevels
+               do iScalar=1,s_old % num_scalars
                   scalar_new(iScalar,k,iCell) = (   scalar_old(iScalar,k,iCell)*h_old(k,iCell) &amp;
                         + dt*( scalar_tend(iScalar,k,iCell) -rdnw(k)*(wdtn(iScalar,k+1)-wdtn(iScalar,k)) ) )/h_new(k,iCell)
-                end do
-             end do
+               end do
+            end do
 
-           end do
+         end do
                                                                                         
-         else 
+      else 
 
-           write(0,*) ' bad value for config_scalar_vadv_order - ', config_scalar_vadv_order
+         write(0,*) ' bad value for config_scalar_vadv_order - ', config_scalar_vadv_order
 
-         end if
+      end if
 
    end subroutine atm_advance_scalars
 
 !---------------------------
 
-   subroutine atm_advance_scalars_mono(tend, s_old, s_new, diag, grid, dt, rk_step, rk_order)
+   subroutine atm_advance_scalars_mono(tend, s_old, s_new, diag, grid, dt)
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    !
-   ! Input: s - current model state
+   ! Integrate scalar equations - transport plus other tendencies
+   !
+   ! Input: s - current model state, 
+   !            including tendencies from sources other than resolved transport.
    !        grid - grid metadata
    !
+   ! input scalars in state are uncoupled (i.e. not mulitplied by density)
+   ! 
+   ! Output: updated uncoupled scalars (scalars in s_new).
+   ! Note: scalar tendencies are also modified by this routine.
+   !
+   ! This routine DOES apply positive definite or monotonic renormalizations.
+   !
+   ! The transport scheme is from Skamarock and Gassmann MWR 2011.
+   !
+   ! The positive-definite or monotonic renormalization is from Zalesak JCP 1979
+   !   as used in the RK3 scheme as described in Wang et al MWR 2009
+   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
+
       implicit none
 
       type (tend_type),intent(in)     :: tend
@@ -1416,12 +1416,10 @@
       type (diag_type),intent(in)     :: diag
       type (mesh_type),intent(in)     :: grid
       real (kind=RKIND),intent(in)    :: dt
-      integer, intent(in)             :: rk_step, rk_order
 
       type (block_type), pointer :: block
       integer :: i, iCell, iEdge, k, iScalar, cell1, cell2
-      real (kind=RKIND) :: flux, scalar_edge, d2fdx2_cell1, d2fdx2_cell2, scalar_weight
-      real (kind=RKIND) :: scalar_weight_cell1, scalar_weight_cell2
+      real (kind=RKIND) :: flux, scalar_weight
 
       real (kind=RKIND), dimension(:,:,:), pointer :: scalar_tend
       real (kind=RKIND), dimension(:,:,:), pointer :: deriv_two
@@ -1433,22 +1431,25 @@
       integer, dimension(:), pointer :: nAdvCellsForEdge
       real (kind=RKIND), dimension(:,:), pointer :: adv_coefs, adv_coefs_3rd
 
-      type (field2DReal), pointer :: tempField
-      type (field2DReal), target :: tempFieldTarget
+      type (field3DReal), pointer :: tempField
+      type (field3DReal), target :: tempFieldTarget
 
       real (kind=RKIND), dimension( grid % nVertLevels, grid % nCells ) :: scalar_old, scalar_new
-      real (kind=RKIND), dimension( grid % nVertLevels, grid % nCells ) :: s_max, s_min, s_update
-      real (kind=RKIND), dimension( grid % nVertLevels, grid % nCells ), target :: scale_in, scale_out
+      real (kind=RKIND), dimension( grid % nVertLevels, grid % nCells ) :: s_max, s_min
+      real (kind=RKIND), dimension( 2, grid % nVertLevels, grid % nCells ), target :: scale_arr
 
+      integer, parameter :: SCALE_IN = 1, SCALE_OUT = 2
+
       real (kind=RKIND), dimension( grid % nVertLevels, grid % nEdges ) :: flux_arr
       real (kind=RKIND), dimension( grid % nVertLevels + 1, grid % nCells ) :: wdtn
 
-      integer :: nVertLevels, isc, num_scalars, icellmax, kmax
+      integer :: nCells, nCellsSolve, nEdges, nVertLevels, num_scalars, icellmax, kmax
 
       real (kind=RKIND), dimension(:), pointer :: fnm, fnp, rdnw, meshScalingDel2, meshScalingDel4
+      integer, dimension(:), pointer :: nEdgesOnCell
       real (kind=RKIND) :: coef_3rd_order
 
-      real (kind=RKIND) :: h_theta_eddy_visc2, v_theta_eddy_visc2, scalar_turb_flux, z1,z2,z3,z4,zm,z0,zp
+      real (kind=RKIND) :: h_theta_eddy_visc2, v_theta_eddy_visc2
 
       real (kind=RKIND) :: flux3, flux4, flux_upwind
       real (kind=RKIND) :: q_im2, q_im1, q_i, q_ip1, ua, coef3, scmin,scmax
@@ -1487,11 +1488,15 @@
       meshScalingDel2 =&gt; grid % meshScalingDel2 % array
       meshScalingDel4 =&gt; grid % meshScalingDel4 % array
 
+      nEdgesOnCell =&gt; grid % nEdgesOnCell % array
       nAdvCellsForEdge =&gt; grid % nAdvCellsForEdge % array
       advCellsForEdge =&gt; grid % advCellsForEdge % array
       adv_coefs =&gt; grid % adv_coefs % array
       adv_coefs_3rd =&gt; grid % adv_coefs_3rd % array
 
+      nCells      = grid % nCells
+      nCellsSolve = grid % nCellsSolve
+      nEdges      = grid % nEdges
       nVertLevels = grid % nVertLevels
 
       h_theta_eddy_visc2 = config_h_theta_eddy_visc2
@@ -1505,13 +1510,13 @@
       scalar_tend = 0.  !  testing purposes - we have no sources or sinks
 #endif
 
-      !
-      ! Update scalars for physics (i.e., what is in scalar_tend)
-      !   we should probably move this to another routine called before mono advection ****
-      !
+      !  for positive-definite or monotonic option, we first update scalars using the tendency from sources other than
+      !  the resolved transport (these should constitute a positive definite update).  
+      !  Note, however, that we enforce positive-definiteness in this update.
+      !  The transport will maintain this positive definite solution and optionally, shape preservation (monotonicity).
 
-      do iCell = 1,grid%nCellsSolve
-      do k = 1, grid%nVertLevels
+      do iCell = 1, nCellsSolve
+      do k = 1, nVertLevels
       do iScalar = 1,s_old%num_scalars
          s_old % scalars % array(iScalar,k,iCell) = s_old % scalars % array(iScalar,k,iCell)+dt*scalar_tend(iScalar,k,iCell) / h_old(k,iCell)
          scalar_tend(iScalar,k,iCell) = 0.
@@ -1532,34 +1537,36 @@
       num_scalars = 1
 
       do iScalar = 1, s_old % num_scalars
-        write(0,*) ' mono transport for scalar ',iScalar
+         write(0,*) ' mono transport for scalar ',iScalar
 
-        do iCell = 1, grid%nCells
-        do k=1, grid%nVertLevels
-          scalar_old(k,iCell) = s_old % scalars % array(iScalar,k,iCell)
-          scalar_new(k,iCell) = s_new % scalars % array(iScalar,k,iCell)
-        end do
-        end do
+         do iCell = 1, nCells
+         do k = 1, nVertLevels
+            scalar_old(k,iCell) = s_old % scalars % array(iScalar,k,iCell)
+            scalar_new(k,iCell) = s_new % scalars % array(iScalar,k,iCell)
+         end do
+         end do
 
-        scmin = scalar_old(1,1)
-        scmax = scalar_old(1,1)
-        do iCell = 1, grid%nCells
-        do k=1, grid%nVertLevels
-          scmin = min(scmin,scalar_old(k,iCell))
-          scmax = max(scmax,scalar_old(k,iCell))
-        enddo
-        enddo
-        write(0,*) ' scmin, scmin old in ',scmin,scmax
+         if (debug_print) then
+            scmin = scalar_old(1,1)
+            scmax = scalar_old(1,1)
+            do iCell = 1, nCells
+            do k=1, nVertLevels
+               scmin = min(scmin,scalar_old(k,iCell))
+               scmax = max(scmax,scalar_old(k,iCell))
+            end do
+            end do
+            write(0,*) ' scmin, scmin old in ',scmin,scmax
 
-        scmin = scalar_new(1,1)
-        scmax = scalar_new(1,1)
-        do iCell = 1, grid%nCells
-        do k=1, grid%nVertLevels
-          scmin = min(scmin,scalar_new(k,iCell))
-          scmax = max(scmax,scalar_new(k,iCell))
-        enddo
-        enddo
-        write(0,*) ' scmin, scmin new in ',scmin,scmax
+            scmin = scalar_new(1,1)
+            scmax = scalar_new(1,1)
+            do iCell = 1, nCells
+            do k=1, nVertLevels
+               scmin = min(scmin,scalar_new(k,iCell))
+               scmax = max(scmax,scalar_new(k,iCell))
+            end do
+            end do
+            write(0,*) ' scmin, scmin new in ',scmin,scmax
+         end if
 
 
       !
@@ -1567,42 +1574,42 @@
       !
 
  
-         do iCell=1,grid % nCellsSolve
+         do iCell=1,nCellsSolve
 
-          ! zero flux at top and bottom
-           wdtn(1,iCell) = 0.
-           wdtn(grid % nVertLevels+1,iCell) = 0.
+            ! zero flux at top and bottom
+            wdtn(1,iCell) = 0.
+            wdtn(grid % nVertLevels+1,iCell) = 0.
 
-           k = 1
-           s_max(k,iCell) = max(scalar_old(1,iCell),scalar_old(2,iCell))
-           s_min(k,iCell) = min(scalar_old(1,iCell),scalar_old(2,iCell))
+            k = 1
+            s_max(k,iCell) = max(scalar_old(1,iCell),scalar_old(2,iCell))
+            s_min(k,iCell) = min(scalar_old(1,iCell),scalar_old(2,iCell))
 
-           k = 2
-           wdtn(k,iCell) = wwAvg(k,iCell)*(fnm(k)*scalar_new(k,iCell)+fnp(k)*scalar_new(k-1,iCell))
-           s_max(k,iCell) = max(scalar_old(k-1,iCell),scalar_old(k,iCell),scalar_old(k+1,iCell))
-           s_min(k,iCell) = min(scalar_old(k-1,iCell),scalar_old(k,iCell),scalar_old(k+1,iCell))
+            k = 2
+            wdtn(k,iCell) = wwAvg(k,iCell)*(fnm(k)*scalar_new(k,iCell)+fnp(k)*scalar_new(k-1,iCell))
+            s_max(k,iCell) = max(scalar_old(k-1,iCell),scalar_old(k,iCell),scalar_old(k+1,iCell))
+            s_min(k,iCell) = min(scalar_old(k-1,iCell),scalar_old(k,iCell),scalar_old(k+1,iCell))
              
-           do k=3,nVertLevels-1
-              wdtn(k,iCell) = flux3( scalar_new(k-2,iCell),scalar_new(k-1,iCell),  &amp;
-                                     scalar_new(k  ,iCell),scalar_new(k+1,iCell),  &amp;
-                                     wwAvg(k,iCell), coef_3rd_order )
-              s_max(k,iCell) = max(scalar_old(k-1,iCell),scalar_old(k,iCell),scalar_old(k+1,iCell))
-              s_min(k,iCell) = min(scalar_old(k-1,iCell),scalar_old(k,iCell),scalar_old(k+1,iCell))
-           end do
+            do k=3,nVertLevels-1
+               wdtn(k,iCell) = flux3( scalar_new(k-2,iCell),scalar_new(k-1,iCell),  &amp;
+                                      scalar_new(k  ,iCell),scalar_new(k+1,iCell),  &amp;
+                                      wwAvg(k,iCell), coef_3rd_order )
+               s_max(k,iCell) = max(scalar_old(k-1,iCell),scalar_old(k,iCell),scalar_old(k+1,iCell))
+               s_min(k,iCell) = min(scalar_old(k-1,iCell),scalar_old(k,iCell),scalar_old(k+1,iCell))
+            end do
  
-           k = nVertLevels
-           wdtn(k,iCell) = wwAvg(k,iCell)*(fnm(k)*scalar_new(k,iCell)+fnp(k)*scalar_new(k-1,iCell))
-           s_max(k,iCell) = max(scalar_old(k,iCell),scalar_old(k-1,iCell))
-           s_min(k,iCell) = min(scalar_old(k,iCell),scalar_old(k-1,iCell))
+            k = nVertLevels
+            wdtn(k,iCell) = wwAvg(k,iCell)*(fnm(k)*scalar_new(k,iCell)+fnp(k)*scalar_new(k-1,iCell))
+            s_max(k,iCell) = max(scalar_old(k,iCell),scalar_old(k-1,iCell))
+            s_min(k,iCell) = min(scalar_old(k,iCell),scalar_old(k-1,iCell))
 
       ! pull s_min and s_max from the (horizontal) surrounding cells
 
-           do i=1, grid % nEdgesOnCell % array(iCell)
-             do k=1, grid % nVertLevels
-               s_max(k,iCell) = max(s_max(k,iCell),scalar_old(k, grid % CellsOnCell % array(i,iCell)))
-               s_min(k,iCell) = min(s_min(k,iCell),scalar_old(k, grid % CellsOnCell % array(i,iCell)))
-             end do
-           end do
+            do i=1, nEdgesOnCell(iCell)
+               do k=1, grid % nVertLevels
+                  s_max(k,iCell) = max(s_max(k,iCell),scalar_old(k, grid % CellsOnCell % array(i,iCell)))
+                  s_min(k,iCell) = min(s_min(k,iCell),scalar_old(k, grid % CellsOnCell % array(i,iCell)))
+               end do
+            end do
 
          end do
 
@@ -1610,203 +1617,204 @@
       !  horizontal flux divergence
 
          flux_arr(:,:) = 0.
-         do iEdge=1,grid%nEdges
+         do iEdge=1,nEdges
 
             cell1 = cellsOnEdge(1,iEdge)
             cell2 = cellsOnEdge(2,iEdge)
 
-            if (cell1 &lt;= grid%nCellsSolve .or. cell2 &lt;= grid%nCellsSolve) then  ! only for owned cells
+            if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then  ! only for owned cells
   
                do i=1,nAdvCellsForEdge(iEdge)
-                 iCell = advCellsForEdge(i,iEdge)
-                 do k=1,grid % nVertLevels
-                   scalar_weight = uhAvg(k,iEdge)*(adv_coefs(i,iEdge) + coef_3rd_order*sign(1.0_RKIND,uhAvg(k,iEdge))*adv_coefs_3rd(i,iEdge))
-                   flux_arr(k,iEdge) = flux_arr(k,iEdge) + scalar_weight* scalar_new(k,iCell)
-                 end do
+                  iCell = advCellsForEdge(i,iEdge)
+                  do k=1,nVertLevels
+                     scalar_weight = uhAvg(k,iEdge)*(adv_coefs(i,iEdge) + coef_3rd_order*sign(1.0_RKIND,uhAvg(k,iEdge))*adv_coefs_3rd(i,iEdge))
+                     flux_arr(k,iEdge) = flux_arr(k,iEdge) + scalar_weight* scalar_new(k,iCell)
+                  end do
                end do
 
             end if
 
-          end do
+         end do
 
 !  vertical flux divergence for upwind update, we will put upwind update into scalar_new, and put factor of dt in fluxes
 
-          do iCell = 1, grid % nCellsSolve
+         do iCell = 1, nCellsSolve
 
             k = 1
             scalar_new(k,iCell) = scalar_old(k,iCell)*h_old(k,iCell)
 
             do k = 2, nVertLevels
-              scalar_new(k,iCell) = scalar_old(k,iCell)*h_old(k,iCell)
-              flux_upwind = dt*(max(0.0_RKIND,wwAvg(k,iCell))*scalar_old(k-1,iCell) + min(0.0_RKIND,wwAvg(k,iCell))*scalar_old(k,iCell))
-              scalar_new(k-1,iCell) = scalar_new(k-1,iCell) - flux_upwind*rdnw(k-1)
-              scalar_new(k  ,iCell) = scalar_new(k  ,iCell) + flux_upwind*rdnw(k)
-              wdtn(k,iCell) = dt*wdtn(k,iCell) - flux_upwind
+               scalar_new(k,iCell) = scalar_old(k,iCell)*h_old(k,iCell)
+               flux_upwind = dt*(max(0.0_RKIND,wwAvg(k,iCell))*scalar_old(k-1,iCell) + min(0.0_RKIND,wwAvg(k,iCell))*scalar_old(k,iCell))
+               scalar_new(k-1,iCell) = scalar_new(k-1,iCell) - flux_upwind*rdnw(k-1)
+               scalar_new(k  ,iCell) = scalar_new(k  ,iCell) + flux_upwind*rdnw(k)
+               wdtn(k,iCell) = dt*wdtn(k,iCell) - flux_upwind
             end do
 
-! scale_in(:,:) and scale_out(:,:) are used here to store the incoming and outgoing perturbation flux 
+! scale_arr(SCALE_IN,:,:) and scale_arr(SCALE_OUT:,:) are used here to store the incoming and outgoing perturbation flux 
 ! contributions to the update:  first the vertical flux component, then the horizontal
 
             do k=1,nVertLevels
-              scale_in (k,iCell) = - rdnw(k)*(min(0.0_RKIND,wdtn(k+1,iCell))-max(0.0_RKIND,wdtn(k,iCell)))
-              scale_out(k,iCell) = - rdnw(k)*(max(0.0_RKIND,wdtn(k+1,iCell))-min(0.0_RKIND,wdtn(k,iCell)))
+               scale_arr(SCALE_IN, k,iCell) = - rdnw(k)*(min(0.0_RKIND,wdtn(k+1,iCell))-max(0.0_RKIND,wdtn(k,iCell)))
+               scale_arr(SCALE_OUT,k,iCell) = - rdnw(k)*(max(0.0_RKIND,wdtn(k+1,iCell))-min(0.0_RKIND,wdtn(k,iCell)))
             end do
 
-          end do
+         end do
 
 !  horizontal flux divergence for upwind update
 
          !  upwind flux computation
 
-         do iEdge=1,grid%nEdges
-           cell1 = cellsOnEdge(1,iEdge)
-           cell2 = cellsOnEdge(2,iEdge)
-             if (cell1 &lt;= grid%nCellsSolve .or. cell2 &lt;= grid%nCellsSolve) then  ! only for owned cells
-               do k=1,grid % nVertLevels
-                 flux_upwind = grid % dvEdge % array(iEdge) * dt *   &amp;
-                        (max(0.0_RKIND,uhAvg(k,iEdge))*scalar_old(k,cell1) + min(0.0_RKIND,uhAvg(k,iEdge))*scalar_old(k,cell2))
-                 flux_arr(k,iEdge) = dt*flux_arr(k,iEdge) - flux_upwind
-                 scalar_new(k,cell1) = scalar_new(k,cell1) - flux_upwind / areaCell(cell1)
-                 scalar_new(k,cell2) = scalar_new(k,cell2) + flux_upwind / areaCell(cell2)
-
-                 scale_out(k,cell1) = scale_out(k,cell1) - max(0.0_RKIND,flux_arr(k,iEdge)) / areaCell(cell1)
-                 scale_in (k,cell1) = scale_in (k,cell1) - min(0.0_RKIND,flux_arr(k,iEdge)) / areaCell(cell1)
-                 scale_out(k,cell2) = scale_out(k,cell2) + min(0.0_RKIND,flux_arr(k,iEdge)) / areaCell(cell2)
-                 scale_in (k,cell2) = scale_in (k,cell2) + max(0.0_RKIND,flux_arr(k,iEdge)) / areaCell(cell2)
-
+         do iEdge=1,nEdges
+            cell1 = cellsOnEdge(1,iEdge)
+            cell2 = cellsOnEdge(2,iEdge)
+            if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then  ! only for owned cells
+               do k=1, nVertLevels
+                  flux_upwind = grid % dvEdge % array(iEdge) * dt *   &amp;
+                         (max(0.0_RKIND,uhAvg(k,iEdge))*scalar_old(k,cell1) + min(0.0_RKIND,uhAvg(k,iEdge))*scalar_old(k,cell2))
+                  flux_arr(k,iEdge) = dt*flux_arr(k,iEdge) - flux_upwind
+                  scalar_new(k,cell1) = scalar_new(k,cell1) - flux_upwind / areaCell(cell1)
+                  scalar_new(k,cell2) = scalar_new(k,cell2) + flux_upwind / areaCell(cell2)

+                  scale_arr(SCALE_OUT,k,cell1) = scale_arr(SCALE_OUT,k,cell1) - max(0.0_RKIND,flux_arr(k,iEdge)) / areaCell(cell1)
+                  scale_arr(SCALE_IN, k,cell1) = scale_arr(SCALE_IN, k,cell1) - min(0.0_RKIND,flux_arr(k,iEdge)) / areaCell(cell1)
+                  scale_arr(SCALE_OUT,k,cell2) = scale_arr(SCALE_OUT,k,cell2) + min(0.0_RKIND,flux_arr(k,iEdge)) / areaCell(cell2)
+                  scale_arr(SCALE_IN, k,cell2) = scale_arr(SCALE_IN, k,cell2) + max(0.0_RKIND,flux_arr(k,iEdge)) / areaCell(cell2)

                end do
-             end if
-          end do
+            end if
+         end do
 
 !  next, the limiter
 
-          do iCell = 1, grid % nCellsSolve
+         do iCell = 1, nCellsSolve
             do k = 1, nVertLevels
-               s_min_update = (scalar_new(k,iCell)+scale_out(k,iCell))/h_new(k,iCell)
-               s_max_update = (scalar_new(k,iCell)+scale_in (k,iCell))/h_new(k,iCell)
+               s_min_update = (scalar_new(k,iCell)+scale_arr(SCALE_OUT,k,iCell))/h_new(k,iCell)
+               s_max_update = (scalar_new(k,iCell)+scale_arr(SCALE_IN,k,iCell))/h_new(k,iCell)
                s_upwind = scalar_new(k,iCell)/h_new(k,iCell)
            
                scale_factor = (s_max(k,iCell)-s_upwind)/(s_max_update-s_upwind+eps)
-               scale_in(k,iCell) = min( 1.0_RKIND, max( 0.0_RKIND, scale_factor) )
+               scale_arr(SCALE_IN,k,iCell) = min( 1.0_RKIND, max( 0.0_RKIND, scale_factor) )
 
                scale_factor = (s_upwind-s_min(k,iCell))/(s_upwind-s_min_update+eps)
-               scale_out(k,iCell) = min( 1.0_RKIND, max( 0.0_RKIND, scale_factor) )
+               scale_arr(SCALE_OUT,k,iCell) = min( 1.0_RKIND, max( 0.0_RKIND, scale_factor) )
 
             end do
-          end do
+         end do
 !
-!  communicate scale factors here
+!  communicate scale factors here.
+!  communicate only first halo row in these next two exchanges
 !
-!
-!  WCS_halo_opt_2 - communicate only first halo row in these next two exchanges
-!
-      tempField =&gt; tempFieldTarget
+         tempField =&gt; tempFieldTarget
 
-      tempField % block =&gt; block
-      tempField % dimSizes(1) = grid % nVertLevels
-      tempField % dimSizes(2) = grid % nCells
-      tempField % sendList =&gt; block % parinfo % cellsToSend
-      tempField % recvList =&gt; block % parinfo % cellsToRecv
-      tempField % copyList =&gt; block % parinfo % cellsToCopy
-      tempField % prev =&gt; null()
-      tempField % next =&gt; null()
+         tempField % block =&gt; block
+         tempField % dimSizes(1) = 2
+         tempField % dimSizes(2) = grid % nVertLevels
+         tempField % dimSizes(3) = grid % nCells
+         tempField % sendList =&gt; block % parinfo % cellsToSend
+         tempField % recvList =&gt; block % parinfo % cellsToRecv
+         tempField % copyList =&gt; block % parinfo % cellsToCopy
+         tempField % prev =&gt; null()
+         tempField % next =&gt; null()
 
-      tempField % array =&gt; scale_in
-      call mpas_dmpar_exch_halo_field(tempField, (/ 1 /))
+         tempField % array =&gt; scale_arr
+         call mpas_dmpar_exch_halo_field(tempField, (/ 1 /))
 
-      tempField % array =&gt; scale_out
-      call mpas_dmpar_exch_halo_field(tempField, (/ 1 /))
-
 !
 !  rescale the fluxes
 !
-            do iEdge = 1, grid % nEdges
-               cell1 = grid % cellsOnEdge % array(1,iEdge)
-               cell2 = grid % cellsOnEdge % array(2,iEdge)
-               if (cell1 &lt;= grid%nCellsSolve .or. cell2 &lt;= grid%nCellsSolve) then
-                  do k = 1, nVertLevels
-                     flux = flux_arr(k,iEdge)
-                     flux = max(0.0_RKIND,flux) * min(scale_out(k,cell1), scale_in(k,cell2)) &amp;
-                          + min(0.0_RKIND,flux) * min(scale_in(k,cell1), scale_out(k,cell2))
-                     flux_arr(k,iEdge) = flux
-                  end do
-               end if
-            end do
+         do iEdge = 1, nEdges
+            cell1 = cellsOnEdge(1,iEdge)
+            cell2 = cellsOnEdge(2,iEdge)
+            if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
+               do k = 1, nVertLevels
+                  flux = flux_arr(k,iEdge)
+                  flux = max(0.0_RKIND,flux) * min(scale_arr(SCALE_OUT,k,cell1), scale_arr(SCALE_IN, k,cell2)) &amp;
+                       + min(0.0_RKIND,flux) * min(scale_arr(SCALE_IN, k,cell1), scale_arr(SCALE_OUT,k,cell2))
+                  flux_arr(k,iEdge) = flux
+               end do
+            end if
+         end do
  
        ! rescale the vertical flux
  
-            do iCell=1,grid % nCells
-               do k = 2, nVertLevels
-                  flux =  wdtn(k,iCell)
-                  flux = max(0.0_RKIND,flux) * min(scale_out(k-1,iCell), scale_in(k  ,iCell)) &amp;
-                       + min(0.0_RKIND,flux) * min(scale_out(k  ,iCell), scale_in(k-1,iCell))
-                  wdtn(k,iCell) = flux
-               end do
+         do iCell=1,nCells
+            do k = 2, nVertLevels
+               flux =  wdtn(k,iCell)
+               flux = max(0.0_RKIND,flux) * min(scale_arr(SCALE_OUT,k-1,iCell), scale_arr(SCALE_IN,k  ,iCell)) &amp;
+                    + min(0.0_RKIND,flux) * min(scale_arr(SCALE_OUT,k  ,iCell), scale_arr(SCALE_IN,k-1,iCell))
+               wdtn(k,iCell) = flux
             end do
+         end do
 !
 !  do the scalar update now that we have the fluxes
 !
-         do iEdge=1,grid%nEdges
+         do iEdge=1,nEdges
             cell1 = cellsOnEdge(1,iEdge)
             cell2 = cellsOnEdge(2,iEdge)
-            if (cell1 &lt;= grid%nCellsSolve .or. cell2 &lt;= grid%nCellsSolve) then  ! only for owned cells
-               do k=1,grid % nVertLevels
+            if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then  ! only for owned cells
+               do k=1,nVertLevels
                   scalar_new(k,cell1) = scalar_new(k,cell1) - flux_arr(k,iEdge)/areaCell(cell1)
                   scalar_new(k,cell2) = scalar_new(k,cell2) + flux_arr(k,iEdge)/areaCell(cell2)
                end do
             end if
          end do
 
-          do iCell=1,grid % nCellsSolve
-             do k=1,grid % nVertLevels
+         do iCell=1,nCellsSolve
+            do k=1,nVertLevels
                scalar_new(k,iCell) = (   scalar_new(k,iCell)  &amp;
                    + (-rdnw(k)*(wdtn(k+1,iCell)-wdtn(k,iCell)) ) )/h_new(k,iCell)
-             end do
-          end do
+            end do
+         end do
 
-        if(debug_print) then
+         if(debug_print) then
 
-        scmin = scalar_new(1,1)
-        scmax = scalar_new(1,1)
-        do iCell = 1, grid%nCellsSolve
-        do k=1, grid%nVertLevels
-          scmax = max(scmax,scalar_new(k,iCell))
-          scmin = min(scmin,scalar_new(k,iCell))
-          if(s_max(k,iCell) &lt; scalar_new(k,iCell)) then
-            write(32,*) ' over - k,iCell,s_min,s_max,scalar_new ',k,iCell,s_min(k,iCell),s_max(k,iCell),scalar_new(k,iCell)
-          end if
-          if(s_min(k,iCell) &gt; scalar_new(k,iCell)) then
-            write(32,*) ' under - k,iCell,s_min,s_max,scalar_new ',k,iCell,s_min(k,iCell),s_max(k,iCell),scalar_new(k,iCell)
-          end if
-        enddo
-        enddo
-        write(0,*) ' scmin, scmax new out ',scmin,scmax
-        write(0,*) ' icell_min, k_min ',icellmax, kmax
+            scmin = scalar_new(1,1)
+            scmax = scalar_new(1,1)
+            do iCell = 1, nCellsSolve
+            do k=1, nVertLevels
+               scmax = max(scmax,scalar_new(k,iCell))
+               scmin = min(scmin,scalar_new(k,iCell))
+               if (s_max(k,iCell) &lt; scalar_new(k,iCell)) then
+                  write(32,*) ' over - k,iCell,s_min,s_max,scalar_new ',k,iCell,s_min(k,iCell),s_max(k,iCell),scalar_new(k,iCell)
+               end if
+               if (s_min(k,iCell) &gt; scalar_new(k,iCell)) then
+                  write(32,*) ' under - k,iCell,s_min,s_max,scalar_new ',k,iCell,s_min(k,iCell),s_max(k,iCell),scalar_new(k,iCell)
+               end if
+            end do
+            end do
+            write(0,*) ' scmin, scmax new out ',scmin,scmax
+            write(0,*) ' icell_min, k_min ',icellmax, kmax
 
-        end if
+         end if
 
-          do iCell = 1, grid%nCells
-          do k=1, grid%nVertLevels
-             s_new % scalars % array(iScalar,k,iCell) = max(0.0_RKIND,scalar_new(k,iCell))
-          end do
-          end do
+         ! the update should be positive definite. but roundoff can sometimes leave small negative values
+         ! hence the enforcement of PD in the copy back to the model state.
 
+         do iCell = 1, nCells
+         do k=1, nVertLevels
+            s_new % scalars % array(iScalar,k,iCell) = max(0.0_RKIND,scalar_new(k,iCell))
+         end do
+         end do
+
       end do !  loop over scalars
 
    end subroutine atm_advance_scalars_mono
 
 !----
 
-   subroutine atm_compute_dyn_tend(tend, s, diag, grid, rk_step)
+   subroutine atm_compute_dyn_tend(tend, s, diag, grid, rk_step, dt)
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    ! Compute height and normal wind tendencies, as well as diagnostic variables
    !
    ! Input: s - current model state
    !        grid - grid metadata
+   !        diag - some grid diagnostics
    !
-   ! Output: tend - computed diagnostics (parallel velocities, v; mass fluxes, rv; 
-   !                circulation; vorticity; and kinetic energy, ke) and the 
-   !                tendencies for height (h) and u (u)
+   ! Output: tend - tendencies: tend_u, tend_w, tend_theta and tend_rho
+   !                these are all coupled-variable tendencies.
+   !         various other quantities in diag: Smagorinsky eddy viscosity
+   !                
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
 
       implicit none
@@ -1816,18 +1824,20 @@
       type (diag_type), intent(in) :: diag
       type (mesh_type), intent(in) :: grid
       integer, intent(in) :: rk_step
+      real (kind=RKIND), intent(in) :: dt
 
+
       logical, parameter :: rk_diffusion = .false.
 
       integer :: iEdge, iCell, iVertex, k, cell1, cell2, vertex1, vertex2, eoe, i, j, iq
-      real (kind=RKIND) :: flux, vorticity_abs, rho_vertex, workpv, upstream_bias
+      real (kind=RKIND) :: flux, workpv
 
-      integer :: nCells, nEdges, nVertices, nVertLevels, nCellsSolve
+      integer :: nCells, nEdges, nVertices, nVertLevels, nCellsSolve, nEdgesSolve
       real (kind=RKIND) :: h_mom_eddy_visc2,   v_mom_eddy_visc2,   h_mom_eddy_visc4
       real (kind=RKIND) :: h_theta_eddy_visc2, v_theta_eddy_visc2, h_theta_eddy_visc4
       real (kind=RKIND) :: u_diffusion
-      real (kind=RKIND), dimension(:), pointer ::  fVertex, fEdge, dvEdge, dcEdge, areaCell, areaTriangle, meshScalingDel2, meshScalingDel4
-      real (kind=RKIND), dimension(:,:), pointer :: weightsOnEdge, kiteAreasOnVertex, zgrid, rho_edge, rho_zz, ru, u, v, tend_u, &amp;
+      real (kind=RKIND), dimension(:), pointer ::  fEdge, dvEdge, dcEdge, areaCell, areaTriangle, meshScalingDel2, meshScalingDel4
+      real (kind=RKIND), dimension(:,:), pointer :: weightsOnEdge, zgrid, rho_edge, rho_zz, ru, u, v, tend_u, &amp;
                                                     circulation, divergence, vorticity, ke, pv_edge, theta_m, rw, tend_rho, &amp;
                                                     rt_diabatic_tend, tend_theta, tend_w, w, cqw, rb, rr, pp, pressure_b, zz, zx, cqu, &amp; 
                                                     h_divergence, kdiff
@@ -1835,13 +1845,13 @@
       real (kind=RKIND), dimension(:,:), pointer :: tend_u_euler, tend_w_euler, tend_theta_euler
 
       real (kind=RKIND), dimension(:,:,:), pointer :: deriv_two
-      integer, dimension(:,:), pointer :: cellsOnEdge, cellsOnVertex, verticesOnEdge, edgesOnCell, edgesOnEdge, edgesOnVertex
+      integer, dimension(:,:), pointer :: cellsOnEdge, verticesOnEdge, edgesOnCell, edgesOnEdge
       integer, dimension(:), pointer :: nEdgesOnCell, nEdgesOnEdge
 
       real (kind=RKIND), dimension( grid % nVertLevels + 1 ) :: wduz, wdwz, wdtz, dpzx
       real (kind=RKIND), dimension( grid % nVertLevels ) :: u_mix, ru_edge_w, q
-      real (kind=RKIND) :: theta_edge, theta_turb_flux, z1, z2, z3, z4, zm, z0, zp, r
-      real (kind=RKIND) :: d2fdx2_cell1, d2fdx2_cell2, pgrad
+      real (kind=RKIND) :: theta_turb_flux, z1, z2, z3, z4, zm, z0, zp, r
+      real (kind=RKIND) :: d2fdx2_cell1, d2fdx2_cell2
 
       integer, dimension(:,:), pointer :: advCellsForEdge
       integer, dimension(:), pointer :: nAdvCellsForEdge
@@ -1854,16 +1864,15 @@
       real (kind=RKIND), dimension(:,:), pointer :: cpr, cpl, pzp, pzm
       integer :: kr, kl
 
-      real (kind=RKIND), allocatable, dimension(:,:) :: rv, divergence_ru, qtot 
+      real (kind=RKIND), allocatable, dimension(:,:) :: divergence_ru, qtot 
       real (kind=RKIND), allocatable, dimension(:,:) :: delsq_theta, delsq_divergence
       real (kind=RKIND), allocatable, dimension(:,:) :: delsq_u
       real (kind=RKIND), allocatable, dimension(:,:) :: delsq_circulation, delsq_vorticity
       real (kind=RKIND) :: cf1, cf2, cf3, pr, pl
+      real (kind=RKIND) :: prandtl_inv
 
-!      logical, parameter :: debug = .true.
       logical, parameter :: debug = .false.
 
-      !SHP-curvature
       logical, parameter :: curvature = .true.
       real (kind=RKIND) :: r_earth
       real (kind=RKIND), dimension(:,:), pointer :: ur_cell, vr_cell
@@ -1889,7 +1898,6 @@
 
 !-----------
 
-      !SHP-curvature
       r_earth = grid % sphere_radius
       ur_cell =&gt; diag % uReconstructZonal % array
       vr_cell =&gt; diag % uReconstructMeridional % array
@@ -1972,32 +1980,36 @@
       nVertLevels = grid % nVertLevels
       nVertices   = grid % nVertices
       nCellsSolve = grid % nCellsSolve
+      nEdgesSolve = grid % nEdgesSolve
 
       h_mom_eddy_visc2 = config_h_mom_eddy_visc2
-      h_mom_eddy_visc4 = config_h_mom_eddy_visc4
+!     h_mom_eddy_visc4 = config_h_mom_eddy_visc4
       v_mom_eddy_visc2 = config_v_mom_eddy_visc2
       h_theta_eddy_visc2 = config_h_theta_eddy_visc2
-      h_theta_eddy_visc4 = config_h_theta_eddy_visc4
+!     h_theta_eddy_visc4 = config_h_theta_eddy_visc4
       v_theta_eddy_visc2 = config_v_theta_eddy_visc2
 
+      nEdgesOnCell =&gt; grid % nEdgesOnCell % array
       nAdvCellsForEdge =&gt; grid % nAdvCellsForEdge % array
       advCellsForEdge =&gt; grid % advCellsForEdge % array
       adv_coefs =&gt; grid % adv_coefs % array
       adv_coefs_3rd =&gt; grid % adv_coefs_3rd % array
 
-      !
-      ! Compute u (normal) velocity tendency for each edge (cell face)
-      !
+      prandtl_inv = 1.0_RKIND/prandtl
 
       write(0,*) ' rk_step in compute_dyn_tend ',rk_step
 
 
       delsq_horiz_mixing = .false.
       if (config_horiz_mixing == &quot;2d_smagorinsky&quot; .and. (rk_step == 1 .or. rk_diffusion)) then
+
+         ! Smagorinsky eddy viscosity, based on horizontal deformation (in this case on model coordinate surfaces).
+         ! The integration coefficients were precomputed and stored in defc_a and defc_b
+
          do iCell = 1, nCells
             d_diag(:) = 0.
             d_off_diag(:) = 0.
-            do iEdge = 1, grid % nEdgesOnCell % array (iCell)
+            do iEdge = 1, nEdgesOnCell(iCell)
                do k=1, nVertLevels
                   d_diag(k)     = d_diag(k)     + defc_a(iEdge,iCell)*u(k,EdgesOnCell(iEdge,iCell))  &amp;
                                                 - defc_b(iEdge,iCell)*v(k,EdgesOnCell(iEdge,iCell))
@@ -2006,12 +2018,24 @@
                end do
             end do
             do k=1, nVertLevels
+               ! here is the Smagorinsky formulation, 
+               ! followed by imposition of an upper bound on the eddy viscosity
                kdiff(k,iCell) = (c_s * config_len_disp)**2 * sqrt(d_diag(k)**2 + d_off_diag(k)**2)
+               kdiff(k,iCell) = min(kdiff(k,iCell),(0.01*config_len_disp**2)/dt)
             end do
          end do
+!ldf (2012-10-10):
+         h_mom_eddy_visc4   = config_visc4_2dsmag * config_len_disp**3
+         h_theta_eddy_visc4 = h_mom_eddy_visc4
          delsq_horiz_mixing = .true.
+         write(0,*) '... config_visc4_2dsmag = ', config_visc4_2dsmag
+         write(0,*) '... h_mom_eddy_visc4    = ', h_mom_eddy_visc4
+         write(0,*) '... h_theta_eddy_visc4  = ', h_theta_eddy_visc4
       else if ( config_horiz_mixing == &quot;2d_fixed&quot;) then
+         h_mom_eddy_visc4   = config_h_mom_eddy_visc4
+         h_theta_eddy_visc4 = config_h_theta_eddy_visc4
          delsq_horiz_mixing = .true.
+!ldf (2012-10-10):
       end if
 
       tend_u(:,:) = 0.0
@@ -2020,157 +2044,162 @@
       cf2 = grid % cf2 % scalar
       cf3 = grid % cf3 % scalar
 
-      !  tendency for density
-      !  divergence_ru may calculated in the diagnostic subroutine - it is temporary
+      ! tendency for density.
+      ! accumulate total water here for later use in w tendency calculation.
+
       allocate(divergence_ru(nVertLevels, nCells+1))
       allocate(qtot(nVertLevels, nCells+1))
 
       divergence_ru(:,:) = 0.0
       h_divergence(:,:) = 0.
-      do iEdge=1,grid % nEdges
+
+      ! accumulate horizontal mass-flux
+
+      do iEdge=1,nEdges
          cell1 = cellsOnEdge(1,iEdge)
          cell2 = cellsOnEdge(2,iEdge)
          do k=1,nVertLevels
-           flux = ru(k,iEdge)*dvEdge(iEdge)
-           divergence_ru(k,cell1) = divergence_ru(k,cell1) + flux
-           divergence_ru(k,cell2) = divergence_ru(k,cell2) - flux
+            flux = ru(k,iEdge)*dvEdge(iEdge)
+            divergence_ru(k,cell1) = divergence_ru(k,cell1) + flux
+            divergence_ru(k,cell2) = divergence_ru(k,cell2) - flux
          end do
       end do
 
       qtot(:,:)=0.
+
+      ! compute horiontal mass-flux divergence, add vertical mass flux divergence to complete tend_rho
+
       do iCell = 1,nCells
-        r = 1.0 / areaCell(iCell)
-        do k = 1,nVertLevels
-           divergence_ru(k,iCell) = divergence_ru(k,iCell) * r
-           h_divergence(k,iCell) = divergence_ru(k,iCell)
-           tend_rho(k,iCell) = -divergence_ru(k,iCell)-rdzw(k)*(rw(k+1,iCell)-rw(k,iCell))
+         r = 1.0 / areaCell(iCell)
+         do k = 1,nVertLevels
+            divergence_ru(k,iCell) = divergence_ru(k,iCell) * r
+            h_divergence(k,iCell) = divergence_ru(k,iCell)
+            tend_rho(k,iCell) = -divergence_ru(k,iCell)-rdzw(k)*(rw(k+1,iCell)-rw(k,iCell))
 
-           do iq = s % moist_start, s % moist_end
-              qtot(k,iCell) = qtot(k,iCell) + s % scalars % array (iq, k, iCell)
-           end do
+            do iq = s % moist_start, s % moist_end
+               qtot(k,iCell) = qtot(k,iCell) + s % scalars % array (iq, k, iCell)
+            end do
 
-        end do
+         end do
       end do    
 
-!****       u dyn tend
+      !
+      ! Compute u (normal) velocity tendency for each edge (cell face)
+      !
 
-         do iEdge=1,grid % nEdgesSolve
-            cell1 = cellsOnEdge(1,iEdge)
-            cell2 = cellsOnEdge(2,iEdge)
+      do iEdge=1,nEdgesSolve
 
-           if(newpx)  then
+         cell1 = cellsOnEdge(1,iEdge)
+         cell2 = cellsOnEdge(2,iEdge)
 
-               k = 1
-               pr  = cpr(k,iEdge)*pp(k,cell2)+cpr(k+1,iEdge)*pp(k+1,cell2)+cpr(k+2,iEdge)*pp(k+2,cell2)
-               pl  = cpl(k,iEdge)*pp(k,cell1)+cpl(k+1,iEdge)*pp(k+1,cell1)+cpl(k+2,iEdge)*pp(k+2,cell1)
-               tend_u(k,iEdge) =  - cqu(k,iEdge)*2./(zz(k,cell1)+zz(k,cell2))*(pr-pl)/dcEdge(iEdge)
+         ! horizontal pressure gradient 
 
-               do k=2,nVertLevels
+         if (newpx)  then
 
-                  kr = min(nVertLevels,k+ nint(.5-sign(0.5_RKIND,zx(k,iEdge)+zx(k+1,iEdge))))
-                  kl = min(nVertLevels,2*k+1-kr)
+            k = 1
+            pr  = cpr(k,iEdge)*pp(k,cell2)+cpr(k+1,iEdge)*pp(k+1,cell2)+cpr(k+2,iEdge)*pp(k+2,cell2)
+            pl  = cpl(k,iEdge)*pp(k,cell1)+cpl(k+1,iEdge)*pp(k+1,cell1)+cpl(k+2,iEdge)*pp(k+2,cell1)
+            tend_u(k,iEdge) =  - cqu(k,iEdge)*2./(zz(k,cell1)+zz(k,cell2))*(pr-pl)/dcEdge(iEdge)
 
-                  pr = pp(k,cell2)+.5*(zgrid(k   ,cell1)+zgrid(k +1,cell1)-zgrid(k ,cell2)-zgrid(k +1,cell2))   &amp;
-                                     /(zgrid(kr+1,cell2)-zgrid(kr-1,cell2))*( pp(kr,cell2)-pp   (kr-1,cell2))
-                  pl = pp(k,cell1)+.5*(zgrid(k   ,cell2)+zgrid(k +1,cell2)-zgrid(k ,cell1)-zgrid(k +1,cell1))   &amp;
-                                     /(zgrid(kl+1,cell1)-zgrid(kl-1,cell1))*( pp(kl,cell1)-pp   (kl-1,cell1))
-                  tend_u(k,iEdge) =  - cqu(k,iEdge)*2./(zz(k,cell1)+zz(k,cell2))*(pr-pl)/dcEdge(iEdge)
+            do k=2,nVertLevels
 
-               end do
+               kr = min(nVertLevels,k+ nint(.5-sign(0.5_RKIND,zx(k,iEdge)+zx(k+1,iEdge))))
+               kl = min(nVertLevels,2*k+1-kr)
 
-            else
-               k = 1
-!!              dpzx(k) = .5*zx(k,iEdge)*(cf1*(pp(k  ,cell2)+pp(k  ,cell1))   &amp;
-!!                                       +cf2*(pp(k+1,cell2)+pp(k+1,cell1))   &amp;
-!!                                       +cf3*(pp(k+2,cell2)+pp(k+2,cell1)))
+               pr = pp(k,cell2)+.5*(zgrid(k   ,cell1)+zgrid(k +1,cell1)-zgrid(k ,cell2)-zgrid(k +1,cell2))   &amp;
+                                  /(zgrid(kr+1,cell2)-zgrid(kr-1,cell2))*( pp(kr,cell2)-pp   (kr-1,cell2))
+               pl = pp(k,cell1)+.5*(zgrid(k   ,cell2)+zgrid(k +1,cell2)-zgrid(k ,cell1)-zgrid(k +1,cell1))   &amp;
+                                  /(zgrid(kl+1,cell1)-zgrid(kl-1,cell1))*( pp(kl,cell1)-pp   (kl-1,cell1))
+               tend_u(k,iEdge) =  - cqu(k,iEdge)*2./(zz(k,cell1)+zz(k,cell2))*(pr-pl)/dcEdge(iEdge)
 
-               dpzx(k) = .25*(zx(k,iEdge)+zx(k+1,iEdge))                  &amp;
-                            *(pzm(k,cell2)*(pp(k+1,cell2)-pp(k,cell2))    &amp;
-                             +pzm(k,cell1)*(pp(k+1,cell1)-pp(k,cell1))    &amp;
-                             +pzp(k,cell2)*(pp(k+2,cell2)-pp(k,cell2))    &amp;
-                             +pzp(k,cell1)*(pp(k+2,cell1)-pp(k,cell1))) 
-  
-               do k = 2, nVertLevels-1
+            end do
 
-!!              dpzx(k) = .5*zx(k,iEdge)*(fzm(k)*(pp(k  ,cell2)+pp(k  ,cell1))  &amp;
-!!                                   +fzp(k)*(pp(k-1,cell2)+pp(k-1,cell1)))
+         else
+            k = 1
 
-                  dpzx(k) = .25*(zx(k,iEdge)+zx(k+1,iEdge))                  &amp;
-                             *(pzp(k,cell2)*(pp(k+1,cell2)-pp(k  ,cell2))    &amp;
-                              +pzm(k,cell2)*(pp(k  ,cell2)-pp(k-1,cell2))    &amp;
-                              +pzp(k,cell1)*(pp(k+1,cell1)-pp(k  ,cell1))    &amp;
-                              +pzm(k,cell1)*(pp(k  ,cell1)-pp(k-1,cell1)))   
+            dpzx(k) = .25*(zx(k,iEdge)+zx(k+1,iEdge))                  &amp;
+                         *(pzm(k,cell2)*(pp(k+1,cell2)-pp(k,cell2))    &amp;
+                          +pzm(k,cell1)*(pp(k+1,cell1)-pp(k,cell1))    &amp;
+                          +pzp(k,cell2)*(pp(k+2,cell2)-pp(k,cell2))    &amp;
+                          +pzp(k,cell1)*(pp(k+2,cell1)-pp(k,cell1))) 
+  
+            do k = 2, nVertLevels-1
 
-               end do
-
-               k = nVertLevels
                dpzx(k) = .25*(zx(k,iEdge)+zx(k+1,iEdge))                  &amp;
-                          *(pzm(k,cell2)*(pp(k  ,cell2)-pp(k-1,cell2))    &amp;
+                          *(pzp(k,cell2)*(pp(k+1,cell2)-pp(k  ,cell2))    &amp;
+                           +pzm(k,cell2)*(pp(k  ,cell2)-pp(k-1,cell2))    &amp;
+                           +pzp(k,cell1)*(pp(k+1,cell1)-pp(k  ,cell1))    &amp;
                            +pzm(k,cell1)*(pp(k  ,cell1)-pp(k-1,cell1)))   
 
-!!               dpzx(nVertLevels+1) = 0.
+            end do
 
-               do k=1,nVertLevels
+            k = nVertLevels
+            dpzx(k) = .25*(zx(k,iEdge)+zx(k+1,iEdge))                  &amp;
+                       *(pzm(k,cell2)*(pp(k  ,cell2)-pp(k-1,cell2))    &amp;
+                        +pzm(k,cell1)*(pp(k  ,cell1)-pp(k-1,cell1)))   
 
-!!                  tend_u(k,iEdge) =  - cqu(k,iEdge)*( (pp(k,cell2)/zz(k,cell2) - pp(k,cell1)/zz(k,cell1))  &amp;
-!!                                                   /  dcEdge(iEdge) - rdzw(k)*(dpzx(k+1)-dpzx(k)) )
+            do k=1,nVertLevels
 
-                  tend_u(k,iEdge) =  - cqu(k,iEdge)*((pp(k,cell2)-pp(k,cell1))/dcEdge(iEdge)   &amp;
-                                          - dpzx(k) ) / (.5*(zz(k,cell2)+zz(k,cell1)))
-               end do
+               tend_u(k,iEdge) =  - cqu(k,iEdge)*((pp(k,cell2)-pp(k,cell1))/dcEdge(iEdge)   &amp;
+                                       - dpzx(k) ) / (.5*(zz(k,cell2)+zz(k,cell1)))
+            end do
 
-            end if
+         end if
 
-            wduz(1) = 0.
-            k = 2
-            wduz(k) =  0.5*( rw(k,cell1)+rw(k,cell2) )*(fzm(k)*u(k,iEdge)+fzp(k)*u(k-1,iEdge))  
-            do k=3,nVertLevels-1
-               wduz(k) = flux3( u(k-2,iEdge),u(k-1,iEdge),u(k,iEdge),u(k+1,iEdge),0.5*(rw(k,cell1)+rw(k,cell2)), 1.0_RKIND )
-            end do
-            k = nVertLevels
-            wduz(k) =  0.5*( rw(k,cell1)+rw(k,cell2) )*(fzm(k)*u(k,iEdge)+fzp(k)*u(k-1,iEdge))  
+         ! vertical transport of u
 
-            wduz(nVertLevels+1) = 0.
+         wduz(1) = 0.
+         k = 2
+         wduz(k) =  0.5*( rw(k,cell1)+rw(k,cell2) )*(fzm(k)*u(k,iEdge)+fzp(k)*u(k-1,iEdge))  
+         do k=3,nVertLevels-1
+            wduz(k) = flux3( u(k-2,iEdge),u(k-1,iEdge),u(k,iEdge),u(k+1,iEdge),0.5*(rw(k,cell1)+rw(k,cell2)), 1.0_RKIND )
+         end do
+         k = nVertLevels
+         wduz(k) =  0.5*( rw(k,cell1)+rw(k,cell2) )*(fzm(k)*u(k,iEdge)+fzp(k)*u(k-1,iEdge))  
 
+         wduz(nVertLevels+1) = 0.
+
+         do k=1,nVertLevels
+            tend_u(k,iEdge) = tend_u(k,iEdge) - rdzw(k)*(wduz(k+1)-wduz(k)) 
+         end do
+
+         ! Next, nonlinear Coriolis term (q) following Ringler et al JCP 2009
+
+         q(:) = 0.0
+         do j = 1,nEdgesOnEdge(iEdge)
+            eoe = edgesOnEdge(j,iEdge)
             do k=1,nVertLevels
-!               tend_u(k,iEdge) =  - cqu(k,iEdge)*( (pp(k,cell2)/zz(k,cell2) - pp(k,cell1)/zz(k,cell1))  &amp;
-!                                                /  dcEdge(iEdge) - rdzw(k)*(dpzx(k+1)-dpzx(k)) )
-               tend_u(k,iEdge) = tend_u(k,iEdge) - rdzw(k)*(wduz(k+1)-wduz(k)) 
+               workpv = 0.5 * (pv_edge(k,iEdge) + pv_edge(k,eoe))
+               q(k) = q(k) + weightsOnEdge(j,iEdge) * u(k,eoe) * workpv * rho_edge(k,eoe)
             end do
+         end do
 
-               q(:) = 0.0
-               do j = 1,nEdgesOnEdge(iEdge)
-                 eoe = edgesOnEdge(j,iEdge)
-                 do k=1,nVertLevels
-                   workpv = 0.5 * (pv_edge(k,iEdge) + pv_edge(k,eoe))
-                   q(k) = q(k) + weightsOnEdge(j,iEdge) * u(k,eoe) * workpv * rho_edge(k,eoe)
-                 end do
-               end do
+         do k=1,nVertLevels
 
-            do k=1,nVertLevels
-               tend_u(k,iEdge) = tend_u(k,iEdge) + rho_edge(k,iEdge)* (q(k) - (ke(k,cell2) - ke(k,cell1))       &amp;
-                                                                    / dcEdge(iEdge))                            &amp;
-                                                - u(k,iEdge)*0.5*(divergence_ru(k,cell1)+divergence_ru(k,cell2)) 
-               !SHP-curvature
-               if (curvature) then
+            ! horizontal ke gradient and vorticity terms in the vector invariant formulation
+            ! of the horizontal momentum equation
+            tend_u(k,iEdge) = tend_u(k,iEdge) + rho_edge(k,iEdge)* (q(k) - (ke(k,cell2) - ke(k,cell1))       &amp;
+                                                                 / dcEdge(iEdge))                            &amp;
+                                             - u(k,iEdge)*0.5*(divergence_ru(k,cell1)+divergence_ru(k,cell2)) 
+            if (curvature) then
+
+               ! curvature terms for the sphere
+
                tend_u(k,iEdge) = tend_u(k,iEdge) &amp;
                                 - 2.*omega*cos(grid % angleEdge % array(iEdge))*cos(grid % latEdge % array(iEdge))  &amp;
                                   *rho_edge(k,iEdge)*.25*(w(k,cell1)+w(k+1,cell1)+w(k,cell2)+w(k+1,cell2))          &amp; 
                                 - u(k,iEdge)*.25*(w(k+1,cell1)+w(k,cell1)+w(k,cell2)+w(k+1,cell2))                  &amp;
                                   *rho_edge(k,iEdge)/r_earth
-               !old-err.
-               !tend_u(k,iEdge) = tend_u(k,iEdge) &amp;
-               !                 - 2.*omega_e*cos(grid % angleEdge % array(iEdge))*cos(grid % latEdge % array(iEdge))  &amp;
-               !                   *.25*(rw(k,cell1)+rw(k+1,cell1)+rw(k,cell2)+rw(k+1,cell2))                          &amp;
-               !                 - u(k,iEdge)*.25*(rw(k+1,cell1)+rw(k,cell1)+rw(k,cell2)+rw(k+1,cell2))/r_earth
-               end if
-            end do
+            end if
          end do
+      end do
 
       deallocate(divergence_ru)
 
       !
       !  horizontal mixing for u
+      !  mixing terms are integrated using forward-Euler, so this tendency is only computed in the
+      !  first Runge-Kutta substep and saved for use in later RK substeps 2 and 3.
       !
 
       if (rk_step == 1 .or. rk_diffusion) then
@@ -2179,57 +2208,63 @@
 
       if (delsq_horiz_mixing) then
 
-        if (h_mom_eddy_visc2 &gt; 0.0) then
-           do iEdge=1,grid % nEdgesSolve
-              cell1 = cellsOnEdge(1,iEdge)
-              cell2 = cellsOnEdge(2,iEdge)
-              vertex1 = verticesOnEdge(1,iEdge)
-              vertex2 = verticesOnEdge(2,iEdge)
+         if ((h_mom_eddy_visc2 &gt; 0.0) .and. (config_horiz_mixing == &quot;2d_fixed&quot;)) then
+            do iEdge=1, nEdgesSolve
+               cell1 = cellsOnEdge(1,iEdge)
+               cell2 = cellsOnEdge(2,iEdge)
+               vertex1 = verticesOnEdge(1,iEdge)
+               vertex2 = verticesOnEdge(2,iEdge)
+   
+               do k=1,nVertLevels
   
-              do k=1,nVertLevels
+                  !
+                  ! Compute diffusion, computed as </font>
<font color="black">abla divergence - k \times </font>
<font color="red">abla vorticity
+                  !                    only valid for h_mom_eddy_visc2 == constant
+                  !
+                  ! Note that we impose a lower bound on the edge length used in the derivative of the vorticity;
+                  ! this is done to avoid an overly stringent stability constraint for small edge lengths that can
+                  ! occur on some variable-resolution meshes.
+                  !
+                  u_diffusion =   ( divergence(k,cell2)  - divergence(k,cell1) ) / dcEdge(iEdge)  &amp;
+                                 -( vorticity(k,vertex2) - vorticity(k,vertex1) ) / max(dvEdge(iEdge),0.25*dcEdge(iEdge))
+                  u_diffusion = rho_edge(k,iEdge)*h_mom_eddy_visc2 * u_diffusion
+                  u_diffusion = u_diffusion * meshScalingDel2(iEdge)
   
-                 !
-                 ! Compute diffusion, computed as </font>
<font color="black">abla divergence - k \times </font>
<font color="red">abla vorticity
-                 !                    only valid for h_mom_eddy_visc2 == constant
-                 !
-                 u_diffusion =   ( divergence(k,cell2)  - divergence(k,cell1) ) / dcEdge(iEdge)  &amp;
-                                -( vorticity(k,vertex2) - vorticity(k,vertex1) ) / dvEdge(iEdge)
-                 u_diffusion = rho_edge(k,iEdge)*h_mom_eddy_visc2 * u_diffusion
-                 u_diffusion = u_diffusion * meshScalingDel2(iEdge)
-  
-!                 tend_u(k,iEdge) = tend_u(k,iEdge) + u_diffusion
-                 tend_u_euler(k,iEdge) = tend_u_euler(k,iEdge) + u_diffusion
-              end do
-           end do
+                  tend_u_euler(k,iEdge) = tend_u_euler(k,iEdge) + u_diffusion
+               end do
+            end do
 
-        else if ( config_horiz_mixing == &quot;2d_smagorinsky&quot;) then
+         else if ( config_horiz_mixing == &quot;2d_smagorinsky&quot;) then
 
-           do iEdge=1,grid % nEdgesSolve
-              cell1 = cellsOnEdge(1,iEdge)
-              cell2 = cellsOnEdge(2,iEdge)
-              vertex1 = verticesOnEdge(1,iEdge)
-              vertex2 = verticesOnEdge(2,iEdge)
+            do iEdge=1, nEdgesSolve
+               cell1 = cellsOnEdge(1,iEdge)
+               cell2 = cellsOnEdge(2,iEdge)
+               vertex1 = verticesOnEdge(1,iEdge)
+               vertex2 = verticesOnEdge(2,iEdge)

+               do k=1,nVertLevels
+                  !
+                  ! Compute diffusion, computed as </font>
<font color="black">abla divergence - k \times </font>
<font color="red">abla vorticity
+                  !                    only valid for h_mom_eddy_visc2 == constant
+                  !
+                  u_diffusion =   ( divergence(k,cell2)  - divergence(k,cell1) ) / dcEdge(iEdge)  &amp;
+                                 -( vorticity(k,vertex2) - vorticity(k,vertex1) ) / max(dvEdge(iEdge),0.25*dcEdge(iEdge))
+                  u_diffusion = rho_edge(k,iEdge)* 0.5*(kdiff(k,cell1)+kdiff(k,cell2)) * u_diffusion
+                  u_diffusion = u_diffusion * meshScalingDel2(iEdge)

+                  tend_u_euler(k,iEdge) = tend_u_euler(k,iEdge) + u_diffusion
+               end do
+            end do
+         end if
 
-              do k=1,nVertLevels
-                 !
-                 ! Compute diffusion, computed as </font>
<font color="black">abla divergence - k \times </font>
<font color="gray">abla vorticity
-                 !                    only valid for h_mom_eddy_visc2 == constant
-                 !
-                 u_diffusion =   ( divergence(k,cell2)  - divergence(k,cell1) ) / dcEdge(iEdge)  &amp;
-                                -( vorticity(k,vertex2) - vorticity(k,vertex1) ) / dvEdge(iEdge)
-                 u_diffusion = rho_edge(k,iEdge)* 0.5*(kdiff(k,cell1)+kdiff(k,cell2)) * u_diffusion
-                 u_diffusion = u_diffusion * meshScalingDel2(iEdge)
+      end if ! delsq_horiz_mixing for u
 
-!                 tend_u(k,iEdge) = tend_u(k,iEdge) + u_diffusion
-                 tend_u_euler(k,iEdge) = tend_u_euler(k,iEdge) + u_diffusion
-              end do
-           end do
-        end if
+      if ((h_mom_eddy_visc4 &gt; 0.0 .and. config_horiz_mixing == &quot;2d_fixed&quot;) .or. &amp;
+          (h_mom_eddy_visc4 &gt; 0.0 .and. config_horiz_mixing == &quot;2d_smagorinsky&quot;)) then
 
-      end if ! delsq_horiz_mixing for u
+         ! del^4 horizontal filter.  We compute this as del^2 ( del^2 (u) ).
+         ! First, storage to hold the result from the first del^2 computation.
 
-      if ( h_mom_eddy_visc4 &gt; 0.0 ) then
-
          allocate(delsq_divergence(nVertLevels, nCells+1))
          allocate(delsq_u(nVertLevels, nEdges+1))
          allocate(delsq_circulation(nVertLevels, nVertices+1))
@@ -2237,7 +2272,7 @@
 
          delsq_u(:,:) = 0.0
 
-         do iEdge=1,grid % nEdges
+         do iEdge=1, nEdges
             cell1 = cellsOnEdge(1,iEdge)
             cell2 = cellsOnEdge(2,iEdge)
             vertex1 = verticesOnEdge(1,iEdge)
@@ -2258,10 +2293,10 @@
 
          delsq_circulation(:,:) = 0.0
          do iEdge=1,nEdges
-               do k=1,nVertLevels
-                  delsq_circulation(k,verticesOnEdge(1,iEdge)) = delsq_circulation(k,verticesOnEdge(1,iEdge)) - dcEdge(iEdge) * delsq_u(k,iEdge)
-                  delsq_circulation(k,verticesOnEdge(2,iEdge)) = delsq_circulation(k,verticesOnEdge(2,iEdge)) + dcEdge(iEdge) * delsq_u(k,iEdge)
-               end do
+            do k=1,nVertLevels
+               delsq_circulation(k,verticesOnEdge(1,iEdge)) = delsq_circulation(k,verticesOnEdge(1,iEdge)) - dcEdge(iEdge) * delsq_u(k,iEdge)
+               delsq_circulation(k,verticesOnEdge(2,iEdge)) = delsq_circulation(k,verticesOnEdge(2,iEdge)) + dcEdge(iEdge) * delsq_u(k,iEdge)
+            end do
          end do
          do iVertex=1,nVertices
             r = 1.0 / areaTriangle(iVertex)
@@ -2274,10 +2309,10 @@
          do iEdge=1,nEdges
             cell1 = cellsOnEdge(1,iEdge)
             cell2 = cellsOnEdge(2,iEdge)
-               do k=1,nVertLevels
-                 delsq_divergence(k,cell1) = delsq_divergence(k,cell1) + delsq_u(k,iEdge)*dvEdge(iEdge)
-                 delsq_divergence(k,cell2) = delsq_divergence(k,cell2) - delsq_u(k,iEdge)*dvEdge(iEdge)
-               end do
+            do k=1,nVertLevels
+               delsq_divergence(k,cell1) = delsq_divergence(k,cell1) + delsq_u(k,iEdge)*dvEdge(iEdge)
+               delsq_divergence(k,cell2) = delsq_divergence(k,cell2) - delsq_u(k,iEdge)*dvEdge(iEdge)
+            end do
          end do
          do iCell = 1,nCells
             r = 1.0 / areaCell(iCell)
@@ -2286,7 +2321,7 @@
             end do
          end do
 
-         do iEdge=1,grid % nEdgesSolve
+         do iEdge=1,nEdgesSolve
             cell1 = cellsOnEdge(1,iEdge)
             cell2 = cellsOnEdge(2,iEdge)
             vertex1 = verticesOnEdge(1,iEdge)
@@ -2298,11 +2333,14 @@
                ! Compute diffusion, computed as </font>
<font color="black">abla divergence - k \times </font>
<font color="gray">abla vorticity
                !                    only valid for h_mom_eddy_visc4 == constant
                !
-               u_diffusion =  rho_edge(k,iEdge) * (  ( delsq_divergence(k,cell2)  - delsq_divergence(k,cell1) ) / dcEdge(iEdge)  &amp;
+               ! Here, we scale the diffusion on the divergence part a factor of config_del4u_div_factor 
+               !    relative to the rotational part.  The stability constraint on the divergence component is much less
+               !    stringent than the rotational part, and this flexibility may be useful.
+               !
+               u_diffusion =  rho_edge(k,iEdge) * ( config_del4u_div_factor * ( delsq_divergence(k,cell2)  - delsq_divergence(k,cell1) ) / dcEdge(iEdge)  &amp;
                            -( delsq_vorticity(k,vertex2) - delsq_vorticity(k,vertex1) ) / max(dvEdge(iEdge), 0.25*dcEdge(iEdge)) &amp;
                                                   )
 
-!               tend_u(k,iEdge) = tend_u(k,iEdge) - h_mom_eddy_visc4 * u_diffusion
                u_diffusion = u_diffusion * meshScalingDel4(iEdge)
                tend_u_euler(k,iEdge) = tend_u_euler(k,iEdge) - h_mom_eddy_visc4 * u_diffusion
             end do
@@ -2316,71 +2354,65 @@
       end if
 
       !
-      !  vertical mixing for u - 2nd order 
+      !  vertical mixing for u - 2nd order filter in physical (z) space
       !
       if ( v_mom_eddy_visc2 &gt; 0.0 ) then
 
          if (config_mix_full) then
 
-         do iEdge=1,grid % nEdgesSolve
+            do iEdge=1,nEdgesSolve
 
-            cell1 = cellsOnEdge(1,iEdge)
-            cell2 = cellsOnEdge(2,iEdge)
+               cell1 = cellsOnEdge(1,iEdge)
+               cell2 = cellsOnEdge(2,iEdge)
 
-            do k=2,nVertLevels-1
+               do k=2,nVertLevels-1
 
-               z1 = 0.5*(zgrid(k-1,cell1)+zgrid(k-1,cell2))
-               z2 = 0.5*(zgrid(k  ,cell1)+zgrid(k  ,cell2))
-               z3 = 0.5*(zgrid(k+1,cell1)+zgrid(k+1,cell2))
-               z4 = 0.5*(zgrid(k+2,cell1)+zgrid(k+2,cell2))
+                  z1 = 0.5*(zgrid(k-1,cell1)+zgrid(k-1,cell2))
+                  z2 = 0.5*(zgrid(k  ,cell1)+zgrid(k  ,cell2))
+                  z3 = 0.5*(zgrid(k+1,cell1)+zgrid(k+1,cell2))
+                  z4 = 0.5*(zgrid(k+2,cell1)+zgrid(k+2,cell2))
 
-               zm = 0.5*(z1+z2)
-               z0 = 0.5*(z2+z3)
-               zp = 0.5*(z3+z4)
+                  zm = 0.5*(z1+z2)
+                  z0 = 0.5*(z2+z3)
+                  zp = 0.5*(z3+z4)
 
-!               tend_u(k,iEdge) = tend_u(k,iEdge) + rho_edge(k,iEdge) * v_mom_eddy_visc2*(  &amp;
-!                                  (u(k+1,iEdge)-u(k  ,iEdge))/(zp-z0)                      &amp;
-!                                 -(u(k  ,iEdge)-u(k-1,iEdge))/(z0-zm) )/(0.5*(zp-zm))
-               tend_u_euler(k,iEdge) = tend_u_euler(k,iEdge) + rho_edge(k,iEdge) * v_mom_eddy_visc2*(  &amp;
-                                  (u(k+1,iEdge)-u(k  ,iEdge))/(zp-z0)                      &amp;
-                                 -(u(k  ,iEdge)-u(k-1,iEdge))/(z0-zm) )/(0.5*(zp-zm))
+                  tend_u_euler(k,iEdge) = tend_u_euler(k,iEdge) + rho_edge(k,iEdge) * v_mom_eddy_visc2*(  &amp;
+                                     (u(k+1,iEdge)-u(k  ,iEdge))/(zp-z0)                      &amp;
+                                    -(u(k  ,iEdge)-u(k-1,iEdge))/(z0-zm) )/(0.5*(zp-zm))
+               end do
             end do
-         end do
 
          else  ! idealized cases where we mix on the perturbation from the initial 1-D state
 
-         do iEdge=1,grid % nEdgesSolve
+            do iEdge=1,nEdgesSolve
 
-            cell1 = cellsOnEdge(1,iEdge)
-            cell2 = cellsOnEdge(2,iEdge)
+               cell1 = cellsOnEdge(1,iEdge)
+               cell2 = cellsOnEdge(2,iEdge)
 
-            do k=1,nVertLevels
+               do k=1,nVertLevels
 #ifdef ROTATED_GRID
-              u_mix(k) = u(k,iEdge) - grid % u_init % array(k) * sin( grid % angleEdge % array(iEdge) )
+                  u_mix(k) = u(k,iEdge) - grid % u_init % array(k) * sin( grid % angleEdge % array(iEdge) )
 #else
-              u_mix(k) = u(k,iEdge) - grid % u_init % array(k) * cos( grid % angleEdge % array(iEdge) )
+                  u_mix(k) = u(k,iEdge) - grid % u_init % array(k) * cos( grid % angleEdge % array(iEdge) )
 #endif
-            end do
+               end do
 
-            do k=2,nVertLevels-1
+               do k=2,nVertLevels-1
 
-               z1 = 0.5*(zgrid(k-1,cell1)+zgrid(k-1,cell2))
-               z2 = 0.5*(zgrid(k  ,cell1)+zgrid(k  ,cell2))
-               z3 = 0.5*(zgrid(k+1,cell1)+zgrid(k+1,cell2))
-               z4 = 0.5*(zgrid(k+2,cell1)+zgrid(k+2,cell2))
+                  z1 = 0.5*(zgrid(k-1,cell1)+zgrid(k-1,cell2))
+                  z2 = 0.5*(zgrid(k  ,cell1)+zgrid(k  ,cell2))
+                  z3 = 0.5*(zgrid(k+1,cell1)+zgrid(k+1,cell2))
+                  z4 = 0.5*(zgrid(k+2,cell1)+zgrid(k+2,cell2))
 
-               zm = 0.5*(z1+z2)
-               z0 = 0.5*(z2+z3)
-               zp = 0.5*(z3+z4)
+                  zm = 0.5*(z1+z2)
+                  z0 = 0.5*(z2+z3)
+                  zp = 0.5*(z3+z4)
 
-               tend_u_euler(k,iEdge) = tend_u_euler(k,iEdge) + rho_edge(k,iEdge) * v_mom_eddy_visc2*(  &amp;
-                                  (u_mix(k+1)-u_mix(k  ))/(zp-z0)                      &amp;
-                                 -(u_mix(k  )-u_mix(k-1))/(z0-zm) )/(0.5*(zp-zm))
-!               tend_u(k,iEdge) = tend_u(k,iEdge) + rho_edge(k,iEdge) * v_mom_eddy_visc2*(  &amp;
-!                                  (u_mix(k+1)-u_mix(k  ))/(zp-z0)                      &amp;
-!                                 -(u_mix(k  )-u_mix(k-1))/(z0-zm) )/(0.5*(zp-zm))
+                  tend_u_euler(k,iEdge) = tend_u_euler(k,iEdge) + rho_edge(k,iEdge) * v_mom_eddy_visc2*(  &amp;
+                                     (u_mix(k+1)-u_mix(k  ))/(zp-z0)                      &amp;
+                                    -(u_mix(k  )-u_mix(k-1))/(z0-zm) )/(0.5*(zp-zm))
+               end do
             end do
-         end do
 
          end if
 
@@ -2390,7 +2422,7 @@
 
 !  add in mixing for u
 
-      do iEdge=1,grid % nEdgesSolve
+      do iEdge=1,nEdgesSolve
          do k=1,nVertLevels
             tend_u(k,iEdge) = tend_u(k,iEdge) + tend_u_euler(k,iEdge)
          end do
@@ -2410,7 +2442,7 @@
             cell1 = cellsOnEdge(1,iEdge)
             cell2 = cellsOnEdge(2,iEdge)
             if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
-               do k=2,grid % nVertLevels
+               do k=2,nVertLevels
                   flux = dvEdge(iEdge) * (fzm(k)*ru(k,iEdge) + fzp(k)*ru(k-1,iEdge) ) &amp;
                                         *(w(k,cell1) + w(k,cell2))*0.5 
                   tend_w(k,cell1) = tend_w(k,cell1) - flux
@@ -2426,53 +2458,27 @@
             cell2 = cellsOnEdge(2,iEdge)
             if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
 
-               do k=2,grid % nVertLevels
-                 ru_edge_w(k) = fzm(k)*ru(k,iEdge) + fzp(k)*ru(k-1,iEdge)
+               do k=2,nVertLevels
+                  ru_edge_w(k) = fzm(k)*ru(k,iEdge) + fzp(k)*ru(k-1,iEdge)
                end do
 
                flux_arr(:) = 0.
+
+               ! flux_arr stores the value of w at the cell edge used in the horizontal transport
+
                do i=1,nAdvCellsForEdge(iEdge)
-                 iCell = advCellsForEdge(i,iEdge)
-                 do k=2,grid % nVertLevels
-                   scalar_weight = adv_coefs(i,iEdge) + coef_3rd_order*sign(1.0_RKIND,ru_edge_w(k))*adv_coefs_3rd(i,iEdge)
-                   flux_arr(k) = flux_arr(k) + scalar_weight* w(k,iCell)
-                 end do
+                  iCell = advCellsForEdge(i,iEdge)
+                  do k=2,nVertLevels
+                     scalar_weight = adv_coefs(i,iEdge) + coef_3rd_order*sign(1.0_RKIND,ru_edge_w(k))*adv_coefs_3rd(i,iEdge)
+                     flux_arr(k) = flux_arr(k) + scalar_weight* w(k,iCell)
+                  end do
                end do
 
-               do k=1,grid % nVertLevels
+               do k=1,nVertLevels
                   tend_w(k,cell1) = tend_w(k,cell1) - ru_edge_w(k)*flux_arr(k)
                   tend_w(k,cell2) = tend_w(k,cell2) + ru_edge_w(k)*flux_arr(k)
                end do
 
-!               do k=2,grid % nVertLevels
-!
-!                  d2fdx2_cell1 = deriv_two(1,1,iEdge) * w(k,cell1)
-!                  d2fdx2_cell2 = deriv_two(1,2,iEdge) * w(k,cell2)
-!                  do i=1, grid % nEdgesOnCell % array (cell1)
-!                     if ( grid % CellsOnCell % array (i,cell1) &lt;= grid%nCells) &amp;
-!                     d2fdx2_cell1 = d2fdx2_cell1 + deriv_two(i+1,1,iEdge) * w(k,grid % CellsOnCell % array (i,cell1))
-!                  end do
-!                  do i=1, grid % nEdgesOnCell % array (cell2)
-!                     if ( grid % CellsOnCell % array (i,cell2) &lt;= grid%nCells) &amp;
-!                     d2fdx2_cell2 = d2fdx2_cell2 + deriv_two(i+1,2,iEdge) * w(k,grid % CellsOnCell % array (i,cell2))
-!                  end do
-!
-!  3rd order stencil
-!                  if( u(k,iEdge)+u(k-1,iEdge) &gt; 0) then
-!                     flux = dvEdge(iEdge) * (fzm(k)*ru(k,iEdge) + fzp(k)*ru(k-1,iEdge))*(  &amp;
-!                                             0.5*(w(k,cell1) + w(k,cell2))                 &amp;
-!                                            -(dcEdge(iEdge) **2) * (d2fdx2_cell1) / 6. )
-!                  else
-!                     flux = dvEdge(iEdge) * (fzm(k)*ru(k,iEdge) + fzp(k)*ru(k-1,iEdge))*(  &amp;
-!                                             0.5*(w(k,cell1) + w(k,cell2))                 &amp;
-!                                            -(dcEdge(iEdge) **2) * (d2fdx2_cell2) / 6. )
-!                  end if
-!
-!                  tend_w(k,cell1) = tend_w(k,cell1) - flux
-!                  tend_w(k,cell2) = tend_w(k,cell2) + flux
-!
-!               end do
-
             end if
          end do
 
@@ -2483,16 +2489,16 @@
             cell2 = cellsOnEdge(2,iEdge)
             if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
 
-               do k=2,grid % nVertLevels
+               do k=2,nVertLevels
 
                   d2fdx2_cell1 = deriv_two(1,1,iEdge) * w(k,cell1)
                   d2fdx2_cell2 = deriv_two(1,2,iEdge) * w(k,cell2)
-                  do i=1, grid % nEdgesOnCell % array (cell1)
-                     if ( grid % CellsOnCell % array (i,cell1) &lt;= grid%nCells) &amp;
+                  do i=1, nEdgesOnCell(cell1)
+                     if ( grid % CellsOnCell % array (i,cell1) &lt;= nCells) &amp;
                      d2fdx2_cell1 = d2fdx2_cell1 + deriv_two(i+1,1,iEdge) * w(k,grid % CellsOnCell % array (i,cell1))
                   end do
-                  do i=1, grid % nEdgesOnCell % array (cell2)
-                     if ( grid % CellsOnCell % array (i,cell2) &lt;= grid%nCells) &amp;
+                  do i=1, nEdgesOnCell(cell2)
+                     if ( grid % CellsOnCell % array (i,cell2) &lt;= nCells) &amp;
                      d2fdx2_cell2 = d2fdx2_cell2 + deriv_two(i+1,2,iEdge) * w(k,grid % CellsOnCell % array (i,cell2))
                   end do
 
@@ -2509,10 +2515,9 @@
          end do
       end if
 
-      !SHP-curvature
       if (curvature) then
 
-         do iCell = 1, grid % nCellsSolve
+         do iCell = 1, nCellsSolve
             do k=2,nVertLevels
                tend_w(k,iCell) = tend_w(k,iCell) + (rho_zz(k,iCell)*fzm(k)+rho_zz(k-1,iCell)*fzp(k))*          &amp;
                                          ( (fzm(k)*ur_cell(k,iCell)+fzp(k)*ur_cell(k-1,iCell))**2.             &amp;
@@ -2521,12 +2526,6 @@
                                           *(fzm(k)*ur_cell(k,iCell)+fzp(k)*ur_cell(k-1,iCell))                 &amp;
                                           *(rho_zz(k,iCell)*fzm(k)+rho_zz(k-1,iCell)*fzp(k))
 
-               !old_err.
-               !tend_w(k,iCell) = tend_w(k,iCell) &amp;
-               !                 + rho_zz(k,iCell)*( (fzm(k)*ur_cell(k,iCell)+fzp(k)*ur_cell(k-1,iCell))**2.          &amp;
-               !                                 +(fzm(k)*vr_cell(k,iCell)+fzp(k)*vr_cell(k-1,iCell))**2. )/r_earth   &amp;
-               !                 + 2.*omega_e*cos(grid % latCell % array(iCell))*rho_zz(k,iCell)      &amp;
-               !                     *(fzm(k)*ur_cell(k,iCell)+fzp(k)*ur_cell(k-1,iCell))
             end do
          end do
 
@@ -2537,108 +2536,106 @@
       !  but here we can also code in hyperdiffusion if we wish (2nd order at present)
       !
 
-      !  Note: we are using quite a bit of the theta code here - could be combined later???
-
       if (rk_step == 1 .or. rk_diffusion) then
 
-      tend_w_euler = 0.
+         tend_w_euler = 0.
 
-      if (delsq_horiz_mixing) then
+         if (delsq_horiz_mixing) then
 
-        if (h_mom_eddy_visc2 &gt; 0.0) then
+            if ((h_mom_eddy_visc2 &gt; 0.0) .and. (config_horiz_mixing == &quot;2d_fixed&quot;)) then
 
-          do iEdge=1,grid % nEdges
-            cell1 = grid % cellsOnEdge % array(1,iEdge)
-            cell2 = grid % cellsOnEdge % array(2,iEdge)
-            if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
+               do iEdge=1,nEdges
+                  cell1 = cellsOnEdge(1,iEdge)
+                  cell2 = cellsOnEdge(2,iEdge)
+                  if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
 
-               do k=2,grid % nVertLevels
-                  theta_turb_flux = h_mom_eddy_visc2*(w(k,cell2) - w(k,cell1))/dcEdge(iEdge)
-                  theta_turb_flux = theta_turb_flux * meshScalingDel2(iEdge)
-                  flux = 0.5*dvEdge (iEdge) * (rho_edge(k,iEdge)+rho_edge(k-1,iEdge)) * theta_turb_flux
-!                  tend_w(k,cell1) = tend_w(k,cell1) + flux
-!                  tend_w(k,cell2) = tend_w(k,cell2) - flux
-                  tend_w_euler(k,cell1) = tend_w_euler(k,cell1) + flux/areaCell(cell1)
-                  tend_w_euler(k,cell2) = tend_w_euler(k,cell2) - flux/areaCell(cell2)
+                     ! horizontal flux divergence of the gradient (i.e. del^2)
+                     ! note, for w, even though we use theta_* local scratch variables
+                     do k=2,nVertLevels
+                        theta_turb_flux = h_mom_eddy_visc2*(w(k,cell2) - w(k,cell1))/dcEdge(iEdge)
+                        theta_turb_flux = theta_turb_flux * meshScalingDel2(iEdge)
+                        flux = 0.5*dvEdge (iEdge) * (rho_edge(k,iEdge)+rho_edge(k-1,iEdge)) * theta_turb_flux
+                        tend_w_euler(k,cell1) = tend_w_euler(k,cell1) + flux/areaCell(cell1)
+                        tend_w_euler(k,cell2) = tend_w_euler(k,cell2) - flux/areaCell(cell2)
+                     end do
+
+                  end if
                end do
 
-             end if
-           end do
-        else if (config_horiz_mixing == &quot;2d_smagorinsky&quot;) then
+            else if (config_horiz_mixing == &quot;2d_smagorinsky&quot;) then
 
-          do iEdge=1,grid % nEdges
-            cell1 = grid % cellsOnEdge % array(1,iEdge)
-            cell2 = grid % cellsOnEdge % array(2,iEdge)
-            if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
+               do iEdge=1,nEdges
+                  cell1 = cellsOnEdge(1,iEdge)
+                  cell2 = cellsOnEdge(2,iEdge)
+                  if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
+   
+                     do k=2,nVertLevels
+                        theta_turb_flux = 0.25*(kdiff(k,cell1)+kdiff(k,cell2)+kdiff(k-1,cell1)+kdiff(k,cell2))  &amp;
+                                              *(w(k,cell2) - w(k,cell1))/dcEdge(iEdge)
+                        theta_turb_flux = theta_turb_flux * meshScalingDel2(iEdge)
+                        flux = 0.5*dvEdge (iEdge) * (rho_edge(k,iEdge)+rho_edge(k-1,iEdge)) * theta_turb_flux
+                        tend_w_euler(k,cell1) = tend_w_euler(k,cell1) + flux/areaCell(cell1)
+                        tend_w_euler(k,cell2) = tend_w_euler(k,cell2) - flux/areaCell(cell2)
+                     end do
 
-               do k=2,grid % nVertLevels
-!                  theta_turb_flux = h_mom_eddy_visc2*(w(k,cell2) - w(k,cell1))/dcEdge(iEdge)
-                  theta_turb_flux = 0.25*(kdiff(k,cell1)+kdiff(k,cell2)+kdiff(k-1,cell1)+kdiff(k,cell2))  &amp;
-                                        *(w(k,cell2) - w(k,cell1))/dcEdge(iEdge)
-                  theta_turb_flux = theta_turb_flux * meshScalingDel2(iEdge)
-                  flux = 0.5*dvEdge (iEdge) * (rho_edge(k,iEdge)+rho_edge(k-1,iEdge)) * theta_turb_flux
-!                  tend_w(k,cell1) = tend_w(k,cell1) + flux
-!                  tend_w(k,cell2) = tend_w(k,cell2) - flux
-                  tend_w_euler(k,cell1) = tend_w_euler(k,cell1) + flux/areaCell(cell1)
-                  tend_w_euler(k,cell2) = tend_w_euler(k,cell2) - flux/areaCell(cell2)
+                  end if
                end do
+            end if
+         end if   ! delsq_horiz_mixing
 
-             end if
-           end do
-        end if

-      end if
+         if ((h_mom_eddy_visc4 &gt; 0.0 .and. config_horiz_mixing == &quot;2d_fixed&quot;) .or. &amp;
+             (h_mom_eddy_visc4 &gt; 0.0 .and. config_horiz_mixing == &quot;2d_smagorinsky&quot;)) then
 
-      if ( h_mom_eddy_visc4 &gt; 0.0 ) then
 
-         allocate(delsq_theta(nVertLevels, nCells+1))
+            ! del^4 horizontal filter.  We compute this as del^2 ( del^2 (u) ).
+            !
+            ! First, storage to hold the result from the first del^2 computation.
+            !  we copied code from the theta mixing, hence the theta* names.
 
-         delsq_theta(:,:) = 0.
+            allocate(delsq_theta(nVertLevels, nCells+1))
 
-         do iEdge=1,grid % nEdges
-            cell1 = grid % cellsOnEdge % array(1,iEdge)
-            cell2 = grid % cellsOnEdge % array(2,iEdge)
-            do k=2,grid % nVertLevels
-               delsq_theta(k,cell1) = delsq_theta(k,cell1) + dvEdge(iEdge)*0.5*(rho_edge(k,iEdge)+rho_edge(k-1,iEdge))*(w(k,cell2) - w(k,cell1))/dcEdge(iEdge)
-               delsq_theta(k,cell2) = delsq_theta(k,cell2) - dvEdge(iEdge)*0.5*(rho_edge(k,iEdge)+rho_edge(k-1,iEdge))*(w(k,cell2) - w(k,cell1))/dcEdge(iEdge)
+            delsq_theta(:,:) = 0.
+
+            do iEdge=1,nEdges
+               cell1 = cellsOnEdge(1,iEdge)
+               cell2 = cellsOnEdge(2,iEdge)
+               do k=2,nVertLevels
+                  delsq_theta(k,cell1) = delsq_theta(k,cell1) + dvEdge(iEdge)*0.5*(rho_edge(k,iEdge)+rho_edge(k-1,iEdge))*(w(k,cell2) - w(k,cell1))/dcEdge(iEdge)
+                  delsq_theta(k,cell2) = delsq_theta(k,cell2) - dvEdge(iEdge)*0.5*(rho_edge(k,iEdge)+rho_edge(k-1,iEdge))*(w(k,cell2) - w(k,cell1))/dcEdge(iEdge)
+               end do
             end do
-         end do
 
-         do iCell = 1, nCells
-            r = 1.0 / areaCell(iCell)
-            do k=2,nVertLevels
-               delsq_theta(k,iCell) = delsq_theta(k,iCell) * r
+            do iCell = 1, nCells
+               r = 1.0 / areaCell(iCell)
+               do k=2,nVertLevels
+                  delsq_theta(k,iCell) = delsq_theta(k,iCell) * r
+               end do
             end do
-         end do
 
-         do iEdge=1,grid % nEdges
-            cell1 = grid % cellsOnEdge % array(1,iEdge)
-            cell2 = grid % cellsOnEdge % array(2,iEdge)
-            if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
+            do iEdge=1,nEdges
+               cell1 = cellsOnEdge(1,iEdge)
+               cell2 = cellsOnEdge(2,iEdge)
+               if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
 
-               do k=2,grid % nVertLevels
-                  theta_turb_flux = h_mom_eddy_visc4*(delsq_theta(k,cell2) - delsq_theta(k,cell1))/dcEdge(iEdge)
-                  theta_turb_flux = theta_turb_flux * meshScalingDel4(iEdge)
-                  flux = dvEdge (iEdge) * theta_turb_flux
+                  do k=2,nVertLevels
+                     theta_turb_flux = h_mom_eddy_visc4*(delsq_theta(k,cell2) - delsq_theta(k,cell1))/dcEdge(iEdge)
+                     theta_turb_flux = theta_turb_flux * meshScalingDel4(iEdge)
+                     flux = dvEdge (iEdge) * theta_turb_flux
+                     tend_w_euler(k,cell1) = tend_w_euler(k,cell1) - flux/areaCell(cell1)
+                     tend_w_euler(k,cell2) = tend_w_euler(k,cell2) + flux/areaCell(cell2)
+                  end do
 
-!                  tend_w(k,cell1) = tend_w(k,cell1) - flux
-!                  tend_w(k,cell2) = tend_w(k,cell2) + flux
-                  tend_w_euler(k,cell1) = tend_w_euler(k,cell1) - flux/areaCell(cell1)
-                  tend_w_euler(k,cell2) = tend_w_euler(k,cell2) + flux/areaCell(cell2)
-               end do
+               end if
+            end do
 
-            end if
-         end do
+            deallocate(delsq_theta)
 
-         deallocate(delsq_theta)
+         end if
 
-      end if
-
       end if ! horizontal mixing for w computed in first rk_step
 
       !
       !  vertical advection, pressure gradient and buoyancy for w
-      !  Note: we are also dividing through by the cell area after the horizontal flux divergence
       !
 
       do iCell = 1, nCells
@@ -2674,10 +2671,11 @@
 
          wdwz(nVertLevels+1) = 0.
 
+      !  Note: next we are also dividing through by the cell area after the horizontal flux divergence
+
          do k=2,nVertLevels
 
             tend_w(k,iCell) = tend_w(k,iCell)/areaCell(iCell) -rdzu(k)*(wdwz(k+1)-wdwz(k))    &amp;
-!SHP-buoy
                                   - cqw(k,iCell)*( rdzu(k)*(pp(k,iCell)-pp(k-1,iCell))        &amp;
                                   + gravity*  &amp;
                                    ( fzm(k)*(rb(k,iCell)*(qtot(k,iCell)) +         &amp;
@@ -2693,24 +2691,24 @@
 
       if (rk_step == 1 .or. rk_diffusion) then
 
-      if ( v_mom_eddy_visc2 &gt; 0.0 ) then
+         if ( v_mom_eddy_visc2 &gt; 0.0 ) then
 
-         do iCell = 1, grid % nCellsSolve
+            do iCell = 1, nCellsSolve
             do k=2,nVertLevels
                tend_w_euler(k,iCell) = tend_w_euler(k,iCell) + v_mom_eddy_visc2*0.5*(rho_zz(k,iCell)+rho_zz(k-1,iCell))*(  &amp;
                                         (w(k+1,iCell)-w(k  ,iCell))*rdzw(k)                              &amp;
                                        -(w(k  ,iCell)-w(k-1,iCell))*rdzw(k-1) )*rdzu(k)
             end do
-         end do
+            end do
 
-      end if
+         end if
 
       end if ! mixing term computed first rk_step
 
 
 ! add in mixing terms for w
 
-      do iCell = 1, grid % nCellsSolve
+      do iCell = 1, nCellsSolve
          do k=2,nVertLevels
             tend_w(k,iCell) = tend_w(k,iCell) + tend_w_euler(k,iCell)
          end do
@@ -2732,7 +2730,7 @@
             cell1 = cellsOnEdge(1,iEdge)
             cell2 = cellsOnEdge(2,iEdge)
             if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
-               do k=1,grid % nVertLevels
+               do k=1,nVertLevels
                   flux = dvEdge(iEdge) *  ru(k,iEdge) * ( 0.5*(theta_m(k,cell1) + theta_m(k,cell2)) )
                   tend_theta(k,cell1) = tend_theta(k,cell1) - flux
                   tend_theta(k,cell2) = tend_theta(k,cell2) + flux
@@ -2749,51 +2747,18 @@
 
                flux_arr(:) = 0.
                do i=1,nAdvCellsForEdge(iEdge)
-                 iCell = advCellsForEdge(i,iEdge)
-                 do k=1,grid % nVertLevels
-                   scalar_weight = adv_coefs(i,iEdge) + coef_3rd_order*sign(1.0_RKIND,ru(k,iEdge))*adv_coefs_3rd(i,iEdge)
-                   flux_arr(k) = flux_arr(k) + scalar_weight* theta_m(k,iCell)
-                 end do
+                  iCell = advCellsForEdge(i,iEdge)
+                  do k=1,nVertLevels
+                     scalar_weight = adv_coefs(i,iEdge) + coef_3rd_order*sign(1.0_RKIND,ru(k,iEdge))*adv_coefs_3rd(i,iEdge)
+                     flux_arr(k) = flux_arr(k) + scalar_weight* theta_m(k,iCell)
+                  end do
                end do
 
-               do k=1,grid % nVertLevels
+               do k=1,nVertLevels
                   tend_theta(k,cell1) = tend_theta(k,cell1) - ru(k,iEdge)*flux_arr(k)
                   tend_theta(k,cell2) = tend_theta(k,cell2) + ru(k,iEdge)*flux_arr(k)
                end do
 
-
-!               do k=1,grid % nVertLevels
-!
-!                  d2fdx2_cell1 = deriv_two(1,1,iEdge) * theta_m(k,cell1)
-!                  d2fdx2_cell2 = deriv_two(1,2,iEdge) * theta_m(k,cell2)
-!                  do i=1, grid % nEdgesOnCell % array (cell1)
-!                     if ( grid % CellsOnCell % array (i,cell1) &lt;= grid%nCells) &amp;
-!                     d2fdx2_cell1 = d2fdx2_cell1 + deriv_two(i+1,1,iEdge) * theta_m(k,grid % CellsOnCell % array (i,cell1))
-!                  end do
-!                  do i=1, grid % nEdgesOnCell % array (cell2)
-!                     if ( grid % CellsOnCell % array (i,cell2) &lt;= grid%nCells) &amp;
-!                     d2fdx2_cell2 = d2fdx2_cell2 + deriv_two(i+1,2,iEdge) * theta_m(k,grid % CellsOnCell % array (i,cell2))
-!                  end do
-!
-!  3rd order stencil
-!
-!                  if( u(k,iEdge) &gt; 0) then
-!                        flux = dvEdge(iEdge) * ru(k,iEdge) * (          &amp;
-!                                               0.5*(theta_m(k,cell1) + theta_m(k,cell2))      &amp;
-!                                                -(dcEdge(iEdge) **2) * (d2fdx2_cell1 + d2fdx2_cell2) / 12.          &amp;
-!                                                -(dcEdge(iEdge) **2) * coef_3rd_order*(d2fdx2_cell1 - d2fdx2_cell2) / 12. )
-!                     else
-!                        flux = dvEdge(iEdge) *  ru(k,iEdge) * (          &amp;
-!                                               0.5*(theta_m(k,cell1) + theta_m(k,cell2))      &amp;
-!                                                -(dcEdge(iEdge) **2) * (d2fdx2_cell1 + d2fdx2_cell2) / 12.          &amp;
-!                                                +(dcEdge(iEdge) **2) * coef_3rd_order*(d2fdx2_cell1 - d2fdx2_cell2) / 12. )
-!                  end if
-!
-!                  tend_theta(k,cell1) = tend_theta(k,cell1) - flux
-!                  tend_theta(k,cell2) = tend_theta(k,cell2) + flux
-!
-!               end do
-
             end if
          end do
 
@@ -2802,19 +2767,19 @@
          do iEdge=1,nEdges
             cell1 = cellsOnEdge(1,iEdge)
             cell2 = cellsOnEdge(2,iEdge)
-            if (cell1 &lt;= grid%nCells .and. cell2 &lt;= grid%nCells) then
+            if (cell1 &lt;= nCells .and. cell2 &lt;= nCells) then
 
-               do k=1,grid % nVertLevels
+               do k=1,nVertLevels
 
                   d2fdx2_cell1 = deriv_two(1,1,iEdge) * theta_m(k,cell1)
                   d2fdx2_cell2 = deriv_two(1,2,iEdge) * theta_m(k,cell2)
-                  do i=1, grid % nEdgesOnCell % array (cell1)
+                  do i=1, nEdgesOnCell(cell1)
                      if ( grid % CellsOnCell % array (i,cell1) &lt;= grid%nCells) &amp;
-                     d2fdx2_cell1 = d2fdx2_cell1 + deriv_two(i+1,1,iEdge) * theta_m(k,grid % CellsOnCell % array (i,cell1))
+                        d2fdx2_cell1 = d2fdx2_cell1 + deriv_two(i+1,1,iEdge) * theta_m(k,grid % CellsOnCell % array (i,cell1))
                   end do
-                  do i=1, grid % nEdgesOnCell % array (cell2)
+                  do i=1, nEdgesOnCell(cell2)
                      if ( grid % CellsOnCell % array (i,cell2) &lt;= grid%nCells) &amp;
-                     d2fdx2_cell2 = d2fdx2_cell2 + deriv_two(i+1,2,iEdge) * theta_m(k,grid % CellsOnCell % array (i,cell2))
+                        d2fdx2_cell2 = d2fdx2_cell2 + deriv_two(i+1,2,iEdge) * theta_m(k,grid % CellsOnCell % array (i,cell2))
                   end do
 
                   flux = dvEdge(iEdge) *  ru(k,iEdge) * (                                               &amp;
@@ -2840,19 +2805,17 @@
       tend_theta_euler = 0.
 
       if (delsq_horiz_mixing) then
-         if ( h_theta_eddy_visc2 &gt; 0.0 ) then
+         if ( (h_theta_eddy_visc2 &gt; 0.0) .and. (config_horiz_mixing == &quot;2d_fixed&quot;) ) then
 
-            do iEdge=1,grid % nEdges
-               cell1 = grid % cellsOnEdge % array(1,iEdge)
-               cell2 = grid % cellsOnEdge % array(2,iEdge)
+            do iEdge=1,nEdges
+               cell1 = cellsOnEdge(1,iEdge)
+               cell2 = cellsOnEdge(2,iEdge)
                if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
   
-                  do k=1,grid % nVertLevels
-                     theta_turb_flux = h_theta_eddy_visc2*prandtl*(theta_m(k,cell2) - theta_m(k,cell1))/dcEdge(iEdge)
+                  do k=1,nVertLevels
+                     theta_turb_flux = h_theta_eddy_visc2*prandtl_inv*(theta_m(k,cell2) - theta_m(k,cell1))/dcEdge(iEdge)
                      theta_turb_flux = theta_turb_flux * meshScalingDel2(iEdge)
                      flux = dvEdge (iEdge) * rho_edge(k,iEdge) * theta_turb_flux
-!                     tend_theta(k,cell1) = tend_theta(k,cell1) + flux
-!                     tend_theta(k,cell2) = tend_theta(k,cell2) - flux
                      tend_theta_euler(k,cell1) = tend_theta_euler(k,cell1) + flux/areaCell(cell1)
                      tend_theta_euler(k,cell2) = tend_theta_euler(k,cell2) - flux/areaCell(cell2)
                   end do
@@ -2862,18 +2825,16 @@
 
          else if (  ( config_horiz_mixing == &quot;2d_smagorinsky&quot;) ) then
 
-            do iEdge=1,grid % nEdges
-               cell1 = grid % cellsOnEdge % array(1,iEdge)
-               cell2 = grid % cellsOnEdge % array(2,iEdge)
+            do iEdge=1,nEdges
+               cell1 = cellsOnEdge(1,iEdge)
+               cell2 = cellsOnEdge(2,iEdge)
                if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
  
-                  do k=1,grid % nVertLevels
-                     theta_turb_flux = 0.5*(kdiff(k,cell1)+kdiff(k,cell2))*prandtl  &amp;
+                  do k=1,nVertLevels
+                     theta_turb_flux = 0.5*(kdiff(k,cell1)+kdiff(k,cell2))*prandtl_inv  &amp;
                                            *(theta_m(k,cell2) - theta_m(k,cell1))/dcEdge(iEdge)
                      theta_turb_flux = theta_turb_flux * meshScalingDel2(iEdge)
                      flux = dvEdge (iEdge) * rho_edge(k,iEdge) * theta_turb_flux
-!                     tend_theta(k,cell1) = tend_theta(k,cell1) + flux
-!                     tend_theta(k,cell2) = tend_theta(k,cell2) - flux
                      tend_theta_euler(k,cell1) = tend_theta_euler(k,cell1) + flux/areaCell(cell1)
                      tend_theta_euler(k,cell2) = tend_theta_euler(k,cell2) - flux/areaCell(cell2)
                   end do
@@ -2884,16 +2845,17 @@
 
       end if
 
-      if ( h_theta_eddy_visc4 &gt; 0.0 ) then
+      if ((h_theta_eddy_visc4 &gt; 0.0 .and. config_horiz_mixing == &quot;2d_fixed&quot;) .or. &amp;
+          (h_theta_eddy_visc4 &gt; 0.0 .and. config_horiz_mixing == &quot;2d_smagorinsky&quot;)) then
 
          allocate(delsq_theta(nVertLevels, nCells+1))
 
          delsq_theta(:,:) = 0.
 
-         do iEdge=1,grid % nEdges
-            cell1 = grid % cellsOnEdge % array(1,iEdge)
-            cell2 = grid % cellsOnEdge % array(2,iEdge)
-            do k=1,grid % nVertLevels
+         do iEdge=1,nEdges
+            cell1 = cellsOnEdge(1,iEdge)
+            cell2 = cellsOnEdge(2,iEdge)
+            do k=1,nVertLevels
                delsq_theta(k,cell1) = delsq_theta(k,cell1) + dvEdge(iEdge)*rho_edge(k,iEdge)*(theta_m(k,cell2) - theta_m(k,cell1))/dcEdge(iEdge)
                delsq_theta(k,cell2) = delsq_theta(k,cell2) - dvEdge(iEdge)*rho_edge(k,iEdge)*(theta_m(k,cell2) - theta_m(k,cell1))/dcEdge(iEdge)
             end do
@@ -2906,18 +2868,15 @@
             end do
          end do
 
-         do iEdge=1,grid % nEdges
-            cell1 = grid % cellsOnEdge % array(1,iEdge)
-            cell2 = grid % cellsOnEdge % array(2,iEdge)
+         do iEdge=1,nEdges
+            cell1 = cellsOnEdge(1,iEdge)
+            cell2 = cellsOnEdge(2,iEdge)
             if (cell1 &lt;= nCellsSolve .or. cell2 &lt;= nCellsSolve) then
 
-               do k=1,grid % nVertLevels
-                  theta_turb_flux = h_theta_eddy_visc4*prandtl*(delsq_theta(k,cell2) - delsq_theta(k,cell1))/dcEdge(iEdge)
+               do k=1,nVertLevels
+                  theta_turb_flux = h_theta_eddy_visc4*prandtl_inv*(delsq_theta(k,cell2) - delsq_theta(k,cell1))/dcEdge(iEdge)
                   theta_turb_flux = theta_turb_flux * meshScalingDel4(iEdge)
                   flux = dvEdge (iEdge) * theta_turb_flux
-
-!                  tend_theta(k,cell1) = tend_theta(k,cell1) - flux
-!                  tend_theta(k,cell2) = tend_theta(k,cell2) + flux
                   tend_theta_euler(k,cell1) = tend_theta_euler(k,cell1) - flux/areaCell(cell1)
                   tend_theta_euler(k,cell2) = tend_theta_euler(k,cell2) + flux/areaCell(cell2)
                end do
@@ -2985,47 +2944,41 @@
 
          if (config_mix_full) then
 
-         do iCell = 1, grid % nCellsSolve
-            do k=2,nVertLevels-1
-               z1 = zgrid(k-1,iCell)
-               z2 = zgrid(k  ,iCell)
-               z3 = zgrid(k+1,iCell)
-               z4 = zgrid(k+2,iCell)
+            do iCell = 1, nCellsSolve
+               do k=2,nVertLevels-1
+                  z1 = zgrid(k-1,iCell)
+                  z2 = zgrid(k  ,iCell)
+                  z3 = zgrid(k+1,iCell)
+                  z4 = zgrid(k+2,iCell)
 
-               zm = 0.5*(z1+z2)
-               z0 = 0.5*(z2+z3)
-               zp = 0.5*(z3+z4)
+                  zm = 0.5*(z1+z2)
+                  z0 = 0.5*(z2+z3)
+                  zp = 0.5*(z3+z4)
 
-!               tend_theta(k,iCell) = tend_theta(k,iCell) + v_theta_eddy_visc2*prandtl*rho_zz(k,iCell)*(&amp;
-!                                        (theta_m(k+1,iCell)-theta_m(k  ,iCell))/(zp-z0)                 &amp;
-!                                       -(theta_m(k  ,iCell)-theta_m(k-1,iCell))/(z0-zm) )/(0.5*(zp-zm))
-               tend_theta_euler(k,iCell) = tend_theta_euler(k,iCell) + v_theta_eddy_visc2*prandtl*rho_zz(k,iCell)*(&amp;
-                                        (theta_m(k+1,iCell)-theta_m(k  ,iCell))/(zp-z0)                 &amp;
-                                       -(theta_m(k  ,iCell)-theta_m(k-1,iCell))/(z0-zm) )/(0.5*(zp-zm))
+                  tend_theta_euler(k,iCell) = tend_theta_euler(k,iCell) + v_theta_eddy_visc2*prandtl_inv*rho_zz(k,iCell)*(&amp;
+                                           (theta_m(k+1,iCell)-theta_m(k  ,iCell))/(zp-z0)                 &amp;
+                                          -(theta_m(k  ,iCell)-theta_m(k-1,iCell))/(z0-zm) )/(0.5*(zp-zm))
+               end do
             end do
-         end do
 
          else  ! idealized cases where we mix on the perturbation from the initial 1-D state
 
-         do iCell = 1, grid % nCellsSolve
-            do k=2,nVertLevels-1
-               z1 = zgrid(k-1,iCell)
-               z2 = zgrid(k  ,iCell)
-               z3 = zgrid(k+1,iCell)
-               z4 = zgrid(k+2,iCell)
+            do iCell = 1, nCellsSolve
+               do k=2,nVertLevels-1
+                  z1 = zgrid(k-1,iCell)
+                  z2 = zgrid(k  ,iCell)
+                  z3 = zgrid(k+1,iCell)
+                  z4 = zgrid(k+2,iCell)
 
-               zm = 0.5*(z1+z2)
-               z0 = 0.5*(z2+z3)
-               zp = 0.5*(z3+z4)
+                  zm = 0.5*(z1+z2)
+                  z0 = 0.5*(z2+z3)
+                  zp = 0.5*(z3+z4)
 
-!               tend_theta(k,iCell) = tend_theta(k,iCell) + v_theta_eddy_visc2*prandtl*rho_zz(k,iCell)*(&amp;
-!                                        ((theta_m(k+1,iCell)-t_init(k+1,iCell))-(theta_m(k  ,iCell)-t_init(k,iCell)))/(zp-z0)      &amp;
-!                                       -((theta_m(k  ,iCell)-t_init(k,iCell))-(theta_m(k-1,iCell)-t_init(k-1,iCell)))/(z0-zm) )/(0.5*(zp-zm))
-               tend_theta_euler(k,iCell) = tend_theta_euler(k,iCell) + v_theta_eddy_visc2*prandtl*rho_zz(k,iCell)*(&amp;
-                                        ((theta_m(k+1,iCell)-t_init(k+1,iCell))-(theta_m(k  ,iCell)-t_init(k,iCell)))/(zp-z0)      &amp;
-                                       -((theta_m(k  ,iCell)-t_init(k,iCell))-(theta_m(k-1,iCell)-t_init(k-1,iCell)))/(z0-zm) )/(0.5*(zp-zm))
+                  tend_theta_euler(k,iCell) = tend_theta_euler(k,iCell) + v_theta_eddy_visc2*prandtl_inv*rho_zz(k,iCell)*(&amp;
+                                           ((theta_m(k+1,iCell)-t_init(k+1,iCell))-(theta_m(k  ,iCell)-t_init(k,iCell)))/(zp-z0)      &amp;
+                                          -((theta_m(k  ,iCell)-t_init(k,iCell))-(theta_m(k-1,iCell)-t_init(k-1,iCell)))/(z0-zm) )/(0.5*(zp-zm))
+               end do
             end do
-         end do
 
          end if
 
@@ -3033,7 +2986,7 @@
 
       end if ! compute theta mixing on first rk_step
 
-      do iCell = 1, grid % nCellsSolve
+      do iCell = 1, nCellsSolve
          do k=1,nVertLevels
             tend_theta(k,iCell) = tend_theta(k,iCell) + tend_theta_euler(k,iCell)
          end do
@@ -3047,9 +3000,9 @@
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    ! Compute diagnostic fields used in the tendency computations
    !
-   ! Input: grid - grid metadata
+   ! Input: state (s), grid - grid metadata
    !
-   ! Output: s - computed diagnostics
+   ! Output: diag - computed diagnostics
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
 
       implicit none
@@ -3060,18 +3013,17 @@
       type (mesh_type), intent(in) :: grid
 
 
-      integer :: iEdge, iCell, iVertex, k, cell1, cell2, vertex1, vertex2, eoe, i, j, cov
-      real (kind=RKIND) :: flux, vorticity_abs, h_vertex, workpv, r
+      integer :: iEdge, iCell, iVertex, k, cell1, cell2, eoe, i
+      real (kind=RKIND) :: h_vertex, r
 
-      integer :: nCells, nEdges, nVertices, nVertLevels
+      integer :: nCells, nEdges, nVertices, nVertLevels, vertexDegree
       real (kind=RKIND), dimension(:), pointer :: fVertex, fEdge, dvEdge, dcEdge, areaCell, areaTriangle
-      real (kind=RKIND), dimension(:,:), pointer :: vh, weightsOnEdge, kiteAreasOnVertex, h_edge, h, u, v, tend_h, tend_u, &amp;
+      real (kind=RKIND), dimension(:,:), pointer :: vh, weightsOnEdge, kiteAreasOnVertex, h_edge, h, u, v, &amp;
                                                     circulation, vorticity, ke, pv_edge, pv_vertex, pv_cell, gradPVn, gradPVt, &amp;
                                                     divergence
       integer, dimension(:,:), pointer :: cellsOnEdge, cellsOnVertex, verticesOnEdge, edgesOnCell, edgesOnEdge, edgesOnVertex
       integer, dimension(:), pointer :: nEdgesOnCell, nEdgesOnEdge
 
-      !WCS-instability
       logical, parameter :: hollingsworth=.true.
       real (kind=RKIND), allocatable, dimension(:,:) :: ke_vertex
       real (kind=RKIND)  :: ke_fact
@@ -3109,10 +3061,11 @@
       fVertex           =&gt; grid % fVertex % array
       fEdge             =&gt; grid % fEdge % array
                   
-      nCells      = grid % nCells
-      nEdges      = grid % nEdges
-      nVertices   = grid % nVertices
-      nVertLevels = grid % nVertLevels
+      nCells       = grid % nCells
+      nEdges       = grid % nEdges
+      nVertices    = grid % nVertices
+      nVertLevels  = grid % nVertLevels
+      vertexDegree = grid % vertexDegree
 
       !
       ! Compute height on cell edges at velocity locations
@@ -3164,7 +3117,7 @@
 
 
       !
-      ! Compute kinetic energy in each cell
+      ! Compute kinetic energy in each cell (Ringler et al JCP 2009)
       !
       ke(:,:) = 0.0
       do iCell=1,nCells
@@ -3179,52 +3132,49 @@
          end do
       end do
 
-      !WCS-instability
-      ! Compute ke at cell vertices - AG's new KE construction, part 1
-      ! *** approximation here because we don't have inner triangle areas
-      !
       if (hollingsworth) then
-      allocate (ke_vertex(nVertLevels,nVertices))
-      do iVertex=1,nVertices
-         do k=1,nVertLevels
-!            ke_vertex(k,iVertex) = (  subTriangleAreasOnVertex(1,iVertex)*u(k,EdgesOnVertex(1,iVertex))**2.0  &amp;
-!                                    + subTriangleAreasOnVertex(2,iVertex)*u(k,EdgesOnVertex(2,iVertex))**2.0  &amp;
-!                                    + subTriangleAreasOnVertex(3,iVertex)*u(k,EdgesOnVertex(3,iVertex))**2.0  &amp;
-!                                                 ) / AreaTriangle(iVertex)
 
-            ke_vertex(k,iVertex) = (  dcEdge(EdgesOnVertex(1,iVertex))*dvEdge(EdgesOnVertex(1,iVertex))*u(k,EdgesOnVertex(1,iVertex))**2.0  &amp;
-                                     +dcEdge(EdgesOnVertex(2,iVertex))*dvEdge(EdgesOnVertex(2,iVertex))*u(k,EdgesOnVertex(2,iVertex))**2.0  &amp;
-                                     +dcEdge(EdgesOnVertex(3,iVertex))*dvEdge(EdgesOnVertex(3,iVertex))*u(k,EdgesOnVertex(3,iVertex))**2.0  &amp;
-                                                 ) * 0.25 / AreaTriangle(iVertex)
+         ! Compute ke at cell vertices - AG's new KE construction, part 1
+         ! *** approximation here because we don't have inner triangle areas
+         !
 
+         allocate (ke_vertex(nVertLevels,nVertices))
+         do iVertex=1,nVertices
+            do k=1,nVertLevels
+
+               ke_vertex(k,iVertex) = (  dcEdge(EdgesOnVertex(1,iVertex))*dvEdge(EdgesOnVertex(1,iVertex))*u(k,EdgesOnVertex(1,iVertex))**2.0  &amp;
+                                        +dcEdge(EdgesOnVertex(2,iVertex))*dvEdge(EdgesOnVertex(2,iVertex))*u(k,EdgesOnVertex(2,iVertex))**2.0  &amp;
+                                        +dcEdge(EdgesOnVertex(3,iVertex))*dvEdge(EdgesOnVertex(3,iVertex))*u(k,EdgesOnVertex(3,iVertex))**2.0  &amp;
+                                                    ) * 0.25 / AreaTriangle(iVertex)
+
+            end do
          end do
-      end do
 
-      ! adjust ke at cell vertices - AG's new KE construction, part 2
-      !
+         ! adjust ke at cell vertices - AG's new KE construction, part 2
+         !
 
-      ke_fact = 1.0 - .375
+         ke_fact = 1.0 - .375
 
-      do iCell=1,nCells
-         do k=1,nVertLevels
-            ke(k,iCell) = ke_fact*ke(k,iCell)
+         do iCell=1,nCells
+            do k=1,nVertLevels
+               ke(k,iCell) = ke_fact*ke(k,iCell)
+            end do
          end do
-      end do
 
-      do iVertex = 1, nVertices
-       do i=1,grid % vertexDegree
-          iCell = cellsOnVertex(i,iVertex)
-          do k = 1,nVertLevels
-             ke(k,iCell) = ke(k,iCell) + (1.-ke_fact)*kiteAreasOnVertex(i, iVertex) * ke_vertex(k, iVertex) / areaCell(iCell)
-          end do
-       end do
-      end do
-      deallocate (ke_vertex)
+         do iVertex = 1, nVertices
+            do i=1,vertexDegree
+               iCell = cellsOnVertex(i,iVertex)
+               do k = 1,nVertLevels
+                  ke(k,iCell) = ke(k,iCell) + (1.-ke_fact)*kiteAreasOnVertex(i, iVertex) * ke_vertex(k, iVertex) / areaCell(iCell)
+               end do
+            end do
+         end do
+         deallocate (ke_vertex)
+
       end if
-      !END of WCS-instability
 
       !
-      ! Compute v (tangential) velocities
+      ! Compute v (tangential) velocities following Thuburn et al JCP 2009
       !
       v(:,:) = 0.0
       do iEdge = 1,nEdges
@@ -3244,7 +3194,7 @@
       do iVertex = 1,nVertices
          do k=1,nVertLevels
             h_vertex = 0.0
-            do i=1,grid % vertexDegree
+            do i=1,vertexDegree
                h_vertex = h_vertex + h(k,cellsOnVertex(i,iVertex)) * kiteAreasOnVertex(i,iVertex)
             end do
             h_vertex = h_vertex / areaTriangle(iVertex)
@@ -3260,7 +3210,7 @@
       !
       pv_edge(:,:) = 0.0
       do iVertex = 1,nVertices
-         do i=1,grid % vertexDegree
+         do i=1,vertexDegree
             iEdge = edgesOnVertex(i,iVertex)
             do k=1,nVertLevels
                pv_edge(k,iEdge) =  pv_edge(k,iEdge)  + 0.5 * pv_vertex(k,iVertex)
@@ -3274,7 +3224,7 @@
       !
       pv_cell(:,:) = 0.0
       do iVertex = 1, nVertices
-         do i=1,grid % vertexDegree
+         do i=1,vertexDegree
             iCell = cellsOnVertex(i,iVertex)
             do k = 1,nVertLevels
                pv_cell(k,iCell) = pv_cell(k,iCell) + kiteAreasOnVertex(i, iVertex) * pv_vertex(k, iVertex) / areaCell(iCell)
@@ -3285,44 +3235,44 @@
 
       if (config_apvm_upwinding &gt; 0.0) then
 
-      !
-      ! Modify PV edge with upstream bias. 
-      !
-      ! Compute gradient of PV in the tangent direction
-      !   ( this computes gradPVt at all edges bounding real cells )
-      !
-      do iEdge = 1,nEdges
-         do k = 1,nVertLevels
-            gradPVt(k,iEdge) = (pv_vertex(k,verticesOnEdge(2,iEdge)) - pv_vertex(k,verticesOnEdge(1,iEdge))) / &amp;
-                               dvEdge(iEdge)
+         !
+         ! Modify PV edge with upstream bias. 
+         !
+         ! Compute gradient of PV in the tangent direction
+         !   ( this computes gradPVt at all edges bounding real cells )
+         !
+         do iEdge = 1,nEdges
+            do k = 1,nVertLevels
+               gradPVt(k,iEdge) = (pv_vertex(k,verticesOnEdge(2,iEdge)) - pv_vertex(k,verticesOnEdge(1,iEdge))) / &amp;
+                                  dvEdge(iEdge)
+            end do
          end do
-      end do
 
-      !
-      ! Compute gradient of PV in normal direction
-      !   (tdr: 2009-10-02: this is not correct because the pv_cell in the halo is not correct)
-      !
-      gradPVn(:,:) = 0.0
-      do iEdge = 1,nEdges
-         do k = 1,nVertLevels
-            gradPVn(k,iEdge) = (pv_cell(k,cellsOnEdge(2,iEdge)) - pv_cell(k,cellsOnEdge(1,iEdge))) / &amp;
-                                 dcEdge(iEdge)
+         !
+         ! Compute gradient of PV in normal direction
+         !   (tdr: 2009-10-02: this is not correct because the pv_cell in the halo is not correct)
+         !
+         gradPVn(:,:) = 0.0
+         do iEdge = 1,nEdges
+            do k = 1,nVertLevels
+               gradPVn(k,iEdge) = (pv_cell(k,cellsOnEdge(2,iEdge)) - pv_cell(k,cellsOnEdge(1,iEdge))) / &amp;
+                                    dcEdge(iEdge)
+            end do
          end do
-      end do
 
-      do iEdge = 1,nEdges
-         do k = 1,nVertLevels
-            pv_edge(k,iEdge) = pv_edge(k,iEdge) - config_apvm_upwinding * v(k,iEdge) * dt * gradPVt(k,iEdge)
+         do iEdge = 1,nEdges
+            do k = 1,nVertLevels
+               pv_edge(k,iEdge) = pv_edge(k,iEdge) - config_apvm_upwinding * v(k,iEdge) * dt * gradPVt(k,iEdge)
+            end do
          end do
-      end do
 
-      ! Modify PV edge with upstream bias.
-      !
-      do iEdge = 1,nEdges
-         do k = 1,nVertLevels
-            pv_edge(k,iEdge) = pv_edge(k,iEdge) - config_apvm_upwinding * u(k,iEdge) *dt * gradPVn(k,iEdge)
+         ! Modify PV edge with upstream bias.
+         !
+         do iEdge = 1,nEdges
+            do k = 1,nVertLevels
+               pv_edge(k,iEdge) = pv_edge(k,iEdge) - config_apvm_upwinding * u(k,iEdge) *dt * gradPVn(k,iEdge)
+            end do
          end do
-      end do
 
       end if  ! apvm upwinding
 
@@ -3339,64 +3289,56 @@
       type (diag_type), intent(inout) :: diag
       type (mesh_type), intent(inout) :: grid
 
-      !SHP-w
-      integer :: k,iCell,iEdge,i,iCell1,iCell2, cell1, cell2, coef_3rd_order
+      integer :: k,iCell,iEdge,iCell1,iCell2, cell1, cell2, coef_3rd_order
+      integer :: nCells, nEdges, nVertLevels
       real (kind=RKIND) :: p0, rcv, flux
+      integer, dimension(:,:), pointer :: cellsOnEdge
 
-      !SHP-w
+      nCells      = grid % nCells
+      nEdges      = grid % nEdges
+      nVertLevels = grid % nVertLevels
+
+      cellsOnEdge =&gt; grid % cellsOnEdge % array
+
       coef_3rd_order = config_coef_3rd_order
       if(config_theta_adv_order /=3) coef_3rd_order = 0
 
       rcv = rgas / (cp-rgas)
       p0 = 1.e5  ! this should come from somewhere else...
 
-      do iCell=1,grid%nCells
-         do k=1,grid%nVertLevels
-            state % theta_m % array(k,iCell) = diag % theta % array(k,iCell) * (1.0 + 1.61 * state % scalars % array(state % index_qv,k,iCell))
+      do iCell=1,nCells
+         do k=1,nVertLevels
+            state % theta_m % array(k,iCell) = diag % theta % array(k,iCell) * (1._RKIND + rvord * state % scalars % array(state % index_qv,k,iCell))
             state % rho_zz % array(k,iCell) = diag % rho % array(k,iCell) / grid % zz % array(k,iCell)
          end do
       end do
 
-      do iEdge = 1, grid % nEdges
-         iCell1 = grid % cellsOnEdge % array(1,iEdge)
-         iCell2 = grid % cellsOnEdge % array(2,iEdge)
-         do k=1,grid % nVertLevels
+      do iEdge = 1, nEdges
+         iCell1 = cellsOnEdge(1,iEdge)
+         iCell2 = cellsOnEdge(2,iEdge)
+         do k=1,nVertLevels
             diag % ru % array(k,iEdge) = 0.5 * state % u % array(k,iEdge) * (state % rho_zz % array(k,iCell1) + state % rho_zz % array(k,iCell2))
          end do
       end do
 
-!      ! Compute w from rho_zz and rw
-!      do iCell=1,grid%nCells
-!         diag % rw % array(1,iCell) = 0.
-!         diag % rw % array(grid%nVertLevels+1,iCell) = 0.
-!         do k=2,grid%nVertLevels
-!            diag % rw % array(k,iCell) = state % w % array(k,iCell)     &amp;
-!                          * (grid % fzp % array(k) * state % rho_zz % array(k-1,iCell) + grid % fzm % array(k) * state % rho_zz % array(k,iCell))
-!         end do
-!      end do
-
-
-! WCS bug fix 20110916
-
       ! Compute rw (i.e. rho_zz * omega) from rho_zz, w, and ru.
       ! We are reversing the procedure we use in subroutine atm_recover_large_step_variables.
       ! first, the piece that depends on w.
-      do iCell=1,grid%nCells
+      do iCell=1,nCells
          diag % rw % array(1,iCell) = 0.
          diag % rw % array(grid%nVertLevels+1,iCell) = 0.
-         do k=2,grid%nVertLevels
+         do k=2,nVertLevels
             diag % rw % array(k,iCell) = state % w % array(k,iCell)     &amp;
                           * (grid % fzp % array(k) * state % rho_zz % array(k-1,iCell) + grid % fzm % array(k) * state % rho_zz % array(k,iCell)) &amp;
                           * (grid % fzp % array(k) * grid % zz % array(k-1,iCell) + grid % fzm % array(k) * grid % zz % array(k,iCell))
          end do
       end do
   
-      !SHP-w
       ! next, the piece that depends on ru
-      do iEdge=1,grid%nEdges
-        cell1 = grid % CellsOnEdge % array(1,iEdge)
-        cell2 = grid % CellsOnEdge % array(2,iEdge)
-          do k = 2, grid % nVertLevels
+      do iEdge=1,nEdges
+         cell1 = cellsOnEdge(1,iEdge)
+         cell2 = cellsOnEdge(2,iEdge)
+         do k = 2, nVertLevels
             flux = (grid % fzm % array(k) * diag % ru % array(k,iEdge)+grid % fzp % array(k) * diag % ru % array(k-1,iEdge))
             diag % rw % array(k,cell2) = diag % rw % array(k,cell2)   &amp;
                           + (grid % zb % array(k,2,iEdge) + coef_3rd_order * sign(1.0_RKIND,flux) * grid % zb3 % array(k,2,iEdge))*flux   &amp;
@@ -3404,38 +3346,36 @@
             diag % rw % array(k,cell1) = diag % rw % array(k,cell1)   &amp;
                           - (grid % zb % array(k,1,iEdge) + coef_3rd_order * sign(1.0_RKIND,flux) * grid % zb3 % array(k,1,iEdge))*flux   &amp;
                           * (grid % fzp % array(k) * grid % zz % array(k-1,cell1) + grid % fzm % array(k) * grid % zz % array(k,cell1))
-          end do
+         end do
       end do
 
-!  end WCS bug fix
-
-      do iCell = 1, grid % nCells
-         do k=1,grid % nVertLevels
+      do iCell = 1, nCells
+         do k=1,nVertLevels
             diag % rho_p % array(k,iCell) = state % rho_zz % array(k,iCell) - diag % rho_base % array(k,iCell)
          end do
       end do
 
-      do iCell = 1, grid % nCells
-         do k=1,grid % nVertLevels
+      do iCell = 1, nCells
+         do k=1,nVertLevels
             diag % rtheta_base % array(k,iCell) = diag % theta_base % array(k,iCell) * diag % rho_base % array(k,iCell)
          end do
       end do
 
-      do iCell = 1, grid % nCells
-         do k=1,grid % nVertLevels
+      do iCell = 1, nCells
+         do k=1,nVertLevels
             diag % rtheta_p % array(k,iCell) = state % theta_m % array(k,iCell) * diag % rho_p % array(k,iCell)  &amp;
                                              + diag % rho_base % array(k,iCell)   * (state % theta_m % array(k,iCell) - diag % theta_base % array(k,iCell))
          end do
       end do
 
-      do iCell=1,grid % nCells
-         do k=1,grid % nVertLevels
+      do iCell=1,nCells
+         do k=1,nVertLevels
             diag % exner % array(k,iCell) = (grid % zz % array(k,iCell) * (rgas/p0) * (diag % rtheta_p % array(k,iCell) + diag % rtheta_base % array(k,iCell)))**rcv
          end do
       end do
 
-      do iCell=1,grid % nCells
-         do k=1,grid % nVertLevels
+      do iCell=1,nCells
+         do k=1,nVertLevels
             diag % pressure_p % array(k,iCell) = grid % zz % array(k,iCell) * rgas &amp;
                                                * (  diag % exner % array(k,iCell) * diag % rtheta_p % array(k,iCell) &amp;
                                                   + diag % rtheta_base % array(k,iCell) * (diag % exner % array(k,iCell) - diag % exner_base % array(k,iCell)) &amp;

Index: branches/mpas_cdg_advection/src/core_ocean
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean        2013-04-22 01:31:32 UTC (rev 2783)

Property changes on: branches/mpas_cdg_advection/src/core_ocean
___________________________________________________________________
Modified: svn:mergeinfo
## -1,9 +1,11 ##
 /branches/atmos_physics/src/core_ocean:1672-1846
 /branches/cam_mpas_nh/src/core_ocean:1260-1270
+/branches/history_attribute/src/core_ocean:2698-2745
 /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
## -21,6 +23,7 ##
 /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/variable_name_change/src/core_ocean:2689-2767
 /branches/ocean_projects/vert_adv_mrp/src/core_ocean:704-745
 /branches/ocean_projects/vol_cons_RK_imp_mix/src/core_ocean:1965-1992
 /branches/ocean_projects/zstar_restart_new/src/core_ocean:1762-1770
## -31,6 +34,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:2390-2599
+/branches/xml_registry/src/core_ocean:2610-2662
+/trunk/mpas/src/core_ocean:2390-2782
\ No newline at end of property
Modified: branches/mpas_cdg_advection/src/core_ocean/Makefile
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/Makefile        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/Makefile        2013-04-22 01:31:32 UTC (rev 2783)
@@ -15,21 +15,6 @@
        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 \
@@ -37,6 +22,9 @@
        mpas_ocn_restoring.o \
        mpas_ocn_tendency.o \
        mpas_ocn_diagnostics.o \
+           mpas_ocn_tracer_hmix.o \
+           mpas_ocn_tracer_hmix_del2.o \
+           mpas_ocn_tracer_hmix_del4.o \
        mpas_ocn_tracer_advection.o \
        mpas_ocn_tracer_advection_std.o \
        mpas_ocn_tracer_advection_std_hadv.o \
@@ -104,30 +92,6 @@
 
 mpas_ocn_vel_coriolis.o:
 
-mpas_ocn_tracer_hadv.o:  mpas_ocn_tracer_hadv2.o  mpas_ocn_tracer_hadv3.o  mpas_ocn_tracer_hadv4.o
-
-mpas_ocn_tracer_hadv2.o:
-
-mpas_ocn_tracer_hadv3.o:
-
-mpas_ocn_tracer_hadv4.o:
-
-mpas_ocn_tracer_vadv.o: mpas_ocn_tracer_vadv_spline.o mpas_ocn_tracer_vadv_stencil.o
-
-mpas_ocn_tracer_vadv_spline.o: mpas_ocn_tracer_vadv_spline2.o  mpas_ocn_tracer_vadv_spline3.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_vadv_stencil2.o:
-
-mpas_ocn_tracer_vadv_stencil3.o:
-
-mpas_ocn_tracer_vadv_stencil4.o:
-
 mpas_ocn_tracer_hmix.o: mpas_ocn_tracer_hmix_del2.o mpas_ocn_tracer_hmix_del4.o
 
 mpas_ocn_tracer_hmix_del2.o:
@@ -183,18 +147,6 @@
                       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 \

Copied: branches/mpas_cdg_advection/src/core_ocean/Registry.xml (from rev 2782, trunk/mpas/src/core_ocean/Registry.xml)
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/Registry.xml                                (rev 0)
+++ branches/mpas_cdg_advection/src/core_ocean/Registry.xml        2013-04-22 01:31:32 UTC (rev 2783)
@@ -0,0 +1,1071 @@
+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;registry model=&quot;mpas&quot; core=&quot;ocean&quot; version=&quot;0.0.0&quot;&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;unitless&quot;
+                            description=&quot;If true, the Leith enstrophy-cascade closure is turned on&quot;
+                            possible_values=&quot;.true. or .false.&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_Leith_parameter&quot; type=&quot;real&quot; default_value=&quot;1.0&quot; units=&quot;non-dimensional&quot;
+                            description=&quot;Non-dimensional Leith closure parameter&quot;
+                            possible_values=&quot;any positive real&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_Leith_dx&quot; type=&quot;real&quot; default_value=&quot;15000.0&quot; units=&quot;m&quot;
+                            description=&quot;Characteristic length scale, usually the smallest dx in the mesh&quot;
+                            possible_values=&quot;any positive real&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_Leith_visc2_max&quot; type=&quot;real&quot; default_value=&quot;2.5e3&quot; units=&quot;m^2 s^{-1}&quot;
+                            description=&quot;Upper bound on the allowable value of Leith-computed viscosity&quot;
+                            possible_values=&quot;any positive real&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 normalVelocityForcing, 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;unitless&quot;
+                            description=&quot;Method for interpolating tracer values from layer centers to layer edges&quot;
+                            possible_values=&quot;'spline' and 'stencil'&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_vert_tracer_adv_order&quot; type=&quot;integer&quot; default_value=&quot;3&quot; units=&quot;unitless&quot;
+                            description=&quot;Order of polynomial used for tracer reconstruction at layer edges&quot;
+                            possible_values=&quot;2, 3 and 4&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_horiz_tracer_adv_order&quot; type=&quot;integer&quot; default_value=&quot;3&quot; units=&quot;unitless&quot;
+                            description=&quot;Order of polynomial used for tracer reconstruction at cell edges&quot;
+                            possible_values=&quot;2, 3 and 4&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_coef_3rd_order&quot; type=&quot;real&quot; default_value=&quot;0.25&quot; units=&quot;non-dimensional&quot;
+                            description=&quot;Reconstruction of 3rd-order reconstruction to blend with 4th-order reconstuction&quot;
+                            possible_values=&quot;any real between 0 and 1&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_monotonic&quot; type=&quot;logical&quot; default_value=&quot;.true.&quot; units=&quot;unitless&quot;
+                            description=&quot;If .true. then fluxes are limited to produce a monotonic advection scheme&quot;
+                            possible_values=&quot;.true. and .false.&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_density0&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;unitless&quot;
+                            description=&quot;Character string to choose EOS formulation&quot;
+                            possible_values=&quot;Jackett McDougall EOS = 'jm' and Linear EOS = 'linear'&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;kg m^{-3} C^{-1}&quot;
+                            description=&quot;Linear thermal expansion coefficient&quot;
+                            possible_values=&quot;any positive real&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;kg m^{-3} PSU^{-1}&quot;
+                            description=&quot;Linear haline contraction coefficient&quot;
+                            possible_values=&quot;any positive real&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_eos_linear_Tref&quot; type=&quot;real&quot; default_value=&quot;19.0&quot; units=&quot;C&quot;
+                            description=&quot;Reference temperature&quot;
+                            possible_values=&quot;any real&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_eos_linear_Sref&quot; type=&quot;real&quot; default_value=&quot;35.0&quot; units=&quot;PSU&quot;
+                            description=&quot;Reference salinity&quot;
+                            possible_values=&quot;any real&quot;
+                /&gt;
+                &lt;nml_option name=&quot;config_eos_linear_densityref&quot; type=&quot;real&quot; default_value=&quot;1025.022&quot; units=&quot;kg m^{-3}&quot;
+                            description=&quot;Reference density, i.e. density when T=Tref and S=Sref&quot;
+                            possible_values=&quot;any positive real&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_vel_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_velWt1&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_velWt2&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_thick_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_thick_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_thick_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_vel_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_vel_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_vel_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_vel_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_vel_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_vel_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_vel_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;normalVelocity&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;layerThickness&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;density&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;normalBarotropicVelocity&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;normalBarotropicVelocitySubcycle&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;barotropicThicknessFlux&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;barotropicForcing&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;normalBaroclinicVelocity&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;tangentialVelocity&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;relativeVorticity&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;potentialVorticityEdge&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;potentialVorticityVertex&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;potentialVorticityCell&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;layerThicknessEdge&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;layerThicknessVertex&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;kineticEnergy&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;kineticEnergyVertex&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;kineticEnergyVertexOnCells&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;kineticEnergyEdge&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;normalVelocityX&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;normalVelocityY&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;normalVelocityZ&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;normalVelocityZonal&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;normalVelocityMeridional&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;normalVelocityForcingReconstructX&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;normalVelocityForcingReconstructY&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;normalVelocityForcingReconstructZ&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;normalVelocityForcingReconstructZonal&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;normalVelocityForcingReconstructMeridional&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;montgomeryPotential&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;vertTransportVelocityTop&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;displacedDensity&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;nAverage&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;avgSsh&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;varSsh&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;avgNormalVelocityZonal&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;avgNormalVelocityMeridional&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;varNormalVelocityZonal&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;varNormalVelocityMeridional&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;avgNormalVelocity&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;varNormalVelocity&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;avgVertVelocityTop&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;m^{-2}&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;m&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;m&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;m&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;m^{-1}&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;m^{-1}&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;unitless&quot;
+                         description=&quot;Coefficients to reconstruct velocity vectors at cells centers.&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;normalVelocityForcing&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_normalVelocity&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nEdges Time&quot; units=&quot;m s^{-2}&quot; name_in_code=&quot;normalVelocity&quot;
+                     description=&quot;time tendency of normal component of velocity&quot;
+                /&gt;
+                &lt;var name=&quot;tend_layerThickness&quot; type=&quot;real&quot; dimensions=&quot;nVertLevels nCells Time&quot; units=&quot;m s^{-1}&quot; name_in_code=&quot;layerThickness&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;

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_diagnostics.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_diagnostics.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_diagnostics.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -8,7 +8,7 @@
 !&gt; \version SVN:$Id:$
 !&gt; \details
 !&gt;  This module contains the routines for computing
-!&gt;  diagnostic variables, and other quantities such as wTop.
+!&gt;  diagnostic variables, and other quantities such as vertTransportVelocityTop.
 !
 !-----------------------------------------------------------------------
 
@@ -41,10 +41,10 @@
    !--------------------------------------------------------------------
 
    public :: ocn_diagnostic_solve, &amp;
-             ocn_wtop, &amp;
+             ocn_vert_transport_velocity_top, &amp;
              ocn_fuperp, &amp;
-             ocn_filter_btr_mode_u, &amp;
-             ocn_filter_btr_mode_tend_u, &amp;
+             ocn_filter_btr_mode_vel, &amp;
+             ocn_filter_btr_mode_tend_vel, &amp;
              ocn_diagnostics_init
 
    !--------------------------------------------------------------------
@@ -92,42 +92,42 @@
         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
+        invAreaCell1, invAreaCell2, invAreaTri1, invAreaTri2, invLength, layerThicknessVertex, 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;
+        weightsOnEdge, kiteAreasOnVertex, layerThicknessEdge, layerThickness, normalVelocity, tangentialVelocity, pressure,&amp;
+        circulation, relativeVorticity, kineticEnergy, kineticEnergyEdge, montgomeryPotential, vertTransportVelocityTop, zMid, &amp;
+        potentialVorticityEdge, potentialVorticityVertex, potentialVorticityCell, gradVor_n, gradVor_t, divergence, &amp;
+        density, displacedDensity, temperature, salinity, kineticEnergyVertex, kineticEnergyVertexOnCells, 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
+      layerThickness =&gt; s % layerThickness % array
+      normalVelocity =&gt; s % normalVelocity % array
       uTransport  =&gt; s % uTransport % array
       uBolusGM    =&gt; s % uBolusGM % array
-      v           =&gt; s % v % array
-      h_edge      =&gt; s % h_edge % array
+      tangentialVelocity =&gt; s % tangentialVelocity % array
+      layerThicknessEdge =&gt; s % layerThicknessEdge % array
       circulation =&gt; s % circulation % array
-      vorticity   =&gt; s % vorticity % array
+      relativeVorticity   =&gt; s % relativeVorticity % 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
+      kineticEnergy          =&gt; s % kineticEnergy % array
+      kineticEnergyVertex         =&gt; s % kineticEnergyVertex % array
+      kineticEnergyVertexOnCells        =&gt; s % kineticEnergyVertexOnCells % array
+      kineticEnergyEdge     =&gt; s % kineticEnergyEdge % array
+      potentialVorticityEdge    =&gt; s % potentialVorticityEdge % array
+      potentialVorticityVertex  =&gt; s % potentialVorticityVertex % array
+      potentialVorticityCell    =&gt; s % potentialVorticityCell % 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
+      density         =&gt; s % density % array
+      displacedDensity=&gt; s % displacedDensity % array
+      montgomeryPotential     =&gt; s % montgomeryPotential % array
       pressure    =&gt; s % pressure % array
       zMid        =&gt; s % zMid % array
       ssh         =&gt; s % ssh % array
@@ -174,20 +174,18 @@
 
       !
       ! Compute height on cell edges at velocity locations
-      !   Namelist options control the order of accuracy of the reconstructed h_edge value
+      !   Namelist options control the order of accuracy of the reconstructed layerThicknessEdge 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
+      ! initialize layerThicknessEdge to avoid divide by zero and NaN problems.
+      layerThicknessEdge = -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))
+            layerThicknessEdge(k,iEdge) = 0.5 * (layerThickness(k,cell1) + layerThickness(k,cell2))
          end do
       end do
 
@@ -195,26 +193,26 @@
       ! 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
+      normalVelocity(:,nEdges+1) = -1e34
+      layerThickness(:,nCells+1) = -1e34
       tracers(s % index_temperature,:,nCells+1) = -1e34
       tracers(s % index_salinity,:,nCells+1) = -1e34
 
       circulation(:,:) = 0.0
-      vorticity(:,:) = 0.0
+      relativeVorticity(:,:) = 0.0
       divergence(:,:) = 0.0
       vertVelocityTop(:,:)=0.0
-      ke(:,:) = 0.0
-      v(:,:) = 0.0
+      kineticEnergy(:,:) = 0.0
+      tangentialVelocity(:,:) = 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)
+              r_tmp = dcEdge(iEdge) * normalVelocity(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
+              relativeVorticity(k, iVertex) = relativeVorticity(k, iVertex) + edgeSignOnVertex(i, iVertex) * r_tmp * invAreaTri1
             end do
          end do
       end do
@@ -226,11 +224,11 @@
          do i = 1, nEdgesOnCell(iCell)
             iEdge = edgesOnCell(i, iCell)
             do k = 1, maxLevelCell(iCell)
-               r_tmp = dvEdge(iEdge) * u(k, iEdge) * invAreaCell1
+               r_tmp = dvEdge(iEdge) * normalVelocity(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)
+               div_hu(k)    = div_hu(k) - layerThicknessEdge(k, iEdge) * edgeSignOnCell(i, iCell) * r_tmp 
+               kineticEnergy(k, iCell) = kineticEnergy(k, iCell) + 0.25 * r_tmp * dcEdge(iEdge) * normalVelocity(k,iEdge)
             end do
          end do
          ! Vertical velocity at bottom (maxLevelCell(iCell)+1) is zero, initialized above.
@@ -244,25 +242,22 @@
          ! 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)
+               tangentialVelocity(k,iEdge) = tangentialVelocity(k,iEdge) + weightsOnEdge(i,iEdge) * normalVelocity(k, eoe)
             end do
          end do
-
       end do
 
       !
       ! Compute kinetic energy in each vertex
       !
-      kev(:,:) = 0.0; kevc(:,:) = 0.0
+      kineticEnergyVertex(:,:) = 0.0; kineticEnergyVertexOnCells(:,:) = 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
+            kineticEnergyVertex(k, iVertex) = kineticEnergyVertex(k, iVertex) + r_tmp * normalVelocity(k, iEdge)**2
           end do
         end do
       end do
@@ -273,57 +268,55 @@
           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
+            kineticEnergyVertexOnCells(k, iCell) = kineticEnergyVertexOnCells(k, iCell) + kiteAreasOnVertex(j, iVertex) * kineticEnergyVertex(k, iVertex) * invAreaCell1
           end do
         end do
       end do
 
       !
-      ! Compute kinetic energy in each cell by blending ke and kevc
+      ! Compute kinetic energy in each cell by blending kineticEnergy and kineticEnergyVertexOnCells
       !
       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)
+            kineticEnergy(k,iCell) = 5.0/8.0*kineticEnergy(k,iCell) + 3.0/8.0*kineticEnergyVertexOnCells(k,iCell)
          end do
       end do
 
       !
-      ! Compute ke on cell edges at velocity locations for quadratic bottom drag. 
+      ! Compute kineticEnergy 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))
+            kineticEnergyEdge(k,iEdge) = 0.5 * (kineticEnergy(k,cell1) + kineticEnergy(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 )
+      !  ( this computes potentialVorticityVertex 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
+            layerThicknessVertex = 0.0
             do i=1,vertexDegree
-               h_vertex = h_vertex + h(k,cellsOnVertex(i,iVertex)) * kiteAreasOnVertex(i,iVertex)
+               layerThicknessVertex = layerThicknessVertex + layerThickness(k,cellsOnVertex(i,iVertex)) * kiteAreasOnVertex(i,iVertex)
             end do
-            h_vertex = h_vertex * invAreaTri1
+            layerThicknessVertex = layerThicknessVertex * invAreaTri1
 
-            Vor_vertex(k,iVertex) = (fCoef*fVertex(iVertex) + vorticity(k,iVertex)) / h_vertex
+            potentialVorticityVertex(k,iVertex) = (fCoef*fVertex(iVertex) + relativeVorticity(k,iVertex)) / layerThicknessVertex
          end do
       end do
 
-      Vor_cell(:,:) = 0.0
-      Vor_edge(:,:) = 0.0
+      potentialVorticityCell(:,:) = 0.0
+      potentialVorticityEdge(:,:) = 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))
+          potentialVorticityEdge(k, iEdge) = 0.5 * (potentialVorticityVertex(k, vertex1) + potentialVorticityVertex(k, vertex2))
         end do
       end do
 
@@ -334,7 +327,7 @@
           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
+            potentialVorticityCell(k, iCell) = potentialVorticityCell(k, iCell) + kiteAreasOnVertex(j, iVertex) * potentialVorticityVertex(k, iVertex) * invAreaCell1
           end do
         end do
       end do
@@ -349,14 +342,14 @@
          ! 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
+            gradVor_n(k,iEdge) = (potentialVorticityCell(k,cell2) - potentialVorticityCell(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
+           gradVor_t(k,iEdge) = (potentialVorticityVertex(k,vertex2) - potentialVorticityVertex(k,vertex1)) * invLength
          enddo
 
       enddo
@@ -366,9 +359,9 @@
       !
       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) )
+           potentialVorticityEdge(k,iEdge) = potentialVorticityEdge(k,iEdge) &amp;
+             - config_apvm_scale_factor * dt* (  normalVelocity(k,iEdge) * gradVor_n(k,iEdge) &amp;
+                          + tangentialVelocity(k,iEdge) * gradVor_t(k,iEdge) )
          enddo
       enddo
 
@@ -381,19 +374,18 @@
          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)
+         call ocn_equation_of_state_density(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)
+         ! compute displacedDensity, the potential density referenced to the top layer
+         call ocn_equation_of_state_density(s, grid, 1, 'relative', err)
 
          call mpas_timer_stop(&quot;equation of state&quot;, diagEOSTimer)
       endif
 
       !
       ! Pressure
-      ! This section must be after computing rho
+      ! This section must be after computing density
       !
-      ! dwj: 10/25/2011 - Need to explore isopycnal vs zlevel flags
       if (config_pressure_gradient_type.eq.'MontgomeryPotential') then
 
         ! For Isopycnal model.
@@ -407,15 +399,15 @@
            ! 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)))
+           montgomeryPotential(1,iCell) = gravity &amp;
+              * (bottomDepth(iCell) + sum(layerThickness(1:nVertLevels,iCell)))
 
            do k=2,nVertLevels
-              pTop(k) = pTop(k-1) + rho(k-1,iCell)*gravity* h(k-1,iCell)
+              pTop(k) = pTop(k-1) + density(k-1,iCell)*gravity* layerThickness(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)) 
+              ! from delta M = p delta / density
+              montgomeryPotential(k,iCell) = montgomeryPotential(k-1,iCell) &amp;
+                 + pTop(k)*(1.0/density(k,iCell) - 1.0/density(k-1,iCell)) 
            end do
 
         end do
@@ -427,26 +419,26 @@
            ! 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)
+           pressure(1,iCell) = seaSurfacePressure(iCell) + density(1,iCell)*gravity &amp;
+              * 0.5*layerThickness(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))
+                + 0.5*gravity*(  density(k-1,iCell)*layerThickness(k-1,iCell) &amp;
+                               + density(k  ,iCell)*layerThickness(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.
+           ! This is used for the density 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)
+           zMid(k:nVertLevels,iCell) = -bottomDepth(iCell) + 0.5*layerThickness(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))
+                + 0.5*(  layerThickness(k+1,iCell) &amp;
+                       + layerThickness(k  ,iCell))
            end do
 
         end do
@@ -456,11 +448,11 @@
       !
       ! Brunt-Vaisala frequency
       !
-      coef = -gravity/config_rho0
+      coef = -gravity/config_density0
       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; 
+            BruntVaisalaFreqTop(k,iCell) = coef * (displacedDensity(k-1,iCell) - displacedDensity(k,iCell)) &amp; 
               / (zMid(k-1,iCell) - zMid(k,iCell))
           end do
       end do
@@ -474,7 +466,7 @@
          ! 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))
+         ssh(iCell) = - bottomDepth(iCell) + sum(layerThickness(1:maxLevelCell(iCell),iCell))
 
       end do
 
@@ -484,7 +476,6 @@
       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
 
@@ -492,7 +483,7 @@
 
 !***********************************************************************
 !
-!  routine ocn_wtop
+!  routine ocn_vert_transport_velocity_top
 !
 !&gt; \brief   Computes vertical transport
 !&gt; \author  Mark Petersen
@@ -503,7 +494,7 @@
 !&gt;  cell.
 !
 !-----------------------------------------------------------------------
-   subroutine ocn_wtop(grid,h,h_edge,u,wTop, err)!{{{
+   subroutine ocn_vert_transport_velocity_top(grid,layerThickness,layerThicknessEdge,normalVelocity,vertTransportVelocityTop, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -515,13 +506,13 @@
          grid          !&lt; Input: grid information
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h    !&lt; Input: thickness
+         layerThickness    !&lt; Input: thickness
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge     !&lt; Input: h interpolated to an edge
+         layerThicknessEdge     !&lt; Input: layerThickness interpolated to an edge
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         u     !&lt; Input: transport
+         normalVelocity     !&lt; Input: transport
 
       !-----------------------------------------------------------------
       !
@@ -530,7 +521,7 @@
       !-----------------------------------------------------------------
 
       real (kind=RKIND), dimension(:,:), intent(out) :: &amp;
-         wTop     !&lt; Output: vertical transport at top of cell
+         vertTransportVelocityTop     !&lt; Output: vertical transport at top of cell
 
       integer, intent(out) :: err !&lt; Output: error flag
 
@@ -541,7 +532,7 @@
       !-----------------------------------------------------------------
 
       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
+      real (kind=RKIND) :: flux, layerThicknessVertex, workpv, density0Inv, thicknessSum, invAreaCell
 
       integer :: nCells, nEdges, nVertices, nVertLevels, vertexDegree
 
@@ -577,7 +568,7 @@
 
       if (config_vert_coord_movement.eq.'isopycnal') then
         ! set vertical transport to zero in isopycnal case
-        wTop=0.0
+        vertTransportVelocityTop=0.0
         return
       end if
 
@@ -591,39 +582,39 @@
       do iCell=1,nCells
         div_hu(:) = 0.0
         div_hu_btr = 0.0
-        hSum = 0.0
+        thicknessSum = 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
+            flux = layerThicknessEdge(k, iEdge) * normalVelocity(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)
+           h_tend_col(k) = - vertCoordMovementWeights(k) * layerThickness(k, iCell) * div_hu_btr
+           thicknessSum = thicknessSum + vertCoordMovementWeights(k) * layerThickness(k, iCell)
         end do
 
-        if(hSum &gt; 0.0) then
-           h_tend_col = h_tend_col / hSum
+        if(thicknessSum &gt; 0.0) then
+           h_tend_col = h_tend_col / thicknessSum
         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
+        vertTransportVelocityTop(1,iCell) = 0.0
+        vertTransportVelocityTop(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)
+           vertTransportVelocityTop(k,iCell) = vertTransportVelocityTop(k+1,iCell) - div_hu(k) - h_tend_col(k)
         end do
       end do
 
       deallocate(div_hu, h_tend_col)
 
-   end subroutine ocn_wtop!}}}
+   end subroutine ocn_vert_transport_velocity_top!}}}
 
 !***********************************************************************
 !
@@ -644,13 +635,10 @@
       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
+      real (kind=RKIND), dimension(:,:), pointer :: weightsOnEdge, normalVelocity, normalBaroclinicVelocity
       type (dm_info) :: dminfo
 
       integer, dimension(:), pointer :: maxLevelEdgeTop, nEdgesOnEdge
@@ -658,8 +646,8 @@
 
       call mpas_timer_start(&quot;ocn_fuperp&quot;)
 
-      u           =&gt; s % u % array
-      uBcl        =&gt; s % uBcl % array
+      normalVelocity           =&gt; s % normalVelocity % array
+      normalBaroclinicVelocity        =&gt; s % normalBaroclinicVelocity % array
       weightsOnEdge     =&gt; grid % weightsOnEdge % array
       fEdge             =&gt; grid % fEdge % array
       maxLevelEdgeTop      =&gt; grid % maxLevelEdgeTop % array
@@ -672,7 +660,7 @@
       nEdgesSolve = grid % nEdgesSolve
 
       !
-      ! Put f*uBcl^{perp} in u as a work variable
+      ! Put f*normalBaroclinicVelocity^{perp} in u as a work variable
       !
       do iEdge=1,nEdgesSolve
          cell1 = cellsOnEdge(1,iEdge)
@@ -680,10 +668,10 @@
 
          do k=1,maxLevelEdgeTop(iEdge)
 
-            u(k,iEdge) = 0.0
+            normalVelocity(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) 
+               normalVelocity(k,iEdge) = normalVelocity(k,iEdge) + weightsOnEdge(j,iEdge) * normalBaroclinicVelocity(k,eoe) * fEdge(eoe) 
             end do
          end do
       end do
@@ -694,7 +682,7 @@
 
 !***********************************************************************
 !
-!  routine ocn_filter_btr_mode_u
+!  routine ocn_filter_btr_mode_vel
 !
 !&gt; \brief   filters barotropic mode out of the velocity variable.
 !&gt; \author  Mark Petersen
@@ -704,60 +692,60 @@
 !&gt;  This routine filters barotropic mode out of the velocity variable.
 !
 !-----------------------------------------------------------------------
-   subroutine ocn_filter_btr_mode_u(s, grid)!{{{
+   subroutine ocn_filter_btr_mode_vel(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
+      real (kind=RKIND) :: vertSum, normalThicknessFluxSum, thicknessSum
+      real (kind=RKIND), dimension(:,:), pointer :: layerThicknessEdge, normalVelocity
       integer, dimension(:), pointer :: maxLevelEdgeTop
 
-      call mpas_timer_start(&quot;ocn_filter_btr_mode_u&quot;)
+      call mpas_timer_start(&quot;ocn_filter_btr_mode_vel&quot;)
 
-      u           =&gt; s % u % array
-      h_edge      =&gt; s % h_edge % array
+      normalVelocity =&gt; s % normalVelocity % array
+      layerThicknessEdge =&gt; s % layerThicknessEdge % 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 
+        ! thicknessSum is initialized outside the loop because on land boundaries 
+        ! maxLevelEdgeTop=0, but I want to initialize thicknessSum with a 
         ! nonzero value to avoid a NaN.
-        uhSum = h_edge(1,iEdge) * u(1,iEdge)
-        hSum  = h_edge(1,iEdge)
+        normalThicknessFluxSum = layerThicknessEdge(1,iEdge) * normalVelocity(1,iEdge)
+        thicknessSum  = layerThicknessEdge(1,iEdge)
 
         do k=2,maxLevelEdgeTop(iEdge)
-          uhSum = uhSum + h_edge(k,iEdge) * u(k,iEdge)
-          hSum  =  hSum + h_edge(k,iEdge)
+          normalThicknessFluxSum = normalThicknessFluxSum + layerThicknessEdge(k,iEdge) * normalVelocity(k,iEdge)
+          thicknessSum  =  thicknessSum + layerThicknessEdge(k,iEdge)
         enddo
 
-        vertSum = uhSum/hSum
+        vertSum = normalThicknessFluxSum/thicknessSum
         do k=1,maxLevelEdgeTop(iEdge)
-          u(k,iEdge) = u(k,iEdge) - vertSum
+          normalVelocity(k,iEdge) = normalVelocity(k,iEdge) - vertSum
         enddo
       enddo ! iEdge
 
-      call mpas_timer_stop(&quot;ocn_filter_btr_mode_u&quot;)
+      call mpas_timer_stop(&quot;ocn_filter_btr_mode_vel&quot;)
 
-   end subroutine ocn_filter_btr_mode_u!}}}
+   end subroutine ocn_filter_btr_mode_vel!}}}
 
 !***********************************************************************
 !
-!  routine ocn_filter_btr_mode_tend_u
+!  routine ocn_filter_btr_mode_tend_vel
 !
-!&gt; \brief   ocn_filters barotropic mode out of the u tendency
+!&gt; \brief   ocn_filters barotropic mode out of the velocity 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.
+!&gt;  This routine filters barotropic mode out of the velocity tendency.
 !
 !-----------------------------------------------------------------------
-   subroutine ocn_filter_btr_mode_tend_u(tend, s, grid)!{{{
+   subroutine ocn_filter_btr_mode_tend_vel(tend, s, grid)!{{{
       implicit none
 
       type (tend_type), intent(inout) :: tend
@@ -765,40 +753,40 @@
       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
+      real (kind=RKIND) :: vertSum, normalThicknessFluxSum, thicknessSum
+      real (kind=RKIND), dimension(:,:), pointer :: layerThicknessEdge, tend_normalVelocity
 
       integer, dimension(:), pointer :: maxLevelEdgeTop
 
-      call mpas_timer_start(&quot;ocn_filter_btr_mode_tend_u&quot;)
+      call mpas_timer_start(&quot;ocn_filter_btr_mode_tend_vel&quot;)
 
-      tend_u      =&gt; tend % u % array
-      h_edge      =&gt; s % h_edge % array
+      tend_normalVelocity      =&gt; tend % normalVelocity % array
+      layerThicknessEdge      =&gt; s % layerThicknessEdge % 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 
+        ! thicknessSum is initialized outside the loop because on land boundaries 
+        ! maxLevelEdgeTop=0, but I want to initialize thicknessSum with a 
         ! nonzero value to avoid a NaN.
-        uhSum = h_edge(1,iEdge) * tend_u(1,iEdge)
-        hSum  = h_edge(1,iEdge)
+        normalThicknessFluxSum = layerThicknessEdge(1,iEdge) * tend_normalVelocity(1,iEdge)
+        thicknessSum  = layerThicknessEdge(1,iEdge)
 
         do k=2,maxLevelEdgeTop(iEdge)
-          uhSum = uhSum + h_edge(k,iEdge) * tend_u(k,iEdge)
-          hSum  =  hSum + h_edge(k,iEdge)
+          normalThicknessFluxSum = normalThicknessFluxSum + layerThicknessEdge(k,iEdge) * tend_normalVelocity(k,iEdge)
+          thicknessSum  =  thicknessSum + layerThicknessEdge(k,iEdge)
         enddo
 
-        vertSum = uhSum/hSum
+        vertSum = normalThicknessFluxSum/thicknessSum
         do k=1,maxLevelEdgeTop(iEdge)
-          tend_u(k,iEdge) = tend_u(k,iEdge) - vertSum
+          tend_normalVelocity(k,iEdge) = tend_normalVelocity(k,iEdge) - vertSum
         enddo
       enddo ! iEdge
 
-      call mpas_timer_stop(&quot;ocn_filter_btr_mode_tend_u&quot;)
+      call mpas_timer_stop(&quot;ocn_filter_btr_mode_tend_vel&quot;)
 
-   end subroutine ocn_filter_btr_mode_tend_u!}}}
+   end subroutine ocn_filter_btr_mode_tend_vel!}}}
 
 !***********************************************************************
 !
@@ -827,15 +815,13 @@
         endif
 
         if (trim(config_time_integrator) == 'RK4') then
-            ! for RK4, PV is really PV = (eta+f)/h
+            ! 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 f is added separately to the momentum forcing.
-            ! mrp temp, new should be:
+            ! For split explicit, PV is eta/h because the Coriolis term 
+            ! is added separately to the momentum tendencies.
             fCoef = 0
-            ! old, for testing:
-            !         fCoef = 1
         end if
 
     end subroutine ocn_diagnostics_init!}}}

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_equation_of_state.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_equation_of_state.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_equation_of_state.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -36,7 +36,7 @@
    !
    !--------------------------------------------------------------------
 
-   public :: ocn_equation_of_state_rho, &amp;
+   public :: ocn_equation_of_state_density, &amp;
              ocn_equation_of_state_init
 
    !--------------------------------------------------------------------
@@ -66,7 +66,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_equation_of_state_rho(s, grid, k_displaced, displacement_type, err)!{{{
+   subroutine ocn_equation_of_state_density(s, grid, k_displaced, displacement_type, err)!{{{
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !  This module contains routines necessary for computing the density
    !  from model temperature and salinity using an equation of state.
@@ -75,11 +75,11 @@
    !        s - state: tracers
    !        k_displaced 
    !
-   !  If k_displaced==0, state % rho is returned with no displacement 
+   !  If k_displaced==0, state % density is returned with no displacement 
    !
-   !  If k_displaced~=0,the state % rhoDisplaced is returned, and is for
+   !  If k_displaced~=0,the state % displacedDensity is returned, and is for
    !  a parcel adiabatically displaced from its original level to level 
-   !  k_displaced.  When using the linear EOS, state % rhoDisplaced is 
+   !  k_displaced.  When using the linear EOS, state % displacedDensity is 
    !  still filled, but depth (i.e. pressure) does not modify the output.
    !
    ! Output: s - state: computed density
@@ -93,7 +93,7 @@
       character(len=*), intent(in) :: displacement_type
 
       integer, dimension(:), pointer :: maxLevelCell
-      real (kind=RKIND), dimension(:,:), pointer :: rho
+      real (kind=RKIND), dimension(:,:), pointer :: density
       real (kind=RKIND), dimension(:,:,:), pointer :: tracers
       integer :: nCells, iCell, k, indexT, indexS
       type (dm_info) :: dminfo
@@ -106,24 +106,24 @@
       indexT = s % index_temperature
       indexS = s % index_salinity
 
-      !  Choose to fill the array rho or rhoDisplaced
+      !  Choose to fill the array density or displacedDensity
       if (k_displaced == 0) then
-         rho =&gt; s % rho % array
+         density =&gt; s % density % array
       else
-         rho =&gt; s % rhoDisplaced % array
+         density =&gt; s % displacedDensity % array
       endif
 
       if (linearEos) then
 
-         call ocn_equation_of_state_linear_rho(grid, indexT, indexS, tracers, rho, err)
+         call ocn_equation_of_state_linear_density(grid, indexT, indexS, tracers, density, err)
 
       elseif (jmEos) then
 
-         call ocn_equation_of_state_jm_rho(grid, k_displaced, displacement_type, indexT, indexS, tracers, rho, err)
+         call ocn_equation_of_state_jm_density(grid, k_displaced, displacement_type, indexT, indexS, tracers, density, err)
 
       endif
 
-   end subroutine ocn_equation_of_state_rho!}}}
+   end subroutine ocn_equation_of_state_density!}}}
 
 !***********************************************************************
 !

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_equation_of_state_jm.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_equation_of_state_jm.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_equation_of_state_jm.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -34,7 +34,7 @@
    !
    !--------------------------------------------------------------------
 
-   public :: ocn_equation_of_state_jm_rho, &amp;
+   public :: ocn_equation_of_state_jm_density, &amp;
              ocn_equation_of_state_jm_init
 
    !--------------------------------------------------------------------
@@ -49,7 +49,7 @@
 
 !***********************************************************************
 !
-!  routine ocn_equation_of_state_jm_rho
+!  routine ocn_equation_of_state_jm_density
 !
 !&gt; \brief   Calls JM equation of state
 !&gt; \author  Doug Jacobsen
@@ -60,7 +60,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_equation_of_state_jm_rho(grid, k_displaced, displacement_type, indexT, indexS, tracers, rho, err)!{{{
+   subroutine ocn_equation_of_state_jm_density(grid, k_displaced, displacement_type, indexT, indexS, tracers, density, err)!{{{
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !  This module contains routines necessary for computing the density
    !  from model temperature and salinity using an equation of state.
@@ -98,7 +98,7 @@
       real (kind=RKIND), dimension(:), pointer :: &amp;
         refBottomDepth, pRefEOS
       real (kind=RKIND), dimension(:,:), intent(inout) :: &amp;
-        rho
+        density
       real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers
 
       integer, dimension(:), pointer :: maxLevelCell
@@ -106,7 +106,7 @@
       real (kind=RKIND) :: &amp;
          TQ,SQ,             &amp;! adjusted T,S
          BULK_MOD,          &amp;! Bulk modulus
-         RHO_S,             &amp;! density at the surface
+         density_S,             &amp;! density at the surface
          DRDT0,             &amp;! d(density)/d(temperature), for surface
          DRDS0,             &amp;! d(density)/d(salinity   ), for surface
          DKDT,              &amp;! d(bulk modulus)/d(pot. temp.)
@@ -280,7 +280,7 @@
                    (uns1t2 + uns1t3*TQ + uns1t4*T2)*T2
             WORK2 = SQR*(unsqt0 + unsqt1*TQ + unsqt2*T2)
 
-            RHO_S = unt1*TQ + (unt2 + unt3*TQ + (unt4 + unt5*TQ)*T2)*T2 &amp;
+            density_S = unt1*TQ + (unt2 + unt3*TQ + (unt4 + unt5*TQ)*T2)*T2 &amp;
                             + (uns2t0*SQ + WORK1 + WORK2)*SQ
 
             !***
@@ -304,13 +304,13 @@
   
             DENOMK = 1.0/(BULK_MOD - p(k))
    
-            rho(k,iCell) = (unt0 + RHO_S)*BULK_MOD*DENOMK
+            density(k,iCell) = (unt0 + density_S)*BULK_MOD*DENOMK
 
          end do
       end do
 
       deallocate(pRefEOS,p,p2)
-   end subroutine ocn_equation_of_state_jm_rho!}}}
+   end subroutine ocn_equation_of_state_jm_density!}}}
 
 !***********************************************************************
 !

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_equation_of_state_linear.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_equation_of_state_linear.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_equation_of_state_linear.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -33,7 +33,7 @@
    !
    !--------------------------------------------------------------------
 
-   public :: ocn_equation_of_state_linear_rho, &amp;
+   public :: ocn_equation_of_state_linear_density, &amp;
              ocn_equation_of_state_linear_init
 
    !--------------------------------------------------------------------
@@ -48,7 +48,7 @@
 
 !***********************************************************************
 !
-!  routine ocn_equation_of_state_linear_rho
+!  routine ocn_equation_of_state_linear_density
 !
 !&gt; \brief   Calls equation of state
 !&gt; \author  Doug Jacobsen
@@ -59,7 +59,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_equation_of_state_linear_rho(grid, indexT, indexS, tracers, rho, err)!{{{
+   subroutine ocn_equation_of_state_linear_density(grid, indexT, indexS, tracers, density, err)!{{{
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !  This module contains routines necessary for computing the density
    !  from model temperature and salinity using an equation of state.
@@ -67,8 +67,8 @@
    ! Input: grid - grid metadata
    !        s - state: tracers
    !        k_displaced 
-   !  If k_displaced&lt;=0, state % rho is returned with no displaced
-   !  If k_displaced&gt;0,the state % rhoDisplaced is returned, and is for
+   !  If k_displaced&lt;=0, state % density is returned with no displaced
+   !  If k_displaced&gt;0,the state % densityDisplaced is returned, and is for
    !  a parcel adiabatically displaced from its original level to level 
    !  k_displaced.  This does not effect the linear EOS.
    !
@@ -77,7 +77,7 @@
       implicit none
 
       type (mesh_type), intent(in) :: grid
-      real (kind=RKIND), dimension(:,:), intent(inout) :: rho
+      real (kind=RKIND), dimension(:,:), intent(inout) :: density
       real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers
       integer, intent(in) :: indexT, indexS
       integer, intent(out) :: err
@@ -94,13 +94,13 @@
       do iCell=1,nCells
          do k=1,maxLevelCell(iCell)
             ! Linear equation of state
-            rho(k,iCell) =  config_eos_linear_rhoref &amp;
+            density(k,iCell) =  config_eos_linear_densityref &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
 
-   end subroutine ocn_equation_of_state_linear_rho!}}}
+   end subroutine ocn_equation_of_state_linear_density!}}}
 
 !***********************************************************************
 !

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_global_diagnostics.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_global_diagnostics.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_global_diagnostics.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -24,7 +24,7 @@
       ! timeIndex is the current time step counter
       ! dt is the duration of each time step
 
-      ! Sums of variables at vertices are not weighted by thickness (since h is not known at
+      ! Sums of variables at vertices are not weighted by thickness (since layerThickness is not known at
       !    vertices as it is at cell centers and at edges).
 
       implicit none
@@ -46,8 +46,8 @@
 
       real (kind=RKIND) :: volumeCellGlobal, volumeEdgeGlobal, CFLNumberGlobal, localCFL, localSum, areaCellGlobal, areaEdgeGlobal, areaTriangleGlobal
       real (kind=RKIND), dimension(:), pointer ::  areaCell, dcEdge, dvEdge, areaTriangle, areaEdge
-      real (kind=RKIND), dimension(:,:), pointer :: h, u, v, h_edge, vorticity, ke, Vor_edge, Vor_vertex, &amp;
-         Vor_cell, gradVor_n, gradVor_t, pressure, MontPot, wTop, rho, tracerTemp
+      real (kind=RKIND), dimension(:,:), pointer :: layerThickness, normalVelocity, tangentialVelocity, layerThicknessEdge, relativeVorticity, kineticEnergy, potentialVorticityEdge, potentialVorticityVertex, &amp;
+         potentialVorticityCell, gradVor_n, gradVor_t, pressure, montgomeryPotential, vertTransportVelocityTop, density, tracerTemp
       real (kind=RKIND), dimension(:,:,:), pointer :: tracers
       
       real (kind=RKIND), dimension(kMaxVariables) :: sums, mins, maxes, averages, verticalSumMins, verticalSumMaxes, reductions
@@ -85,27 +85,27 @@
          allocate(areaEdge(1:nEdgesSolve))
          areaEdge = dcEdge(1:nEdgesSolve)*dvEdge(1:nEdgesSolve)
 
-         h =&gt; state % h % array
-         u =&gt; state % u % array
-         rho =&gt; state % rho % array
+         layerThickness =&gt; state % layerThickness % array
+         normalVelocity =&gt; state % normalVelocity % array
+         density =&gt; state % density % array
          tracers =&gt; state % tracers % array
-         v =&gt; state % v % array
-         wTop =&gt; state % wTop % array
-         h_edge =&gt; state % h_edge % array
-         vorticity =&gt; state % vorticity % array
-         ke =&gt; state % ke % array
-         Vor_edge =&gt; state % Vor_edge % array
-         Vor_vertex =&gt; state % Vor_vertex % array
-         Vor_cell =&gt; state % Vor_cell % array
+         tangentialVelocity =&gt; state % tangentialVelocity % array
+         vertTransportVelocityTop =&gt; state % vertTransportVelocityTop % array
+         layerThicknessEdge =&gt; state % layerThicknessEdge % array
+         relativeVorticity =&gt; state % relativeVorticity % array
+         kineticEnergy =&gt; state % kineticEnergy % array
+         potentialVorticityEdge =&gt; state % potentialVorticityEdge % array
+         potentialVorticityVertex =&gt; state % potentialVorticityVertex % array
+         potentialVorticityCell =&gt; state % potentialVorticityCell % array
          gradVor_n =&gt; state % gradVor_n % array
          gradVor_t =&gt; state % gradVor_t % array
-         MontPot =&gt; state % MontPot % array
+         montgomeryPotential =&gt; state % montgomeryPotential % array
          pressure =&gt; state % pressure % array
 
          variableIndex = 0
-         ! h
+         ! layerThickness
          variableIndex = variableIndex + 1
-         call ocn_compute_field_area_weighted_local_stats(dminfo, nVertLevels, nCellsSolve, areaCell(1:nCellsSolve), h(:,1:nCellsSolve), &amp;
+         call ocn_compute_field_area_weighted_local_stats(dminfo, nVertLevels, nCellsSolve, areaCell(1:nCellsSolve), layerThickness(:,1:nCellsSolve), &amp;
             sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), verticalSumMaxes_tmp(variableIndex))
          sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
          mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -113,10 +113,10 @@
          verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
          verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
 
-         ! u
+         ! normalVelocity
          variableIndex = variableIndex + 1
-         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), h_edge(:,1:nEdgesSolve), &amp;
-            u(:,1:nEdgesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
+         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), layerThicknessEdge(:,1:nEdgesSolve), &amp;
+            normalVelocity(:,1:nEdgesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
             verticalSumMaxes_tmp(variableIndex))
          sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
          mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -124,10 +124,10 @@
          verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
          verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
 
-         ! v
+         ! tangentialVelocity
          variableIndex = variableIndex + 1
-         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), h_edge(:,1:nEdgesSolve), &amp;
-            v(:,1:nEdgesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
+         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), layerThicknessEdge(:,1:nEdgesSolve), &amp;
+            tangentialVelocity(:,1:nEdgesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
             verticalSumMaxes_tmp(variableIndex))
          sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
          mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -135,9 +135,9 @@
          verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
          verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
 
-         ! h_edge
+         ! layerThicknessEdge
          variableIndex = variableIndex + 1
-         call ocn_compute_field_area_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), h_edge(:,1:nEdgesSolve), &amp;
+         call ocn_compute_field_area_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), layerThicknessEdge(:,1:nEdgesSolve), &amp;
             sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), verticalSumMaxes_tmp(variableIndex))
          sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
          mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -145,9 +145,9 @@
          verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
          verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
 
-         ! vorticity
+         ! relativeVorticity
          variableIndex = variableIndex + 1
-         call ocn_compute_field_local_stats(dminfo, nVertLevels, nVerticesSolve, vorticity(:,1:nVerticesSolve), &amp;
+         call ocn_compute_field_local_stats(dminfo, nVertLevels, nVerticesSolve, relativeVorticity(:,1:nVerticesSolve), &amp;
             sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), verticalSumMaxes_tmp(variableIndex))
             sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
          mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -155,9 +155,9 @@
          verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
          verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
 
-         ! vorticity**2
+         ! relativeVorticity**2
          allocate(enstrophy(nVertLevels,nVerticesSolve))
-         enstrophy(:,:)=vorticity(:,1:nVerticesSolve)**2
+         enstrophy(:,:)=relativeVorticity(:,1:nVerticesSolve)**2
          variableIndex = variableIndex + 1
          call ocn_compute_field_area_weighted_local_stats(dminfo, nVertLevels, nVerticesSolve, areaTriangle(1:nVerticesSolve), &amp;
             enstrophy(:,:), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), &amp;
@@ -169,10 +169,10 @@
          verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
          verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
 
-         ! ke
+         ! kineticEnergy
          variableIndex = variableIndex + 1
-         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nCellsSolve, areaCell(1:nCellsSolve), h(:,1:nCellsSolve), &amp;
-            ke(:,1:nCellsSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
+         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nCellsSolve, areaCell(1:nCellsSolve), layerThickness(:,1:nCellsSolve), &amp;
+            kineticEnergy(:,1:nCellsSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
             verticalSumMaxes_tmp(variableIndex))
          sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
          mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -180,10 +180,10 @@
          verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
          verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
 
-         ! Vor_edge
+         ! potentialVorticityEdge
          variableIndex = variableIndex + 1
-         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), h_edge(:,1:nEdgesSolve), &amp;
-            Vor_edge(:,1:nEdgesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
+         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), layerThicknessEdge(:,1:nEdgesSolve), &amp;
+            potentialVorticityEdge(:,1:nEdgesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
             verticalSumMaxes_tmp(variableIndex))
          sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
          mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -191,10 +191,10 @@
          verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
          verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
 
-         ! Vor_vertex
+         ! potentialVorticityVertex
          variableIndex = variableIndex + 1
          call ocn_compute_field_area_weighted_local_stats(dminfo, nVertLevels, nVerticesSolve, areaTriangle(1:nVerticesSolve), &amp;
-            Vor_vertex(:,1:nVerticesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), &amp;
+            potentialVorticityVertex(:,1:nVerticesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), &amp;
             verticalSumMins_tmp(variableIndex), verticalSumMaxes_tmp(variableIndex))
          sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
          mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -202,10 +202,10 @@
          verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
          verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
 
-         ! Vor_cell
+         ! potentialVorticityCell
          variableIndex = variableIndex + 1
-         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nCellsSolve, areaCell(1:nCellsSolve), h(:,1:nCellsSolve), &amp;
-            Vor_cell(:,1:nCellsSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
+         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nCellsSolve, areaCell(1:nCellsSolve), layerThickness(:,1:nCellsSolve), &amp;
+            potentialVorticityCell(:,1:nCellsSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
             verticalSumMaxes_tmp(variableIndex))
          sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
          mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -215,7 +215,7 @@
 
          ! gradVor_n
          variableIndex = variableIndex + 1
-         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), h_edge(:,1:nEdgesSolve), &amp;
+         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), layerThicknessEdge(:,1:nEdgesSolve), &amp;
             gradVor_n(:,1:nEdgesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
             verticalSumMaxes_tmp(variableIndex))
          sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
@@ -226,7 +226,7 @@
 
          ! gradVor_t
          variableIndex = variableIndex + 1
-         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), h_edge(:,1:nEdgesSolve), &amp;
+         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), layerThicknessEdge(:,1:nEdgesSolve), &amp;
             gradVor_t(:,1:nEdgesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
             verticalSumMaxes_tmp(variableIndex))
          sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
@@ -237,7 +237,7 @@
 
          ! pressure
          variableIndex = variableIndex + 1
-         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nCellsSolve, areaCell(1:nCellsSolve), h(:,1:nCellsSolve), &amp;
+         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nCellsSolve, areaCell(1:nCellsSolve), layerThickness(:,1:nCellsSolve), &amp;
             pressure(:,1:nCellsSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
             verticalSumMaxes_tmp(variableIndex))
          sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
@@ -246,10 +246,10 @@
          verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
          verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
 
-         ! MontPot
+         ! montgomeryPotential
          variableIndex = variableIndex + 1
-         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nCellsSolve, areaCell(1:nCellsSolve), h(:,1:nCellsSolve), &amp;
-            MontPot(:,1:nCellsSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
+         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nCellsSolve, areaCell(1:nCellsSolve), layerThickness(:,1:nCellsSolve), &amp;
+            montgomeryPotential(:,1:nCellsSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
             verticalSumMaxes_tmp(variableIndex))
          sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
          mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -257,10 +257,10 @@
          verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
          verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
 
-         ! wTop vertical velocity
+         ! vertTransportVelocityTop vertical velocity
          variableIndex = variableIndex + 1
-         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels+1, nCellsSolve, areaCell(1:nCellsSolve), h(:,1:nCellsSolve), &amp;
-            wTop(:,1:nCellsSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
+         call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels+1, nCellsSolve, areaCell(1:nCellsSolve), layerThickness(:,1:nCellsSolve), &amp;
+            vertTransportVelocityTop(:,1:nCellsSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
             verticalSumMaxes_tmp(variableIndex))
          sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
          mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -273,7 +273,7 @@
          do iTracer=1,num_tracers
             variableIndex = variableIndex + 1
             tracerTemp = Tracers(iTracer,:,1:nCellsSolve)
-            call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nCellsSolve, areaCell(1:nCellsSolve), h(:,1:nCellsSolve), &amp;
+            call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nCellsSolve, areaCell(1:nCellsSolve), layerThickness(:,1:nCellsSolve), &amp;
                tracerTemp, sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &amp;
                verticalSumMaxes_tmp(variableIndex))
             sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
@@ -309,7 +309,7 @@
 
          localCFL = 0.0
          do elementIndex = 1,nEdgesSolve
-            localCFL = max(localCFL, maxval(dt*u(:,elementIndex)/dcEdge(elementIndex)))
+            localCFL = max(localCFL, maxval(dt*normalVelocity(:,elementIndex)/dcEdge(elementIndex)))
          end do
          nMaxes = nMaxes + 1
          maxes(nMaxes) = localCFL
@@ -350,43 +350,43 @@
       volumeEdgeGlobal = sums(4)
       ! compute the averages (slightly different depending on how the sum was computed)
       variableIndex = 0
-      ! h
+      ! layerThickness
       variableIndex = variableIndex + 1
       averages(variableIndex) = sums(variableIndex)/(areaCellGlobal*nVertLevels)
 
-      ! u
+      ! normalVelocity
       variableIndex = variableIndex + 1
       averages(variableIndex) = sums(variableIndex)/volumeEdgeGlobal
 
-      ! v
+      ! tangentialVelocity
       variableIndex = variableIndex + 1
       averages(variableIndex) = sums(variableIndex)/volumeEdgeGlobal
 
-      ! h_edge
+      ! layerThicknessEdge
       variableIndex = variableIndex + 1
       averages(variableIndex) = sums(variableIndex)/(areaEdgeGlobal*nVertLevels)
 
-      ! vorticity
+      ! relativeVorticity
       variableIndex = variableIndex + 1
       averages(variableIndex) = sums(variableIndex)/(nVerticesGlobal*nVertLevels)
 
-      ! vorticity
+      ! relativeVorticity
       variableIndex = variableIndex + 1
       averages(variableIndex) = sums(variableIndex)/(areaTriangleGlobal*nVertLevels)
 
-      ! ke
+      ! kineticEnergy
       variableIndex = variableIndex + 1
       averages(variableIndex) = sums(variableIndex)/volumeCellGlobal
 
-      ! Vor_edge
+      ! potentialVorticityEdge
       variableIndex = variableIndex + 1
       averages(variableIndex) = sums(variableIndex)/volumeEdgeGlobal
 
-      ! Vor_vertex
+      ! potentialVorticityVertex
       variableIndex = variableIndex + 1
       averages(variableIndex) = sums(variableIndex)/(areaTriangleGlobal*nVertLevels)
 
-      ! Vor_cell
+      ! potentialVorticityCell
       variableIndex = variableIndex + 1
       averages(variableIndex) = sums(variableIndex)/volumeCellGlobal
 
@@ -402,11 +402,11 @@
       variableIndex = variableIndex + 1
       averages(variableIndex) = sums(variableIndex)/volumeCellGlobal
 
-      ! MontPot
+      ! montgomeryPotential
       variableIndex = variableIndex + 1
       averages(variableIndex) = sums(variableIndex)/volumeCellGlobal
 
-      ! wTop vertical velocity
+      ! vertTransportVelocityTop vertical velocity
       variableIndex = variableIndex + 1
       averages(variableIndex) = sums(variableIndex)/volumeCellGlobal
 
@@ -544,7 +544,7 @@
 
    end subroutine ocn_compute_field_thickness_weighted_local_stats!}}}
 
-   subroutine ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nElements, areas, h, field, &amp;!{{{
+   subroutine ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nElements, areas, layerThickness, field, &amp;!{{{
       localSum, localMin, localMax, localVertSumMin, localVertSumMax)
 
       implicit none
@@ -552,7 +552,7 @@
       type (dm_info), intent(in) :: dminfo
       integer, intent(in) :: nVertLevels, nElements
       real (kind=RKIND), dimension(nElements), intent(in) :: areas
-      real (kind=RKIND), dimension(nVertLevels, nElements), intent(in) :: h
+      real (kind=RKIND), dimension(nVertLevels, nElements), intent(in) :: layerThickness
       real (kind=RKIND), dimension(nVertLevels, nElements), intent(in) :: field
       real (kind=RKIND), intent(out) :: localSum, localMin, localMax, localVertSumMin, &amp;
       localVertSumMax
@@ -563,13 +563,13 @@
 
       localSum = 0.0
       do elementIndex = 1, nElements
-        localSum = localSum + areas(elementIndex) * sum(h(:,elementIndex)*field(:,elementIndex))
+        localSum = localSum + areas(elementIndex) * sum(layerThickness(:,elementIndex)*field(:,elementIndex))
       end do
 
       localMin = minval(field)
       localMax = maxval(field)
-      localVertSumMin = minval(sum(h*field,1))
-      localVertSumMax = maxval(sum(h*field,1))
+      localVertSumMin = minval(sum(layerThickness*field,1))
+      localVertSumMax = maxval(sum(layerThickness*field,1))
 
    end subroutine ocn_compute_field_volume_weighted_local_stats!}}}
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_gm.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_gm.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_gm.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -35,13 +35,13 @@
       type(state_type), intent(inout)        :: s
       type(mesh_type), intent(in)            :: grid
 
-      real(kind=RKIND), dimension(:,:), pointer :: uBolusGM, hEddyFlux, h_edge
+      real(kind=RKIND), dimension(:,:), pointer :: uBolusGM, hEddyFlux, layerThicknessEdge
 
       integer, dimension(:), pointer   :: maxLevelEdgeTop
       integer                          :: k, iEdge, nEdges
 
       uBolusGM         =&gt; s % uBolusGM % array
-      h_edge         =&gt; s % h_edge % array
+      layerThicknessEdge =&gt; s % layerThicknessEdge % array
       hEddyFlux      =&gt; s % hEddyFlux % array
 
       maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
@@ -54,7 +54,7 @@
 
          do iEdge = 1, nEdges
             do k = 1, maxLevelEdgeTop(iEdge)
-               uBolusGM(k,iEdge) = hEddyFlux(k,iEdge)/h_edge(k,iEdge)
+               uBolusGM(k,iEdge) = hEddyFlux(k,iEdge)/layerThicknessEdge(k,iEdge)
             end do
          end do
 
@@ -72,14 +72,14 @@
       type(state_type), intent(inout)     :: s
       type(mesh_type), intent(in)         :: grid
 
-      real(kind=RKIND), dimension(:,:), pointer  :: hEddyFlux, h
+      real(kind=RKIND), dimension(:,:), pointer  :: hEddyFlux, layerThickness
       real(kind=RKIND), dimension(:), pointer    :: dcEdge
       integer, dimension(:,:), pointer           :: cellsOnEdge
       integer, dimension(:), pointer             :: maxLevelEdgeTop
       integer                                    :: k, cell1, cell2, iEdge, nEdges
 
       hEddyFlux      =&gt; s % hEddyFlux % array
-      h              =&gt; s % h % array
+      layerThickness =&gt; s % layerThickness % array
 
       dcEdge         =&gt; grid % dcEdge % array
       cellsOnEdge    =&gt; grid % cellsOnEdge % array
@@ -94,7 +94,7 @@
                cell1 = cellsOnEdge(1,iEdge)
                cell2 = cellsOnEdge(2,iEdge)
                do k=1,maxLevelEdgeTop(iEdge)
-                  hEddyFlux(k,iEdge) = -config_h_kappa * (h(k,cell2) - h(k,cell1)) / dcEdge(iEdge)
+                  hEddyFlux(k,iEdge) = -config_h_kappa * (layerThickness(k,cell2) - layerThickness(k,cell1)) / dcEdge(iEdge)
                end do
             end do
       else

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_monthly_forcing.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_monthly_forcing.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_monthly_forcing.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -102,7 +102,7 @@
       real (kind=RKIND), dimension(:,:), pointer :: windStressMonthly 
       real (kind=RKIND), dimension(:), pointer :: temperatureRestore 
       real (kind=RKIND), dimension(:), pointer :: salinityRestore 
-      real (kind=RKIND), dimension(:,:), pointer :: u_src
+      real (kind=RKIND), dimension(:,:), pointer :: normalVelocityForcing
       integer :: iCell, iEdge, nCells, nEdges, nMonths, k
       integer :: iMonth, iMonthP1, iDayInMonth, ierr
       real (kind=RKIND) :: data, dataP1, weight, weightP1
@@ -117,7 +117,7 @@
 
       temperatureRestore =&gt; grid % temperatureRestore % array
       salinityRestore =&gt; grid % salinityRestore % array
-      u_src =&gt; grid % u_src % array
+      normalVelocityForcing =&gt; grid % normalVelocityForcing % array
 
       temperatureRestoreMonthly =&gt; grid % temperatureRestoreMonthly % array
       salinityRestoreMonthly =&gt; grid % salinityRestoreMonthly % array
@@ -146,7 +146,7 @@
         ! Interpolate between iMonth and iMonthP1 records, using iDayInMonth
         data = windStressMonthly(iMonth,iEdge)
         dataP1 = windStressMonthly(iMonthP1,iEdge)
-        u_src(1,iEdge) = data * weight + dataP1 * weightP1
+        normalVelocityForcing(1,iEdge) = data * weight + dataP1 * weightP1
       end do
 
    !--------------------------------------------------------------------

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_mpas_core.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_mpas_core.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_mpas_core.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -22,8 +22,6 @@
    use ocn_vel_forcing
    use ocn_vel_coriolis
 
-   use ocn_tracer_hadv
-   use ocn_tracer_vadv
    use ocn_tracer_hmix
    use ocn_gm
    use ocn_restoring
@@ -85,10 +83,6 @@
       call ocn_vel_forcing_init(err_tmp)
       err = ior(err, err_tmp)
 
-      call ocn_tracer_hadv_init(err_tmp)
-      err = ior(err, err_tmp)
-      call ocn_tracer_vadv_init(err_tmp)
-      err = ior(err, err_tmp)
       call ocn_tracer_hmix_init(err_tmp)
       err = ior(err, err_tmp)
       call ocn_restoring_init(err_tmp)
@@ -169,16 +163,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_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
@@ -279,59 +267,48 @@
       call ocn_diagnostic_solve(dt, block % state % time_levs(1) % state, mesh)
       call mpas_timer_stop(&quot;diagnostic solve&quot;, initDiagSolveTimer)
 
-      ! Compute velocity transport, used in advection terms of h and tracer tendency
+      ! Compute velocity transport, used in advection terms of layerThickness and tracer tendency
         block % state % time_levs(1) % state % uTransport % array(:,:) &amp;
-      = block % state % time_levs(1) % state % u % array(:,:) &amp;
+      = block % state % time_levs(1) % state % normalVelocity % array(:,:) &amp;
       + block % state % time_levs(1) % state % uBolusGM % array(:,:)
 
       call ocn_compute_mesh_scaling(mesh)
  
       call mpas_rbf_interp_initialize(mesh)
       call mpas_init_reconstruct(mesh)
-      call mpas_reconstruct(mesh, block % state % time_levs(1) % state % u % array,                  &amp;
-                       block % state % time_levs(1) % state % uReconstructX % array,            &amp;
-                       block % state % time_levs(1) % state % uReconstructY % array,            &amp;
-                       block % state % time_levs(1) % state % uReconstructZ % array,            &amp;
-                       block % state % time_levs(1) % state % uReconstructZonal % array,        &amp;
-                       block % state % time_levs(1) % state % uReconstructMeridional % array    &amp;
+      call mpas_reconstruct(mesh, block % state % time_levs(1) % state % normalVelocity % array,                  &amp;
+                       block % state % time_levs(1) % state % normalVelocityX % array,            &amp;
+                       block % state % time_levs(1) % state % normalVelocityY % array,            &amp;
+                       block % state % time_levs(1) % state % normalVelocityZ % array,            &amp;
+                       block % state % time_levs(1) % state % normalVelocityZonal % array,        &amp;
+                       block % state % time_levs(1) % state % normalVelocityMeridional % 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;
-                       block % state % time_levs(1) % state % uSrcReconstructZ % array,            &amp;
-                       block % state % time_levs(1) % state % uSrcReconstructZonal % array,        &amp;
-                       block % state % time_levs(1) % state % uSrcReconstructMeridional % array    &amp;
+      call mpas_reconstruct(mesh, mesh % normalVelocityForcing % array,                  &amp;
+                       block % state % time_levs(1) % state % normalVelocityForcingReconstructX % array,            &amp;
+                       block % state % time_levs(1) % state % normalVelocityForcingReconstructY % array,            &amp;
+                       block % state % time_levs(1) % state % normalVelocityForcingReconstructZ % array,            &amp;
+                       block % state % time_levs(1) % state % normalVelocityForcingReconstructZonal % array,        &amp;
+                       block % state % time_levs(1) % state % normalVelocityForcingReconstructMeridional % 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 % state % time_levs(1) % state % normalVelocity % array( &amp;
              block % mesh % maxLevelEdgeTop % array(iEdge)+1 &amp;
             :block % mesh % maxLevelEdgeBot % array(iEdge), iEdge) = 0.0
 
-         block % state % time_levs(1) % state % u % array( &amp;
+         block % state % time_levs(1) % state % normalVelocity % 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
@@ -569,14 +546,14 @@
       type (block_type), pointer :: block
 
       integer :: iTracer, cell, cell1, cell2
-      real (kind=RKIND) :: uhSum, hSum, hEdge1, zMidPBC
+      real (kind=RKIND) :: normalThicknessFluxSum, thicknessSum, hEdge1, zMidPBC
 
       integer, dimension(:), pointer :: maxLevelCell
       real (kind=RKIND), dimension(:), pointer :: refBottomDepth, &amp;
          refBottomDepthTopOfCell, vertCoordMovementWeights, hZLevel, bottomDepth
       real (kind=RKIND), dimension(:), allocatable :: minBottomDepth, minBottomDepthMid, zMidZLevel
          
-      real (kind=RKIND), dimension(:,:), pointer :: h
+      real (kind=RKIND), dimension(:,:), pointer :: layerThickness
       real (kind=RKIND), dimension(:,:,:), pointer :: tracers
       integer :: nVertLevels
       logical :: consistentSSH
@@ -585,8 +562,8 @@
       block =&gt; domain % blocklist
       do while (associated(block))
 
-         h          =&gt; block % state % time_levs(1) % state % h % array
-         tracers    =&gt; block % state % time_levs(1) % state % tracers % array
+         layerThickness =&gt; block % state % time_levs(1) % state % layerThickness % array
+         tracers =&gt; block % state % time_levs(1) % state % tracers % array
          refBottomDepth =&gt; block % mesh % refBottomDepth % array
          refBottomDepthTopOfCell =&gt; block % mesh % refBottomDepthTopOfCell % array
          bottomDepth =&gt; block % mesh % bottomDepth % array
@@ -598,11 +575,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)
@@ -642,7 +614,7 @@
           if (config_alter_ICs_for_pbcs.eq.'zlevel_pbcs_on') then
 
             write (0,'(a)') ' Altering bottomDepth to avoid very thin cells.'
-            write (0,'(a)') ' Altering h and tracer initial conditions to conform with partial bottom cells.'
+            write (0,'(a)') ' Altering layerThickness and tracer initial conditions to conform with partial bottom cells.'
 
             allocate(minBottomDepth(nVertLevels),minBottomDepthMid(nVertLevels),zMidZLevel(nVertLevels))
 
@@ -672,7 +644,7 @@
                 k = maxLevelCell(iCell)
 
                ! Alter thickness of bottom level to account for PBC
-               h(k,iCell) = bottomDepth(iCell) - refBottomDepthTopOfCell(k) 
+               layerThickness(k,iCell) = bottomDepth(iCell) - refBottomDepthTopOfCell(k) 
 
                ! Linearly interpolate the initial T&amp;S for new location of bottom cell for PBCs
                zMidPBC = -0.5*(bottomDepth(iCell) + refBottomDepthTopOfCell(k))
@@ -710,19 +682,19 @@
             consistentSSH = .true.
             do iCell = 1,nCells
                ! Check if abs(ssh)&gt;2m.  If so, print warning.
-               if (abs(sum(h(1:maxLevelCell(iCell),iCell))-bottomDepth(iCell))&gt;2.0) then
+               if (abs(sum(layerThickness(1:maxLevelCell(iCell),iCell))-bottomDepth(iCell))&gt;2.0) then
                   consistentSSH = .false.
 #ifdef MPAS_DEBUG
-                  write (0,'(a)') ' Warning: abs(sum(h)-bottomDepth)&gt;2m.  Most likely, initial h does not match bottomDepth.'
+                  write (0,'(a)') ' Warning: abs(sum(h)-bottomDepth)&gt;2m.  Most likely, initial layerThickness does not match bottomDepth.'
                   write (0,*) ' iCell, K=maxLevelCell(iCell), bottomDepth(iCell),sum(h),bottomDepth,hZLevel(K),h(K): ', &amp;
-                                iCell, maxLevelCell(iCell), bottomDepth(iCell),sum(h(1:maxLevelCell(iCell),iCell)),bottomDepth(iCell), &amp;
-                                hZLevel(maxLevelCell(iCell)), h(maxLevelCell(iCell),iCell)
+                                iCell, maxLevelCell(iCell), bottomDepth(iCell),sum(layerThickness(1:maxLevelCell(iCell),iCell)),bottomDepth(iCell), &amp;
+                                hZLevel(maxLevelCell(iCell)), layerThickness(maxLevelCell(iCell),iCell)
 #endif                            
                endif
             enddo
 
             if (.not. consistentSSH) then
-               write(0,*) 'Warning: SSH is not consistent. Most likely, initial h does not match bottomDepth.'
+               write(0,*) 'Warning: SSH is not consistent. Most likely, initial layerThickness does not match bottomDepth.'
             end if
          endif
 
@@ -761,33 +733,33 @@
       type (block_type), pointer :: block
 
       integer :: iTracer, cell, cell1, cell2
-      real (kind=RKIND) :: uhSum, hSum, hEdge1
+      real (kind=RKIND) :: normalThicknessFluxSum, layerThicknessSum, layerThicknessEdge1
       real (kind=RKIND), dimension(:), pointer :: refBottomDepth
          
-      real (kind=RKIND), dimension(:,:), pointer :: h
+      real (kind=RKIND), dimension(:,:), pointer :: layerThickness
       integer :: nVertLevels
 
       ! 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
+         layerThickness          =&gt; block % state % time_levs(1) % state % layerThickness % array
          refBottomDepth =&gt; block % mesh % refBottomDepth % array
          nVertLevels = block % mesh % nVertLevels
 
          ! Compute barotropic velocity at first timestep
          ! This is only done upon start-up.
          if (trim(config_time_integrator) == 'unsplit_explicit') then
-            block % state % time_levs(1) % state % uBtr % array(:) = 0.0
+            block % state % time_levs(1) % state % normalBarotropicVelocity % array(:) = 0.0
 
-              block % state % time_levs(1) % state % uBcl % array(:,:) &amp;
-            = block % state % time_levs(1) % state % u % array(:,:) 
+              block % state % time_levs(1) % state % normalBaroclinicVelocity % array(:,:) &amp;
+            = block % state % time_levs(1) % state % normalVelocity % array(:,:) 
 
          elseif (trim(config_time_integrator) == 'split_explicit') then
 
             if (config_filter_btr_mode) then
                do iCell=1,block % mesh % nCells
-                  block % state % time_levs(1) % state % h % array(1,iCell) &amp; 
+                  block % state % time_levs(1) % state % layerThickness % array(1,iCell) &amp; 
                 = block % mesh % refBottomDepth % array(1)
                enddo
             endif 
@@ -796,53 +768,53 @@
                cell1 = block % mesh % cellsOnEdge % array(1,iEdge)
                cell2 = block % mesh % cellsOnEdge % array(2,iEdge)
 
-               ! uBtr = sum(u)/sum(h) on each column
+               ! normalBarotropicVelocity = sum(u)/sum(h) on each column
                ! ocn_diagnostic_solve has not yet been called, so compute hEdge 
                ! just for this edge.
 
-               ! hSum is initialized outside the loop because on land boundaries 
-               ! maxLevelEdgeTop=0, but I want to initialize hSum with a 
+               ! thicknessSum is initialized outside the loop because on land boundaries 
+               ! maxLevelEdgeTop=0, but I want to initialize thicknessSum with a 
                ! nonzero value to avoid a NaN.
-               hEdge1 = 0.5*( &amp;
-                   block % state % time_levs(1) % state % h % array(1,cell1) &amp; 
-                 + block % state % time_levs(1) % state % h % array(1,cell2) ) 
-               uhSum = hEdge1*block % state % time_levs(1) % state % u % array(1,iEdge)
-               hSum = hEdge1
+               layerThicknessEdge1 = 0.5*( &amp;
+                   block % state % time_levs(1) % state % layerThickness % array(1,cell1) &amp; 
+                 + block % state % time_levs(1) % state % layerThickness % array(1,cell2) ) 
+               normalThicknessFluxSum = layerThicknessEdge1*block % state % time_levs(1) % state % normalVelocity % array(1,iEdge)
+               layerThicknessSum = layerThicknessEdge1
 
                do k=2,block % mesh % maxLevelEdgeTop % array(iEdge)
                   ! ocn_diagnostic_solve has not yet been called, so compute hEdge 
                   ! just for this edge.
-                  hEdge1 = 0.5*( &amp;
-                      block % state % time_levs(1) % state % h % array(k,cell1) &amp; 
-                    + block % state % time_levs(1) % state % h % array(k,cell2) ) 
+                  layerThicknessEdge1 = 0.5*( &amp;
+                      block % state % time_levs(1) % state % layerThickness % array(k,cell1) &amp; 
+                    + block % state % time_levs(1) % state % layerThickness % array(k,cell2) ) 
 
-                  uhSum = uhSum &amp;
-                     + hEdge1*block % state % time_levs(1) % state % u % array(k,iEdge)
-                  hSum = hSum + hEdge1
+                  normalThicknessFluxSum = normalThicknessFluxSum &amp;
+                     + layerThicknessEdge1*block % state % time_levs(1) % state % normalVelocity % array(k,iEdge)
+                  layerThicknessSum = layerThicknessSum + layerThicknessEdge1
 
                enddo
-               block % state % time_levs(1) % state % uBtr % array(iEdge) = uhSum/hsum
+               block % state % time_levs(1) % state % normalBarotropicVelocity % array(iEdge) = normalThicknessFluxSum/layerThicknessSum
 
-               ! uBcl(k,iEdge) = u(k,iEdge) - uBtr(iEdge)
+               ! normalBaroclinicVelocity(k,iEdge) = normalVelocity(k,iEdge) - normalBarotropicVelocity(iEdge)
                do k=1,block % mesh % maxLevelEdgeTop % array(iEdge)
-                 block % state % time_levs(1) % state % uBcl % array(k,iEdge) &amp;
-                 = block % state % time_levs(1) % state % u % array(k,iEdge) &amp;
-                 - block % state % time_levs(1) % state % uBtr % array(iEdge)
+                 block % state % time_levs(1) % state % normalBaroclinicVelocity % array(k,iEdge) &amp;
+                 = block % state % time_levs(1) % state % normalVelocity % array(k,iEdge) &amp;
+                 - block % state % time_levs(1) % state % normalBarotropicVelocity % array(iEdge)
                enddo
 
-               ! uBcl=0, u=0 on land cells
+               ! normalBaroclinicVelocity=0, normalVelocity=0 on land cells
                do k=block % mesh % maxLevelEdgeTop % array(iEdge)+1, block % mesh % nVertLevels
-                 block % state % time_levs(1) % state % uBcl % array(k,iEdge) = 0.0
-                 block % state % time_levs(1) % state % u % array(k,iEdge) = 0.0
+                 block % state % time_levs(1) % state % normalBaroclinicVelocity % array(k,iEdge) = 0.0
+                 block % state % time_levs(1) % state % normalVelocity % array(k,iEdge) = 0.0
                enddo
             enddo
 
             if (config_filter_btr_mode) then
-               ! filter uBtr out of initial condition
-                block % state % time_levs(1) % state % u % array(:,:) &amp;
-              = block % state % time_levs(1) % state % uBcl % array(:,:)
+               ! filter normalBarotropicVelocity out of initial condition
+                block % state % time_levs(1) % state % normalVelocity % array(:,:) &amp;
+              = block % state % time_levs(1) % state % normalBaroclinicVelocity % array(:,:)
 
-               block % state % time_levs(1) % state % uBtr % array(:) = 0.0
+               block % state % time_levs(1) % state % normalBarotropicVelocity % array(:) = 0.0
             endif 
 
          endif

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_restoring.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_restoring.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_restoring.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -65,7 +65,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_restoring_tend(grid, h, indexT, indexS, tracers, tend, err)!{{{
+   subroutine ocn_restoring_tend(grid, layerThickness, indexT, indexS, tracers, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -74,7 +74,7 @@
       !-----------------------------------------------------------------
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h    !&lt; Input: thickness
+         layerThickness    !&lt; Input: thickness
 
       type (mesh_type), intent(in) :: &amp;
          grid          !&lt; Input: grid information
@@ -127,8 +127,8 @@
 
       k = 1  ! restoring only in top layer
       do iCell=1,nCellsSolve
-        tend(indexT, k, iCell) = tend(indexT, k, iCell) - h(k,iCell)*(tracers(indexT, k, iCell) - temperatureRestore(iCell)) * invTemp
-        tend(indexS, k, iCell) = tend(indexS, k, iCell) - h(k,iCell)*(tracers(indexS, k, iCell) - salinityRestore(iCell)) * invSalinity
+        tend(indexT, k, iCell) = tend(indexT, k, iCell) - layerThickness(k,iCell)*(tracers(indexT, k, iCell) - temperatureRestore(iCell)) * invTemp
+        tend(indexS, k, iCell) = tend(indexS, k, iCell) - layerThickness(k,iCell)*(tracers(indexS, k, iCell) - salinityRestore(iCell)) * invSalinity
 
 !       write(6,10) iCell, tracers(indexT, k, iCell), &amp;
 !              temperatureRestore(iCell), tracers(indexT, k, iCell), &amp;

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tendency.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tendency.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tendency.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -31,8 +31,6 @@
    use ocn_vel_forcing
    use ocn_vmix
 
-   use ocn_tracer_hadv
-   use ocn_tracer_vadv
    use ocn_tracer_hmix
    use ocn_restoring
 
@@ -56,8 +54,8 @@
    !
    !--------------------------------------------------------------------
 
-   public :: ocn_tend_h, &amp;
-             ocn_tend_u, &amp;
+   public :: ocn_tend_thick, &amp;
+             ocn_tend_vel, &amp;
              ocn_tend_tracer, &amp;
              ocn_tendency_init
 
@@ -73,7 +71,7 @@
 
 !***********************************************************************
 !
-!  routine ocn_tend_h
+!  routine ocn_tend_thick
 !
 !&gt; \brief   Computes thickness tendency
 !&gt; \author  Doug Jacobsen
@@ -84,31 +82,31 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_tend_h(tend, s, grid)!{{{
+   subroutine ocn_tend_thick(tend, s, grid)!{{{
       implicit none
 
       type (tend_type), intent(inout) :: tend !&lt; Input/Output: Tendency structure
       type (state_type), intent(in) :: s !&lt; Input: State information
       type (mesh_type), intent(in) :: grid !&lt; Input: Grid information
 
-      real (kind=RKIND), dimension(:,:), pointer :: h_edge, wTop, tend_h, uTransport
+      real (kind=RKIND), dimension(:,:), pointer :: layerThicknessEdge, vertTransportVelocityTop, tend_layerThickness, uTransport
 
       integer :: err
 
-      call mpas_timer_start(&quot;ocn_tend_h&quot;)
+      call mpas_timer_start(&quot;ocn_tend_thick&quot;)
 
       uTransport  =&gt; s % uTransport % array
-      wTop        =&gt; s % wTop % array
-      h_edge      =&gt; s % h_edge % array
+      vertTransportVelocityTop        =&gt; s % vertTransportVelocityTop % array
+      layerThicknessEdge      =&gt; s % layerThicknessEdge % array
 
-      tend_h      =&gt; tend % h % array
+      tend_layerThickness      =&gt; tend % layerThickness % array
                   
       !
       ! height tendency: start accumulating tendency terms
       !
-      tend_h = 0.0
+      tend_layerThickness = 0.0
 
-      if(config_disable_h_all_tend) return
+      if(config_disable_thick_all_tend) return
 
       !
       ! height tendency: horizontal advection term -</font>
<font color="gray">abla\cdot ( hu)
@@ -119,23 +117,23 @@
       ! QC Comment (3/15/12): need to make sure that uTranport is the right
       ! transport velocity here.
       call mpas_timer_start(&quot;hadv&quot;, .false., thickHadvTimer)
-      call ocn_thick_hadv_tend(grid, uTransport, h_edge, tend_h, err)
+      call ocn_thick_hadv_tend(grid, uTransport, layerThicknessEdge, tend_layerThickness, err)
       call mpas_timer_stop(&quot;hadv&quot;, thickHadvTimer)
 
       !
       ! height tendency: vertical advection term -d/dz(hw)
       !
       call mpas_timer_start(&quot;vadv&quot;, .false., thickVadvTimer)
-      call ocn_thick_vadv_tend(grid, wtop, tend_h, err)
+      call ocn_thick_vadv_tend(grid, vertTransportVelocityTop, tend_layerThickness, err)
       call mpas_timer_stop(&quot;vadv&quot;, thickVadvTimer)
 
-      call mpas_timer_stop(&quot;ocn_tend_h&quot;)
+      call mpas_timer_stop(&quot;ocn_tend_thick&quot;)
    
-   end subroutine ocn_tend_h!}}}
+   end subroutine ocn_tend_thick!}}}
 
 !***********************************************************************
 !
-!  routine ocn_tend_u
+!  routine ocn_tend_vel
 !
 !&gt; \brief   Computes velocity tendency
 !&gt; \author  Doug Jacobsen
@@ -146,7 +144,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_tend_u(tend, s, d, grid)!{{{
+   subroutine ocn_tend_vel(tend, s, d, grid)!{{{
       implicit none
 
       type (tend_type), intent(inout) :: tend !&lt; Input/Output: Tendency structure
@@ -155,56 +153,55 @@
       type (mesh_type), intent(in) :: grid !&lt; Input: Grid information
 
       real (kind=RKIND), dimension(:,:), pointer :: &amp;
-        h_edge, h, u, rho, zMid, pressure, &amp;
-        tend_u, circulation, vorticity, viscosity, ke, ke_edge, Vor_edge, &amp;
-        MontPot, wTop, divergence, vertViscTopOfEdge
+        layerThicknessEdge, h, normalVelocity, density, zMid, pressure, &amp;
+        tend_normalVelocity, circulation, relativeVorticity, viscosity, kineticEnergy, kineticEnergyEdge, potentialVorticityEdge, &amp;
+        montgomeryPotential, vertTransportVelocityTop, divergence, vertViscTopOfEdge
 
-      real (kind=RKIND), dimension(:,:), pointer :: u_src
+      real (kind=RKIND), dimension(:,:), pointer :: normalVelocityForcing
 
       integer :: err
 
-      call mpas_timer_start(&quot;ocn_tend_u&quot;)
+      call mpas_timer_start(&quot;ocn_tend_vel&quot;)
 
-      u           =&gt; s % u % array
-      rho         =&gt; s % rho % array
-      wTop        =&gt; s % wTop % array
+      normalVelocity =&gt; s % normalVelocity % array
+      density         =&gt; s % density % array
+      vertTransportVelocityTop        =&gt; s % vertTransportVelocityTop % array
       zMid        =&gt; s % zMid % array
-      h_edge      =&gt; s % h_edge % array
+      layerThicknessEdge      =&gt; s % layerThicknessEdge % array
       viscosity   =&gt; s % viscosity % array
-      vorticity   =&gt; s % vorticity % array
+      relativeVorticity   =&gt; s % relativeVorticity % array
       divergence  =&gt; s % divergence % array
-      ke          =&gt; s % ke % array
-      ke_edge     =&gt; s % ke_edge % array
-      Vor_edge     =&gt; s % Vor_edge % array
-      MontPot     =&gt; s % MontPot % array
+      kineticEnergy          =&gt; s % kineticEnergy % array
+      kineticEnergyEdge     =&gt; s % kineticEnergyEdge % array
+      potentialVorticityEdge     =&gt; s % potentialVorticityEdge % array
+      montgomeryPotential     =&gt; s % montgomeryPotential % array
       pressure    =&gt; s % pressure % array
       vertViscTopOfEdge =&gt; d % vertViscTopOfEdge % array
 
-      tend_u      =&gt; tend % u % array
+      tend_normalVelocity      =&gt; tend % normalVelocity % array
                   
-      u_src =&gt; grid % u_src % array
+      normalVelocityForcing =&gt; grid % normalVelocityForcing % array
 
       !
       ! 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
+      tend_normalVelocity(:,:) = 0.0
 
-      if(config_disable_u_all_tend) return
+      if(config_disable_vel_all_tend) return
 
       !
       ! velocity tendency: nonlinear Coriolis term and grad of kinetic energy
       !
 
       call mpas_timer_start(&quot;coriolis&quot;, .false., velCorTimer)
-      call ocn_vel_coriolis_tend(grid, Vor_edge, h_edge, u, ke, tend_u, err)
+      call ocn_vel_coriolis_tend(grid, potentialVorticityEdge, layerThicknessEdge, normalVelocity, kineticEnergy, tend_normalVelocity, err)
       call mpas_timer_stop(&quot;coriolis&quot;, velCorTimer)
 
       !
       ! velocity tendency: vertical advection term -w du/dz
       !
       call mpas_timer_start(&quot;vadv&quot;, .false., velVadvTimer)
-      call ocn_vel_vadv_tend(grid, u, h_edge, wtop, tend_u, err)
+      call ocn_vel_vadv_tend(grid, normalVelocity, layerThicknessEdge, vertTransportVelocityTop, tend_normalVelocity, err)
       call mpas_timer_stop(&quot;vadv&quot;, velVadvTimer)
 
       !
@@ -212,37 +209,35 @@
       !
       call mpas_timer_start(&quot;pressure grad&quot;, .false., velPgradTimer)
       if (config_pressure_gradient_type.eq.'MontgomeryPotential') then
-          call ocn_vel_pressure_grad_tend(grid, MontPot,  zMid, rho, tend_u, err)
+          call ocn_vel_pressure_grad_tend(grid, montgomeryPotential,  zMid, density, tend_normalVelocity, err)
       else
-          call ocn_vel_pressure_grad_tend(grid, pressure, zMid, rho, tend_u, err)
+          call ocn_vel_pressure_grad_tend(grid, pressure, zMid, density, tend_normalVelocity, err)
       end if
       call mpas_timer_stop(&quot;pressure grad&quot;, velPgradTimer)
 
       !
       ! velocity tendency: del2 dissipation, </font>
<font color="black">u_2 </font>
<font color="red">abla^2 u
-      !   computed as </font>
<font color="black">u( </font>
<font color="black">abla divergence + k \times </font>
<font color="blue">abla vorticity )
+      !   computed as </font>
<font color="black">u( </font>
<font color="black">abla divergence + k \times </font>
<font color="gray">abla relativeVorticity )
       !   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)
+      call ocn_vel_hmix_tend(grid, divergence, relativeVorticity, viscosity, tend_normalVelocity, err)
       call mpas_timer_stop(&quot;hmix&quot;, velHmixTimer)
 
       !
       ! 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)
+      call ocn_vel_forcing_tend(grid, normalVelocity, normalVelocityForcing, kineticEnergyEdge, layerThicknessEdge, tend_normalVelocity, err)
       call mpas_timer_stop(&quot;forcings&quot;, velForceTimer)
 
       !
       ! velocity tendency: vertical mixing d/dz( nu_v du/dz))
       !
-      call mpas_timer_stop(&quot;ocn_tend_u&quot;)
+      call mpas_timer_stop(&quot;ocn_tend_vel&quot;)
 
-   end subroutine ocn_tend_u!}}}
+   end subroutine ocn_tend_vel!}}}
 
 !***********************************************************************
 !
@@ -266,7 +261,7 @@
       real (kind=RKIND), intent(in) :: dt !&lt; Input: Time step
 
       real (kind=RKIND), dimension(:,:), pointer :: &amp;
-        uTransport, h,wTop, h_edge, vertDiffTopOfCell, tend_h, uh
+        uTransport, layerThickness,vertTransportVelocityTop, layerThicknessEdge, vertDiffTopOfCell, tend_layerThickness, normalThicknessFlux
       real (kind=RKIND), dimension(:,:,:), pointer :: &amp;
         tracers, tend_tr
 
@@ -275,14 +270,14 @@
       call mpas_timer_start(&quot;ocn_tend_tracer&quot;)
 
       uTransport  =&gt; s % uTransport % array
-      h           =&gt; s % h % array
-      wTop        =&gt; s % wTop % array
+      layerThickness           =&gt; s % layerThickness % array
+      vertTransportVelocityTop        =&gt; s % vertTransportVelocityTop % array
       tracers     =&gt; s % tracers % array
-      h_edge      =&gt; s % h_edge % array
+      layerThicknessEdge      =&gt; s % layerThicknessEdge % array
       vertDiffTopOfCell =&gt; d % vertDiffTopOfCell % array
 
       tend_tr     =&gt; tend % tracers % array
-      tend_h      =&gt; tend % h % array
+      tend_layerThickness      =&gt; tend % layerThickness % array
 
       !
       ! initialize tracer tendency (RHS of tracer equation) to zero.
@@ -291,62 +286,44 @@
 
       if(config_disable_tr_all_tend) return
 
-      allocate(uh(grid % nVertLevels, grid % nEdges+1))
+      allocate(normalThicknessFlux(grid % nVertLevels, grid % nEdges+1))
       !
       ! QC Comment (3/15/12): need to make sure that uTransport is the right
       ! transport velocity for the tracer.
       do iEdge = 1, grid % nEdges
          do k = 1, grid % nVertLevels
-            uh(k, iEdge) = uTransport(k, iEdge) * h_edge(k, iEdge)
+            normalThicknessFlux(k, iEdge) = uTransport(k, iEdge) * layerThicknessEdge(k, iEdge)
          end do
       end do
 
       !
-      ! tracer tendency: horizontal advection term -div( h \phi u)
+      ! tracer tendency: horizontal advection term -div( layerThickness \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)
-      call mpas_ocn_tracer_advection_tend(tracers, uh, wTop, h, h, dt, grid, tend_h, tend_tr)
+      call mpas_ocn_tracer_advection_tend(tracers, normalThicknessFlux, vertTransportVelocityTop, layerThickness, layerThickness, dt, grid, tend_layerThickness, tend_tr)
       call mpas_timer_stop(&quot;adv&quot;, tracerHadvTimer)
 
       !
       ! tracer tendency: del2 horizontal tracer diffusion, div(h \kappa_2 </font>
<font color="gray">abla \phi)
       !
       call mpas_timer_start(&quot;hmix&quot;, .false., tracerHmixTimer)
-      call ocn_tracer_hmix_tend(grid, h_edge, tracers, tend_tr, err)
+      call ocn_tracer_hmix_tend(grid, layerThicknessEdge, 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
-
-
-! 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)
 
-      call ocn_restoring_tend(grid, h, s%index_temperature, s%index_salinity, tracers, tend_tr, err)
+      call ocn_restoring_tend(grid, layerThickness, s%index_temperature, s%index_salinity, tracers, tend_tr, err)
 
       call mpas_timer_stop(&quot;restoring&quot;, tracerRestoringTimer)
 
- 10   format(2i8,10e20.10)
       call mpas_timer_stop(&quot;ocn_tend_tracer&quot;)
 
-      deallocate(uh)
+      deallocate(normalThicknessFlux)
 
    end subroutine ocn_tend_tracer!}}}
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_thick_hadv.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_thick_hadv.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_thick_hadv.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -62,7 +62,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_thick_hadv_tend(grid, u, h_edge, tend, err)!{{{
+   subroutine ocn_thick_hadv_tend(grid, normalVelocity, layerThicknessEdge, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -71,10 +71,10 @@
       !-----------------------------------------------------------------
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         u    !&lt; Input: velocity
+         normalVelocity    !&lt; Input: velocity
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge     !&lt; Input: thickness at edge
+         layerThicknessEdge     !&lt; Input: thickness at edge
 
       type (mesh_type), intent(in) :: &amp;
          grid          !&lt; Input: grid information
@@ -142,7 +142,7 @@
         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 = normalVelocity(k, iEdge) * dvEdge(iEdge) * layerThicknessEdge(k, iEdge)
             tend(k, iCell) = tend(k, iCell) + edgeSignOnCell(i, iCell) * flux * invAreaCell
           end do
         end do
@@ -180,7 +180,7 @@
 
       thickHadvOn = .true.
 
-      if(config_disable_h_hadv) thickHadvOn = .false.
+      if(config_disable_thick_hadv) thickHadvOn = .false.
 
       err = 0
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_thick_vadv.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_thick_vadv.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_thick_vadv.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -62,7 +62,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_thick_vadv_tend(grid, wTop, tend, err)!{{{
+   subroutine ocn_thick_vadv_tend(grid, vertTransportVelocityTop, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -71,7 +71,7 @@
       !-----------------------------------------------------------------
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         wTop     !&lt; Input: vertical velocity on top layer
+         vertTransportVelocityTop     !&lt; Input: vertical velocity on top layer
 
       type (mesh_type), intent(in) :: &amp;
          grid          !&lt; Input: grid information
@@ -121,7 +121,7 @@
 
       do iCell=1,nCells
          do k=1,maxLevelCell(iCell)
-            tend(k,iCell) = tend(k,iCell) + wTop(k+1,iCell) - wTop(k,iCell)
+            tend(k,iCell) = tend(k,iCell) + vertTransportVelocityTop(k+1,iCell) - vertTransportVelocityTop(k,iCell)
          end do
       end do
 
@@ -157,7 +157,7 @@
 
       thickVadvOn = .true.
 
-      if(config_disable_h_vadv) thickVadvOn = .false.
+      if(config_disable_thick_vadv) thickVadvOn = .false.
       
       err = 0
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_time_average.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_time_average.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_time_average.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -11,35 +11,35 @@
     subroutine ocn_time_average_init(state)!{{{
         type (state_type), intent(inout) :: state
 
-        real (kind=RKIND), pointer :: nAccumulate
+        real (kind=RKIND), pointer :: nAverage
 
-        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, acc_vertVelocityTop
+        real (kind=RKIND), dimension(:), pointer :: avgSSH, varSSH
+        real (kind=RKIND), dimension(:,:), pointer :: avgnormalVelocityZonal, avgnormalVelocityMeridional, varnormalVelocityZonal, varnormalVelocityMeridional
+        real (kind=RKIND), dimension(:,:), pointer :: avgNormalVelocity, varNormalVelocity, avgVertVelocityTop
 
-        nAccumulate =&gt; state % nAccumulate % scalar
+        nAverage =&gt; state % nAverage % scalar
 
-        acc_ssh =&gt; state % acc_ssh % array
-        acc_sshVar =&gt; state % acc_sshVar % array
-        acc_uReconstructZonal =&gt; state % acc_uReconstructZonal % array
-        acc_uReconstructMeridional =&gt; state % acc_uReconstructMeridional % array
-        acc_uReconstructZonalVar =&gt; state % acc_uReconstructZonalVar % array
-        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
+        avgSSH =&gt; state % avgSSH % array
+        varSSH =&gt; state % varSSH % array
+        avgnormalVelocityZonal =&gt; state % avgnormalVelocityZonal % array
+        avgnormalVelocityMeridional =&gt; state % avgnormalVelocityMeridional % array
+        varnormalVelocityZonal =&gt; state % varnormalVelocityZonal % array
+        varnormalVelocityMeridional =&gt; state % varnormalVelocityMeridional % array
+        avgNormalVelocity =&gt; state % avgNormalVelocity % array
+        varNormalVelocity =&gt; state % varNormalVelocity % array
+        avgVertVelocityTop =&gt; state % avgVertVelocityTop % array
 
-        nAccumulate = 0
+        nAverage = 0
 
-        acc_ssh = 0.0
-        acc_sshVar = 0.0
-        acc_uReconstructZonal = 0.0
-        acc_uReconstructMeridional = 0.0
-        acc_uReconstructZonalVar = 0.0
-        acc_uReconstructMeridionalVar = 0.0
-        acc_u = 0.0
-        acc_uVar = 0.0
-        acc_vertVelocityTop = 0.0
+        avgSSH = 0.0
+        varSSH = 0.0
+        avgnormalVelocityZonal = 0.0
+        avgnormalVelocityMeridional = 0.0
+        varnormalVelocityZonal = 0.0
+        varnormalVelocityMeridional = 0.0
+        avgNormalVelocity = 0.0
+        varNormalVelocity = 0.0
+        avgVertVelocityTop = 0.0
 
     end subroutine ocn_time_average_init!}}}
 
@@ -47,92 +47,92 @@
         type (state_type), intent(inout) :: state
         type (state_type), intent(in) :: old_state
 
-        real (kind=RKIND), pointer :: nAccumulate, old_nAccumulate
+        real (kind=RKIND), pointer :: nAverage, old_nAverage
 
         real (kind=RKIND), dimension(:), pointer :: ssh
-        real (kind=RKIND), dimension(:,:), pointer :: uReconstructZonal, uReconstructMeridional, u, vertVelocityTop
+        real (kind=RKIND), dimension(:,:), pointer :: normalVelocityZonal, normalVelocityMeridional, normalVelocity, vertVelocityTop
 
-        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 :: avgNormalVelocity, varNormalVelocity, avgVertVelocityTop
+        real (kind=RKIND), dimension(:,:), pointer :: avgnormalVelocityZonal, avgnormalVelocityMeridional, varnormalVelocityZonal, varnormalVelocityMeridional
+        real (kind=RKIND), dimension(:), pointer :: avgSSH, varSSH
 
-        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
+        real (kind=RKIND), dimension(:,:), pointer :: old_avgNormalVelocity, old_varNormalVelocity, old_avgVertVelocityTop
+        real (kind=RKIND), dimension(:,:), pointer :: old_avgnormalVelocityZonal, old_avgnormalVelocityMeridional, old_varnormalVelocityZonal, old_varnormalVelocityMeridional
+        real (kind=RKIND), dimension(:), pointer :: old_avgSSH, old_varSSH
 
-        old_nAccumulate =&gt; old_state % nAccumulate  % scalar
-        nAccumulate =&gt; state % nAccumulate  % scalar
+        old_nAverage =&gt; old_state % nAverage  % scalar
+        nAverage =&gt; state % nAverage  % scalar
 
         ssh =&gt; state % ssh % array
-        uReconstructZonal =&gt; state % uReconstructZonal % array
-        uReconstructMeridional =&gt; state % uReconstructMeridional % array
-        u =&gt; state % u % array
+        normalVelocityZonal =&gt; state % normalVelocityZonal % array
+        normalVelocityMeridional =&gt; state % normalVelocityMeridional % array
+        normalVelocity =&gt; state % normalVelocity % array
         vertVelocityTop =&gt; state % vertVelocityTop % array
 
-        acc_ssh =&gt; state % acc_ssh % array
-        acc_sshVar =&gt; state % acc_sshVar % array
-        acc_uReconstructZonal =&gt; state % acc_uReconstructZonal % array
-        acc_uReconstructMeridional =&gt; state % acc_uReconstructMeridional % array
-        acc_uReconstructZonalVar =&gt; state % acc_uReconstructZonalVar % array
-        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
+        avgSSH =&gt; state % avgSSH % array
+        varSSH =&gt; state % varSSH % array
+        avgnormalVelocityZonal =&gt; state % avgnormalVelocityZonal % array
+        avgnormalVelocityMeridional =&gt; state % avgnormalVelocityMeridional % array
+        varnormalVelocityZonal =&gt; state % varnormalVelocityZonal % array
+        varnormalVelocityMeridional =&gt; state % varnormalVelocityMeridional % array
+        avgNormalVelocity =&gt; state % avgNormalVelocity % array
+        varNormalVelocity =&gt; state % varNormalVelocity % array
+        avgVertVelocityTop =&gt; state % avgVertVelocityTop % array
 
-        old_acc_ssh =&gt; old_state % acc_ssh % array
-        old_acc_sshVar =&gt; old_state % acc_sshVar % array
-        old_acc_uReconstructZonal =&gt; old_state % acc_uReconstructZonal % array
-        old_acc_uReconstructMeridional =&gt; old_state % acc_uReconstructMeridional % array
-        old_acc_uReconstructZonalVar =&gt; old_state % acc_uReconstructZonalVar % array
-        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
+        old_avgSSH =&gt; old_state % avgSSH % array
+        old_varSSH =&gt; old_state % varSSH % array
+        old_avgnormalVelocityZonal =&gt; old_state % avgnormalVelocityZonal % array
+        old_avgnormalVelocityMeridional =&gt; old_state % avgnormalVelocityMeridional % array
+        old_varnormalVelocityZonal =&gt; old_state % varnormalVelocityZonal % array
+        old_varnormalVelocityMeridional =&gt; old_state % varnormalVelocityMeridional % array
+        old_avgNormalVelocity =&gt; old_state % avgNormalVelocity % array
+        old_varNormalVelocity =&gt; old_state % varNormalVelocity % array
+        old_avgVertVelocityTop =&gt; old_state % avgVertVelocityTop % array
 
-        acc_ssh = old_acc_ssh + ssh
-        acc_sshVar = old_acc_sshVar + ssh**2
-        acc_uReconstructZonal = old_acc_uReconstructZonal + uReconstructZonal
-        acc_uReconstructMeridional = old_acc_uReconstructMeridional + uReconstructMeridional
-        acc_uReconstructZonalVar = old_acc_uReconstructZonalVar + uReconstructZonal**2
-        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
+        avgSSH = old_avgSSH + ssh
+        varSSH = old_varSSH + ssh**2
+        avgnormalVelocityZonal = old_avgnormalVelocityZonal + normalVelocityZonal
+        avgnormalVelocityMeridional = old_avgnormalVelocityMeridional + normalVelocityMeridional
+        varnormalVelocityZonal = old_varnormalVelocityZonal + normalVelocityZonal**2
+        varnormalVelocityMeridional = old_varnormalVelocityMeridional + normalVelocityMeridional**2
+        avgNormalVelocity = old_avgNormalVelocity + normalVelocity
+        varNormalVelocity = old_varNormalVelocity + normalVelocity**2
+        avgVertVelocityTop = old_avgVertVelocityTop + vertVelocityTop
 
-        nAccumulate = old_nAccumulate + 1
+        nAverage = old_nAverage + 1
     end subroutine ocn_time_average_accumulate!}}}
 
     subroutine ocn_time_average_normalize(state)!{{{
         type (state_type), intent(inout) :: state
 
-        real (kind=RKIND), pointer :: nAccumulate
+        real (kind=RKIND), pointer :: nAverage
 
-        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, acc_vertVelocityTop
+        real (kind=RKIND), dimension(:), pointer :: avgSSH, varSSH
+        real (kind=RKIND), dimension(:,:), pointer :: avgnormalVelocityZonal, avgnormalVelocityMeridional, varnormalVelocityZonal, varnormalVelocityMeridional
+        real (kind=RKIND), dimension(:,:), pointer :: avgNormalVelocity, varNormalVelocity, avgVertVelocityTop
 
-        nAccumulate =&gt; state % nAccumulate  % scalar
+        nAverage =&gt; state % nAverage  % scalar
 
-        acc_ssh =&gt; state % acc_ssh % array
-        acc_sshVar =&gt; state % acc_sshVar % array
-        acc_uReconstructZonal =&gt; state % acc_uReconstructZonal % array
-        acc_uReconstructMeridional =&gt; state % acc_uReconstructMeridional % array
-        acc_uReconstructZonalVar =&gt; state % acc_uReconstructZonalVar % array
-        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
+        avgSSH =&gt; state % avgSSH % array
+        varSSH =&gt; state % varSSH % array
+        avgnormalVelocityZonal =&gt; state % avgnormalVelocityZonal % array
+        avgnormalVelocityMeridional =&gt; state % avgnormalVelocityMeridional % array
+        varnormalVelocityZonal =&gt; state % varnormalVelocityZonal % array
+        varnormalVelocityMeridional =&gt; state % varnormalVelocityMeridional % array
+        avgNormalVelocity =&gt; state % avgNormalVelocity % array
+        varNormalVelocity =&gt; state % varNormalVelocity % array
+        avgVertVelocityTop =&gt; state % avgVertVelocityTop % array
 
-        if(nAccumulate &gt; 0) then
-          acc_ssh = acc_ssh / nAccumulate
-          acc_sshVar = acc_sshVar / nAccumulate
-          acc_uReconstructZonal = acc_uReconstructZonal / nAccumulate
-          acc_uReconstructMeridional = acc_uReconstructMeridional / nAccumulate
-          acc_uReconstructZonalVar = acc_uReconstructZonalVar / nAccumulate
-          acc_uReconstructMeridionalVar = acc_uReconstructMeridionalVar / nAccumulate
-          acc_u = acc_u / nAccumulate
-          acc_uVar = acc_uVar / nAccumulate
-          acc_vertVelocityTop = acc_vertVelocityTop / nAccumulate
+        if(nAverage &gt; 0) then
+          avgSSH = avgSSH / nAverage
+          varSSH = varSSH / nAverage
+          avgnormalVelocityZonal = avgnormalVelocityZonal / nAverage
+          avgnormalVelocityMeridional = avgnormalVelocityMeridional / nAverage
+          varnormalVelocityZonal = varnormalVelocityZonal / nAverage
+          varnormalVelocityMeridional = varnormalVelocityMeridional / nAverage
+          avgNormalVelocity = avgNormalVelocity / nAverage
+          varNormalVelocity = varNormalVelocity / nAverage
+          avgVertVelocityTop = avgVertVelocityTop / nAverage
         end if
     end subroutine ocn_time_average_normalize!}}}
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_time_integration.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_time_integration.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_time_integration.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -100,7 +100,7 @@
      do while (associated(block))
         block % state % time_levs(2) % state % xtime % scalar = timeStamp
 
-        nanCheck = sum(block % state % time_levs(2) % state % u % array)
+        nanCheck = sum(block % state % time_levs(2) % state % normalVelocity % array)
 
         if (nanCheck /= nanCheck) then
            write(0,*) 'Abort: NaN detected'

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_time_integration_rk4.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_time_integration_rk4.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_time_integration_rk4.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -87,7 +87,7 @@
       integer :: nCells, nEdges, nVertLevels, num_tracers
       real (kind=RKIND) :: coef
       real (kind=RKIND), dimension(:,:), pointer :: &amp;
-        u, h, h_edge, vertViscTopOfEdge, vertDiffTopOfCell, ke_edge
+        u, layerThickness, layerThicknessEdge, vertViscTopOfEdge, vertDiffTopOfCell, kineticEnergyEdge
       real (kind=RKIND), dimension(:,:,:), pointer :: tracers
       integer, dimension(:), pointer :: &amp; 
         maxLevelCell, maxLevelEdgeTop
@@ -99,17 +99,17 @@
       !
       ! Initialize time_levs(2) with state at current time
       ! Initialize first RK state
-      ! Couple tracers time_levs(2) with h in time-levels
+      ! Couple tracers time_levs(2) with layerThickness in time-levels
       ! Initialize RK weights
       !
       block =&gt; domain % blocklist
       do while (associated(block))
-        block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
-        block % state % time_levs(2) % state % h % array(:,:) = block % state % time_levs(1) % state % h % array(:,:)
+        block % state % time_levs(2) % state % normalVelocity % array(:,:) = block % state % time_levs(1) % state % normalVelocity % array(:,:)
+        block % state % time_levs(2) % state % layerThickness % array(:,:) = block % state % time_levs(1) % state % layerThickness % array(:,:)
         do iCell=1,block % mesh % nCells  ! couple tracers to h
           do k=1,block % mesh % maxLevelCell % array(iCell)
             block % state % time_levs(2) % state % tracers % array(:,k,iCell) = block % state % time_levs(1) % state % tracers % array(:,k,iCell) &amp;
-                                                                      * block % state % time_levs(1) % state % h % array(k,iCell)
+                                                                      * block % state % time_levs(1) % state % layerThickness % array(k,iCell)
            end do
         end do
 
@@ -137,10 +137,10 @@
 ! ---  update halos for diagnostic variables
 
         call mpas_timer_start(&quot;RK4-diagnostic halo update&quot;)
-        call mpas_dmpar_exch_halo_field(domain % blocklist % provis % Vor_edge)
+        call mpas_dmpar_exch_halo_field(domain % blocklist % provis % potentialVorticityEdge)
         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)
+           call mpas_dmpar_exch_halo_field(domain % blocklist % provis % relativeVorticity)
         end if
         call mpas_timer_stop(&quot;RK4-diagnostic halo update&quot;)
 
@@ -149,17 +149,17 @@
         call mpas_timer_start(&quot;RK4-tendency computations&quot;)
         block =&gt; domain % blocklist
         do while (associated(block))
-           ! 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)
-           call ocn_tend_u(block % tend, block % provis, block % diagnostics, block % mesh)
+           ! advection of u uses u, while advection of layerThickness and tracers use uTransport.
+           call ocn_vert_transport_velocity_top(block % mesh, block % provis % layerThickness % array, block % provis % layerThicknessEdge % array, &amp;
+              block % provis % normalVelocity % array, block % provis % vertTransportVelocityTop % array, err)
+           call ocn_tend_vel(block % tend, block % provis, block % diagnostics, block % mesh)
 
-           call ocn_wtop(block % mesh, block % provis % h % array, block % provis % h_edge % array, &amp;
-              block % provis % uTransport % array, block % provis % wTop % array, err)
-           call ocn_tend_h(block % tend, block % provis, block % mesh)
+           call ocn_vert_transport_velocity_top(block % mesh, block % provis % layerThickness % array, block % provis % layerThicknessEdge % array, &amp;
+              block % provis % uTransport % array, block % provis % vertTransportVelocityTop % array, err)
+           call ocn_tend_thick(block % tend, block % provis, block % mesh)
 
            if (config_filter_btr_mode) then
-               call ocn_filter_btr_mode_tend_u(block % tend, block % provis, block % mesh)
+               call ocn_filter_btr_mode_tend_vel(block % tend, block % provis, block % mesh)
            endif
 
            call ocn_tend_tracer(block % tend, block % provis, block % diagnostics, block % mesh, dt)
@@ -170,8 +170,8 @@
 ! ---  update halos for prognostic variables
 
         call mpas_timer_start(&quot;RK4-pronostic halo update&quot;)
-        call mpas_dmpar_exch_halo_field(domain % blocklist % tend % u)
-        call mpas_dmpar_exch_halo_field(domain % blocklist % tend % h)
+        call mpas_dmpar_exch_halo_field(domain % blocklist % tend % normalVelocity)
+        call mpas_dmpar_exch_halo_field(domain % blocklist % tend % layerThickness)
         call mpas_dmpar_exch_halo_field(domain % blocklist % tend % tracers)
         call mpas_timer_stop(&quot;RK4-pronostic halo update&quot;)
 
@@ -182,33 +182,33 @@
            block =&gt; domain % blocklist
            do while (associated(block))
 
-              block % provis % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)  &amp;
-                                                    + rk_substep_weights(rk_step) * block % tend % u % array(:,:)
+              block % provis % normalVelocity % array(:,:) = block % state % time_levs(1) % state % normalVelocity % array(:,:)  &amp;
+                                                    + rk_substep_weights(rk_step) * block % tend % normalVelocity % array(:,:)
 
-              block % provis % h % array(:,:) = block % state % time_levs(1) % state % h % array(:,:)  &amp;
-                                              + rk_substep_weights(rk_step) * block % tend % h % array(:,:)
+              block % provis % layerThickness % array(:,:) = block % state % time_levs(1) % state % layerThickness % array(:,:)  &amp;
+                                              + rk_substep_weights(rk_step) * block % tend % layerThickness % array(:,:)
               do iCell=1,block % mesh % nCells
                  do k=1,block % mesh % maxLevelCell % array(iCell)
-                 block % provis % tracers % array(:,k,iCell) = ( block % state % time_levs(1) % state % h % array(k,iCell) * &amp;
+                 block % provis % tracers % array(:,k,iCell) = ( block % state % time_levs(1) % state % layerThickness % array(k,iCell) * &amp;
                                                                  block % state % time_levs(1) % state % tracers % array(:,k,iCell)  &amp;
                                                              + rk_substep_weights(rk_step) * block % tend % tracers % array(:,k,iCell) &amp;
-                                                               ) / block % provis % h % array(k,iCell)
+                                                               ) / block % provis % layerThickness % array(k,iCell)
                  end do
 
               end do
               if (config_prescribe_velocity) then
-                 block % provis % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
+                 block % provis % normalVelocity % array(:,:) = block % state % time_levs(1) % state % normalVelocity % array(:,:)
               end if
 
               if (config_prescribe_thickness) then
-                 block % provis % h % array(:,:) = block % state % time_levs(1) % state % h % array(:,:)
+                 block % provis % layerThickness % array(:,:) = block % state % time_levs(1) % state % layerThickness % array(:,:)
               end if
 
               call ocn_diagnostic_solve(dt, block % provis, block % mesh)
 
-              ! Compute velocity transport, used in advection terms of h and tracer tendency
+              ! Compute velocity transport, used in advection terms of layerThickness and tracer tendency
               block % provis % uTransport % array(:,:) &amp;
-                    = block % provis % u          % array(:,:) &amp;
+                    = block % provis % normalVelocity % array(:,:) &amp;
                     + block % provis % uBolusGM   % array(:,:)
 
               block =&gt; block % next
@@ -221,11 +221,11 @@
         call mpas_timer_start(&quot;RK4-RK4 accumulate update&quot;)
         block =&gt; domain % blocklist
         do while (associated(block))
-           block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(2) % state % u % array(:,:) &amp;
-                                   + rk_weights(rk_step) * block % tend % u % array(:,:) 
+           block % state % time_levs(2) % state % normalVelocity % array(:,:) = block % state % time_levs(2) % state % normalVelocity % array(:,:) &amp;
+                                   + rk_weights(rk_step) * block % tend % normalVelocity % array(:,:) 
 
-           block % state % time_levs(2) % state % h % array(:,:) = block % state % time_levs(2) % state % h % array(:,:) &amp;
-                                   + rk_weights(rk_step) * block % tend % h % array(:,:) 
+           block % state % time_levs(2) % state % layerThickness % array(:,:) = block % state % time_levs(2) % state % layerThickness % array(:,:) &amp;
+                                   + rk_weights(rk_step) * block % tend % layerThickness % array(:,:) 
 
            do iCell=1,block % mesh % nCells
               do k=1,block % mesh % maxLevelCell % array(iCell)
@@ -256,7 +256,7 @@
         do iCell = 1, block % mesh % nCells
           do k = 1, block % mesh % maxLevelCell % array(iCell)
             block % state % time_levs(2) % state % tracers % array(:, k, iCell) = block % state % time_levs(2) % state % tracers % array(:, k, iCell) &amp;
-                                                                                / block % state % time_levs(2) % state % h % array(k, iCell)
+                                                                                / block % state % time_levs(2) % state % layerThickness % array(k, iCell)
           end do
         end do
         block =&gt; block % next
@@ -268,10 +268,10 @@
 
         ! 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 
+        ! For Richardson vertical mixing, only density, layerThicknessEdge, and kineticEnergyEdge 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.
+        ! 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)
@@ -283,7 +283,7 @@
       ! 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 % normalVelocity)
       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;)
 
@@ -292,37 +292,35 @@
       block =&gt; domain % blocklist
       do while (associated(block))
          if (config_prescribe_velocity) then
-            block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
+            block % state % time_levs(2) % state % normalVelocity % array(:,:) = block % state % time_levs(1) % state % normalVelocity % array(:,:)
          end if
 
          if (config_prescribe_thickness) then
-            block % state % time_levs(2) % state % h % array(:,:) = block % state % time_levs(1) % state % h % array(:,:)
+            block % state % time_levs(2) % state % layerThickness % array(:,:) = block % state % time_levs(1) % state % layerThickness % array(:,:)
          end if
 
          call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
 
-         ! Compute velocity transport, used in advection terms of h and tracer tendency
+         ! Compute velocity transport, used in advection terms of layerThickness and tracer tendency
             block % state % time_levs(2) % state % uTransport % array(:,:) &amp;
-          = block % state % time_levs(2) % state % u % array(:,:) &amp;
+          = block % state % time_levs(2) % state % normalVelocity % array(:,:) &amp;
           + block % state % time_levs(2) % state % uBolusGM % array(:,:)
 
-         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;
-                          block % state % time_levs(2) % state % uReconstructZ % array,            &amp;
-                          block % state % time_levs(2) % state % uReconstructZonal % array,        &amp;
-                          block % state % time_levs(2) % state % uReconstructMeridional % array    &amp;
+         call mpas_reconstruct(block % mesh, block % state % time_levs(2) % state % normalVelocity % array,          &amp;
+                          block % state % time_levs(2) % state % normalVelocityX % array,            &amp;
+                          block % state % time_levs(2) % state % normalVelocityY % array,            &amp;
+                          block % state % time_levs(2) % state % normalVelocityZ % array,            &amp;
+                          block % state % time_levs(2) % state % normalVelocityZonal % array,        &amp;
+                          block % state % time_levs(2) % state % normalVelocityMeridional % 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;
-                          block % state % time_levs(2) % state % uSrcReconstructZ % array,            &amp;
-                          block % state % time_levs(2) % state % uSrcReconstructZonal % array,        &amp;
-                          block % state % time_levs(2) % state % uSrcReconstructMeridional % array    &amp;
+         call mpas_reconstruct(block % mesh, block % mesh % normalVelocityForcing % array,          &amp;
+                          block % state % time_levs(2) % state % normalVelocityForcingReconstructX % array,            &amp;
+                          block % state % time_levs(2) % state % normalVelocityForcingReconstructY % array,            &amp;
+                          block % state % time_levs(2) % state % normalVelocityForcingReconstructZ % array,            &amp;
+                          block % state % time_levs(2) % state % normalVelocityForcingReconstructZonal % array,        &amp;
+                          block % state % time_levs(2) % state % normalVelocityForcingReconstructMeridional % array    &amp;
                          )
-!TDR
 
          call ocn_time_average_accumulate(block % state % time_levs(2) % state, block % state % time_levs(1) % state)
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_time_integration_split.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_time_integration_split.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_time_integration_split.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -49,8 +49,8 @@
    public :: ocn_time_integrator_split
 
    type (timer_node), pointer :: timer_main, timer_prep, timer_bcl_vel, timer_btr_vel, timer_diagnostic_update, timer_implicit_vmix, &amp;
-                                 timer_halo_diagnostic, timer_halo_ubtr, timer_halo_ssh, timer_halo_f, timer_halo_h, &amp; 
-                                 timer_halo_tracers, timer_halo_ubcl
+                                 timer_halo_diagnostic, timer_halo_normalBarotropicVelocity, timer_halo_ssh, timer_halo_f, timer_halo_thickness, &amp; 
+                                 timer_halo_tracers, timer_halo_normalBaroclinicVelocity
 
    contains
 
@@ -89,11 +89,11 @@
                  eoe, oldBtrSubcycleTime, newBtrSubcycleTime, uPerpTime, BtrCorIter, &amp;
                  n_bcl_iter(config_n_ts_iter), stage1_tend_time
       type (block_type), pointer :: block
-      real (kind=RKIND) :: uhSum, hSum, flux, sshEdge, hEdge1, &amp;
-                 CoriolisTerm, uCorr, temp, temp_h, coef, FBtr_coeff, sshCell1, sshCell2
+      real (kind=RKIND) :: normalThicknessFluxSum, thicknessSum, flux, sshEdge, hEdge1, &amp;
+                 CoriolisTerm, uCorr, temp, temp_h, coef, barotropicThicknessFlux_coeff, sshCell1, sshCell2
       integer :: num_tracers, ucorr_coef, err
       real (kind=RKIND), dimension(:,:), pointer :: &amp;
-                 u, h, h_edge, ke_edge, vertViscTopOfEdge, vertDiffTopOfCell
+                 u, h, layerThicknessEdge, kineticEnergyEdge, vertViscTopOfEdge, vertDiffTopOfCell
       real (kind=RKIND), dimension(:,:,:), pointer :: tracers
       integer, dimension(:), pointer :: &amp; 
                  maxLevelCell, maxLevelEdgeTop
@@ -117,22 +117,22 @@
 
                ! The baroclinic velocity needs be recomputed at the beginning of a 
                ! timestep because the implicit vertical mixing is conducted on the
-               ! total u.  We keep uBtr from the previous timestep.
-               ! Note that uBcl may now include a barotropic component, because the 
-               ! weights h have changed.  That is OK, because the GBtrForcing variable
+               ! total u.  We keep normalBarotropicVelocity from the previous timestep.
+               ! Note that normalBaroclinicVelocity may now include a barotropic component, because the 
+               ! weights layerThickness have changed.  That is OK, because the barotropicForcing variable
                ! subtracts out the barotropic component from the baroclinic.
-                 block % state % time_levs(1) % state % uBcl % array(k,iEdge) &amp;
-               = block % state % time_levs(1) % state % u    % array(k,iEdge) &amp;
-               - block % state % time_levs(1) % state % uBtr % array(  iEdge)
+                 block % state % time_levs(1) % state % normalBaroclinicVelocity % array(k,iEdge) &amp;
+               = block % state % time_levs(1) % state % normalVelocity    % array(k,iEdge) &amp;
+               - block % state % time_levs(1) % state % normalBarotropicVelocity % array(  iEdge)
 
-                 block % state % time_levs(2) % state % u % array(k,iEdge) &amp;
-               = block % state % time_levs(1) % state % u % array(k,iEdge)
+                 block % state % time_levs(2) % state % normalVelocity % array(k,iEdge) &amp;
+               = block % state % time_levs(1) % state % normalVelocity % array(k,iEdge)
 
-                 block % state % time_levs(2) % state % uBcl % array(k,iEdge) &amp;
-               = block % state % time_levs(1) % state % uBcl % array(k,iEdge)
+                 block % state % time_levs(2) % state % normalBaroclinicVelocity % array(k,iEdge) &amp;
+               = block % state % time_levs(1) % state % normalBaroclinicVelocity % array(k,iEdge)
 
-                 block % state % time_levs(2) % state % h_edge % array(k,iEdge) &amp;
-               = block % state % time_levs(1) % state % h_edge % array(k,iEdge)
+                 block % state % time_levs(2) % state % layerThicknessEdge % array(k,iEdge) &amp;
+               = block % state % time_levs(1) % state % layerThicknessEdge % array(k,iEdge)
 
             end do 
          end do 
@@ -143,8 +143,8 @@
          do iCell=1,block % mesh % nCells  
             do k=1,block % mesh % maxLevelCell % array(iCell)
 
-                 block % state % time_levs(2) % state % h % array(k,iCell) &amp;
-               = block % state % time_levs(1) % state % h % array(k,iCell)
+                 block % state % time_levs(2) % state % layerThickness % array(k,iCell) &amp;
+               = block % state % time_levs(1) % state % layerThickness % array(k,iCell)
 
                  block % state % time_levs(2) % state % tracers % array(:,k,iCell) &amp; 
                = block % state % time_levs(1) % state % tracers % array(:,k,iCell) 
@@ -167,10 +167,10 @@
          ! ---  update halos for diagnostic variables
 
          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)
+         call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % potentialVorticityEdge)
          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)
+           call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % relativeVorticity)
          end if
          call mpas_timer_stop(&quot;se halo diag&quot;, timer_halo_diagnostic)
 
@@ -188,14 +188,14 @@
 
             stage1_tend_time = min(split_explicit_step,2)
 
-           ! compute wTop.  Use u (rather than uTransport) for momentum advection.
+           ! compute vertTransportVelocityTop.  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;
-              block % state % time_levs(stage1_tend_time) % state % h_edge % array, &amp;
-              block % state % time_levs(stage1_tend_time) % state % u % array, &amp;
-              block % state % time_levs(stage1_tend_time) % state % wTop % array, err)
+           call ocn_vert_transport_velocity_top(block % mesh, block % state % time_levs(stage1_tend_time) % state % layerThickness % array, &amp;
+              block % state % time_levs(stage1_tend_time) % state % layerThicknessEdge % array, &amp;
+              block % state % time_levs(stage1_tend_time) % state % normalVelocity % array, &amp;
+              block % state % time_levs(stage1_tend_time) % state % vertTransportVelocityTop % array, err)
 
-            call ocn_tend_u(block % tend, block % state % time_levs(stage1_tend_time) % state, block % diagnostics, block % mesh)
+            call ocn_tend_vel(block % tend, block % state % time_levs(stage1_tend_time) % state, block % diagnostics, block % mesh)
 
             block =&gt; block % next
          end do
@@ -216,7 +216,7 @@
             do while (associated(block))
                allocate(uTemp(block % mesh % nVertLevels))
 
-               ! Put f*uBcl^{perp} in uNew as a work variable
+               ! Put f*normalBaroclinicVelocity^{perp} in uNew as a work variable
                call ocn_fuperp(block % state % time_levs(2) % state , block % mesh)
 
                do iEdge=1,block % mesh % nEdges
@@ -226,38 +226,38 @@
                   uTemp = 0.0  ! could put this after with uTemp(maxleveledgetop+1:nvertlevels)=0
                   do k=1,block % mesh % maxLevelEdgeTop % array(iEdge)
 
-                     ! uBclNew = uBclOld + dt*(-f*uBclPerp + T(u*,w*,p*) + g*grad(SSH*) )
-                     ! Here uNew is a work variable containing -fEdge(iEdge)*uBclPerp(k,iEdge)
-                      uTemp(k) = block % state % time_levs(1) % state % uBcl % array(k,iEdge) &amp;
-                         + dt * (block % tend % u % array (k,iEdge) &amp;
-                         + block % state % time_levs(2) % state % u % array (k,iEdge) &amp;  ! this is f*uBcl^{perp}
+                     ! normalBaroclinicVelocityNew = normalBaroclinicVelocityOld + dt*(-f*normalBaroclinicVelocityPerp + T(u*,w*,p*) + g*grad(SSH*) )
+                     ! Here uNew is a work variable containing -fEdge(iEdge)*normalBaroclinicVelocityPerp(k,iEdge)
+                      uTemp(k) = block % state % time_levs(1) % state % normalBaroclinicVelocity % array(k,iEdge) &amp;
+                         + dt * (block % tend % normalVelocity % array (k,iEdge) &amp;
+                         + block % state % time_levs(2) % state % normalVelocity % array (k,iEdge) &amp;  ! this is f*normalBaroclinicVelocity^{perp}
                          + split * gravity * (  block % state % time_levs(2) % state % ssh % array(cell2) &amp;
                          - block % state % time_levs(2) % state % ssh % array(cell1) ) &amp;
                           /block % mesh % dcEdge % array(iEdge) )
                   enddo
 
-                  ! hSum is initialized outside the loop because on land boundaries 
-                  ! maxLevelEdgeTop=0, but I want to initialize hSum with a 
+                  ! thicknessSum is initialized outside the loop because on land boundaries 
+                  ! maxLevelEdgeTop=0, but I want to initialize thicknessSum with a 
                   ! nonzero value to avoid a NaN.
-                  uhSum = block % state % time_levs(2) % state % h_edge % array(1,iEdge) * uTemp(1)
-                  hSum  = block % state % time_levs(2) % state % h_edge % array(1,iEdge)
+                  normalThicknessFluxSum = block % state % time_levs(2) % state % layerThicknessEdge % array(1,iEdge) * uTemp(1)
+                  thicknessSum  = block % state % time_levs(2) % state % layerThicknessEdge % array(1,iEdge)
 
                   do k=2,block % mesh % maxLevelEdgeTop % array(iEdge)
-                     uhSum = uhSum + block % state % time_levs(2) % state % h_edge % array(k,iEdge) * uTemp(k)
-                     hSum  =  hSum + block % state % time_levs(2) % state % h_edge % array(k,iEdge)
+                     normalThicknessFluxSum = normalThicknessFluxSum + block % state % time_levs(2) % state % layerThicknessEdge % array(k,iEdge) * uTemp(k)
+                     thicknessSum  =  thicknessSum + block % state % time_levs(2) % state % layerThicknessEdge % array(k,iEdge)
                   enddo
-                  block % state % time_levs(1) % state % GBtrForcing % array(iEdge) = split*uhSum/hSum/dt
+                  block % state % time_levs(1) % state % barotropicForcing % array(iEdge) = split*normalThicknessFluxSum/thicknessSum/dt
 
 
                   do k=1,block % mesh % maxLevelEdgeTop % array(iEdge)
                      ! These two steps are together here:
                      !{\bf u}'_{k,n+1} = {\bf u}'_{k,n} - \Delta t {\overline {\bf G}}
                      !{\bf u}'_{k,n+1/2} = \frac{1}{2}\left({\bf u}^{'}_{k,n} +{\bf u}'_{k,n+1}\right) 
-                     ! so that uBclNew is at time n+1/2
-                       block % state % time_levs(2) % state % uBcl % array(k,iEdge) &amp;
+                     ! so that normalBaroclinicVelocityNew is at time n+1/2
+                       block % state % time_levs(2) % state % normalBaroclinicVelocity % array(k,iEdge) &amp;
                      = 0.5*( &amp;
-                       block % state % time_levs(1) % state % uBcl % array(k,iEdge) &amp;
-                     + uTemp(k) - dt * block % state % time_levs(1) % state % GBtrForcing % array(iEdge))
+                       block % state % time_levs(1) % state % normalBaroclinicVelocity % array(k,iEdge) &amp;
+                     + uTemp(k) - dt * block % state % time_levs(1) % state % barotropicForcing % array(iEdge))
 
                   enddo
  
@@ -268,9 +268,9 @@
                block =&gt; block % next
             end do
 
-            call mpas_timer_start(&quot;se halo ubcl&quot;, .false., timer_halo_ubcl)
-            call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % uBcl)
-            call mpas_timer_stop(&quot;se halo ubcl&quot;, timer_halo_ubcl)
+            call mpas_timer_start(&quot;se halo normalBaroclinicVelocity&quot;, .false., timer_halo_normalBaroclinicVelocity)
+            call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % normalBaroclinicVelocity)
+            call mpas_timer_stop(&quot;se halo normalBaroclinicVelocity&quot;, timer_halo_normalBaroclinicVelocity)
 
          end do  ! do j=1,config_n_bcl_iter
 
@@ -296,20 +296,20 @@
             block =&gt; domain % blocklist
             do while (associated(block))
 
-               ! For Split_Explicit unsplit, simply set uBtrNew=0, uBtrSubcycle=0, and uNew=uBclNew
-               block % state % time_levs(2) % state % uBtr % array(:) = 0.0
+               ! For Split_Explicit unsplit, simply set normalBarotropicVelocityNew=0, normalBarotropicVelocitySubcycle=0, and uNew=normalBaroclinicVelocityNew
+               block % state % time_levs(2) % state % normalBarotropicVelocity % array(:) = 0.0
 
-               block % state % time_levs(2) % state % u % array(:,:)  = block % state % time_levs(2) % state % uBcl % array(:,:) 
+               block % state % time_levs(2) % state % normalVelocity % array(:,:)  = block % state % time_levs(2) % state % normalBaroclinicVelocity % array(:,:) 
 
                do iEdge=1,block % mesh % nEdges
                   do k=1,block % mesh % nVertLevels
 
-                     ! uTranport = uBcl + uBolus 
-                     ! This is u used in advective terms for h and tracers 
+                     ! uTranport = normalBaroclinicVelocity + uBolus 
+                     ! This is u used in advective terms for layerThickness and tracers 
                      ! in tendency calls in stage 3.
                        block % state % time_levs(2) % state % uTransport % array(k,iEdge) &amp;
                      = block % mesh % edgeMask % array(k,iEdge) &amp;
-                     *(  block % state % time_levs(2) % state % uBcl       % array(k,iEdge) &amp;
+                     *(  block % state % time_levs(2) % state % normalBaroclinicVelocity       % array(k,iEdge) &amp;
                        + block % state % time_levs(1) % state % uBolusGM   % array(k,iEdge) )
 
                   enddo
@@ -325,7 +325,7 @@
             do while (associated(block))
 
                if (config_filter_btr_mode) then
-                  block % state % time_levs(1) % state % GBtrForcing % array(:) = 0.0
+                  block % state % time_levs(1) % state % barotropicForcing % array(:) = 0.0
                endif
 
                do iCell=1,block % mesh % nCells
@@ -336,16 +336,16 @@
 
                do iEdge=1,block % mesh % nEdges
 
-                  ! uBtrSubcycleOld = uBtrOld 
-                    block % state % time_levs(oldBtrSubcycleTime) % state % uBtrSubcycle % array(iEdge) &amp;
-                  = block % state % time_levs(1) % state % uBtr % array(iEdge) 
+                  ! normalBarotropicVelocitySubcycleOld = normalBarotropicVelocityOld 
+                    block % state % time_levs(oldBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(iEdge) &amp;
+                  = block % state % time_levs(1) % state % normalBarotropicVelocity % array(iEdge) 
 
-                  ! uBtrNew = BtrOld  This is the first for the summation
-                    block % state % time_levs(2) % state % uBtr % array(iEdge) &amp;
-                  = block % state % time_levs(1) % state % uBtr % array(iEdge) 
+                  ! normalBarotropicVelocityNew = BtrOld  This is the first for the summation
+                    block % state % time_levs(2) % state % normalBarotropicVelocity % array(iEdge) &amp;
+                  = block % state % time_levs(1) % state % normalBarotropicVelocity % array(iEdge) 
 
-                  ! FBtr = 0  
-                  block % state % time_levs(1) % state % FBtr % array(iEdge) = 0.0
+                  ! barotropicThicknessFlux = 0  
+                  block % state % time_levs(1) % state % barotropicThicknessFlux % array(iEdge) = 0.0
                end do
 
                block =&gt; block % next
@@ -359,7 +359,7 @@
                !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                ! Barotropic subcycle: VELOCITY PREDICTOR STEP
                !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-               if (config_btr_gam1_uWt1&gt;1.0e-12) then  ! only do this part if it is needed in next SSH solve
+               if (config_btr_gam1_velWt1&gt;1.0e-12) then  ! only do this part if it is needed in next SSH solve
                   uPerpTime = oldBtrSubcycleTime
 
                   block =&gt; domain % blocklist
@@ -376,28 +376,28 @@
                            eoe = block % mesh % edgesOnEdge % array(i,iEdge)
                            CoriolisTerm = CoriolisTerm &amp;
                              + block % mesh % weightsOnEdge % array(i,iEdge) &amp;
-                             * block % state % time_levs(uPerpTime) % state % uBtrSubcycle % array(eoe) &amp;
+                             * block % state % time_levs(uPerpTime) % state % normalBarotropicVelocitySubcycle % array(eoe) &amp;
                              * block % mesh % fEdge % array(eoe)
                         end do
       
-                        ! uBtrNew = uBtrOld + dt/J*(-f*uBtroldPerp - g*grad(SSH) + G)
-                        block % state % time_levs(newBtrSubcycleTime) % state % uBtrSubcycle % array(iEdge) &amp;
-                          = (block % state % time_levs(oldBtrSubcycleTime) % state % uBtrSubcycle % array(iEdge) &amp;
+                        ! normalBarotropicVelocityNew = normalBarotropicVelocityOld + dt/J*(-f*normalBarotropicVelocityoldPerp - g*grad(SSH) + G)
+                        block % state % time_levs(newBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(iEdge) &amp;
+                          = (block % state % time_levs(oldBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(iEdge) &amp;
                           + dt / config_n_btr_subcycles * (CoriolisTerm - gravity &amp;
                           * (block % state % time_levs(oldBtrSubcycleTime) % state % sshSubcycle % array(cell2) &amp;
                            - block % state % time_levs(oldBtrSubcycleTime) % state % sshSubcycle % array(cell1) ) &amp;
                           / block % mesh % dcEdge % array(iEdge) &amp;
-                          + block % state % time_levs(1) % state % GBtrForcing % array(iEdge))) * block % mesh % edgeMask % array(1, iEdge)
+                          + block % state % time_levs(1) % state % barotropicForcing % array(iEdge))) * block % mesh % edgeMask % array(1, iEdge)
                      end do
 
                      block =&gt; block % next
                   end do  ! block
 
-                !   boundary update on uBtrNew
-                call mpas_timer_start(&quot;se halo ubtr&quot;, .false., timer_halo_ubtr)
-                call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(newBtrSubcycleTime) % state % uBtrSubcycle)
-                call mpas_timer_stop(&quot;se halo ubtr&quot;, timer_halo_ubtr)
-              endif ! config_btr_gam1_uWt1&gt;1.0e-12
+                !   boundary update on normalBarotropicVelocityNew
+                call mpas_timer_start(&quot;se halo normalBarotropicVelocity&quot;, .false., timer_halo_normalBarotropicVelocity)
+                call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(newBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle)
+                call mpas_timer_stop(&quot;se halo normalBarotropicVelocity&quot;, timer_halo_normalBarotropicVelocity)
+              endif ! config_btr_gam1_velWt1&gt;1.0e-12
 
               !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
               ! Barotropic subcycle: SSH PREDICTOR STEP 
@@ -408,19 +408,18 @@
                 block % tend % ssh % array(:) = 0.0
       
                 if (config_btr_solve_SSH2) then
-                   ! If config_btr_solve_SSH2=.true., then do NOT accumulate FBtr in this SSH predictor 
+                   ! If config_btr_solve_SSH2=.true., then do NOT accumulate barotropicThicknessFlux in this SSH predictor 
                    ! section, because it will be accumulated in the SSH corrector section.
-                   FBtr_coeff = 0.0
+                   barotropicThicknessFlux_coeff = 0.0
                 else
-                   ! otherwise, DO accumulate FBtr in this SSH predictor section
-                   FBtr_coeff = 1.0
+                   ! otherwise, DO accumulate barotropicThicknessFlux in this SSH predictor section
+                   barotropicThicknessFlux_coeff = 1.0
                 endif
       
-                ! config_btr_gam1_uWt1 sets the forward weighting of velocity in the SSH computation
-                ! 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?
+                ! config_btr_gam1_velWt1 sets the forward weighting of velocity in the SSH computation
+                ! config_btr_gam1_velWt1=  1     flux = normalBarotropicVelocityNew*H
+                ! config_btr_gam1_velWt1=0.5     flux = 1/2*(normalBarotropicVelocityNew+normalBarotropicVelocityOld)*H
+                ! config_btr_gam1_velWt1=  0     flux = normalBarotropicVelocityOld*H
 
                 do iCell = 1, block % mesh % nCells
                   do i = 1, block % mesh % nEdgesOnCell % array(iCell)
@@ -433,21 +432,21 @@
                               + block % state % time_levs(oldBtrSubcycleTime) % state % sshSubcycle % array(cell2) )
 
                    ! method 0: orig, works only without pbc:      
-                   !hSum = sshEdge + block % mesh % refBottomDepthTopOfCell % array (block % mesh % maxLevelEdgeTop % array(iEdge)+1)
+                   !thicknessSum = sshEdge + block % mesh % refBottomDepthTopOfCell % array (block % mesh % maxLevelEdgeTop % array(iEdge)+1)
  
                    ! method 1, matches method 0 without pbcs, works with pbcs.
-                   hSum = sshEdge + min(block % mesh % bottomDepth % array(cell1), &amp;
+                   thicknessSum = sshEdge + min(block % mesh % bottomDepth % array(cell1), &amp;
                                         block % mesh % bottomDepth % array(cell2))
 
                    ! method 2: may be better than method 1.
                    ! Take average  of full thickness at two neighboring cells.
-                   !hSum = sshEdge + 0.5 *(  block % mesh % bottomDepth % array(cell1) &amp;
+                   !thicknessSum = sshEdge + 0.5 *(  block % mesh % bottomDepth % array(cell1) &amp;
                    !                       + block % mesh % bottomDepth % array(cell2) )
 
 
-                    flux = ((1.0-config_btr_gam1_uWt1) * block % state % time_levs(oldBtrSubcycleTime) % state % uBtrSubcycle % array(iEdge) &amp;
-                           + config_btr_gam1_uWt1 * block % state % time_levs(newBtrSubcycleTime) % state % uBtrSubcycle % array(iEdge)) &amp;
-                           * hSum 
+                    flux = ((1.0-config_btr_gam1_velWt1) * block % state % time_levs(oldBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(iEdge) &amp;
+                           + config_btr_gam1_velWt1 * block % state % time_levs(newBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(iEdge)) &amp;
+                           * thicknessSum 
 
                     block % tend % ssh % array(iCell) = block % tend % ssh % array(iCell) + block % mesh % edgeSignOncell % array(i, iCell) * flux &amp;
                            * block % mesh % dvEdge % array(iEdge)
@@ -463,23 +462,23 @@
                              + block % state % time_levs(oldBtrSubcycleTime) % state % sshSubcycle % array(cell2) )
 
                    ! method 0: orig, works only without pbc:      
-                   !hSum = sshEdge + block % mesh % refBottomDepthTopOfCell % array (block % mesh % maxLevelEdgeTop % array(iEdge)+1)
+                   !thicknessSum = sshEdge + block % mesh % refBottomDepthTopOfCell % array (block % mesh % maxLevelEdgeTop % array(iEdge)+1)
  
                    ! method 1, matches method 0 without pbcs, works with pbcs.
-                   hSum = sshEdge + min(block % mesh % bottomDepth % array(cell1), &amp;
+                   thicknessSum = sshEdge + min(block % mesh % bottomDepth % array(cell1), &amp;
                                         block % mesh % bottomDepth % array(cell2))
 
                    ! method 2: may be better than method 1.
                    ! take average  of full thickness at two neighboring cells
-                   !hSum = sshEdge + 0.5 *(  block % mesh % bottomDepth % array(cell1) &amp;
+                   !thicknessSum = sshEdge + 0.5 *(  block % mesh % bottomDepth % array(cell1) &amp;
                    !                       + block % mesh % bottomDepth % array(cell2) )
 
-                   flux = ((1.0-config_btr_gam1_uWt1) * block % state % time_levs(oldBtrSubcycleTime) % state % uBtrSubcycle % array(iEdge) &amp;
-                          + config_btr_gam1_uWt1 * block % state % time_levs(newBtrSubcycleTime) % state % uBtrSubcycle % array(iEdge)) &amp;
-                          * hSum 
+                   flux = ((1.0-config_btr_gam1_velWt1) * block % state % time_levs(oldBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(iEdge) &amp;
+                          + config_btr_gam1_velWt1 * block % state % time_levs(newBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(iEdge)) &amp;
+                          * thicknessSum 
 
-                   block % state % time_levs(1) % state % FBtr % array(iEdge) = block % state % time_levs(1) % state % FBtr % array(iEdge) &amp;
-                     + FBtr_coeff*flux
+                   block % state % time_levs(1) % state % barotropicThicknessFlux % array(iEdge) = block % state % time_levs(1) % state % barotropicThicknessFlux % array(iEdge) &amp;
+                     + barotropicThicknessFlux_coeff*flux
                 end do
       
                 ! SSHnew = SSHold + dt/J*(-div(Flux))
@@ -508,7 +507,7 @@
                 block =&gt; domain % blocklist
                 do while (associated(block))
                    allocate(utemp(block % mesh % nEdges+1))
-                   uTemp(:) = block % state % time_levs(newBtrSubcycleTime) % state % uBtrSubcycle % array(:)
+                   uTemp(:) = block % state % time_levs(newBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(:)
                    do iEdge=1,block % mesh % nEdges 
                      cell1 = block % mesh % cellsOnEdge % array(1,iEdge)
                      cell2 = block % mesh % cellsOnEdge % array(2,iEdge)
@@ -518,7 +517,7 @@
                      do i = 1,block % mesh % nEdgesOnEdge % array(iEdge)
                          eoe = block % mesh % edgesOnEdge % array(i,iEdge)
                        CoriolisTerm = CoriolisTerm + block % mesh % weightsOnEdge % array(i,iEdge) &amp;
-                             !* block % state % time_levs(uPerpTime) % state % uBtrSubcycle % array(eoe) &amp;
+                             !* block % state % time_levs(uPerpTime) % state % normalBarotropicVelocitySubcycle % array(eoe) &amp;
                              * uTemp(eoe) &amp;
                              * block % mesh % fEdge  % array(eoe) 
                      end do
@@ -530,21 +529,21 @@
                      sshCell2 = (1-config_btr_gam2_SSHWt1)*block % state % time_levs(oldBtrSubcycleTime) % state % sshSubcycle % array(cell2) &amp;
                                +   config_btr_gam2_SSHWt1 *block % state % time_levs(newBtrSubcycleTime) % state % sshSubcycle % array(cell2)
     
-                     ! uBtrNew = uBtrOld + dt/J*(-f*uBtroldPerp - g*grad(SSH) + G)
-                     block % state % time_levs(newBtrSubcycleTime) % state % uBtrSubcycle % array(iEdge) &amp; 
-                         = (block % state % time_levs(oldBtrSubcycleTime) % state % uBtrSubcycle % array(iEdge) &amp; 
+                     ! normalBarotropicVelocityNew = normalBarotropicVelocityOld + dt/J*(-f*normalBarotropicVelocityoldPerp - g*grad(SSH) + G)
+                     block % state % time_levs(newBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(iEdge) &amp; 
+                         = (block % state % time_levs(oldBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(iEdge) &amp; 
                          + dt/config_n_btr_subcycles *(CoriolisTerm - gravity *(sshCell2 - sshCell1) /block % mesh % dcEdge % array(iEdge) &amp;
-                         + block % state % time_levs(1) % state % GBtrForcing % array(iEdge))) * block % mesh % edgeMask % array(1,iEdge)
+                         + block % state % time_levs(1) % state % barotropicForcing % array(iEdge))) * block % mesh % edgeMask % array(1,iEdge)
                    end do
                    deallocate(uTemp)
       
                    block =&gt; block % next
                 end do  ! block
       
-                !   boundary update on uBtrNew
-                call mpas_timer_start(&quot;se halo ubtr&quot;, .false., timer_halo_ubtr)
-                call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(newBtrSubcycleTime) % state % uBtrSubcycle)
-                call mpas_timer_stop(&quot;se halo ubtr&quot;, timer_halo_ubtr)
+                !   boundary update on normalBarotropicVelocityNew
+                call mpas_timer_start(&quot;se halo normalBarotropicVelocity&quot;, .false., timer_halo_normalBarotropicVelocity)
+                call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(newBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle)
+                call mpas_timer_stop(&quot;se halo normalBarotropicVelocity&quot;, timer_halo_normalBarotropicVelocity)
               end do !do BtrCorIter=1,config_n_btr_cor_iter
       
               !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -556,11 +555,10 @@
                 do while (associated(block))
                    block % tend % ssh % array(:) = 0.0
       
-                  ! config_btr_gam3_uWt2 sets the forward weighting of velocity in the SSH computation
-                  ! 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?
+                  ! config_btr_gam3_velWt2 sets the forward weighting of velocity in the SSH computation
+                  ! config_btr_gam3_velWt2=  1     flux = normalBarotropicVelocityNew*H
+                  ! config_btr_gam3_velWt2=0.5     flux = 1/2*(normalBarotropicVelocityNew+normalBarotropicVelocityOld)*H
+                  ! config_btr_gam3_velWt2=  0     flux = normalBarotropicVelocityOld*H
 
                   do iCell = 1, block % mesh % nCells
                     do i = 1, block % mesh % nEdgesOnCell % array(iCell)
@@ -578,21 +576,21 @@
                       sshEdge = 0.5 * (sshCell1 + sshCell2)
 
                      ! method 0: orig, works only without pbc:      
-                     !hSum = sshEdge + block % mesh % refBottomDepthTopOfCell % array (block % mesh % maxLevelEdgeTop % array(iEdge)+1)
+                     !thicknessSum = sshEdge + block % mesh % refBottomDepthTopOfCell % array (block % mesh % maxLevelEdgeTop % array(iEdge)+1)
  
                      ! method 1, matches method 0 without pbcs, works with pbcs.
-                     hSum = sshEdge + min(block % mesh % bottomDepth % array(cell1), &amp;
+                     thicknessSum = sshEdge + min(block % mesh % bottomDepth % array(cell1), &amp;
                                           block % mesh % bottomDepth % array(cell2))
 
                      ! method 2: may be better than method 1.
                      ! take average  of full thickness at two neighboring cells
-                     !hSum = sshEdge + 0.5 *(  block % mesh % bottomDepth % array(cell1) &amp;
+                     !thicknessSum = sshEdge + 0.5 *(  block % mesh % bottomDepth % array(cell1) &amp;
                      !                       + block % mesh % bottomDepth % array(cell2) )
       
        
-                      flux = ((1.0-config_btr_gam3_uWt2) * block % state % time_levs(oldBtrSubcycleTime) % state % uBtrSubcycle % array(iEdge) &amp;
-                             + config_btr_gam3_uWt2 * block % state % time_levs(newBtrSubcycleTime) % state % uBtrSubcycle % array(iEdge)) &amp;
-                             * hSum
+                      flux = ((1.0-config_btr_gam3_velWt2) * block % state % time_levs(oldBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(iEdge) &amp;
+                             + config_btr_gam3_velWt2 * block % state % time_levs(newBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(iEdge)) &amp;
+                             * thicknessSum
 
                       block % tend % ssh % array(iCell) = block % tend % ssh % array(iCell) + block % mesh % edgeSignOnCell % array(i, iCell) * flux &amp;
                              * block % mesh % dvEdge % array(iEdge)
@@ -612,22 +610,22 @@
                      sshEdge = 0.5 * (sshCell1 + sshCell2)
 
                      ! method 0: orig, works only without pbc:      
-                     !hSum = sshEdge + block % mesh % refBottomDepthTopOfCell % array (block % mesh % maxLevelEdgeTop % array(iEdge)+1)
+                     !thicknessSum = sshEdge + block % mesh % refBottomDepthTopOfCell % array (block % mesh % maxLevelEdgeTop % array(iEdge)+1)
  
                      ! method 1, matches method 0 without pbcs, works with pbcs.
-                     hSum = sshEdge + min(block % mesh % bottomDepth % array(cell1), &amp;
+                     thicknessSum = sshEdge + min(block % mesh % bottomDepth % array(cell1), &amp;
                                           block % mesh % bottomDepth % array(cell2))
 
                      ! method 2, better, I think.
                      ! take average  of full thickness at two neighboring cells
-                     !hSum = sshEdge + 0.5 *(  block % mesh % bottomDepth % array(cell1) &amp;
+                     !thicknessSum = sshEdge + 0.5 *(  block % mesh % bottomDepth % array(cell1) &amp;
                      !                       + block % mesh % bottomDepth % array(cell2) )
       
-                     flux = ((1.0-config_btr_gam3_uWt2) * block % state % time_levs(oldBtrSubcycleTime) % state % uBtrSubcycle % array(iEdge) &amp;
-                            + config_btr_gam3_uWt2 * block % state % time_levs(newBtrSubcycleTime) % state % uBtrSubcycle % array(iEdge)) &amp;
-                            * hSum
+                     flux = ((1.0-config_btr_gam3_velWt2) * block % state % time_levs(oldBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(iEdge) &amp;
+                            + config_btr_gam3_velWt2 * block % state % time_levs(newBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(iEdge)) &amp;
+                            * thicknessSum
       
-                     block % state % time_levs(1) % state % FBtr % array(iEdge) = block % state % time_levs(1) % state % FBtr % array(iEdge) + flux
+                     block % state % time_levs(1) % state % barotropicThicknessFlux % array(iEdge) = block % state % time_levs(1) % state % barotropicThicknessFlux % array(iEdge) + flux
                   end do
       
                   ! SSHnew = SSHold + dt/J*(-div(Flux))
@@ -653,15 +651,15 @@
                block =&gt; domain % blocklist
                do while (associated(block))
       
-                  ! uBtrNew = uBtrNew + uBtrSubcycleNEW
+                  ! normalBarotropicVelocityNew = normalBarotropicVelocityNew + normalBarotropicVelocitySubcycleNEW
                   ! This accumulates the sum.
                   ! If the Barotropic Coriolis iteration is limited to one, this could 
                   ! be merged with the above code.
                   do iEdge=1,block % mesh % nEdges 
       
-                       block % state % time_levs(2) % state % uBtr % array(iEdge) &amp;
-                     = block % state % time_levs(2) % state % uBtr % array(iEdge) &amp; 
-                     + block % state % time_levs(newBtrSubcycleTime) % state % uBtrSubcycle % array(iEdge)  
+                       block % state % time_levs(2) % state % normalBarotropicVelocity % array(iEdge) &amp;
+                     = block % state % time_levs(2) % state % normalBarotropicVelocity % array(iEdge) &amp; 
+                     + block % state % time_levs(newBtrSubcycleTime) % state % normalBarotropicVelocitySubcycle % array(iEdge)  
       
                   end do  ! iEdge
                   block =&gt; block % next
@@ -676,15 +674,15 @@
             ! END Barotropic subcycle loop
             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-            ! Normalize Barotropic subcycle sums: ssh, uBtr, and F
+            ! Normalize Barotropic subcycle sums: ssh, normalBarotropicVelocity, and F
             block =&gt; domain % blocklist
             do while (associated(block))
       
                do iEdge=1,block % mesh % nEdges
-                  block % state % time_levs(1) % state % FBtr % array(iEdge) = block % state % time_levs(1) % state % FBtr % array(iEdge) &amp;
+                  block % state % time_levs(1) % state % barotropicThicknessFlux % array(iEdge) = block % state % time_levs(1) % state % barotropicThicknessFlux % array(iEdge) &amp;
                       / (config_n_btr_subcycles*config_btr_subcycle_loop_factor)
       
-                  block % state % time_levs(2) % state % uBtr % array(iEdge) = block % state % time_levs(2) % state % uBtr % array(iEdge) &amp; 
+                  block % state % time_levs(2) % state % normalBarotropicVelocity % array(iEdge) = block % state % time_levs(2) % state % normalBarotropicVelocity % array(iEdge) &amp; 
                      / (config_n_btr_subcycles*config_btr_subcycle_loop_factor + 1)
                end do
       
@@ -694,7 +692,7 @@
       
             ! boundary update on F
             call mpas_timer_start(&quot;se halo F&quot;, .false., timer_halo_f)
-            call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(1) % state % FBtr)
+            call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(1) % state % barotropicThicknessFlux)
             call mpas_timer_stop(&quot;se halo F&quot;, timer_halo_f)
 
 
@@ -713,7 +711,7 @@
                !  - \sum_{k=1}^{N^{edge}} h_{k,*}^{edge}  {\bf u}_k^{avg} \right)
                ! \left/ \sum_{k=1}^{N^{edge}} h_{k,*}^{edge}   \right. 
 
-               if (config_u_correction) then
+               if (config_vel_correction) then
                   ucorr_coef = 1
                else
                   ucorr_coef = 0
@@ -721,34 +719,34 @@
 
                do iEdge=1,block % mesh % nEdges
 
-                  ! velocity for uCorrection is uBtr + uBcl + uBolus
+                  ! velocity for uCorrection is normalBarotropicVelocity + normalBaroclinicVelocity + uBolus
                   uTemp(:) &amp;
-                     = block % state % time_levs(2) % state % uBtr     % array(  iEdge) &amp;
-                     + block % state % time_levs(2) % state % uBcl     % array(:,iEdge) &amp;
+                     = block % state % time_levs(2) % state % normalBarotropicVelocity     % array(  iEdge) &amp;
+                     + block % state % time_levs(2) % state % normalBaroclinicVelocity     % array(:,iEdge) &amp;
                      + block % state % time_levs(1) % state % uBolusGM % array(:,iEdge)
 
-                  ! hSum is initialized outside the loop because on land boundaries 
-                  ! maxLevelEdgeTop=0, but I want to initialize hSum with a 
+                  ! thicknessSum is initialized outside the loop because on land boundaries 
+                  ! maxLevelEdgeTop=0, but I want to initialize thicknessSum with a 
                   ! nonzero value to avoid a NaN.
-                  uhSum = block % state % time_levs(2) % state % h_edge % array(1,iEdge) * uTemp(1)
-                  hSum  = block % state % time_levs(2) % state % h_edge % array(1,iEdge)
+                  normalThicknessFluxSum = block % state % time_levs(2) % state % layerThicknessEdge % array(1,iEdge) * uTemp(1)
+                  thicknessSum  = block % state % time_levs(2) % state % layerThicknessEdge % array(1,iEdge)
 
                   do k=2,block % mesh % maxLevelEdgeTop % array(iEdge)
-                     uhSum = uhSum + block % state % time_levs(2) % state % h_edge % array(k,iEdge) * uTemp(k)
-                     hSum  =  hSum + block % state % time_levs(2) % state % h_edge % array(k,iEdge)
+                     normalThicknessFluxSum = normalThicknessFluxSum + block % state % time_levs(2) % state % layerThicknessEdge % array(k,iEdge) * uTemp(k)
+                     thicknessSum  =  thicknessSum + block % state % time_levs(2) % state % layerThicknessEdge % array(k,iEdge)
                   enddo
 
-                  uCorr =   ucorr_coef*(( block % state % time_levs(1) % state % FBtr % array(iEdge) - uhSum)/hSum)
+                  uCorr =   ucorr_coef*(( block % state % time_levs(1) % state % barotropicThicknessFlux % array(iEdge) - normalThicknessFluxSum)/thicknessSum)
 
                   do k=1,block % mesh % nVertLevels
 
-                     ! uTranport = uBtr + uBcl + uBolus + uCorrection
-                     ! This is u used in advective terms for h and tracers 
+                     ! uTranport = normalBarotropicVelocity + normalBaroclinicVelocity + uBolus + uCorrection
+                     ! This is u used in advective terms for layerThickness and tracers 
                      ! in tendency calls in stage 3.
                        block % state % time_levs(2) % state % uTransport % array(k,iEdge) &amp;
                      = block % mesh % edgeMask % array(k,iEdge) &amp;
-                     *(  block % state % time_levs(2) % state % uBtr       % array(  iEdge) &amp;
-                       + block % state % time_levs(2) % state % uBcl       % array(k,iEdge) &amp;
+                     *(  block % state % time_levs(2) % state % normalBarotropicVelocity       % array(  iEdge) &amp;
+                       + block % state % time_levs(2) % state % normalBaroclinicVelocity       % array(k,iEdge) &amp;
                        + block % state % time_levs(1) % state % uBolusGM   % array(k,iEdge) &amp;
                        + uCorr )
 
@@ -771,31 +769,26 @@
          !
          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-         !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))
 
-            ! compute wTop.  Use uTransport for advection of h and tracers.
-            ! Use time level 1 values of h and h_edge because h has not yet been computed for time level 2.
-            call ocn_wtop(block % mesh, block % state % time_levs(1) % state % h % array, &amp;
-               block % state % time_levs(1) % state % h_edge % array, &amp;
+            ! compute vertTransportVelocityTop.  Use uTransport for advection of layerThickness and tracers.
+            ! Use time level 1 values of layerThickness and layerThicknessEdge because layerThickness has not yet been computed for time level 2.
+            call ocn_vert_transport_velocity_top(block % mesh, block % state % time_levs(1) % state % layerThickness % array, &amp;
+               block % state % time_levs(1) % state % layerThicknessEdge % array, &amp;
                block % state % time_levs(2) % state % uTransport % array, &amp;
-               block % state % time_levs(2) % state % wTop % array, err)
+               block % state % time_levs(2) % state % vertTransportVelocityTop % array, err)
 
-            call ocn_tend_h(block % tend, block % state % time_levs(2) % state, block % mesh)
+            call ocn_tend_thick(block % tend, block % state % time_levs(2) % state, block % mesh)
             block =&gt; block % next
          end do
 
          ! update halo for thickness and tracer tendencies
-         call mpas_timer_start(&quot;se halo h&quot;, .false., timer_halo_h)
-         call mpas_dmpar_exch_halo_field(domain % blocklist % tend % h)
-         call mpas_timer_stop(&quot;se halo h&quot;, timer_halo_h)
+         call mpas_timer_start(&quot;se halo thickness&quot;, .false., timer_halo_thickness)
+         call mpas_dmpar_exch_halo_field(domain % blocklist % tend % layerThickness)
+         call mpas_timer_stop(&quot;se halo thickness&quot;, timer_halo_thickness)
 
          block =&gt; domain % blocklist
          do while (associated(block))
@@ -819,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
@@ -830,20 +820,20 @@
 
                      ! this is h_{n+1}
                      temp_h &amp;
-                        = block % state % time_levs(1) % state % h % array(k,iCell) &amp;
-                        + dt* block % tend % h % array(k,iCell) 
+                        = block % state % time_levs(1) % state % layerThickness % array(k,iCell) &amp;
+                        + dt* block % tend % layerThickness % array(k,iCell) 
 
                      ! this is h_{n+1/2}
-                       block % state % time_levs(2) % state % h % array(k,iCell) &amp;
+                       block % state % time_levs(2) % state % layerThickness % array(k,iCell) &amp;
                      = 0.5*(  &amp;
-                       block % state % time_levs(1) % state % h % array(k,iCell) &amp;
+                       block % state % time_levs(1) % state % layerThickness % array(k,iCell) &amp;
                        + temp_h)
 
                      do i=1,2
                         ! This is Phi at n+1
                         temp = (  &amp;
                            block % state % time_levs(1) % state % tracers % array(i,k,iCell) &amp;
-                         * block % state % time_levs(1) % state % h % array(k,iCell) &amp;
+                         * block % state % time_levs(1) % state % layerThickness % array(k,iCell) &amp;
                          + dt * block % tend % tracers % array(i,k,iCell)) &amp;
                               / temp_h
   
@@ -860,20 +850,20 @@
 
                   do k=1,block % mesh % nVertLevels
 
-                     ! u = uBtr + uBcl 
-                     ! here uBcl is at time n+1/2
+                     ! u = normalBarotropicVelocity + normalBaroclinicVelocity 
+                     ! here normalBaroclinicVelocity is at time n+1/2
                      ! This is u used in next iteration or step
-                       block % state % time_levs(2) % state % u    % array(k,iEdge) &amp;
+                       block % state % time_levs(2) % state % normalVelocity    % array(k,iEdge) &amp;
                      = block % mesh % edgeMask % array(k,iEdge) &amp;
-                     *(  block % state % time_levs(2) % state % uBtr % array(  iEdge) &amp;
-                       + block % state % time_levs(2) % state % uBcl % array(k,iEdge) )
+                     *(  block % state % time_levs(2) % state % normalBarotropicVelocity % array(  iEdge) &amp;
+                       + block % state % time_levs(2) % state % normalBaroclinicVelocity % array(k,iEdge) )
 
                   enddo
 
                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 layerThicknessEdge, density, pressure, and SSH 
+               ! in this diagnostics solve.
                call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
 
             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -883,44 +873,41 @@
             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
             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)
 
                      ! this is h_{n+1}
-                        block % state % time_levs(2) % state % h % array(k,iCell) &amp;
-                      = block % state % time_levs(1) % state % h % array(k,iCell) &amp;
-                      + dt* block % tend % h % array(k,iCell) 
+                        block % state % time_levs(2) % state % layerThickness % array(k,iCell) &amp;
+                      = block % state % time_levs(1) % state % layerThickness % array(k,iCell) &amp;
+                      + dt* block % tend % layerThickness % array(k,iCell) 
 
                      ! This is Phi at n+1
                      do i=1,block % state % time_levs(1) % state % num_tracers
                            block % state % time_levs(2) % state % tracers % array(i,k,iCell)  &amp;
                         = (block % state % time_levs(1) % state % tracers % array(i,k,iCell) &amp;
-                         * block % state % time_levs(1) % state % h % array(k,iCell) &amp;
+                         * block % state % time_levs(1) % state % layerThickness % array(k,iCell) &amp;
                          + dt * block % tend % tracers % array(i,k,iCell)) &amp;
-                         / block % state % time_levs(2) % state % h % array(k,iCell)
+                         / block % state % time_levs(2) % state % layerThickness % array(k,iCell)
 
                      enddo
                   end do
                end do
 
                ! Recompute final u to go on to next step.
-               ! u_{n+1} = uBtr_{n+1} + uBcl_{n+1} 
-               ! Right now uBclNew is at time n+1/2, so back compute to get uBcl at time n+1
-               !   using uBcl_{n+1/2} = 1/2*(uBcl_n + u_Bcl_{n+1})
+               ! u_{n+1} = normalBarotropicVelocity_{n+1} + normalBaroclinicVelocity_{n+1} 
+               ! Right now normalBaroclinicVelocityNew is at time n+1/2, so back compute to get normalBaroclinicVelocity at time n+1
+               !   using normalBaroclinicVelocity_{n+1/2} = 1/2*(normalBaroclinicVelocity_n + u_Bcl_{n+1})
                ! so the following lines are
-               ! u_{n+1} = uBtr_{n+1} + 2*uBcl_{n+1/2} - uBcl_n
-               ! note that uBcl is recomputed at the beginning of the next timestep due to Imp Vert mixing,
-               ! so uBcl does not have to be recomputed here.
+               ! u_{n+1} = normalBarotropicVelocity_{n+1} + 2*normalBaroclinicVelocity_{n+1/2} - normalBaroclinicVelocity_n
+               ! note that normalBaroclinicVelocity is recomputed at the beginning of the next timestep due to Imp Vert mixing,
+               ! so normalBaroclinicVelocity does not have to be recomputed here.
       
                do iEdge=1,block % mesh % nEdges
                   do k=1,block % mesh % maxLevelEdgeTop % array(iEdge)
-                       block % state % time_levs(2) % state % u    % array(k,iEdge) &amp;
-                     = block % state % time_levs(2) % state % uBtr % array(  iEdge) &amp;
-                    +2*block % state % time_levs(2) % state % uBcl % array(k,iEdge) &amp;
-                     - block % state % time_levs(1) % state % uBcl % array(k,iEdge)
+                       block % state % time_levs(2) % state % normalVelocity    % array(k,iEdge) &amp;
+                     = block % state % time_levs(2) % state % normalBarotropicVelocity % array(  iEdge) &amp;
+                    +2*block % state % time_levs(2) % state % normalBaroclinicVelocity % array(k,iEdge) &amp;
+                     - block % state % time_levs(1) % state % normalBaroclinicVelocity % array(k,iEdge)
                   end do
                end do ! iEdges
 
@@ -942,10 +929,10 @@
 
         ! 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 
+        ! For Richardson vertical mixing, only density, layerThicknessEdge, and kineticEnergyEdge 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.
+        ! 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)
@@ -958,7 +945,7 @@
       ! 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 % normalVelocity)
       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;)
 
@@ -968,37 +955,35 @@
       do while (associated(block))
 
          if (config_prescribe_velocity) then
-            block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
+            block % state % time_levs(2) % state % normalVelocity % array(:,:) = block % state % time_levs(1) % state % normalVelocity % array(:,:)
          end if
 
          if (config_prescribe_thickness) then
-            block % state % time_levs(2) % state % h % array(:,:) = block % state % time_levs(1) % state % h % array(:,:)
+            block % state % time_levs(2) % state % layerThickness % array(:,:) = block % state % time_levs(1) % state % layerThickness % array(:,:)
          end if
 
          call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
 
-         ! Compute velocity transport, used in advection terms of h and tracer tendency
+         ! Compute velocity transport, used in advection terms of layerThickness and tracer tendency
             block % state % time_levs(2) % state % uTransport % array(:,:) &amp;
-          = block % state % time_levs(2) % state % u % array(:,:) &amp;
+          = block % state % time_levs(2) % state % normalVelocity % array(:,:) &amp;
           + block % state % time_levs(2) % state % uBolusGM % array(:,:)
 
-         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;
-                          block % state % time_levs(2) % state % uReconstructZ % array,            &amp;
-                          block % state % time_levs(2) % state % uReconstructZonal % array,        &amp;
-                          block % state % time_levs(2) % state % uReconstructMeridional % array    &amp;
+         call mpas_reconstruct(block % mesh, block % state % time_levs(2) % state % normalVelocity % array,          &amp;
+                          block % state % time_levs(2) % state % normalVelocityX % array,            &amp;
+                          block % state % time_levs(2) % state % normalVelocityY % array,            &amp;
+                          block % state % time_levs(2) % state % normalVelocityZ % array,            &amp;
+                          block % state % time_levs(2) % state % normalVelocityZonal % array,        &amp;
+                          block % state % time_levs(2) % state % normalVelocityMeridional % 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;
-                          block % state % time_levs(2) % state % uSrcReconstructZ % array,            &amp;
-                          block % state % time_levs(2) % state % uSrcReconstructZonal % array,        &amp;
-                          block % state % time_levs(2) % state % uSrcReconstructMeridional % array    &amp;
+         call mpas_reconstruct(block % mesh, block % mesh % normalVelocityForcing % array,          &amp;
+                          block % state % time_levs(2) % state % normalVelocityForcingReconstructX % array,            &amp;
+                          block % state % time_levs(2) % state % normalVelocityForcingReconstructY % array,            &amp;
+                          block % state % time_levs(2) % state % normalVelocityForcingReconstructZ % array,            &amp;
+                          block % state % time_levs(2) % state % normalVelocityForcingReconstructZonal % array,        &amp;
+                          block % state % time_levs(2) % state % normalVelocityForcingReconstructMeridional % array    &amp;
                          )
-!TDR
 
          call ocn_time_average_accumulate(block % state % time_levs(2) % state, block % state % time_levs(1) % state)
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_advection.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_advection.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_advection.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -240,24 +240,24 @@
 !&gt;  advection of tracers.
 !
 !-----------------------------------------------------------------------
-   subroutine mpas_ocn_tracer_advection_tend(tracers, uh, w, h, verticalCellSize, dt, grid, tend_h, tend)!{{{
+   subroutine mpas_ocn_tracer_advection_tend(tracers, normalThicknessFlux, w, layerThickness, verticalCellSize, dt, grid, tend_layerThickness, tend)!{{{
 
       real (kind=RKIND), dimension(:,:,:), intent(inout) :: tend !&lt; Input/Output: tracer tendency
       real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers !&lt; Input/Output: tracer values
-      real (kind=RKIND), dimension(:,:), intent(in) :: uh !&lt; Input: Thickness weighted horizontal velocity
+      real (kind=RKIND), dimension(:,:), intent(in) :: normalThicknessFlux !&lt; Input: Thickness weighted horizontal velocity
       real (kind=RKIND), dimension(:,:), intent(in) :: w  !&lt; Input: Vertical velocity
-      real (kind=RKIND), dimension(:,:), intent(in) :: h  !&lt; Input: Thickness field
+      real (kind=RKIND), dimension(:,:), intent(in) :: layerThickness  !&lt; Input: Thickness field
       real (kind=RKIND), dimension(:,:), intent(in) :: verticalCellSize !&lt; Input: Distance between vertical interfaces of a cell
       real (kind=RKIND), intent(in) :: dt !&lt; Input: Time step
       type (mesh_type), intent(in) :: grid !&lt; Input: grid information
-      real (kind=RKIND), dimension(:,:), intent(in) :: tend_h !&lt; Input: Thickness tendency information
+      real (kind=RKIND), dimension(:,:), intent(in) :: tend_layerThickness !&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)
+         call mpas_ocn_tracer_advection_mono_tend(tracers, normalThicknessFlux, w, layerThickness, verticalCellSize, dt, grid, tend_layerThickness, tend)
       else
-         call mpas_ocn_tracer_advection_std_tend(tracers, uh, w, verticalCellSize, grid, tend)
+         call mpas_ocn_tracer_advection_std_tend(tracers, normalThicknessFlux, w, verticalCellSize, grid, tend)
       endif
    end subroutine mpas_ocn_tracer_advection_tend!}}}
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_advection_mono.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_advection_mono.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_advection_mono.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -43,7 +43,7 @@
 !&gt;  Both horizontal and vertical.
 !
 !-----------------------------------------------------------------------
-   subroutine mpas_ocn_tracer_advection_mono_tend(tracers, uh, w, h, verticalCellSize, dt, grid, tend_h, tend)!{{{
+   subroutine mpas_ocn_tracer_advection_mono_tend(tracers, normalThicknessFlux, w, layerThickness, verticalCellSize, dt, grid, tend_layerThickness, tend)!{{{
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    !
    ! Input: s - current model state
@@ -52,11 +52,11 @@
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
 
       real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers !&lt; Input: current tracer values
-      real (kind=RKIND), dimension(:,:), intent(in) :: uh !&lt; Input: Thichness weighted velocitiy
+      real (kind=RKIND), dimension(:,:), intent(in) :: normalThicknessFlux !&lt; Input: Thichness weighted velocitiy
       real (kind=RKIND), dimension(:,:), intent(in) :: w !&lt; Input: Vertical velocitiy
-      real (kind=RKIND), dimension(:,:), intent(in) :: h !&lt; Input: Thickness
+      real (kind=RKIND), dimension(:,:), intent(in) :: layerThickness !&lt; Input: Thickness
       real (kind=RKIND), dimension(:,:), intent(in) :: verticalCellSize !&lt; Input: Distance between vertical interfaces of a cell
-      real (kind=RKIND), dimension(:,:), intent(in) :: tend_h !&lt; Input: Tendency for thickness field
+      real (kind=RKIND), dimension(:,:), intent(in) :: tend_layerThickness !&lt; Input: Tendency for thickness field
       real (kind=RKIND), intent(in) :: dt !&lt; Input: Timestep
       type (mesh_type), intent(in) :: grid !&lt; Input: Grid information
       real (kind=RKIND), dimension(:,:,:), intent(inout) :: tend !&lt; Input/Output: Tracer tendency
@@ -134,7 +134,7 @@
 
       do iCell = 1, nCells
         do k=1, maxLevelCell(iCell)
-          inv_h_new(k, iCell) = 1.0 / (h(k, iCell) + dt * tend_h(k, iCell))
+          inv_h_new(k, iCell) = 1.0 / (layerThickness(k, iCell) + dt * tend_layerThickness(k, iCell))
         end do
       end do
 
@@ -199,9 +199,9 @@
             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.0_RKIND,uh(k,iEdge))*adv_coefs_3rd(i,iEdge))
+                            + highOrderAdvectionMask(k, iEdge) * (adv_coefs(i,iEdge) + coef_3rd_order*sign(1.0_RKIND,normalThicknessFlux(k,iEdge))*adv_coefs_3rd(i,iEdge))
 
-              tracer_weight = uh(k,iEdge)*tracer_weight
+              tracer_weight = normalThicknessFlux(k,iEdge)*tracer_weight
               high_order_horiz_flux(k,iEdge) = high_order_horiz_flux(k,iEdge) + tracer_weight* tracer_cur(k,iCell)
             end do ! k loop
           end do ! i loop over nAdvCellsForEdge
@@ -247,7 +247,7 @@
           invAreaCell2 = 1.0 / areaCell(cell2)
 
           do k = 1, maxLevelEdgeTop(iEdge)
-            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))
+            flux_upwind = dvEdge(iEdge) * (max(0.0_RKIND,normalThicknessFlux(k,iEdge))*tracer_cur(k,cell1) + min(0.0_RKIND,normalThicknessFlux(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
@@ -259,7 +259,7 @@
             cell1 = cellsOnEdge(1,iEdge)
             cell2 = cellsOnEdge(2,iEdge)
             do k = 1, maxLevelEdgeTop(iEdge)
-              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))
+              flux_upwind = dvEdge(iEdge) * (max(0.0_RKIND,normalThicknessFlux(k,iEdge))*tracer_cur(k,cell1) + min(0.0_RKIND,normalThicknessFlux(k,iEdge))*tracer_cur(k,cell2))
 
               upwind_tendency(k,iCell) = upwind_tendency(k,iCell) + edgeSignOncell(i, iCell) * flux_upwind * invAreaCell1
 
@@ -275,9 +275,9 @@
         ! Factors are placed in the flux_incoming and flux_outgoing arrays
         do iCell = 1, nCells
           do k = 1, maxLevelCell(iCell)
-            tracer_min_new = (tracer_cur(k,iCell)*h(k,iCell) + dt*(upwind_tendency(k,iCell)+flux_outgoing(k,iCell))) * inv_h_new(k,iCell)
-            tracer_max_new = (tracer_cur(k,iCell)*h(k,iCell) + dt*(upwind_tendency(k,iCell)+flux_incoming(k,iCell))) * inv_h_new(k,iCell)
-            tracer_upwind_new = (tracer_cur(k,iCell)*h(k,iCell) + dt*upwind_tendency(k,iCell)) * inv_h_new(k,iCell)
+            tracer_min_new = (tracer_cur(k,iCell)*layerThickness(k,iCell) + dt*(upwind_tendency(k,iCell)+flux_outgoing(k,iCell))) * inv_h_new(k,iCell)
+            tracer_max_new = (tracer_cur(k,iCell)*layerThickness(k,iCell) + dt*(upwind_tendency(k,iCell)+flux_incoming(k,iCell))) * inv_h_new(k,iCell)
+            tracer_upwind_new = (tracer_cur(k,iCell)*layerThickness(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_RKIND, max( 0.0_RKIND, scale_factor) )
@@ -337,7 +337,7 @@
               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)
 
               !tracer_new is now the new state of the tracer. Only for a check on monotonicity
-              tracer_new(k, iCell) = (tracer_cur(k, iCell)*h(k, iCell) + dt * tracer_new(k, iCell)) * inv_h_new(k, iCell)
+              tracer_new(k, iCell) = (tracer_cur(k, iCell)*layerThickness(k, iCell) + dt * tracer_new(k, iCell)) * inv_h_new(k, iCell)
             end if
           end do ! k loop
         end do ! iCell loop

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_advection_std.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_advection_std.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_advection_std.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -45,7 +45,7 @@
 !&gt;  tracer advection tendencies.
 !
 !-----------------------------------------------------------------------
-   subroutine mpas_ocn_tracer_advection_std_tend(tracers, uh, w, verticalCellSize, grid, tend)!{{{
+   subroutine mpas_ocn_tracer_advection_std_tend(tracers, normalThicknessFlux, w, verticalCellSize, grid, tend)!{{{
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    !
    ! Input: s - current model state
@@ -56,13 +56,13 @@
 
       real (kind=RKIND), dimension(:,:,:), intent(inout) :: tend !&lt; Input/Output: Tracer tendency
       real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers !&lt; Input: Tracer values
-      real (kind=RKIND), dimension(:,:), intent(in) :: uh !&lt; Input: Thickness weighted horizontal velocity
+      real (kind=RKIND), dimension(:,:), intent(in) :: normalThicknessFlux !&lt; Input: Thickness weighted horizontal velocity
       real (kind=RKIND), dimension(:,:), intent(in) :: w !&lt; Input: Vertical Velocity
       real (kind=RKIND), dimension(:,:), intent(in) :: verticalCellSize !&lt; Input: Distance between vertical interfaces of a cell
       type (mesh_type), intent(in) :: grid !&lt; Input: Grid information
 
       call mpas_timer_start(&quot;tracer-hadv&quot;, .false.)
-      call mpas_ocn_tracer_advection_std_hadv_tend(tracers, uh, grid, tend)
+      call mpas_ocn_tracer_advection_std_hadv_tend(tracers, normalThicknessFlux, grid, tend)
       call mpas_timer_stop(&quot;tracer-hadv&quot;)
       call mpas_timer_start(&quot;tracer-vadv&quot;, .false.)
       call mpas_ocn_tracer_advection_std_vadv_tend(tracers, w, verticalCellSize, grid, tend)

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_advection_std_hadv.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_advection_std_hadv.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_advection_std_hadv.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -45,10 +45,10 @@
 !&gt;  This routine computes the tendency for 3rd order horizontal advection of tracers.
 !
 !-----------------------------------------------------------------------
-   subroutine mpas_ocn_tracer_advection_std_hadv_tend(tracers, uh, grid, tend)!{{{
+   subroutine mpas_ocn_tracer_advection_std_hadv_tend(tracers, normalThicknessFlux, grid, tend)!{{{
       real (kind=RKIND), dimension(:,:,:), intent(inout) :: tend !&lt; Input/output: Tracer tendency
       real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers !&lt; Input: Tracer values
-      real (kind=RKIND), dimension(:,:), intent(in) :: uh !&lt; Input: Thickness weighted horizontal velocity
+      real (kind=RKIND), dimension(:,:), intent(in) :: normalThicknessFlux !&lt; Input: Thickness weighted horizontal velocity
       type (mesh_type), intent(in) :: grid !&lt; Input: Grid information
 
       integer :: i, iCell, iEdge, k, iTracer, cell1, cell2
@@ -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.0_RKIND,uh(k,iEdge))*adv_coefs_3rd(i,iEdge))
+                            + highOrderAdvectionMask(k, iEdge) * (adv_coefs(i,iEdge) + coef_3rd_order*sign(1.0_RKIND,normalThicknessFlux(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
@@ -100,8 +100,8 @@
 
             do k=1,grid % nVertLevels
                do iTracer=1,num_tracers
-                  tend(iTracer,k,cell1) = tend(iTracer,k,cell1) - uh(k,iEdge)*flux_arr(iTracer,k)/areaCell(cell1)
-                  tend(iTracer,k,cell2) = tend(iTracer,k,cell2) + uh(k,iEdge)*flux_arr(iTracer,k)/areaCell(cell2)
+                  tend(iTracer,k,cell1) = tend(iTracer,k,cell1) - normalThicknessFlux(k,iEdge)*flux_arr(iTracer,k)/areaCell(cell1)
+                  tend(iTracer,k,cell2) = tend(iTracer,k,cell2) + normalThicknessFlux(k,iEdge)*flux_arr(iTracer,k)/areaCell(cell2)
                end do
             end do
          end if

Deleted: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hadv.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hadv.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hadv.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,189 +0,0 @@
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-!
-!  ocn_tracer_hadv
-!
-!&gt; \brief MPAS ocean horizontal tracer advection driver
-!&gt; \author Doug Jacobsen
-!&gt; \date   16 September 2011
-!&gt; \version SVN:$Id:$
-!&gt; \details
-!&gt;  This module contains the main driver routine for computing 
-!&gt;  horizontal advection tendencies.  
-!
-!-----------------------------------------------------------------------
-
-module ocn_tracer_hadv
-
-   use mpas_grid_types
-   use mpas_configure
-   use mpas_timer
-
-   use ocn_tracer_hadv2
-   use ocn_tracer_hadv3
-   use ocn_tracer_hadv4
-
-   implicit none
-   private
-   save
-
-   !--------------------------------------------------------------------
-   !
-   ! Public parameters
-   !
-   !--------------------------------------------------------------------
-
-   !--------------------------------------------------------------------
-   !
-   ! Public member functions
-   !
-   !--------------------------------------------------------------------
-
-   public :: ocn_tracer_hadv_tend, &amp;
-             ocn_tracer_hadv_init
-
-   !--------------------------------------------------------------------
-   !
-   ! Private module variables
-   !
-   !--------------------------------------------------------------------
-
-   type (timer_node), pointer :: hadv2Timer, hadv3Timer, hadv4Timer
-
-
-!***********************************************************************
-
-contains
-
-!***********************************************************************
-!
-!  routine ocn_tracer_hadv_tend
-!
-!&gt; \brief   Computes tendency term for horizontal tracer advection
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the horizontal advection tendency for tracer
-!&gt;  based on current state and user choices of advection parameterization.
-!&gt;  Multiple parameterizations may be chosen and added together.  These
-!&gt;  tendencies are generally computed by calling the specific routine
-!&gt;  for the chosen parameterization, so this routine is primarily a
-!&gt;  driver for managing these choices.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_hadv_tend(grid, u, h_edge, tracers, tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      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;
-         tracers     !&lt; Input: tracers
-
-      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 :: err1, err2, err3
-
-      !-----------------------------------------------------------------
-      !
-      ! call relevant routines for computing tendencies
-      ! note that the user can choose multiple options and the 
-      !   tendencies will be added together
-      !
-      !-----------------------------------------------------------------
-
-      call mpas_timer_start(&quot;hadv2&quot;, .false., hadv2Timer);
-      call ocn_tracer_hadv2_tend(grid, u, h_edge, tracers, tend, err1)
-      call mpas_timer_stop(&quot;hadv2&quot;, hadv2Timer);
-      call mpas_timer_start(&quot;hadv3&quot;, .false., hadv3Timer);
-      call ocn_tracer_hadv3_tend(grid, u, h_edge, tracers, tend, err2)
-      call mpas_timer_stop(&quot;hadv3&quot;, hadv3Timer);
-      call mpas_timer_start(&quot;hadv4&quot;, .false., hadv4Timer);
-      call ocn_tracer_hadv4_tend(grid, u, h_edge, tracers, tend, err3)
-      call mpas_timer_stop(&quot;hadv4&quot;, hadv4Timer);
-
-      err = ior(err1, ior(err2, err3))
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_hadv_tend!}}}
-
-!***********************************************************************
-!
-!  routine ocn_tracer_hadv_init
-!
-!&gt; \brief   Initializes ocean tracer horizontal advection quantities
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine initializes a variety of quantities related to 
-!&gt;  horizontal velocity advection in the ocean. Since a variety of 
-!&gt;  parameterizations are available, this routine primarily calls the
-!&gt;  individual init routines for each parameterization. 
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_hadv_init(err)!{{{
-
-   !--------------------------------------------------------------------
-
-      !-----------------------------------------------------------------
-      !
-      ! call individual init routines for each parameterization
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: Error flag
-
-      integer :: err1, err2, err3
-
-      call ocn_tracer_hadv2_init(err1)
-      call ocn_tracer_hadv3_init(err2)
-      call ocn_tracer_hadv4_init(err3)
-
-      err = ior(err1, ior(err2, err3))
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_hadv_init!}}}
-
-!***********************************************************************
-
-end module ocn_tracer_hadv
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-! vim: foldmethod=marker

Deleted: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hadv2.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hadv2.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hadv2.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,199 +0,0 @@
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-!
-!  ocn_tracer_hadv2
-!
-!&gt; \brief MPAS ocean horizontal tracer advection 2nd order
-!&gt; \author Doug Jacobsen
-!&gt; \date   16 September 2011
-!&gt; \version SVN:$Id:$
-!&gt; \details
-!&gt;  This module contains the main driver routine for computing 
-!&gt;  horizontal advection tendencies.  
-!
-!-----------------------------------------------------------------------
-
-module ocn_tracer_hadv2
-
-   use mpas_grid_types
-   use mpas_configure
-
-   implicit none
-   private
-   save
-
-   !--------------------------------------------------------------------
-   !
-   ! Public parameters
-   !
-   !--------------------------------------------------------------------
-
-   !--------------------------------------------------------------------
-   !
-   ! Public member functions
-   !
-   !--------------------------------------------------------------------
-
-   public :: ocn_tracer_hadv2_tend, &amp;
-             ocn_tracer_hadv2_init
-
-   !--------------------------------------------------------------------
-   !
-   ! Private module variables
-   !
-   !--------------------------------------------------------------------
-
-   logical :: hadv2On !&lt; Flag to turn on/off 2nd order hadv
-
-!***********************************************************************
-
-contains
-
-!***********************************************************************
-!
-!  routine ocn_tracer_hadv2_tend
-!
-!&gt; \brief   Computes tendency term for horizontal tracer advection 2nd order
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the horizontal advection tendency for tracer
-!&gt;  based on current state using a 2nd order formulation.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_hadv2_tend(grid, u, h_edge, tracers , tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         u    !&lt; Input: tracer
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge     !&lt; Input: thickness at edge
-
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: &amp;
-        tracers     !&lt; Input: tracers
-
-      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: tracer tendency
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: Error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: iEdge, nEdges, cell1, cell2, iTracer, num_tracers, k
-
-      integer, dimension(:), pointer :: maxLevelEdgeTop
-      integer, dimension(:,:), pointer :: cellsOnEdge
-
-      real (kind=RKIND) :: flux, tracer_edge, invAreaCell1, invAreaCell2, r_tmp
-
-      real (kind=RKIND), dimension(:), pointer :: dvEdge, areaCell
-
-      !-----------------------------------------------------------------
-      !
-      ! 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.hadv2On) return
-
-      nEdges = grid % nEdges
-      maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
-      cellsOnEdge =&gt; grid % cellsOnEdge % array
-      dvEdge =&gt; grid % dvEdge % array
-      areaCell =&gt; grid % areaCell % array
-      num_tracers = size(tracers, 1)
-
-      do iEdge=1,nEdges
-         cell1 = cellsOnEdge(1,iEdge)
-         cell2 = cellsOnEdge(2,iEdge)
-
-         invAreaCell1 = 1.0 / areaCell(cell1)
-         invAreaCell2 = 1.0 / areaCell(cell2)
-         do k=1,maxLevelEdgeTop(iEdge)
-            r_tmp = u(k,iEdge) * dvEdge(iEdge) * h_edge(k,iEdge)
-            do iTracer=1,num_tracers
-               tracer_edge = 0.5 * (tracers(iTracer,k,cell1) + tracers(iTracer,k,cell2))
-               flux = r_tmp * tracer_edge
-               tend(iTracer,k,cell1) = tend(iTracer,k,cell1) - flux * invAreaCell1
-               tend(iTracer,k,cell2) = tend(iTracer,k,cell2) + flux * invAreaCell2
-            end do
-         end do
-      end do
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_hadv2_tend!}}}
-
-!***********************************************************************
-!
-!  routine ocn_tracer_hadv2_init
-!
-!&gt; \brief   Initializes ocean tracer horizontal advection quantities
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine initializes a variety of quantities related to 
-!&gt;  2nd order horizontal tracer advection in the ocean.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_hadv2_init(err)!{{{
-
-   !--------------------------------------------------------------------
-
-      !-----------------------------------------------------------------
-      !
-      ! call individual init routines for each parameterization
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: Error flag
-
-      err = 0
-      hadv2On = .false.
-
-      if (config_horiz_tracer_adv_order == 2) then
-          hadv2On = .true.
-      end if
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_hadv2_init!}}}
-
-!***********************************************************************
-
-end module ocn_tracer_hadv2
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-
-! vim: foldmethod=marker

Deleted: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hadv3.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hadv3.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hadv3.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,239 +0,0 @@
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-!
-!  ocn_tracer_hadv3
-!
-!&gt; \brief MPAS ocean horizontal tracer advection 3rd order
-!&gt; \author Doug Jacobsen
-!&gt; \date   16 September 2011
-!&gt; \version SVN:$Id:$
-!&gt; \details
-!&gt;  This module contains the main driver routine for computing 
-!&gt;  horizontal advection tendencies.  
-!
-!-----------------------------------------------------------------------
-
-module ocn_tracer_hadv3
-
-   use mpas_grid_types
-   use mpas_configure
-
-   implicit none
-   private
-   save
-
-   !--------------------------------------------------------------------
-   !
-   ! Public parameters
-   !
-   !--------------------------------------------------------------------
-
-   !--------------------------------------------------------------------
-   !
-   ! Public member functions
-   !
-   !--------------------------------------------------------------------
-
-   public :: ocn_tracer_hadv3_tend, &amp;
-             ocn_tracer_hadv3_init
-
-   !--------------------------------------------------------------------
-   !
-   ! Private module variables
-   !
-   !--------------------------------------------------------------------
-
-   logical :: hadv3On !&lt; Flag to turn on/off 3rd order hadv
-   real (kind=RKIND) :: coef_3rd_order !&lt; Coefficient for 3rd order hadv
-
-!***********************************************************************
-
-contains
-
-!***********************************************************************
-!
-!  routine ocn_tracer_hadv3_tend
-!
-!&gt; \brief   Computes tendency term for horizontal tracer advection 3rd order
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the horizontal advection tendency for tracer
-!&gt;  based on current state using a 3rd order formulation.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_hadv3_tend(grid, u, h_edge, tracers , tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         u    !&lt; Input: tracer
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge     !&lt; Input: thickness at edge
-
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: &amp;
-        tracers     !&lt; Input: tracers
-
-      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: tracer tendency
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: iEdge, nEdges, cell1, cell2, iTracer, num_tracers, i, k, &amp;
-                 boundaryMask, velMask
-
-      integer, dimension(:), pointer :: maxLevelEdgeTop, nEdgesOnCell
-      integer, dimension(:,:), pointer :: cellsOnEdge, cellsOnCell, &amp;
-                                          cellMask, edgeMask
-
-      real (kind=RKIND) :: flux, tracer_edge, d2fdx2_cell1, d2fdx2_cell2, &amp;
-                           invAreaCell1, invAreaCell2
-
-      real (kind=RKIND), dimension(:), pointer :: dvEdge, dcEdge, areaCell
-      real (kind=RKIND), dimension(:,:,:), pointer :: deriv_two
-
-      !-----------------------------------------------------------------
-      !
-      ! 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.hadv3On) return
-
-      nEdges = grid % nEdges
-      num_tracers = size(tracers, dim=1)
-      maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
-      nEdgesOnCell =&gt; grid % nEdgesOnCell % array
-      cellMask =&gt; grid % cellMask % array
-      cellsOnEdge =&gt; grid % cellsOnEdge % array
-      cellsOnCell =&gt; grid % cellsOnCell % array
-      dvEdge =&gt; grid % dvEdge % array
-      dcEdge =&gt; grid % dcEdge % array
-      areaCell =&gt; grid % areaCell % array
-      deriv_two =&gt; grid % deriv_two % array
-
-      do iEdge=1,nEdges
-         cell1 = cellsOnEdge(1,iEdge)
-         cell2 = cellsOnEdge(2,iEdge)
-
-         invAreaCell1 = 1.0 / areaCell(cell1)
-         invAreaCell2 = 1.0 / areaCell(cell2)
-
-         do k=1,maxLevelEdgeTop(iEdge)
-
-            d2fdx2_cell1 = 0.0
-            d2fdx2_cell2 = 0.0
-
-            boundaryMask = abs(transfer(cellMask(k,cell1)  == 1 .and. cellMask(k,cell2) == 1,boundaryMask))
-
-            do iTracer=1,num_tracers
-
-               !-- if not a boundary cell
-               d2fdx2_cell1 = deriv_two(1,1,iEdge) * tracers(iTracer,k,cell1) * boundaryMask
-               d2fdx2_cell2 = deriv_two(1,2,iEdge) * tracers(iTracer,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) * tracers(iTracer,k,cellsOnCell(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) * tracers(iTracer,k,cellsOnCell(i,cell2))
-               end do
-
-
-               velMask = 2*(abs(transfer(u(k,iEdge) &lt;= 0, velMask))) - 1
-               flux = dvEdge(iEdge) *  u(k,iEdge) * h_edge(k,iEdge) * (          &amp;
-                    0.5*(tracers(iTracer,k,cell1) + tracers(iTracer,k,cell2))      &amp;
-                    -(dcEdge(iEdge) **2) * (d2fdx2_cell1 + d2fdx2_cell2) / 12.          &amp;
-                    +velMask*(dcEdge(iEdge) **2) * coef_3rd_order*(d2fdx2_cell1 - d2fdx2_cell2) / 12. )
-
-               !-- update tendency
-               tend(iTracer,k,cell1) = tend(iTracer,k,cell1) - flux*invAreaCell1
-               tend(iTracer,k,cell2) = tend(iTracer,k,cell2) + flux*invAreaCell2
-            enddo
-         end do
-      end do
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_hadv3_tend!}}}
-
-!***********************************************************************
-!
-!  routine ocn_tracer_hadv3_init
-!
-!&gt; \brief   Initializes ocean tracer horizontal advection quantities
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine initializes a variety of quantities related to 
-!&gt;  3rd order horizontal tracer advection in the ocean. 
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_hadv3_init(err)!{{{
-
-   !--------------------------------------------------------------------
-
-      !-----------------------------------------------------------------
-      !
-      ! call individual init routines for each parameterization
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      err = 0
-      hadv3On = .false.
-
-      if (config_horiz_tracer_adv_order == 3) then
-          hadv3On = .true.
-
-          coef_3rd_order = config_coef_3rd_order
-      end if
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_hadv3_init!}}}
-
-!***********************************************************************
-
-end module ocn_tracer_hadv3
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-! vim: foldmethod=marker

Deleted: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hadv4.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hadv4.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hadv4.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,229 +0,0 @@
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-!
-!  ocn_tracer_hadv4
-!
-!&gt; \brief MPAS ocean horizontal tracer advection 4th order
-!&gt; \author Doug Jacobsen
-!&gt; \date   16 September 2011
-!&gt; \version SVN:$Id:$
-!&gt; \details
-!&gt;  This module contains the main driver routine for computing 
-!&gt;  horizontal advection tendencies.  
-!
-!-----------------------------------------------------------------------
-
-module ocn_tracer_hadv4
-
-   use mpas_grid_types
-   use mpas_configure
-
-   implicit none
-   private
-   save
-
-   !--------------------------------------------------------------------
-   !
-   ! Public parameters
-   !
-   !--------------------------------------------------------------------
-
-   !--------------------------------------------------------------------
-   !
-   ! Public member functions
-   !
-   !--------------------------------------------------------------------
-
-   public :: ocn_tracer_hadv4_tend, &amp;
-             ocn_tracer_hadv4_init
-
-   !--------------------------------------------------------------------
-   !
-   ! Private module variables
-   !
-   !--------------------------------------------------------------------
-
-   logical :: hadv4On !&lt; Flag to turning on/off 4th order hadv
-
-!***********************************************************************
-
-contains
-
-!***********************************************************************
-!
-!  routine ocn_tracer_hadv4_tend
-!
-!&gt; \brief   Computes tendency term for horizontal tracer advection 4th order
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the horizontal advection tendency for tracer
-!&gt;  based on current state using a 4th order formulation.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_hadv4_tend(grid, u, h_edge, tracers , tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         u    !&lt; Input: tracer
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge     !&lt; Input: thickness at edge
-
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: &amp;
-        tracers     !&lt; Input: tracers
-
-      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: tracer tendency
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: iEdge, nEdges, cell1, cell2, iTracer, num_tracers, i, k, &amp;
-                 boundaryMask
-
-      integer, dimension(:), pointer :: maxLevelEdgeTop, nEdgesOnCell
-      integer, dimension(:,:), pointer :: cellsOnEdge, cellsOnCell, cellMask
-
-      real (kind=RKIND) :: flux, tracer_edge, d2fdx2_cell1, d2fdx2_cell2, invAreaCell1, invAreaCell2
-
-      real (kind=RKIND), dimension(:), pointer :: dvEdge, dcEdge, areaCell
-      real (kind=RKIND), dimension(:,:,:), pointer :: deriv_two
-
-      !-----------------------------------------------------------------
-      !
-      ! 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.hadv4On) return
-
-      nEdges = grid % nEdges
-      num_tracers = size(tracers, dim=1)
-      maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
-      nEdgesOnCell =&gt; grid % nEdgesOnCell % array
-      cellMask =&gt; grid % cellMask % array
-      cellsOnEdge =&gt; grid % cellsOnEdge % array
-      cellsOnCell =&gt; grid % cellsOnCell % array
-      dvEdge =&gt; grid % dvEdge % array
-      dcEdge =&gt; grid % dcEdge % array
-      areaCell =&gt; grid % areaCell % array
-      deriv_two =&gt; grid % deriv_two % array
-
-      do iEdge=1,nEdges
-         cell1 = cellsOnEdge(1,iEdge)
-         cell2 = cellsOnEdge(2,iEdge)
-
-         invAreaCell1 = 1.0 / areaCell(cell1)
-         invAreaCell2 = 1.0 / areaCell(cell2)
-
-         do k=1,maxLevelEdgeTop(iEdge)
-
-            d2fdx2_cell1 = 0.0
-            d2fdx2_cell2 = 0.0
-
-            boundaryMask = abs(transfer(cellMask(k,cell1) == 1 .and. cellMask(k, cell2) == 1, boundaryMask))
-
-            do iTracer=1,num_tracers
-               d2fdx2_cell1 = deriv_two(1,1,iEdge) * tracers(iTracer,k,cell1) * boundaryMask
-               d2fdx2_cell2 = deriv_two(1,2,iEdge) * tracers(iTracer,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) * tracers(iTracer,k,cellsOnCell(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) * tracers(iTracer,k,cellsOnCell(i,cell2))
-               end do
-
-               flux = dvEdge(iEdge) *  u(k,iEdge) * h_edge(k,iEdge) * (          &amp;
-                    0.5*(tracers(iTracer,k,cell1) + tracers(iTracer,k,cell2))      &amp;
-                       -(dcEdge(iEdge) **2) * (d2fdx2_cell1 + d2fdx2_cell2) / 12. )
-
-               !-- update tendency
-               tend(iTracer,k,cell1) = tend(iTracer,k,cell1) - flux * invAreaCell1
-               tend(iTracer,k,cell2) = tend(iTracer,k,cell2) + flux * invAreaCell2
-            enddo
-         end do
-      end do
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_hadv4_tend!}}}
-
-!***********************************************************************
-!
-!  routine ocn_tracer_hadv4_init
-!
-!&gt; \brief   Initializes ocean tracer horizontal advection quantities
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine initializes the 4th order formulation for 
-!&gt;  horizontal tracer advection in the ocean. 
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_hadv4_init(err)!{{{
-
-   !--------------------------------------------------------------------
-
-      !-----------------------------------------------------------------
-      !
-      ! call individual init routines for each parameterization
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: Error flag
-
-      err = 0
-      hadv4On = .false.
-
-      if (config_horiz_tracer_adv_order == 4) then
-          hadv4On = .true.
-      end if
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_hadv4_init!}}}
-
-!***********************************************************************
-
-end module ocn_tracer_hadv4
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-! vim: foldmethod=marker

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hmix.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hmix.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hmix.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -73,7 +73,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_tracer_hmix_tend(grid, h_edge, tracers, tend, err)!{{{
+   subroutine ocn_tracer_hmix_tend(grid, layerThicknessEdge, tracers, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -82,7 +82,7 @@
       !-----------------------------------------------------------------
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge    !&lt; Input: thickness at edge
+         layerThicknessEdge    !&lt; Input: thickness at edge
 
       type (mesh_type), intent(in) :: &amp;
          grid          !&lt; Input: grid information
@@ -126,10 +126,10 @@
       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 ocn_tracer_hmix_del2_tend(grid, layerThicknessEdge, tracers, tend, err1)
       call mpas_timer_stop(&quot;del2&quot;, del2Timer)
       call mpas_timer_start(&quot;del4&quot;, .false., del4Timer)
-      call ocn_tracer_hmix_del4_tend(grid, h_edge, tracers, tend, err2)
+      call ocn_tracer_hmix_del4_tend(grid, layerThicknessEdge, tracers, tend, err2)
       call mpas_timer_stop(&quot;del4&quot;, del4Timer)
 
       err = ior(err1, err2)

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hmix_del2.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hmix_del2.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hmix_del2.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -67,7 +67,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_tracer_hmix_del2_tend(grid, h_edge, tracers, tend, err)!{{{
+   subroutine ocn_tracer_hmix_del2_tend(grid, layerThicknessEdge, tracers, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -76,7 +76,7 @@
       !-----------------------------------------------------------------
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge    !&lt; Input: thickness at edge
+         layerThicknessEdge    !&lt; Input: thickness at edge
 
       type (mesh_type), intent(in) :: &amp;
          grid          !&lt; Input: grid information
@@ -168,7 +168,7 @@
               tracer_turb_flux = tracers(iTracer, k, cell2) - tracers(iTracer, k, cell1)
 
               ! div(h \kappa_2 </font>
<font color="gray">abla \phi) at cell center
-              flux = h_edge(k, iEdge) * tracer_turb_flux * edgeMask(k, iEdge) * r_tmp
+              flux = layerThicknessEdge(k, iEdge) * tracer_turb_flux * edgeMask(k, iEdge) * r_tmp
 
               tend(iTracer, k, iCell) = tend(iTracer, k, iCell) - edgeSignOnCell(i, iCell) * flux * invAreaCell1
             end do

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hmix_del4.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hmix_del4.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_hmix_del4.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -67,7 +67,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_tracer_hmix_del4_tend(grid, h_edge, tracers, tend, err)!{{{
+   subroutine ocn_tracer_hmix_del4_tend(grid, layerThicknessEdge, tracers, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -76,7 +76,7 @@
       !-----------------------------------------------------------------
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge    !&lt; Input: thickness at edge
+         layerThicknessEdge    !&lt; Input: thickness at edge
 
       type (mesh_type), intent(in) :: &amp;
          grid          !&lt; Input: grid information
@@ -168,8 +168,8 @@
           do k = 1, maxLevelEdgeTop(iEdge)
             do iTracer = 1, num_tracers * edgeMask(k, iEdge)
 
-              r_tmp1 = invdcEdge * h_edge(k, iEdge) * tracers(iTracer, k, cell1)
-              r_tmp2 = invdcEdge * h_edge(k, iEdge) * tracers(iTracer, k, cell2)
+              r_tmp1 = invdcEdge * layerThicknessEdge(k, iEdge) * tracers(iTracer, k, cell1)
+              r_tmp2 = invdcEdge * layerThicknessEdge(k, iEdge) * tracers(iTracer, k, cell2)
 
               delsq_tracer(iTracer, k, iCell) = delsq_tracer(iTracer, k, iCell) - edgeSignOnCell(i, iCell) * (r_tmp2 - r_tmp1) * invAreaCell1
             end do

Deleted: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,192 +0,0 @@
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-!
-!  ocn_tracer_vadv
-!
-!&gt; \brief MPAS ocean vertical tracer advection driver
-!&gt; \author Doug Jacobsen
-!&gt; \date   16 September 2011
-!&gt; \version SVN:$Id:$
-!&gt; \details
-!&gt;  This module contains the main driver routine for computing 
-!&gt;  vertical advection tendencies.  
-!
-!-----------------------------------------------------------------------
-
-module ocn_tracer_vadv
-
-   use mpas_grid_types
-   use mpas_configure
-
-   use ocn_tracer_vadv_stencil
-   use ocn_tracer_vadv_spline
-
-   implicit none
-   private
-   save
-
-   !--------------------------------------------------------------------
-   !
-   ! Public parameters
-   !
-   !--------------------------------------------------------------------
-
-   !--------------------------------------------------------------------
-   !
-   ! Public member functions
-   !
-   !--------------------------------------------------------------------
-
-   public :: ocn_tracer_vadv_tend, &amp;
-             ocn_tracer_vadv_init
-
-   !--------------------------------------------------------------------
-   !
-   ! Private module variables
-   !
-   !--------------------------------------------------------------------
-
-   logical :: vadvOn
-
-
-!***********************************************************************
-
-contains
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_tend
-!
-!&gt; \brief   Computes tendency term for vertical tracer advection
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the vertical advection tendency for tracer
-!&gt;  based on current state and user choices of advection parameterization.
-!&gt;  Multiple parameterizations may be chosen and added together.  These
-!&gt;  tendencies are generally computed by calling the specific routine
-!&gt;  for the chosen parameterization, so this routine is primarily a
-!&gt;  driver for managing these choices.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_tend(grid, h, wTop, tracers, tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h, &amp;    !&lt; Input: layer thickness
-         wTop    !&lt; Input: vertical tracer in top layer
-
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: &amp;
-         tracers     !&lt; Input: tracers
-
-      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: tracer tendency
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: err1, err2
-
-      !-----------------------------------------------------------------
-      !
-      ! call relevant routines for computing tendencies
-      ! note that the user can choose multiple options and the 
-      !   tendencies will be added together
-      !
-      !-----------------------------------------------------------------
-
-      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)
-      call ocn_tracer_vadv_spline_tend(grid, h, wTop, tracers, tend, err2)
-
-      err = ior(err1, err2)
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_tend!}}}
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_init
-!
-!&gt; \brief   Initializes ocean tracer vertical advection quantities
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine initializes a variety of quantities related to 
-!&gt;  vertical tracer advection in the ocean. Since a variety of 
-!&gt;  parameterizations are available, this routine primarily calls the
-!&gt;  individual init routines for each parameterization. 
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_init(err)!{{{
-
-   !--------------------------------------------------------------------
-
-      !-----------------------------------------------------------------
-      !
-      ! call individual init routines for each parameterization
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      integer :: err1, err2
-
-      err = 0
-      vadvOn = .false.
-
-      if (config_vert_coord_movement.ne.'isopycnal') then
-          vadvOn = .true.
-          call ocn_tracer_vadv_stencil_init(err1)
-          call ocn_tracer_vadv_spline_init(err2)
-
-          err = ior(err1, err2)
-      endif
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_init!}}}
-
-!***********************************************************************
-
-end module ocn_tracer_vadv
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-! vim: foldmethod=marker

Deleted: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_spline.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_spline.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_spline.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,196 +0,0 @@
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-!
-!  ocn_tracer_vadv_spline
-!
-!&gt; \brief MPAS ocean vertical tracer advection driver
-!&gt; \author Doug Jacobsen
-!&gt; \date   16 September 2011
-!&gt; \version SVN:$Id:$
-!&gt; \details
-!&gt;  This module contains the main driver routine for computing 
-!&gt;  vertical advection tendencies.  
-!
-!-----------------------------------------------------------------------
-
-module ocn_tracer_vadv_spline
-
-   use mpas_grid_types
-   use mpas_configure
-   use mpas_timer
-
-   use ocn_tracer_vadv_spline2
-   use ocn_tracer_vadv_spline3
-
-   implicit none
-   private
-   save
-
-   !--------------------------------------------------------------------
-   !
-   ! Public parameters
-   !
-   !--------------------------------------------------------------------
-
-   !--------------------------------------------------------------------
-   !
-   ! Public member functions
-   !
-   !--------------------------------------------------------------------
-
-   public :: ocn_tracer_vadv_spline_tend, &amp;
-             ocn_tracer_vadv_spline_init
-
-   !--------------------------------------------------------------------
-   !
-   ! Private module variables
-   !
-   !--------------------------------------------------------------------
-
-   type (timer_node), pointer :: spline2_timer, spline3_timer
-   logical :: splineOn
-
-
-!***********************************************************************
-
-contains
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_spline_tend
-!
-!&gt; \brief   Computes tendency term for vertical tracer advection
-!&gt; \author  Doug Jacobsen
-!&gt; \date    16 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the vertical advection tendency for tracer
-!&gt;  based on current state and user choices of advection parameterization.
-!&gt;  Multiple parameterizations may be chosen and added together.  These
-!&gt;  tendencies are generally computed by calling the specific routine
-!&gt;  for the chosen parameterization, so this routine is primarily a
-!&gt;  driver for managing these choices.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_spline_tend(grid, h, wTop, tracers, tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h, &amp;    !&lt; Input: layer thickness
-         wTop    !&lt; Input: vertical tracer in top layer
-
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: &amp;
-         tracers     !&lt; Input: tracers
-
-      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: tracer tendency
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: err1, err2
-
-      !-----------------------------------------------------------------
-      !
-      ! 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.splineOn) return
-
-      call mpas_timer_start(&quot;spline 2&quot;, .false., spline2_timer)
-      call ocn_tracer_vadv_spline2_tend(grid, h, wTop, tracers, tend, err1)
-      call mpas_timer_stop(&quot;spline 2&quot;, spline2_timer)
-
-      call mpas_timer_start(&quot;spline 3&quot;, .false., spline3_timer)
-      call ocn_tracer_vadv_spline3_tend(grid, h, wTop, tracers, tend, err2)
-      call mpas_timer_stop(&quot;spline 3&quot;, spline3_timer)
-
-      err = ior(err1, err2)
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_spline_tend!}}}
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_spline_init
-!
-!&gt; \brief   Initializes ocean tracer vertical advection quantities
-!&gt; \author  Doug Jacobsen
-!&gt; \date    16 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine initializes a variety of quantities related to 
-!&gt;  vertical tracer advection in the ocean. Since a variety of 
-!&gt;  parameterizations are available, this routine primarily calls the
-!&gt;  individual init routines for each parameterization. 
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_spline_init(err)!{{{
-
-   !--------------------------------------------------------------------
-
-      !-----------------------------------------------------------------
-      !
-      ! call individual init routines for each parameterization
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      integer :: err1, err2
-
-      err = 0
-
-      splineOn = .false.
-
-      if(config_vert_tracer_adv.eq.'spline') then
-         splineOn = .true.
-
-         call ocn_tracer_vadv_spline2_init(err1)
-         call ocn_tracer_vadv_spline3_init(err2)
-
-         err = ior(err1, err2)
-      endif
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_spline_init!}}}
-
-!***********************************************************************
-
-end module ocn_tracer_vadv_spline
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-! vim: foldmethod=marker

Deleted: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_spline2.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_spline2.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_spline2.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,208 +0,0 @@
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-!
-!  ocn_tracer_vadv_spline2
-!
-!&gt; \brief MPAS ocean vertical tracer advection driver
-!&gt; \author Doug Jacobsen
-!&gt; \date   16 September 2011
-!&gt; \version SVN:$Id:$
-!&gt; \details
-!&gt;  This module contains the main driver routine for computing 
-!&gt;  vertical advection tendencies.  
-!
-!-----------------------------------------------------------------------
-
-module ocn_tracer_vadv_spline2
-
-   use mpas_grid_types
-   use mpas_configure
-
-   implicit none
-   private
-   save
-
-   !--------------------------------------------------------------------
-   !
-   ! Public parameters
-   !
-   !--------------------------------------------------------------------
-
-   !--------------------------------------------------------------------
-   !
-   ! Public member functions
-   !
-   !--------------------------------------------------------------------
-
-   public :: ocn_tracer_vadv_spline2_tend, &amp;
-             ocn_tracer_vadv_spline2_init
-
-   !--------------------------------------------------------------------
-   !
-   ! Private module variables
-   !
-   !--------------------------------------------------------------------
-
-   logical :: spline2On
-
-
-!***********************************************************************
-
-contains
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_spline2_tend
-!
-!&gt; \brief   Computes tendency term for vertical tracer advection 2nd order spline
-!&gt; \author  Doug Jacobsen
-!&gt; \date    16 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the vertical advection tendency for tracer
-!&gt;  based on current state using a 2nd order spline.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_spline2_tend(grid, h, wTop, tracers, tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h, &amp;    !&lt; Input: layer thickness
-         wTop    !&lt; Input: vertical tracer in top layer
-
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: &amp;
-         tracers     !&lt; Input: tracers
-
-      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: tracer tendency
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: iCell, nCells, nCellsSolve, k, iTracer, num_tracers, nVertLevels
-
-      integer, dimension(:), pointer :: maxLevelCell
-
-      real (kind=RKIND), dimension(:,:,:), allocatable :: tracerTop
-
-      !-----------------------------------------------------------------
-      !
-      ! 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.spline2On) return
-      ! Compute tracerTop using linear interpolation.
-
-      nCells = grid % nCells
-      nCellsSolve = grid % nCellsSolve
-      nVertLevels = grid % nVertLevels
-      num_tracers = size(tracers, 1)
-      maxLevelCell =&gt; grid % maxLevelCell % array
-
-      allocate(tracerTop(num_tracers,nVertLevels+1,nCells))
-
-      do iCell=1,nCellsSolve 
-         tracerTop(:,1,iCell) = tracers(:,1,iCell) 
-         do k=2,maxLevelCell(iCell)
-            do iTracer=1,num_tracers
-               ! Note h on the k side is multiplied by tracer at k-1
-               ! and h on the Km1 (k-1) side is mult. by tracer at k.
-               tracerTop(iTracer,k,iCell) = &amp;
-                  (  h(k  ,iCell)*tracers(iTracer,k-1,iCell) &amp;
-                   + h(k-1,iCell)*tracers(iTracer,k  ,iCell) ) &amp;
-                  / (h(k-1,iCell) + h(k,iCell))   
-            end do
-         end do
-         tracerTop(:,maxLevelCell(iCell)+1,iCell) = tracers(:,maxLevelCell(iCell),iCell)
-      end do
-
-      do iCell=1,nCellsSolve 
-         do k=1,maxLevelCell(iCell)  
-            do iTracer=1,num_tracers
-               tend(iTracer,k,iCell) = tend(iTracer,k,iCell) &amp;
-                  - (   wTop(k  ,iCell)*tracerTop(iTracer,k  ,iCell) &amp;
-                      - wTop(k+1,iCell)*tracerTop(iTracer,k+1,iCell))
-            end do
-         end do
-      end do
-
-      deallocate(tracerTop)
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_spline2_tend!}}}
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_spline2_init
-!
-!&gt; \brief   Initializes ocean tracer vertical advection quantities
-!&gt; \author  Doug Jacobsen
-!&gt; \date    16 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine initializes a variety of quantities related to 
-!&gt;  2nd order spline based vertical tracer advection in the ocean.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_spline2_init(err)!{{{
-
-   !--------------------------------------------------------------------
-
-      !-----------------------------------------------------------------
-      !
-      ! call individual init routines for each parameterization
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      err = 0
-
-      spline2On = .false.
-
-      if(config_vert_tracer_adv_order.eq.2) then
-        spline2On = .true.
-      endif
-
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_spline2_init!}}}
-
-!***********************************************************************
-
-end module ocn_tracer_vadv_spline2
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-! vim: foldmethod=marker

Deleted: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_spline3.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_spline3.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_spline3.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,235 +0,0 @@
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-!
-!  ocn_tracer_vadv_spline3
-!
-!&gt; \brief MPAS ocean vertical tracer advection driver
-!&gt; \author Doug Jacobsen
-!&gt; \date   16 September 2011
-!&gt; \version SVN:$Id:$
-!&gt; \details
-!&gt;  This module contains the main driver routine for computing 
-!&gt;  vertical advection tendencies.  
-!
-!-----------------------------------------------------------------------
-
-module ocn_tracer_vadv_spline3
-
-   use mpas_grid_types
-   use mpas_configure
-   use mpas_spline_interpolation
-
-   implicit none
-   private
-   save
-
-   !--------------------------------------------------------------------
-   !
-   ! Public parameters
-   !
-   !--------------------------------------------------------------------
-
-   !--------------------------------------------------------------------
-   !
-   ! Public member functions
-   !
-   !--------------------------------------------------------------------
-
-   public :: ocn_tracer_vadv_spline3_tend, &amp;
-             ocn_tracer_vadv_spline3_init
-
-   !--------------------------------------------------------------------
-   !
-   ! Private module variables
-   !
-   !--------------------------------------------------------------------
-
-   logical :: spline3On
-
-
-!***********************************************************************
-
-contains
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_spline3_tend
-!
-!&gt; \brief   Computes tendency term for vertical tracer advection 3rd order spline
-!&gt; \author  Doug Jacobsen
-!&gt; \date    16 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the vertical advection tendency for tracer
-!&gt;  based on current state using a 3rd order spline.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_spline3_tend(grid, h, wTop, tracers, tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h, &amp;    !&lt; Input: layer thickness
-         wTop    !&lt; Input: vertical tracer in top layer
-
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: &amp;
-         tracers     !&lt; Input: tracers
-
-      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: tracer tendency
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: iCell, nCells, nCellsSolve, k, iTracer, num_tracers, nVertLevels
-
-      integer, dimension(:), pointer :: maxLevelCell
-
-      real (kind=RKIND), dimension(:), allocatable :: tracer2ndDer,  &amp;
-            tracersIn, tracersOut, depthTop, depthMid
-      real (kind=RKIND), dimension(:,:,:), allocatable :: tracerTop
-
-      !-----------------------------------------------------------------
-      !
-      ! 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.spline3On) return
-      ! Compute tracerTop using linear interpolation.
-
-      nCells = grid % nCells
-      nCellsSolve = grid % nCellsSolve
-      nVertLevels = grid % nVertLevels
-      num_tracers = size(tracers, 1)
-      maxLevelCell =&gt; grid % maxLevelCell % array
-
-      allocate(tracerTop(num_tracers,nVertLevels+1,nCells))
-
-      ! Compute tracerTop using cubic spline interpolation.
-
-      allocate(tracer2ndDer(nVertLevels))
-      allocate(tracersIn(nVertLevels),tracersOut(nVertLevels), &amp;
-            depthMid(nVertLevels), depthTop(nVertLevels+1))
-
-      do iCell=1,nCellsSolve 
-
-         ! Here depth considers SSH to be depth=0.  We don't need to 
-         ! have true z-coordinate depths because it is just for interpolation.
-         depthTop(1) = 0.0
-         do k=1,maxLevelCell(iCell)
-            depthMid(k  ) = depthTop(k) + 0.5*h(k,iCell)
-            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 
-            ! subroutine call.  
-            tracersIn(1:maxLevelCell(iCell))=tracers(iTracer,1:maxLevelCell(iCell),iCell)
-
-            call mpas_cubic_spline_coefficients(depthMid, &amp;
-               tracersIn, maxLevelCell(iCell), tracer2ndDer)
-
-            call mpas_interpolate_cubic_spline( &amp;
-               depthMid, tracersIn, tracer2ndDer, maxLevelCell(iCell), &amp;
-               depthTop(2:maxLevelCell(iCell)), tracersOut, maxLevelCell(iCell)-1 )
-
-            tracerTop(itracer,1,iCell) = tracers(iTracer,1,iCell)
-            tracerTop(iTracer,2:maxLevelCell(iCell),iCell) = tracersOut(1:maxLevelCell(iCell)-1)
-            tracerTop(itracer,maxLevelCell(iCell)+1,iCell) = tracers(iTracer,maxLevelCell(iCell),iCell)
-         end do
-      end do
-
-      do iCell=1,nCellsSolve 
-         do k=1,maxLevelCell(iCell)  
-            do iTracer=1,num_tracers
-               tend(iTracer,k,iCell) = tend(iTracer,k,iCell) &amp;
-                  - (   wTop(k  ,iCell)*tracerTop(iTracer,k  ,iCell) &amp;
-                      - wTop(k+1,iCell)*tracerTop(iTracer,k+1,iCell))
-            end do
-         end do
-      end do
-
-      deallocate(tracer2ndDer)
-      deallocate(tracersIn,tracersOut, depthMid, depthTop)
-      deallocate(tracerTop)
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_spline3_tend!}}}
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_spline3_init
-!
-!&gt; \brief   Initializes ocean tracer vertical advection quantities
-!&gt; \author  Doug Jacobsen
-!&gt; \date    16 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine initializes a variety of quantities related to 
-!&gt;  3rd order spline based vertical tracer advection in the ocean.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_spline3_init(err)!{{{
-
-   !--------------------------------------------------------------------
-
-      !-----------------------------------------------------------------
-      !
-      ! call individual init routines for each parameterization
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      err = 0
-
-      spline3On = .false.
-
-      if(config_vert_tracer_adv_order.eq.3) then
-        spline3On = .true.
-      endif
-
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_spline3_init!}}}
-
-!***********************************************************************
-
-end module ocn_tracer_vadv_spline3
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-! vim: foldmethod=marker

Deleted: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_stencil.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_stencil.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_stencil.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,201 +0,0 @@
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-!
-!  ocn_tracer_vadv_stencil
-!
-!&gt; \brief MPAS ocean vertical tracer advection driver
-!&gt; \author Doug Jacobsen
-!&gt; \date   16 September 2011
-!&gt; \version SVN:$Id:$
-!&gt; \details
-!&gt;  This module contains the main driver routine for computing 
-!&gt;  vertical advection tendencies.  
-!
-!-----------------------------------------------------------------------
-
-module ocn_tracer_vadv_stencil
-
-   use mpas_grid_types
-   use mpas_configure
-   use mpas_timer
-
-   use ocn_tracer_vadv_stencil2
-   use ocn_tracer_vadv_stencil3
-   use ocn_tracer_vadv_stencil4
-
-   implicit none
-   private
-   save
-
-   !--------------------------------------------------------------------
-   !
-   ! Public parameters
-   !
-   !--------------------------------------------------------------------
-
-   !--------------------------------------------------------------------
-   !
-   ! Public member functions
-   !
-   !--------------------------------------------------------------------
-
-   public :: ocn_tracer_vadv_stencil_tend, &amp;
-             ocn_tracer_vadv_stencil_init
-
-   !--------------------------------------------------------------------
-   !
-   ! Private module variables
-   !
-   !--------------------------------------------------------------------
-
-   type (timer_node), pointer :: stencil2_timer, stencil3_timer, stencil4_timer
-
-   logical :: stencilOn
-
-
-!***********************************************************************
-
-contains
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_stencil_tend
-!
-!&gt; \brief   Computes tendency term for vertical tracer advection
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the vertical advection tendency for tracers
-!&gt;  based on current state and user choices of stencil based advection parameterization.
-!&gt;  Multiple parameterizations may be chosen and added together.  These
-!&gt;  tendencies are generally computed by calling the specific routine
-!&gt;  for the chosen parameterization, so this routine is primarily a
-!&gt;  driver for managing these choices.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_stencil_tend(grid, h, wTop, tracers, tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h, &amp;    !&lt; Input: layer thickness
-         wTop    !&lt; Input: vertical tracer in top layer
-
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: &amp;
-         tracers     !&lt; Input: tracers
-
-      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: tracer tendency
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: err1, err2, err3
-
-      !-----------------------------------------------------------------
-      !
-      ! 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. stencilOn) return
-
-      call mpas_timer_start(&quot;stencil 2&quot;, .false., stencil2_timer)
-      call ocn_tracer_vadv_stencil2_tend(grid, wTop, tracers, tend, err1)
-      call mpas_timer_stop(&quot;stencil 2&quot;, stencil2_timer)
-      call mpas_timer_start(&quot;stencil 3&quot;, .false., stencil3_timer)
-      call ocn_tracer_vadv_stencil3_tend(grid, h, wTop, tracers, tend, err2)
-      call mpas_timer_stop(&quot;stencil 3&quot;, stencil3_timer)
-      call mpas_timer_start(&quot;stencil 4&quot;, .false., stencil4_timer)
-      call ocn_tracer_vadv_stencil4_tend(grid, h, wTop, tracers, tend, err3)
-      call mpas_timer_stop(&quot;stencil 4&quot;, stencil4_timer)
-
-      err = ior(err1, ior(err2, err3))
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_stencil_tend!}}}
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_stencil_init
-!
-!&gt; \brief   Initializes ocean tracer vertical advection quantities
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine initializes a variety of quantities related to 
-!&gt;  stencil based vertical tracer advection in the ocean. Since a variety of 
-!&gt;  parameterizations are available, this routine primarily calls the
-!&gt;  individual init routines for each parameterization. 
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_stencil_init(err)!{{{
-
-   !--------------------------------------------------------------------
-
-      !-----------------------------------------------------------------
-      !
-      ! call individual init routines for each parameterization
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      integer :: err1, err2, err3
-
-      err = 0
-
-      stencilOn = .false.
-
-      if (config_vert_tracer_adv.eq.'stencil') then
-         stencilOn = .true.
-
-         call ocn_tracer_vadv_stencil2_init(err1)
-         call ocn_tracer_vadv_stencil3_init(err2)
-         call ocn_tracer_vadv_stencil4_init(err3)
-
-         err = ior(err1, ior(err2, err3))
-      endif
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_stencil_init!}}}
-
-!***********************************************************************
-
-end module ocn_tracer_vadv_stencil
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-! vim: foldmethod=marker

Deleted: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_stencil2.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_stencil2.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_stencil2.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,208 +0,0 @@
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-!
-!  ocn_tracer_vadv_stencil2
-!
-!&gt; \brief MPAS ocean vertical tracer advection driver
-!&gt; \author Doug Jacobsen
-!&gt; \date   16 September 2011
-!&gt; \version SVN:$Id:$
-!&gt; \details
-!&gt;  This module contains the main driver routine for computing 
-!&gt;  vertical advection tendencies.  
-!
-!-----------------------------------------------------------------------
-
-module ocn_tracer_vadv_stencil2
-
-   use mpas_grid_types
-   use mpas_configure
-
-   implicit none
-   private
-   save
-
-   !--------------------------------------------------------------------
-   !
-   ! Public parameters
-   !
-   !--------------------------------------------------------------------
-
-   !--------------------------------------------------------------------
-   !
-   ! Public member functions
-   !
-   !--------------------------------------------------------------------
-
-   public :: ocn_tracer_vadv_stencil2_tend, &amp;
-             ocn_tracer_vadv_stencil2_init
-
-   !--------------------------------------------------------------------
-   !
-   ! Private module variables
-   !
-   !--------------------------------------------------------------------
-
-   logical :: stencil2On
-
-
-!***********************************************************************
-
-contains
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_stencil2_tend
-!
-!&gt; \brief   Computes tendency term for vertical tracer advection 2nd order stencil
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the vertical advection tendency for tracer
-!&gt;  based on current state using a 2nd order stencil.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_stencil2_tend(grid, wTop, tracers, tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         wTop    !&lt; Input: vertical tracer in top layer
-
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: &amp;
-         tracers     !&lt; Input: tracers
-
-      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: tracer tendency
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: nCellsSolve, iCell, k, iTracer, num_tracers, nVertLevels
-      integer :: nCells
-
-      integer, dimension(:), pointer :: maxLevelCell
-
-      real (kind=RKIND), dimension(:,:,:), allocatable :: tracerTop
-
-
-      !-----------------------------------------------------------------
-      !
-      ! 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.stencil2On) return
-
-      nCells = grid % nCells
-      nCellsSolve = grid % nCellsSolve
-      num_tracers = size(tracers, 1)
-      nVertLevels = grid % nVertLevels
-      maxLevelCell =&gt; grid % maxLevelCell % array
-
-      allocate(tracerTop(num_tracers,nVertLevels+1,nCells))
-
-      ! Compute tracerTop using centered stencil, a simple average.
-
-      do iCell=1,nCellsSolve 
-         tracerTop(:,1,iCell) = tracers(:,1,iCell)
-         do k=2,maxLevelCell(iCell)
-            do iTracer=1,num_tracers
-               tracerTop(iTracer,k,iCell) = &amp;
-                  ( tracers(iTracer,k-1,iCell) &amp;
-                   +tracers(iTracer,k  ,iCell))/2.0
-            end do
-         end do
-        tracerTop(:,maxLevelCell(iCell)+1,iCell) = tracers(:,maxLevelCell(iCell),iCell)
-      end do
-
-      do iCell=1,nCellsSolve 
-         do k=1,maxLevelCell(iCell)  
-            do iTracer=1,num_tracers
-               tend(iTracer,k,iCell) = tend(iTracer,k,iCell) &amp;
-                  - (   wTop(k  ,iCell)*tracerTop(iTracer,k  ,iCell) &amp;
-                      - wTop(k+1,iCell)*tracerTop(iTracer,k+1,iCell))
-            end do
-         end do
-      end do
-
-      deallocate(tracerTop)
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_stencil2_tend!}}}
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_stencil2_init
-!
-!&gt; \brief   Initializes ocean tracer vertical advection quantities
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine initializes a variety of quantities related to 
-!&gt;  a 2nd order stencil based vertical tracer advection in the ocean.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_stencil2_init(err)!{{{
-
-   !--------------------------------------------------------------------
-
-      !-----------------------------------------------------------------
-      !
-      ! call individual init routines for each parameterization
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      integer :: err1, err2, err3
-
-      err = 0
-      stencil2On = .false.
-
-      if(config_vert_tracer_adv_order.eq.2) then
-          stencil2On = .true.
-      endif
-
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_stencil2_init!}}}
-
-!***********************************************************************
-
-end module ocn_tracer_vadv_stencil2
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-! vim: foldmethod=marker

Deleted: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_stencil3.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_stencil3.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_stencil3.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,230 +0,0 @@
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-!
-!  ocn_tracer_vadv_stencil3
-!
-!&gt; \brief MPAS ocean vertical tracer advection driver
-!&gt; \author Doug Jacobsen
-!&gt; \date   16 September 2011
-!&gt; \version SVN:$Id:$
-!&gt; \details
-!&gt;  This module contains the main driver routine for computing 
-!&gt;  vertical advection tendencies.  
-!
-!-----------------------------------------------------------------------
-
-module ocn_tracer_vadv_stencil3
-
-   use mpas_grid_types
-   use mpas_configure
-
-   implicit none
-   private
-   save
-
-   !--------------------------------------------------------------------
-   !
-   ! Public parameters
-   !
-   !--------------------------------------------------------------------
-
-   !--------------------------------------------------------------------
-   !
-   ! Public member functions
-   !
-   !--------------------------------------------------------------------
-
-   public :: ocn_tracer_vadv_stencil3_tend, &amp;
-             ocn_tracer_vadv_stencil3_init
-
-   !--------------------------------------------------------------------
-   !
-   ! Private module variables
-   !
-   !--------------------------------------------------------------------
-
-   logical :: stencil3On
-
-
-!***********************************************************************
-
-contains
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_stencil3_tend
-!
-!&gt; \brief   Computes tendency term for vertical tracer advection 3rd order stencil
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the vertical advection tendency for tracer
-!&gt;  based on current state using a 3rd order stencil.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_stencil3_tend(grid, h, wTop, tracers, tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h, &amp;    !&lt; Input: layer thickness
-         wTop    !&lt; Input: vertical tracer in top layer
-
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: &amp;
-         tracers     !&lt; Input: tracers
-
-      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: tracer tendency
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: nCellsSolve, iCell, k, iTracer, num_tracers, nVertLevels
-      integer :: nCells
-
-      integer, dimension(:), pointer :: maxLevelCell
-
-      real (kind=RKIND) :: cSignWTop, flux3Coef
-      real (kind=RKIND), dimension(:,:,:), allocatable :: tracerTop
-
-
-      !-----------------------------------------------------------------
-      !
-      ! 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.stencil3On) return
-
-      nCells = grid % nCells
-      nCellsSolve = grid % nCellsSolve
-      num_tracers = size(tracers, 1)
-      nVertLevels = grid % nVertLevels
-      maxLevelCell =&gt; grid % maxLevelCell % array
-
-      allocate(tracerTop(num_tracers,nVertLevels+1,nCells))
-
-      ! Compute tracerTop using 3rd order stencil.  This is the same
-      ! as 4th order, but includes upwinding.
-
-      ! Hardwire flux3Coeff at 1.0 for now.  Could add this to the 
-      ! namelist, if desired.
-      flux3Coef = 1.0
-      do iCell=1,nCellsSolve 
-         tracerTop(:,1,iCell) = tracers(:,1,iCell)
-         k=2
-         do iTracer=1,num_tracers
-            tracerTop(iTracer,k,iCell) = &amp;
-               (  h(k,iCell)*tracers(iTracer,k-1,iCell) &amp;
-                + h(k-1,iCell)*tracers(iTracer,k  ,iCell) ) &amp;
-               / (h(k-1,iCell) + h(k,iCell))   
-         end do
-         do k=3,maxLevelCell(iCell)-1
-            cSignWTop = sign(flux3Coef,wTop(k,iCell))
-            do iTracer=1,num_tracers
-               tracerTop(iTracer,k,iCell) = &amp;
-                  ( (-1.+   cSignWTop)*tracers(iTracer,k-2,iCell) &amp;
-                   +( 7.-3.*cSignWTop)*tracers(iTracer,k-1,iCell) &amp;
-                   +( 7.+3.*cSignWTop)*tracers(iTracer,k  ,iCell) &amp;
-                   +(-1.-   cSignWTop)*tracers(iTracer,k+1,iCell) &amp;
-                  )/12.
-            end do
-         end do
-         k=maxLevelCell(iCell)
-            do iTracer=1,num_tracers
-            tracerTop(iTracer,k,iCell) = &amp;
-               (  h(k,iCell)*tracers(iTracer,k-1,iCell) &amp;
-                + h(k-1,iCell)*tracers(iTracer,k  ,iCell) ) &amp;
-               / (h(k-1,iCell) + h(k,iCell))   
-            end do
-        tracerTop(:,maxLevelCell(iCell)+1,iCell) = tracers(:,maxLevelCell(iCell),iCell)
-      end do
-
-      do iCell=1,nCellsSolve 
-         do k=1,maxLevelCell(iCell)  
-            do iTracer=1,num_tracers
-               tend(iTracer,k,iCell) = tend(iTracer,k,iCell) &amp;
-                  - (   wTop(k  ,iCell)*tracerTop(iTracer,k  ,iCell) &amp;
-                      - wTop(k+1,iCell)*tracerTop(iTracer,k+1,iCell))
-            end do
-         end do
-      end do
-
-      deallocate(tracerTop)
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_stencil3_tend!}}}
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_stencil3_init
-!
-!&gt; \brief   Initializes ocean tracer vertical advection quantities
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine initializes a variety of quantities related to 
-!&gt;  3rd order stencil based vertical tracer advection in the ocean. 
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_stencil3_init(err)!{{{
-
-   !--------------------------------------------------------------------
-
-      !-----------------------------------------------------------------
-      !
-      ! call individual init routines for each parameterization
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      err = 0
-      stencil3On = .false.
-
-      if(config_vert_tracer_adv_order.eq.3) then
-          stencil3On = .true.
-      endif
-
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_stencil3_init!}}}
-
-!***********************************************************************
-
-end module ocn_tracer_vadv_stencil3
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-! vim: foldmethod=marker

Deleted: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_stencil4.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_stencil4.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_tracer_vadv_stencil4.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,225 +0,0 @@
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-!
-!  ocn_tracer_vadv_stencil4
-!
-!&gt; \brief MPAS ocean vertical tracer advection driver
-!&gt; \author Doug Jacobsen
-!&gt; \date   16 September 2011
-!&gt; \version SVN:$Id:$
-!&gt; \details
-!&gt;  This module contains the main driver routine for computing 
-!&gt;  vertical advection tendencies.  
-!
-!-----------------------------------------------------------------------
-
-module ocn_tracer_vadv_stencil4
-
-   use mpas_grid_types
-   use mpas_configure
-
-   implicit none
-   private
-   save
-
-   !--------------------------------------------------------------------
-   !
-   ! Public parameters
-   !
-   !--------------------------------------------------------------------
-
-   !--------------------------------------------------------------------
-   !
-   ! Public member functions
-   !
-   !--------------------------------------------------------------------
-
-   public :: ocn_tracer_vadv_stencil4_tend, &amp;
-             ocn_tracer_vadv_stencil4_init
-
-   !--------------------------------------------------------------------
-   !
-   ! Private module variables
-   !
-   !--------------------------------------------------------------------
-
-   logical :: stencil4On
-
-
-!***********************************************************************
-
-contains
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_stencil4_tend
-!
-!&gt; \brief   Computes tendency term for vertical tracer advection 4th order stencil
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the vertical advection tendency for tracer
-!&gt;  based on current state using a 4th order stencil.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_stencil4_tend(grid, h, wTop, tracers, tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h, &amp;    !&lt; Input: layer thickness
-         wTop    !&lt; Input: vertical tracer in top layer
-
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: &amp;
-         tracers     !&lt; Input: tracers
-
-      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: tracer tendency
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: nCellsSolve, iCell, k, iTracer, num_tracers, nVertLevels
-      integer :: nCells
-
-      integer, dimension(:), pointer :: maxLevelCell
-
-      real (kind=RKIND) :: cSingWTop, flux3Coef
-      real (kind=RKIND), dimension(:,:,:), allocatable :: tracerTop
-
-
-      !-----------------------------------------------------------------
-      !
-      ! 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.Stencil4On) return
-
-      nCells = grid % nCells
-      nCellsSolve = grid % nCellsSolve
-      num_tracers = size(tracers, 1)
-      nVertLevels = grid % nVertLevels
-      maxLevelCell =&gt; grid % maxLevelCell % array
-
-      allocate(tracerTop(num_tracers,nVertLevels+1,nCells))
-
-      ! Compute tracerTop using 4rd order stencil [-1 7 7 -1]
-
-      do iCell=1,nCellsSolve 
-         tracerTop(:,1,iCell) = tracers(:,1,iCell)
-         k=2
-            do iTracer=1,num_tracers
-               tracerTop(iTracer,k,iCell) = &amp;
-                  (  h(k  ,iCell)*tracers(iTracer,k-1,iCell) &amp;
-                   + h(k-1,iCell)*tracers(iTracer,k  ,iCell) ) &amp;
-                  / (h(k-1,iCell) + h(k,iCell))   
-            end do
-         do k=3,maxLevelCell(iCell)-1
-            do iTracer=1,num_tracers
-               tracerTop(iTracer,k,iCell) = &amp;
-                  (-   tracers(iTracer,k-2,iCell) &amp;
-                   +7.*tracers(iTracer,k-1,iCell) &amp;
-                   +7.*tracers(iTracer,k  ,iCell) &amp;
-                   -   tracers(iTracer,k+1,iCell) &amp;
-                  )/12.
-            end do
-         end do
-         k=maxLevelCell(iCell)
-            do iTracer=1,num_tracers
-               tracerTop(iTracer,k,iCell) = &amp;
-                  (  h(k  ,iCell)*tracers(iTracer,k-1,iCell) &amp;
-                   + h(k-1,iCell)*tracers(iTracer,k  ,iCell) ) &amp;
-                  / (h(k-1,iCell) + h(k,iCell))   
-            end do
-        tracerTop(:,maxLevelCell(iCell)+1,iCell) = tracers(:,maxLevelCell(iCell),iCell)
-      end do
-
-      do iCell=1,nCellsSolve 
-         do k=1,maxLevelCell(iCell)  
-            do iTracer=1,num_tracers
-               tend(iTracer,k,iCell) = tend(iTracer,k,iCell) &amp;
-                      - (   wTop(k  ,iCell)*tracerTop(iTracer,k  ,iCell) &amp;
-                      - wTop(k+1,iCell)*tracerTop(iTracer,k+1,iCell))
-            end do
-         end do
-      end do
-
-      deallocate(tracerTop)
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_stencil4_tend!}}}
-
-!***********************************************************************
-!
-!  routine ocn_tracer_vadv_stencil4_init
-!
-!&gt; \brief   Initializes ocean tracer vertical advection quantities
-!&gt; \author  Phil Jones, Doug Jacobsen
-!&gt; \date    15 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine initializes a variety of quantities related to 
-!&gt;  4th order stencil based vertical tracer advection in the ocean.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vadv_stencil4_init(err)!{{{
-
-   !--------------------------------------------------------------------
-
-      !-----------------------------------------------------------------
-      !
-      ! call individual init routines for each parameterization
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      err = 0
-      stencil4On = .false.
-
-      if(config_vert_tracer_adv_order.eq.4) then
-          stencil4On = .true.
-      endif
-
-
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vadv_stencil4_init!}}}
-
-!***********************************************************************
-
-end module ocn_tracer_vadv_stencil4
-
-!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-! vim: foldmethod=marker

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_coriolis.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_coriolis.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_coriolis.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -63,7 +63,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vel_coriolis_tend(grid, Vor_edge, h_edge, u, ke, tend, err)!{{{
+   subroutine ocn_vel_coriolis_tend(grid, Vor_edge, layerThicknessEdge, normalVelocity, kineticEnergy, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -74,11 +74,11 @@
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
          Vor_edge  !&lt; Input: Potential vorticity on edge
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge  !&lt; Input: Thickness on edge
+         layerThicknessEdge  !&lt; Input: Thickness on edge
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         u  !&lt; Input: Horizontal velocity
+         normalVelocity  !&lt; Input: Horizontal velocity
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         ke  !&lt; Input: Kinetic Energy
+         kineticEnergy  !&lt; Input: Kinetic Energy
 
       type (mesh_type), intent(in) :: &amp;
          grid          !&lt; Input: grid information
@@ -142,10 +142,10 @@
             do j = 1,nEdgesOnEdge(iEdge)
                eoe = edgesOnEdge(j,iEdge)
                workpv = 0.5 * (Vor_edge(k,iEdge) + Vor_edge(k,eoe))
-               q = q + weightsOnEdge(j,iEdge) * u(k,eoe) * workpv * h_edge(k,eoe) 
+               q = q + weightsOnEdge(j,iEdge) * normalVelocity(k,eoe) * workpv * layerThicknessEdge(k,eoe) 
             end do
 
-           tend(k,iEdge) = tend(k,iEdge) + edgeMask(k, iEdge) * (q - (   ke(k,cell2) - ke(k,cell1) ) * invLength )
+           tend(k,iEdge) = tend(k,iEdge) + edgeMask(k, iEdge) * (q - (   kineticEnergy(k,cell2) - kineticEnergy(k,cell1) ) * invLength )
 
          end do
       end do
@@ -186,7 +186,7 @@
 
       coriolisOn = .true.
 
-      if(config_disable_u_coriolis) coriolisOn = .false.
+      if(config_disable_vel_coriolis) coriolisOn = .false.
 
    !--------------------------------------------------------------------
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_forcing.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_forcing.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_forcing.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -68,7 +68,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vel_forcing_tend(grid, u, u_src, ke_edge, h_edge, tend, err)!{{{
+   subroutine ocn_vel_forcing_tend(grid, u, normalVelocityForcing, kineticEnergyEdge, layerThicknessEdge, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -80,13 +80,13 @@
          u    !&lt; Input: velocity
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         u_src     !&lt; Input: wind stress
+         normalVelocityForcing     !&lt; Input: wind stress
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         ke_edge     !&lt; Input: kinetic energy at edge
+         kineticEnergyEdge     !&lt; Input: kinetic energy at edge
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge     !&lt; Input: thickness at edge
+         layerThicknessEdge     !&lt; Input: thickness at edge
 
       type (mesh_type), intent(in) :: &amp;
          grid          !&lt; Input: grid information
@@ -124,7 +124,7 @@
       !
       !-----------------------------------------------------------------
 
-      call ocn_vel_forcing_windstress_tend(grid, u_src, h_edge, tend, err1)
+      call ocn_vel_forcing_windstress_tend(grid, normalVelocityForcing, layerThicknessEdge, tend, err1)
       call ocn_vel_forcing_rayleigh_tend(grid, u, tend, err2)
 
       err = ior(err1, err2)

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_forcing_rayleigh.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_forcing_rayleigh.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_forcing_rayleigh.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -64,7 +64,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vel_forcing_rayleigh_tend(grid, u, tend, err)!{{{
+   subroutine ocn_vel_forcing_rayleigh_tend(grid, normalVelocity, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -73,7 +73,7 @@
       !-----------------------------------------------------------------
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         u    !&lt; Input: velocity 
+         normalVelocity    !&lt; Input: velocity 
 
       type (mesh_type), intent(in) :: &amp;
          grid          !&lt; Input: grid information
@@ -122,7 +122,7 @@
       do iEdge=1,nEdgesSolve
         do k=1,maxLevelEdgeTop(iEdge)
 
-           tend(k,iEdge) = tend(k,iEdge) - rayleighDampingCoef * u(k,iEdge)
+           tend(k,iEdge) = tend(k,iEdge) - rayleighDampingCoef * normalVelocity(k,iEdge)
 
         enddo
       enddo

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_forcing_windstress.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_forcing_windstress.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_forcing_windstress.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -62,7 +62,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vel_forcing_windstress_tend(grid, u_src, h_edge, tend, err)!{{{
+   subroutine ocn_vel_forcing_windstress_tend(grid, normalVelocityForcing, layerThicknessEdge, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -71,10 +71,10 @@
       !-----------------------------------------------------------------
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         u_src    !&lt; Input: wind stress
+         normalVelocityForcing    !&lt; Input: wind stress
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge     !&lt; Input: thickness at edge
+         layerThicknessEdge     !&lt; Input: thickness at edge
 
       type (mesh_type), intent(in) :: &amp;
          grid          !&lt; Input: grid information
@@ -130,7 +130,7 @@
 
         do k = 1,min(maxLevelEdgeTop(iEdge),1)
            ! forcing in top layer only
-           tend(k,iEdge) =  tend(k,iEdge) + edgeMask(k, iEdge) * (u_src(k,iEdge) / config_rho0 / h_edge(k,iEdge))
+           tend(k,iEdge) =  tend(k,iEdge) + edgeMask(k, iEdge) * (normalVelocityForcing(k,iEdge) / config_density0 / layerThicknessEdge(k,iEdge))
         enddo
 
       enddo
@@ -168,7 +168,7 @@
 
       windStressOn = .true.
 
-      if(config_disable_u_windstress) windStressOn = .false.
+      if(config_disable_vel_windstress) windStressOn = .false.
 
       err = 0
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_hmix.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_hmix.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_hmix.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -74,7 +74,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vel_hmix_tend(grid, divergence, vorticity, viscosity, tend, err)!{{{
+   subroutine ocn_vel_hmix_tend(grid, divergence, relativeVorticity, viscosity, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -86,7 +86,7 @@
          divergence    !&lt; Input: velocity divergence
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         vorticity     !&lt; Input: vorticity
+         relativeVorticity     !&lt; Input: relative vorticity
 
       type (mesh_type), intent(in) :: &amp;
          grid          !&lt; Input: grid information
@@ -132,15 +132,15 @@
       viscosity = 0.0
 
       call mpas_timer_start(&quot;del2&quot;, .false., del2Timer)
-      call ocn_vel_hmix_del2_tend(grid, divergence, vorticity, viscosity, tend, err1)
+      call ocn_vel_hmix_del2_tend(grid, divergence, relativeVorticity, viscosity, tend, err1)
       call mpas_timer_stop(&quot;del2&quot;, del2Timer)
 
       call mpas_timer_start(&quot;leith&quot;, .false., leithTimer)
-      call ocn_vel_hmix_leith_tend(grid, divergence, vorticity, viscosity, tend, err2)
+      call ocn_vel_hmix_leith_tend(grid, divergence, relativeVorticity, viscosity, tend, err2)
       call mpas_timer_stop(&quot;leith&quot;, leithTimer)
 
       call mpas_timer_start(&quot;del4&quot;, .false., del4Timer)
-      call ocn_vel_hmix_del4_tend(grid, divergence, vorticity, tend, err3)
+      call ocn_vel_hmix_del4_tend(grid, divergence, relativeVorticity, tend, err3)
       call mpas_timer_stop(&quot;del4&quot;, del4Timer)
 
       err = ior(ior(err1, err2),err3)
@@ -187,7 +187,7 @@
 
       err = ior(ior(err1, err2),err3)
 
-      if(config_disable_u_hmix) hmixOn = .false.
+      if(config_disable_vel_hmix) hmixOn = .false.
 
    !--------------------------------------------------------------------
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_hmix_del2.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_hmix_del2.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_hmix_del2.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -64,13 +64,13 @@
 !&gt;  This routine computes the horizontal mixing tendency for momentum
 !&gt;  based on a Laplacian form for the mixing, \f$</font>
<font color="black">u_2 </font>
<font color="red">abla^2 u\f$
 !&gt;  This tendency takes the
-!&gt;  form \f$</font>
<font color="black">u( </font>
<font color="black">abla divergence + k \times </font>
<font color="blue">abla vorticity )\f$,
+!&gt;  form \f$</font>
<font color="black">u( </font>
<font color="black">abla divergence + k \times </font>
<font color="black">abla relativeVorticity )\f$,
 !&gt;  where \f$</font>
<font color="black">u\f$ is a viscosity and \f$k\f$ is the vertical unit vector.
 !&gt;  This form is strictly only valid for constant \f$</font>
<font color="gray">u\f$ .
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vel_hmix_del2_tend(grid, divergence, vorticity, viscosity, tend, err)!{{{
+   subroutine ocn_vel_hmix_del2_tend(grid, divergence, relativeVorticity, viscosity, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -82,7 +82,7 @@
          divergence      !&lt; Input: velocity divergence
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         vorticity       !&lt; Input: vorticity
+         relativeVorticity       !&lt; Input: relative vorticity
 
       type (mesh_type), intent(in) :: &amp;
          grid            !&lt; Input: grid information
@@ -151,13 +151,13 @@
 
          do k=1,maxLevelEdgeTop(iEdge)
 
-            ! Here -( vorticity(k,vertex2) - vorticity(k,vertex1) ) / dvEdge(iEdge)
-            ! is - </font>
<font color="red">abla vorticity pointing from vertex 2 to vertex 1, or equivalently 
-            !    + k \times </font>
<font color="blue">abla vorticity pointing from cell1 to cell2.
+            ! Here -( relativeVorticity(k,vertex2) - relativeVorticity(k,vertex1) ) / dvEdge(iEdge)
+            ! is - </font>
<font color="blue">abla relativeVorticity pointing from vertex 2 to vertex 1, or equivalently 
+            !    + k \times </font>
<font color="gray">abla relativeVorticity pointing from cell1 to cell2.
 
             u_diffusion = ( divergence(k,cell2)  - divergence(k,cell1) ) * invLength1 &amp;
                           -viscVortCoef &amp;
-                          *( vorticity(k,vertex2) - vorticity(k,vertex1) ) * invLength2
+                          *( relativeVorticity(k,vertex2) - relativeVorticity(k,vertex1) ) * invLength2
 
             visc2 = meshScalingDel2(iEdge) * eddyVisc2
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_hmix_del4.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_hmix_del4.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_hmix_del4.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -66,13 +66,13 @@
 !&gt;  based on a biharmonic form for the mixing.  This mixing tendency
 !&gt;  takes the form  \f$-</font>
<font color="black">u_4 </font>
<font color="red">abla^4 u\f$
 !&gt;  but is computed as 
-!&gt;  \f$</font>
<font color="black">abla^2 u = </font>
<font color="black">abla divergence + k \times </font>
<font color="blue">abla vorticity\f$
+!&gt;  \f$</font>
<font color="black">abla^2 u = </font>
<font color="black">abla divergence + k \times </font>
<font color="black">abla relativeVorticity\f$
 !&gt;  applied recursively.
 !&gt;  This formulation is only valid for constant \f$</font>
<font color="gray">u_4\f$ .
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vel_hmix_del4_tend(grid, divergence, vorticity, tend, err)!{{{
+   subroutine ocn_vel_hmix_del4_tend(grid, divergence, relativeVorticity, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -84,7 +84,7 @@
          divergence      !&lt; Input: velocity divergence
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         vorticity       !&lt; Input: vorticity
+         relativeVorticity       !&lt; Input: relative vorticity
 
       type (mesh_type), intent(in) :: &amp;
          grid           !&lt; Input: grid information
@@ -127,7 +127,7 @@
             meshScalingDel4, areaCell
 
       real (kind=RKIND), dimension(:,:), allocatable :: delsq_divergence, &amp;
-            delsq_circulation, delsq_vorticity, delsq_u
+            delsq_circulation, delsq_relativeVorticity, delsq_u
 
       err = 0
 
@@ -159,10 +159,10 @@
 
       allocate(delsq_u(nVertLEvels, nEdges+1))
       allocate(delsq_divergence(nVertLevels, nCells+1))
-      allocate(delsq_vorticity(nVertLevels, nVertices+1))
+      allocate(delsq_relativeVorticity(nVertLevels, nVertices+1))
 
       delsq_u(:,:) = 0.0
-      delsq_vorticity(:,:) = 0.0
+      delsq_relativeVorticity(:,:) = 0.0
       delsq_divergence(:,:) = 0.0
 
       !Compute delsq_u
@@ -177,19 +177,19 @@
          invDvEdge = 1.0 / dvEdge(iEdge)
 
          do k=1,maxLevelEdgeTop(iEdge)
-            ! Compute </font>
<font color="black">abla^2 u = </font>
<font color="black">abla divergence + k \times </font>
<font color="blue">abla vorticity
+            ! Compute </font>
<font color="black">abla^2 u = </font>
<font color="black">abla divergence + k \times </font>
<font color="gray">abla relativeVorticity
             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 *( relativeVorticity(k,vertex2) - relativeVorticity(k,vertex1)) * invDcEdge * sqrt(3.0)   
          end do
       end do
 
-      ! Compute delsq_vorticity
+      ! Compute delsq_relativeVorticity
       do iVertex = 1, nVertices
          invAreaTri1 = 1.0 / areaTriangle(iVertex)
          do i = 1, vertexDegree
             iEdge = edgesOnVertex(i, iVertex)
             do k = 1, maxLevelVertexTop(iVertex)
-               delsq_vorticity(k, iVertex) = delsq_vorticity(k, iVertex) + edgeSignOnVertex(i, iVertex) * dcEdge(iEdge) * delsq_u(k, iEdge) * invAreaTri1
+               delsq_relativeVorticity(k, iVertex) = delsq_relativeVorticity(k, iVertex) + edgeSignOnVertex(i, iVertex) * dcEdge(iEdge) * delsq_u(k, iEdge) * invAreaTri1
             end do
          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_relativeVorticity(k,vertex2) - delsq_relativeVorticity(k,vertex1) ) * invDcEdge * sqrt(3.0) 
 
             tend(k,iEdge) = tend(k,iEdge) - edgeMask(k, iEdge) * u_diffusion * r_tmp
          end do
@@ -227,7 +227,7 @@
 
       deallocate(delsq_u)
       deallocate(delsq_divergence)
-      deallocate(delsq_vorticity)
+      deallocate(delsq_relativeVorticity)
 
    !--------------------------------------------------------------------
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_hmix_leith.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_hmix_leith.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_hmix_leith.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -76,7 +76,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vel_hmix_leith_tend(grid, divergence, vorticity, viscosity, tend, err)!{{{
+   subroutine ocn_vel_hmix_leith_tend(grid, divergence, relativeVorticity, viscosity, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -88,7 +88,7 @@
          divergence      !&lt; Input: velocity divergence
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         vorticity       !&lt; Input: vorticity
+         relativeVorticity       !&lt; Input: relative vorticity
 
       type (mesh_type), intent(in) :: &amp;
          grid            !&lt; Input: grid information
@@ -157,19 +157,19 @@
 
          do k=1,maxLevelEdgeTop(iEdge)
 
-            ! Here -( vorticity(k,vertex2) - vorticity(k,vertex1) ) / dvEdge(iEdge)
-            ! is - </font>
<font color="red">abla vorticity pointing from vertex 2 to vertex 1, or equivalently 
-            !    + k \times </font>
<font color="blue">abla vorticity pointing from cell1 to cell2.
+            ! Here -( relativeVorticity(k,vertex2) - relativeVorticity(k,vertex1) ) / dvEdge(iEdge)
+            ! is - </font>
<font color="blue">abla relativeVorticity pointing from vertex 2 to vertex 1, or equivalently 
+            !    + k \times </font>
<font color="red">abla relativeVorticity pointing from cell1 to cell2.
 
             u_diffusion = ( divergence(k,cell2)  - divergence(k,cell1) ) * invLength1 &amp;
                           -viscVortCoef &amp;
-                          *( vorticity(k,vertex2) - vorticity(k,vertex1) ) * invLength2
+                          *( relativeVorticity(k,vertex2) - relativeVorticity(k,vertex1) ) * invLength2
 
             ! Here the first line is (\delta x)^3
             ! the second line is |</font>
<font color="black">abla \omega|
             ! and u_diffusion is </font>
<font color="gray">abla^2 u (see formula for $\bf{D}$ above).
             visc2 = ( config_leith_parameter * config_leith_dx * meshScaling(iEdge) / 3.14)**3 &amp;
-                     * abs( vorticity(k,vertex2) - vorticity(k,vertex1) ) * invLength1 * sqrt(3.0)
+                     * abs( relativeVorticity(k,vertex2) - relativeVorticity(k,vertex1) ) * invLength1 * sqrt(3.0)
             visc2 = min(visc2, config_leith_visc2_max)
 
             tend(k,iEdge) = tend(k,iEdge) + edgeMask(k, iEdge) * visc2 * u_diffusion

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_pressure_grad.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_pressure_grad.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_pressure_grad.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -45,7 +45,7 @@
    !--------------------------------------------------------------------
 
    logical :: pgradOn
-   real (kind=RKIND) :: rho0Inv, grho0Inv
+   real (kind=RKIND) :: density0Inv, gdensity0Inv
 
 
 !***********************************************************************
@@ -66,7 +66,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vel_pressure_grad_tend(grid, pressure, zMid, rho, tend, err)!{{{
+   subroutine ocn_vel_pressure_grad_tend(grid, pressure, zMid, density, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -77,7 +77,7 @@
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
          pressure, &amp; !&lt; Input: Pressure field or Mongomery potential
          zMid, &amp;     !&lt; Input: z-coordinate at mid-depth of layer
-         rho         !&lt; Input: density
+         density         !&lt; Input: density
 
       type (mesh_type), intent(in) :: &amp;
          grid          !&lt; Input: grid information
@@ -123,12 +123,12 @@
       edgeMask =&gt; grid % edgeMask % array
 
       ! pressure for generalized coordinates
-      ! -1/rho_0 (grad p_k + rho g grad z_k^{mid})
+      ! -1/density_0 (grad p_k + density g grad z_k^{mid})
 
       ! For pure isopycnal coordinates, we are still using 
       ! grad(M), the gradient of Montgomery Potential, because
-      ! we have set rho0Inv=1 and grho0Inv=0 in the init routine,
-      ! and pressure is passed in as MontPot.
+      ! we have set density0Inv=1 and gdensity0Inv=0 in the init routine,
+      ! and pressure is passed in as montgomeryPotential.
 
       do iEdge=1,nEdgesSolve
          cell1 = cellsOnEdge(1,iEdge)
@@ -137,9 +137,9 @@
 
          do k=1,maxLevelEdgeTop(iEdge)
             tend(k,iEdge) = tend(k,iEdge)     &amp;
-              - edgeMask(k,iEdge) * rho0Inv*(  pressure(k,cell2) &amp;
+              - edgeMask(k,iEdge) * density0Inv*(  pressure(k,cell2) &amp;
                          - pressure(k,cell1) )* invdcEdge &amp;
-              - edgeMask(k,iEdge) * grho0Inv*  0.5*(rho(k,cell1)+rho(k,cell2)) &amp;
+              - edgeMask(k,iEdge) * gdensity0Inv*  0.5*(density(k,cell1)+density(k,cell2)) &amp;
                         *(  zMid(k,cell2) &amp;
                           - zMid(k,cell1) )* invdcEdge
                       
@@ -192,14 +192,14 @@
       pgradOn = .true.
 
       if (config_pressure_gradient_type.eq.'MontgomeryPotential') then
-        rho0Inv = 1.0
-        grho0Inv = 0.0
+        density0Inv = 1.0
+        gdensity0Inv = 0.0
       else 
-        rho0Inv = 1.0/config_rho0
-        grho0Inv = gravity/config_rho0
+        density0Inv = 1.0/config_density0
+        gdensity0Inv = gravity/config_density0
       end if
 
-      if(config_disable_u_pgrad) pgradOn = .false.
+      if(config_disable_vel_pgrad) pgradOn = .false.
 
 
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_vadv.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_vadv.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vel_vadv.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -64,7 +64,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vel_vadv_tend(grid, u, h_edge, wTop, tend, err)!{{{
+   subroutine ocn_vel_vadv_tend(grid, u, layerThicknessEdge, vertTransportVelocityTop, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -75,8 +75,8 @@
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
          u     !&lt; Input: Horizontal velocity
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge,&amp;!&lt; Input: thickness at edge
-         wTop  !&lt; Input: Vertical velocity on top layer
+         layerThicknessEdge,&amp;!&lt; Input: thickness at edge
+         vertTransportVelocityTop  !&lt; Input: Vertical velocity on top layer
 
       type (mesh_type), intent(in) :: &amp;
          grid          !&lt; Input: grid information
@@ -109,14 +109,9 @@
       integer, dimension(:), pointer :: maxLevelEdgeTop
       integer, dimension(:,:), pointer :: cellsOnEdge, edgeMask
 
-      real (kind=RKIND) :: wTopEdge
+      real (kind=RKIND) :: vertTransportVelocityTopEdge
       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
@@ -135,11 +130,11 @@
 
         do k=2,maxLevelEdgeTop(iEdge)
           ! Average w from cell center to edge
-          wTopEdge = 0.5*(wTop(k,cell1)+wTop(k,cell2))
+          vertTransportVelocityTopEdge = 0.5*(vertTransportVelocityTop(k,cell1)+vertTransportVelocityTop(k,cell2))
 
           ! compute dudz at vertical interface with first order derivative.
-          w_dudzTopEdge(k) = wTopEdge * (u(k-1,iEdge)-u(k,iEdge)) &amp;
-                       / (0.5*(h_edge(k-1,iEdge) + h_edge(k,iEdge)))
+          w_dudzTopEdge(k) = vertTransportVelocityTopEdge * (u(k-1,iEdge)-u(k,iEdge)) &amp;
+                       / (0.5*(layerThicknessEdge(k-1,iEdge) + layerThicknessEdge(k,iEdge)))
         end do
         w_dudzTopEdge(maxLevelEdgeTop(iEdge)+1) = 0.0
         ! Average w*du/dz from vertical interface to vertical middle of cell
@@ -187,7 +182,7 @@
           velVadvOn = .true.
       end if
 
-      if(config_disable_u_vadv) velVadvOn = .false.
+      if(config_disable_vel_vadv) velVadvOn = .false.
 
    !--------------------------------------------------------------------
 

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vmix.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vmix.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vmix.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -149,7 +149,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vel_vmix_tend_implicit(grid, dt, ke_edge, vertViscTopOfEdge, h, h_edge, u, err)!{{{
+   subroutine ocn_vel_vmix_tend_implicit(grid, dt, kineticEnergyEdge, vertViscTopOfEdge, layerThickness, layerThicknessEdge, normalVelocity, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -161,7 +161,7 @@
          grid          !&lt; Input: grid information
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         ke_edge        !&lt; Input: kinetic energy at edge
+         kineticEnergyEdge        !&lt; Input: kinetic energy at edge
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
          vertViscTopOfEdge !&lt; Input: vertical mixing coefficients
@@ -170,7 +170,7 @@
          dt            !&lt; Input: time step
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h             !&lt; Input: thickness at cell center
+         layerThickness !&lt; Input: thickness at cell center
 
       !-----------------------------------------------------------------
       !
@@ -179,10 +179,10 @@
       !-----------------------------------------------------------------
 
       real (kind=RKIND), dimension(:,:), intent(inout) :: &amp;
-         u             !&lt; Input: velocity
+         normalVelocity             !&lt; Input: velocity
 
       real (kind=RKIND), dimension(:,:), intent(inout) :: &amp;
-         h_edge        !&lt; Input: thickness at edge
+         layerThicknessEdge        !&lt; Input: thickness at edge
 
       !-----------------------------------------------------------------
       !
@@ -204,7 +204,7 @@
 
       integer, dimension(:,:), pointer :: cellsOnEdge
 
-      real (kind=RKIND), dimension(:), allocatable :: A, B, C, uTemp
+      real (kind=RKIND), dimension(:), allocatable :: A, B, C, velTemp
 
       err = 0
 
@@ -215,7 +215,7 @@
       maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
       cellsOnEdge =&gt; grid % cellsOnEdge % array
 
-      allocate(A(nVertLevels),B(nVertLevels),C(nVertLevels),uTemp(nVertLevels)) 
+      allocate(A(nVertLevels),B(nVertLevels),C(nVertLevels),velTemp(nVertLevels)) 
       A(1)=0
 
       do iEdge=1,nEdges
@@ -223,26 +223,26 @@
         if (N.gt.0) then
 
          ! Compute A(k), B(k), C(k)
-         ! h_edge is computed in compute_solve_diag, and is not available yet,
-         ! so recompute h_edge here.
+         ! layerThicknessEdge is computed in compute_solve_diag, and is not available yet,
+         ! so recompute layerThicknessEdge here.
          cell1 = cellsOnEdge(1,iEdge)
          cell2 = cellsOnEdge(2,iEdge)
          do k=1,N
-            h_edge(k,iEdge) = 0.5 * (h(k,cell1) + h(k,cell2))
+            layerThicknessEdge(k,iEdge) = 0.5 * (layerThickness(k,cell1) + layerThickness(k,cell2))
          end do
 
          ! A is lower diagonal term
          do k=2,N
             A(k) = -2.0*dt*vertViscTopOfEdge(k,iEdge) &amp;
-               / (h_edge(k-1,iEdge) + h_edge(k,iEdge)) &amp;
-               / h_edge(k,iEdge)
+               / (layerThicknessEdge(k-1,iEdge) + layerThicknessEdge(k,iEdge)) &amp;
+               / layerThicknessEdge(k,iEdge)
          enddo
 
          ! C is upper diagonal term
          do k=1,N-1
             C(k) = -2.0*dt*vertViscTopOfEdge(k+1,iEdge) &amp;
-               / (h_edge(k,iEdge) + h_edge(k+1,iEdge)) &amp;
-               / h_edge(k,iEdge)
+               / (layerThicknessEdge(k,iEdge) + layerThicknessEdge(k+1,iEdge)) &amp;
+               / layerThicknessEdge(k,iEdge)
          enddo
 
          ! B is diagonal term
@@ -253,17 +253,17 @@
 
          ! Apply bottom drag boundary condition on the viscous term
          B(N) = 1 - A(N) + dt*config_bottom_drag_coeff  &amp;
-            *sqrt(2.0*ke_edge(k,iEdge))/h_edge(k,iEdge)
+            *sqrt(2.0*kineticEnergyEdge(k,iEdge))/layerThicknessEdge(k,iEdge)
 
-         call tridiagonal_solve(A(2:N),B,C(1:N-1),u(:,iEdge),uTemp,N)
+         call tridiagonal_solve(A(2:N),B,C(1:N-1),normalVelocity(:,iEdge),velTemp,N)
 
-         u(1:N,iEdge) = uTemp(1:N)
-         u(N+1:nVertLevels,iEdge) = 0.0
+         normalVelocity(1:N,iEdge) = velTemp(1:N)
+         normalVelocity(N+1:nVertLevels,iEdge) = 0.0
 
         end if
       end do
 
-      deallocate(A,B,C,uTemp)
+      deallocate(A,B,C,velTemp)
 
    !--------------------------------------------------------------------
 
@@ -283,7 +283,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_tracer_vmix_tend_implicit(grid, dt, vertDiffTopOfCell, h, tracers, err)!{{{
+   subroutine ocn_tracer_vmix_tend_implicit(grid, dt, vertDiffTopOfCell, layerThickness, tracers, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -301,7 +301,7 @@
          dt            !&lt; Input: time step
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h             !&lt; Input: thickness at cell center
+         layerThickness             !&lt; Input: thickness at cell center
 
       !-----------------------------------------------------------------
       !
@@ -352,13 +352,13 @@
          A(1)=0
          do k=2,N
             A(k) = -2.0*dt*vertDiffTopOfCell(k,iCell) &amp;
-                 / (h(k-1,iCell) + h(k,iCell)) / h(k,iCell)
+                 / (layerThickness(k-1,iCell) + layerThickness(k,iCell)) / layerThickness(k,iCell)
          enddo
 
          ! C is upper diagonal term
          do k=1,N-1
             C(k) = -2.0*dt*vertDiffTopOfCell(k+1,iCell) &amp;
-                 / (h(k,iCell) + h(k+1,iCell)) / h(k,iCell)
+                 / (layerThickness(k,iCell) + layerThickness(k+1,iCell)) / layerThickness(k,iCell)
          enddo
          C(N) = 0.0
 
@@ -403,17 +403,17 @@
       integer, intent(out) :: err
 
       integer :: nCells
-      real (kind=RKIND), dimension(:,:), pointer :: u, h, h_edge, vertViscTopOfEdge, vertDiffTopOfCell, ke_edge
+      real (kind=RKIND), dimension(:,:), pointer :: normalVelocity, layerThickness, layerThicknessEdge, vertViscTopOfEdge, vertDiffTopOfCell, kineticEnergyEdge
       real (kind=RKIND), dimension(:,:,:), pointer :: tracers
       integer, dimension(:), pointer :: maxLevelCell
 
       err = 0
 
-      u           =&gt; state % u % array
+      normalVelocity =&gt; state % normalVelocity % array
       tracers     =&gt; state % tracers % array
-      h           =&gt; state % h % array
-      h_edge      =&gt; state % h_edge % array
-      ke_edge     =&gt; state % ke_edge % array
+      layerThickness  =&gt; state % layerThickness % array
+      layerThicknessEdge      =&gt; state % layerThicknessEdge % array
+      kineticEnergyEdge     =&gt; state % kineticEnergyEdge % array
       vertViscTopOfEdge =&gt; diagnostics % vertViscTopOfEdge % array
       vertDiffTopOfCell =&gt; diagnostics % vertDiffTopOfCell % array
       maxLevelCell    =&gt; grid % maxLevelCell % array
@@ -425,13 +425,13 @@
       !
       !  Implicit vertical solve for momentum
       !
-      call ocn_vel_vmix_tend_implicit(grid, dt, ke_edge, vertViscTopOfEdge, h, h_edge, u, err)
+      call ocn_vel_vmix_tend_implicit(grid, dt, kineticEnergyEdge, vertViscTopOfEdge, layerThickness, layerThicknessEdge, normalVelocity, err)
 
       !
       !  Implicit vertical solve for tracers
       !
 
-      call ocn_tracer_vmix_tend_implicit(grid, dt, vertDiffTopOfCell, h, tracers, err)
+      call ocn_tracer_vmix_tend_implicit(grid, dt, vertDiffTopOfCell, layerThickness, tracers, err)
 
    end subroutine ocn_vmix_implicit!}}}
 
@@ -469,7 +469,7 @@
       velVmixOn = .true.
       tracerVmixOn = .true.
 
-      if(config_disable_u_vmix) velVmixOn = .false.
+      if(config_disable_vel_vmix) velVmixOn = .false.
       if(config_disable_tr_vmix) tracerVmixOn = .false.
 
       call ocn_vmix_coefs_const_init(err1)

Modified: branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vmix_coefs_rich.F
===================================================================
--- branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vmix_coefs_rich.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_ocean/mpas_ocn_vmix_coefs_rich.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -109,7 +109,7 @@
       integer :: err1, err2, err3, indexT, indexS
 
       real (kind=RKIND), dimension(:,:), pointer :: &amp;
-        vertViscTopOfEdge, vertDiffTopOfCell, u, h, h_edge, rho, rhoDisplaced
+        vertViscTopOfEdge, vertDiffTopOfCell, normalVelocity, layerThickness, layerThicknessEdge, density, displacedDensity
 
       real (kind=RKIND), dimension(:,:), pointer :: RiTopOfEdge, RiTopOfCell
 
@@ -133,23 +133,23 @@
       RiTopOfEdge =&gt; d % RiTopOfEdge % array
       RiTopOfCell =&gt; d % RiTopOfCell % array
 
-      u =&gt; s % u % array
-      h =&gt; s % h % array
-      h_edge =&gt; s % h_edge % array
-      rho =&gt; s % rho % array
-      rhoDisplaced =&gt; s % rhoDisplaced % array
+      normalVelocity =&gt; s % normalVelocity % array
+      layerThickness =&gt; s % layerThickness % array
+      layerThicknessEdge =&gt; s % layerThicknessEdge % array
+      density =&gt; s % density % array
+      displacedDensity =&gt; s % displacedDensity % array
       tracers =&gt; s % tracers % array
 
       call mpas_timer_start(&quot;eos rich&quot;, .false., richEOSTimer)
-      call ocn_equation_of_state_rho(s, grid, 0,'relative', err)
-      call ocn_equation_of_state_rho(s, grid, 1,'relative', err)
+      call ocn_equation_of_state_density(s, grid, 0,'relative', err)
+      call ocn_equation_of_state_density(s, grid, 1,'relative', err)
       call mpas_timer_stop(&quot;eos rich&quot;, richEOSTimer)
 
-      call ocn_vmix_get_rich_numbers(grid, indexT, indexS, u, h, h_edge, &amp; 
-                                  rho, rhoDisplaced, tracers, RiTopOfEdge, RiTopOfCell, err1)
+      call ocn_vmix_get_rich_numbers(grid, indexT, indexS, normalVelocity, layerThickness, layerThicknessEdge, &amp; 
+                                  density, displacedDensity, tracers, RiTopOfEdge, RiTopOfCell, err1)
 
-      call ocn_vel_vmix_coefs_rich(grid, RiTopOfEdge, h_edge, vertViscTopOfEdge, err2)
-      call ocn_tracer_vmix_coefs_rich(grid, RiTopOfCell, h, vertDiffTopOfCell, err3)
+      call ocn_vel_vmix_coefs_rich(grid, RiTopOfEdge, layerThicknessEdge, vertViscTopOfEdge, err2)
+      call ocn_tracer_vmix_coefs_rich(grid, RiTopOfCell, layerThickness, vertDiffTopOfCell, err3)
 
       err = ior(err1, ior(err2, err3))
 
@@ -170,7 +170,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vel_vmix_coefs_rich(grid, RiTopOfEdge, h_edge, vertViscTopOfEdge, err)!{{{
+   subroutine ocn_vel_vmix_coefs_rich(grid, RiTopOfEdge, layerThicknessEdge, vertViscTopOfEdge, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -182,7 +182,7 @@
          grid          !&lt; Input: grid information
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge        !&lt; Input: thickness at edge
+         layerThicknessEdge        !&lt; Input: thickness at edge
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
          RiTopOfEdge   !&lt; Richardson number at top of edge
@@ -223,13 +223,11 @@
 
       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) = 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
                   vertViscTopOfEdge(k,iEdge) = config_convective_visc
                end if
@@ -258,7 +256,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_tracer_vmix_coefs_rich(grid, RiTopOfCell, h, vertDiffTopOfCell, err)!{{{
+   subroutine ocn_tracer_vmix_coefs_rich(grid, RiTopOfCell, layerThickness, vertDiffTopOfCell, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -270,7 +268,7 @@
          grid          !&lt; Input: grid information
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h             !&lt; Input: thickness at cell center
+         layerThickness             !&lt; Input: thickness at cell center
 
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
          RiTopOfCell   !&lt; Input: Richardson number at top of cell
@@ -311,18 +309,16 @@
 
       maxLevelCell =&gt; grid % maxLevelCell % array
 
-      coef = -gravity/config_rho0/2.0
+      coef = -gravity/config_density0/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) = 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
                   vertDiffTopOfCell(k,iCell) = config_convective_diff
                end if
@@ -352,8 +348,8 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vmix_get_rich_numbers(grid, indexT, indexS, u, h, h_edge, &amp; !{{{
-                                 rho, rhoDisplaced, tracers, RiTopOfEdge, RiTopOfCell, err)
+   subroutine ocn_vmix_get_rich_numbers(grid, indexT, indexS, normalVelocity, layerThickness, layerThicknessEdge, &amp; !{{{
+                                 density, displacedDensity, tracers, RiTopOfEdge, RiTopOfCell, err)
 
       !-----------------------------------------------------------------
       !
@@ -367,9 +363,9 @@
       integer, intent(in) :: indexT !&lt; Input: index for temperature
       integer, intent(in) :: indexS !&lt; Input: index for salinity
 
-      real (kind=RKIND), dimension(:,:), intent(in) :: u       !&lt; Input: horizontal velocity
-      real (kind=RKIND), dimension(:,:), intent(in) :: h       !&lt; Input: thickness
-      real (kind=RKIND), dimension(:,:), intent(in) :: h_edge  !&lt; Input: thickness at edge 
+      real (kind=RKIND), dimension(:,:), intent(in) :: normalVelocity       !&lt; Input: horizontal velocity
+      real (kind=RKIND), dimension(:,:), intent(in) :: layerThickness       !&lt; Input: thickness
+      real (kind=RKIND), dimension(:,:), intent(in) :: layerThicknessEdge  !&lt; Input: thickness at edge 
 
       real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers !&lt; Input: tracers
 
@@ -385,8 +381,8 @@
       !
       !-----------------------------------------------------------------
 
-      real (kind=RKIND), dimension(:,:), intent(inout) :: rho    !&lt; Input/output: density
-      real (kind=RKIND), dimension(:,:), intent(inout) :: rhoDisplaced    !&lt; Input/output: displaced density
+      real (kind=RKIND), dimension(:,:), intent(inout) :: density    !&lt; Input/output: density
+      real (kind=RKIND), dimension(:,:), intent(inout) :: displacedDensity    !&lt; Input/output: displaced density
       real (kind=RKIND), dimension(:,:), intent(inout) :: RiTopOfEdge     !&lt; Input/output: Richardson number top of cell
       real (kind=RKIND), dimension(:,:), intent(inout) :: RiTopOfCell     !&lt; Input/output: Richardson number top of cell
 
@@ -406,8 +402,8 @@
 
       real (kind=RKIND) :: coef, invAreaCell
       real (kind=RKIND), dimension(:), pointer :: dcEdge, dvEdge, areaCell
-      real (kind=RKIND), dimension(:,:), allocatable :: drhoTopOfCell, du2TopOfCell, &amp;
-                                                        drhoTopOfEdge, du2TopOfEdge
+      real (kind=RKIND), dimension(:,:), allocatable :: ddensityTopOfCell, du2TopOfCell, &amp;
+                                                        ddensityTopOfEdge, du2TopOfEdge
 
       err = 0
 
@@ -429,36 +425,26 @@
       edgeSignOnCell =&gt; grid % edgeSignOnCell % array
 
       allocate( &amp;
-         drhoTopOfCell(nVertLevels+1,nCells+1), drhoTopOfEdge(nVertLevels+1,nEdges), &amp;
+         ddensityTopOfCell(nVertLevels+1,nCells+1), ddensityTopOfEdge(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
+      ! ddensityTopOfCell(k) = $\density^*_{k-1}-\density^*_k$
+      ddensityTopOfCell = 0.0
       do iCell=1,nCells
          do k=2,maxLevelCell(iCell)
-            drhoTopOfCell(k,iCell) = rhoDisplaced(k-1,iCell) - rhoDisplaced(k,iCell)
+            ddensityTopOfCell(k,iCell) = displacedDensity(k-1,iCell) - displacedDensity(k,iCell)
           end do
       end do
 
-      ! interpolate drhoTopOfCell to drhoTopOfEdge
-      drhoTopOfEdge = 0.0
+      ! interpolate ddensityTopOfCell to ddensityTopOfEdge
+      ddensityTopOfEdge = 0.0
       do iEdge=1,nEdges
          cell1 = cellsOnEdge(1,iEdge)
          cell2 = cellsOnEdge(2,iEdge)
          do k=2,maxLevelEdgeTop(iEdge)
-            drhoTopOfEdge(k,iEdge) = &amp;
-               (drhoTopOfCell(k,cell1) + &amp;
-                drhoTopOfCell(k,cell2))/2  
+            ddensityTopOfEdge(k,iEdge) = &amp;
+               (ddensityTopOfCell(k,cell1) + &amp;
+                ddensityTopOfCell(k,cell2))/2  
          end do
        end do
 
@@ -466,7 +452,7 @@
       du2TopOfEdge=0.0
       do iEdge=1,nEdges
          do k=2,maxLevelEdgeTop(iEdge)
-            du2TopOfEdge(k,iEdge) = (u(k-1,iEdge) - u(k,iEdge))**2
+            du2TopOfEdge(k,iEdge) = (normalVelocity(k-1,iEdge) - normalVelocity(k,iEdge))**2
          end do
       end do
 
@@ -483,30 +469,30 @@
         end do
       end do
 
-      ! compute RiTopOfEdge using drhoTopOfEdge and du2TopOfEdge
-      ! coef = -g/rho_0/2
+      ! compute RiTopOfEdge using ddensityTopOfEdge and du2TopOfEdge
+      ! coef = -g/density_0/2
       RiTopOfEdge = 0.0
-      coef = -gravity/config_rho0/2.0
+      coef = -gravity/config_density0/2.0
       do iEdge = 1,nEdges
          do k = 2,maxLevelEdgeTop(iEdge)
-            RiTopOfEdge(k,iEdge) = coef*drhoTopOfEdge(k,iEdge) &amp;
-               *(h_edge(k-1,iEdge)+h_edge(k,iEdge)) &amp;
+            RiTopOfEdge(k,iEdge) = coef*ddensityTopOfEdge(k,iEdge) &amp;
+               *(layerThicknessEdge(k-1,iEdge)+layerThicknessEdge(k,iEdge)) &amp;
                / (du2TopOfEdge(k,iEdge) + 1e-20)
          end do
       end do
 
-      ! compute RiTopOfCell using drhoTopOfCell and du2TopOfCell
-      ! coef = -g/rho_0/2
+      ! compute RiTopOfCell using ddensityTopOfCell and du2TopOfCell
+      ! coef = -g/density_0/2
       RiTopOfCell = 0.0
       do iCell = 1,nCells
          do k = 2,maxLevelCell(iCell)
-            RiTopOfCell(k,iCell) = coef*drhoTopOfCell(k,iCell) &amp;
-               *(h(k-1,iCell)+h(k,iCell)) &amp;
+            RiTopOfCell(k,iCell) = coef*ddensityTopOfCell(k,iCell) &amp;
+               *(layerThickness(k-1,iCell)+layerThickness(k,iCell)) &amp;
                / (du2TopOfCell(k,iCell) + 1e-20)
          end do
       end do
 
-      deallocate(drhoTopOfCell, drhoTopOfEdge, &amp;
+      deallocate(ddensityTopOfCell, ddensityTopOfEdge, &amp;
         du2TopOfCell, du2TopOfEdge)
 
    !--------------------------------------------------------------------

Deleted: branches/mpas_cdg_advection/src/core_sw/Registry
===================================================================
--- branches/mpas_cdg_advection/src/core_sw/Registry        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/core_sw/Registry        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,165 +0,0 @@
-%
-% namelist  type  namelist_record  name  default_value
-%
-namelist integer     sw_model  config_test_case             5
-namelist character   sw_model  config_time_integration      RK4
-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_h_ScaleWithMesh       false
-namelist real        sw_model  config_h_mom_eddy_visc2      0.0
-namelist real        sw_model  config_h_mom_eddy_visc4      0.0
-namelist real        sw_model  config_h_tracer_eddy_diff2   0.0
-namelist real        sw_model  config_h_tracer_eddy_diff4   0.0
-namelist integer     sw_model  config_thickness_adv_order   2
-namelist integer     sw_model  config_tracer_adv_order      2
-namelist logical     sw_model  config_positive_definite     false
-namelist logical     sw_model  config_monotonic             false
-namelist logical     sw_model  config_wind_stress           false
-namelist logical     sw_model  config_bottom_drag           false
-namelist real        sw_model  config_apvm_upwinding        0.5
-namelist integer     sw_model  config_num_halos             2
-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       06:00:00
-namelist integer     io        config_frames_per_outfile    0
-namelist integer     io        config_pio_num_iotasks       0 
-namelist integer     io        config_pio_stride            1
-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
-
-%
-% dim  type  name_in_file  name_in_code
-%
-dim nCells nCells
-dim nEdges nEdges
-dim maxEdges maxEdges
-dim maxEdges2 maxEdges2
-dim nVertices nVertices
-dim TWO 2
-dim R3 3
-dim FIFTEEN 15
-dim TWENTYONE 21
-dim vertexDegree vertexDegree
-dim nVertLevels nVertLevels
-dim nTracers nTracers
-
-%
-% var persistence type  name_in_file  ( dims )  time_levs iro-  name_in_code struct super-array array_class
-%
-var persistent text    xtime ( Time ) 2 ro xtime state - -
-
-var persistent real    latCell ( nCells ) 0 iro latCell mesh - -
-var persistent real    lonCell ( nCells ) 0 iro lonCell mesh - -
-var persistent real    xCell ( nCells ) 0 iro xCell mesh - -
-var persistent real    yCell ( nCells ) 0 iro yCell mesh - -
-var persistent real    zCell ( nCells ) 0 iro zCell mesh - -
-var persistent integer indexToCellID ( nCells ) 0 iro indexToCellID mesh - -
-
-var persistent real    latEdge ( nEdges ) 0 iro latEdge mesh - -
-var persistent real    lonEdge ( nEdges ) 0 iro lonEdge mesh - -
-var persistent real    xEdge ( nEdges ) 0 iro xEdge mesh - -
-var persistent real    yEdge ( nEdges ) 0 iro yEdge mesh - -
-var persistent real    zEdge ( nEdges ) 0 iro zEdge mesh - -
-var persistent integer indexToEdgeID ( nEdges ) 0 iro indexToEdgeID mesh - -
-
-var persistent real    latVertex ( nVertices ) 0 iro latVertex mesh - -
-var persistent real    lonVertex ( nVertices ) 0 iro lonVertex mesh - -
-var persistent real    xVertex ( nVertices ) 0 iro xVertex mesh - -
-var persistent real    yVertex ( nVertices ) 0 iro yVertex mesh - -
-var persistent real    zVertex ( nVertices ) 0 iro zVertex mesh - -
-var persistent integer indexToVertexID ( nVertices ) 0 iro indexToVertexID mesh - -
-
-var persistent real    meshDensity ( nCells ) 0 iro meshDensity mesh - -
-var persistent real    meshScalingDel2 ( nEdges ) 0 ro meshScalingDel2 mesh - -
-var persistent real    meshScalingDel4 ( nEdges ) 0 ro meshScalingDel4 mesh - -
-
-var persistent integer cellsOnEdge ( TWO nEdges ) 0 iro cellsOnEdge mesh - -
-var persistent integer nEdgesOnCell ( nCells ) 0 iro nEdgesOnCell mesh - -
-var persistent integer nEdgesOnEdge ( nEdges ) 0 iro nEdgesOnEdge mesh - -
-var persistent integer edgesOnCell ( maxEdges nCells ) 0 iro edgesOnCell mesh - -
-var persistent integer edgesOnEdge ( maxEdges2 nEdges ) 0 iro edgesOnEdge mesh - -
-
-var persistent real    weightsOnEdge ( maxEdges2 nEdges ) 0 iro weightsOnEdge mesh - -
-var persistent real    dvEdge ( nEdges ) 0 iro dvEdge mesh - -
-var persistent real    dcEdge ( nEdges ) 0 iro dcEdge mesh - -
-var persistent real    angleEdge ( nEdges ) 0 iro angleEdge mesh - -
-var persistent real    areaCell ( nCells ) 0 iro areaCell mesh - -
-var persistent real    areaTriangle ( nVertices ) 0 iro areaTriangle mesh - -
-
-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 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 - -
-var persistent integer verticesOnEdge ( TWO nEdges ) 0 iro verticesOnEdge mesh - -
-var persistent integer edgesOnVertex ( vertexDegree nVertices ) 0 iro edgesOnVertex mesh - -
-var persistent integer cellsOnVertex ( vertexDegree nVertices ) 0 iro cellsOnVertex mesh - -
-var persistent real    kiteAreasOnVertex ( vertexDegree nVertices ) 0 iro kiteAreasOnVertex mesh - -
-var persistent real    fEdge ( nEdges ) 0 iro fEdge mesh - -
-var persistent real    fVertex ( nVertices ) 0 iro fVertex mesh - -
-var persistent real    fCell ( nCells ) 0 iro fCell mesh - -
-var persistent real    h_s ( nCells ) 0 iro h_s mesh - -
-
-% Space needed for advection
-var persistent real    deriv_two ( FIFTEEN TWO nEdges ) 0 o deriv_two mesh - -
-var persistent integer advCells ( TWENTYONE nCells ) 0 - advCells mesh - -
-
-% !! NOTE: the following arrays are needed to allow the use
-% !! of the module_advection.F w/o alteration
-% Space needed for deformation calculation weights
-var persistent real    defc_a ( maxEdges nCells ) 0 - defc_a mesh - -
-var persistent real    defc_b ( maxEdges nCells ) 0 - defc_b mesh - -
-var persistent real    kdiff ( nVertLevels nCells Time ) 0 - kdiff mesh - -
-
-% Arrays required for reconstruction of velocity field
-var persistent real    coeffs_reconstruct ( R3 maxEdges nCells ) 0 - coeffs_reconstruct mesh - -
-
-% Boundary conditions: read from input, saved in restart and written to output
-var persistent integer boundaryEdge ( nVertLevels nEdges ) 0 iro boundaryEdge mesh - -
-var persistent integer boundaryVertex ( nVertLevels nVertices ) 0 iro boundaryVertex mesh - -
-var persistent integer boundaryCell ( nVertLevels nCells ) 0 iro boundaryCell mesh - -
-var persistent real    u_src ( nVertLevels nEdges ) 0 iro u_src mesh - -
-
-% Prognostic variables: read from input, saved in restart, and written to output
-var persistent real    u ( nVertLevels nEdges Time ) 2 iro u state - -
-var persistent real    h ( nVertLevels nCells Time ) 2 iro h state - -
-var persistent real    tracers ( nTracers nVertLevels nCells Time ) 2 iro tracers state - -
-
-% Tendency variables
-var persistent real    tend_u ( nVertLevels nEdges Time ) 1 - u tend - -
-var persistent real    tend_h ( nVertLevels nCells Time ) 1 - h tend - -
-var persistent real    tend_tracers ( nTracers nVertLevels nCells Time ) 1 - tracers tend - -
-
-% Diagnostic fields: only written to output
-var persistent real    v ( nVertLevels nEdges Time ) 2 o v state - -
-var persistent real    divergence ( nVertLevels nCells Time ) 2 o divergence state - -
-var persistent real    vorticity ( nVertLevels nVertices Time ) 2 o vorticity state - -
-var persistent real    vorticity_cell ( nVertLevels nCells Time ) 2 o vorticity_cell state - -
-var persistent real    pv_edge ( nVertLevels nEdges Time ) 2 o pv_edge state - -
-var persistent real    h_edge ( nVertLevels nEdges Time ) 2 o h_edge state - -
-var persistent real    ke ( nVertLevels nCells Time ) 2 o ke state - -
-var persistent real    pv_vertex ( nVertLevels nVertices Time ) 2 o pv_vertex state - -
-var persistent real    pv_cell ( nVertLevels nCells Time ) 2 o pv_cell state - -
-var persistent real    uReconstructX ( nVertLevels nCells Time ) 2 o uReconstructX state - -
-var persistent real    uReconstructY ( nVertLevels nCells Time ) 2 o uReconstructY state - -
-var persistent real    uReconstructZ ( nVertLevels nCells Time ) 2 o uReconstructZ state - -
-var persistent real    uReconstructZonal ( nVertLevels nCells Time ) 2 o uReconstructZonal state - -
-var persistent real    uReconstructMeridional ( nVertLevels nCells Time ) 2 o uReconstructMeridional state - -
-
-% Other diagnostic variables: neither read nor written to any files
-var persistent real    vh ( nVertLevels nEdges Time ) 2 - vh state - -
-var persistent real    circulation ( nVertLevels nVertices Time ) 2 - circulation state - -
-var persistent real    gradPVt ( nVertLevels nEdges Time ) 2 - gradPVt state - -
-var persistent real    gradPVn ( nVertLevels nEdges Time ) 2 - gradPVn state - -
-var persistent real    h_vertex ( nVertLevels nVertices Time ) 2 - h_vertex state - -
-

Copied: branches/mpas_cdg_advection/src/core_sw/Registry.xml (from rev 2782, trunk/mpas/src/core_sw/Registry.xml)
===================================================================
--- branches/mpas_cdg_advection/src/core_sw/Registry.xml                                (rev 0)
+++ branches/mpas_cdg_advection/src/core_sw/Registry.xml        2013-04-22 01:31:32 UTC (rev 2783)
@@ -0,0 +1,146 @@
+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;registry model=&quot;mpas&quot; core=&quot;sw&quot; version=&quot;0.0.0&quot;&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/mpas_cdg_advection/src/framework/Makefile
===================================================================
--- branches/mpas_cdg_advection/src/framework/Makefile        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/Makefile        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,9 +1,5 @@
 .SUFFIXES: .F .o
 
-ifdef ZOLTAN_HOME
-   ZOLTANOBJ = mpas_zoltan_interface.o
-endif
-
 OBJS = mpas_kind_types.o \
        mpas_framework.o \
        mpas_timer.o \
@@ -22,7 +18,6 @@
        mpas_io_streams.o \
        mpas_io_input.o \
        mpas_io_output.o \
-       $(ZOLTANOBJ) \
        streams.o
 
 all: framework
@@ -58,7 +53,7 @@
 
 mpas_io_streams.o: mpas_attlist.o mpas_grid_types.o mpas_timekeeping.o mpas_io.o
 
-mpas_io_input.o: mpas_grid_types.o mpas_dmpar.o mpas_block_decomp.o mpas_block_creator.o mpas_sort.o mpas_configure.o mpas_timekeeping.o mpas_io_streams.o $(ZOLTANOBJ)
+mpas_io_input.o: mpas_grid_types.o mpas_dmpar.o mpas_block_decomp.o mpas_block_creator.o mpas_sort.o mpas_configure.o mpas_timekeeping.o mpas_io_streams.o
 
 mpas_io_output.o: mpas_grid_types.o mpas_dmpar.o mpas_sort.o mpas_configure.o mpas_io_streams.o
 

Modified: branches/mpas_cdg_advection/src/framework/mpas_attlist.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_attlist.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_attlist.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,3 +1,16 @@
+!***********************************************************************
+!
+!  mpas_attlist
+!
+!&gt; \brief   MPAS Attribute list module
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This module provides type definitions and subroutines for working with attribute lists.
+!
+!-----------------------------------------------------------------------
+
 module mpas_attlist
 
    use mpas_kind_types
@@ -42,15 +55,26 @@
 
 contains
 
+!***********************************************************************
+!
+!  routine mpas_add_att_int0d
+!
+!&gt; \brief   MPAS Add 0D integer attribute routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine adds a 0D integer attribute the attribute list.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_add_att_int0d(attList, attName, attValue, ierr)!{{{
 
-   subroutine mpas_add_att_int0d(attList, attName, attValue, ierr)
-
       implicit none
 
-      type (att_list_type), pointer :: attList
-      character (len=*), intent(in) :: attName
-      integer, intent(in) :: attValue
-      integer, intent(out), optional :: ierr
+      type (att_list_type), pointer :: attList !&lt; Input/Output: Attribute list
+      character (len=*), intent(in) :: attName !&lt; Input: Attribute name
+      integer, intent(in) :: attValue !&lt; Input: Attribute value
+      integer, intent(out), optional :: ierr !&lt; Output: Error flag
 
       type (att_list_type), pointer :: cursor
 
@@ -72,17 +96,28 @@
       write(cursor % attName,'(a)') trim(attName)
       cursor % attValueInt = attValue
 
-   end subroutine mpas_add_att_int0d
+   end subroutine mpas_add_att_int0d!}}}
 
+!***********************************************************************
+!
+!  routine mpas_add_att_int1d
+!
+!&gt; \brief   MPAS Add 1D integer attribute routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine adds a 1D integer attribute the attribute list.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_add_att_int1d(attList, attName, attValue, ierr)!{{{
 
-   subroutine mpas_add_att_int1d(attList, attName, attValue, ierr)
-
       implicit none
 
-      type (att_list_type), pointer :: attList
-      character (len=*), intent(in) :: attName
-      integer, dimension(:), intent(in) :: attValue
-      integer, intent(out), optional :: ierr
+      type (att_list_type), pointer :: attList !&lt; Input/Output: Attribute list
+      character (len=*), intent(in) :: attName !&lt; Input: Attribute name
+      integer, dimension(:), intent(in) :: attValue !&lt; Input: Attribute value
+      integer, intent(out), optional :: ierr !&lt; Output: Error flag
 
       type (att_list_type), pointer :: cursor
 
@@ -105,17 +140,28 @@
       write(cursor % attName,'(a)') trim(attName)
       cursor % attValueIntA(:) = attValue(:)
 
-   end subroutine mpas_add_att_int1d
+   end subroutine mpas_add_att_int1d!}}}
 
+!***********************************************************************
+!
+!  routine mpas_add_att_real0d
+!
+!&gt; \brief   MPAS Add 0D real attribute routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine adds a 0D real attribute the attribute list.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_add_att_real0d(attList, attName, attValue, ierr)!{{{
 
-   subroutine mpas_add_att_real0d(attList, attName, attValue, ierr)
-
       implicit none
 
-      type (att_list_type), pointer :: attList
-      character (len=*), intent(in) :: attName
-      real (kind=RKIND), intent(in) :: attValue
-      integer, intent(out), optional :: ierr
+      type (att_list_type), pointer :: attList !&lt; Input/Output: Attribute list
+      character (len=*), intent(in) :: attName !&lt; Input: Attribute name
+      real (kind=RKIND), intent(in) :: attValue !&lt; Input: Attribute value
+      integer, intent(out), optional :: ierr !&lt; Output: Error flag
 
       type (att_list_type), pointer :: cursor
 
@@ -137,17 +183,28 @@
       write(cursor % attName,'(a)') trim(attName)
       cursor % attValueReal = attValue
 
-   end subroutine mpas_add_att_real0d
+   end subroutine mpas_add_att_real0d!}}}
 
+!***********************************************************************
+!
+!  routine mpas_add_att_real1d
+!
+!&gt; \brief   MPAS Add 1D real attribute routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine adds a 1D real attribute the attribute list.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_add_att_real1d(attList, attName, attValue, ierr)!{{{
 
-   subroutine mpas_add_att_real1d(attList, attName, attValue, ierr)
-
       implicit none
 
-      type (att_list_type), pointer :: attList
-      character (len=*), intent(in) :: attName
-      real (kind=RKIND), dimension(:), intent(in) :: attValue
-      integer, intent(out), optional :: ierr
+      type (att_list_type), pointer :: attList !&lt; Input/Output: Attribute list
+      character (len=*), intent(in) :: attName !&lt; Input: Attribute name
+      real (kind=RKIND), dimension(:), intent(in) :: attValue !&lt; Input: Attribute value
+      integer, intent(out), optional :: ierr !&lt; Output: Error flag
 
       type (att_list_type), pointer :: cursor
 
@@ -170,17 +227,28 @@
       write(cursor % attName,'(a)') trim(attName)
       cursor % attValueRealA(:) = attValue(:)
 
-   end subroutine mpas_add_att_real1d
+   end subroutine mpas_add_att_real1d!}}}
 
+!***********************************************************************
+!
+!  routine mpas_add_att_text
+!
+!&gt; \brief   MPAS Add text attribute routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine adds a text attribute the attribute list.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_add_att_text(attList, attName, attValue, ierr)!{{{
 
-   subroutine mpas_add_att_text(attList, attName, attValue, ierr)
-
       implicit none
 
-      type (att_list_type), pointer :: attList
-      character (len=*), intent(in) :: attName
-      character (len=*), intent(in) :: attValue
-      integer, intent(out), optional :: ierr
+      type (att_list_type), pointer :: attList !&lt; Input/Output: Attribute list
+      character (len=*), intent(in) :: attName !&lt; Input: Attribute name
+      character (len=*), intent(in) :: attValue !&lt; Input: Attribute value
+      integer, intent(out), optional :: ierr !&lt; Output: Error flag
 
       type (att_list_type), pointer :: cursor
 
@@ -202,17 +270,28 @@
       write(cursor % attName,'(a)') trim(attName)
       write(cursor % attValueText,'(a)') trim(attValue)
 
-   end subroutine mpas_add_att_text
+   end subroutine mpas_add_att_text!}}}
 
+!***********************************************************************
+!
+!  routine mpas_get_att_int0d
+!
+!&gt; \brief   MPAS get 0D integer attribute routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine returns the attribute value of a 0D integer attribute.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_get_att_int0d(attList, attName, attValue, ierr)!{{{
 
-   subroutine mpas_get_att_int0d(attList, attName, attValue, ierr)
-
       implicit none
 
-      type (att_list_type), pointer :: attList
-      character (len=*), intent(in) :: attName
-      integer, intent(out) :: attValue
-      integer, intent(out), optional :: ierr
+      type (att_list_type), pointer :: attList !&lt; Input: Attribute list
+      character (len=*), intent(in) :: attName !&lt; Input: Attribute name
+      integer, intent(out) :: attValue !&lt; Output: Attribute value
+      integer, intent(out), optional :: ierr !&lt; Output: Error flag
 
       type (att_list_type), pointer :: cursor
 
@@ -233,17 +312,28 @@
 
       if (present(ierr)) ierr = 1    ! Not found
 
-   end subroutine mpas_get_att_int0d
+   end subroutine mpas_get_att_int0d!}}}
 
+!***********************************************************************
+!
+!  routine mpas_get_att_int1d
+!
+!&gt; \brief   MPAS get 1D integer attribute routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine returns the attribute value of a 1D integer attribute.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_get_att_int1d(attList, attName, attValue, ierr)!{{{
 
-   subroutine mpas_get_att_int1d(attList, attName, attValue, ierr)
-
       implicit none
 
-      type (att_list_type), pointer :: attList
-      character (len=*), intent(in) :: attName
-      integer, dimension(:), pointer :: attValue
-      integer, intent(out), optional :: ierr
+      type (att_list_type), pointer :: attList !&lt; Input: Attribute list
+      character (len=*), intent(in) :: attName !&lt; Input: Attribute name
+      integer, dimension(:), pointer :: attValue !&lt; Output: Attribute value
+      integer, intent(out), optional :: ierr !&lt; Output: Error flag
 
       type (att_list_type), pointer :: cursor
 
@@ -265,17 +355,28 @@
 
       if (present(ierr)) ierr = 1    ! Not found
 
-   end subroutine mpas_get_att_int1d
+   end subroutine mpas_get_att_int1d!}}}
 
+!***********************************************************************
+!
+!  routine mpas_get_att_real0d
+!
+!&gt; \brief   MPAS get 0D real attribute routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine returns the attribute value of a 0D real attribute.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_get_att_real0d(attList, attName, attValue, ierr)!{{{
 
-   subroutine mpas_get_att_real0d(attList, attName, attValue, ierr)
-
       implicit none
 
-      type (att_list_type), pointer :: attList
-      character (len=*), intent(in) :: attName
-      real (kind=RKIND), intent(out) :: attValue
-      integer, intent(out), optional :: ierr
+      type (att_list_type), pointer :: attList !&lt; Input: Attribute list
+      character (len=*), intent(in) :: attName !&lt; Input: Attribute name
+      real (kind=RKIND), intent(out) :: attValue !&lt; Output: Attribute value
+      integer, intent(out), optional :: ierr !&lt; Output: Error flag
 
       type (att_list_type), pointer :: cursor
 
@@ -296,17 +397,28 @@
 
       if (present(ierr)) ierr = 1    ! Not found
 
-   end subroutine mpas_get_att_real0d
+   end subroutine mpas_get_att_real0d!}}}
 
+!***********************************************************************
+!
+!  routine mpas_get_att_real1d
+!
+!&gt; \brief   MPAS get 1D real attribute routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine returns the attribute value of a 1D real attribute.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_get_att_real1d(attList, attName, attValue, ierr)!{{{
 
-   subroutine mpas_get_att_real1d(attList, attName, attValue, ierr)
-
       implicit none
 
-      type (att_list_type), pointer :: attList
-      character (len=*), intent(in) :: attName
-      real (kind=RKIND), dimension(:), pointer :: attValue
-      integer, intent(out), optional :: ierr
+      type (att_list_type), pointer :: attList !&lt; Input: Attribute list
+      character (len=*), intent(in) :: attName !&lt; Input: Attribute name
+      real (kind=RKIND), dimension(:), pointer :: attValue !&lt; Output: Attribute value
+      integer, intent(out), optional :: ierr !&lt; Output: Error flag
 
       type (att_list_type), pointer :: cursor
 
@@ -328,17 +440,28 @@
 
       if (present(ierr)) ierr = 1    ! Not found
 
-   end subroutine mpas_get_att_real1d
+   end subroutine mpas_get_att_real1d!}}}
 
+!***********************************************************************
+!
+!  routine mpas_get_att_text
+!
+!&gt; \brief   MPAS get text attribute routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine returns the attribute value of a text attribute.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_get_att_text(attList, attName, attValue, ierr)!{{{
 
-   subroutine mpas_get_att_text(attList, attName, attValue, ierr)
-
       implicit none
 
-      type (att_list_type), pointer :: attList
-      character (len=*), intent(in) :: attName
-      character (len=*), intent(out) :: attValue
-      integer, intent(out), optional :: ierr
+      type (att_list_type), pointer :: attList !&lt; Input: Attribute list
+      character (len=*), intent(in) :: attName !&lt; Input: Attribute name
+      character (len=*), intent(out) :: attValue !&lt; Output: Attribute value
+      integer, intent(out), optional :: ierr !&lt; Output: Error flag
 
       type (att_list_type), pointer :: cursor
 
@@ -359,16 +482,27 @@
 
       if (present(ierr)) ierr = 1    ! Not found
 
-   end subroutine mpas_get_att_text
+   end subroutine mpas_get_att_text!}}}
 
+!***********************************************************************
+!
+!  routine mpas_remove_att
+!
+!&gt; \brief   MPAS remove attribute routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine removes an attribute from an attribute list.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_remove_att(attList, attName, ierr)!{{{
 
-   subroutine mpas_remove_att(attList, attName, ierr)
-
       implicit none
 
-      type (att_list_type), pointer :: attList
-      character (len=*), intent(in) :: attName
-      integer, intent(out), optional :: ierr
+      type (att_list_type), pointer :: attList !&lt; Input/Output: Attribute list
+      character (len=*), intent(in) :: attName !&lt; Input: Attribute name
+      integer, intent(out), optional :: ierr !&lt; Output: Error flag
 
       type (att_list_type), pointer :: cursor, cursor_prev
 
@@ -410,15 +544,26 @@
 
       if (present(ierr)) ierr = 1    ! Not found
 
-   end subroutine mpas_remove_att
+   end subroutine mpas_remove_att!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_attlist
+!
+!&gt; \brief   MPAS attribute list deallocation routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates an attribute list.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_deallocate_attlist(attList, ierr)!{{{
 
-   subroutine mpas_deallocate_attlist(attList, ierr)
-
       implicit none
 
-      type (att_list_type), pointer :: attList
-      integer, intent(out), optional :: ierr
+      type (att_list_type), pointer :: attList !&lt; Input/Output: Attribute list
+      integer, intent(out), optional :: ierr !&lt; Output: Error flag
 
       type (att_list_type), pointer :: cursor
 
@@ -436,6 +581,6 @@
          cursor =&gt; attList
       end do
 
-   end subroutine mpas_deallocate_attlist
+   end subroutine mpas_deallocate_attlist!}}}
 
 end module mpas_attlist

Modified: branches/mpas_cdg_advection/src/framework/mpas_block_decomp.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_block_decomp.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_block_decomp.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,3 +1,16 @@
+!***********************************************************************
+!
+!  mpas_block_decomp
+!
+!&gt; \brief   This module contains routines related to the block decomposition.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/26/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;   This module is repsonsible for reading the decomposition files, and determining which elements should live within which blocks.
+!&gt;   It also provides interfaces to find out how blocks map to processors.
+!
+!-----------------------------------------------------------------------
 module mpas_block_decomp
 
    use mpas_dmpar
@@ -23,6 +36,18 @@
 
    contains
 
+!***********************************************************************
+!
+!  routine mpas_block_decomp_cells_for_proc
+!
+!&gt; \brief   Determines list of cells for a specific processor
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/26/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine determines a list of cells for each processor, and what blocks the live in.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_block_decomp_cells_for_proc(dminfo, partial_global_graph_info, local_cell_list, block_id, block_start, block_count)!{{{
 
       use mpas_configure
@@ -226,15 +251,30 @@
 
    end subroutine mpas_block_decomp_cells_for_proc!}}}
 
+!***********************************************************************
+!
+!  routine mpas_block_decomp_partitioned_edge_list
+!
+!&gt; \brief   Partitions list of edges for a processor
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/26/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine partitions a list of edges for each processor, based on a list of owned cells.
+!&gt;  Output edge list has 0-Halo edges first, followed by halo edges.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_block_decomp_partitioned_edge_list(nCells, cellIDList, maxCells, nEdges, cellsOnEdge, edgeIDList, ghostEdgeStart)!{{{
 
       implicit none
 
-      integer, intent(in) :: nCells, maxCells, nEdges
-      integer, dimension(nCells), intent(in) :: cellIDList
-      integer, dimension(maxCells, nEdges), intent(in) :: cellsOnEdge
-      integer, dimension(nEdges), intent(inout) :: edgeIDList
-      integer, intent(inout) :: ghostEdgeStart
+      integer, intent(in) :: nCells !&lt; Input: Number of owned cells
+      integer, intent(in) :: maxCells !&lt; Input: Maximum number of cells on an edge
+      integer, intent(in) :: nEdges !&lt; Input: Number of edges
+      integer, dimension(nCells), intent(in) :: cellIDList !&lt; Input: List of owned cell IDs
+      integer, dimension(maxCells, nEdges), intent(in) :: cellsOnEdge !&lt; Input: Connectivity of cells on edges.
+      integer, dimension(nEdges), intent(inout) :: edgeIDList !&lt; Input/Output: List of edge IDs
+      integer, intent(inout) :: ghostEdgeStart !&lt; Input/Output: Index to beginning of edge halo
 
       integer :: i, j, lastEdge
       integer, dimension(nEdges) :: edgeIDListLocal
@@ -281,15 +321,28 @@
 
    end subroutine mpas_block_decomp_partitioned_edge_list!}}}
 
+!***********************************************************************
+!
+!  routine mpas_block_decomp_all_edges_in_block
+!
+!&gt; \brief   Determines all edges in a block.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/26/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine creates a list of all edges that are in a block, based on a list of owned cells.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_block_decomp_all_edges_in_block(maxEdges, nCells, nEdgesOnCell, edgesOnCell, nEdges, edgeList)!{{{
 
       implicit none
 
-      integer, intent(in) :: maxEdges, nCells
-      integer, dimension(nCells), intent(in) :: nEdgesOnCell
-      integer, dimension(maxEdges, nCells), intent(in) :: edgesOnCell
-      integer, intent(out) :: nEdges
-      integer, dimension(:), pointer :: edgeList
+      integer, intent(in) :: maxEdges !&lt; Input: Maximum number of edges on cell
+      integer, intent(in) :: nCells !&lt; Input: Number of owned cells
+      integer, dimension(nCells), intent(in) :: nEdgesOnCell !&lt; Input: Number of edges on each cell
+      integer, dimension(maxEdges, nCells), intent(in) :: edgesOnCell !&lt; Input: ID of edges that border each cell
+      integer, intent(out) :: nEdges !&lt; Output: Number of edges in block
+      integer, dimension(:), pointer :: edgeList !&lt; Output: List of edges in block
 
       integer :: i, j, k
       type (hashtable) :: h
@@ -334,13 +387,25 @@
 
    end subroutine mpas_block_decomp_all_edges_in_block!}}}
 
+!***********************************************************************
+!
+!  routine mpas_block_decomp_add_halo
+!
+!&gt; \brief   Add halo to block
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/26/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine adds a halo layer to the block.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_block_decomp_add_halo(dminfo, local_graph_info, local_graph_with_halo)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      type (graph), intent(in) :: local_graph_info
-      type (graph), intent(out) :: local_graph_with_halo
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      type (graph), intent(in) :: local_graph_info !&lt; Input: Local graph structure for a block
+      type (graph), intent(out) :: local_graph_with_halo !&lt; Output: Local graph structure for a block, with an extra halo
 
       integer :: i, j, k
       type (hashtable) :: h
@@ -408,6 +473,18 @@
 
    end subroutine mpas_block_decomp_add_halo!}}}
 
+!***********************************************************************
+!
+!  routine mpas_get_blocks_per_proc
+!
+!&gt; \brief   Determine number of blocks per processor
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/26/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine returns the number of blocks a specific processor owns.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_get_blocks_per_proc(dminfo, proc_number, blocks_per_proc)!{{{
      type(dm_info), intent(in) :: dminfo !&lt; Input: Domain Information
      integer, intent(in) :: proc_number !&lt; Input: Processor number
@@ -447,6 +524,18 @@
 
    end subroutine mpas_get_blocks_per_proc!}}}
 
+!***********************************************************************
+!
+!  routine mpas_get_local_block_id
+!
+!&gt; \brief   Determine the local ID of a block
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/26/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine returns the local block ID on the owning processor.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_get_local_block_id(dminfo, global_block_number, local_block_number)!{{{
      type(dm_info), intent(in) :: dminfo !&lt; Input: Domain Information
      integer, intent(in) :: global_block_number !&lt; Input: Global block id from 0 to config_number_of_blocks-1
@@ -473,6 +562,18 @@
      end if
    end subroutine mpas_get_local_block_id!}}}
 
+!***********************************************************************
+!
+!  routine mpas_get_owning_proc
+!
+!&gt; \brief   Determine the owning processor ID for a specific block.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/26/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine returns the ID of the processor that owns a specific block.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_get_owning_proc(dminfo, global_block_number, owning_proc)!{{{
      type(dm_info), intent(in) :: dminfo !&lt; Input: Domain Information
      integer, intent(in) :: global_block_number !&lt; Input: Global block id from 0 to config_number_of_blocks-1
@@ -499,13 +600,25 @@
      end if
    end subroutine mpas_get_owning_proc!}}}
 
+!***********************************************************************
+!
+!  routine mpas_build_block_proc_list
+!
+!&gt; \brief   Build list of blocks per processor
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/26/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine builds the mapping of blocks to processors. Most useful when using an explicit decomposition.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_build_block_proc_list(dminfo)!{{{
 
      use mpas_configure
 
      implicit none
 
-     type(dm_info), intent(in) :: dminfo
+     type(dm_info), intent(in) :: dminfo !&lt; Input: Domain information
 
      integer :: iounit, istatus, i, owning_proc
      character (len=StrKIND) :: filename
@@ -556,6 +669,18 @@
 
    end subroutine mpas_build_block_proc_list!}}}
 
+!***********************************************************************
+!
+!  routine mpas_finish_block_proc_list
+!
+!&gt; \brief   Destroy list of blocks per processor
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/26/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine destroys the mapping of blocks to processors.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_finish_block_proc_list()!{{{
      if(.not.explicitDecomp) return
      deallocate(block_proc_list)

Modified: branches/mpas_cdg_advection/src/framework/mpas_configure.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_configure.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_configure.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,3 +1,14 @@
+!-----------------------------------------------------------------------
+!  mpas_configure
+!
+!&gt; \brief MPAS Configuration routines.
+!&gt; \author Michael Duda, Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This module will contain all namelist parameter definitions, as well as the routine which reads them from the namelist file.
+!
+!-----------------------------------------------------------------------
 module mpas_configure
 
    use mpas_dmpar
@@ -6,13 +17,23 @@
 
    contains
 
-
+!-----------------------------------------------------------------------
+!  routine mpas_read_namelist
+!
+!&gt; \brief MPAS read namelist routine
+!&gt; \author Michael Duda, Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine reads and broadcasts the namelist file. 
+!
+!-----------------------------------------------------------------------
    subroutine mpas_read_namelist(dminfo, nml_filename)
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      character (len=*), optional :: nml_filename
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      character (len=*), optional :: nml_filename !&lt; Input - Optional: Namelist filename. Defaults to namelist.input
 
       integer :: funit, ierr
 

Modified: branches/mpas_cdg_advection/src/framework/mpas_constants.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_constants.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_constants.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,3 +1,17 @@
+!***********************************************************************
+!
+!  mpas_constants
+!
+!&gt; \brief   MPAS Constant Module
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This module provides various constants that can be used in different parts of MPAS.
+!&gt; They may or may not be a physical quantity.
+!
+!-----------------------------------------------------------------------
+
 module mpas_constants
 
    use mpas_kind_types
@@ -2,15 +16,30 @@
 
-   real (kind=RKIND), parameter :: pii     = 3.141592653589793   
-   real (kind=RKIND), parameter :: a       = 6371229.0
-   real (kind=RKIND), parameter :: omega   = 7.29212e-5
-   real (kind=RKIND), parameter :: gravity = 9.80616
-   real (kind=RKIND), parameter :: rgas = 287.
-   real (kind=RKIND), parameter :: cp = 1003.
-   real (kind=RKIND), parameter :: cv = 716.  ! cp - rgas
-   real (kind=RKIND), parameter :: cvpm = -.71385842 ! -cv/cp
-   real (kind=RKIND), parameter :: prandtl = 1.0
+   real (kind=RKIND), parameter :: pii     = 3.141592653589793   !&lt; Constant: Pi
+   real (kind=RKIND), parameter :: a       = 6371229.0           !&lt; Constant: Spherical Earth radius [m]
+   real (kind=RKIND), parameter :: omega   = 7.29212e-5          !&lt; Constant: Angular rotation rate of the Earth [s-1]
+   real (kind=RKIND), parameter :: gravity = 9.80616             !&lt; Constant: Acceleration due to gravity [m s-2]
+   real (kind=RKIND), parameter :: rgas    = 287.0               !&lt; Constant: Gas constant for dry air [J kg-1 K-1]
+   real (kind=RKIND), parameter :: rv      = 461.6               !&lt; Constant: Gas constant for water vapor [J kg-1 K-1]
+   real (kind=RKIND), parameter :: rvord   = rv/rgas             !
+   real (kind=RKIND), parameter :: cp      = 1003.0              !&lt; Constant: Specific heat of dry air at constant pressure [J kg-1 K-1]
+   real (kind=RKIND), parameter :: cv      = cp - rgas           !&lt; Constant: Specific heat of dry air at constant volume [J kg-1 K-1]
+   real (kind=RKIND), parameter :: cvpm    = -cv/cp              !
+   real (kind=RKIND), parameter :: prandtl = 1.0                 !&lt; Constant: Prandtl number
 
 
    contains
 
+
+!***********************************************************************
+!
+!  routine dummy
+!
+!&gt; \brief   MPAS Dummy Routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This is a dummy routine that doesn't do anything.
+!
+!-----------------------------------------------------------------------
    subroutine dummy()

Modified: branches/mpas_cdg_advection/src/framework/mpas_dmpar.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_dmpar.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_dmpar.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,3 +1,14 @@
+!-----------------------------------------------------------------------
+!  mpas_dmpar
+!
+!&gt; \brief MPAS Communication Routines
+!&gt; \author Michael Duda, Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This module contains all communication routines. All MPI calls should be made in this module.
+!
+!-----------------------------------------------------------------------
 module mpas_dmpar
 
    use mpas_dmpar_types
@@ -80,12 +91,24 @@
 
    contains
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_init
+!
+!&gt; \brief MPAS dmpar initialization routine.
+!&gt; \author Michael Duda, Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine initializes dmpar. It calls MPI_Init (if required), and setups up the communicators.
+!&gt;  It also setups of the domain information structure.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_init(dminfo, mpi_comm)!{{{
 
       implicit none
 
-      type (dm_info), intent(inout) :: dminfo
-      integer, intent(in), optional :: mpi_comm     ! Optional: externally-supplied MPI communicator
+      type (dm_info), intent(inout) :: dminfo !&lt; Input/Output: Domain information
+      integer, intent(in), optional :: mpi_comm !&lt; Input - Optional: externally-supplied MPI communicator
 
 #ifdef _MPI
       integer :: mpi_rank, mpi_size
@@ -124,11 +147,22 @@
 
    end subroutine mpas_dmpar_init!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_finalize
+!
+!&gt; \brief MPAS dmpar finalization routine.
+!&gt; \author Michael Duda, Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine finalizes dmpar. It calls MPI_Finalize (if required).
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_finalize(dminfo)!{{{
 
       implicit none
 
-      type (dm_info), intent(inout) :: dminfo
+      type (dm_info), intent(inout) :: dminfo !&lt; Input/Output: Domain information.
 
 #ifdef _MPI
       integer :: mpi_ierr
@@ -140,11 +174,22 @@
 
    end subroutine mpas_dmpar_finalize!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_abort
+!
+!&gt; \brief MPAS dmpar abort routine.
+!&gt; \author Michael Duda, Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine aborts MPI. A call to it kills the model through the use of MPI_Abort.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_abort(dminfo)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
 
 #ifdef _MPI
       integer :: mpi_ierr, mpi_errcode
@@ -156,11 +201,22 @@
 
    end subroutine mpas_dmpar_abort!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_global_abort
+!
+!&gt; \brief MPAS dmpar global abort routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine aborts MPI. A call to it kills the model through the use of MPI_Abort on the world communicator, and outputs a message.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_global_abort(mesg)!{{{
 
       implicit none
 
-      character (len=*), intent(in) :: mesg
+      character (len=*), intent(in) :: mesg !&lt; Input: Abort message
 
 #ifdef _MPI
       integer :: mpi_ierr, mpi_errcode
@@ -174,12 +230,23 @@
 
    end subroutine mpas_dmpar_global_abort!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_bcast_int
+!
+!&gt; \brief MPAS dmpar broadcast integer routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine broadcasts an integer to all processors in the communicator.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_bcast_int(dminfo, i)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      integer, intent(inout) :: i
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      integer, intent(inout) :: i !&lt; Input/Output: Integer to broadcast
 
 #ifdef _MPI
       integer :: mpi_ierr
@@ -189,13 +256,24 @@
 
    end subroutine mpas_dmpar_bcast_int!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_bcast_ints
+!
+!&gt; \brief MPAS dmpar broadcast integers routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine broadcasts an array of integers to all processors in the communicator.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_bcast_ints(dminfo, n, iarray)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      integer, intent(in) :: n
-      integer, dimension(n), intent(inout) :: iarray
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      integer, intent(in) :: n !&lt; Input: Length of array
+      integer, dimension(n), intent(inout) :: iarray !&lt; Input/Output: Array of integers
 
 #ifdef _MPI
       integer :: mpi_ierr
@@ -205,12 +283,23 @@
 
    end subroutine mpas_dmpar_bcast_ints!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_bcast_real
+!
+!&gt; \brief MPAS dmpar broadcast real routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine broadcasts a real to all processors in the communicator.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_bcast_real(dminfo, r)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      real (kind=RKIND), intent(inout) :: r
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      real (kind=RKIND), intent(inout) :: r !&lt; Input/Output: Real to be broadcast
 
 #ifdef _MPI
       integer :: mpi_ierr
@@ -220,13 +309,24 @@
 
    end subroutine mpas_dmpar_bcast_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_bcast_reals
+!
+!&gt; \brief MPAS dmpar broadcast reals routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine broadcasts an array of reals to all processors in the communicator.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_bcast_reals(dminfo, n, rarray)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      integer, intent(in) :: n
-      real (kind=RKIND), dimension(n), intent(inout) :: rarray
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      integer, intent(in) :: n !&lt; Input: Length of array
+      real (kind=RKIND), dimension(n), intent(inout) :: rarray !&lt; Input/Output: Array of reals to be broadcast
 
 #ifdef _MPI
       integer :: mpi_ierr
@@ -236,12 +336,23 @@
 
    end subroutine mpas_dmpar_bcast_reals!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_bcast_logical
+!
+!&gt; \brief MPAS dmpar broadcast logical routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine broadcasts a logical to all processors in the communicator.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_bcast_logical(dminfo, l)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      logical, intent(inout) :: l
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      logical, intent(inout) :: l !&lt; Input/Output: Logical to be broadcast
 
 #ifdef _MPI
       integer :: mpi_ierr
@@ -266,12 +377,23 @@
 
    end subroutine mpas_dmpar_bcast_logical!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_bcast_char
+!
+!&gt; \brief MPAS dmpar broadcast character routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine broadcasts a character to all processors in the communicator.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_bcast_char(dminfo, c)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      character (len=*), intent(inout) :: c
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      character (len=*), intent(inout) :: c !&lt; Input/Output: Character to be broadcast
 
 #ifdef _MPI
       integer :: mpi_ierr
@@ -281,13 +403,24 @@
 
    end subroutine mpas_dmpar_bcast_char!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_sum_int
+!
+!&gt; \brief MPAS dmpar sum integers routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine sums (Allreduce) integer values across all processors in a communicator.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_sum_int(dminfo, i, isum)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      integer, intent(in) :: i
-      integer, intent(out) :: isum
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      integer, intent(in) :: i !&lt; Input: Integer value input
+      integer, intent(out) :: isum !&lt; Output: Integer sum for output
 
       integer :: mpi_ierr
 
@@ -299,13 +432,24 @@
 
    end subroutine mpas_dmpar_sum_int!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_sum_real
+!
+!&gt; \brief MPAS dmpar sum real routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine sums (Allreduce) real values across all processors in a communicator.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_sum_real(dminfo, r, rsum)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      real(kind=RKIND), intent(in) :: r
-      real(kind=RKIND), intent(out) :: rsum
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      real(kind=RKIND), intent(in) :: r !&lt; Input: Real values to be summed
+      real(kind=RKIND), intent(out) :: rsum  !&lt; Output: Sum of reals for output
 
       integer :: mpi_ierr
 
@@ -317,13 +461,24 @@
 
    end subroutine mpas_dmpar_sum_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_min_int
+!
+!&gt; \brief MPAS dmpar minimum integer routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine returns the minimum integer value across all processors in a communicator.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_min_int(dminfo, i, imin)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      integer, intent(in) :: i
-      integer, intent(out) :: imin
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      integer, intent(in) :: i !&lt; Input: Integer value
+      integer, intent(out) :: imin !&lt; Output: Minimum integer value
 
       integer :: mpi_ierr
 
@@ -335,13 +490,24 @@
 
    end subroutine mpas_dmpar_min_int!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_min_real
+!
+!&gt; \brief MPAS dmpar minimum real routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine returns the minimum real value across all processors in a communicator.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_min_real(dminfo, r, rmin)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      real(kind=RKIND), intent(in) :: r
-      real(kind=RKIND), intent(out) :: rmin
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      real(kind=RKIND), intent(in) :: r !&lt; Input: Real value
+      real(kind=RKIND), intent(out) :: rmin !&lt; Output: Minimum of real value
 
       integer :: mpi_ierr
 
@@ -353,13 +519,24 @@
 
    end subroutine mpas_dmpar_min_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_max_int
+!
+!&gt; \brief MPAS dmpar maximum integer routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine returns the maximum integer value across all processors in a communicator.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_max_int(dminfo, i, imax)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      integer, intent(in) :: i
-      integer, intent(out) :: imax
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      integer, intent(in) :: i !&lt; Input: Integer value
+      integer, intent(out) :: imax !&lt; Output: Maximum of integer values
       
       integer :: mpi_ierr 
       
@@ -371,13 +548,24 @@
 
    end subroutine mpas_dmpar_max_int!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_max_real
+!
+!&gt; \brief MPAS dmpar maximum real routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine returns the maximum real value across all processors in a communicator.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_max_real(dminfo, r, rmax)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      real(kind=RKIND), intent(in) :: r
-      real(kind=RKIND), intent(out) :: rmax
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      real(kind=RKIND), intent(in) :: r !&lt; Input: Real value
+      real(kind=RKIND), intent(out) :: rmax !&lt; Output: Maximum of real values
 
       integer :: mpi_ierr
 
@@ -389,14 +577,25 @@
 
    end subroutine mpas_dmpar_max_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_sum_int_array
+!
+!&gt; \brief MPAS dmpar integer array sum routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine computes the sum of a set of integer arrays across all processors in a communicator.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_sum_int_array(dminfo, nElements, inArray, outArray)!{{{
 
       implicit none
    
-      type (dm_info), intent(in) :: dminfo
-      integer, intent(in) :: nElements
-      integer, dimension(nElements), intent(in) :: inArray
-      integer, dimension(nElements), intent(out) :: outArray
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      integer, intent(in) :: nElements !&lt; Input: Length of arrays
+      integer, dimension(nElements), intent(in) :: inArray !&lt; Input: Processor specific array to sum
+      integer, dimension(nElements), intent(out) :: outArray !&lt; Output: Sum of arrays
       
       integer :: mpi_ierr
 
@@ -408,14 +607,25 @@
 
    end subroutine mpas_dmpar_sum_int_array!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_min_int_array
+!
+!&gt; \brief MPAS dmpar integer array minimum routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine computes an array of minimum values for each index across all processors in a communicator, from some input arrays.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_min_int_array(dminfo, nElements, inArray, outArray)!{{{
    
       implicit none
       
-      type (dm_info), intent(in) :: dminfo
-      integer, intent(in) :: nElements
-      integer, dimension(nElements), intent(in) :: inArray
-      integer, dimension(nElements), intent(out) :: outArray
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      integer, intent(in) :: nElements !&lt; Input: Array size
+      integer, dimension(nElements), intent(in) :: inArray !&lt; Input: Input array of integers
+      integer, dimension(nElements), intent(out) :: outArray !&lt; Output: Array of minimum integers
 
       integer :: mpi_ierr
 
@@ -427,14 +637,25 @@
 
    end subroutine mpas_dmpar_min_int_array!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_min_int_array
+!
+!&gt; \brief MPAS dmpar integer array maximum routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine computes an array of maximum values for each index across all processors in a communicator, from some input arrays.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_max_int_array(dminfo, nElements, inArray, outArray)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      integer, intent(in) :: nElements
-      integer, dimension(nElements), intent(in) :: inArray
-      integer, dimension(nElements), intent(out) :: outArray
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      integer, intent(in) :: nElements !&lt; Input: Length of arrays
+      integer, dimension(nElements), intent(in) :: inArray !&lt; Input: Array of integers
+      integer, dimension(nElements), intent(out) :: outArray !&lt; Output: Array of maximum integers
 
       integer :: mpi_ierr
 
@@ -446,14 +667,25 @@
 
    end subroutine mpas_dmpar_max_int_array!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_sum_real_array
+!
+!&gt; \brief MPAS dmpar real array sum routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine computes the sum array of real values  across all processors in a communicator, from some input arrays.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_sum_real_array(dminfo, nElements, inArray, outArray)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      integer, intent(in) :: nElements
-      real(kind=RKIND), dimension(nElements), intent(in) :: inArray
-      real(kind=RKIND), dimension(nElements), intent(out) :: outArray
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      integer, intent(in) :: nElements !&lt; Input: Length of arrays
+      real(kind=RKIND), dimension(nElements), intent(in) :: inArray !&lt; Input: Array of reals
+      real(kind=RKIND), dimension(nElements), intent(out) :: outArray !&lt; Output: Array of real sums
 
       integer :: mpi_ierr
 
@@ -465,14 +697,25 @@
 
    end subroutine mpas_dmpar_sum_real_array!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_min_real_array
+!
+!&gt; \brief MPAS dmpar real array minimum routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine computes the minimum array of real values  across all processors in a communicator, from some input arrays.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_min_real_array(dminfo, nElements, inArray, outArray)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      integer, intent(in) :: nElements
-      real(kind=RKIND), dimension(nElements), intent(in) :: inArray
-      real(kind=RKIND), dimension(nElements), intent(out) :: outArray
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      integer, intent(in) :: nElements !&lt; Input: Length of arrays
+      real(kind=RKIND), dimension(nElements), intent(in) :: inArray !&lt; Input: Array of reals
+      real(kind=RKIND), dimension(nElements), intent(out) :: outArray !&lt; Input: Array of minimum reals
 
       integer :: mpi_ierr
 
@@ -484,14 +727,25 @@
 
    end subroutine mpas_dmpar_min_real_array!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_max_real_array
+!
+!&gt; \brief MPAS dmpar real array maximum routine.
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine computes the maximum array of real values  across all processors in a communicator, from some input arrays.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_max_real_array(dminfo, nElements, inArray, outArray)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      integer, intent(in) :: nElements
-      real(kind=RKIND), dimension(nElements), intent(in) :: inArray
-      real(kind=RKIND), dimension(nElements), intent(out) :: outArray
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      integer, intent(in) :: nElements !&lt; Input: Length of arrays
+      real(kind=RKIND), dimension(nElements), intent(in) :: inArray !&lt; Input: Array of reals
+      real(kind=RKIND), dimension(nElements), intent(out) :: outArray !&lt; Output: Array of maximum reals
 
       integer :: mpi_ierr
 
@@ -503,15 +757,28 @@
 
    end subroutine mpas_dmpar_max_real_array!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_scatter_ints
+!
+!&gt; \brief MPAS dmpar scatter integers routine
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine computes the maximum array of real values  across all processors in a communicator, from some input arrays.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_scatter_ints(dminfo, nprocs, noutlist, displs, counts, inlist, outlist)!{{{
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      integer, intent(in) :: nprocs, noutlist
-      integer, dimension(nprocs), intent(in) :: displs, counts
-      integer, dimension(:), pointer :: inlist
-      integer, dimension(noutlist), intent(inout) :: outlist
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      integer, intent(in) :: nprocs !&lt; Input: Number of processors
+      integer, intent(in) :: noutlist !&lt; Input: Number integers to receive
+      integer, dimension(nprocs), intent(in) :: displs !&lt; Input: Displacement in sending array
+      integer, dimension(nprocs), intent(in) :: counts !&lt; Input: Number of integers to distribute
+      integer, dimension(:), pointer :: inlist !&lt; Input: List of integers to send
+      integer, dimension(noutlist), intent(inout) :: outlist !&lt; Output: List of received integers
 
 #ifdef _MPI
       integer :: mpi_ierr
@@ -521,15 +788,28 @@
 
    end subroutine mpas_dmpar_scatter_ints!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_get_index_range
+!
+!&gt; \brief MPAS dmpar processor specific range of indices
+!&gt; \author Michael Duda
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine divides a global range of indices among all processors, and returns the range of indices a specific processors is responsible for.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_get_index_range(dminfo, &amp;!{{{
                                     global_start, global_end, &amp;
                                     local_start, local_end)
 
       implicit none
 
-      type (dm_info), intent(in) :: dminfo
-      integer, intent(in) :: global_start, global_end
-      integer, intent(out) :: local_start, local_end
+      type (dm_info), intent(in) :: dminfo !&lt; Input: Domain information
+      integer, intent(in) :: global_start !&lt; Input: Starting index in global range
+      integer, intent(in) :: global_end !&lt; Input: Ending index in global range
+      integer, intent(out) :: local_start !&lt; Output: Starting index in local range
+      integer, intent(out) :: local_end !&lt; Output: Ending index in local range
 
       local_start = nint(real(dminfo % my_proc_id) * real(global_end - global_start + 1) / real(dminfo % nprocs)) + 1
       local_end   = nint(real(dminfo % my_proc_id + 1) * real(global_end - global_start + 1) / real(dminfo % nprocs)) 
@@ -572,16 +852,27 @@
    
    end subroutine mpas_dmpar_compute_index_range!}}}
 
-   ! ----- NEW ROUTINES BELOW ----- !
-
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_get_exch_list
+!
+!&gt; \brief MPAS dmpar exchange list builder
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine builds exchange lists to communicated between the lists of owned and needed fields, over a given number of halos.
+!&gt;  Exchange lists are built into the input fields.
+!
+!-----------------------------------------------------------------------
 subroutine mpas_dmpar_get_exch_list(haloLayer, ownedListField, neededListField, offsetListField, ownedLimitField)!{{{
 
       implicit none
 
-      integer, intent(in) :: haloLayer
-      type (field1dInteger), pointer :: ownedListField, neededListField
-      type (field0dInteger), pointer, optional :: offsetListField
-      type (field0dInteger), pointer, optional :: ownedLimitField
+      integer, intent(in) :: haloLayer !&lt; Input: Halo layer to build exchange list for
+      type (field1dInteger), pointer :: ownedListField !&lt; Input/Output: List of owned fields
+      type (field1dInteger), pointer :: neededListField !&lt; Input/Output: List of needed fields
+      type (field0dInteger), pointer, optional :: offsetListField !&lt; Input: Offsets for placement of received data into destination arrays
+      type (field0dInteger), pointer, optional :: ownedLimitField !&lt; Input: List of limits in owned array
 
       type (dm_info), pointer :: dminfo
 
@@ -624,7 +915,7 @@
       !
     
       ! For the neededListField:
-      !    similar to the owneListField...
+      !    similar to the ownedListField...
 
       dminfo =&gt; ownedListField % block % domain % dminfo
 
@@ -1122,14 +1413,25 @@
 
    end subroutine mpas_dmpar_get_exch_list!}}}
 
-
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_alltoall_field1d_integer
+!
+!&gt; \brief MPAS dmpar all-to-all 1D integer routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the all-to-all communication of an input field into an output field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_alltoall_field1d_integer(fieldIn, fieldout, haloLayersIn)!{{{
 
      implicit none
 
-     type (field1dInteger), pointer :: fieldIn
-     type (field1dInteger), pointer :: fieldOut
-     integer, dimension(:), pointer, optional :: haloLayersIn
+     type (field1dInteger), pointer :: fieldIn !&lt; Input: Field to send
+     type (field1dInteger), pointer :: fieldOut !&lt; Output: Field to receive
+     integer, dimension(:), pointer, optional :: haloLayersIn !&lt; Input: Halo layers to communicated. Defaults to all.
 
      type (field1dInteger), pointer :: fieldInPtr, fieldOutPtr
      type (mpas_exchange_list), pointer :: exchListPtr, exchListPtr2
@@ -1403,13 +1705,25 @@
 
    end subroutine mpas_dmpar_alltoall_field1d_integer!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_alltoall_field2d_integer
+!
+!&gt; \brief MPAS dmpar all-to-all 2D integer routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the all-to-all communication of an input field into an output field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_alltoall_field2d_integer(fieldIn, fieldout, haloLayersIn)!{{{
 
      implicit none
 
-     type (field2dInteger), pointer :: fieldIn
-     type (field2dInteger), pointer :: fieldOut
-     integer, dimension(:), pointer, optional :: haloLayersIn
+     type (field2dInteger), pointer :: fieldIn !&lt; Input: Field to communicate from
+     type (field2dInteger), pointer :: fieldOut !&lt; Output: Field to receive into
+     integer, dimension(:), pointer, optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all
 
      type (field2dInteger), pointer :: fieldInPtr, fieldOutPtr
      type (mpas_exchange_list), pointer :: exchListPtr, exchListPtr2
@@ -1684,13 +1998,25 @@
 
    end subroutine mpas_dmpar_alltoall_field2d_integer!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_alltoall_field3d_integer
+!
+!&gt; \brief MPAS dmpar all-to-all 3D integer routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the all-to-all communication of an input field into an output field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_alltoall_field3d_integer(fieldIn, fieldout, haloLayersIn)!{{{
 
      implicit none
 
-     type (field3dInteger), pointer :: fieldIn
-     type (field3dInteger), pointer :: fieldOut
-     integer, dimension(:), pointer, optional :: haloLayersIn
+     type (field3dInteger), pointer :: fieldIn !&lt; Input: Field to send from
+     type (field3dInteger), pointer :: fieldOut !&lt; Output: Field to receive into
+     integer, dimension(:), pointer, optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all
 
      type (field3dInteger), pointer :: fieldInPtr, fieldOutPtr
      type (mpas_exchange_list), pointer :: exchListPtr, exchListPtr2
@@ -1972,13 +2298,25 @@
 
    end subroutine mpas_dmpar_alltoall_field3d_integer!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_alltoall_field1d_real
+!
+!&gt; \brief MPAS dmpar all-to-all 1D real routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the all-to-all communication of an input field into an output field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_alltoall_field1d_real(fieldIn, fieldout, haloLayersIn)!{{{
 
      implicit none
 
-     type (field1dReal), pointer :: fieldIn
-     type (field1dReal), pointer :: fieldOut
-     integer, dimension(:), pointer, optional :: haloLayersIn
+     type (field1dReal), pointer :: fieldIn !&lt; Input: Field to send from
+     type (field1dReal), pointer :: fieldOut !&lt; Output: Field to receive into
+     integer, dimension(:), pointer, optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all
 
      type (field1dReal), pointer :: fieldInPtr, fieldOutPtr
      type (mpas_exchange_list), pointer :: exchListPtr, exchListPtr2
@@ -2250,13 +2588,25 @@
 
    end subroutine mpas_dmpar_alltoall_field1d_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_alltoall_field2d_real
+!
+!&gt; \brief MPAS dmpar all-to-all 2D real routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the all-to-all communication of an input field into an output field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_alltoall_field2d_real(fieldIn, fieldout, haloLayersIn)!{{{
 
      implicit none
 
-     type (field2dReal), pointer :: fieldIn
-     type (field2dReal), pointer :: fieldOut
-     integer, dimension(:), pointer, optional :: haloLayersIn
+     type (field2dReal), pointer :: fieldIn !&lt; Input: Field to send from
+     type (field2dReal), pointer :: fieldOut !&lt; Output: Field to receive into
+     integer, dimension(:), pointer, optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all
 
      type (field2dReal), pointer :: fieldInPtr, fieldOutPtr
      type (mpas_exchange_list), pointer :: exchListPtr, exchListPtr2
@@ -2532,13 +2882,25 @@
 
    end subroutine mpas_dmpar_alltoall_field2d_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_alltoall_field3d_real
+!
+!&gt; \brief MPAS dmpar all-to-all 3D real routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the all-to-all communication of an input field into an output field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_alltoall_field3d_real(fieldIn, fieldout, haloLayersIn)!{{{
 
      implicit none
 
-     type (field3dReal), pointer :: fieldIn
-     type (field3dReal), pointer :: fieldOut
-     integer, dimension(:), pointer, optional :: haloLayersIn
+     type (field3dReal), pointer :: fieldIn !&lt; Input: Field to send from
+     type (field3dReal), pointer :: fieldOut !&lt; Output: Field to receive into
+     integer, dimension(:), pointer, optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all
 
      type (field3dReal), pointer :: fieldInPtr, fieldOutPtr
      type (mpas_exchange_list), pointer :: exchListPtr, exchListPtr2
@@ -2822,13 +3184,25 @@
 
    end subroutine mpas_dmpar_alltoall_field3d_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_alltoall_field4d_real
+!
+!&gt; \brief MPAS dmpar all-to-all 4D real routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the all-to-all communication of an input field into an output field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_alltoall_field4d_real(fieldIn, fieldout, haloLayersIn)!{{{
 
      implicit none
 
-     type (field4dReal), pointer :: fieldIn
-     type (field4dReal), pointer :: fieldOut
-     integer, dimension(:), pointer, optional :: haloLayersIn
+     type (field4dReal), pointer :: fieldIn !&lt; Input: Field to send from
+     type (field4dReal), pointer :: fieldOut !&lt; Output: Field to receive into
+     integer, dimension(:), pointer, optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all
 
      type (field4dReal), pointer :: fieldInPtr, fieldOutPtr
      type (mpas_exchange_list), pointer :: exchListPtr, exchListPtr2
@@ -3120,13 +3494,25 @@
 
    end subroutine mpas_dmpar_alltoall_field4d_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_alltoall_field5d_real
+!
+!&gt; \brief MPAS dmpar all-to-all 5D real routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the all-to-all communication of an input field into an output field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_alltoall_field5d_real(fieldIn, fieldout, haloLayersIn)!{{{
 
      implicit none
 
-     type (field5dReal), pointer :: fieldIn
-     type (field5dReal), pointer :: fieldOut
-     integer, dimension(:), pointer, optional :: haloLayersIn
+     type (field5dReal), pointer :: fieldIn !&lt; Input: Field to send from
+     type (field5dReal), pointer :: fieldOut !&lt; Output: Field to receive into
+     integer, dimension(:), pointer, optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all.
 
      type (field5dReal), pointer :: fieldInPtr, fieldOutPtr
      type (mpas_exchange_list), pointer :: exchListPtr, exchListPtr2
@@ -3424,14 +3810,24 @@
 
    end subroutine mpas_dmpar_alltoall_field5d_real!}}}
 
-
-
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_exch_halo_field1d_integer
+!
+!&gt; \brief MPAS dmpar halo exchange 1D integer field
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the halo exchange communication of an input field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_exch_halo_field1d_integer(field, haloLayersIn)!{{{
 
       implicit none
 
-      type (field1DInteger), pointer :: field
-      integer, dimension(:), intent(in), optional :: haloLayersIn
+      type (field1DInteger), pointer :: field !&lt; Input: Field to communicate
+      integer, dimension(:), intent(in), optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all
 
       type (dm_info), pointer :: dminfo
       type (field1DInteger), pointer :: fieldCursor, fieldCursor2
@@ -3706,12 +4102,24 @@
 
    end subroutine mpas_dmpar_exch_halo_field1d_integer!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_exch_halo_field2d_integer
+!
+!&gt; \brief MPAS dmpar halo exchange 2D integer field
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the halo exchange communication of an input field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_exch_halo_field2d_integer(field, haloLayersIn)!{{{
 
       implicit none
 
-      type (field2DInteger), pointer :: field
-      integer, dimension(:), intent(in), optional :: haloLayersIn
+      type (field2DInteger), pointer :: field !&lt; Input: Field to communicate
+      integer, dimension(:), intent(in), optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all
 
       type (dm_info), pointer :: dminfo
       type (field2DInteger), pointer :: fieldCursor, fieldCursor2
@@ -3987,12 +4395,24 @@
 
    end subroutine mpas_dmpar_exch_halo_field2d_integer!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_exch_halo_field3d_integer
+!
+!&gt; \brief MPAS dmpar halo exchange 3D integer field
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the halo exchange communication of an input field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_exch_halo_field3d_integer(field, haloLayersIn)!{{{
 
       implicit none
 
-      type (field3DInteger), pointer :: field
-      integer, dimension(:), intent(in), optional :: haloLayersIn
+      type (field3DInteger), pointer :: field !&lt; Input: Field to communicate
+      integer, dimension(:), intent(in), optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all
 
       type (dm_info), pointer :: dminfo
       type (field3DInteger), pointer :: fieldCursor, fieldCursor2
@@ -4274,12 +4694,24 @@
 
    end subroutine mpas_dmpar_exch_halo_field3d_integer!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_exch_halo_field1d_real
+!
+!&gt; \brief MPAS dmpar halo exchange 1D real field
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the halo exchange communication of an input field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_exch_halo_field1d_real(field, haloLayersIn)!{{{
 
       implicit none
 
-      type (field1dReal), pointer :: field
-      integer, dimension(:), intent(in), optional :: haloLayersIn
+      type (field1dReal), pointer :: field !&lt; Input: Field to communicate
+      integer, dimension(:), intent(in), optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all
 
       type (dm_info), pointer :: dminfo
       type (field1dReal), pointer :: fieldCursor, fieldCursor2
@@ -4552,12 +4984,24 @@
 
    end subroutine mpas_dmpar_exch_halo_field1d_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_exch_halo_field2d_real
+!
+!&gt; \brief MPAS dmpar halo exchange 2D real field
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the halo exchange communication of an input field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_exch_halo_field2d_real(field, haloLayersIn)!{{{
 
       implicit none
 
-      type (field2dReal), pointer :: field
-      integer, dimension(:), intent(in), optional :: haloLayersIn
+      type (field2dReal), pointer :: field !&lt; Input: Field to communicate
+      integer, dimension(:), intent(in), optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all
 
       type (dm_info), pointer :: dminfo
       type (field2dReal), pointer :: fieldCursor, fieldCursor2
@@ -4835,12 +5279,24 @@
 
    end subroutine mpas_dmpar_exch_halo_field2d_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_exch_halo_field3d_real
+!
+!&gt; \brief MPAS dmpar halo exchange 3D real field
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the halo exchange communication of an input field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_exch_halo_field3d_real(field, haloLayersIn)!{{{
 
       implicit none
 
-      type (field3dReal), pointer :: field
-      integer, dimension(:), intent(in), optional :: haloLayersIn
+      type (field3dReal), pointer :: field !&lt; Input: Field to communicate
+      integer, dimension(:), intent(in), optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all
 
       type (dm_info), pointer :: dminfo
       type (field3dReal), pointer :: fieldCursor, fieldCursor2
@@ -5122,12 +5578,24 @@
 
    end subroutine mpas_dmpar_exch_halo_field3d_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_exch_halo_field4d_real
+!
+!&gt; \brief MPAS dmpar halo exchange 4D real field
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the halo exchange communication of an input field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_exch_halo_field4d_real(field, haloLayersIn)!{{{
 
       implicit none
 
-      type (field4dReal), pointer :: field
-      integer, dimension(:), intent(in), optional :: haloLayersIn
+      type (field4dReal), pointer :: field !&lt; Input: Field to communicate
+      integer, dimension(:), intent(in), optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all
 
       type (dm_info), pointer :: dminfo
       type (field4dReal), pointer :: fieldCursor, fieldCursor2
@@ -5417,12 +5885,24 @@
 
    end subroutine mpas_dmpar_exch_halo_field4d_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_exch_halo_field5d_real
+!
+!&gt; \brief MPAS dmpar halo exchange 5D real field
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine handles the halo exchange communication of an input field across all processors.
+!&gt;  It requries exchange lists to be created prior to calling this routine.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_exch_halo_field5d_real(field, haloLayersIn)!{{{
 
       implicit none
 
-      type (field5dReal), pointer :: field
-      integer, dimension(:), intent(in), optional :: haloLayersIn
+      type (field5dReal), pointer :: field !&lt; Input: Field to communicate
+      integer, dimension(:), intent(in), optional :: haloLayersIn !&lt; Input: List of halo layers to communicate. Defaults to all
 
       type (dm_info), pointer :: dminfo
       type (field5dReal), pointer :: fieldCursor, fieldCursor2
@@ -5718,9 +6198,20 @@
 
    end subroutine mpas_dmpar_exch_halo_field5d_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_init_mulithalo_exchange_list
+!
+!&gt; \brief MPAS dmpar initialize muiltihalo exchange list routine.
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine initializes the multihalo exchange lists, based on a number of halo layers.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_init_mulithalo_exchange_list(exchList, nHalos)!{{{
-     type (mpas_multihalo_exchange_list), pointer :: exchList
-     integer, intent(in) :: nHalos
+     type (mpas_multihalo_exchange_list), pointer :: exchList !&lt; Input: Exchange list to initialize
+     integer, intent(in) :: nHalos !&lt; Input: Number of halo layers for exchange list
 
      integer :: i
 
@@ -5731,8 +6222,19 @@
      end do
    end subroutine mpas_dmpar_init_mulithalo_exchange_list!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_destroy_mulithalo_exchange_list
+!
+!&gt; \brief MPAS dmpar destroy muiltihalo exchange list routine.
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine destroys the multihalo exchange lists.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_destroy_mulithalo_exchange_list(exchList)!{{{
-     type (mpas_multihalo_exchange_list), pointer :: exchList
+     type (mpas_multihalo_exchange_list), pointer :: exchList !&lt; Input: Exchange list to destroy.
 
      integer :: nHalos
      integer :: i
@@ -5748,8 +6250,19 @@
      nullify(exchList)
    end subroutine mpas_dmpar_destroy_mulithalo_exchange_list!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_destroy_communication_list
+!
+!&gt; \brief MPAS dmpar destroy communication list routine.
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine destroys a communication lists.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_destroy_communication_list(commList)!{{{
-     type (mpas_communication_list), pointer :: commList
+     type (mpas_communication_list), pointer :: commList !&lt; Input: Communication list to destroy.
      type (mpas_communication_list), pointer :: commListPtr
 
      commListPtr =&gt; commList
@@ -5774,8 +6287,19 @@
 
    end subroutine mpas_dmpar_destroy_communication_list!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_destroy_exchange_list
+!
+!&gt; \brief MPAS dmpar destroy exchange list routine.
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine destroys a exchange lists.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_destroy_exchange_list(exchList)!{{{
-     type (mpas_exchange_list), pointer :: exchList
+     type (mpas_exchange_list), pointer :: exchList !&lt; Input: Exchange list to destroy
      type (mpas_exchange_list), pointer :: exchListPtr
 
      exchListPtr =&gt; exchList
@@ -5800,8 +6324,19 @@
 
    end subroutine mpas_dmpar_destroy_exchange_list!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_copy_field1d_integer
+!
+!&gt; \brief MPAS dmpar copy 1D integer field routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine copies a 1D integer field throughout a block list.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_copy_field1d_integer(field)!{{{
-       type (field1dInteger), pointer :: field
+       type (field1dInteger), pointer :: field !&lt; Input: Field to copy
        type (field1dInteger), pointer :: fieldCursor
 
        if(associated(field % next)) then
@@ -5813,8 +6348,19 @@
        end if
    end subroutine mpas_dmpar_copy_field1d_integer!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_copy_field2d_integer
+!
+!&gt; \brief MPAS dmpar copy 2D integer field routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine copies a 2D integer field throughout a block list.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_copy_field2d_integer(field)!{{{
-       type (field2dInteger), pointer :: field
+       type (field2dInteger), pointer :: field !&lt; Input: Field to copy
        type (field2dInteger), pointer :: fieldCursor
 
        if(associated(field % next)) then
@@ -5826,8 +6372,19 @@
        end if
    end subroutine mpas_dmpar_copy_field2d_integer!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_copy_field3d_integer
+!
+!&gt; \brief MPAS dmpar copy 3D integer field routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine copies a 3D integer field throughout a block list.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_copy_field3d_integer(field)!{{{
-       type (field3dInteger), pointer :: field
+       type (field3dInteger), pointer :: field !&lt; Input: Field to copy
        type (field3dInteger), pointer :: fieldCursor
 
        if(associated(field % next)) then
@@ -5839,8 +6396,19 @@
        end if
    end subroutine mpas_dmpar_copy_field3d_integer!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_copy_field1d_real
+!
+!&gt; \brief MPAS dmpar copy 1D real field routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine copies a 1D real field throughout a block list.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_copy_field1d_real(field)!{{{
-       type (field1dReal), pointer :: field
+       type (field1dReal), pointer :: field !&lt; Input: Field to copy
        type (field1dReal), pointer :: fieldCursor
 
 
@@ -5853,8 +6421,19 @@
        end if
    end subroutine mpas_dmpar_copy_field1d_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_copy_field2d_real
+!
+!&gt; \brief MPAS dmpar copy 2D real field routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine copies a 2D real field throughout a block list.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_copy_field2d_real(field)!{{{
-       type (field2dReal), pointer :: field
+       type (field2dReal), pointer :: field !&lt; Input: Field to copy
        type (field2dReal), pointer :: fieldCursor
 
        if(associated(field % next)) then
@@ -5866,8 +6445,19 @@
        end if
    end subroutine mpas_dmpar_copy_field2d_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_copy_field3d_real
+!
+!&gt; \brief MPAS dmpar copy 3D real field routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine copies a 3D real field throughout a block list.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_copy_field3d_real(field)!{{{
-       type (field3dReal), pointer :: field
+       type (field3dReal), pointer :: field !&lt; Input: Field to copy
        type (field3dReal), pointer :: fieldCursor
 
        if(associated(field % next)) then
@@ -5879,8 +6469,19 @@
        end if
    end subroutine mpas_dmpar_copy_field3d_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_copy_field4d_real
+!
+!&gt; \brief MPAS dmpar copy 4D real field routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine copies a 4D real field throughout a block list.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_copy_field4d_real(field)!{{{
-       type (field4dReal), pointer :: field
+       type (field4dReal), pointer :: field !&lt; Input: Field to copy
        type (field4dReal), pointer :: fieldCursor
 
        if(associated(field % next)) then
@@ -5892,8 +6493,19 @@
        end if
    end subroutine mpas_dmpar_copy_field4d_real!}}}
 
+!-----------------------------------------------------------------------
+!  routine mpas_dmpar_copy_field5d_real
+!
+!&gt; \brief MPAS dmpar copy 5D real field routine
+!&gt; \author Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine copies a 5D real field throughout a block list.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_dmpar_copy_field5d_real(field)!{{{
-       type (field5dReal), pointer :: field
+       type (field5dReal), pointer :: field !&lt; Input: Field to copy
        type (field5dReal), pointer :: fieldCursor
 
        if(associated(field % next)) then

Modified: branches/mpas_cdg_advection/src/framework/mpas_dmpar_types.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_dmpar_types.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_dmpar_types.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,3 +1,14 @@
+!-----------------------------------------------------------------------
+!  mpas_dmpar_types
+!
+!&gt; \brief MPAS Communication Type Definitions
+!&gt; \author Michael Duda, Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This module defines all communication related derived data types
+!
+!-----------------------------------------------------------------------
 module mpas_dmpar_types
 
    use mpas_kind_types

Modified: branches/mpas_cdg_advection/src/framework/mpas_framework.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_framework.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_framework.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,3 +1,14 @@
+!-----------------------------------------------------------------------
+!  mpas_framework
+!
+!&gt; \brief MPAS Framework routines
+!&gt; \author Michael Duda, Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This module contains all routines related to the general MPAS framework interface.
+!
+!-----------------------------------------------------------------------
 module mpas_framework
 
    use mpas_dmpar
@@ -12,8 +23,18 @@
 
    contains
 
-   
-   subroutine mpas_framework_init(dminfo, domain, mpi_comm, nml_filename, io_system)
+!-----------------------------------------------------------------------
+!  routine mpas_framework_init
+!
+!&gt; \brief MPAS framework initialization routine.
+!&gt; \author Michael Duda, Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine initializes the MPAS framework. It calls routines related to initializing different parts of MPAS, that are housed within the framework.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_framework_init(dminfo, domain, mpi_comm, nml_filename, io_system)!{{{
 
       implicit none
 
@@ -43,10 +64,20 @@
       end if
       call MPAS_io_init(dminfo, pio_num_iotasks, pio_stride, io_system)
 
-   end subroutine mpas_framework_init
+   end subroutine mpas_framework_init!}}}
 
-   
-   subroutine mpas_framework_finalize(dminfo, domain, io_system)
+!-----------------------------------------------------------------------
+!  routine mpas_framework_finalize
+!
+!&gt; \brief MPAS framework finalization routine.
+!&gt; \author Michael Duda, Doug Jacobsen
+!&gt; \date   03/26/13
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This routine finalizes the MPAS framework. It calls routines related to finalizing different parts of MPAS, that are housed within the framework.
+!
+!-----------------------------------------------------------------------  
+   subroutine mpas_framework_finalize(dminfo, domain, io_system)!{{{
   
       implicit none
 
@@ -62,6 +93,6 @@
 
       call mpas_timekeeping_finalize()
 
-   end subroutine mpas_framework_finalize
+   end subroutine mpas_framework_finalize!}}}
 
 end module mpas_framework

Modified: branches/mpas_cdg_advection/src/framework/mpas_grid_types.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_grid_types.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_grid_types.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,3 +1,16 @@
+!***********************************************************************
+!
+!  mpas_grid_types
+!
+!&gt; \brief   MPAS Grid and field type defintion module
+!&gt; \author  Michael Duda, Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This module defines derived data types related to fields, and variable structures.
+!&gt; It also includes routines for allocating and deallocating these types.
+!
+!-----------------------------------------------------------------------
 module mpas_grid_types
 
    use mpas_kind_types
@@ -37,6 +50,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 +80,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 +111,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 +141,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 +171,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 +228,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 +258,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 +288,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 +345,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
@@ -419,6 +441,8 @@
    
       ! Also store parallelization info here
       type (dm_info), pointer :: dminfo
+#include &quot;model_variables.inc&quot;
+      character (len=StrKIND*2) :: history !&lt; History attribute, read in from input file.
    end type domain_type
 
    interface mpas_allocate_scratch_field
@@ -463,31 +487,54 @@
 
    contains
 
+!***********************************************************************
+!
+!  routine mpas_allocate_domain
+!
+!&gt; \brief   MPAS Domain allocation routine
+!&gt; \author  Michael Duda
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine allocates a domain structure.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_allocate_domain(dom, dminfo)!{{{
 
-   subroutine mpas_allocate_domain(dom, dminfo)
-
       implicit none
 
-      type (domain_type), pointer :: dom
-      type (dm_info), pointer :: dminfo
+      type (domain_type), pointer :: dom !&lt; Input/Output: Domain structure
+      type (dm_info), pointer :: dminfo !&lt; Input: Domain Information
 
       allocate(dom)
       nullify(dom % blocklist)
       dom % dminfo =&gt; dminfo
 
-   end subroutine mpas_allocate_domain
+   end subroutine mpas_allocate_domain!}}}
 
-
-   subroutine mpas_allocate_block(nHaloLayers, b, dom, blockID, &amp;
+!***********************************************************************
+!
+!  routine mpas_allocate_block
+!
+!&gt; \brief   MPAS Block allocation routine
+!&gt; \author  Michael Duda
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine allocates a block structure. It calls routines to allocate the variable structures
+!&gt; that are members of the block type.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_allocate_block(nHaloLayers, b, dom, blockID, &amp;!{{{
 #include &quot;dim_dummy_args.inc&quot;
                             )
 
       implicit none
 
-      integer, intent(in) :: nHaloLayers
-      type (block_type), pointer :: b
-      type (domain_type), pointer :: dom
-      integer, intent(in) :: blockID
+      integer, intent(in) :: nHaloLayers !&lt; Input: Number of halo laters
+      type (block_type), pointer :: b !&lt; Input/Output: Block structure
+      type (domain_type), pointer :: dom !&lt; Input: Domain structure
+      integer, intent(in) :: blockID !&lt; Input: Global ID of block
 #include &quot;dim_dummy_decls.inc&quot;
 
 
@@ -502,19 +549,30 @@
 
 #include &quot;block_allocs.inc&quot;
 
-   end subroutine mpas_allocate_block
+   end subroutine mpas_allocate_block!}}}
 
 
 #include &quot;group_alloc_routines.inc&quot;
 
 #include &quot;provis_alloc_routines.inc&quot;
 
-
+!***********************************************************************
+!
+!  routine mpas_deallocate_domain
+!
+!&gt; \brief   MPAS Domain deallocation routine
+!&gt; \author  Michael Duda
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a domain structure. 
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_domain(dom)!{{{
 
       implicit none
 
-      type (domain_type), pointer :: dom
+      type (domain_type), pointer :: dom !&lt; Input/Output: Domain to deallocate
 
       type (block_type), pointer :: block_ptr
 
@@ -528,12 +586,28 @@
 
    end subroutine mpas_deallocate_domain!}}}
 
+!***********************************************************************
+!
+!  routine mpas_allocate_scratch_field1d_integer
+!
+!&gt; \brief   MPAS 1D Scratch integer allocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine allocates a 1D scratch integer field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_allocate_scratch_field1d_integer(f, single_block_in)!{{{
-       type (field1dInteger), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field1dInteger), pointer :: f !&lt; Input: Field to allocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical flag that determines if a single block should be allocated or all blocks.
        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
@@ -556,12 +630,28 @@
 
    end subroutine mpas_allocate_scratch_field1d_integer!}}}
 
+!***********************************************************************
+!
+!  routine mpas_allocate_scratch_field2d_integer
+!
+!&gt; \brief   MPAS 2D Scratch integer allocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine allocates a 2D scratch integer field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_allocate_scratch_field2d_integer(f, single_block_in)!{{{
-       type (field2dInteger), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field2dInteger), pointer :: f !&lt; Input: Field to allocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical flag that determines if a single block should be allocated, or all blocks.
        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
@@ -584,12 +674,28 @@
 
    end subroutine mpas_allocate_scratch_field2d_integer!}}}
 
+!***********************************************************************
+!
+!  routine mpas_allocate_scratch_field3d_integer
+!
+!&gt; \brief   MPAS 3D Scratch integer allocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine allocates a 3D scratch integer field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_allocate_scratch_field3d_integer(f, single_block_in)!{{{
-       type (field3dInteger), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field3dInteger), pointer :: f !&lt; Input: Field to allocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical flag that determines if a single block should be allocated, or all blocks.
        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
@@ -612,12 +718,28 @@
 
    end subroutine mpas_allocate_scratch_field3d_integer!}}}
 
+!***********************************************************************
+!
+!  routine mpas_allocate_scratch_field1d_real
+!
+!&gt; \brief   MPAS 1D Scratch real allocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine allocates a 1D scratch real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_allocate_scratch_field1d_real(f, single_block_in)!{{{
-       type (field1dReal), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field1dReal), pointer :: f !&lt; Input: Field to allocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical flag that determines if a single block should be allocated, or all blocks.
        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
@@ -640,12 +762,28 @@
 
    end subroutine mpas_allocate_scratch_field1d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_allocate_scratch_field2d_real
+!
+!&gt; \brief   MPAS 2D Scratch real allocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine allocates a 2D scratch real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_allocate_scratch_field2d_real(f, single_block_in)!{{{
-       type (field2dReal), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field2dReal), pointer :: f !&lt; Input: Field to allocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical flag that determines if a single block should be allocated, or all blocks.
        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
@@ -668,12 +806,28 @@
 
    end subroutine mpas_allocate_scratch_field2d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_allocate_scratch_field3d_real
+!
+!&gt; \brief   MPAS 3D Scratch real allocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine allocates a 3D scratch real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_allocate_scratch_field3d_real(f, single_block_in)!{{{
-       type (field3dReal), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field3dReal), pointer :: f !&lt; Input: Field to allocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical flag that determines if a single block should be allocated, or all blocks.
        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
@@ -696,12 +850,28 @@
 
    end subroutine mpas_allocate_scratch_field3d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_allocate_scratch_field4D_real
+!
+!&gt; \brief   MPAS 4D Scratch real allocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine allocates a 4D scratch real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_allocate_scratch_field4d_real(f, single_block_in)!{{{
-       type (field4dReal), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field4dReal), pointer :: f !&lt; Input: Field to allocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical flag that determines if a single block should be allocated, or all blocks.
        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
@@ -724,12 +894,28 @@
 
    end subroutine mpas_allocate_scratch_field4d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_allocate_scratch_field5D_real
+!
+!&gt; \brief   MPAS 5D Scratch real allocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine allocates a 5D scratch real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_allocate_scratch_field5d_real(f, single_block_in)!{{{
-       type (field5dReal), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field5dReal), pointer :: f !&lt; Input: Field to allocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical flag that determines if a single block should be allocated, or all blocks.
        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
@@ -752,12 +938,28 @@
 
    end subroutine mpas_allocate_scratch_field5d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_allocate_scratch_field1D_char
+!
+!&gt; \brief   MPAS 1D Scratch character deallocation rotuine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine allocates a 1D scratch character field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_allocate_scratch_field1d_char(f, single_block_in)!{{{
-       type (field1dChar), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field1dChar), pointer :: f !&lt; Input: Field to allocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical flag that determines if a single block should be allocated, or all blocks.
        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
@@ -780,12 +982,28 @@
 
    end subroutine mpas_allocate_scratch_field1d_char!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_scratch_field1D_integer
+!
+!&gt; \brief   MPAS 1D Scratch integer deallocation rotuine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 1D scratch integer field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_scratch_field1d_integer(f, single_block_in)!{{{
-       type (field1dInteger), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field1dInteger), pointer :: f !&lt; Input: Field to deallocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical that determines if a single block should be deallocated, or all blocks.
        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
@@ -809,12 +1027,28 @@
 
    end subroutine mpas_deallocate_scratch_field1d_integer!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_scratch_field2D_integer
+!
+!&gt; \brief   MPAS 2D Scratch integer deallocation rotuine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 2D scratch integer field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_scratch_field2d_integer(f, single_block_in)!{{{
-       type (field2dInteger), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field2dInteger), pointer :: f !&lt; Input: Field to deallocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical that determines if a single block should be deallocated, or all blocks.
        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
@@ -838,12 +1072,28 @@
 
    end subroutine mpas_deallocate_scratch_field2d_integer!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_scratch_field3D_integer
+!
+!&gt; \brief   MPAS 3D Scratch integer deallocation rotuine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 3D scratch integer field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_scratch_field3d_integer(f, single_block_in)!{{{
-       type (field3dInteger), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field3dInteger), pointer :: f !&lt; Input: Field to deallocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical that determines if a single block should be deallocated, or all blocks.
        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
@@ -867,12 +1117,28 @@
 
    end subroutine mpas_deallocate_scratch_field3d_integer!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_scratch_field1D_real
+!
+!&gt; \brief   MPAS 1D Scratch real deallocation rotuine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 1D scratch real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_scratch_field1d_real(f, single_block_in)!{{{
-       type (field1dReal), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field1dReal), pointer :: f !&lt; Input: Field to deallocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical that determines if a single block should be deallocated, or all blocks.
        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
@@ -896,12 +1162,28 @@
 
    end subroutine mpas_deallocate_scratch_field1d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_scratch_field2D_real
+!
+!&gt; \brief   MPAS 2D Scratch real deallocation rotuine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 2D scratch real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_scratch_field2d_real(f, single_block_in)!{{{
-       type (field2dReal), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field2dReal), pointer :: f !&lt; Input: Field to deallocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical that determines if a single block should be deallocated, or all blocks.
        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
@@ -925,12 +1207,28 @@
 
    end subroutine mpas_deallocate_scratch_field2d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_scratch_field3D_real
+!
+!&gt; \brief   MPAS 3D Scratch real deallocation rotuine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 3D scratch real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_scratch_field3d_real(f, single_block_in)!{{{
-       type (field3dReal), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field3dReal), pointer :: f !&lt; Input: Field to deallocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical that determines if a single block should be deallocated, or all blocks.
        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
@@ -954,12 +1252,28 @@
 
    end subroutine mpas_deallocate_scratch_field3d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_scratch_field4D_real
+!
+!&gt; \brief   MPAS 4D Scratch real deallocation rotuine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 4D scratch real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_scratch_field4d_real(f, single_block_in)!{{{
-       type (field4dReal), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field4dReal), pointer :: f !&lt; Input: Field to deallocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical that determines if a single block should be deallocated, or all blocks.
        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
@@ -983,12 +1297,28 @@
 
    end subroutine mpas_deallocate_scratch_field4d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_scratch_field5D_real
+!
+!&gt; \brief   MPAS 5D Scratch real deallocation rotuine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 5D scratch real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_scratch_field5d_real(f, single_block_in)!{{{
-       type (field5dReal), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field5dReal), pointer :: f !&lt; Input: Field to deallocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical that determines if a single block should be deallocated, or all blocks.
        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
@@ -1012,12 +1342,28 @@
 
    end subroutine mpas_deallocate_scratch_field5d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_scratch_field1D_char
+!
+!&gt; \brief   MPAS 1D Scratch character deallocation rotuine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 1D scratch character field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_scratch_field1d_char(f, single_block_in)!{{{
-       type (field1dChar), pointer :: f
-       logical, intent(in), optional :: single_block_in
+       type (field1dChar), pointer :: f !&lt; Input: Field to deallocate
+       logical, intent(in), optional :: single_block_in !&lt; Input: Logical that determines if a single block should be deallocated, or all blocks.
        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
@@ -1041,9 +1387,20 @@
 
    end subroutine mpas_deallocate_scratch_field1d_char!}}}
 
-
+!***********************************************************************
+!
+!  routine mpas_deallocate_field0d_integer
+!
+!&gt; \brief   MPAS 0D integer deallocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 0D integer field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_field0d_integer(f)!{{{
-       type (field0dInteger), pointer :: f
+       type (field0dInteger), pointer :: f !&lt; Input: Field to deallocate
        type (field0dInteger), pointer :: f_cursor
 
        f_cursor =&gt; f
@@ -1065,8 +1422,20 @@
 
    end subroutine mpas_deallocate_field0d_integer!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_field1D_integer
+!
+!&gt; \brief   MPAS 1D integer deallocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 1D integer field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_field1d_integer(f)!{{{
-       type (field1dInteger), pointer :: f
+       type (field1dInteger), pointer :: f !&lt; Input: Field to deallocate
        type (field1dInteger), pointer :: f_cursor
 
        f_cursor =&gt; f
@@ -1092,8 +1461,20 @@
 
    end subroutine mpas_deallocate_field1d_integer!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_field2D_integer
+!
+!&gt; \brief   MPAS 2D integer deallocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 2D integer field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_field2d_integer(f)!{{{
-       type (field2dInteger), pointer :: f
+       type (field2dInteger), pointer :: f !&lt; Input: Field to deallocate
        type (field2dInteger), pointer :: f_cursor
 
        f_cursor =&gt; f
@@ -1119,8 +1500,20 @@
 
    end subroutine mpas_deallocate_field2d_integer!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_field3D_integer
+!
+!&gt; \brief   MPAS 3D integer deallocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 3D integer field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_field3d_integer(f)!{{{
-       type (field3dInteger), pointer :: f
+       type (field3dInteger), pointer :: f !&lt; Input: Field to deallocate
        type (field3dInteger), pointer :: f_cursor
 
        f_cursor =&gt; f
@@ -1146,8 +1539,20 @@
 
    end subroutine mpas_deallocate_field3d_integer!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_field0d_real
+!
+!&gt; \brief   MPAS 0D real deallocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 0D real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_field0d_real(f)!{{{
-       type (field0dReal), pointer :: f
+       type (field0dReal), pointer :: f !&lt; Input: Field to deallocate
        type (field0dReal), pointer :: f_cursor
 
        f_cursor =&gt; f
@@ -1170,8 +1575,20 @@
 
    end subroutine mpas_deallocate_field0d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_field1D_real
+!
+!&gt; \brief   MPAS 1D real deallocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 1D real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_field1d_real(f)!{{{
-       type (field1dReal), pointer :: f
+       type (field1dReal), pointer :: f !&lt; Input: Field to deallocate
        type (field1dReal), pointer :: f_cursor
 
        f_cursor =&gt; f
@@ -1197,8 +1614,20 @@
 
    end subroutine mpas_deallocate_field1d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_field2D_real
+!
+!&gt; \brief   MPAS 2D real deallocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 2D real field.
+!
+
    subroutine mpas_deallocate_field2d_real(f)!{{{
-       type (field2dReal), pointer :: f
+       type (field2dReal), pointer :: f !&lt; Input: Field to deallocate
        type (field2dReal), pointer :: f_cursor
 
        f_cursor =&gt; f
@@ -1224,8 +1653,20 @@
 
    end subroutine mpas_deallocate_field2d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_field3D_real
+!
+!&gt; \brief   MPAS 3D real deallocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 3D real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_field3d_real(f)!{{{
-       type (field3dReal), pointer :: f
+       type (field3dReal), pointer :: f !&lt; Input: Field to deallocate
        type (field3dReal), pointer :: f_cursor
 
        f_cursor =&gt; f
@@ -1251,8 +1692,20 @@
 
    end subroutine mpas_deallocate_field3d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_field4D_real
+!
+!&gt; \brief   MPAS 4D real deallocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 4D real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_field4d_real(f)!{{{
-       type (field4dReal), pointer :: f
+       type (field4dReal), pointer :: f !&lt; Input: Field to deallocate
        type (field4dReal), pointer :: f_cursor
 
        f_cursor =&gt; f
@@ -1278,8 +1731,20 @@
 
    end subroutine mpas_deallocate_field4d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_field5D_real
+!
+!&gt; \brief   MPAS 5D real deallocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 5D real field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_field5d_real(f)!{{{
-       type (field5dReal), pointer :: f
+       type (field5dReal), pointer :: f !&lt; Input: Field to deallocate
        type (field5dReal), pointer :: f_cursor
 
        f_cursor =&gt; f
@@ -1305,8 +1770,20 @@
 
    end subroutine mpas_deallocate_field5d_real!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_field0D_char
+!
+!&gt; \brief   MPAS 0D character deallocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 0D character field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_field0d_char(f)!{{{
-       type (field0dChar), pointer :: f
+       type (field0dChar), pointer :: f !&lt; Input: Field to deallocate
        type (field0dChar), pointer :: f_cursor
 
        f_cursor =&gt; f
@@ -1328,8 +1805,20 @@
 
    end subroutine mpas_deallocate_field0d_char!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_field1D_char
+!
+!&gt; \brief   MPAS 1D character deallocation routine.
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a 1D character field.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_field1d_char(f)!{{{
-       type (field1dChar), pointer :: f
+       type (field1dChar), pointer :: f !&lt; Input: Field to deallocate
        type (field1dChar), pointer :: f_cursor
 
        f_cursor =&gt; f
@@ -1355,16 +1844,29 @@
 
    end subroutine mpas_deallocate_field1d_char!}}}
 
+!***********************************************************************
+!
+!  routine mpas_deallocate_block
+!
+!&gt; \brief   MPAS Block deallocation routine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine deallocates a block structure.
+!
+!-----------------------------------------------------------------------
    subroutine mpas_deallocate_block(b)!{{{
  
       implicit none
 
-      type (block_type), intent(inout) :: b
+      type (block_type), intent(inout) :: b !&lt; Input/Output: Block to be deallocated.
 
       integer :: i
 
       ! BUG: It seems like we should be deallocating the exchange lists before we 
       !      deallocate the array of head pointers and the parinfo type...
+      !      It also seems like these deallocations should happen with mpas_dmpar_destroy_multihalo_exchange_list
 
       deallocate(b % parinfo % cellsToSend)
       deallocate(b % parinfo % cellsToRecv)

Modified: branches/mpas_cdg_advection/src/framework/mpas_hash.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_hash.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_hash.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,14 +1,19 @@
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! MODULE HASH
+!***********************************************************************
 !
-! Purpose: This module provides a dictionary/hashtable with insert, search, and
-!   remove routines. 
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!  mpas_hash
+!
+!&gt; \brief   MPAS Hash table module
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This module provides A dictionary/hashtable with insert, search, and remove routines.
+!
+!-----------------------------------------------------------------------
 module mpas_hash
 
    ! Parameters
-   integer, parameter :: TABLESIZE=27183     ! Number of spaces in the table (the
-                                             !   number of linked lists)
+   integer, parameter :: TABLESIZE=27183     !&lt; Number of spaces in the table (the number of linked lists)
  
    type hashnode
       integer :: key
@@ -16,29 +21,35 @@
    end type hashnode
  
    type hashnode_ptr
-      type (hashnode), pointer :: p        ! Pointer to a list of entries
+      type (hashnode), pointer :: p        !&lt; Pointer to a list of entries
    end type hashnode_ptr
  
    type hashtable
       integer :: size
-      type (hashnode_ptr), dimension(TABLESIZE) :: table ! The hashtable array
+      type (hashnode_ptr), dimension(TABLESIZE) :: table !&lt; The hashtable array
    end type hashtable
 
  
    contains
  

-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-   ! Name: hash_init
-   !
-   ! Purpose: To initialize a hashtable
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-   subroutine mpas_hash_init(h)
+!***********************************************************************
+!
+!  routine mpas_hash_init
+!
+!&gt; \brief   MPAS Hash table init routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine initializes a hashtable.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_hash_init(h)!{{{
    
      implicit none
  
      ! Arguments
-     type (hashtable), intent(inout) :: h
+     type (hashtable), intent(inout) :: h !&lt; Input/Output: Hash table
  
      ! Local variables
      integer :: i
@@ -49,25 +60,29 @@
         nullify(h%table(i)%p)
      end do
  
-   end subroutine mpas_hash_init
+   end subroutine mpas_hash_init!}}}
  
  
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-   ! Name: hash_insert
-   !
-   ! Purpose: Given a hashtable h and a key to be inserted into the hashtable,
-   !   this routine adds key to the table. 
-   !
-   ! NOTE: If the key already exists in the table, a second copy of the
-   !   key is added to the table
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-   subroutine mpas_hash_insert(h, key)
+!***********************************************************************
+!
+!  routine mpas_hash_insert
+!
+!&gt; \brief   MPAS Hash table insert routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine inserts a key into a hashtable. If the key already exists in the hash table,
+!&gt; a second copy of the key is added to the table.
+!
+!-----------------------------------------------------------------------
+   subroutine mpas_hash_insert(h, key)!{{{
    
      implicit none
  
      ! Arguments
-     integer, intent(in) :: key
-     type (hashtable), intent(inout) :: h
+     integer, intent(in) :: key !&lt; Input: Key
+     type (hashtable), intent(inout) :: h !&lt; Input/Output: Hashtable
  
      ! Local variables
      integer :: hashval, i
@@ -82,22 +97,27 @@
 
      h%size = h%size + 1
  
-   end subroutine mpas_hash_insert
+   end subroutine mpas_hash_insert!}}}
  

-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-   ! Name: hash_search
-   !
-   ! Purpose: This function returns TRUE if the specified key was found in the
-   !   hashtable h, and FALSE otherwise.
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-   logical function mpas_hash_search(h, key)
+!***********************************************************************
+!
+!  logical function mpas_hash_search
+!
+!&gt; \brief   MPAS Hash table search routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This function searches for a key within a hashtable. If the key is found TRUE is returned, and FALSE is return otherwise.
+!
+!-----------------------------------------------------------------------
+   logical function mpas_hash_search(h, key)!{{{
    
       implicit none
   
       ! Arguments
-      integer, intent(in) :: key
-      type (hashtable), intent(inout) :: h
+      integer, intent(in) :: key !&lt; Input: Key
+      type (hashtable), intent(inout) :: h !&lt; Input/Output: Hashtable
   
       ! Local variables
       integer :: hashval, i
@@ -170,6 +190,6 @@
 
       h%size = 0
  
-   end subroutine mpas_hash_destroy
+   end subroutine mpas_hash_destroy!}}}
  
 end module mpas_hash

Modified: branches/mpas_cdg_advection/src/framework/mpas_io.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_io.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_io.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1248,7 +1248,10 @@
             pio_ierr = PIO_get_var(handle % pio_file, field_cursor % fieldhandle % fieldid, start2, count2, tempchar)
             charVal(1:count2(1)) = tempchar(1)(1:count2(1))
          else
-            pio_ierr = PIO_get_var(handle % pio_file, field_cursor % fieldhandle % field_desc, charVal)
+            start1(1) = 1
+            count1(1) = field_cursor % fieldhandle % dims(1) % dimsize
+            pio_ierr = PIO_get_var(handle % pio_file, field_cursor % fieldhandle % fieldid, start1, count1, tempchar)
+            charVal(1:count1(1)) = tempchar(1)(1:count1(1))
          end if
       else if (present(realArray1d)) then
 !         write (0,*) '  value is real1'
@@ -1643,7 +1646,9 @@
             count2(1) = field_cursor % fieldhandle % dims(1) % dimsize
             pio_ierr = PIO_put_var(handle % pio_file, field_cursor % fieldhandle % fieldid, start2, count2, (/charVal/))
          else
-            pio_ierr = PIO_put_var(handle % pio_file, field_cursor % fieldhandle % field_desc, charVal)
+            start1(1) = 1
+            count1(1) = field_cursor % fieldhandle % dims(1) % dimsize
+            pio_ierr = PIO_put_var(handle % pio_file, field_cursor % fieldhandle % fieldid, start1, count1, (/charVal/))
          end if
       else if (present(realArray1d)) then
          call PIO_write_darray(handle % pio_file, field_cursor % fieldhandle % field_desc, field_cursor % fieldhandle % decomp % pio_iodesc, &amp;

Modified: branches/mpas_cdg_advection/src/framework/mpas_io_input.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_io_input.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_io_input.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -10,10 +10,6 @@
    use mpas_io_streams
 
 
-#ifdef HAVE_ZOLTAN
-   use mpas_zoltan_interface
-#endif
-
    integer, parameter :: STREAM_INPUT=1, STREAM_SFC=2, STREAM_RESTART=3
 
    type io_input_object
@@ -245,6 +241,22 @@
         end if
       end if
 
+      call MPAS_readStreamAtt(input_obj % io_stream, 'history', domain % history, ierr)
+      if (ierr /= MPAS_STREAM_NOERR) then
+        write(0,*) 'Warning: Attribute History not found in '//trim(input_obj % filename)
+        write(0,*) '   Setting History to '''''
+        domain % history = &quot;&quot;
+      else
+        ! Remove C String NULL characters, replace C String newlines with semicolons
+        do i = 1, len(domain % history)
+          if(iachar(domain % history(i:i)) == 0) then
+            domain % history(i:i) = &quot; &quot;
+          else if(iachar(domain % history(i:i)) == 10) then
+            domain % history(i:i) = &quot;;&quot;
+          end if
+        end do
+      end if
+
       block_ptr =&gt; domain % blocklist % next
       do while (associated(block_ptr))
         block_ptr % mesh % sphere_radius = domain % blocklist % mesh % sphere_radius
@@ -339,161 +351,12 @@
       call mpas_deallocate_field(nVerticesSolveField)
       call mpas_deallocate_field(nEdgesSolveField)
 
-#ifdef HAVE_ZOLTAN      
-      call mpas_deallocate_field(xCellField)
-      call mpas_deallocate_field(yCellField)
-      call mpas_deallocate_field(zCellField)
-      call mpas_deallocate_field(xVertexField)
-      call mpas_deallocate_field(yVertexField)
-      call mpas_deallocate_field(zVertexField)
-      call mpas_deallocate_field(xEdgeField)
-      call mpas_deallocate_field(yEdgeField)
-      call mpas_deallocate_field(zEdgeField)
-
-      call mpas_deallocate_field(xCell)
-      call mpas_deallocate_field(yCell)
-      call mpas_deallocate_field(zCell)
-      call mpas_deallocate_field(xVertex)
-      call mpas_deallocate_field(yVertex)
-      call mpas_deallocate_field(zVertex)
-      call mpas_deallocate_field(xEdge)
-      call mpas_deallocate_field(yEdge)
-      call mpas_deallocate_field(zEdge)
-#endif
-
       deallocate(local_cell_list)
       deallocate(block_id)
       deallocate(block_start)
       deallocate(block_count)
       deallocate(readingBlock)
 
-!#ifdef HAVE_ZOLTAN
-!#ifdef _MPI 
-!     allocate(xCell(size(local_cell_list)))
-!     allocate(yCell(size(local_cell_list)))
-!     allocate(zCell(size(local_cell_list)))
-!     call mpas_dmpar_alltoall_field(domain % dminfo, xCellField % array, xCell, &amp;
-!                               size(xCellField % array), size(local_cell_list), &amp;
-!                               sendCellList, recvCellList)
-!   
-!     call mpas_dmpar_alltoall_field(domain % dminfo, yCellField % array, yCell, &amp;
-!                               size(yCellField % array), size(local_cell_list), &amp;
-!                               sendCellList, recvCellList)
-!   
-!     call mpas_dmpar_alltoall_field(domain % dminfo, zCellField % array, zCell, &amp;
-!                               size(zCellField % array), size(local_cell_list), &amp;
-!                               sendCellList, recvCellList)
-!#endif
-!#endif

-!#ifdef HAVE_ZOLTAN
-!#ifdef _MPI 
-!      !! For now, only use Zoltan with MPI
-!      !! Zoltan initialization
-!      call mpas_zoltan_start()
-!
-!      !! Zoltan hook for cells
-!      call mpas_zoltan_order_loc_hsfc_cells(block_graph_2Halo%nVertices,block_graph_2Halo%VertexID,3,xCell,yCell,zCell)
-!#endif
-!#endif
-!
-!   
-!#ifdef HAVE_ZOLTAN
-!#ifdef _MPI 
-!      allocate(xEdge(nlocal_edges))
-!      allocate(yEdge(nlocal_edges))
-!      allocate(zEdge(nlocal_edges))
-!      allocate(xVertex(nlocal_vertices))
-!      allocate(yVertex(nlocal_vertices))
-!      allocate(zVertex(nlocal_vertices))
-!#endif
-!#endif
-!    
-!#ifdef HAVE_ZOLTAN
-!#ifdef _MPI 
-!      call mpas_dmpar_alltoall_field(domain % dminfo, xEdgeField % array, xEdge, &amp;
-!                                size(xEdgeField % array), nlocal_edges, &amp;
-!                                sendEdgeList, recvEdgeList)
-!      call mpas_dmpar_alltoall_field(domain % dminfo, yEdgeField % array, yEdge, &amp;
-!                                size(yEdgeField % array), nlocal_edges, &amp;
-!                                sendEdgeList, recvEdgeList)
-!      call mpas_dmpar_alltoall_field(domain % dminfo, zEdgeField % array, zEdge, &amp;
-!                                size(zEdgeField % array), nlocal_edges, &amp;
-!                                sendEdgeList, recvEdgeList)
-!
-!      call mpas_dmpar_alltoall_field(domain % dminfo, xVertexField % array, xVertex, &amp;
-!                                size(xVertexField % array), nlocal_vertices, &amp;
-!                                sendVertexList, recvVertexList)
-!      call mpas_dmpar_alltoall_field(domain % dminfo, yVertexField % array, yVertex, &amp;
-!                                size(yVertexField % array), nlocal_vertices, &amp;
-!                                sendVertexList, recvVertexList)
-!      call mpas_dmpar_alltoall_field(domain % dminfo, zVertexField % array, zVertex, &amp;
-!                                size(zVertexField % array), nlocal_vertices, &amp;
-!                                sendVertexList, recvVertexList)
-!      !!!!!!!!!!!!!!!!!!
-!      !! Reorder edges
-!      !!!!!!!!!!!!!!!!!!
-!      call mpas_zoltan_order_loc_hsfc_edges(nOwnEdges,local_edge_list,3,xEdge,yEdge,zEdge)
-!      !!!!!!!!!!!!!!!!!!
-!
-!      !!!!!!!!!!!!!!!!!!
-!      !! Reorder vertices
-!      !!!!!!!!!!!!!!!!!!
-!      call mpas_zoltan_order_loc_hsfc_verts(nOwnVertices,local_vertex_list,3,xVertex,yVertex,zVertex)
-!      !!!!!!!!!!!!!!!!!!
-!
-!      deallocate(sendEdgeList % list)
-!      deallocate(sendEdgeList)
-!      deallocate(recvEdgeList % list)
-!      deallocate(recvEdgeList)
-!   
-!      deallocate(sendVertexList % list)
-!      deallocate(sendVertexList)
-!      deallocate(recvVertexList % list)
-!      deallocate(recvVertexList)
-!    
-!      !
-!      ! Knowing which edges/vertices are owned by this block and which are actually read
-!      !   from the input or restart file, we can build exchange lists to perform 
-!      !   all-to-all field exchanges from process that reads a field to the processes that
-!      !   need them
-!      !
-!      call mpas_dmpar_get_owner_list(domain % dminfo, &amp;
-!                                size(indexToEdgeIDField % array), nlocal_edges, &amp;
-!                                indexToEdgeIDField % array, local_edge_list, &amp;
-!                                sendEdgeList, recvEdgeList)
-!   
-!      call mpas_dmpar_get_owner_list(domain % dminfo, &amp;
-!                                size(indexToVertexIDField % array), nlocal_vertices, &amp;
-!                                indexToVertexIDField % array, local_vertex_list, &amp;
-!                                sendVertexList, recvVertexList)
-!
-!#endif
-!#endif
-!
-
-
-!      !
-!      ! Deallocate fields, graphs, and other memory
-!      !
-!#ifdef HAVE_ZOLTAN
-!#ifdef _MPI 
-!      deallocate(xCellField % ioinfo)
-!      deallocate(xCellField % array)
-!      deallocate(yCellField % ioinfo)
-!      deallocate(yCellField % array)
-!      deallocate(zCellField % ioinfo)
-!      deallocate(zCellField % array)
-!#endif
-!#endif
-
-!#ifdef HAVE_ZOLTAN
-!#ifdef _MPI
-!      deallocate(xCell)
-!      deallocate(yCell)
-!      deallocate(zCell)
-!#endif
-!#endif
    end subroutine mpas_input_state_for_domain!}}}
 
    !CR:TODO: an identical subroutine is found in module_io_output - merge
@@ -672,61 +535,7 @@
      call mpas_dmpar_init_mulithalo_exchange_list(indexToCellID % copyList, nHalos)
      nullify(indexToCellID % next)
    
-#ifdef HAVE_ZOLTAN
-#ifdef _MPI 
-     ! Cell x-coordinates (in 3d Cartesian space)
-     allocate(xCell)
-     allocate(xCell % ioinfo)
-     xCell % ioinfo % fieldName = 'xCell'
-     xCell % ioinfo % start(1) = readCellStart
-     xCell % ioinfo % count(1) = nReadCells
-     allocate(xCell % array(nReadCells))
-     call MPAS_io_inq_var(inputHandle, 'xCell', ierr=ierr)
-     call MPAS_io_set_var_indices(inputHandle, 'xCell', readIndices, ierr=ierr)
-     call mpas_io_get_var(inputHandle, 'xCell', xCell % array, ierr)
-     xCell % dimSizes(1) = nReadCells
-     xCell % block =&gt; readingBlock
-     xCell % sendList =&gt; indexToCellID % sendList
-     xCell % recvList =&gt; indexToCellID % recvList
-     xCell % copyList =&gt; indexToCellID % copyList
-     nullify(xCell % next)
 
-     ! Cell y-coordinates (in 3d Cartesian space)
-     allocate(yCell)
-     allocate(yCell % ioinfo)
-     yCell % ioinfo % fieldName = 'yCell'
-     yCell % ioinfo % start(1) = readCellStart
-     yCell % ioinfo % count(1) = nReadCells
-     allocate(yCell % array(nReadCells))
-     call MPAS_io_inq_var(inputHandle, 'yCell', ierr=ierr)
-     call MPAS_io_set_var_indices(inputHandle, 'yCell', readIndices, ierr=ierr)
-     call mpas_io_get_var(inputHandle, 'yCell', yCell % array, ierr)
-     yCell % sendList =&gt; indexToCellID % sendList
-     yCell % recvList =&gt; indexToCellID % recvList
-     yCell % copyList =&gt; indexToCellID % copyList
-     yCell % dimSizes(1) = nReadCells
-     yCell % block =&gt; readingBlock
-     nullify(yCell % next)
-
-     ! Cell z-coordinates (in 3d Cartesian space)
-     allocate(zCell)
-     allocate(zCell % ioinfo)
-     zCell % ioinfo % fieldName = 'zCell'
-     zCell % ioinfo % start(1) = readCellStart
-     zCell % ioinfo % count(1) = nReadCells
-     allocate(zCell % array(nReadCells))
-     call MPAS_io_inq_var(inputHandle, 'zCell', ierr=ierr)
-     call MPAS_io_set_var_indices(inputHandle, 'zCell', readIndices, ierr=ierr)
-     call mpas_io_get_var(inputHandle, 'zCell', zCell % array, ierr)
-     zCell % dimSizes(1) = nReadCells
-     zCell % block =&gt; readingBlock
-     zCell % sendList =&gt; indexToCellID % sendList
-     zCell % recvList =&gt; indexToCellID % recvList
-     zCell % copyList =&gt; indexToCellID % copyList
-     nullify(zCell % next)
-#endif
-#endif
-
      ! Number of cell/edges/vertices adjacent to each cell
      allocate(nEdgesOnCell)
      allocate(nEdgesOnCell % ioinfo)
@@ -852,61 +661,6 @@
      call mpas_dmpar_init_mulithalo_exchange_list(indexToEdgeID % copyList, nHalos+1)
      nullify(indexToEdgeID % next)
    
-#ifdef HAVE_ZOLTAN
-#ifdef _MPI 
-     ! Edge x-coordinates (in 3d Cartesian space)
-     allocate(xEdge)
-     allocate(xEdge % ioinfo)
-     xEdge % ioinfo % fieldName = 'xEdge'
-     xEdge % ioinfo % start(1) = readEdgeStart
-     xEdge % ioinfo % count(1) = nReadEdges
-     allocate(xEdge % array(nReadEdges))
-     call MPAS_io_inq_var(inputHandle, 'xEdge', ierr=ierr)
-     call MPAS_io_set_var_indices(inputHandle, 'xEdge', readIndices, ierr=ierr)
-     call mpas_io_get_var(inputHandle, 'xEdge', xEdge % array, ierr)
-     xEdge % dimSizes(1) = nReadEdges
-     xEdge % block =&gt; readingBlock
-     xEdge % sendList =&gt; indexToEdgeID % sendList
-     xEdge % recvList =&gt; indexToEdgeID % recvList
-     xEdge % copyList =&gt; indexToEdgeID % copyList
-     nullify(xEdge % next)
-
-     ! Edge y-coordinates (in 3d Cartesian space)
-     allocate(yEdge)
-     allocate(yEdge % ioinfo)
-     yEdge % ioinfo % fieldName = 'yEdge'
-     yEdge % ioinfo % start(1) = readEdgeStart
-     yEdge % ioinfo % count(1) = nReadEdges
-     allocate(yEdge % array(nReadEdges))
-     call MPAS_io_inq_var(inputHandle, 'yEdge', ierr=ierr)
-     call MPAS_io_set_var_indices(inputHandle, 'yEdge', readIndices, ierr=ierr)
-     call mpas_io_get_var(inputHandle, 'yEdge', yEdge % array, ierr)
-     yEdge % dimSizes(1) = nReadEdges
-     yEdge % block =&gt; readingBlock
-     yEdge % sendList =&gt; indexToEdgeID % sendList
-     yEdge % recvList =&gt; indexToEdgeID % recvList
-     yEdge % copyList =&gt; indexToEdgeID % copyList
-     nullify(yEdge % next)
-
-     ! Edge z-coordinates (in 3d Cartesian space)
-     allocate(zEdge)
-     allocate(zEdge % ioinfo)
-     zEdge % ioinfo % fieldName = 'zEdge'
-     zEdge % ioinfo % start(1) = readEdgeStart
-     zEdge % ioinfo % count(1) = nReadEdges
-     allocate(zEdge % array(nReadEdges))
-     call MPAS_io_inq_var(inputHandle, 'zEdge', ierr=ierr)
-     call MPAS_io_set_var_indices(inputHandle, 'zEdge', readIndices, ierr=ierr)
-     call mpas_io_get_var(inputHandle, 'zEdge', zEdge % array, ierr)
-     zEdge % dimSizes(1) = nReadEdges
-     zEdge % block =&gt; readingBlock
-     zEdge % sendList =&gt; indexToEdgeID % sendList
-     zEdge % recvList =&gt; indexToEdgeID % recvList
-     zEdge % copyList =&gt; indexToEdgeID % copyList
-     nullify(zEdge % next)
-#endif
-#endif
-
    
      ! Global indices of cells adjacent to each edge
      !    used for determining which edges are owned by a block, where 
@@ -972,61 +726,6 @@
      call mpas_dmpar_init_mulithalo_exchange_list(indexToVertexID % copyList, nHalos+1)
      nullify(indexToVertexID % next)
    
-#ifdef HAVE_ZOLTAN
-#ifdef _MPI
-     ! Vertex x-coordinates (in 3d Cartesian space)
-     allocate(xVertex)
-     allocate(xVertex % ioinfo)
-     xVertex % ioinfo % fieldName = 'xVertex'
-     xVertex % ioinfo % start(1) = readVertexStart
-     xVertex % ioinfo % count(1) = nReadVertices
-     allocate(xVertex % array(nReadVertices))
-     call MPAS_io_inq_var(inputHandle, 'xVertex', ierr=ierr)
-     call MPAS_io_set_var_indices(inputHandle, 'xVertex', readIndices, ierr=ierr)
-     call mpas_io_get_var(inputHandle, 'xVertex', xVertex % array, ierr)
-     xVertex % dimSizes(1) = nReadVertices
-     xVertex % block =&gt; readingBlock
-     xVertex % sendList =&gt; indexToVertexID % sendList
-     xVertex % recvList =&gt; indexToVertexID % recvList
-     xVertex % copyList =&gt; indexToVertexID % copyList
-     nullify(xVertex % next)
-
-     ! Vertex y-coordinates (in 3d Cartesian space)
-     allocate(yVertex)
-     allocate(yVertex % ioinfo)
-     yVertex % ioinfo % fieldName = 'yVertex'
-     yVertex % ioinfo % start(1) = readVertexStart
-     yVertex % ioinfo % count(1) = nReadVertices
-     allocate(yVertex % array(nReadVertices))
-     call MPAS_io_inq_var(inputHandle, 'yVertex', ierr=ierr)
-     call MPAS_io_set_var_indices(inputHandle, 'yVertex', readIndices, ierr=ierr)
-     call mpas_io_get_var(inputHandle, 'yVertex', yVertex % array, ierr)
-     yVertex % dimSizes(1) = nReadVertices
-     yVertex % block =&gt; readingBlock
-     yVertex % sendList =&gt; indexToVertexID % sendList
-     yVertex % recvList =&gt; indexToVertexID % recvList
-     yVertex % copyList =&gt; indexToVertexID % copyList
-     nullify(yVertex % next)
-
-     ! Vertex z-coordinates (in 3d Cartesian space)
-     allocate(zVertex)
-     allocate(zVertex % ioinfo)
-     zVertex % ioinfo % fieldName = 'zVertex'
-     zVertex % ioinfo % start(1) = readVertexStart
-     zVertex % ioinfo % count(1) = nReadVertices
-     allocate(zVertex % array(nReadVertices))
-     call MPAS_io_inq_var(inputHandle, 'zVertex', ierr=ierr)
-     call MPAS_io_set_var_indices(inputHandle, 'zVertex', readIndices, ierr=ierr)
-     call mpas_io_get_var(inputHandle, 'zVertex', zVertex % array, ierr)
-     zVertex % dimSizes(1) = nReadVertices
-     zVertex % block =&gt; readingBlock
-     zVertex % sendList =&gt; indexToVertexID % sendList
-     zVertex % recvList =&gt; indexToVertexID % recvList
-     zVertex % copyList =&gt; indexToVertexID % copyList
-     nullify(zVertex % next)
-#endif
-#endif
-
    
      ! Global indices of cells adjacent to each vertex
      !    used for determining which vertices are owned by a block, where 

Modified: branches/mpas_cdg_advection/src/framework/mpas_io_output.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_io_output.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_io_output.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -343,6 +343,13 @@
  
       integer :: nferr, ierr
       integer, dimension(10) :: dimlist
+      character (len=StrKIND*4) :: runCmd
+
+      if(len(trim(domain % history)) &gt; 0) then
+          write(runCmd,'(a,a,i0,a,a,a)') trim(domain % history),' mpirun -n ',domain % dminfo % nProcs, ' ', trim(domain % coreName), '_model.exe; '
+      else
+          write(runCmd,'(a,i0,a,a,a)') 'mpirun -n ',domain % dminfo % nProcs, ' ', trim(domain % coreName), '_model.exe; '
+      end if
  
       call MPAS_createStream(output_obj % io_stream, trim(output_obj % filename), MPAS_IO_PNETCDF, MPAS_IO_WRITE, 1, nferr)
 
@@ -354,6 +361,10 @@
          call MPAS_writeStreamAtt(output_obj % io_stream, 'on_a_sphere', 'NO              ', nferr)
       end if
       call MPAS_writeStreamAtt(output_obj % io_stream, 'sphere_radius', mesh % sphere_radius, nferr)
+      call MPAS_writeStreamAtt(output_obj % io_stream, 'model_name', domain % modelName, nferr)
+      call MPAS_writeStreamAtt(output_obj % io_stream, 'core_name', domain % coreName, nferr)
+      call MPAS_writeStreamAtt(output_obj % io_stream, 'model_version', domain % modelVersion, nferr)
+      call MPAS_writeStreamAtt(output_obj % io_stream, 'history', runCmd, nferr)
 
 #include &quot;add_output_atts.inc&quot;
  

Modified: branches/mpas_cdg_advection/src/framework/mpas_kind_types.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_kind_types.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_kind_types.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,3 +1,16 @@
+!***********************************************************************
+!
+!  mpas_kind_types
+!
+!&gt; \brief   MPAS Kind definition module
+!&gt; \author  Michael Duda, Doug Jacobsen
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This module defines the kind types for basic fortran data types within MPAS.
+!
+!-----------------------------------------------------------------------
+
 module mpas_kind_types
 
 #ifdef SINGLE_PRECISION
@@ -10,6 +23,18 @@
 
    contains
 
+!***********************************************************************
+!
+!  routine dummy_kinds
+!
+!&gt; \brief   MPAS Dummy kind routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This is a dummy routine that doesn't do anything.
+!
+!-----------------------------------------------------------------------
    subroutine dummy_kinds()
 
    end subroutine dummy_kinds

Modified: branches/mpas_cdg_advection/src/framework/mpas_sort.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_sort.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_sort.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,3 +1,16 @@
+!***********************************************************************
+!
+!  mpas_sort
+!
+!&gt; \brief   MPAS Sort and search module
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This module provides routines for various sorting methods, in addition to a binary search.
+!
+!-----------------------------------------------------------------------
+
 module mpas_sort
 
    use mpas_kind_types
@@ -11,13 +24,27 @@
 
    contains
 
+!***********************************************************************
+!
+!  recursive routine mpas_mergesort
+!
+!&gt; \brief   MPAS Merge sort
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine recursively calls itself to perform a merge sort on array.
+!
+!-----------------------------------------------------------------------
    recursive subroutine mpas_mergesort(array, d1, n1, n2)!{{{
    
       implicit none
    
       ! Arguments
-      integer, intent(in) :: n1, n2, d1
-      integer, dimension(1:d1,n1:n2), intent(inout) :: array
+      integer, intent(in) :: d1 !&lt; Input: Size of first dimension of array
+      integer, intent(in) :: n1 !&lt; Input: Beginning of second dimension of array
+      integer, intent(in) :: n2 !&lt; Input: Ending of second dimension of array
+      integer, dimension(1:d1,n1:n2), intent(inout) :: array !&lt; Input/Output: Array to be sorted (in-place)
    
       ! Local variables
       integer :: i, j, k
@@ -73,12 +100,24 @@
    
    end subroutine mpas_mergesort!}}}
 
+!***********************************************************************
+!
+!  routine mpas_quicksort_1dint
+!
+!&gt; \brief   MPAS 1D integer quicksort
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine performs a quicksort on a 1D integer array
+!
+!-----------------------------------------------------------------------
    subroutine mpas_quicksort_1dint(nArray, array)!{{{
 
       implicit none
 
-      integer, intent(in) :: nArray
-      integer, dimension(nArray), intent(inout) :: array
+      integer, intent(in) :: nArray !&lt; Input: Array size
+      integer, dimension(nArray), intent(inout) :: array !&lt; Input/Output: Array to be sorted
 
       integer :: i, j, top, l, r, pivot, s
       integer :: pivot_value
@@ -135,12 +174,24 @@
 
    end subroutine mpas_quicksort_1dint!}}}
 
+!***********************************************************************
+!
+!  routine mpas_quicksort_1dreal
+!
+!&gt; \brief   MPAS 1D real quicksort
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine performs a quicksort on a 1D real array
+!
+!-----------------------------------------------------------------------
    subroutine mpas_quicksort_1dreal(nArray, array)!{{{
 
       implicit none
 
-      integer, intent(in) :: nArray
-      real (kind=RKIND), dimension(nArray), intent(inout) :: array
+      integer, intent(in) :: nArray !&lt; Input: Array size
+      real (kind=RKIND), dimension(nArray), intent(inout) :: array !&lt; Input/Output: Array to be sorted
 
       integer :: i, j, top, l, r, pivot, s
       real (kind=RKIND) :: pivot_value
@@ -197,12 +248,24 @@
 
    end subroutine mpas_quicksort_1dreal!}}}
 
+!***********************************************************************
+!
+!  routine mpas_quicksort_2dint
+!
+!&gt; \brief   MPAS 2D integer quicksort
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine performs a quicksort on a 2D integer array
+!
+!-----------------------------------------------------------------------
    subroutine mpas_quicksort_2dint(nArray, array)!{{{
 
       implicit none
 
-      integer, intent(in) :: nArray
-      integer, dimension(2,nArray), intent(inout) :: array
+      integer, intent(in) :: nArray !&lt; Input: Array size
+      integer, dimension(2,nArray), intent(inout) :: array !&lt; Input/Output: Array to be sorted
 
       integer :: i, j, top, l, r, pivot, s
       integer :: pivot_value
@@ -259,12 +322,24 @@
 
    end subroutine mpas_quicksort_2dint!}}}
 
+!***********************************************************************
+!
+!  routine mpas_quicksort_2dreal
+!
+!&gt; \brief   MPAS 2D real quicksort
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine performs a quicksort on a 2D real array
+!
+!-----------------------------------------------------------------------
    subroutine mpas_quicksort_2dreal(nArray, array)!{{{
 
       implicit none
 
-      integer, intent(in) :: nArray
-      real (kind=RKIND), dimension(2,nArray), intent(inout) :: array
+      integer, intent(in) :: nArray !&lt; Input: Array size
+      real (kind=RKIND), dimension(2,nArray), intent(inout) :: array !&lt; Input/Output: Array to be sorted
 
       integer :: i, j, top, l, r, pivot, s
       real (kind=RKIND) :: pivot_value
@@ -321,6 +396,18 @@
 
    end subroutine mpas_quicksort_2dreal!}}}
 
+!***********************************************************************
+!
+!  integer function mpas_binary_search
+!
+!&gt; \brief   MPAS Binary search routine
+!&gt; \author  Michael Duda
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine performs a binary search in array for the key. It either returns the index of the key within array, or n2+1 if the key is not found.
+!
+!-----------------------------------------------------------------------
    integer function mpas_binary_search(array, d1, n1, n2, key)!{{{
 
       implicit none

Modified: branches/mpas_cdg_advection/src/framework/mpas_timer.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_timer.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_timer.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,3 +1,17 @@
+!***********************************************************************
+!
+!  mpas_timer
+!
+!&gt; \brief   MPAS Timer module
+!&gt; \author  Michael Duda, Doug Jacobsen
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This module provides developers with internal timer routines. These can be
+!&gt; use to profile various parts of code within MPAS. Calls to TAU happen in this module as well
+!&gt; to provide more detailed profiling.
+!
+!-----------------------------------------------------------------------
       module mpas_timer
 
         use mpas_kind_types
@@ -32,6 +46,19 @@
 
         contains
 
+!***********************************************************************
+!
+!  routine mpas_timer_start
+!
+!&gt; \brief   MPAS Timer start routine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine starts a timer. By default, timer_name is searched for in the linked list of timers.
+!&gt; If timer_ptr is provided, the search doesn't happen and the pointer to the timer is used (or allocated if not created yet).
+!
+!-----------------------------------------------------------------------
         subroutine mpas_timer_start(timer_name, clear_timer, timer_ptr)!{{{
 #         ifdef _MPI
           use mpi
@@ -161,6 +188,19 @@
           
         end subroutine mpas_timer_start!}}}
        
+!***********************************************************************
+!
+!  routine mpas_timer_stop
+!
+!&gt; \brief   MPAS Timer stop routine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine stops a timer. By default, timer_name is searched for in the linked list of timers.
+!&gt; If timer_ptr is provided, the search doesn't happen and the pointer to the timer is used.
+!
+!-----------------------------------------------------------------------
         subroutine mpas_timer_stop(timer_name, timer_ptr)!{{{
 #         ifdef _MPI
           use mpi
@@ -238,9 +278,23 @@
 
         end subroutine mpas_timer_stop!}}}
 
+!***********************************************************************
+!
+!  recursive routine mpas_timer_write
+!
+!&gt; \brief   MPAS Timer write routine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine writes all timer output to stdout. It recursively calls 
+!&gt; itself until all timers have been written out. Prior to writing timers,
+!&gt; this routine calls mpas_timer_sync.
+!
+!-----------------------------------------------------------------------
         recursive subroutine mpas_timer_write(timer_ptr, total_ptr)!{{{
-          type (timer_node), pointer, optional :: timer_ptr
-          type (timer_node), pointer, optional :: total_ptr
+          type (timer_node), pointer, optional :: timer_ptr !&lt; Input - Optional: Pointer to a specific timer to write out.
+          type (timer_node), pointer, optional :: total_ptr !&lt; Input - Optional: Pointer to the total_time timer.
           character (len=StrKIND) :: tname
 
           logical :: total_found, string_equals
@@ -312,8 +366,20 @@
 
         end subroutine mpas_timer_write!}}}
 
+!***********************************************************************
+!
+!  routine mpas_timer_init
+!
+!&gt; \brief   MPAS Timer init routine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine initializes the mpas_timer setup. It needs to have access to the dminfo object in order to sync timers.
+!
+!-----------------------------------------------------------------------
         subroutine mpas_timer_init(domain)!{{{
-          type (domain_type), intent(in), optional :: domain
+          type (domain_type), intent(in), optional :: domain !&lt; Input - Optional: Domain structure
 
           if( present(domain) ) then
               domain_info =&gt; domain % dminfo
@@ -323,6 +389,19 @@
 
         end subroutine mpas_timer_init!}}}
 
+!***********************************************************************
+!
+!  routine mpas_timer_sync
+!
+!&gt; \brief   MPAS Timer sync routine
+!&gt; \author  Doug Jacobsen
+!&gt; \date    03/27/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine synchronizes timers across all processors in order to better represent
+!&gt; the entire run domain with the timer output.
+!
+!-----------------------------------------------------------------------
         subroutine mpas_timer_sync()!{{{
           use mpas_dmpar
 

Deleted: branches/mpas_cdg_advection/src/framework/mpas_zoltan_interface.F
===================================================================
--- branches/mpas_cdg_advection/src/framework/mpas_zoltan_interface.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/mpas_zoltan_interface.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,581 +0,0 @@
-module mpas_zoltan_interface
-   use zoltan
-
-   implicit none
-
-   include 'mpif.h'
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! Data for reordering cells
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   integer :: numCells
-   integer, dimension(:), pointer :: cellIDs
-   integer :: geomDim
-   real (kind=RKIND), dimension(:), pointer :: cellCoordX, cellCoordY, cellCoordZ
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! Data for reordering edges
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   integer :: numEdges
-   integer, dimension(:), pointer :: edgeIDs
-   real (kind=RKIND), dimension(:), pointer :: edgeCoordX, edgeCoordY, edgeCoordZ  
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! Data for reordering vertices
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   integer :: numVerts
-   integer, dimension(:), pointer :: vertIDs
-   real (kind=RKIND), dimension(:), pointer :: vertCoordX, vertCoordY, vertCoordZ  
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-
-   contains
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! Perhaps not necessary, but implemented in case it helps
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   subroutine mpas_zoltan_start()  
-
-      integer(Zoltan_INT) :: error
-      real(Zoltan_FLOAT) :: version
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! Body of subroutine
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      error = Zoltan_Initialize(version)
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      
-   end subroutine
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   subroutine mpas_zoltan_order_loc_hsfc_cells(in_numcells,in_cellIDs,in_geomDim,in_cellX, &amp;
-                                       in_cellY, in_cellZ)
-      implicit none
-
-      integer :: in_numcells
-      integer, dimension(:), pointer :: in_cellIDs
-      integer :: in_geomDim
-      real (kind=RKIND), dimension(:), pointer :: in_cellX, in_cellY, in_cellZ
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! local variables
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      type(Zoltan_Struct), pointer :: zz_obj
-      integer(ZOLTAN_INT) :: ierr
-
-      integer :: numGidEntries, i
-      integer(ZOLTAN_INT), allocatable :: global_ids(:), permIndices(:),permGIDs(:)
-      real(kind=RKIND), allocatable :: permXs(:),permYs(:),permZs(:)
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! Body of subroutine
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      numCells = in_numcells
-      cellIDs =&gt; in_cellIDs
-      geomDim = in_geomDim
-      cellCoordX =&gt; in_cellX
-      cellCoordY =&gt; in_cellY
-      cellCoordZ =&gt; in_cellZ
-
-      nullify(zz_obj)
-      zz_obj =&gt; Zoltan_Create(MPI_COMM_SELF)
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! General Zoltan Parameters
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      ierr = Zoltan_Set_Param(zz_obj, &quot;ORDER_METHOD&quot;, &quot;LOCAL_HSFC&quot;)
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! register query functions
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      ierr = Zoltan_Set_Fn(zz_obj, ZOLTAN_NUM_OBJ_FN_TYPE,zqfNumCells)
-      ierr = Zoltan_Set_Fn(zz_obj, ZOLTAN_OBJ_LIST_FN_TYPE,zqfGetCells)
-      ierr = Zoltan_Set_Fn(zz_obj, ZOLTAN_NUM_GEOM_FN_TYPE,zqfGeomDim)
-      ierr =  Zoltan_Set_Fn(zz_obj, ZOLTAN_GEOM_FN_TYPE, zqfGetCellGeom)
-
-      numGidEntries=1
-
-      allocate(global_ids(numCells))
-      allocate(permIndices(numCells))
-      allocate(permGIDs(numCells))
-      allocate(permXs(numCells))
-      allocate(permYs(numCells))
-      allocate(permZs(numCells))
-
-      !! MMW: There might be a way to use cellIDs directly
-      do i=1,numCells
-        global_ids(i) = cellIDs(i)
-      end do
-
-      ierr = Zoltan_Order(zz_obj, numGidEntries, numCells, global_ids, permIndices);
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! This is necessary for now until we fix a small bug in Zoltan_Order
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-      do i=1,numCells
-        permGIDs(i) = global_ids(permIndices(i)+1)
-        permXs(i) = cellCoordX(permIndices(i)+1)
-        permYs(i) = cellCoordY(permIndices(i)+1)
-        permZs(i) = cellCoordZ(permIndices(i)+1)
-      end do
-
-      !!do i=1,numCells
-      !!   write(*,*) global_ids(i), permGIDs(i)
-      !!end do
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! Actually change the ordering of the cells
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-      do i=1,numCells
-        cellIDs(i) = permGIDs(i)
-        cellCoordX(i) = permXs(i)
-        cellCoordY(i) = permYs(i)
-        cellCoordZ(i) = permZs(i)
-      end do
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      deallocate(global_ids)
-      deallocate(permIndices)
-      deallocate(permGIDs)
-      deallocate(permXs)
-      deallocate(permYs)
-      deallocate(permZs)
-
-      call Zoltan_Destroy(zz_obj)
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   end subroutine mpas_zoltan_order_loc_hsfc_cells
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! zoltan query function:
-   !!    Returns number of cells
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   integer function zqfNumCells(data, ierr)
-
-      ! Local declarations
-      integer(ZOLTAN_INT), intent(in) :: data(*)
-      integer(ZOLTAN_INT), intent(out) :: ierr
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      zqfNumCells = numCells
-      ierr = ZOLTAN_OK
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   end function zqfNumCells
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! zoltan query function: 
-   !!    Returns lists of Cell IDs
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   subroutine mpas_zqf_get_cells (data, num_gid_entries, num_lid_entries, global_ids, &amp;
-                           local_ids, wgt_dim, obj_wgts, ierr)
-     integer(ZOLTAN_INT), intent(in) :: data(*)
-     integer(ZOLTAN_INT), intent(in) :: num_gid_entries, num_lid_entries
-     integer(ZOLTAN_INT), intent(out) :: global_ids(*), local_ids(*)
-     integer(ZOLTAN_INT), intent(in) :: wgt_dim 
-     real(ZOLTAN_FLOAT), intent(out) :: obj_wgts(*)
-     integer(ZOLTAN_INT), intent(out) :: ierr
-
-     ! local declarations
-     integer :: i
-
-     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-     do i= 1, numCells
-       global_ids(i) = cellIDs(i)
-       local_ids(i) = i
-     end do
-
-     ierr = ZOLTAN_OK
-     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   end subroutine mpas_zqf_get_cells
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! Zoltan Query Function:
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   integer function zqfGeomDim(data, ierr)
-      !use zoltan
-      implicit none
-      integer(ZOLTAN_INT), intent(in) :: data(*)
-      integer(ZOLTAN_INT) :: ierr
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      zqfGeomDim = geomDim
-      ierr = ZOLTAN_OK
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   end function zqfGeomDim
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! Zoltan Query Function:
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   subroutine mpas_zqf_get_cell_geom(data, num_gid_entries, num_lid_entries, global_id, &amp;
-                             local_id, geom_vec, ierr)
-      !use zoltan
-      implicit none
-
-      integer(ZOLTAN_INT), intent(in) :: data(*)
-      integer(ZOLTAN_INT), intent(in) :: num_gid_entries, num_lid_entries
-      integer(ZOLTAN_INT), intent(in) :: global_id, local_id
-      real(ZOLTAN_DOUBLE), intent(out) :: geom_vec(*)
-      integer(ZOLTAN_INT), intent(out) :: ierr
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! Assuming geom_dim is 3
-      geom_vec(1) = cellCoordX(local_id)
-      geom_vec(2) = cellCoordY(local_id)
-      geom_vec(3) = cellCoordZ(local_id)
-
-      ierr = ZOLTAN_OK
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   end subroutine mpas_zqf_get_cell_geom
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! The ordering functions should perhaps be refactored so that there
-   !! are not separate functions for cells, edges, and vertices
-   !! Not sure if this is worth it with the additional conditionals that would 
-   !! be required. 
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   subroutine mpas_zoltan_order_loc_hsfc_edges(in_numedges,in_edgeIDs,in_geomDim,in_edgeX, &amp;
-                                       in_edgeY, in_edgeZ)
-      implicit none
-
-      integer :: in_numedges
-      integer, dimension(:), pointer :: in_edgeIDs
-      integer :: in_geomDim
-      real (kind=RKIND), dimension(:), pointer :: in_edgeX, in_edgeY, in_edgeZ
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! local variables
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      type(Zoltan_Struct), pointer :: zz_obj
-      integer(ZOLTAN_INT) :: ierr
-
-      integer :: numGidEntries, i
-      integer(ZOLTAN_INT), allocatable :: global_ids(:), permIndices(:),permGIDs(:)
-      real(kind=RKIND), allocatable :: permXs(:),permYs(:),permZs(:)
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! Body of subroutine
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      numEdges = in_numedges
-      edgeIDs =&gt; in_edgeIDs
-      geomDim = in_geomDim
-      edgeCoordX =&gt; in_edgeX
-      edgeCoordY =&gt; in_edgeY
-      edgeCoordZ =&gt; in_edgeZ
-
-      nullify(zz_obj)
-      zz_obj =&gt; Zoltan_Create(MPI_COMM_SELF)
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! General Zoltan Parameters
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      ierr = Zoltan_Set_Param(zz_obj, &quot;ORDER_METHOD&quot;, &quot;LOCAL_HSFC&quot;)
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! register query functions
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      ierr = Zoltan_Set_Fn(zz_obj, ZOLTAN_NUM_OBJ_FN_TYPE,zqfNumEdges)
-      ierr = Zoltan_Set_Fn(zz_obj, ZOLTAN_OBJ_LIST_FN_TYPE,zqfGetEdges)
-      ierr = Zoltan_Set_Fn(zz_obj, ZOLTAN_NUM_GEOM_FN_TYPE,zqfGeomDim)
-      ierr =  Zoltan_Set_Fn(zz_obj, ZOLTAN_GEOM_FN_TYPE, zqfGetEdgeGeom)
-
-      numGidEntries=1
-
-      allocate(global_ids(numEdges))
-      allocate(permIndices(numEdges))
-      allocate(permGIDs(numEdges))
-      allocate(permXs(numEdges))
-      allocate(permYs(numEdges))
-      allocate(permZs(numEdges))
-
-      !! MMW: There might be a way to use edgeIDs directly
-      do i=1,numEdges
-        global_ids(i) = edgeIDs(i)
-      end do
-
-      ierr = Zoltan_Order(zz_obj, numGidEntries, numEdges, global_ids, permIndices);
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! This is necessary for now until we fix a small bug in Zoltan_Order
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-      do i=1,numEdges
-        permGIDs(i) = global_ids(permIndices(i)+1)
-        permXs(i) = edgeCoordX(permIndices(i)+1)
-        permYs(i) = edgeCoordY(permIndices(i)+1)
-        permZs(i) = edgeCoordZ(permIndices(i)+1)
-      end do
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! Actually change the ordering of the edges
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-      do i=1,numEdges
-        edgeIDs(i) = permGIDs(i)
-        edgeCoordX(i) = permXs(i)
-        edgeCoordY(i) = permYs(i)
-        edgeCoordZ(i) = permZs(i)
-      end do
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      deallocate(global_ids)
-      deallocate(permIndices)
-      deallocate(permGIDs)
-      deallocate(permXs)
-      deallocate(permYs)
-      deallocate(permZs)
-
-      call Zoltan_Destroy(zz_obj)
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   end subroutine mpas_zoltan_order_loc_hsfc_edges
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! zoltan query function:
-   !!    Returns number of edges
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   integer function zqfNumEdges(data, ierr)
-      ! Local declarations
-      integer(ZOLTAN_INT), intent(in) :: data(*)
-      integer(ZOLTAN_INT), intent(out) :: ierr
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      zqfNumEdges = numEdges
-      ierr = ZOLTAN_OK
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   end function zqfNumEdges
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! zoltan query function: 
-   !!    Returns lists of Edge IDs
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   subroutine mpas_zqf_get_edges (data, num_gid_entries, num_lid_entries, global_ids, &amp;
-                           local_ids, wgt_dim, obj_wgts, ierr)
-     integer(ZOLTAN_INT), intent(in) :: data(*)
-     integer(ZOLTAN_INT), intent(in) :: num_gid_entries, num_lid_entries
-     integer(ZOLTAN_INT), intent(out) :: global_ids(*), local_ids(*)
-     integer(ZOLTAN_INT), intent(in) :: wgt_dim 
-     real(ZOLTAN_FLOAT), intent(out) :: obj_wgts(*)
-     integer(ZOLTAN_INT), intent(out) :: ierr
-
-     ! local declarations
-     integer :: i
-
-     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-     do i= 1, numEdges
-       global_ids(i) = edgeIDs(i)
-       local_ids(i) = i
-     end do
-
-     ierr = ZOLTAN_OK
-     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   end subroutine mpas_zqf_get_edges
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! Zoltan Query Function:
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   subroutine mpas_zqf_get_edge_geom(data, num_gid_entries, num_lid_entries, global_id, &amp;
-                             local_id, geom_vec, ierr)
-      !use zoltan
-      implicit none
-
-      integer(ZOLTAN_INT), intent(in) :: data(*)
-      integer(ZOLTAN_INT), intent(in) :: num_gid_entries, num_lid_entries
-      integer(ZOLTAN_INT), intent(in) :: global_id, local_id
-      real(ZOLTAN_DOUBLE), intent(out) :: geom_vec(*)
-      integer(ZOLTAN_INT), intent(out) :: ierr
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! Assuming geom_dim is 3
-      geom_vec(1) = edgeCoordX(local_id)
-      geom_vec(2) = edgeCoordY(local_id)
-      geom_vec(3) = edgeCoordZ(local_id)
-
-      ierr = ZOLTAN_OK
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   end subroutine mpas_zqf_get_edge_geom
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   subroutine mpas_zoltan_order_loc_hsfc_verts(in_numverts,in_vertIDs,in_geomDim,in_vertX, &amp;
-                                       in_vertY, in_vertZ)
-      implicit none
-
-      integer :: in_numverts
-      integer, dimension(:), pointer :: in_vertIDs
-      integer :: in_geomDim
-      real (kind=RKIND), dimension(:), pointer :: in_vertX, in_vertY, in_vertZ
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! local variables
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      type(Zoltan_Struct), pointer :: zz_obj
-      integer(ZOLTAN_INT) :: ierr
-
-      integer :: numGidEntries, i
-      integer(ZOLTAN_INT), allocatable :: global_ids(:), permIndices(:),permGIDs(:)
-      real(kind=RKIND), allocatable :: permXs(:),permYs(:),permZs(:)
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! Body of subroutine
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      numVerts = in_numverts
-      vertIDs =&gt; in_vertIDs
-      geomDim = in_geomDim
-      vertCoordX =&gt; in_vertX
-      vertCoordY =&gt; in_vertY
-      vertCoordZ =&gt; in_vertZ
-
-      nullify(zz_obj)
-      zz_obj =&gt; Zoltan_Create(MPI_COMM_SELF)
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! General Zoltan Parameters
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      ierr = Zoltan_Set_Param(zz_obj, &quot;ORDER_METHOD&quot;, &quot;LOCAL_HSFC&quot;)
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! register query functions
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      ierr = Zoltan_Set_Fn(zz_obj, ZOLTAN_NUM_OBJ_FN_TYPE,zqfNumVerts)
-      ierr = Zoltan_Set_Fn(zz_obj, ZOLTAN_OBJ_LIST_FN_TYPE,zqfGetVerts)
-      ierr = Zoltan_Set_Fn(zz_obj, ZOLTAN_NUM_GEOM_FN_TYPE,zqfGeomDim)
-      ierr =  Zoltan_Set_Fn(zz_obj, ZOLTAN_GEOM_FN_TYPE, zqfGetVertGeom)
-
-      numGidEntries=1
-
-      allocate(global_ids(numVerts))
-      allocate(permIndices(numVerts))
-      allocate(permGIDs(numVerts))
-      allocate(permXs(numVerts))
-      allocate(permYs(numVerts))
-      allocate(permZs(numVerts))
-
-      !! MMW: There might be a way to use vertIDs directly
-      do i=1,numVerts
-        global_ids(i) = vertIDs(i)
-      end do
-
-      ierr = Zoltan_Order(zz_obj, numGidEntries, numVerts, global_ids, permIndices);
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! This is necessary for now until we fix a small bug in Zoltan_Order
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-      do i=1,numVerts
-        permGIDs(i) = global_ids(permIndices(i)+1)
-        permXs(i) = vertCoordX(permIndices(i)+1)
-        permYs(i) = vertCoordY(permIndices(i)+1)
-        permZs(i) = vertCoordZ(permIndices(i)+1)
-      end do
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! Actually change the ordering of the verts
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-      do i=1,numVerts
-        vertIDs(i) = permGIDs(i)
-        vertCoordX(i) = permXs(i)
-        vertCoordY(i) = permYs(i)
-        vertCoordZ(i) = permZs(i)
-      end do
-      !!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      deallocate(global_ids)
-      deallocate(permIndices)
-      deallocate(permGIDs)
-      deallocate(permXs)
-      deallocate(permYs)
-      deallocate(permZs)
-
-      call Zoltan_Destroy(zz_obj)
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   end subroutine mpas_zoltan_order_loc_hsfc_verts
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! zoltan query function:
-   !!    Returns number of verts
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   integer function zqfNumVerts(data, ierr)
-
-      ! Local declarations
-      integer(ZOLTAN_INT), intent(in) :: data(*)
-      integer(ZOLTAN_INT), intent(out) :: ierr
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      zqfNumVerts = numVerts
-      ierr = ZOLTAN_OK
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   end function zqfNumVerts
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! zoltan query function: 
-   !!    Returns lists of Vert IDs
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   subroutine mpas_zqf_get_verts (data, num_gid_entries, num_lid_entries, global_ids, &amp;
-                           local_ids, wgt_dim, obj_wgts, ierr)
-
-     integer(ZOLTAN_INT), intent(in) :: data(*)
-     integer(ZOLTAN_INT), intent(in) :: num_gid_entries, num_lid_entries
-     integer(ZOLTAN_INT), intent(out) :: global_ids(*), local_ids(*)
-     integer(ZOLTAN_INT), intent(in) :: wgt_dim 
-     real(ZOLTAN_FLOAT), intent(out) :: obj_wgts(*)
-     integer(ZOLTAN_INT), intent(out) :: ierr
-
-     ! local declarations
-     integer :: i
-
-     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-     do i= 1, numVerts
-       global_ids(i) = vertIDs(i)
-       local_ids(i) = i
-     end do
-
-     ierr = ZOLTAN_OK
-     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   end subroutine mpas_zqf_get_verts
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !! Zoltan Query Function:
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   subroutine mpas_zqf_get_vert_geom(data, num_gid_entries, num_lid_entries, global_id, &amp;
-                             local_id, geom_vec, ierr)
-      !use zoltan
-      implicit none
-
-      integer(ZOLTAN_INT), intent(in) :: data(*)
-      integer(ZOLTAN_INT), intent(in) :: num_gid_entries, num_lid_entries
-      integer(ZOLTAN_INT), intent(in) :: global_id, local_id
-      real(ZOLTAN_DOUBLE), intent(out) :: geom_vec(*)
-      integer(ZOLTAN_INT), intent(out) :: ierr
-
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      !! Assuming geom_dim is 3
-      geom_vec(1) = vertCoordX(local_id)
-      geom_vec(2) = vertCoordY(local_id)
-      geom_vec(3) = vertCoordZ(local_id)
-
-      ierr = ZOLTAN_OK
-      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   end subroutine mpas_zqf_get_vert_geom
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-
-
-
-end module mpas_zoltan_interface

Modified: branches/mpas_cdg_advection/src/framework/streams.c
===================================================================
--- branches/mpas_cdg_advection/src/framework/streams.c        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/framework/streams.c        2013-04-22 01:31:32 UTC (rev 2783)
@@ -34,14 +34,14 @@
                    return;
            }
    } else {
-           sprintf(fname, &quot;/dev/null&quot;, *id);
+           sprintf(fname, &quot;/dev/null&quot;);
            fd_err = open(fname,O_CREAT|O_WRONLY|O_TRUNC,0644);
            if (dup2(fd_err, 2) &lt; 0) {
                    printf(&quot;Error duplicating STDERR</font>
<font color="red">&quot;);
                    return;
            }
 
-           sprintf(fname, &quot;/dev/null&quot;, *id);
+           sprintf(fname, &quot;/dev/null&quot;);
            fd_out = open(fname,O_CREAT|O_WRONLY|O_TRUNC,0644);
            if (dup2(fd_out, 1) &lt; 0) {
                    printf(&quot;Error duplicating STDOUT</font>
<font color="gray">&quot;);

Modified: branches/mpas_cdg_advection/src/operators/mpas_rbf_interpolation.F
===================================================================
--- branches/mpas_cdg_advection/src/operators/mpas_rbf_interpolation.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/operators/mpas_rbf_interpolation.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,3 +1,16 @@
+!***********************************************************************
+!
+!  mpas_rbf_interpolation
+!
+!&gt; \brief   MPAS Radial basis function interpolation module
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This module provides routines for performing interpolation with radial basis functions.
+!&gt; It performs interpolation of scalar and vector functions in 2 and 3 dimensions.
+!
+!-----------------------------------------------------------------------
 module mpas_rbf_interpolation
    use mpas_dmpar
    use mpas_grid_types
@@ -6,11 +19,6 @@
    private
    save
 
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-! Purpose: perform interpolation of scalar and vector functions in 2D
-!   and 3D using Radial Basis Functions (RBFs).
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-
    ! Initialize the geometry that will be useful from interpolation
   public :: mpas_rbf_interp_initialize
 
@@ -93,26 +101,32 @@
 
   contains
 
-  subroutine mpas_rbf_interp_initialize(grid)
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: compute geometric fields that will be potentially useful for calling
-  !          the interpolation routines
-  !
-  ! Input: the grid
-  !
-  ! Output: 
-  !  edgeNormalVectors - the unit vector at the center of each edge tangent to the sphere
-  !  cellTangentPlane - 2 orthogonal unit vectors in the tangent plane of each cell
-  !                     The first unit vector is chosen to point toward the center of the first
-  !                     edge on the cell.
-  !  localVerticalUnitVectors - the unit normal vector of the tangent plane at the center 
-  !                             of each cell
-  !       
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
 
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_initialize
+!
+!&gt; \brief   MPAS RBF interpolation initialization routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine computes geometric fields that will be potentially useful for calling
+!&gt; the interpolation routines.
+!&gt; Input: the grid
+!&gt; Output:
+!&gt;      edgeNormalVectors - the unit vector at the center of each edge tangent to the sphere
+!&gt;      cellTangentPlane - 2 orthogonal unit vectors in the tangent plane of each cell
+!&gt;                         The first unit vector is chosen to point toward the center of the first
+!&gt;                         edge on the cell.
+!&gt;      localVerticalUnitVectors - the unit normal vector of the tangent plane at the center 
+!&gt;                         of each cell
+!-----------------------------------------------------------------------
+  subroutine mpas_rbf_interp_initialize(grid)!{{{
+
     implicit none
 
-    type (mesh_type), intent(inout) :: grid 
+    type (mesh_type), intent(inout) :: grid  !&lt; Input/Output: Grid information
 
     integer :: nCells, nEdges
     integer, dimension(:,:), pointer :: cellsOnEdge, edgesOnCell
@@ -185,34 +199,41 @@
       cellTangentPlane(:,2,iCell) = yHatPlane
     end do
 
-  end subroutine mpas_rbf_interp_initialize
+  end subroutine mpas_rbf_interp_initialize!}}}
 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: Compute interpolation coefficients in 2D that can be used to
-  !  reconstruct a given scalar function at varying locations. This is useful
-  !  for finding the location on the the RBF reconstruction of a function
-  !  (e.g., a height field) that minimizes the distance to a point in 3D space.
-  !  The reconstruction is performed with basis functions that are RBFs and constant 
-  ! Input:
-  !  pointCount - the number of &quot;source&quot; points and functionValues supplied
-  !  coeffCount - the size of coefficients, must be at least pointCount + 1
-  !  points - the location of the &quot;source&quot; points in the 2D space where the values of
-  !    the function are known
-  !  fieldValues - the values of the function of interest at the points
-  !  alpha - a constant that give the characteristic length scale of the RBFs,
-  !    should be on the order of the distance between points
-  ! Output:
-  !  coefficients - the coefficients needed to perform interpolation of the funciton
-  !    at destination points yet to be specified
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  subroutine mpas_rbf_interp_loc_2D_sca_const_comp_coeffs(pointCount, coeffCount, &amp;
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_loc_2D_sca_const_comp_coeffs
+!
+!&gt; \brief   MPAS 2D scalar constant interpolation coefficient routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes interpolation coefficients in 2D that can be used to reconstruct a given scalar function at varying locations.
+!&gt;  This is useful for finding the location on the RBF reconstruction of a function (e.g. a heigh field) that minimizes the distantce
+!&gt;  to a point in 3D space. The reconstruction is performed with basis functions that are RBFs and constant.
+!&gt;  Input:
+!&gt;   pointCount - the number of &quot;source&quot; points and functionValues supplied
+!&gt;   coeffCount - the size of coefficients, must be at least pointCount + 1
+!&gt;   points - the location of the &quot;source&quot; points in the 2D space where the values of
+!&gt;     the function are known
+!&gt;   fieldValues - the values of the function of interest at the points
+!&gt;   alpha - a constant that give the characteristic length scale of the RBFs,
+!&gt;     should be on the order of the distance between points
+!&gt;  Output:
+!&gt;   coefficients - the coefficients needed to perform interpolation of the funciton
+!&gt;     at destination points yet to be specified       
+!-----------------------------------------------------------------------
+  subroutine mpas_rbf_interp_loc_2D_sca_const_comp_coeffs(pointCount, coeffCount, &amp;!{{{
     points, fieldValues, alpha, coefficients)
  
-    integer, intent(in) :: pointCount, coeffCount
-    real(kind=RKIND), dimension(pointCount,2), intent(in) :: points
-    real(kind=RKIND), dimension(pointCount), intent(in) :: fieldValues
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(coeffCount), intent(out) :: coefficients
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    integer, intent(in) :: coeffCount !&lt; Input: Number of coefficients
+    real(kind=RKIND), dimension(pointCount,2), intent(in) :: points !&lt; Input: List of points
+    real(kind=RKIND), dimension(pointCount), intent(in) :: fieldValues !&lt; Input: Value at points
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Charachteristic length scale of RBFs
+    real(kind=RKIND), dimension(coeffCount), intent(out) :: coefficients !&lt; Output: List of coefficients
 
     integer :: i, j, matrixSize
     real(kind=RKIND), dimension(pointCount+1,pointCount+1) :: matrix
@@ -242,35 +263,44 @@
     call mpas_legs(matrix(1:matrixSize,1:matrixSize), matrixSize, rhs(1:matrixSize), &amp;
       coefficients(1:matrixSize), pivotIndices(1:matrixSize))
 
-  end subroutine mpas_rbf_interp_loc_2D_sca_const_comp_coeffs
+  end subroutine mpas_rbf_interp_loc_2D_sca_const_comp_coeffs!}}}
 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: Compute interpolation coefficients in 2D that can be used to
-  !  reconstruct a given scalar function at varying locations. This is useful
-  !  for finding the location on the the RBF reconstruction of a function
-  !  (e.g., a height field) that minimizes the distance to a point in 3D space.
-  !  The reconstruction is performed with basis functions that are RBFs plus constant
-  !  and linear 
-  ! Input:
-  !  pointCount - the number of &quot;source&quot; points and functionValues supplied
-  !  coeffCount - the size of coefficients, must be at least pointCount + 3
-  !  points - the location of the &quot;source&quot; points in the 2D space where the values of
-  !    the function are known
-  !  fieldValues - the values of the function of interest at the points
-  !  alpha - a constant that give the characteristic length scale of the RBFs,
-  !    should be on the order of the distance between points
-  ! Output:
-  !  coefficients - the coefficients needed to perform interpolation of the funciton
-  !    at destination points yet to be specified
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  subroutine mpas_rbf_interp_loc_2D_sca_lin_comp_coeffs(pointCount, coeffCount, &amp;
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_loc_2D_sca_lin_comp_coeffs
+!
+!&gt; \brief   MPAS 2D scalar linear interpolation coefficient routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine computes interpolation coefficients in 2D that can be used to
+!&gt;  reconstruct a given scalar function at varying locations. This is useful
+!&gt;  for finding the location on the the RBF reconstruction of a function
+!&gt;  (e.g., a height field) that minimizes the distance to a point in 3D space.
+!&gt;  The reconstruction is performed with basis functions that are RBFs plus constant
+!&gt;  and linear 
+!&gt; Input:
+!&gt;  pointCount - the number of &quot;source&quot; points and functionValues supplied
+!&gt;  coeffCount - the size of coefficients, must be at least pointCount + 3
+!&gt;  points - the location of the &quot;source&quot; points in the 2D space where the values of
+!&gt;    the function are known
+!&gt;  fieldValues - the values of the function of interest at the points
+!&gt;  alpha - a constant that give the characteristic length scale of the RBFs,
+!&gt;    should be on the order of the distance between points
+!&gt; Output:
+!&gt;  coefficients - the coefficients needed to perform interpolation of the funciton
+!&gt;    at destination points yet to be specified
+!-----------------------------------------------------------------------
+  subroutine mpas_rbf_interp_loc_2D_sca_lin_comp_coeffs(pointCount, coeffCount, &amp;!{{{
     points, fieldValues, alpha, coefficients)
  
-    integer, intent(in) :: pointCount, coeffCount
-    real(kind=RKIND), dimension(pointCount,2), intent(in) :: points
-    real(kind=RKIND), dimension(pointCount), intent(in) :: fieldValues
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(coeffCount), intent(out) :: coefficients
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    integer, intent(in) :: coeffCount !&lt; Input: Number of coefficients
+    real(kind=RKIND), dimension(pointCount,2), intent(in) :: points !&lt; Input: List of points
+    real(kind=RKIND), dimension(pointCount), intent(in) :: fieldValues !&lt; Input: List of values at points
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale for RBFs 
+    real(kind=RKIND), dimension(coeffCount), intent(out) :: coefficients !&lt; Output: List of coefficients
 
     integer :: i, j, matrixSize
     real(kind=RKIND), dimension(pointCount+3,pointCount+3) :: matrix
@@ -301,43 +331,53 @@
     call mpas_legs(matrix(1:matrixSize,1:matrixSize), matrixSize, rhs(1:matrixSize), &amp;
       coefficients(1:matrixSize), pivotIndices(1:matrixSize))
 
-  end subroutine mpas_rbf_interp_loc_2D_sca_lin_comp_coeffs
+  end subroutine mpas_rbf_interp_loc_2D_sca_lin_comp_coeffs!}}}
 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: Evalute a scalar function in 2D using coefficients computed in
-  !  rbfInterp_loc_2D_sca_const_compCoeffs.  This 
-  !  function can be called repeatedly with different destination points
-  !  to quickly evaluate the interpolating function using the same
-  !  coefficients.  This is useful for finding the location on the the 
-  !  RBF reconstruction of a function (e.g., a height field) that minimizes
-  !  the distance to a point in 3D space. The reconstruction is performed
-  !  with basis functions that are RBFs and constant 
-  ! Input:
-  !  fieldCount - the number fields to be evaluated.  This is useful for reconstructing,
-  !    for example, the x-, y- and z-components of a vector field at the same
-  !    point in 2D
-  !  coeffCount - the size of coefficients, must be at least pointCount + 1
-  !  pointCount - the number of &quot;source&quot; points and functionValues supplied
-  !  coefficients - the coefficients needed to perform interpolation of the funciton
-  !    at the evaluationPoint
-  !  evaluationPoint - the point in 2D where the function is to be reconstructed
-  !  points - the location of the &quot;source&quot; points in the 2D space where the values of
-  !    the function are known
-  !  alpha - a constant that give the characteristic length scale of the RBFs,
-  !    should be on the order of the distance between points
-  ! Output:
-  !  derivs - the value of the function, the 2 components of its Jacobian and
-  !    the 3 unique components of its Hessian at the evaluationPoint
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  subroutine mpas_rbf_interp_loc_2D_sca_const_eval_with_derivs(fieldCount, coeffCount, &amp;
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_loc_2D_sca_const_eval_with_derivs
+!
+!&gt; \brief   MPAS 2D scalar constant evaulation routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine evalutes a scalar function in 2D using coefficients computed in
+!&gt;   rbfInterp_loc_2D_sca_const_compCoeffs.  This 
+!&gt;   function can be called repeatedly with different destination points
+!&gt;   to quickly evaluate the interpolating function using the same
+!&gt;   coefficients.  This is useful for finding the location on the the 
+!&gt;   RBF reconstruction of a function (e.g., a height field) that minimizes
+!&gt;   the distance to a point in 3D space. The reconstruction is performed
+!&gt;   with basis functions that are RBFs and constant 
+!&gt;  Input:
+!&gt;   fieldCount - the number fields to be evaluated.  This is useful for reconstructing,
+!&gt;     for example, the x-, y- and z-components of a vector field at the same
+!&gt;     point in 2D
+!&gt;   coeffCount - the size of coefficients, must be at least pointCount + 1
+!&gt;   pointCount - the number of &quot;source&quot; points and functionValues supplied
+!&gt;   coefficients - the coefficients needed to perform interpolation of the funciton
+!&gt;     at the evaluationPoint
+!&gt;   evaluationPoint - the point in 2D where the function is to be reconstructed
+!&gt;   points - the location of the &quot;source&quot; points in the 2D space where the values of
+!&gt;     the function are known
+!&gt;   alpha - a constant that give the characteristic length scale of the RBFs,
+!&gt;     should be on the order of the distance between points
+!&gt;  Output:
+!&gt;   derivs - the value of the function, the 2 components of its Jacobian and
+!&gt;     the 3 unique components of its Hessian at the evaluationPoint
+!-----------------------------------------------------------------------
+  subroutine mpas_rbf_interp_loc_2D_sca_const_eval_with_derivs(fieldCount, coeffCount, &amp;!{{{
     pointCount, coefficients, evaluationPoint, points, alpha, derivs)
-    integer, intent(in) :: fieldCount, coeffCount, pointCount
-    real(kind=RKIND), dimension(coeffCount, fieldCount), intent(in) :: coefficients
-    real(kind=RKIND), dimension(2), intent(in) :: evaluationPoint
-    real(kind=RKIND), dimension(pointCount,2), intent(in) :: points
-    real(kind=RKIND), intent(in) :: alpha
+    integer, intent(in) :: fieldCount !&lt; Input: Number of fields
+    integer, intent(in) :: coeffCount !&lt; Input: Number of coefficients
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    real(kind=RKIND), dimension(coeffCount, fieldCount), intent(in) :: coefficients !&lt; Input: List of coefficients
+    real(kind=RKIND), dimension(2), intent(in) :: evaluationPoint !&lt; Input: Location for evaluation
+    real(kind=RKIND), dimension(pointCount,2), intent(in) :: points !&lt; Input: List of points
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale for RBFs
 
-    real(kind=RKIND), dimension(6,fieldCount), intent(out) :: derivs
+    real(kind=RKIND), dimension(6,fieldCount), intent(out) :: derivs !&lt; Output: List of derivatives
 
     integer :: pointIndex
     real(kind=RKIND) :: x, y, rSquared, rbfValue, rbfDerivOverR, rbfSecondDeriv
@@ -369,43 +409,53 @@
       end if
     end do
     derivs(1,:) = derivs(1,:) + coefficients(pointCount+1,:)
-  end subroutine mpas_rbf_interp_loc_2D_sca_const_eval_with_derivs
+  end subroutine mpas_rbf_interp_loc_2D_sca_const_eval_with_derivs!}}}
 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: Evalute a scalar function in 2D using coefficients computed in
-  !  rbfInterp_loc_2D_sca_const_compCoeffs.  This 
-  !  function can be called repeatedly with different destination points
-  !  to quickly evaluate the interpolating function using the same
-  !  coefficients.  This is useful for finding the location on the the 
-  !  RBF reconstruction of a function (e.g., a height field) that minimizes
-  !  the distance to a point in 3D space. The reconstruction is performed
-  !  with basis functions that are RBFs, constant and linear
-  ! Input:
-  !  fieldCount - the number fields to be evaluated.  This is useful for reconstructing,
-  !    for example, the x-, y- and z-components of a vector field at the same
-  !    point in 2D
-  !  coeffCount - the size of coefficients, must be at least pointCount + 1
-  !  pointCount - the number of &quot;source&quot; points and functionValues supplied
-  !  coefficients - the coefficients needed to perform interpolation of the funciton
-  !    at the evaluationPoint
-  !  evaluationPoint - the point in 2D where the function is to be reconstructed
-  !  points - the location of the &quot;source&quot; points in the 2D space where the values of
-  !    the function are known
-  !  alpha - a constant that give the characteristic length scale of the RBFs,
-  !    should be on the order of the distance between points
-  ! Output:
-  !  derivs - the value of the function, the 2 components of its Jacobian and
-  !    the 3 unique components of its Hessian at the evaluationPoint
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  subroutine mpas_rbf_interp_loc_2D_sca_lin_eval_with_derivs(fieldCount, coeffCount, &amp;
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_loc_2D_sca_lin_eval_with_derivs
+!
+!&gt; \brief   MPAS 2D scalar linear evaluation routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine evalutes a scalar function in 2D using coefficients computed in
+!&gt;   rbfInterp_loc_2D_sca_const_compCoeffs.  This 
+!&gt;   function can be called repeatedly with different destination points
+!&gt;   to quickly evaluate the interpolating function using the same
+!&gt;   coefficients.  This is useful for finding the location on the the 
+!&gt;   RBF reconstruction of a function (e.g., a height field) that minimizes
+!&gt;   the distance to a point in 3D space. The reconstruction is performed
+!&gt;   with basis functions that are RBFs, constant and linear
+!&gt;  Input:
+!&gt;   fieldCount - the number fields to be evaluated.  This is useful for reconstructing,
+!&gt;     for example, the x-, y- and z-components of a vector field at the same
+!&gt;     point in 2D
+!&gt;   coeffCount - the size of coefficients, must be at least pointCount + 1
+!&gt;   pointCount - the number of &quot;source&quot; points and functionValues supplied
+!&gt;   coefficients - the coefficients needed to perform interpolation of the funciton
+!&gt;     at the evaluationPoint
+!&gt;   evaluationPoint - the point in 2D where the function is to be reconstructed
+!&gt;   points - the location of the &quot;source&quot; points in the 2D space where the values of
+!&gt;     the function are known
+!&gt;   alpha - a constant that give the characteristic length scale of the RBFs,
+!&gt;     should be on the order of the distance between points
+!&gt;  Output:
+!&gt;   derivs - the value of the function, the 2 components of its Jacobian and
+!&gt;     the 3 unique components of its Hessian at the evaluationPoint
+!-----------------------------------------------------------------------
+  subroutine mpas_rbf_interp_loc_2D_sca_lin_eval_with_derivs(fieldCount, coeffCount, &amp;!{{{
     pointCount, coefficients, evaluationPoint, points, alpha, derivs)
-    integer, intent(in) :: fieldCount, coeffCount, pointCount
-    real(kind=RKIND), dimension(coeffCount, fieldCount), intent(in) :: coefficients
-    real(kind=RKIND), dimension(2), intent(in) :: evaluationPoint
-    real(kind=RKIND), dimension(pointCount,2), intent(in) :: points
-    real(kind=RKIND), intent(in) :: alpha
+    integer, intent(in) :: fieldCount !&lt; Input: Number of fields
+    integer, intent(in) :: coeffCount !&lt; Input: Number of coefficients
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    real(kind=RKIND), dimension(coeffCount, fieldCount), intent(in) :: coefficients !&lt; Input: List of coefficients
+    real(kind=RKIND), dimension(2), intent(in) :: evaluationPoint !&lt; Input: Point for evaluation
+    real(kind=RKIND), dimension(pointCount,2), intent(in) :: points !&lt; Input: List of points
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale of RBFs
 
-    real(kind=RKIND), dimension(6,fieldCount), intent(out) :: derivs
+    real(kind=RKIND), dimension(6,fieldCount), intent(out) :: derivs !&lt; Output: Derivatives
 
     integer :: pointIndex
     real(kind=RKIND) :: x, y, rSquared, rbfValue, rbfDerivOverR, rbfSecondDeriv
@@ -442,39 +492,47 @@
     derivs(2,:) = derivs(2,:) + coefficients(pointCount+2,:)
     derivs(3,:) = derivs(3,:) + coefficients(pointCount+3,:)
 
-  end subroutine mpas_rbf_interp_loc_2D_sca_lin_eval_with_derivs
+  end subroutine mpas_rbf_interp_loc_2D_sca_lin_eval_with_derivs!}}}
 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: Compute interpolation coefficients in 3D that can be used to
-  !  interpolate a number of scalar functions at a given locations. This is useful
-  !  if the interpolation location does not change with time, or if several
-  !  fields are to be interpolated at a given time step.  (If both the fields
-  !  and the interpolation locations vary with time, there is no clear advantage in
-  !  using either this method or the method for 2D interpoaltion above; for simplicity
-  !  and because we foresee more uses for the method of this subroutine, we have not
-  !  implemented a 3D version of the fixed field, variable interpolation location method
-  !  as we have in 2D.) Coefficients are produced for handling Dirichlet boundary
-  !  conditions (or no boundaries).  The interpolation is performed with basis functions
-  !  that are RBFs plus a constant.
-  ! Input:
-  !  pointCount - the number of &quot;source&quot; points and functionValues supplied
-  !  sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
-  !    the function are known
-  !  destinationPoint - the point where the interpolation will be performed
-  !  alpha - a constant that give the characteristic length scale of the RBFs,
-  !    should be on the order of the distance between points
-  ! Output:
-  !  coefficients - the coefficients used to interpolate a function with Dirichlet
-  !    boundary conditions to the specified destinationPoint
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  subroutine mpas_rbf_interp_func_3D_sca_const_dir_comp_coeffs( &amp;
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_func_3D_sca_const_dir_comp_coeffs
+!
+!&gt; \brief   MPAS 3D scalar constant coefficients routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes interpolation coefficients in 3D that can be used to
+!&gt;   interpolate a number of scalar functions at a given locations. This is useful
+!&gt;   if the interpolation location does not change with time, or if several
+!&gt;   fields are to be interpolated at a given time step.  (If both the fields
+!&gt;   and the interpolation locations vary with time, there is no clear advantage in
+!&gt;   using either this method or the method for 2D interpoaltion above; for simplicity
+!&gt;   and because we foresee more uses for the method of this subroutine, we have not
+!&gt;   implemented a 3D version of the fixed field, variable interpolation location method
+!&gt;   as we have in 2D.) Coefficients are produced for handling Dirichlet boundary
+!&gt;   conditions (or no boundaries).  The interpolation is performed with basis functions
+!&gt;   that are RBFs plus a constant.
+!&gt;  Input:
+!&gt;   pointCount - the number of &quot;source&quot; points and functionValues supplied
+!&gt;   sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
+!&gt;     the function are known
+!&gt;   destinationPoint - the point where the interpolation will be performed
+!&gt;   alpha - a constant that give the characteristic length scale of the RBFs,
+!&gt;     should be on the order of the distance between points
+!&gt;  Output:
+!&gt;   coefficients - the coefficients used to interpolate a function with Dirichlet
+!&gt;     boundary conditions to the specified destinationPoint
+!-----------------------------------------------------------------------
+  subroutine mpas_rbf_interp_func_3D_sca_const_dir_comp_coeffs( &amp;!{{{
     pointCount, sourcePoints, destinationPoint, alpha, coefficients)
 
-    integer, intent(in) :: pointCount
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints
-    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(pointCount), intent(out) :: coefficients
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints !&lt; Input: List of source points
+    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint !&lt; Input: List of destination points
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale of RBFs
+    real(kind=RKIND), dimension(pointCount), intent(out) :: coefficients !&lt; Output: List of coefficients
 
     integer :: i, j
     integer :: matrixSize
@@ -513,46 +571,54 @@
     deallocate(coeffs)  
     deallocate(pivotIndices) 
 
-  end subroutine mpas_rbf_interp_func_3D_sca_const_dir_comp_coeffs
+  end subroutine mpas_rbf_interp_func_3D_sca_const_dir_comp_coeffs!}}}
 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: Compute interpolation coefficients in a plane in 3D that can be used to
-  !  interpolate a number of scalar functions at a given locations. This is useful
-  !  if the interpolation location does not change with time, or if several
-  !  fields are to be interpolated at a given time step.  (If both the fields
-  !  and the interpolation locations vary with time, there is no clear advantage in
-  !  using either this method or the method for 2D interpoaltion above; for simplicity
-  !  and because we foresee more uses for the method of this subroutine, we have not
-  !  implemented a 3D version of the fixed field, variable interpolation location method
-  !  as we have in 2D.) Coefficients are produced for handling both Dirichlet (or no)
-  !  boundary conditions.  The interpolation is performed with basis functions that are
-  !  RBFs plus constant and linear.  All points are projected into the plane given by the
-  !  planeBasisVectors.
-  ! Input:
-  !  pointCount - the number of &quot;source&quot; points and functionValues supplied
-  !  sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
-  !    the function are known.  The points will be projected into the plane given by 
-  !    planeBasisVectors
-  !  destinationPoint - the point in 3D where the interpolation will be performed.  The
-  !    destinationPoint will be projected into the plane given by planeBasisVectors.
-  !  alpha - a constant that give the characteristic length scale of the RBFs,
-  !    should be on the order of the distance between points
-  !  planeBasisVectors - the basis fectors for the plane where interpolation is performed.
-  !    All points are projected into this plane. 
-  ! Output:
-  !  coefficients - the coefficients used to interpolate a function with Dirichlet
-  !    boundary conditions to the specified destinationPoint
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  subroutine mpas_rbf_interp_func_3D_plane_sca_lin_dir_comp_coeffs( &amp;
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_func_3D_plane_sca_lin_dir_comp_coeffs
+!
+!&gt; \brief   MPAS 3D planar scalar linear coefficients routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes interpolation coefficients in a plane in 3D that can be used to
+!&gt;   interpolate a number of scalar functions at a given locations. This is useful
+!&gt;   if the interpolation location does not change with time, or if several
+!&gt;   fields are to be interpolated at a given time step.  (If both the fields
+!&gt;   and the interpolation locations vary with time, there is no clear advantage in
+!&gt;   using either this method or the method for 2D interpoaltion above; for simplicity
+!&gt;   and because we foresee more uses for the method of this subroutine, we have not
+!&gt;   implemented a 3D version of the fixed field, variable interpolation location method
+!&gt;   as we have in 2D.) Coefficients are produced for handling both Dirichlet (or no)
+!&gt;   boundary conditions.  The interpolation is performed with basis functions that are
+!&gt;   RBFs plus constant and linear.  All points are projected into the plane given by the
+!&gt;   planeBasisVectors.
+!&gt;  Input:
+!&gt;   pointCount - the number of &quot;source&quot; points and functionValues supplied
+!&gt;   sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
+!&gt;     the function are known.  The points will be projected into the plane given by 
+!&gt;     planeBasisVectors
+!&gt;   destinationPoint - the point in 3D where the interpolation will be performed.  The
+!&gt;     destinationPoint will be projected into the plane given by planeBasisVectors.
+!&gt;   alpha - a constant that give the characteristic length scale of the RBFs,
+!&gt;     should be on the order of the distance between points
+!&gt;   planeBasisVectors - the basis fectors for the plane where interpolation is performed.
+!&gt;     All points are projected into this plane. 
+!&gt;  Output:
+!&gt;   coefficients - the coefficients used to interpolate a function with Dirichlet
+!&gt;     boundary conditions to the specified destinationPoint
+!-----------------------------------------------------------------------
+  subroutine mpas_rbf_interp_func_3D_plane_sca_lin_dir_comp_coeffs( &amp;!{{{
     pointCount, sourcePoints, destinationPoint, &amp;
     alpha, planeBasisVectors, coefficients)
 
-    integer, intent(in) :: pointCount
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints
-    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(2,3) :: planeBasisVectors
-    real(kind=RKIND), dimension(pointCount), intent(out) :: coefficients
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints !&lt; Input: List of source points
+    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint !&lt; Input: Destination point
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale of RBFs
+    real(kind=RKIND), dimension(2,3) :: planeBasisVectors !&lt; Input: Basis vectors for the interpolation plane
+    real(kind=RKIND), dimension(pointCount), intent(out) :: coefficients !&lt; Output: List of coefficients
 
     integer :: i, j
     integer :: matrixSize
@@ -596,39 +662,47 @@
     deallocate(coeffs)  
     deallocate(pivotIndices) 
 
-  end subroutine mpas_rbf_interp_func_3D_plane_sca_lin_dir_comp_coeffs
+  end subroutine mpas_rbf_interp_func_3D_plane_sca_lin_dir_comp_coeffs!}}}
 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: Compute interpolation coefficients in 3D that can be used to
-  !  interpolate a number of scalar functions at a given locations. This is useful
-  !  if the interpolation location does not change with time, or if several
-  !  fields are to be interpolated at a given time step.  (If both the fields
-  !  and the interpolation locations vary with time, there is no clear advantage in
-  !  using either this method or the method for 2D interpoaltion above; for simplicity
-  !  and because we foresee more uses for the method of this subroutine, we have not
-  !  implemented a 3D version of the fixed field, variable interpolation location method
-  !  as we have in 2D.) Coefficients are produced for handling both Dirichlet (or no)
-  !  boundary conditions.  The interpolation is performed with basis functions that are
-  !  RBFs plus constant and linear.
-  ! Input:
-  !  pointCount - the number of &quot;source&quot; points and functionValues supplied
-  !  sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
-  !    the function are known
-  !  destinationPoint - the point where the interpolation will be performed
-  !  alpha - a constant that give the characteristic length scale of the RBFs,
-  !    should be on the order of the distance between points
-  ! Output:
-  !  coefficients - the coefficients used to interpolate a function with Dirichlet
-  !    boundary conditions to the specified destinationPoint
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  subroutine mpas_rbf_interp_func_3D_sca_lin_dir_comp_coeffs(pointCount, &amp;
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_func_3D_sca_lin_dir_comp_coeffs
+!
+!&gt; \brief   MPAS 3D scalar linear coefficients routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes interpolation coefficients in 3D that can be used to
+!&gt;   interpolate a number of scalar functions at a given locations. This is useful
+!&gt;   if the interpolation location does not change with time, or if several
+!&gt;   fields are to be interpolated at a given time step.  (If both the fields
+!&gt;   and the interpolation locations vary with time, there is no clear advantage in
+!&gt;   using either this method or the method for 2D interpoaltion above; for simplicity
+!&gt;   and because we foresee more uses for the method of this subroutine, we have not
+!&gt;   implemented a 3D version of the fixed field, variable interpolation location method
+!&gt;   as we have in 2D.) Coefficients are produced for handling both Dirichlet (or no)
+!&gt;   boundary conditions.  The interpolation is performed with basis functions that are
+!&gt;   RBFs plus constant and linear.
+!&gt;  Input:
+!&gt;   pointCount - the number of &quot;source&quot; points and functionValues supplied
+!&gt;   sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
+!&gt;     the function are known
+!&gt;   destinationPoint - the point where the interpolation will be performed
+!&gt;   alpha - a constant that give the characteristic length scale of the RBFs,
+!&gt;     should be on the order of the distance between points
+!&gt;  Output:
+!&gt;   coefficients - the coefficients used to interpolate a function with Dirichlet
+!&gt;     boundary conditions to the specified destinationPoint
+!-----------------------------------------------------------------------
+  subroutine mpas_rbf_interp_func_3D_sca_lin_dir_comp_coeffs(pointCount, &amp;!{{{
     sourcePoints, destinationPoint, alpha, coefficients)
 
-    integer, intent(in) :: pointCount
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints
-    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(pointCount), intent(out) :: coefficients
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints !&lt; Input: List of source points
+    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint !&lt; Input: Destination point
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale for RBFs
+    real(kind=RKIND), dimension(pointCount), intent(out) :: coefficients !&lt; Output: List of coefficients
 
     integer :: i, j
     integer :: matrixSize
@@ -670,52 +744,60 @@
     deallocate(coeffs)  
     deallocate(pivotIndices) 
 
-  end subroutine mpas_rbf_interp_func_3D_sca_lin_dir_comp_coeffs
+  end subroutine mpas_rbf_interp_func_3D_sca_lin_dir_comp_coeffs!}}}
 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: Compute interpolation coefficients in 3D that can be used to
-  !  interpolate a number of scalar functions at a given locations. This is useful
-  !  if the interpolation location does not change with time, or if several
-  !  fields are to be interpolated at a given time step.  (If both the fields
-  !  and the interpolation locations vary with time, there is no clear advantage in
-  !  using either this method or the method for 2D interpoaltion above; for simplicity
-  !  and because we foresee more uses for the method of this subroutine, we have not
-  !  implemented a 3D version of the fixed field, variable interpolation location method
-  !  as we have in 2D.) Coefficients are produced for handling both Dirichlet and Neumann
-  !  boundary conditions.  The interpolation is performed with basis functions that are
-  !  RBFs plus a constant.
-  ! Input:
-  !  pointCount - the number of &quot;source&quot; points and functionValues supplied
-  !  sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
-  !    the function are known
-  !  isInterface - a logical array indicating which of the source points (if any) are at
-  !    at the domain interface.  These points and their normals will be used to compute the
-  !    neumannCoefficients below
-  !  interfaceNormals - a 3D normal vector for each sourcePoint.  These vectors are only used
-  !    at points where isInterface == .true., and can take arbitrary values elsewehere.  The
-  !    normal vector is used to compute coefficients for the normal derivative of the
-  !    interpolating function in order to impose the Neumann Boundary condition
-  !  destinationPoint - the point where the interpolation will be performed
-  !  alpha - a constant that give the characteristic length scale of the RBFs,
-  !    should be on the order of the distance between points
-  ! Output:
-  !  dirichletCoefficients - the coefficients used to interpolate a function with Dirichlet
-  !    boundary conditions to the specified destinationPoint
-  !  neumannCoefficients - the coefficients used to interpolate a function with Neumann
-  !    boundary conditions to the specified destinationPoint
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  subroutine mpas_rbf_interp_func_3D_sca_const_dir_neu_comp_coeffs( &amp;
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_func_3D_sca_const_dir_neu_comp_coeffs
+!
+!&gt; \brief   MPAS 3D scalar constant Dirichlet and Neumann coefficients routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes interpolation coefficients in 3D that can be used to
+!&gt;   interpolate a number of scalar functions at a given locations. This is useful
+!&gt;   if the interpolation location does not change with time, or if several
+!&gt;   fields are to be interpolated at a given time step.  (If both the fields
+!&gt;   and the interpolation locations vary with time, there is no clear advantage in
+!&gt;   using either this method or the method for 2D interpoaltion above; for simplicity
+!&gt;   and because we foresee more uses for the method of this subroutine, we have not
+!&gt;   implemented a 3D version of the fixed field, variable interpolation location method
+!&gt;   as we have in 2D.) Coefficients are produced for handling both Dirichlet and Neumann
+!&gt;   boundary conditions.  The interpolation is performed with basis functions that are
+!&gt;   RBFs plus a constant.
+!&gt;  Input:
+!&gt;   pointCount - the number of &quot;source&quot; points and functionValues supplied
+!&gt;   sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
+!&gt;     the function are known
+!&gt;   isInterface - a logical array indicating which of the source points (if any) are at
+!&gt;     at the domain interface.  These points and their normals will be used to compute the
+!&gt;     neumannCoefficients below
+!&gt;   interfaceNormals - a 3D normal vector for each sourcePoint.  These vectors are only used
+!&gt;     at points where isInterface == .true., and can take arbitrary values elsewehere.  The
+!&gt;     normal vector is used to compute coefficients for the normal derivative of the
+!&gt;     interpolating function in order to impose the Neumann Boundary condition
+!&gt;   destinationPoint - the point where the interpolation will be performed
+!&gt;   alpha - a constant that give the characteristic length scale of the RBFs,
+!&gt;     should be on the order of the distance between points
+!&gt;  Output:
+!&gt;   dirichletCoefficients - the coefficients used to interpolate a function with Dirichlet
+!&gt;     boundary conditions to the specified destinationPoint
+!&gt;   neumannCoefficients - the coefficients used to interpolate a function with Neumann
+!&gt;     boundary conditions to the specified destinationPoint
+!-----------------------------------------------------------------------
+  subroutine mpas_rbf_interp_func_3D_sca_const_dir_neu_comp_coeffs( &amp;!{{{
     pointCount, sourcePoints, isInterface, interfaceNormals, destinationPoint, &amp;
     alpha, dirichletCoefficients, neumannCoefficients)
 
-    integer, intent(in) :: pointCount
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints
-    logical, dimension(pointCount), intent(in) :: isInterface
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: interfaceNormals
-    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(pointCount), intent(out) :: &amp;
-      dirichletCoefficients, neumannCoefficients
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints !&lt; Input: List of source points
+    logical, dimension(pointCount), intent(in) :: isInterface !&lt; Input: Logicals determining if a source point is at an interface
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: interfaceNormals !&lt; Input: Normal vector at interface for each source point
+    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint !&lt; Input: Destination point
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale of RBFs
+    real(kind=RKIND), dimension(pointCount), intent(out) :: dirichletCoefficients !&lt; Output: Coefficients with Dirichlet BCs
+    real(kind=RKIND), dimension(pointCount), intent(out) :: neumannCoefficients !&lt; Output: Coefficients with Neumann BCs
 
     integer :: i, j
     integer :: matrixSize
@@ -772,58 +854,66 @@
     deallocate(coeffs)  
     deallocate(pivotIndices) 
 
-  end subroutine mpas_rbf_interp_func_3D_sca_const_dir_neu_comp_coeffs
+  end subroutine mpas_rbf_interp_func_3D_sca_const_dir_neu_comp_coeffs!}}}
 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: Compute interpolation coefficients in a plane in 3D that can be used to
-  !  interpolate a number of scalar functions at a given locations. This is useful
-  !  if the interpolation location does not change with time, or if several
-  !  fields are to be interpolated at a given time step.  (If both the fields
-  !  and the interpolation locations vary with time, there is no clear advantage in
-  !  using either this method or the method for 2D interpoaltion above; for simplicity
-  !  and because we foresee more uses for the method of this subroutine, we have not
-  !  implemented a 3D version of the fixed field, variable interpolation location method
-  !  as we have in 2D.) Coefficients are produced for handling both Dirichlet and Neumann
-  !  boundary conditions.  The interpolation is performed with basis functions that are
-  !  RBFs plus constant and linear.  All points are projected into the plane given by the
-  !  planeBasisVectors.
-  ! Input:
-  !  pointCount - the number of &quot;source&quot; points and functionValues supplied
-  !  sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
-  !    the function are known.  The sourcePoints will be projected into the plane given by
-  !    planeBasisVectors
-  !  isInterface - a logical array indicating which of the source points (if any) are at
-  !    at the domain interface.  These points and their normals will be used to compute the
-  !    neumannCoefficients below
-  !  interfaceNormals - a 3D normal vector for each sourcePoint.  These vectors are only used
-  !    at points where isInterface == .true., and can take arbitrary values elsewehere.  The
-  !    normal vector is used to compute coefficients for the normal derivative of the
-  !    interpolating function in order to impose the Neumann Boundary condition
-  !  destinationPoint - the point in 3D where the interpolation will be performed.  The
-  !    destinationPoint will be projected into the plane given by planeBasisVectors.
-  !  alpha - a constant that give the characteristic length scale of the RBFs,
-  !    should be on the order of the distance between points
-  !  planeBasisVectors - the basis fectors for the plane where interpolation is performed.
-  !    All points are projected into this plane. 
-  ! Output:
-  !  dirichletCoefficients - the coefficients used to interpolate a function with Dirichlet
-  !    boundary conditions to the specified destinationPoint
-  !  neumannCoefficients - the coefficients used to interpolate a function with Neumann
-  !    boundary conditions to the specified destinationPoint
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  subroutine mpas_rbf_interp_func_3D_plane_sca_lin_dir_neu_comp_coeffs( &amp;
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_func_3D_plane_sca_lin_dir_neu_comp_coeffs
+!
+!&gt; \brief   MPAS 3D scalar planar linear Dirichlet and Neumann coefficients routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes interpolation coefficients in a plane in 3D that can be used to
+!&gt;   interpolate a number of scalar functions at a given locations. This is useful
+!&gt;   if the interpolation location does not change with time, or if several
+!&gt;   fields are to be interpolated at a given time step.  (If both the fields
+!&gt;   and the interpolation locations vary with time, there is no clear advantage in
+!&gt;   using either this method or the method for 2D interpoaltion above; for simplicity
+!&gt;   and because we foresee more uses for the method of this subroutine, we have not
+!&gt;   implemented a 3D version of the fixed field, variable interpolation location method
+!&gt;   as we have in 2D.) Coefficients are produced for handling both Dirichlet and Neumann
+!&gt;   boundary conditions.  The interpolation is performed with basis functions that are
+!&gt;   RBFs plus constant and linear.  All points are projected into the plane given by the
+!&gt;   planeBasisVectors.
+!&gt;  Input:
+!&gt;   pointCount - the number of &quot;source&quot; points and functionValues supplied
+!&gt;   sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
+!&gt;     the function are known.  The sourcePoints will be projected into the plane given by
+!&gt;     planeBasisVectors
+!&gt;   isInterface - a logical array indicating which of the source points (if any) are at
+!&gt;     at the domain interface.  These points and their normals will be used to compute the
+!&gt;     neumannCoefficients below
+!&gt;   interfaceNormals - a 3D normal vector for each sourcePoint.  These vectors are only used
+!&gt;     at points where isInterface == .true., and can take arbitrary values elsewehere.  The
+!&gt;     normal vector is used to compute coefficients for the normal derivative of the
+!&gt;     interpolating function in order to impose the Neumann Boundary condition
+!&gt;   destinationPoint - the point in 3D where the interpolation will be performed.  The
+!&gt;     destinationPoint will be projected into the plane given by planeBasisVectors.
+!&gt;   alpha - a constant that give the characteristic length scale of the RBFs,
+!&gt;     should be on the order of the distance between points
+!&gt;   planeBasisVectors - the basis fectors for the plane where interpolation is performed.
+!&gt;     All points are projected into this plane. 
+!&gt;  Output:
+!&gt;   dirichletCoefficients - the coefficients used to interpolate a function with Dirichlet
+!&gt;     boundary conditions to the specified destinationPoint
+!&gt;   neumannCoefficients - the coefficients used to interpolate a function with Neumann
+!&gt;     boundary conditions to the specified destinationPoint
+!-----------------------------------------------------------------------
+  subroutine mpas_rbf_interp_func_3D_plane_sca_lin_dir_neu_comp_coeffs( &amp;!{{{
     pointCount, sourcePoints, isInterface, interfaceNormals, destinationPoint, &amp;
     alpha, planeBasisVectors, dirichletCoefficients, neumannCoefficients)
 
-    integer, intent(in) :: pointCount
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints
-    logical, dimension(pointCount), intent(in) :: isInterface
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: interfaceNormals
-    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(2,3) :: planeBasisVectors
-    real(kind=RKIND), dimension(pointCount), intent(out) :: &amp;
-      dirichletCoefficients, neumannCoefficients
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints !&lt; Input: List of points
+    logical, dimension(pointCount), intent(in) :: isInterface !&lt; Input: List of logicals determining if point is at an interface
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: interfaceNormals !&lt; Input: List of interface normals
+    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint !&lt; Input: Destination point
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale of RBFs
+    real(kind=RKIND), dimension(2,3) :: planeBasisVectors !&lt; Input: Basis vectors for interpolation plane
+    real(kind=RKIND), dimension(pointCount), intent(out) :: dirichletCoefficients !&lt; Output: List of Dirichlet coefficients
+    real(kind=RKIND), dimension(pointCount), intent(out) :: neumannCoefficients !&lt; Output: List of Neumann coefficients
 
     integer :: i, j
     integer :: matrixSize
@@ -889,52 +979,60 @@
     deallocate(coeffs)  
     deallocate(pivotIndices) 
 
-  end subroutine mpas_rbf_interp_func_3D_plane_sca_lin_dir_neu_comp_coeffs
+  end subroutine mpas_rbf_interp_func_3D_plane_sca_lin_dir_neu_comp_coeffs!}}}
 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: Compute interpolation coefficients in 3D that can be used to
-  !  interpolate a number of scalar functions at a given locations. This is useful
-  !  if the interpolation location does not change with time, or if several
-  !  fields are to be interpolated at a given time step.  (If both the fields
-  !  and the interpolation locations vary with time, there is no clear advantage in
-  !  using either this method or the method for 2D interpoaltion above; for simplicity
-  !  and because we foresee more uses for the method of this subroutine, we have not
-  !  implemented a 3D version of the fixed field, variable interpolation location method
-  !  as we have in 2D.) Coefficients are produced for handling both Dirichlet and Neumann
-  !  boundary conditions.  The interpolation is performed with basis functions that are
-  !  RBFs plus constant and linear.
-  ! Input:
-  !  pointCount - the number of &quot;source&quot; points and functionValues supplied
-  !  sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
-  !    the function are known
-  !  isInterface - a logical array indicating which of the source points (if any) are at
-  !    at the domain interface.  These points and their normals will be used to compute the
-  !    neumannCoefficients below
-  !  interfaceNormals - a 3D normal vector for each sourcePoint.  These vectors are only used
-  !    at points where isInterface == .true., and can take arbitrary values elsewehere.  The
-  !    normal vector is used to compute coefficients for the normal derivative of the
-  !    interpolating function in order to impose the Neumann Boundary condition
-  !  destinationPoint - the point where the interpolation will be performed
-  !  alpha - a constant that give the characteristic length scale of the RBFs,
-  !    should be on the order of the distance between points
-  ! Output:
-  !  dirichletCoefficients - the coefficients used to interpolate a function with Dirichlet
-  !    boundary conditions to the specified destinationPoint
-  !  neumannCoefficients - the coefficients used to interpolate a function with Neumann
-  !    boundary conditions to the specified destinationPoint
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  subroutine mpas_rbf_interp_func_3D_sca_lin_dir_neu_comp_coeffs(pointCount, &amp;
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_func_3D_sca_lin_dir_neu_comp_coeffs
+!
+!&gt; \brief   MPAS 3D scalar linear Dirichlet and Neumann coefficients routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes interpolation coefficients in 3D that can be used to
+!&gt;   interpolate a number of scalar functions at a given locations. This is useful
+!&gt;   if the interpolation location does not change with time, or if several
+!&gt;   fields are to be interpolated at a given time step.  (If both the fields
+!&gt;   and the interpolation locations vary with time, there is no clear advantage in
+!&gt;   using either this method or the method for 2D interpoaltion above; for simplicity
+!&gt;   and because we foresee more uses for the method of this subroutine, we have not
+!&gt;   implemented a 3D version of the fixed field, variable interpolation location method
+!&gt;   as we have in 2D.) Coefficients are produced for handling both Dirichlet and Neumann
+!&gt;   boundary conditions.  The interpolation is performed with basis functions that are
+!&gt;   RBFs plus constant and linear.
+!&gt;  Input:
+!&gt;   pointCount - the number of &quot;source&quot; points and functionValues supplied
+!&gt;   sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
+!&gt;     the function are known
+!&gt;   isInterface - a logical array indicating which of the source points (if any) are at
+!&gt;     at the domain interface.  These points and their normals will be used to compute the
+!&gt;     neumannCoefficients below
+!&gt;   interfaceNormals - a 3D normal vector for each sourcePoint.  These vectors are only used
+!&gt;     at points where isInterface == .true., and can take arbitrary values elsewehere.  The
+!&gt;     normal vector is used to compute coefficients for the normal derivative of the
+!&gt;     interpolating function in order to impose the Neumann Boundary condition
+!&gt;   destinationPoint - the point where the interpolation will be performed
+!&gt;   alpha - a constant that give the characteristic length scale of the RBFs,
+!&gt;     should be on the order of the distance between points
+!&gt;  Output:
+!&gt;   dirichletCoefficients - the coefficients used to interpolate a function with Dirichlet
+!&gt;     boundary conditions to the specified destinationPoint
+!&gt;   neumannCoefficients - the coefficients used to interpolate a function with Neumann
+!&gt;     boundary conditions to the specified destinationPoint
+!-----------------------------------------------------------------------
+  subroutine mpas_rbf_interp_func_3D_sca_lin_dir_neu_comp_coeffs(pointCount, &amp;!{{{
     sourcePoints, isInterface, interfaceNormals, destinationPoint, &amp;
     alpha, dirichletCoefficients, neumannCoefficients)
 
-    integer, intent(in) :: pointCount
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints
-    logical, dimension(pointCount), intent(in) :: isInterface
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: interfaceNormals
-    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(pointCount), intent(out) :: &amp;
-      dirichletCoefficients, neumannCoefficients
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints !&lt; Input: List of points
+    logical, dimension(pointCount), intent(in) :: isInterface !&lt; Input: List of logicals determining if point as at an interface
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: interfaceNormals !&lt; Input: List of interface normals
+    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint !&lt; Input: Destination point
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale of RBFs
+    real(kind=RKIND), dimension(pointCount), intent(out) :: dirichletCoefficients !&lt; Output: List of Dirichlet coefficients
+    real(kind=RKIND), dimension(pointCount), intent(out) :: neumannCoefficients !&lt; Outut: List of Neumann coefficients
 
     integer :: i, j
     integer :: matrixSize
@@ -997,45 +1095,53 @@
     deallocate(coeffs)  
     deallocate(pivotIndices) 
 
-  end subroutine mpas_rbf_interp_func_3D_sca_lin_dir_neu_comp_coeffs
+  end subroutine mpas_rbf_interp_func_3D_sca_lin_dir_neu_comp_coeffs!}}}
 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: Compute interpolation coefficients in 3D that can be used to
-  !  interpolate a number of vector functions at a given locations. This is useful
-  !  if the interpolation location does not change with time, or if several
-  !  fields are to be interpolated at a given time step.  (If both the vector fields
-  !  and the interpolation locations vary with time, there is no clear advantage in
-  !  using either this method or the method for 2D interpoaltion above; for simplicity
-  !  and because we foresee more uses for the method of this subroutine, we have not
-  !  implemented a 3D version of the fixed field, variable interpolation location method
-  !  as we have in 2D.) Coefficients are produced for handling Dirichlet boundary
-  !  conditions (or no boundaries).  The interpolation is performed with basis functions
-  !  that are RBFs plus a constant.
-  ! Input:
-  !  pointCount - the number of &quot;source&quot; points and functionValues supplied
-  !  sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
-  !    the function are known
-  !  unitVectors - the unit vectors associated with each of the sourcePoints.  Interpolation
-  !    is performed by supplying the value of the vector function dotted into each of these unit
-  !    vectors.  If multiple unit vectors are supplied at the same sourcePoint, they *must* be
-  !    orthogonal for the interpolation to succeed.
-  !  destinationPoint - the point where the interpolation will be performed
-  !  alpha - a constant that give the characteristic length scale of the RBFs,
-  !    should be on the order of the distance between points
-  ! Output:
-  !  coefficients - the coefficients used to interpolate a function with Dirichlet
-  !    boundary conditions to the specified destinationPoint
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  subroutine mpas_rbf_interp_func_3D_vec_const_dir_comp_coeffs(pointCount, &amp;
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_func_3D_vec_const_dir_comp_coeffs
+!
+!&gt; \brief   MPAS 3D vector constant Dirichlet coefficients routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes interpolation coefficients in 3D that can be used to
+!&gt;   interpolate a number of vector functions at a given locations. This is useful
+!&gt;   if the interpolation location does not change with time, or if several
+!&gt;   fields are to be interpolated at a given time step.  (If both the vector fields
+!&gt;   and the interpolation locations vary with time, there is no clear advantage in
+!&gt;   using either this method or the method for 2D interpoaltion above; for simplicity
+!&gt;   and because we foresee more uses for the method of this subroutine, we have not
+!&gt;   implemented a 3D version of the fixed field, variable interpolation location method
+!&gt;   as we have in 2D.) Coefficients are produced for handling Dirichlet boundary
+!&gt;   conditions (or no boundaries).  The interpolation is performed with basis functions
+!&gt;   that are RBFs plus a constant.
+!&gt;  Input:
+!&gt;   pointCount - the number of &quot;source&quot; points and functionValues supplied
+!&gt;   sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
+!&gt;     the function are known
+!&gt;   unitVectors - the unit vectors associated with each of the sourcePoints.  Interpolation
+!&gt;     is performed by supplying the value of the vector function dotted into each of these unit
+!&gt;     vectors.  If multiple unit vectors are supplied at the same sourcePoint, they *must* be
+!&gt;     orthogonal for the interpolation to succeed.
+!&gt;   destinationPoint - the point where the interpolation will be performed
+!&gt;   alpha - a constant that give the characteristic length scale of the RBFs,
+!&gt;     should be on the order of the distance between points
+!&gt;  Output:
+!&gt;   coefficients - the coefficients used to interpolate a function with Dirichlet
+!&gt;     boundary conditions to the specified destinationPoint
+!-----------------------------------------------------------------------
+  subroutine mpas_rbf_interp_func_3D_vec_const_dir_comp_coeffs(pointCount, &amp;!{{{
     sourcePoints, unitVectors, destinationPoint, &amp;
     alpha, coefficients)
 
-    integer, intent(in) :: pointCount
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: unitVectors
-    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(pointCount, 3), intent(out) :: coefficients
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints !&lt; Input: List of points
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: unitVectors !&lt; Input: List of unit vectors
+    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint !&lt; Input: Destination point
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale of RBFs
+    real(kind=RKIND), dimension(pointCount, 3), intent(out) :: coefficients !&lt; Output: List of coefficients
 
     integer :: i, j
     integer :: matrixSize
@@ -1082,51 +1188,59 @@
     deallocate(coeffs)  
     deallocate(pivotIndices) 
 
-  end subroutine mpas_rbf_interp_func_3D_vec_const_dir_comp_coeffs 
+  end subroutine mpas_rbf_interp_func_3D_vec_const_dir_comp_coeffs !}}}
 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: Compute interpolation coefficients in 3D that can be used to
-  !  interpolate a number of vector functions at a given locations. This is useful
-  !  if the interpolation location does not change with time, or if several
-  !  fields are to be interpolated at a given time step.  (If both the vector fields
-  !  and the interpolation locations vary with time, there is no clear advantage in
-  !  using either this method or the method for 2D interpoaltion above; for simplicity
-  !  and because we foresee more uses for the method of this subroutine, we have not
-  !  implemented a 3D version of the fixed field, variable interpolation location method
-  !  as we have in 2D.) Coefficients are produced for handling Dirichlet boundary
-  !  conditions (or no boundaries).  The interpolation is performed with basis functions
-  !  that are RBFs plus a constant.
-  ! Input:
-  !  pointCount - the number of &quot;source&quot; points and functionValues supplied
-  !  sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
-  !    the function are known.  The sourcePoints are projected into the plane given by
-  !    planeBasisVectors
-  !  unitVectors - the unit vectors associated with each of the sourcePoints.  Interpolation
-  !    is performed by supplying the value of the vector function dotted into each of these unit
-  !    vectors.  If multiple unit vectors are supplied at the same sourcePoint, they *must* be
-  !    orthogonal for the interpolation to succeed.  The unitVectors are projected into the
-  !    plane given by planeBasisVectors
-  !  destinationPoint - the point where the interpolation will be performed.  The destinationPoint
-  !    is projected into the plane given by planeBasisVectors
-  !  alpha - a constant that give the characteristic length scale of the RBFs,
-  !    should be on the order of the distance between points
-  !  planeBasisVectors - the basis fectors for the plane where interpolation is performed.
-  !    All points are projected into this plane. 
-  ! Output:
-  !  coefficients - the coefficients used to interpolate a function with Dirichlet
-  !    boundary conditions to the specified destinationPoint
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  subroutine mpas_rbf_interp_func_3D_plane_vec_const_dir_comp_coeffs(pointCount, &amp;
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_func_3D_plane_vec_const_dir_comp_coeffs
+!
+!&gt; \brief   MPAS 3D vector planar constant Dirichlet coefficients routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;   This routine computes interpolation coefficients in 3D that can be used to
+!&gt;    interpolate a number of vector functions at a given locations. This is useful
+!&gt;    if the interpolation location does not change with time, or if several
+!&gt;    fields are to be interpolated at a given time step.  (If both the vector fields
+!&gt;    and the interpolation locations vary with time, there is no clear advantage in
+!&gt;    using either this method or the method for 2D interpoaltion above; for simplicity
+!&gt;    and because we foresee more uses for the method of this subroutine, we have not
+!&gt;    implemented a 3D version of the fixed field, variable interpolation location method
+!&gt;    as we have in 2D.) Coefficients are produced for handling Dirichlet boundary
+!&gt;    conditions (or no boundaries).  The interpolation is performed with basis functions
+!&gt;    that are RBFs plus a constant.
+!&gt;   Input:
+!&gt;    pointCount - the number of &quot;source&quot; points and functionValues supplied
+!&gt;    sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
+!&gt;      the function are known.  The sourcePoints are projected into the plane given by
+!&gt;      planeBasisVectors
+!&gt;    unitVectors - the unit vectors associated with each of the sourcePoints.  Interpolation
+!&gt;      is performed by supplying the value of the vector function dotted into each of these unit
+!&gt;      vectors.  If multiple unit vectors are supplied at the same sourcePoint, they *must* be
+!&gt;      orthogonal for the interpolation to succeed.  The unitVectors are projected into the
+!&gt;      plane given by planeBasisVectors
+!&gt;    destinationPoint - the point where the interpolation will be performed.  The destinationPoint
+!&gt;      is projected into the plane given by planeBasisVectors
+!&gt;    alpha - a constant that give the characteristic length scale of the RBFs,
+!&gt;      should be on the order of the distance between points
+!&gt;    planeBasisVectors - the basis fectors for the plane where interpolation is performed.
+!&gt;      All points are projected into this plane. 
+!&gt;   Output:
+!&gt;    coefficients - the coefficients used to interpolate a function with Dirichlet
+!&gt;      boundary conditions to the specified destinationPoint
+!-----------------------------------------------------------------------
+  subroutine mpas_rbf_interp_func_3D_plane_vec_const_dir_comp_coeffs(pointCount, &amp;!{{{
     sourcePoints, unitVectors, destinationPoint, &amp;
     alpha, planeBasisVectors, coefficients)
 
-    integer, intent(in) :: pointCount
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: unitVectors
-    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(2,3) :: planeBasisVectors
-    real(kind=RKIND), dimension(pointCount, 3), intent(out) :: coefficients
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints !&lt; Input: List of points
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: unitVectors !&lt; Input: List of unit vectors
+    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint !&lt; Input: Destination point
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale of RBFs
+    real(kind=RKIND), dimension(2,3) :: planeBasisVectors !&lt; Input: Basis vectors for interpolation plane
+    real(kind=RKIND), dimension(pointCount, 3), intent(out) :: coefficients !&lt; Output: List of coefficients
 
     integer :: i, j
     integer :: matrixSize
@@ -1191,55 +1305,63 @@
     deallocate(coeffs)  
     deallocate(pivotIndices)
 
-  end subroutine mpas_rbf_interp_func_3D_plane_vec_const_dir_comp_coeffs 
+  end subroutine mpas_rbf_interp_func_3D_plane_vec_const_dir_comp_coeffs !}}}
 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: Compute interpolation coefficients in 3D that can be used to
-  !  interpolate a number of vector functions at a given locations. This is useful
-  !  if the interpolation location does not change with time, or if several
-  !  fields are to be interpolated at a given time step.  (If both the vector fields
-  !  and the interpolation locations vary with time, there is no clear advantage in
-  !  using either this method or the method for 2D interpoaltion above; for simplicity
-  !  and because we foresee more uses for the method of this subroutine, we have not
-  !  implemented a 3D version of the fixed field, variable interpolation location method
-  !  as we have in 2D.) Coefficients are produced for handling Dirichlet normal /
-  !  Neumann tangential boundary conditions (such as free slip).  The interpolation is 
-  !  performed with basis functions that are RBFs plus a constant.
-  ! Input:
-  !  pointCount - the number of &quot;source&quot; points and functionValues supplied
-  !  sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
-  !    the function are known
-  !  isTangentToInterface - a logical array indicating which sourcePoints/unitVectors are
-  !    tangent to the interface where the boundary condition will be applied.  A Neumann
-  !    boundary condition will be applied at these points in these directions.
-  !  normalVectorIndex - where isTangentToInterface == .true., the index into unitVectors that
-  !    gives the normal vector at the same sourcePoint.  This information is needed to compute
-  !    the Neumann boundary condition at this point.
-  !  unitVectors - the unit vectors associated with each of the sourcePoints.  Interpolation
-  !    is performed by supplying the value of the vector function dotted into each of these unit
-  !    vectors.  If multiple unit vectors are supplied at the same sourcePoint, they *must* be
-  !    orthogonal for the interpolation to succeed.  A normal vector and two tangential vectors
-  !    are needed at each interface point in order to satisfy the Dirichlet normal boundary
-  !    condition and the Neumann tangential boundary conditions at these points.
-  !  destinationPoint - the point where the interpolation will be performed
-  !  alpha - a constant that give the characteristic length scale of the RBFs,
-  !    should be on the order of the distance between points
-  ! Output:
-  !  coefficients - the coefficients used to interpolate a function with Dirichlet
-  !    boundary conditions to the specified destinationPoint
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  subroutine mpas_rbf_interp_func_3D_vec_const_tan_neu_comp_coeffs(pointCount, &amp;
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_func_3D_vec_const_tan_neu_comp_coeffs
+!
+!&gt; \brief   MPAS 3D vector constant tangent Neumann coefficients routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes interpolation coefficients in 3D that can be used to
+!&gt;   interpolate a number of vector functions at a given locations. This is useful
+!&gt;   if the interpolation location does not change with time, or if several
+!&gt;   fields are to be interpolated at a given time step.  (If both the vector fields
+!&gt;   and the interpolation locations vary with time, there is no clear advantage in
+!&gt;   using either this method or the method for 2D interpoaltion above; for simplicity
+!&gt;   and because we foresee more uses for the method of this subroutine, we have not
+!&gt;   implemented a 3D version of the fixed field, variable interpolation location method
+!&gt;   as we have in 2D.) Coefficients are produced for handling Dirichlet normal /
+!&gt;   Neumann tangential boundary conditions (such as free slip).  The interpolation is 
+!&gt;   performed with basis functions that are RBFs plus a constant.
+!&gt;  Input:
+!&gt;   pointCount - the number of &quot;source&quot; points and functionValues supplied
+!&gt;   sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
+!&gt;     the function are known
+!&gt;   isTangentToInterface - a logical array indicating which sourcePoints/unitVectors are
+!&gt;     tangent to the interface where the boundary condition will be applied.  A Neumann
+!&gt;     boundary condition will be applied at these points in these directions.
+!&gt;   normalVectorIndex - where isTangentToInterface == .true., the index into unitVectors that
+!&gt;     gives the normal vector at the same sourcePoint.  This information is needed to compute
+!&gt;     the Neumann boundary condition at this point.
+!&gt;   unitVectors - the unit vectors associated with each of the sourcePoints.  Interpolation
+!&gt;     is performed by supplying the value of the vector function dotted into each of these unit
+!&gt;     vectors.  If multiple unit vectors are supplied at the same sourcePoint, they *must* be
+!&gt;     orthogonal for the interpolation to succeed.  A normal vector and two tangential vectors
+!&gt;     are needed at each interface point in order to satisfy the Dirichlet normal boundary
+!&gt;     condition and the Neumann tangential boundary conditions at these points.
+!&gt;   destinationPoint - the point where the interpolation will be performed
+!&gt;   alpha - a constant that give the characteristic length scale of the RBFs,
+!&gt;     should be on the order of the distance between points
+!&gt;  Output:
+!&gt;   coefficients - the coefficients used to interpolate a function with Dirichlet
+!&gt;     boundary conditions to the specified destinationPoint
+!-----------------------------------------------------------------------
+  subroutine mpas_rbf_interp_func_3D_vec_const_tan_neu_comp_coeffs(pointCount, &amp;!{{{
     sourcePoints, isTangentToInterface, normalVectorIndex, unitVectors, destinationPoint, &amp;
     alpha, coefficients)
 
-    integer, intent(in) :: pointCount
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints
-    logical, dimension(pointCount), intent(in) :: isTangentToInterface
-    integer, dimension(pointCount), intent(in) :: normalVectorIndex
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: unitVectors
-    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(pointCount, 3), intent(out) :: coefficients
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints !&lt; Input: List of points
+    logical, dimension(pointCount), intent(in) :: isTangentToInterface !&lt; Input: List of logicals determining if point is tangent to interface
+    integer, dimension(pointCount), intent(in) :: normalVectorIndex !&lt; Input: Index of for normal vectors
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: unitVectors !&lt; Input: List of unit vectors
+    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint !&lt; Input: Destination point
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale of RBFs
+    real(kind=RKIND), dimension(pointCount, 3), intent(out) :: coefficients !&lt; Output: List of coefficients
 
     integer :: i, j
     integer :: matrixSize
@@ -1287,61 +1409,70 @@
     deallocate(coeffs)  
     deallocate(pivotIndices)
 
-  end subroutine mpas_rbf_interp_func_3D_vec_const_tan_neu_comp_coeffs 
+  end subroutine mpas_rbf_interp_func_3D_vec_const_tan_neu_comp_coeffs !}}}
 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: Compute interpolation coefficients in 3D that can be used to
-  !  interpolate a number of vector functions at a given locations. This is useful
-  !  if the interpolation location does not change with time, or if several
-  !  fields are to be interpolated at a given time step.  (If both the vector fields
-  !  and the interpolation locations vary with time, there is no clear advantage in
-  !  using either this method or the method for 2D interpoaltion above; for simplicity
-  !  and because we foresee more uses for the method of this subroutine, we have not
-  !  implemented a 3D version of the fixed field, variable interpolation location method
-  !  as we have in 2D.) Coefficients are produced for handling Dirichlet normal /
-  !  Neumann tangential boundary conditions (such as free slip).  The interpolation is 
-  !  performed with basis functions that are RBFs plus a constant.
-  ! Input:
-  !  pointCount - the number of &quot;source&quot; points and functionValues supplied
-  !  sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
-  !    the function are known.  The sourcePoints are projected into the plane given by
-  !    planeBasisVectors
-  !  isTangentToInterface - a logical array indicating which sourcePoints/unitVectors are
-  !    tangent to the interface where the boundary condition will be applied.  A Neumann
-  !    boundary condition will be applied at these points in these directions.
-  !  normalVectorIndex - where isTangentToInterface == .true., the index into unitVectors that
-  !    gives the normal vector at the same sourcePoint.  This information is needed to compute
-  !    the Neumann boundary condition at this point.
-  !  unitVectors - the unit vectors associated with each of the sourcePoints.  Interpolation
-  !    is performed by supplying the value of the vector function dotted into each of these unit
-  !    vectors.  If multiple unit vectors are supplied at the same sourcePoint, they *must* be
-  !    orthogonal for the interpolation to succeed.  A normal vector and two tangential vectors
-  !    are needed at each interface point in order to satisfy the Dirichlet normal boundary
-  !    condition and the Neumann tangential boundary conditions at these points. The unitVectors
-  !    are projected into the plane given by planeBasisVectors
-  !  destinationPoint - the point where the interpolation will be performed.  The destinationPoint
-  !    is projected into the plane given by planeBasisVectors
-  !  alpha - a constant that give the characteristic length scale of the RBFs,
-  !    should be on the order of the distance between points
-  !  planeBasisVectors - the basis fectors for the plane where interpolation is performed.
-  !    All points are projected into this plane. 
-  ! Output:
-  !  coefficients - the coefficients used to interpolate a function with Dirichlet
-  !    boundary conditions to the specified destinationPoint
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  subroutine mpas_rbf_interp_func_3D_plane_vec_const_tan_neu_comp_coeffs(&amp;
+!***********************************************************************
+!
+!  routine mpas_rbf_interp_func_3D_plane_vec_const_tan_neu_comp_coeffs
+!
+!&gt; \brief   MPAS 3D vector planar constant tangent Neumann coefficients routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes interpolation coefficients in 3D that can be used to
+!&gt;   interpolate a number of vector functions at a given locations. This is useful
+!&gt;   if the interpolation location does not change with time, or if several
+!&gt;   fields are to be interpolated at a given time step.  (If both the vector fields
+!&gt;   and the interpolation locations vary with time, there is no clear advantage in
+!&gt;   using either this method or the method for 2D interpoaltion above; for simplicity
+!&gt;   and because we foresee more uses for the method of this subroutine, we have not
+!&gt;   implemented a 3D version of the fixed field, variable interpolation location method
+!&gt;   as we have in 2D.) Coefficients are produced for handling Dirichlet normal /
+!&gt;   Neumann tangential boundary conditions (such as free slip).  The interpolation is 
+!&gt;   performed with basis functions that are RBFs plus a constant.
+!&gt;  Input:
+!&gt;   pointCount - the number of &quot;source&quot; points and functionValues supplied
+!&gt;   sourcePoints - the location of the &quot;source&quot; points in the 3D space where the values of
+!&gt;     the function are known.  The sourcePoints are projected into the plane given by
+!&gt;     planeBasisVectors
+!&gt;   isTangentToInterface - a logical array indicating which sourcePoints/unitVectors are
+!&gt;     tangent to the interface where the boundary condition will be applied.  A Neumann
+!&gt;     boundary condition will be applied at these points in these directions.
+!&gt;   normalVectorIndex - where isTangentToInterface == .true., the index into unitVectors that
+!&gt;     gives the normal vector at the same sourcePoint.  This information is needed to compute
+!&gt;     the Neumann boundary condition at this point.
+!&gt;   unitVectors - the unit vectors associated with each of the sourcePoints.  Interpolation
+!&gt;     is performed by supplying the value of the vector function dotted into each of these unit
+!&gt;     vectors.  If multiple unit vectors are supplied at the same sourcePoint, they *must* be
+!&gt;     orthogonal for the interpolation to succeed.  A normal vector and two tangential vectors
+!&gt;     are needed at each interface point in order to satisfy the Dirichlet normal boundary
+!&gt;     condition and the Neumann tangential boundary conditions at these points. The unitVectors
+!&gt;     are projected into the plane given by planeBasisVectors
+!&gt;   destinationPoint - the point where the interpolation will be performed.  The destinationPoint
+!&gt;     is projected into the plane given by planeBasisVectors
+!&gt;   alpha - a constant that give the characteristic length scale of the RBFs,
+!&gt;     should be on the order of the distance between points
+!&gt;   planeBasisVectors - the basis fectors for the plane where interpolation is performed.
+!&gt;     All points are projected into this plane. 
+!&gt;  Output:
+!&gt;   coefficients - the coefficients used to interpolate a function with Dirichlet
+!&gt;     boundary conditions to the specified destinationPoint
+!-----------------------------------------------------------------------
+
+  subroutine mpas_rbf_interp_func_3D_plane_vec_const_tan_neu_comp_coeffs(&amp;!{{{
     pointCount, sourcePoints, isTangentToInterface, normalVectorIndex, unitVectors, &amp;
     destinationPoint, alpha, planeBasisVectors, coefficients)
 
-    integer, intent(in) :: pointCount
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints
-    logical, dimension(pointCount), intent(in) :: isTangentToInterface
-    integer, dimension(pointCount), intent(in) :: normalVectorIndex
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: unitVectors
-    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(2,3), intent(in) :: planeBasisVectors
-    real(kind=RKIND), dimension(pointCount, 3), intent(out) :: coefficients
+    integer, intent(in) :: pointCount !&lt; input: Number of points
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints !&lt; Input: List of points
+    logical, dimension(pointCount), intent(in) :: isTangentToInterface !&lt; Input: List of logicals determining if point is tangent to interface
+    integer, dimension(pointCount), intent(in) :: normalVectorIndex !&lt; Input: Index for normal vectors
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: unitVectors !&lt; Input: List of unit vectors
+    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint !&lt; Input: Destination point
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale of RBFs
+    real(kind=RKIND), dimension(2,3), intent(in) :: planeBasisVectors !&lt; Input: Basis vectors for interpolation plane
+    real(kind=RKIND), dimension(pointCount, 3), intent(out) :: coefficients !&lt; Output: List of coefficients
 
     integer :: i, j
     integer :: matrixSize
@@ -1407,52 +1538,99 @@
     deallocate(coeffs)  
     deallocate(pivotIndices)
 
-   end subroutine mpas_rbf_interp_func_3D_plane_vec_const_tan_neu_comp_coeffs 
+   end subroutine mpas_rbf_interp_func_3D_plane_vec_const_tan_neu_comp_coeffs !}}}
 
 
 !!!!!!!!!!!!!!!!!!!!!
 ! private subroutines
 !!!!!!!!!!!!!!!!!!!!!
 
-  function evaluate_rbf(rSquared) result(rbfValue)
-    real(kind=RKIND), intent(in) :: rSquared
+!***********************************************************************
+!
+!  function evaluate_rbf
+!
+!&gt; \brief   MPAS RBF Evaluation function
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This function evaluates an RBF and returns the value.
+!-----------------------------------------------------------------------
+  function evaluate_rbf(rSquared) result(rbfValue)!{{{
+    real(kind=RKIND), intent(in) :: rSquared !&lt; Input: Squared value of r
     real(kind=RKIND) :: rbfValue
 
     ! inverse multiquadratic
     rbfValue = 1/sqrt(1 + rSquared)
 
-  end function evaluate_rbf
+  end function evaluate_rbf!}}}
 
-  subroutine mpas_evaluate_rbf_and_deriv(rSquared, rbfValue, rbfDerivOverR)
-    real(kind=RKIND), intent(in) :: rSquared
-    real(kind=RKIND), intent(out) :: rbfValue, rbfDerivOverR
+!***********************************************************************
+!
+!  routine mpas_evaluate_rbf_and_deriv
+!
+!&gt; \brief   MPAS RBF Evaluation and derivative routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine computes the value and derivative of a RBF.
+!-----------------------------------------------------------------------
+  subroutine mpas_evaluate_rbf_and_deriv(rSquared, rbfValue, rbfDerivOverR)!{{{
+    real(kind=RKIND), intent(in) :: rSquared !&lt; Input: Squared value of R
+    real(kind=RKIND), intent(out) :: rbfValue !&lt; Output: Value of RBF
+    real(kind=RKIND), intent(out) :: rbfDerivOverR  !&lt; Outut: Derivative of RBF over R
 
     ! inverse multiquadratic
     rbfValue = 1/sqrt(1 + rSquared)
     rbfDerivOverR = -rbfValue**3
 
-  end subroutine mpas_evaluate_rbf_and_deriv
+  end subroutine mpas_evaluate_rbf_and_deriv!}}}
 
-  subroutine mpas_evaluate_rbf_and_derivs(rSquared, rbfValue, rbfDerivOverR, rbfSecondDeriv)
-    real(kind=RKIND), intent(in) :: rSquared
-    real(kind=RKIND), intent(out) :: rbfValue, rbfDerivOverR, rbfSecondDeriv
+!***********************************************************************
+!
+!  routine mpas_evaluate_rbf_and_derivs
+!
+!&gt; \brief   MPAS RBF Evaluation and first and second derivative routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine computes the value and the first two derivatives of a RBF.
+!-----------------------------------------------------------------------
+  subroutine mpas_evaluate_rbf_and_derivs(rSquared, rbfValue, rbfDerivOverR, rbfSecondDeriv)!{{{
+    real(kind=RKIND), intent(in) :: rSquared !&lt; Input: Squared value of R
+    real(kind=RKIND), intent(out) :: rbfValue !&lt; Output: Value of RBF
+    real(kind=RKIND), intent(out) :: rbfDerivOverR !&lt; Output: Value of first derivative of RBF
+    real(kind=RKIND), intent(out) :: rbfSecondDeriv !&lt; Output: Value of second derivative of RBF
 
     ! inverse multiquadratic
     rbfValue = 1/sqrt(1 + rSquared)
     rbfDerivOverR = -rbfValue**3
     rbfSecondDeriv = (2*rSquared-1)*rbfValue**5
 
-  end subroutine mpas_evaluate_rbf_and_derivs
+  end subroutine mpas_evaluate_rbf_and_derivs!}}}
 
-  subroutine mpas_set_up_scalar_rbf_dirichlet_matrix_and_rhs(pointCount, sourcePoints, destinationPoint, &amp;
+!***********************************************************************
+!
+!  routine mpas_set_up_scalar_rbf_dirichlet_matrix_and_rhs
+!
+!&gt; \brief   MPAS RBF Scalar Matrix and RHS setup routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine sets up the matrix and RHS for scalar Dirichlet RBF interpolation.
+!-----------------------------------------------------------------------
+  subroutine mpas_set_up_scalar_rbf_dirichlet_matrix_and_rhs(pointCount, sourcePoints, destinationPoint, &amp;!{{{
     alpha, dirichletMatrix, rhs)
 
-    integer, intent(in) :: pointCount
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints
-    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(pointCount,pointCount), intent(out) :: dirichletMatrix
-    real(kind=RKIND), dimension(pointCount), intent(out) :: rhs
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints !&lt; Input: List of points
+    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint !&lt; Input: Destination point
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale of RBF
+    real(kind=RKIND), dimension(pointCount,pointCount), intent(out) :: dirichletMatrix !&lt; Output: Matrix
+    real(kind=RKIND), dimension(pointCount), intent(out) :: rhs !&lt; Output: Right hand side
 
     integer :: i, j
 
@@ -1471,21 +1649,32 @@
       rhs(j) = evaluate_rbf(rSquared)
     end do
 
-  end subroutine mpas_set_up_scalar_rbf_dirichlet_matrix_and_rhs
+  end subroutine mpas_set_up_scalar_rbf_dirichlet_matrix_and_rhs!}}}
 
-  subroutine mpas_set_up_scalar_rbf_matrix_and_rhs(pointCount, &amp;
+!***********************************************************************
+!
+!  routine mpas_set_up_scalar_rbf_matrix_and_rhs
+!
+!&gt; \brief   MPAS RBF Scalar Matrix and RHS setup routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine sets up the matrix and RHS for scalar Dirichlet and Neumann RBF interpolation.
+!-----------------------------------------------------------------------
+  subroutine mpas_set_up_scalar_rbf_matrix_and_rhs(pointCount, &amp;!{{{
     sourcePoints, isInterface, interfaceNormals, destinationPoint, &amp;
     alpha, dirichletMatrix, neumannMatrix, rhs)
 
-    integer, intent(in) :: pointCount
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints
-    logical, dimension(pointCount), intent(in) :: isInterface
-    real(kind=RKIND), dimension(pointCount,3), intent(in) :: interfaceNormals
-    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(pointCount,pointCount), intent(out) :: &amp;
-      dirichletMatrix, neumannMatrix
-    real(kind=RKIND), dimension(pointCount), intent(out) :: rhs
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: sourcePoints !&lt; Input: List of points
+    logical, dimension(pointCount), intent(in) :: isInterface !&lt; Input: Logicals determining if point is an interface
+    real(kind=RKIND), dimension(pointCount,3), intent(in) :: interfaceNormals !&lt; Input: Normals at interfaces
+    real(kind=RKIND), dimension(3), intent(in) :: destinationPoint !&lt; Input: Destination point
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale of RBF
+    real(kind=RKIND), dimension(pointCount,pointCount), intent(out) :: dirichletMatrix !&lt; Output: Dirichlet Matrix
+    real(kind=RKIND), dimension(pointCount,pointCount), intent(out) :: neumannMatrix !&lt; Output: Neumann Matrix
+    real(kind=RKIND), dimension(pointCount), intent(out) :: rhs !&lt; Output: Right hand side
 
     integer :: i, j
 
@@ -1517,19 +1706,31 @@
       rhs(j) = evaluate_rbf(rSquared)
     end do
 
-  end subroutine mpas_set_up_scalar_rbf_matrix_and_rhs
+  end subroutine mpas_set_up_scalar_rbf_matrix_and_rhs!}}}
 
-  subroutine mpas_set_up_vector_dirichlet_rbf_matrix_and_rhs(pointCount, dimensions, &amp;
+!***********************************************************************
+!
+!  routine mpas_set_up_vector_dirichlet_rbf_matrix_and_rhs
+!
+!&gt; \brief   MPAS RBF Vector Matrix and RHS setup routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine sets up the matrix and RHS for vector Dirichlet RBF interpolation.
+!-----------------------------------------------------------------------
+  subroutine mpas_set_up_vector_dirichlet_rbf_matrix_and_rhs(pointCount, dimensions, &amp;!{{{
     sourcePoints, unitVectors, destinationPoint, &amp;
     alpha, matrix, rhs)
 
-    integer, intent(in) :: pointCount, dimensions
-    real(kind=RKIND), dimension(pointCount,dimensions), intent(in) :: sourcePoints
-    real(kind=RKIND), dimension(pointCount,dimensions), intent(in) :: unitVectors
-    real(kind=RKIND), dimension(dimensions), intent(in) :: destinationPoint
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(pointCount,pointCount), intent(out) :: matrix
-    real(kind=RKIND), dimension(pointCount,dimensions), intent(out) :: rhs
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    integer, intent(in) :: dimensions !&lt; Input: Number of dimensions
+    real(kind=RKIND), dimension(pointCount,dimensions), intent(in) :: sourcePoints !&lt; Input: List of points
+    real(kind=RKIND), dimension(pointCount,dimensions), intent(in) :: unitVectors !&lt; Input: List of unit vectors
+    real(kind=RKIND), dimension(dimensions), intent(in) :: destinationPoint !&lt; Input: Destination point
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale of RBFs
+    real(kind=RKIND), dimension(pointCount,pointCount), intent(out) :: matrix !&lt; Output: Matrix
+    real(kind=RKIND), dimension(pointCount,dimensions), intent(out) :: rhs !&lt; Output: Right hand side
 
     integer :: i, j
 
@@ -1550,21 +1751,33 @@
       rhs(j,:) = evaluate_rbf(rSquared)*unitVectors(j,:)
     end do
 
-  end subroutine mpas_set_up_vector_dirichlet_rbf_matrix_and_rhs
+  end subroutine mpas_set_up_vector_dirichlet_rbf_matrix_and_rhs!}}}
 
-  subroutine mpas_set_up_vector_free_slip_rbf_matrix_and_rhs(pointCount, dimensions, &amp;
+!***********************************************************************
+!
+!  routine mpas_set_up_vector_free_slip_rbf_matrix_and_rhs
+!
+!&gt; \brief   MPAS RBF Vector Matrix and RHS setup routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine sets up the matrix and RHS for vector Free Slip RBF interpolation.
+!-----------------------------------------------------------------------
+  subroutine mpas_set_up_vector_free_slip_rbf_matrix_and_rhs(pointCount, dimensions, &amp;!{{{
     sourcePoints, isTangentToInterface, normalVectorIndex, unitVectors, destinationPoint, &amp;
     alpha, matrix, rhs)
 
-    integer, intent(in) :: pointCount, dimensions
-    real(kind=RKIND), dimension(pointCount,dimensions), intent(in) :: sourcePoints
-    logical, dimension(pointCount), intent(in) :: isTangentToInterface
-    integer, dimension(pointCount), intent(in) :: normalVectorIndex
-    real(kind=RKIND), dimension(pointCount,dimensions), intent(in) :: unitVectors
-    real(kind=RKIND), dimension(dimensions), intent(in) :: destinationPoint
-    real(kind=RKIND), intent(in) :: alpha
-    real(kind=RKIND), dimension(pointCount,pointCount), intent(out) :: matrix
-    real(kind=RKIND), dimension(pointCount,dimensions), intent(out) :: rhs
+    integer, intent(in) :: pointCount !&lt; Input: Number of points
+    integer, intent(in) :: dimensions !&lt; Input: Number of dimensions
+    real(kind=RKIND), dimension(pointCount,dimensions), intent(in) :: sourcePoints !&lt; Input: List of points
+    logical, dimension(pointCount), intent(in) :: isTangentToInterface !&lt; Input: Logical to determine if point is tangent to interface
+    integer, dimension(pointCount), intent(in) :: normalVectorIndex !&lt; Input: Index to normal vector
+    real(kind=RKIND), dimension(pointCount,dimensions), intent(in) :: unitVectors !&lt; Input: List of unit vectors
+    real(kind=RKIND), dimension(dimensions), intent(in) :: destinationPoint !&lt; Input: Destination point
+    real(kind=RKIND), intent(in) :: alpha !&lt; Input: Characteristic length scale of RBF
+    real(kind=RKIND), dimension(pointCount,pointCount), intent(out) :: matrix !&lt; Output: Matrix
+    real(kind=RKIND), dimension(pointCount,dimensions), intent(out) :: rhs !&lt; Output: Right hand side
 
     integer :: i, j
 
@@ -1597,24 +1810,47 @@
       rhs(j,:) = evaluate_rbf(rSquared)*unitVectors(j,:)
     end do
 
-  end subroutine mpas_set_up_vector_free_slip_rbf_matrix_and_rhs
+  end subroutine mpas_set_up_vector_free_slip_rbf_matrix_and_rhs!}}}
 
-  subroutine mpas_unit_vec_in_r3(xin)
+!***********************************************************************
+!
+!  routine mpas_unit_vec_in_r3
+!
+!&gt; \brief   MPAS 3D unit vector routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine creates a unit vector out of an input point.
+!-----------------------------------------------------------------------
+  subroutine mpas_unit_vec_in_r3(xin)!{{{
     implicit none
-    real (kind=RKIND), intent(inout) :: xin(3)
+    real (kind=RKIND), intent(inout) :: xin(3) !&lt; Input/Output: Vector and unit vector
     real (kind=RKIND) :: mag
     mag = sqrt(xin(1)**2+xin(2)**2+xin(3)**2)
     xin(:) = xin(:) / mag
-  end subroutine mpas_unit_vec_in_r3
+  end subroutine mpas_unit_vec_in_r3!}}}
 
-  subroutine mpas_cross_product_in_r3(p_1,p_2,p_out)
-    real (kind=RKIND), intent(in) :: p_1 (3), p_2 (3)
-    real (kind=RKIND), intent(out) :: p_out (3)
+!***********************************************************************
+!
+!  routine mpas_cross_product_in_r3
+!
+!&gt; \brief   MPAS 3D cross product routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine computes the cross product of two input vectors.
+!-----------------------------------------------------------------------
+  subroutine mpas_cross_product_in_r3(p_1,p_2,p_out)!{{{
+    real (kind=RKIND), intent(in) :: p_1 (3) !&lt; Input: Vector 1
+    real (kind=RKIND), intent(in) :: p_2 (3) !&lt; Input: Vector 2
+    real (kind=RKIND), intent(out) :: p_out (3) !&lt; Output: Cross product of vector 1 and vector 2
 
     p_out(1) = p_1(2)*p_2(3)-p_1(3)*p_2(2)
     p_out(2) = p_1(3)*p_2(1)-p_1(1)*p_2(3)
     p_out(3) = p_1(1)*p_2(2)-p_1(2)*p_2(1)
-  end subroutine mpas_cross_product_in_r3
+  end subroutine mpas_cross_product_in_r3!}}}
 
 ! Updated 10/24/2001.
 !
@@ -1656,20 +1892,28 @@
 !  WRITE (6, &quot;(F16.8)&quot;) (X(I), I=1,N)
 !END PROGRAM EX43
 
-
-subroutine mpas_legs (A,N,B,X,INDX)
+!***********************************************************************
 !
-! subroutine to solve the equation A(N,N)*X(N) = B(N) with the
-! partial-pivoting Gaussian elimination scheme.
-! Copyright (c) Tao Pang 2001.
+!  routine mpas_legs
 !
+!&gt; \brief   MPAS Gaussian elimination solver routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine solves the equation A(N,N)*X(N) = B(N) with the partial-pivoting
+!&gt; Gaussian Elimination scheme. Copyright (c) Tao Pang 2001.
+!-----------------------------------------------------------------------
+subroutine mpas_legs (A,N,B,X,INDX)!{{{
+
   IMPLICIT NONE
-  integer, INTENT (IN) :: N
-  integer :: I,J
-  integer, INTENT (OUT), DIMENSION (N) :: INDX
-  real(kind=RKIND), INTENT (INOUT), DIMENSION (N,N) :: A
-  real(kind=RKIND), INTENT (INOUT), DIMENSION (N) :: B
-  real(kind=RKIND), INTENT (OUT), DIMENSION (N) :: X
+  integer, INTENT (IN) :: N !&lt; Input: Size of matrix and vectors
+  integer, INTENT (OUT), DIMENSION (N) :: INDX !&lt; Output: Pivot vector
+  real(kind=RKIND), INTENT (INOUT), DIMENSION (N,N) :: A !&lt; Input/Output: Matrix
+  real(kind=RKIND), INTENT (INOUT), DIMENSION (N) :: B !&lt; Input/Output: Right hand side vector
+  real(kind=RKIND), INTENT (OUT), DIMENSION (N) :: X !&lt; Output: Solution
+
+  integer :: I,J 
 !
   CALL elgs (A,N,INDX)
 !
@@ -1688,7 +1932,7 @@
     X(I) =  X(I)/A(INDX(I),I)
   END DO
 !
-END subroutine mpas_legs
+END subroutine mpas_legs!}}}
 !
 
 
@@ -1709,18 +1953,26 @@
 !                                                                       !
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 !
-subroutine migs (A,N,X,INDX)
+!***********************************************************************
 !
-! subroutine to invert matrix A(N,N) with the inverse stored
-! in X(N,N) in the output.  Copyright (c) Tao Pang 2001.
+!  routine migs
 !
+!&gt; \brief   Matrix inversion routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine inverts the matrix A(N,N) and stores it in X(N,B)
+!&gt; Copyright (c) Tao Pang 2001.
+!-----------------------------------------------------------------------
+subroutine migs (A,N,X,INDX)!{{{
   IMPLICIT NONE
-  integer, INTENT (IN) :: N
+  integer, INTENT (IN) :: N !&lt; Input: Size of matrix and inverse
+  integer, INTENT (OUT), DIMENSION (N) :: INDX !&lt; Output: Pivot vector
+  real(kind=RKIND), INTENT (INOUT), DIMENSION (N,N):: A !&lt; Input/Output: Matrix to invert
+  real(kind=RKIND), INTENT (OUT), DIMENSION (N,N):: X !&lt; Output: Inverse of Matrix
+  real(kind=RKIND), DIMENSION (N,N) :: B
   integer :: I,J,K
-  integer, INTENT (OUT), DIMENSION (N) :: INDX
-  real(kind=RKIND), INTENT (INOUT), DIMENSION (N,N):: A
-  real(kind=RKIND), INTENT (OUT), DIMENSION (N,N):: X
-  real(kind=RKIND), DIMENSION (N,N) :: B
 !
   DO I = 1, N
     DO J = 1, N
@@ -1751,10 +2003,22 @@
       X(J,I) =  X(J,I)/A(INDX(J),J)
     END DO
   END DO
-END subroutine migs
+END subroutine migs!}}}
 
+!***********************************************************************
+!
+!  routine elgs
+!
+!&gt; \brief   Partial-pivoting Gaussian elimination routine
+!&gt; \author  Xylar Asay-Davis
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This routine performs the partial-pivoting Gaussian elimination.
+!&gt; Copyright (c) Tao Pang 2001.
+!-----------------------------------------------------------------------
 
-subroutine elgs (A,N,INDX)
+subroutine elgs (A,N,INDX)!{{{
 !
 ! subroutine to perform the partial-pivoting Gaussian elimination.
 ! A(N,N) is the original matrix in the input and transformed matrix
@@ -1762,11 +2026,11 @@
 ! INDX(N) records the pivoting order.  Copyright (c) Tao Pang 2001.
 !
   IMPLICIT NONE
-  integer, INTENT (IN) :: N
+  integer, INTENT (IN) :: N !&lt; Input: Size of matrix
+  integer, INTENT (OUT), DIMENSION (N) :: INDX !&lt; Output: Pivot vector
+  real(kind=RKIND), INTENT (INOUT), DIMENSION (N,N) :: A !&lt; Input/Output: Matrix and solution
   integer :: I,J,K,ITMP
-  integer, INTENT (OUT), DIMENSION (N) :: INDX
   real(kind=RKIND) :: C1,PI,PI1,PJ
-  real(kind=RKIND), INTENT (INOUT), DIMENSION (N,N) :: A
   real(kind=RKIND), DIMENSION (N) :: C
 !
 ! Initialize the index
@@ -1818,7 +2082,7 @@
     END DO
   END DO
 !
-END subroutine elgs
+END subroutine elgs!}}}
 
 end module mpas_rbf_interpolation
 

Modified: branches/mpas_cdg_advection/src/operators/mpas_spline_interpolation.F
===================================================================
--- branches/mpas_cdg_advection/src/operators/mpas_spline_interpolation.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/operators/mpas_spline_interpolation.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,3 +1,15 @@
+!***********************************************************************
+!
+!  mpas_spline_interpolation
+!
+!&gt; \brief   MPAS Vector reconstruction module
+!&gt; \author  Mark Petersen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This module provides routines for performing spline interpolation.
+!
+!-----------------------------------------------------------------------
 module mpas_spline_interpolation
 
   use mpas_kind_types
@@ -13,44 +25,42 @@
               mpas_interpolate_linear, &amp;
               mpas_test_interpolate
 
-! Short Descriptions:
-
-!   mpas_cubic_spline_coefficients: Compute second derivatives at nodes.  
-!      This must be run before any of the other cubic spine functions.
-
-!   mpas_interpolate_cubic_spline: Compute cubic spline interpolation. 
-
-!   mpas_integrate_cubic_spline:  Compute a single integral from spline data.
-
-!   mpas_integrate_column_cubic_spline:  Compute multiple integrals from spline data.
-
-!   mpas_interpolate_linear:  Compute linear interpolation.
-
-!   mpas_test_interpolate:  Test spline interpolation subroutines.
-
   contains
 
- subroutine mpas_cubic_spline_coefficients(x,y,n,y2ndDer)  
+!***********************************************************************
+!
+!  routine mpas_cubic_spline_coefficients
+!
+!&gt; \brief   MPAS Cubic spline coefficients routine
+!&gt; \author  Mark Petersen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes second derivatives at nodes.  
+!&gt;  This must be run before any of the other cubic spine functions.
+!&gt;
+!&gt;  Given arrays x(1:n) and y(1:n) containing a function,
+!&gt;  i.e., y(i) = f(x(i)), with x monotonically increasing
+!&gt;  this routine returns an array y2ndDer(1:n) that contains 
+!&gt;  the second derivatives of the interpolating function at x(1:n). 
+!&gt;  This routine uses boundary conditions for a natural spline, 
+!&gt;  with zero second derivative on that boundary.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_cubic_spline_coefficients(x,y,n,y2ndDer)  !{{{
 
-!  Given arrays x(1:n) and y(1:n) containing a function,
-!  i.e., y(i) = f(x(i)), with x monotonically increasing
-!  this routine returns an array y2ndDer(1:n) that contains 
-!  the second derivatives of the interpolating function at x(1:n). 
-!  This routine uses boundary conditions for a natural spline, 
-!  with zero second derivative on that boundary.
-
 ! INPUT PARAMETERS:
 
   integer, intent(in) :: &amp;
-    n     ! number of nodes
+    n     !&lt; Input: number of nodes
   real(kind=RKIND), intent(in), dimension(n) :: &amp;
-    x,   &amp;! location of nodes
-    y     ! value at nodes
+    x,   &amp;!&lt; Input: location of nodes
+    y     !&lt; Input: value at nodes
 
 ! OUTPUT PARAMETERS:
 
   real(kind=RKIND), intent(out), dimension(n) :: &amp;
-    y2ndDer    ! dy^2/dx^2 at each node
+    y2ndDer    !&lt; Output: dy^2/dx^2 at each node
 
 !  local variables:
 
@@ -75,39 +85,48 @@
       y2ndDer(i)=y2ndDer(i)*y2ndDer(i+1)+a(i)  
    enddo
 
-  end subroutine mpas_cubic_spline_coefficients
+  end subroutine mpas_cubic_spline_coefficients!}}}
 
-
-  subroutine mpas_interpolate_cubic_spline( &amp;
+!***********************************************************************
+!
+!  routine mpas_interpolate_cubic_spline
+!
+!&gt; \brief   MPAS Cubic spline interpolation routine
+!&gt; \author  Mark Petersen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  Given the arrays x(1:n) and y(1:n), which tabulate a function,
+!&gt;  and given the array y2ndDer(1:n), which is the output from 
+!&gt;  CubicSplineCoefficients above, this routine returns the 
+!&gt;  cubic-spline interpolated values of yOut(1:nOut) at xOut(1:nOut).
+!&gt;  This subroutine assumes that both x and xOut are monotonically
+!&gt;  increasing, and that all values of xOut are within the first and
+!&gt;  last values of x.
+!
+!-----------------------------------------------------------------------
+  subroutine mpas_interpolate_cubic_spline( &amp;!{{{
                 x,y,y2ndDer,n, &amp;
                 xOut,yOut,nOut)  
 
-!  Given the arrays x(1:n) and y(1:n), which tabulate a function,
-!  and given the array y2ndDer(1:n), which is the output from 
-!  CubicSplineCoefficients above, this routine returns the 
-!  cubic-spline interpolated values of yOut(1:nOut) at xOut(1:nOut).
-!  This subroutine assumes that both x and xOut are monotonically
-!  increasing, and that all values of xOut are within the first and
-!  last values of x.
-
 ! INPUT PARAMETERS:
 
   real (kind=RKIND), dimension(n), intent(in) :: &amp;
-    x,         &amp;! node location, input grid
-    y,       &amp;! interpolation variable, input grid
-    y2ndDer     ! 2nd derivative of y at nodes
+    x,         &amp;!&lt; Input: node location, input grid
+    y,       &amp;!&lt; Input: interpolation variable, input grid
+    y2ndDer     !&lt; Input: 2nd derivative of y at nodes
 
   real (kind=RKIND), dimension(nOut), intent(in) :: &amp;
-    xOut          ! node location, output grid
+    xOut          !&lt; Input: node location, output grid
 
   integer, intent(in) :: &amp;
-    n,      &amp;! number of nodes, input grid
-    nOut       ! number of nodes, output grid
+    n,      &amp;!&lt; Input: number of nodes, input grid
+    nOut       !&lt; Input: number of nodes, output grid
 
 ! OUTPUT PARAMETERS:
 
   real (kind=RKIND), dimension(nOut), intent(out) :: &amp;
-    yOut        ! interpolation variable, output grid
+    yOut        !&lt; Output: interpolation variable, output grid
 
 !  local variables:
 
@@ -139,34 +158,43 @@
   
   enddo kInLoop
 
-end subroutine mpas_interpolate_cubic_spline
+end subroutine mpas_interpolate_cubic_spline!}}}
 
+!***********************************************************************
+!
+!  routine mpas_integrate_cubic_spline
+!
+!&gt; \brief   MPAS Cubic spline integration routine
+!&gt; \author  Mark Petersen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  Given the arrays x(1:n) and y(1:n), which tabulate a function,
+!&gt;  and given the array y2ndDer(1:n), which is the output from 
+!&gt;  CubicSplineCoefficients above, this routine returns y_integral,
+!&gt;  the integral of y from x1 to x2.  The integration formula was 
+!&gt;  created by analytically integrating a cubic spline between each node.
+!&gt;  This subroutine assumes that x is monotonically increasing, and
+!&gt;  that x1 &lt; x2.
+!
+!-----------------------------------------------------------------------
+subroutine mpas_integrate_cubic_spline(x,y,y2ndDer,n,x1,x2,y_integral)  !{{{
 
-subroutine mpas_integrate_cubic_spline(x,y,y2ndDer,n,x1,x2,y_integral)  
-
-!  Given the arrays x(1:n) and y(1:n), which tabulate a function,
-!  and given the array y2ndDer(1:n), which is the output from 
-!  CubicSplineCoefficients above, this routine returns y_integral,
-!  the integral of y from x1 to x2.  The integration formula was 
-!  created by analytically integrating a cubic spline between each node.
-!  This subroutine assumes that x is monotonically increasing, and
-!  that x1 &lt; x2.
-
 ! INPUT PARAMETERS:
 
   integer, intent(in) :: &amp;
-    n     ! number of nodes
+    n     !&lt; Input: number of nodes
   real(kind=RKIND), intent(in), dimension(n) :: &amp;
-    x,   &amp;! location of nodes
-    y,   &amp;! value at nodes
-    y2ndDer    ! dy^2/dx^2 at each node
+    x,   &amp;!&lt; Input: location of nodes
+    y,   &amp;!&lt; Input: value at nodes
+    y2ndDer    !&lt; Input: dy^2/dx^2 at each node
   real(kind=RKIND), intent(in) :: &amp;
-    x1,x2 ! limits of integration
+    x1,x2 !&lt; Input: limits of integration
 
 ! OUTPUT PARAMETERS:
 
   real(kind=RKIND), intent(out) :: &amp;
-    y_integral  ! integral of y
+    y_integral  !&lt; Output: integral of y
 
 !  local variables:
   
@@ -215,40 +243,49 @@
 
   enddo ! j
 
-  end subroutine mpas_integrate_cubic_spline
+  end subroutine mpas_integrate_cubic_spline!}}}
 
-
-  subroutine mpas_integrate_column_cubic_spline( &amp;
+!***********************************************************************
+!
+!  routine mpas_integrate_column_cubic_spline
+!
+!&gt; \brief   MPAS Cubic spline column integration routine
+!&gt; \author  Mark Petersen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  Given the arrays x(1:n) and y(1:n), which tabulate a function,
+!&gt;  and given the array y2ndDer(1:n), which is the output from 
+!&gt;  CubicSplineCoefficients above, this routine returns 
+!&gt;  y_integral(1:nOut), the integral of y.
+!&gt;  This is a cumulative integration, so that
+!&gt;  y_integral(j) holds the integral of y from x(1) to xOut(j).
+!&gt;  The integration formula was created by analytically integrating a 
+!&gt;  cubic spline between each node.
+!&gt;  This subroutine assumes that both x and xOut are monotonically
+!&gt;  increasing, and that all values of xOut are within the first and
+!
+!-----------------------------------------------------------------------
+  subroutine mpas_integrate_column_cubic_spline( &amp;!{{{
                x,y,y2ndDer,n, &amp;
                xOut,y_integral, nOut)  
 
-!  Given the arrays x(1:n) and y(1:n), which tabulate a function,
-!  and given the array y2ndDer(1:n), which is the output from 
-!  CubicSplineCoefficients above, this routine returns 
-!  y_integral(1:nOut), the integral of y.
-!  This is a cumulative integration, so that
-!  y_integral(j) holds the integral of y from x(1) to xOut(j).
-!  The integration formula was created by analytically integrating a 
-!  cubic spline between each node.
-!  This subroutine assumes that both x and xOut are monotonically
-!  increasing, and that all values of xOut are within the first and
-
 ! INPUT PARAMETERS:
 
   integer, intent(in) :: &amp;
-    n,   &amp;! number of nodes
-    nOut  ! number of output locations to compute integral
+    n,   &amp;!&lt; Input: number of nodes
+    nOut  !&lt; Input: number of output locations to compute integral
   real(kind=RKIND), intent(in), dimension(n) :: &amp;
-    x,   &amp;! location of nodes
-    y,   &amp;! value at nodes
-    y2ndDer    ! dy^2/dx^2 at each node
+    x,   &amp;!&lt; Input: location of nodes
+    y,   &amp;!&lt; Input: value at nodes
+    y2ndDer    !&lt; Input: dy^2/dx^2 at each node
   real(kind=RKIND), dimension(nOut), intent(in) :: &amp;
-    xOut  ! output locations to compute integral
+    xOut  !&lt; Input: output locations to compute integral
 
 ! OUTPUT PARAMETERS:
 
   real(kind=RKIND), dimension(nOut), intent(out) :: &amp;
-    y_integral  ! integral from 0 to xOut
+    y_integral  !&lt; Output: integral from 0 to xOut
 
 !  local variables:
 
@@ -295,37 +332,47 @@
 
   enddo k_loop
 
- end subroutine mpas_integrate_column_cubic_spline
+ end subroutine mpas_integrate_column_cubic_spline!}}}
 
-
- subroutine mpas_interpolate_linear( &amp;
+!***********************************************************************
+!
+!  routine mpas_interpolate_linear
+!
+!&gt; \brief   MPAS Linear interpolation routine
+!&gt; \author  Mark Petersen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  Given the arrays x(1:n) and y(1:n), which tabulate a function,
+!&gt;  this routine returns the linear interpolated values of yOut(1:nOut)
+!&gt;  at xOut(1:nOut).
+!&gt;  This subroutine assumes that both x and xOut are monotonically
+!&gt;  increasing, and that all values of xOut are within the first and
+!&gt;  last values of x.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_interpolate_linear( &amp;!{{{
                 x,y,n, &amp;
                 xOut,yOut,nOut)  
 
-!  Given the arrays x(1:n) and y(1:n), which tabulate a function,
-!  this routine returns the linear interpolated values of yOut(1:nOut)
-!  at xOut(1:nOut).
-!  This subroutine assumes that both x and xOut are monotonically
-!  increasing, and that all values of xOut are within the first and
-!  last values of x.
 
 ! !INPUT PARAMETERS:
 
   real (kind=RKIND), dimension(n), intent(in) :: &amp;
-    x,         &amp;! node location, input grid
-    y         ! interpolation variable, input grid
+    x,         &amp;!&lt; Input: node location, input grid
+    y         !&lt; Input: interpolation variable, input grid
 
   real (kind=RKIND), dimension(nOut), intent(in) :: &amp;
-    xOut          ! node location, output grid
+    xOut          !&lt; Input: node location, output grid
 
   integer, intent(in) :: &amp;
-    N,      &amp;! number of nodes, input grid
-    NOut       ! number of nodes, output grid
+    N,      &amp;!&lt; Input: number of nodes, input grid
+    NOut       !&lt; Input: number of nodes, output grid
 
 ! !OUTPUT PARAMETERS:
 
   real (kind=RKIND), dimension(nOut), intent(out) :: &amp;
-    yOut        ! interpolation variable, output grid
+    yOut        !&lt; Output: interpolation variable, output grid
 
 !-----------------------------------------------------------------------
 !
@@ -355,13 +402,22 @@
   
   enddo kInLoop
 
-  end subroutine mpas_interpolate_linear
+  end subroutine mpas_interpolate_linear!}}}
 
+!***********************************************************************
+!
+!  routine mpas_test_interpolate
+!
+!&gt; \brief   MPAS Interpolation test routine
+!&gt; \author  Mark Petersen
+!&gt; \date    04/02/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  Test routine to show how to operate the cubic spline subroutines
+!
+!-----------------------------------------------------------------------
+  subroutine mpas_test_interpolate!{{{
 
-  subroutine mpas_test_interpolate
-
-!  Test function to show how to operate the cubic spline subroutines
-
   integer, parameter :: &amp;
     n = 10
   real (kind=RKIND), dimension(n) :: &amp;
@@ -426,7 +482,7 @@
    print '(a,100f8.4,a)', 'yOut = [',yOut,'];'
    print *, &quot;plot(x,y,'-*r',xOut,yOut,'x')&quot;
 
-  end subroutine mpas_test_interpolate
+  end subroutine mpas_test_interpolate!}}}
 
 end module mpas_spline_interpolation
 

Modified: branches/mpas_cdg_advection/src/operators/mpas_vector_reconstruction.F
===================================================================
--- branches/mpas_cdg_advection/src/operators/mpas_vector_reconstruction.F        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/operators/mpas_vector_reconstruction.F        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,3 +1,15 @@
+!***********************************************************************
+!
+!  mpas_vector_reconstruction
+!
+!&gt; \brief   MPAS Vector reconstruction module
+!&gt; \author  Xylar Asay-Davis, Todd Ringler
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt; This module provides routines for performing vector reconstruction from edges to cell centers.
+!
+!-----------------------------------------------------------------------
 module mpas_vector_reconstruction
 
   use mpas_grid_types
@@ -11,19 +23,25 @@
 
   contains
 
-  subroutine mpas_init_reconstruct(grid)
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  ! Purpose: pre-compute coefficients used by the reconstruct() routine
-  !
-  ! Input: grid meta data
-  !
-  ! Output: grid % coeffs_reconstruct - coefficients used to reconstruct 
-  !                                     velocity vectors at cell centers 
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
+!***********************************************************************
+!
+!  routine mpas_init_reconstruct
+!
+!&gt; \brief   MPAS Vector reconstruction initialization routine
+!&gt; \author  Xylar Asay-Davis, Todd Ringler
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  Purpose: pre-compute coefficients used by the reconstruct() routine
+!&gt;  Input: grid meta data
+!&gt;  Output: grid % coeffs_reconstruct - coefficients used to reconstruct 
+!&gt;                                      velocity vectors at cell centers 
+!-----------------------------------------------------------------------
+  subroutine mpas_init_reconstruct(grid)!{{{
 
     implicit none
 
-    type (mesh_type), intent(inout) :: grid 
+    type (mesh_type), intent(inout) :: grid  !&lt; Input/Output: Grid information
 
     ! temporary arrays needed in the (to be constructed) init procedure
     integer :: nCellsSolve
@@ -110,23 +128,32 @@
     deallocate(edgeOnCellNormals)
     deallocate(coeffs)
 
-  end subroutine mpas_init_reconstruct
+  end subroutine mpas_init_reconstruct!}}}
 
-  subroutine mpas_reconstruct(grid, u, uReconstructX, uReconstructY, uReconstructZ, uReconstructZonal, uReconstructMeridional)
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  ! Purpose: reconstruct vector field at cell centers based on radial basis functions
-  !
-  ! Input: grid meta data and vector component data residing at cell edges
-  !
-  ! Output: reconstructed vector field (measured in X,Y,Z) located at cell centers
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!***********************************************************************
+!
+!  routine mpas_reconstruct
+!
+!&gt; \brief   MPAS Vector reconstruction routine
+!&gt; \author  Xylar Asay-Davis, Todd Ringler
+!&gt; \date    03/28/13
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  Purpose: reconstruct vector field at cell centers based on radial basis functions
+!&gt;  Input: grid meta data and vector component data residing at cell edges
+!&gt;  Output: reconstructed vector field (measured in X,Y,Z) located at cell centers
+!-----------------------------------------------------------------------
+  subroutine mpas_reconstruct(grid, u, uReconstructX, uReconstructY, uReconstructZ, uReconstructZonal, uReconstructMeridional)!{{{
 
     implicit none
 
-    type (mesh_type), intent(in) :: grid
-    real (kind=RKIND), dimension(:,:), intent(in) :: u
-    real (kind=RKIND), dimension(:,:), intent(out) :: uReconstructX, uReconstructY, uReconstructZ
-    real (kind=RKIND), dimension(:,:), intent(out) :: uReconstructZonal, uReconstructMeridional
+    type (mesh_type), intent(in) :: grid !&lt; Input: Grid information
+    real (kind=RKIND), dimension(:,:), intent(in) :: u !&lt; Input: Velocity field on edges
+    real (kind=RKIND), dimension(:,:), intent(out) :: uReconstructX !&lt; Output: X Component of velocity reconstructed to cell centers
+    real (kind=RKIND), dimension(:,:), intent(out) :: uReconstructY !&lt; Output: Y Component of velocity reconstructed to cell centers
+    real (kind=RKIND), dimension(:,:), intent(out) :: uReconstructZ !&lt; Output: Z Component of velocity reconstructed to cell centers
+    real (kind=RKIND), dimension(:,:), intent(out) :: uReconstructZonal !&lt; Output: Zonal Component of velocity reconstructed to cell centers
+    real (kind=RKIND), dimension(:,:), intent(out) :: uReconstructMeridional !&lt; Output: Meridional Component of velocity reconstructed to cell centers
 
     !   temporary arrays needed in the compute procedure
     integer :: nCellsSolve
@@ -191,6 +218,6 @@
       uReconstructMeridional = uReconstructY
     end if
 
-  end subroutine mpas_reconstruct
+  end subroutine mpas_reconstruct!}}}
 
 end module mpas_vector_reconstruction

Modified: branches/mpas_cdg_advection/src/registry/Makefile
===================================================================
--- branches/mpas_cdg_advection/src/registry/Makefile        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/registry/Makefile        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,14 +1,17 @@
 .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)
 
 clean:
-        $(RM) *.o parse
+        $(RM) *.o ezxml/*.o parse
 
 .c.o:
         $(CC) -c $&lt;

Copied: branches/mpas_cdg_advection/src/registry/Registry.xsd (from rev 2782, trunk/mpas/src/registry/Registry.xsd)
===================================================================
--- branches/mpas_cdg_advection/src/registry/Registry.xsd                                (rev 0)
+++ branches/mpas_cdg_advection/src/registry/Registry.xsd        2013-04-22 01:31:32 UTC (rev 2783)
@@ -0,0 +1,125 @@
+&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;!-- The model attribute defines the name of the model that is being run. Typically this will be MPAS. It will be written to all output files as a global attribute. --&gt;
+                        &lt;xs:attribute name=&quot;model&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                        &lt;!-- The core attribute defines the core a Registry.xml file belongs to. It will be written to all output files as a global attribute. --&gt;
+                        &lt;xs:attribute name=&quot;core&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                        &lt;!-- The version attribute defines the version of the model/core combination. It will be written to all output files as a global attribute. --&gt;
+                        &lt;xs:attribute name=&quot;version&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                &lt;/xs:complexType&gt;
+        &lt;/xs:element&gt;
+&lt;/xs:schema&gt;

Modified: branches/mpas_cdg_advection/src/registry/gen_inc.c
===================================================================
--- branches/mpas_cdg_advection/src/registry/gen_inc.c        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/registry/gen_inc.c        2013-04-22 01:31:32 UTC (rev 2783)
@@ -169,7 +169,18 @@
    fclose(fd);
 }
 
+void gen_history_attributes(char * modelname, char * corename, char * version)
+{
+        FILE *fd;
 
+        fd = fopen(&quot;model_variables.inc&quot;,&quot;w&quot;);
+        fortprintf(fd, &quot;       character (len=StrKIND) :: modelName = '%s' !&lt; Constant: Name of model</font>
<font color="blue">&quot;, modelname);
+        fortprintf(fd, &quot;       character (len=StrKIND) :: coreName = '%s' !&lt; Constant: Name of core</font>
<font color="blue">&quot;, corename);
+        fortprintf(fd, &quot;       character (len=StrKIND) :: modelVersion = '%s' !&lt; Constant: Version number</font>
<font color="gray">&quot;, version);
+        fclose(fd);
+}
+
+
 void gen_field_defs(struct group_list * groups, struct variable * vars, struct dimension * dims)
 {
    struct variable * var_ptr;
@@ -822,8 +833,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) ||
@@ -1161,7 +1174,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;);        
@@ -1389,7 +1405,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;
@@ -2119,8 +2135,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);
@@ -2176,8 +2194,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);
@@ -2383,7 +2403,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;
@@ -2565,8 +2585,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/mpas_cdg_advection/src/registry/gen_inc.h
===================================================================
--- branches/mpas_cdg_advection/src/registry/gen_inc.h        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/registry/gen_inc.h        2013-04-22 01:31:32 UTC (rev 2783)
@@ -1,4 +1,5 @@
 void gen_namelists(struct namelist *);
+void gen_history_attributes(char * modelname, char * corename, char * version);
 void gen_field_defs(struct group_list * groups, struct variable *, struct dimension *);
 void gen_reads(struct group_list * groups, struct variable *, struct dimension *);
 void gen_writes(struct group_list * groups, struct variable *, struct dimension *, struct namelist *);

Modified: branches/mpas_cdg_advection/src/registry/parse.c
===================================================================
--- branches/mpas_cdg_advection/src/registry/parse.c        2013-04-19 20:21:24 UTC (rev 2782)
+++ branches/mpas_cdg_advection/src/registry/parse.c        2013-04-22 01:31:32 UTC (rev 2783)
@@ -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 *);
@@ -18,6 +19,8 @@
    struct variable * vars;
    struct group_list * groups;
 
+   char modelname[1024], corename[1024], version[1024];
+
    if (argc != 2) {
       fprintf(stderr,&quot;Reading registry file from standard input</font>
<font color="gray">&quot;);
       regfile = stdin;
@@ -30,13 +33,21 @@
    nls = NULL;
    dims = NULL;
    vars = NULL;
+  
+   if (parse_reg_xml(regfile, &amp;nls, &amp;dims, &amp;vars, &amp;groups, &amp;modelname, &amp;corename, &amp;version)) {
+      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);
 
+   gen_history_attributes(modelname, corename, version);
    gen_namelists(nls);
    gen_field_defs(groups, vars, dims);
    gen_reads(groups, vars, dims);
@@ -45,7 +56,412 @@
    return 0;
 }
 
+int parse_reg_xml(FILE * regfile, struct namelist **nls, struct dimension ** dims, struct variable ** vars, struct group_list ** groups, char * modelname, char * corename, char * version)
+{
+        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;
+        const char *const_model, *const_core, *const_version;
+
+        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;
+
+        // Get model information
+        const_model = ezxml_attr(registry, &quot;model&quot;);
+        const_core = ezxml_attr(registry, &quot;core&quot;);
+        const_version = ezxml_attr(registry, &quot;version&quot;);
+
+        if(const_model == NULL)
+                sprintf(modelname, &quot;MISSING&quot;);
+        else
+                sprintf(modelname, &quot;%s&quot;, const_model);
+
+        if(const_core == NULL)
+                sprintf(corename, &quot;MISSING&quot;);
+        else
+                sprintf(corename, &quot;%s&quot;, const_core);
+
+        if(const_version == NULL)
+                sprintf(version, &quot;MISSING&quot;);
+        else
+                sprintf(version, &quot;%s&quot;, const_version);
+
+        // 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 +644,6 @@
             vlist_cursor-&gt;var = var_ptr;
          }
 
-
          getword(regfile, var_ptr-&gt;super_array);
          getword(regfile, var_ptr-&gt;array_class);
 
@@ -402,7 +817,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>