Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise a more informative message when the coordinate file is missed #3634

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/vapor/DCCF.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <algorithm>
#include <map>
#include <iostream>
#include <memory>
#include <vapor/MyBase.h>
#include <vapor/NetCDFCFCollection.h>
#include <vapor/Proj4API.h>
Expand Down Expand Up @@ -58,7 +59,8 @@ class VDF_API DCCF : public VAPoR::DC {
//! \sa EndDefine();
//
virtual int initialize(const vector<string> &paths, const std::vector<string> &options);
virtual int initialize(const vector<string> &paths, const std::vector<string> &options, NetCDFCFCollection *ncdfc);
virtual int initialize_impl(const vector<string> &paths, const std::vector<string> &options,
std::unique_ptr<NetCDFCFCollection> ncdfc);

//! \copydoc DC::getDimension()
//!
Expand Down
30 changes: 24 additions & 6 deletions lib/vdc/DCCF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,13 @@ DCCF::~DCCF()

int DCCF::initialize(const vector<string> &paths, const std::vector<string> &options)
{
return initialize(paths, options, new NetCDFCFCollection());
auto ncdf = std::unique_ptr<NetCDFCFCollection>(new NetCDFCFCollection());
return initialize_impl(paths, options, std::move(ncdf));
}

int DCCF::initialize(const vector<string> &paths, const std::vector<string> &options, NetCDFCFCollection *ncdfc)
int DCCF::initialize_impl(const vector<string> &paths, const std::vector<string> &options,
std::unique_ptr<NetCDFCFCollection> ncdfc)
{
if (_ncdfc) delete _ncdfc;
_paths = paths;

// Initialize the NetCDFCFCollection class.
//
int rc = ncdfc->Initialize(paths);
Expand All @@ -87,7 +86,26 @@ int DCCF::initialize(const vector<string> &paths, const std::vector<string> &opt
return (-1);
}

_ncdfc = ncdfc;
//
// To provide a more detailed message in the case described by issue 3626:
// https://github.com/NCAR/VAPOR/issues/3626
// add a test if there's any 2D or 3D variables detected. If not, we raise an error.
//
auto vars2d = ncdfc->GetDataVariableNames(2, true);
if (vars2d.empty()) {
auto vars3d = ncdfc->GetDataVariableNames(3, true);
if (vars3d.empty()) {
SetErrMsg("Failed to detect any 2D or 3D variables.\n"
"Did you forget any coordinate files?\n");
return (-1);
}
}

if (_ncdfc) {
delete _ncdfc;
}
_ncdfc = ncdfc.release();
_paths = paths;

return BuildCache();
}
Expand Down