[Dart-dev] [5926] DART/branches/development: The NOAH LSM is now fully documented and code reviewed.

nancy at ucar.edu nancy at ucar.edu
Mon Nov 19 16:39:11 MST 2012


Revision: 5926
Author:   thoar
Date:     2012-11-19 16:39:10 -0700 (Mon, 19 Nov 2012)
Log Message:
-----------
The NOAH LSM is now fully documented and code reviewed.
It still needs to be extended to do multiple gridcells.

Modified Paths:
--------------
    DART/branches/development/doc/html/doc.css
    DART/branches/development/index.html
    DART/branches/development/location/threed_sphere/location_mod.html
    DART/branches/development/models/noah/dart_to_noah.f90
    DART/branches/development/models/noah/model_mod.f90
    DART/branches/development/models/noah/model_mod.html
    DART/branches/development/models/noah/model_mod.nml
    DART/branches/development/models/noah/model_mod_check.f90
    DART/branches/development/models/noah/noah_to_dart.f90
    DART/branches/development/models/noah/shell_scripts/advance_model.csh
    DART/branches/development/models/noah/shell_scripts/run_filter.csh
    DART/branches/development/models/noah/work/input.nml
    DART/branches/development/models/noah/work/obs_seq.in
    DART/branches/development/models/noah/work/set_def.out
    DART/branches/development/obs_def/obs_def_COSMOS_mod.f90

Added Paths:
-----------
    DART/branches/development/models/noah/dart_to_noah.html
    DART/branches/development/models/noah/noah_to_dart.html
    DART/branches/development/models/noah/work/input.create_fixed_network_seq.txt
    DART/branches/development/models/noah/work/input.create_obs_sequence.txt

-------------- next part --------------
Modified: DART/branches/development/doc/html/doc.css
===================================================================
--- DART/branches/development/doc/html/doc.css	2012-11-15 17:00:46 UTC (rev 5925)
+++ DART/branches/development/doc/html/doc.css	2012-11-19 23:39:10 UTC (rev 5926)
@@ -205,12 +205,12 @@
 em.program{
     color:green; 
     font-style:oblique;
-    font-family:"Courier",monospace;}
+    font-family:"Lucida Console",monospace;}
 
 em.file{
     color:green; 
     font-style:normal;
-    font-family:"Courier",monospace;}
+    font-family:"Lucida Console",monospace;}
 
 em.nav{
     font-family:sans-serif;

Modified: DART/branches/development/index.html
===================================================================
--- DART/branches/development/index.html	2012-11-15 17:00:46 UTC (rev 5925)
+++ DART/branches/development/index.html	2012-11-19 23:39:10 UTC (rev 5926)
@@ -254,6 +254,7 @@
 <A HREF='models/lorenz_96_2scale/model_mod.f90'>lorenz_96_2scale (source)</A>
 <A HREF='models/MITgcm_annulus/model_mod.f90'>MITgcm_annulus (source)</A>
 <A HREF='models/MITgcm_ocean/model_mod.html'>MITgcm_ocean (html)</A>
+<A HREF='models/noah/model_mod.html'>NOAH (html)</A>
 <A HREF='models/NOGAPS/model_mod.f90'>NOGAPS (source)</A>
 <A HREF='models/null_model/model_mod.f90'>null_model (source)</A>
 <A HREF='models/PBL_1d/model_mod.html'>PBL_1d (html)</A>
@@ -471,6 +472,9 @@
 <a href="models/POP/dart_to_pop.html">POP/dart_to_pop</a>
 <a href="models/POP/model_mod.html">POP/model_mod</a>
 <a href="models/POP/pop_to_dart.html">POP/pop_to_dart</a>
+<a href="models/noah/dart_to_noah.html">noah/dart_to_noah</a>
+<a href="models/noah/model_mod.html">noah/model_mod</a>
+<a href="models/noah/noah_to_dart.html">noah/noah_to_dart</a>
 <a href="models/cam/cam_to_dart.html">cam/cam_to_dart</a>
 <a href="models/cam/dart_to_cam.html">cam/dart_to_cam</a>
 <a href="models/cam/doc/cam_guidelines.html">cam/doc/cam_guidelines</a>
@@ -527,6 +531,7 @@
 <a href="observations/var/littler_tf_dart.html">little-r obs converter</a>
 <a href="observations/var/rad_3d_var_to_dart.html">var radar obs converter</a>
 <a href="observations/var/var.html">var obs converter</a>
+<a href="observations/COSMOS/COSMOS_to_obs.html">COSMOS to obs converter</a>
 <a href="perfect_model_obs/perfect_model_obs.html">perfect_model_obs</a>
 <a href="preprocess/preprocess.html">preprocess</a>
 <a href="system_simulation/system_simulation.html">system_simulation (sampling error correction)</a>

Modified: DART/branches/development/location/threed_sphere/location_mod.html
===================================================================
--- DART/branches/development/location/threed_sphere/location_mod.html	2012-11-15 17:00:46 UTC (rev 5925)
+++ DART/branches/development/location/threed_sphere/location_mod.html	2012-11-19 23:39:10 UTC (rev 5926)
@@ -1496,7 +1496,7 @@
 </TR>
 <TR><!-- routine --><TD VALIGN=top>read_location</TD>
     <!-- message --><TD VALIGN=top>Expected location header "loc3d" in input file, got ___</TD>
-    <!-- comment --><TD VALIGN=top>Vertical coordinate confusion involving NetCDF file.</TD>
+    <!-- comment --><TD VALIGN=top>Probable mixing of other location modules in observation sequence   processing.</TD>
 </TR>
 <TR><!-- routine --><TD VALIGN=top>nc_write_location</TD>
     <!-- message --><TD VALIGN=top>Various NetCDF-f90 interface error messages</TD>

Modified: DART/branches/development/models/noah/dart_to_noah.f90
===================================================================
--- DART/branches/development/models/noah/dart_to_noah.f90	2012-11-15 17:00:46 UTC (rev 5925)
+++ DART/branches/development/models/noah/dart_to_noah.f90	2012-11-19 23:39:10 UTC (rev 5926)
@@ -27,7 +27,7 @@
 !----------------------------------------------------------------------
 
 use        types_mod, only : r8, obstypelength
-use    utilities_mod, only : initialize_utilities, timestamp, &
+use    utilities_mod, only : initialize_utilities, finalize_utilities, &
                              find_namelist_in_file, check_namelist_read, &
                              logfileunit, open_file, close_file, &
                              error_handler, E_ERR
@@ -36,7 +36,7 @@
                              set_time, operator(+), operator(-), operator(<=)
 use        model_mod, only : static_init_model, dart_vector_to_model_file, &
                              get_model_size, get_noah_restart_filename, &
-                             get_noah_timestepping
+                             get_noah_timestepping, get_debug_level
 
 implicit none
 
@@ -46,28 +46,27 @@
    revision = "$Revision$", &
    revdate  = "$Date$"
 
-!------------------------------------------------------------------
-! The namelist variables
-!------------------------------------------------------------------
+!-----------------------------------------------------------------------
+! namelist parameters with default values.
+!-----------------------------------------------------------------------
 
 character (len = 128) :: dart_to_noah_input_file = 'dart_restart'
-character (len = 128) :: noah_reqd_file_list = 'ldasin_files_needed'
 character (len=obstypelength), dimension(40) :: skip_variables = ' '
 logical               :: advance_time_present   = .true.
 
 namelist /dart_to_noah_nml/ dart_to_noah_input_file, &
-                            noah_reqd_file_list,     &
                             skip_variables, &
                             advance_time_present
 
 !----------------------------------------------------------------------
+! global storage
+!----------------------------------------------------------------------
 
 character(len=20)     :: noah_restart_filename
 integer               :: ifile, nfiles, iunit, io, x_size
 type(time_type)       :: model_time, adv_to_time, mytime
 type(time_type)       :: forcingtimestep, nexttimestep
 real(r8), allocatable :: statevector(:)
-logical               :: verbose              = .FALSE.
 integer               :: kday, khour, noah_timestep, output_timestep
 integer               :: forcing_timestep, restart_frequency_seconds
 
@@ -77,7 +76,7 @@
 
 !----------------------------------------------------------------------
 
-call initialize_utilities(progname='dart_to_noah', output_flag=verbose)
+call initialize_utilities(progname='dart_to_noah')
 
 !----------------------------------------------------------------------
 ! Call model_mod:static_init_model() which reads the NOAH namelist
@@ -86,9 +85,6 @@
 
 call static_init_model()
 
-x_size = get_model_size()
-allocate(statevector(x_size))
-
 ! Read the namelist to get the input filename.
 
 call find_namelist_in_file("input.nml", "dart_to_noah_nml", iunit)
@@ -100,14 +96,21 @@
 call get_noah_restart_filename( noah_restart_filename )
 
 write(*,*)
-write(*,'(''dart_to_noah:converting DART file '',A, &
-      &'' to NOAH restart file '',A)') &
+write(*,'(''dart_to_noah:converting DART file <'',A, &
+      &''> to NOAH restart file <'',A,''>'')') &
      trim(dart_to_noah_input_file), trim(noah_restart_filename)
+write(logfileunit,*)
+write(logfileunit,'(''dart_to_noah:converting DART file <'',A, &
+      &''> to NOAH restart file <'',A,''>'')') &
+     trim(dart_to_noah_input_file), trim(noah_restart_filename)
 
 !----------------------------------------------------------------------
 ! Reads the valid time, the state, and the target time.
 !----------------------------------------------------------------------
 
+x_size = get_model_size()
+allocate(statevector(x_size))
+
 iunit = open_restart_read(dart_to_noah_input_file)
 
 if ( advance_time_present ) then
@@ -126,7 +129,7 @@
 
 !----------------------------------------------------------------------
 ! Convey adv_to_time to noah by updating kday or khour in the namelist.
-! We should be able to predict the names of the LDASIN files needed -
+! Predict the names of the LDASIN files needed -
 !    write these to a file that will be queried by advance_model.csh
 !    so they get staged appropriately.
 !----------------------------------------------------------------------
@@ -160,6 +163,7 @@
       mytime = mytime + nexttimestep
    enddo TIMELOOP
 
+   if (get_debug_level() > 0) &
    write(*,*)'needed ',nfiles,' LDASIN files to get from model_time to adv_to_time.'
 
    iunit = open_file('noah_advance_information.txt',form='formatted',action='write')
@@ -190,32 +194,26 @@
 
    call close_file(iunit)
 
-!  We know we need the forcing file for the timestring contained in the restart file.
-!  This is a direct consequence of requiring the noah_timestep to be the same as the restart_frequency.
-!  determine how many forcing files are needed
-!  determine the setting of kday or khour
-
-!  convey kday or khour in some fashion
-
 endif
 
 !----------------------------------------------------------------------
 ! Log what we think we're doing, and exit.
 !----------------------------------------------------------------------
 
-call print_date( model_time,'dart_to_noah:noah model date')
-call print_time( model_time,'dart_to_noah:DART model time')
-call print_date( model_time,'dart_to_noah:noah model date',logfileunit)
-call print_time( model_time,'dart_to_noah:DART model time',logfileunit)
+if (get_debug_level() > 0) then
+   call print_date( model_time,'dart_to_noah:noah model date')
+   call print_time( model_time,'dart_to_noah:DART model time')
+   call print_date( model_time,'dart_to_noah:noah model date',logfileunit)
+   call print_time( model_time,'dart_to_noah:DART model time',logfileunit)
 
-if ( advance_time_present ) then
-   call print_time(adv_to_time,'dart_to_noah:advance_to time')
-   call print_date(adv_to_time,'dart_to_noah:advance_to date')
-   call print_time(adv_to_time,'dart_to_noah:advance_to time',logfileunit)
-   call print_date(adv_to_time,'dart_to_noah:advance_to date',logfileunit)
+   if ( advance_time_present ) then
+      call print_time(adv_to_time,'dart_to_noah:advance_to time')
+      call print_date(adv_to_time,'dart_to_noah:advance_to date')
+      call print_time(adv_to_time,'dart_to_noah:advance_to time',logfileunit)
+      call print_date(adv_to_time,'dart_to_noah:advance_to date',logfileunit)
+   endif
 endif
 
-! When called with 'end', timestamp will call finalize_utilities()
-call timestamp(string1=source, pos='end')
+call finalize_utilities()
 
 end program dart_to_noah

Added: DART/branches/development/models/noah/dart_to_noah.html
===================================================================
--- DART/branches/development/models/noah/dart_to_noah.html	                        (rev 0)
+++ DART/branches/development/models/noah/dart_to_noah.html	2012-11-19 23:39:10 UTC (rev 5926)
@@ -0,0 +1,396 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<HTML>
+<HEAD>
+<TITLE>program dart_to_noah</TITLE>
+<link rel="stylesheet" type="text/css" href="../../doc/html/doc.css" />
+</HEAD>
+<BODY>
+<A NAME="TOP"></A>
+
+<table border=0 summary="" cellpadding=5>
+<tr>
+    <td valign=middle>
+    <img src="../../doc/html/Dartboard7.png" alt="DART project logo" height=70 />
+    </td>
+    <td>
+       <P><a href="../../index.html">DART Documentation Main Index</a><br />
+          <small>version information for this file: <br />
+          <!-- version tag follows, do not edit -->
+          $Id$</small>
+       </P></td>
+</tr>
+</table>
+
+<A HREF="#Namelist">NAMELIST</A> /
+<A HREF="#Modules">MODULES</A> /
+<A HREF="#FilesUsed">FILES</A> /
+<A HREF="#References">REFERENCES</A> /
+<A HREF="#Errors">ERRORS</A> /
+<A HREF="#FuturePlans">PLANS</A> /
+<A HREF="#Legalese">TERMS OF USE</A>
+
+<H1>PROGRAM <em class=program>dart_to_noah</em></H1>
+
+
+
+<P>
+   <em class=program>dart_to_noah</em> is the program that <strong>overwrites</strong>
+   a NOAH netCDF-format restart file (usually linked to "<em class=file>restart.nc</em>")
+   with the state information contained in a DART output/restart file
+   (e.g. <em class=file>perfect_restart, filter_restart, ... </em>).
+   The DART model time is compared to the time in the NOAH restart file.
+   If the time in the restart file does not match the DART model time,
+   the <em class=program>dart_vector_to_model_file</em> routine issues an
+   error message and aborts. Due to the fact the NOAH restart files are
+   timestamped such that the time reflects the valid time 
+   <strong>UPON THE NEXT ADVANCE</strong>, one <em class=code>NOAH_TIMESTEP</em>
+   is subtracted from the time in the <em class=code>Time</em> variable in the NOAH restart file.
+   See the expanded explanation in the NOAH <a href="model_mod.html#NOAHtimes">model_mod.html</a>.
+   <br />
+   <br />
+   The standalone version of NOAH (<em class=program>Noah_hrldas_beta</em>) requires
+   a separate forcing file for each hour in its current configuration. 
+   <em class=program>dart_to_noah</em> creates a file
+   (<em class=file>noah_advance_information.txt</em>) that has a list of
+   the expected <em class=file>*******.LDASIN_DOMAIN1</em> files needed for the next
+   model advance. Example <em class=file>noah_advance_information.txt</em> file:</P>
+
+<pre>dart_to_noah:noah  model      date 2009 Jan 02 08:00:00
+dart_to_noah:noah  advance_to_date 2009 Jan 02 09:00:00
+khour  =      1
+nfiles =      2
+2009010209.LDASIN_DOMAIN1
+2009010210.LDASIN_DOMAIN1
+</pre>
+
+       <!--There are two different types of DART output files, so there is a namelist
+       option to specify if the DART file has two time records or just one
+       (if there are two, the first one is the 'advance_to' time, followed
+       by the 'valid_time' of the ensuing state). <em class=program>dart_to_noah</em>
+       requires the DART file to be named <em class=file>dart_restart</em> and the
+       NOAH restart file have a name of <em class=file>restart.nc</em> &nbsp;.
+       If the DART file contains an 'advance_to' time,
+       <em class=program>dart_to_noah</em> creates a file
+       <em class=file>noah_advance_information.txt</em> which contains information
+       to control the length of the NOAH integration.-->
+<P>
+   While setting up an experiment or for testing purposes,
+   <em class=program>dart_to_noah</em> may be used on DART files that
+   have a header containing one time stamp followed by the model state by
+   setting <em class=file>input.nml</em>
+   <em class=code>&amp;dart_to_noah_nml:advance_time_present</em> =
+   <em class=input>.false.</em>&nbsp;.
+   <br />
+   <br />
+   During <em class=program>perfect_model_obs</em> or <em class=program>filter</em>,
+   the <em class=code>&amp;dart_to_noah_nml:advance_time_present</em> must be set
+   to <em class=input>.true.</em> to read the
+   internal DART files that have
+   <em class=italic>two</em> timestamps in the header. These files are
+   temporarily generated when DART is used to advance the model.
+   One timestamp is the 'advance_to' time, the other is the 'valid_time'
+   of the model state.
+   <br />
+   <br />
+   Conditions required for successful execution of <em class=program>dart_to_noah</em>:
+</P>
+
+<UL>
+   <LI>a valid <em class=file>input.nml</em> namelist file for DART</LI>
+   <LI>a valid <em class=file>namelist.hrldas</em> namelist file for NOAH</LI>
+   <LI>a DART file (typically linked to <em class=file>dart_restart</em>)</LI>
+   <LI>a NOAH restart file (typically linked to <em class=file>noah_restart.nc</em>).</LI>
+</UL>
+
+<P>
+<em class=program>dart_to_noah</em> and
+<em class=program>noah_to_dart</em> are used extensively in the scripts in the
+<em class=file>shell_scripts</em> directory.
+Since this program is called repeatedly for every ensemble member,
+we have found it convenient to link the DART input file
+to the default input filename (<em class=file>dart_restart</em>). The same
+thing is true for the NOAH restart files (<em class=file>noah_restart.nc</em>).
+</P>
+
+<!--==================================================================-->
+<!--=================== DESCRIPTION OF A NAMELIST ====================-->
+<!--==================================================================-->
+
+<A NAME="Namelist"></A>
+<div class="top">[<a href="#">top</a>]</div><hr />
+<H2>NAMELIST</H2>
+<P>We adhere to the F90 standard of starting a namelist with an ampersand
+'&amp;' and terminating with a slash '/' for all our namelist input.
+Character strings that contain a '/' must be
+enclosed in quotes to prevent them from prematurely terminating the namelist.
+</P>
+
+<div class=namelist>
+<pre>
+<em class=call>namelist / dart_to_noah_nml / </em> dart_to_noah_input_file, &amp;
+                                              skip_variables, &amp;
+                                              advance_time_present
+</pre>
+</div>
+<P>The <em class=code>dart_to_noah_nml</em> namelist is read from
+       <em class=file>input.nml</em></P>
+<div class=indent1>
+<!-- Description -->
+<TABLE border=0 cellpadding=3 width=100%>
+<TR><TH align=left>Contents    </TH>
+    <TH align=left>Type        </TH>
+    <TH align=left>Description </TH></TR>
+
+<TR><!--contents--><TD valign=top>dart_to_noah_input_file&nbsp;&nbsp;&nbsp;</TD>
+    <!--  type  --><TD valign=top>character(len=128)</TD>
+    <!--descript--><TD>The name of the DART file containing the model state
+                       to insert into the NOAH restart file.
+                       <em class=units>[default:&nbsp;'dart_restart']</em>
+                       </TD></TR>
+
+<TR><!--contents--><TD valign=top>skip_variables&nbsp;&nbsp;&nbsp;</TD>
+    <!--  type  --><TD valign=top>character(len=32)::<br />
+                              dimension(40)</TD>
+    <!--descript--><TD>The list of NOAH variables that <strong>must not</strong> be
+                       updated in the NOAH restart file even if they were used to 
+                       create the DART state vector. Be aware that these variables WILL
+                       be modified in <em class=file>Posterior_Diag.nc</em> so you can see
+                       the assimilated state. 
+                       <em class=units>[default:&nbsp;<em>see&nbsp;example&nbsp;below</em>]</em>
+                       </TD></TR>
+
+<TR><!--contents--><TD valign=top>advance_time_present</TD>
+    <!--  type  --><TD valign=top>logical</TD>
+    <!--descript--><TD>switch to control the ability to read a DART file
+                       containing TWO timestamps in the file header.
+		       If you are converting a DART initial conditions or
+		       restart file - this should be
+		       <em class=code>.false.</em> - these files have a
+		       single timestamp describing the valid time of the
+		       model state.
+		       <br />
+		       <br />
+		       If <em class=code>.true.</em>, TWO timestamps are
+		       expected to be the DART file header.  In this case, a
+		       namelist for NOAH (called <em class=file>noah_in.DART</em>)
+		       is created that contains the
+		       <em class=code>&amp;time_manager_nml</em> settings
+		       appropriate to advance NOAH to the time
+		       requested by DART.
+                       <em class=units>[default:&nbsp;.true.]</em>
+                       </TD></TR>
+</TABLE>
+
+</div>
+<br />
+
+
+
+<div class=namelist>
+<pre>
+<em class=call>namelist / model_nml / </em>noah_netcdf_filename, &amp;
+                                   noah_state_variables
+</pre>
+</div>
+<P>
+The <em class=code>model_nml</em> namelist is read from <em class=file>input.nml</em> .
+The full description of the <em class=code>model_nml</em> namelist is documented
+in the <a href="model_mod.html#Namelist">noah model_mod</a>, but the most important
+variables for <em class=program>noah_to_dart</em> are repeated here.
+</P>
+<div class=indent1>
+<!-- Description -->
+<TABLE border=0 cellpadding=3 width=100%>
+<TR><TH align=left>Contents    </TH>
+    <TH align=left>Type        </TH>
+    <TH align=left>Description </TH></TR>
+
+<TR><!--contents--><TD valign=top>noah_netcdf_filename&nbsp;&nbsp;&nbsp;</TD>
+    <!--  type  --><TD valign=top>character(len=128)&nbsp;&nbsp;&nbsp;</TD>
+    <!--descript--><TD>The name of the NOAH RESTART file to use to
+                       create the DART state vector. For convenience, the
+                       <em class=program>advance_model.csh</em> script usually
+                       links the most recent restart file to a static name.
+                       <em class=units>[default:&nbsp;'restart.nc']</em></TD></TR>
+
+<TR><!--contents--><TD valign=top>noah_state_variables&nbsp;&nbsp;&nbsp;</TD>
+    <!--  type  --><TD valign=top>character(len=32)::<br />
+                              dimension(2,40)&nbsp;&nbsp;&nbsp;</TD>
+    <!--descript--><TD>The list of variable names in the NOAH restart file to use to
+                       create the DART state vector and their corresponding DART kinds.
+                       <em class=units>[default:&nbsp;<em>see&nbsp;example&nbsp;below</em>]</em>
+                       </TD></TR>
+</TABLE>
+</div>
+<br />
+
+<H3 class=indent1>Example of namelists from <em class=file>input.nml</em></H3>
+<pre>
+&amp;model_nml
+   noah_netcdf_filename    = 'restart.nc',
+   noah_state_variables    = 'SOIL_T',   'KIND_SOIL_TEMPERATURE',
+                             'SOIL_M',   'KIND_SOIL_MOISTURE',
+                             'SOIL_W',   'KIND_SOIL_LIQUID_WATER',
+                             'SKINTEMP', 'KIND_SKIN_TEMPERATURE',
+                             'SNODEP',   'KIND_SNOW_THICKNESS',
+                             'WEASD',    'KIND_SNOW_WATER',
+                             'CANWAT',   'KIND_CANOPY_WATER',
+                             'QFX',      'KIND_LATENT_HEAT_FLUX',
+                             'HFX',      'KIND_SENSIBLE_HEAT_FLUX',
+                             'GRDFLX',   'KIND_GROUND_HEAT_FLUX'
+  /
+
+&amp;dart_to_noah_nml
+   dart_to_noah_input_file = 'dart_restart',
+   skip_variables          = 'QFX','HFX',
+   advance_time_present    = .true.
+  /
+</pre>
+
+<!--  ------------------------------------------------  -->
+
+<div class=namelist>
+<pre>
+<em class=call>namelist / NOAHLSM_OFFLINE / </em>khour, &amp;
+                                            forcing_timestep, &amp;
+                                            noah_timestep, &amp;
+                                            output_timestep, &amp;
+                                            restart_frequency_hours, &amp;
+                                            split_output_count
+</pre>
+</div>
+<P>
+The <em class=code>NOAHLSM_OFFLINE</em> namelist is read from 
+<em class=file>namelist.hrldas</em> - only those variables important for
+<em class=program>noah_to_dart</em> are repeated here. The interpretations
+are exactly as described in the NOAH documentation. <br />
+<strong>The values in the following example are the only values expected to work.</strong>
+Change these at your own risk!
+</P>
+
+<H3 class=indent1>Example of namelist from <em class=file>namelist.hrldas</em></H3>
+<pre>
+&amp;NOAHLSM_OFFLINE
+   ...
+   KHOUR                   = 1
+   FORCING_TIMESTEP        = 3600
+   NOAH_TIMESTEP           = 3600
+   OUTPUT_TIMESTEP         = 3600
+   RESTART_FREQUENCY_HOURS = 1
+   SPLIT_OUTPUT_COUNT      = 1
+   ...
+  /
+</pre>
+</div>
+<P></P>
+
+<!--==================================================================-->
+
+<A NAME="Modules"></A>
+<div class="top">[<a href="#">top</a>]</div><hr />
+<H2>MODULES USED</H2>
+<PRE>
+assim_model_mod
+location_mod
+model_mod
+null_mpi_utilities_mod
+obs_kind_mod
+random_seq_mod
+time_manager_mod
+types_mod
+utilities_mod
+</PRE>
+<P></P>
+
+<!--==================================================================-->
+<!-- Describe the Files Used by this module.                          -->
+<!--==================================================================-->
+
+<A NAME="FilesUsed"></A>
+<div class="top">[<a href="#">top</a>]</div><hr />
+<H2>FILES Read</H2>
+<UL><LI>DART initial conditions/restart file, e.g. <em class=file>dart_restart</em></LI>
+    <LI>DART namelist file: <em class=file>input.nml</em></LI>
+    <LI>NOAH namelist file: <em class=file>namelist.hrldas</em></LI>
+    <LI>NOAH restart file: <em class=file>noah_restart.nc</em></LI>
+</UL>
+
+<H2>FILES Written</H2>
+<UL><LI>NOAH restart file: <em class=file>noah_restart.nc</em></LI>
+    <LI><em class=file>noah_advance_information.txt</em> - which contains a
+        list of "LDASIN" files needed to advance the model.</LI>
+</UL>
+<P></P>
+
+<!--==================================================================-->
+<!-- Cite references, if need be.                                     -->
+<!--==================================================================-->
+
+<A NAME="References"></A>
+<div class="top">[<a href="#">top</a>]</div><hr />
+<H2>REFERENCES</H2>
+<ul>
+<li>The site for the offline 2D driver code <em class=program>HRLDAS v3.4.1</em>
+can be found at <a href="http://www.ral.ucar.edu/research/land/technology/lsm.php">
+http://www.ral.ucar.edu/research/land/technology/lsm.php</a>
+</ul>
+<P>
+</P>
+
+<!--==================================================================-->
+<!-- Describe all the error conditions and codes.                     -->
+<!--==================================================================-->
+
+<A NAME="Errors"></A>
+<div class="top">[<a href="#">top</a>]</div><hr />
+<H2>ERROR CODES and CONDITIONS</H2>
+<P>
+none - all error messages come from modules that have their own documentation.
+</P>
+
+<H2>KNOWN BUGS</H2>
+<P>
+none
+</P>
+
+<!--==================================================================-->
+<!-- Describe Future Plans.                                           -->
+<!--==================================================================-->
+
+<A NAME="FuturePlans"></A>
+<div class="top">[<a href="#">top</a>]</div><hr />
+<H2>FUTURE PLANS</H2>
+<P>
+None.
+</P>
+
+<!--==================================================================-->
+<!-- Legalese & Metadata                                              -->
+<!--==================================================================-->
+
+<A NAME="Legalese"></A>
+<div class="top">[<a href="#">top</a>]</div><hr />
+<H2>Terms of Use</H2>
+
+<P>
+DART software - Copyright 2004 - 2011 UCAR.<br />
+This open source software is provided by UCAR, "as is",<br />
+without charge, subject to all terms of use at<br />
+<a href="http://www.image.ucar.edu/DAReS/DART/DART_download">
+http://www.image.ucar.edu/DAReS/DART/DART_download</a>
+</P>
+
+<TABLE border=0 cellpadding=0 width=100% summary="">
+<TR><TD valign=top>Contact:       </TD><TD> Tim Hoar </TD></TR>
+<TR><TD valign=top>Revision:      </TD><TD> $Revision$ </TD></TR>
+<TR><TD valign=top>Source:        </TD><TD> $URL$ </TD></TR>
+<TR><TD valign=top>Change Date:   </TD><TD> $Date$ </TD></TR>
+<TR><TD valign=top>Change&nbsp;history:&nbsp;</TD><TD> try "svn&nbsp;log" or "svn&nbsp;diff" </TD></TR>
+</TABLE>
+
+<!--==================================================================-->
+
+</BODY>
+</HTML>


Property changes on: DART/branches/development/models/noah/dart_to_noah.html
___________________________________________________________________
Added: svn:mime-type
   + text/html
Added: svn:keywords
   + Date Rev Author HeadURL Id
Added: svn:eol-style
   + native

Modified: DART/branches/development/models/noah/model_mod.f90
===================================================================
--- DART/branches/development/models/noah/model_mod.f90	2012-11-15 17:00:46 UTC (rev 5925)
+++ DART/branches/development/models/noah/model_mod.f90	2012-11-19 23:39:10 UTC (rev 5926)
@@ -78,7 +78,8 @@
 public :: noah_to_dart_vector, &
           dart_vector_to_model_file, &
           get_noah_restart_filename, &
-          get_noah_timestepping
+          get_noah_timestepping,     &
+          get_debug_level
 
 ! version controlled file description for error handling, do not edit
 character(len=128), parameter :: &
@@ -87,26 +88,29 @@
    revdate  = "$Date$"
 
 !------------------------------------------------------------------
-! The variables in the noah restart file that are used to create the
-! DART state vector are specified in the input.nml:model_nml namelist.
-!
-!    noah_variables  = 'STC',    'KIND_SOIL_TEMPERATURE',
-!                      'SMC',    'KIND_SOIL_MOISTURE',
-!                      'SH2O',   'KIND_LIQUID_SOIL_MOISTURE',
-!                      'T1',     'KIND_SKIN_TEMPERATURE',
-!                      'SNOWH',  'KIND_SNOW_DEPTH',
-!                      'SNEQV',  'KIND_LIQUID_EQUIVALENT',
-!                      'CMC',    'KIND_CANOPY_WATER',
+! The NSOLDX parameter comes from the NOAH source code. We need it
+! because we have to read the NOAH namelist for timestep information.
 !------------------------------------------------------------------
 
 integer :: nfields
 integer, parameter :: NSOLDX = 100
 integer, parameter :: MAX_STATE_VARIABLES = 40
 integer, parameter :: NUM_STATE_TABLE_COLUMNS = 2
-character(len=obstypelength) :: variable_table(MAX_STATE_VARIABLES, NUM_STATE_TABLE_COLUMNS)
 
 !------------------------------------------------------------------
 ! things which can/should be in the DART model_nml
+! The variables in the noah restart file that are used to create the
+! DART state vector are specified in the input.nml:model_nml namelist.
+! For example:
+!
+! noah_state_variables  = 'STC',    'KIND_SOIL_TEMPERATURE',
+!                         'SMC',    'KIND_SOIL_MOISTURE',
+!                         'SH2O',   'KIND_LIQUID_SOIL_MOISTURE',
+!                         'T1',     'KIND_SKIN_TEMPERATURE',
+!                         'SNOWH',  'KIND_SNOW_DEPTH',
+!                         'SNEQV',  'KIND_LIQUID_EQUIVALENT',
+!                         'CMC',    'KIND_CANOPY_WATER'
+!
 !------------------------------------------------------------------
 
 character(len=128)    :: noah_netcdf_filename   = 'restart.nc'
@@ -114,14 +118,13 @@
 integer               :: assimilation_period_seconds  = 60
 real(r8)              :: model_perturbation_amplitude = 0.2
 logical               :: output_state_vector          = .true.
-character(len=32)     :: calendar = 'Gregorian'
 integer               :: debug    = 0  ! turn up for more and more debug messages
-character(len=obstypelength) :: noah_variables(MAX_STATE_VARIABLES*NUM_STATE_TABLE_COLUMNS) = ' '
+character(len=obstypelength) :: noah_state_variables(NUM_STATE_TABLE_COLUMNS,MAX_STATE_VARIABLES) = ' '
 
 namelist /model_nml/ noah_netcdf_filename, &
           assimilation_period_days, assimilation_period_seconds,   &
           model_perturbation_amplitude, output_state_vector,       &
-          calendar, debug, noah_variables
+          debug, noah_state_variables
 
 !------------------------------------------------------------------
 ! Everything needed to recreate the NOAH METADTA_NAMELIST
@@ -137,10 +140,10 @@
 
 character(len=128)    :: noah_namelist_filename = 'namelist.hrldas' ! mandate
 
-real(r8), dimension(nsoldx) :: zsoil
+real(r8), dimension(NSOLDX) :: zsoil
 integer                     :: nsoil
 
-CHARACTER(len=256) :: indir
+CHARACTER(len=256) :: indir = "."
 character(len=256) :: outdir = "."
 character(len=256) :: hrldas_constants_file = " "
 character(len=256) :: external_fpar_filename_template = " "
@@ -220,6 +223,7 @@
 type(time_type)    :: model_time_step  ! smallest time to adv model
 character(len=256) :: string1, string2, string3
 logical, save      :: module_initialized = .false.
+character(len=32)  :: calendar = 'Gregorian'
 
 real(r8), allocatable, dimension(:,:) :: xlong, xlat
 integer :: south_north, west_east
@@ -322,7 +326,7 @@
 ! FIXME ... make sure model_time_step is attainable given OUTPUT_TIMESTEP
 model_time_step = set_time(assimilation_period_seconds, assimilation_period_days)
 
-if (do_output()) then
+if (do_output() .and. (debug > 0)) then
    call print_date(model_time     ,' static_init_model:model date')
    call print_time(model_time     ,' static_init_model:model time')
    call print_time(model_time_step,' static_init_model:model timestep')
@@ -333,7 +337,7 @@
 call nc_check(nf90_inq_dimid(iunit, 'soil_layers_stag', dimIDs(1)), &
                   'static_init_model','inq_dimid soil_layers_stag '//trim(noah_netcdf_filename))
 call nc_check(nf90_inquire_dimension(iunit, dimIDs(1), len=nLayers), &
-                  'static_init_model','inquire_dimension Time '//trim(noah_netcdf_filename))
+                  'static_init_model','inquire_dimension soil_layers_stag '//trim(noah_netcdf_filename))
 
 if (nsoil /= nLayers) then
    write(string1,*) 'Expected ',nsoil,' soil layers ', &
@@ -341,11 +345,11 @@
    call error_handler(E_ERR,'static_init_model',string1,source,revision,revdate)
 endif
 
-! TJH FIXME ... extend to 2D case ... should be in get_state_meta_data()
-! convert soil thicknesses to depths
-! closer to the center of the earth is an increasingly large negative number
+! FIXME ... extend to 2D case ... should be in get_state_meta_data()
+! Convert soil thicknesses (from namelist.hrldas) to "heights".
+! Closer to the center of the earth is an increasingly large negative number
 allocate(state_loc(0:nsoil))
-state_loc(0)   = set_location(xlong(1,1), xlat(1,1), 0.0_r8, VERTISSURFACE)
+state_loc(0)   = set_location(xlong(1,1), xlat(1,1), 0.0_r8, VERTISHEIGHT)
 do i = 1,nsoil
    state_loc(  i) = set_location(xlong(1,1), xlat(1,1), zsoil(i), VERTISHEIGHT)
 enddo
@@ -358,14 +362,13 @@
 ! Compute the offsets into the state vector for each variable type.
 ! Record the extent of the variable type in the state vector.
 
-call verify_state_variables( noah_variables, iunit, noah_netcdf_filename, &
-                             nfields, variable_table )
+call verify_state_variables(iunit, noah_netcdf_filename, nfields)
 
 index1  = 1
 FILL_PROGVAR : do ivar = 1, nfields
 
-   varname                   = trim(variable_table(ivar,1))
-   kind_string               = trim(variable_table(ivar,2))
+   varname                   = trim(noah_state_variables(1,ivar))
+   kind_string               = trim(noah_state_variables(2,ivar))
    progvar(ivar)%varname     = varname
    progvar(ivar)%kind_string = kind_string
    progvar(ivar)%dart_kind   = get_raw_obs_kind_index( progvar(ivar)%kind_string )
@@ -413,13 +416,14 @@
       progvar(ivar)%stagger = '-'
    endif
 
+   ! This is fundamentally hardcoded clamping. See WRF/model_mod.f90 for a namelist-driven
+   ! example.  It would be nice to use the netCDF file valid_range attribute ...
+   !
    ! if the variable is bounded, then we need to know how to restrict it.
    ! rangeRestricted == 0 is unbounded
    ! rangeRestricted == 1 is bounded below
    ! rangeRestricted == 2 is bounded above           ( TJH unsupported )
    ! rangeRestricted == 3 is bounded above and below ( TJH unsupported )
-   ! Until we have more information ... (i.e. the netCDF files have the appropriate
-   ! valid_range attribute) ... we must guess.
 
    if ( varname == 'QFX' ) then
       progvar(ivar)%rangeRestricted = 0
@@ -457,7 +461,7 @@
    progvar(ivar)%indexN      = index1 + varsize - 1
    index1                    = index1 + varsize      ! sets up for next variable
 
-   if ( debug > 99 ) then
+   if ( (do_output()) .and. debug > 10 ) then
       write(logfileunit,*)
       write(logfileunit,*) trim(progvar(ivar)%varname),' variable number ',ivar
       write(logfileunit,*) '  long_name   ',trim(progvar(ivar)%long_name)
@@ -497,7 +501,7 @@
 
 model_size = progvar(nfields)%indexN
 
-if ( debug > 99 ) then
+if ( (do_output()) .and. debug > 99 ) then
 
    write(*,*)
    do i=0,nsoil
@@ -513,7 +517,6 @@
 
 subroutine init_conditions(x)
 !------------------------------------------------------------------
-! subroutine init_conditions(x)
 !
 ! Returns a model state vector, x, that is some sort of appropriate
 ! initial condition for starting up a long integration of the model.
@@ -527,6 +530,11 @@
 
 if ( .not. module_initialized ) call static_init_model
 
+write(string1,*) 'PROBLEM: no known way to set arbitrary initial conditions.'
+write(string2,*) 'start_from_restart must be .true. in this model.'
+call error_handler(E_ERR,'init_conditions',string1,source,revision,revdate, &
+                               text2=string2)
+
 x = MISSING_R8
 
 end subroutine init_conditions
@@ -535,7 +543,6 @@
 
 subroutine adv_1step(x, time)
 !------------------------------------------------------------------
-! subroutine adv_1step(x, time)
 !
 ! Does a single timestep advance of the model. The input value of
 ! the vector x is the starting condition and x is updated to reflect
@@ -694,13 +701,14 @@
          exit DEPTH
       endif
    enddo DEPTH
+   ! FIXME what if zlev is never set
    indx = progvar(ivar)%index1 + zlev - 1
 endif
 
 obs_val = x( indx )
 if (obs_val /= MISSING_R8) istatus = 0
 
-if ( debug > 99 ) then
+if ( (do_output()) .and. debug > 20 ) then
    write(*,*)'model_interpolate : progvar%kind_string is ',trim(progvar(ivar)%kind_string)
    write(*,*)'model_interpolate : state index         is ',indx
    write(*,*)'model_interpolate : value               is ',obs_val
@@ -765,7 +773,7 @@
    endif
 enddo FindIndex
 
-if ( debug > 99 ) then
+if ( (do_output()) .and. debug > 30 ) then
    write(*,*)'get_state_meta_data: index_in is ',index_in
    write(*,*)'get_state_meta_data: ivar     is ',ivar
    write(*,*)'get_state_meta_data: layer    is ',layer
@@ -983,8 +991,6 @@
   has_noah_namelist = .false.
 endif
 
-if ( debug > 99 ) print *, 'noah namelist: nlines, linelen = ', nlines, linelen
-
 if (has_noah_namelist) then
    allocate(textblock(nlines))
    textblock = ''
@@ -993,12 +999,12 @@
           len = nlines, dimid = nlinesDimID), &
           'nc_write_model_atts', 'def_dim noahNMLnlines '//trim(filename))
 
-   call nc_check(nf90_def_var(ncFileID,name='noah_namelist', xtype=nf90_char,    &
+   call nc_check(nf90_def_var(ncFileID,name=trim(noah_namelist_filename), xtype=nf90_char,    &
           dimids = (/ linelenDimID, nlinesDimID /),  varid=nmlVarID), &
-          'nc_write_model_atts', 'def_var noah_namelist'//trim(filename))
+          'nc_write_model_atts', 'def_var noah_namelist '//trim(filename))
 
-   call nc_check(nf90_put_att(ncFileID, nmlVarID, 'long_name', 'contents of noah_namelist'), &
-          'nc_write_model_atts', 'put_att noah_namelist'//trim(filename))
+   call nc_check(nf90_put_att(ncFileID, nmlVarID, 'long_name', 'contents of '//trim(noah_namelist_filename)), &
+          'nc_write_model_atts', 'put_att noah_namelist '//trim(filename))
 
 endif
 
@@ -1328,10 +1334,10 @@
       where(dimIDs == TimeDimID) mystart = timeindex
       where(dimIDs == TimeDimID) mycount = 1
 
-      if ( debug > 99 ) then
+      if ( (do_output()) .and. debug > 10 ) then
          write(*,*)'nc_write_model_vars '//trim(varname)//' start is ',mystart(1:ncNdims)
          write(*,*)'nc_write_model_vars '//trim(varname)//' count is ',mycount(1:ncNdims)
-         write(*,*)'nc_write_model_vars ',dimnames(1:progvar(ivar)%numdims)
+         write(*,'(A20)')'nc_write_model_vars ',dimnames(1:progvar(ivar)%numdims)
       endif
 
       ! If the original variable is shaped:
@@ -1442,17 +1448,20 @@
 
 if ( .not. module_initialized ) call static_init_model
 
-pert_state      = state
+call error_handler(E_ERR,'pert_model_state', &
+                  'NOAH cannot be started from a single vector', &
+                  source, revision, revdate, &
+                  text2='see comments in noah/model_mod.f90::pert_model_state()',&
+                  text3='or noah/model_mod.html#pert_model_state')
+
 interf_provided = .false.
 
 end subroutine pert_model_state
 
 
 
-
 subroutine ens_mean_for_model(ens_mean)
 !------------------------------------------------------------------
-! Not used in low-order models
 
 real(r8), intent(in) :: ens_mean(:)
 
@@ -1468,37 +1477,38 @@
 ! with predefined file formats and control structures.)
 !==================================================================
 
+function get_debug_level()
+   integer :: get_debug_level
 
-subroutine verify_state_variables( state_variables, ncid, filename, ngood, table )
+   get_debug_level = debug
+
+end function
+
+
+
+subroutine verify_state_variables( ncid, filename, ngood )
 !------------------------------------------------------------------
 
-character(len=*), dimension(:),   intent(in)  :: state_variables
 integer,                          intent(in)  :: ncid
 character(len=*),                 intent(in)  :: filename
 integer,                          intent(out) :: ngood
-character(len=*), dimension(:,:), intent(out) :: table
 
-integer :: nrows, ncols, i, VarID
+integer :: i, VarID
 character(len=NF90_MAX_NAME) :: varname
 character(len=NF90_MAX_NAME) :: dartstr
 
 if ( .not. module_initialized ) call static_init_model
 
-nrows = size(table,1)
-ncols = size(table,2)
-
 ngood = 0

@@ Diff output truncated at 40000 characters. @@


More information about the Dart-dev mailing list