Skip to content
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
63 changes: 50 additions & 13 deletions grid_gen/mesh_conversion_tools/Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,68 @@
#Assumes ${NETCDF} is defined to the root of the netcdf library

# gfortran
#### titan instructions ####
# module purge
# module load gcc/4.9.3
# module load cray-netcdf/3.6.2
# printenv NETCDF_DIR
# export NETCDF=$NETCDF_DIR
# make

#### edison instructions ####
# In this file:
# comment gnu, uncomment intel flags
# change to:
# CC=CC
# may need to unload parallel NetCDF and HDF5 libraries
# to avoid g++ conflicts:
# module unload python
# then:
# module load cray-netcdf
# module load netcdf-cxx
# export NETCDF=/usr/common/graphics/netcdf-cxx/4.2
# make

# gnu
CC=g++
CFLAGS= -O3 -std=c++0x -fopenmp
DFLAGS= -g -std=c++0x -D_DEBUG -fopenmp
CFLAGS= -O3 -std=c++0x -fopenmp -lstdc++
DFLAGS= -g -std=c++0x -D_DEBUG -fopenmp -lstdc++

# intel
# CC=icpc
# CFLAGS= -O3 -std=c++0x -openmp
# DFLAGS= -g -std=c++0x -D_DEBUG -openmp
# CFLAGS= -O3 -std=c++0x -qopenmp -lstdc++
# DFLAGS= -g -std=c++0x -D_DEBUG -qopenmp -lstdc++

CONV_EXECUTABLE= MpasMeshConverter.x
CULL_EXECUTABLE= MpasCellCuller.x
MASK_EXECUTABLE= MpasMaskCreator.x

NCINCDIR=${NETCDF}/include
NCLIBDIR=${NETCDF}/lib
ifneq (${NETCDF}, )
ifneq ($(shell which ${NETCDF}/bin/nc-config 2> /dev/null), )
LIBS = $(shell ${NETCDF}/bin/nc-config --libs) -lnetcdf_c++
INCS = $(shell ${NETCDF}/bin/nc-config --cflags)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous two lines are causing the problem on grizzly using intel. For some reason I don't understand, I end up with the $NETCDF path prepended to both $LIBS and $INCS due to these lines. That is, I get:

gr-fe3.lanl.gov> pwd
/turquoise/usr/projects/climate/mpeterse/repos/MPAS-Tools/pr_temp/grid_gen/mesh_conversion_tools
gr-fe3.lanl.gov> module load intel/17.0.1 openmpi/1.10.5 netcdf/4.4.1 parallel-netcdf/1.5.0 pio/1.7.2
gr-fe3.lanl.gov> make
icpc mpas_mesh_converter.cpp netcdf_utils.cpp -O3 -std=c++0x -openmp -lstdc++ -o MpasMeshConverter.x -I. /usr/projects/climate/SHARED_CLIMATE/software/grizzly/netcdf/4.4.1/intel-17.0.1 -I/usr/projects/climate/SHARED_CLIMATE/software/grizzly/netcdf/4.4.1/intel-17.0.1/include /usr/projects/climate/SHARED_CLIMATE/software/grizzly/netcdf/4.4.1/intel-17.0.1 -L/usr/projects/climate/SHARED_CLIMATE/software/grizzly/netcdf/4.4.1/intel-17.0.1/lib -lnetcdf -lnetcdf_c++

else
LIBS= -L${NETCDF}/lib
LIBS += -lnetcdf_c++ -lnetcdf
INCS = -I${NETCDF}/include
endif
else ifneq ($(shell which nc-config 2> /dev/null), )
LIBS = $(shell nc-config --libs) -lnetcdf_c++
INCS = $(shell nc-config --cflags)
else
LIBS= -L${NETCDF}/lib
LIBS += -lnetcdf_c++ -lnetcdf
INCS = -I${NETCDF}/include
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pwolfram, isn't $NETCDF empty in this case? So you might as well try not adding any path to LIBS and INCS and hope it's in the default path. Or issue an error.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I see. Based on your commands above, on grizzly with intel loaded:

gr-fe2.lanl.gov> ${NETCDF}/bin/nc-config --cflags
/usr/projects/climate/SHARED_CLIMATE/software/grizzly/netcdf/4.4.1/intel-17.0.1
-I/usr/projects/climate/SHARED_CLIMATE/software/grizzly/netcdf/4.4.1/intel-17.0.1/include

That is the trouble. For some reason intel adds the extra path. Compare to the gnu version on grizzly:

gr-fe3.lanl.gov> ${NETCDF}/bin/nc-config --cflags
-I/usr/projects/climate/lvanroekel/netcdf_gcc/include

In fact, it always does it. Look at this strange behavior on grizzly with intel:

gr-fe2.lanl.gov> module use /usr/projects/climate/SHARED_CLIMATE/modulefiles/all/;module load python/anaconda-2.7-climate;module load intel/17.0.1 openmpi/1.10.5 netcdf/4.4.1 parallel-netcdf/1.5.0 pio/1.7.2;
gr-fe2.lanl.gov> ${NETCDF}/bin/nc-config --includedir
/usr/projects/climate/SHARED_CLIMATE/software/grizzly/netcdf/4.4.1/intel-17.0.1
/usr/projects/climate/SHARED_CLIMATE/software/grizzly/netcdf/4.4.1/intel-17.0.1/include
gr-fe2.lanl.gov> ${NETCDF}/bin/nc-config --libs
/usr/projects/climate/SHARED_CLIMATE/software/grizzly/netcdf/4.4.1/intel-17.0.1
-L/usr/projects/climate/SHARED_CLIMATE/software/grizzly/netcdf/4.4.1/intel-17.0.1/lib -lnetcdf

this appears to be a bug in the nc-config script. I guess we need a work-around.

endif

all:
${CC} mpas_mesh_converter.cpp netcdf_utils.cpp ${CFLAGS} -o ${CONV_EXECUTABLE} -I${NCINCDIR} -L${NCLIBDIR} -lnetcdf_c++ -lnetcdf -lstdc++
${CC} mpas_cell_culler.cpp netcdf_utils.cpp ${CFLAGS} -o ${CULL_EXECUTABLE} -I${NCINCDIR} -L${NCLIBDIR} -lnetcdf_c++ -lnetcdf -lstdc++
${CC} mpas_mask_creator.cpp netcdf_utils.cpp jsoncpp.cpp ${CFLAGS} -o ${MASK_EXECUTABLE} -I. -I${NCINCDIR} -L${NCLIBDIR} -lnetcdf_c++ -lnetcdf -lstdc++
${CC} mpas_mesh_converter.cpp netcdf_utils.cpp ${CFLAGS} -o ${CONV_EXECUTABLE} -I. ${INCS} ${LIBS}
${CC} mpas_cell_culler.cpp netcdf_utils.cpp ${CFLAGS} -o ${CULL_EXECUTABLE} ${INCS} ${LIBS}
${CC} mpas_mask_creator.cpp netcdf_utils.cpp jsoncpp.cpp ${CFLAGS} -o ${MASK_EXECUTABLE} -I. ${INCS} ${LIBS}

debug:
${CC} mpas_mesh_converter.cpp netcdf_utils.cpp ${DFLAGS} -o ${CONV_EXECUTABLE} -I${NCINCDIR} -L${NCLIBDIR} -lnetcdf_c++ -lnetcdf -lstdc++
${CC} mpas_cell_culler.cpp netcdf_utils.cpp ${DFLAGS} -o ${CULL_EXECUTABLE} -I${NCINCDIR} -L${NCLIBDIR} -lnetcdf_c++ -lnetcdf -lstdc++
${CC} mpas_mask_creator.cpp netcdf_utils.cpp jsoncpp.cpp ${DFLAGS} -o ${MASK_EXECUTABLE} -I. -I${NCINCDIR} -L${NCLIBDIR} -lnetcdf_c++ -lnetcdf -lstdc++
${CC} mpas_mesh_converter.cpp netcdf_utils.cpp ${DFLAGS} -o ${CONV_EXECUTABLE} ${INCS} ${LIBS}
${CC} mpas_cell_culler.cpp netcdf_utils.cpp ${DFLAGS} -o ${CULL_EXECUTABLE} ${INCS} ${LIBS}
${CC} mpas_mask_creator.cpp netcdf_utils.cpp jsoncpp.cpp ${DFLAGS} -o ${MASK_EXECUTABLE} -I. ${INCS} ${LIBS}

clean:
rm -f grid.nc
Expand Down
20 changes: 10 additions & 10 deletions grid_gen/mesh_conversion_tools/json/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ namespace Json {
class JSON_API Exception : public std::exception {
public:
Exception(std::string const& msg);
~Exception() throw() override;
char const* what() const throw() override;
~Exception() throw() ;
char const* what() const throw() ;
protected:
std::string msg_;
};
Expand Down Expand Up @@ -1581,9 +1581,9 @@ class JSON_API CharReaderBuilder : public CharReader::Factory {
Json::Value settings_;

CharReaderBuilder();
~CharReaderBuilder() override;
~CharReaderBuilder() ;

CharReader* newCharReader() const override;
CharReader* newCharReader() const ;

/** \return true if 'settings' are legal and consistent;
* otherwise, indicate bad settings via 'invalid'.
Expand Down Expand Up @@ -1778,12 +1778,12 @@ class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
Json::Value settings_;

StreamWriterBuilder();
~StreamWriterBuilder() override;
~StreamWriterBuilder() ;

/**
* \throw std::exception if something goes wrong (e.g. invalid settings)
*/
StreamWriter* newStreamWriter() const override;
StreamWriter* newStreamWriter() const ;

/** \return true if 'settings' are legal and consistent;
* otherwise, indicate bad settings via 'invalid'.
Expand Down Expand Up @@ -1824,7 +1824,7 @@ class JSON_API FastWriter : public Writer {

public:
FastWriter();
~FastWriter() override {}
~FastWriter() {}

void enableYAMLCompatibility();

Expand All @@ -1838,7 +1838,7 @@ class JSON_API FastWriter : public Writer {
void omitEndingLineFeed();

public: // overridden from Writer
std::string write(const Value& root) override;
std::string write(const Value& root) ;

private:
void writeValue(const Value& value);
Expand Down Expand Up @@ -1876,14 +1876,14 @@ class JSON_API FastWriter : public Writer {
class JSON_API StyledWriter : public Writer {
public:
StyledWriter();
~StyledWriter() override {}
~StyledWriter() {}

public: // overridden from Writer
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
* \param root Value to serialize.
* \return String containing the JSON document that represents the root value.
*/
std::string write(const Value& root) override;
std::string write(const Value& root) ;

private:
void writeValue(const Value& value);
Expand Down
6 changes: 3 additions & 3 deletions grid_gen/mesh_conversion_tools/jsoncpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2088,7 +2088,7 @@ class OurCharReader : public CharReader {
{}
bool parse(
char const* beginDoc, char const* endDoc,
Value* root, std::string* errs) override {
Value* root, std::string* errs) {
bool ok = reader_.parse(beginDoc, endDoc, *root, collectComments_);
if (errs) {
*errs = reader_.getFormattedErrorMessages();
Expand Down Expand Up @@ -2652,7 +2652,7 @@ Value::CZString::CZString(const CZString& other)
#if JSON_HAS_RVALUE_REFERENCES
Value::CZString::CZString(CZString&& other)
: cstr_(other.cstr_), index_(other.index_) {
other.cstr_ = nullptr;
other.cstr_ = NULL;
}
#endif

Expand Down Expand Up @@ -4806,7 +4806,7 @@ struct BuiltStyledStreamWriter : public StreamWriter
std::string const& endingLineFeedSymbol,
bool useSpecialFloats,
unsigned int precision);
int write(Value const& root, std::ostream* sout) override;
int write(Value const& root, std::ostream* sout) ;
private:
void writeValue(Value const& value);
void writeArrayValue(Value const& value);
Expand Down
6 changes: 3 additions & 3 deletions grid_gen/mesh_conversion_tools/mpas_cell_culler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ int main ( int argc, char *argv[] ) {

for ( int i = 3; i < argc; i+=2 ) {
if (strcmp(argv[i], "-m") == 0 ) {
mask_ops.push_back(merge);
mask_ops.push_back(static_cast<int>(merge));
} else if ( strcmp(argv[i], "-i") == 0 ){
mask_ops.push_back(invert);
mask_ops.push_back(static_cast<int>(invert));
} else if ( strcmp(argv[i], "-p") == 0 ){
mask_ops.push_back(preserve);
mask_ops.push_back(static_cast<int>(preserve));
} else {
cout << " ERROR: Invalid option passed on the command line " << argv[i] << ". Exiting..." << endl;
exit(1);
Expand Down
4 changes: 2 additions & 2 deletions grid_gen/mesh_conversion_tools/mpas_mask_creator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ int resetFeatureInfo(){/*{{{*/
return 0;
}/*}}}*/
int getFeatureInfo(const string featureFilename){/*{{{*/
ifstream json_file(featureFilename);
ifstream json_file(featureFilename.c_str());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this was causing a lot of unnecessary trouble.

Json::Value root;
string groupName, tempGroupName;
vector<int> pointIndices;
Expand Down Expand Up @@ -1304,7 +1304,7 @@ int getFeatureInfo(const string featureFilename){/*{{{*/
return 0;
}/*}}}*/
int getSeedInfo(const string seedFilename){/*{{{*/
ifstream json_file(seedFilename);
ifstream json_file(seedFilename.c_str());
Json::Value root;

json_file >> root;
Expand Down