Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 2032f3af authored by David Parsons's avatar David Parsons
Browse files

aevol_propagate will now create a last_gener file

parent 933c9fd0
No related branches found
No related tags found
No related merge requests found
......@@ -220,8 +220,11 @@ void ExpManager::save(void) const
\see write_setup_files(void)
\see save(void)
*/
void ExpManager::save_copy(char* dir, int32_t num_gener /*= 0*/) const
void ExpManager::save_copy(char* dir, int64_t num_gener /*= 0*/) const
{
// Set time to num_gener
Time::set_time(num_gener);
// Create missing directories
create_missing_directories(dir);
......@@ -241,6 +244,9 @@ void ExpManager::save_copy(char* dir, int32_t num_gener /*= 0*/) const
// Close setup and backup files
close_setup_files(exp_s_file, out_p_file);
close_backup_files(sel_file, world_file);
// Write last gener file
_output_m->WriteLastGenerFile(dir);
}
void ExpManager::step_to_next_generation() {
......
......@@ -171,7 +171,7 @@ class ExpManager : public Observer
bool share_phenotypic_target);
void write_setup_files(void);
void save(void) const;
void save_copy(char* dir, int32_t num_gener = 0) const;
void save_copy(char* dir, int64_t num_gener = 0) const;
inline void load(int32_t first_gener,
bool verbose = false, bool to_be_run = true);
void load(const char* dir, int64_t t0,
......
......@@ -28,21 +28,22 @@
// =================================================================
// Libraries
// Includes
// =================================================================
#include "OutputManager.h"
#include <err.h>
#include <errno.h>
#include <sys/stat.h>
#include <fstream>
#include <string>
// =================================================================
// Project Files
// =================================================================
#include "OutputManager.h"
#include "ExpManager.h"
#include "Time.h"
using std::string;
using std::endl;
namespace aevol {
......@@ -115,29 +116,6 @@ void OutputManager::write_setup_file( gzFile setup_file ) const
gzwrite( setup_file, &logs, sizeof(logs) );
}
void OutputManager::write_setup_file(FILE* setup_file) const
{
// Write the backup steps
fprintf(setup_file, "BACKUP_STEP %" PRId64 "\n", _backup_step);
fprintf(setup_file, "BIG_BACKUP_STEP %" PRId64 "\n", _big_backup_step);
// Stats
fprintf(setup_file, "COMPUTE_PHENOTYPIC_CONTRIBUTION_BY_GU %" PRId8 "\n", (int8_t) _compute_phen_contrib_by_GU );
// Tree
fprintf(setup_file, "RECORD_TREE %s\n", _record_tree ? "true" : "false");
if (_record_tree)
fprintf(setup_file, "TREE_STEP %" PRId64 "\n", _tree->get_tree_step());
// Dumps
fprintf(setup_file, "MAKE_DUMPS %s\n", _make_dumps ? "true" : "false");
fprintf(setup_file, "DUMP_STEP %" PRId64 "\n", _dump_step);
// Logs
int8_t logs = _logs->get_logs();
fprintf(setup_file, "LOGS %" PRId8 "\n", logs);
}
void OutputManager::load(gzFile setup_file, bool verbose, bool to_be_run)
{
// Write the backup steps
......@@ -259,16 +237,8 @@ void OutputManager::write_current_generation_outputs( void ) const
if (Time::get_time() % _backup_step == 0) {
_stats->flush();
_exp_m->save();
// Update the LAST_GENER file
FILE* last_gener_file = fopen(LAST_GENER_FNAME, "w");
if (last_gener_file != NULL) {
fprintf(last_gener_file, "%" PRId64 "\n", Time::get_time());
fclose(last_gener_file);
}
else {
printf( "Error : could not open file " LAST_GENER_FNAME "\n" );
}
WriteLastGenerFile();
}
// Write dumps
......@@ -279,6 +249,19 @@ void OutputManager::write_current_generation_outputs( void ) const
}
}
// TODO <david.parsons@inria.fr> we need an output_dir attribute in this class !
void OutputManager::WriteLastGenerFile(const string& output_dir) const {
std::ofstream last_gener_file(output_dir + "/" + LAST_GENER_FNAME,
std::ofstream::out);
if (last_gener_file.fail()) {
Utils::ExitWithUsrMsg(string("could not open file ") + LAST_GENER_FNAME);
}
else {
last_gener_file << Time::get_time() << endl;
last_gener_file.close();
}
}
// TODO <david.parsons@inria.fr> we need an input_dir attribute in this class !
int32_t OutputManager::get_last_gener() {
int32_t num_gener;
......
......@@ -116,21 +116,13 @@ class OutputManager
// Public Methods
// =================================================================
void write_setup_file( gzFile setup_file ) const;
void write_setup_file( FILE* setup_file ) const;
void WriteLastGenerFile(const std::string& input_dir = ".") const;
void load( gzFile file, bool verbose, bool to_be_run );
void load( FILE* file, bool verbose, bool to_be_run );
void write_current_generation_outputs( void ) const;
inline void flush( void );
static int32_t get_last_gener();
// =================================================================
// Public Attributes
// =================================================================
static int32_t get_last_gener();
protected :
// =================================================================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment