<p><b>dwj07@fsu.edu</b> 2013-04-12 20:16:57 -0600 (Fri, 12 Apr 2013)</p><p><br>
        -- TRUNK COMMIT --<br>
<br>
        Merging histroy_attribute branch onto trunk.<br>
<br>
        Trunk now has provanence information in all output files.<br>
        This includes:<br>
        history attribute<br>
        model_name attribute<br>
        core_name attribute<br>
        model_version attribute<br>
<br>
        The model_name, core_name, and model_version are definable in each core's Registry.xml<br>
</p><hr noshade><pre><font color="gray">Index: trunk/mpas
===================================================================
--- trunk/mpas        2013-04-13 02:12:15 UTC (rev 2745)
+++ trunk/mpas        2013-04-13 02:16:57 UTC (rev 2746)

Property changes on: trunk/mpas
___________________________________________________________________
Modified: svn:mergeinfo
## -1,5 +1,6 ##
 /branches/atmos_physics:1672-1846
 /branches/cam_mpas_nh:1260-1270
+/branches/history_attribute:2698-2745
 /branches/ocean_projects/ale_split_exp:1437-1483
 /branches/ocean_projects/ale_vert_coord:1225-1383
 /branches/ocean_projects/ale_vert_coord_new:1387-1428
\ No newline at end of property
Modified: trunk/mpas/src/core_hyd_atmos/Registry.xml
===================================================================
--- trunk/mpas/src/core_hyd_atmos/Registry.xml        2013-04-13 02:12:15 UTC (rev 2745)
+++ trunk/mpas/src/core_hyd_atmos/Registry.xml        2013-04-13 02:16:57 UTC (rev 2746)
@@ -1,5 +1,5 @@
 &lt;?xml version=&quot;1.0&quot;?&gt;
-&lt;registry&gt;
+&lt;registry model=&quot;mpas&quot; core=&quot;hyd_atmos&quot; version=&quot;0.0.0&quot;&gt;
         &lt;dims&gt;
                 &lt;dim name=&quot;nCells&quot;/&gt;
                 &lt;dim name=&quot;nEdges&quot;/&gt;

Modified: trunk/mpas/src/core_init_nhyd_atmos/Registry.xml
===================================================================
--- trunk/mpas/src/core_init_nhyd_atmos/Registry.xml        2013-04-13 02:12:15 UTC (rev 2745)
+++ trunk/mpas/src/core_init_nhyd_atmos/Registry.xml        2013-04-13 02:16:57 UTC (rev 2746)
@@ -1,5 +1,5 @@
 &lt;?xml version=&quot;1.0&quot;?&gt;
-&lt;registry&gt;
+&lt;registry model=&quot;mpas&quot; core=&quot;init_nhyd_atmos&quot; version=&quot;0.0.0&quot;&gt;
 
 &lt;!-- **************************************************************************************** --&gt;
 &lt;!-- ************************************** Dimensions ************************************** --&gt;

Modified: trunk/mpas/src/core_nhyd_atmos/Registry.xml
===================================================================
--- trunk/mpas/src/core_nhyd_atmos/Registry.xml        2013-04-13 02:12:15 UTC (rev 2745)
+++ trunk/mpas/src/core_nhyd_atmos/Registry.xml        2013-04-13 02:16:57 UTC (rev 2746)
@@ -1,5 +1,5 @@
 &lt;?xml version=&quot;1.0&quot;?&gt;
-&lt;registry&gt;
+&lt;registry model=&quot;mpas&quot; core=&quot;nhyd_atmos&quot; version=&quot;0.0.0&quot;&gt;
 
 &lt;!-- **************************************************************************************** --&gt;
 &lt;!-- ************************************** Dimensions ************************************** --&gt;

Index: trunk/mpas/src/core_ocean
===================================================================
--- trunk/mpas/src/core_ocean        2013-04-13 02:12:15 UTC (rev 2745)
+++ trunk/mpas/src/core_ocean        2013-04-13 02:16:57 UTC (rev 2746)

Property changes on: trunk/mpas/src/core_ocean
___________________________________________________________________
Modified: svn:mergeinfo
## -1,5 +1,6 ##
 /branches/atmos_physics/src/core_ocean:1672-1846
 /branches/cam_mpas_nh/src/core_ocean:1260-1270
+/branches/history_attribute/src/core_ocean:2698-2745
 /branches/ocean_projects/ale_split_exp/src/core_ocean:1437-1483
 /branches/ocean_projects/ale_vert_coord/src/core_ocean:1225-1383
 /branches/ocean_projects/ale_vert_coord_new/src/core_ocean:1387-1428
\ No newline at end of property
Modified: trunk/mpas/src/core_ocean/Registry.xml
===================================================================
--- trunk/mpas/src/core_ocean/Registry.xml        2013-04-13 02:12:15 UTC (rev 2745)
+++ trunk/mpas/src/core_ocean/Registry.xml        2013-04-13 02:16:57 UTC (rev 2746)
@@ -1,5 +1,5 @@
 &lt;?xml version=&quot;1.0&quot;?&gt;
-&lt;registry&gt;
+&lt;registry model=&quot;mpas&quot; core=&quot;ocean&quot; version=&quot;0.0.0&quot;&gt;
         &lt;dims&gt;
                 &lt;dim name=&quot;nCells&quot; units=&quot;unitless&quot;
                      description=&quot;The number of polygons in the primary grid.&quot;

Modified: trunk/mpas/src/core_sw/Registry.xml
===================================================================
--- trunk/mpas/src/core_sw/Registry.xml        2013-04-13 02:12:15 UTC (rev 2745)
+++ trunk/mpas/src/core_sw/Registry.xml        2013-04-13 02:16:57 UTC (rev 2746)
@@ -1,5 +1,5 @@
 &lt;?xml version=&quot;1.0&quot;?&gt;
-&lt;registry&gt;
+&lt;registry model=&quot;mpas&quot; core=&quot;sw&quot; version=&quot;0.0.0&quot;&gt;
         &lt;dims&gt;
                 &lt;dim name=&quot;nCells&quot;/&gt;
                 &lt;dim name=&quot;nEdges&quot;/&gt;

Modified: trunk/mpas/src/framework/mpas_grid_types.F
===================================================================
--- trunk/mpas/src/framework/mpas_grid_types.F        2013-04-13 02:12:15 UTC (rev 2745)
+++ trunk/mpas/src/framework/mpas_grid_types.F        2013-04-13 02:16:57 UTC (rev 2746)
@@ -441,6 +441,8 @@
    
       ! Also store parallelization info here
       type (dm_info), pointer :: dminfo
+#include &quot;model_variables.inc&quot;
+      character (len=StrKIND*2) :: history !&lt; History attribute, read in from input file.
    end type domain_type
 
    interface mpas_allocate_scratch_field

Modified: trunk/mpas/src/framework/mpas_io_input.F
===================================================================
--- trunk/mpas/src/framework/mpas_io_input.F        2013-04-13 02:12:15 UTC (rev 2745)
+++ trunk/mpas/src/framework/mpas_io_input.F        2013-04-13 02:16:57 UTC (rev 2746)
@@ -245,6 +245,22 @@
         end if
       end if
 
+      call MPAS_readStreamAtt(input_obj % io_stream, 'history', domain % history, ierr)
+      if (ierr /= MPAS_STREAM_NOERR) then
+        write(0,*) 'Warning: Attribute History not found in '//trim(input_obj % filename)
+        write(0,*) '   Setting History to '''''
+        domain % history = &quot;&quot;
+      else
+        ! Remove C String NULL characters, replace C String newlines with semicolons
+        do i = 1, len(domain % history)
+          if(iachar(domain % history(i:i)) == 0) then
+            domain % history(i:i) = &quot; &quot;
+          else if(iachar(domain % history(i:i)) == 10) then
+            domain % history(i:i) = &quot;;&quot;
+          end if
+        end do
+      end if
+
       block_ptr =&gt; domain % blocklist % next
       do while (associated(block_ptr))
         block_ptr % mesh % sphere_radius = domain % blocklist % mesh % sphere_radius

Modified: trunk/mpas/src/framework/mpas_io_output.F
===================================================================
--- trunk/mpas/src/framework/mpas_io_output.F        2013-04-13 02:12:15 UTC (rev 2745)
+++ trunk/mpas/src/framework/mpas_io_output.F        2013-04-13 02:16:57 UTC (rev 2746)
@@ -343,6 +343,13 @@
  
       integer :: nferr, ierr
       integer, dimension(10) :: dimlist
+      character (len=StrKIND*4) :: runCmd
+
+      if(len(trim(domain % history)) &gt; 0) then
+          write(runCmd,'(a,a,i0,a,a,a)') trim(domain % history),' mpirun -n ',domain % dminfo % nProcs, ' ', trim(domain % coreName), '_model.exe; '
+      else
+          write(runCmd,'(a,i0,a,a,a)') 'mpirun -n ',domain % dminfo % nProcs, ' ', trim(domain % coreName), '_model.exe; '
+      end if
  
       call MPAS_createStream(output_obj % io_stream, trim(output_obj % filename), MPAS_IO_PNETCDF, MPAS_IO_WRITE, 1, nferr)
 
@@ -354,6 +361,10 @@
          call MPAS_writeStreamAtt(output_obj % io_stream, 'on_a_sphere', 'NO              ', nferr)
       end if
       call MPAS_writeStreamAtt(output_obj % io_stream, 'sphere_radius', mesh % sphere_radius, nferr)
+      call MPAS_writeStreamAtt(output_obj % io_stream, 'model_name', domain % modelName, nferr)
+      call MPAS_writeStreamAtt(output_obj % io_stream, 'core_name', domain % coreName, nferr)
+      call MPAS_writeStreamAtt(output_obj % io_stream, 'model_version', domain % modelVersion, nferr)
+      call MPAS_writeStreamAtt(output_obj % io_stream, 'history', runCmd, nferr)
 
 #include &quot;add_output_atts.inc&quot;
  

Modified: trunk/mpas/src/registry/Registry.xsd
===================================================================
--- trunk/mpas/src/registry/Registry.xsd        2013-04-13 02:12:15 UTC (rev 2745)
+++ trunk/mpas/src/registry/Registry.xsd        2013-04-13 02:16:57 UTC (rev 2746)
@@ -114,6 +114,12 @@
                                         &lt;/xs:complexType&gt;
                                 &lt;/xs:element&gt;
                         &lt;/xs:sequence&gt;
+                        &lt;!-- The model attribute defines the name of the model that is being run. Typically this will be MPAS. It will be written to all output files as a global attribute. --&gt;
+                        &lt;xs:attribute name=&quot;model&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                        &lt;!-- The core attribute defines the core a Registry.xml file belongs to. It will be written to all output files as a global attribute. --&gt;
+                        &lt;xs:attribute name=&quot;core&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
+                        &lt;!-- The version attribute defines the version of the model/core combination. It will be written to all output files as a global attribute. --&gt;
+                        &lt;xs:attribute name=&quot;version&quot; type=&quot;xs:string&quot; use=&quot;required&quot;/&gt;
                 &lt;/xs:complexType&gt;
         &lt;/xs:element&gt;
 &lt;/xs:schema&gt;

Modified: trunk/mpas/src/registry/gen_inc.c
===================================================================
--- trunk/mpas/src/registry/gen_inc.c        2013-04-13 02:12:15 UTC (rev 2745)
+++ trunk/mpas/src/registry/gen_inc.c        2013-04-13 02:16:57 UTC (rev 2746)
@@ -169,7 +169,18 @@
    fclose(fd);
 }
 
+void gen_history_attributes(char * modelname, char * corename, char * version)
+{
+        FILE *fd;
 
+        fd = fopen(&quot;model_variables.inc&quot;,&quot;w&quot;);
+        fortprintf(fd, &quot;       character (len=StrKIND) :: modelName = '%s' !&lt; Constant: Name of model</font>
<font color="blue">&quot;, modelname);
+        fortprintf(fd, &quot;       character (len=StrKIND) :: coreName = '%s' !&lt; Constant: Name of core</font>
<font color="blue">&quot;, corename);
+        fortprintf(fd, &quot;       character (len=StrKIND) :: modelVersion = '%s' !&lt; Constant: Version number</font>
<font color="gray">&quot;, version);
+        fclose(fd);
+}
+
+
 void gen_field_defs(struct group_list * groups, struct variable * vars, struct dimension * dims)
 {
    struct variable * var_ptr;

Modified: trunk/mpas/src/registry/gen_inc.h
===================================================================
--- trunk/mpas/src/registry/gen_inc.h        2013-04-13 02:12:15 UTC (rev 2745)
+++ trunk/mpas/src/registry/gen_inc.h        2013-04-13 02:16:57 UTC (rev 2746)
@@ -1,4 +1,5 @@
 void gen_namelists(struct namelist *);
+void gen_history_attributes(char * modelname, char * corename, char * version);
 void gen_field_defs(struct group_list * groups, struct variable *, struct dimension *);
 void gen_reads(struct group_list * groups, struct variable *, struct dimension *);
 void gen_writes(struct group_list * groups, struct variable *, struct dimension *, struct namelist *);

Modified: trunk/mpas/src/registry/parse.c
===================================================================
--- trunk/mpas/src/registry/parse.c        2013-04-13 02:12:15 UTC (rev 2745)
+++ trunk/mpas/src/registry/parse.c        2013-04-13 02:16:57 UTC (rev 2746)
@@ -19,6 +19,8 @@
    struct variable * vars;
    struct group_list * groups;
 
+   char modelname[1024], corename[1024], version[1024];
+
    if (argc != 2) {
       fprintf(stderr,&quot;Reading registry file from standard input</font>
<font color="gray">&quot;);
       regfile = stdin;
@@ -32,7 +34,7 @@
    dims = NULL;
    vars = NULL;
   
-   if (parse_reg_xml(regfile, &amp;nls, &amp;dims, &amp;vars, &amp;groups)) {
+   if (parse_reg_xml(regfile, &amp;nls, &amp;dims, &amp;vars, &amp;groups, &amp;modelname, &amp;corename, &amp;version)) {
       return 1;
    }
   
@@ -45,6 +47,7 @@
    sort_vars(vars);
    sort_group_vars(groups);
 
+   gen_history_attributes(modelname, corename, version);
    gen_namelists(nls);
    gen_field_defs(groups, vars, dims);
    gen_reads(groups, vars, dims);
@@ -53,7 +56,7 @@
    return 0;
 }
 
-int parse_reg_xml(FILE * regfile, struct namelist **nls, struct dimension ** dims, struct variable ** vars, struct group_list ** groups)
+int parse_reg_xml(FILE * regfile, struct namelist **nls, struct dimension ** dims, struct variable ** vars, struct group_list ** groups, char * modelname, char * corename, char * version)
 {
         struct namelist * nls_ptr, *nls_ptr2;
         struct namelist * nls_chk_ptr;
@@ -75,6 +78,7 @@
         const char *vararrname, *vararrtype, *vararrdims, *vararrpersistence;
         const char *varname, *varpersistence, *vartype, *vardims, *varunits, *vardesc, *vararrgroup, *varstreams;
         const char *varname_in_code;
+        const char *const_model, *const_core, *const_version;
 
         char dimensions[2048];
         char *dimension_list;
@@ -90,6 +94,26 @@
         *vars = var_ptr;
         *groups = grouplist_ptr;
 
+        // Get model information
+        const_model = ezxml_attr(registry, &quot;model&quot;);
+        const_core = ezxml_attr(registry, &quot;core&quot;);
+        const_version = ezxml_attr(registry, &quot;version&quot;);
+
+        if(const_model == NULL)
+                sprintf(modelname, &quot;MISSING&quot;);
+        else
+                sprintf(modelname, &quot;%s&quot;, const_model);
+
+        if(const_core == NULL)
+                sprintf(corename, &quot;MISSING&quot;);
+        else
+                sprintf(corename, &quot;%s&quot;, const_core);
+
+        if(const_version == NULL)
+                sprintf(version, &quot;MISSING&quot;);
+        else
+                sprintf(version, &quot;%s&quot;, const_version);
+
         // Parse Namelist Records
         for (nmlrecs_xml = ezxml_child(registry, &quot;nml_record&quot;); nmlrecs_xml; nmlrecs_xml = nmlrecs_xml-&gt;next){
                 nmlrecname = ezxml_attr(nmlrecs_xml, &quot;name&quot;);

</font>
</pre>