コード例 #1
0
ファイル: Fault.cpp プロジェクト: m-ahsan-nazer/SeisSol
void seissol::checkpoint::sionlib::Fault::load(int &timestepFault) {
#ifdef USE_SIONLIB
  if (numSides() == 0)
    return;  
  seissol::checkpoint::CheckPoint::load();
  int file; FILE *file_ptr; char fname[1023], *newfname=NULL;
  int globalrank,numFiles;  unsigned long lidentifier;  
  sion_int32 fsblksize= utils::Env::get<sion_int32>("SEISSOL_CHECKPOINT_BLOCK_SIZE", 0);
  m_gComm = comm(); m_lComm = m_gComm;	
  globalrank  = rank(); numFiles = 0;
  file = sion_paropen_mpi(const_cast<char*>(linkFile().c_str()), "br", &numFiles, m_gComm, &m_lComm,
			  &m_chunksize, &fsblksize, &globalrank, &file_ptr, &newfname);
  checkErr(file);
  checkErr(sion_fread(&lidentifier, sizeof(unsigned long),1,file));
  checkErr(sion_fread(&timestepFault, sizeof(timestepFault),1,file));
  for (int i = 0; i < NUM_VARIABLES; i++)
    checkErr(sion_fread(data(i),sizeof(real),this->numSides()*this->numBndGP(),file));
  if (ferror (file_ptr))
    logWarning(rank())<<"Error reading fault data SIONlib-checkpoint\n";
  checkErr(sion_parclose_mpi(file));
#endif
}
コード例 #2
0
int main(int argc, char *argv[])
{
	/* SION parameters */
	int sid, numFiles, globalrank, my_rank, num_procs;
	MPI_Comm lComm;
	sion_int64 chunksize, left, bwrote;
	sion_int32 fsblksize;
	char fname[256], *newfname=NULL;
	FILE *fileptr;
	/* initialize MPI */
	MPI_Init(&argc, &argv);
	MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
	MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
	/* open parameters */
	chunksize = 10; globalrank = my_rank;
	strcpy(fname, "parfile.sion");
	numFiles = 1; fsblksize = -1;
	
	/* create a new file */
	sid = sion_paropen_mpi(fname, "bw", &numFiles,
	MPI_COMM_WORLD, &lComm,
	&chunksize, &fsblksize,
	&globalrank,
	&fileptr, &newfname);
	/* write buffer to file */
	left=chunksize;
	char* p = (char *) fname;
	while (left > 0) {
		sion_ensure_free_space(sid, left);
		bwrote = fwrite(p, 1, left, fileptr);
		left -= bwrote; p += bwrote;
	}
	/* close file */
	sion_parclose_mpi(sid);
	/* finalize MPI */
	MPI_Finalize();
}