diff --git a/.gitignore b/.gitignore index c4bd975..ef95009 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,7 @@ *.o *.mod .vscode -cMaponiA3_test* -fMaponiA3_test* -QMCChem_dataset_test Slater* Updates* -tests/test datasets/datasets.* - +bin/ diff --git a/Makefile b/Makefile index 127e584..147c26e 100644 --- a/Makefile +++ b/Makefile @@ -1,68 +1,84 @@ -# ARCH = -xCORE-AVX2 - -## Used compilers +## Compilers +ARCH = -xCORE-AVX2 H5CXX = h5c++ CXX = icpc FC = ifort -## Compiler flags & common obs & libs +## Compiler flags H5CXXFLAGS = -O0 -g CXXFLAGS = -O0 -g -traceback FFLAGS = -O0 -g -traceback + +INCLUDE = -I $(INC_DIR)/ +DEPS_CXX = $(OBJ_DIR)/SM_MaponiA3.o +DEPS_F = $(DEPS_CXX) $(OBJ_DIR)/SM_MaponiA3_mod.o $(OBJ_DIR)/Helpers_mod.o FLIBS = -lstdc++ -OBJS = SM_MaponiA3.o -## Deps & objs for C++ cMaponiA3_test_3x3_3 -cMaponiA3_test_3x3_3OBJ = cMaponiA3_test_3x3_3.o -fMaponiA3_test_3x3_3OBJ = SM_MaponiA3_mod.o fMaponiA3_test_3x3_3.o -fMaponiA3_test_4x4_2OBJ = Helpers_mod.o SM_MaponiA3_mod.o fMaponiA3_test_4x4_2.o -QMCChem_dataset_testOBJ = Helpers_mod.o SM_MaponiA3_mod.o QMCChem_dataset_test.o - - -## Default build target: build everything -all: cMaponiA3_test_3x3_3 fMaponiA3_test_3x3_3 fMaponiA3_test_4x4_2 QMCChem_dataset_test tests/test - - -## Compile recipes for C++ -%.o: %.cpp - $(CXX) $(ARCH) $(CXXFLAGS) -c -o $@ $< - -## Compile recepies for Fortran -%.o: %.f90 - $(FC) $(ARCH) $(FFLAGS) -c -o $@ $< - -## Explicit recipe to trigger rebuild and relinking when headerfile is changed -SM_MaponiA3.o: SM_MaponiA3.cpp Helpers.hpp - $(CXX) $(ARCH) $(CXXFLAGS) -fPIC -c -o $@ $< +SRC_DIR := src +TST_DIR := tests +INC_DIR := include +OBJ_DIR := build +BIN_DIR := bin +EXEC := $(BIN_DIR)/cMaponiA3_test_3x3_3 \ + $(BIN_DIR)/test_h5 \ + $(BIN_DIR)/fMaponiA3_test_3x3_3 \ + $(BIN_DIR)/fMaponiA3_test_4x4_2 \ + $(BIN_DIR)/QMCChem_dataset_test ## Build tagets .PHONY: all clean distclean +all: $(EXEC) + clean: - @rm -vf *.o *.mod + @rm -vrf $(OBJ_DIR) distclean: clean - @rm -vf cMaponiA3_test_3x3_3 \ - fMaponiA3_test_3x3_3 fMaponiA3_test_4x4_2 \ - QMCChem_dataset_test \ - Slater* Updates.dat \ - tests/test + @rm -vrf $(BIN_DIR) \ + Slater* Updates.dat -## Linking the C++ example program -cMaponiA3_test_3x3_3: $(cMaponiA3_test_3x3_3OBJ) $(OBJS) - $(CXX) $(ARCH) $(CXXFLAGS) -o $@ $^ +#### COMPILING +$(BIN_DIR) $(OBJ_DIR): + mkdir -p $@ -## Linking Fortran example program calling the C++ function -fMaponiA3_test_3x3_3: $(fMaponiA3_test_3x3_3OBJ) $(OBJS) - $(FC) $(ARCH) $(FFLAGS) $(FLIBS) -o $@ $^ +### IMPLICIT BUILD RULES +## C++ objects +$(OBJ_DIR)/%.o: $(TST_DIR)/%.cpp $(INC_DIR)/* | $(OBJ_DIR) + $(CXX) $(CXXFLAGS) $(ARCH) $(INCLUDE) -c -o $@ $< -fMaponiA3_test_4x4_2: $(fMaponiA3_test_4x4_2OBJ) $(OBJS) - $(FC) $(ARCH) $(FFLAGS) $(FLIBS) -o $@ $^ +## HDF5/C++ objects +$(OBJ_DIR)/%_h5.o: $(TST_DIR)/%_h5.cpp $(INC_DIR)/* | $(OBJ_DIR) + $(H5CXX) $(H5CXXFLAGS) $(INCLUDE) -c -o $@ $< -QMCChem_dataset_test: $(QMCChem_dataset_testOBJ) $(OBJS) - $(FC) $(ARCH) $(FFLAGS) $(FLIBS) -o $@ $^ +## Fortran modules +$(OBJ_DIR)/%_mod.o: $(SRC_DIR)/%_mod.f90 | $(OBJ_DIR) + $(FC) $(FFLAGS) $(ARCH) -module $(OBJ_DIR)/ -c -o $@ $< -tests/test: tests/test.cpp SM_MaponiA3.o - $(H5CXX) $(ARCH) $(H5CXXFLAGS) -o $@ $^ +## Fortran objects +$(OBJ_DIR)/%.o: $(TST_DIR)/%.f90 | $(OBJ_DIR) + $(FC) $(FFLAGS) $(ARCH) -I $(OBJ_DIR)/ -c -o $@ $< + +### EXPLICIT BUILD RULES +## special compiler flag -fPIC otherwise h5c++ builds fail +$(OBJ_DIR)/SM_MaponiA3.o: $(SRC_DIR)/SM_MaponiA3.cpp $(INC_DIR)/* | $(OBJ_DIR) + $(CXX) $(CXXFLAGS) -fPIC $(ARCH) $(INCLUDE) -c -o $@ $< + + + +#### LINKING +$(BIN_DIR)/cMaponiA3_test_3x3_3: $(OBJ_DIR)/cMaponiA3_test_3x3_3.o $(DEPS_CXX) | $(BIN_DIR) + $(CXX) -o $@ $^ + +$(BIN_DIR)/test_h5: $(OBJ_DIR)/test_h5.o $(DEPS_CXX) | $(BIN_DIR) + $(H5CXX) -o $@ $^ + +$(BIN_DIR)/fMaponiA3_test_3x3_3: $(DEPS_F) $(OBJ_DIR)/fMaponiA3_test_3x3_3.o | $(BIN_DIR) + $(FC) $(FLIBS) -o $@ $^ + +$(BIN_DIR)/fMaponiA3_test_4x4_2: $(DEPS_F) $(OBJ_DIR)/fMaponiA3_test_4x4_2.o | $(BIN_DIR) + $(FC) $(FLIBS) -o $@ $^ + +$(BIN_DIR)/QMCChem_dataset_test: $(DEPS_F) $(OBJ_DIR)/QMCChem_dataset_test.o | $(BIN_DIR) + $(FC) $(FLIBS) -o $@ $^ diff --git a/Helpers.hpp b/include/Helpers.hpp similarity index 100% rename from Helpers.hpp rename to include/Helpers.hpp diff --git a/SM_MaponiA3.hpp b/include/SM_MaponiA3.hpp similarity index 100% rename from SM_MaponiA3.hpp rename to include/SM_MaponiA3.hpp diff --git a/mwe/compile.sh b/mwe/compile.sh deleted file mode 100755 index 72b5010..0000000 --- a/mwe/compile.sh +++ /dev/null @@ -1 +0,0 @@ -icpc -c worker.cpp && ifort -c main.f90 && ifort -lstdc++ worker.o main.o -o test diff --git a/mwe/main.cpp b/mwe/main.cpp deleted file mode 100644 index cdf7867..0000000 --- a/mwe/main.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - - -int main() -{ - - typedef int (*to2D)[3]; //pint2 is a pointer to an array of 2 ints - int linArray[9] = {0,1,2,3,4,5,6,7,8}; - - to2D dArray = (to2D)linArray; - - std::cout << dArray[0][0] << std::endl; - std::cout << dArray[0][1] << std::endl; - std::cout << dArray[0][2] << std::endl; - std::cout << dArray[1][0] << std::endl; - std::cout << dArray[1][1] << std::endl; - std::cout << dArray[1][2] << std::endl; - std::cout << dArray[2][0] << std::endl; - std::cout << dArray[2][1] << std::endl; - std::cout << dArray[2][2] << std::endl; - - return 0; -} diff --git a/mwe/main.f90 b/mwe/main.f90 deleted file mode 100644 index 4d9a8e1..0000000 --- a/mwe/main.f90 +++ /dev/null @@ -1,12 +0,0 @@ -program test - use iso_c_binding - implicit none - - interface - subroutine hello() bind(C, name="worker") - end subroutine - end interface - - call hello() - -end program test diff --git a/mwe/worker.cpp b/mwe/worker.cpp deleted file mode 100644 index 1b678b8..0000000 --- a/mwe/worker.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "worker.h" - -void worker() -{ - std::cout << "Hello, World!" << std::endl; -} - diff --git a/mwe/worker.h b/mwe/worker.h deleted file mode 100644 index 70ff209..0000000 --- a/mwe/worker.h +++ /dev/null @@ -1,6 +0,0 @@ -#include - -extern "C" -{ - void worker(); -} diff --git a/QMCChem_dataset_test.m b/octave-tests/QMCChem_dataset_test.m similarity index 100% rename from QMCChem_dataset_test.m rename to octave-tests/QMCChem_dataset_test.m diff --git a/Octave-tests/SM-Coppens-1.m b/octave-tests/SM-Coppens-1.m similarity index 100% rename from Octave-tests/SM-Coppens-1.m rename to octave-tests/SM-Coppens-1.m diff --git a/Octave-tests/SMMaponiA3.m b/octave-tests/SMMaponiA3.m similarity index 100% rename from Octave-tests/SMMaponiA3.m rename to octave-tests/SMMaponiA3.m diff --git a/Octave-tests/SMMaponiA4.m b/octave-tests/SMMaponiA4.m similarity index 100% rename from Octave-tests/SMMaponiA4.m rename to octave-tests/SMMaponiA4.m diff --git a/Helpers_mod.f90 b/src/Helpers_mod.f90 similarity index 100% rename from Helpers_mod.f90 rename to src/Helpers_mod.f90 diff --git a/SM_MaponiA3.cpp b/src/SM_MaponiA3.cpp similarity index 100% rename from SM_MaponiA3.cpp rename to src/SM_MaponiA3.cpp diff --git a/SM_MaponiA3_mod.f90 b/src/SM_MaponiA3_mod.f90 similarity index 100% rename from SM_MaponiA3_mod.f90 rename to src/SM_MaponiA3_mod.f90 diff --git a/det.irp.f b/src/det.irp.f similarity index 100% rename from det.irp.f rename to src/det.irp.f diff --git a/QMCChem_dataset_test.f90 b/tests/QMCChem_dataset_test.f90 similarity index 100% rename from QMCChem_dataset_test.f90 rename to tests/QMCChem_dataset_test.f90 diff --git a/cMaponiA3_test_3x3_3.cpp b/tests/cMaponiA3_test_3x3_3.cpp similarity index 100% rename from cMaponiA3_test_3x3_3.cpp rename to tests/cMaponiA3_test_3x3_3.cpp diff --git a/fMaponiA3_test_3x3_3.f90 b/tests/fMaponiA3_test_3x3_3.f90 similarity index 100% rename from fMaponiA3_test_3x3_3.f90 rename to tests/fMaponiA3_test_3x3_3.f90 diff --git a/fMaponiA3_test_4x4_2.f90 b/tests/fMaponiA3_test_4x4_2.f90 similarity index 100% rename from fMaponiA3_test_4x4_2.f90 rename to tests/fMaponiA3_test_4x4_2.f90 diff --git a/tests/test.cpp b/tests/test_h5.cpp similarity index 95% rename from tests/test.cpp rename to tests/test_h5.cpp index 01ae2b5..ef96b0e 100644 --- a/tests/test.cpp +++ b/tests/test_h5.cpp @@ -3,13 +3,13 @@ #include "hdf5/serial/hdf5.h" #include "H5Cpp.h" -#include "../SM_MaponiA3.hpp" -#include "../Helpers.hpp" +#include "SM_MaponiA3.hpp" +#include "Helpers.hpp" using namespace H5; -#define DEBUG 1 +//#define DEBUG 0 -const H5std_string FILE_NAME( "datasets.small.hdf5" ); +const H5std_string FILE_NAME( "datasets.hdf5" ); void read_int(H5File file, std::string key, unsigned int * data) { DataSet ds = file.openDataSet(key); diff --git a/tests/convert-to-h5.py b/tools/convert-to-h5.py similarity index 97% rename from tests/convert-to-h5.py rename to tools/convert-to-h5.py index 72a1173..e3dcaf9 100644 --- a/tests/convert-to-h5.py +++ b/tools/convert-to-h5.py @@ -7,7 +7,7 @@ def rl(rf): with h5py.File('datasets.hdf5', 'w') as f: - with open('datasets.short.dat', 'r') as rf: + with open('datasets.dat', 'r') as rf: while(1): line = rl(rf) if not line or not line.startswith('#START_PACKET'):