Skip to content

Commit 817a399

Browse files
committed
keep previous SCR code in getDt
1 parent 7beb75c commit 817a399

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/CheckPoint.C

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,45 @@ float_sw4 CheckPoint::getDt() {
650650
}
651651
MPI_Bcast(&dt, 1, mEW->m_mpifloat, 0, mEW->m_cartesian_communicator);
652652
return dt;
653+
654+
#if 0
655+
int have_restart = 0;
656+
char checkpoint_dir[SCR_MAX_FILENAME];
657+
SCR_Have_restart(&have_restart, checkpoint_dir);
658+
if (! have_restart) {
659+
std::cerr<<"Error :: SCR found no checkpoints ! \n"<<std::flush;
660+
abort();
661+
}
662+
663+
SCR_Start_restart(checkpoint_dir);
664+
665+
std::stringstream s;
666+
s<<checkpoint_dir<<"/CheckPoint_"<<mEW->getRank()<<".bin";
667+
char scr_file[SCR_MAX_FILENAME];
668+
SCR_Route_file(s.str().c_str(), scr_file);
669+
int valid=1;
670+
if (std::FILE *file=std::fopen(scr_file,"rb")){
671+
float_sw4 dt;
672+
if ( std::fread(&dt,sizeof dt,1,file)==1) {
673+
scr_file_handle=file;
674+
return dt;
675+
} else {
676+
std::cerr<<"ERROR:: Read of SCR checkpoint file failed in getDt \n"<<std::flush;
677+
std::fclose(file);
678+
valid = 0;
679+
}
680+
} else {
681+
std::cerr<<"ERROR::Restart file opening failed in getDt "<<s.str()<<"\n"<<std::flush;
682+
valid = 0;
683+
}
684+
685+
if (!valid){
686+
std::cerr<<"ERROR :: Invalid restart file "<<s.str()<<"\n Aborting..\n"<<std::flush;
687+
abort();
688+
}
689+
690+
return -1.0e99; // Dummy return to suppress warnings. Should never be reached
691+
#endif
653692
}
654693

655694
//-----------------------------------------------------------------------

0 commit comments

Comments
 (0)