Skip to content

Commit

Permalink
Record version information in output files
Browse files Browse the repository at this point in the history
The version is stored in the second line of the header such as

   # generated with galfast version Lucky-119-g01af5d4-diffsha=4dd0d34d

unless an environment variable NOVERSION exist and is set to a nonzero value
(useful for producing bit-for-bit identical files with different versions).
  • Loading branch information
mjuric committed May 20, 2010
1 parent 01af5d4 commit 9df8ee5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
11 changes: 10 additions & 1 deletion src/common/otable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,13 @@ std::ostream& otable::serialize_header(std::ostream &out)
(*i)->serialize_def(out);
out << " ";
}

// serialize version information
if(!galfast_version.empty())
{
out << "\n# generated with galfast version " << galfast_version;
}

return out;
}

Expand Down Expand Up @@ -703,8 +710,10 @@ otable::columndef &otable::use_column_by_cloning(const std::string &newColumnNam
return *col;
}

void otable::init()
void otable::init(const std::string &galfast_version)
{
this->galfast_version = galfast_version;

// definition of built-in classes and column defaults
parse(
"(class) default {fmt=% 7.3f;}" // NOTE: This class must come be defined before any columns are ever instantiated
Expand Down
7 changes: 4 additions & 3 deletions src/common/otable.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class otable
}
};

std::string galfast_version;
public:
struct columndef : public kv
{
Expand Down Expand Up @@ -383,7 +384,7 @@ class otable
struct parse_callback { virtual bool operator()(kv *kvobj) = 0; };

protected:
void init();
void init(const std::string &galfast_version);
kv *parse(const std::string &defs, parse_callback *cback = NULL);

void getColumnsForOutput(std::vector<const columndef*> &cols) const; // aux helper
Expand Down Expand Up @@ -421,12 +422,12 @@ class otable
}
// bool del_column(const std::string &name);

otable(const size_t len)
otable(const size_t len, const std::string &galfast_version_)
{
nrows_capacity = len;
nrows = 0;

init();
init(galfast_version_);
}

struct mask_functor { virtual bool shouldOutput(int row) const = 0; };
Expand Down
8 changes: 7 additions & 1 deletion src/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "config.h"

#include "version.h"
#include "analysis.h"
#include "io.h"
#include "pipeline.h"
Expand Down Expand Up @@ -1248,7 +1249,12 @@ void generate_catalog(int seed, size_t maxstars, size_t nstars, const std::set<C
if(kb) { Kbatch = (int)atof(kb.c_str()); } // atof instead of atoi to allow shorthands such as 1e5
if(kb) { MLOG(verb1) << "Batch size: " << Kbatch << " objects"; }
DLOG(verb1) << "Processing in batches of " << Kbatch << " objects";
otable t(Kbatch);

std::string ver;
EnvVar nover("NOVERSION");
if(!nover || atoi(nover.c_str()) == 0) { ver = VERSION_STRING; }
else { MLOG(verb1) << "WARNING: Not recording software version in output files."; }
otable t(Kbatch, ver);

// load all module config files and detect and set aside
// models and footprints
Expand Down

0 comments on commit 9df8ee5

Please sign in to comment.