63 string main_input =
save.chRedirectPrefix +
".in";
64 string main_output =
save.chRedirectPrefix +
".out";
68 for(
int j=0; j <
grid.totNumModels; ++j )
71 string in_name = Base +
".in";
72 remove( in_name.c_str() );
73 string out_name = Base +
".out";
74 append_file( main_output_handle, out_name.c_str() );
75 remove( out_name.c_str() );
77 fclose( main_output_handle );
79 fstream main_input_handle;
85 while( getline( main_input_handle, line ) )
89 string::const_iterator p = line.begin();
90 while( p != line.end() )
91 caps_line.push_back(
toupper(*p++) );
92 if( caps_line.compare( 0, 4,
"SAVE" ) == 0 || caps_line.compare( 0, 4,
"PUNC" ) == 0 )
95 string fnam =
save.chFilenamePrefix;
96 string::size_type p = line.find(
'"' );
97 fnam += line.substr( ++p );
98 fnam.erase( fnam.find(
'"' ) );
100 for(
int j=0; j <
grid.totNumModels; ++j )
106 if(
save.lgSaveToSeparateFiles[ipPun] )
117 rename( fnam.c_str(), gridnam.c_str() );
122 for(
int j=0; j <
grid.totNumModels; ++j )
126 remove( gridnam.c_str() );
129 if( caps_line.find(
"XSPE", 4 ) != string::npos )
135 fseek( dest, 0, SEEK_END );
136 ASSERT( ftell(dest)%2880 == 0 );
145 fprintf(
ioQQQ,
"PROBLEM - could not open file %s\n", fnam.c_str() );
153 fprintf(
ioQQQ,
"PROBLEM - an internal error occurred while post-processing the grid output\n" );
163 if(
save.lgFITS[ipPun] )
166 bool lgForceNoDelimiter =
false;
168 if( !
save.lgHashEndIter[ipPun] || !
save.lg_separate_iterations[ipPun] ||
169 dynamics.lgTimeDependentStatic || strcmp(
save.chHashString ,
"TIME_DEP" ) == 0 )
170 lgForceNoDelimiter =
true;
172 bool lgAppendDelimiter =
true;
173 bool lgAppendNewline =
false;
179 str.seekg( 0, ios_base::end );
180 if( str.good() && str.tellg() > 0 )
183 str.seekg( -1, ios_base::cur );
186 lgAppendNewline = ( chr !=
'\n' );
189 str.seekg( 0, ios_base::beg );
190 while( getline( str, line ) )
192 if( line.find(
"GRID_DELIMIT" ) != string::npos )
193 lgAppendDelimiter =
false;
198 if( lgForceNoDelimiter )
199 lgAppendDelimiter =
false;
200 if( lgAppendNewline || lgAppendDelimiter )
205 if( lgAppendNewline )
207 if( lgAppendDelimiter )
209 str <<
save.chHashString <<
" GRID_DELIMIT -- grid";
210 str << setfill(
'0' ) << setw(9) << j << endl;