diff -Nru WRFV3.5/chem/chem_driver.F WRFV3.5_MR/chem/chem_driver.F
--- WRFV3.5/chem/chem_driver.F	2013-03-22 20:32:12.000000000 +0100
+++ WRFV3.5_MR/chem/chem_driver.F	2014-12-17 11:53:55.938794000 +0100
@@ -972,7 +972,14 @@
 
               ids,ide, jds,jde, kds,kde,                                                   &
               ims,ime, jms,jme, kms,kme,                                                   &
-              its,ite,jts,jte,kts,kte)
+!cmr              its,ite,jts,jte,kts,kte)
+              its,ite,jts,jte,kts,kte,                                                     &
+              fco2=grid%fco2,fco2mn=grid%fco2mn,fco2mx=grid%fco2mx,                        &
+              fco2nf=grid%fco2nf,co2_clm=grid%co2_clm,                                     &
+              co2_clm2=grid%co2_clm2,co2_clm3=grid%co2_clm3     )
+!cmr end
+
+
               if( config_flags%chem_opt == MOZART_KPP .or. &
                   config_flags%chem_opt == MOZCART_KPP .or. &
                   config_flags%chem_opt == MOZART_MOSAIC_4BIN_VBS0_KPP ) then
diff -Nru WRFV3.5/chem/chemics_init.F WRFV3.5_MR/chem/chemics_init.F
--- WRFV3.5/chem/chemics_init.F	2013-03-15 21:25:43.000000000 +0100
+++ WRFV3.5_MR/chem/chemics_init.F	2014-12-17 11:53:55.997748000 +0100
@@ -306,20 +306,21 @@
 !   ENDIF
 
     CALL nl_get_mminlu( 1, mminlu_loc )
-
-    IF (trim(mminlu_loc) /= 'USGS' .and. trim(mminlu_loc) /= 'MODIFIED_IGBP_MODIS_NOAH' ) THEN
-      print*,mminlu_loc
-      message_txt = " ERROR: CHEM_INIT: Chemistry routines require USGS or MODIS_NOAH land use maps. Need to change land use option."
-      call wrf_error_fatal( trim(message_txt) )
-    ELSE
-      IF (trim(mminlu_loc) == 'USGS' .and. grid%num_land_cat /= 24 ) THEN
-        message_txt = " ERROR: CHEM_INIT: USGS land use map should have 24 catagories."
-        call wrf_error_fatal( trim(message_txt) )
-      ELSEIF (trim(mminlu_loc) == 'MODIFIED_IGBP_MODIS_NOAH' .and. grid%num_land_cat /= 20 ) THEN
-        message_txt = " ERROR: CHEM_INIT: MODIS_NOAH land use map should have 20 catagories."
-        call wrf_error_fatal( trim(message_txt) )
-      ENDIF
-    ENDIF
+!cmr begin
+!    IF (trim(mminlu_loc) /= 'USGS' .and. trim(mminlu_loc) /= 'MODIFIED_IGBP_MODIS_NOAH' ) THEN
+!      print*,mminlu_loc
+!      message_txt = " ERROR: CHEM_INIT: Chemistry routines require USGS or MODIS_NOAH land use maps. Need to change land use option."
+!      call wrf_error_fatal( trim(message_txt) )
+!    ELSE
+!      IF (trim(mminlu_loc) == 'USGS' .and. grid%num_land_cat /= 24 ) THEN
+!        message_txt = " ERROR: CHEM_INIT: USGS land use map should have 24 catagories."
+!        call wrf_error_fatal( trim(message_txt) )
+!      ELSEIF (trim(mminlu_loc) == 'MODIFIED_IGBP_MODIS_NOAH' .and. grid%num_land_cat /= 20 ) THEN
+!        message_txt = " ERROR: CHEM_INIT: MODIS_NOAH land use map should have 20 catagories."
+!        call wrf_error_fatal( trim(message_txt) )
+!      ENDIF
+!    ENDIF
+     print*,'!cmr: skipping fatal error for debugging: "ERROR: CHEM_INIT: Chemistry routines require USGS or MODIS_NOAH land use maps. Need to change land use option."'
 !--
 
     if( .NOT. config_flags%restart ) then
@@ -416,6 +417,19 @@
      call VPRM_par_initialize ( grid%rad_vprm, grid%lambda_vprm, grid%alpha_vprm, grid%resp_vprm, config_flags )
      call wrf_message("Warning: the VPRM parameters may need to be optimized depending on the season, year and region!")
      call wrf_message("The parameters provided here should be used for testing purposes only!")
+!cmr - initialize CO2 tracers:
+       do j=jts,jte
+        do k=kts,kte
+         do i=its,ite
+            chem(i,k,j,p_co2_bck)=config_flags%valley_CO2backgr  ! background CO2 tracer
+            chem(i,k,j,p_co2_bio)=config_flags%valley_CO2backgr  ! A user should subtract this from the output fields!
+            chem(i,k,j,p_co2_oce)=config_flags%valley_CO2backgr   ! A user should subtract this from the output fields!
+            chem(i,k,j,p_co2_ant)=config_flags%valley_CO2backgr   ! A user should subtract this from the output fields!
+            chem(i,k,j,p_co2_tst)=config_flags%valley_CO2backgr   ! A user should subtract this from the output fields!
+         enddo
+        enddo
+       enddo
+!cmr end
 end if
 ! Read parameters for the termite model and put them into wrfinput file
 if (config_flags%chem_opt .EQ. GHG_TRACER) then
diff -Nru WRFV3.5/chem/emissions_driver.F WRFV3.5_MR/chem/emissions_driver.F
--- WRFV3.5/chem/emissions_driver.F	2013-03-22 20:32:12.000000000 +0100
+++ WRFV3.5_MR/chem/emissions_driver.F	2014-12-17 11:53:55.959404000 +0100
@@ -66,7 +66,11 @@
 
          ids,ide, jds,jde, kds,kde,                                        &
          ims,ime, jms,jme, kms,kme,                                        &
-         its,ite, jts,jte, kts,kte                                         )
+!cmr begin        its,ite, jts,jte, kts,kte                                         )
+         its,ite, jts,jte, kts,kte,                                        &
+         fco2,fco2mn,fco2mx,fco2nf,co2_clm,co2_clm2,co2_clm3              )
+!cmr end
+
 !----------------------------------------------------------------------
   USE module_configure
   USE module_state_description
@@ -289,6 +293,10 @@
      REAL, DIMENSION( ims:ime, kms:kme, jms:jme ),           INTENT(IN   ) :: refl_10cm
 ! end stuff for lightning NOx
 !
+!cmr define CO2 flux variable
+      real, dimension(ims:ime,jms:jme),intent(inout) :: fco2,fco2mn,fco2mx,fco2nf 
+      real, dimension(ims:ime,kms:kme,jms:jme),intent(inout) :: co2_clm,co2_clm2,co2_clm3 
+!cmr end
 ! Local variables...
 !
       INTEGER :: begday,endday,i, j, k, ksub, dust_emiss_active, seasalt_emiss_active,emiss_ash_hgt
@@ -987,7 +995,10 @@
                             its,ite, jts,jte, kts,kte,          &
 
                             dtstep,dz8w,config_flags,rho_phy,   &
-                            chem,emis_ant,eghg_bio,ebio_co2oce  )
+!cmr begin                  chem,emis_ant,eghg_bio,ebio_co2oce  )
+                            chem,emis_ant,eghg_bio,ebio_co2oce, &
+                            fco2,fco2mn,fco2mx,fco2nf,co2_clm,co2_clm2,co2_clm3,swdown)
+!cmr end
    END IF
 !**************************************************************************************************
     CASE (SAPRC99_KPP) !FIX FOR SAPRC07A
diff -Nru WRFV3.5/chem/module_ghg_fluxes.F WRFV3.5_MR/chem/module_ghg_fluxes.F
--- WRFV3.5/chem/module_ghg_fluxes.F	2012-07-27 21:07:12.000000000 +0200
+++ WRFV3.5_MR/chem/module_ghg_fluxes.F	2014-12-17 11:53:55.974718000 +0100
@@ -44,7 +44,9 @@
                              its,ite, jts,jte, kts,kte,             &     ! Tile dimensions
                                                                     
                              dtstep, dz8w, config_flags, rho_phy,   &
-                             chem, emis_ant,eghg_bio,ebio_co2oce    )
+!cmr                             chem, emis_ant,eghg_bio,ebio_co2oce    )
+                             chem, emis_ant,eghg_bio,ebio_co2oce,   &
+                             fco2,fco2mn,fco2mx,fco2nf,co2_clm,co2_clm2,co2_clm3,swrad )
 
 ! March-28, this subroutine adds all type of greenhouse gases to the chem species
 
@@ -63,6 +65,13 @@
 REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT(IN ) ::   rho_phy, dz8w
 REAL, DIMENSION( ims:ime, kms:config_flags%kemit, jms:jme, num_emis_ant ), INTENT(IN ) :: emis_ant
 REAL, DIMENSION( ims:ime, 1,jms:jme, num_eghg_bio ), INTENT(IN ) :: eghg_bio
+!cmr define CO2 net flux variable
+real, dimension(ims:ime,jms:jme),intent(IN) :: fco2,fco2mn,fco2mx,fco2nf
+REAL, DIMENSION( ims:ime, kms:kme, jms:jme), INTENT(INOUT ) :: co2_clm,co2_clm2,co2_clm3
+REAL, DIMENSION (ims:ime, jms:jme), INTENT(IN)    :: swrad
+REAL    :: valley_CO2antr
+!cmr
+
 
 INTEGER :: i,j,k
 REAL    :: conv_rho
@@ -73,22 +82,36 @@
 DO j=jts,jte
    DO i=its,ite
       !  3D anthropogenic fluxes
-      DO k=kts,min(config_flags%kemit,kte)
-         conv_rho=8.0461e-6/rho_phy(i,k,j)*dtstep/dz8w(i,k,j)  ! 8.0461e-6=molar_mass(air)/3600, [g/mol/s]
-         chem(i,k,j,p_co2_ant)= chem(i,k,j,p_co2_ant) + conv_rho* emis_ant(i,k,j,p_e_co2)
-         chem(i,k,j,p_co2_tst)= chem(i,k,j,p_co2_tst) + conv_rho* emis_ant(i,k,j,p_e_co2tst)
-         chem(i,k,j,p_co_ant) = chem(i,k,j,p_co_ant)  + conv_rho* emis_ant(i,k,j,p_e_co)
+!cmr      DO k=kts,min(config_flags%kemit,kte)
+         k = 1
+!          conv_rho=8.0461e-6/rho_phy(i,k,j)*dtstep/dz8w(i,k,j)  ! 8.0461e-6=molar_mass(air)/3600, [g/mol/s]
+         conv_rho=44.e-3/rho_phy(i,k,j)*dtstep/dz8w(i,k,j) ! conversion from [mmol/m^2/s]to ppmv
+!         chem(i,k,j,p_co2_ant)= chem(i,k,j,p_co2_ant) + conv_rho* emis_ant(i,k,j,p_e_co2)
+!         chem(i,k,j,p_co2_tst)= chem(i,k,j,p_co2_tst) + conv_rho* emis_ant(i,k,j,p_e_co2tst)
+!         chem(i,k,j,p_co_ant) = chem(i,k,j,p_co_ant)  + conv_rho* emis_ant(i,k,j,p_e_co)
 
       ! 2D biospheric fluxes:
-      if (k==1) then
-         chem(i,1,j,p_co2_bio)= chem(i,1,j,p_co2_bio) + conv_rho* (eghg_bio(i,1,j,p_ebio_gee) + eghg_bio(i,1,j,p_ebio_res))   ! both uptake and release
-         chem(i,1,j,p_co2_oce)= chem(i,1,j,p_co2_oce) + conv_rho* ebio_co2oce(i,j)
-      end if
-
-      ENDDO
+!cmr  add net CO2 flux here  
+         chem(i,1,j,p_co2_bio) = chem(i,1,j,p_co2_bio) + conv_rho*fco2(i,j)
+         chem(i,1,j,p_co2_ant) = chem(i,1,j,p_co2_ant) + conv_rho*fco2mn(i,j)
+         chem(i,1,j,p_co2_oce) = chem(i,1,j,p_co2_oce) + conv_rho*fco2mx(i,j)
+         chem(i,1,j,p_co2_bck) = chem(i,1,j,p_co2_bck) + conv_rho*fco2nf(i,j)
+!cmr  adding anthropogenic CO2 flux in valley centre here  
+!      valley_CO2antr = 50.
+!      if ( (j .eq. 20) .and. (maxval(swrad) .gt. 1.) ) then
+!         chem(i,1,j,p_co2_ant)= chem(i,1,j,p_co2_ant) + conv_rho*valley_CO2antr
+!      end if
+!      ENDDO
    ENDDO
 ENDDO
 
+!cmr copy co2_bio field on co2_clm
+co2_clm(:,:,:) = chem(:,:,:,p_co2_bio)
+co2_clm2(:,:,:) = chem(:,:,:,p_co2_ant)
+co2_clm3(:,:,:) = chem(:,:,:,p_co2_oce)
+!cmr
+
+
 ! For the GHG_TRACER option only
 IF(config_flags%chem_opt==GHG_TRACER) THEN
     DO j=jts,jte
diff -Nru WRFV3.5/configure_WRFV3.5_leo3.wrf WRFV3.5_MR/configure_WRFV3.5_leo3.wrf
--- WRFV3.5/configure_WRFV3.5_leo3.wrf	1970-01-01 01:00:00.000000000 +0100
+++ WRFV3.5_MR/configure_WRFV3.5_leo3.wrf	2014-12-17 11:53:56.232218000 +0100
@@ -0,0 +1,536 @@
+# configure.wrf
+#
+# This file was automatically generated by the configure script in the
+# top level directory. You may make changes to the settings in this
+# file but be aware they will be overwritten each time you run configure.
+# Ordinarily, it is necessary to run configure once, when the code is
+# first installed.
+#
+# To permanently change options, change the settings for your platform
+# in the file arch/configure.defaults then rerun configure.
+#
+SHELL           =       /bin/sh
+DEVTOP          =       `pwd`
+LIBINCLUDE      =       .
+.SUFFIXES: .F .i .o .f90 .c
+
+#### Get core settings from environment (set in compile script)
+#### Note to add a core, this has to be added to.
+
+COREDEFS = -DEM_CORE=$(WRF_EM_CORE) \
+           -DNMM_CORE=$(WRF_NMM_CORE) -DNMM_MAX_DIM=2600 \
+	   -DCOAMPS_CORE=$(WRF_COAMPS_CORE) \
+	   -DDA_CORE=$(WRF_DA_CORE) \
+           -DEXP_CORE=$(WRF_EXP_CORE)
+
+#### Single location for defining total number of domains.  You need
+#### at least 1 + 2*(number of total nests).  For example, 1 coarse
+#### grid + three fine grids = 1 + 2(3) = 7, so MAX_DOMAINS=7.
+
+MAX_DOMAINS	=	21
+
+#### DM buffer length for the configuration flags.
+
+CONFIG_BUF_LEN	=	65536
+
+#### Size of bitmasks (in 4byte integers) of stream masks for WRF I/O
+
+MAX_HISTORY = 25
+
+IWORDSIZE = 4
+DWORDSIZE = 8
+LWORDSIZE = 4
+
+##############################################################################
+#### The settings in this section are defaults that may be overridden by the 
+#### architecture-specific settings in the next section.  
+##############################################################################
+
+##############################################################################
+#### NOTE:  Do not modify these default values here.  To override these 
+####        values, make changes after "Architecture specific settings".  
+##############################################################################
+
+#### Native size (in bytes) of Fortran REAL data type on this architecture ####
+#### Note:  to change real wordsize (for example, to promote REALs from 
+####        4-byte to 8-byte), modify the definition of RWORDSIZE in the 
+####        section following "Architecture specific settings".  Do not 
+####        change NATIVE_RWORDSIZE as is it architecture-specific.  
+NATIVE_RWORDSIZE = 4
+
+#### Default sed command and script for Fortran source files ####
+#SED_FTN = sed -f $(WRF_SRC_ROOT_DIR)/arch/standard.sed
+SED_FTN = $(WRF_SRC_ROOT_DIR)/tools/standard.exe
+
+# Hack to work around $(PWD) not changing during OSF1 build.  
+# $(IO_GRIB_SHARE_DIR) is reset during the OSF1 build only.  
+IO_GRIB_SHARE_DIR = 
+
+#### ESMF switches                 ####
+#### These are set up by Config.pl ####
+# switch to use separately installed ESMF library for coupling:  1==true
+ESMF_COUPLING       = 0
+# select dependences on module_utility.o
+ESMF_MOD_DEPENDENCE = $(WRF_SRC_ROOT_DIR)/external/esmf_time_f90/module_utility.o
+# select -I options for external/io_esmf vs. external/esmf_time_f90
+ESMF_IO_INC         = -I$(WRF_SRC_ROOT_DIR)/external/esmf_time_f90
+# select -I options for separately installed ESMF library, if present
+ESMF_MOD_INC        =  $(ESMF_IO_INC)
+# select cpp token for external/io_esmf vs. external/esmf_time_f90
+ESMF_IO_DEFS        = 
+# select build target for external/io_esmf vs. external/esmf_time_f90
+ESMF_TARGET         = esmf_time
+
+# ESMFINCLUDEGOESHERE
+
+
+#### NETCDF4 pieces
+
+NETCDF4_IO_OPTS = -DUSE_NETCDF4_FEATURES -DWRFIO_NCD_LARGE_FILE_SUPPORT
+GPFS            =
+CURL            =
+HDF5            =
+ZLIB            =
+DEP_LIB_PATH    = 
+NETCDF4_DEP_LIB = $(DEP_LIB_PATH) $(HDF5) $(ZLIB) $(GPFS) $(CURL)
+
+# NETCDF4INCLUDEGOESHERE
+
+
+##############################################################################
+
+LIBWRFLIB = libwrflib.a
+
+
+#### Architecture specific settings ####
+
+# Settings for Linux x86_64 i486 i586 i686, PGI compiler with gcc  (dmpar)
+#
+DMPARALLEL      =        1
+OMPCPP          =       # -D_OPENMP
+OMP             =       # -mp -Minfo=mp -Mrecursive
+OMPCC           =       # -mp
+SFC             =       pgf90
+SCC             =       gcc
+CCOMP           =       pgcc
+DM_FC           =       mpif90 
+DM_CC           =       mpicc 
+FC              =        $(DM_FC)
+CC              =       $(DM_CC) -DMPI2_SUPPORT -DFSEEKO64_OK 
+LD              =       $(FC)
+RWORDSIZE       =       $(NATIVE_RWORDSIZE)
+PROMOTION       =       -r$(RWORDSIZE) -i4
+ARCH_LOCAL      =       -DNONSTANDARD_SYSTEM_SUBR -DWRF_USE_CLM
+CFLAGS_LOCAL    =       -w -O3
+LDFLAGS_LOCAL   =       
+CPLUSPLUSLIB    =       
+ESMF_LDFLAG     =       $(CPLUSPLUSLIB)
+FCOPTIM         =       -O3 #-fastsse -Mvect=noaltcode -Msmartalloc -Mprefetch=distance:8 -Mfprelaxed # -Minfo=all =Mneginfo=all
+FCREDUCEDOPT	=       $(FCOPTIM)
+FCNOOPT		=       -O0
+FCDEBUG         =       # -g $(FCNOOPT)  # -C -Ktrap=fp -traceback
+FORMAT_FIXED    =       -Mfixed
+FORMAT_FREE     =       -Mfree
+FCSUFFIX        =
+BYTESWAPIO      =       -byteswapio
+FCBASEOPTS_NO_G =       -w $(FORMAT_FREE) $(BYTESWAPIO) $(OMP)
+FCBASEOPTS      =       $(FCBASEOPTS_NO_G) $(FCDEBUG)
+MODULE_SRCH_FLAG =     -module $(WRF_SRC_ROOT_DIR)/main
+TRADFLAG        =      -traditional
+CPP             =      /lib/cpp -C -P
+AR              =      ar
+ARFLAGS         =      ru
+M4              =      m4 -B 14000
+RANLIB          =      ranlib
+CC_TOOLS        =      $(SCC) 
+
+###########################################################
+######################
+# POSTAMBLE
+
+FGREP = fgrep -iq
+
+ARCHFLAGS       =    $(COREDEFS) -DIWORDSIZE=$(IWORDSIZE) -DDWORDSIZE=$(DWORDSIZE) -DRWORDSIZE=$(RWORDSIZE) -DLWORDSIZE=$(LWORDSIZE) \
+                     $(ARCH_LOCAL) \
+                     $(DA_ARCHFLAGS) \
+                      -DDM_PARALLEL \
+                       \
+                      -DNETCDF \
+                       \
+                       \
+                       \
+                       \
+                       \
+                       \
+                       \
+                       \
+                      -DUSE_ALLOCATABLES \
+                      -DGRIB1 \
+                      -DINTIO \
+                      -DLIMIT_ARGS \
+                      -DCONFIG_BUF_LEN=$(CONFIG_BUF_LEN) \
+                      -DMAX_DOMAINS_F=$(MAX_DOMAINS) \
+                      -DMAX_HISTORY=$(MAX_HISTORY) \
+		      -DNMM_NEST=$(WRF_NMM_NEST)
+CFLAGS          =    $(CFLAGS_LOCAL) -DDM_PARALLEL  \
+                      -DMAX_HISTORY=$(MAX_HISTORY) -DNMM_CORE=$(WRF_NMM_CORE)
+FCFLAGS         =    $(FCOPTIM) $(FCBASEOPTS)
+ESMF_LIB_FLAGS  =    
+# ESMF 5 -- these are defined in esmf.mk, included above
+ ESMF_IO_LIB     =    -L$(WRF_SRC_ROOT_DIR)/external/esmf_time_f90 -lesmf_time
+ESMF_IO_LIB_EXT =    -L$(WRF_SRC_ROOT_DIR)/external/esmf_time_f90 -lesmf_time
+INCLUDE_MODULES =    $(MODULE_SRCH_FLAG) \
+                     $(ESMF_MOD_INC) $(ESMF_LIB_FLAGS) \
+                      -I$(WRF_SRC_ROOT_DIR)/main \
+                      -I$(WRF_SRC_ROOT_DIR)/external/io_netcdf \
+                      -I$(WRF_SRC_ROOT_DIR)/external/io_int \
+                      -I$(WRF_SRC_ROOT_DIR)/frame \
+                      -I$(WRF_SRC_ROOT_DIR)/share \
+                      -I$(WRF_SRC_ROOT_DIR)/phys \
+                      -I$(WRF_SRC_ROOT_DIR)/chem -I$(WRF_SRC_ROOT_DIR)/inc \
+                      -I$(NETCDFPATH)/include \
+                      
+REGISTRY        =    Registry
+CC_TOOLS_CFLAGS = -DNMM_CORE=$(WRF_NMM_CORE)
+
+ LIB_BUNDLED     = \
+                      $(WRF_SRC_ROOT_DIR)/external/fftpack/fftpack5/libfftpack.a \
+                      $(WRF_SRC_ROOT_DIR)/external/io_grib1/libio_grib1.a \
+                      $(WRF_SRC_ROOT_DIR)/external/io_grib_share/libio_grib_share.a \
+                      $(WRF_SRC_ROOT_DIR)/external/io_int/libwrfio_int.a \
+                      $(ESMF_IO_LIB) \
+                      $(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a \
+                      $(WRF_SRC_ROOT_DIR)/frame/module_internal_header_util.o \
+                      $(WRF_SRC_ROOT_DIR)/frame/pack_utils.o 
+
+ LIB_EXTERNAL    = \
+                      -L$(WRF_SRC_ROOT_DIR)/external/io_netcdf -lwrfio_nf -L/usr/site/hpc/x86_64/glibc-2.12/gulftown/netcdf/4.1.3/pgi-11.10/lib -lnetcdff -lnetcdf    
+
+LIB             =    $(LIB_BUNDLED) $(LIB_EXTERNAL) $(LIB_LOCAL) $(LIB_WRF_HYDRO)
+LDFLAGS         =    $(OMP) $(FCFLAGS) $(LDFLAGS_LOCAL) 
+ENVCOMPDEFS     =     -DWRF_CHEM -DBUILD_CHEM=1
+WRF_CHEM	=	1 
+CPPFLAGS        =    $(ARCHFLAGS) $(ENVCOMPDEFS) -I$(LIBINCLUDE) $(TRADFLAG) 
+NETCDFPATH      =    /usr/site/hpc/x86_64/glibc-2.12/gulftown/netcdf/4.1.3/pgi-11.10
+PNETCDFPATH     =    
+
+bundled:  wrf_ioapi_includes wrfio_grib_share wrfio_grib1 wrfio_int esmf_time fftpack 
+external:  wrfio_nf   $(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a gen_comms_rsllite module_dm_rsllite $(ESMF_TARGET)
+
+######################
+externals: bundled external
+
+gen_comms_serial :
+	( /bin/rm -f $(WRF_SRC_ROOT_DIR)/tools/gen_comms.c )
+
+module_dm_serial :
+	( if [ ! -e module_dm.F ] ; then /bin/cp module_dm_warning module_dm.F ; cat module_dm_stubs.F >> module_dm.F ; fi )
+
+gen_comms_rsllite :
+	( if [ ! -e $(WRF_SRC_ROOT_DIR)/tools/gen_comms.c ] ; then \
+          /bin/cp $(WRF_SRC_ROOT_DIR)/tools/gen_comms_warning $(WRF_SRC_ROOT_DIR)/tools/gen_comms.c ; \
+          cat $(WRF_SRC_ROOT_DIR)/external/RSL_LITE/gen_comms.c >> $(WRF_SRC_ROOT_DIR)/tools/gen_comms.c ; fi )
+
+module_dm_rsllite :
+	( if [ ! -e module_dm.F ] ; then /bin/cp module_dm_warning module_dm.F ; \
+          cat $(WRF_SRC_ROOT_DIR)/external/RSL_LITE/module_dm.F >> module_dm.F ; fi )
+
+wrfio_nf : 
+	( cd $(WRF_SRC_ROOT_DIR)/external/io_netcdf ; \
+          make $(J) NETCDFPATH="$(NETCDFPATH)" RANLIB="$(RANLIB)" CPP="$(CPP)" \
+          CC="$(SCC)" CFLAGS="$(CFLAGS)" \
+          FC="$(SFC) $(PROMOTION) $(OMP) $(FCFLAGS)" TRADFLAG="$(TRADFLAG)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" )
+
+wrfio_pnf : 
+	( cd $(WRF_SRC_ROOT_DIR)/external/io_pnetcdf ; \
+          make $(J) NETCDFPATH="$(PNETCDFPATH)" RANLIB="$(RANLIB)" CPP="$(CPP) $(ARCHFLAGS)" \
+          FC="$(FC) $(PROMOTION) $(OMP) $(FCFLAGS)" TRADFLAG="$(TRADFLAG)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" )
+
+wrfio_grib_share :
+	( cd $(WRF_SRC_ROOT_DIR)/external/io_grib_share ; \
+          make $(J) CC="$(SCC)" CFLAGS="$(CFLAGS)" RM="$(RM)" RANLIB="$(RANLIB)" CPP="$(CPP)" \
+          FC="$(SFC) $(PROMOTION) -I. $(FCDEBUG) $(FCBASEOPTS) $(FCSUFFIX)" TRADFLAG="$(TRADFLAG)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" archive) 
+
+wrfio_grib1 :
+	( cd $(WRF_SRC_ROOT_DIR)/external/io_grib1 ; \
+          make $(J) CC="$(SCC)" CFLAGS="$(CFLAGS)" RM="$(RM)" RANLIB="$(RANLIB)" CPP="$(CPP)" \
+          FC="$(SFC) $(PROMOTION) -I. $(FCDEBUG) $(FCBASEOPTS) $(FCSUFFIX)" TRADFLAG="$(TRADFLAG)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" archive)
+
+wrfio_grib2 :
+	( cd $(WRF_SRC_ROOT_DIR)/external/io_grib2 ; \
+          make $(J) CC="$(SCC)" CFLAGS="$(CFLAGS) " RM="$(RM)" RANLIB="$(RANLIB)" \
+          CPP="$(CPP)" \
+          FC="$(SFC) $(PROMOTION) -I. $(FCDEBUG) $(FCBASEOPTS) $(FCSUFFIX)" TRADFLAG="-traditional" AR="$(AR)" ARFLAGS="$(ARFLAGS)" \
+          FIXED="$(FORMAT_FIXED)" archive)
+
+wrfio_int : 
+	( cd $(WRF_SRC_ROOT_DIR)/external/io_int ; \
+          make $(J) CC="$(CC)" RM="$(RM)" RANLIB="$(RANLIB)" CPP="$(CPP)" \
+          FC="$(FC) $(PROMOTION) $(FCDEBUG) $(FCBASEOPTS) $(OMP)" FGREP="$(FGREP)" \
+          TRADFLAG="$(TRADFLAG)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" ARCHFLAGS="$(ARCHFLAGS)" all )
+
+esmf_time : 
+	( cd $(WRF_SRC_ROOT_DIR)/external/esmf_time_f90 ; \
+          make $(J) FC="$(SFC) $(PROMOTION) $(FCDEBUG) $(FCBASEOPTS)" RANLIB="$(RANLIB)" \
+          CPP="$(CPP) -I$(WRF_SRC_ROOT_DIR)/inc -I. $(ARCHFLAGS) $(TRADFLAG)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" )
+
+fftpack :
+	( cd $(WRF_SRC_ROOT_DIR)/external/fftpack/fftpack5 ; \
+          make $(J) FC="$(SFC)" FFLAGS="$(PROMOTION) $(FCDEBUG) $(FCBASEOPTS)" RANLIB="$(RANLIB)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" )
+
+atm_ocn :
+	( cd $(WRF_SRC_ROOT_DIR)/external/atm_ocn ; \
+          make $(J) CC="$(SCC)" CFLAGS="$(CFLAGS) " RM="$(RM)" RANLIB="$(RANLIB)" \
+          CPP="$(CPP)" \
+          FC="$(DM_FC) $(PROMOTION) -I. $(FCDEBUG) $(FCBASEOPTS) $(FCSUFFIX)" TRADFLAG="-traditional" AR="$(AR)" ARFLAGS="$(ARFLAGS)" \
+          FIXED="$(FORMAT_FIXED)" )
+
+$(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a :
+	( cd $(WRF_SRC_ROOT_DIR)/external/RSL_LITE ; make $(J) CC="$(CC) $(CFLAGS)" \
+          FC="$(FC) $(FCFLAGS) $(OMP) $(PROMOTION) $(BYTESWAPIO)" \
+          CPP="$(CPP) -I. $(ARCHFLAGS) $(OMPCPP) $(TRADFLAG)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" ;\
+          $(RANLIB) $(WRF_SRC_ROOT_DIR)/external/RSL_LITE/librsl_lite.a )
+
+######################
+#	Macros, these should be generic for all machines
+
+LN	=	ln -sf
+MAKE	=	make -i -r
+RM	= 	rm -f
+
+
+# These sub-directory builds are identical across all architectures
+
+wrf_ioapi_includes :
+	( cd $(WRF_SRC_ROOT_DIR)/external/ioapi_share ; \
+          $(MAKE) NATIVE_RWORDSIZE="$(NATIVE_RWORDSIZE)" RWORDSIZE="$(RWORDSIZE)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" )
+
+wrfio_esmf :
+	( cd $(WRF_SRC_ROOT_DIR)/external/io_esmf ; \
+          make FC="$(FC) $(PROMOTION) $(FCDEBUG) $(FCBASEOPTS) $(ESMF_MOD_INC)" \
+          RANLIB="$(RANLIB)" CPP="$(CPP) $(POUND_DEF) " AR="$(AR)" ARFLAGS="$(ARFLAGS)" )
+
+#	There is probably no reason to modify these rules
+
+.F.i:
+	$(RM) $@
+	$(CPP) -I$(WRF_SRC_ROOT_DIR)/inc $(CPPFLAGS) $*.F > $@
+	mv $*.i $(DEVTOP)/pick/$*.f90
+	cp $*.F $(DEVTOP)/pick
+
+.F.o:
+	$(RM) $@
+	$(CPP) -I$(WRF_SRC_ROOT_DIR)/inc $(CPPFLAGS) $(OMPCPP) $*.F  > $*.bb
+	$(SED_FTN) $*.bb | $(CPP) > $*.f90
+	$(RM) $*.b $*.bb
+	@ if echo $(ARCHFLAGS) | $(FGREP) 'DVAR4D'; then \
+          echo COMPILING $*.F for 4DVAR ; \
+          $(WRF_SRC_ROOT_DIR)/var/build/da_name_space.pl $*.f90 > $*.f90.tmp ; \
+          mv $*.f90.tmp $*.f90 ; \
+        fi
+	$(FC) -o $@ -c $(FCFLAGS) $(OMP) $(MODULE_DIRS) $(PROMOTION) $(FCSUFFIX) $*.f90
+        
+
+.F.f90:
+	$(RM) $@
+	$(SED_FTN) $*.F > $*.b 
+	$(CPP) -I$(WRF_SRC_ROOT_DIR)/inc $(CPPFLAGS) $*.b  > $@
+	$(RM) $*.b
+
+.f90.o:
+	$(RM) $@
+	$(FC) -o $@ -c $(FCFLAGS) $(PROMOTION) $(FCSUFFIX) $*.f90
+
+setfeenv.o : setfeenv.c
+	$(RM) $@
+	$(CCOMP) -o $@ -c $(CFLAGS) $(OMPCC) $*.c
+
+.c.o:
+	$(RM) $@
+	$(CC) -o $@ -c $(CFLAGS) $*.c
+
+# A little more adventurous.  Allow full opt on 
+# mediation_integrate.o \
+# shift_domain_em.o \
+# solve_em.o  <-- gets a little kick from SOLVE_EM_SPECIAL too, if defined
+# mediation_feedback_domain.o : mediation_feedback_domain.F
+# mediation_force_domain.o : mediation_force_domain.F
+# mediation_interp_domain.o : mediation_interp_domain.F
+
+# compile these without high optimization to speed compile
+mediation_integrate.o : mediation_integrate.F
+track_driver.o : track_driver.F
+convert_nmm.o : convert_nmm.F
+init_modules_em.o : init_modules_em.F
+input_wrf.o : input_wrf.F
+module_io.o : module_io.F
+module_comm_dm.o : module_comm_dm.F
+module_comm_dm_0.o : module_comm_dm_0.F
+module_comm_dm_1.o : module_comm_dm_1.F
+module_comm_dm_2.o : module_comm_dm_2.F
+module_comm_dm_3.o : module_comm_dm_3.F
+module_comm_nesting_dm.o : module_comm_nesting_dm.F
+module_configure.o : module_configure.F
+module_dm.o : module_dm.F
+module_domain.o : module_domain.F
+module_domain_type.o : module_domain_type.F
+module_alloc_space_0.o : module_alloc_space_0.F
+module_alloc_space_1.o : module_alloc_space_1.F
+module_alloc_space_2.o : module_alloc_space_2.F
+module_alloc_space_3.o : module_alloc_space_3.F
+module_alloc_space_4.o : module_alloc_space_4.F
+module_alloc_space_5.o : module_alloc_space_5.F
+module_alloc_space_6.o : module_alloc_space_6.F
+module_alloc_space_7.o : module_alloc_space_7.F
+module_alloc_space_8.o : module_alloc_space_8.F
+module_alloc_space_9.o : module_alloc_space_9.F
+module_tiles.o : module_tiles.F
+module_fddaobs_rtfdda.o : module_fddaobs_rtfdda.F
+module_initialize.o : module_initialize.F
+module_physics_init.o : module_physics_init.F 
+module_initialize_b_wave.o : module_initialize_b_wave.F
+module_initialize_hill2d_x.o : module_initialize_hill2d_x.F
+module_initialize_quarter_ss.o : module_initialize_quarter_ss.F
+module_initialize_real.o : module_initialize_real.F
+module_initialize_real.o: module_initialize_real.F
+module_initialize_squall2d_x.o : module_initialize_squall2d_x.F
+module_initialize_squall2d_y.o : module_initialize_squall2d_y.F
+module_initialize_scm_xy.o : module_initialize_scm_xy.F
+module_integrate.o : module_integrate.F
+module_io_mm5.o : module_io_mm5.F
+module_io_wrf.o : module_io_wrf.F
+module_si_io.o : module_si_io.F
+module_wps_io_arw.o : module_wps_io_arw.F
+module_state_description.o : module_state_description.F 
+output_wrf.o : output_wrf.F
+solve_interface.o : solve_interface.F
+start_domain.o : start_domain.F
+start_em.o : start_em.F
+wrf_bdyin.o : wrf_bdyin.F
+wrf_bdyout.o : wrf_bdyout.F
+wrf_ext_read_field.o : wrf_ext_read_field.F
+wrf_ext_write_field.o : wrf_ext_write_field.F
+wrf_fddaobs_in.o : wrf_fddaobs_in.F
+wrf_histin.o : wrf_histin.F
+wrf_histout.o : wrf_histout.F
+wrf_inputin.o : wrf_inputin.F
+wrf_inputout.o : wrf_inputout.F
+wrf_restartin.o : wrf_restartin.F
+wrf_restartout.o : wrf_restartout.F
+wrf_tsin.o : wrf_tsin.F
+nl_get_0_routines.o : nl_get_0_routines.F
+nl_get_1_routines.o : nl_get_1_routines.F
+nl_set_0_routines.o : nl_set_0_routines.F
+nl_set_1_routines.o : nl_set_1_routines.F
+
+mediation_integrate.o \
+track_driver.o \
+convert_nmm.o \
+init_modules_em.o \
+module_dm.o \
+module_fddaobs_rtfdda.o \
+module_initialize.o \
+module_initialize_b_wave.o \
+module_initialize_hill2d_x.o \
+module_initialize_quarter_ss.o \
+module_initialize_real.o \
+module_initialize_squall2d_x.o \
+module_initialize_squall2d_y.o \
+module_initialize_scm_xy.o \
+module_integrate.o \
+module_io_mm5.o \
+module_io_wrf.o \
+module_si_io.o \
+module_wps_io_arw.o \
+module_tiles.o \
+output_wrf.o \
+solve_interface.o \
+start_domain.o \
+start_em.o \
+wrf_fddaobs_in.o \
+wrf_tsin.o :
+	$(RM) $@
+	$(SED_FTN) $*.F > $*.b 
+	$(CPP) -I$(WRF_SRC_ROOT_DIR)/inc $(CPPFLAGS) $(OMPCPP) $*.b  > $*.f90
+	$(RM) $*.b
+	@ if echo $(ARCHFLAGS) | $(FGREP) 'DVAR4D'; then \
+          echo COMPILING $*.F for 4DVAR ; \
+          $(WRF_SRC_ROOT_DIR)/var/build/da_name_space.pl $*.f90 > $*.f90.tmp ; \
+          mv $*.f90.tmp $*.f90 ; \
+        fi
+	if $(FGREP) '!$$OMP' $*.f90 ; then \
+          if [ -n "$(OMP)" ] ; then echo COMPILING $*.F WITH OMP ; fi ; \
+	  $(FC) -c $(PROMOTION) $(FCNOOPT) $(FCBASEOPTS) $(MODULE_DIRS) $(FCSUFFIX) $(OMP) $*.f90 ; \
+        else \
+          if [ -n "$(OMP)" ] ; then echo COMPILING $*.F WITHOUT OMP ; fi ; \
+	  $(FC) -c $(PROMOTION) $(FCNOOPT) $(FCBASEOPTS) $(MODULE_DIRS) $(FCSUFFIX) $*.f90 ; \
+        fi
+
+#solve_em.o :
+#	$(RM) $@
+#	$(SED_FTN) $*.F > $*.b 
+#	$(CPP) -I$(WRF_SRC_ROOT_DIR)/inc $(CPPFLAGS) $*.b  > $*.f90
+#	$(RM) $*.b
+#	$(FC) -o $@ -c $(FCFLAGS) $(MODULE_DIRS) $(PROMOTION) $(FCSUFFIX) $(SOLVE_EM_SPECIAL) $(OMP) $*.f90
+
+module_sf_ruclsm.o : module_sf_ruclsm.F
+
+module_sf_ruclsm.o :
+	$(RM) $@
+	$(SED_FTN) $*.F > $*.b 
+	$(CPP) -I$(WRF_SRC_ROOT_DIR)/inc $(CPPFLAGS) $(OMPCPP) $*.b  > $*.f90
+	$(RM) $*.b
+	if $(FGREP) '!$$OMP' $*.f90 ; then \
+          echo COMPILING $*.F WITH OMP ; \
+          if [ -n "$(OMP)" ] ; then echo COMPILING $*.F WITH OMP ; fi ; \
+	  $(FC) -c $(PROMOTION) $(FCREDUCEDOPT) $(FCBASEOPTS) $(MODULE_DIRS) $(FCSUFFIX) $(OMP) $*.f90 ; \
+        else \
+          if [ -n "$(OMP)" ] ; then echo COMPILING $*.F WITHOUT OMP ; fi ; \
+	  $(FC) -c $(PROMOTION) $(FCREDUCEDOPT) $(FCBASEOPTS) $(MODULE_DIRS) $(FCSUFFIX) $*.f90 ; \
+        fi
+
+# compile without OMP
+input_wrf.o \
+module_domain.o \
+module_domain_type.o \
+module_physics_init.o \
+module_io.o \
+wrf_bdyin.o \
+wrf_bdyout.o \
+wrf_ext_read_field.o \
+wrf_ext_write_field.o \
+wrf_histin.o \
+wrf_histout.o \
+wrf_inputin.o \
+wrf_inputout.o \
+wrf_restartin.o \
+wrf_restartout.o \
+module_state_description.o \
+module_alloc_space.o \
+module_alloc_space_0.o \
+module_alloc_space_1.o \
+module_alloc_space_2.o \
+module_alloc_space_3.o \
+module_alloc_space_4.o \
+module_alloc_space_5.o \
+module_alloc_space_6.o \
+module_alloc_space_7.o \
+module_alloc_space_8.o \
+module_alloc_space_9.o \
+module_comm_dm.o \
+module_comm_dm_0.o \
+module_comm_dm_1.o \
+module_comm_dm_2.o \
+module_comm_dm_3.o \
+module_comm_nesting_dm.o \
+module_configure.o :
+	$(RM) $@
+	$(CPP) -I$(WRF_SRC_ROOT_DIR)/inc $(CPPFLAGS) $(OMPCPP) $*.F  > $*.bb
+	$(SED_FTN) $*.bb | $(CPP) > $*.f90
+	@ if echo $(ARCHFLAGS) | $(FGREP) 'DVAR4D'; then \
+          echo COMPILING $*.F for 4DVAR ; \
+          $(WRF_SRC_ROOT_DIR)/var/build/da_name_space.pl $*.f90 > $*.f90.tmp ; \
+          mv $*.f90.tmp $*.f90 ; \
+        fi
+	$(RM) $*.b $*.bb
+	$(FC) -c $(PROMOTION) $(FCSUFFIX) $(FCNOOPT) $(FCBASEOPTS) $(MODULE_DIRS) $*.f90
diff -Nru WRFV3.5/dyn_em/module_big_step_utilities_em.F WRFV3.5_MR/dyn_em/module_big_step_utilities_em.F
--- WRFV3.5/dyn_em/module_big_step_utilities_em.F	2013-04-01 16:53:17.000000000 +0200
+++ WRFV3.5_MR/dyn_em/module_big_step_utilities_em.F	2014-12-17 11:53:56.028518000 +0100
@@ -4804,11 +4804,13 @@
     k_start = kts
     k_end = min( kte, kde-1 )
 !jdf
-    do j = j_start,j_end
-    do i = i_start, i_end
-      if(landmask(i,j).lt.0.5) xland(i,j)=2.0
-    enddo
-    enddo
+!cmr uncomment to keep xland to 1
+!    do j = j_start,j_end
+!    do i = i_start, i_end
+!      if(landmask(i,j).lt.0.5) xland(i,j)=2.0
+!    enddo
+!    enddo
+!cmr
 !jdf
 
 !  compute thermodynamics and velocities at pressure points (or half levels)
diff -Nru WRFV3.5/dyn_em/module_first_rk_step_part1.F WRFV3.5_MR/dyn_em/module_first_rk_step_part1.F
--- WRFV3.5/dyn_em/module_first_rk_step_part1.F	2013-03-22 20:30:26.000000000 +0100
+++ WRFV3.5_MR/dyn_em/module_first_rk_step_part1.F	2014-12-17 11:53:56.041947000 +0100
@@ -116,6 +116,7 @@
     INTEGER, INTENT(IN)                           ::  k_start, k_end
     LOGICAL, INTENT(IN), OPTIONAL                 ::  f_flux
 
+!    real,  dimension(ims:ime,jms:jme ) :: fco2!cmr
 ! Local
     real :: HYDRO_dt
     REAL, DIMENSION( ims:ime, jms:jme ) :: exch_temf  ! 1/7/09 WA
@@ -401,7 +402,8 @@
           HYDRO_dt = -1
       endif
 
-      CALL surface_driver(                                                &
+      CALL surface_driver(                                                
+!cmr     &         cf1=grid%cf1, cf2=grid%cf2, cf3=grid%cf3,                  &
      &        HYDRO_dt=HYDRO_dt,  sfcheadrt=grid%sfcheadrt,               &
      &        INFXSRT=grid%INFXSRT,  soldrain=grid%soldrain,              &
      &         ACGRDFLX=grid%acgrdflx  ,ACHFX=grid%achfx        ,ACLHF=grid%aclhf        &
@@ -692,7 +694,20 @@
      &        , okms = 1, okme=config_flags%ocean_levels                  & ! cyl:3DPWP
      &        ,rdx=grid%rdx, rdy=grid%rdy,msfu=grid%msfu,msfv=grid%msfv,msft=grid%msft &!cyl: 3DPWP
      &        ,XTIME=grid%xtime,OM_TINI=grid%om_tini,OM_SINI=grid%om_sini,id=grid%id,omdt=config_flags%omdt &!cyl: 3DPWP 
-     &                                                              )
+     &        ,fco2=grid%fco2,fco2mn=grid%fco2mn,fco2mx=grid%fco2mx,fco2nf=grid%fco2nf,reco=grid%reco,reco_gpp=grid%reco_gpp & 
+     &        ,reco_gppmn=grid%reco_gppmn,reco_gppmx=grid%reco_gppmx,fpsn=grid%fpsn,fpsn_mn=grid%fpsn_mn, & !cmr
+     &         fpsn_mx=grid%fpsn_mx,fpsn_nf=grid%fpsn_nf,fpsn_noslp=grid%fpsn_noslp & !cmr
+     &        ,co2_clm=grid%co2_clm,co2_clm2=grid%co2_clm2,co2_clm3=grid%co2_clm3,wj=grid%wj,we=grid%we,wc=grid%wc  & !cmr
+     &        ,ci_mr=grid%ci_mr,rs_mr=grid%rs_mr,rb_mr=grid%rb_mr,btran_mr=grid%btran_mr,apar_mr=grid%apar_mr & !cmr 
+     &        ,sla_mr=grid%sla_mr,vcmx_mr=grid%vcmx_mr,svpts_mr=grid%svpts_mr,eah_mr=grid%eah_mr  & !cmr
+     &        ,valley_CO2pft2=config_flags%valley_CO2pft2,valley_CO2backgr=config_flags%valley_CO2backgr & !cmr
+     &           )
+!cmr
+!   write(message,*) 'shape(grid%fpsnco2) = ',shape(grid%fpsnco2),'maxval',maxval(grid%fpsnco2) 
+!   CALL wrf_debug(0,message)
+!   write(message,*) 'shape(grid%xland) =',shape(grid%xland),'xland(20,20)',grid%xland(20,20)
+!   CALL wrf_debug(0,message)
+!cmr end
 
 #ifdef WRF_HYDRO
         if(HYDRO_dt .gt. 1 ) call wrf_drv_HYDRO(HYDRO_dt, grid,  &
diff -Nru WRFV3.5/dyn_em/module_initialize_les.F WRFV3.5_MR/dyn_em/module_initialize_les.F
--- WRFV3.5/dyn_em/module_initialize_les.F	2009-06-19 23:17:46.000000000 +0200
+++ WRFV3.5_MR/dyn_em/module_initialize_les.F	2014-12-17 11:53:56.080235000 +0100
@@ -23,6 +23,7 @@
    USE module_timing
    USE module_configure
    USE module_init_utilities
+   USE module_soil_pre
 #ifdef DM_PARALLEL
    USE module_dm
 #endif
@@ -39,6 +40,9 @@
 ! copies of assumed-shape arrays (by passing down as arguments, the 
 ! data are treated as assumed-size -- ie. f77 -- arrays and the copying
 ! business is avoided).  Fie on the F90 designers.  Fie and a pox.
+! NOTE:  Modified to remove all but arrays of rank 4 or more from the 
+!        argument list.  Arrays with rank>3 are still problematic due to the 
+!        above-noted fie- and pox-ities.  TBH 20061129.  
 
    SUBROUTINE init_domain ( grid )
 
@@ -56,7 +60,6 @@
 #include <actual_new_args.inc>
 !
                         )
-
    END SUBROUTINE init_domain
 
 !-------------------------------------------------------------------
@@ -80,21 +83,17 @@
                                   ids, ide, jds, jde, kds, kde, &
                                   ims, ime, jms, jme, kms, kme, &
                                   its, ite, jts, jte, kts, kte, &
-                                  i, j, k
-
-   ! Local data
+                                  i, j, k, ll
 
    INTEGER, PARAMETER :: nl_max = 1000
    REAL, DIMENSION(nl_max) :: zk, p_in, theta, rho, u, v, qv, pd_in
    INTEGER :: nl_in
 
-
-   INTEGER :: icm,jcm, ii, im1, jj, jm1, loop, error, fid, nxc, nyc
+   INTEGER :: icm,jcm, ii, im1, jj, jm1, loop, error, fid, nxc, nyc, lm
    REAL    :: u_mean,v_mean, f0, p_surf, p_level, qvf, z_at_v, z_at_u
    REAL    :: z_scale, xrad, yrad, zrad, rad, delt, cof1, cof2
 !   REAL, EXTERNAL :: interp_0
-   REAL    :: hm
-   REAL    :: pi
+   REAL    :: pi, rnd
 
 !  stuff from original initialization that has been dropped from the Registry 
    REAL    :: vnu, xnu, xnus, dinit0, cbh, p0_temp, t0_temp, zd, zt
@@ -104,13 +103,22 @@
 
    LOGICAL :: moisture_init
    LOGICAL :: stretch_grid, dry_sounding
+   character (len=256) :: mminlu2
 
-  INTEGER :: xs , xe , ys , ye
-  REAL :: mtn_ht
-   LOGICAL, EXTERNAL :: wrf_dm_on_monitor
+!  cjw begin
+!  variables for topography
+   REAL                            :: hp, Ly, Sy, Sx, X1, X2, X3, X4, shiftx, shifty 
+   REAL, DIMENSION(:), ALLOCATABLE :: hx, hy
+   REAL                            :: xx, yy 
+   INTEGER                         :: istart, iend, jstart, jend 
+   INTEGER, DIMENSION(:), ALLOCATABLE  :: valley_maskl, valley_maskr, &
+                                          valley_maskx, valley_masky
 !  For LES, add randx
    real :: randx
+!  cjw end
+   character*256 :: msg !cmr
 
+ 
 #ifdef DM_PARALLEL
 #    include <data_calls.inc>
 #endif
@@ -157,16 +165,14 @@
    END SELECT
 
 
-!  stretch_grid = .true.
-!  FOR LES, set stretch to false
    stretch_grid = .false.
-   delt = 3.
-!   z_scale = .50
+!   delt = 6.
    z_scale = .40
    pi = 2.*asin(1.0)
    write(6,*) ' pi is ',pi
    nxc = (ide-ids)/2
-   nyc = (jde-jds)/2
+   nyc = jde/2
+   icm = ide/2
 
    CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
 
@@ -183,50 +189,86 @@
    CALL wrf_dm_bcast_bytes( jcm , IWORDSIZE )
 #endif
 
-    CALL nl_set_mminlu(1, '    ')
-    CALL nl_set_iswater(1,0)
-    CALL nl_set_cen_lat(1,40.)
-    CALL nl_set_cen_lon(1,-105.)
-    CALL nl_set_truelat1(1,0.)
-    CALL nl_set_truelat2(1,0.)
+    mminlu2 = ' '
+    mminlu2(1:4) = 'USGS'
+    CALL nl_set_mminlu(1, mminlu2)
+!   CALL nl_set_mminlu(1, 'USGS')
+    CALL nl_set_iswater(1,16)
+    CALL nl_set_isice(1,3)
+    CALL nl_set_cen_lat(1,model_config_rec%valley_latitude)
+    CALL nl_set_cen_lon(1,model_config_rec%valley_longitude)
+    CALL nl_set_truelat1(1,model_config_rec%valley_latitude)
+    CALL nl_set_truelat2(1,model_config_rec%valley_longitude)
     CALL nl_set_moad_cen_lat (1,0.)
     CALL nl_set_stand_lon (1,0.)
     CALL nl_set_pole_lon (1,0.)
     CALL nl_set_pole_lat (1,90.)
     CALL nl_set_map_proj(1,0)
+!   CALL model_to_grid_config_rec(1,model_config_rec,config_flags)
+    CALL nl_get_iswater(1,grid%iswater)
 
-
-!  here we initialize data we currently is not initialized 
+!  here we initialize data that currently is not initialized 
 !  in the input data
 
     DO j = jts, jte
       DO i = its, ite
+         grid%msft(i,j)     = 1.
+         grid%msfu(i,j)     = 1.
+         grid%msfv(i,j)     = 1.
          grid%msftx(i,j)    = 1.
          grid%msfty(i,j)    = 1.
          grid%msfux(i,j)    = 1.
          grid%msfuy(i,j)    = 1.
          grid%msfvx(i,j)    = 1.
-         grid%msfvx_inv(i,j)= 1.
          grid%msfvy(i,j)    = 1.
+         grid%msfvx_inv(i,j)= 1.
          grid%sina(i,j)     = 0.
          grid%cosa(i,j)     = 1.
          grid%e(i,j)        = 0.
-!  for LES, include Coriolis force
-         grid%f(i,j)        = 1.e-4 
-
+         grid%f(i,j)        = 0.
       END DO
    END DO
 
-    DO j = jts, jte
+! for Noah LSM, additional variables need to be initialized
+
+   other_masked_fields : SELECT CASE ( model_config_rec%sf_surface_physics(grid%id) )
+
+      CASE (SLABSCHEME)
+
+
+      CASE (LSMSCHEME)
+
+! cjw: LSM variables are initialised further down
+
+      CASE (RUCLSMSCHEME)
+
+   END SELECT other_masked_fields
+
+   DO j = jts, jte
     DO k = kts, kte
       DO i = its, ite
          grid%ww(i,k,j)     = 0.
       END DO
-   END DO
+    END DO
    END DO
 
    grid%step_number = 0
 
+! Process the soil; note that there are some things hard-wired into share/module_soil_pre.F
+! cjw begin: soil properties initialised further down
+
+!      CALL process_soil_ideal(grid%xland,grid%xice,grid%vegfra,grid%snow,grid%canwat, &
+!                     grid%ivgtyp,grid%isltyp,grid%tslb,grid%smois, &
+!                     grid%tsk,grid%tmn,grid%zs,grid%dzs,model_config_rec%num_soil_layers, &
+!                     model_config_rec%sf_surface_physics(grid%id), &
+!                                   ids,ide, jds,jde, kds,kde,&
+!                                   ims,ime, jms,jme, kms,kme,&
+!                                   its,ite, jts,jte, kts,kte )
+
+! cjw end
+
+
+
 ! set up the grid
 
    IF (stretch_grid) THEN ! exponential stretch for eta (nearly constant dz)
@@ -236,7 +278,10 @@
      ENDDO
    ELSE
      DO k=1, kde
-      grid%znw(k) = 1. - float(k-1)/float(kde-1)
+! cjw      grid%znw(k) = 1. - float(k-1)/float(kde-1)
+! cjw begin
+      grid%znw(k) = model_config_rec%eta_levels(k)
+! cjw end
      ENDDO
    ENDIF
 
@@ -266,21 +311,9 @@
 !  get the sounding from the ascii sounding file, first get dry sounding and 
 !  calculate base state
 
-  dry_sounding = .true.
-  IF ( wrf_dm_on_monitor() ) THEN
   write(6,*) ' getting dry sounding for base state '
-
+  dry_sounding = .true.
   CALL get_sounding( zk, p_in, pd_in, theta, rho, u, v, qv, dry_sounding, nl_max, nl_in )
-  ENDIF
-  CALL wrf_dm_bcast_real( zk , nl_max )
-  CALL wrf_dm_bcast_real( p_in , nl_max )
-  CALL wrf_dm_bcast_real( pd_in , nl_max )
-  CALL wrf_dm_bcast_real( theta , nl_max )
-  CALL wrf_dm_bcast_real( rho , nl_max )
-  CALL wrf_dm_bcast_real( u , nl_max )
-  CALL wrf_dm_bcast_real( v , nl_max )
-  CALL wrf_dm_bcast_real( qv , nl_max )
-  CALL wrf_dm_bcast_integer ( nl_in , 1 ) 
 
   write(6,*) ' returned from reading sounding, nl_in is ',nl_in
 
@@ -289,50 +322,202 @@
 
   grid%p_top = interp_0( p_in, zk, config_flags%ztop, nl_in )
 
-  DO j=jts,jte
+!  cjw begin
+!  compute topography
+   hp = model_config_rec%valley_topo_hp
+   Ly = model_config_rec%valley_topo_ly 
+   Sy = model_config_rec%valley_topo_sy
+   Sx = model_config_rec%valley_topo_sx
+   X1 = model_config_rec%valley_topo_x1
+   X2 = model_config_rec%valley_topo_x2
+   X3 = model_config_rec%valley_topo_x3
+   X4 = model_config_rec%valley_topo_x4
+   shiftx = model_config_rec%valley_topo_shiftx
+   shifty = model_config_rec%valley_topo_shifty
+   allocate(hx(its:ite))
+   allocate(hy(jts:jte))
+   allocate(valley_maskx(its:ite))
+   allocate(valley_masky(jts:jte))
+
+  xx = 0.
+  yy = 0.
+!  compute hy(j)
+!cmr tranpose topo hx<->hy
+! now compute hx(j)
   DO i=its,ite
-    grid%ht(i,j) = 0.
-  ENDDO
-  ENDDO
+    IF (yy-shifty <= -Sy) THEN 
+      hx(i) = 0.
+      valley_maskx(i) = 0
+    ELSEIF (yy-shifty >= 2.*Ly+Sy) THEN
+      hx(i) = 0.
+      valley_maskx(i) = 0
+    ELSEIF (yy-shifty > -Sy .and. yy-shifty < 0.) THEN
+      hx(i) = 0.5 + 0.5*cos((pi/Sy)*(yy-shifty))
+      valley_maskx(i) = 0
+    ELSEIF (yy-shifty > 2.*Ly .and. yy-shifty < 2.*Ly+Sy) THEN
+      hx(i) = 0.5 + 0.5*cos((pi/Sy)*(yy-shifty-2.*Ly))
+      valley_maskx(i) = 0
+    ELSEIF (yy-shifty >= 0. .and. yy-shifty <= 2.*Ly ) THEN
+      hx(i) = 1.
+      valley_maskx(i) = 1
+    ENDIF
+    yy = yy + config_flags%dy
+  ENDDO 
 
-  xs=ide/2 -3
-  xs=ids   -3
-  xe=xs + 6
-  ys=jde/2 -3
-  ye=ys + 6
-  mtn_ht = 500
-#ifdef MTN
-  DO j=max(ys,jds),min(ye,jde-1)
-  DO i=max(xs,ids),min(xe,ide-1)
-     grid%ht(i,j) = mtn_ht * 0.25 * &
-               ( 1. + COS ( 2*pi/(xe-xs) * ( i-xs ) + pi ) ) * &
-               ( 1. + COS ( 2*pi/(ye-ys) * ( j-ys ) + pi ) )
-  ENDDO
-  ENDDO
-#endif
-#ifdef EW_RIDGE
-  DO j=max(ys,jds),min(ye,jde-1)
-  DO i=ids,ide
-     grid%ht(i,j) = mtn_ht * 0.50 * &
-               ( 1. + COS ( 2*pi/(ye-ys) * ( j-ys ) + pi ) )
+!  compute(hx(i))
+! changed to hy(j)
+  DO j=jts,jte
+    IF (xx-shiftx >= -X1 .and. xx-shiftx <= X1) THEN
+      hy(j) = 0.
+      valley_masky(j) = 1
+    ELSEIF (xx-shiftx > X1 .and. xx-shiftx < X2) THEN
+      hy(j) = 0.5 - 0.5*cos((pi/Sx)*((xx-shiftx)-X1))
+      valley_masky(j) = 1
+    ELSEIF (xx-shiftx > -X2 .and. xx-shiftx < -X1) THEN
+      hy(j) = 0.5 - 0.5*cos((pi/Sx)*((-xx+shiftx)-X1))
+      valley_masky(j) = 1
+    ELSEIF (xx-shiftx >= X2 .and. xx-shiftx <= X3) THEN
+      hy(j) = 1.
+      valley_masky(j) = 1
+    ELSEIF (xx-shiftx >= -X3 .and. xx-shiftx <= -X2) THEN
+      hy(j) = 1.
+      valley_masky(j) = 1
+    ELSEIF (xx-shiftx > X3 .and. xx-shiftx < X4) THEN
+      hy(j) = 0.5 + 0.5*cos((pi/Sx)*((xx-shiftx)-X3))
+      valley_masky(j) = 0
+    ELSEIF (xx-shiftx > -X4 .and. xx-shiftx < -X3) THEN
+      hy(j) = 0.5 + 0.5*cos((pi/Sx)*((-xx+shiftx)-X3))
+      valley_masky(j) = 0
+    ELSEIF (xx-shiftx >= X4 .or. xx-shiftx <= -X4) THEN
+      hy(j) = 0.
+      valley_masky(j) = 0
+    ENDIF
+    xx = xx + config_flags%dx
+  ENDDO 
+
+! ==== Get centre of valley:
+  i = its
+  DO WHILE (valley_maskx(i) /= 1)
+     i = i + 1 
   ENDDO
+  istart = i
+
+  i = ite
+  DO WHILE (valley_maskx(i) /= 1)
+     i = i - 1 
   ENDDO
-#endif
-#ifdef NS_RIDGE
-  DO j=jds,jde
-  DO i=max(xs,ids),min(xe,ide-1)
-     grid%ht(i,j) = mtn_ht * 0.50 * &
-               ( 1. + COS ( 2*pi/(xe-xs) * ( i-xs ) + pi ) )
+  iend = i
+
+  j = jts
+  DO WHILE (valley_masky(j) /= 1)
+     j = j + 1 
   ENDDO
+  jstart = j
+
+  j = jte
+  DO WHILE (valley_masky(j) /= 1)
+     j = j - 1 
   ENDDO
-#endif
+  jend = j
+
   DO j=jts,jte
-  DO i=its,ite
-    grid%phb(i,1,j) = g * grid%ht(i,j)
-    grid%ph0(i,1,j) = g * grid%ht(i,j)
+  DO i=its,ite  
+!cmr 20.02.14 transposed topo   
+    IF (config_flags%valley_CO2flat .eq. 1) THEN
+      grid%ht(i,j) = hp/2.
+    ELSE
+      grid%ht(i,j) = hp*hy(j)*hx(i)
+    ENDIF
+    grid%valley_mask(i,j) = valley_maskx(i)*valley_masky(j)
+    grid%phb(i,1,j) = g*grid%ht(i,j)
+    grid%php(i,1,j) = 0.
+    grid%ph0(i,1,j) = grid%phb(i,1,j)
   ENDDO
   ENDDO
 
+!cmr flat topo switch: 
+! cmr end
+ 
+  deallocate(hx)
+  deallocate(hy)
+  deallocate(valley_maskx)
+  deallocate(valley_masky)
+
+!  ! ==== Compute valley_mask: 1=valley; 0=no valley:
+!  allocate(valley_maskl(its:ite))
+!  allocate(valley_maskr(its:ite))
+!
+!
+!  DO j=jts,jte
+!
+!     valley_maskl(its) = 0
+!     DO i=its+1,ite  
+!        IF (grid%ht(i,j) == hp .and. valley_maskl(i-1) == 0) THEN
+!           valley_maskl(i) = 1
+!        ELSEIF (grid%ht(i,j) < hp .and. valley_maskl(i-1) == 0) THEN
+!           valley_maskl(i) = 0
+!        ELSEIF (valley_maskl(i-1) == 1) THEN
+!           valley_maskl(i) = 1
+!        ENDIF
+!     ENDDO
+!
+!     valley_maskr(ite) = 0
+!     DO i=ite-1,its,-1
+!        IF (valley_maskr(i+1) == 0 .and. grid%ht(i,j) == hp) THEN
+!           valley_maskr(i) = 1
+!        ELSEIF (valley_maskr(i+1) == 1) THEN
+!           valley_maskr(i) = 1
+!        ELSEIF (valley_maskr(i+1) == 0 .and. grid%ht(i,j) < hp) THEN
+!           valley_maskr(i) = 0
+!        ENDIF
+!     ENDDO
+!
+!     DO i = its,ite
+!        grid%valley_mask(i,j) = valley_maskl(i) * valley_maskr(i)
+!     ENDDO
+!
+!  ENDDO
+!
+!  deallocate(valley_maskl)
+!  deallocate(valley_maskr)
+
+  ! ==== Compute mask for entry, exit of valle in y- and x-direction:
+  grid%valley_xinout_mask  = 0
+  grid%valley_xin_mask     = 0
+  grid%valley_xout_mask    = 0
+  grid%valley_yinout_mask  = 0
+  grid%valley_yin_mask     = 0
+  grid%valley_yout_mask    = 0
+
+  j=jts
+  DO WHILE (maxval(grid%valley_mask(:,j)) == 0)
+     j = j + 1
+  ENDDO
+  grid%valley_yinout_mask(:,j) = grid%valley_mask(:,j) 
+  grid%valley_yin_mask(:,j) = grid%valley_mask(:,j) 
+
+  j=jte-2
+  DO WHILE (maxval(grid%valley_mask(:,j)) == 0)
+     j = j - 1
+  ENDDO 
+  grid%valley_yinout_mask(:,j) = grid%valley_mask(:,j) 
+  grid%valley_yout_mask(:,j) = grid%valley_mask(:,j) 
+
+  i=its          
+  DO WHILE (maxval(grid%valley_mask(i,:)) == 0)
+     i = i + 1
+  ENDDO
+  grid%valley_xinout_mask(i,:) = grid%valley_mask(i,:)
+  grid%valley_xin_mask(i,:) = grid%valley_mask(i,:)
+
+  i=ite-2          
+  DO WHILE (maxval(grid%valley_mask(i,:)) == 0)
+     i = i - 1
+  ENDDO
+  grid%valley_xinout_mask(i,:) = grid%valley_mask(i,:)
+  grid%valley_xout_mask(i,:) = grid%valley_mask(i,:)
+!  cjw end
+
   DO J = jts, jte
   DO I = its, ite
 
@@ -360,10 +545,19 @@
   ENDDO
   ENDDO
 
-  IF ( wrf_dm_on_monitor() ) THEN
-    write(6,*) ' ptop is ',grid%p_top
-    write(6,*) ' base state grid%mub(1,1), p_surf is ',grid%mub(1,1),grid%mub(1,1)+grid%p_top
-  ENDIF
+! cjw begin
+  DO j = jts, jte
+     DO i = its, ite
+        DO k = kts,kte-1
+        grid%ZPVALCENTRE(i,k,j) = (0.5*(grid%phb(int(0.5*(iend+istart)),k,int(0.5*(jend+jstart))) + &
+                               grid%phb(int(0.5*(iend+istart)),k+1,int(0.5*(jend+jstart)))))/9.81 
+        ENDDO  
+     ENDDO
+  ENDDO
+! cjw end
+
+  write(6,*) ' ptop is ',grid%p_top
+  write(6,*) ' base state grid%mub(1,1), p_surf is ',grid%mub(1,1),grid%mub(1,1)+grid%p_top
 
 !  calculate full state for each column - this includes moisture.
 
@@ -444,52 +638,51 @@
       grid%ph0(i,k,j) = grid%ph_1(i,k,j) + grid%phb(i,k,j)
     ENDDO
 
-    IF ( wrf_dm_on_monitor() ) THEN
     if((i==2) .and. (j==2)) then
      write(6,*) ' grid%ph_1 calc ',grid%ph_1(2,1,2),grid%ph_1(2,2,2),&
                               grid%mu_1(2,2)+grid%mub(2,2),grid%mu_1(2,2), &
                               grid%alb(2,1,2),grid%al(1,2,1),grid%rdnw(1)
     endif
-    ENDIF
 
   ENDDO
   ENDDO
 
-!#if 0
+! cjw begin
 
-!  thermal perturbation to kick off convection
+   if (model_config_rec%valley_randx .eq. 1) then
+! add random perturbations to perturbation theta
 
+!   if (0.gt.1) then
+!
+!!#if 0
+!!  The seabreeze case is adapted from the squall line case
+!!  so we just turn off the thermal perturbation
+!
+!!  thermal perturbation to kick off convection
+ call random_seed
   write(6,*) ' nxc, nyc for perturbation ',nxc,nyc
-  write(6,*) ' delt for perturbation ',delt
-
-! For LES, change the initial random perturbations
-! For 2D test, call randx outside I-loop
-! For 3D runs, call randx inside both I-J loops
-
+!  write(6,*) ' delt for perturbation ',delt
+!
   DO J = jts, min(jde-1,jte)
-!   yrad = config_flags%dy*float(j-nyc)/10000.
-    yrad = 0.
+!!    yrad = config_flags%dy*float(j-nyc)/4000.
+     yrad = 0.
     DO I = its, min(ide-1,ite)
-!     xrad = config_flags%dx*float(i-nxc)/10000.
-      xrad = 0.
-      call random_number (randx)
-      randx = randx - 0.5
-!     DO K = 1, kte-1
-      DO K = 1, 4 
+!      xrad = config_flags%dx*float(i-nxc)/10000.
+     xrad = 0.
+     call random_number (randx)
+     randx = randx - 0.5
+      DO K = 1, 5
 
 !  No bubbles for LES!
 !  put in preturbation theta (bubble) and recalc density.  note,
 !  the mass in the column is not changing, so when theta changes,
 !  we recompute density and geopotential
 
-!       zrad = 0.5*(grid%ph_1(i,k,j)+grid%ph_1(i,k+1,j)  &
-!                  +grid%phb(i,k,j)+grid%phb(i,k+1,j))/g
-!       zrad = (zrad-1500.)/1500.
         zrad = 0.
         RAD=SQRT(xrad*xrad+yrad*yrad+zrad*zrad)
         IF(RAD <= 1.) THEN
 !          grid%t_1(i,k,j)=grid%t_1(i,k,j)+delt*COS(.5*PI*RAD)**2
-           grid%t_1(i,k,j)=grid%t_1(i,k,j)+ 0.1 *randx
+           grid%t_1(i,k,j)=grid%t_1(i,k,j)+ randx
            grid%t_2(i,k,j)=grid%t_1(i,k,j)
            qvf = 1. + rvovrd*moist(i,k,j,P_QV)
            grid%alt(i,k,j) = (r_d/p1000mb)*(grid%t_1(i,k,j)+t0)*qvf* &
@@ -497,24 +690,64 @@
            grid%al(i,k,j) = grid%alt(i,k,j) - grid%alb(i,k,j)
         ENDIF
       ENDDO
-
 !  rebalance hydrostatically
 
       DO k  = 2,kte
         grid%ph_1(i,k,j) = grid%ph_1(i,k-1,j) - (1./grid%rdnw(k-1))*(       &
                      (grid%mub(i,j)+grid%mu_1(i,j))*grid%al(i,k-1,j)+ &
                       grid%mu_1(i,j)*grid%alb(i,k-1,j)  )
-                                                   
-        grid%ph_2(i,k,j) = grid%ph_1(i,k,j) 
+
+        grid%ph_2(i,k,j) = grid%ph_1(i,k,j)
         grid%ph0(i,k,j) = grid%ph_1(i,k,j) + grid%phb(i,k,j)
       ENDDO
 
     ENDDO
   ENDDO
 
+
+
+!
+!!  put in preturbation theta (bubble) and recalc density.  note,
+!!  the mass in the column is not changing, so when theta changes,
+!!  we recompute density and geopotential
+!        zrad = 0.5*(grid%ph_1(i,k,j)+grid%ph_1(i,k+1,j)  &
+!                   +grid%phb(i,k,j)+grid%phb(i,k+1,j))/g
+!        zrad = (zrad-1500.)/1500.
+!        RAD=SQRT(xrad*xrad+yrad*yrad+zrad*zrad)
+!!        IF(RAD <= 1.) THEN
+!	call RANDOM_NUMBER(rnd)
+!	  grid%t_1(i,k,j)=grid%t_1(i,k,j)+delt*(rnd-0.5)
+!         !  grid%t_1(i,k,j)=grid%t_1(i,k,j)+delt*COS(.5*PI*RAD)**2
+!           grid%t_2(i,k,j)=grid%t_1(i,k,j)
+!           qvf = 1. + rvovrd*moist(i,k,j,P_QV)
+!           grid%alt(i,k,j) = (r_d/p1000mb)*(grid%t_1(i,k,j)+t0)*qvf* &
+!                        (((grid%p(i,k,j)+grid%pb(i,k,j))/p1000mb)**cvpm)
+!           grid%al(i,k,j) = grid%alt(i,k,j) - grid%alb(i,k,j)
+!!        ENDIF
+!      ENDDO
+!
+!!  rebalance hydrostatically
+!
+!      DO k  = 2,kte
+!        grid%ph_1(i,k,j) = grid%ph_1(i,k-1,j) - (1./grid%rdnw(k-1))*(       &
+!                     (grid%mub(i,j)+grid%mu_1(i,j))*grid%al(i,k-1,j)+ &
+!                      grid%mu_1(i,j)*grid%alb(i,k-1,j)  )
+!                                                   
+!        grid%ph_2(i,k,j) = grid%ph_1(i,k,j) 
+!        grid%ph0(i,k,j) = grid%ph_1(i,k,j) + grid%phb(i,k,j)
+!      ENDDO
+!
+!    ENDDO
+!  ENDDO
+
+!   endif 
+
+endif
+
+! cjw end
+
 !#endif
 
-   IF ( wrf_dm_on_monitor() ) THEN
    write(6,*) ' grid%mu_1 from comp ', grid%mu_1(1,1)
    write(6,*) ' full state sounding from comp, ph, grid%p, grid%al, grid%t_1, qv '
    do k=1,kde-1
@@ -529,7 +762,6 @@
                                       grid%p(1,k,1), grid%al(1,k,1), &
                                       grid%t_1(1,k,1), moist(1,k,1,P_QV)
    enddo
-   ENDIF
 
 ! interp v
 
@@ -543,9 +775,10 @@
     ELSE
       z_at_v = 0.5*(grid%phb(i,1,j)+grid%phb(i,1,j-1))/g
     END IF
+
     p_surf = interp_0( p_in, zk, z_at_v, nl_in )
 
-    DO K = 1, kte-1
+    DO K = 1, kte
       p_level = grid%znu(k)*(p_surf - grid%p_top) + grid%p_top
       grid%v_1(i,k,j) = interp_0( v, p_in, p_level, nl_in )
       grid%v_2(i,k,j) = grid%v_1(i,k,j)
@@ -569,7 +802,7 @@
 
     p_surf = interp_0( p_in, zk, z_at_u, nl_in )
 
-    DO K = 1, kte-1
+    DO K = 1, kte
       p_level = grid%znu(k)*(p_surf - grid%p_top) + grid%p_top
       grid%u_1(i,k,j) = interp_0( u, p_in, p_level, nl_in )
       grid%u_2(i,k,j) = grid%u_1(i,k,j)
@@ -599,7 +832,6 @@
   ENDDO
   ENDDO
 
-  IF ( wrf_dm_on_monitor() ) THEN
   DO k=1,kte-1
     grid%t_base(k) = grid%t_1(1,k,1)
     grid%qv_base(k) = moist(1,k,1,P_QV)
@@ -607,33 +839,220 @@
     grid%v_base(k) = grid%v_1(1,k,1)
     grid%z_base(k) = 0.5*(grid%phb(1,k,1)+grid%phb(1,k+1,1)+grid%ph_1(1,k,1)+grid%ph_1(1,k+1,1))/g
   ENDDO
-  ENDIF
-  CALL wrf_dm_bcast_real( grid%t_base , kte )
-  CALL wrf_dm_bcast_real( grid%qv_base , kte )
-  CALL wrf_dm_bcast_real( grid%u_base , kte )
-  CALL wrf_dm_bcast_real( grid%v_base , kte )
-  CALL wrf_dm_bcast_real( grid%z_base , kte )
+     
+! cjw begin
+SELECT CASE ( model_config_rec%sf_surface_physics(grid%id) )
+
+!cmrwrite:
+!   write(msg,*)'model_config_rec%sf_surface_physics(grid%id)=',model_config_rec%sf_surface_physics(grid%id)
+!   CALL wrf_debug(0,msg)
+
+
+CASE (LSMSCHEME)
+! define soil manually instead of calling process_soil_ideal:
+
+! get soil layers (share/module_soil_pre.F):
+
+   CALL init_soil_depth_2 (grid%zs , grid%dzs , model_config_rec%num_soil_layers)
+
+! define land properties:
+  DO j = jts , MIN(jde-1,jte)
+     DO i = its , MIN(ide-1,ite)
+
+        thtmp   = grid%t_2(i,1,j)+t0
+        ptmp    = grid%p(i,1,j)+grid%pb(i,1,j)
+        temp(1) = thtmp * (ptmp/p1000mb)**rcp
+        thtmp   = grid%t_2(i,2,j)+t0
+        ptmp    = grid%p(i,2,j)+grid%pb(i,2,j)
+        temp(2) = thtmp * (ptmp/p1000mb)**rcp
+        thtmp   = grid%t_2(i,3,j)+t0
+        ptmp    = grid%p(i,3,j)+grid%pb(i,3,j)
+        temp(3) = thtmp * (ptmp/p1000mb)**rcp
+
+        grid%tsk(i,j)=grid%cf1*temp(1)+grid%cf2*temp(2)+grid%cf3*temp(3)
+        grid%tmn(i,j)=grid%tsk(i,j)+model_config_rec%valley_tsk_tmn
+
+
+        DO ll = 1,model_config_rec%num_soil_layers
+           ! constant soil moisture:
+           grid%smois(i,ll,j) = model_config_rec%valley_smois
+           ! logarithmical soil temperature profile:
+           grid%tslb(i,ll,j) = grid%tsk(i,j) + (grid%tmn(i,j) - grid%tsk(i,j)) * &
+                               log(((exp(1.) - 1.)/grid%zs(model_config_rec%num_soil_layers)) * &
+                               grid%zs(ll) + 1.) 
+        ENDDO
+        grid%xland(i,j)    = 1.
+        grid%xice(i,j)     = 0.
+        grid%snow(i,j)     = 0.
+        grid%xlat(i,j)     = model_config_rec%valley_latitude
+        grid%xlong(i,j)    = model_config_rec%valley_longitude
+        grid%lai(i,j)      = model_config_rec%valley_lai
+        grid%vegfra(i,j)   = model_config_rec%valley_vegfra 
+        grid%lu_index(i,j)  = model_config_rec%valley_lu_index
+        grid%canwat(i,j) = model_config_rec%valley_canwat
+        grid%isltyp(i,j) = model_config_rec%valley_isltyp
+        grid%ivgtyp(i,j) = model_config_rec%valley_ivgtyp
+     ENDDO
+  ENDDO
 
-  DO J = jts, min(jde-1,jte)
-  DO I = its, min(ide-1,ite)
-     thtmp   = grid%t_2(i,1,j)+t0
-     ptmp    = grid%p(i,1,j)+grid%pb(i,1,j)
-     temp(1) = thtmp * (ptmp/p1000mb)**rcp
-     thtmp   = grid%t_2(i,2,j)+t0
-     ptmp    = grid%p(i,2,j)+grid%pb(i,2,j)
-     temp(2) = thtmp * (ptmp/p1000mb)**rcp
-     thtmp   = grid%t_2(i,3,j)+t0
-     ptmp    = grid%p(i,3,j)+grid%pb(i,3,j)
-     temp(3) = thtmp * (ptmp/p1000mb)**rcp
-
-!    For LES-CBL, add 5 degrees to the surface temperature!
-!
-!    grid%tsk(I,J)=grid%cf1*temp(1)+grid%cf2*temp(2)+grid%cf3*temp(3)
-     grid%tsk(I,J)=grid%cf1*temp(1)+grid%cf2*temp(2)+grid%cf3*temp(3)+5.
-     grid%tmn(I,J)=grid%tsk(I,J)-0.5
+
+
+
+CASE (SLABSCHEME)
+
+! get soil layers (share/module_soil_pre.F):
+  CALL init_soil_depth_1 (grid%zs , grid%dzs , model_config_rec%num_soil_layers)
+
+! define land properties:
+  DO j = jts , MIN(jde-1,jte)
+     DO i = its , MIN(ide-1,ite)
+
+        thtmp   = grid%t_2(i,1,j)+t0
+        ptmp    = grid%p(i,1,j)+grid%pb(i,1,j)
+        temp(1) = thtmp * (ptmp/p1000mb)**rcp
+        thtmp   = grid%t_2(i,2,j)+t0
+        ptmp    = grid%p(i,2,j)+grid%pb(i,2,j)
+        temp(2) = thtmp * (ptmp/p1000mb)**rcp
+        thtmp   = grid%t_2(i,3,j)+t0
+        ptmp    = grid%p(i,3,j)+grid%pb(i,3,j)
+        temp(3) = thtmp * (ptmp/p1000mb)**rcp
+
+        grid%tsk(i,j)=grid%cf1*temp(1)+grid%cf2*temp(2)+grid%cf3*temp(3)
+        grid%tmn(i,j)=grid%tsk(i,j)+model_config_rec%valley_tsk_tmn
+
+        DO ll = 1,model_config_rec%num_soil_layers
+           ! logarithmical soil temperature profile:
+!           grid%tslb(i,ll,j) = grid%tsk(i,j) + (grid%tmn(i,j) - grid%tsk(i,j)) * &
+!                               log(((exp(1.) -1.)/grid%zs(model_config_rec%num_soil_layers)) * &
+!                               grid%zs(ll) + 1.)
+
+           ! tslb from init_soil_1_ideal (share/module_soil_pre.F)
+           grid%tslb(i,ll,j) = ( grid%tsk(i,j)*(grid%zs(model_config_rec%num_soil_layers)- & 
+                                 grid%zs(ll)) + grid%tmn(i,j)*(grid%zs(ll)-grid%zs(1)) ) / &
+                               ( grid%zs(model_config_rec%num_soil_layers)-grid%zs(1) )
+
+
+        ENDDO
+        grid%xland(i,j)    = 1.
+        grid%xice(i,j)     = 0.
+        grid%snow(i,j)     = 0.
+        grid%xlat(i,j)     = model_config_rec%valley_latitude
+        grid%xlong(i,j)    = model_config_rec%valley_longitude
+        grid%lai(i,j)      = model_config_rec%valley_lai
+        grid%vegfra(i,j)   = model_config_rec%valley_vegfra
+        grid%lu_index(i,j)  = model_config_rec%valley_lu_index
+        grid%canwat(i,j) = model_config_rec%valley_canwat
+        grid%isltyp(i,j) = model_config_rec%valley_isltyp
+        grid%ivgtyp(i,j) = model_config_rec%valley_ivgtyp
+     ENDDO
   ENDDO
+
+!cmr begin : add CLM SCHEME
+CASE (CLMSCHEME)
+! define soil manually instead of calling process_soil_ideal:
+
+! get soil layers (share/module_soil_pre.F):
+
+   CALL init_soil_depth_4 (grid%zs , grid%dzs ,model_config_rec%num_soil_layers)
+!cmrwrite:
+!   write(msg,*)'max zs=',maxval(grid%zs),'max dzs=',maxval(grid%dzs),'num_soil_layers=',model_config_rec%num_soil_layers
+!   CALL wrf_debug(0,msg)
+
+! define land properties:
+  DO j = jts , MIN(jde-1,jte)
+     DO i = its , MIN(ide-1,ite)
+
+        thtmp   = grid%t_2(i,1,j)+t0
+        ptmp    = grid%p(i,1,j)+grid%pb(i,1,j)
+        temp(1) = thtmp * (ptmp/p1000mb)**rcp
+        thtmp   = grid%t_2(i,2,j)+t0
+        ptmp    = grid%p(i,2,j)+grid%pb(i,2,j)
+        temp(2) = thtmp * (ptmp/p1000mb)**rcp
+        thtmp   = grid%t_2(i,3,j)+t0
+        ptmp    = grid%p(i,3,j)+grid%pb(i,3,j)
+        temp(3) = thtmp * (ptmp/p1000mb)**rcp
+
+        grid%tsk(i,j)=grid%cf1*temp(1)+grid%cf2*temp(2)+grid%cf3*temp(3)
+        grid%tmn(i,j)=grid%tsk(i,j)+model_config_rec%valley_tsk_tmn
+
+        DO ll = 1,model_config_rec%num_soil_layers
+           ! constant soil moisture:
+           grid%smois(i,ll,j) = model_config_rec%valley_smois
+           ! logarithmical soil temperature profile:
+           grid%tslb(i,ll,j) = grid%tsk(i,j) + (grid%tmn(i,j) - grid%tsk(i,j)) * &
+                               log(((exp(1.) - 1.)/grid%zs(model_config_rec%num_soil_layers)) * &
+                               grid%zs(ll) + 1.) 
+!add more clm variables? -> if Initialized values are overwritten in clm again
+!           grid%t_grnd(i,ll,j)     = grid%tslb(i,1,j)
+!           grid%t_veg(i,ll,j)     = grid%tslb(i,1,j)
+!           grid%h2ocan(i,ll,j)     = model_config_rec%valley_smois
+!           grid%h2ocan_col(i,ll,j) = 1
+!           grid%h2osno(i,ll,j)      = 0.
+! also albedo?           grid%albedosubgrid(i,m,j) =
+
+        ENDDO
+        grid%xland(i,j)    = 1.
+        grid%xice(i,j)     = 0.
+        grid%snow(i,j)     = 0.
+        grid%xlat(i,j)     = model_config_rec%valley_latitude
+        grid%xlong(i,j)    = model_config_rec%valley_longitude
+        grid%lai(i,j)      = model_config_rec%valley_lai
+        grid%vegfra(i,j)   = model_config_rec%valley_vegfra 
+        grid%lu_index(i,j)  = model_config_rec%valley_lu_index
+        grid%canwat(i,j) = model_config_rec%valley_canwat
+        grid%isltyp(i,j) = model_config_rec%valley_isltyp
+        grid%ivgtyp(i,j) = model_config_rec%valley_ivgtyp
+     ENDDO
+   ENDDO
+!cmrwrite:
+   write(msg,*) 'grid%tslb(20,1:3,20)',grid%tslb(20,1,20),grid%tsk(20,20),grid%tmn(20,20)
+   CALL wrf_debug(0,msg)
+   write(msg,*) 'grid%tslb(1,1:3,1)',grid%tslb(1,1,1),grid%tslb(1,2,1),grid%tslb(1,3,1)
+   CALL wrf_debug(0,msg)
+   write(msg,*) 'maxval(grid%h20can)',maxval(grid%h2ocan(:,1,:)),maxval(grid%h2ocan(:,2,:))
+   CALL wrf_debug(0,msg)
+!   write(msg,*) 'grid%tmn',maxval(grid%tmn)
+!   CALL wrf_debug(0,msg)
+!cmr end
+
+CASE DEFAULT
+
+! define land properties:
+  DO j = jts , MIN(jde-1,jte)
+     DO i = its , MIN(ide-1,ite)
+
+        thtmp   = grid%t_2(i,1,j)+t0
+        ptmp    = grid%p(i,1,j)+grid%pb(i,1,j)
+        temp(1) = thtmp * (ptmp/p1000mb)**rcp
+        thtmp   = grid%t_2(i,2,j)+t0
+        ptmp    = grid%p(i,2,j)+grid%pb(i,2,j)
+        temp(2) = thtmp * (ptmp/p1000mb)**rcp
+        thtmp   = grid%t_2(i,3,j)+t0
+        ptmp    = grid%p(i,3,j)+grid%pb(i,3,j)
+        temp(3) = thtmp * (ptmp/p1000mb)**rcp
+
+        grid%tsk(i,j)=grid%cf1*temp(1)+grid%cf2*temp(2)+grid%cf3*temp(3)
+        grid%tmn(i,j)=grid%tsk(i,j)+model_config_rec%valley_tsk_tmn
+
+        grid%xland(i,j)    = 1.
+        grid%xice(i,j)     = 0.
+        grid%snow(i,j)     = 0.
+        grid%xlat(i,j)     = model_config_rec%valley_latitude
+        grid%xlong(i,j)    = model_config_rec%valley_longitude
+        grid%lai(i,j)      = model_config_rec%valley_lai
+        grid%vegfra(i,j)   = model_config_rec%valley_vegfra
+        grid%lu_index(i,j)  = model_config_rec%valley_lu_index
+        grid%canwat(i,j) = model_config_rec%valley_canwat
+        grid%isltyp(i,j) = model_config_rec%valley_isltyp
+        grid%ivgtyp(i,j) = model_config_rec%valley_ivgtyp
+     ENDDO
   ENDDO
 
+END SELECT
+! cjw end
+
+  RETURN
+
  END SUBROUTINE init_domain_rk
 
    SUBROUTINE init_module_initialize
@@ -673,7 +1092,7 @@
       logical dry
 
       integer n
-      parameter(n=1000)
+      parameter(n=3000)
       logical debug
       parameter( debug = .true.)
 
@@ -775,7 +1194,7 @@
 
 
         do k=1,nl
-
+! For the seabreeze case, we can hard-wire the winds and qv fields 
           zk(k) = h_input(k)
           p(k) = pm_input(k)
           p_dry(k) = p_input(k)
diff -Nru WRFV3.5/job_compile_wrf WRFV3.5_MR/job_compile_wrf
--- WRFV3.5/job_compile_wrf	1970-01-01 01:00:00.000000000 +0100
+++ WRFV3.5_MR/job_compile_wrf	2014-12-17 11:53:56.254450000 +0100
@@ -0,0 +1,13 @@
+#!/bin/bash
+#$ -o output.dat
+#$ -e error.dat
+#$ -cwd
+#$ -l h_vmem=8G,h_rt=02:00:00
+#$ -j yes
+#$ -R y
+#$ -N wrf_compile
+
+WRF_CASE='em_les'
+
+./compile $WRF_CASE >& compile.log
+
diff -Nru WRFV3.5/phys/module_sf_clm.F WRFV3.5_MR/phys/module_sf_clm.F
--- WRFV3.5/phys/module_sf_clm.F	2013-04-17 17:12:47.000000000 +0200
+++ WRFV3.5_MR/phys/module_sf_clm.F	2014-12-17 11:53:55.877462524 +0100
@@ -870,22 +870,26 @@
 ! (18) lava
 ! (19) white-sand
 !----------------------------------------------------------------------------
-  data (plant(i,1),i=1,24) / 0,  15,  15,  15,  15,  15, &
-                            14,   9,   9,  14,   7,   3, &
-                             4,   1,   1,   0,   0,   4, &
+
+!cmr: change settings for plant types: 
+! discard plant types 1-6 and define own plant types!
+! i just want to use single pft 13,12,1,3,5 and 8
+  data (plant(i,1),i=1,24) / 1,   2,   3,   4,   5,   6, &
+                             7,   8,   9,  10,  11,  12, &
+                            13,  14,  15,  16,   0,   4, &
                             11,  11,   2,  11,  11,   0/
-  data (cover(i,1),i=1,24) /100.,  85.,  85.,  85.,  50.,  40., &
-                             60.,  80.,  50.,  70.,  75.,  50., &
-                             95.,  75.,  37., 100., 100.,  80., &
+  data (cover(i,1),i=1,24) /100., 100., 100., 100., 100., 100., &
+                            100., 100., 100., 100., 100., 100., &
+                            100., 100., 100., 100., 100.,  80., &
                              10.,  30.,  13.,  20.,  10., 100./
 
-  data (plant(i,2),i=1,24) / 0,   0,   0,   0,  14,   3, &
-                            13,   0,  14,   6,   0,   0, &
-                             0,   0,   7,   0,   0,   0, &
+  data (plant(i,2),i=1,24) / 0,   0,   0,   0,   0,   0, &
+                             0,   0,   0,   0,   0,   0, &
+                             0,   0,   0,   0,   0,   0, &
                              0,  12,   3,  12,  12,   0/
-  data (cover(i,2),i=1,24) /  0.,  15.,  15.,  15.,  35.,  30., &
-                             20.,  20.,  30.,  30.,  25.,  50., &
-                              5.,  25.,  37.,   0.,   0.,  20., &
+  data (cover(i,2),i=1,24) /  0.,   0.,   0.,   0.,   0.,   0., &
+                              0.,   0.,   0.,   0.,   0.,   0., &
+                              0.,   0.,   0.,   0.,   0.,   0., &
                              90.,  30.,  13.,  20.,  10.,   0./
 
   data (plant(i,3),i=1,24) / 0,   0,   0,   0,   0,   0, &
@@ -893,9 +897,9 @@
                              0,   0,   0,   0,   0,   0, &
                              0,   0,  10,   0,   0,   0/
 
-  data (cover(i,3),i=1,24) /  0.,   0.,   0.,   0.,  15.,  30., &
-                             20.,   0.,  20.,   0.,   0.,   0., &
-                              0.,   0.,  26.,   0.,   0.,   0., &
+  data (cover(i,3),i=1,24) /  0.,   0.,   0.,   0.,   0.,   0., &
+                              0.,   0.,   0.,   0.,   0.,   0., &
+                              0.,   0.,   0.,   0.,   0.,   0., &
                               0.,  40.,  24.,  60.,  80.,   0./
 
   data (plant(i,4),i=1,24) / 0,   0,   0,   0,   0,   0, &
@@ -948,33 +952,47 @@
 
 
     data (lai(1,i),i=1,12) &
-        /4.1,4.2,4.6,4.8,4.9,5.0,4.8,4.7,4.6,4.2,4.0,4.0/
+        /4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0/
+!cmr set LAI all equal        /4.1,4.2,4.6,4.8,4.9,5.0,4.8,4.7,4.6,4.2,4.0,4.0/
     data (lai(2,i),i=1,12) &
-        /4.1,4.2,4.6,4.8,4.9,5.0,4.8,4.7,4.6,4.2,4.0,4.0/
+        /4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0/
+!cmr set LAI all equal        /4.1,4.2,4.6,4.8,4.9,5.0,4.8,4.7,4.6,4.2,4.0,4.0/
     data (lai(3,i),i=1,12) &
         /0.0,0.0,0.0,0.6,1.2,2.0,2.6,1.7,1.0,0.5,0.2,0.0/
     data (lai(4,i),i=1,12) &
-        /4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5/
+        /4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0/
+!cmr        /4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5/
     data (lai(5,i),i=1,12) &
-        /4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5/
+        /4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0/
+!cmr        /4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5/
     data (lai(6,i),i=1,12) &
-        /0.8,0.7,0.4,0.5,0.5,0.7,1.7,3.0,2.5,1.6,1.0,1.0/
+        /4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0/
+!cmr        /0.8,0.7,0.4,0.5,0.5,0.7,1.7,3.0,2.5,1.6,1.0,1.0/
     data (lai(7,i),i=1,12) &
-        /0.0,0.0,0.3,1.2,3.0,4.7,4.5,3.4,1.2,0.3,0.0,0.0/
+        /4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0/
+!cmr        /0.0,0.0,0.3,1.2,3.0,4.7,4.5,3.4,1.2,0.3,0.0,0.0/
     data (lai(8,i),i=1,12) &
-        /0.0,0.0,0.3,1.2,3.0,4.7,4.5,3.4,1.2,0.3,0.0,0.0/
+        /4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0/
+!cmr        /0.0,0.0,0.3,1.2,3.0,4.7,4.5,3.4,1.2,0.3,0.0,0.0/
     data (lai(9,i),i=1,12) &
-        /1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0/
+        /4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0/
+!cmr        /1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0/
     data (lai(10,i),i=1,12) &
-        /0.9,0.8,0.2,0.2,0.0,0.0,0.0,0.2,0.4,0.5,0.6,0.8/
+        /4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0/
+!cmr        /0.9,0.8,0.2,0.2,0.0,0.0,0.0,0.2,0.4,0.5,0.6,0.8/
     data (lai(11,i),i=1,12) &
-        /0.0,0.0,0.0,0.0,0.0,0.2,1.4,1.2,0.0,0.0,0.0,0.0/
+        /4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0/
+!cmr        /0.0,0.0,0.0,0.0,0.0,0.2,1.4,1.2,0.0,0.0,0.0,0.0/
     data (lai(12,i),i=1,12) &
-        /0.4,0.5,0.6,0.7,1.2,3.0,3.5,1.5,0.7,0.6,0.5,0.4/
+        /4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0/
+!cmr        /0.4,0.5,0.6,0.7,1.2,3.0,3.5,1.5,0.7,0.6,0.5,0.4/
     data (lai(13,i),i=1,12) &
-        /0.0,0.0,0.0,0.0,0.0,0.2,1.4,1.2,0.0,0.0,0.0,0.0/
+        /4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0/
+!cmr       /2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0/
+!cmr set LAI all equal        /0.0,0.0,0.0,0.0,0.0,0.2,1.4,1.2,0.0,0.0,0.0,0.0/
     data (lai(14,i),i=1,12) &
-        /0.4,0.5,0.6,0.7,1.2,3.0,3.5,1.5,0.7,0.6,0.5,0.4/
+        /4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0/
+!cmr set LAI all equal        /0.4,0.5,0.6,0.7,1.2,3.0,3.5,1.5,0.7,0.6,0.5,0.4/
     data (lai(15,i),i=1,12) &
         /0.0,0.0,0.0,0.0,1.0,2.0,3.0,3.0,1.5,0.0,0.0,0.0/
     data (lai(16,i),i=1,12) &
@@ -1419,6 +1437,7 @@
    real(r8), pointer :: dewmx(:)                !Maximum allowed dew [mm]
    real(r8), pointer :: rssun(:)                !sunlit stomatal resistance (s/m)
    real(r8), pointer :: rssha(:)                !shaded stomatal resistance (s/m)
+   real(r8), pointer :: rs_mr(:)                !shaded stomatal resistance (s/m) for export !cmr
    real(r8), pointer :: laisun(:)               !sunlit projected leaf area index
    real(r8), pointer :: laisha(:)               !shaded projected leaf area index
    real(r8), pointer :: btran(:)                !transpiration wetness factor (0 to 1)
@@ -1495,6 +1514,14 @@
    ! Adding isotope code
    real(r8), pointer :: cisun(:)       !sunlit intracellular CO2 (Pa)
    real(r8), pointer :: cisha(:)       !shaded intracellular CO2 (Pa)
+   real(r8), pointer :: ci_mr(:)       !shaded intracellular CO2 (Pa) for export !cmr
+   real(r8), pointer :: rb_mr(:)       ! !cmr
+   real(r8), pointer :: btran_mr(:)       ! !cmr
+   real(r8), pointer :: apar_mr(:)       ! !cmr
+   real(r8), pointer :: sla_mr(:)       ! !cmr
+   real(r8), pointer :: vcmx_mr(:)       ! !cmr
+   real(r8), pointer :: svpts_mr(:)       ! !cmr
+   real(r8), pointer :: eah_mr(:)       ! !cmr
 #if (defined C13)
    real(r8), pointer :: alphapsnsun(:) !sunlit 13c fractionation ([])
    real(r8), pointer :: alphapsnsha(:) !shaded 13c fractionation ([])
@@ -1995,7 +2022,31 @@
    real(r8), pointer :: psnsun(:)         !sunlit leaf photosynthesis (umol CO2 /m**2/ s)
    real(r8), pointer :: psnsha(:)         !shaded leaf photosynthesis (umol CO2 /m**2/ s)
    real(r8), pointer :: fpsn(:)           !photosynthesis (umol CO2 /m**2 /s)
-   real(r8), pointer :: fco2(:)           !net CO2 flux (umol CO2 /m**2 /s) [+ = to atm]
+!cmr define more variables 
+   real(r8), pointer :: psnsun2(:)         !sunlit leaf photosynthesis (umol CO2 /m**2/ s)
+   real(r8), pointer :: psnsha2(:)         !shaded leaf photosynthesis (umol CO2 /m**2/ s)
+   real(r8), pointer :: fpsn_mn(:)           !photosynthesis (umol CO2 /m**2 /s)
+   real(r8), pointer :: psnsun3(:)         !sunlit leaf photosynthesis (umol CO2 /m**2/ s)
+   real(r8), pointer :: psnsun4(:)         !sunlit leaf photosynthesis (umol CO2 /m**2/ s)
+   real(r8), pointer :: psnsha3(:)         !shaded leaf photosynthesis (umol CO2 /m**2/ s)
+   real(r8), pointer :: psnsha4(:)         !shaded leaf photosynthesis (umol CO2 /m**2/ s)
+   real(r8), pointer :: fpsn_mx(:)           !photosynthesis (umol CO2 /m**2 /s)
+   real(r8), pointer :: fpsn_nf(:)           !photosynthesis (umol CO2 /m**2 /s)
+   real(r8), pointer :: wc(:)      ! rubisco limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: wj(:)      ! light limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: we(:)      ! export limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: wcsun(:)      ! rubisco limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: wjsun(:)      ! light limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: wesun(:)      ! export limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: wcsha(:)      ! rubisco limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: wjsha(:)      ! light limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: wesha(:)      ! export limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: reco(:)           !respiration CO2 flux (umol CO2 /m**2 /s) [+ =to atm]
+   real(r8), pointer :: reco_gpp(:)           !respiration CO2 flux (umol CO2 /m**2 /s) [+ =to atm]
+   real(r8), pointer :: reco_gppmn(:)           !respiration CO2 flux (umol CO2 /m**2 /s) [+ =to atm]
+   real(r8), pointer :: reco_gppmx(:)           !respiration CO2 flux (umol CO2 /m**2 /s) [+ =to atm]
+   real(r8), pointer :: fpsn_noslp(:)           !photosynthesis (umol CO2 /m**2 /s)
+!cmr end
    ! new variables for CN code
    ! gap mortality fluxes
    real(r8), pointer :: m_leafc_to_litter(:)                 ! leaf C mortality (gC/m2/s)
@@ -3741,7 +3792,10 @@
   use clm_varcon, only: hvap, hsub,tfrz, vkc, sb  ,&
                         snowage_drdt0,ndep,organic,fmax,efisop
   use module_cam_support, only: endrun
-  
+!cmr use namelist parameters 
+  USE module_configure, only: grid_config_rec_type
+!cmr end
+ 
 !
 CONTAINS
 !
@@ -3842,13 +3896,16 @@
                 ,dwt_frootn_to_litr1n,dwt_frootn_to_litr2n, dwt_frootn_to_litr3n &
                 , dwt_livecrootn_to_cwdn,dwt_deadcrootn_to_cwdn,retransn &
 #endif
-                 )
+                ,fco2,fco2mn,fco2mx,fco2nf,reco,reco_gpp,reco_gppmn,reco_gppmx,fpsn,fpsn_mn,fpsn_mx,fpsn_nf,fpsn_noslp & 
+                ,co2_clm,co2_clm2,co2_clm3,wj,we,wc,ci_mr,rs_mr, &
+                rb_mr,btran_mr,apar_mr,sla_mr,vcmx_mr,svpts_mr,eah_mr,slope  & !cmr 
+                ,valley_CO2pft2,valley_CO2backgr & !cmr  
+              )
 
 
   USE module_date_time
   USE module_sf_urban, only: urban
   USE module_configure
-
   implicit none
 
   integer,  intent(in)       ::     ids,ide, jds,jde, kds,kde,  &
@@ -3872,7 +3929,7 @@
                    ,canwat     ,acsnom     ,acsnow,   emiss, z0
 
   real,dimension(ims:ime,jms:jme ),intent(in) ::&
-                 vegfra, tmn,shdmin,shdmax
+                 vegfra, tmn,shdmin,shdmax,slope !cmr added slope
 
   real,dimension(ims:ime,jms:jme ),intent(in) ::&
                    qgh,chs,chs2
@@ -3881,6 +3938,12 @@
   logical :: found = .false.
   integer,   dimension(ims:ime,jms:jme ),intent(inout) :: numc,nump
   real,  dimension(ims:ime,jms:jme ),intent(inout) :: soiflx,sabv,sabg,lwup,t2m_max,t2m_min
+  real,  dimension(ims:ime,jms:jme ),intent(out) :: reco,reco_gpp,reco_gppmn,reco_gppmx,fpsn,fpsn_mn,fpsn_mx,fpsn_nf,fpsn_noslp,wj,we,wc, &
+                                                    ci_mr,rs_mr,rb_mr,btran_mr,apar_mr,sla_mr,vcmx_mr,svpts_mr,eah_mr !cmr
+  real,  dimension(ims:ime,jms:jme ),intent(out) :: fco2,fco2mn,fco2mx,fco2nf !cmr
+  REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT(IN ) :: co2_clm,co2_clm2,co2_clm3 !cmr
+  INTEGER :: valley_CO2pft2 !cmr
+  REAL :: valley_CO2backgr !cmr
   integer,  dimension(ims:ime,1:maxpatch,jms:jme ) :: snl,snl1
   real,  dimension(ims:ime,1:maxpatch,jms:jme ),intent(inout) ::  &
                 snowdp,wtc,wtp,h2osno,t_grnd,t_veg,         &
@@ -3993,6 +4056,27 @@
   real(r8) :: qdnxy_buf
   real(r8) :: soiflx_buf
   real(r8) :: sabv_buf
+  real(r8) :: fpsn_buf !cmr
+  real(r8) :: fpsn_mn_buf !cmr
+  real(r8) :: fpsn_mx_buf !cmr
+  real(r8) :: fpsn_nf_buf !cmr
+  real(r8) :: reco_buf !cmr
+  real(r8) :: reco_gpp_buf !cmr
+  real(r8) :: reco_gppmn_buf !cmr
+  real(r8) :: reco_gppmx_buf !cmr
+  real(r8) :: wj_buf !cmr
+  real(r8) :: we_buf !cmr
+  real(r8) :: wc_buf !cmr
+  real(r8) :: ci_buf !cmr
+  real(r8) :: rs_buf !cmr
+  real(r8) :: rb_buf !cmr
+  real(r8) :: btran_buf !cmr
+  real(r8) :: apar_buf !cmr
+  real(r8) :: sla_buf !cmr
+  real(r8) :: vcmx_buf !cmr
+  real(r8) :: svpts_buf !cmr
+  real(r8) :: eah_buf !cmr
+  real,dimension(4) :: atm_co2 !cmr
   real(r8) :: sabg_buf
   real(r8) :: lwup_buf
   real(r8) :: znt_buf
@@ -4221,7 +4305,7 @@
  character*256 :: msg
  real :: mh_urb,stdh_urb,lp_urb,hgt_urb,frc_urb,lb_urb,check
  real, dimension(4) :: lf_urb
- 
+
 ! ----------------------------------------------------------------------
    call clm_varpar_mod
 
@@ -4272,9 +4356,6 @@
   mbdate = myrs*10000 + mons*100 + mdays
 
 
-!write(6,*) 'at nstep=',nstep,'snowage_drdt0(1,31,8)=',snowage_drdt0(1,31,8)
-
-
   do j=jts,jte
 
    do i=its,ite
@@ -4283,9 +4364,9 @@
       else
         lndmsk = 0
       end if
-
   
-    if(lndmsk == 1) then
+
+      if(lndmsk == 1) then
       qsfxy_buf       = qsfxy(i,j)
       qdnxy_buf       = qdnxy(i,j)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -4319,7 +4400,11 @@
       forc_txy_buf   = forc_txy(i,1,j)
       forc_uxy_buf   = forc_uxy(i,1,j)
       forc_vxy_buf   = forc_vxy(i,1,j)
-      forc_qxy_buf   = forc_qxy(i,1,j)
+!cmr wind set to constant value
+!      forc_uxy_buf   = 5.  !forc_uxy(i,1,j)
+!      forc_vxy_buf   = 0.  !forc_vxy(i,1,j)
+!cmr end
+      forc_qxy_buf   = forc_qxy(i,1,j)/(1.0+forc_qxy(i,1,j)) !cmr bugfix in wrf3.5.1
       zgcmxy_buf     = zgcmxy(i,1,j)
       prec_buf       = prec(i,j)/dtt ! mm/s
       flwdsxy_buf    = flwdsxy(i,j)
@@ -4340,7 +4425,43 @@
       sabv_buf       = 0.0
       sabg_buf       = 0.0
       lwup_buf       = 0.0
-
+!cmr begin
+      fpsn(i,j) = 0.0   
+      fpsn_mn(i,j) = 0.0   
+      fpsn_mx(i,j) = 0.0   
+      fpsn_nf(i,j) = 0.0   
+      fpsn_noslp(i,j) = 0.0   
+      fco2(i,j) = 0.0
+      fco2mn(i,j) = 0.0
+      fco2mx(i,j) = 0.0
+      fco2nf(i,j) = 0.0
+      reco(i,j) = 0.0
+      reco_gpp(i,j) = 0.0
+      reco_gppmn(i,j) = 0.0
+      reco_gppmx(i,j) = 0.0
+      wj(i,j) = 0.0
+      we(i,j) = 0.0
+      wc(i,j) = 0.0 
+      ci_mr(i,j) = 0.0
+      rs_mr(i,j) = 0.0
+! rb_mr,btran_mr,apar_mr,sla_mr,vcmx_mr
+      rb_mr(i,j) = 0.0
+      btran_mr(i,j) = 0.0
+      apar_mr(i,j) = 0.0
+      sla_mr(i,j) = 0.0
+      vcmx_mr(i,j) = 0.0
+      svpts_mr(i,j) = 0.0
+      eah_mr(i,j) = 0.0
+      fpsn_buf = 0.0      
+      fpsn_mn_buf = 0.0      
+      fpsn_mx_buf = 0.0      
+      fpsn_nf_buf = 0.0      
+      reco_buf = 0.0
+      reco_gpp_buf = 0.0
+      reco_gppmn_buf = 0.0
+      reco_gppmx_buf = 0.0
+!cmr end
+    
      swvisdir_buf = swvisdir(i,j)
      swvisdif_buf = swvisdif(i,j)
      swnirdir_buf = swnirdir(i,j)
@@ -4457,14 +4578,27 @@
 
       t_grnd_buf(m)     = t_grnd(i,m,j)
       t_veg_buf(m)      = t_veg(i,m,j)
+!cmr: the following variables are not initializedwith canwat, it could be done manually further
+!     down in clminit  
       h2ocan_buf(m)     = h2ocan(i,m,j)
       h2ocan_col_buf(m) = h2ocan_col(i,m,j)
       h2osno_buf(m)     = h2osno(i,m,j)
+!cmr
       albedosubgrid_buf(m) = albedosubgrid(i,m,j)
       lhsubgrid_buf(m)  = lhsubgrid(i,m,j)
       hfxsubgrid_buf(m) = hfxsubgrid(i,m,j)
       lwupsubgrid_buf(m)= lwupsubgrid(i,m,j)
       q2subgrid_buf(m)  = q2subgrid(i,m,j)
+
+
+!cmrwrite
+!   write(msg,*) 'cmr: before clm:',t_grnd(i,m,j),t_veg(i,m,j),h2ocan(i,m,j)
+!   CALL CLMDebug(msg)
+!   write(msg,*) h2ocan_col(i,m,j),h2osno(i,m,j),albedosubgrid(i,m,j)
+!   CALL CLMDebug(msg)
+!   write(msg,*) lhsubgrid(i,m,j),hfxsubgrid(i,m,j),lwupsubgrid(i,m,j),q2subgrid(i,m,j)
+!   CALL CLMDebug(msg)
+
 !ylu 01/14/09
       sabvsubgrid_buf(m) = sabvsubgrid(i,m,j)
       sabgsubgrid_buf(m) = sabgsubgrid(i,m,j)
@@ -4624,8 +4758,20 @@
       retransn_buf(m)               = retransn(i,m,j)
 #endif
     end do !!!!!!!!!!!!!!!!! m=1, maxpatch
-       
-   !  if(lndmsk  == 1) then
+
+!cmr: need to link CO2_BIO (=co2_clm) from wrf chem to CLM here
+      atm_co2(1) = co2_clm(i,1,j)*1e-06 ! CO2 concentration with feedback 
+      atm_co2(2) = co2_clm2(i,1,j)*1e-06 ! CO2 concentration highest gpp and lowest reco 
+      atm_co2(3) = co2_clm3(i,1,j)*1e-06 ! CO2 concentration lowest gpp and highest reco 
+      atm_co2(4) = valley_CO2backgr*1e-06 ! no feedback, using background concentration here 
+   write(msg,*) 'atm_co2(1)=',atm_co2(1),'atm_co2(2)=',atm_co2(2),'atm_co2(3)=',atm_co2(3)
+   CALL CLMDebug(msg)
+!   write(msg,*) 'valley_CO2backgr=',valley_CO2backgr
+!   CALL wrf_debug(0,msg)
+!cmr end 
+
+     
+    ! if(lndmsk  == 0) then 
 
           call clm(forc_txy_buf        ,forc_uxy_buf           ,forc_vxy_buf    &
                   ,forc_qxy_buf        ,zgcmxy_buf             ,prec_buf        &
@@ -4690,8 +4836,14 @@
                 ,dwt_frootn_to_litr1n_buf,dwt_frootn_to_litr2n_buf, dwt_frootn_to_litr3n_buf &
                 , dwt_livecrootn_to_cwdn_buf,dwt_deadcrootn_to_cwdn_buf,retransn_buf &                                                 
 #endif
-                  )
+                ,fpsn_buf,fpsn_mn_buf,fpsn_mx_buf,fpsn_nf_buf,reco_buf,reco_gpp_buf,reco_gppmn_buf,reco_gppmx_buf & 
+                ,atm_co2,wj_buf,we_buf,wc_buf,ci_buf,rs_buf  & !cmr
+                ,rb_buf,btran_buf,apar_buf,sla_buf,vcmx_buf,svpts_buf,eah_buf  )
                  
+!cmrwrite
+   write(msg,*) 'cmr: after clm: maxval(smois)',smois(i,j),'canwat',canwat(i,j)
+   CALL CLMDebug(msg)
+
                  if(albxy_buf ==  1) albxy_buf = 0.991
 
                   albxy(i,j)          = albxy_buf
@@ -4708,14 +4860,19 @@
                      tslb (i,k,j)     = sum(t_soisno_buf(1:numc(i,j),k)*wtc_buf(1:numc(i,j)))
                   end do !over levels
               end if
-                  call CLMDebug('get tslb')
+
+!cmrwrite
+   write(msg,*) 'cmr: after clm: maxval(smois)',smois(i,j),'canwat',canwat(i,j)
+   CALL CLMDebug(msg)
+
+   call CLMDebug('get tslb')
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
                   tsxy(i,j)           = tsxy_buf
                   qsfxy(i,j)          = qsfxy_buf
                   qdnxy(i,j)          = qdnxy_buf
                   soiflx(i,j)         = soiflx_buf
-                  sabv(i,j)           = sabv_buf
+                  sabv(i,j)           = sabv_buf 
                   sabg(i,j)           = sabg_buf
                   lwup(i,j)           = lwup_buf
                   znt(i,j)            = znt_buf
@@ -4726,6 +4883,35 @@
                   alswnirdif(i,j)     = alswnirdif_buf
 
                   t2clm(i,j)       = trefxy_buf
+
+!cmr write out photosynthesis
+                  fpsn(i,j)           = fpsn_buf*(1/cos(slope(i,j)))
+                  fpsn_mn(i,j)          = fpsn_mn_buf*(1/cos(slope(i,j)))
+                  fpsn_mx(i,j)          = fpsn_mx_buf*(1/cos(slope(i,j)))
+                  fpsn_nf(i,j)          = fpsn_nf_buf*(1/cos(slope(i,j)))
+                  fpsn_noslp(i,j)     = fpsn_buf
+                  reco(i,j)           = reco_buf*(1/cos(slope(i,j)))
+                  reco_gpp(i,j)       = reco_gpp_buf*(1/cos(slope(i,j)))
+                  reco_gppmn(i,j)       = reco_gppmn_buf*(1/cos(slope(i,j)))
+                  reco_gppmx(i,j)       = reco_gppmx_buf*(1/cos(slope(i,j)))
+                  fco2(i,j)           = reco_gpp(i,j)-fpsn(i,j) 
+                  fco2mn(i,j)          = reco_gppmn(i,j)-fpsn_mx(i,j) !adding lowest reco and (most negative) max fpsn
+                  fco2mx(i,j)          = reco_gppmx(i,j)-fpsn_mn(i,j) !adding highest reco and (least neg.) min fpsn
+                  fco2nf(i,j)          = reco_gpp(i,j)-fpsn_nf(i,j) 
+                  wj(i,j)             = wj_buf*(1/cos(slope(i,j)))
+                  we(i,j)             = we_buf*(1/cos(slope(i,j)))
+                  wc(i,j)             = wc_buf*(1/cos(slope(i,j)))
+                  ci_mr(i,j)          = ci_buf
+                  rs_mr(i,j)          = rs_buf
+                  rb_mr(i,j)          = rb_buf
+                  btran_mr(i,j)          = btran_buf
+                  apar_mr(i,j)          = apar_buf
+                  sla_mr(i,j)          = sla_buf
+                  vcmx_mr(i,j)          = vcmx_buf
+                  svpts_mr(i,j)          = svpts_buf
+                  eah_mr(i,j)          = eah_buf
+!cmr end
+
 !Accumulate T2 MAX/MIN between history interval --Yaqiong Lu
                   if(mod(dt*(nstep-1),60.*history_interval)==0) then 
                     t2m_max(i,j) = 0.0
@@ -5010,6 +5196,10 @@
 
               end do !!!!!!!!!!!!! m = 1, maxpatch
       end if
+
+      
+
+      
         call CLMDebug('good before call urban')
         IF (sf_urban_physics == 1 ) THEN                                              ! Beginning of UCM CALL if block
 !--------------------------------------
@@ -5198,6 +5388,7 @@
   end do ! of i loop
   end do ! of j loop
 
+
    do i=its,ite
     do j=jts,jte
      do m=1,maxpatch
@@ -5372,6 +5563,8 @@
    LOGICAL                   :: opened
 
    integer                   :: lu_unit
+   
+   character*256 :: msg !cmr 
 
    call CLMDebug('Now in clminit.')
 
@@ -5492,8 +5685,19 @@
 !------------------------------------------------------------------------------
           DO j = jts,jtf
           DO i = its,itf
-
-
+!cmr initialize CLM soil temperature to 10°C and total soil moisture to 1 -> will need to use a realistic T profile
+!              tslb(i,:,j)=283.16 
+!              tslb(i,1,j)=285.8
+!              tslb(i,2,j)=286.1
+!              tslb(i,3,j)=286.6
+!              tslb(i,4,j)=287.0
+!              tslb(i,5,j)=286.7
+!              tslb(i,6,j)=285.1
+!              tslb(i,7,j)=283.7
+!              tslb(i,8,j)=282.1
+!              tslb(i,9,j)=280.4
+!              tslb(i,10,j)=279.5
+!cmr              smois(i,:,j)=0.3 !cmr smois
           if((xland(i,j)-1.5).ge.0.)then
 
              If(xice(i,j).eq.1)print*,' SEA-ICE AT WATER POINT, i=',i,'j=',j
@@ -5717,6 +5921,9 @@
           do j=jts,jtf
               h2ocan(i,:,j) = 0.0
               h2ocan_col(i,:,j) = 0.0
+!cmr initialized canwat but decreased to zero in 2h anyway
+!              h2ocan(i,:,j) = smois(i,:,j)
+!              h2ocan_col(i,:,j) = smois(i,:,j)
               sfcrunoff(i,j) = 0.0 
               udrunoff(i,j) = 0.0
           end do
@@ -5945,6 +6152,14 @@
       end do
       end do
 
+!cmrwrite
+   write(msg,*) 'cmr: in clminit:smois',maxval(smois),'h2osoi_vol1',maxval(h2osoi_vol1),'h2osoi_liq1',maxval(h2osoi_liq1),&
+             'h2osoi_ice1',maxval(h2osoi_ice1),'dzs(1)',dzs(1),'t_soisno1',maxval(t_soisno1)
+   CALL CLMDebug(msg)
+   write(msg,*) 'cmr: in clminit:max_minval(sh2o)',maxval(sh2o),minval(sh2o)
+   CALL CLMDebug(msg)
+!cmr
+
    call CLMDebug('clminit done')
 !------------------------------------------------------------------------------
  END SUBROUTINE clminit
@@ -6282,6 +6497,10 @@
   IMPLICIT NONE
   CHARACTER*(*), str
 
+!cmrwrite uncomment if you need to debug
+CALL wrf_debug(1,str)
+!cmr end
+
 #if (defined DEBUGCLM)
   print*, TRIM(str)
   call flush(6)
@@ -7208,6 +7427,7 @@
     allocate(pps%dewmx(beg:end))
     allocate(pps%rssun(beg:end))
     allocate(pps%rssha(beg:end))
+    allocate(pps%rs_mr(beg:end)) !cmr
     allocate(pps%laisun(beg:end))
     allocate(pps%laisha(beg:end))
     allocate(pps%btran(beg:end))
@@ -7283,6 +7503,14 @@
     ! Adding isotope code
     allocate(pps%cisun(beg:end))
     allocate(pps%cisha(beg:end))
+    allocate(pps%ci_mr(beg:end)) !cmr
+    allocate(pps%rb_mr(beg:end)) !cmr
+    allocate(pps%btran_mr(beg:end)) !cmr
+    allocate(pps%apar_mr(beg:end)) !cmr
+    allocate(pps%sla_mr(beg:end)) !cmr
+    allocate(pps%vcmx_mr(beg:end)) !cmr
+    allocate(pps%svpts_mr(beg:end)) !cmr
+    allocate(pps%eah_mr(beg:end)) !cmr
 #if (defined C13)
     allocate(pps%alphapsnsun(beg:end))
     allocate(pps%alphapsnsha(beg:end))
@@ -7385,6 +7613,7 @@
     pps%dewmx(beg:end) = nan
     pps%rssun(beg:end) = nan
     pps%rssha(beg:end) = nan
+    pps%rs_mr(beg:end) = nan !cmr
     pps%laisun(beg:end) = nan
     pps%laisha(beg:end) = nan
     pps%btran(beg:end) = nan
@@ -7460,6 +7689,14 @@
     ! Adding isotope code
     pps%cisun(beg:end) = nan
     pps%cisha(beg:end) = nan
+    pps%ci_mr(beg:end) = nan !cmr
+    pps%rb_mr(beg:end) = nan !cmr
+    pps%btran_mr(beg:end) = nan !cmr
+    pps%apar_mr(beg:end) = nan !cmr
+    pps%sla_mr(beg:end) = nan !cmr
+    pps%vcmx_mr(beg:end) = nan !cmr
+    pps%svpts_mr(beg:end) = nan !cmr
+    pps%eah_mr(beg:end) = nan !cmr
 #if (defined C13)
     pps%alphapsnsun(beg:end) = nan
     pps%alphapsnsha(beg:end) = nan
@@ -8351,7 +8588,30 @@
     allocate(pcf%psnsun(beg:end))
     allocate(pcf%psnsha(beg:end))
     allocate(pcf%fpsn(beg:end))
-    allocate(pcf%fco2(beg:end))
+    allocate(pcf%psnsun2(beg:end)) !cmr
+    allocate(pcf%psnsun3(beg:end)) !cmr
+    allocate(pcf%psnsun4(beg:end)) !cmr
+    allocate(pcf%psnsha2(beg:end)) !cmr
+    allocate(pcf%psnsha3(beg:end)) !cmr
+    allocate(pcf%psnsha4(beg:end)) !cmr
+    allocate(pcf%fpsn_mn(beg:end)) !cmr
+    allocate(pcf%fpsn_mx(beg:end)) !cmr
+    allocate(pcf%fpsn_nf(beg:end)) !cmr
+    allocate(pcf%fpsn_noslp(beg:end)) !cmr
+!    allocate(pcf%fco2(beg:end))
+    allocate(pcf%reco(beg:end)) !cmr
+    allocate(pcf%reco_gpp(beg:end)) !cmr
+    allocate(pcf%reco_gppmn(beg:end)) !cmr
+    allocate(pcf%reco_gppmx(beg:end)) !cmr
+    allocate(pcf%wj(beg:end)) !cmr
+    allocate(pcf%wc(beg:end)) !cmr
+    allocate(pcf%we(beg:end)) !cmr
+    allocate(pcf%wjsun(beg:end)) !cmr
+    allocate(pcf%wcsun(beg:end)) !cmr
+    allocate(pcf%wesun(beg:end)) !cmr
+    allocate(pcf%wjsha(beg:end)) !cmr
+    allocate(pcf%wcsha(beg:end)) !cmr
+    allocate(pcf%wesha(beg:end)) !cmr
 
     allocate(pcf%m_leafc_to_litter(beg:end))
     allocate(pcf%m_frootc_to_litter(beg:end))
@@ -8522,7 +8782,30 @@
     pcf%psnsun(beg:end) = nan
     pcf%psnsha(beg:end) = nan
     pcf%fpsn(beg:end) = nan
-    pcf%fco2(beg:end) = 0._r8
+    pcf%psnsun2(beg:end) = nan !cmr
+    pcf%psnsun3(beg:end) = nan !cmr
+    pcf%psnsun4(beg:end) = nan !cmr
+    pcf%psnsha2(beg:end) = nan !cmr
+    pcf%psnsha3(beg:end) = nan !cmr
+    pcf%psnsha4(beg:end) = nan !cmr
+    pcf%fpsn_mn(beg:end) = nan !cmr
+    pcf%fpsn_mx(beg:end) = nan !cmr
+    pcf%fpsn_nf(beg:end) = nan !cmr
+    pcf%fpsn_noslp(beg:end) = nan !cmr
+!    pcf%fco2(beg:end) = 0._r8
+    pcf%reco(beg:end) = 0._r8 !cmr
+    pcf%reco_gpp(beg:end) = 0._r8 !cmr
+    pcf%reco_gppmn(beg:end) = 0._r8 !cmr
+    pcf%reco_gppmx(beg:end) = 0._r8 !cmr
+    pcf%wj(beg:end) = 0._r8 !cmr
+    pcf%we(beg:end) = 0._r8 !cmr
+    pcf%wc(beg:end) = 0._r8 !cmr
+    pcf%wjsun(beg:end) = 0._r8 !cmr
+    pcf%wesun(beg:end) = 0._r8 !cmr
+    pcf%wcsun(beg:end) = 0._r8 !cmr
+    pcf%wjsha(beg:end) = 0._r8 !cmr
+    pcf%wesha(beg:end) = 0._r8 !cmr
+    pcf%wcsha(beg:end) = 0._r8 !cmr
 
     pcf%m_leafc_to_litter(beg:end) = nan
     pcf%m_frootc_to_litter(beg:end) = nan
@@ -11326,6 +11609,7 @@
     deallocate(pps%dewmx )
     deallocate(pps%rssun )
     deallocate(pps%rssha )
+    deallocate(pps%rs_mr ) !cmr
     deallocate(pps%laisun )
     deallocate(pps%laisha )
     deallocate(pps%btran )
@@ -11401,6 +11685,14 @@
     ! Adding isotope code
     deallocate(pps%cisun )
     deallocate(pps%cisha )
+    deallocate(pps%ci_mr ) !cmr
+    deallocate(pps%rb_mr ) !cmr
+    deallocate(pps%btran_mr ) !cmr
+    deallocate(pps%apar_mr ) !cmr
+    deallocate(pps%sla_mr ) !cmr
+    deallocate(pps%vcmx_mr ) !cmr
+    deallocate(pps%svpts_mr ) !cmr
+    deallocate(pps%eah_mr ) !cmr
 #if (defined C13)
     deallocate(pps%alphapsnsun )
     deallocate(pps%alphapsnsha )
@@ -11998,7 +12290,30 @@
     deallocate(pcf%psnsun )
     deallocate(pcf%psnsha )  
     deallocate(pcf%fpsn )
-    deallocate(pcf%fco2 )
+    deallocate(pcf%psnsun2 ) !cmr
+    deallocate(pcf%psnsun3 ) !cmr
+    deallocate(pcf%psnsun4 ) !cmr
+    deallocate(pcf%psnsha2 ) !cmr
+    deallocate(pcf%psnsha3 ) !cmr  
+    deallocate(pcf%psnsha4 ) !cmr  
+    deallocate(pcf%fpsn_mn ) !cmr
+    deallocate(pcf%fpsn_mx ) !cmr
+    deallocate(pcf%fpsn_nf ) !cmr
+    deallocate(pcf%fpsn_noslp )!cmr
+!    deallocate(pcf%fco2 )
+    deallocate(pcf%reco ) !cmr
+    deallocate(pcf%reco_gpp ) !cmr
+    deallocate(pcf%reco_gppmn ) !cmr
+    deallocate(pcf%reco_gppmx ) !cmr
+    deallocate(pcf%wj ) !cmr
+    deallocate(pcf%we ) !cmr
+    deallocate(pcf%wc ) !cmr
+    deallocate(pcf%wjsun ) !cmr
+    deallocate(pcf%wesun ) !cmr
+    deallocate(pcf%wcsun ) !cmr
+    deallocate(pcf%wjsha ) !cmr
+    deallocate(pcf%wesha ) !cmr
+    deallocate(pcf%wcsha ) !cmr
 
     deallocate(pcf%m_leafc_to_litter )
     deallocate(pcf%m_frootc_to_litter )
@@ -17865,11 +18180,10 @@
       mss_frc_cly_vld(c) = min(clay*0.01_r8, 0.20_r8)
 
    end do
-
-
-    call CLMDebug('mark3')
+   call CLMDebug('mark3')
    ! pft level initialization
-   do p = begp, endp
+   
+      do p = begp, endp
 
       ! Initialize maximum allowed dew
 
@@ -23684,6 +23998,9 @@
     real(r8) :: rmax                                     ! maximum patch cover
 !ylu 01/16/2009
     integer  :: pftid
+ 
+    character*254 :: msg !cmr 
+  
 !!-------------------------------------------------------------------------
        ! Initialize surface data to fill value
   call CLMDebug('surfrd-mark1')
@@ -23731,6 +24048,7 @@
 
           call CLMDebug('surfrd-mark2')
 
+
 !---------------------------------------------------
 ! in current versions of CLM, the lake scheme has problems 
 ! in simulating deep lakes. Esepcially, observed lake depth data should
@@ -23746,10 +24064,11 @@
 !              pctgla(g)      = 100.0
 !           end if
 !----------------------------------------------------
-           do m=1,maxpatch_pft
-               pft(g,m) = plant(iveg,m)
+!cmrpft: one can set pft here manually 
+          do m=1,maxpatch_pft
+               pft(g,m) =  plant(iveg,m)
                if(cover(iveg,m).ne.0.0) then
-                pctpft(g,pft(g,m)) = cover(iveg,m)
+                  pctpft(g,pft(g,m)) = cover(iveg,m)
                end if
            end do
 
@@ -23764,6 +24083,7 @@
 !---------------------------------------------------------------------
          end do
            call CLMDebug('surfrd--mark3')
+
        ! Error check: valid PFTs and sum of cover must equal 100
 
 #ifndef DGVM
@@ -25586,6 +25906,7 @@
 
 !-----------------------------------------------------------------------
 
+  character(256) :: msg
   ! Assign local pointers to derived subtypes components (landunit-level)
 
   ltype => clm3%g%l%itype
@@ -31739,7 +32060,7 @@
     real(r8) :: voleq1                      ! temp variable for calculating vol_eq
     real(r8) :: zwtmm(lbc:ubc)              ! water table depth [mm]
 !-----------------------------------------------------------------------
-
+    character*256 :: msg !cmrwrite
     ! Assign local pointers to derived type members (column-level)
 
     qcharge           => clm3%g%l%c%cws%qcharge
@@ -32133,6 +32454,10 @@
        endif
     end do
 
+!cmrwrite
+   write(msg, *) 'cmr: in SoilWater: h20soi_liq = ',maxval(h2osoi_liq)
+   call CLMDebug(msg)
+
   end subroutine SoilWater
 
 !-----------------------------------------------------------------------
@@ -32247,7 +32572,7 @@
     real(r8) :: available_h2osoi_liq     !available soil liquid water in a layer
 !KO
 !-----------------------------------------------------------------------
-
+    character*254 :: msg  !cmr
     ! Assign local pointers to derived subtypes components (column-level)
 
     ctype          => clm3%g%l%c%itype
@@ -32539,6 +32864,9 @@
 
     end do
 
+!cmrwrite
+   write(msg, *) 'cmr: in Drainage: h20soi_liq = ',maxval(h2osoi_liq),'h20soi_ice = ', maxval(h2osoi_ice)
+   call CLMDebug(msg)
 
   end subroutine Drainage
 
@@ -35539,6 +35867,7 @@
     real(r8) :: snowcap_scl_fct            ! temporary factor used to correct for snow capping
     real(r8) :: fracl                      ! fraction of soil layer contributing to 10cm total soil water
 
+    character(254) :: msg !cmr
 !-----------------------------------------------------------------------
 
     ! Assign local pointers to derived subtypes components (gridcell-level)
@@ -35788,7 +36117,6 @@
        
        c = filter_nolakec(fc)
        l = clandunit(c)
-
        t_grnd(c) = t_soisno(c,snl(c)+1)
        if (ityplun(l) /= isturb) then
           t_soi_10cm(c) = t_soi_10cm(c)/0.1_r8
@@ -35816,6 +36144,14 @@
           c = filter_nolakec(fc)
           endwb(c) = endwb(c) + h2osoi_ice(c,j) + h2osoi_liq(c,j)
           h2osoi_vol(c,j) = h2osoi_liq(c,j)/(dz(c,j)*denh2o) + h2osoi_ice(c,j)/(dz(c,j)*denice)
+!cmrwrite
+   write(msg,*)'cmr: in Hydrology2: h2osoi_liq',maxval(h2osoi_liq),'h2osoi_ice',maxval(h2osoi_ice),'h2osoi_vol(c,j)',h2osoi_vol(c,j) 
+   CALL CLMDebug(msg) 
+! d01 2013-06-21_06:00:00  t_soi_10cm(c)=    283.1589335233167     
+! z(c,j) 6.2258571386337280E-002 dz(c,j)   4.5470034703612328E-002 
+!h2osoi_liq   1.0000000000000002E-002 h2osoi_ice    1.000000000000000
+!h2osoi_vol(c,j)   5.7101028202578765E-004
+!cmr end
        end do
     end do
 
@@ -35860,7 +36196,7 @@
        do fc = 1, num_hydrologyc
           c = filter_hydrologyc(fc)
           
-          if (h2osoi_liq(c,j) > 0._r8) then
+          if (h2ooi_liqoi_liq(c,j) > 0._r8) then
              vwc = h2osoi_liq(c,j)/(dz(c,j)*denh2o)
             
              ! the following limit set to catch very small values of 
@@ -36237,7 +36573,7 @@
 !
 ! !INTERFACE:
   subroutine CanopyFluxes(lbg, ubg, lbc, ubc, lbp, ubp, &
-                          num_nolakep, filter_nolakep)
+                          num_nolakep, filter_nolakep,atm_co2,valley_CO2pft2)
 !
 ! !DESCRIPTION:
 ! 1. Calculates the leaf temperature:
@@ -36271,7 +36607,8 @@
     use clmtype
     use clm_varpar         , only : nlevgrnd, nlevsno
     use clm_varcon         , only : sb, cpair, hvap, vkc, grav, denice, &
-                                    denh2o, tfrz, csoilc, tlsai_crit, alpha_aero
+!cmr: add lai                                    denh2o, tfrz, csoilc, tlsai_crit, alpha_aero
+                                    denh2o, tfrz, csoilc, tlsai_crit,alpha_aero,lai
     use QSatMod            , only : QSat
     use FrictionVelocityMod, only : FrictionVelocity, MoninObukIni
     use globals            , only : dtime
@@ -36283,6 +36620,8 @@
     integer, intent(in) :: lbp, ubp                    ! pft bounds
     integer, intent(in) :: num_nolakep                 ! number of column non-lake points in pft filter
     integer, intent(in) :: filter_nolakep(ubp-lbp+1)   ! pft filter for non-lake points
+    real,dimension(4), intent(in) :: atm_co2 !cmr
+    integer, intent(in) :: valley_CO2pft2              ! cmr second pft with forcing of pft 1
 !
 ! !CALLED FROM:
 ! subroutine Biogeophysics1 in module Biogeophysics1Mod
@@ -36303,6 +36642,7 @@
 !
 ! !LOCAL VARIABLES:
 !
+   CHARACTER*256 :: msg !cmr
 ! local pointers to implicit in variables
 !
    integer , pointer :: frac_veg_nosno(:) ! frac of veg not covered by snow (0 OR 1 now) [-]
@@ -36439,7 +36779,8 @@
    real(r8), parameter :: ria  = 0.5_r8    ! free parameter for stable formulation (currently = 0.5, "gamma" in Sakaguchi&Zeng,2008)
    real(r8) :: zldis(lbp:ubp)        ! reference height "minus" zero displacement height [m]
    real(r8) :: zeta                  ! dimensionless height used in Monin-Obukhov theory
-   real(r8) :: wc                    ! convective velocity [m/s]
+!cmr changed wc to wcv cause of double use of wc:   real(r8) :: wc                    ! convective velocity [m/s]
+   real(r8) :: wcv                    ! convective velocity [m/s]
    real(r8) :: dth(lbp:ubp)          ! diff of virtual temp. between ref. height and surface
    real(r8) :: dthv(lbp:ubp)         ! diff of vir. poten. temp. between ref. height and surface
    real(r8) :: dqh(lbp:ubp)          ! diff of humidity between ref. height and surface
@@ -36558,6 +36899,100 @@
    real(r8) :: dayl                  ! daylength (s)
    real(r8) :: temp                  ! temporary, for daylength calculation
    real(r8) :: dayl_factor(lbp:ubp)  ! scalar (0-1) for daylength effect on Vcmax
+   integer :: flop !cmr switch for stomata
+!cmr
+!   real(r8), pointer :: fco2(:)      ! net CO2 flux (umol CO2 /m**2 /s) [+ =to atm] 
+   real(r8), pointer :: reco(:)      ! respiration from soil and plants
+   real(r8), pointer :: reco_gpp(:)      ! respiration from soil and plants
+   real(r8), pointer :: reco_gppmn(:)      ! respiration from soil and plants
+   real(r8), pointer :: reco_gppmx(:)      ! respiration from soil and plants
+   real(r8), pointer :: wc(:)      ! rubisco limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: wj(:)      ! light limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: we(:)      ! export limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: wcsun(:)      ! rubisco limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: wjsun(:)      ! light limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: wesun(:)      ! export limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: wcsha(:)      ! rubisco limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: wjsha(:)      ! light limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: wesha(:)      ! export limited photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: psnsun2(:)    ! anthropogenic forcing photosynthesis (umol co2/m**2/s) 
+   real(r8), pointer :: psnsha2(:) 
+   real(r8), pointer :: psnsun3(:)    ! no feedback photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: psnsha3(:) 
+   real(r8), pointer :: psnsun4(:)    ! no feedback photosynthesis (umol co2/m**2/s)
+   real(r8), pointer :: psnsha4(:) 
+   real(r8), pointer :: fpsn_mn(:)      ! anthropogenic forcing photosynthesis
+   real(r8), pointer :: fpsn_mx(:)      ! no feedback photosynthesis 
+   real(r8), pointer :: fpsn_nf(:)      ! no feedback photosynthesis 
+   real(r8), pointer :: rs_mr(:)      ! stomatal resistance (s/m) for export
+   real(r8), pointer :: ci_mr(:)      ! intracellular CO2 (Pa) for export
+   real(r8), pointer :: rb_mr(:)      ! cmr
+   real(r8), pointer :: btran_mr(:)   ! cmr
+   real(r8), pointer :: apar_mr(:)    ! cmr
+   real(r8), pointer :: sla_mr(:)     ! cmr
+   real(r8), pointer :: vcmx_mr(:)    ! cmr
+   real(r8), pointer :: svpts_mr(:)   ! cmr saturation vapor pressure at t_veg (pa)
+   real(r8), pointer :: eah_mr(:)     ! cmr canopy air vapor pressure (pa) 
+   real(r8), pointer :: slasun(:)        ! specific leaf area for sunlit canopy, projected area basis (m^2/gC)
+   real(r8), pointer :: slasha(:)        ! specific leaf area for shaded canopy, projected area basis (m^2/gC)
+   real(r8), pointer :: vcmxsha(:)            ! shaded leaf Vcmax (umolCO2/m^2/s)
+   real(r8), pointer :: vcmxsun(:)            ! sunlit leaf Vcmax (umolCO2/m^2/s)
+   real(r8), pointer :: parsun(:)        ! average absorbed PAR for sunlit leaves (W/m**2)
+   real(r8), pointer :: parsha(:)        ! average absorbed PAR for shaded leaves (W/m**2)
+   real(r8),dimension(1:16) :: R0,al_lai,k2,E0,R0mn,al_laimn,k2mn,R0mx,al_laimx,k2mx,E0mn,E0mx
+   data(R0(i),i=1,16)/1.02,1.02,1.02,-0.47,-0.47,1.27,1.27,1.27,0.42,0.42,0.42,0.41,0.41,0.41,0.25,0.25/
+   data(R0mn(i),i=1,16)/0.6,0.6,0.6,-0.97,-0.97,0.77,0.77,0.77,0.03,0.03,0.03,-0.3,-0.3,-0.3,-0.41,-0.41/
+   data(R0mx(i),i=1,16)/1.44,1.44,1.44,0.03,0.03,1.77,1.77,1.77,0.81,0.81,0.81,1.12,1.12,1.12,0.91,0.91/
+   data(al_lai(i),i=1,16)/0.42,0.42,0.42,0.82,0.82,0.34,0.34,0.34,0.57,0.57,0.57,1.14,1.14,1.14,0.40,0.40/
+   data(al_laimn(i),i=1,16)/0.34,0.34,0.34,0.69,0.69,0.24,0.24,0.24,0.40,0.40,0.40,0.81,0.81,0.81,0.29,0.29/
+   data(al_laimx(i),i=1,16)/0.50,0.50,0.50,0.95,0.95,0.44,0.44,0.44,0.74,0.74,0.74,1.47,1.47,1.47,0.51,0.51/
+   data(k2(i),i=1,16)/0.478,0.478,0.478,0.602,0.602,0.247,0.247,0.247,0.354,0.354,0.354,0.578,0.578,0.578,0.244,0.244/
+   data(k2mn(i),i=1,16)/0.465,0.465,0.465,0.658,0.658,0.238,0.238,0.238,0.333,0.333,0.333,0.516,0.516,0.516,0.228,0.228/
+   data(k2mx(i),i=1,16)/0.491,0.491,0.491,0.646,0.646,0.256,0.256,0.256,0.375,0.375,0.375,0.640,0.640,0.640,0.260,0.260/
+   data(E0(i),i=1,16)/124.833,124.833,124.833,52.753,52.753,87.655,87.655,87.655,156.746,156.746,156.746,101.181,101.181,101.181,129.498,129.498/
+   data(E0mn(i),i=1,16)/120.177,120.177,120.177,48.402,48.402,83.25,83.25,83.25,148.524,148.524,148.524,94.819,94.819,94.819,123.88,123.88/
+   data(E0mx(i),i=1,16)/129.489,129.489,129.489,57.104,57.104,92.06,92.06,92.06,164.968,164.968,164.968,107.543,107.543,107.543,135.116,135.116/
+
+!   fco2      => clm3%g%l%c%p%pcf%fco2
+   reco      => clm3%g%l%c%p%pcf%reco
+   reco_gpp      => clm3%g%l%c%p%pcf%reco_gpp
+   reco_gppmn      => clm3%g%l%c%p%pcf%reco_gppmn
+   reco_gppmx      => clm3%g%l%c%p%pcf%reco_gppmx
+   wj    => clm3%g%l%c%p%pcf%wj
+   wc    => clm3%g%l%c%p%pcf%wc
+   we    => clm3%g%l%c%p%pcf%we
+   wjsun    => clm3%g%l%c%p%pcf%wjsun
+   wcsun    => clm3%g%l%c%p%pcf%wcsun
+   wesun    => clm3%g%l%c%p%pcf%wesun
+   wjsha    => clm3%g%l%c%p%pcf%wjsha
+   wcsha    => clm3%g%l%c%p%pcf%wcsha
+   wesha    => clm3%g%l%c%p%pcf%wesha
+   psnsun2  => clm3%g%l%c%p%pcf%psnsun2
+   psnsun3  => clm3%g%l%c%p%pcf%psnsun3
+   psnsun4  => clm3%g%l%c%p%pcf%psnsun4
+   psnsha2  => clm3%g%l%c%p%pcf%psnsha2
+   psnsha3  => clm3%g%l%c%p%pcf%psnsha3
+   psnsha4  => clm3%g%l%c%p%pcf%psnsha4
+   fpsn_mn  => clm3%g%l%c%p%pcf%fpsn_mn
+   fpsn_mx  => clm3%g%l%c%p%pcf%fpsn_mx
+   fpsn_nf  => clm3%g%l%c%p%pcf%fpsn_nf
+   ci_mr  => clm3%g%l%c%p%pps%ci_mr
+   rs_mr  => clm3%g%l%c%p%pps%rs_mr
+   rb_mr  => clm3%g%l%c%p%pps%rb_mr
+   btran_mr  => clm3%g%l%c%p%pps%btran_mr
+   apar_mr  => clm3%g%l%c%p%pps%apar_mr
+   sla_mr  => clm3%g%l%c%p%pps%sla_mr
+   vcmx_mr  => clm3%g%l%c%p%pps%vcmx_mr
+   svpts_mr  => clm3%g%l%c%p%pps%svpts_mr
+   eah_mr  => clm3%g%l%c%p%pps%eah_mr
+   slasun  => clm3%g%l%c%p%pps%slasun
+   slasha  => clm3%g%l%c%p%pps%slasha
+   vcmxsha  => clm3%g%l%c%p%pps%vcmxsha
+   vcmxsun  => clm3%g%l%c%p%pps%vcmxsun
+   parsun  => clm3%g%l%c%p%pef%parsun
+   parsha  => clm3%g%l%c%p%pef%parsha
+
+!cmr end
 !------------------------------------------------------------------------------
 
    ! Assign local pointers to derived type members (gridcell-level)
@@ -36677,7 +37112,6 @@
    smpsc          => pftcon%smpsc
 
 
-
    ! Filter pfts where frac_veg_nosno is non-zero
 
    fn = 0
@@ -36803,7 +37237,13 @@
 
       ! Determine atmospheric co2 and o2
 
-      co2(p) = forc_pco2(g)
+!cmr      co2(p) = forc_pco2(g)
+! make a namelist controlled co2 feedback
+!      IF ( co2_feedback == 1) THEN
+      co2(p) = atm_co2(1)*forc_pbot(g) 
+!      ENDIF
+
+!cmr end
       o2(p)  = forc_po2(g)
       
 #if (defined C13)
@@ -36942,9 +37382,24 @@
       end do
 
       ! 4/25/05, PET: Now calling the sun/shade version of Stomata by default
-      call Stomata (fn, filterp, lbp, ubp, svpts, eah, o2, co2, rb, dayl_factor, phase='sun')
-      call Stomata (fn, filterp, lbp, ubp, svpts, eah, o2, co2, rb, dayl_factor, phase='sha')
-
+      flop = 1 !cmr: FPSN with feedback
+      co2(p) = atm_co2(flop)*forc_pbot(g) 
+      call Stomata (fn, filterp, lbp, ubp, svpts, eah, o2, co2, rb, dayl_factor, flop, valley_CO2pft2, phase='sun')
+      call Stomata (fn, filterp, lbp, ubp, svpts, eah, o2, co2, rb, dayl_factor, flop, valley_CO2pft2, phase='sha')
+
+      flop = 2 ! minimal NEE
+      co2(p) = atm_co2(flop)*forc_pbot(g)
+      call Stomata (fn, filterp, lbp, ubp, svpts, eah, o2, co2, rb, dayl_factor, flop, valley_CO2pft2, phase='sun')
+      call Stomata (fn, filterp, lbp, ubp, svpts, eah, o2, co2, rb, dayl_factor, flop, valley_CO2pft2, phase='sha')
+      flop = 3 !cmr: maximal NEE
+      co2(p) = atm_co2(flop)*forc_pbot(g)
+      call Stomata (fn, filterp, lbp, ubp, svpts, eah, o2, co2, rb, dayl_factor, flop, valley_CO2pft2, phase='sun')
+      call Stomata (fn, filterp, lbp, ubp, svpts, eah, o2, co2, rb, dayl_factor, flop, valley_CO2pft2, phase='sha')
+      
+      flop = 4 !cmr: FPSN without feedback
+      co2(p) = atm_co2(flop)*forc_pbot(g)
+      call Stomata (fn, filterp, lbp, ubp, svpts, eah, o2, co2, rb, dayl_factor, flop, valley_CO2pft2, phase='sun')
+      call Stomata (fn, filterp, lbp, ubp, svpts, eah, o2, co2, rb, dayl_factor, flop, valley_CO2pft2, phase='sha')
 !dir$ concurrent
 !cdir nodep
       do f = 1, fn
@@ -37113,8 +37568,8 @@
             um(p) = max(ur(p),0.1_r8)
          else                     !unstable
             zeta = max(-100._r8,min(zeta,-0.01_r8))
-            wc = beta*(-grav*ustar(p)*thvstar*zii/thv(c))**0.333_r8
-            um(p) = sqrt(ur(p)*ur(p)+wc*wc)
+            wcv = beta*(-grav*ustar(p)*thvstar*zii/thv(c))**0.333_r8 !cmr:  wc -> wcv
+            um(p) = sqrt(ur(p)*ur(p)+wcv*wcv) !cmr:  wc -> wcv
          end if
          obu(p) = zldis(p)/zeta
 
@@ -37211,7 +37666,56 @@
       ! total photosynthesis
 
       fpsn(p) = psnsun(p)*laisun(p) + psnsha(p)*laisha(p)
-      
+!cmr: do antro & single of photosynthesis:
+      fpsn_mx(p) = psnsun2(p)*laisun(p) + psnsha2(p)*laisha(p) + &
+              0.3*(psnsun2(p)*laisun(p) + psnsha2(p)*laisha(p))
+      fpsn_mn(p) = psnsun3(p)*laisun(p) + psnsha3(p)*laisha(p) - & 
+              0.3*(psnsun3(p)*laisun(p) + psnsha3(p)*laisha(p))
+      fpsn_nf(p) = psnsun4(p)*laisun(p) + psnsha4(p)*laisha(p)
+      wj(p) = wjsun(p)*laisun(p) + wjsha(p)*laisha(p)
+      we(p) = wesun(p)*laisun(p) + wesha(p)*laisha(p)
+      wc(p) = wcsun(p)*laisun(p) + wcsha(p)*laisha(p)
+      ci_mr(p) = cisun(p)+cisha(p)
+      rs_mr(p) = rssun(p)+rssha(p) 
+      rb_mr(p) = rb(p)
+      btran_mr(p) = btran(p) 
+      apar_mr(p) = parsun(p)+parsha(p)
+      sla_mr(p) = slasun(p)+slasha(p)
+      vcmx_mr(p) = vcmxsun(p)+vcmxsha(p) 
+
+!cmr get saturation vapor pressure svpts_mr and vapor pressure of canopy air eah_mr:
+      svpts_mr(p) = el(p)                         ! pa
+      eah_mr(p) = forc_pbot(g) * qaf(p) / 0.622_r8   ! pa
+
+!cmr do respiration
+! R_ecosystem = R_soil + R_plant
+! RsTref = 3.23
+! RpTref = 0.58
+! Es = 78844
+! Ep = 69571
+! Tp = t_veg !leaf temperature in Kelvin
+! Ts = t_soisno(c,3)  ! soil temperature (Kelvin) (c,3) is for top 30 cm 
+! R = 8.314 ! universal gas constant [J mol^-1 K^-1]
+! Tref = 283.16 !reference Temperature [K]
+! L = laisun+laisha  ! sunlit and shaded projected leaf area index 
+! reco = RsTref*exp(Es/(R*Tref)*(1-Tref/Ts)) + L*RpTref*exp(Ep/(R*Tref)*(1-Tref/Tp))  
+      reco(p) = 3.23*exp(78844/(8.314*283.16)*(1-283.16/t_soisno(c,3)))+ &
+                (laisun(p)+laisha(p))*0.58*exp(69571/(8.314*283.16)*(1-283.16/t_veg(p))) 
+! R_eco according to migliavacca linGPP:
+reco_gpp(p)=(R0(ivt(p))+al_lai(ivt(p))*maxval(lai(ivt(p),:))+k2(ivt(p))*fpsn(p))*exp(E0(ivt(p))*(1/(288.15-227.13)-1/(taf(p)-227.13))) 
+reco_gppmn(p)=(R0mn(ivt(p))+al_laimn(ivt(p))*maxval(lai(ivt(p),:))+k2mn(ivt(p))*fpsn(p))*exp(E0mn(ivt(p))*(1/(288.15-227.13)-1/(taf(p)-227.13))) 
+reco_gppmx(p)=(R0mx(ivt(p))+al_laimx(ivt(p))*maxval(lai(ivt(p),:))+k2mx(ivt(p))*fpsn(p))*exp(E0mx(ivt(p))*(1/(288.15-227.13)-1/(taf(p)-227.13))) 
+
+! Net ecosystem exchange:
+!      fco2(p) = reco(p) - fpsn(p)
+! Check out the Values: 
+!   write(msg,*)'shape(t_soisno)',shape(t_soisno),'t_soisno(c,1)=',t_soisno(c,1),'t_soisno(c,2)=',t_soisno(c,2),'t_soisno(c,3)=',t_soisno(c,3), &
+!               't_veg(p)=',t_veg(p)
+!   write(msg,*) 'p=',p,'ivt(p)=',ivt(p),'maxval(lai(ivt(p),:))',maxval(lai(ivt(p),:)),'reco_gpp(p)=',reco_gpp(p),'taf(p)',taf(p)
+!   CALL wrf_debug(0,msg)
+!cmr end
+
+
 #if (defined CN) && (defined C13)
       ! 4/14/05: PET
       ! Adding isotope code
@@ -37249,7 +37753,8 @@
 ! !IROUTINE: Stomata
 !
 ! !INTERFACE:
-   subroutine Stomata (fn, filterp, lbp, ubp, ei, ea, o2, co2, rb, dayl_factor, phase)
+!cmr   subroutine Stomata (fn, filterp, lbp, ubp, ei, ea, o2, co2, rb, dayl_factor, phase)
+   subroutine Stomata (fn, filterp, lbp, ubp, ei, ea, o2, co2, rb, dayl_factor, flop, valley_CO2pft2, phase)
 !
 ! !DESCRIPTION: 
 ! Leaf stomatal resistance and leaf photosynthesis. Modifications for CN code.
@@ -37285,6 +37790,8 @@
      real(r8), intent(inout) :: rb(lbp:ubp)        ! boundary layer resistance (s/m)
      real(r8), intent(in)    :: dayl_factor(lbp:ubp) ! scalar (0-1) for daylength
      character(len=*), intent(in) :: phase         ! 'sun' or 'sha'
+     integer , intent(in)    :: flop               ! cmr: 1,2 and 3 for CO2 with feedback, anthropogenic source and without feedback 
+     integer, intent(in) :: valley_CO2pft2              ! cmr second pft with forcing of pft 1
 !
 ! !CALLED FROM:
 ! subroutine CanopyFluxes in this module
@@ -37320,6 +37827,12 @@
      real(r8), pointer :: alphapsn(:)    ! 13C fractionation factor for PSN ()
 #endif
 
+!cmr add variables for output
+     real(r8), pointer :: wc(:)      ! rubisco limited photosynthesis (umol co2/m**2/s)
+     real(r8), pointer :: wj(:)      ! light limited photosynthesis (umol co2/m**2/s)
+     real(r8), pointer :: we(:)      ! export limited photosynthesis (umol co2/m**2/s)
+!cmr
+
 !
 ! local pointers to implicit out variables
 !
@@ -37348,9 +37861,9 @@
      real(r8) :: q       ! intermediate calculations for rs
      real(r8) :: r1,r2   ! roots for rs
      real(r8) :: ppf     ! absorb photosynthetic photon flux (umol photons/m**2/s)
-     real(r8) :: wc      ! rubisco limited photosynthesis (umol co2/m**2/s)
-     real(r8) :: wj      ! light limited photosynthesis (umol co2/m**2/s)
-     real(r8) :: we      ! export limited photosynthesis (umol co2/m**2/s)
+!cmr     real(r8) :: wc      ! rubisco limited photosynthesis (umol co2/m**2/s)
+!cmr     real(r8) :: wj      ! light limited photosynthesis (umol co2/m**2/s)
+!cmr     real(r8) :: we      ! export limited photosynthesis (umol co2/m**2/s)
      real(r8) :: cp      ! co2 compensation point (pa)
      real(r8) :: awc     ! intermediate calcuation for wc
      real(r8) :: j       ! electron transport (umol co2/m**2/s)
@@ -37369,7 +37882,8 @@
      real(r8) :: q10act  ! (DIM) Q_10 for Rubisco activity
      real(r8) :: fnr     ! (gRubisco/gN in Rubisco)
 !------------------------------------------------------------------------------
-
+     character*256 :: msg !cmr
+     integer  :: temp_ivt !cmr temporary integer
      ! Set statement functions
 
      f1(ab,bc) = ab**((bc-25._r8)/10._r8)
@@ -37385,7 +37899,7 @@
      if (phase == 'sun') then
         apar   => clm3%g%l%c%p%pef%parsun
         rs     => clm3%g%l%c%p%pps%rssun
-        psn    => clm3%g%l%c%p%pcf%psnsun
+!cmr        psn    => clm3%g%l%c%p%pcf%psnsun
         ci     => clm3%g%l%c%p%pps%cisun
 #if (defined C13)
         alphapsn  => clm3%g%l%c%p%pps%alphapsnsun
@@ -37393,10 +37907,25 @@
         sla    => clm3%g%l%c%p%pps%slasun
         lnc    => clm3%g%l%c%p%pps%lncsun   
         vcmx   => clm3%g%l%c%p%pps%vcmxsun   
+!cmr 
+        wj    => clm3%g%l%c%p%pcf%wjsun
+        wc    => clm3%g%l%c%p%pcf%wcsun
+        we    => clm3%g%l%c%p%pcf%wesun
+        if (flop .eq. 1) then
+          psn    => clm3%g%l%c%p%pcf%psnsun
+        else if (flop .eq. 2) then
+          psn    => clm3%g%l%c%p%pcf%psnsun2
+        else if (flop .eq. 3) then
+          psn    => clm3%g%l%c%p%pcf%psnsun3
+        else if (flop .eq. 4) then
+          psn    => clm3%g%l%c%p%pcf%psnsun4
+        end if
+
+!cmr end
      else if (phase == 'sha') then
         apar   => clm3%g%l%c%p%pef%parsha
         rs     => clm3%g%l%c%p%pps%rssha
-        psn    => clm3%g%l%c%p%pcf%psnsha
+!cmr         psn    => clm3%g%l%c%p%pcf%psnsha
         ci     => clm3%g%l%c%p%pps%cisha
         sla    => clm3%g%l%c%p%pps%slasha   
 #if (defined C13)
@@ -37404,8 +37933,23 @@
 #endif
         lnc    => clm3%g%l%c%p%pps%lncsha   
         vcmx   => clm3%g%l%c%p%pps%vcmxsha
+!cmr 
+        wj    => clm3%g%l%c%p%pcf%wjsha
+        wc    => clm3%g%l%c%p%pcf%wcsha
+        we    => clm3%g%l%c%p%pcf%wesha
+        if (flop .eq. 1) then
+          psn    => clm3%g%l%c%p%pcf%psnsha
+        else if (flop .eq. 2) then
+          psn    => clm3%g%l%c%p%pcf%psnsha2
+        else if (flop .eq. 3) then
+          psn    => clm3%g%l%c%p%pcf%psnsha3
+        else if (flop .eq. 4) then
+          psn    => clm3%g%l%c%p%pcf%psnsha4
+        end if
+!cmr end
      end if
 
+
      ! Assign local pointers to derived type members (gridcell-level)
 
      forc_pbot => clm_a2l%forc_pbot
@@ -37444,6 +37988,7 @@
 
      act25 = act25 * 1000.0_r8 / 60.0_r8
 
+
 !dir$ concurrent
 !cdir nodep
      do f = 1, fn
@@ -37451,7 +37996,18 @@
         c = pcolumn(p)
         g = pgridcell(p)
 
-        ! Initialize rs=rsmax and psn=0 because calculations are performed only
+!cmr set swappped ivt for flop = 2 to get psn of other parameterization with
+!similar temperatures as base ivt:
+!        if (flop .eq. 2) then
+!          temp_ivt = ivt(p)
+!          ivt(p) = valley_CO2pft2
+!        endif
+
+!    write(msg,*) 'p = ',p,' ivt(p) = ',ivt(p)
+!    CALL wrf_debug(0,msg)
+!cmr end
+
+       ! Initialize rs=rsmax and psn=0 because calculations are performed only
         ! when apar > 0, in which case rs <= rsmax and psn >= 0
         ! Set constants
 
@@ -37466,7 +38022,9 @@
            alphapsn(p) = 1._r8
 #endif
         else                             ! day time
+          
            tc = tl(p) - SHR_CONST_TKFRZ
+
            ppf = 4.6_r8 * apar(p)                  
            j = ppf * qe25(ivt(p))
            kc = kc25 * f1(akc,tc)       
@@ -37491,7 +38049,7 @@
 #if (defined CN)
            vcmx(p) = lnc(p) * flnr(ivt(p)) * fnr * act / f2(tc) * btran(p) * dayl_factor(p)
 #else
-           vcmx(p) = lnc(p) * flnr(ivt(p)) * fnr * act / f2(tc) * btran(p) * dayl_factor(p) * fnitr(ivt(p))
+           vcmx(p) = lnc(p) * flnr(ivt(p)) * fnr * act / f2(tc) * btran(p) *dayl_factor(p) * fnitr(ivt(p))
 #endif
            
            ! First guess ci
@@ -37513,10 +38071,10 @@
            !
            ! ITER = 1
            !
-           wj = max(ci(p)-cp,0._r8)*j/(ci(p)+2._r8*cp)*c3psn(ivt(p)) + j*(1._r8-c3psn(ivt(p)))
-           wc = max(ci(p)-cp,0._r8)*vcmx(p)/(ci(p)+awc)*c3psn(ivt(p)) + vcmx(p)*(1._r8-c3psn(ivt(p)))
-           we = 0.5_r8*vcmx(p)*c3psn(ivt(p)) + 4000._r8*vcmx(p)*ci(p)/forc_pbot(g)*(1._r8-c3psn(ivt(p))) 
-           psn(p) = min(wj,wc,we) 
+           wj(p) = max(ci(p)-cp,0._r8)*j/(ci(p)+2._r8*cp)*c3psn(ivt(p)) + j*(1._r8-c3psn(ivt(p)))
+           wc(p) = max(ci(p)-cp,0._r8)*vcmx(p)/(ci(p)+awc)*c3psn(ivt(p)) + vcmx(p)*(1._r8-c3psn(ivt(p)))
+           we(p) = 0.5_r8*vcmx(p)*c3psn(ivt(p)) + 4000._r8*vcmx(p)*ci(p)/forc_pbot(g)*(1._r8-c3psn(ivt(p))) 
+           psn(p) = min(wj(p),wc(p),we(p)) 
            cs = max( co2(p)-1.37_r8*rb(p)*forc_pbot(g)*psn(p), mpe )
            atmp = mp(ivt(p))*psn(p)*forc_pbot(g)*cea / (cs*ei(p)) + bp
            btmp = ( mp(ivt(p))*psn(p)*forc_pbot(g)/cs + bp ) * rb(p) - 1._r8
@@ -37533,10 +38091,10 @@
            !
            ! ITER = 2
            !
-           wj = max(ci(p)-cp,0._r8)*j/(ci(p)+2._r8*cp)*c3psn(ivt(p)) + j*(1._r8-c3psn(ivt(p)))
-           wc = max(ci(p)-cp,0._r8)*vcmx(p)/(ci(p)+awc)*c3psn(ivt(p)) + vcmx(p)*(1._r8-c3psn(ivt(p)))
-           we = 0.5_r8*vcmx(p)*c3psn(ivt(p)) + 4000._r8*vcmx(p)*ci(p)/forc_pbot(g)*(1._r8-c3psn(ivt(p))) 
-           psn(p) = min(wj,wc,we) 
+           wj(p) = max(ci(p)-cp,0._r8)*j/(ci(p)+2._r8*cp)*c3psn(ivt(p)) + j*(1._r8-c3psn(ivt(p)))
+           wc(p) = max(ci(p)-cp,0._r8)*vcmx(p)/(ci(p)+awc)*c3psn(ivt(p)) + vcmx(p)*(1._r8-c3psn(ivt(p)))
+           we(p) = 0.5_r8*vcmx(p)*c3psn(ivt(p)) + 4000._r8*vcmx(p)*ci(p)/forc_pbot(g)*(1._r8-c3psn(ivt(p))) 
+           psn(p) = min(wj(p),wc(p),we(p)) 
            cs = max( co2(p)-1.37_r8*rb(p)*forc_pbot(g)*psn(p), mpe )
            atmp = mp(ivt(p))*psn(p)*forc_pbot(g)*cea / (cs*ei(p)) + bp
            btmp = ( mp(ivt(p))*psn(p)*forc_pbot(g)/cs + bp ) * rb(p) - 1._r8
@@ -37553,10 +38111,10 @@
            !
            ! ITER = 3
            !
-           wj = max(ci(p)-cp,0._r8)*j/(ci(p)+2._r8*cp)*c3psn(ivt(p)) + j*(1._r8-c3psn(ivt(p)))
-           wc = max(ci(p)-cp,0._r8)*vcmx(p)/(ci(p)+awc)*c3psn(ivt(p)) + vcmx(p)*(1._r8-c3psn(ivt(p)))
-           we = 0.5_r8*vcmx(p)*c3psn(ivt(p)) + 4000._r8*vcmx(p)*ci(p)/forc_pbot(g)*(1._r8-c3psn(ivt(p))) 
-           psn(p) = min(wj,wc,we) 
+           wj(p) = max(ci(p)-cp,0._r8)*j/(ci(p)+2._r8*cp)*c3psn(ivt(p)) + j*(1._r8-c3psn(ivt(p)))
+           wc(p) = max(ci(p)-cp,0._r8)*vcmx(p)/(ci(p)+awc)*c3psn(ivt(p)) + vcmx(p)*(1._r8-c3psn(ivt(p)))
+           we(p) = 0.5_r8*vcmx(p)*c3psn(ivt(p)) + 4000._r8*vcmx(p)*ci(p)/forc_pbot(g)*(1._r8-c3psn(ivt(p))) 
+           psn(p) = min(wj(p),wc(p),we(p)) 
            cs = max( co2(p)-1.37_r8*rb(p)*forc_pbot(g)*psn(p), mpe )
            atmp = mp(ivt(p))*psn(p)*forc_pbot(g)*cea / (cs*ei(p)) + bp
            btmp = ( mp(ivt(p))*psn(p)*forc_pbot(g)/cs + bp ) * rb(p) - 1._r8
@@ -37573,10 +38131,10 @@
 !NEC NEC NEC
 #else
            do iter = 1, niter
-              wj = max(ci(p)-cp,0._r8)*j/(ci(p)+2._r8*cp)*c3psn(ivt(p)) + j*(1._r8-c3psn(ivt(p)))
-              wc = max(ci(p)-cp,0._r8)*vcmx(p)/(ci(p)+awc)*c3psn(ivt(p)) + vcmx(p)*(1._r8-c3psn(ivt(p)))
-              we = 0.5_r8*vcmx(p)*c3psn(ivt(p)) + 4000._r8*vcmx(p)*ci(p)/forc_pbot(g)*(1._r8-c3psn(ivt(p))) 
-              psn(p) = min(wj,wc,we) 
+              wj(p) = max(ci(p)-cp,0._r8)*j/(ci(p)+2._r8*cp)*c3psn(ivt(p)) + j*(1._r8-c3psn(ivt(p)))
+              wc(p) = max(ci(p)-cp,0._r8)*vcmx(p)/(ci(p)+awc)*c3psn(ivt(p)) + vcmx(p)*(1._r8-c3psn(ivt(p)))
+              we(p) = 0.5_r8*vcmx(p)*c3psn(ivt(p)) + 4000._r8*vcmx(p)*ci(p)/forc_pbot(g)*(1._r8-c3psn(ivt(p))) 
+              psn(p) = min(wj(p),wc(p),we(p)) 
               cs = max( co2(p)-1.37_r8*rb(p)*forc_pbot(g)*psn(p), mpe )
               atmp = mp(ivt(p))*psn(p)*forc_pbot(g)*cea / (cs*ei(p)) + bp
               btmp = ( mp(ivt(p))*psn(p)*forc_pbot(g)/cs + bp ) * rb(p) - 1._r8
@@ -37607,6 +38165,11 @@
            
         end if
 
+! cmr switch vegetation back to avoid possible errors
+!        if (flop .eq. 2) then
+!         ivt(p) = temp_ivt
+!        endif
+
      end do
 
   end subroutine Stomata
@@ -37931,6 +38494,8 @@
     integer :: begg, endg   ! per-proc gridcell ending gridcell indices
     integer :: numc, nump
 !-----------------------------------------------------------------------
+    character*256 :: msg !cmr
+
     call get_proc_bounds(begg, endg, begl, endl, begc, endc, begp, endp)
 
     numc = endc-begc+1
@@ -38196,6 +38761,11 @@
     do p = begp,endp
          wtp(p)  = clm3%g%l%c%p%wtgcell(p)
     end do
+
+!cmrwrite
+   write(msg, *) 'cmr: in biophy_to_wrf: h20soi_liq = ',maxval(h2osoi_liq),'h20soi_ice = ', maxval(h2osoi_ice) &
+                 ,'h20soi_vol = ', maxval(h2osoi_vol)
+   call CLMDebug(msg)
     
   end subroutine biophy_to_wrf
 !===========================================================================================================
@@ -38701,7 +39271,8 @@
 
     found = .false.
     do c = lbc, ubc
-       if (abs(errsoi_col(c)) > 1.0e-7_r8 ) then
+       !cmr bug fix in wrf 3.5.1 if (abs(errsoi_col(c)) > 1.0e-7_r8 ) then
+       if (abs(errsoi_col(c)) > 1.0e-2_r8 ) then
           found = .true.
           indexc = c
        end if
@@ -39109,7 +39680,7 @@
 
        ! Soil evaporation resistance
        www     = (h2osoi_liq(c,1)/denh2o+h2osoi_ice(c,1)/denice)/dz(c,1)/watsat(c,1)
-       www     = min(max(www,0.0_r8),1._r8)
+       !cmr bugfix in WRF3.5.1 www     = min(max(www,0.0_r8),1._r8)
 
        !changed by K.Sakaguchi. Soilbeta is used for evaporation
        if (dqh(p) .gt. 0._r8) then   !dew  (beta is not applied, just like rsoil used to be)
@@ -57663,7 +58234,7 @@
      call var_par()
 
 
-     call CLMDebug('call surfrd')
+     call CLMDebug('call surfrd ')
      call surfrd (organicxy,efisopxy,gtixy,ilx,jlx, iveg, isl, lndmsk)
     ! Initialize clump and processor decomposition
     call CLMDebug('call initDecomp')
@@ -57920,7 +58491,8 @@
                 ,dwt_frootn_to_litr1n_buf,dwt_frootn_to_litr2n_buf, dwt_frootn_to_litr3n_buf &
                 , dwt_livecrootn_to_cwdn_buf,dwt_deadcrootn_to_cwdn_buf,retransn_buf &
 #endif         
-                                                            )
+                ,fpsn,fpsn_mn,fpsn_mx,fpsn_nf,reco,reco_gpp,reco_gppmn,reco_gppmx,atm_co2,wj,we,wc,ci_mr,rs_mr & !cmr
+                ,rb_mr,btran_mr,apar_mr,sla_mr,vcmx_mr,svpts_mr,eah_mr               )
 !-----------------------------------------------------------------------
 !
 ! !USES:
@@ -58143,7 +58715,29 @@
   real(r8)  :: sabg
   real(r8)  :: znt0
   real(r8),intent(out)  :: rhoxy
-
+  
+  real(r8)  :: fpsn !cmr
+  real(r8)  :: fpsn_mn !cmr
+  real(r8)  :: fpsn_mx !cmr
+  real(r8)  :: fpsn_nf !cmr
+  real(r8)  :: ci_mr !cmr
+  real(r8)  :: rs_mr !cmr
+  real(r8)  :: rb_mr !cmr
+  real(r8)  :: btran_mr !cmr
+  real(r8)  :: apar_mr !cmr
+  real(r8)  :: sla_mr !cmr
+  real(r8)  :: vcmx_mr !cmr
+  real(r8)  :: svpts_mr !cmr
+  real(r8)  :: eah_mr !cmr
+  real(r8)  :: reco !cmr
+  real(r8)  :: reco_gpp !cmr
+  real(r8)  :: reco_gppmn !cmr
+  real(r8)  :: reco_gppmx !cmr
+  real(r8)  :: wj !cmr
+  real(r8)  :: we !cmr
+  real(r8)  :: wc !cmr
+  real,dimension(3),intent(in)  :: atm_co2 !cmr
+  integer   :: valley_CO2pft2              ! cmr second pft with forcing of pft 1
   integer   :: nstp
 !ylu add albedo coefficients
  real(r8),dimension(1:numrad) :: cof_dir,cof_dif  !1=visible, 2=nir
@@ -58191,6 +58785,7 @@
 
 !------------------------------------------------------------------------
 
+
        call CLMDebug('Starting clm3.F')
        msg= ''
        write(msg, *) 'At i,j = ', ilx, ', ', jlx, '.'
@@ -58252,7 +58847,12 @@
     call CLMDebug('End shr_orb_params & decl')    
     call CLMDebug('Start initialize()') 
 
+
    !  write(6,*) 'in clm3, t_soisno=',t_soisno
+!cmrwrite
+!   write(msg, *) 'cmr: before initialize h20soi_liq = ', maxval(h2osoi_liq)
+!   call CLMDebug(msg)
+
     call  initialize(snl    ,snowdp  ,dzclm     ,zclm         &
                   ,ziclm       ,h2osno  ,h2osoi_liq,h2osoi_ice,t_grnd      &
                   ,t_soisno    ,t_lake  ,t_veg     ,h2ocan    ,h2ocan_col  &
@@ -58295,6 +58895,11 @@
                                                                       )
     call CLMDebug('initialize done. Back in clm3')
 
+!cmrwrite
+!   write(msg, *) 'cmr: after initialize h2osoi_liq = ', maxval(h2osoi_liq)
+!   call CLMDebug(msg)
+
+
     ! Determine necessary indices
 
     call get_proc_bounds(begg, endg, begl, endl, begc, endc, begp, endp)
@@ -58412,18 +59017,31 @@
      ! non-land points and must be set by the appropriate surface model
 
      call CLMDebug('Calling Driver')
-     call driver (doalb,ilx,jlx,caldayp1, declinp1, declin)
+     call driver (doalb,ilx,jlx,caldayp1, declinp1,declin,atm_co2,valley_CO2pft2)
      call CLMDebug('Driver done, back to clm3.F')
 
 !-------------------------------------------------------------------------
      call CLMDebug('biophy_to_wrf')
+
+!cmrwrite
+   write(msg, *) 'cmr: before biophy_to_wrf h2osoi_liq = ', maxval(h2osoi_liq) &
+                    ,'h2osoi_ice = ', maxval(h2osoi_ice),&
+                    'h2osoi_vol = ',maxval(h2osoi_vol)
+   call CLMDebug(msg)
+
      call biophy_to_wrf(snl      ,snowdp  ,dzclm      ,zclm        ,&
                      ziclm       ,h2osno  ,h2osoi_liq   ,h2osoi_ice ,t_grnd      ,&
                      t_soisno    ,t_lake  ,t_veg        ,h2ocan     ,h2ocan_col  ,&
                      h2osoi_vol  ,wtc     ,wtp          ,numc       ,nump        ,&
                      htop        ,tsai        &
                      ,t_ref2m ,znt          ,q_ref2m, snw_rdsxy)
- 
+
+!cmrwrite
+   write(msg, *) 'cmr: after biophy_to_wrf h2osoi_liq = ',&
+                   maxval(h2osoi_liq),'h2osoi_ice = ', maxval(h2osoi_ice),&
+                    'h2osoi_vol = ',maxval(h2osoi_vol)
+   call CLMDebug(msg)
+
 
 #if (defined CN)
      call biochem_to_wrf(htmx_buf,croplive_buf,gdd1020_buf,gdd820_buf,gdd020_buf,grainc_buf,grainc_storage_buf  &
@@ -58488,6 +59106,26 @@
     alswvisdif = 0._r8
     alswnirdir = 0._r8
     alswnirdif = 0._r8
+    fpsn = 0._r8 !cmr
+    fpsn_mn = 0._r8 !cmr
+    fpsn_mx = 0._r8 !cmr
+    fpsn_nf = 0._r8 !cmr
+    ci_mr = 0._r8 !cmr
+    rs_mr = 0._r8 !cmr
+    rb_mr = 0._r8 !cmr
+    btran_mr = 0._r8 !cmr
+    apar_mr = 0._r8 !cmr
+    sla_mr = 0._r8 !cmr
+    vcmx_mr = 0._r8 !cmr
+    svpts_mr = 0._r8 !cmr
+    eah_mr = 0._r8 !cmr
+    reco = 0._r8 !cmr
+    reco_gpp = 0._r8 !cmr
+    reco_gppmn = 0._r8 !cmr
+    reco_gppmx = 0._r8 !cmr
+    wj = 0._r8 !cmr
+    we = 0._r8 !cmr
+    wc = 0._r8 !cmr
 !!
   
     do p = begp,endp 
@@ -58504,9 +59142,32 @@
 
         
        alswvisdir = alswvisdir + clm3%g%l%c%p%pps%albd(p,1)*wtp(p)
-       alswnirdif = alswnirdif + clm3%g%l%c%p%pps%albi(p,1)*wtp(p)
+       !cmr wrf3.5.1 bugfix alswnirdif = alswnirdif + clm3%g%l%c%p%pps%albi(p,1)*wtp(p)
+       alswvisdif = alswvisdif + clm3%g%l%c%p%pps%albi(p,1)*wtp(p)
        alswnirdir = alswnirdir + clm3%g%l%c%p%pps%albd(p,2)*wtp(p)  !1=visible, 2=nir
        alswnirdif = alswnirdif + clm3%g%l%c%p%pps%albi(p,2)*wtp(p) 
+!cmr get ecosystem exchange into output
+       fpsn       = fpsn+clm3%g%l%c%p%pcf%fpsn(p)*wtp(p) !cmr add up single values (wpt is weighting function for 10 veg. layers)
+       fpsn_mn       = fpsn_mn+clm3%g%l%c%p%pcf%fpsn_mn(p)*wtp(p) 
+       fpsn_mx       = fpsn_mx+clm3%g%l%c%p%pcf%fpsn_mx(p)*wtp(p)
+       fpsn_nf       = fpsn_nf+clm3%g%l%c%p%pcf%fpsn_nf(p)*wtp(p)
+       reco       = reco+clm3%g%l%c%p%pcf%reco(p)*wtp(p) 
+       reco_gpp   = reco_gpp+clm3%g%l%c%p%pcf%reco_gpp(p)*wtp(p) 
+       reco_gppmn   = reco_gppmn+clm3%g%l%c%p%pcf%reco_gppmn(p)*wtp(p) 
+       reco_gppmx   = reco_gppmx+clm3%g%l%c%p%pcf%reco_gppmx(p)*wtp(p) 
+       wj       = wj+clm3%g%l%c%p%pcf%wj(p)*wtp(p)
+       we       = we+clm3%g%l%c%p%pcf%we(p)*wtp(p)
+       wc       = wc+clm3%g%l%c%p%pcf%wc(p)*wtp(p)
+       ci_mr       = ci_mr+clm3%g%l%c%p%pps%ci_mr(p)*wtp(p) 
+       rs_mr       = rs_mr+clm3%g%l%c%p%pps%rs_mr(p)*wtp(p) 
+       rb_mr       = rb_mr+clm3%g%l%c%p%pps%rb_mr(p)*wtp(p) 
+       btran_mr       = btran_mr+clm3%g%l%c%p%pps%btran_mr(p)*wtp(p) 
+       apar_mr       = apar_mr+clm3%g%l%c%p%pps%apar_mr(p)*wtp(p) 
+       sla_mr       = sla_mr+clm3%g%l%c%p%pps%sla_mr(p)*wtp(p) 
+       vcmx_mr       = vcmx_mr+clm3%g%l%c%p%pps%vcmx_mr(p)*wtp(p) 
+       svpts_mr       = svpts_mr+clm3%g%l%c%p%pps%svpts_mr(p)*wtp(p) 
+       eah_mr       = eah_mr+clm3%g%l%c%p%pps%eah_mr(p)*wtp(p) 
+!cmr end
 
 !!PFT-level outputs
        if ( wtp(p) > 0.001 ) then
@@ -58543,6 +59204,7 @@
        qdnxy = qdnxy + clm3%g%l%c%cwf%qflx_drain(c)*wtc(c)*dtime
     end do
 !-------------------------------------------------------------------------
+
     call CLMDebug('call clmtype_dealloc')
     call clmtype_dealloc()
     call CLMDebug('call filters_dealloc')
@@ -58563,7 +59225,7 @@
 ! !ROUTINE: driver
 !
 ! !INTERFACE:
-subroutine driver (doalb,ilx,jlx,nextsw_cday, declinp1, declin)
+subroutine driver (doalb,ilx,jlx,nextsw_cday, declinp1,declin,atm_co2,valley_CO2pft2)
 !
 ! !DESCRIPTION:
 ! This subroutine provides the main CLM driver calling sequence.  Most
@@ -58740,7 +59402,8 @@
   real(r8), intent(in) :: nextsw_cday                   ! calendar day at Greenwich (1.00, ..., 365.99)
   real(r8), intent(in) :: declinp1                   ! declination angle (radians) for next time step
   real(r8), intent(in) :: declin      ! declination angle for current time step
-
+  real,dimension(3), intent(in) :: atm_co2 !cmr
+  integer, intent(in) :: valley_CO2pft2              ! cmr second pft with forcing of pft 1
 !temp value
   real(r8), pointer :: t_soisno(:,:)
 
@@ -59003,7 +59666,7 @@
 
      call CLMDebug('CanopyFluxes')  !checked and modified according to CLM4
      call CanopyFluxes(begg, endg, begc, endc, begp, endp, &
-                       filter%num_nolakep, filter%nolakep)
+                       filter%num_nolakep, filter%nolakep,atm_co2,valley_CO2pft2)
      ! ============================================================================
      ! Determine lake temperature and surface fluxes
      ! ============================================================================
@@ -59031,9 +59694,9 @@
      ! VOC emission (A. Guenther's model)
 !     call VOCEmission(begp, endp, &
 !                      filter%num_nolakep, filter%nolakep)      !CLM3.5
-     call CLMDebug('Begin VOCEmission')
-   call VOCEmission(begp, endp, &  
-                      filter%num_soilp, filter%soilp)   !CLM4  !checked and modified according to CLM4
+!     call CLMDebug('Begin VOCEmission')
+!   call VOCEmission(begp, endp, &  
+!                      filter%num_soilp, filter%soilp)   !CLM4  !checked and modified according to CLM4
 !#endif
 
      ! ============================================================================
diff -Nru WRFV3.5/phys/module_surface_driver.F WRFV3.5_MR/phys/module_surface_driver.F
--- WRFV3.5/phys/module_surface_driver.F	2013-03-15 22:28:41.000000000 +0100
+++ WRFV3.5_MR/phys/module_surface_driver.F	2014-12-17 11:53:55.908901000 +0100
@@ -221,7 +221,11 @@
      &          ,dl_u_bep                                             &                          
      &          ,tsk_save                                             & !for fractional seaice
      &          ,cldfra                                               & !ssib
-     &                                                             )
+     &          ,fco2,fco2mn,fco2mx,fco2nf,reco,reco_gpp,reco_gppmn   &
+     &          ,reco_gppmx,fpsn,fpsn_mn,fpsn_mx,fpsn_nf,fpsn_noslp   &
+     &          ,co2_clm,co2_clm2,co2_clm3,wj,we,wc,ci_mr,rs_mr,      & !cmr
+     &           rb_mr,btran_mr,apar_mr,sla_mr,vcmx_mr,svpts_mr,eah_mr& !cmr
+     &          ,valley_CO2pft2,valley_CO2backgr ) !cmr
               
 #if ( ! NMM_CORE == 1 )
    USE module_state_description, ONLY : SFCLAYSCHEME              &
@@ -897,9 +901,11 @@
    REAL, DIMENSION( ims:ime, jms:jme ) , INTENT(OUT), OPTIONAL  ::   NOAHRES
 
    INTEGER, INTENT(IN) :: MAXPATCH, inest
-
   integer, optional,  dimension(ims:ime,jms:jme ),intent(inout) :: numc,nump
-  real,    optional,  dimension(ims:ime,jms:jme ),intent(inout) :: sabv,sabg,lwup
+  real,    optional,  dimension(ims:ime,jms:jme ),intent(inout) :: sabv,sabg,lwup,fco2,fco2mn,fco2mx,fco2nf,reco,reco_gpp,reco_gppmn,reco_gppmx,fpsn,fpsn_mn,fpsn_mx,fpsn_nf,fpsn_noslp,wj,we,wc,ci_mr,rs_mr,rb_mr,btran_mr,apar_mr,sla_mr,vcmx_mr,svpts_mr,eah_mr !cmr
+  REAL,    optional,  DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT(INOUT ) :: co2_clm,co2_clm2,co2_clm3 !cmr
+  INTEGER :: valley_CO2pft2 !cmr
+  REAL :: valley_CO2backgr !cmr
   integer, optional,  dimension(ims:ime,1:maxpatch,jms:jme ),intent(inout) :: snl
   real,    optional,  dimension(ims:ime,jms:jme ),intent(inout) ::t2m_max,t2m_min,t2clm
   real,    optional,  dimension(ims:ime,1:maxpatch,jms:jme ),intent(inout) ::  &
@@ -2794,8 +2800,6 @@
          ENDIF
 
 
-       CALL wrf_debug(100,'in clmdrv')
-
        CALL clmdrv(dz8w,qv_curr,p8w, t_phy,tsk,                   &
                 hfx,qfx,lh,grdflx,qgh,gsw,swdown,               &
                 ra_sw_physics,history_interval,glw,smstav,smstot, &
@@ -2893,6 +2897,11 @@
                 ,dwt_frootn_to_litr1n,dwt_frootn_to_litr2n, dwt_frootn_to_litr3n &
                 ,dwt_livecrootn_to_cwdn,dwt_deadcrootn_to_cwdn,retransn &
 #endif
+                ,fco2,fco2mn,fco2mx,fco2nf,reco,reco_gpp,reco_gppmn,reco_gppmx & !cmr 
+                ,fpsn,fpsn_mn,fpsn_mx,fpsn_nf,fpsn_noslp & !cmr
+                ,co2_clm,co2_clm2,co2_clm3,wj,we,wc,ci_mr,rs_mr, & !cmr 
+                 rb_mr,btran_mr,apar_mr,sla_mr,vcmx_mr,svpts_mr,eah_mr,slope & !cmr 
+                ,valley_CO2pft2,valley_CO2backgr & !cmr
                  )
 
          IF ( FRACTIONAL_SEAICE == 1 ) THEN
diff -Nru WRFV3.5/README.valley WRFV3.5_MR/README.valley
--- WRFV3.5/README.valley	1970-01-01 01:00:00.000000000 +0100
+++ WRFV3.5_MR/README.valley	2014-12-17 11:53:56.267763000 +0100
@@ -0,0 +1,123 @@
+==================================================================================================
+README for valley changes and namelist variables
+==================================================================================================
+
+Version: WRFV3.4
+
+Author:  Johannes Wagner
+
+==================================================================================================
+
+&valley
+
+ :: valley_latitude        Latitude                                           [deg]         real
+
+ :: valley_longitude       Longitude                                          [deg]         real
+
+ :: valley_tsk             Skintemperature                                    [K]           real
+
+ :: valley_tsk_tmn         tsk+tsk_tmn=tmn                                    [K]           real
+
+ :: valley_lu_index        Landuse index                                      []            integer
+
+ :: valley_lai             Leaf area index                                    []            real
+
+ :: valley_vegfra          Vegetation fraction                                []            real
+
+ :: valley_ivgtyp          Vegetation type                                    []            integer
+
+ :: valley_isltyp          Soil type                                          []            integer
+
+ :: valley_tslb            Soil temperature init                              [K]           real
+
+ :: valley_smois           Soil moisture init                                 []            real
+
+ :: valley_canwat          Soil canopy water init                             []            real
+
+ :: valley_topo_hp_off     Offset of topo variable hp                         [m]           real
+                           (used in valley_calcstatistics)
+
+ :: valley_topo_hp         Topo variable hp                                   [m]           real
+
+ :: valley_topo_ly         Topo variable Ly                                   [m]           real
+                           entspr. valley half-length
+
+ :: valley_topo_sy         Topo variable Sy                                   [m]           real
+
+ :: valley_topo_sx         Topo variable Sx                                   [m]           real
+
+ :: valley_topo_x1         Topo variable X1                                   [m]           real
+
+ :: valley_topo_x2         Topo variable X2                                   [m]           real
+
+ :: valley_topo_x3         Topo variable X3                                   [m]           real
+
+ :: valley_topo_x4         Topo variable X4                                   [m]           real
+
+ :: valley_topo_shiftx     Topo variable shiftx                               [m]           real
+
+ :: valley_topo_shifty     Topo variable shifty                               [m]           real
+
+ :: valley_tke_lscale      Length scale for 3D TKE                            []            integer
+                           turbulence closure:
+                           0: WRF formulation
+                           1: Schmidli formulation: l=dx
+                           2: Scotti (Phys. Fluid A., 1993) formulation
+
+ :: valley_hfx_tke         definition of constant surface heat                []            integer
+                           flux (works only for isfflx = 0,2).
+                           0: hfx defined by tke_heat_flux
+                           1: hfx defined by valley_hfx
+
+ :: valley_hfx             Value for constant surface heat flux               [W m-2]       real
+
+ :: valley_randx           Add random perturbation to perturbation theta      []            integer
+                           in module_initialize_les.F
+                           0: no perturbation
+                           1: add aditional perturbation
+
+ :: valley_statistics      compute valley statistics in                       []            integer
+                           diagnostic_output_calc
+                           0: no
+                           1: yes
+                           averaged variables should be
+                           written out in auxiliary history
+                           stream (e.g. auxhist1).
+                           auxhist1_begin should not start
+                           before 2*valley_av
+                           Hint: if 0 is chosen valley_nst 
+                           should be 0, too.
+
+ :: valley_av              half of time averaging interval in                 [min]         integer
+                           integer minutes
+
+ :: valley_avstep          number of time steps after which                   []            integer
+                           routine valley_calcstatistics is called
+
+ :: valley_nst             time dimension of storing fields:                  []            integer
+                           should be an integer and has to be computed
+                           as follows: valley_nst =
+                             1 + (2*valley_av*60)/(valley_avstep*dt)
+                           Hint for large domains:
+                           => set valley_nst to 0 for ideal.exe
+                           => use correct valley_nst for wrf.exe
+                           Hint for valley_statistics = 0:
+                           => valley_nst should be 0, too
+
+ :: valley_avspdir         direction of horizontal averaging:                 []            integer
+                           1: along x-axis
+                           2: along y-axis
+
+ :: valley_avsptype        type of horizontal averaging:                      []            integer
+                           1: average along whole domain
+                           2: moving average
+
+ :: valley_avsp            half of space averaging interval in                [metres]      real
+                           in real metres. 
+                           The following rules must be valid:
+                           -- 2.*valley_avsp/dx or 2.*valley_avsp/dy 
+                              must be an integer (depending on the value 
+                              of valley_avspdir). 
+                           -- 2.*valley_avsp/dx < e_we - s_we+1 (if valley_avspdir=1)
+                           -- 2.*valley_avsp/dy < e_sn - s_sn+1 (if valley_avspdir=2)
+                           Only used if valley_avsptype = 2
diff -Nru WRFV3.5/Registry/registry.clm WRFV3.5_MR/Registry/registry.clm
--- WRFV3.5/Registry/registry.clm	2012-12-21 22:22:51.000000000 +0100
+++ WRFV3.5_MR/Registry/registry.clm	2014-12-17 11:53:56.176749000 +0100
@@ -56,7 +56,7 @@
 state   real    T_SOISNO_S3    i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "T_SOISNO_S3"     "3RD  SNOWLAYER TEMPERATURE"     "K"
 state   real    T_SOISNO_S4    i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "T_SOISNO_S4"     "4TH  SNOWLAYER TEMPERATURE"     "K"
 state   real    T_SOISNO_S5    i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "T_SOISNO_S5"     "5TH  SNOWLAYER TEMPERATURE"     "K"
-state   real    T_SOISNO1      i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "T_SOISNO1"       "1ST  SOILLAYER TEMPERATURE"     "K"
+state   real    T_SOISNO1      i4j      misc      1          Z     rdh=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "T_SOISNO1"       "1ST  SOILLAYER TEMPERATURE"     "K"
 state   real    T_SOISNO2      i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "T_SOISNO2"       "2ND  SOILLAYER TEMPERATURE"     "K"
 state   real    T_SOISNO3      i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "T_SOISNO3"       "3RD  SOILLAYER TEMPERATURE"     "K"
 state   real    T_SOISNO4      i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "T_SOISNO4"       "4TH  SOILLAYER TEMPERATURE"     "K"
@@ -89,7 +89,7 @@
 state   real    T_LAKE8        i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "T_LAKE8"         "8TH  LAKELAYER TEMPERATURE"     "K"
 state   real    T_LAKE9        i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "T_LAKE9"         "9TH  LAKELAYER TEMPERATURE"     "K"
 state   real    T_LAKE10       i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "T_LAKE10"        "10TH LAKELAYER TEMPERATURE"     "K"
-state   real    H2OSOI_VOL1    i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "H2OSOI_VOL1"      "1ST  SOILLAYER VOL MOIST"   "fraction"
+state   real    H2OSOI_VOL1    i4j      misc      1          Z     rdh=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "H2OSOI_VOL1"      "1ST  SOILLAYER VOL MOIST"   "fraction"
 state   real    H2OSOI_VOL2    i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "H2OSOI_VOL2"      "2ND  SOILLAYER VOL MOIST"   "fraction"
 state   real    H2OSOI_VOL3    i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "H2OSOI_VOL3"      "3RD  SOILLAYER VOL MOIST"   "fraction"
 state   real    H2OSOI_VOL4    i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "H2OSOI_VOL4"      "4TH  SOILLAYER VOL MOIST"   "fraction"
@@ -101,13 +101,43 @@
 state   real    H2OSOI_VOL10   i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "H2OSOI_VOL10"     "10TH SOILLAYER VOL MOIST"   "fraction"
 
 #Extra subgrid (PFT-level) output variables
-state   real    ALBEDOsubgrid  i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "ALBEDOsubgrid"    "PFT-level ALBEDO"           ""
-state   real    LHsubgrid      i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "LHsubgrid"        "PFT-level Latent Heat"      "W/m^2"
-state   real    HFXsubgrid     i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "HFXsubgrid"       "PFT-level Sensible Heat"    "W/m^2"
-state   real    LWUPsubgrid    i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "LWUPsubgrid"      "PFT-level Longwave Up"      "W/m^2"
+state   real    ALBEDOsubgrid  i4j      misc      1          Z     rdh=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "ALBEDOsubgrid"    "PFT-level ALBEDO"           ""
+state   real    LHsubgrid      i4j      misc      1          Z     rdh=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "LHsubgrid"        "PFT-level Latent Heat"      "W/m^2"
+state   real    HFXsubgrid     i4j      misc      1          Z     rdh=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "HFXsubgrid"       "PFT-level Sensible Heat"    "W/m^2"
+state   real    LWUPsubgrid    i4j      misc      1          Z     rdh=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "LWUPsubgrid"      "PFT-level Longwave Up"      "W/m^2"
 state   real    Q2subgrid      i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "Q2subgrid"        "PFT-level 2m Moisture"      "mixing ratio"
 state   real    SABVsubgrid    i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "SABVsubgrid"      "PFT-level SABV"             "W/m^2"
 state   real    SABGsubgrid    i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "SABGsubgrid"      "PFT-level SABG"             "W/m^2"
-state   real    NRAsubgrid     i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "NRAsubgrid"       "PFT-level Net Radiation"    "W/m^2"
-state   real    SWUPsubgrid    i4j      misc      1          Z     rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "SWUPsubgrid"      "PFT-level Shortwave Up"     "W/m^2"
+state   real    NRAsubgrid     i4j      misc      1          Z     rdh=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "NRAsubgrid"       "PFT-level Net Radiation"    "W/m^2"
+state   real    SWUPsubgrid    i4j      misc      1          Z     rdh=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "SWUPsubgrid"      "PFT-level Shortwave Up"     "W/m^2"
+!cmr begin: define variables for output
+state   real    FCO2           ij       misc      1          -     h                                                           "FCO2"             "net CO2 flux"               "umol CO2 /m**2 /s"
+state   real    FCO2mn         ij       misc      1          -     h                                                           "FCO2mn"            "min CO2 flux (b)"           "umol CO2 /m**2 /s"
+state   real    FCO2mx         ij       misc      1          -     h                                                           "FCO2mx"            "max CO2 flux (c)"           "umol CO2 /m**2 /s"
+state   real    FCO2nf         ij       misc      1          -     h                                                           "FCO2nf"            "no fbck CO2 flux"           "umol CO2 /m**2 /s"
+state   real    RECO           ij       misc      1          -     h                                                           "RECO"             "ecosys. respiration"        "umol CO2 /m**2 /s"
+state   real    RECO_GPP       ij       misc      1          -     h                                                           "RECO_GPP"         "ecosys. respiration linGPP" "umol CO2 /m**2 /s"
+state   real    RECO_GPPmn     ij       misc      1          -     h                                                           "RECO_GPPmn"         "minimal respiration linGPP" "umol CO2 /m**2 /s"
+state   real    RECO_GPPmx     ij       misc      1          -     h                                                           "RECO_GPPmx"         "maximal respiration linGPP" "umol CO2 /m**2 /s"
+state   real    FPSN           ij       misc      1          -     h                                                           "FPSN"             "photosythesis"              "umol CO2 /m**2 /s"
+state   real    FPSN_mn        ij       misc      1          -     h                                                           "FPSN_mn"            "minimal photosythesis"      "umol CO2 /m**2 /s"
+state   real    FPSN_mx        ij       misc      1          -     h                                                           "FPSN_mx"            "maximal photosythesis"      "umol CO2 /m**2 /s"
+state   real    FPSN_nf        ij       misc      1          -     h                                                           "FPSN_nf"            "photosythesis no feedback"  "umol CO2 /m**2 /s"
+state   real    FPSN_NOSLP     ij       misc      1          -     h                                                           "FPSN_NOSLP"         "psn without slope"        "umol CO2 /m**2 /s"
+state   real    CO2_CLM        ikj      misc      1          -     -                                                           "CO2_CLM"          "CO2 mixing ratio"           "ppmv"
+state   real    CO2_CLM2       ikj      misc      1          -     -                                                           "CO2_CLM2"          "CO2 mixing ratio min fpsn" "ppmv"
+state   real    CO2_CLM3       ikj      misc      1          -     -                                                           "CO2_CLM3"          "CO2 mixing ratio max fpsn" "ppmv"
+state   real    WJ             ij       misc      1          -     h                                                           "WJ"               "light lim. photosythesis"   "umol CO2 /m**2 /s"
+state   real    WE             ij       misc      1          -     h                                                           "WE"               "export lim. photosythesis"  "umol CO2 /m**2 /s"
+state   real    WC             ij       misc      1          -     h                                                           "WC"               "rubisco lim. photosythesi"  "umol CO2 /m**2 /s"
+state   real    CI_MR          ij       misc      1          -     h                                                           "CI_MR"            "Intracellular CO2"           "Pa"
+state   real    RS_MR          ij       misc      1          -     h                                                           "RS_MR"               "Stomatal resistance"        "(s/m)"
+state   real    RB_MR          ij       misc      1          -     -                                                           "RB_MR"               "boundary layer resistance"        "(s/m)"
+state   real    BTRAN_MR       ij       misc      1          -     -                                                           "BTRAN_MR"            "transpiration wetness factor"     "(0 to 1)"
+state   real    APAR_MR        ij       misc      1          -     -                                                           "APAR_MR"             "par absorbed per unit lai"        "(w/m**2)"
+state   real    SLA_MR         ij       misc      1          -     -                                                           "SLA_MR"              "specific leaf area"               "m^2/gC"
+state   real    VCMX_MR        ij       misc      1          -     -                                                           "VCMX_MR"             "maximum rate of carboxylation"    "umol co2/m**2/s"
+state   real    SVPTS_MR       ij       misc      1          -     h                                                           "SVPTS_MR"            "sat. vapor pr. at t_veg (pa)"    "umol co2/m**2/s"
+state   real    EAH_MR         ij       misc      1          -     h                                                           "EAH_MR"             "canopy air vapor pr. (pa)"    "umol co2/m**2/s"
+!cmr end
 # end of CLM variables ---------------------------------------------------------------------------------
diff -Nru WRFV3.5/Registry/Registry.EM_COMMON WRFV3.5_MR/Registry/Registry.EM_COMMON
--- WRFV3.5/Registry/Registry.EM_COMMON	2013-04-08 20:48:08.000000000 +0200
+++ WRFV3.5_MR/Registry/Registry.EM_COMMON	2014-12-17 11:53:56.136389000 +0100
@@ -55,8 +55,8 @@
 # interpolated with a mask, as lu_index supplies that mask.
 # this next 1 is for the HFSoLE/PET demo; writing these to auxhist1 output over MCEL for coupling
 # with wave model, only if compiled with -DMCELIO, JM 2003/05/29
-state    real  LU_INDEX         ij      misc        1         -     i012rh01d=(interp_fcnm)u=(copy_fcnm)   "LU_INDEX"              "LAND USE CATEGORY"         ""
-state    real  LU_MASK          ij      misc        1         -     i3h1     "LU_MASK"              "0 land 1 water"         ""
+state    real  LU_INDEX         ij      misc        1         -     i012r01d=(interp_fcnm)u=(copy_fcnm)   "LU_INDEX"              "LAND USE CATEGORY"         ""
+state    real  LU_MASK          ij      misc        1         -     i3h     "LU_MASK"              "0 land 1 water"         ""
 
 # znw, znu, dzs, and zs must be listed before any 3-d fields
 # in order for the grib output module to work correctly.  The grib output
@@ -64,8 +64,8 @@
 # dzs, and zs are not listed first, vertical level will not be encoded at 
 # time 0.
 
-state    real    znu            k       dyn_em      1         -     irh      "znu"  "eta values on half (mass) levels"  ""
-state    real    znw            k       dyn_em      1         Z     i0rh     "znw"  "eta values on full (w) levels"  ""
+state    real    znu            k       dyn_em      1         -     ir      "znu"  "eta values on half (mass) levels"  ""
+state    real    znw            k       dyn_em      1         Z     i0r     "znw"  "eta values on full (w) levels"  ""
 state    real   ZS              l        misc      -         Z     irh       "ZS"                    "DEPTHS OF CENTERS OF SOIL LAYERS"         "m"
 state    real   DZS             l        misc      -         Z     irh       "DZS"                   "THICKNESSES OF SOIL LAYERS"               "m"
 # cyl : variables for trajectory calculation
@@ -89,8 +89,8 @@
 state    real   xlat_gc        ij       dyn_em      1        -     i1  "XLAT_M" "latitude, positive north" "degrees"
 state    real   xlong_gc       ij       dyn_em      1        -     i1  "XLONG_M" "longitude, positive east" "degrees"
 state    real   ht_gc          ij       dyn_em      1        -     i1  "HGT_M" "topography elevation" "m"
-state    real   var_sso        ij       dyn_em      1        -     i01hr "var_sso" "variance of subgrid-scale orography" "m2"
-state    real   lap_hgt        ij       dyn_em      1        -     hr    "lap_hgt" "Laplacian of orography" "m"
+state    real   var_sso        ij       dyn_em      1        -     i01r "var_sso" "variance of subgrid-scale orography" "m2"
+state    real   lap_hgt        ij       dyn_em      1        -     r    "lap_hgt" "Laplacian of orography" "m"
 state    real   tsk_gc         ij       dyn_em      1        -     i1  "SKINTEMP"  "skin temperature"  "K"
 state    real   tavgsfc        ij       dyn_em      1        -     i1  "TAVGSFC"  "daily mean of surface air temperature"  "K"
 state    real   tmn_gc         ij       dyn_em      1        -     i1  "SOILTEMP"  "annual mean deep soil temperature"  "K"
@@ -247,12 +247,12 @@
 state    real   tau_soil            {fslay}     dyn_em      1      -      i3rh     "TAU_SOIL" "SCM soil forcing timescale" "s"
 state    real   soil_depth_force    {fslay}     dyn_em      1      -      i3rh     "SOIL_DEPTH_FORCE" "SCM depth at center of soil layers in forcing file" "1"
 
-state    real   hfx_force           -     dyn_em      1      -      i3rh     "HFX_FORCE" "SCM ideal surface sensible heat flux" "W m-2"
-state    real   lh_force            -     dyn_em      1      -      i3rh     "LH_FORCE" "SCM ideal surface latent heat flux" "W m-2"
-state    real   tsk_force           -     dyn_em      1      -      i3rh     "TSK_FORCE" "SCM ideal surface skin temperature" "W m-2"
-state    real   hfx_force_tend      -     dyn_em      1      -      i3rh     "HFX_FORCE_TEND" "SCM ideal surface sensible heat flux tendency" "W m-2 s-1"
-state    real   lh_force_tend       -     dyn_em      1      -      i3rh     "LH_FORCE_TEND" "SCM ideal surface latent heat flux tendency" "W m-2 s-1"
-state    real   tsk_force_tend      -     dyn_em      1      -      i3rh     "TSK_FORCE_TEND" "SCM ideal surface skin temperature tendency" "W m-2 s-1"
+state    real   hfx_force           -     dyn_em      1      -      i3r     "HFX_FORCE" "SCM ideal surface sensible heat flux" "W m-2"
+state    real   lh_force            -     dyn_em      1      -      i3r     "LH_FORCE" "SCM ideal surface latent heat flux" "W m-2"
+state    real   tsk_force           -     dyn_em      1      -      i3r     "TSK_FORCE" "SCM ideal surface skin temperature" "W m-2"
+state    real   hfx_force_tend      -     dyn_em      1      -      i3r     "HFX_FORCE_TEND" "SCM ideal surface sensible heat flux tendency" "W m-2 s-1"
+state    real   lh_force_tend       -     dyn_em      1      -      i3r     "LH_FORCE_TEND" "SCM ideal surface latent heat flux tendency" "W m-2 s-1"
+state    real   tsk_force_tend      -     dyn_em      1      -      i3r     "TSK_FORCE_TEND" "SCM ideal surface skin temperature tendency" "W m-2 s-1"
 
 
 # Mass
@@ -275,13 +275,13 @@
 i1       real   mu_tendf        ij     dyn_em      1          -     
 
 #diagnostic for looking at nest position in output. A mungy version of terrain height.
-state    real   nest_pos        ij     misc        1   -   rhu=(mark_domain)  "NEST_POS"
+state    real   nest_pos        ij     misc        1   -   ru=(mark_domain)  "NEST_POS"
 state    real   nest_mask       ij     misc        1   -   ru=(mark_domain)   "NEST_MASK"     "LOCATION OF NEST IF ANY"
 state    real   ht_coarse       ij     misc        1   -     r                -              "STORAGE FOR LOW-RES TERRAIN"
 
 
 # TKE
-state    real   tke            ikj     dyn_em      2         -       r        "tke"          "TURBULENCE KINETIC ENERGY"     "m2 s-2"
+state    real   tke            ikj     dyn_em      2         -       rh        "tke"          "TURBULENCE KINETIC ENERGY"     "m2 s-2"
 i1       real   tke_tend       ikj     dyn_em      1         -      
 
 # Pressure and Density
@@ -309,17 +309,17 @@
 i1       real   cqv            ikj     dyn_em      1         -     -
 i1       real   cqw            ikj     dyn_em      1         -     -
 i1       real   pm1            ikj     dyn_em      1         -     -
-state    real    fnm            k       dyn_em      1         -     irh       "fnm"  "upper weight for vertical stretching"  ""
-state    real    fnp            k       dyn_em      1         -     irh       "fnp"  "lower weight for vertical stretching"  ""
-state    real    rdnw           k       dyn_em      1         -     irh       "rdnw"  "inverse d(eta) values between full (w) levels"   ""
-state    real    rdn            k       dyn_em      1         -     irh       "rdn"  "inverse d(eta) values between half (mass) levels"   ""
-state    real    dnw            k       dyn_em      1         -     irh       "dnw" "d(eta) values between full (w) levels"   ""
-state    real    dn             k       dyn_em      1         -     irh       "dn " "d(eta) values between half (mass) levels"   ""
+state    real    fnm            k       dyn_em      1         -     ir       "fnm"  "upper weight for vertical stretching"  ""
+state    real    fnp            k       dyn_em      1         -     ir       "fnp"  "lower weight for vertical stretching"  ""
+state    real    rdnw           k       dyn_em      1         -     ir       "rdnw"  "inverse d(eta) values between full (w) levels"   ""
+state    real    rdn            k       dyn_em      1         -     ir       "rdn"  "inverse d(eta) values between half (mass) levels"   ""
+state    real    dnw            k       dyn_em      1         -     ir       "dnw" "d(eta) values between full (w) levels"   ""
+state    real    dn             k       dyn_em      1         -     ir       "dn " "d(eta) values between half (mass) levels"   ""
 state    real    t_base         k       dyn_em      1         -     ir        "t_base"               "BASE STATE T IN IDEALIZED CASES"         "K"      
 state    real    z              ikj     dyn_em      1         -     -         " " " " " "
 state    real    z_at_w         ikj     dyn_em      1         Z 
-state    real    cfn            -       misc      -         -     irh       "cfn"    "extrapolation constant"  ""
-state    real    cfn1           -       misc      -         -     irh       "cfn1"   "extrapolation constant"  ""
+state    real    cfn            -       misc      -         -     ir       "cfn"    "extrapolation constant"  ""
+state    real    cfn1           -       misc      -         -     ir       "cfn1"   "extrapolation constant"  ""
 state    integer step_number    -       misc      -         -     ir        "step_number"  ""
 
 # Idealized run
@@ -336,19 +336,19 @@
 state    integer last_dt_mm             - misc    -         -      r     "last_dt_mm"               "Relative month"                   "months"
 
 # hydrostatic pressure vars
-state    real   p_hyd           ikj     dyn_em      1         -      irh       "p_hyd"       "hydrostatic pressure"         "Pa"
+state    real   p_hyd           ikj     dyn_em      1         -      ir       "p_hyd"       "hydrostatic pressure"         "Pa"
 state    real   p_hyd_w         ikj     dyn_em      1         Z       r        "p_hyd_w"     "hydrostatic pressure at full levels"         "Pa"
 
 # 2m and 10m output diagnostics
-state    real   Q2               ij     misc        1         -     irh0{23}du     "Q2"                   "QV at 2 M"         "kg kg-1"
-state    real   T2               ij     misc        1         -     i01rh0{23}du   "T2"                   "TEMP at 2 M"       "K"
-state    real   TH2              ij     misc        1         -     irhdu     "TH2"                  "POT TEMP at 2 M"   "K"
+state    real   Q2               ij     misc        1         -     ir0{23}du     "Q2"                   "QV at 2 M"         "kg kg-1"
+state    real   T2               ij     misc        1         -     i01r0{23}du   "T2"                   "TEMP at 2 M"       "K"
+state    real   TH2              ij     misc        1         -     irdu     "TH2"                  "POT TEMP at 2 M"   "K"
 state    real   PSFC             ij     misc        1         -     i01rhdu   "PSFC"                 "SFC PRESSURE"      "Pa"
 
 # these next 2 are for the HFSoLE/PET demo; writing these to auxhist1 output over MCEL for coupling
 # with wave model, only if compiled with -DMCELIO, JM 2003/05/29
-state    real   U10              ij     misc        1         -     irh01du     "U10"                "U at 10 M"         "m s-1"
-state    real   V10              ij     misc        1         -     irh01du     "V10"                "V at 10 M"         "m s-1"
+state    real   U10              ij     misc        1         -     ir01du     "U10"                "U at 10 M"         "m s-1"
+state    real   V10              ij     misc        1         -     ir01du     "V10"                "V at 10 M"         "m s-1"
 
 # these next 4 are for observational nudging
 state    real   uratx           ij      misc        1         -      r          "URATX"            "Ratio of U over U10 on mass points "         "dimensionless"
@@ -357,22 +357,22 @@
 state    real   obs_savwt      hikj     dyn_em      1         X      -       "OBS_SAVWT"
 
 # Other
-state   real    rdx            -        misc      -         -     irh       "rdx"                   "INVERSE X GRID LENGTH"         ""      
-state   real    rdy            -        misc      -         -     irh       "rdy"                   "INVERSE Y GRID LENGTH"         ""      
+state   real    rdx            -        misc      -         -     ir       "rdx"                   "INVERSE X GRID LENGTH"         ""      
+state   real    rdy            -        misc      -         -     ir       "rdy"                   "INVERSE Y GRID LENGTH"         ""      
 state   real    dts            -        misc      -         -     ir        "dts"                   "SMALL TIMESTEP"         ""      
 state   real    dtseps         -        misc      -         -     ir        "dtseps"                "TIME WEIGHT CONSTANT FOR SMALL STEPS"         ""      
-state   real    resm           -        misc      -         -     irh       "resm"                  "TIME WEIGHT CONSTANT FOR SMALL STEPS"         ""      
-state   real    zetatop        -        misc      -         -     irh       "zetatop"               "ZETA AT MODEL TOP"         ""      
-state   real    cf1            -        misc      -         -     irh       "cf1"                   "2nd order extrapolation constant"         ""      
-state   real    cf2            -        misc      -         -     irh       "cf2"                   "2nd order extrapolation constant"         ""      
-state   real    cf3            -        misc      -         -     irh       "cf3"                   "2nd order extrapolation constant"         ""      
+state   real    resm           -        misc      -         -     ir       "resm"                  "TIME WEIGHT CONSTANT FOR SMALL STEPS"         ""      
+state   real    zetatop        -        misc      -         -     ir       "zetatop"               "ZETA AT MODEL TOP"         ""      
+state   real    cf1            -        misc      -         -     ir       "cf1"                   "2nd order extrapolation constant"         ""      
+state   real    cf2            -        misc      -         -     ir       "cf2"                   "2nd order extrapolation constant"         ""      
+state   real    cf3            -        misc      -         -     ir       "cf3"                   "2nd order extrapolation constant"         ""      
 state   integer number_at_same_level    -         -         -     -          -        "number_at_same_level"  ""         ""      
 state   real    radtacttime    -        -         -         -     r         "radtacttime"              "RADTACTTIME"         "LW SW ACTIVATION TIME in s"
 state   real    bldtacttime    -        -         -         -     r         "bldtacttime"              "BLDTACTTIME"         "PBL   ACTIVATION TIME in s"
 state   real    cudtacttime    -        -         -         -     r         "cudtacttime"              "CUDTACTTIME"         "CPS   ACTIVATION TIME in s"
 
 # State for derived time quantities.  
-state   integer itimestep      -        -          -         -     rh         "itimestep"             ""         ""      
+state   integer itimestep      -        -          -         -     r         "itimestep"             ""         ""      
 state   real    xtime          -        -          -         -     rh         "xtime"                 "minutes since simulation start"         ""      
 state   real    julian         -        -          -         -     -          "julian"                "day of year, 0.0 at 0Z on 1 Jan."         "days"      
 
@@ -415,13 +415,13 @@
 state   real    qr             ikjftb   moist       1         -     \
    i0rhusdf=(bdy_interp:dt)  "QRAIN"            "Rain water mixing ratio"       "kg kg-1"
 state   real    qi             ikjftb   moist       1         -     \
-   i0rhusdf=(bdy_interp:dt)  "QICE"             "Ice mixing ratio"              "kg kg-1"
+   i0rusdf=(bdy_interp:dt)  "QICE"             "Ice mixing ratio"              "kg kg-1"
 state   real    qs             ikjftb   moist       1         -     \
-   i0rhusdf=(bdy_interp:dt)  "QSNOW"            "Snow mixing ratio"             "kg kg-1"
+   i0rusdf=(bdy_interp:dt)  "QSNOW"            "Snow mixing ratio"             "kg kg-1"
 state   real    qg             ikjftb   moist       1         -     \
-   i0rhusdf=(bdy_interp:dt)  "QGRAUP"           "Graupel mixing ratio"          "kg kg-1"
+   i0rusdf=(bdy_interp:dt)  "QGRAUP"           "Graupel mixing ratio"          "kg kg-1"
 state   real    qh             ikjftb   moist       1         -     \
-   i0rhusdf=(bdy_interp:dt)  "QHAIL"            "Hail mixing ratio"             "kg kg-1"
+   i0rusdf=(bdy_interp:dt)  "QHAIL"            "Hail mixing ratio"             "kg kg-1"
 state   real    -              ikjftb   dfi_moist       1         -     -    -
 state   real    dfi_qv         ikjftb   dfi_moist       1         -     \
    rusdf=(bdy_interp:dt)  "DFI_QVAPOR"       "Water vapor mixing ratio"      "kg kg-1"
@@ -558,9 +558,9 @@
 state   real   toposlpy            ij    misc          1     -     i012rdu "TOPOSLPY"      "ELEVATION Y SLOPE"  ""
 state   real   slope               ij    misc          1     -     rdu     "SLOPE"         "ELEVATION SLOPE"  ""
 state   real   slp_azi             ij    misc          1     -     rdu     "SLP_AZI"       "ELEVATION SLOPE AZIMUTH"  "rad"
-state   real   shdmax              ij    misc          1     -     i012rhd=(interp_mask_land_field:lu_index)u=(copy_fcnm)   "SHDMAX"        "ANNUAL MAX VEG FRACTION" ""
-state   real   shdmin              ij    misc          1     -     i012rhd=(interp_mask_land_field:lu_index)u=(copy_fcnm)   "SHDMIN"        "ANNUAL MIN VEG FRACTION" ""
-state   real   snoalb              ij    misc          1     -     i012rh  "SNOALB"        "ANNUAL MAX SNOW ALBEDO IN FRACTION" ""
+state   real   shdmax              ij    misc          1     -     i012rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)   "SHDMAX"        "ANNUAL MAX VEG FRACTION" ""
+state   real   shdmin              ij    misc          1     -     i012rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)   "SHDMIN"        "ANNUAL MIN VEG FRACTION" ""
+state   real   snoalb              ij    misc          1     -     i012r  "SNOALB"        "ANNUAL MAX SNOW ALBEDO IN FRACTION" ""
 state   real   slopecat            ij    misc          1     -     i12     "SLOPECAT"      "SLOPE CATEGORY"  ""
 state   real   toposoil            ij    misc          1     -     i12     "SOILHGT"       "ELEVATION OF LSM DATA"  "m"
 state   real   landusef            iuj   misc          1     Z     i012r   "LANDUSEF"      "LANDUSE FRACTION BY CATEGORY"  ""
@@ -575,7 +575,7 @@
 
 # soil model variables  (Note that they are marked as staggered in the vertical dimension
 # because they are "fully dimensioned" -- they use every element in that dim
-state    real   TSLB           ilj       misc      1         Z     i02rhd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "TSLB"     "SOIL TEMPERATURE"   "K"
+state    real   TSLB           ilj       misc      1         Z     ih02rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)           "TSLB"     "SOIL TEMPERATURE"   "K"
 
 # Time series variables
 state    real   ts_hour         ?!       misc      -         -      -        "TS_HOUR"        "Model integration time, hours"
@@ -632,42 +632,42 @@
 
 # lsm State Variables
 
-state    real   SMOIS            ilj     -          1         Z     i02rhd=(interp_mask_land_field:lu_index)u=(copy_fcnm)    "SMOIS"            "SOIL MOISTURE"     "m3 m-3"
-state    real   SH2O             ilj     -          1         Z     i02rhd=(interp_mask_land_field:lu_index)u=(copy_fcnm)    "SH2O"             "SOIL LIQUID WATER" "m3 m-3"
-state    real   SMCREL           ilj     -          1         Z     i02rhd=(interp_mask_land_field:lu_index)u=(copy_fcnm)    "SMCREL"           "RELATIVE SOIL MOISTURE" ""
-state    real   XICE             ij     misc        1         -     i0124rhd=(interp_mask_water_field:lu_index,isice)u=(copy_fcnm)  "SEAICE"             "SEA ICE FLAG"  ""
-state    real   ICEDEPTH         ij     misc        1         -     i0124rhd=(interp_mask_water_field:lu_index,isice)u=(copy_fcnm)  "ICEDEPTH"     "SEA ICE THICKNESS"  "m"
-state    real   XICEM            ij     misc        1         -     rhd=(interp_mask_water_field:lu_index,isice)u=(copy_fcnm)  "XICEM"             "SEA ICE FLAG (PREVIOUS STEP)"  ""
-state    real   ALBSI            ij     misc        1         -     i0124rhd=(interp_mask_water_field:lu_index,isice)u=(copy_fcnm)  "ALBSI"        "SEA ICE ALBEDO"  ""
-state    real   SNOWSI           ij     misc        1         -     i0124rhd=(interp_mask_water_field:lu_index,isice)u=(copy_fcnm)  "SNOWSI"       "SNOW DEPTH ON SEA ICE"  "m"
+state    real   SMOIS            ilj     -          1         Z     i02rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)    "SMOIS"            "SOIL MOISTURE"     "m3 m-3"
+state    real   SH2O             ilj     -          1         Z     i02rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)    "SH2O"             "SOIL LIQUID WATER" "m3 m-3"
+state    real   SMCREL           ilj     -          1         Z     i02rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)    "SMCREL"           "RELATIVE SOIL MOISTURE" ""
+state    real   XICE             ij     misc        1         -     i0124rd=(interp_mask_water_field:lu_index,isice)u=(copy_fcnm)  "SEAICE"             "SEA ICE FLAG"  ""
+state    real   ICEDEPTH         ij     misc        1         -     i0124rd=(interp_mask_water_field:lu_index,isice)u=(copy_fcnm)  "ICEDEPTH"     "SEA ICE THICKNESS"  "m"
+state    real   XICEM            ij     misc        1         -     rd=(interp_mask_water_field:lu_index,isice)u=(copy_fcnm)  "XICEM"             "SEA ICE FLAG (PREVIOUS STEP)"  ""
+state    real   ALBSI            ij     misc        1         -     i0124rd=(interp_mask_water_field:lu_index,isice)u=(copy_fcnm)  "ALBSI"        "SEA ICE ALBEDO"  ""
+state    real   SNOWSI           ij     misc        1         -     i0124rd=(interp_mask_water_field:lu_index,isice)u=(copy_fcnm)  "SNOWSI"       "SNOW DEPTH ON SEA ICE"  "m"
 state    real   SMSTAV           ij     misc        1         -      rd=(interp_mask_land_field:lu_index)       "SMSTAV"           "MOISTURE AVAILABILITY" ""
 state    real   SMSTOT           ij     misc        1         -      r                                          "SMSTOT"           "TOTAL SOIL MOISTURE" "m3 m-3"
 state    real   SOLDRAIN         ij     misc        1         -      r                                          "SOLDRAIN"         "soil column drainage"  "mm"
 state    real   SFCHEADRT        ij     misc        1         -      r                                          "SFCHEADRT"        "surface water depth"  "mm"
 state    real   INFXSRT          ij     misc        1         -      r                                          "INFXSRT"          "time step infiltration excess"  "mm"
-state    real   SFCRUNOFF        ij     misc        1         -      rhd=(interp_mask_land_field:lu_index)      "SFROFF"           "SURFACE RUNOFF"     "mm"
-state    real   UDRUNOFF         ij     misc        1         -      rhd=(interp_mask_land_field:lu_index)      "UDROFF"           "UNDERGROUND RUNOFF" "mm"
-state  integer  IVGTYP           ij     misc        1         -     i02rhd=(interp_fcni)u=(copy_fcni)           "IVGTYP"           "DOMINANT VEGETATION CATEGORY" ""
-state  integer  ISLTYP           ij     misc        1         -     i02rhd=(interp_fcni)u=(copy_fcni)           "ISLTYP"           "DOMINANT SOIL CATEGORY"       ""
-state    real   VEGFRA           ij     misc        1         -     i024rhd=(interp_mask_land_field:lu_index)u=(copy_fcnm)   "VEGFRA"           "VEGETATION FRACTION" ""
+state    real   SFCRUNOFF        ij     misc        1         -      rd=(interp_mask_land_field:lu_index)      "SFROFF"           "SURFACE RUNOFF"     "mm"
+state    real   UDRUNOFF         ij     misc        1         -      rd=(interp_mask_land_field:lu_index)      "UDROFF"           "UNDERGROUND RUNOFF" "mm"
+state  integer  IVGTYP           ij     misc        1         -     i02rd=(interp_fcni)u=(copy_fcni)           "IVGTYP"           "DOMINANT VEGETATION CATEGORY" ""
+state  integer  ISLTYP           ij     misc        1         -     i02rd=(interp_fcni)u=(copy_fcni)           "ISLTYP"           "DOMINANT SOIL CATEGORY"       ""
+state    real   VEGFRA           ij     misc        1         -     i024rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)   "VEGFRA"           "VEGETATION FRACTION" ""
 state    real   SFCEVP           ij     misc        1         -      r                                          "SFCEVP"           "ACCUMULATED SURFACE EVAPORATION" "kg m-2"
 state    real   GRDFLX           ij     misc        1         -      rh                                         "GRDFLX"           "GROUND HEAT FLUX" "W m-2"
-state    real   ACGRDFLX         ij     misc        1         -      rhdu                                       "ACGRDFLX"         "ACCUMULATED GROUND HEAT FLUX" "J m-2"
+state    real   ACGRDFLX         ij     misc        1         -      rdu                                       "ACGRDFLX"         "ACCUMULATED GROUND HEAT FLUX" "J m-2"
 state    real   SFCEXC           ij     misc        1         -      r                                          "SFCEXC "          "SURFACE EXCHANGE COEFFICIENT"   "m s-1"
 
 state    real   ACSNOW           ij     misc        1         -      rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)       "ACSNOW"           "ACCUMULATED SNOW"         "kg m-2"
-state    real   ACSNOM           ij     misc        1         -      rhd=(interp_mask_land_field:lu_index)u=(copy_fcnm)       "ACSNOM"           "ACCUMULATED MELTED SNOW"  "kg m-2"
-state    real   SNOW             ij     misc        1         -     i012rhd=(interp_mask_land_field:lu_index)u=(copy_fcnm)    "SNOW"             "SNOW WATER EQUIVALENT"    "kg m-2"
-state    real   SNOWH            ij     misc        1         -     i012rhd=(interp_mask_land_field:lu_index)u=(copy_fcnm)    "SNOWH"            "PHYSICAL SNOW DEPTH"      "m"
+state    real   ACSNOM           ij     misc        1         -      rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)       "ACSNOM"           "ACCUMULATED MELTED SNOW"  "kg m-2"
+state    real   SNOW             ij     misc        1         -     i012rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)    "SNOW"             "SNOW WATER EQUIVALENT"    "kg m-2"
+state    real   SNOWH            ij     misc        1         -     i012rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)    "SNOWH"            "PHYSICAL SNOW DEPTH"      "m"
 #state    real   RHOSN            ij     misc        1         -    i02rhd=(interp_mask_land_field:lu_index)u=(copy_fcnm)    "RHOSN"            " SNOW DENSITY"      "kg m-3" 
-state    real   CANWAT           ij     misc        1         -     i012rhd=(interp_mask_land_field:lu_index)u=(copy_fcnm)    "CANWAT"           "CANOPY WATER"             "kg m-2"
+state    real   CANWAT           ij     misc        1         -     i012rd=(interp_mask_land_field:lu_index)u=(copy_fcnm)    "CANWAT"           "CANOPY WATER"             "kg m-2"
 state  integer  IFNDSNOWH        -      misc        1         -     i         "FNDSNOWH" "SNOWH_LOGICAL"
 state  integer  IFNDSOILW        -      misc        1         -     i         "FNDSOILW" "SOILW_LOGICAL"
 state  integer  IFNDALBSI        -      misc        1         -     i         "FNDALBSI" "ALBSI_LOGICAL"
 state  integer  IFNDSNOWSI       -      misc        1         -     i         "FNDSNOWSI" "SNOWSI_LOGICAL"
 state  integer  IFNDICEDEPTH     -      misc        1         -     i         "FNDICEDEPTH" "ICEDEPTH_LOGICAL"
 # SKIN SST
-state    real   SSTSK            ij     misc        1         -     rhd=(interp_mask_water_field:lu_index,iswater)   "SSTSK"              "SKIN SEA SURFACE TEMPERATURE" "K"
+state    real   SSTSK            ij     misc        1         -     rd=(interp_mask_water_field:lu_index,iswater)   "SSTSK"              "SKIN SEA SURFACE TEMPERATURE" "K"
 state    real   DTW              ij     misc        1         -     r   "DTW"              "WARM LAYER TEMP DIFF" "C"
 
 # DFI variables
@@ -769,7 +769,7 @@
 # Additional for P-X PBL and LSM
 state    real   RA               ij     misc        1         -      r        "RA"           "AERODYNAMIC RESISTANCE"   "s m-1"
 state    real   RS               ij     misc        1         -      r        "RS"           "SURFACE RESISTANCE"       "s m-1"
-state    real   LAI              ij     misc        1         -      i0124rh       "LAI"          "Leaf area index"          "area/area"
+state    real   LAI              ij     misc        1         -      i0124r       "LAI"          "Leaf area index"          "area/area"
 state    real   VEGF_PX          ij     misc        1         -      r        "VEGF_PX"      "Vegetation Fraction for PX LSM"    "area/area"
 state    real   T2OBS            ij     misc        1         -      r        "T2OBS"        "2-m temperature from analysis "          "K"
 state    real   Q2OBS            ij     misc        1         -      r        "Q2OBS"        "2-m mixing ratio from analysis "         "kg/kg"
@@ -991,21 +991,21 @@
 
 # Other Misc State Variables                                            
 state   real    h_diabatic     ikj     misc         1         -      rdu      "h_diabatic"            "MICROPHYSICS LATENT HEATING"         "K s-1"      
-state   real    msft           ij      misc         1         -     i012rhdu=(copy_fcnm)    "MAPFAC_M"         "Map scale factor on mass grid" ""
-state   real    msfu           ij      misc         1         X     i012rhdu=(copy_fcnm)    "MAPFAC_U"         "Map scale factor on u-grid" ""
-state   real    msfv           ij      misc         1         Y     i012rhdu=(copy_fcnm)    "MAPFAC_V"         "Map scale factor on v-grid" ""
-state   real    msftx          ij      misc         1         -     i012rhdu=(copy_fcnm)    "MAPFAC_MX"         "Map scale factor on mass grid, x direction" ""
-state   real    msfty          ij      misc         1         -     i012rhdu=(copy_fcnm)    "MAPFAC_MY"         "Map scale factor on mass grid, y direction" ""
-state   real    msfux          ij      misc         1         X     i012rhdu=(copy_fcnm)    "MAPFAC_UX"         "Map scale factor on u-grid, x direction" ""
-state   real    msfuy          ij      misc         1         X     i012rhdu=(copy_fcnm)    "MAPFAC_UY"         "Map scale factor on u-grid, y direction" ""
-state   real    msfvx          ij      misc         1         Y     i012rhdu=(copy_fcnm)    "MAPFAC_VX"         "Map scale factor on v-grid, x direction" ""
-state   real    msfvx_inv      ij      misc         1         Y     i012rhdu=(copy_fcnm)    "MF_VX_INV"         "Inverse map scale factor on v-grid, x direction" ""
-state   real    msfvy          ij      misc         1         Y     i012rhdu=(copy_fcnm)    "MAPFAC_VY"         "Map scale factor on v-grid, y direction" ""
-
-state   real    f              ij      misc         1         -     i012rhdu=(copy_fcnm)    "f"                "Coriolis sine latitude term"  "s-1"
-state   real    e              ij      misc         1         -     i012rhdu=(copy_fcnm)    "e"                "Coriolis cosine latitude term"  "s-1"
-state   real    sina           ij      misc         1         -     i012rhdu=(copy_fcnm)    "SINALPHA"         "Local sine of map rotation"   ""
-state   real    cosa           ij      misc         1         -     i012rhdu=(copy_fcnm)    "COSALPHA"         "Local cosine of map rotation"  ""
+state   real    msft           ij      misc         1         -     i012rdu=(copy_fcnm)    "MAPFAC_M"         "Map scale factor on mass grid" ""
+state   real    msfu           ij      misc         1         X     i012rdu=(copy_fcnm)    "MAPFAC_U"         "Map scale factor on u-grid" ""
+state   real    msfv           ij      misc         1         Y     i012rdu=(copy_fcnm)    "MAPFAC_V"         "Map scale factor on v-grid" ""
+state   real    msftx          ij      misc         1         -     i012rdu=(copy_fcnm)    "MAPFAC_MX"         "Map scale factor on mass grid, x direction" ""
+state   real    msfty          ij      misc         1         -     i012rdu=(copy_fcnm)    "MAPFAC_MY"         "Map scale factor on mass grid, y direction" ""
+state   real    msfux          ij      misc         1         X     i012rdu=(copy_fcnm)    "MAPFAC_UX"         "Map scale factor on u-grid, x direction" ""
+state   real    msfuy          ij      misc         1         X     i012rdu=(copy_fcnm)    "MAPFAC_UY"         "Map scale factor on u-grid, y direction" ""
+state   real    msfvx          ij      misc         1         Y     i012rdu=(copy_fcnm)    "MAPFAC_VX"         "Map scale factor on v-grid, x direction" ""
+state   real    msfvx_inv      ij      misc         1         Y     i012rdu=(copy_fcnm)    "MF_VX_INV"         "Inverse map scale factor on v-grid, x direction" ""
+state   real    msfvy          ij      misc         1         Y     i012rdu=(copy_fcnm)    "MAPFAC_VY"         "Map scale factor on v-grid, y direction" ""
+
+state   real    f              ij      misc         1         -     i012rdu=(copy_fcnm)    "f"                "Coriolis sine latitude term"  "s-1"
+state   real    e              ij      misc         1         -     i012rdu=(copy_fcnm)    "e"                "Coriolis cosine latitude term"  "s-1"
+state   real    sina           ij      misc         1         -     i012rdu=(copy_fcnm)    "SINALPHA"         "Local sine of map rotation"   ""
+state   real    cosa           ij      misc         1         -     i012rdu=(copy_fcnm)    "COSALPHA"         "Local cosine of map rotation"  ""
 state   real    ht             ij      misc         1         -     i012rhdus  "HGT"              "Terrain Height"   "m"
 state   real    ht_fine        ij      misc         1         -     -          "HGT_FINE"         "Fine Terrain Height"   "m"
 state   real    ht_int         ij      misc         1         -     -          "HGT_INT"          "Terrain Height Horizontally Interpolated"   "m"
@@ -1033,13 +1033,13 @@
 # collision between a metadata name and a field record in the I/O data
 # resolve this how?  Have the real program throw a switch to tell the code to get it
 # from the metadata?  Otherwise it's a field?
-state   real    p_top          -       misc         -         -     irh       "p_top"                 "PRESSURE TOP OF THE MODEL"  "Pa"
+state   real    p_top          -       misc         -         -     ir       "p_top"                 "PRESSURE TOP OF THE MODEL"  "Pa"
 state   real    t00            -       misc         -         -     i02rh     "t00"                   "BASE STATE TEMPERATURE   "  "K"
 state   real    p00            -       misc         -         -     i02rh     "p00"                   "BASE STATE PRESURE"         "Pa"
 state   real    tlp            -       misc         -         -     i02rh     "tlp"                   "BASE STATE LAPSE RATE    "  ""
-state   real    tiso           -       misc         -         -     i02rh     "tiso"                  "TEMP AT WHICH THE BASE T TURNS CONST"  "K"
-state   real    max_msftx      -       misc         -         -      rh       "max_mstfx"             "Max map factor in domain"  ""
-state   real    max_msfty      -       misc         -         -      rh       "max_mstfy"             "Max map factor in domain"  ""
+state   real    tiso           -       misc         -         -     i02r     "tiso"                  "TEMP AT WHICH THE BASE T TURNS CONST"  "K"
+state   real    max_msftx      -       misc         -         -      r       "max_mstfx"             "Max map factor in domain"  ""
+state   real    max_msfty      -       misc         -         -      r       "max_mstfy"             "Max map factor in domain"  ""
 
 # State variables for Goddard LW and SW radiation
 state    real  TLWDN           ij      misc        1         -      h         "TLWDN"                 "TOA LW downwelling flux"           "W m-2"
@@ -1077,24 +1077,24 @@
 state    real  RQINCUTEN       ikj      misc        1         -      r       "RQINCUTEN"             "COUPLED Q_IN TENDENCY DUE TO CUMULUS SCHEME"       "Pa kg kg-1 s-1"
 state    real  W0AVG           ikj      misc        1         -      r        "W0AVG"                 "AVERAGE VERTICAL VELOCITY FOR KF CUMULUS SCHEME"         "m s-1"
 
-state    real  RAINC            ij      misc        1         -      rhdu     "RAINC"                 "ACCUMULATED TOTAL CUMULUS PRECIPITATION"                 "mm"      
-state    real  RAINSH           ij      misc        1         -      rhdu     "RAINSH"                "ACCUMULATED SHALLOW CUMULUS PRECIPITATION"               "mm"
-state    real  RAINNC           ij      misc        1         -      rhdu     "RAINNC"                "ACCUMULATED TOTAL GRID SCALE PRECIPITATION"              "mm"      
-state  integer I_RAINC          ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_RAINC"            "BUCKET FOR RAINC"                    ""
-state  integer I_RAINNC         ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_RAINNC"           "BUCKET FOR RAINNC"                   ""
+state    real  RAINC            ij      misc        1         -      rdu     "RAINC"                 "ACCUMULATED TOTAL CUMULUS PRECIPITATION"                 "mm"      
+state    real  RAINSH           ij      misc        1         -      rdu     "RAINSH"                "ACCUMULATED SHALLOW CUMULUS PRECIPITATION"               "mm"
+state    real  RAINNC           ij      misc        1         -      rdu     "RAINNC"                "ACCUMULATED TOTAL GRID SCALE PRECIPITATION"              "mm"      
+state  integer I_RAINC          ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_RAINC"            "BUCKET FOR RAINC"                    ""
+state  integer I_RAINNC         ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_RAINNC"           "BUCKET FOR RAINNC"                   ""
 state    real  PRATEC           ij      misc        1         -      r        "PRATEC"                "PRECIP RATE FROM CUMULUS SCHEME"                         "mm s-1"
 state    real  PRATESH          ij      misc        1         -      r        "PRATESH"               "PRECIP RATE FROM SHALLOW CUMULUS SCHEME"                 "mm s-1"
 state    real  RAINCV           ij      misc        1         -      r        "RAINCV"                "TIME-STEP CUMULUS PRECIPITATION"                         "mm"
 state    real  RAINSHV          ij      misc        1         -      r        "RAINSHV"               "TIME-STEP SHALLOW CUMULUS PRECIPITATION"                 "mm"
 state    real  RAINNCV          ij      misc        1         -      r        "RAINNCV"               "TIME-STEP NONCONVECTIVE PRECIPITATION"                   "mm"
 state    real  RAINBL           ij      misc        1         -      r        "RAINBL"                "PBL TIME-STEP TOTAL PRECIPITATION"                       "mm"      
-state    real  SNOWNC           ij      misc        1         -      rhdu     "SNOWNC"                "ACCUMULATED TOTAL GRID SCALE SNOW AND ICE"               "mm"
-state    real  GRAUPELNC        ij      misc        1         -      rhdu     "GRAUPELNC"             "ACCUMULATED TOTAL GRID SCALE GRAUPEL"                    "mm"
-state    real  HAILNC           ij      misc        1         -      rhdu     "HAILNC"                "ACCUMULATED TOTAL GRID SCALE HAIL"                       "mm"
+state    real  SNOWNC           ij      misc        1         -      rdu     "SNOWNC"                "ACCUMULATED TOTAL GRID SCALE SNOW AND ICE"               "mm"
+state    real  GRAUPELNC        ij      misc        1         -      rdu     "GRAUPELNC"             "ACCUMULATED TOTAL GRID SCALE GRAUPEL"                    "mm"
+state    real  HAILNC           ij      misc        1         -      rdu     "HAILNC"                "ACCUMULATED TOTAL GRID SCALE HAIL"                       "mm"
 state    real  SNOWNCV          ij      misc        1         -      r        "SNOWNCV"               "TIME-STEP NONCONVECTIVE SNOW AND ICE"                    "mm"
 state    real  GRAUPELNCV       ij      misc        1         -      r        "GRAUPELNCV"            "TIME-STEP NONCONVECTIVE GRAUPEL"                         "mm"
 state    real  HAILNCV          ij      misc        1         -      r        "HAILNCV"               "TIME-STEP NONCONVECTIVE HAIL"                            "mm"
-state    real    refl_10cm      ikj     dyn_em      1         -     hdu       "refl_10cm"             "Radar reflectivity (lamda = 10 cm)"  "dBZ"
+state    real    refl_10cm      ikj     dyn_em      1         -     du       "refl_10cm"             "Radar reflectivity (lamda = 10 cm)"  "dBZ"
 state    real  NCA              ij      misc        1         -      r        "NCA"                   "COUNTER OF THE CLOUD RELAXATION TIME IN KF CUMULUS SCHEME"    ""      
 state    integer  LOWLYR        ij      misc        1         -     -         "LOWLYR"                "INDEX OF LOWEST MODEL LAYER ABOVE THE GROUND IN BMJ SCHEME"   ""      
 state    real  MASS_FLUX        ij      misc        1         -      r        "MASS_FLUX"             "DOWNDRAFT MASS FLUX FOR IN GRELL CUMULUS SCHEME"  "mb hour-1"
@@ -1141,7 +1141,7 @@
 state    real  RTHRATEN        ikj      misc        1         -      rd       "RTHRATEN"              "COUPLED THETA TENDENCY DUE TO RADIATION"              "Pa K s-1"
 state    real  RTHRATENLW      ikj      misc        1         -      r        "RTHRATLW"              "UNCOUPLED THETA TENDENCY DUE TO LONG WAVE RADIATION"    "K s-1"
 state    real  RTHRATENSW      ikj      misc        1         -      r        "RTHRATSW"              "UNCOUPLED THETA TENDENCY DUE TO SHORT WAVE RADIATION"   "K s-1"
-state    real  CLDFRA          ikj      misc        1         -      rh       "CLDFRA"                "CLOUD FRACTION"                                       ""
+state    real  CLDFRA          ikj      misc        1         -      r       "CLDFRA"                "CLOUD FRACTION"                                       ""
 state    real  CLDFRA_OLD      ikj      misc        1         -      r        "CLDFRA_OLD"            "previous time level cldfra"                           ""
 
 state    real  SWDOWN           ij      misc        1         -      rhd      "SWDOWN"                "DOWNWARD SHORT WAVE FLUX AT GROUND SURFACE"           "W m-2"      
@@ -1189,38 +1189,38 @@
 state    real  RAINNCVSTD       ij      misc        1         -      rh3      "RAINNCVSTD"             "STANDARD DEV. GRID SCALE PRECIPITATION IN FLUX DIAGNOSTIC OUTPUT INTERVAL"          "kg m-2 s-1"
 
 # upward and downward clearsky and total diagnostic fluxes for CAM radiation
-state    real  ACSWUPT          ij      misc        1         -      rhdu     "ACSWUPT"               "ACCUMULATED UPWELLING SHORTWAVE FLUX AT TOP"          "J m-2"
-state    real  ACSWUPTC         ij      misc        1         -      rhdu     "ACSWUPTC"              "ACCUMULATED UPWELLING CLEAR SKY SHORTWAVE FLUX AT TOP" "J m-2"
-state    real  ACSWDNT          ij      misc        1         -      rhdu     "ACSWDNT"               "ACCUMULATED DOWNWELLING SHORTWAVE FLUX AT TOP"          "J m-2"
-state    real  ACSWDNTC         ij      misc        1         -      rhdu     "ACSWDNTC"              "ACCUMULATED DOWNWELLING CLEAR SKY SHORTWAVE FLUX AT TOP" "J m-2"
-state    real  ACSWUPB          ij      misc        1         -      rhdu     "ACSWUPB"               "ACCUMULATED UPWELLING SHORTWAVE FLUX AT BOTTOM"          "J m-2"
-state    real  ACSWUPBC         ij      misc        1         -      rhdu     "ACSWUPBC"              "ACCUMULATED UPWELLING CLEAR SKY SHORTWAVE FLUX AT BOTTOM" "J m-2"
-state    real  ACSWDNB          ij      misc        1         -      rhdu     "ACSWDNB"               "ACCUMULATED DOWNWELLING SHORTWAVE FLUX AT BOTTOM"          "J m-2"
-state    real  ACSWDNBC         ij      misc        1         -      rhdu     "ACSWDNBC"              "ACCUMULATED DOWNWELLING CLEAR SKY SHORTWAVE FLUX AT BOTTOM" "J m-2"
-state    real  ACLWUPT          ij      misc        1         -      rhdu     "ACLWUPT"               "ACCUMULATED UPWELLING LONGWAVE FLUX AT TOP"          "J m-2"
-state    real  ACLWUPTC         ij      misc        1         -      rhdu     "ACLWUPTC"              "ACCUMULATED UPWELLING CLEAR SKY LONGWAVE FLUX AT TOP" "J m-2"
-state    real  ACLWDNT          ij      misc        1         -      rhdu     "ACLWDNT"               "ACCUMULATED DOWNWELLING LONGWAVE FLUX AT TOP"          "J m-2"
-state    real  ACLWDNTC         ij      misc        1         -      rhdu     "ACLWDNTC"              "ACCUMULATED DOWNWELLING CLEAR SKY LONGWAVE FLUX AT TOP" "J m-2"
-state    real  ACLWUPB          ij      misc        1         -      rhdu     "ACLWUPB"               "ACCUMULATED UPWELLING LONGWAVE FLUX AT BOTTOM"          "J m-2"
-state    real  ACLWUPBC         ij      misc        1         -      rhdu     "ACLWUPBC"              "ACCUMULATED UPWELLING CLEAR SKY LONGWAVE FLUX AT BOTTOM" "J m-2"
-state    real  ACLWDNB          ij      misc        1         -      rhdu     "ACLWDNB"               "ACCUMULATED DOWNWELLING LONGWAVE FLUX AT BOTTOM"          "J m-2"
-state    real  ACLWDNBC         ij      misc        1         -      rhdu     "ACLWDNBC"              "ACCUMULATED DOWNWELLING CLEAR SKY LONGWAVE FLUX AT BOTTOM" "J m-2"
-state integer  I_ACSWUPT        ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACSWUPT"     "BUCKET FOR UPWELLING SHORTWAVE FLUX AT TOP"          "J m-2"
-state integer  I_ACSWUPTC       ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACSWUPTC"    "BUCKET FOR UPWELLING CLEAR SKY SHORTWAVE FLUX AT TOP" "J m-2"
-state integer  I_ACSWDNT        ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACSWDNT"     "BUCKET FOR DOWNWELLING SHORTWAVE FLUX AT TOP"          "J m-2"
-state integer  I_ACSWDNTC       ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACSWDNTC"    "BUCKET FOR DOWNWELLING CLEAR SKY SHORTWAVE FLUX AT TOP" "J m-2"
-state integer  I_ACSWUPB        ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACSWUPB"     "BUCKET FOR UPWELLING SHORTWAVE FLUX AT BOTTOM"          "J m-2"
-state integer  I_ACSWUPBC       ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACSWUPBC"    "BUCKET FOR UPWELLING CLEAR SKY SHORTWAVE FLUX AT BOTTOM" "J m-2"
-state integer  I_ACSWDNB        ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACSWDNB"     "BUCKET FOR DOWNWELLING SHORTWAVE FLUX AT BOTTOM"          "J m-2"
-state integer  I_ACSWDNBC       ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACSWDNBC"    "BUCKET FOR DOWNWELLING CLEAR SKY SHORTWAVE FLUX AT BOTTOM" "J m-2"
-state integer  I_ACLWUPT        ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACLWUPT"     "BUCKET FOR UPWELLING LONGWAVE FLUX AT TOP"          "J m-2"
-state integer  I_ACLWUPTC       ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACLWUPTC"    "BUCKET FOR UPWELLING CLEAR SKY LONGWAVE FLUX AT TOP" "J m-2"
-state integer  I_ACLWDNT        ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACLWDNT"     "BUCKET FOR DOWNWELLING LONGWAVE FLUX AT TOP"          "J m-2"
-state integer  I_ACLWDNTC       ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACLWDNTC"    "BUCKET FOR DOWNWELLING CLEAR SKY LONGWAVE FLUX AT TOP" "J m-2"
-state integer  I_ACLWUPB        ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACLWUPB"     "BUCKET FOR UPWELLING LONGWAVE FLUX AT BOTTOM"          "J m-2"
-state integer  I_ACLWUPBC       ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACLWUPBC"    "BUCKET FOR UPWELLING CLEAR SKY LONGWAVE FLUX AT BOTTOM" "J m-2"
-state integer  I_ACLWDNB        ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACLWDNB"     "BUCKET FOR DOWNWELLING LONGWAVE FLUX AT BOTTOM"          "J m-2"
-state integer  I_ACLWDNBC       ij      misc        1         -      rhd=(interp_fcni)u=(copy_fcni)     "I_ACLWDNBC"    "BUCKET FOR DOWNWELLING CLEAR SKY LONGWAVE FLUX AT BOTTOM" "J m-2"
+state    real  ACSWUPT          ij      misc        1         -      rdu     "ACSWUPT"               "ACCUMULATED UPWELLING SHORTWAVE FLUX AT TOP"          "J m-2"
+state    real  ACSWUPTC         ij      misc        1         -      rdu     "ACSWUPTC"              "ACCUMULATED UPWELLING CLEAR SKY SHORTWAVE FLUX AT TOP" "J m-2"
+state    real  ACSWDNT          ij      misc        1         -      rdu     "ACSWDNT"               "ACCUMULATED DOWNWELLING SHORTWAVE FLUX AT TOP"          "J m-2"
+state    real  ACSWDNTC         ij      misc        1         -      rdu     "ACSWDNTC"              "ACCUMULATED DOWNWELLING CLEAR SKY SHORTWAVE FLUX AT TOP" "J m-2"
+state    real  ACSWUPB          ij      misc        1         -      rdu     "ACSWUPB"               "ACCUMULATED UPWELLING SHORTWAVE FLUX AT BOTTOM"          "J m-2"
+state    real  ACSWUPBC         ij      misc        1         -      rdu     "ACSWUPBC"              "ACCUMULATED UPWELLING CLEAR SKY SHORTWAVE FLUX AT BOTTOM" "J m-2"
+state    real  ACSWDNB          ij      misc        1         -      rdu     "ACSWDNB"               "ACCUMULATED DOWNWELLING SHORTWAVE FLUX AT BOTTOM"          "J m-2"
+state    real  ACSWDNBC         ij      misc        1         -      rdu     "ACSWDNBC"              "ACCUMULATED DOWNWELLING CLEAR SKY SHORTWAVE FLUX AT BOTTOM" "J m-2"
+state    real  ACLWUPT          ij      misc        1         -      rdu     "ACLWUPT"               "ACCUMULATED UPWELLING LONGWAVE FLUX AT TOP"          "J m-2"
+state    real  ACLWUPTC         ij      misc        1         -      rdu     "ACLWUPTC"              "ACCUMULATED UPWELLING CLEAR SKY LONGWAVE FLUX AT TOP" "J m-2"
+state    real  ACLWDNT          ij      misc        1         -      rdu     "ACLWDNT"               "ACCUMULATED DOWNWELLING LONGWAVE FLUX AT TOP"          "J m-2"
+state    real  ACLWDNTC         ij      misc        1         -      rdu     "ACLWDNTC"              "ACCUMULATED DOWNWELLING CLEAR SKY LONGWAVE FLUX AT TOP" "J m-2"
+state    real  ACLWUPB          ij      misc        1         -      rdu     "ACLWUPB"               "ACCUMULATED UPWELLING LONGWAVE FLUX AT BOTTOM"          "J m-2"
+state    real  ACLWUPBC         ij      misc        1         -      rdu     "ACLWUPBC"              "ACCUMULATED UPWELLING CLEAR SKY LONGWAVE FLUX AT BOTTOM" "J m-2"
+state    real  ACLWDNB          ij      misc        1         -      rdu     "ACLWDNB"               "ACCUMULATED DOWNWELLING LONGWAVE FLUX AT BOTTOM"          "J m-2"
+state    real  ACLWDNBC         ij      misc        1         -      rdu     "ACLWDNBC"              "ACCUMULATED DOWNWELLING CLEAR SKY LONGWAVE FLUX AT BOTTOM" "J m-2"
+state integer  I_ACSWUPT        ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACSWUPT"     "BUCKET FOR UPWELLING SHORTWAVE FLUX AT TOP"          "J m-2"
+state integer  I_ACSWUPTC       ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACSWUPTC"    "BUCKET FOR UPWELLING CLEAR SKY SHORTWAVE FLUX AT TOP" "J m-2"
+state integer  I_ACSWDNT        ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACSWDNT"     "BUCKET FOR DOWNWELLING SHORTWAVE FLUX AT TOP"          "J m-2"
+state integer  I_ACSWDNTC       ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACSWDNTC"    "BUCKET FOR DOWNWELLING CLEAR SKY SHORTWAVE FLUX AT TOP" "J m-2"
+state integer  I_ACSWUPB        ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACSWUPB"     "BUCKET FOR UPWELLING SHORTWAVE FLUX AT BOTTOM"          "J m-2"
+state integer  I_ACSWUPBC       ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACSWUPBC"    "BUCKET FOR UPWELLING CLEAR SKY SHORTWAVE FLUX AT BOTTOM" "J m-2"
+state integer  I_ACSWDNB        ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACSWDNB"     "BUCKET FOR DOWNWELLING SHORTWAVE FLUX AT BOTTOM"          "J m-2"
+state integer  I_ACSWDNBC       ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACSWDNBC"    "BUCKET FOR DOWNWELLING CLEAR SKY SHORTWAVE FLUX AT BOTTOM" "J m-2"
+state integer  I_ACLWUPT        ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACLWUPT"     "BUCKET FOR UPWELLING LONGWAVE FLUX AT TOP"          "J m-2"
+state integer  I_ACLWUPTC       ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACLWUPTC"    "BUCKET FOR UPWELLING CLEAR SKY LONGWAVE FLUX AT TOP" "J m-2"
+state integer  I_ACLWDNT        ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACLWDNT"     "BUCKET FOR DOWNWELLING LONGWAVE FLUX AT TOP"          "J m-2"
+state integer  I_ACLWDNTC       ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACLWDNTC"    "BUCKET FOR DOWNWELLING CLEAR SKY LONGWAVE FLUX AT TOP" "J m-2"
+state integer  I_ACLWUPB        ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACLWUPB"     "BUCKET FOR UPWELLING LONGWAVE FLUX AT BOTTOM"          "J m-2"
+state integer  I_ACLWUPBC       ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACLWUPBC"    "BUCKET FOR UPWELLING CLEAR SKY LONGWAVE FLUX AT BOTTOM" "J m-2"
+state integer  I_ACLWDNB        ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACLWDNB"     "BUCKET FOR DOWNWELLING LONGWAVE FLUX AT BOTTOM"          "J m-2"
+state integer  I_ACLWDNBC       ij      misc        1         -      rd=(interp_fcni)u=(copy_fcni)     "I_ACLWDNBC"    "BUCKET FOR DOWNWELLING CLEAR SKY LONGWAVE FLUX AT BOTTOM" "J m-2"
 state    real  SWUPT            ij      misc        1         -      rhdu     "SWUPT"                 "INSTANTANEOUS UPWELLING SHORTWAVE FLUX AT TOP"          "W m-2"
 state    real  SWUPTC           ij      misc        1         -      rhdu     "SWUPTC"                "INSTANTANEOUS UPWELLING CLEAR SKY SHORTWAVE FLUX AT TOP" "W m-2"
 state    real  SWDNT            ij      misc        1         -      rhdu     "SWDNT"                 "INSTANTANEOUS DOWNWELLING SHORTWAVE FLUX AT TOP"          "W m-2"
@@ -1244,19 +1244,19 @@
 
 # these next 2 are for the HFSoLE/PET demo; writing these to auxhist1 output over MCEL for coupling
 # with wave model, only if compiled with -DMCELIO, JM 2003/05/29
-state    real  XLAT             ij      misc        1         -     i0123rh01du=(copy_fcnm)      "XLAT"                "LATITUDE, SOUTH IS NEGATIVE"                                          "degree_north"
-state    real  XLONG            ij      misc        1         -     i0123rh01du=(copy_fcnm)      "XLONG"               "LONGITUDE, WEST IS NEGATIVE"                                          "degree_east"
-state    real  XLAT_U           ij      dyn_em      1         X     i012rh01du=(copy_fcnm)       "XLAT_U"              "LATITUDE, SOUTH IS NEGATIVE"                                          "degree_north"
-state    real  XLONG_U          ij      dyn_em      1         X     i012rh01du=(copy_fcnm)       "XLONG_U"             "LONGITUDE, WEST IS NEGATIVE"                                          "degree_east"
-state    real  XLAT_V           ij      dyn_em      1         Y     i012rh01du=(copy_fcnm)       "XLAT_V"              "LATITUDE, SOUTH IS NEGATIVE"                                          "degree_north"
-state    real  XLONG_V          ij      dyn_em      1         Y     i012rh01du=(copy_fcnm)       "XLONG_V"             "LONGITUDE, WEST IS NEGATIVE"                                          "degree_east"
+state    real  XLAT             ij      misc        1         -     i0123r01du=(copy_fcnm)      "XLAT"                "LATITUDE, SOUTH IS NEGATIVE"                                          "degree_north"
+state    real  XLONG            ij      misc        1         -     i0123r01du=(copy_fcnm)      "XLONG"               "LONGITUDE, WEST IS NEGATIVE"                                          "degree_east"
+state    real  XLAT_U           ij      dyn_em      1         X     i012r01du=(copy_fcnm)       "XLAT_U"              "LATITUDE, SOUTH IS NEGATIVE"                                          "degree_north"
+state    real  XLONG_U          ij      dyn_em      1         X     i012r01du=(copy_fcnm)       "XLONG_U"             "LONGITUDE, WEST IS NEGATIVE"                                          "degree_east"
+state    real  XLAT_V           ij      dyn_em      1         Y     i012r01du=(copy_fcnm)       "XLAT_V"              "LATITUDE, SOUTH IS NEGATIVE"                                          "degree_north"
+state    real  XLONG_V          ij      dyn_em      1         Y     i012r01du=(copy_fcnm)       "XLONG_V"             "LONGITUDE, WEST IS NEGATIVE"                                          "degree_east"
 state    real  ALBEDO           ij      misc        1         -      rh          "ALBEDO"                   "ALBEDO"
-state    real  CLAT             ij      misc        1         -     i012rhdu=(copy_fcnm)         "CLAT"                "COMPUTATIONAL GRID LATITUDE, SOUTH IS NEGATIVE"                       "degree_north"
-state    real  ALBBCK           ij      misc        1         -     i0124rh   "ALBBCK"                "BACKGROUND ALBEDO"        ""
+state    real  CLAT             ij      misc        1         -     i012rdu=(copy_fcnm)         "CLAT"                "COMPUTATIONAL GRID LATITUDE, SOUTH IS NEGATIVE"                       "degree_north"
+state    real  ALBBCK           ij      misc        1         -     i0124r   "ALBBCK"                "BACKGROUND ALBEDO"        ""
 state    real  EMBCK            ij      misc        1         -      r        "EMBCK"                 "BACKGROUND EMISSIVITY"         ""
 state    real  EMISS            ij      misc        1         -      rh       "EMISS"                 "SURFACE EMISSIVITY"         "" 
 state    real  SNOTIME          ij      misc        1         -      r        "SNOTIME"               "SNOTIME"         "" 
-state    real  NOAHRES          ij      misc        1         -      h        "NOAHRES"               "RESIDUAL OF THE NOAH SURFACE ENERGY BUDGET" "W m{-2}"
+state    real  NOAHRES          ij      misc        1         -      -        "NOAHRES"               "RESIDUAL OF THE NOAH SURFACE ENERGY BUDGET" "W m{-2}"
 state    real  CLDEFI           ij      misc        1         -      r        "CLDEFI"                "precipitation efficiency in BMJ SCHEME"    ""      
 state integer  STEPRA          -        misc        1         -      r        "STEPRA"                "NUMBER OF FUNDAMENTAL TIMESTEPS BETWEEN RADIATION CALLS"        ""
                                                 
@@ -1401,8 +1401,8 @@
 state    real  HFX              ij      misc        1         -      rh       "HFX"                   "UPWARD HEAT FLUX AT THE SURFACE"              "W m-2"      
 state    real  QFX              ij      misc        1         -      rh       "QFX"                   "UPWARD MOISTURE FLUX AT THE SURFACE"          "kg m-2 s-1"      
 state    real  LH               ij      misc        1         -      rh       "LH"                    "LATENT HEAT FLUX AT THE SURFACE"              "W m-2"
-state    real  ACHFX            ij      misc        1         -      rhdu     "ACHFX"                 "ACCUMULATED UPWARD HEAT FLUX AT THE SURFACE"  "J m-2"
-state    real  ACLHF            ij      misc        1         -      rhdu     "ACLHF"                 "ACCUMULATED UPWARD LATENT HEAT FLUX AT THE SURFACE"  "J m-2"
+state    real  ACHFX            ij      misc        1         -      rdu     "ACHFX"                 "ACCUMULATED UPWARD HEAT FLUX AT THE SURFACE"  "J m-2"
+state    real  ACLHF            ij      misc        1         -      rdu     "ACLHF"                 "ACCUMULATED UPWARD LATENT HEAT FLUX AT THE SURFACE"  "J m-2"
 state    real  FLHC             ij      misc        1         -      r        "FLHC"                  "SURFACE EXCHANGE COEFFICIENT FOR HEAT"       ""
 state    real  FLQC             ij      misc        1         -      r        "FLQC"                  "SURFACE EXCHANGE COEFFICIENT FOR MOISTURE"   ""
 state    real  QSG              ij      misc        1         -      r        "QSG"                   "SURFACE SATURATION WATER VAPOR MIXING RATIO"   "kg kg-1"
@@ -1415,12 +1415,12 @@
 state    real  TSNAV            ij      misc        1         -      r        "TSNAV"                 "AVERAGE SNOW TEMPERATURE "                    "C"
 state    real  dfi_TSNAV        ij      misc        1         -      r        "TSNAV_dfi"             "AVERAGE SNOW TEMPERATURE "                    "C"
 state    real  REGIME           ij      misc        1         -      r        "REGIME"  "FLAGS: 1=Night/Stable, 2=Mechanical Turbulent, 3=Forced Conv, 4=Free Conv" ""
-state    real  SNOWC            ij      misc        1         -     irhd=(interp_mask_land_field:lu_index)u=(copy_fcnm)  "SNOWC"  "FLAG INDICATING SNOW COVERAGE (1 FOR SNOW COVER)"  ""
+state    real  SNOWC            ij      misc        1         -     ird=(interp_mask_land_field:lu_index)u=(copy_fcnm)  "SNOWC"  "FLAG INDICATING SNOW COVERAGE (1 FOR SNOW COVER)"  ""
 state    real  dfi_SNOWC        ij      misc        1         -      r        "SNOWC_dfi"             "FLAG INDICATING SNOW COVERAGE (1 FOR SNOW COVER)"         ""
 state    real  MAVAIL           ij      misc        1         -      r        "MAVAIL"                "SURFACE MOISTURE AVAILABILITY"                ""
                                                 
 state   real   tkesfcf          ij      misc        1         -      r        "tkesfcf"               "TKE AT THE SURFACE"                           "m2 s-2"      
-state    real   sr             ij      dyn_em      1         -      irh       "sr" "fraction of frozen precipitation"
+state    real   sr             ij      dyn_em      1         -      ir       "sr" "fraction of frozen precipitation"
 state    real   potevp         ij      dyn_em      1         -       r        "potevp" "accumulated potential evaporation" "m"
 state    real   snopcx         ij      dyn_em      1         -       r        "snopcx" "snow phase change heat flux" "W m-2"
 state    real   soiltb         ij      dyn_em      1         -       r        "soiltb" "bottom soil temperature" "K"
@@ -1435,15 +1435,15 @@
 state   real  defor33          ikj      misc        1         z     r         "defor33"               "DEFORMATION 33"              "s-1"      
 state   real  defor13          ikj      misc        1         z     r         "defor13"               "DEFORMATION 13"              "s-1"      
 state   real  defor23          ikj      misc        1         z     r         "defor23"               "DEFORMATION 23"              "s-1"      
-state   real   xkmv            ikj      misc        1         -     r         "xkmv"                  "VERTICAL EDDY VISCOSITY"     "m2 s-1"      
-state   real   xkmh            ikj      misc        1         -     r         "xkmh"                  "HORIZONTAL EDDY VISCOSITY"   "m2 s-1"      
-state   real   xkhv            ikj      misc        1         -     r         "xkhv"                  "VERTICAL EDDY DIFFUSIVITY OF HEAT"                               "m2 s-1"      
-state   real   xkhh            ikj      misc        1         -     r         "xkhh"                  "HORIZONTAL EDDY DIFFUSIVITY OF HEAT"                             "m2 s-1"      
+state   real   xkmv            ikj      misc        1         -     rh         "xkmv"                  "VERTICAL EDDY VISCOSITY"     "m2 s-1"      
+state   real   xkmh            ikj      misc        1         -     rh         "xkmh"                  "HORIZONTAL EDDY VISCOSITY"   "m2 s-1"      
+state   real   xkhv            ikj      misc        1         -     rh         "xkhv"                  "VERTICAL EDDY DIFFUSIVITY OF HEAT"                               "m2 s-1"      
+state   real   xkhh            ikj      misc        1         -     rh         "xkhh"                  "HORIZONTAL EDDY DIFFUSIVITY OF HEAT"                             "m2 s-1"      
 state   real    div            ikj      misc        1         -     r         "div"                   "DIVERGENCE"                                                      "s-1"
-state   real    BN2            ikj      misc        1         -     r         "BN2"                   "BRUNT-VAISALA FREQUENCY"                                         "s-2"
+state   real    BN2            ikj      misc        1         -     rh         "BN2"                   "BRUNT-VAISALA FREQUENCY"                                         "s-2"
 state  logical warm_rain        -       misc        1         -     -         "warm_rain"              "WARM_RAIN_LOGICAL"
 state  logical adv_moist_cond   -       misc        1         -     -         "adv_moist_cond"         "ADVECT MOIST CONDENSATES LOGICAL"
-state  integer save_topo_from_real -    dyn_em	    1         -    irh        "save_topo_from_real"    "1=original topo from real/0=topo modified by WRF"      "flag"
+state  integer save_topo_from_real -    dyn_em	    1         -    ir        "save_topo_from_real"    "1=original topo from real/0=topo modified by WRF"      "flag"
 
 ## FDDA variables
 
@@ -2106,6 +2106,334 @@
 rconfig   integer production_status       namelist,grib2 	        1     255    rh    "production_status"     "Background processing id for grib2"  ""
 rconfig   integer compression             namelist,grib2 	        1      40    rh    "compression"           "grib2 compression, 40 for JPEG2000 or 41 for PNG"  ""
 
+# cmr begin
+# Switches for CO2 feedback, anthropogenic source and flat simulation
+rconfig   real valley_CO2backgr         namelist,valley        1             -       ih   "background CO2 concentration [ppmv]"
+rconfig   integer valley_CO2fbck        namelist,valley        1             -       ih   "CO2 feedback switch 1 = on and 0 = off"
+rconfig   integer valley_CO2pft2           namelist,valley        1             -       ih   "second pft type using forcing of type 1"
+rconfig   integer valley_CO2flat        namelist,valley        1             -       ih   "flat reference simulation switch 1 = on and 0 = off at topo_hp/2 "
+
+# cjw begin
+# Valley namelist
+rconfig   real valley_latitude           namelist,valley        1             -       ih   "valley latitude"
+rconfig   real valley_longitude          namelist,valley        1             -       ih   "valley longitude"
+rconfig   real valley_tsk_tmn            namelist,valley        1             -       ih   "valley_tsk_tmn"
+rconfig   integer valley_lu_index        namelist,valley        1             -       ih   "valley_lu_index"
+rconfig   real valley_lai                namelist,valley        1             -       ih   "valley_lai"
+rconfig   real valley_vegfra             namelist,valley        1             -       ih   "valley_vegfra"
+rconfig   integer valley_ivgtyp          namelist,valley        1             -       ih   "valley_ivgtyp"
+rconfig   integer valley_isltyp          namelist,valley        1             -       ih   "valley_isltyp"
+rconfig   real valley_smois              namelist,valley        1             -       ih   "valley_smois"
+rconfig   real valley_canwat             namelist,valley        1             -       ih   "valley_canwat"
+rconfig   real valley_topo_hp_off        namelist,valley        1             -       ih   "valley_topo_hp_off"
+rconfig   real valley_topo_hp            namelist,valley        1             -       ih   "valley_topo_hp"
+rconfig   real valley_topo_ly            namelist,valley        1             -       ih   "valley_topo_ly"
+rconfig   real valley_topo_sy            namelist,valley        1             -       ih   "valley_topo_sy"
+rconfig   real valley_topo_sx            namelist,valley        1             -       ih   "valley_topo_sx"
+rconfig   real valley_topo_x1            namelist,valley        1             -       ih   "valley_topo_x1"
+rconfig   real valley_topo_x2            namelist,valley        1             -       ih   "valley_topo_x2"
+rconfig   real valley_topo_x3            namelist,valley        1             -       ih   "valley_topo_x3"
+rconfig   real valley_topo_x4            namelist,valley        1             -       ih   "valley_topo_x4"
+rconfig   real valley_topo_shiftx        namelist,valley        1             -       ih   "valley_topo_shiftx"
+rconfig   real valley_topo_shifty        namelist,valley        1             -       ih   "valley_topo_shifty"
+rconfig   integer valley_tke_lscale      namelist,valley        1             -       ih   "valley_tke_lscale"
+rconfig   integer valley_hfx_tke         namelist,valley        1             -       ih   "valley_hfx_tke"
+rconfig   real valley_hfx                namelist,valley        1             -       ih   "valley_hfx"
+rconfig   integer valley_randx           namelist,valley        1             -       ih   "valley_randx"
+rconfig   integer    valley_statistics   namelist,valley        1             -       ih   "valley_statistics"   "compute valley statistics in diagnostic_output_calc: 0 = no; 1 = yes"
+rconfig   integer    valley_av           namelist,valley        1             -       ih   "valley_av"       "minutes"
+rconfig   real       valley_avsp         namelist,valley        1             -       ih   "valley_avsp"     "metres"
+rconfig   integer    valley_avstep       namelist,valley        1             -       ih   "valley_avstep"   "number of time steps"
+rconfig   integer    valley_nst          namelist,valley        1             -       ih   "valley_nst"      "time dimension of storing fields"
+rconfig   integer    valley_avspdir      namelist,valley        1             -       ih   "valley_avspdir"  "direction of horizontal averaging (x or y)"
+rconfig   integer    valley_avsptype     namelist,valley        1             -       ih   "valley_avsptype"  "type of horizontal averaging"
+
+## Valley code variables
+state     integer VALLEY_MASK                 ij     misc      1         -     i         "VALLEY_MASK"              "Mask for valley (1=valley; 0=no valley)"                                      ""
+state     integer VALLEY_XINOUT_MASK          ij     misc      1         -     i         "VALLEY_XINOUT_MASK"       "Mask for valley entry in x-direction (1=valley entry; 0=no valley)"           ""
+state     integer VALLEY_XIN_MASK             ij     misc      1         -     i         "VALLEY_XIN_MASK"          "Mask for valley entry in x-direction (1=valley entry; 0=no valley)"           ""
+state     integer VALLEY_XOUT_MASK            ij     misc      1         -     i         "VALLEY_XOUT_MASK"         "Mask for valley entry in x-direction (1=valley entry; 0=no valley)"           ""
+state     integer VALLEY_YINOUT_MASK          ij     misc      1         -     i         "VALLEY_YINOUT_MASK"       "Mask for valley entry in y-direction (1=valley entry; 0=no valley)"           ""
+state     integer VALLEY_YIN_MASK             ij     misc      1         -     i         "VALLEY_YIN_MASK"          "Mask for valley entry in y-direction (1=valley entry; 0=no valley)"           ""
+state     integer VALLEY_YOUT_MASK            ij     misc      1         -     i         "VALLEY_YOUT_MASK"         "Mask for valley entry in y-direction (1=valley entry; 0=no valley)"           ""
+state     real   PSIM                         ij     misc      1         -     -         "PSIM"                     "SIMILARITY FUNCTION FOR MOMENTUM"                                             ""
+state     real   PSIH                         ij     misc      1         -     -         "PSIH"                     "SIMILARITY FUNCTION FOR HEAT"                                                 ""
+state     real   PTMIX                        ikj    misc      1         -     -         "PTMIX"                    "potential temperature mixing term"                                            "K s-1"
+state     real   UMEAN                        ikj    misc      1         -     -         "UMEAN"                    "time average of x-velocity"                                                   "m s-1"
+state     real   UMEAN2D                      ikj    misc      1         -     -         "UMEAN2D"                  "time and space average of x-velocity"                                         "m s-1"
+state     real   USTORE                       ikjz   misc      1         -     -         "USTORE"                   "store x-velocity in valley_statistics"                                        "m s-1"
+state     real   U_U                          ikj    misc      1         -     -         "U_U"                      "U-velocity variance"                                                          "m2 s-2"
+state     real   VMEAN                        ikj    misc      1         -     -         "VMEAN"                    "time average of y-velocity"                                                   "m s-1"
+state     real   VMEAN2D                      ikj    misc      1         -     -         "VMEAN2D"                  "time and space average of y-velocity"                                         "m s-1"
+state     real   VSTORE                       ikjz   misc      1         -     -         "VSTORE"                   "store y-velocity in valley_statistics"                                        "m s-1"
+state     real   V_V                          ikj    misc      1         -     -         "V_V"                      "V-velocity variance"                                                          "m2 s-2"
+state     real   WMEAN                        ikj    misc      1         Z     -         "WMEAN"                    "time average of z-velocity"                                                   "m s-1"
+state     real   WMEAN2D                      ikj    misc      1         Z     -         "WMEAN2D"                  "time and space average of z-velocity"                                         "m s-1"
+state     real   WSTORE                       ikjz   misc      1         Z     -         "WSTORE"                   "store z-velocity in valley_statistics"                                        "m s-1"
+state     real   W_W                          ikj    misc      1         Z     -         "W_W"                      "W-velocity variance"                                                          "m2 s-2"
+state     real   Uint                         ij     misc      1         -     -         "Uint"                     "x-velocity interpolated on valley top"                                        "m s-1"
+state     real   Vint                         ij     misc      1         -     -         "Vint"                     "y-velocity interpolated on valley top"                                        "m s-1"
+state     real   Wint                         ij     misc      1         -     -         "Wint"                     "z-velocity interpolated on valley top"                                        "m s-1"
+state     real   PTMEAN                       ikj    misc      1         -     -         "PTMEAN"                   "time average of potential temperature"                                        "K"
+state     real   PTMEAN2D                     ikj    misc      1         -     -         "PTMEAN2D"                 "time and space average of potential temperature"                              "K"
+state     real   PTSTORE                      ikjz   misc      1         -     -         "PTSTORE"                  "store potential temperature"                                                  "K"
+state     real   PTint                        ij     misc      1         -     -         "PTint"                    "potential temperature interpolated on valley top"                             "K"
+state     real   dPTdX                        ikj    misc      1         -     -         "dPTdX"                    "dTHETAdX"                                                                     "Km-1"
+state     real   dPTdXMEAN2D                  ikj    misc      1         -     -         "dPTdXMEAN2D"              "time and space average of dTHETAdX"                                           "K/m"
+state     real   dPTdXSTORE                   ikjz   misc      1         -     -         "dPTdXSTORE"               "store dPTdX"                                                                  "K/m"
+state     real   dPTdY                        ikj    misc      1         -     -         "dPTdY"                    "dTHETAdY"                                                                     "Km-1"
+state     real   dPTdYMEAN2D                  ikj    misc      1         -     -         "dPTdYMEAN2D"              "time and space average of dTHETAdY"                                           "K/m"
+state     real   dPTdYSTORE                   ikjz   misc      1         -     -         "dPTdYSTORE"               "store dPTdY"                                                                  "K/m"
+state     real   dPTdZ                        ikj    misc      1         Z     -         "dPTdZ"                    "dTHETAdZ"                                                                     "Km-1"
+state     real   dPTdZMEAN2D                  ikj    misc      1         Z     -         "dPTdZMEAN2D"              "time and space average of dTHETAdZ"                                           "K/m"
+state     real   dPTdZSTORE                   ikjz   misc      1         Z     -         "dPTdZSTORE"               "store dPTdZ"                                                                  "K/m"
+state     real   QVMEAN                       ikj    misc      1         -     -         "QVMEAN"                   "time average of water vapor mixing ratio"                                     "kg kg-1"
+state     real   QVMEAN2D                     ikj    misc      1         -     -         "QVMEAN2D"                 "time and space average of water vapor mixing ratio"                           "kg kg-1"
+state     real   QVSTORE                      ikjz   misc      1         -     -         "QVSTORE"                  "store water vapor mixing ratio"                                               "kg kg-1"
+state     real   QVint                        ij     misc      1         -     -         "QVint"                    "water vapor mixing ratio interpolated on valley top"                          "kg kg-1"
+state     real   RHOint                       ij     misc      1         -     -         "RHOint"                   "density interpolated on valley top"                                           "kg m-3"
+state     real   ZPMEAN                       ikj    misc      1         Z     -         "ZPMEAN"                   "time average of geopotential height"                                          "m"
+state     real   ZPMEAN2D                     ikj    misc      1         Z     -         "ZPMEAN2D"                 "time and space average of geopotential height"                                "m"
+state     real   ZPSTORE                      ikjz   misc      1         Z     -         "ZPSTORE"                  "store geopotential height in valley_statistics"                               "m"
+state     real   ZPMEAN2DM                    ikj    misc      1         -     -         "ZPMEAN2DM"                 "time and space average of geopotential height (unstaggered)"                 "m"
+state     real   ZPVALCENTRE                  ikj    misc      1         -     i         "ZPVALCENTRE"               "Vertical grid in the valley centre"                                          "m"
+state     real   PRESMEAN                     ikj    misc      1         -     -         "PRESMEAN"                 "time average of pressure"                                                     "Pa"
+state     real   PRESMEAN2D                   ikj    misc      1         -     -         "PRESMEAN2D"               "time and space average of pressure"                                           "Pa"
+state     real   PRESSTORE                    ikjz   misc      1         -     -         "PRESSTORE"                "store pressure"                                                               "Pa"
+state     real   PRESint                      ij     misc      1         -     -         "PRESint"                  "pressure interpolated on valley top"                                      "Pa"
+state    real    TKEMEAN                      ikj    misc      1         -     -         "TKEMEAN"                  "time average of SGS TKE"                                                      "m2 s-2"
+state    real    TKEMEAN2D                    ikj    misc      1         -     -         "TKEMEAN2D"                "time and space average of SGS TKE"                                            "m2 s-2"
+state     real   TKESTORE                     ikjz   misc      1         -     -         "TKESTORE"                 "store SGS TKE"                                                                "m2 s-2"
+state     real   TKEBUOY                      ikj    misc      1         -     -         "TKEBUOY"                  "turbulent kinetic energy buoyancy term"                                       "m2 s-3"
+state    real    TKEBUOYSTORE                 ikjz   misc      1         -     -         "TKEBUOYSTORE"             "store TKEBUOY"                                                                "m2 s-2"
+state    real    TKEBUOYMEAN                  ikj    misc      1         -     -         "TKEBUOYMEAN"              "time average of TKEBUOY"                                                      "m2 s-2"
+state    real    TKEBUOYMEAN2D                ikj    misc      1         -     -         "TKEBUOYMEAN2D"            "time and space average of TKEBUOY"                                            "m2 s-2"
+state     real   TKEDISS                      ikj    misc      1         -     -         "TKEDISS"                  "turbulent kinetic energy dissipation term"                                    "m2 s-3"
+state    real    TKEDISSSTORE                 ikjz   misc      1         -     -         "TKEDISSSTORE"             "store TKEDISS"                                                                "m2 s-2"
+state    real    TKEDISSMEAN                  ikj    misc      1         -     -         "TKEDISSMEAN"              "time average of TKEDISS"                                                      "m2 s-2"
+state    real    TKEDISSMEAN2D                ikj    misc      1         -     -         "TKEDISSMEAN2D"            "time and space average of TKEDISS"                                            "m2 s-2"
+state     real   TKESHEA                      ikj    misc      1         -     -         "TKESHEA"                  "turbulent kinetic energy shear production term"                               "m2 s-3"
+state    real    TKESHEASTORE                 ikjz   misc      1         -     -         "TKESHEASTORE"             "store TKESHEA"                                                                "m2 s-2"
+state    real    TKESHEAMEAN                  ikj    misc      1         -     -         "TKESHEAMEAN"              "time average of TKESHEA"                                                      "m2 s-2"
+state    real    TKESHEAMEAN2D                ikj    misc      1         -     -         "TKESHEAMEAN2D"            "time and space average of TKESHEA"                                            "m2 s-2"
+state     real   TKEADVC                      ikj    misc      1         -     -         "TKEADVC"                  "turbulent kinetic energy advection term"                                      "m2 s-3"
+state    real    TKEADVCSTORE                 ikjz   misc      1         -     -         "TKEADVCSTORE"             "store TKEADVC"                                                                "m2 s-2"
+state    real    TKEADVCMEAN                  ikj    misc      1         -     -         "TKEADVCMEAN"              "time average of TKEADVC"                                                      "m2 s-2"
+state    real    TKEADVCMEAN2D                ikj    misc      1         -     -         "TKEADVCMEAN2D"            "time and space average of TKEADVC"                                            "m2 s-2"
+state    real    TKEDIFF                      ikj    misc      1         -     -         "TKEDIFF"                  "turbulent kinetic energy diffusion term"                                      "m2 s-3"
+state    real    TKEDIFFSTORE                 ikjz   misc      1         -     -         "TKEDIFFSTORE"             "store TKEDIFF"                                                                "m2 s-2"
+state    real    TKEDIFFMEAN                  ikj    misc      1         -     -         "TKEDIFFMEAN"              "time average of TKEDIFF"                                                      "m2 s-2"
+state    real    TKEDIFFMEAN2D                ikj    misc      1         -     -         "TKEDIFFMEAN2D"            "time and space average of TKEDIFF"                                            "m2 s-2"
+state    real    RTKE                         ikj    misc      1         -     -         "RTKE"                     "resolved TKE"                                                                 "m2 s-2"
+state    real    RTKEMEAN                     ikj    misc      1         -     -         "RTKEMEAN"                 "time average of RTKE"                                                         "m2 s-2"
+state    real    RTKEMEAN2D                   ikj    misc      1         -     -         "RTKEMEAN2D"               "time and space average of RTKE"                                               "m2 s-2"
+state    real    RTKESTORE                    ikjz   misc      1         -     -         "RTKESTORE"                "store RTKE"                                                                   "m2 s-2"
+state    real    UPTRES                       ikj    misc      1         -     -         "UPTRES"                   "resolved u-horizontal heat flux"                                              "K m s-1"
+state    real    UPTRESMEAN                   ikj    misc      1         -     -         "UPTRESMEAN"               "time average of resolved u-horizontal heat flux"                              "K m s-1"
+state    real    UPTRESMEAN2D                 ikj    misc      1         -     -         "UPTRESMEAN2D"             "time and space average of resolved u-horizontal heat flux"                    "K m s-1"
+state    real    UPTRESSTORE                  ikjz   misc      1         -     -         "UPTRESSTORE"              "store UPTRES"                                                                 "K m s-1"
+state    real    UPTRESint                    ij     misc      1         -     -         "UPTRESint"                "resolved u-horizontal heat flux interpolated on valley top"                   "K m s-1"
+state    real    UPTSGS                       ikj    misc      1         -     -         "UPTSGS"                   "subgrid scale u-horizontal heat flux"                                         "K m s-1"
+state    real    UPTSGSMEAN                   ikj    misc      1         -     -         "UPTSGSMEAN"               "time average of subgrid scale u-horizontal heat flux"                         "K m s-1"
+state    real    UPTSGSMEAN2D                 ikj    misc      1         -     -         "UPTSGSMEAN2D"             "time and space average of subgrid scale u-horizontal heat flux"               "K m s-1"
+state    real    UPTSGSSTORE                  ikjz   misc      1         -     -         "UPTSGSSTORE"              "store UPTSGS"                                                                 "K m s-1"
+state    real    UPTSGSint                    ij     misc      1         -     -         "UPTSGSint"                "subgrid scale vertical heat flux interpolated on valley top"                  "K m s-1"
+state    real    VPTRES                       ikj    misc      1         -     -         "VPTRES"                   "resolved v-horizontal heat flux"                                              "K m s-1"
+state    real    VPTRESMEAN                   ikj    misc      1         -     -         "VPTRESMEAN"               "time average of resolved v-horizontal heat flux"                              "K m s-1"
+state    real    VPTRESMEAN2D                 ikj    misc      1         -     -         "VPTRESMEAN2D"             "time and space average of resolved v-horizontal heat flux"                    "K m s-1"
+state    real    VPTRESSTORE                  ikjz   misc      1         -     -         "VPTRESSTORE"              "store VPTRES"                                                                 "K m s-1"
+state    real    VPTRESint                    ij     misc      1         -     -         "VPTRESint"                "resolved v-horizontal heat flux interpolated on valley top"                   "K m s-1"
+state    real    VPTSGS                       ikj    misc      1         -     -         "VPTSGS"                   "subgrid scale v-horizontal heat flux"                                         "K m s-1"
+state    real    VPTSGSMEAN                   ikj    misc      1         -     -         "VPTSGSMEAN"               "time average of subgrid scale v-horizontal heat flux"                         "K m s-1"
+state    real    VPTSGSMEAN2D                 ikj    misc      1         -     -         "VPTSGSMEAN2D"             "time and space average of subgrid scale v-horizontal heat flux"               "K m s-1"
+state    real    VPTSGSSTORE                  ikjz   misc      1         -     -         "VPTSGSSTORE"              "store VPTSGS"                                                                 "K m s-1"
+state    real    VPTSGSint                    ij     misc      1         -     -         "VPTSGSint"                "subgrid scale vertical heat flux interpolated on valley top"                  "K m s-1"
+state    real    WPTRES                       ikj    misc      1         Z     -         "WPTRES"                   "resolved vertical heat flux"                                                  "K m s-1"
+state    real    WPTRESMEAN                   ikj    misc      1         Z     -         "WPTRESMEAN"               "time average of resolved vertical heat flux"                                  "K m s-1"
+state    real    WPTRESMEAN2D                 ikj    misc      1         Z     -         "WPTRESMEAN2D"             "time and space average of resolved vertical heat flux"                        "K m s-1"
+state    real    WPTRESSTORE                  ikjz   misc      1         Z     -         "WPTRESSTORE"              "store WPTRES"                                                                 "K m s-1"
+state    real    WPTRESint                    ij     misc      1         -     -         "WPTRESint"                "resolved vertical heat flux interpolated on valley top"                       "K m s-1"
+state    real    WPTSGS                       ikj    misc      1         Z     -         "WPTSGS"                   "subgrid scale vertical heat flux"                                             "K m s-1"
+state    real    WPTSGSMEAN                   ikj    misc      1         Z     -         "WPTSGSMEAN"               "time average of subgrid scale vertical heat flux"                             "K m s-1"
+state    real    WPTSGSMEAN2D                 ikj    misc      1         Z     -         "WPTSGSMEAN2D"             "time and space average of subgrid scale vertical heat flux"                   "K m s-1"
+state    real    WPTSGSSTORE                  ikjz   misc      1         Z     -         "WPTSGSSTORE"              "store WPTSGS"                                                                 "K m s-1"
+state    real    WPTSGSint                    ij     misc      1         -     -         "WPTSGSint"                "subgrid scale vertical heat flux interpolated on valley top"                  "K m s-1"
+state    real    WUVRES                       ikj    misc      1         -     -         "WUVRES"                   "resolved vertical momentum flux"                                              "kg s-2 m-1"
+state    real    WUVRESMEAN                   ikj    misc      1         -     -         "WUVRESMEAN"               "time average of resolved vertical momentum flux"                              "kg s-2 m-1"
+state    real    WUVRESMEAN2D                 ikj    misc      1         -     -         "WUVRESMEAN2D"             "time and space average of resolved vertical momentum flux"                    "kg s-2 m-1"
+state    real    WUVRESSTORE                  ikjz   misc      1         -     -         "WUVRESSTORE"              "store WUVRES"                                                                 "kg s-2 m-1"
+state    real    WUVSGS                       ikj    misc      1         -     -         "WUVSGS"                   "subgrid scale vertical momentum flux"                                         "kg s-2 m-1"
+state    real    WUVSGSMEAN                   ikj    misc      1         -     -         "WUVSGSMEAN"               "time average of resolved vertical momentum flux"                              "kg s-2 m-1"
+state    real    WUVSGSMEAN2D                 ikj    misc      1         -     -         "WUVSGSMEAN2D"             "time and space average of resolved vertical momentum flux"                    "kg s-2 m-1"
+state    real    WUVSGSSTORE                  ikjz   misc      1         -     -         "WUVSGSSTORE"              "store WUVSGS"                                                                 "kg s-2 m-1"
+state    real    WUVSGSint                    ij     misc      1         -     -         "WUVSGSint"                "subgrid scale vertical momentum flux interpolated on valley top"              "kg s-2 m-1"
+state    real    WQVRES                       ikj    misc      1         -     -         "WQVRES"                   "resolved vertical moisture flux"                                              "kg s-1 m-2"
+state    real    WQVRESMEAN                   ikj    misc      1         -     -         "WQVRESMEAN"               "time average of resolved vertical moisture flux"                              "kg s-1 m-2"
+state    real    WQVRESMEAN2D                 ikj    misc      1         -     -         "WQVRESMEAN2D"             "time and space average of resolved vertical moisture flux"                    "kg s-1 m-2"
+state    real    WQVRESSTORE                  ikjz   misc      1         -     -         "WQVRESSTORE"              "store WQRES"                                                                  "kg s-1 m-2"
+state    real    WQVSGS                       ikj    misc      1         -     -         "WQVSGS"                   "subgrid scale vertical momentum flux"                                         "kg s-1 m-2"
+state    real    WQVSGSMEAN                   ikj    misc      1         -     -         "WQVSGSMEAN"               "time average of resolved vertical momentum flux"                              "kg s-1 m-2"
+state    real    WQVSGSMEAN2D                 ikj    misc      1         -     -         "WQVSGSMEAN2D"             "time and space average of resolved vertical momentum flux"                    "kg s-1 m-2"
+state    real    WQVSGSSTORE                  ikjz   misc      1         -     -         "WQVSGSSTORE"              "store WQSGS"                                                                  "kg s-1 m-2"
+state    real    WQVSGSint                    ij     misc      1         -     -         "WQVSGSint"                "subgrid scale vertical momentum flux interpolated on valley top"              "kg s-2 m-1"
+state    real    XKMVMEAN                     ikj    misc      1         -     -         "XKMVMEAN"                 "time average of XKMV"                                                         "m2 s-1"
+state    real    XKMVMEAN2D                   ikj    misc      1         -     -         "XKMVMEAN2D"               "time and space average of XKMV"                                               "m2 s-1"
+state    real    XKMVSTORE                    ikjz   misc      1         -     -         "XKMVSTORE"                "store XKMV"                                                                   "m2 s-1"
+state    real    XKMHMEAN                     ikj    misc      1         -     -         "XKMHMEAN"                 "time average of XKMH"                                                         "m2 s-1"
+state    real    XKMHMEAN2D                   ikj    misc      1         -     -         "XKMHMEAN2D"               "time and space average of XKMH"                                               "m2 s-1"
+state    real    XKMHSTORE                    ikjz   misc      1         -     -         "XKMHSTORE"                "store XKMH"                                                                   "m2 s-1"
+state    real    XKHVMEAN                     ikj    misc      1         -     -         "XKHVMEAN"                 "time average of XKHV"                                                         "m2 s-1"
+state    real    XKHVMEAN2D                   ikj    misc      1         -     -         "XKHVMEAN2D"               "time and space average of XKHV"                                               "m2 s-1"
+state    real    XKHVSTORE                    ikjz   misc      1         -     -         "XKHVSTORE"                "store XKHV"                                                                   "m2 s-1"
+state    real    USTMEAN                       ij    misc      1         -     -         "USTMEAN"                  "time average of U* IN SIMILARITY THEORY"                                      "m s-1"
+state    real    USTMEAN2D                     ij    misc      1         -     -         "USTMEAN2D"                "time and space average of U* IN SIMILARITY THEORY"                            "m s-1"
+state    real    USTSTORE                      ijz   misc      1         -     -         "USTSTORE"                 "store UST"                                                                    "m s-1"
+state    real    HMEANtop                      ij    misc      1         -     -         "HMEANtop"                 "mean vertical heat flux at valley top"                                    "W m-2"
+state    real    HMEANtopQ                      -    misc      1         -     -         "HMEANtopQ"                "mean vertical heat flux at valley top"                                        "W m-2"
+state    real    HMEANtopQMEAN                  -    misc      1         -     -         "HMEANtopQMEAN"            "time average of mean vertical heat flux at valley top"                        "W m-2"
+state    real    HMEANtopQSTORE                 z    misc      1         -     -         "HMEANtopQSTORE"           "store HMEANtopQ"                                                              "W m-2"
+state    real    HMEANval                     ikj    misc      1         -     -         "HMEANval"                 "mean vertical heat flux in the valley"                                        "K m s-1"
+state    real    HFLUCtop                      ij    misc      1         -     -         "HFLUCtop"                 "resolved vertical heat flux at valley top"                                    "W m-2"
+state    real    HFLUCtopQ                      -    misc      1         -     -         "HFLUCtopQ"                "resolved averaged vertical heat flux at valley top"                           "W m-2"
+state    real    HFLUCtopQMEAN                  -    misc      1         -     -         "HFLUCtopQMEAN"            "time average of resolved averaged vertical heat flux at valley top"           "W m-2"
+state    real    HFLUCtopQSTORE                 z    misc      1         -     -         "HFLUCtopQSTORE"           "store HFLUCtopQ"                                                              "W m-2"
+state    real    HFLUCval                     ikj    misc      1         -     -         "HFLUCval"                 "mean vertical heat flux in the valley"                                        "K m s-1"
+state    real    HSGStop                       ij    misc      1         -     -         "HSGStop"                  "subgrid scale vertical heat flux at valley top"                               "W m-2"
+state    real    HSGStopQ                       -    misc      1         -     -         "HSGStopQ"                 "subgrid scale averaged vertical heat flux at valley top"                      "W m-2"
+state    real    HSGStopQMEAN                   -    misc      1         -     -         "HSGStopQMEAN"             "time average of subgrid scale averaged vertical heat flux at valley top"      "W m-2"
+state    real    HSGStopQSTORE                  z    misc      1         -     -         "HSGStopQSTORE"            "store HSGStopQ"                                                               "W m-2"
+state    real    HSGSval                      ikj    misc      1         -     -         "HSGSval"                 "SGS vertical heat flux in the valley"                                          "K m s-1"
+state    real    IMEANtop                      ij    misc      1         -     -         "IMEANtop"                 "mean vertical momentum flux at valley top"                                   "kg s-2 m"
+state    real    IMEANtopQ                      -    misc      1         -     -         "IMEANtopQ"                "mean vertical momentum flux at valley top"                                    "kg s-2 m-1"
+state    real    IMEANtopQMEAN                  -    misc      1         -     -         "IMEANtopQMEAN"            "time average of mean vertical momentum flux at valley top"                    "kg s-2 m-1"
+state    real    IMEANtopQSTORE                 z    misc      1         -     -         "IMEANtopQSTORE"           "store IMEANtopQ"                                                              "kg s-2 m-1"
+state    real    IFLUCtop                      ij    misc      1         -     -         "IFLUCtop"                 "resolved vertical momentum flux at valley top"                                "kg s-2 m-1"
+state    real    IFLUCtopQ                      -    misc      1         -     -         "IFLUCtopQ"                "resolved averaged vertical momentum flux at valley top"                       "kg s-2 m-1"
+state    real    IFLUCtopQMEAN                  -    misc      1         -     -         "IFLUCtopQMEAN"            "time average of resolved averaged vertical momentum flux at valley top"       "kg s-2 m-1"
+state    real    IFLUCtopQSTORE                 z    misc      1         -     -         "IFLUCtopQSTORE"           "store IFLUCtopQ"                                                              "kg s-2 m-1"
+state    real    ISGStop                       ij    misc      1         -     -         "ISGStop"                  "subgrid scale vertical momentum flux at valley top"                           "kg s-2 m-1"
+state    real    ISGStopQ                       -    misc      1         -     -         "ISGStopQ"                 "subgrid scale averaged vertical momentum flux at valley top"                  "kg s-2 m-1"
+state    real    ISGStopQMEAN                   -    misc      1         -     -         "ISGStopQMEAN"             "time average of subgrid scale averaged vertical momentum flux at valley top"  "kg s-2 m-1"
+state    real    ISGStopQSTORE                  z    misc      1         -     -         "ISGStopQSTORE"            "store ISGStopQ"                                                               "kg s-2 m-1"
+state    real    LMEANtop                      ij    misc      1         -     -         "LMEANtop"                 "mean vertical moisture flux at valley top"                                    "W m-2"
+state    real    LMEANtopQ                      -    misc      1         -     -         "LMEANtopQ"                "mean vertical moisture flux at valley top"                                    "W m-2"
+state    real    LMEANtopQMEAN                  -    misc      1         -     -         "LMEANtopQMEAN"            "time average of mean vertical moisture flux at valley top"                    "W m-2"
+state    real    LMEANtopQSTORE                 z    misc      1         -     -         "LMEANtopQSTORE"           "store LMEANtopQ"                                                              "W m-2"
+state    real    LFLUCtop                      ij    misc      1         -     -         "LFLUCtop"                 "resolved vertical moisture flux at valley top"                                "W m-2"
+state    real    LFLUCtopQ                      -    misc      1         -     -         "LFLUCtopQ"                "resolved averaged vertical moisture flux at valley top"                       "W m-2"
+state    real    LFLUCtopQMEAN                  -    misc      1         -     -         "LFLUCtopQMEAN"            "time average of resolved averaged vertical moisture flux at valley top"       "W m-2"
+state    real    LFLUCtopQSTORE                 z    misc      1         -     -         "LFLUCtopQSTORE"           "store LFLUCtopQ"                                                              "W m-2"
+state    real    LSGStop                       ij    misc      1         -     -         "LSGStop"                  "subgrid scale vertical moisture flux at valley top"                           "W m-2"
+state    real    LSGStopQ                       -    misc      1         -     -         "LSGStopQ"                 "subgrid scale averaged vertical moisture flux at valley top"                  "W m-2"
+state    real    LSGStopQMEAN                   -    misc      1         -     -         "LSGStopQMEAN"             "time average of subgrid scale averaged vertical moisture flux at valley top"  "W m-2"
+state    real    LSGStopQSTORE                  z    misc      1         -     -         "LSGStopQSTORE"            "store LSGStopQ"                                                               "W m-2"
+state    real    MASStop                       ij    misc      1         -     -         "MASStop"                  "vertical mass flux at valley top"                                             "kg s-1 m-2"
+state    real    MASStopQ                       -    misc      1         -     -         "MASStopQ"                 "averaged vertical mass flux at valley top"                                    "kg s-1 m-2"
+state    real    MASStopQMEAN                   -    misc      1         -     -         "MASStopQMEAN"             "time average of averaged vertical mass flux at valley top"                    "kg s-1 m-2"
+state    real    MASStopQSTORE                  z    misc      1         -     -         "MASStopQSTORE"            "store MASStopQ"                                                               "W m-2"
+state    real    PTTNDV                         -    misc      1         -     -         "PTTNDV"                   "total theta tendency valley volume average"                                   "K s-1"
+state    real    PTTNDVMEAN                     -    misc      1         -     -         "PTTNDVMEAN"               "time average of theta tendency valley volume average"                         "K s-1"
+state    real    PTTNDVSTORE                    z    misc      1         -     -         "PTTNDVSTORE"              "store PTTNDV"                                                                 "K s-1"
+state    real    PTTNDMEAN                    ikj    misc      1         -     -         "PTTNDMEAN"                "time average of potential temperature tendency"                               "K s-1"
+state    real    PTTNDMEAN2D                  ikj    misc      1         -     -         "PTTNDMEAN2D"              "time and space average of potential temperature tendency"                     "K s-1"
+state    real    PTTNDSTORE                   ikjz   misc      1         -     -         "PTTNDSTORE"               "store potential temperature tendency"                                         "K s-1"
+state    real    PTSHFV                         -    misc      1         -     -         "PTSHFV"                   "surface heat flux theta tendency valley volume average"                       "K s-1"
+state    real    PTSHFVMEAN                     -    misc      1         -     -         "PTSHFVMEAN"               "time average of surface heat flux theta tendency valley volume average"       "K s-1"
+state    real    PTSHFVSTORE                    z    misc      1         -     -         "PTSHFVSTORE"              "store PTSHF"                                                                  "K s-1"
+state    real    PTRADV                         -    misc      1         -     -         "PTRADV"                   "radiation flux divergence theta tendency valley volume average"               "K s-1"
+state    real    PTRADVMEAN                     -    misc      1         -     -         "PTRADVMEAN"               "time average of radiation flux div. theta tendency valley volume average"     "K s-1"
+state    real    PTRADVSTORE                    z    misc      1         -     -         "PTRADVSTORE"              "store PTRADV"                                                                 "K s-1"
+state    real    PTADVVX                        -    misc      1         -     -         "PTADVVX"                   "total x-advection theta tendency valley volume average"                      "K s-1"
+state    real    PTADVVXMEAN                    -    misc      1         -     -         "PTADVVXMEAN"               "time x-average of total advection theta tendency valley volume average"      "K s-1"
+state    real    PTADVVXSTORE                   z    misc      1         -     -         "PTADVVXSTORE"              "store PTADVVX"                                                               "K s-1"
+state    real    PTADVVXIN                      -    misc      1         -     -         "PTADVVXIN"                 "total x-advection (IN) theta tendency valley volume average"                 "K s-1"
+state    real    PTADVVXINMEAN                  -    misc      1         -     -         "PTADVVXINMEAN"            "time x-average (IN) of total advection theta tendency valley volume average" "K s-1"
+state    real    PTADVVXINSTORE                 z    misc      1         -     -         "PTADVVXINSTORE"           "store PTADVVXIN"                                                             "K s-1"
+state    real    PTADVVXOUT                     -    misc      1         -     -         "PTADVVXOUT"               "total x-advection (OUT) theta tendency valley volume average"                "K s-1"
+state    real    PTADVVXOUTMEAN                 -    misc      1         -     -         "PTADVVXOUTMEAN"           "time x-average (OUT) of total advection theta tendency valley volume average" "K s-1"
+state    real    PTADVVXOUTSTORE                 z    misc      1         -     -         "PTADVVXOUTSTORE"           "store PTADVVXOUT"                                                             "K s-1"
+state    real    PTADVVY                        -    misc      1         -     -         "PTADVVY"                   "total y-advection theta tendency valley volume average"                      "K s-1"
+state    real    PTADVVYMEAN                    -    misc      1         -     -         "PTADVVYMEAN"               "time y-average of total advection theta tendency valley volume average"      "K s-1"
+state    real    PTADVVYSTORE                   z    misc      1         -     -         "PTADVVYSTORE"              "store PTADVVY"                                                               "K s-1"
+state    real    PTADVVYIN                      -    misc      1         -     -         "PTADVVYIN"                 "total x-advection (IN) theta tendency valley volume average"                 "K s-1"
+state    real    PTADVVYINMEAN                  -    misc      1         -     -         "PTADVVYINMEAN"            "time x-average (IN) of total advection theta tendency valley volume average" "K s-1"
+state    real    PTADVVYINSTORE                 z    misc      1         -     -         "PTADVVYINSTORE"           "store PTADVVYIN"                                                             "K s-1"
+state    real    PTADVVYOUT                     -    misc      1         -     -         "PTADVVYOUT"               "total x-advection (OUT) theta tendency valley volume average"                "K s-1"
+state    real    PTADVVYOUTMEAN                 -    misc      1         -     -         "PTADVVYOUTMEAN"           "time x-average (OUT) of total advection theta tendency valley volume average" "K s-1"
+state    real    PTADVVYOUTSTORE                 z    misc      1         -     -         "PTADVVYOUTSTORE"           "store PTADVVYOUT"                                                             "K s-1"
+state    real    PTADVVZ                        -    misc      1         -     -         "PTADVVZ"                   "total z-advection theta tendency valley volume average"                      "K s-1"
+state    real    PTADVVZMEAN                    -    misc      1         -     -         "PTADVVZMEAN"               "time z-average of total advection theta tendency valley volume average"      "K s-1"
+state    real    PTADVVZSTORE                   z    misc      1         -     -         "PTADVVZSTORE"              "store PTADVVZ"                                                               "K s-1"
+state    real    PTADVV                         -    misc      1         -     -         "PTADVV"                   "total advection theta tendency valley volume average"                         "K s-1"
+state    real    PTADVVMEAN                     -    misc      1         -     -         "PTADVVMEAN"               "time average of total advection theta tendency valley volume average"         "K s-1"
+state    real    PTADVVSTORE                    z    misc      1         -     -         "PTADVVSTORE"              "store PTADVV"                                                                 "K s-1"
+state    real    PTADVV2                        -    misc      1         -     -         "PTADVV2"                  "total advection theta tendency valley volume average (advection form)"        "K s-1"
+state    real    PTADVX                       ikj    misc      1         -     -         "PTADVX"                   "x-advection theta tendency"                                                   "K s-1"
+state    real    PTADVXMEAN                   ikj    misc      1         -     -         "PTADVXMEAN"               "time average of x-advection theta tendency"                                   "K s-1"
+state    real    PTADVXMEAN2D                 ikj    misc      1         -     -         "PTADVXMEAN2D"             "time and space average of x-advection theta tendency"                         "K s-1"
+state    real    PTADVXSTORE                  ikjz   misc      1         -     -         "PTADVXSTORE"              "store PTADVX"                                                                 "K s-1"
+state    real    PTADVY                       ikj    misc      1         -     -         "PTADVY"                   "total y-advection theta tendency"                                             "K s-1"
+state    real    PTADVYMEAN                   ikj    misc      1         -     -         "PTADVYMEAN"               "time average of y-advection theta tendency"                                   "K s-1"
+state    real    PTADVYMEAN2D                 ikj    misc      1         -     -         "PTADVYMEAN2D"             "time and space average of y-advection theta tendency"                         "K s-1"
+state    real    PTADVYSTORE                  ikjz   misc      1         -     -         "PTADVYSTORE"              "store PTADVY"                                                                 "K s-1"
+state    real    PTADVZ                       ikj    misc      1         -     -         "PTADVZ"                   "total z-advection theta tendency"                                             "K s-1"
+state    real    PTADVZMEAN                   ikj    misc      1         -     -         "PTADVZMEAN"               "time average of z-advection theta tendency"                                   "K s-1"
+state    real    PTADVZMEAN2D                 ikj    misc      1         -     -         "PTADVZMEAN2D"             "time and space average of z-advection theta tendency"                         "K s-1"
+state    real    PTADVZSTORE                  ikjz   misc      1         -     -         "PTADVZSTORE"              "store PTADVZ"                                                                 "K s-1"
+state    real    PTTRBVX                        -    misc      1         -     -         "PTTRBVX"                  "x-turbulent heat flux theta tendency valley volume average"                   "K s-1"
+state    real    PTTRBVXMEAN                    -    misc      1         -     -         "PTTRBVXMEAN"              "time average of x-turbulent heat flux theta tendency valley volume average"   "K s-1"
+state    real    PTTRBVXSTORE                   z    misc      1         -     -         "PTTRBVXSTORE"             "store PTTRBX"                                                                 "K s-1"
+state    real    PTTRBVY                        -    misc      1         -     -         "PTTRBVY"                  "y-turbulent heat flux theta tendency valley volume average"                   "K s-1"
+state    real    PTTRBVYMEAN                    -    misc      1         -     -         "PTTRBVYMEAN"              "time average of y-turbulent heat flux theta tendency valley volume average"   "K s-1"
+state    real    PTTRBVYSTORE                   z    misc      1         -     -         "PTTRBVYSTORE"             "store PTTRBY"                                                                 "K s-1"
+state    real    PTTRBVZ                        -    misc      1         -     -         "PTTRBVZ"                  "z-turbulent heat flux theta tendency valley volume average"                   "K s-1"
+state    real    PTTRBVZMEAN                    -    misc      1         -     -         "PTTRBVZMEAN"              "time average of z-turbulent heat flux theta tendency valley volume average"   "K s-1"
+state    real    PTTRBVZSTORE                   z    misc      1         -     -         "PTTRBVZSTORE"             "store PTTRBZ"                                                                 "K s-1"
+state    real    PTTRBV                         -    misc      1         -     -         "PTTRBV"                   "turbulent heat flux theta tendency valley volume average"                     "K s-1"
+state    real    PTTRBVMEAN                     -    misc      1         -     -         "PTTRBVMEAN"               "time average of turbulent heat flux theta tendency valley volume average"     "K s-1"
+state    real    PTTRBVSTORE                    z    misc      1         -     -         "PTTRBVSTORE"              "store PTTRB"                                                                  "K s-1"
+state    real    PTTRBV2                        -    misc      1         -     -         "PTTRBV2"                  "turbulent heat flux theta tendency valley volume average (advection form)"    "K s-1"
+state    real    PTTRBX                       ikj    misc      1         -     -         "PTTRBX"                   "turbulent x-heat flux theta tendency"                                         "K s-1"
+state    real    PTTRBXMEAN                   ikj    misc      1         -     -         "PTTRBXMEAN"               "time average of turbulent x-heat flux theta tendency"                         "K s-1"
+state    real    PTTRBXMEAN2D                 ikj    misc      1         -     -         "PTTRBXMEAN2D"             "time and space average of turbulent x-heat flux theta tendency"               "K s-1"
+state    real    PTTRBXSTORE                  ikjz   misc      1         -     -         "PTTRBXSTORE"              "store PTTRBX"                                                                 "K s-1"
+state    real    PTTRBXRES                    ikj    misc      1         -     -         "PTTRBXRES"                "turbulent x-heat flux theta tendency"                                         "K s-1"
+state    real    PTTRBXRESMEAN                ikj    misc      1         -     -         "PTTRBXRESMEAN"            "time average of turbulent x-heat flux theta tendency"                         "K s-1"
+state    real    PTTRBXRESMEAN2D              ikj    misc      1         -     -         "PTTRBXRESMEAN2D"          "time and space average of turbulent x-heat flux theta tendency"               "K s-1"
+state    real    PTTRBXRESSTORE               ikjz   misc      1         -     -         "PTTRBXRESSTORE"           "store PTTRBXRES"                                                              "K s-1"
+state    real    PTTRBXSGS                    ikj    misc      1         -     -         "PTTRBXSGS"                "turbulent x-heat flux theta tendency"                                         "K s-1"
+state    real    PTTRBXSGSMEAN                ikj    misc      1         -     -         "PTTRBXSGSMEAN"            "time average of turbulent x-heat flux theta tendency"                         "K s-1"
+state    real    PTTRBXSGSMEAN2D              ikj    misc      1         -     -         "PTTRBXSGSMEAN2D"          "time and space average of turbulent x-heat flux theta tendency"               "K s-1"
+state    real    PTTRBXSGSSTORE               ikjz   misc      1         -     -         "PTTRBXSGSSTORE"           "store PTTRBXSGS"                                                              "K s-1"
+state    real    PTTRBY                       ikj    misc      1         -     -         "PTTRBY"                   "turbulent y-heat flux theta tendency"                                         "K s-1"
+state    real    PTTRBYMEAN                   ikj    misc      1         -     -         "PTTRBYMEAN"               "time average of turbulent y-heat flux theta tendency"                         "K s-1"
+state    real    PTTRBYMEAN2D                 ikj    misc      1         -     -         "PTTRBYMEAN2D"             "time and space average of turbulent y-heat flux theta tendency"               "K s-1"
+state    real    PTTRBYSTORE                  ikjz   misc      1         -     -         "PTTRBYSTORE"              "store PTTRBY"                                                                 "K s-1"
+state    real    PTTRBYRES                    ikj    misc      1         -     -         "PTTRBYRES"                "turbulent y-heat flux theta tendency"                                         "K s-1"
+state    real    PTTRBYRESMEAN                ikj    misc      1         -     -         "PTTRBYRESMEAN"            "time average of turbulent y-heat flux theta tendency"                         "K s-1"
+state    real    PTTRBYRESMEAN2D              ikj    misc      1         -     -         "PTTRBYRESMEAN2D"          "time and space average of turbulent y-heat flux theta tendency"               "K s-1"
+state    real    PTTRBYRESSTORE               ikjz   misc      1         -     -         "PTTRBYRESSTORE"           "store PTTRBYRES"                                                              "K s-1"
+state    real    PTTRBYSGS                    ikj    misc      1         -     -         "PTTRBYSGS"                "turbulent y-heat flux theta tendency"                                         "K s-1"
+state    real    PTTRBYSGSMEAN                ikj    misc      1         -     -         "PTTRBYSGSMEAN"            "time average of turbulent y-heat flux theta tendency"                         "K s-1"
+state    real    PTTRBYSGSMEAN2D              ikj    misc      1         -     -         "PTTRBYSGSMEAN2D"          "time and space average of turbulent y-heat flux theta tendency"               "K s-1"
+state    real    PTTRBYSGSSTORE               ikjz   misc      1         -     -         "PTTRBYSGSSTORE"           "store PTTRBYSGS"                                                              "K s-1"
+state    real    PTTRBZ                       ikj    misc      1         -     -         "PTTRBZ"                   "turbulent z-heat flux theta tendency"                                         "K s-1"
+state    real    PTTRBZMEAN                   ikj    misc      1         -     -         "PTTRBZMEAN"               "time average of turbulent z-heat flux theta tendency"                         "K s-1"
+state    real    PTTRBZMEAN2D                 ikj    misc      1         -     -         "PTTRBZMEAN2D"             "time and space average of turbulent z-heat flux theta tendency"               "K s-1"
+state    real    PTTRBZSTORE                  ikjz   misc      1         -     -         "PTTRBZSTORE"              "store PTTRBZ"                                                                 "K s-1"
+state    real    PTTRBZRES                    ikj    misc      1         -     -         "PTTRBZRES"                "turbulent z-heat flux theta tendency"                                         "K s-1"
+state    real    PTTRBZRESMEAN                ikj    misc      1         -     -         "PTTRBZRESMEAN"            "time average of turbulent z-heat flux theta tendency"                         "K s-1"
+state    real    PTTRBZRESMEAN2D              ikj    misc      1         -     -         "PTTRBZRESMEAN2D"          "time and space average of turbulent z-heat flux theta tendency"               "K s-1"
+state    real    PTTRBZRESSTORE               ikjz   misc      1         -     -         "PTTRBZRESSTORE"           "store PTTRBZRES"                                                              "K s-1"
+state    real    PTTRBZSGS                    ikj    misc      1         -     -         "PTTRBZSGS"                "turbulent z-heat flux theta tendency"                                         "K s-1"
+state    real    PTTRBZSGSMEAN                ikj    misc      1         -     -         "PTTRBZSGSMEAN"            "time average of turbulent z-heat flux theta tendency"                         "K s-1"
+state    real    PTTRBZSGSMEAN2D              ikj    misc      1         -     -         "PTTRBZSGSMEAN2D"          "time and space average of turbulent z-heat flux theta tendency"               "K s-1"
+state    real    PTTRBZSGSSTORE               ikjz   misc      1         -     -         "PTTRBZSGSSTORE"           "store PTTRBZSGS"                                                              "K s-1"
+state    real    MVALLEY                        -    misc      1         -     -         "MVALLEY"                  "total mass in valley volume"                                                  "kg"
+state    real    MVALLEYMEAN                    -    misc      1         -     -         "MVALLEYMEAN"              "time average of total mass in valley volume"                                  "kg"
+state    real    MVALLEYSTORE                   z    misc      1         -     -         "MVALLEYSTORE"             "store MVALLEY"                                                                "kg"
+# cjw end
+
 # NAMELIST DERIVED
 rconfig   integer nobs_ndg_vars           derived                       1         6       -        "num_ndg_vars"         "Number of nudging variables"          ""
 rconfig   integer nobs_err_flds           derived                       1         9       -        "num_err_flds"         "Number of error fields"               ""
@@ -2412,6 +2740,11 @@
 ### 8. Edit the Registry file and create a halo-exchange for x_1.
 
 # Halo Update Communications
+#cjw begin
+halo      HALO_EM_VALLEY dyn_em 4:PTMEAN,PTMEAN2D,UMEAN,UMEAN2D,VMEAN,VMEAN2D,WMEAN,WMEAN2D,QVMEAN,QVMEAN2D,ZPMEAN,ZPMEAN2D,ZPMEAN2DM,PRESMEAN,PRESMEAN2D,TKEMEAN,TKEMEAN2D,XKMVMEAN,XKMVMEAN2D,XKHVMEAN,XKHVMEAN2D,dPTdX,dPTdY,dPTdZ
+period    PERIOD_EM_VALLEY dyn_em 2:PTMEAN,PTMEAN2D,UMEAN,UMEAN2D,VMEAN,VMEAN2D,WMEAN,WMEAN2D,QVMEAN,QVMEAN2D,ZPMEAN,ZPMEAN2D,ZPMEAN2DM,PRESMEAN,PRESMEAN2D,TKEMEAN,TKEMEAN2D,XKMVMEAN,XKMVMEAN2D,XKHVMEAN,XKHVMEAN2D,dPTdX,dPTdY,dPTdZ
+#cjw end
+
 halo      HALO_EM_INIT_1 dyn_em 48:u_1,u_2,v_1,v_2,w_1,w_2,ph_1,ph_2
 halo      HALO_EM_INIT_2 dyn_em 48:t_1,t_2,mu_1,mu_2,tke_1,tke_2,ww,phb
 halo      HALO_EM_INIT_3 dyn_em 48:ph0,php,t_init,mub,mu0,p,al,alt,alb
diff -Nru WRFV3.5/run/input_sounding WRFV3.5_MR/run/input_sounding
--- WRFV3.5/run/input_sounding	1970-01-01 01:00:00.000000000 +0100
+++ WRFV3.5_MR/run/input_sounding	2014-12-17 11:53:56.358367000 +0100
@@ -0,0 +1,58 @@
+1000.000	 285.00	 2.62	
+    0.00	 285.00	  2.62	  0.00	  0.00	
+   25.00	 285.24	  2.62	  0.00	  0.00	
+   52.50	 285.49	  2.63	  0.00	  0.00	
+   82.75	 285.78	  2.64	  0.00	  0.00	
+  116.03	 286.09	  2.64	  0.00	  0.00	
+  152.63	 286.44	  2.65	  0.00	  0.00	
+  192.89	 286.82	  2.66	  0.00	  0.00	
+  237.18	 287.24	  2.68	  0.00	  0.00	
+  285.90	 287.70	  2.69	  0.00	  0.00	
+  339.49	 288.21	  2.70	  0.00	  0.00	
+  398.44	 288.78	  2.72	  0.00	  0.00	
+  463.28	 289.39	  2.73	  0.00	  0.00	
+  534.61	 290.08	  2.75	  0.00	  0.00	
+  613.07	 290.83	  2.77	  0.00	  0.00	
+  699.37	 291.66	  2.80	  0.00	  0.00	
+  794.31	 292.58	  2.82	  0.00	  0.00	
+  898.74	 293.59	  2.85	  0.00	  0.00	
+ 1013.62	 294.70	  2.88	  0.00	  0.00	
+ 1139.98	 295.94	  2.92	  0.00	  0.00	
+ 1278.98	 297.30	  2.96	  0.00	  0.00	
+ 1431.87	 298.80	  3.00	  0.00	  0.00	
+ 1600.06	 300.47	  3.05	  0.00	  0.00	
+ 1785.07	 302.31	  3.10	  0.00	  0.00	
+ 1988.58	 304.35	  3.16	  0.00	  0.00	
+ 2212.43	 306.61	  3.23	  0.00	  0.00	
+ 2458.68	 309.11	  3.31	  0.00	  0.00	
+ 2729.54	 311.89	  3.39	  0.00	  0.00	
+ 3027.50	 314.97	  3.49	  0.00	  0.00	
+ 3347.50	 318.32	  3.60	  0.00	  0.00	
+ 3667.50	 319.36	  3.22	  5.00	  0.00	
+ 3987.50	 320.40	  2.87	  5.00	  0.00	
+ 4307.50	 321.45	  2.55	  5.00	  0.00	
+ 4627.50	 322.50	  2.27	  5.00	  0.00	
+ 4947.50	 323.55	  2.00	  5.00	  0.00	
+ 5267.50	 324.61	  1.77	  5.00	  0.00	
+ 5587.50	 325.67	  1.56	  5.00	  0.00	
+ 5907.50	 326.73	  1.37	  5.00	  0.00	
+ 6227.50	 327.80	  1.19	  5.00	  0.00	
+ 6547.50	 328.87	  1.04	  5.00	  0.00	
+ 6867.50	 329.95	  0.90	  5.00	  0.00	
+ 7187.50	 331.02	  0.78	  5.00	  0.00	
+ 7507.50	 332.11	  0.67	  5.00	  0.00	
+ 7827.50	 333.19	  0.58	  5.00	  0.00	
+ 8147.50	 334.28	  0.50	  5.00	  0.00	
+ 8467.50	 335.37	  0.42	  5.00	  0.00	
+ 8787.50	 336.47	  0.36	  5.00	  0.00	
+ 9107.50	 337.57	  0.30	  5.00	  0.00	
+ 9427.50	 338.67	  0.26	  5.00	  0.00	
+ 9745.06	 339.77	  0.21	  5.00	  0.00	
+10060.20	 340.86	  0.18	  5.00	  0.00	
+10372.95	 341.95	  0.15	  5.00	  0.00	
+10683.31	 343.03	  0.12	  5.00	  0.00	
+10991.30	 344.11	  0.10	  5.00	  0.00	
+11296.95	 345.19	  0.09	  5.00	  0.00	
+11600.27	 346.25	  0.07	  5.00	  0.00	
+11901.28	 347.32	  0.06	  5.00	  0.00	
+12200.00	 348.38	  0.05	  5.00	  0.00	
diff -Nru WRFV3.5/run/job_wrf WRFV3.5_MR/run/job_wrf
--- WRFV3.5/run/job_wrf	1970-01-01 01:00:00.000000000 +0100
+++ WRFV3.5_MR/run/job_wrf	2014-12-17 11:53:56.315475000 +0100
@@ -0,0 +1,16 @@
+#!/bin/bash
+#$ -cwd
+#$ -o output.dat
+#$ -e error.dat
+##$ -M matze.reif@gmail.com
+#$ -m e
+#$ -R y
+#$ -l h_rt=04:00:00
+#$ -N wrf_clm
+#$ -pe openmpi-fillup 48
+
+rm rsl.*
+module purge
+module load pgi openmpi netcdf
+mpirun -np $NSLOTS ./wrf.exe
+
diff -Nru WRFV3.5/run/namelist.input WRFV3.5_MR/run/namelist.input
--- WRFV3.5/run/namelist.input	1970-01-01 01:00:00.000000000 +0100
+++ WRFV3.5_MR/run/namelist.input	2014-12-17 11:53:56.382417000 +0100
@@ -0,0 +1,157 @@
+ &time_control
+ run_days                            = 0,
+ run_hours                           = 0,
+ run_minutes                         = 0,
+ run_seconds                         = 0,
+ start_year                          = 2013,
+ start_month                         = 06,
+ start_day                           = 21,
+ start_hour                          = 06,
+ start_minute                        = 00,
+ start_second                        = 00,
+ end_year                            = 2013,
+ end_month                           = 06,
+ end_day                             = 23,
+ end_hour                            = 18,
+ end_minute                          = 00,
+ end_second                          = 00,
+ history_interval                    = 60,
+ frames_per_outfile                  = 1,
+ restart                             = .false.,
+ restart_interval                    = 1440,
+ io_form_history                     = 2,
+ io_form_restart                     = 2,
+ io_form_input                       = 2,
+ io_form_boundary                    = 2,
+ debug_level                         = 0,
+ /
+
+ &domains
+ time_step                           = 6,
+ time_step_fract_num                 = 0,
+ time_step_fract_den                 = 1,
+ max_dom                             = 1,
+ s_we                                = 1,
+ e_we                                = 42,
+ s_sn                                = 1,
+ e_sn                                = 42,
+ s_vert                              = 1,
+ e_vert                              = 57,
+ eta_levels                          = 1.000000,0.996243,0.992123,0.987607,0.982658,0.977237,0.971302,0.964806,0.957700,0.949932,0.941445,0.932178,0.922067,0.911046,0.899041,0.885979,0.871783,0.856371,0.839663,0.821575,0.802025,0.780932,0.758218,0.733810,0.707644,0.679666,0.649834,0.618020,0.584877,0.552769,0.521671,0.491560,0.462410,0.434199,0.406903,0.380498,0.354963,0.330276,0.306416,0.283360,0.261088,0.239580,0.218816,0.198777,0.179442,0.160794,0.142814,0.125484,0.108911,0.093062,0.077908,0.063419,0.049566,0.036323,0.023664,0.011565,0.000000, 
+ dx                                  = 1000.,
+ dy                                  = 1000.,
+ ztop                                = 12200.,
+ /
+
+ &physics
+ mp_physics                          = 2,
+ ra_lw_physics                       = 4,
+ ra_sw_physics                       = 4,
+ radt                                = 5,
+ sf_sfclay_physics                   = 1,
+ sf_surface_physics                  = 5,
+ bl_pbl_physics                      = 5,
+ bldt                                = 0,
+ cu_physics                          = 0,
+ cudt                                = 0,
+ cu_diag                             = 1,
+ isfflx                              = 1,
+ num_soil_layers                     = 10,
+ slope_rad                           = 1,
+ ifsnow                              = 0,
+ icloud                              = 0,
+ mp_zero_out                         = 0,
+ /
+
+ &fdda
+ /
+
+ &dynamics
+ rk_ord                              = 3,
+ diff_opt                            = 0,
+ km_opt                              = 4,
+ damp_opt                            = 3,
+ dampcoef                            = 0.2,
+ zdamp                               = 1000.,
+ khdif                               = 0,
+ kvdif                               = 0,
+ smdiv                               = 0.1,
+ emdiv                               = 0.01,
+ epssm                               = 0.1,
+ time_step_sound                     = 6,
+ h_mom_adv_order                     = 5,
+ v_mom_adv_order                     = 3,
+ h_sca_adv_order                     = 5,
+ v_sca_adv_order                     = 3,
+ mix_full_fields                     = .true.,
+ mix_isotropic                       = 1,
+ non_hydrostatic                     = .true.,
+ /
+
+ &bdy_control
+ periodic_x                          = .true.,
+ symmetric_xs                        = .false.,
+ symmetric_xe                        = .false.,
+ open_xs                             = .false., 
+ open_xe                             = .false.,
+ periodic_y                          = .true.,
+ symmetric_ys                        = .false.,
+ symmetric_ye                        = .false.,
+ open_ys                             = .false.,
+ open_ye                             = .false.,
+ /
+
+ &grib2
+ /
+
+ &namelist_quilt
+ nio_tasks_per_group = 0,
+ nio_groups = 1,
+ /
+
+&chem 
+ chem_opt = 16,
+ emiss_inpt_opt = 16,
+ chem_conv_tr = 0,
+ gas_drydep_opt = 0, 
+ vprm_opt = 'VPRM_table_EUROPE',
+ /
+
+&valley
+ valley_CO2backgr                    = 380.,
+ valley_CO2antr                      = 50.,
+ valley_CO2fbck                      = 1,
+ valley_CO2flat                      = 0,
+ valley_latitude                     = 45.,
+ valley_longitude                    = 0.,
+ valley_tsk_tmn                      = -5.,
+ valley_lu_index                     = 3,
+ valley_lai                          = 3.,
+ valley_vegfra                       = 1.,
+ valley_ivgtyp                       = 2,
+ valley_isltyp                       = 6,
+ valley_smois                        = 0.176,
+ valley_canwat                       = 0.0,
+ valley_topo_hp                      = 1.5E3,
+ valley_topo_ly                      = 40.0E3,
+ valley_topo_sy                      = 9.0E3,
+ valley_topo_sx                      = 9.0E3,
+ valley_topo_x1                      = 0.5E3,
+ valley_topo_x2                      = 9.5E3,
+ valley_topo_x3                      = 10.5E3,
+ valley_topo_x4                      = 19.5E3,
+ valley_topo_shiftx                  = 20.0E3,
+ valley_topo_shifty                  = 0.0E3,
+ valley_tke_lscale                   = 0,
+ valley_hfx_tke                      = 0,
+ valley_hfx                          = 0,
+ valley_randx                        = 1,
+ valley_statistics                   = 0,
+ valley_av                           = 20,
+ valley_avstep                       = 120,
+ valley_nst                          = 1,
+ valley_avspdir                      = 1,
+ valley_avsptype                     = 1,
+ valley_avsp                         = 25.,
+ /
+
diff -Nru WRFV3.5/run/run_ideal WRFV3.5_MR/run/run_ideal
--- WRFV3.5/run/run_ideal	1970-01-01 01:00:00.000000000 +0100
+++ WRFV3.5_MR/run/run_ideal	2014-12-17 11:53:56.294698000 +0100
@@ -0,0 +1,10 @@
+#!/bin/bash
+#$ -cwd
+##$ -M matze.reif@gmail.com
+#$ -e error.dat
+#$ -m e
+#$ -R y
+#$ -l h_rt=300,h_vmem=8G
+#$ -N ideal
+
+./ideal.exe
diff -Nru WRFV3.5/run/save_run.sh WRFV3.5_MR/run/save_run.sh
--- WRFV3.5/run/save_run.sh	1970-01-01 01:00:00.000000000 +0100
+++ WRFV3.5_MR/run/save_run.sh	2014-12-17 11:53:56.403914000 +0100
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+echo "momentan gibt es unter  /scratch/c707249/output/ folgende Ordner \n"
+subdir=final_refval
+ls /scratch/c707249/output/$subdir/
+
+echo -n "Geben Sie den ordner an unter dem der neue Lauf gespeichert werden soll: " 
+read newdir
+mkdir /scratch/c707249/output/$subdir/$newdir
+echo "der neue ordner: $newdir wurde angelegt"
+mkdir /scratch/c707249/output/$subdir/$newdir/wrfout
+
+mv wrfout* /scratch/c707249/output/$subdir/$newdir/wrfout
+mv wrfrst* /scratch/c707249/output/$subdir/$newdir
+mv wrfinp* /scratch/c707249/output/$subdir/$newdir
+cp namelist.input /scratch/c707249/output/$subdir/$newdir
+cp input_sounding /scratch/c707249/output/$subdir/$newdir
+mv rsl.error.0000 /scratch/c707249/output/$subdir/$newdir
+mv rsl.out.0000 /scratch/c707249/output/$subdir/$newdir
+rm rsl.*
+
+cp /scratch/c707249/WRFV3.5_CLM/phys/module_physics_init.F /scratch/c707249/output/$subdir/$newdir
+cp /scratch/c707249/WRFV3.5_CLM/phys/module_sf_clm.F /scratch/c707249/output/$subdir/$newdir
+cp /scratch/c707249/WRFV3.5_CLM/phys/module_surface_driver.F /scratch/c707249/output/$subdir/$newdir
+cp /scratch/c707249/WRFV3.5_CLM/chem/chem_driver.F /scratch/c707249/output/$subdir/$newdir
+cp /scratch/c707249/WRFV3.5_CLM/chem/emissions_driver.F /scratch/c707249/output/$subdir/$newdir
+cp /scratch/c707249/WRFV3.5_CLM/chem/module_ghg_fluxes.F /scratch/c707249/output/$subdir/$newdir
+cp /scratch/c707249/WRFV3.5_CLM/chem/chemics_init.F /scratch/c707249/output/$subdir/$newdir
+cp /scratch/c707249/WRFV3.5_CLM/dyn_em/module_big_step_utilities_em.F /scratch/c707249/output/$subdir/$newdir
+cp /scratch/c707249/WRFV3.5_CLM/dyn_em/module_first_rk_step_part1.F /scratch/c707249/output/$subdir/$newdir
+cp /scratch/c707249/WRFV3.5_CLM/dyn_em/module_initialize_les.F /scratch/c707249/output/$subdir/$newdir
+cp /scratch/c707249/WRFV3.5_CLM/Registry/Registry.EM_COMMON /scratch/c707249/output/$subdir/$newdir
+echo "Lauf gesichert in /scratch/c707249/output/$subdir/$newdir"
+
diff -Nru WRFV3.5/share/module_soil_pre.F WRFV3.5_MR/share/module_soil_pre.F
--- WRFV3.5/share/module_soil_pre.F	2012-12-21 22:22:51.000000000 +0100
+++ WRFV3.5_MR/share/module_soil_pre.F	2014-12-17 11:53:56.220674000 +0100
@@ -3642,6 +3642,7 @@
       !  Local variables.
 
       INTEGER :: itf,jtf
+      character*256 :: msg !cmr 
 
       itf=MIN(ite,ide-1)
       jtf=MIN(jte,jde-1)
@@ -3671,8 +3672,25 @@
                                   its,ite, jts,jte, kts,kte              )
       ELSE IF ( ( sf_surface_physics .EQ. RUCLSMSCHEME ) .AND. ( num_soil_layers .GT. 1 ) ) THEN
          CALL init_soil_depth_3 ( zs , dzs , num_soil_layers )
+!cmr
+      ELSE IF ( ( sf_surface_physics .EQ. CLMSCHEME ) .AND. ( num_soil_layers.GT. 1 ) ) THEN
+         CALL init_soil_depth_4 ( zs , dzs , num_soil_layers )
+         CALL init_soil_2_ideal ( xland,xice,vegfra,snow,canwat,         &
+                                  ivgtyp,isltyp,tslb,smois,tmn,          &
+                                  num_soil_layers,                       &
+                                  ids,ide, jds,jde, kds,kde,             &
+                                  ims,ime, jms,jme, kms,kme,             &
+                                  its,ite, jts,jte, kts,kte              )
 
+!cmr end
       END IF
+   write(msg,*)'max zs=',maxval(zs),'max dzs=',maxval(dzs),'num_soil_layers=',num_soil_layers 
+   CALL wrf_debug(0,msg)
+   write(msg,*) maxval(xland),maxval(xice),maxval(vegfra),maxval(snow),maxval(canwat),         &
+                maxval(ivgtyp),maxval(isltyp),maxval(tslb),maxval(smois),maxval(tmn),          &
+
+   write(msg,*) 'sf_surface_physics=',sf_surface_physics,'CLMSCHEME',CLMSCHEME
+   CALL wrf_debug(0,msg)
 
    END SUBROUTINE process_soil_ideal
 
