<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 @@
<?xml version="1.0"?>
-<registry>
+<registry model="mpas" core="hyd_atmos" version="0.0.0">
        <dims>
                <dim name="nCells"/>
                <dim name="nEdges"/>
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 @@
<?xml version="1.0"?>
-<registry>
+<registry model="mpas" core="init_nhyd_atmos" version="0.0.0">
<!-- **************************************************************************************** -->
<!-- ************************************** Dimensions ************************************** -->
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 @@
<?xml version="1.0"?>
-<registry>
+<registry model="mpas" core="nhyd_atmos" version="0.0.0">
<!-- **************************************************************************************** -->
<!-- ************************************** Dimensions ************************************** -->
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 @@
<?xml version="1.0"?>
-<registry>
+<registry model="mpas" core="ocean" version="0.0.0">
        <dims>
                <dim name="nCells" units="unitless"
                 description="The number of polygons in the primary grid."
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 @@
<?xml version="1.0"?>
-<registry>
+<registry model="mpas" core="sw" version="0.0.0">
        <dims>
                <dim name="nCells"/>
                <dim name="nEdges"/>
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 "model_variables.inc"
+ character (len=StrKIND*2) :: history !< 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 = ""
+ 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) = " "
+ else if(iachar(domain % history(i:i)) == 10) then
+ domain % history(i:i) = ";"
+ end if
+ end do
+ end if
+
block_ptr => 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)) > 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 "add_output_atts.inc"
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 @@
                                        </xs:complexType>
                                </xs:element>
                        </xs:sequence>
+                        <!-- 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. -->
+                        <xs:attribute name="model" type="xs:string" use="required"/>
+                        <!-- The core attribute defines the core a Registry.xml file belongs to. It will be written to all output files as a global attribute. -->
+                        <xs:attribute name="core" type="xs:string" use="required"/>
+                        <!-- The version attribute defines the version of the model/core combination. It will be written to all output files as a global attribute. -->
+                        <xs:attribute name="version" type="xs:string" use="required"/>
                </xs:complexType>
        </xs:element>
</xs:schema>
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("model_variables.inc","w");
+        fortprintf(fd, " character (len=StrKIND) :: modelName = '%s' !< Constant: Name of model</font>
<font color="blue">", modelname);
+        fortprintf(fd, " character (len=StrKIND) :: coreName = '%s' !< Constant: Name of core</font>
<font color="blue">", corename);
+        fortprintf(fd, " character (len=StrKIND) :: modelVersion = '%s' !< Constant: Version number</font>
<font color="gray">", 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,"Reading registry file from standard input</font>
<font color="gray">");
regfile = stdin;
@@ -32,7 +34,7 @@
dims = NULL;
vars = NULL;
- if (parse_reg_xml(regfile, &nls, &dims, &vars, &groups)) {
+ if (parse_reg_xml(regfile, &nls, &dims, &vars, &groups, &modelname, &corename, &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, "model");
+        const_core = ezxml_attr(registry, "core");
+        const_version = ezxml_attr(registry, "version");
+
+        if(const_model == NULL)
+                sprintf(modelname, "MISSING");
+        else
+                sprintf(modelname, "%s", const_model);
+
+        if(const_core == NULL)
+                sprintf(corename, "MISSING");
+        else
+                sprintf(corename, "%s", const_core);
+
+        if(const_version == NULL)
+                sprintf(version, "MISSING");
+        else
+                sprintf(version, "%s", const_version);
+
        // Parse Namelist Records
        for (nmlrecs_xml = ezxml_child(registry, "nml_record"); nmlrecs_xml; nmlrecs_xml = nmlrecs_xml->next){
                nmlrecname = ezxml_attr(nmlrecs_xml, "name");
</font>
</pre>