<p><b>duda</b> 2010-05-27 15:40:42 -0600 (Thu, 27 May 2010)</p><p>Add changes to the registry program to allow field dimensions (other than<br>
the outer-most dimension, which must be one of nCells, nEdges, nVertices,<br>
nVertLevels, or nVertLevelsP1) to be defined in the namelist at run-time<br>
rather than by the input grid file.<br>
<br>
For example, one can now define the following in the Registry file:<br>
<br>
   namelist integer   dimensions     config_nx        10<br>
<br>
   dim nx namelist:config_nx<br>
<br>
   var real    foo ( nx nCells ) ro foo - -<br>
<br>
where the dimension nx will take on whatever value is specified by the<br>
namelist parameter config_nx, which has a default value of 10. The key to<br>
specifying namelist-defined dimensions is the prefix 'namelist:' in the<br>
dimension definition.<br>
<br>
<br>
M    src/registry/registry_types.h<br>
M    src/registry/gen_inc.c<br>
M    src/registry/parse.c<br>
</p><hr noshade><pre><font color="gray">Modified: trunk/mpas/src/registry/gen_inc.c
===================================================================
--- trunk/mpas/src/registry/gen_inc.c        2010-05-27 19:41:43 UTC (rev 315)
+++ trunk/mpas/src/registry/gen_inc.c        2010-05-27 21:40:42 UTC (rev 316)
@@ -222,12 +222,14 @@
    fd = fopen(&quot;field_dimensions.inc&quot;, &quot;w&quot;);
    dim_ptr = dims;
    while (dim_ptr) {
-      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: %s</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: %s</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: %s</font>
<font color="red">&quot;, dim_ptr-&gt;name_in_file);
       dim_ptr = dim_ptr-&gt;next;
    }
    dim_ptr = dims;
    while (dim_ptr) {
-      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: %sSolve</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: %sSolve</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: %sSolve</font>
<font color="gray">&quot;, dim_ptr-&gt;name_in_file);
       dim_ptr = dim_ptr-&gt;next;
    }
 
@@ -239,12 +241,17 @@
     */
    fd = fopen(&quot;dim_dummy_args.inc&quot;, &quot;w&quot;);
    dim_ptr = dims;
-   if (dim_ptr &amp;&amp; dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) {
+   if (dim_ptr &amp;&amp; dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) {
       fortprintf(fd, &quot;                            %s&quot;, dim_ptr-&gt;name_in_code);
       dim_ptr = dim_ptr-&gt;next;
    }
+   else if (dim_ptr &amp;&amp; dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) {
+      fortprintf(fd, &quot;                            %s&quot;, dim_ptr-&gt;name_in_file);
+      dim_ptr = dim_ptr-&gt;next;
+   }
    while (dim_ptr) {
-      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;, %s&quot;, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;, %s&quot;, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;, %s&quot;, dim_ptr-&gt;name_in_file);
       dim_ptr = dim_ptr-&gt;next;
    }
    fortprintf(fd, &quot; &amp;</font>
<font color="gray">&quot;);
@@ -257,12 +264,17 @@
     */
    fd = fopen(&quot;dim_dummy_decls.inc&quot;, &quot;w&quot;);
    dim_ptr = dims;
-   if (dim_ptr &amp;&amp; dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) {
+   if (dim_ptr &amp;&amp; dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) {
       fortprintf(fd, &quot;      integer, intent(in) :: %s&quot;, dim_ptr-&gt;name_in_code);
       dim_ptr = dim_ptr-&gt;next;
    }
+   else if (dim_ptr &amp;&amp; dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) {
+      fortprintf(fd, &quot;      integer, intent(in) :: %s&quot;, dim_ptr-&gt;name_in_file);
+      dim_ptr = dim_ptr-&gt;next;
+   }
    while (dim_ptr) {
-      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;, %s&quot;, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;, %s&quot;, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;, %s&quot;, dim_ptr-&gt;name_in_file);
       dim_ptr = dim_ptr-&gt;next;
    }
    fortprintf(fd, &quot;</font>
<font color="gray">&quot;);
@@ -276,7 +288,8 @@
    fd = fopen(&quot;dim_decls.inc&quot;, &quot;w&quot;);
    dim_ptr = dims;
    while (dim_ptr) {
-      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: %s</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: %s</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: %s</font>
<font color="gray">&quot;, dim_ptr-&gt;name_in_file);
       dim_ptr = dim_ptr-&gt;next;
    }
 
@@ -289,7 +302,8 @@
    fd = fopen(&quot;read_dims.inc&quot;, &quot;w&quot;);
    dim_ptr = dims;
    while (dim_ptr) {
-      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      call io_input_get_dimension(input_obj, \'%s\', %s)</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_file, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      call io_input_get_dimension(input_obj, \'%s\', %s)</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_file, dim_ptr-&gt;name_in_code);
+      else if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      call io_input_get_dimension(input_obj, \'%s\', %s)</font>
<font color="gray">&quot;, dim_ptr-&gt;name_in_file, dim_ptr-&gt;name_in_file);
       dim_ptr = dim_ptr-&gt;next;
    }
 
@@ -365,7 +379,8 @@
 
    dim_ptr = dims;
    while (dim_ptr) {
-      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      g %% %s = %s</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      g %% %s = %s</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      g %% %s = %s</font>
<font color="black">&quot;, dim_ptr-&gt;name_in_file, dim_ptr-&gt;name_in_file);
       dim_ptr = dim_ptr-&gt;next;
    }
    fortprintf(fd, &quot;</font>
<font color="gray">&quot;);
@@ -392,7 +407,8 @@
                 !strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nVertices&quot;, 1024))
                fortprintf(fd, &quot;%s + 1&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
             else
-               fortprintf(fd, &quot;%s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+               if (dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;%s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
+               else fortprintf(fd, &quot;%s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
             dimlist_ptr = dimlist_ptr-&gt;next;
             while (dimlist_ptr) {
                if (!strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nCells&quot;, 1024) ||
@@ -400,7 +416,8 @@
                    !strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nVertices&quot;, 1024))
                   fortprintf(fd, &quot;, %s + 1&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
                else
-                  fortprintf(fd, &quot;, %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  if (dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;, %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
+                  else fortprintf(fd, &quot;, %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
                dimlist_ptr = dimlist_ptr-&gt;next;
             }
             fortprintf(fd, &quot;))</font>
<font color="gray">&quot;);
@@ -432,7 +449,8 @@
                    !strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nVertices&quot;, 1024))
                   fortprintf(fd, &quot;%s + 1&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
                else
-                  fortprintf(fd, &quot;%s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  if (dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;%s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
+                  else fortprintf(fd, &quot;%s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
                dimlist_ptr = dimlist_ptr-&gt;next;
                while (dimlist_ptr) {
                   if (!strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nCells&quot;, 1024) ||
@@ -440,7 +458,8 @@
                       !strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nVertices&quot;, 1024))
                      fortprintf(fd, &quot;, %s + 1&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
                   else
-                     fortprintf(fd, &quot;, %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                     if (dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;, %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
+                     else fortprintf(fd, &quot;, %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
                   dimlist_ptr = dimlist_ptr-&gt;next;
                }
                fortprintf(fd, &quot;))</font>
<font color="gray">&quot;);
@@ -541,7 +560,8 @@
                 !strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nVertices&quot;, 1024))
                fortprintf(fd, &quot;b %% mesh %% %s + 1&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
             else
-               fortprintf(fd, &quot;b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+               if (dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
+               else fortprintf(fd, &quot;b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
             dimlist_ptr = dimlist_ptr-&gt;next;
             while (dimlist_ptr) {
                if (!strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nCells&quot;, 1024) ||
@@ -549,7 +569,8 @@
                    !strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nVertices&quot;, 1024))
                   fortprintf(fd, &quot;, b %% mesh %% %s + 1&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
                else
-                  fortprintf(fd, &quot;, b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  if (dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;, b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
+                  else fortprintf(fd, &quot;, b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
                dimlist_ptr = dimlist_ptr-&gt;next;
             }
             fortprintf(fd, &quot;))</font>
<font color="gray">&quot;);
@@ -582,7 +603,8 @@
                    !strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nVertices&quot;, 1024))
                   fortprintf(fd, &quot;b %% mesh %% %s + 1&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
                else
-                  fortprintf(fd, &quot;b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  if (dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
+                  else fortprintf(fd, &quot;b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
             }
             else {
                fortprintf(fd, &quot;%i&quot;, dimlist_ptr-&gt;dim-&gt;constant_value);
@@ -595,7 +617,8 @@
                       !strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nVertices&quot;, 1024))
                      fortprintf(fd, &quot;, b %% mesh %% %s + 1&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
                   else
-                     fortprintf(fd, &quot;, b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                     if (dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;, b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
+                     else fortprintf(fd, &quot;, b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
                }
                else {
                   fortprintf(fd, &quot;, %i&quot;, dimlist_ptr-&gt;dim-&gt;constant_value);
@@ -783,7 +806,7 @@
    fortprintf(fd, &quot;      integer :: rdDimIDTime</font>
<font color="red">&quot;);
    dim_ptr = dims;
    while (dim_ptr) {
-      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: rdDimID%s</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_file);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: rdDimID%s</font>
<font color="black">&quot;, dim_ptr-&gt;name_in_file);
       dim_ptr = dim_ptr-&gt;next;
    }
    fortprintf(fd, &quot;</font>
<font color="gray">&quot;);
@@ -791,7 +814,7 @@
    fortprintf(fd, &quot;      integer :: rdLocalTime</font>
<font color="red">&quot;);
    dim_ptr = dims;
    while (dim_ptr) {
-      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: rdLocal%s</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_file);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: rdLocal%s</font>
<font color="black">&quot;, dim_ptr-&gt;name_in_file);
       dim_ptr = dim_ptr-&gt;next;
    }
    fortprintf(fd, &quot;</font>
<font color="gray">&quot;);
@@ -851,7 +874,8 @@
                   fortprintf(fd, &quot;#endif</font>
<font color="red">&quot;);
                }
                if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-                  fortprintf(fd, &quot;      %s%id %% ioinfo %% count(%i) = block %% mesh %% %s</font>
<font color="blue">&quot;, vtype, var_ptr-&gt;ndims, i, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;      %s%id %% ioinfo %% count(%i) = block %% mesh %% %s</font>
<font color="blue">&quot;, vtype, var_ptr-&gt;ndims, i, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  else fortprintf(fd, &quot;      %s%id %% ioinfo %% count(%i) = block %% mesh %% %s</font>
<font color="black">&quot;, vtype, var_ptr-&gt;ndims, i, dimlist_ptr-&gt;dim-&gt;name_in_file);
                else
                   fortprintf(fd, &quot;      %s%id %% ioinfo %% count(%i) = %s</font>
<font color="gray">&quot;, vtype, var_ptr-&gt;ndims, i, dimlist_ptr-&gt;dim-&gt;name_in_code);
                if (has_vert_dim) {
@@ -884,7 +908,8 @@
    
          if (i &lt; var_ptr-&gt;ndims) {
             if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-               fortprintf(fd, &quot;block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+               if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+               else fortprintf(fd, &quot;block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
             else
                fortprintf(fd, &quot;%s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
          }
@@ -904,7 +929,8 @@
          while (dimlist_ptr) {
             if (i &lt; var_ptr-&gt;ndims) {
                if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-                  fortprintf(fd, &quot;, block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;, block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  else fortprintf(fd, &quot;, block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
                else
                   fortprintf(fd, &quot;, %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
             }
@@ -930,7 +956,8 @@
       
             if (i &lt; var_ptr-&gt;ndims) {
                if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-                  fortprintf(fd, &quot;block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  else fortprintf(fd, &quot;block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
                else
                   fortprintf(fd, &quot;%s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
             }
@@ -938,7 +965,8 @@
             i++;
             while (dimlist_ptr) {
                if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-                  fortprintf(fd, &quot;, block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;, block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  else fortprintf(fd, &quot;, block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
                else
                   fortprintf(fd, &quot;, %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
                dimlist_ptr = dimlist_ptr-&gt;next;
@@ -994,7 +1022,8 @@
          
          if (i &lt; var_ptr-&gt;ndims)
             if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-               fortprintf(fd, &quot;                                block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+               if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;                                block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+               else fortprintf(fd, &quot;                                block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
             else
                fortprintf(fd, &quot;                                %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
          else {
@@ -1014,7 +1043,8 @@
          while (dimlist_ptr) {
             if (i &lt; var_ptr-&gt;ndims)
                if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-                  fortprintf(fd, &quot;, block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;, block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  else fortprintf(fd, &quot;, block %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
                else
                   fortprintf(fd, &quot;, %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
             else {
@@ -1046,7 +1076,8 @@
             dimlist_ptr = var_ptr-&gt;dimlist;
             while (i &lt;= var_ptr-&gt;ndims) {
                if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-                  fortprintf(fd, &quot;      do i%i=1,block %% mesh %% %s</font>
<font color="blue">&quot;, i, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;      do i%i=1,block %% mesh %% %s</font>
<font color="blue">&quot;, i, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  else fortprintf(fd, &quot;      do i%i=1,block %% mesh %% %s</font>
<font color="black">&quot;, i, dimlist_ptr-&gt;dim-&gt;name_in_file);
                else
                   fortprintf(fd, &quot;      do i%i=1,%s</font>
<font color="gray">&quot;, i, dimlist_ptr-&gt;dim-&gt;name_in_code);
    
@@ -1104,7 +1135,7 @@
    fortprintf(fd, &quot;      nferr = nf_inq_dimlen(input_obj %% rd_ncid, input_obj %% rdDimIDTime, input_obj %% rdLocalTime)</font>
<font color="red">&quot;);
    dim_ptr = dims;
    while (dim_ptr) {
-      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) {
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) {
          fortprintf(fd, &quot;      nferr = nf_inq_dimid(input_obj %% rd_ncid, \'%s\', input_obj %% rdDimID%s)</font>
<font color="black">&quot;, dim_ptr-&gt;name_in_file, dim_ptr-&gt;name_in_file);
          fortprintf(fd, &quot;      nferr = nf_inq_dimlen(input_obj %% rd_ncid, input_obj %% rdDimID%s, input_obj %% rdLocal%s)</font>
<font color="gray">&quot;, dim_ptr-&gt;name_in_file, dim_ptr-&gt;name_in_file);
       }
@@ -1128,13 +1159,25 @@
 
    dim_ptr = dims;
    while (dim_ptr-&gt;constant_value &gt;= 0 || is_derived_dim(dim_ptr-&gt;name_in_code)) dim_ptr = dim_ptr-&gt;next;
-   fortprintf(fd, &quot;      if (trim(dimname) == \'%s\') then</font>
<font color="red">&quot;, dim_ptr-&gt;name_in_code);
-   fortprintf(fd, &quot;         dimsize = input_obj %% rdLocal%s</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_file);
+   if (!dim_ptr-&gt;namelist_defined) {
+      fortprintf(fd, &quot;      if (trim(dimname) == \'%s\') then</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code);
+      fortprintf(fd, &quot;         dimsize = input_obj %% rdLocal%s</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_file);
+   }
+   else {
+      fortprintf(fd, &quot;      if (trim(dimname) == \'%s\') then</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_file);
+      fortprintf(fd, &quot;         dimsize = %s</font>
<font color="red">&quot;, dim_ptr-&gt;name_in_code);
+   }
    dim_ptr = dim_ptr-&gt;next;
    while (dim_ptr) {
       if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) {
-         fortprintf(fd, &quot;      else if (trim(dimname) == \'%s\') then</font>
<font color="red">&quot;, dim_ptr-&gt;name_in_code);
-         fortprintf(fd, &quot;         dimsize = input_obj %% rdLocal%s</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_file);
+         if (!dim_ptr-&gt;namelist_defined) {
+            fortprintf(fd, &quot;      else if (trim(dimname) == \'%s\') then</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code);
+            fortprintf(fd, &quot;         dimsize = input_obj %% rdLocal%s</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_file);
+         }
+         else {
+            fortprintf(fd, &quot;      else if (trim(dimname) == \'%s\') then</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_file);
+            fortprintf(fd, &quot;         dimsize = %s</font>
<font color="gray">&quot;, dim_ptr-&gt;name_in_code);
+         }
       }
       dim_ptr = dim_ptr-&gt;next;
    }
@@ -1252,7 +1295,8 @@
 
    dim_ptr = dims;
    while (dim_ptr) {
-      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: %sGlobal</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: %sGlobal</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      integer :: %sGlobal</font>
<font color="black">&quot;, dim_ptr-&gt;name_in_file);
       dim_ptr = dim_ptr-&gt;next;
    }
    fortprintf(fd, &quot;</font>
<font color="gray">&quot;);
@@ -1267,7 +1311,8 @@
 
    dim_ptr = dims;
    while (dim_ptr) {
-      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      %sGlobal = block_ptr %% mesh %% %s</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      %sGlobal = block_ptr %% mesh %% %s</font>
<font color="blue">&quot;, dim_ptr-&gt;name_in_code, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;      %sGlobal = block_ptr %% mesh %% %s</font>
<font color="black">&quot;, dim_ptr-&gt;name_in_file, dim_ptr-&gt;name_in_file);
       dim_ptr = dim_ptr-&gt;next;
    }
    fortprintf(fd, &quot;</font>
<font color="gray">&quot;);
@@ -1281,11 +1326,13 @@
    fd = fopen(&quot;output_dim_actual_args.inc&quot;, &quot;w&quot;);
    dim_ptr = dims;
    if (dim_ptr &amp;&amp; dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) {
-      fortprintf(fd, &quot;                            %sGlobal&quot;, dim_ptr-&gt;name_in_code);
+      if (!dim_ptr-&gt;namelist_defined) fortprintf(fd, &quot;                            %sGlobal&quot;, dim_ptr-&gt;name_in_code);
+      else fortprintf(fd, &quot;                            %sGlobal&quot;, dim_ptr-&gt;name_in_file);
       dim_ptr = dim_ptr-&gt;next;
    }
    while (dim_ptr) {
-      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;, %sGlobal&quot;, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; !dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;, %sGlobal&quot;, dim_ptr-&gt;name_in_code);
+      if (dim_ptr-&gt;constant_value &lt; 0 &amp;&amp; dim_ptr-&gt;namelist_defined &amp;&amp; !is_derived_dim(dim_ptr-&gt;name_in_code)) fortprintf(fd, &quot;, %sGlobal&quot;, dim_ptr-&gt;name_in_file);
       dim_ptr = dim_ptr-&gt;next;
    }
    fortprintf(fd, &quot; &amp;</font>
<font color="gray">&quot;);
@@ -1393,7 +1440,8 @@
                if (i &lt; var_ptr-&gt;ndims) {
                   fortprintf(fd, &quot;      %s%id %% ioinfo %% start(%i) = 1</font>
<font color="red">&quot;, vtype, var_ptr-&gt;ndims, i);
                   if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-                     fortprintf(fd, &quot;      %s%id %% ioinfo %% count(%i) = domain %% blocklist %% mesh %% %s</font>
<font color="blue">&quot;, vtype, var_ptr-&gt;ndims, i, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                     if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;      %s%id %% ioinfo %% count(%i) = domain %% blocklist %% mesh %% %s</font>
<font color="blue">&quot;, vtype, var_ptr-&gt;ndims, i, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                     else fortprintf(fd, &quot;      %s%id %% ioinfo %% count(%i) = domain %% blocklist %% mesh %% %s</font>
<font color="black">&quot;, vtype, var_ptr-&gt;ndims, i, dimlist_ptr-&gt;dim-&gt;name_in_file);
                   else
                      fortprintf(fd, &quot;      %s%id %% ioinfo %% count(%i) = %s</font>
<font color="gray">&quot;, vtype, var_ptr-&gt;ndims, i, dimlist_ptr-&gt;dim-&gt;name_in_code);
                }
@@ -1418,7 +1466,8 @@
    
          if (i &lt; var_ptr-&gt;ndims)
             if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-               fortprintf(fd, &quot;domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+               if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+               else fortprintf(fd, &quot;domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
             else
                fortprintf(fd, &quot;%s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
          else {
@@ -1437,7 +1486,8 @@
          while (dimlist_ptr) {
             if (i &lt; var_ptr-&gt;ndims)
                if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-                  fortprintf(fd, &quot;, domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;, domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  else fortprintf(fd, &quot;, domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
                else
                   fortprintf(fd, &quot;, %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
             else {
@@ -1463,7 +1513,8 @@
                dimlist_ptr = var_ptr-&gt;dimlist;
                while (dimlist_ptr) {
                   if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-                     fortprintf(fd, &quot;domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                     if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                     else fortprintf(fd, &quot;domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
                   else
                      fortprintf(fd, &quot;%s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
    
@@ -1480,7 +1531,8 @@
             dimlist_ptr = var_ptr-&gt;dimlist;
             while (i &lt;= var_ptr-&gt;ndims) {
                if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-                  fortprintf(fd, &quot;      do i%i=1,domain %% blocklist %% mesh %% %s</font>
<font color="blue">&quot;, i, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;      do i%i=1,domain %% blocklist %% mesh %% %s</font>
<font color="blue">&quot;, i, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  else fortprintf(fd, &quot;      do i%i=1,domain %% blocklist %% mesh %% %s</font>
<font color="black">&quot;, i, dimlist_ptr-&gt;dim-&gt;name_in_file);
                else
                   fortprintf(fd, &quot;      do i%i=1,%s</font>
<font color="gray">&quot;, i, dimlist_ptr-&gt;dim-&gt;name_in_code);
 
@@ -1525,7 +1577,8 @@
          dimlist_ptr = var_ptr-&gt;dimlist;
          
          if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-            fortprintf(fd, &quot;                                domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+            if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;                                domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+            else fortprintf(fd, &quot;                                domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
          else
             fortprintf(fd, &quot;                                %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
     
@@ -1533,7 +1586,8 @@
          i++;
          while (dimlist_ptr) {
             if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0)
-               fortprintf(fd, &quot;, domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+               if (!dimlist_ptr-&gt;dim-&gt;namelist_defined) fortprintf(fd, &quot;, domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+               else fortprintf(fd, &quot;, domain %% blocklist %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_file);
             else
                fortprintf(fd, &quot;, %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
    

Modified: trunk/mpas/src/registry/parse.c
===================================================================
--- trunk/mpas/src/registry/parse.c        2010-05-27 19:41:43 UTC (rev 315)
+++ trunk/mpas/src/registry/parse.c        2010-05-27 21:40:42 UTC (rev 316)
@@ -49,6 +49,7 @@
 {
    char word[1024];
    struct namelist * nls_ptr;
+   struct namelist * nls_chk_ptr;
    struct dimension * dim_ptr;
    struct variable * var_ptr;
    struct dimension_list * dimlist_ptr;
@@ -96,9 +97,31 @@
       else if (strncmp(word, &quot;dim&quot;, 1024) == 0) {
          NEW_DIMENSION(dim_ptr-&gt;next)
          dim_ptr = dim_ptr-&gt;next;
+         dim_ptr-&gt;namelist_defined = 0;
          getword(regfile, dim_ptr-&gt;name_in_file); 
          getword(regfile, dim_ptr-&gt;name_in_code); 
          dim_ptr-&gt;constant_value = is_integer_constant(dim_ptr-&gt;name_in_code);
+         if (strncmp(dim_ptr-&gt;name_in_code, &quot;namelist:&quot;, 9) == 0) {
+            dim_ptr-&gt;namelist_defined = 1;
+            sprintf(dim_ptr-&gt;name_in_code, &quot;%s&quot;, (dim_ptr-&gt;name_in_code)+9);
+            
+            /* Check that the referenced namelist variable is defined as an integer variable */
+            nls_chk_ptr = (*nls)-&gt;next;
+            while (nls_chk_ptr) {
+               if (strncmp(nls_chk_ptr-&gt;name, dim_ptr-&gt;name_in_code, 1024) == 0) {
+                  if (nls_chk_ptr-&gt;vtype != INTEGER) {
+                     printf(&quot;</font>
<font color="black">Registry error: Namelist variable %s must be an integer for namelist-derived dimension %s</font>
<font color="black"></font>
<font color="blue">&quot;, nls_chk_ptr-&gt;name, dim_ptr-&gt;name_in_file);
+                     return 1;
+                  }
+                  break;
+               } 
+               nls_chk_ptr = nls_chk_ptr-&gt;next;
+            }
+            if (!nls_chk_ptr) {
+               printf(&quot;</font>
<font color="black">Registry error: Namelist variable %s not defined for namelist-derived dimension %s</font>
<font color="black"></font>
<font color="gray">&quot;, dim_ptr-&gt;name_in_code, dim_ptr-&gt;name_in_file);
+               return 1;
+            }
+         }
       }
       else if (strncmp(word, &quot;var&quot;, 1024) == 0) {
          NEW_VARIABLE(var_ptr-&gt;next)

Modified: trunk/mpas/src/registry/registry_types.h
===================================================================
--- trunk/mpas/src/registry/registry_types.h        2010-05-27 19:41:43 UTC (rev 315)
+++ trunk/mpas/src/registry/registry_types.h        2010-05-27 21:40:42 UTC (rev 316)
@@ -31,6 +31,7 @@
    char name_in_file[1024];
    char name_in_code[1024];
    int constant_value;
+   int namelist_defined;
    struct dimension * next;
 };
 

</font>
</pre>