@@ -99,6 +99,7 @@ void ParamFileReader::file_read(boost::filesystem::path filename, FILE *segfp)
9999/* ********************************************************/
100100
101101void ParamFileReader::sample_distribution_values ( char *buf ) {
102+ bool sampled = false ;
102103 while ( char *beg = strstr ( buf, " N(" ) ) {
103104 double mean = NAN , std = NAN ;
104105 if ( sscanf ( beg, " N(%lf,%lf)" , &mean, &std ) != 2 )
@@ -109,6 +110,7 @@ void ParamFileReader::sample_distribution_values( char *buf ) {
109110 s.replace ( beg-buf, strchr ( beg, ' )' ) - beg + 1 ,
110111 boost::lexical_cast<std::string>( nd ( *getRandGen () ) ) );
111112 strcpy ( buf, s.c_str () );
113+ sampled = true ;
112114 }
113115
114116 while ( char *beg = strstr ( buf, " U(" ) ) {
@@ -122,6 +124,7 @@ void ParamFileReader::sample_distribution_values( char *buf ) {
122124 s.replace ( beg-buf, strchr ( beg, ' )' ) - beg + 1 ,
123125 boost::lexical_cast<std::string>( ud ( *getRandGen () ) ) );
124126 strcpy ( buf, s.c_str () );
127+ sampled = true ;
125128 }
126129
127130 while ( char *beg = strstr ( buf, " T(" ) ) {
@@ -135,6 +138,7 @@ void ParamFileReader::sample_distribution_values( char *buf ) {
135138 s.replace ( beg-buf, strchr ( beg, ' )' ) - beg + 1 ,
136139 boost::lexical_cast<std::string>( td ( *getRandGen () ) ) );
137140 strcpy ( buf, s.c_str () );
141+ sampled = true ;
138142 }
139143
140144 while ( char *beg = strstr ( buf, " E(" ) ) {
@@ -147,6 +151,11 @@ void ParamFileReader::sample_distribution_values( char *buf ) {
147151 s.replace ( beg-buf, strchr ( beg, ' )' ) - beg + 1 ,
148152 boost::lexical_cast<std::string>( ed ( *getRandGen () ) ) );
149153 strcpy ( buf, s.c_str () );
154+ sampled = true ;
155+ }
156+ if (sampled && getenv (" COSI_SAVE_SAMPLED" )) {
157+ std::ofstream f (getenv (" COSI_SAVE_SAMPLED" ), std::ofstream::app);
158+ f << buf;
150159 }
151160
152161}
0 commit comments