<p><b>dwj07@fsu.edu</b> 2013-03-29 08:40:23 -0600 (Fri, 29 Mar 2013)</p><p><br>
        -- BRANCH COMMIT --<br>
<br>
        Merging trunk into openmp elements branch.<br>
        Validates on a single processor (no OpenMP).<br>
</p><hr noshade><pre><font color="gray">Index: branches/ocean_projects/openmp_elements
===================================================================
--- branches/ocean_projects/openmp_elements        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements        2013-03-29 14:40:23 UTC (rev 2678)

Property changes on: branches/ocean_projects/openmp_elements
___________________________________________________________________
Modified: svn:mergeinfo
## -4,16 +4,22 ##
 /branches/ocean_projects/ale_vert_coord:1225-1383
 /branches/ocean_projects/ale_vert_coord_new:1387-1428
 /branches/ocean_projects/cesm_coupling:2147-2344
+/branches/ocean_projects/comment_cleanup:2626-2630
+/branches/ocean_projects/diagnostics_revision:2439-2462
+/branches/ocean_projects/explicit_vmix_removal:2486-2490
 /branches/ocean_projects/gmvar:1214-1514,1517-1738
 /branches/ocean_projects/imp_vert_mix_error:1847-1887
 /branches/ocean_projects/imp_vert_mix_mrp:754-986
 /branches/ocean_projects/leith_mrp:2182-2241
+/branches/ocean_projects/linear_eos:2435-2437
 /branches/ocean_projects/monotonic_advection:1499-1640
 /branches/ocean_projects/monthly_forcing:1810-1867
 /branches/ocean_projects/namelist_cleanup:2319-2414
 /branches/ocean_projects/option3_b4b_test:2201-2231
 /branches/ocean_projects/partial_bottom_cells:2172-2226
+/branches/ocean_projects/remove_sw_test_cases:2539-2540
 /branches/ocean_projects/restart_reproducibility:2239-2272
+/branches/ocean_projects/sea_level_pressure:2488-2528
 /branches/ocean_projects/split_explicit_mrp:1134-1138
 /branches/ocean_projects/split_explicit_timestepping:1044-1097
 /branches/ocean_projects/vert_adv_mrp:704-745
## -24,6 +30,8 ##
 /branches/omp_blocks/halo:1570-1638
 /branches/omp_blocks/io:1639-1787
 /branches/omp_blocks/multiple_blocks:1803-2084
+/branches/scratch_indication:2555-2656
 /branches/source_renaming:1082-1113
 /branches/time_manager:924-962
-/trunk/mpas:2346-2428
+/branches/xml_registry:2610-2662
+/trunk/mpas:2346-2677
\ No newline at end of property
Modified: branches/ocean_projects/openmp_elements/Makefile
===================================================================
--- branches/ocean_projects/openmp_elements/Makefile        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/Makefile        2013-03-29 14:40:23 UTC (rev 2678)
@@ -363,12 +363,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/ocean_projects/openmp_elements/namelist.input.nhyd_atmos
===================================================================
--- branches/ocean_projects/openmp_elements/namelist.input.nhyd_atmos        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/namelist.input.nhyd_atmos        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/namelist.input.ocean
===================================================================
--- branches/ocean_projects/openmp_elements/namelist.input.ocean        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/namelist.input.ocean        2013-03-29 14:40:23 UTC (rev 2678)
@@ -4,19 +4,18 @@
         config_stop_time = 'none'
         config_run_duration = '0_06:00:00'
         config_calendar_type = '360day'
-        config_ncouple_per_day = 1
 /
 &amp;io
         config_input_name = 'grid.nc'
         config_output_name = 'output.nc'
         config_restart_name = 'restart.nc'
-        config_restart_interval = '0_03:00:00'
+        config_restart_interval = '0_06:00:00'
         config_output_interval = '0_06:00:00'
-        config_stats_interval = '00_00:00:01'
-        config_write_stats_on_startup = .false.
-        config_write_output_on_startup = .false.
-        config_frames_per_outfile = 0
-        config_pio_num_iotasks = 0 
+        config_stats_interval = '0_01:00:00'
+        config_write_stats_on_startup = .true.
+        config_write_output_on_startup = .true.
+        config_frames_per_outfile = 1000
+        config_pio_num_iotasks = 0
         config_pio_stride = 1
 /
 &amp;time_integration
@@ -25,7 +24,6 @@
 /
 &amp;grid
         config_num_halos = 3
-        config_enforce_grid_on_restart = .false.
         config_vert_coord_movement = 'uniform_stretching'
         config_alter_ICs_for_pbcs = 'zlevel_pbcs_off'
         config_min_pbc_fraction = 0.10
@@ -38,23 +36,23 @@
         config_proc_decomp_file_prefix = 'graph.info.part.'
 /
 &amp;hmix
-        config_h_ScaleWithMesh = .true.
+        config_hmix_ScaleWithMesh = .false.
         config_visc_vorticity_term = .true.
         config_apvm_scale_factor = 0.0
 /
 &amp;hmix_del2
         config_use_mom_del2 = .false.
         config_use_tracer_del2 = .false.
-        config_h_mom_eddy_visc2 = 0.0
-        config_h_tracer_eddy_diff2 = 0.0
-        config_visc_vorticity_visc2_scale = 1.0
+        config_mom_del2 = 0.0
+        config_tracer_del2 = 0.0
+        config_vorticity_del2_scale = 1.0
 /
 &amp;hmix_del4
         config_use_mom_del4 = .true.
         config_use_tracer_del4 = .false.
-        config_h_mom_eddy_visc4 = 5.0e13
-        config_h_tracer_eddy_diff4 = 0.0
-        config_visc_vorticity_visc4_scale = 1.0
+        config_mom_del4 = 5.0e13
+        config_tracer_del4 = 0.0
+        config_vorticity_del4_scale = 1.0
 /
 &amp;hmix_Leith
         config_use_Leith_del2 = .false.
@@ -71,7 +69,6 @@
         config_Rayleigh_damping_coeff = 0.0
 /
 &amp;vmix
-        config_implicit_vertical_mix = .true.
         config_convective_visc = 1.0
         config_convective_diff = 1.0
 /
@@ -121,6 +118,13 @@
 &amp;eos
         config_eos_type = 'jm'
 /
+&amp;eos_linear
+        config_eos_linear_alpha = 2.55e-1
+        config_eos_linear_beta = 7.64e-1
+        config_eos_linear_Tref = 19.0
+        config_eos_linear_Sref = 35.0
+        config_eos_linear_rhoref = 1025.022
+/
 &amp;split_explicit_ts
         config_n_ts_iter = 2
         config_n_bcl_iter_beg = 1
@@ -135,13 +139,10 @@
         config_btr_gam3_uWt2 = 1.0
         config_btr_solve_SSH2 = .false.
 /
-&amp;sw_model
-        config_test_case = 0
-/
 &amp;debug
         config_check_zlevel_consistency = .false.
         config_filter_btr_mode = .false.
-        config_prescribe_velocity  = .false.
+        config_prescribe_velocity = .false.
         config_prescribe_thickness = .false.
         config_include_KE_vertex = .false.
         config_check_tracer_monotonicity = .false.

Modified: branches/ocean_projects/openmp_elements/src/Makefile
===================================================================
--- branches/ocean_projects/openmp_elements/src/Makefile        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/Makefile        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/Makefile
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/Makefile        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/Makefile        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_control.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_control.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_control.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_date_time.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_date_time.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_date_time.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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 
@@ -118,6 +119,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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_convection_deep.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_convection_deep.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_convection_deep.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_gwdo.F (from rev 2677, trunk/mpas/src/core_atmos_physics/mpas_atmphys_driver_gwdo.F)
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_gwdo.F                                (rev 0)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_gwdo.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_lsm.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_lsm.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_lsm.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_microphysics.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_microphysics.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_microphysics.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_pbl.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_pbl.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_pbl.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_radiation_lw.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_radiation_lw.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_radiation_lw.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_radiation_sw.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_radiation_sw.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_radiation_sw.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_sfclayer.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_sfclayer.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_driver_sfclayer.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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
@@ -135,59 +141,52 @@
     qfx_p(i,j)    = diag_physics % qfx    % array(i)
     qsfc_p(i,j)   = diag_physics % qsfc   % array(i) 
     mol_p(i,j)    = diag_physics % mol    % array(i) 
+    regime_p(i,j) = diag_physics % regime % array(i)
     ust_p(i,j)    = diag_physics % ust    % array(i)
-    ustm_p(i,j)   = diag_physics % ustm   % 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.
+    br_p(i,j)     = 0._RKIND
     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.
+    chs_p(i,j)    = 0._RKIND
+    chs2_p(i,j)   = 0._RKIND
+    cqs2_p(i,j)   = 0._RKIND
+    flhc_p(i,j)   = 0._RKIND
+    flqc_p(i,j)   = 0._RKIND
+    fh_p(i,j)     = 0._RKIND
+    fm_p(i,j)     = 0._RKIND
+    gz1oz0_p(i,j) = 0._RKIND
+    lh_p(i,j)     = 0._RKIND
+    psim_p(i,j)   = 0._RKIND
+    psih_p(i,j)   = 0._RKIND
+    qgh_p(i,j)    = 0._RKIND
+    rmol_p(i,j)   = 0._RKIND
+    wspd_p(i,j)   = 0._RKIND
+    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 % flhc   % array(i) = flhc_p(i,j)
     diag_physics % flqc   % array(i) = flqc_p(i,j)
@@ -203,7 +202,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 +216,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 +240,9 @@
 
  end subroutine init_sfclayer
 
-!=============================================================================================
+!==================================================================================================
  subroutine driver_sfclayer(mesh,diag_physics,sfc_input)
-!=============================================================================================
+!==================================================================================================
 
 !input and inout arguments:
 !--------------------------
@@ -256,7 +254,7 @@
 !----------------
  real(kind=RKIND):: dx
 
-!---------------------------------------------------------------------------------------------
+!--------------------------------------------------------------------------------------------------
  write(0,*)
  write(0,*) '--- enter subroutine driver_sfclayer:'
 
@@ -267,32 +265,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 +338,6 @@
 
  end subroutine driver_sfclayer
 
-!=============================================================================================
+!==================================================================================================
  end module mpas_atmphys_driver_sfclayer
-!=============================================================================================
+!==================================================================================================

Modified: branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_initialize_real.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_initialize_real.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_initialize_real.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_interface_nhyd.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_interface_nhyd.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_interface_nhyd.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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,6 +100,14 @@
  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
 
 !=============================================================================================
@@ -114,7 +131,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 +169,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 +179,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 +220,7 @@
  enddo
  enddo
 
+!arrays located at w points:
  do j = jts, jte
  do k = kts,kte+1
  do i = its,ite
@@ -225,38 +230,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 +279,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,31 +290,35 @@
     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
 
@@ -546,15 +544,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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_manager.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_manager.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_manager.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_todynamics.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_todynamics.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_todynamics.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_update_surface.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_update_surface.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_update_surface.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_vars.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_vars.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/mpas_atmphys_vars.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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;!
@@ -344,6 +419,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 +449,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 +464,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/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/Makefile
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/Makefile        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/Makefile        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_bl_gwdo.F (from rev 2677, trunk/mpas/src/core_atmos_physics/physics_wrf/module_bl_gwdo.F)
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_bl_gwdo.F                                (rev 0)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_bl_gwdo.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_bl_ysu.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_bl_ysu.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_bl_ysu.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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,21 @@
 !              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
 !
 !     references:
 !
@@ -324,7 +392,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 +451,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 +459,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 +472,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 +506,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 +526,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 +543,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 +653,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 +678,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 +740,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 +778,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 +944,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 +980,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 +999,26 @@
          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)
          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 +1056,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 +1092,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 +1147,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 +1189,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 +1228,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 +1259,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 +1302,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/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_cu_tiedtke.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_cu_tiedtke.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_cu_tiedtke.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_mp_radar.F (from rev 2677, trunk/mpas/src/core_atmos_physics/physics_wrf/module_mp_radar.F)
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_mp_radar.F                                (rev 0)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_mp_radar.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_mp_wsm6.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_mp_wsm6.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_mp_wsm6.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_ra_rrtmg_sw.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_ra_rrtmg_sw.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_ra_rrtmg_sw.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_sf_sfclay.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_sf_sfclay.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_atmos_physics/physics_wrf/module_sf_sfclay.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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

Modified: branches/ocean_projects/openmp_elements/src/core_hyd_atmos/Registry
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_hyd_atmos/Registry        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_hyd_atmos/Registry        2013-03-29 14:40:23 UTC (rev 2678)
@@ -96,7 +96,7 @@
 
 var persistent real    edgeNormalVectors ( R3 nEdges ) 0 o edgeNormalVectors mesh - -
 var persistent real    localVerticalUnitVectors ( R3 nCells ) 0 o localVerticalUnitVectors mesh - -
-var persistent real    cellTangentPlane ( R3 TWO nEdges ) 0 o cellTangentPlane mesh - -
+var persistent real    cellTangentPlane ( R3 TWO nCells ) 0 o cellTangentPlane mesh - -
 
 var persistent integer cellsOnCell ( maxEdges nCells ) 0 iro cellsOnCell mesh - -
 var persistent integer verticesOnCell ( maxEdges nCells ) 0 iro verticesOnCell mesh - -

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

Modified: branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/Makefile
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/Makefile        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/Makefile        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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
 

Modified: branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/Registry
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/Registry        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/Registry        2013-03-29 14:40:23 UTC (rev 2678)
@@ -108,7 +108,7 @@
 
 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 nEdges ) 0 io cellTangentPlane 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 - -
@@ -140,6 +140,17 @@
 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 - -
+var persistent real    varsso      ( nCells ) 0 io varsso  mesh - -
+var persistent real    var2d       ( nCells ) 0 io var2d   mesh - -
+var persistent real    con         ( nCells ) 0 io con     mesh - -
+var persistent real    oa1         ( nCells ) 0 io oa1     mesh - -
+var persistent real    oa2         ( nCells ) 0 io oa2     mesh - -
+var persistent real    oa3         ( nCells ) 0 io oa3     mesh - -
+var persistent real    oa4         ( nCells ) 0 io oa4     mesh - -
+var persistent real    ol1         ( nCells ) 0 io ol1     mesh - -
+var persistent real    ol2         ( nCells ) 0 io ol2     mesh - -
+var persistent real    ol3         ( nCells ) 0 io ol3     mesh - -
+var persistent real    ol4         ( nCells ) 0 io ol4     mesh - -
 
 % description of the vertical grid structure
 
@@ -162,10 +173,10 @@
 % 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    t_fg ( nFGLevels nCells Time ) 1 o t fg - -
+var persistent real    p_fg ( nFGLevels nCells Time ) 1 o p fg - -
+var persistent real    z_fg ( nFGLevels nCells Time ) 1 o z fg - -
+var persistent real    rh_fg ( nFGLevels nCells Time ) 1 o 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 - -
@@ -216,6 +227,8 @@
 var persistent real    qv_init ( nVertLevels ) 0 io qv_init mesh - -
 
 % Diagnostic fields: only written to output
+var persistent real    precipw ( nCells Time ) 1 o precipw diag_physics - -
+var persistent real    rh ( nVertLevels nCells Time ) 1 o rh diag - -
 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 - -

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

Modified: branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/mpas_init_atm_llxy.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/mpas_init_atm_llxy.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/mpas_init_atm_llxy.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/mpas_init_atm_static.F (from rev 2677, trunk/mpas/src/core_init_nhyd_atmos/mpas_init_atm_static.F)
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/mpas_init_atm_static.F                                (rev 0)
+++ branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/mpas_init_atm_static.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/mpas_init_atm_surface.F (from rev 2677, trunk/mpas/src/core_init_nhyd_atmos/mpas_init_atm_surface.F)
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/mpas_init_atm_surface.F                                (rev 0)
+++ branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/mpas_init_atm_surface.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/mpas_init_atm_test_cases.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/mpas_init_atm_test_cases.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_init_nhyd_atmos/mpas_init_atm_test_cases.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_nhyd_atmos/Makefile
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_nhyd_atmos/Makefile        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_nhyd_atmos/Makefile        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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 )

Modified: branches/ocean_projects/openmp_elements/src/core_nhyd_atmos/Registry
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_nhyd_atmos/Registry        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_nhyd_atmos/Registry        2013-03-29 14:40:23 UTC (rev 2678)
@@ -15,6 +15,7 @@
 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 real      nhyd_model config_visc4_2dsmag         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
@@ -33,7 +34,7 @@
 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 logical   nhyd_model config_h_ScaleWithMesh      true
 namelist integer   nhyd_model config_num_halos            2
 namelist real      damping    config_zd                   22000.0
 namelist real      damping    config_xnutr                0.0
@@ -45,6 +46,7 @@
 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 io         config_pio_format           pnetcdf
 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.
@@ -113,7 +115,7 @@
 
 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 nEdges ) 0 iro cellTangentPlane 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 - -
@@ -283,15 +285,34 @@
 % 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 - -
+var persistent real    kdiff ( nVertLevels nCells Time ) 1 o 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 - -
+var persistent real    surface_pressure    ( nCells Time    ) 1 iro surface_pressure       diag - -
 
+var persistent real    temperature_200hPa  ( nCells Time    ) 1   o temperature_200hPa     diag - -
+var persistent real    temperature_500hPa  ( nCells Time    ) 1   o temperature_500hPa     diag - -
+var persistent real    temperature_850hPa  ( nCells Time    ) 1   o temperature_850hPa     diag - -
+var persistent real    height_200hPa       ( nCells Time    ) 1   o height_200hPa          diag - -
+var persistent real    height_500hPa       ( nCells Time    ) 1   o height_500hPa          diag - -
+var persistent real    height_850hPa       ( nCells Time    ) 1   o height_850hPa          diag - -
+var persistent real    uzonal_200hPa       ( nCells Time    ) 1   o uzonal_200hPa          diag - -
+var persistent real    uzonal_500hPa       ( nCells Time    ) 1   o uzonal_500hPa          diag - -
+var persistent real    uzonal_850hPa       ( nCells Time    ) 1   o uzonal_850hPa          diag - -
+var persistent real    umeridional_200hPa  ( nCells Time    ) 1   o umeridional_200hPa     diag - -
+var persistent real    umeridional_500hPa  ( nCells Time    ) 1   o umeridional_500hPa     diag - -
+var persistent real    umeridional_850hPa  ( nCells Time    ) 1   o umeridional_850hPa     diag - -
+var persistent real    w_200hPa            ( nCells Time    ) 1   o w_200hPa               diag - -
+var persistent real    w_500hPa            ( nCells Time    ) 1   o w_500hPa               diag - -
+var persistent real    w_850hPa            ( nCells Time    ) 1   o w_850hPa               diag - -
+
+var persistent real    vorticity_200hPa    ( nVertices Time ) 1   o vorticity_200hPa       diag - -
+var persistent real    vorticity_500hPa    ( nVertices Time ) 1   o vorticity_500hPa       diag - -
+var persistent real    vorticity_850hPa    ( nVertices Time ) 1   o vorticity_850hPa       diag - -
+
 %==================================================================================================
 % DECLARATIONS OF ALL PHYSICS VARIABLES (will need to be moved to a Physics Registry shared by the
 % hydrostatic and non-hydrostatic dynamical cores):
@@ -360,6 +381,7 @@
 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_gwdo_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
@@ -402,7 +424,11 @@
 % 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                   (-)
+% precipw   : precipitable water                                                            (kg/m2)
+% refl10cm_max: maximum column reflectivity                                                   (dBz)
 
+var persistent real    refl10cm_max ( nCells Time           ) 1   o refl10cm_max   diag_physics - -
+
 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 - -
@@ -413,8 +439,9 @@
 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 - -
+var persistent real    precipw    ( nCells Time             ) 1   o precipw        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:
@@ -488,7 +515,50 @@
 var persistent real    rqcblten ( nVertLevels nCells Time   ) 1  ro rqcblten       tend_physics - -
 var persistent real    rqiblten ( nVertLevels nCells Time   ) 1  ro rqiblten       tend_physics - -
 
+%    TEMPORARY:
+var persistent real    kzh      ( nVertLevels nCells Time   ) 1   o kzh            diag_physics - -
+var persistent real    kzm      ( nVertLevels nCells Time   ) 1   o kzm            diag_physics - -
+var persistent real    kzq      ( nVertLevels nCells Time   ) 1   o kzq            diag_physics - -
+
 %--------------------------------------------------------------------------------------------------
+%... PARAMETERIZATION OF GRAVITY WAVE DRAG OVER OROGRAPHY:
+%--------------------------------------------------------------------------------------------------
+
+% var2d      : orographic variance                                                             (m2)
+% con        : orographic convexity                                                            (m2)
+% oa1        : orographic direction asymmetry function                                          (-)
+% oa2        : orographic direction asymmetry function                                          (-)
+% oa3        : orographic direction asymmetry function                                          (-)
+% oa4        : orographic direction asymmetry function                                          (-)
+% ol1        : orographic direction asymmetry function                                          (-)
+% ol2        : orographic direction asymmetry function                                          (-)
+% ol3        : orographic direction asymmetry function                                          (-)
+% ol4        : orographic direction asymmetry function                                          (-)
+% dusfcg     : vertically-integrated gravity wave drag over orography u-stress           (Pa m s-1)
+% dvsfcg     : vertically-integrated gravity wave drag over orography v-stress           (Pa m s-1)
+% dtaux3d    : gravity wave drag over orography u-stress                                    (m s-1)
+% dtauy3d    : gravity wave drag over orography v-stress                                    (m s-1)
+
+var persistent real    var2d    ( nCells                    ) 0  iro var2d         sfc_input    - -
+var persistent real    con      ( nCells                    ) 0  iro con           sfc_input    - -
+var persistent real    oa1      ( nCells                    ) 0  iro oa1           sfc_input    - -
+var persistent real    oa2      ( nCells                    ) 0  iro oa2           sfc_input    - -
+var persistent real    oa3      ( nCells                    ) 0  iro oa3           sfc_input    - -
+var persistent real    oa4      ( nCells                    ) 0  iro oa4           sfc_input    - -
+var persistent real    ol1      ( nCells                    ) 0  iro ol1           sfc_input    - -
+var persistent real    ol2      ( nCells                    ) 0  iro ol2           sfc_input    - -
+var persistent real    ol3      ( nCells                    ) 0  iro ol3           sfc_input    - -
+var persistent real    ol4      ( nCells                    ) 0  iro ol4           sfc_input    - -
+
+var persistent real    dusfcg   ( nCells Time               ) 1  ro dusfcg         diag_physics - -
+var persistent real    dvsfcg   ( nCells Time               ) 1  ro dvsfcg         diag_physics - -
+var persistent real    dtaux3d  ( nVertLevels nCells Time   ) 1  ro dtaux3d        diag_physics - -
+var persistent real    dtauy3d  ( nVertLevels nCells Time   ) 1  ro dtauy3d        diag_physics - -
+
+var persistent real    rubldiff ( nVertLevels nCells Time   ) 1  ro rubldiff       diag_physics - -
+var persistent real    rvbldiff ( nVertLevels nCells Time   ) 1  ro rvbldiff       diag_physics - -
+
+%--------------------------------------------------------------------------------------------------
 %... PARAMETERIZATION OF SURFACE LAYER PROCESSES:
 %--------------------------------------------------------------------------------------------------
 
@@ -772,7 +842,6 @@
 % 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                                                            [-]
@@ -781,8 +850,9 @@
 % 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]
+% sstsk          : skin sea-surface temperature                                                 [K]
+% sstsk_dtc      : skin sea-surface temperature cooling                                         [K]
+% sstsk_dtw      : skin sea-surface temperature warming                                         [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                                              [-]
@@ -798,7 +868,6 @@
 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 - -
@@ -808,7 +877,8 @@
 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    sstsk_dtc  ( nCells Time             ) 1  ro sstsk_dtc      diag_physics - -
+var persistent real    sstsk_dtw  ( nCells Time             ) 1  ro sstsk_dtw      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 - -

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

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

Modified: branches/ocean_projects/openmp_elements/src/core_nhyd_atmos/mpas_atm_advection.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_nhyd_atmos/mpas_atm_advection.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_nhyd_atmos/mpas_atm_advection.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_nhyd_atmos/mpas_atm_interp_diagnostics.F (from rev 2677, trunk/mpas/src/core_nhyd_atmos/mpas_atm_interp_diagnostics.F)
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_nhyd_atmos/mpas_atm_interp_diagnostics.F                                (rev 0)
+++ branches/ocean_projects/openmp_elements/src/core_nhyd_atmos/mpas_atm_interp_diagnostics.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/core_nhyd_atmos/mpas_atm_mpas_core.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_nhyd_atmos/mpas_atm_mpas_core.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_nhyd_atmos/mpas_atm_mpas_core.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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))
@@ -340,8 +337,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 +371,8 @@
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    
       use mpas_grid_types
+      use mpas_constants
+      use mpas_atm_interp_diagnostics
    
       implicit none
    
@@ -383,15 +380,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 +405,7 @@
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    
       use mpas_grid_types
+      use mpas_constants
    
       implicit none
    
@@ -414,12 +413,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/ocean_projects/openmp_elements/src/core_nhyd_atmos/mpas_atm_time_integration.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_nhyd_atmos/mpas_atm_time_integration.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_nhyd_atmos/mpas_atm_time_integration.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -95,9 +95,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
 
 
       !
@@ -169,7 +168,7 @@
         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 )
+           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 '
@@ -185,7 +184,8 @@
                         block % tend, &amp;
                         block % tend_physics, &amp;
                         block % state % time_levs(2) % state % rho_zz % array(:,:), &amp;
-                        block % diag % rho_edge % array(:,:) )
+                        block % diag % rho_edge % array(:,:), &amp; 
+                        rk_step )
            block =&gt; block % next
         end do
         if (debug) write(0,*) ' finished add physics tendencies '
@@ -201,8 +201,8 @@
 
          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 % state % time_levs(1) % state, block % state % time_levs(2) % state,  &amp;
+               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
@@ -290,7 +290,7 @@
                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
@@ -396,7 +396,7 @@
 
 
 !      if(debug) then
-        101 format(' local  min, max scalar',i4,2(1x,e17.10))
+!        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
@@ -456,7 +456,6 @@
      implicit none
      type (state_type) :: s_new, s_old
      type (diag_type) :: diag
-     integer :: iCell, k
 
      diag % ru_save % array = diag % ru % array
      diag % rw_save % array = diag % rw % array
@@ -639,10 +638,9 @@
 
 !------------------------
 
-   subroutine atm_set_smlstep_pert_variables( s_old, s_new, tend, diag, grid )
+   subroutine atm_set_smlstep_pert_variables( tend, diag, grid )
 
       implicit none
-      type (state_type) :: s_new, s_old
       type (tend_type) :: tend
       type (diag_type) :: diag
       type (mesh_type) :: grid
@@ -728,7 +726,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
@@ -738,8 +736,6 @@
       logical, parameter :: debug = .false.
 !      logical, parameter :: debug = .true.
       logical, parameter :: debug1 = .false.
-      real (kind=RKIND) :: wmax
-      integer :: iwmax, kwmax
       logical :: newpx
 
 !--
@@ -971,7 +967,7 @@
         end do
 
         do k=nVertLevels,1,-1
-          rw_p(k,iCell) = rw_p(k,iCell) - gamma_tri(k,iCell)*rw_p(k+1,iCell)                     
+          rw_p(k,iCell) = rw_p(k,iCell) - gamma_tri(k,iCell)*rw_p(k+1,iCell)     
         end do
 
         do k=2,nVertLevels
@@ -1199,8 +1195,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 +1208,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
 
       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
@@ -1402,7 +1395,7 @@
 
 !---------------------------
 
-   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
@@ -1416,12 +1409,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 +1424,24 @@
       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 :: nVertLevels, num_scalars, icellmax, kmax
 
       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, flux_upwind
       real (kind=RKIND) :: q_im2, q_im1, q_i, q_ip1, ua, coef3, scmin,scmax
@@ -1541,25 +1534,27 @@
         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, 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
 
-        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, 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
+         end if
 
 
       !
@@ -1644,12 +1639,12 @@
               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
@@ -1669,10 +1664,10 @@
                  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)
+                 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
@@ -1682,15 +1677,15 @@
 
           do iCell = 1, grid % 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
@@ -1703,20 +1698,18 @@
       tempField =&gt; tempFieldTarget
 
       tempField % block =&gt; block
-      tempField % dimSizes(1) = grid % nVertLevels
-      tempField % dimSizes(2) = grid % nCells
+      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
+      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
 !
@@ -1726,8 +1719,8 @@
                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 = 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
@@ -1738,8 +1731,8 @@
             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))
+                  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
@@ -1757,39 +1750,39 @@
             end if
          end do
 
-          do iCell=1,grid % nCellsSolve
-             do k=1,grid % 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
+         do iCell=1,grid % nCellsSolve
+            do k=1,grid % 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
 
-        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, 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
 
-        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
+         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
 
       end do !  loop over scalars
 
@@ -1797,7 +1790,7 @@
 
 !----
 
-   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
    !
@@ -1816,18 +1809,19 @@
       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
       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 +1829,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,11 +1848,12 @@
       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.
@@ -1974,10 +1969,10 @@
       nCellsSolve = grid % nCellsSolve
 
       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
 
       nAdvCellsForEdge =&gt; grid % nAdvCellsForEdge % array
@@ -1985,6 +1980,8 @@
       adv_coefs =&gt; grid % adv_coefs % array
       adv_coefs_3rd =&gt; grid % adv_coefs_3rd % array
 
+      prandtl_inv = 1.0_RKIND/prandtl
+
       !
       ! Compute u (normal) velocity tendency for each edge (cell face)
       !
@@ -2007,11 +2004,21 @@
             end do
             do k=1, nVertLevels
                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
@@ -2179,7 +2186,7 @@
 
       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 % nEdgesSolve
               cell1 = cellsOnEdge(1,iEdge)
               cell2 = cellsOnEdge(2,iEdge)
@@ -2193,7 +2200,7 @@
                  !                    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)
+                                -( 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)
   
@@ -2216,7 +2223,7 @@
                  !                    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)
+                                -( 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)
 
@@ -2228,7 +2235,10 @@
 
       end if ! delsq_horiz_mixing for u
 
-      if ( h_mom_eddy_visc4 &gt; 0.0 ) then
+!ldf (2012-10-10): Modified loop below to allow hyper-diffusion when 2d_smagorinsky is set to true.
+!     if ((h_mom_eddy_visc4 &gt; 0.0) .and. (config_horiz_mixing == &quot;2d_fixed&quot;)) then
+      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
 
          allocate(delsq_divergence(nVertLevels, nCells+1))
          allocate(delsq_u(nVertLevels, nEdges+1))
@@ -2545,7 +2555,7 @@
 
       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)
@@ -2589,7 +2599,10 @@
  
       end if
 
-      if ( h_mom_eddy_visc4 &gt; 0.0 ) then
+!ldf (2010-10-10):
+!     if ( (h_mom_eddy_visc4 &gt; 0.0) .and. (config_horiz_mixing == &quot;2d_fixed&quot;)) then
+      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
 
          allocate(delsq_theta(nVertLevels, nCells+1))
 
@@ -2840,7 +2853,7 @@
       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)
@@ -2848,7 +2861,7 @@
                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)
+                     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
@@ -2868,7 +2881,7 @@
                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;
+                     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
@@ -2884,7 +2897,10 @@
 
       end if
 
-      if ( h_theta_eddy_visc4 &gt; 0.0 ) then
+!ldf (2010-10-10):
+!     if ( (h_theta_eddy_visc4 &gt; 0.0) .and. (config_horiz_mixing == &quot;2d_fixed&quot;) ) 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))
 
@@ -2912,7 +2928,7 @@
             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)
+                  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
 
@@ -2996,10 +3012,10 @@
                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;
+!               tend_theta(k,iCell) = tend_theta(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))
-               tend_theta_euler(k,iCell) = tend_theta_euler(k,iCell) + v_theta_eddy_visc2*prandtl*rho_zz(k,iCell)*(&amp;
+               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
@@ -3018,10 +3034,10 @@
                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;
+!               tend_theta(k,iCell) = tend_theta(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))
-               tend_theta_euler(k,iCell) = tend_theta_euler(k,iCell) + v_theta_eddy_visc2*prandtl*rho_zz(k,iCell)*(&amp;
+               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
@@ -3060,12 +3076,12 @@
       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
       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
@@ -3340,7 +3356,7 @@
       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
       real (kind=RKIND) :: p0, rcv, flux
 
       !SHP-w
@@ -3352,7 +3368,7 @@
 
       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))
+            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

Index: branches/ocean_projects/openmp_elements/src/core_ocean
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean        2013-03-29 14:40:23 UTC (rev 2678)

Property changes on: branches/ocean_projects/openmp_elements/src/core_ocean
___________________________________________________________________
Modified: svn:mergeinfo
## -4,16 +4,22 ##
 /branches/ocean_projects/ale_vert_coord/src/core_ocean:1225-1383
 /branches/ocean_projects/ale_vert_coord_new/src/core_ocean:1387-1428
 /branches/ocean_projects/cesm_coupling/src/core_ocean:2147-2344
+/branches/ocean_projects/comment_cleanup/src/core_ocean:2626-2630
+/branches/ocean_projects/diagnostics_revision/src/core_ocean:2439-2462
+/branches/ocean_projects/explicit_vmix_removal/src/core_ocean:2486-2490
 /branches/ocean_projects/gmvar/src/core_ocean:1214-1514,1517-1738
 /branches/ocean_projects/imp_vert_mix_error/src/core_ocean:1847-1887
 /branches/ocean_projects/imp_vert_mix_mrp/src/core_ocean:754-986
 /branches/ocean_projects/leith_mrp/src/core_ocean:2182-2241
+/branches/ocean_projects/linear_eos/src/core_ocean:2435-2437
 /branches/ocean_projects/monotonic_advection/src/core_ocean:1499-1640
 /branches/ocean_projects/monthly_forcing/src/core_ocean:1810-1867
 /branches/ocean_projects/namelist_cleanup/src/core_ocean:2319-2414
 /branches/ocean_projects/option3_b4b_test/src/core_ocean:2201-2231
 /branches/ocean_projects/partial_bottom_cells/src/core_ocean:2172-2226
+/branches/ocean_projects/remove_sw_test_cases/src/core_ocean:2539-2540
 /branches/ocean_projects/restart_reproducibility/src/core_ocean:2239-2272
+/branches/ocean_projects/sea_level_pressure/src/core_ocean:2488-2528
 /branches/ocean_projects/split_explicit_mrp/src/core_ocean:1134-1138
 /branches/ocean_projects/split_explicit_timestepping/src/core_ocean:1044-1097
 /branches/ocean_projects/vert_adv_mrp/src/core_ocean:704-745
## -26,6 +32,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:2346-2428
+/branches/xml_registry/src/core_ocean:2610-2662
+/trunk/mpas/src/core_ocean:2346-2677
\ No newline at end of property
Modified: branches/ocean_projects/openmp_elements/src/core_ocean/Makefile
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/Makefile        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/Makefile        2013-03-29 14:40:23 UTC (rev 2678)
@@ -1,79 +1,79 @@
 .SUFFIXES: .F .o
 
 OBJS = mpas_ocn_mpas_core.o \
-       mpas_ocn_test_cases.o \
        mpas_ocn_advection.o \
-           mpas_ocn_thick_hadv.o \
-           mpas_ocn_thick_vadv.o \
-           mpas_ocn_gm.o \
-           mpas_ocn_vel_coriolis.o \
-           mpas_ocn_vel_vadv.o \
-           mpas_ocn_vel_hmix.o \
-           mpas_ocn_vel_hmix_del2.o \
-           mpas_ocn_vel_hmix_leith.o \
-           mpas_ocn_vel_hmix_del4.o \
-           mpas_ocn_vel_forcing.o \
-           mpas_ocn_vel_forcing_windstress.o \
-           mpas_ocn_vel_forcing_bottomdrag.o \
-           mpas_ocn_vel_forcing_rayleigh.o \
-           mpas_ocn_vel_pressure_grad.o \
-           mpas_ocn_tracer_vadv.o \
-           mpas_ocn_tracer_vadv_spline.o \
-           mpas_ocn_tracer_vadv_spline2.o \
-           mpas_ocn_tracer_vadv_spline3.o \
-           mpas_ocn_tracer_vadv_stencil.o \
-           mpas_ocn_tracer_vadv_stencil2.o \
-           mpas_ocn_tracer_vadv_stencil3.o \
-           mpas_ocn_tracer_vadv_stencil4.o \
-           mpas_ocn_tracer_hadv.o \
-           mpas_ocn_tracer_hadv2.o \
-           mpas_ocn_tracer_hadv3.o \
-           mpas_ocn_tracer_hadv4.o \
-           mpas_ocn_tracer_hmix.o \
-           mpas_ocn_tracer_hmix_del2.o \
-           mpas_ocn_tracer_hmix_del4.o \
-           mpas_ocn_vmix.o \
-           mpas_ocn_vmix_coefs_const.o \
-           mpas_ocn_vmix_coefs_rich.o \
-           mpas_ocn_vmix_coefs_tanh.o \
-           mpas_ocn_restoring.o \
-           mpas_ocn_tendency.o \
-           mpas_ocn_tracer_advection.o \
-           mpas_ocn_tracer_advection_std.o \
-           mpas_ocn_tracer_advection_std_hadv.o \
-           mpas_ocn_tracer_advection_std_vadv.o \
-           mpas_ocn_tracer_advection_std_vadv2.o \
-           mpas_ocn_tracer_advection_std_vadv3.o \
-           mpas_ocn_tracer_advection_std_vadv4.o \
-           mpas_ocn_tracer_advection_mono.o \
-           mpas_ocn_tracer_advection_helpers.o \
+       mpas_ocn_thick_hadv.o \
+       mpas_ocn_thick_vadv.o \
+       mpas_ocn_gm.o \
+       mpas_ocn_vel_coriolis.o \
+       mpas_ocn_vel_vadv.o \
+       mpas_ocn_vel_hmix.o \
+       mpas_ocn_vel_hmix_del2.o \
+       mpas_ocn_vel_hmix_leith.o \
+       mpas_ocn_vel_hmix_del4.o \
+       mpas_ocn_vel_forcing.o \
+       mpas_ocn_vel_forcing_windstress.o \
+       mpas_ocn_vel_forcing_rayleigh.o \
+       mpas_ocn_vel_pressure_grad.o \
+       mpas_ocn_tracer_vadv.o \
+       mpas_ocn_tracer_vadv_spline.o \
+       mpas_ocn_tracer_vadv_spline2.o \
+       mpas_ocn_tracer_vadv_spline3.o \
+       mpas_ocn_tracer_vadv_stencil.o \
+       mpas_ocn_tracer_vadv_stencil2.o \
+       mpas_ocn_tracer_vadv_stencil3.o \
+       mpas_ocn_tracer_vadv_stencil4.o \
+       mpas_ocn_tracer_hadv.o \
+       mpas_ocn_tracer_hadv2.o \
+       mpas_ocn_tracer_hadv3.o \
+       mpas_ocn_tracer_hadv4.o \
+       mpas_ocn_tracer_hmix.o \
+       mpas_ocn_tracer_hmix_del2.o \
+       mpas_ocn_tracer_hmix_del4.o \
+       mpas_ocn_vmix.o \
+       mpas_ocn_vmix_coefs_const.o \
+       mpas_ocn_vmix_coefs_rich.o \
+       mpas_ocn_vmix_coefs_tanh.o \
+       mpas_ocn_restoring.o \
+       mpas_ocn_tendency.o \
+       mpas_ocn_diagnostics.o \
+       mpas_ocn_tracer_advection.o \
+       mpas_ocn_tracer_advection_std.o \
+       mpas_ocn_tracer_advection_std_hadv.o \
+       mpas_ocn_tracer_advection_std_vadv.o \
+       mpas_ocn_tracer_advection_std_vadv2.o \
+       mpas_ocn_tracer_advection_std_vadv3.o \
+       mpas_ocn_tracer_advection_std_vadv4.o \
+       mpas_ocn_tracer_advection_mono.o \
+       mpas_ocn_tracer_advection_helpers.o \
        mpas_ocn_time_integration.o \
        mpas_ocn_time_integration_rk4.o \
        mpas_ocn_time_integration_split.o \
-           mpas_ocn_equation_of_state.o \
-           mpas_ocn_equation_of_state_jm.o \
-           mpas_ocn_equation_of_state_linear.o \
+       mpas_ocn_equation_of_state.o \
+       mpas_ocn_equation_of_state_jm.o \
+       mpas_ocn_equation_of_state_linear.o \
+       mpas_ocn_diagnostics.o \
        mpas_ocn_global_diagnostics.o \
-           mpas_ocn_time_average.o \
-           mpas_ocn_monthly_forcing.o
+       mpas_ocn_time_average.o \
+       mpas_ocn_monthly_forcing.o
 
 all: core_hyd
 
 core_hyd: $(OBJS)
         ar -ru libdycore.a $(OBJS)
 
-mpas_ocn_test_cases.o:
-
 mpas_ocn_advection.o:
 
 mpas_ocn_time_integration.o: mpas_ocn_time_integration_rk4.o mpas_ocn_time_integration_split.o
 
-mpas_ocn_time_integration_rk4.o:
+mpas_ocn_time_integration_rk4.o: mpas_ocn_tendency.o mpas_ocn_diagnostics.o
 
-mpas_ocn_time_integration_split.o:
+mpas_ocn_time_integration_split.o: mpas_ocn_tendency.o mpas_ocn_diagnostics.o
 
 mpas_ocn_tendency.o: mpas_ocn_time_average.o
 
+mpas_ocn_diagnostics.o: mpas_ocn_time_average.o
+
 mpas_ocn_global_diagnostics.o: 
 
 mpas_ocn_time_average.o:
@@ -96,12 +96,10 @@
 
 mpas_ocn_vel_hmix_del4.o:
 
-mpas_ocn_vel_forcing.o: mpas_ocn_vel_forcing_windstress.o mpas_ocn_vel_forcing_bottomdrag.o mpas_ocn_vel_forcing_rayleigh.o
+mpas_ocn_vel_forcing.o: mpas_ocn_vel_forcing_windstress.o mpas_ocn_vel_forcing_rayleigh.o
 
 mpas_ocn_vel_forcing_windstress.o:
 
-mpas_ocn_vel_forcing_bottomdrag.o:
-
 mpas_ocn_vel_forcing_rayleigh.o:
 
 mpas_ocn_vel_coriolis.o:
@@ -172,61 +170,59 @@
 
 mpas_ocn_monthly_forcing.o:
 
-mpas_ocn_mpas_core.o: mpas_ocn_mpas_core.o \
-                                  mpas_ocn_test_cases.o \
-                                          mpas_ocn_advection.o \
-                                          mpas_ocn_thick_hadv.o \
+mpas_ocn_mpas_core.o: mpas_ocn_advection.o \
+                      mpas_ocn_thick_hadv.o \
                       mpas_ocn_gm.o \
-                                          mpas_ocn_thick_vadv.o \
-                                          mpas_ocn_vel_coriolis.o \
-                                          mpas_ocn_vel_vadv.o \
-                                          mpas_ocn_vel_hmix.o \
-                                          mpas_ocn_vel_hmix_del2.o \
-                                          mpas_ocn_vel_hmix_leith.o \
-                                          mpas_ocn_vel_hmix_del4.o \
-                                          mpas_ocn_vel_forcing.o \
-                                          mpas_ocn_vel_forcing_windstress.o \
-                                          mpas_ocn_vel_forcing_bottomdrag.o \
-                                          mpas_ocn_vel_pressure_grad.o \
-                                          mpas_ocn_tracer_vadv.o \
-                                          mpas_ocn_tracer_vadv_spline.o \
-                                          mpas_ocn_tracer_vadv_spline2.o \
-                                          mpas_ocn_tracer_vadv_spline3.o \
-                                          mpas_ocn_tracer_vadv_stencil.o \
-                                          mpas_ocn_tracer_vadv_stencil2.o \
-                                          mpas_ocn_tracer_vadv_stencil3.o \
-                                          mpas_ocn_tracer_vadv_stencil4.o \
-                                          mpas_ocn_tracer_hadv.o \
-                                          mpas_ocn_tracer_hadv2.o \
-                                          mpas_ocn_tracer_hadv3.o \
-                                          mpas_ocn_tracer_hadv4.o \
-                                          mpas_ocn_tracer_hmix.o \
-                                          mpas_ocn_tracer_hmix_del2.o \
-                                          mpas_ocn_tracer_hmix_del4.o \
-                                          mpas_ocn_vmix.o \
-                                          mpas_ocn_vmix_coefs_const.o \
-                                          mpas_ocn_vmix_coefs_rich.o \
-                                          mpas_ocn_vmix_coefs_tanh.o \
-                                          mpas_ocn_restoring.o \
-                                          mpas_ocn_tracer_advection.o \
-                                          mpas_ocn_tracer_advection_std.o \
-                                          mpas_ocn_tracer_advection_std_hadv.o \
-                                          mpas_ocn_tracer_advection_std_vadv.o \
-                                          mpas_ocn_tracer_advection_std_vadv2.o \
-                                          mpas_ocn_tracer_advection_std_vadv3.o \
-                                          mpas_ocn_tracer_advection_std_vadv4.o \
-                                          mpas_ocn_tracer_advection_mono.o \
-                                          mpas_ocn_tracer_advection_helpers.o \
-                                          mpas_ocn_tendency.o \
-                                          mpas_ocn_time_integration.o \
-                                          mpas_ocn_time_integration_rk4.o \
-                                          mpas_ocn_time_integration_split.o \
-                                          mpas_ocn_equation_of_state.o \
-                                          mpas_ocn_equation_of_state_jm.o \
-                                          mpas_ocn_equation_of_state_linear.o \
-                                          mpas_ocn_global_diagnostics.o \
-                                          mpas_ocn_time_average.o \
-                                          mpas_ocn_monthly_forcing.o
+                      mpas_ocn_thick_vadv.o \
+                      mpas_ocn_vel_coriolis.o \
+                      mpas_ocn_vel_vadv.o \
+                      mpas_ocn_vel_hmix.o \
+                      mpas_ocn_vel_hmix_del2.o \
+                      mpas_ocn_vel_hmix_leith.o \
+                      mpas_ocn_vel_hmix_del4.o \
+                      mpas_ocn_vel_forcing.o \
+                      mpas_ocn_vel_forcing_windstress.o \
+                      mpas_ocn_vel_pressure_grad.o \
+                      mpas_ocn_tracer_vadv.o \
+                      mpas_ocn_tracer_vadv_spline.o \
+                      mpas_ocn_tracer_vadv_spline2.o \
+                      mpas_ocn_tracer_vadv_spline3.o \
+                      mpas_ocn_tracer_vadv_stencil.o \
+                      mpas_ocn_tracer_vadv_stencil2.o \
+                      mpas_ocn_tracer_vadv_stencil3.o \
+                      mpas_ocn_tracer_vadv_stencil4.o \
+                      mpas_ocn_tracer_hadv.o \
+                      mpas_ocn_tracer_hadv2.o \
+                      mpas_ocn_tracer_hadv3.o \
+                      mpas_ocn_tracer_hadv4.o \
+                      mpas_ocn_tracer_hmix.o \
+                      mpas_ocn_tracer_hmix_del2.o \
+                      mpas_ocn_tracer_hmix_del4.o \
+                      mpas_ocn_vmix.o \
+                      mpas_ocn_vmix_coefs_const.o \
+                      mpas_ocn_vmix_coefs_rich.o \
+                      mpas_ocn_vmix_coefs_tanh.o \
+                      mpas_ocn_restoring.o \
+                      mpas_ocn_tracer_advection.o \
+                      mpas_ocn_tracer_advection_std.o \
+                      mpas_ocn_tracer_advection_std_hadv.o \
+                      mpas_ocn_tracer_advection_std_vadv.o \
+                      mpas_ocn_tracer_advection_std_vadv2.o \
+                      mpas_ocn_tracer_advection_std_vadv3.o \
+                      mpas_ocn_tracer_advection_std_vadv4.o \
+                      mpas_ocn_tracer_advection_mono.o \
+                      mpas_ocn_tracer_advection_helpers.o \
+                      mpas_ocn_tendency.o \
+                      mpas_ocn_diagnostics.o \
+                      mpas_ocn_time_integration.o \
+                      mpas_ocn_time_integration_rk4.o \
+                      mpas_ocn_time_integration_split.o \
+                      mpas_ocn_equation_of_state.o \
+                      mpas_ocn_equation_of_state_jm.o \
+                      mpas_ocn_equation_of_state_linear.o \
+                      mpas_ocn_global_diagnostics.o \
+                      mpas_ocn_time_average.o \
+                      mpas_ocn_monthly_forcing.o
 
 clean:
         $(RM) *.o *.mod *.f90 libdycore.a

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/Registry
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/Registry        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/Registry        2013-03-29 14:40:23 UTC (rev 2678)
@@ -4,57 +4,55 @@
 namelist logical   time_management config_do_restart          .false.
 namelist character time_management config_start_time          '0000-01-01_00:00:00'
 namelist character time_management config_stop_time           'none'
-namelist character time_management config_run_duration        'none'
+namelist character time_management config_run_duration        '0_06:00:00'
 namelist character time_management config_calendar_type       '360day'
-namelist integer   time_management config_ncouple_per_day       1
 
 namelist character io       config_input_name          'grid.nc'
 namelist character io       config_output_name         'output.nc'
 namelist character io       config_restart_name        'restart.nc'
-namelist character io       config_restart_interval    'none'
-namelist character io       config_output_interval     '24:00:00'
-namelist character io       config_stats_interval      '24:00:00'
-namelist logical   io       config_write_stats_on_startup   .false.
+namelist character io       config_restart_interval    '0_06:00:00'
+namelist character io       config_output_interval     '0_06:00:00'
+namelist character io       config_stats_interval      '0_01:00:00'
+namelist logical   io       config_write_stats_on_startup   .true.
 namelist logical   io       config_write_output_on_startup  .true.
-namelist integer   io       config_frames_per_outfile  0
+namelist integer   io       config_frames_per_outfile  1000
 namelist integer   io       config_pio_num_iotasks     0 
 namelist integer   io       config_pio_stride          1
 
-namelist real      time_integration config_dt                  172.8
-namelist character time_integration config_time_integrator    'RK4'
+namelist real      time_integration config_dt                  3000.0
+namelist character time_integration config_time_integrator    'split_explicit'
 
-namelist integer   grid config_num_halos           3
-namelist logical   grid config_enforce_grid_on_restart .false.
-namelist character grid config_vert_coord_movement      'isopycnal'
-namelist character grid config_alter_ICs_for_pbcs 'zlevel_pbcs_off'
-namelist real      grid config_min_pbc_fraction  0.10
-namelist logical   grid config_check_ssh_consistency .true.
+namelist integer   grid config_num_halos                3
+namelist character grid config_vert_coord_movement      'uniform_stretching'
+namelist character grid config_alter_ICs_for_pbcs       'zlevel_pbcs_off'
+namelist real      grid config_min_pbc_fraction         0.10
+namelist logical   grid config_check_ssh_consistency    .true.
 
 namelist character decomposition config_block_decomp_file_prefix  'graph.info.part.'
 namelist integer   decomposition config_number_of_blocks          0
 namelist logical   decomposition config_explicit_proc_decomp      .false.
 namelist character decomposition config_proc_decomp_file_prefix   'graph.info.part.'
 
-namelist logical   hmix          config_h_ScaleWithMesh     .false.
+namelist logical   hmix          config_hmix_ScaleWithMesh  .false.
 namelist logical   hmix          config_visc_vorticity_term .true.
 namelist real      hmix          config_apvm_scale_factor      0.0
 
-namelist logical   hmix_del2     config_use_mom_del2     .true.
-namelist logical   hmix_del2     config_use_tracer_del2     .true.
-namelist real      hmix_del2     config_h_mom_eddy_visc2     0.0
-namelist real      hmix_del2     config_h_tracer_eddy_diff2  0.0
-namelist real      hmix_del2     config_visc_vorticity_visc2_scale 1.0
+namelist logical   hmix_del2     config_use_mom_del2        .false.
+namelist logical   hmix_del2     config_use_tracer_del2     .false.
+namelist real      hmix_del2     config_mom_del2             0.0
+namelist real      hmix_del2     config_tracer_del2          0.0
+namelist real      hmix_del2     config_vorticity_del2_scale 1.0
 
-namelist logical   hmix_del4     config_use_mom_del4     .true.
-namelist logical   hmix_del4     config_use_tracer_del4     .true.
-namelist real      hmix_del4     config_h_mom_eddy_visc4     0.0
-namelist real      hmix_del4     config_h_tracer_eddy_diff4  0.0
-namelist real      hmix_del4     config_visc_vorticity_visc4_scale 1.0
+namelist logical   hmix_del4     config_use_mom_del4        .true.
+namelist logical   hmix_del4     config_use_tracer_del4     .false.
+namelist real      hmix_del4     config_mom_del4             5.0e13
+namelist real      hmix_del4     config_tracer_del4          0.0
+namelist real      hmix_del4     config_vorticity_del4_scale 1.0
 
-namelist logical   hmix_Leith    config_use_Leith_del2         .false.
-namelist real      hmix_Leith    config_Leith_parameter        0.0
-namelist real      hmix_Leith    config_Leith_dx               0.0
-namelist real      hmix_Leith    config_Leith_visc2_max      1000000.0
+namelist logical   hmix_Leith    config_use_Leith_del2      .false.
+namelist real      hmix_Leith    config_Leith_parameter      1.0
+namelist real      hmix_Leith    config_Leith_dx             15000.0
+namelist real      hmix_Leith    config_Leith_visc2_max      2.5e3
 
 namelist real      standard_GM     config_h_kappa              0.0
 namelist real      standard_GM     config_h_kappa_q            0.0
@@ -62,12 +60,11 @@
 namelist logical   Rayleigh_damping     config_Rayleigh_friction    .false.
 namelist real      Rayleigh_damping     config_Rayleigh_damping_coeff 0.0
 
-namelist logical   vmix     config_implicit_vertical_mix  .true.
 namelist real      vmix     config_convective_visc      1.0
 namelist real      vmix     config_convective_diff      1.0
 
-namelist logical   vmix_const   config_use_const_visc   .true.
-namelist logical   vmix_const   config_use_const_diff   .true.
+namelist logical   vmix_const   config_use_const_visc   .false.
+namelist logical   vmix_const   config_use_const_diff   .false.
 namelist real      vmix_const   config_vert_visc        2.5e-4
 namelist real      vmix_const   config_vert_diff        2.5e-5
 
@@ -77,8 +74,8 @@
 namelist real      vmix_rich    config_bkrd_vert_diff   1.0e-5
 namelist real      vmix_rich    config_rich_mix         0.005
 
-namelist logical   vmix_tanh    config_use_tanh_visc    .true.
-namelist logical   vmix_tanh    config_use_tanh_diff    .true.
+namelist logical   vmix_tanh    config_use_tanh_visc    .false.
+namelist logical   vmix_tanh    config_use_tanh_diff    .false.
 namelist real      vmix_tanh    config_max_visc_tanh    2.5e-1
 namelist real      vmix_tanh    config_min_visc_tanh    1.0e-4
 namelist real      vmix_tanh    config_max_diff_tanh    2.5e-2
@@ -92,20 +89,26 @@
 namelist real      forcing   config_restoreS_timescale  90.0
 
 namelist character advection config_vert_tracer_adv     'stencil'
-namelist integer   advection config_vert_tracer_adv_order  4
-namelist integer   advection config_horiz_tracer_adv_order 2
+namelist integer   advection config_vert_tracer_adv_order  3
+namelist integer   advection config_horiz_tracer_adv_order 3
 namelist real      advection config_coef_3rd_order      0.25
-namelist logical   advection config_monotonic           .false.
+namelist logical   advection config_monotonic           .true.
 
 namelist real      bottom_drag config_bottom_drag_coeff    1.0e-3
 
 namelist character pressure_gradient     config_pressure_gradient_type       'pressure_and_zmid'
 namelist real      pressure_gradient     config_rho0                1014.65
 
-namelist character eos       config_eos_type            'linear'
+namelist character eos       config_eos_type            'jm'
 
+namelist real      eos_linear config_eos_linear_alpha    2.55e-1
+namelist real      eos_linear config_eos_linear_beta     7.64e-1
+namelist real      eos_linear config_eos_linear_Tref     19.0
+namelist real      eos_linear config_eos_linear_Sref     35.0
+namelist real      eos_linear config_eos_linear_rhoref   1025.022
+
 namelist integer   split_explicit_ts config_n_ts_iter     2
-namelist integer   split_explicit_ts config_n_bcl_iter_beg   2
+namelist integer   split_explicit_ts config_n_bcl_iter_beg   1
 namelist integer   split_explicit_ts config_n_bcl_iter_mid   2
 namelist integer   split_explicit_ts config_n_bcl_iter_end   2
 namelist integer   split_explicit_ts config_n_btr_subcycles  20
@@ -117,8 +120,6 @@
 namelist real      split_explicit_ts config_btr_gam3_uWt2    1.0
 namelist logical   split_explicit_ts config_btr_solve_SSH2   .false.
 
-namelist integer   sw_model config_test_case           0
-
 namelist logical   debug config_check_zlevel_consistency .false.
 namelist logical   debug config_filter_btr_mode .false.
 namelist logical   debug config_prescribe_velocity  .false.
@@ -204,7 +205,7 @@
 
 var persistent real    edgeNormalVectors ( R3 nEdges ) 0 o edgeNormalVectors mesh - -
 var persistent real    localVerticalUnitVectors ( R3 nCells ) 0 o localVerticalUnitVectors mesh - -
-var persistent real    cellTangentPlane ( R3 TWO nEdges ) 0 o cellTangentPlane mesh - -
+var persistent real    cellTangentPlane ( R3 TWO nCells ) 0 o cellTangentPlane mesh - -
 
 var persistent integer cellsOnCell ( maxEdges nCells ) 0 iro cellsOnCell mesh - -
 var persistent integer verticesOnCell ( maxEdges nCells ) 0 iro verticesOnCell mesh - -
@@ -327,7 +328,9 @@
 var persistent real    MontPot ( nVertLevels nCells Time ) 2 - MontPot state - -
 var persistent real    pressure ( nVertLevels nCells Time ) 2 - pressure state - -
 var persistent real    wTop ( nVertLevelsP1 nCells Time ) 2 - wTop state - -
+var persistent real    vertVelocityTop ( nVertLevelsP1 nCells Time ) 2 - vertVelocityTop state - -
 var persistent real    rhoDisplaced ( nVertLevels nCells Time ) 2 - rhoDisplaced state - -
+var persistent real    BruntVaisalaFreqTop ( nVertLevels nCells Time ) 2 o BruntVaisalaFreqTop state - -
 var persistent real    viscosity ( nVertLevels nEdges Time ) 2 o viscosity state - -
 
 % Other diagnostic variables: neither read nor written to any files
@@ -360,6 +363,7 @@
 var persistent real    acc_uReconstructMeridionalVar ( nVertLevels nCells Time ) 2 o acc_uReconstructMeridionalVar state - -
 var persistent real    acc_u ( nVertLevels nEdges Time ) 2 o acc_u state - -
 var persistent real    acc_uVar ( nVertLevels nEdges Time ) 2 o acc_uVar state - -
+var persistent real    acc_vertVelocityTop ( nVertLevelsP1 nCells Time ) 2 o acc_vertVelocityTop state - -
 
 % Sign fields, for openmp and bit reproducibility without branching statements.
 var persistent integer edgeSignOnCell ( maxEdges nCells ) 0 - edgeSignOnCell mesh - -
@@ -389,3 +393,6 @@
 var scratch real drhoTopOfEdge ( nVertLevelsP1 nEdges ) 0 - drhoTopOfEdge scratch - -
 var scratch real du2TopOfCell ( nVertLevelsP1 nCells ) 0 - du2TopOfCell scratch - -
 var scratch real du2TopOfEdge ( nVertLevelsP1 nEdges ) 0 - du2TopOfEdge scratch - -
+
+% Sea surface pressure, for coupling
+var persistent real    seaSurfacePressure ( nCells Time ) 0 ir seaSurfacePressure mesh - -

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

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

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

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_mpas_core.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_mpas_core.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_mpas_core.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -7,9 +7,9 @@
    use mpas_timer
 
    use ocn_global_diagnostics
-   use ocn_test_cases
    use ocn_time_integration
    use ocn_tendency
+   use ocn_diagnostics
 
    use ocn_monthly_forcing
 
@@ -102,6 +102,8 @@
 
       call ocn_tendency_init(err_tmp)
       err = ior(err,err_tmp)
+      call ocn_diagnostics_init(err_tmp)
+      err = ior(err,err_tmp)
 
       call mpas_ocn_tracer_advection_init(err_tmp)
       err = ior(err,err_tmp)
@@ -115,15 +117,13 @@
           call mpas_dmpar_abort(dminfo)
       endif
 
-      if (.not. config_do_restart) call setup_sw_test_case(domain)
-
       if (config_vert_coord_movement.ne.'isopycnal') call ocn_init_vert_coord(domain)
 
       call ocn_compute_max_level(domain)
 
       if (.not.config_do_restart) call ocn_init_split_timestep(domain)
 
-      write (0,'(a,a10)') ' Vertical coordinate movement is: ',config_vert_coord_movement
+      write (0,'(a,a)') ' Vertical coordinate movement is: ',trim(config_vert_coord_movement)
 
       if (config_vert_coord_movement.ne.'isopycnal'.and. &amp;
           config_vert_coord_movement.ne.'fixed'.and. &amp;
@@ -169,16 +169,10 @@
          block =&gt; block % next
       end do
 
-   ! mrp 100316 In order for this to work, we need to pass domain % dminfo as an 
-   ! input arguement into mpas_init.  Ask about that later.  For now, there will be
-   ! no initial statistics write.
-   
       if (config_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
@@ -296,7 +290,6 @@
                        block % state % time_levs(1) % state % uReconstructMeridional % array    &amp;
                       )
 
-!TDR
       call mpas_reconstruct(mesh, mesh % u_src % array,                  &amp;
                        block % state % time_levs(1) % state % uSrcReconstructX % array,            &amp;
                        block % state % time_levs(1) % state % uSrcReconstructY % array,            &amp;
@@ -304,18 +297,12 @@
                        block % state % time_levs(1) % state % uSrcReconstructZonal % array,        &amp;
                        block % state % time_levs(1) % state % uSrcReconstructMeridional % array    &amp;
                       )
-!TDR
 
-      ! initialize velocities and tracers on land to be -1e34
-      ! The reconstructed velocity on land will have values not exactly
-      ! -1e34 due to the interpolation of reconstruction.
+      ! initialize velocities and tracers on land to be zero.
 
       block % mesh % areaCell % array(block % mesh % nCells+1) = -1.0e34
 
       do iEdge=1,block % mesh % nEdges
-         ! mrp 101115 note: in order to include flux boundary conditions, the following
-         ! line will need to change.  Right now, set boundary edges between land and 
-         ! water to have zero velocity.
          block % state % time_levs(1) % state % u % array( &amp;
              block % mesh % maxLevelEdgeTop % array(iEdge)+1 &amp;
             :block % mesh % maxLevelEdgeBot % array(iEdge), iEdge) = 0.0
@@ -323,15 +310,11 @@
          block % state % time_levs(1) % state % u % array( &amp;
              block % mesh % maxLevelEdgeBot % array(iEdge)+1: &amp;
              block % mesh % nVertLevels,iEdge) = 0.0
-! mrp changed to 0
-!             block % mesh % nVertLevels,iEdge) = -1e34
       end do
       do iCell=1,block % mesh % nCells
          block % state % time_levs(1) % state % tracers % array( &amp;
             :, block % mesh % maxLevelCell % array(iCell)+1 &amp;
               :block % mesh % nVertLevels,iCell) =  0.0
-! mrp changed to 0
-!              :block % mesh % nVertLevels,iCell) =  -1e34
       end do
 
       do i=2,nTimeLevs
@@ -613,11 +596,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)
@@ -1038,7 +1016,7 @@
       meshScalingDel2(:) = 1.0
       meshScalingDel4(:) = 1.0
       meshScaling(:)     = 1.0
-      if (config_h_ScaleWithMesh) then
+      if (config_hmix_ScaleWithMesh) then
          do iEdge=1,mesh%nEdges
             cell1 = mesh % cellsOnEdge % array(1,iEdge)
             cell2 = mesh % cellsOnEdge % array(2,iEdge)

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

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

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_time_average.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_time_average.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_time_average.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -15,7 +15,7 @@
 
         real (kind=RKIND), dimension(:), pointer :: acc_ssh, acc_sshVar
         real (kind=RKIND), dimension(:,:), pointer :: acc_uReconstructZonal, acc_uReconstructMeridional, acc_uReconstructZonalVar, acc_uReconstructMeridionalVar
-        real (kind=RKIND), dimension(:,:), pointer :: acc_u, acc_uVar
+        real (kind=RKIND), dimension(:,:), pointer :: acc_u, acc_uVar, acc_vertVelocityTop
 
         nAccumulate =&gt; state % nAccumulate % scalar
 
@@ -27,6 +27,7 @@
         acc_uReconstructMeridionalVar =&gt; state % acc_uReconstructMeridionalVar % array
         acc_u =&gt; state % acc_u % array
         acc_uVar =&gt; state % acc_uVar % array
+        acc_vertVelocityTop =&gt; state % acc_vertVelocityTop % array
 
         nAccumulate = 0
 
@@ -38,6 +39,7 @@
         acc_uReconstructMeridionalVar = 0.0
         acc_u = 0.0
         acc_uVar = 0.0
+        acc_vertVelocityTop = 0.0
 
     end subroutine ocn_time_average_init!}}}
 
@@ -48,13 +50,13 @@
         real (kind=RKIND), pointer :: nAccumulate, old_nAccumulate
 
         real (kind=RKIND), dimension(:), pointer :: ssh
-        real (kind=RKIND), dimension(:,:), pointer :: uReconstructZonal, uReconstructMeridional, u
+        real (kind=RKIND), dimension(:,:), pointer :: uReconstructZonal, uReconstructMeridional, u, vertVelocityTop
 
-        real (kind=RKIND), dimension(:,:), pointer :: acc_u, acc_uVar
+        real (kind=RKIND), dimension(:,:), pointer :: acc_u, acc_uVar, acc_vertVelocityTop
         real (kind=RKIND), dimension(:,:), pointer :: acc_uReconstructZonal, acc_uReconstructMeridional, acc_uReconstructZonalVar, acc_uReconstructMeridionalVar
         real (kind=RKIND), dimension(:), pointer :: acc_ssh, acc_sshVar
 
-        real (kind=RKIND), dimension(:,:), pointer :: old_acc_u, old_acc_uVar
+        real (kind=RKIND), dimension(:,:), pointer :: old_acc_u, old_acc_uVar, old_acc_vertVelocityTop
         real (kind=RKIND), dimension(:,:), pointer :: old_acc_uReconstructZonal, old_acc_uReconstructMeridional, old_acc_uReconstructZonalVar, old_acc_uReconstructMeridionalVar
         real (kind=RKIND), dimension(:), pointer :: old_acc_ssh, old_acc_sshVar
 
@@ -65,6 +67,7 @@
         uReconstructZonal =&gt; state % uReconstructZonal % array
         uReconstructMeridional =&gt; state % uReconstructMeridional % array
         u =&gt; state % u % array
+        vertVelocityTop =&gt; state % vertVelocityTop % array
 
         acc_ssh =&gt; state % acc_ssh % array
         acc_sshVar =&gt; state % acc_sshVar % array
@@ -74,6 +77,7 @@
         acc_uReconstructMeridionalVar =&gt; state % acc_uReconstructMeridionalVar % array
         acc_u =&gt; state % acc_u % array
         acc_uVar =&gt; state % acc_uVar % array
+        acc_vertVelocityTop =&gt; state % acc_vertVelocityTop % array
 
         old_acc_ssh =&gt; old_state % acc_ssh % array
         old_acc_sshVar =&gt; old_state % acc_sshVar % array
@@ -83,6 +87,7 @@
         old_acc_uReconstructMeridionalVar =&gt; old_state % acc_uReconstructMeridionalVar % array
         old_acc_u =&gt; old_state % acc_u % array
         old_acc_uVar =&gt; old_state % acc_uVar % array
+        old_acc_vertVelocityTop =&gt; old_state % acc_vertVelocityTop % array
 
         acc_ssh = old_acc_ssh + ssh
         acc_sshVar = old_acc_sshVar + ssh**2
@@ -92,6 +97,7 @@
         acc_uReconstructMeridionalVar = old_acc_uReconstructMeridionalVar + uReconstructMeridional**2
         acc_u = old_acc_u + u
         acc_uVar = old_acc_uVar + u**2
+        acc_vertVelocityTop = old_acc_vertVelocityTop + vertVelocityTop
 
         nAccumulate = old_nAccumulate + 1
     end subroutine ocn_time_average_accumulate!}}}
@@ -103,7 +109,7 @@
 
         real (kind=RKIND), dimension(:), pointer :: acc_ssh, acc_sshVar
         real (kind=RKIND), dimension(:,:), pointer :: acc_uReconstructZonal, acc_uReconstructMeridional, acc_uReconstructZonalVar, acc_uReconstructMeridionalVar
-        real (kind=RKIND), dimension(:,:), pointer :: acc_u, acc_uVar
+        real (kind=RKIND), dimension(:,:), pointer :: acc_u, acc_uVar, acc_vertVelocityTop
 
         nAccumulate =&gt; state % nAccumulate  % scalar
 
@@ -115,6 +121,7 @@
         acc_uReconstructMeridionalVar =&gt; state % acc_uReconstructMeridionalVar % array
         acc_u =&gt; state % acc_u % array
         acc_uVar =&gt; state % acc_uVar % array
+        acc_vertVelocityTop =&gt; state % acc_vertVelocityTop % array
 
         if(nAccumulate &gt; 0) then
           acc_ssh = acc_ssh / nAccumulate
@@ -125,6 +132,7 @@
           acc_uReconstructMeridionalVar = acc_uReconstructMeridionalVar / nAccumulate
           acc_u = acc_u / nAccumulate
           acc_uVar = acc_uVar / nAccumulate
+          acc_vertVelocityTop = acc_vertVelocityTop / nAccumulate
         end if
     end subroutine ocn_time_average_normalize!}}}
 

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_time_integration_rk4.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_time_integration_rk4.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_time_integration_rk4.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -22,6 +22,7 @@
    use mpas_timer
 
    use ocn_tendency
+   use ocn_diagnostics
 
    use ocn_equation_of_state
    use ocn_vmix
@@ -148,7 +149,7 @@
         !$OMP SINGLE
         call mpas_timer_start(&quot;RK4-diagnostic halo update&quot;)
         call mpas_dmpar_exch_halo_field(domain % blocklist % provis % Vor_edge)
-        if (config_h_mom_eddy_visc4 &gt; 0.0) then
+        if (config_mom_del4 &gt; 0.0) then
            call mpas_dmpar_exch_halo_field(domain % blocklist % provis % divergence)
            call mpas_dmpar_exch_halo_field(domain % blocklist % provis % vorticity)
         end if
@@ -162,11 +163,6 @@
         !$OMP END SINGLE
         block =&gt; domain % blocklist
         do while (associated(block))
-
-           if (.not.config_implicit_vertical_mix) then
-              call ocn_vmix_coefs(block % mesh, block % provis, block % diagnostics, block % scratch, err)
-           end if
-
            ! advection of u uses u, while advection of h and tracers use uTransport.
            call ocn_wtop(block % mesh, block % provis % h % array, block % provis % h_edge % array, &amp;
               block % provis % u % array, block % provis % wTop % array, err)
@@ -180,7 +176,7 @@
                call ocn_filter_btr_mode_tend_u(block % tend, block % provis, block % mesh)
            endif
 
-           call ocn_tend_scalar(block % tend, block % provis, block % diagnostics, block % mesh, block % scratch, dt)
+           call ocn_tend_tracer(block % tend, block % provis, block % diagnostics, block % mesh, block % scratch, dt)
            block =&gt; block % next
         end do
         !$OMP SINGLE
@@ -222,12 +218,6 @@
               end do
               !$OMP END DO
 
-              if (config_test_case == 1) then    ! For case 1, wind field should be fixed
-                 !$OMP WORKSHARE
-                 block % provis % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
-                 !$OMP END WORKSHARE
-              end if
-
               if (config_prescribe_velocity) then
                  !$OMP WORKSHARE
                  block % provis % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
@@ -296,7 +286,7 @@
       !$OMP END SINGLE
 
       !
-      !  A little clean up at the end: decouple new scalar fields and compute diagnostics for new state
+      !  A little clean up at the end: rescale tracer fields and compute diagnostics for new state
       !
       !$OMP SINGLE
       call mpas_timer_start(&quot;RK4-cleaup phase&quot;)
@@ -316,48 +306,38 @@
         block =&gt; block % next
       end do
 
+      !$OMP SINGLE
+      call mpas_timer_start(&quot;RK4-implicit vert mix&quot;)
+      !$OMP END SINGLE
+      block =&gt; domain % blocklist
+      do while(associated(block))
+        ! Call ocean diagnostic solve in preparation for vertical mixing.  Note 
+        ! it is called again after vertical mixing, because u and tracers change.
+        ! For Richardson vertical mixing, only rho, h_edge, and ke_edge need to 
+        ! be computed.  For kpp, more variables may be needed.  Either way, this
+        ! could be made more efficient by only computing what is needed for the
+        ! implicit vmix routine that follows. 
+        call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
 
-      if (config_implicit_vertical_mix) then
-        !$OMP SINGLE
-        call mpas_timer_start(&quot;RK4-implicit vert mix&quot;)
-        !$OMP END SINGLE
-        block =&gt; domain % blocklist
-        do while(associated(block))
+        call ocn_vmix_implicit(dt, block % mesh, block % diagnostics, block % state % time_levs(2) % state, block % scratch, err)
+        block =&gt; block % next
+      end do
 
-          ! Call ocean diagnostic solve in preparation for vertical mixing.  Note 
-          ! it is called again after vertical mixing, because u and tracers change.
-          ! For Richardson vertical mixing, only rho, h_edge, and ke_edge need to 
-          ! be computed.  For kpp, more variables may be needed.  Either way, this
-          ! could be made more efficient by only computing what is needed for the
-          ! implicit vmix routine that follows. mrp 121023.
-          call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
+      ! Update halo on u and tracers, which were just updated for implicit vertical mixing.  If not done, 
+      ! this leads to lack of volume conservation.  It is required because halo updates in RK4 are only
+      ! conducted on tendencies, not on the velocity and tracer fields.  So this update is required to 
+      ! communicate the change due to implicit vertical mixing across the boundary.
+      !$OMP SINGLE
+      call mpas_timer_start(&quot;RK4-implicit vert mix halos&quot;)
+      call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % u)
+      call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % tracers)
+      call mpas_timer_stop(&quot;RK4-implicit vert mix halos&quot;)
+      call mpas_timer_stop(&quot;RK4-implicit vert mix&quot;)
+      call mpas_timer_stop(&quot;RK4-implicit vert mix&quot;)
+      !$OMP END SINGLE
 
-          call ocn_vmix_implicit(dt, block % mesh, block % diagnostics, block % state % time_levs(2) % state, block % scratch, err)
-          block =&gt; block % next
-        end do
-
-        ! Update halo on u and tracers, which were just updated for implicit vertical mixing.  If not done, 
-        ! this leads to lack of volume conservation.  It is required because halo updates in RK4 are only
-        ! conducted on tendencies, not on the velocity and tracer fields.  So this update is required to 
-        ! communicate the change due to implicit vertical mixing across the boundary.
-        !$OMP SINGLE
-        call mpas_timer_start(&quot;RK4-implicit vert mix halos&quot;)
-        call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % u)
-        call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % tracers)
-        call mpas_timer_stop(&quot;RK4-implicit vert mix halos&quot;)
-
-        call mpas_timer_stop(&quot;RK4-implicit vert mix&quot;)
-        !$OMP END SINGLE
-      end if
-
       block =&gt; domain % blocklist
       do while (associated(block))
-         if (config_test_case == 1) then    ! For case 1, wind field should be fixed
-            !$OMP WORKSHARE
-            block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
-            !$OMP END WORKSHARE
-         end if
-
          if (config_prescribe_velocity) then
             !$OMP WORKSHARE
             block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
@@ -389,7 +369,6 @@
                           block % state % time_levs(2) % state % uReconstructMeridional % array    &amp;
                          )
 
-!TDR
          !$OMP SECTION
          call mpas_reconstruct(block % mesh, block % mesh % u_src % array,          &amp;
                           block % state % time_levs(2) % state % uSrcReconstructX % array,            &amp;

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_time_integration_split.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_time_integration_split.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_time_integration_split.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -24,6 +24,7 @@
    use mpas_timer
 
    use ocn_tendency
+   use ocn_diagnostics
 
    use ocn_equation_of_state
    use ocn_vmix
@@ -178,7 +179,7 @@
          !$OMP SINGLE
          call mpas_timer_start(&quot;se halo diag&quot;, .false., timer_halo_diagnostic)
          call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % Vor_edge)
-         if (config_h_mom_eddy_visc4 &gt; 0.0) then
+         if (config_mom_del4 &gt; 0.0) then
            call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % divergence)
            call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % vorticity)
          end if
@@ -201,12 +202,6 @@
 
             stage1_tend_time = min(split_explicit_step,2)
 
-            !$OMP SINGLE
-            if (.not.config_implicit_vertical_mix) then
-               call ocn_vmix_coefs(block % mesh, block % state % time_levs(stage1_tend_time) % state, block % diagnostics, block % scratch, err)
-            end if
-            !$OMP END SINGLE
-
            ! compute wTop.  Use u (rather than uTransport) for momentum advection.
            ! Use the most recent time level available.
            call ocn_wtop(block % mesh, block % state % time_levs(stage1_tend_time) % state % h % array, &amp;
@@ -462,7 +457,6 @@
                 ! config_btr_gam1_uWt1=  1     flux = uBtrNew*H
                 ! config_btr_gam1_uWt1=0.5     flux = 1/2*(uBtrNew+uBtrOld)*H
                 ! config_btr_gam1_uWt1=  0     flux = uBtrOld*H
-                ! mrp 120201 efficiency: could we combine the following edge and cell loops?
 
                 !$OMP DO PRIVATE(i, iEdge, cell1, cell2, sshEdge, hSum, flux)
                 do iCell = 1, block % mesh % nCells
@@ -626,7 +620,6 @@
                   ! config_btr_gam3_uWt2=  1     flux = uBtrNew*H
                   ! config_btr_gam3_uWt2=0.5     flux = 1/2*(uBtrNew+uBtrOld)*H
                   ! config_btr_gam3_uWt2=  0     flux = uBtrOld*H
-                  ! mrp 120201 efficiency: could we combine the following edge and cell loops?
 
                   !$OMP DO PRIVATE(i, iEdge, cell1, cell2, sshCell1, sshCell2, sshEdge, hSum, flux)
                   do iCell = 1, block % mesh % nCells
@@ -856,13 +849,8 @@
          !
          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-         !TDR: it seems almost trivial to hold off on doing T, S and rho updates until the 
-         !TDR: dycore time step is complete. we might want to take this opportunity to clean-up
-         !TDR: Stage3 in order to faciliate the testing of not doing tracer updates after this code is committed to trunk.
-         !TDR: at this point, I am suggesting just pushing some of this code into subroutines. 
-         !TDR: see comments farther down
-
-         ! dwj: 02/22/12 splitting thickness and tracer tendency computations and halo updates to allow monotonic advection.
+         ! Thickness tendency computations and thickness halo updates are completed before tracer 
+         ! tendency computations to allow monotonic advection.
          block =&gt; domain % blocklist
          do while (associated(block))
 
@@ -886,7 +874,7 @@
 
          block =&gt; domain % blocklist
          do while (associated(block))
-            call ocn_tend_scalar(block % tend, block % state % time_levs(2) % state, block % diagnostics, block % mesh, block % scratch, dt)
+            call ocn_tend_tracer(block % tend, block % state % time_levs(2) % state, block % diagnostics, block % mesh, block % scratch, dt)
 
             block =&gt; block % next
          end do
@@ -908,9 +896,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.
                !$OMP DO PRIVATE(k, temp_h, i)
@@ -963,8 +948,8 @@
                end do ! iEdge
                !$OMP END DO
 
-               ! mrp 110512  I really only need this to compute h_edge, density, pressure, and SSH
-               ! I can par this down later.
+               ! Efficiency note: We really only need this to compute h_edge, density, pressure, and SSH 
+               ! in this diagnostics solve.
                call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
 
             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -974,9 +959,6 @@
             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
             elseif (split_explicit_step == config_n_ts_iter) then
 
-            !TDR: should we move this code into a subroutine called &quot;compute_final_values_at_nplus1&quot;?
-            !TDR: this could be within a contains statement in this routine
-
                !$OMP DO PRIVATE(k, i)
                do iCell=1,block % mesh % nCells
                   do k=1,block % mesh % maxLevelCell % array(iCell)
@@ -1028,95 +1010,84 @@
       ! END large iteration loop 
       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-      if (config_implicit_vertical_mix) then
-        !$OMP SINGLE
-        call mpas_timer_start(&quot;se implicit vert mix&quot;)
-        !$OMP END SINGLE
-        block =&gt; domain % blocklist
-        do while(associated(block))
+      !$OMP SINGLE
+      call mpas_timer_start(&quot;se implicit vert mix&quot;)
+      !$OMP END SINGLE
+      block =&gt; domain % blocklist
+      do while(associated(block))
 
-          ! Call ocean diagnostic solve in preparation for vertical mixing.  Note 
-          ! it is called again after vertical mixing, because u and tracers change.
-          ! For Richardson vertical mixing, only rho, h_edge, and ke_edge need to 
-          ! be computed.  For kpp, more variables may be needed.  Either way, this
-          ! could be made more efficient by only computing what is needed for the
-          ! implicit vmix routine that follows. mrp 121023.
-          call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
+        ! Call ocean diagnostic solve in preparation for vertical mixing.  Note 
+        ! it is called again after vertical mixing, because u and tracers change.
+        ! For Richardson vertical mixing, only rho, h_edge, and ke_edge need to 
+        ! be computed.  For kpp, more variables may be needed.  Either way, this
+        ! could be made more efficient by only computing what is needed for the
+        ! implicit vmix routine that follows.
+        call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
 
-          call ocn_vmix_implicit(dt, block % mesh, block % diagnostics, block % state % time_levs(2) % state, block % scratch, err)
+        call ocn_vmix_implicit(dt, block % mesh, block % diagnostics, block % state % time_levs(2) % state, block % scratch, err)
 
-          block =&gt; block % next
-        end do
+        block =&gt; block % next
+      end do
 
-        ! Update halo on u and tracers, which were just updated for implicit vertical mixing.  If not done, 
-        ! this leads to lack of volume conservation.  It is required because halo updates in stage 3 are only
-        ! conducted on tendencies, not on the velocity and tracer fields.  So this update is required to 
-        ! communicate the change due to implicit vertical mixing across the boundary.
-        !$OMP SINGLE
-        call mpas_timer_start(&quot;se implicit vert mix halos&quot;)
-        call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % u)
-        call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % tracers)
-        call mpas_timer_stop(&quot;se implicit vert mix halos&quot;)
+      ! Update halo on u and tracers, which were just updated for implicit vertical mixing.  If not done, 
+      ! this leads to lack of volume conservation.  It is required because halo updates in stage 3 are only
+      ! conducted on tendencies, not on the velocity and tracer fields.  So this update is required to 
+      ! communicate the change due to implicit vertical mixing across the boundary.
+      !$OMP SINGLE
+      call mpas_timer_start(&quot;se implicit vert mix halos&quot;)
+      call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % u)
+      call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % tracers)
+      call mpas_timer_stop(&quot;se implicit vert mix halos&quot;)
+      call mpas_timer_stop(&quot;se implicit vert mix&quot;)
+      !$OMP END SINGLE
+      call mpas_timer_stop(&quot;se implicit vert mix&quot;)
 
-        call mpas_timer_stop(&quot;se implicit vert mix&quot;)
-        !$OMP END SINGLE
-      end if
-
       block =&gt; domain % blocklist
       do while (associated(block))
+        if (config_prescribe_velocity) then
+           !$OMP WORKSHARE
+           block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
+           !$OMP END WORKSHARE
+        end if
 
-         if (config_test_case == 1) then    ! For case 1, wind field should be fixed
-            !$OMP WORKSHARE
-            block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
-            !$OMP END WORKSHARE
-         end if
+        if (config_prescribe_thickness) then
+           !$OMP WORKSHARE
+           block % state % time_levs(2) % state % h % array(:,:) = block % state % time_levs(1) % state % h % array(:,:)
+           !$OMP END WORKSHARE
+        end if
 
-         if (config_prescribe_velocity) then
-            !$OMP WORKSHARE
-            block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
-            !$OMP END WORKSHARE
-         end if
+        call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
 
-         if (config_prescribe_thickness) then
-            !$OMP WORKSHARE
-            block % state % time_levs(2) % state % h % array(:,:) = block % state % time_levs(1) % state % h % array(:,:)
-            !$OMP END WORKSHARE
-         end if
+        ! Compute velocity transport, used in advection terms of h and tracer tendency
+        !$OMP WORKSHARE
+           block % state % time_levs(2) % state % uTransport % array(:,:) &amp;
+         = block % state % time_levs(2) % state % u % array(:,:) &amp;
+         + block % state % time_levs(2) % state % uBolusGM % array(:,:)
+        !$OMP END WORKSHARE
 
-         call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
+        !$OMP SINGLE
+        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;
+                        )
+        !$OMP END SINGLE NOWAIT
 
-         ! Compute velocity transport, used in advection terms of h and tracer tendency
-         !$OMP WORKSHARE
-            block % state % time_levs(2) % state % uTransport % array(:,:) &amp;
-          = block % state % time_levs(2) % state % u % array(:,:) &amp;
-          + block % state % time_levs(2) % state % uBolusGM % array(:,:)
-         !$OMP END WORKSHARE
-
-         !$OMP SINGLE
-         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;
-                         )
-         !$OMP END SINGLE NOWAIT
-
+        !$OMP SINGLE
+        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;
+                        )
+        !$OMP END SINGLE
 !TDR
-         !$OMP SINGLE
-         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;
-                         )
-         !$OMP END SINGLE
-!TDR
+        call ocn_time_average_accumulate(block % state % time_levs(2) % state, block % state % time_levs(1) % state)
 
-         call ocn_time_average_accumulate(block % state % time_levs(2) % state, block % state % time_levs(1) % state)
-
-         block =&gt; block % next
+        block =&gt; block % next
       end do
 
       !$OMP SINGLE

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_advection_std.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_advection_std.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_advection_std.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -51,7 +51,7 @@
    ! Input: s - current model state
    !        grid - grid metadata
    !
-   ! Output: tend - computed scalar tendencies
+   ! Output: tend - computed tracer tendencies
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
 
       real (kind=RKIND), dimension(:,:,:), intent(inout) :: tend !&lt; Input/Output: Tracer tendency

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_hmix_del2.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_hmix_del2.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_hmix_del2.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -213,9 +213,9 @@
 
       del2on = .false.
 
-      if ( config_h_tracer_eddy_diff2 &gt; 0.0 ) then
+      if ( config_tracer_del2 &gt; 0.0 ) then
           del2On = .true.
-          eddyDiff2 = config_h_tracer_eddy_diff2
+          eddyDiff2 = config_tracer_del2
       endif
 
       if(.not.config_use_tracer_del2) del2on = .false.

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_hmix_del4.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_hmix_del4.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_hmix_del4.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -249,9 +249,9 @@
       err = 0
       del4on = .false.
 
-      if ( config_h_tracer_eddy_diff4 &gt; 0.0 ) then
+      if ( config_tracer_del4 &gt; 0.0 ) then
           del4On = .true.
-          eddyDiff4 = config_h_tracer_eddy_diff4
+          eddyDiff4 = config_tracer_del4
       endif
 
       if(.not.config_use_tracer_del4) del4on = .false.

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_vadv.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_vadv.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_vadv.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -123,11 +123,6 @@
 
       err = 0
 
-      ! mrp 120202 efficiency note:
-      ! The following if statement is not needed, since wTop is set to 
-      ! zero for isopycnal coordinates.  This if statment saves flops
-      ! for isopycnal coordinates.  However, if the loops are pushed
-      ! out, we could get rid of this if statement.
       if(.not.vadvOn) return
 
       call ocn_tracer_vadv_stencil_tend(grid, h, wTop, tracers, tend, err1)

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_vadv_spline3.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_vadv_spline3.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_tracer_vadv_spline3.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -150,8 +150,6 @@
             depthTop(k+1) = depthTop(k) +     h(k,iCell)
          enddo
 
-         ! mrp 110201 efficiency note: push tracer loop down
-         ! into spline subroutines to improve efficiency
          do iTracer=1,num_tracers
 
             ! Place data in arrays to avoid creating new temporary arrays for every 

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

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vel_hmix_del2.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vel_hmix_del2.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vel_hmix_del2.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -203,13 +203,12 @@
 
    hmixDel2On = .false.
 
-   if ( config_h_mom_eddy_visc2 &gt; 0.0 ) then
+   if ( config_mom_del2 &gt; 0.0 ) then
       hmixDel2On = .true.
-      eddyVisc2 = config_h_mom_eddy_visc2
+      eddyVisc2 = config_mom_del2
 
-
       if (config_visc_vorticity_term) then
-         viscVortCoef = config_visc_vorticity_visc2_scale
+         viscVortCoef = config_vorticity_del2_scale
       else
          viscVortCoef = 0.0
       endif

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vel_hmix_del4.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vel_hmix_del4.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vel_hmix_del4.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -193,7 +193,7 @@
          do k=1,maxLevelEdgeTop(iEdge)
             ! Compute </font>
<font color="black">abla^2 u = </font>
<font color="black">abla divergence + k \times </font>
<font color="gray">abla vorticity
             delsq_u(k, iEdge) =          ( divergence(k,cell2)  - divergence(k,cell1) ) * invDcEdge  &amp;
-                -viscVortCoef *( vorticity(k,vertex2) - vorticity(k,vertex1)) * invDcEdge * sqrt(3.0)   ! TDR
+                -viscVortCoef *( vorticity(k,vertex2) - vorticity(k,vertex1)) * invDcEdge * sqrt(3.0)   
          end do
       end do
       !$OMP END DO
@@ -239,7 +239,7 @@
 
          do k=1,maxLevelEdgeTop(iEdge)
             u_diffusion = (delsq_divergence(k,cell2) - delsq_divergence(k,cell1)) * invDcEdge  &amp;
-                -viscVortCoef * (delsq_vorticity(k,vertex2) - delsq_vorticity(k,vertex1) ) * invDcEdge * sqrt(3.0) ! TDR
+                -viscVortCoef * (delsq_vorticity(k,vertex2) - delsq_vorticity(k,vertex1) ) * invDcEdge * sqrt(3.0) 
 
             tend(k,iEdge) = tend(k,iEdge) - edgeMask(k, iEdge) * u_diffusion * r_tmp
          end do
@@ -285,11 +285,11 @@
 
    hmixDel4On = .false.
 
-   if ( config_h_mom_eddy_visc4 &gt; 0.0 ) then
+   if ( config_mom_del4 &gt; 0.0 ) then
       hmixDel4On = .true.
-      eddyVisc4 = config_h_mom_eddy_visc4
+      eddyVisc4 = config_mom_del4
       if (config_visc_vorticity_term) then
-         viscVortCoef = config_visc_vorticity_visc4_scale
+         viscVortCoef = config_vorticity_del4_scale
       else
          viscVortCoef = 0.0
       endif

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vel_hmix_leith.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vel_hmix_leith.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vel_hmix_leith.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -216,7 +216,7 @@
       hmixLeithOn = .true.
 
       if (config_visc_vorticity_term) then
-         viscVortCoef = config_visc_vorticity_visc2_scale
+         viscVortCoef = config_vorticity_del2_scale
       else
          viscVortCoef = 0.0
       endif

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vel_vadv.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vel_vadv.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vel_vadv.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -112,11 +112,6 @@
       real (kind=RKIND) :: wTopEdge
       real (kind=RKIND), dimension(:), allocatable :: w_dudzTopEdge
 
-      ! mrp 120202 efficiency note:
-      ! The following if statement is not needed, since wTop is set to 
-      ! zero for isopycnal coordinates.  This if statment saves flops
-      ! for isopycnal coordinates.  However, if the loops are pushed
-      ! out, we could get rid of this if statement.
       if(.not.velVadvOn) return
 
       err = 0

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vmix.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vmix.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vmix.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -44,8 +44,6 @@
               tridiagonal_solve_mult
 
    public :: ocn_vmix_coefs, &amp;
-             ocn_vel_vmix_tend_explicit, &amp;
-             ocn_tracer_vmix_tend_explicit, &amp;
              ocn_vel_vmix_tend_implicit, &amp;
              ocn_tracer_vmix_tend_implicit, &amp;
              ocn_vmix_init, &amp;
@@ -58,7 +56,6 @@
    !--------------------------------------------------------------------
 
    logical :: velVmixOn, tracerVmixOn
-   logical :: explicitOn, implicitOn
 
 !***********************************************************************
 
@@ -142,100 +139,6 @@
 
 !***********************************************************************
 !
-!  routine ocn_vel_vmix_tendExplict
-!
-!&gt; \brief   Computes tendencies for explict momentum vertical mixing
-!&gt; \author  Doug Jacobsen
-!&gt; \date    19 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the tendencies for explicit vertical mixing for momentum
-!&gt;  using computed coefficients.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_vel_vmix_tend_explicit(grid, u, h_edge, vertViscTopOfEdge, tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      type (mesh_type), intent(in) :: &amp;
-         grid          !&lt; Input: grid information
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         u             !&lt; Input: velocity
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h_edge        !&lt; Input: thickness at edge
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         vertViscTopOfEdge !&lt; Input: vertical mixing coefficients
-
-      !-----------------------------------------------------------------
-      !
-      ! input/output variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:), intent(inout) :: &amp;
-         tend          !&lt; Input/Output: tendency information
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: iEdge, nEdgesSolve, k, nVertLevels
-
-      integer, dimension(:), pointer :: maxLevelEdgeTop
-
-      real (kind=RKIND), dimension(:), allocatable :: fluxVertTop
-
-      err = 0
-
-      if(.not.velVmixOn) return
-      if(implicitOn) return
-
-      nEdgessolve = grid % nEdgesSolve
-      nVertLevels = grid % nVertLevels
-      maxLevelEdgeTop =&gt; grid % maxLevelEdgeTop % array
-
-      allocate(fluxVertTop(nVertLevels+1))
-      fluxVertTop(1) = 0.0
-      do iEdge=1,nEdgesSolve
-         do k=2,maxLevelEdgeTop(iEdge)
-           fluxVertTop(k) = vertViscTopOfEdge(k,iEdge) &amp;
-              * ( u(k-1,iEdge) - u(k,iEdge) ) &amp;
-              * 2 / (h_edge(k-1,iEdge) + h_edge(k,iEdge))
-         enddo
-         fluxVertTop(maxLevelEdgeTop(iEdge)+1) = 0.0
-
-         do k=1,maxLevelEdgeTop(iEdge)
-           tend(k,iEdge) = tend(k,iEdge) &amp;
-             + (fluxVertTop(k) - fluxVertTop(k+1)) &amp;
-             / h_edge(k,iEdge)
-         enddo
-
-      end do
-      deallocate(fluxVertTop)
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_vel_vmix_tend_explicit!}}}
-
-!***********************************************************************
-!
 !  routine ocn_vel_vmix_tend_implicit
 !
 !&gt; \brief   Computes tendencies for implicit momentum vertical mixing
@@ -308,7 +211,6 @@
       err = 0
 
       if(.not.velVmixOn) return
-      if(explicitOn) return
 
       nEdges = grid % nEdges
       nVertLevels = grid % nVertLevels
@@ -373,111 +275,6 @@
 
 !***********************************************************************
 !
-!  routine ocn_tracer_vmix_tendExplict
-!
-!&gt; \brief   Computes tendencies for explict tracer vertical mixing
-!&gt; \author  Doug Jacobsen
-!&gt; \date    19 September 2011
-!&gt; \version SVN:$Id$
-!&gt; \details 
-!&gt;  This routine computes the tendencies for explicit vertical mixing for
-!&gt;  tracers using computed coefficients.
-!
-!-----------------------------------------------------------------------
-
-   subroutine ocn_tracer_vmix_tend_explicit(grid, h, vertDiffTopOfCell, tracers, tend, err)!{{{
-
-      !-----------------------------------------------------------------
-      !
-      ! input variables
-      !
-      !-----------------------------------------------------------------
-
-      type (mesh_type), intent(in) :: &amp;
-         grid          !&lt; Input: grid information
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         h        !&lt; Input: thickness at cell center
-
-      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
-         vertDiffTopOfCell !&lt; Input: vertical mixing coefficients
-
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: &amp;
-         tracers             !&lt; Input: tracers
-
-      !-----------------------------------------------------------------
-      !
-      ! input/output variables
-      !
-      !-----------------------------------------------------------------
-
-      real (kind=RKIND), dimension(:,:,:), intent(inout) :: &amp;
-         tend          !&lt; Input/Output: tendency information
-
-      !-----------------------------------------------------------------
-      !
-      ! output variables
-      !
-      !-----------------------------------------------------------------
-
-      integer, intent(out) :: err !&lt; Output: error flag
-
-      !-----------------------------------------------------------------
-      !
-      ! local variables
-      !
-      !-----------------------------------------------------------------
-
-      integer :: iCell, nCellsSolve, k, iTracer, num_tracers, nVertLevels
-
-      integer, dimension(:), pointer :: maxLevelCell
-
-      real (kind=RKIND), dimension(:,:), allocatable :: fluxVertTop
-
-      err = 0
-
-      if(.not.tracerVmixOn) return
-      if(implicitOn) return
-
-      nCellsSolve = grid % nCellsSolve
-      nVertLevels = grid % nVertLevels
-      num_tracers = size(tracers, dim=1)
-
-      maxLevelCell =&gt; grid % maxLevelCell % array
-
-      allocate(fluxVertTop(num_tracers,nVertLevels+1))
-      fluxVertTop(:,1) = 0.0
-      do iCell=1,nCellsSolve 
-
-         do k=2,maxLevelCell(iCell)
-           do iTracer=1,num_tracers
-             ! compute \kappa_v d\phi/dz
-             fluxVertTop(iTracer,k) = vertDiffTopOfCell(k,iCell) &amp;
-                * (   tracers(iTracer,k-1,iCell)    &amp;
-                    - tracers(iTracer,k  ,iCell) )  &amp;
-                * 2 / (h(k-1,iCell) + h(k,iCell))
-
-           enddo
-         enddo
-         fluxVertTop(:,maxLevelCell(iCell)+1) = 0.0
-
-         do k=1,maxLevelCell(iCell)
-           do iTracer=1,num_tracers
-             ! This is h d/dz( fluxVertTop) but h and dz cancel, so 
-             ! reduces to delta( fluxVertTop)
-             tend(iTracer,k,iCell) = tend(iTracer,k,iCell) &amp;
-               + fluxVertTop(iTracer,k) - fluxVertTop(iTracer,k+1)
-           enddo
-         enddo
-
-      enddo ! iCell loop
-      deallocate(fluxVertTop)
-   !--------------------------------------------------------------------
-
-   end subroutine ocn_tracer_vmix_tend_explicit!}}}
-
-!***********************************************************************
-!
 !  routine ocn_tracer_vmix_tend_implicit
 !
 !&gt; \brief   Computes tendencies for implicit tracer vertical mixing
@@ -543,7 +340,6 @@
       err = 0
 
       if(.not.tracerVmixOn) return
-      if(explicitOn) return
 
       nCells = grid % nCells
       nVertLevels = grid % nVertLevels
@@ -656,8 +452,7 @@
 !&gt; \version SVN:$Id$
 !&gt; \details 
 !&gt;  This routine initializes a variety of quantities related to 
-!&gt;  vertical mixing in the ocean. This primarily determines if
-!&gt;  explicit or implicit vertical mixing is to be used.
+!&gt;  vertical mixing in the ocean. 
 !
 !-----------------------------------------------------------------------
 
@@ -681,14 +476,6 @@
       velVmixOn = .true.
       tracerVmixOn = .true.
 
-      explicitOn = .true.
-      implicitOn = .false.
-
-      if(config_implicit_vertical_mix) then
-          explicitOn = .false.
-          implicitOn = .true.
-      end if
-
       if(config_disable_u_vmix) velVmixOn = .false.
       if(config_disable_tr_vmix) tracerVmixOn = .false.
 

Modified: branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vmix_coefs_rich.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vmix_coefs_rich.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_ocean/mpas_ocn_vmix_coefs_rich.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -228,31 +228,17 @@
       !$OMP DO PRIVATE(k)
       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
-                   if( config_implicit_vertical_mix) then
-                      vertViscTopOfEdge(k,iEdge) = config_convective_visc
-                   else
-                      vertViscTopOfEdge(k,iEdge) = &amp;
-                      ((h_edge(k-1,iEdge)+h_edge(k,iEdge))/2.0)**2/config_dt/4.0
-                   end if
+                  vertViscTopOfEdge(k,iEdge) = config_convective_visc
                end if
             else
-               ! mrp 110324 efficiency note: this if is inside iCell and k loops.
-               if (config_implicit_vertical_mix) then
-                  ! for Ri&lt;0 and implicit mix, use convective diffusion
-                  vertViscTopOfEdge(k,iEdge) = config_convective_visc
-               else
-                  ! for Ri&lt;0 and explicit vertical mix, 
-                  ! use maximum diffusion allowed by CFL criterion
-                  vertViscTopOfEdge(k,iEdge) = vertViscTopOfEdge(k,iEdge) + ((h_edge(k-1,iEdge)+h_edge(k,iEdge))/2.0)**2/config_dt/4.0
-               end if
+               ! for Ri&lt;0 use the convective value for the viscosity
+               vertViscTopOfEdge(k,iEdge) = config_convective_visc
             end if
          end do
       end do
@@ -333,33 +319,19 @@
       !$OMP DO PRIVATE(k)
       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
-                  if (config_implicit_vertical_mix) then
-                     vertDiffTopOfCell(k,iCell) = config_convective_diff
-                  else
-                     vertDiffTopOfCell(k,iCell) = &amp;
-                        ((h(k-1,iCell)+h(k,iCell))/2.0)**2/config_dt/4.0
-                  end if
+                  vertDiffTopOfCell(k,iCell) = config_convective_diff
                end if
              else
-               ! mrp 110324 efficiency note: this if is inside iCell and k loops.
-               if (config_implicit_vertical_mix) then
-                  ! for Ri&lt;0 and implicit mix, use convective diffusion
-                  vertDiffTopOfCell(k,iCell) = config_convective_diff
-               else
-                  ! for Ri&lt;0 and explicit vertical mix, 
-                  ! use maximum diffusion allowed by CFL criterion
-                  vertDiffTopOfCell(k,iCell) = vertDiffTopOfCell(k, iCell) + ((h(k-1,iCell)+h(k,iCell))/2.0)**2/config_dt/4.0
-               end if
+               ! for Ri&lt;0 use the convective value for the diffusion
+               vertDiffTopOfCell(k,iCell) = config_convective_diff
             end if
          end do
       end do
@@ -475,16 +447,6 @@
       du2TopOfCell =&gt; scratch % du2TopOfCell % array
       du2TopOfEdge =&gt; scratch % du2TopOfEdge % array
 
-      ! 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$
       !$OMP WORKSHARE
       drhoTopOfCell = 0.0

Modified: branches/ocean_projects/openmp_elements/src/core_sw/Registry
===================================================================
--- branches/ocean_projects/openmp_elements/src/core_sw/Registry        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/core_sw/Registry        2013-03-29 14:40:23 UTC (rev 2678)
@@ -97,7 +97,7 @@
 
 var persistent real    edgeNormalVectors ( R3 nEdges ) 0 o edgeNormalVectors mesh - -
 var persistent real    localVerticalUnitVectors ( R3 nCells ) 0 o localVerticalUnitVectors mesh - -
-var persistent real    cellTangentPlane ( R3 TWO nEdges ) 0 o cellTangentPlane mesh - -
+var persistent real    cellTangentPlane ( R3 TWO nCells ) 0 o cellTangentPlane mesh - -
 
 var persistent integer cellsOnCell ( maxEdges nCells ) 0 iro cellsOnCell mesh - -
 var persistent integer verticesOnCell ( maxEdges nCells ) 0 iro verticesOnCell mesh - -

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

Modified: branches/ocean_projects/openmp_elements/src/framework/mpas_attlist.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/framework/mpas_attlist.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/framework/mpas_attlist.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/framework/mpas_block_decomp.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/framework/mpas_block_decomp.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/framework/mpas_block_decomp.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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
@@ -165,7 +190,7 @@
            allocate(block_id(blocks_per_proc))
            allocate(block_start(blocks_per_proc))
            allocate(block_count(blocks_per_proc))
-   
+
            do i = 1, blocks_per_proc
              block_start = 0
              block_count = 0
@@ -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
@@ -436,17 +513,29 @@
        end if
      else
        blocks_per_proc = 0
-       do i = 1, total_blocks
+       do i = 0, total_blocks-1
          call mpas_get_owning_proc(dminfo, i, owning_proc)
          if(owning_proc == proc_number) then
            call mpas_get_local_block_id(dminfo, i, local_block_id)
-           blocks_per_proc = max(blocks_per_proc, local_block_id)
+           blocks_per_proc = max(blocks_per_proc, local_block_id+1)
          end if
        end do
      end if
 
    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/ocean_projects/openmp_elements/src/framework/mpas_configure.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/framework/mpas_configure.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/framework/mpas_configure.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/framework/mpas_constants.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/framework/mpas_constants.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/framework/mpas_constants.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/framework/mpas_dmpar.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/framework/mpas_dmpar.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/framework/mpas_dmpar.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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
@@ -25,6 +36,8 @@
       module procedure mpas_dmpar_alltoall_field1d_real
       module procedure mpas_dmpar_alltoall_field2d_real
       module procedure mpas_dmpar_alltoall_field3d_real
+      module procedure mpas_dmpar_alltoall_field4d_real
+      module procedure mpas_dmpar_alltoall_field5d_real
    end interface
 
    private :: mpas_dmpar_alltoall_field1d_integer
@@ -32,6 +45,8 @@
    private :: mpas_dmpar_alltoall_field1d_real
    private :: mpas_dmpar_alltoall_field2d_real
    private :: mpas_dmpar_alltoall_field3d_real
+   private :: mpas_dmpar_alltoall_field4d_real
+   private :: mpas_dmpar_alltoall_field5d_real
 
 
    interface mpas_dmpar_exch_halo_field
@@ -41,6 +56,8 @@
       module procedure mpas_dmpar_exch_halo_field1d_real
       module procedure mpas_dmpar_exch_halo_field2d_real
       module procedure mpas_dmpar_exch_halo_field3d_real
+      module procedure mpas_dmpar_exch_halo_field4d_real
+      module procedure mpas_dmpar_exch_halo_field5d_real
    end interface
 
    private :: mpas_dmpar_exch_halo_field1d_integer
@@ -49,6 +66,8 @@
    private :: mpas_dmpar_exch_halo_field1d_real
    private :: mpas_dmpar_exch_halo_field2d_real
    private :: mpas_dmpar_exch_halo_field3d_real
+   private :: mpas_dmpar_exch_halo_field4d_real
+   private :: mpas_dmpar_exch_halo_field5d_real
 
    interface mpas_dmpar_copy_field
       module procedure mpas_dmpar_copy_field1d_integer
@@ -57,6 +76,8 @@
       module procedure mpas_dmpar_copy_field1d_real
       module procedure mpas_dmpar_copy_field2d_real
       module procedure mpas_dmpar_copy_field3d_real
+      module procedure mpas_dmpar_copy_field4d_real
+      module procedure mpas_dmpar_copy_field5d_real
    end interface
 
    private :: mpas_dmpar_copy_field1d_integer
@@ -65,15 +86,29 @@
    private :: mpas_dmpar_copy_field1d_real
    private :: mpas_dmpar_copy_field2d_real
    private :: mpas_dmpar_copy_field3d_real
+   private :: mpas_dmpar_copy_field4d_real
+   private :: mpas_dmpar_copy_field5d_real
 
    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
@@ -112,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
@@ -128,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
@@ -144,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
@@ -162,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
@@ -177,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
@@ -193,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
@@ -208,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
@@ -224,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
@@ -254,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
@@ -269,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
 
@@ -287,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
 
@@ -305,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
 
@@ -323,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
 
@@ -341,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 
       
@@ -359,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
 
@@ -377,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
 
@@ -396,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
 
@@ -415,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
 
@@ -434,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
 
@@ -453,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
 
@@ -472,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
 
@@ -491,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
@@ -509,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)) 
@@ -560,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
 
@@ -612,7 +915,7 @@
       !
     
       ! For the neededListField:
-      !    similar to the owneListField...
+      !    similar to the ownedListField...
 
       dminfo =&gt; ownedListField % block % domain % dminfo
 
@@ -1110,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
@@ -1391,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
@@ -1672,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
@@ -1960,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
@@ -2238,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
@@ -2520,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
@@ -2810,13 +3184,650 @@
 
    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 !&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
+     type (mpas_communication_list), pointer :: sendList, recvList, commListPtr, commListPtr2
+     type (dm_info), pointer :: dminfo
+
+     logical :: comm_list_found
+
+     integer :: lastPackedIdx, lastUnpackedIdx, nPacked, nUnpacked
+     integer :: nAdded, bufferOffset
+     integer :: mpi_ierr
+     integer :: iHalo, iBuffer, i, j, k, l
+     integer :: nHaloLayers
+     integer, dimension(:), pointer :: haloLayers
+
+     dminfo =&gt; fieldIn % block % domain % dminfo
+
+     if(present(haloLayersIn)) then
+       nHaloLayers = size(haloLayersIn)
+       allocate(haloLayers(nHaloLayers))
+       do iHalo = 1, nHaloLayers
+         haloLayers(iHalo) = haloLayersIn(iHalo)
+       end do
+     else
+       nHaloLayers = size(fieldIn % sendList % halos)
+       allocate(haloLayers(nHaloLayers))
+       do iHalo = 1, nHaloLayers
+         haloLayers(iHalo) = iHalo
+       end do
+     end if
+
+#ifdef _MPI
+     nullify(sendList)
+     nullify(recvList)
+
+     ! Setup recieve lists.
+     do iHalo = 1, nHaloLayers
+       fieldOutPtr =&gt; fieldOut
+       do while(associated(fieldOutPtr))
+         exchListPtr =&gt; fieldOutPtr % recvList % halos(haloLayers(iHalo)) % exchList
+         do while(associated(exchListPtr))
+           comm_list_found = .false.
+  
+           ! Search for an already created commList to this processor.
+           commListPtr =&gt; recvList
+           do while(associated(commListPtr))
+             if(commListPtr % procID == exchListPtr % endPointID) then
+               commListPtr % nList = commListPtr % nList + exchListPtr % nList * fieldOutPtr % dimSizes(1) * fieldOutPtr % dimSizes(2) * fieldOutPtr % dimSizes(3)
+               comm_list_found = .true.
+               exit
+             end if
+  
+             commListPtr =&gt; commListPtr % next
+           end do
+  
+           ! If no comm list exists, create a new one.
+           if(.not. comm_list_found) then
+             if(.not.associated(recvList)) then
+               allocate(recvList)
+               nullify(recvList % next)
+               commListPtr =&gt; recvList
+             else
+               commListPtr =&gt; recvList
+               commListPtr2 =&gt; commListPtr % next
+               do while(associated(commListPtr2))
+                 commListPtr =&gt; commListPtr % next
+                 commListPtr2 =&gt; commListPtr % next
+               end do
+
+               allocate(commListPtr % next)
+               commListPtr =&gt; commListPtr % next
+               nullify(commListPtr % next)
+             end if
+  
+             commListPtr % procID = exchListPtr % endPointID
+             commListPtr % nList = exchListPtr % nList * fieldOutPtr % dimSizes(1) * fieldOutPtr % dimSizes(2) * fieldOutPtr % dimSizes(3)
+           end if
+
+           exchListPtr =&gt; exchListPtr % next
+         end do
+  
+         fieldOutPtr =&gt; fieldOutPtr % next
+       end do
+     end do
+
+     ! Determine size of receive list buffers.
+     commListPtr =&gt; recvList
+     do while(associated(commListPtr))
+       call MPI_Wait(commListPtr % reqID, MPI_STATUS_IGNORE, mpi_ierr)
+
+       bufferOffset = 0
+       do iHalo = 1, nHaloLayers
+         nAdded = 0
+         fieldOutPtr =&gt; fieldOut
+         do while(associated(fieldOutPtr))
+           exchListPtr =&gt; fieldOutPtr % recvList % halos(haloLayers(iHalo)) % exchList
+           do while(associated(exchListPtr))
+             if(exchListPtr % endPointID == commListPtr % procID) then
+               nAdded = max(nAdded, maxval(exchListPtr % srcList) * fieldOutPtr % dimSizes(1) * fieldOutPtr % dimSizes(2) * fieldOutPtr % dimSizes(3))
+             end if
+             exchListPtr =&gt; exchListPtr % next
+           end do
+  
+           fieldOutPtr =&gt; fieldOutPtr % next
+         end do
+         bufferOffset = bufferOffset + nAdded
+       end do
+       commListPtr % nList = nAdded
+
+       commListPtr =&gt; commListPtr % next
+     end do
+
+     ! Allocate buffers for recieves, and initiate mpi_irecv calls.
+     commListPtr =&gt; recvList
+     do while(associated(commListPtr))
+       allocate(commListPtr % rbuffer(commListPtr % nList))
+       nullify(commListPtr % ibuffer)
+       call MPI_Irecv(commListPtr % rbuffer, commListPtr % nList, MPI_realKIND, commListPtr % procID, commListPtr % procID, dminfo % comm, commListPtr % reqID, mpi_ierr)
+       commListPtr =&gt; commListPtr % next
+     end do
+
+     ! Setup send lists, and determine the size of their buffers.
+     do iHalo = 1, nHaloLayers
+       fieldInPtr =&gt; fieldIn
+       do while(associated(fieldInPtr))
+         exchListPtr =&gt; fieldInPtr % sendList % halos(haloLayers(iHalo)) % exchList
+         do while(associated(exchListPtr))
+           comm_list_found = .false.
+  
+           ! Search for an already created commList to this processor.
+           commListPtr =&gt; sendList
+           do while(associated(commListPtr))
+             if(commListPtr % procID == exchListPtr % endPointID) then
+               commListPtr % nList = commListPtr % nList + exchListPtr % nList * fieldInPtr % dimSizes(1) * fieldInPtr % dimSizes(2) * fieldOutPtr % dimSizes(3)
+               comm_list_found = .true.
+               exit
+             end if
+  
+             commListPtr =&gt; commListPtr % next
+           end do
+  
+           ! If no comm list exists, create a new one.
+           if(.not. comm_list_found) then
+             if(.not.associated(sendList)) then
+               allocate(sendList)
+               nullify(sendList % next)
+               commListPtr =&gt; sendList
+             else
+               commListPtr =&gt; sendList
+               commListPtr2 =&gt; commListPtr % next
+               do while(associated(commListPtr2))
+                 commListPtr =&gt; commListPtr % next
+                 commListPtr2 =&gt; commListPtr % next
+               end do
+    
+               allocate(commListPtr % next)
+               commListPtr =&gt; commListPtr % next
+               nullify(commListPtr % next)
+             end if
+             commListPtr % procID = exchListPtr % endPointID
+             commListPtr % nList = exchListPtr % nList * fieldInPtr % dimSizes(1) * fieldInPtr % dimSizes(2) * fieldOutPtr % dimSizes(3)
+           end if
+  
+           exchListPtr =&gt; exchListPtr % next
+         end do
+  
+         fieldInPtr =&gt; fieldInPtr % next
+       end do
+     end do
+
+     ! Allocate sendLists, copy data into buffer, and initiate mpi_isends
+     commListPtr =&gt; sendList
+     do while(associated(commListPtr))
+       allocate(commListPtr % rbuffer(commListPtr % nList))
+       nullify(commListPtr % ibuffer)
+       bufferOffset = 0
+       do iHalo = 1, nHaloLayers
+         nAdded = 0
+         fieldInPtr =&gt; fieldIn
+         do while(associated(fieldInPtr))
+           exchListPtr =&gt; fieldInPtr % sendList % halos(haloLayers(iHalo)) % exchList
+           do while(associated(exchListPtr))
+             if(exchListPtr % endPointID == commListPtr % procID) then
+               do i = 1, exchListPtr % nList
+                 do j = 1, fieldInPtr % dimSizes(3)
+                   do k = 1, fieldInPtr % dimSizes(2)
+                     do l = 1, fieldInPtr % dimSizes(1)
+                       iBuffer = (exchListPtr % destList(i)-1) * fieldInPtr % dimSizes(1) * fieldInPtr % dimSizes(2) * fieldInPtr % dimSizes(3) &amp;
+                               + (j-1) * fieldInPtr % dimSizes(1) * fieldInPtr % dimSizes(2) &amp;
+                               + (k-1) * fieldInPtr % dimSizes(1) + l + bufferOffset
+                       commListPtr % rbuffer(iBuffer) = fieldInPtr % array(l, k, j, exchListPtr % srcList(i))
+                       nAdded = nAdded + 1
+                     end do
+                   end do
+                 end do
+               end do
+             end if
+  
+             exchListPtr =&gt; exchListPtr % next
+           end do
+  
+           fieldInPtr =&gt; fieldInPtr % next
+         end do
+         bufferOffset = bufferOffset + nAdded
+       end do
+
+       call MPI_Isend(commListPtr % rbuffer, commListPtr % nlist, MPI_realKIND, &amp;
+                      commListPtr % procID, dminfo % my_proc_id, dminfo % comm, commListPtr % reqID, mpi_ierr)
+
+       commListPtr =&gt; commListPtr % next
+     end do
+
+#endif     
+
+     ! Handle Local Copies. Only local copies if no MPI
+     do iHalo = 1, nHaloLayers
+       fieldInPtr =&gt; fieldIn
+       do while(associated(fieldInPtr))
+         exchListPtr =&gt; fieldInPtr % copyList % halos(haloLayers(iHalo)) % exchList
+         do while(associated(exchListPtr))
+           fieldOutPtr =&gt; fieldOut
+           do while(associated(fieldOutPtr))
+             if(exchListPtr % endPointID == fieldOutPtr % block % localBlockID) then
+               do i = 1, exchListPtr % nList
+                 fieldOutPtr % array(:, :, :, exchListPtr % destList(i)) = fieldInPtr % array(:, :, :, exchListPtr % srcList(i))
+               end do
+             end if
+             fieldOutPtr =&gt; fieldOutPtr % next
+           end do
+  
+           exchListPtr =&gt; exchListPtr % next
+         end do
+         fieldInPtr =&gt; fieldInPtr % next
+       end do
+     end do
+
+#ifdef _MPI
+     ! Wait for MPI_Irecv's to finish, and unpack data.
+     commListPtr =&gt; recvList
+     do while(associated(commListPtr))
+       call MPI_Wait(commListPtr % reqID, MPI_STATUS_IGNORE, mpi_ierr)
+
+       bufferOffset = 0
+       do iHalo = 1, nHaloLayers
+         nAdded = 0
+         fieldOutPtr =&gt; fieldOut
+         do while(associated(fieldOutPtr))
+           exchListPtr =&gt; fieldOutPtr % recvList % halos(haloLayers(iHalo)) % exchList
+           do while(associated(exchListPtr))
+             if(exchListPtr % endPointID == commListPtr % procID) then
+               do i = 1, exchListPtr % nList
+                 do j = 1, fieldOutPtr % dimSizes(3)
+                   do k = 1, fieldOutPtr % dimSizes(2)
+                     do l = 1, fieldOutPtr % dimSizes(1)
+                       iBuffer = (exchListPtr % srcList(i)-1) * fieldOutPtr % dimSizes(3) * fieldOutPtr % dimSizes(2) * fieldOutPtr % dimSizes(1)  &amp;
+                               + (j-1) * fieldOutPtr % dimSizes(1) * fieldOutPtr % dimSizes(2)  &amp;
+                               + (k-1) * fieldOutPtr % dimSizes(1) + l + bufferOffset
+                       fieldOutPtr % array(l, k, j, exchListPtr % destList(i)) = commListPtr % rbuffer(iBuffer)
+                     end do
+                   end do
+                 end do
+               end do
+               nAdded = max(nAdded, maxval(exchListPtr % srcList) * fieldOutPtr % dimSizes(1) * fieldOutPtr % dimSizes(2) * fieldOutPtr % dimSizes(3))
+             end if
+             exchListPtr =&gt; exchListPtr % next
+           end do
+  
+           fieldOutPtr =&gt; fieldOutPtr % next
+         end do
+         bufferOffset = bufferOffset + nAdded
+       end do
+
+       commListPtr =&gt; commListPtr % next
+     end do
+
+     ! Wait for MPI_Isend's to finish.
+     commListPtr =&gt; sendList
+     do while(associated(commListPtr))
+       call MPI_Wait(commListPtr % reqID, MPI_STATUS_IGNORE, mpi_ierr)
+       commListPtr =&gt; commListPtr % next
+     end do
+
+     ! Destroy commLists.
+     call mpas_dmpar_destroy_communication_list(sendList)
+     call mpas_dmpar_destroy_communication_list(recvList)
+#endif
+
+     deallocate(haloLayers)
+
+   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 !&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
+     type (mpas_communication_list), pointer :: sendList, recvList, commListPtr, commListPtr2
+     type (dm_info), pointer :: dminfo
+
+     logical :: comm_list_found
+
+     integer :: lastPackedIdx, lastUnpackedIdx, nPacked, nUnpacked
+     integer :: nAdded, bufferOffset
+     integer :: mpi_ierr
+     integer :: iHalo, iBuffer, i, j, k, l, m
+     integer :: nHaloLayers
+     integer, dimension(:), pointer :: haloLayers
+
+     dminfo =&gt; fieldIn % block % domain % dminfo
+
+     if(present(haloLayersIn)) then
+       nHaloLayers = size(haloLayersIn)
+       allocate(haloLayers(nHaloLayers))
+       do iHalo = 1, nHaloLayers
+         haloLayers(iHalo) = haloLayersIn(iHalo)
+       end do
+     else
+       nHaloLayers = size(fieldIn % sendList % halos)
+       allocate(haloLayers(nHaloLayers))
+       do iHalo = 1, nHaloLayers
+         haloLayers(iHalo) = iHalo
+       end do
+     end if
+
+#ifdef _MPI
+     nullify(sendList)
+     nullify(recvList)
+
+     ! Setup recieve lists.
+     do iHalo = 1, nHaloLayers
+       fieldOutPtr =&gt; fieldOut
+       do while(associated(fieldOutPtr))
+         exchListPtr =&gt; fieldOutPtr % recvList % halos(haloLayers(iHalo)) % exchList
+         do while(associated(exchListPtr))
+           comm_list_found = .false.
+  
+           ! Search for an already created commList to this processor.
+           commListPtr =&gt; recvList
+           do while(associated(commListPtr))
+             if(commListPtr % procID == exchListPtr % endPointID) then
+               commListPtr % nList = commListPtr % nList + exchListPtr % nList * fieldOutPtr % dimSizes(1) * fieldOutPtr % dimSizes(2) * fieldOutPtr % dimSizes(3) * fieldOutPtr % dimSizes(4)
+               comm_list_found = .true.
+               exit
+             end if
+  
+             commListPtr =&gt; commListPtr % next
+           end do
+  
+           ! If no comm list exists, create a new one.
+           if(.not. comm_list_found) then
+             if(.not.associated(recvList)) then
+               allocate(recvList)
+               nullify(recvList % next)
+               commListPtr =&gt; recvList
+             else
+               commListPtr =&gt; recvList
+               commListPtr2 =&gt; commListPtr % next
+               do while(associated(commListPtr2))
+                 commListPtr =&gt; commListPtr % next
+                 commListPtr2 =&gt; commListPtr % next
+               end do
+
+               allocate(commListPtr % next)
+               commListPtr =&gt; commListPtr % next
+               nullify(commListPtr % next)
+             end if
+  
+             commListPtr % procID = exchListPtr % endPointID
+             commListPtr % nList = exchListPtr % nList * fieldOutPtr % dimSizes(1) * fieldOutPtr % dimSizes(2) * fieldOutPtr % dimSizes(3) * fieldOutPtr % dimSizes(4)
+           end if
+
+           exchListPtr =&gt; exchListPtr % next
+         end do
+  
+         fieldOutPtr =&gt; fieldOutPtr % next
+       end do
+     end do
+
+     ! Determine size of receive list buffers.
+     commListPtr =&gt; recvList
+     do while(associated(commListPtr))
+       call MPI_Wait(commListPtr % reqID, MPI_STATUS_IGNORE, mpi_ierr)
+
+       bufferOffset = 0
+       do iHalo = 1, nHaloLayers
+         nAdded = 0
+         fieldOutPtr =&gt; fieldOut
+         do while(associated(fieldOutPtr))
+           exchListPtr =&gt; fieldOutPtr % recvList % halos(haloLayers(iHalo)) % exchList
+           do while(associated(exchListPtr))
+             if(exchListPtr % endPointID == commListPtr % procID) then
+               nAdded = max(nAdded, maxval(exchListPtr % srcList) * fieldOutPtr % dimSizes(1) * fieldOutPtr % dimSizes(2) * fieldOutPtr % dimSizes(3) * fieldOutPtr % dimSizes(4))
+             end if
+             exchListPtr =&gt; exchListPtr % next
+           end do
+  
+           fieldOutPtr =&gt; fieldOutPtr % next
+         end do
+         bufferOffset = bufferOffset + nAdded
+       end do
+       commListPtr % nList = nAdded
+
+       commListPtr =&gt; commListPtr % next
+     end do
+
+     ! Allocate buffers for recieves, and initiate mpi_irecv calls.
+     commListPtr =&gt; recvList
+     do while(associated(commListPtr))
+       allocate(commListPtr % rbuffer(commListPtr % nList))
+       nullify(commListPtr % ibuffer)
+       call MPI_Irecv(commListPtr % rbuffer, commListPtr % nList, MPI_realKIND, commListPtr % procID, commListPtr % procID, dminfo % comm, commListPtr % reqID, mpi_ierr)
+       commListPtr =&gt; commListPtr % next
+     end do
+
+     ! Setup send lists, and determine the size of their buffers.
+     do iHalo = 1, nHaloLayers
+       fieldInPtr =&gt; fieldIn
+       do while(associated(fieldInPtr))
+         exchListPtr =&gt; fieldInPtr % sendList % halos(haloLayers(iHalo)) % exchList
+         do while(associated(exchListPtr))
+           comm_list_found = .false.
+  
+           ! Search for an already created commList to this processor.
+           commListPtr =&gt; sendList
+           do while(associated(commListPtr))
+             if(commListPtr % procID == exchListPtr % endPointID) then
+               commListPtr % nList = commListPtr % nList + exchListPtr % nList * fieldInPtr % dimSizes(1) * fieldInPtr % dimSizes(2) * fieldOutPtr % dimSizes(3) * fieldInPtr % dimSizes(4)
+               comm_list_found = .true.
+               exit
+             end if
+  
+             commListPtr =&gt; commListPtr % next
+           end do
+  
+           ! If no comm list exists, create a new one.
+           if(.not. comm_list_found) then
+             if(.not.associated(sendList)) then
+               allocate(sendList)
+               nullify(sendList % next)
+               commListPtr =&gt; sendList
+             else
+               commListPtr =&gt; sendList
+               commListPtr2 =&gt; commListPtr % next
+               do while(associated(commListPtr2))
+                 commListPtr =&gt; commListPtr % next
+                 commListPtr2 =&gt; commListPtr % next
+               end do
+    
+               allocate(commListPtr % next)
+               commListPtr =&gt; commListPtr % next
+               nullify(commListPtr % next)
+             end if
+             commListPtr % procID = exchListPtr % endPointID
+             commListPtr % nList = exchListPtr % nList * fieldInPtr % dimSizes(1) * fieldInPtr % dimSizes(2) * fieldOutPtr % dimSizes(3) * fieldInPtr % dimSizes(4)
+           end if
+  
+           exchListPtr =&gt; exchListPtr % next
+         end do
+  
+         fieldInPtr =&gt; fieldInPtr % next
+       end do
+     end do
+
+     ! Allocate sendLists, copy data into buffer, and initiate mpi_isends
+     commListPtr =&gt; sendList
+     do while(associated(commListPtr))
+       allocate(commListPtr % rbuffer(commListPtr % nList))
+       nullify(commListPtr % ibuffer)
+       bufferOffset = 0
+       do iHalo = 1, nHaloLayers
+         nAdded = 0
+         fieldInPtr =&gt; fieldIn
+         do while(associated(fieldInPtr))
+           exchListPtr =&gt; fieldInPtr % sendList % halos(haloLayers(iHalo)) % exchList
+           do while(associated(exchListPtr))
+             if(exchListPtr % endPointID == commListPtr % procID) then
+               do i = 1, exchListPtr % nList
+                 do j = 1, fieldInPtr % dimSizes(4)
+                   do k = 1, fieldInPtr % dimSizes(3)
+                     do l = 1, fieldInPtr % dimSizes(2)
+                       do m = 1, fieldInPtr % dimSizes(1)
+                         iBuffer = (exchListPtr % destList(i)-1) * fieldInPtr % dimSizes(1) * fieldInPtr % dimSizes(2) * fieldInPtr % dimSizes(3) * fieldInPtr % dimSizes(4) &amp;
+                                 + (j-1) * fieldInPtr % dimSizes(1) * fieldInPtr % dimSizes(2) * fieldInPtr % dimSizes(3) &amp;
+                                 + (k-1) * fieldInPtr % dimSizes(1) * fieldInPtr % dimSizes(2) &amp;
+                                 + (l-1) * fieldInPtr % dimSizes(1) + m + bufferOffset
+                         commListPtr % rbuffer(iBuffer) = fieldInPtr % array(m, l, k, j, exchListPtr % srcList(i))
+                         nAdded = nAdded + 1
+                       end do
+                     end do
+                   end do
+                 end do
+               end do
+             end if
+  
+             exchListPtr =&gt; exchListPtr % next
+           end do
+  
+           fieldInPtr =&gt; fieldInPtr % next
+         end do
+         bufferOffset = bufferOffset + nAdded
+       end do
+
+       call MPI_Isend(commListPtr % rbuffer, commListPtr % nlist, MPI_realKIND, &amp;
+                      commListPtr % procID, dminfo % my_proc_id, dminfo % comm, commListPtr % reqID, mpi_ierr)
+
+       commListPtr =&gt; commListPtr % next
+     end do
+
+#endif     
+
+     ! Handle Local Copies. Only local copies if no MPI
+     do iHalo = 1, nHaloLayers
+       fieldInPtr =&gt; fieldIn
+       do while(associated(fieldInPtr))
+         exchListPtr =&gt; fieldInPtr % copyList % halos(haloLayers(iHalo)) % exchList
+         do while(associated(exchListPtr))
+           fieldOutPtr =&gt; fieldOut
+           do while(associated(fieldOutPtr))
+             if(exchListPtr % endPointID == fieldOutPtr % block % localBlockID) then
+               do i = 1, exchListPtr % nList
+                 fieldOutPtr % array(:, :, :, :, exchListPtr % destList(i)) = fieldInPtr % array(:, :, :, :, exchListPtr % srcList(i))
+               end do
+             end if
+             fieldOutPtr =&gt; fieldOutPtr % next
+           end do
+  
+           exchListPtr =&gt; exchListPtr % next
+         end do
+         fieldInPtr =&gt; fieldInPtr % next
+       end do
+     end do
+
+#ifdef _MPI
+     ! Wait for MPI_Irecv's to finish, and unpack data.
+     commListPtr =&gt; recvList
+     do while(associated(commListPtr))
+       call MPI_Wait(commListPtr % reqID, MPI_STATUS_IGNORE, mpi_ierr)
+
+       bufferOffset = 0
+       do iHalo = 1, nHaloLayers
+         nAdded = 0
+         fieldOutPtr =&gt; fieldOut
+         do while(associated(fieldOutPtr))
+           exchListPtr =&gt; fieldOutPtr % recvList % halos(haloLayers(iHalo)) % exchList
+           do while(associated(exchListPtr))
+             if(exchListPtr % endPointID == commListPtr % procID) then
+               do i = 1, exchListPtr % nList
+                 do j = 1, fieldOutPtr % dimSizes(4)
+                   do k = 1, fieldOutPtr % dimSizes(3)
+                     do l = 1, fieldOutPtr % dimSizes(2)
+                       do m = 1, fieldOutPtr % dimSizes(1)
+                         iBuffer = (exchListPtr % srcList(i)-1) * fieldOutPtr % dimSizes(4) * fieldOutPtr % dimSizes(3) * fieldOutPtr % dimSizes(2) * fieldOutPtr % dimSizes(1) &amp;
+                                 + (j-1) * fieldOutPtr % dimSizes(1) * fieldOutPtr % dimSizes(2) * fieldOutPtr % dimSizes(3) &amp;
+                                 + (k-1) * fieldOutPtr % dimSizes(1) * fieldOutPtr % dimSizes(2) &amp;
+                                 + (l-1) * fieldOutPtr % dimSizes(1) + m + bufferOffset
+                         fieldOutPtr % array(m, l, k, j, exchListPtr % destList(i)) = commListPtr % rbuffer(iBuffer)
+                       end do
+                     end do
+                   end do
+                 end do
+               end do
+               nAdded = max(nAdded, maxval(exchListPtr % srcList) * fieldOutPtr % dimSizes(1) * fieldOutPtr % dimSizes(2) * fieldOutPtr % dimSizes(3) * fieldOutPtr % dimSizes(4))
+             end if
+             exchListPtr =&gt; exchListPtr % next
+           end do
+  
+           fieldOutPtr =&gt; fieldOutPtr % next
+         end do
+         bufferOffset = bufferOffset + nAdded
+       end do
+
+       commListPtr =&gt; commListPtr % next
+     end do
+
+     ! Wait for MPI_Isend's to finish.
+     commListPtr =&gt; sendList
+     do while(associated(commListPtr))
+       call MPI_Wait(commListPtr % reqID, MPI_STATUS_IGNORE, mpi_ierr)
+       commListPtr =&gt; commListPtr % next
+     end do
+
+     ! Destroy commLists.
+     call mpas_dmpar_destroy_communication_list(sendList)
+     call mpas_dmpar_destroy_communication_list(recvList)
+#endif
+
+     deallocate(haloLayers)
+
+   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
@@ -3091,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
@@ -3372,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
@@ -3659,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
@@ -3937,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
@@ -4220,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
@@ -4507,9 +5578,640 @@
 
    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 !&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
+      type (mpas_exchange_list), pointer :: exchListPtr
+      type (mpas_communication_list), pointer :: sendList, recvList, commListPtr, commListPtr2
+      integer :: mpi_ierr
+      integer :: nHaloLayers, iHalo, i, j, k, l
+      integer :: bufferOffset, nAdded
+      integer, dimension(:), pointer :: haloLayers
+
+      logical :: comm_list_found
+
+      do i = 1, 4
+        if(field % dimSizes(i) &lt;= 0) then
+          return
+        end if
+      end do
+
+      dminfo =&gt; field % block % domain % dminfo
+
+      if(present(haloLayersIn)) then
+        nHaloLayers = size(haloLayersIn)
+        allocate(haloLayers(nHaloLayers))
+        do iHalo = 1, nHaloLayers
+          haloLayers(iHalo) = haloLayersIn(iHalo)
+        end do
+      else
+        nHaloLayers = size(field % sendList % halos)
+        allocate(haloLayers(nHaloLayers))
+        do iHalo = 1, nHaloLayers
+          haloLayers(iHalo) = iHalo
+        end do
+      end if
+
+#ifdef _MPI
+      ! Allocate communication lists, and setup dead header nodes
+      allocate(sendList)
+      nullify(sendList % next)
+      sendList % procID = -1
+      sendList % nList = 0
+
+      allocate(recvList)
+      nullify(recvList % next)
+      recvList % procID = -1
+      recvList % nList = 0
+
+      dminfo   = field % block % domain % dminfo
+
+      ! Determine size of buffers for communication lists
+      fieldCursor =&gt; field
+      do while(associated(fieldCursor))
+
+        ! Need to aggregate across halo layers
+        do iHalo = 1, nHaloLayers
+          
+          ! Determine size from send lists
+          exchListPtr =&gt; fieldCursor % sendList % halos(haloLayers(iHalo)) % exchList
+          do while(associated(exchListPtr))
+            comm_list_found = .false.
+
+            commListPtr =&gt; sendList
+            do while(associated(commListPtr))
+              if(commListPtr % procID == exchListPtr % endPointId) then
+                comm_list_found = .true.
+                commListPtr % nList = commListPtr % nList + exchListPtr % nList * fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) * fieldCursor % dimSizes(3)
+                exit
+              end if
+
+              commListPtr =&gt; commListPtr % next
+            end do
+
+            if(.not. comm_list_found) then
+              commListPtr =&gt; sendList
+              commListPtr2 =&gt; commListPtr % next
+              do while(associated(commListPtr2))
+                commListPtr =&gt; commListPtr % next
+                commListPtr2 =&gt; commListPtr % next
+              end do
+
+              allocate(commListPtr % next)
+              commListPtr =&gt; commListPtr % next
+              nullify(commListPtr % next)
+              commListPtr % procID = exchListPtr % endPointID
+              commListPtr % nList = exchListPtr % nList * fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) * fieldCursor % dimSizes(3)
+            end if
+
+            exchListPtr =&gt; exchListPtr % next
+          end do
+
+          ! Setup recv lists
+          exchListPtr =&gt; fieldCursor % recvList % halos(haloLayers(iHalo)) % exchList
+          do while(associated(exchListPtr))
+            comm_list_found = .false.
+
+            commListPtr =&gt; recvList
+            do while(associated(commListPtr))
+              if(commListPtr % procID == exchListPtr % endPointId) then
+                comm_list_found = .true.
+                exit
+              end if
+
+              commListPtr =&gt; commListPtr % next
+            end do
+
+            if(.not. comm_list_found) then
+              commListPtr =&gt; recvList
+              commListPtr2 =&gt; commListPtr % next
+              do while(associated(commListPtr2))
+                commListPtr =&gt; commListPtr % next
+                commListPtr2 =&gt; commListPtr % next
+              end do
+
+              allocate(commListPtr % next)
+              commListPtr =&gt; commListPtr % next
+              nullify(commListPtr % next)
+              commListPtr % procID = exchListPtr % endPointID
+            end if
+
+            exchListPtr =&gt; exchListPtr % next
+          end do
+        end do
+
+        fieldCursor =&gt; fieldCursor % next
+      end do
+
+      ! Remove the dead head pointer on send and recv list
+      commListPtr =&gt; sendList
+      sendList =&gt; sendList % next
+      deallocate(commListPtr)
+
+      commListPtr =&gt; recvList
+      recvList =&gt; recvList % next
+      deallocate(commListPtr)
+
+      ! Determine size of recv lists
+      commListPtr =&gt; recvList
+      do while(associated(commListPtr))
+        bufferOffset = 0
+        do iHalo = 1, nHaloLayers
+          nAdded = 0
+          fieldCursor =&gt; field
+          do while(associated(fieldCursor))
+            exchListPtr =&gt; fieldCursor % recvList % halos(haloLayers(iHalo)) % exchList
+            do while(associated(exchListPtr))
+              if(exchListPtr % endPointID == commListPtr % procID) then
+                nAdded = max(nAdded, maxval(exchListPtr % srcList) * fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) * fieldCursor % dimSizes(3))
+              end if
+              exchListPtr =&gt; exchListPtr % next
+            end do
+            
+            fieldCursor =&gt; fieldCursor % next
+          end do
+          bufferOffset = bufferOffset + nAdded
+        end do
+        commListPtr % nList = bufferOffset
+
+        commListPtr =&gt; commListPtr % next
+      end do
+
+      ! Allocate space in recv lists, and initiate mpi_irecv calls
+      commListPtr =&gt; recvList
+      do while(associated(commListPtr))
+        allocate(commListPtr % rbuffer(commListPtr % nList))
+        nullify(commListPtr % ibuffer)
+        call MPI_Irecv(commListPtr % rbuffer, commListPtr % nList, MPI_REALKIND, commListPtr % procID, commListPtr % procID, dminfo % comm, commListPtr % reqID, mpi_ierr)
+
+        commListPtr =&gt; commListPtr % next
+      end do
+
+      ! Allocate space in send lists, copy data into buffer, and initiate mpi_isend calls
+      commListPtr =&gt; sendList
+      do while(associated(commListPtr))
+        allocate(commListPtr % rbuffer(commListPtr % nList))
+        nullify(commListPtr % ibuffer)
+        bufferOffset = 0
+        do iHalo = 1, nHaloLayers
+          nAdded = 0
+          fieldCursor =&gt; field
+          do while(associated(fieldCursor))
+            exchListPtr =&gt; fieldCursor % sendList % halos(haloLayers(iHalo)) % exchList
+            do while(associated(exchListPtr))
+              if(exchListPtr % endPointID == commListPtr % procID) then
+                do  i = 1, exchListPtr % nList
+                  do j = 1, fieldCursor % dimSizes(3)
+                    do k = 1, fieldCursor % dimSizes(2)
+                      do l = 1, fieldCursor % dimSizes(1)
+                        commListPtr % rbuffer((exchListPtr % destList(i)-1) * fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) * fieldCursor % dimSizes(3) &amp;
+                            + (j-1) * fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) &amp;
+                            + (k-1) * fieldCursor % dimSizes(1) + l  + bufferOffset) &amp;
+                            = fieldCursor % array(l, k, j, exchListPtr % srcList(i))
+                        nAdded = nAdded + 1
+                      end do
+                    end do
+                  end do
+                end do
+              end if
+
+              exchListPtr =&gt; exchListPtr % next
+            end do
+
+            fieldCursor =&gt; fieldCursor % next
+          end do
+          bufferOffset = bufferOffset + nAdded
+        end do
+
+        call MPI_Isend(commListPtr % rbuffer, commListPtr % nList, MPI_REALKIND, commListPtr % procID, dminfo % my_proc_id, dminfo % comm, commListPtr % reqID, mpi_ierr)
+        commListPtr =&gt; commListPtr % next
+      end do
+#endif
+
+      ! Handle local copy. If MPI is off, then only local copies are performed.
+      fieldCursor =&gt; field
+      do while(associated(fieldCursor))
+        do iHalo = 1, nHaloLayers
+          exchListPtr =&gt; fieldCursor % copyList % halos(haloLayers(iHalo)) % exchList
+
+          do while(associated(exchListPtr))
+            fieldCursor2 =&gt; field
+            do while(associated(fieldCursor2))
+              if(exchListPtr % endPointID == fieldCursor2 % block % localBlockID) then
+                do i = 1, exchListPtr % nList
+                  fieldCursor2 % array(:, :, :, exchListPtr % destList(i)) = fieldCursor % array(:, :, :, exchListPtr % srcList(i))
+                end do
+              end if
+              
+              fieldCursor2 =&gt; fieldCursor2 % next
+            end do
+
+            exchListPtr =&gt; exchListPtr % next
+          end do
+        end do
+
+        fieldCursor =&gt; fieldCursor % next
+      end do
+
+#ifdef _MPI
+
+      ! Wait for mpi_irecv to finish, and unpack data from buffer
+      commListPtr =&gt; recvList
+      do while(associated(commListPtr))
+        call MPI_Wait(commListPtr % reqID, MPI_STATUS_IGNORE, mpi_ierr)
+        bufferOffset = 0
+        do iHalo = 1, nHaloLayers
+          nAdded = 0
+          fieldCursor =&gt; field
+          do while(associated(fieldCursor))
+            exchListPtr =&gt; fieldCursor % recvList % halos(haloLayers(iHalo)) % exchList
+            do while(associated(exchListPtr))
+              if(exchListPtr % endPointID == commListPtr % procID) then
+                do i = 1, exchListPtr % nList
+                  do j = 1, fieldCursor % dimSizes(3)
+                    do k = 1, fieldCursor % dimSizes(2)
+                      do l = 1, fieldCursor % dimSizes(1)
+                        fieldCursor % array(l, k, j, exchListPtr % destList(i)) = commListPtr % rbuffer((exchListPtr % srcList(i)-1)&amp;
+                                                                               *fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) *fieldCursor % dimSizes(3)&amp;
+                                                                             + (j-1)*fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) &amp;
+                                                                             + (k-1)*fieldCursor % dimSizes(1) + l + bufferOffset)
+                      end do
+                    end do
+                  end do
+                end do
+                nAdded = max(nAdded, maxval(exchListPtr % srcList) * fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) * fieldCursor % dimSizes(3))
+              end if
+              exchListPtr =&gt; exchListPtr % next
+            end do
+            
+            fieldCursor =&gt; fieldCursor % next
+          end do
+          bufferOffset = bufferOffset + nAdded
+        end do
+        commListPtr =&gt; commListPtr % next
+      end do
+
+      ! wait for mpi_isend to finish.
+      commListPtr =&gt; sendList
+      do while(associated(commListPtr))
+        call MPI_Wait(commListPtr % reqID, MPI_STATUS_IGNORE, mpi_ierr)
+        commListPtr =&gt; commListPtr % next
+      end do
+
+     ! Destroy commLists.
+     call mpas_dmpar_destroy_communication_list(sendList)
+     call mpas_dmpar_destroy_communication_list(recvList)
+#endif
+
+     deallocate(haloLayers)
+
+   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 !&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
+      type (mpas_exchange_list), pointer :: exchListPtr
+      type (mpas_communication_list), pointer :: sendList, recvList, commListPtr, commListPtr2
+      integer :: mpi_ierr
+      integer :: nHaloLayers, iHalo, i, j, k, l, m
+      integer :: bufferOffset, nAdded
+      integer, dimension(:), pointer :: haloLayers
+
+      logical :: comm_list_found
+
+      do i = 1, 5
+        if(field % dimSizes(i) &lt;= 0) then
+          return
+        end if
+      end do
+
+      dminfo =&gt; field % block % domain % dminfo
+
+      if(present(haloLayersIn)) then
+        nHaloLayers = size(haloLayersIn)
+        allocate(haloLayers(nHaloLayers))
+        do iHalo = 1, nHaloLayers
+          haloLayers(iHalo) = haloLayersIn(iHalo)
+        end do
+      else
+        nHaloLayers = size(field % sendList % halos)
+        allocate(haloLayers(nHaloLayers))
+        do iHalo = 1, nHaloLayers
+          haloLayers(iHalo) = iHalo
+        end do
+      end if
+
+#ifdef _MPI
+      ! Allocate communication lists, and setup dead header nodes
+      allocate(sendList)
+      nullify(sendList % next)
+      sendList % procID = -1
+      sendList % nList = 0
+
+      allocate(recvList)
+      nullify(recvList % next)
+      recvList % procID = -1
+      recvList % nList = 0
+
+      dminfo   = field % block % domain % dminfo
+
+      ! Determine size of buffers for communication lists
+      fieldCursor =&gt; field
+      do while(associated(fieldCursor))
+
+        ! Need to aggregate across halo layers
+        do iHalo = 1, nHaloLayers
+          
+          ! Determine size from send lists
+          exchListPtr =&gt; fieldCursor % sendList % halos(haloLayers(iHalo)) % exchList
+          do while(associated(exchListPtr))
+            comm_list_found = .false.
+
+            commListPtr =&gt; sendList
+            do while(associated(commListPtr))
+              if(commListPtr % procID == exchListPtr % endPointId) then
+                comm_list_found = .true.
+                commListPtr % nList = commListPtr % nList + exchListPtr % nList * fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) * fieldCursor % dimSizes(3) * fieldCursor % dimSizes(4)
+                exit
+              end if
+
+              commListPtr =&gt; commListPtr % next
+            end do
+
+            if(.not. comm_list_found) then
+              commListPtr =&gt; sendList
+              commListPtr2 =&gt; commListPtr % next
+              do while(associated(commListPtr2))
+                commListPtr =&gt; commListPtr % next
+                commListPtr2 =&gt; commListPtr % next
+              end do
+
+              allocate(commListPtr % next)
+              commListPtr =&gt; commListPtr % next
+              nullify(commListPtr % next)
+              commListPtr % procID = exchListPtr % endPointID
+              commListPtr % nList = exchListPtr % nList * fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) * fieldCursor % dimSizes(3) * fieldCursor % dimSizes(4)
+            end if
+
+            exchListPtr =&gt; exchListPtr % next
+          end do
+
+          ! Setup recv lists
+          exchListPtr =&gt; fieldCursor % recvList % halos(haloLayers(iHalo)) % exchList
+          do while(associated(exchListPtr))
+            comm_list_found = .false.
+
+            commListPtr =&gt; recvList
+            do while(associated(commListPtr))
+              if(commListPtr % procID == exchListPtr % endPointId) then
+                comm_list_found = .true.
+                exit
+              end if
+
+              commListPtr =&gt; commListPtr % next
+            end do
+
+            if(.not. comm_list_found) then
+              commListPtr =&gt; recvList
+              commListPtr2 =&gt; commListPtr % next
+              do while(associated(commListPtr2))
+                commListPtr =&gt; commListPtr % next
+                commListPtr2 =&gt; commListPtr % next
+              end do
+
+              allocate(commListPtr % next)
+              commListPtr =&gt; commListPtr % next
+              nullify(commListPtr % next)
+              commListPtr % procID = exchListPtr % endPointID
+            end if
+
+            exchListPtr =&gt; exchListPtr % next
+          end do
+        end do
+
+        fieldCursor =&gt; fieldCursor % next
+      end do
+
+      ! Remove the dead head pointer on send and recv list
+      commListPtr =&gt; sendList
+      sendList =&gt; sendList % next
+      deallocate(commListPtr)
+
+      commListPtr =&gt; recvList
+      recvList =&gt; recvList % next
+      deallocate(commListPtr)
+
+      ! Determine size of recv lists
+      commListPtr =&gt; recvList
+      do while(associated(commListPtr))
+        bufferOffset = 0
+        do iHalo = 1, nHaloLayers
+          nAdded = 0
+          fieldCursor =&gt; field
+          do while(associated(fieldCursor))
+            exchListPtr =&gt; fieldCursor % recvList % halos(haloLayers(iHalo)) % exchList
+            do while(associated(exchListPtr))
+              if(exchListPtr % endPointID == commListPtr % procID) then
+                nAdded = max(nAdded, maxval(exchListPtr % srcList) * fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) * fieldCursor % dimSizes(3) * fieldCursor % dimSizes(4))
+              end if
+              exchListPtr =&gt; exchListPtr % next
+            end do
+            
+            fieldCursor =&gt; fieldCursor % next
+          end do
+          bufferOffset = bufferOffset + nAdded
+        end do
+        commListPtr % nList = bufferOffset
+
+        commListPtr =&gt; commListPtr % next
+      end do
+
+      ! Allocate space in recv lists, and initiate mpi_irecv calls
+      commListPtr =&gt; recvList
+      do while(associated(commListPtr))
+        allocate(commListPtr % rbuffer(commListPtr % nList))
+        nullify(commListPtr % ibuffer)
+        call MPI_Irecv(commListPtr % rbuffer, commListPtr % nList, MPI_REALKIND, commListPtr % procID, commListPtr % procID, dminfo % comm, commListPtr % reqID, mpi_ierr)
+
+        commListPtr =&gt; commListPtr % next
+      end do
+
+      ! Allocate space in send lists, copy data into buffer, and initiate mpi_isend calls
+      commListPtr =&gt; sendList
+      do while(associated(commListPtr))
+        allocate(commListPtr % rbuffer(commListPtr % nList))
+        nullify(commListPtr % ibuffer)
+        bufferOffset = 0
+        do iHalo = 1, nHaloLayers
+          nAdded = 0
+          fieldCursor =&gt; field
+          do while(associated(fieldCursor))
+            exchListPtr =&gt; fieldCursor % sendList % halos(haloLayers(iHalo)) % exchList
+            do while(associated(exchListPtr))
+              if(exchListPtr % endPointID == commListPtr % procID) then
+                do  i = 1, exchListPtr % nList
+                  do j = 1, fieldCursor % dimSizes(4)
+                    do k = 1, fieldCursor % dimSizes(3)
+                      do l = 1, fieldCursor % dimSizes(2)
+                        do m = 1, fieldCursor % dimSizes(1)
+                          commListPtr % rbuffer((exchListPtr % destList(i)-1) * fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) * fieldCursor % dimSizes(3) * fieldCursor % dimSizes(4) &amp;
+                              + (j-1) * fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) * fieldCursor % dimSizes(3) &amp;
+                              + (k-1) * fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) &amp;
+                              + (l-1) * fieldCursor % dimSizes(1) + m + bufferOffset) &amp;
+                              = fieldCursor % array(m, l, k, j, exchListPtr % srcList(i))
+                          nAdded = nAdded + 1
+                        end do
+                      end do
+                    end do
+                  end do
+                end do
+              end if
+
+              exchListPtr =&gt; exchListPtr % next
+            end do
+
+            fieldCursor =&gt; fieldCursor % next
+          end do
+          bufferOffset = bufferOffset + nAdded
+        end do
+
+        call MPI_Isend(commListPtr % rbuffer, commListPtr % nList, MPI_REALKIND, commListPtr % procID, dminfo % my_proc_id, dminfo % comm, commListPtr % reqID, mpi_ierr)
+        commListPtr =&gt; commListPtr % next
+      end do
+#endif
+
+      ! Handle local copy. If MPI is off, then only local copies are performed.
+      fieldCursor =&gt; field
+      do while(associated(fieldCursor))
+        do iHalo = 1, nHaloLayers
+          exchListPtr =&gt; fieldCursor % copyList % halos(haloLayers(iHalo)) % exchList
+
+          do while(associated(exchListPtr))
+            fieldCursor2 =&gt; field
+            do while(associated(fieldCursor2))
+              if(exchListPtr % endPointID == fieldCursor2 % block % localBlockID) then
+                do i = 1, exchListPtr % nList
+                  fieldCursor2 % array(:, :, :, :, exchListPtr % destList(i)) = fieldCursor % array(:, :, :, :, exchListPtr % srcList(i))
+                end do
+              end if
+              
+              fieldCursor2 =&gt; fieldCursor2 % next
+            end do
+
+            exchListPtr =&gt; exchListPtr % next
+          end do
+        end do
+
+        fieldCursor =&gt; fieldCursor % next
+      end do
+
+#ifdef _MPI
+
+      ! Wait for mpi_irecv to finish, and unpack data from buffer
+      commListPtr =&gt; recvList
+      do while(associated(commListPtr))
+        call MPI_Wait(commListPtr % reqID, MPI_STATUS_IGNORE, mpi_ierr)
+        bufferOffset = 0
+        do iHalo = 1, nHaloLayers
+          nAdded = 0
+          fieldCursor =&gt; field
+          do while(associated(fieldCursor))
+            exchListPtr =&gt; fieldCursor % recvList % halos(haloLayers(iHalo)) % exchList
+            do while(associated(exchListPtr))
+              if(exchListPtr % endPointID == commListPtr % procID) then
+                do i = 1, exchListPtr % nList
+                  do j = 1, fieldCursor % dimSizes(4)
+                    do k = 1, fieldCursor % dimSizes(3)
+                      do l = 1, fieldCursor % dimSizes(2)
+                        do m = 1, fieldCursor % dimSizes(1)
+                          fieldCursor % array(m, l, k, j, exchListPtr % destList(i)) = commListPtr % rbuffer((exchListPtr % srcList(i)-1)&amp;
+                                                                                 *fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) *fieldCursor % dimSizes(3) * fieldCursor % dimSizes(4)&amp;
+                                                                               + (j-1)*fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) * fieldCursor % dimSizes(3) &amp;
+                                                                               + (k-1)*fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) &amp;
+                                                                               + (l-1)*fieldCursor % dimSizes(1) + m + bufferOffset)
+                        end do
+                      end do
+                    end do
+                  end do
+                end do
+                nAdded = max(nAdded, maxval(exchListPtr % srcList) * fieldCursor % dimSizes(1) * fieldCursor % dimSizes(2) * fieldCursor % dimSizes(3) * fieldCursor % dimSizes(4))
+              end if
+              exchListPtr =&gt; exchListPtr % next
+            end do
+            
+            fieldCursor =&gt; fieldCursor % next
+          end do
+          bufferOffset = bufferOffset + nAdded
+        end do
+        commListPtr =&gt; commListPtr % next
+      end do
+
+      ! wait for mpi_isend to finish.
+      commListPtr =&gt; sendList
+      do while(associated(commListPtr))
+        call MPI_Wait(commListPtr % reqID, MPI_STATUS_IGNORE, mpi_ierr)
+        commListPtr =&gt; commListPtr % next
+      end do
+
+     ! Destroy commLists.
+     call mpas_dmpar_destroy_communication_list(sendList)
+     call mpas_dmpar_destroy_communication_list(recvList)
+#endif
+
+     deallocate(haloLayers)
+
+   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
 
@@ -4520,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
@@ -4537,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
@@ -4563,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
@@ -4589,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
@@ -4602,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
@@ -4615,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
@@ -4628,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
 
 
@@ -4642,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
@@ -4655,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
@@ -4668,4 +6469,52 @@
        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 !&lt; Input: Field to copy
+       type (field4dReal), pointer :: fieldCursor
+
+       if(associated(field % next)) then
+         fieldCursor =&gt; field % next
+         do while(associated(fieldCursor))
+           fieldCursor % array = field % array
+           fieldCursor =&gt; fieldCursor % next
+         end do
+       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 !&lt; Input: Field to copy
+       type (field5dReal), pointer :: fieldCursor
+
+       if(associated(field % next)) then
+         fieldCursor =&gt; field % next
+         do while(associated(fieldCursor))
+           fieldCursor % array = field % array
+           fieldCursor =&gt; fieldCursor % next
+         end do
+       end if
+   end subroutine mpas_dmpar_copy_field5d_real!}}}
+
 end module mpas_dmpar

Modified: branches/ocean_projects/openmp_elements/src/framework/mpas_dmpar_types.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/framework/mpas_dmpar_types.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/framework/mpas_dmpar_types.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/framework/mpas_framework.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/framework/mpas_framework.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/framework/mpas_framework.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/framework/mpas_grid_types.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/framework/mpas_grid_types.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/framework/mpas_grid_types.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -20,8 +20,68 @@
       logical :: output
    end type io_info
 
+   ! Derived type for storing fields
+   type field5DReal
+  
+      ! Back-pointer to the containing block
+      type (block_type), pointer :: block
 
+      ! Raw array holding field data on this block
+      real (kind=RKIND), dimension(:,:,:,:,:), pointer :: array
+
+      ! Information used by the I/O layer
+      type (io_info), pointer :: ioinfo       ! to be removed later
+      character (len=StrKIND) :: fieldName
+      character (len=StrKIND), dimension(:), pointer :: constituentNames =&gt; null()
+      character (len=StrKIND), dimension(5) :: dimNames
+      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
+      type (field5DReal), pointer :: prev, next
+
+      ! Halo communication lists
+      type (mpas_multihalo_exchange_list), pointer :: sendList
+      type (mpas_multihalo_exchange_list), pointer :: recvList
+      type (mpas_multihalo_exchange_list), pointer :: copyList
+   end type field5DReal
+
+
    ! Derived type for storing fields
+   type field4DReal
+  
+      ! Back-pointer to the containing block
+      type (block_type), pointer :: block
+
+      ! Raw array holding field data on this block
+      real (kind=RKIND), dimension(:,:,:,:), pointer :: array
+
+      ! Information used by the I/O layer
+      type (io_info), pointer :: ioinfo       ! to be removed later
+      character (len=StrKIND) :: fieldName
+      character (len=StrKIND), dimension(:), pointer :: constituentNames =&gt; null()
+      character (len=StrKIND), dimension(4) :: dimNames
+      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
+      type (field4DReal), pointer :: prev, next
+
+      ! Halo communication lists
+      type (mpas_multihalo_exchange_list), pointer :: sendList
+      type (mpas_multihalo_exchange_list), pointer :: recvList
+      type (mpas_multihalo_exchange_list), pointer :: copyList
+   end type field4DReal
+
+
+
+   ! Derived type for storing fields
    type field3DReal
   
       ! Back-pointer to the containing block
@@ -38,6 +98,7 @@
       integer, dimension(3) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -67,6 +128,7 @@
       integer, dimension(2) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -96,6 +158,7 @@
       integer, dimension(1) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -152,6 +215,7 @@
       integer, dimension(3) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -181,6 +245,7 @@
       integer, dimension(2) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -210,6 +275,7 @@
       integer, dimension(1) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -266,6 +332,7 @@
       integer, dimension(1) :: dimSizes
       logical :: hasTimeDimension
       logical :: isSuperArray
+      logical :: isPersistent
       type (att_list_type), pointer :: attList =&gt; null()     
 
       ! Pointers to the prev and next blocks for this field on this task
@@ -370,6 +437,8 @@
      module procedure mpas_allocate_scratch_field1d_real
      module procedure mpas_allocate_scratch_field2d_real
      module procedure mpas_allocate_scratch_field3d_real
+     module procedure mpas_allocate_scratch_field4d_real
+     module procedure mpas_allocate_scratch_field5d_real
      module procedure mpas_allocate_scratch_field1d_char
    end interface
 
@@ -380,6 +449,8 @@
      module procedure mpas_deallocate_scratch_field1d_real
      module procedure mpas_deallocate_scratch_field2d_real
      module procedure mpas_deallocate_scratch_field3d_real
+     module procedure mpas_deallocate_scratch_field4d_real
+     module procedure mpas_deallocate_scratch_field5d_real
      module procedure mpas_deallocate_scratch_field1d_char
    end interface
 
@@ -392,6 +463,8 @@
      module procedure mpas_deallocate_field1d_real
      module procedure mpas_deallocate_field2d_real
      module procedure mpas_deallocate_field3d_real
+     module procedure mpas_deallocate_field4d_real
+     module procedure mpas_deallocate_field5d_real
      module procedure mpas_deallocate_field0d_char
      module procedure mpas_deallocate_field1d_char
    end interface
@@ -470,6 +543,10 @@
        logical :: single_block
        type (field1dInteger), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -498,6 +575,10 @@
        logical :: single_block
        type (field2dInteger), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -526,6 +607,10 @@
        logical :: single_block
        type (field3dInteger), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -554,6 +639,10 @@
        logical :: single_block
        type (field1dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -582,6 +671,10 @@
        logical :: single_block
        type (field2dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -610,6 +703,10 @@
        logical :: single_block
        type (field3dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -632,12 +729,80 @@
 
    end subroutine mpas_allocate_scratch_field3d_real!}}}
 
+   subroutine mpas_allocate_scratch_field4d_real(f, single_block_in)!{{{
+       type (field4dReal), pointer :: f
+       logical, intent(in), optional :: single_block_in
+       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
+          single_block = .false.
+       end if
+
+       if(.not. single_block) then
+          f_cursor =&gt; f
+          do while(associated(f_cursor))
+             if(.not.associated(f_cursor % array)) then
+                allocate(f_cursor % array(f_cursor % dimSizes(1), f_cursor % dimSizes(2), f_cursor % dimSizes(3), f_cursor % dimSizes(4)))
+             end if
+             f_cursor =&gt; f_cursor % next
+          end do
+       else
+          if(.not.associated(f % array)) then
+            allocate(f % array(f % dimSizes(1), f % dimSizes(2), f % dimSizes(3), f % dimSizes(4)))
+          end if
+       end if
+
+   end subroutine mpas_allocate_scratch_field4d_real!}}}
+
+   subroutine mpas_allocate_scratch_field5d_real(f, single_block_in)!{{{
+       type (field5dReal), pointer :: f
+       logical, intent(in), optional :: single_block_in
+       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
+          single_block = .false.
+       end if
+
+       if(.not. single_block) then
+          f_cursor =&gt; f
+          do while(associated(f_cursor))
+             if(.not.associated(f_cursor % array)) then
+                allocate(f_cursor % array(f_cursor % dimSizes(1), f_cursor % dimSizes(2), f_cursor % dimSizes(3), f_cursor % dimSizes(4), f_cursor % dimSizes(5)))
+             end if
+             f_cursor =&gt; f_cursor % next
+          end do
+       else
+          if(.not.associated(f % array)) then
+            allocate(f % array(f % dimSizes(1), f % dimSizes(2), f % dimSizes(3), f % dimSizes(4), f % dimSizes(5)))
+          end if
+       end if
+
+   end subroutine mpas_allocate_scratch_field5d_real!}}}
+
    subroutine mpas_allocate_scratch_field1d_char(f, single_block_in)!{{{
        type (field1dChar), pointer :: f
        logical, intent(in), optional :: single_block_in
        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
@@ -666,6 +831,10 @@
        logical :: single_block
        type (field1dInteger), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -695,6 +864,10 @@
        logical :: single_block
        type (field2dInteger), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -724,6 +897,10 @@
        logical :: single_block
        type (field3dInteger), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -753,6 +930,10 @@
        logical :: single_block
        type (field1dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -782,6 +963,10 @@
        logical :: single_block
        type (field2dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -811,6 +996,10 @@
        logical :: single_block
        type (field3dReal), pointer :: f_cursor
 
+       if(f % isPersistent) then
+          return
+       end if
+
        if(present(single_block_in)) then
           single_block = single_block_in
        else
@@ -834,12 +1023,82 @@
 
    end subroutine mpas_deallocate_scratch_field3d_real!}}}
 
+   subroutine mpas_deallocate_scratch_field4d_real(f, single_block_in)!{{{
+       type (field4dReal), pointer :: f
+       logical, intent(in), optional :: single_block_in
+       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
+          single_block = .false.
+       end if
+
+       if(.not.single_block) then
+          f_cursor =&gt; f
+          do while(associated(f_cursor))
+            if(associated(f_cursor % array)) then
+              deallocate(f_cursor % array)
+            end if
+   
+            f_cursor =&gt; f_cursor % next
+          end do
+       else
+          if(associated(f % array)) then
+             deallocate(f % array)
+          end if
+       end if
+
+   end subroutine mpas_deallocate_scratch_field4d_real!}}}
+
+   subroutine mpas_deallocate_scratch_field5d_real(f, single_block_in)!{{{
+       type (field5dReal), pointer :: f
+       logical, intent(in), optional :: single_block_in
+       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
+          single_block = .false.
+       end if
+
+       if(.not.single_block) then
+          f_cursor =&gt; f
+          do while(associated(f_cursor))
+            if(associated(f_cursor % array)) then
+              deallocate(f_cursor % array)
+            end if
+   
+            f_cursor =&gt; f_cursor % next
+          end do
+       else
+          if(associated(f % array)) then
+             deallocate(f % array)
+          end if
+       end if
+
+   end subroutine mpas_deallocate_scratch_field5d_real!}}}
+
    subroutine mpas_deallocate_scratch_field1d_char(f, single_block_in)!{{{
        type (field1dChar), pointer :: f
        logical, intent(in), optional :: single_block_in
        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
@@ -1073,6 +1332,60 @@
 
    end subroutine mpas_deallocate_field3d_real!}}}
 
+   subroutine mpas_deallocate_field4d_real(f)!{{{
+       type (field4dReal), pointer :: f
+       type (field4dReal), pointer :: f_cursor
+
+       f_cursor =&gt; f
+       do while(associated(f_cursor))
+         if(associated(f % next)) then
+           f =&gt; f % next
+         else
+           nullify(f)
+         end if
+
+         if(associated(f_cursor % ioinfo)) then
+           deallocate(f_cursor % ioinfo)
+         end if
+
+         if(associated(f_cursor % array)) then
+           deallocate(f_cursor % array)
+         end if
+
+         deallocate(f_cursor)
+
+         f_cursor =&gt; f
+       end do
+
+   end subroutine mpas_deallocate_field4d_real!}}}
+
+   subroutine mpas_deallocate_field5d_real(f)!{{{
+       type (field5dReal), pointer :: f
+       type (field5dReal), pointer :: f_cursor
+
+       f_cursor =&gt; f
+       do while(associated(f_cursor))
+         if(associated(f % next)) then
+           f =&gt; f % next
+         else
+           nullify(f)
+         end if
+
+         if(associated(f_cursor % ioinfo)) then
+           deallocate(f_cursor % ioinfo)
+         end if
+
+         if(associated(f_cursor % array)) then
+           deallocate(f_cursor % array)
+         end if
+
+         deallocate(f_cursor)
+
+         f_cursor =&gt; f
+       end do
+
+   end subroutine mpas_deallocate_field5d_real!}}}
+
    subroutine mpas_deallocate_field0d_char(f)!{{{
        type (field0dChar), pointer :: f
        type (field0dChar), pointer :: f_cursor

Modified: branches/ocean_projects/openmp_elements/src/framework/mpas_hash.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/framework/mpas_hash.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/framework/mpas_hash.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/framework/mpas_io.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/framework/mpas_io.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/framework/mpas_io.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -77,6 +77,7 @@
       module procedure MPAS_io_get_var_real2d
       module procedure MPAS_io_get_var_real3d
       module procedure MPAS_io_get_var_real4d
+      module procedure MPAS_io_get_var_real5d
       module procedure MPAS_io_get_var_char0d
    end interface MPAS_io_get_var
 
@@ -91,6 +92,7 @@
       module procedure MPAS_io_put_var_real2d
       module procedure MPAS_io_put_var_real3d
       module procedure MPAS_io_put_var_real4d
+      module procedure MPAS_io_put_var_real5d
       module procedure MPAS_io_put_var_char0d
    end interface MPAS_io_put_var
 
@@ -1146,7 +1148,7 @@
 
 
    subroutine MPAS_io_get_var_generic(handle, fieldname, intVal, intArray1d, intArray2d, intArray3d, intArray4d, &amp;
-                                                        realVal, realArray1d, realArray2d, realArray3d, realArray4d, &amp;
+                                                        realVal, realArray1d, realArray2d, realArray3d, realArray4d, realArray5d, &amp;
                                                         charVal, ierr)
 
       implicit none
@@ -1163,6 +1165,7 @@
       real (kind=RKIND), dimension(:,:), intent(out), optional :: realArray2d
       real (kind=RKIND), dimension(:,:,:), intent(out), optional :: realArray3d
       real (kind=RKIND), dimension(:,:,:,:), intent(out), optional :: realArray4d
+      real (kind=RKIND), dimension(:,:,:,:,:), intent(out), optional :: realArray5d
       character (len=*), intent(out), optional :: charVal
       integer, intent(out), optional :: ierr
 
@@ -1245,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'
@@ -1263,6 +1269,10 @@
 !         write (0,*) '  value is real4'
          call PIO_read_darray(handle % pio_file, field_cursor % fieldhandle % field_desc, field_cursor % fieldhandle % decomp % pio_iodesc, &amp;
                               realArray4d, pio_ierr)
+      else if (present(realArray5d)) then
+!         write (0,*) '  value is real5'
+         call PIO_read_darray(handle % pio_file, field_cursor % fieldhandle % field_desc, field_cursor % fieldhandle % decomp % pio_iodesc, &amp;
+                              realArray5d, pio_ierr)
       else if (present(intArray1d)) then
 !         write (0,*) '  value is int1'
          call PIO_read_darray(handle % pio_file, field_cursor % fieldhandle % field_desc, field_cursor % fieldhandle % decomp % pio_iodesc, &amp;
@@ -1492,6 +1502,26 @@
    end subroutine MPAS_io_get_var_real4d
 
 
+   subroutine MPAS_io_get_var_real5d(handle, fieldname, array, ierr)
+
+      implicit none
+
+      type (MPAS_IO_Handle_type), intent(inout) :: handle
+      character (len=*), intent(in) :: fieldname
+      real (kind=RKIND), dimension(:,:,:,:,:), intent(out) :: array
+      integer, intent(out), optional :: ierr
+
+      integer :: pio_ierr
+      type (fieldlist_type), pointer :: field_cursor
+
+!      write(0,*) 'Called MPAS_io_get_var_real5d()'
+      if (present(ierr)) ierr = MPAS_IO_NOERR
+
+      call MPAS_io_get_var_generic(handle, fieldname, realArray5d=array, ierr=ierr)
+
+   end subroutine MPAS_io_get_var_real5d
+
+
    subroutine MPAS_io_get_var_char0d(handle, fieldname, val, ierr)
 
       implicit none
@@ -1513,7 +1543,7 @@
 
 
    subroutine MPAS_io_put_var_generic(handle, fieldname, intVal, intArray1d, intArray2d, intArray3d, intArray4d, &amp;
-                                                        realVal, realArray1d, realArray2d, realArray3d, realArray4d, &amp;
+                                                        realVal, realArray1d, realArray2d, realArray3d, realArray4d, realArray5d, &amp;
                                                         charVal, ierr)
 
       implicit none
@@ -1530,6 +1560,7 @@
       real (kind=RKIND), dimension(:,:), intent(in), optional :: realArray2d
       real (kind=RKIND), dimension(:,:,:), intent(in), optional :: realArray3d
       real (kind=RKIND), dimension(:,:,:,:), intent(in), optional :: realArray4d
+      real (kind=RKIND), dimension(:,:,:,:,:), intent(in), optional :: realArray5d
       character (len=*), intent(in), optional :: charVal
       integer, intent(out), optional :: ierr
 
@@ -1615,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;
@@ -1629,6 +1662,9 @@
       else if (present(realArray4d)) then
          call PIO_write_darray(handle % pio_file, field_cursor % fieldhandle % field_desc, field_cursor % fieldhandle % decomp % pio_iodesc, &amp;
                                realArray4d, pio_ierr)
+      else if (present(realArray5d)) then
+         call PIO_write_darray(handle % pio_file, field_cursor % fieldhandle % field_desc, field_cursor % fieldhandle % decomp % pio_iodesc, &amp;
+                               realArray5d, pio_ierr)
       else if (present(intArray1d)) then
          call PIO_write_darray(handle % pio_file, field_cursor % fieldhandle % field_desc, field_cursor % fieldhandle % decomp % pio_iodesc, &amp;
                                intArray1d, pio_ierr)
@@ -1852,6 +1888,26 @@
    end subroutine MPAS_io_put_var_real4d
 
 
+   subroutine MPAS_io_put_var_real5d(handle, fieldname, array, ierr)
+
+      implicit none
+
+      type (MPAS_IO_Handle_type), intent(inout) :: handle
+      character (len=*), intent(in) :: fieldname
+      real (kind=RKIND), dimension(:,:,:,:,:), intent(in) :: array
+      integer, intent(out), optional :: ierr
+
+      integer :: pio_ierr
+      type (fieldlist_type), pointer :: field_cursor
+
+!      write(0,*) 'Called MPAS_io_put_var_real5d()'
+      if (present(ierr)) ierr = MPAS_IO_NOERR
+
+      call MPAS_io_put_var_generic(handle, fieldname, realArray5d=array, ierr=ierr)
+
+   end subroutine MPAS_io_put_var_real5d
+
+
    subroutine MPAS_io_put_var_char0d(handle, fieldname, val, ierr)
 
       implicit none

Modified: branches/ocean_projects/openmp_elements/src/framework/mpas_io_streams.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/framework/mpas_io_streams.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/framework/mpas_io_streams.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -19,6 +19,8 @@
       type (field1dReal), pointer :: real1dField =&gt; null()
       type (field2dReal), pointer :: real2dField =&gt; null()
       type (field3dReal), pointer :: real3dField =&gt; null()
+      type (field4dReal), pointer :: real4dField =&gt; null()
+      type (field5dReal), pointer :: real5dField =&gt; null()
       type (field0dChar), pointer :: char0dField =&gt; null()
       type (field1dChar), pointer :: char1dField =&gt; null()
       type (field_list_type), pointer :: next =&gt; null()
@@ -44,6 +46,8 @@
       module procedure MPAS_streamAddField_1dReal
       module procedure MPAS_streamAddField_2dReal
       module procedure MPAS_streamAddField_3dReal
+      module procedure MPAS_streamAddField_4dReal
+      module procedure MPAS_streamAddField_5dReal
       module procedure MPAS_streamAddField_0dChar
    end interface MPAS_streamAddField
 
@@ -82,8 +86,10 @@
                          FIELD_1D_REAL  =  6, &amp;
                          FIELD_2D_REAL  =  7, &amp;
                          FIELD_3D_REAL  =  8, &amp;
-                         FIELD_0D_CHAR  =  9, &amp;
-                         FIELD_1D_CHAR  =  10
+                         FIELD_4D_REAL  =  9, &amp;
+                         FIELD_5D_REAL  =  10, &amp;
+                         FIELD_0D_CHAR  =  11, &amp;
+                         FIELD_1D_CHAR  =  12
 
    private mergeArrays
 
@@ -996,6 +1002,208 @@
    end subroutine MPAS_streamAddField_3dReal
 
 
+   subroutine MPAS_streamAddField_4dReal(stream, field, ierr)
+
+      implicit none
+
+      type (MPAS_Stream_type), intent(inout) :: stream
+      type (field4DReal), intent(in), target :: field
+      integer, intent(out), optional :: ierr
+
+      integer :: io_err
+      integer :: i
+      integer :: idim
+      integer :: totalDimSize, globalDimSize
+      logical :: isDecomposed
+      integer :: ndims
+      type (field4dReal), pointer :: field_ptr
+      character (len=StrKIND), dimension(5) :: dimNames
+      character (len=StrKIND), dimension(:), pointer :: dimNamesInq
+      integer, dimension(:), pointer :: indices
+      type (field_list_type), pointer :: field_list_cursor
+      type (field_list_type), pointer :: new_field_list_node
+      logical :: any_success
+      logical, dimension(:), pointer :: isAvailable
+
+      if (present(ierr)) ierr = MPAS_STREAM_NOERR
+
+      !
+      ! Sanity checks
+      !
+      if (.not. stream % isInitialized) then
+         if (present(ierr)) ierr = MPAS_STREAM_NOT_INITIALIZED
+         return
+      end if
+
+!write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
+
+      ndims = size(field % dimSizes)
+
+!write(0,*) '... field has ', ndims, ' dimensions'
+
+      ! 
+      ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
+      !    and the total number of outer-indices owned by this task
+      ! 
+#include &quot;add_field_indices.inc&quot;
+
+      
+      any_success = .false.
+      if (field % isSuperArray) then
+!write(0,*) '^^^^^^^^^^^^^^^^^^^^^^^^^^^ we are adding a super-array'
+         allocate(isAvailable(size(field % constituentNames)))
+         isAvailable(:) = .false.
+         do i=1,size(field % constituentNames)
+            call MPAS_streamAddField_generic(stream, trim(field % constituentNames(i)), MPAS_IO_DOUBLE, field % dimNames(2:ndims), &amp;
+                                             field % dimSizes(2:ndims), field % hasTimeDimension, isDecomposed, totalDimSize, globalDimSize, &amp;
+                                             indices, io_err)
+            if (io_err == MPAS_STREAM_NOERR) then
+               isAvailable(i) = .true.
+               any_success = .true.
+            end if
+         end do
+      else
+         nullify(isAvailable)
+         call MPAS_streamAddField_generic(stream, trim(field % fieldName), MPAS_IO_DOUBLE, field % dimNames, field % dimSizes, &amp;
+                                          field % hasTimeDimension, isDecomposed, totalDimSize, globalDimSize, indices, io_err)
+         if (io_err == MPAS_STREAM_NOERR) then
+            any_success = .true.
+         end if
+      end if
+
+      deallocate(indices)
+      if (.not. any_success) then
+          if (present(ierr)) ierr = MPAS_IO_ERR
+          return
+      end if
+
+      if (field % isSuperArray) then
+         do i=1,size(field % constituentNames)
+            call put_get_field_atts(stream % fileHandle, stream % ioDirection, trim(field % constituentNames(i)), field % attList)
+         end do
+      else
+         call put_get_field_atts(stream % fileHandle, stream % ioDirection, trim(field % fieldname), field % attList)
+      end if
+
+
+      !
+      ! Set field pointer and type in fieldList
+      !
+      new_field_list_node =&gt; stream % fieldList
+      do while (associated(new_field_list_node % next))
+         new_field_list_node =&gt; new_field_list_node % next
+      end do
+      new_field_list_node % field_type = FIELD_4D_REAL
+      new_field_list_node % real4dField =&gt; field
+      new_field_list_node % isAvailable =&gt; isAvailable
+
+!write(0,*) '... done adding field'
+!write(0,*) 'DEBUGGING : Finished adding 4d real field '//trim(field % fieldName)
+
+   end subroutine MPAS_streamAddField_4dReal
+
+
+   subroutine MPAS_streamAddField_5dReal(stream, field, ierr)
+
+      implicit none
+
+      type (MPAS_Stream_type), intent(inout) :: stream
+      type (field5DReal), intent(in), target :: field
+      integer, intent(out), optional :: ierr
+
+      integer :: io_err
+      integer :: i
+      integer :: idim
+      integer :: totalDimSize, globalDimSize
+      logical :: isDecomposed
+      integer :: ndims
+      type (field5dReal), pointer :: field_ptr
+      character (len=StrKIND), dimension(5) :: dimNames
+      character (len=StrKIND), dimension(:), pointer :: dimNamesInq
+      integer, dimension(:), pointer :: indices
+      type (field_list_type), pointer :: field_list_cursor
+      type (field_list_type), pointer :: new_field_list_node
+      logical :: any_success
+      logical, dimension(:), pointer :: isAvailable
+
+      if (present(ierr)) ierr = MPAS_STREAM_NOERR
+
+      !
+      ! Sanity checks
+      !
+      if (.not. stream % isInitialized) then
+         if (present(ierr)) ierr = MPAS_STREAM_NOT_INITIALIZED
+         return
+      end if
+
+!write(0,*) '... Adding field '//trim(field % fieldName)//' to stream'
+
+      ndims = size(field % dimSizes)
+
+!write(0,*) '... field has ', ndims, ' dimensions'
+
+      ! 
+      ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
+      !    and the total number of outer-indices owned by this task
+      ! 
+#include &quot;add_field_indices.inc&quot;
+
+      
+      any_success = .false.
+      if (field % isSuperArray) then
+!write(0,*) '^^^^^^^^^^^^^^^^^^^^^^^^^^^ we are adding a super-array'
+         allocate(isAvailable(size(field % constituentNames)))
+         isAvailable(:) = .false.
+         do i=1,size(field % constituentNames)
+            call MPAS_streamAddField_generic(stream, trim(field % constituentNames(i)), MPAS_IO_DOUBLE, field % dimNames(2:ndims), &amp;
+                                             field % dimSizes(2:ndims), field % hasTimeDimension, isDecomposed, totalDimSize, globalDimSize, &amp;
+                                             indices, io_err)
+            if (io_err == MPAS_STREAM_NOERR) then
+               isAvailable(i) = .true.
+               any_success = .true.
+            end if
+         end do
+      else
+         nullify(isAvailable)
+         call MPAS_streamAddField_generic(stream, trim(field % fieldName), MPAS_IO_DOUBLE, field % dimNames, field % dimSizes, &amp;
+                                          field % hasTimeDimension, isDecomposed, totalDimSize, globalDimSize, indices, io_err)
+         if (io_err == MPAS_STREAM_NOERR) then
+            any_success = .true.
+         end if
+      end if
+
+      deallocate(indices)
+      if (.not. any_success) then
+          if (present(ierr)) ierr = MPAS_IO_ERR
+          return
+      end if
+
+      if (field % isSuperArray) then
+         do i=1,size(field % constituentNames)
+            call put_get_field_atts(stream % fileHandle, stream % ioDirection, trim(field % constituentNames(i)), field % attList)
+         end do
+      else
+         call put_get_field_atts(stream % fileHandle, stream % ioDirection, trim(field % fieldname), field % attList)
+      end if
+
+
+      !
+      ! Set field pointer and type in fieldList
+      !
+      new_field_list_node =&gt; stream % fieldList
+      do while (associated(new_field_list_node % next))
+         new_field_list_node =&gt; new_field_list_node % next
+      end do
+      new_field_list_node % field_type = FIELD_5D_REAL
+      new_field_list_node % real5dField =&gt; field
+      new_field_list_node % isAvailable =&gt; isAvailable
+
+!write(0,*) '... done adding field'
+!write(0,*) 'DEBUGGING : Finished adding 3d real field '//trim(field % fieldName)
+
+   end subroutine MPAS_streamAddField_5dReal
+
+
    subroutine MPAS_streamAddField_0dChar(stream, field, ierr)
 
       implicit none
@@ -1313,6 +1521,8 @@
       type (field1dReal), pointer :: field_1dreal_ptr
       type (field2dReal), pointer :: field_2dreal_ptr
       type (field3dReal), pointer :: field_3dreal_ptr
+      type (field4dReal), pointer :: field_4dreal_ptr
+      type (field5dReal), pointer :: field_5dreal_ptr
       type (field0dChar), pointer :: field_0dchar_ptr
       type (field1dChar), pointer :: field_1dchar_ptr
       type (field_list_type), pointer :: field_cursor
@@ -1324,6 +1534,8 @@
       real (kind=RKIND), dimension(:),     pointer :: real1d_temp
       real (kind=RKIND), dimension(:,:),   pointer :: real2d_temp
       real (kind=RKIND), dimension(:,:,:), pointer :: real3d_temp
+      real (kind=RKIND), dimension(:,:,:,:), pointer :: real4d_temp
+      real (kind=RKIND), dimension(:,:,:,:,:), pointer :: real5d_temp
 
       if (present(ierr)) ierr = MPAS_STREAM_NOERR
 
@@ -1876,7 +2088,185 @@
             else
                deallocate(real3d_temp)
             end if
+         else if (field_cursor % field_type == FIELD_4D_REAL) then
 
+!write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % real3dField % fieldName)
+!write(0,*) 'DEBUGGING : reading a 4d real array'
+            if (field_cursor % real4dField % isSuperArray) then
+!write(0,*) 'DEBUGGING : reading a 4d real super-array'
+               ncons = size(field_cursor % real4dField % constituentNames)
+               allocate(real3d_temp(field_cursor % real4dField % dimSizes(2), &amp;
+                                    field_cursor % real4dField % dimSizes(3), &amp;
+                                    field_cursor % totalDimSize))
+            else
+               ncons = 1
+               allocate(real4d_temp(field_cursor % real4dField % dimSizes(1), &amp;
+                                    field_cursor % real4dField % dimSizes(2), &amp;
+                                    field_cursor % real4dField % dimSizes(3), &amp;
+                                    field_cursor % totalDimSize))
+            end if
+
+            do j=1,ncons
+               if (field_cursor % real4dField % isSuperArray) then
+                  if (.not. field_cursor % isAvailable(j)) cycle
+!write(0,*) 'DEBUGGING : calling get_var for a constitutent'
+                  call MPAS_io_get_var(stream % fileHandle, field_cursor % real4dField % constituentNames(j), real3d_temp, io_err)
+               else
+                  call MPAS_io_get_var(stream % fileHandle, field_cursor % real4dField % fieldName, real4d_temp, io_err)
+               end if
+               call MPAS_io_err_mesg(io_err, .false.)
+               if (io_err /= MPAS_IO_NOERR) then
+                   if (present(ierr)) ierr = MPAS_IO_ERR
+                   if (field_cursor % real4dField % isSuperArray) then
+                      deallocate(real3d_temp)
+                   else
+                      deallocate(real4d_temp)
+                   end if
+                   return
+               end if
+   
+               if (field_cursor % isDecomposed) then
+                  ! Distribute field to multiple blocks
+                  field_4dreal_ptr =&gt; field_cursor % real4dField
+                  i = 1
+                  do while (associated(field_4dreal_ptr))
+                     if (trim(field_4dreal_ptr % dimNames(4)) == 'nCells') then
+                        ownedSize = field_4dreal_ptr % block % mesh % nCellsSolve
+                     else if (trim(field_4dreal_ptr % dimNames(4)) == 'nEdges') then
+                        ownedSize = field_4dreal_ptr % block % mesh % nEdgesSolve
+                     else if (trim(field_4dreal_ptr % dimNames(4)) == 'nVertices') then
+                        ownedSize = field_4dreal_ptr % block % mesh % nVerticesSolve
+                     else
+                        ownedSize = field_4dreal_ptr % dimSizes(4)
+                     end if
+
+                     if (field_cursor % real4dField % isSuperArray) then
+!write(0,*) 'DEBUGGING : copying the temporary array'
+                        field_4dreal_ptr % array(j, :,:,1:ownedSize) = real3d_temp(:,:,i:i+ownedSize-1)
+                     else
+                        field_4dreal_ptr % array(:,:,:,1:ownedSize) = real4d_temp(:,:,:,i:i+ownedSize-1)
+                     end if
+                     i = i + ownedSize
+                     field_4dreal_ptr =&gt; field_4dreal_ptr % next
+                  end do
+
+               else
+   
+                  if (field_cursor % real3dField % isSuperArray) then
+                     call mpas_dmpar_bcast_reals(field_cursor % real4dField % block % domain % dminfo, size(real3d_temp), real3d_temp(:,1,1))
+                     field_4dreal_ptr =&gt; field_cursor % real4dField
+                     do while (associated(field_4dreal_ptr))
+                        field_4dreal_ptr % array(j,:,:,:) = real3d_temp(:,:,:)
+                        field_4dreal_ptr =&gt; field_4dreal_ptr % next
+                     end do
+                  else
+                     call mpas_dmpar_bcast_reals(field_cursor % real4dField % block % domain % dminfo, size(real4d_temp), real4d_temp(:,1,1,1))
+                     field_4dreal_ptr =&gt; field_cursor % real4dField
+                     do while (associated(field_4dreal_ptr))
+                        field_4dreal_ptr % array(:,:,:,:) = real4d_temp(:,:,:,:)
+                        field_4dreal_ptr =&gt; field_4dreal_ptr % next
+                     end do
+                  end if
+               end if
+            end do
+
+            if (field_cursor % real4dField % isSuperArray) then
+               deallocate(real3d_temp)
+            else
+               deallocate(real4d_temp)
+            end if
+
+         else if (field_cursor % field_type == FIELD_5D_REAL) then
+
+!write(0,*) 'DEBUGGING : *************** '//trim(field_cursor % real3dField % fieldName)
+!write(0,*) 'DEBUGGING : reading a 4d real array'
+            if (field_cursor % real5dField % isSuperArray) then
+!write(0,*) 'DEBUGGING : reading a 4d real super-array'
+               ncons = size(field_cursor % real5dField % constituentNames)
+               allocate(real4d_temp(field_cursor % real5dField % dimSizes(2), &amp;
+                                    field_cursor % real5dField % dimSizes(3), &amp;
+                                    field_cursor % real5dField % dimSizes(4), &amp;
+                                    field_cursor % totalDimSize))
+            else
+               ncons = 1
+               allocate(real5d_temp(field_cursor % real5dField % dimSizes(1), &amp;
+                                    field_cursor % real5dField % dimSizes(2), &amp;
+                                    field_cursor % real5dField % dimSizes(3), &amp;
+                                    field_cursor % real5dField % dimSizes(4), &amp;
+                                    field_cursor % totalDimSize))
+            end if
+
+            do j=1,ncons
+               if (field_cursor % real5dField % isSuperArray) then
+                  if (.not. field_cursor % isAvailable(j)) cycle
+!write(0,*) 'DEBUGGING : calling get_var for a constitutent'
+                  call MPAS_io_get_var(stream % fileHandle, field_cursor % real5dField % constituentNames(j), real4d_temp, io_err)
+               else
+                  call MPAS_io_get_var(stream % fileHandle, field_cursor % real5dField % fieldName, real5d_temp, io_err)
+               end if
+               call MPAS_io_err_mesg(io_err, .false.)
+               if (io_err /= MPAS_IO_NOERR) then
+                   if (present(ierr)) ierr = MPAS_IO_ERR
+                   if (field_cursor % real5dField % isSuperArray) then
+                      deallocate(real4d_temp)
+                   else
+                      deallocate(real5d_temp)
+                   end if
+                   return
+               end if
+   
+               if (field_cursor % isDecomposed) then
+                  ! Distribute field to multiple blocks
+                  field_5dreal_ptr =&gt; field_cursor % real5dField
+                  i = 1
+                  do while (associated(field_5dreal_ptr))
+                     if (trim(field_5dreal_ptr % dimNames(5)) == 'nCells') then
+                        ownedSize = field_5dreal_ptr % block % mesh % nCellsSolve
+                     else if (trim(field_5dreal_ptr % dimNames(5)) == 'nEdges') then
+                        ownedSize = field_5dreal_ptr % block % mesh % nEdgesSolve
+                     else if (trim(field_5dreal_ptr % dimNames(5)) == 'nVertices') then
+                        ownedSize = field_5dreal_ptr % block % mesh % nVerticesSolve
+                     else
+                        ownedSize = field_5dreal_ptr % dimSizes(5)
+                     end if
+
+                     if (field_cursor % real5dField % isSuperArray) then
+!write(0,*) 'DEBUGGING : copying the temporary array'
+                        field_5dreal_ptr % array(j,:,:,:,1:ownedSize) = real4d_temp(:,:,:,i:i+ownedSize-1)
+                     else
+                        field_5dreal_ptr % array(:,:,:,:,1:ownedSize) = real5d_temp(:,:,:,:,i:i+ownedSize-1)
+                     end if
+                     i = i + ownedSize
+                     field_5dreal_ptr =&gt; field_5dreal_ptr % next
+                  end do
+
+               else
+   
+                  if (field_cursor % real5dField % isSuperArray) then
+                     call mpas_dmpar_bcast_reals(field_cursor % real5dField % block % domain % dminfo, size(real4d_temp), real4d_temp(:,1,1,1))
+                     field_5dreal_ptr =&gt; field_cursor % real5dField
+                     do while (associated(field_5dreal_ptr))
+                        field_5dreal_ptr % array(j,:,:,:,:) = real4d_temp(:,:,:,:)
+                        field_5dreal_ptr =&gt; field_5dreal_ptr % next
+                     end do
+                  else
+                     call mpas_dmpar_bcast_reals(field_cursor % real5dField % block % domain % dminfo, size(real5d_temp), real5d_temp(:,1,1,1,1))
+                     field_5dreal_ptr =&gt; field_cursor % real5dField
+                     do while (associated(field_5dreal_ptr))
+                        field_5dreal_ptr % array(:,:,:,:,:) = real5d_temp(:,:,:,:,:)
+                        field_5dreal_ptr =&gt; field_5dreal_ptr % next
+                     end do
+                  end if
+               end if
+            end do
+
+            if (field_cursor % real5dField % isSuperArray) then
+               deallocate(real4d_temp)
+            else
+               deallocate(real5d_temp)
+            end if
+
+
          else if (field_cursor % field_type == FIELD_0D_CHAR) then
 
 !write(0,*) 'Reading in field '//trim(field_cursor % char0dField % fieldName)

Modified: branches/ocean_projects/openmp_elements/src/framework/mpas_kind_types.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/framework/mpas_kind_types.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/framework/mpas_kind_types.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/framework/mpas_sort.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/framework/mpas_sort.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/framework/mpas_sort.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/framework/mpas_timer.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/framework/mpas_timer.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/framework/mpas_timer.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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
@@ -269,7 +323,7 @@
               timer_ptr%avg_time = 0.0d0
               percent = 0.0d0
             else
-              timer_ptr%avg_time = timer_ptr%avg_time/timer_ptr%calls
+              timer_ptr%avg_time = timer_ptr%total_time/timer_ptr%calls
               percent = timer_ptr%total_time/total_ptr%total_time
             endif
 
@@ -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
 

Modified: branches/ocean_projects/openmp_elements/src/operators/mpas_rbf_interpolation.F
===================================================================
--- branches/ocean_projects/openmp_elements/src/operators/mpas_rbf_interpolation.F        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/operators/mpas_rbf_interpolation.F        2013-03-29 14:40:23 UTC (rev 2678)
@@ -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/ocean_projects/openmp_elements/src/registry/Makefile
===================================================================
--- branches/ocean_projects/openmp_elements/src/registry/Makefile        2013-03-28 19:10:52 UTC (rev 2677)
+++ branches/ocean_projects/openmp_elements/src/registry/Makefile        2013-03-29 14:40:23 UTC (rev 2678)
@@ -1,9 +1,12 @@
 .SUFFIXES: .c .o
 
-OBJS = parse.o dictionary.o gen_inc.o fortprintf.o
+OBJS = parse.o dictionary.o gen_inc.o fortprintf.o ezxml/ezxml.o
 
 all: parse
 
+ezxml/ezxml.o:
+        (cd ezxml; $(CC) -c ezxml.c)
+
 parse: $(OBJS)
         $(CC) -o $@ $(OBJS)
 

Copied: branches/ocean_projects/openmp_elements/src/registry/Registry.xsd (from rev 2677, trunk/mpas/src/registry/Registry.xsd)
===================================================================
--- branches/ocean_projects/openmp_elements/src/registry/Registry.xsd                                (rev 0)
+++ branches/ocean_projects/openmp_elements/src/registry/Registry.xsd        2013-03-29 14:40:23 UTC (rev 2678)
@@ -0,0 +1,121 @@
+&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;!-- The persistence attribute determines if the var is persistent or scratch. Valid options are persistent, and scratch. Default is persistent. --&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;/xs:sequence&gt;
+                                                &lt;!-- The name attribute defines the name of the var_struct. This would be similar to mesh, or state. --&gt;
+                                                &lt;xs:attribute name=&quot;name&quot;  type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                                                &lt;!-- The time_levs attribute defines the number of time levels this var_struct contains. --&gt;
+                                                &lt;xs:attribute name=&quot;time_levs&quot;  type=&quot;xs:int&quot; use=&quot;required&quot;/&gt;
+                                        &lt;/xs:complexType&gt;
+                                &lt;/xs:element&gt;
+                        &lt;/xs:sequence&gt;
+                &lt;/xs:complexType&gt;
+        &lt;/xs:element&gt;
+&lt;/xs:schema&gt;

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

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

</font>
</pre>