2525
2626
2727#include <cmath>
28+ #include <sstream>
2829
2930//#include <advisor-annotate.h>
3031
@@ -44,6 +45,7 @@ StatProps::StatProps(ElementsHashTable *_ElemTable, NodeHashTable* _NodeTable):
4445 xyminmax [0 ] = xyminmax [1 ] = xyminmax [2 ] = xyminmax [3 ] = hxyminmax = 0.0 ;
4546 lhs .refnum = lhs .runid = -1 ;
4647 runid = -1 ;
48+ output_prefix = "" ;
4749}
4850StatProps ::StatProps (ElementsHashTable * _ElemTable , NodeHashTable * _NodeTable , const H5 ::CommonFG * parent , const string group_name ):
4951 EleNodeRef (_ElemTable , _NodeTable )
@@ -56,6 +58,7 @@ StatProps::StatProps(ElementsHashTable *_ElemTable, NodeHashTable* _NodeTable, c
5658 xyminmax [0 ] = xyminmax [1 ] = xyminmax [2 ] = xyminmax [3 ] = hxyminmax = 0.0 ;
5759 lhs .refnum = lhs .runid = -1 ;
5860 runid = -1 ;
61+ output_prefix = "" ;
5962 h5read (parent , group_name );
6063}
6164StatProps ::~StatProps ()
@@ -511,10 +514,11 @@ void out_final_stats(TimeProps* timeprops, StatProps* statprops)
511514 int cpuminutes = (cputime % 3600 ) / 60 ;
512515 int cpuseconds = cputime % 60 ;
513516
514- char filename [256 ];
515- sprintf (filename , "finalstats.%06d" , statprops -> runid );
517+ ostringstream filename ;
518+
519+ filename <<statprops -> output_prefix <<"finalstats." <<setw (6 )<< setfill ('0' ) <<internal <<statprops -> runid <<std ::ends ;
520+ FILE * fp = fopen (filename .str ().c_str (), "wt" );
516521//printf("runid=%d\n",statprops->runid);
517- FILE * fp = fopen (filename , "w" );
518522//print runid xC yC rC area maxh wall time cpu time
519523 fprintf (fp , "%6d %E %E %E %E %E %E %d:%02d:%02d %d:%02d:%02d\n" , statprops -> runid , statprops -> xcen ,
520524 statprops -> ycen , statprops -> rmean , statprops -> area , statprops -> hmax , statprops -> timereached , wallhours ,
@@ -631,6 +635,7 @@ void StatProps::h5write(H5::CommonFG *parent, string group_name) const
631635 TiH5_writeDoubleAttribute (group , timereached );
632636 TiH5_writeDoubleAttribute (group , xyminmax [4 ]);
633637 TiH5_writeDoubleAttribute (group , hxyminmax );
638+ TiH5_writeStringAttribute (group , output_prefix );
634639
635640 lhs .h5write (& group );
636641}
@@ -666,6 +671,7 @@ void StatProps::h5read(const H5::CommonFG *parent, const string group_name)
666671 TiH5_readDoubleAttribute (group , timereached );
667672 TiH5_readDoubleAttribute (group , xyminmax [4 ]);
668673 TiH5_readDoubleAttribute (group , hxyminmax );
674+ TiH5_readStringAttribute (group , output_prefix );
669675
670676 lhs .h5read (& group );
671677
0 commit comments