16 #include <utility/io/izstream.hh>
41 #if defined(WIN32) || defined(BOINC)
46 #include <numeric/random/random.hh>
50 #include <utility/vector1.hh>
51 #include <utility/io/ozstream.hh>
52 #include <utility/file/file_sys_util.hh>
53 #include <basic/options/option.hh>
64 #include <basic/Tracer.hh>
69 #include <basic/options/keys/run.OptionKeys.gen.hh>
79 namespace checkpoint {
81 basic::Tracer
TR(
"protocols::checkpoint");
90 utility::io::ozstream output( filename_ );
92 std::cout <<
"Cannot write checkpoint! open failed for file: " << filename_ << std::endl;
93 utility::exit( EXIT_FAILURE, __FILE__, __LINE__);
98 utility::io::ozstream output( filename_ );
107 using namespace io::silent;
112 pss->print_header( output );
113 pss->print_scores( output );
114 pss->print_conformation( output );
120 using namespace core::chemical;
126 if(!sfd.
read_file( filename ) )
return false;
128 if( iter->decoy_tag() != tag )
continue;
129 iter->fill_pose( tmppose, *residue_set );
132 tmppose.transfer_constraint_set( pose );
141 count_checkpoint_recoveries_( 0 )
143 using namespace basic::options;
145 if( option[ OptionKeys::run::suppress_checkpoints ]() )
disabled_ =
true;
150 using namespace basic::options;
152 if( option[ OptionKeys::run::checkpoint ]() ||
153 option[ OptionKeys::run::checkpoint_interval ].user() ){
155 TR.Info <<
"CHECKDEBUG: " << tag <<
"_" << label <<
" " << data1 <<
" " << data2 <<
" " << data3 << std::endl;
199 boinc_begin_critical_section();
201 using namespace core::io::silent;
203 std::stringstream bail_structure;
204 std::stringstream bail_structure_header;
206 ss->fill_struct( pose,
"W_00000001" );
210 sfd->write_silent_struct( *ss, bail_structure );
215 ss->print_header( bail_structure_header );
229 boinc_end_critical_section();
240 if ( mc == 0 ) mcstr =
"";
241 std::string checkpoint_id(
"chk_" + current_tag +
"_" +
type() +
"_" + mcstr +
"_" +
id );
250 FileBuffer new_file( checkpoint_id +
".rng.state.gz",
true );
251 std::stringstream ss_stream;
252 numeric::random::RandomGenerator::saveAllStates( ss_stream );
264 FileBuffer new_file( checkpoint_id +
"mc_last.out" );
265 std::stringstream ss_stream;
272 FileBuffer new_file( checkpoint_id +
"mc_low.out" );
273 std::stringstream ss_stream;
283 FileBuffer new_file( checkpoint_id +
".out" );
284 std::stringstream ss_stream;
292 TR <<
"CHECK: " <<
" Created virtual checkpoint: " << checkpoint_id << std::endl;
302 boinc_begin_critical_section();
331 using namespace basic::options;
332 using namespace core::chemical;
339 TR.Error <<
"recovering checkpoint of tag " << current_tag
344 if ( mc == 0 ) mcstr =
"";
346 std::string checkpoint_id(
"chk_" + current_tag +
"_" +
type() +
"_" + mcstr +
"_" +
id );
347 if( fullatom ) checkpoint_id +=
"_fa";
355 TR <<
"CHECKING FOR CHECKPOINT" <<
" Id: " << checkpoint_id <<
" : ";
357 TR <<
" NOT PRESENT" << std::endl;
367 TR.Info <<
"Read random number state. " << std::endl;
368 utility::io::izstream izs(checkpoint_id +
".rng.state.gz");
369 numeric::random::RandomGenerator::restoreAllStates(izs);
372 utility_exit_with_message(
"Random generator state not found for checkpoint " + checkpoint_id +
" even though the silent file is there. " );
379 utility_exit_with_message(
"Fullatom mismatch in checkpointer.");
384 #ifdef BOINC_GRAPHICS
386 protocols::boinc::Boinc::attach_graphics_current_pose_observer( pose );
401 TR <<
" SUCCESS" << std::endl;
404 std::cerr <<
"Continuing computation from checkpoint: " << checkpoint_id <<
" ... success! " << std::endl;
414 TR.Info <<
"Deleting checkpoints of " <<
type() << std::endl;
416 using namespace basic::options;
426 TR.Debug <<
"Checkpoint deletion disabled!" << std::endl;