7 #if defined(__unix) || defined(__APPLE__) 
   14 #define fork() TotalInsanityAsStub<pid_t>() 
   15 #define wait(X) TotalInsanityAsStub<pid_t>() 
   22 static const long NFS_SUPER_MAGIC = 0x6969L;
 
   23 static const long SMB_SUPER_MAGIC = 0x517BL;
 
   24 static const long AUTOFS_SUPER_MAGIC = 0x0187L;
 
   26 static const long FUSE_SUPER_MAGIC = 0x65735546L;
 
   48         return TotalInsanityAsStub<int>();
 
   74                 for( 
unsigned int i=0; i < nJobs; ++i )
 
   81                         srand( 
unsigned( time(NULL) ) );
 
   89                 for( 
unsigned int i=1; i < 
p_ncpu; ++i )
 
  118                         for( 
unsigned int i=1; i < 
p_ncpu; ++i )
 
  145                 vector<long> bound( nCPU+1, stride );
 
  147                 for( 
long i=1; i <= remainder; ++i )
 
  150                 for( 
long i=1; i <= nCPU; ++i )
 
  151                         bound[i] += bound[i-1];
 
  162                         if( j >= bound[nRANK] && j < bound[nRANK+1] )
 
  165                                 remove( in_name.c_str() );
 
  169                 fstream main_input_handle;
 
  175                 while( getline( main_input_handle, line ) )
 
  179                         string::const_iterator p = line.begin();
 
  180                         while( p != line.end() )
 
  181                                 caps_line.push_back( 
toupper(*p++) );
 
  182                         if( caps_line.compare( 0, 4, 
"SAVE" ) == 0 || caps_line.compare( 0, 4, 
"PUNC" ) == 0 )
 
  186                                 string::size_type p = line.find( 
'"' );
 
  187                                 fnam += line.substr( ++p );
 
  188                                 fnam.erase( fnam.find( 
'"' ) );
 
  191                                         if( j >= bound[nRANK] && j < bound[nRANK+1] )
 
  199                                                 FILE *dest = 
open_data( fnam.c_str(), 
"ab" );
 
  208                                                 rename( fnam.c_str(), gridnam.c_str() );
 
  215                                 if( caps_line.find( 
"XSPE", 4 ) != string::npos )
 
  219                                                 FILE *dest = 
open_data( fnam.c_str(), 
"ab" );
 
  224                                                 fseek( dest, 0, SEEK_END );
 
  225                                                 ASSERT( ftell(dest)%2880 == 0 );
 
  235                 fprintf( 
ioQQQ, 
"PROBLEM - an internal error occurred while post-processing the grid output\n" );
 
  241                              const vector<long>& bound)
 
  255         FILE* output_handle = 
open_data( basenam.c_str(), 
"ab" );
 
  256         for( 
long j=0; j < nfiles; ++j )
 
  260                 remove( gridnam.c_str() );
 
  262         fclose( output_handle );
 
  267                                      const vector<long>& bound)
 
  272         for( 
long j=0; j < nfiles; ++j )
 
  278                         fseek( fh, 0, SEEK_END );
 
  279                         mySize += 
static_cast<MPI_Offset>( ftell(fh) );
 
  286         vector<MPI_Offset> offset(
cpu.
i().
nCPU());
 
  287         for( 
int i=0; i < 
cpu.
i().
nCPU(); ++i )
 
  292                 MPI_Bcast( &myCopy, 1, MPI_type(myCopy), i, MPI_COMM_WORLD );
 
  301         for( 
int j=0; j < 
cpu.
i().
nCPU(); ++j )
 
  304                 offset[j] = totalSize;
 
  310                                  MPI_CHAR, MPI_CHAR, 
const_cast<char*
>(
"native"),
 
  312         for( 
long j=0; j < nfiles; ++j )
 
  318                         remove( gridnam.c_str() );
 
  330         int res = statfs( fnam.c_str(), &buf );
 
  334         if( buf.f_type == NFS_SUPER_MAGIC ||
 
  335             buf.f_type == SMB_SUPER_MAGIC ||
 
  336             buf.f_type == AUTOFS_SUPER_MAGIC ||
 
  337             buf.f_type == FUSE_SUPER_MAGIC )
 
  359         bool lgForceNoDelimiter = 
false;
 
  363                 lgForceNoDelimiter = 
true;
 
  365         bool lgAppendDelimiter = 
true;
 
  366         bool lgAppendNewline = 
false;
 
  372                 str.seekg( 0, ios_base::end );
 
  373                 if( str.good() && str.tellg() > 0 )
 
  376                         str.seekg( -1, ios_base::cur );
 
  379                         lgAppendNewline = ( chr != 
'\n' );
 
  382                         str.seekg( 0, ios_base::beg );
 
  383                         while( getline( str, line ) )
 
  385                                 if( line.find( 
"GRID_DELIMIT" ) != string::npos )
 
  386                                         lgAppendDelimiter = 
false;
 
  391         if( lgForceNoDelimiter )
 
  392                 lgAppendDelimiter = 
false;
 
  393         if( lgAppendNewline || lgAppendDelimiter )
 
  398                         if( lgAppendNewline )
 
  400                         if( lgAppendDelimiter )
 
  403                                 str << setfill( 
'0' ) << setw(9) << j << endl;
 
  422         const size_t BUF_SIZE = 4096;
 
  427                 size_t nb = fread( buf, 
sizeof(
char), BUF_SIZE, src );
 
  428                 fwrite( buf, 
sizeof(
char), nb, dest );
 
  444         const size_t BUF_SIZE = 32768;
 
  449                 size_t nb = fread( buf, 
sizeof(
char), BUF_SIZE, src );
 
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
void finalize(exit_type exit_status)
STATIC void GridGatherOutput(const string &, long, const vector< long > &)
bool lgKeepMainOutputSeparate
bool lgTimeDependentStatic
STATIC void check_grid_file(const string &, int, int)
char chHashString[INPUT_LINE_LENGTH]
#define MPI_File_close(Z)
void init(unsigned int nJobs, unsigned int nCPU)
bool lg_separate_iterations[LIMPUN]
const ios_base::openmode mode_a
const ios_base::openmode mode_r
#define MPI_File_set_view(U, V, W, X, Y, Z)
STATIC void GridGatherOutputParallel(const string &, long, const vector< long > &)
STATIC bool lgIsRemote(const string &)
const int NUM_OUTPUT_TYPES
#define MPI_File_write(V, W, X, Y, Z)
int total_insanity(MPI_File, int, MPI_Status *)
#define MPI_File_get_size(Y, Z)
void append_file(FILE *dest, const char *source)
bool lgHashEndIter[LIMPUN]
#define DEBUG_ENTRY(funcname)
int fprintf(const Output &stream, const char *format,...)
void saveFITSfile(FILE *io, int option)
string GridPointPrefix(int n)
bool lgSaveToSeparateFiles[LIMPUN]
STATIC void GridGatherOutputSequential(const string &, long)
#define MPI_Bcast(V, W, X, Y, Z)