Commit 58530f13 authored by Paal Kvamme's avatar Paal Kvamme
Browse files

Add --finalize option to zgycopyc for testing the new functionality.

parent 5f79b241
Pipeline #50179 passed with stages
in 21 minutes and 24 seconds
......@@ -80,6 +80,8 @@ using OpenZGY::SeismicStoreIOContext;
class Options
{
public:
typedef std::pair<OpenZGY::FinalizeAction, bool> finalize_t;
std::string myname;
int verbose;
bool nolod;
......@@ -103,6 +105,7 @@ public:
std::array<std::int64_t,3> obricksize;
OpenZGY::SampleDataType osamplesize;
std::vector<OpenZGY::DecimationType> algorithm;
finalize_t finalize;
int lod; // Still unused. Maybe not useful.
int threads;
int brickcount;
......@@ -133,6 +136,7 @@ public:
, obricksize(std::array<std::int64_t,3>{64,64,64})
, osamplesize(OpenZGY::SampleDataType::unknown)
, algorithm()
, finalize(std::make_pair(OpenZGY::FinalizeAction::BuildDefault, false))
, lod()
, threads(1)
, brickcount(-1)
......@@ -177,6 +181,7 @@ public:
"-B, --obricksize I,J,K Brick size in output. E.g. 64x64x64 samples.",
"-O, --osamplesize type Output float int16, or int8.",
"-g, --algorithm 1,2,N: LOD algorithms as 3 int: lod1,lod2,lodN.",
"-f, --finalize type full, incremental, keep, etc.",
//"-l, --lod N: *Level of detail, 0 = full resolution.",
"-t, --threads N: Number of threads to use for reading.",
"-n, --brickcount N: Only copy the first N bricks.",
......@@ -261,6 +266,9 @@ public:
os << " ";
}
if (finalize != finalize_t(OpenZGY::FinalizeAction::BuildDefault, false))
os << "--finalize=" << showFinalizeAction(finalize) << " ";
if (lod != 0)
os << "--lod=" << lod << " ";
if (threads != 1)
......@@ -352,6 +360,47 @@ public:
return result;
}
static std::vector<std::pair<finalize_t, const char*>> finalizeTypes()
{
using OpenZGY::FinalizeAction;
static std::vector<std::pair<finalize_t, const char*>> result
{
{{FinalizeAction::BuildDefault, false}, "default"},
{{FinalizeAction::Delete, false}, "delete"},
{{FinalizeAction::Delete, true}, "force-delete"},
{{FinalizeAction::Keep, false}, "keep"},
{{FinalizeAction::Keep, true}, "force-keep"},
{{FinalizeAction::BuildIncremental, false}, "incremental"},
{{FinalizeAction::BuildIncremental, true}, "force-incremental"},
{{FinalizeAction::BuildFull, false}, "full"},
{{FinalizeAction::BuildFull, true}, "force-full"},
};
return result;
}
static finalize_t getFinalizeAction(const char *name)
{
#ifdef _WIN32
for (const auto& it : finalizeTypes())
if (0 == _stricmp(name, it.second))
return it.first;
#else
for (const auto& it : finalizeTypes())
if (0==strcasecmp(name, it.second))
return it.first;
#endif
throw std::runtime_error("Invalid finalize type \"" +
std::string(name) + "\".");
}
static const char* showFinalizeAction(const finalize_t& finalize)
{
for (const auto& it : finalizeTypes())
if (it.first == finalize)
return it.second;
return "(invalid)";
}
#ifndef HAVE_GETOPT
// getopt_long() missing from windows, so fake it.
struct option {
......@@ -390,6 +439,7 @@ public:
{"obricksize", required_argument, 0, 'B' },
{"osamplesize",required_argument, 0, 'O' },
{"algorithm", required_argument, 0, 'g' },
{"finalize" , required_argument, 0, 'f' },
{"threads", required_argument, 0, 't' },
{"brickcount", required_argument, 0, 'n' },
{"lod", required_argument, 0, 'l' },
......@@ -491,6 +541,7 @@ public:
break;
case 'g': algorithm = getDecimationTypes(optarg); break;
case 'f': finalize = getFinalizeAction(optarg); break;
case 'l': throw std::runtime_error("--lod not supported"); //lod = geti(optarg); break;
case 't': threads = geti(optarg); break;
case 'n': brickcount = geti(optarg); break;
......@@ -1229,9 +1280,7 @@ copy(const Options& opt, SummaryPrintingTimerEx& rtimer, SummaryPrintingTimerEx&
// expect to see finalize reported at all when discarding the output.
SimpleTimerEx ft(ftimer);
w->finalize(opt.algorithm, std::ref(p2),
opt.update ? FinalizeAction::BuildIncremental :
FinalizeAction::BuildDefault,
false);
opt.finalize.first, opt.finalize.second);
w->close();
// If Timer logging is also enabled inside OpenZGY there will now
// be multiple lines of output when the output file is finalized
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment