Skip to content

Commit 09b1d49

Browse files
committed
added output_prefix for statprops
1 parent d27b139 commit 09b1d49

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

src/geoflow/stats.C

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
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
}
4850
StatProps::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
}
6164
StatProps::~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

src/header/stats.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ class StatProps: public EleNodeRef
113113
//! the latin hypercube sampling specific stats
114114
LHS_Props lhs;
115115

116+
std::string output_prefix;
117+
116118
//! the constructor initializes a few statistics
117119
StatProps(ElementsHashTable *_ElemTable, NodeHashTable* _NodeTable);
118120
//! the constructor from hd5

src/main/titan.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,12 @@ def __init__(self,overwrite_output=False):
576576
},
577577
'runid':{'desc':'',
578578
'validator':VarType(int).chk
579-
},
579+
},
580+
'output_prefix':{'desc':'',
581+
'validator':VarTypeString
582+
},
580583
},
581-
defaultParameters={'edge_height':None, 'test_height':None, 'test_location':None, 'runid':-1}
584+
defaultParameters={'edge_height':None, 'test_height':None, 'test_location':None, 'runid':-1, 'output_prefix':''}
582585
)
583586
self.setStatProps()
584587
#setOutlineProps
@@ -1046,6 +1049,7 @@ def check_and_remove_filedir_by_wildcard(filename):
10461049
ui_StatProps['edge_height'], ui_StatProps['test_height'],
10471050
ui_StatProps['test_location'][0], ui_StatProps['test_location'][1])
10481051
self.sim.get_statprops().runid=ui_StatProps['runid']
1052+
self.sim.get_statprops().output_prefix=ui_StatProps['output_prefix']
10491053

10501054
#######################################################################
10511055
# ui_OutlineProps

src/tecplot/outsum.C

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@
2222
#include "../header/hpfem.h"
2323
#include "../header/stats.hpp"
2424

25+
#include <sstream>
2526
#define ADAM_HEIGHT_FRAC 0.02
2627

2728
void output_summary(TimeProps* timeprops, StatProps* statprops, int savefileflag)
2829
{
2930
//FILE *fp=fopen("output_summary.readme","a");
30-
char filename[256];
31-
sprintf(filename, "output_summary.%06d", statprops->runid);
32-
FILE *fp = fopen(filename, "a");
31+
ostringstream filename;
32+
33+
filename<<statprops->output_prefix<<"output_summary."<<setw(6)<< setfill('0') <<internal<<statprops->runid<<std::ends;
34+
FILE *fp = fopen(filename.str().c_str(), "at");
3335

3436
if(timeprops->ifstart())
3537
fprintf(fp, "Summary of Output from Titan2D\n\n");
@@ -50,9 +52,10 @@ void output_summary(TimeProps* timeprops, StatProps* statprops, int savefileflag
5052

5153
void output_stoch_stats(MatProps* matprops, StatProps* statprops)
5254
{
53-
char filename[128];
54-
sprintf(filename, "statout_lhs.%02d", statprops->lhs.refnum);
55-
FILE *fp = fopen(filename, "w");
55+
ostringstream filename;
56+
57+
filename<<statprops->output_prefix<<"statout_lhs."<<setw(6)<< setfill('0') <<internal<<statprops->runid<<std::ends;
58+
FILE *fp = fopen(filename.str().c_str(), "w");
5659
fprintf(fp, "%2d %6d %16.10g %16.10g %16.10g %16.10g %16.10g %16.10g %16.10g\n", statprops->lhs.refnum,
5760
statprops->lhs.runid, statprops->timereached, statprops->vstar * matprops->Vslump, statprops->hmax,
5861
statprops->xcen, statprops->ycen, statprops->xyminmax[1] - statprops->xyminmax[0],

0 commit comments

Comments
 (0)