Commit eb3575d5 authored by Andrew J. Burns (Cont's avatar Andrew J. Burns (Cont

added controller multi-open, dsm tests, and fortran tests

parent 89a31eb2
INCLUDE(TestingSetup)
# We should have one place that points to the c source directory and the c
# binary directory
SET(c_source_dir ${CMAKE_CURRENT_SOURCE_DIR})
SET(c_binary_dir ${CMAKE_CURRENT_BINARY_DIR})
# C Add Dependencies Macro
# Author: Brian Panneton
# Description: This macro adds the c test dependencies.
# Note: The tests already depend on their own file
# Parameters:
# dependencies = any dependencies needed for c tests
MACRO(ADD_TEST_C_DEPENDENCIES dependencies)
IF(NOT ("${dependencies}" STREQUAL ""))
SET_PROPERTY(GLOBAL APPEND PROPERTY C_TEST_DEPENDENCIES
"${dependencies}"
)
ENDIF(NOT ("${dependencies}" STREQUAL ""))
ENDMACRO(ADD_TEST_C_DEPENDENCIES dependencies)
# C Add LDPath Macro
# Author: Brian Panneton
# Description: This macro adds the c test ldpaths.
# Parameters:
# ld = any ldpaths needed for c tests
MACRO(ADD_TEST_C_LDPATH ld)
GET_PROPERTY(ldpath GLOBAL PROPERTY C_TEST_LDPATH)
IF("${ld}" STRGREATER "")
SET_PROPERTY(GLOBAL PROPERTY C_TEST_LDPATH
"${ldpath}${sep}${ld}"
)
ENDIF("${ld}" STRGREATER "")
ENDMACRO(ADD_TEST_C_LDPATH ld)
# C Add Path Macro
# Author: Brian Panneton
# Description: This macro adds the c test paths.
# Parameters:
# p = any paths needed for c tests
MACRO(ADD_TEST_C_PATH p)
GET_PROPERTY(path GLOBAL PROPERTY C_TEST_PATH)
IF("${p}" STRGREATER "")
SET_PROPERTY(GLOBAL PROPERTY C_TEST_PATH
"${path}${sep}${p}"
)
ENDIF("${p}" STRGREATER "")
ENDMACRO(ADD_TEST_C_PATH p)
# C Test Macro
# Author: Brian Panneton
# Description: This macro builds and add the c test in one shot.
# Parameters:
# executable = executable name
# dup = duplicate number
# tdep = test dependency (Full Test Name with Prefix)
# ${ARGN} = any arguments for the executable
MACRO(ADD_TEST_C executable)
PARSE_TEST_ARGS("${ARGN}")
IF(EXISTS ${c_source_dir}/${executable}.c)
ADD_EXECUTABLE(${executable}${dup} ${c_source_dir}/${executable}.c)
ENDIF(EXISTS ${c_source_dir}/${executable}.c)
GET_PROPERTY(c_dependencies GLOBAL PROPERTY C_TEST_DEPENDENCIES)
GET_PROPERTY(c_ldpath GLOBAL PROPERTY C_TEST_LDPATH)
GET_PROPERTY(c_path GLOBAL PROPERTY C_TEST_PATH)
TARGET_LINK_LIBRARIES(${executable}${dup} ${c_dependencies})
# Take care of windowisims
IF(WIN32)
SET_TARGET_PROPERTIES(${executable}${dup} PROPERTIES
PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${c_binary_dir}
LIBRARY_OUTPUT_DIRECTORY ${c_binary_dir}
ARCHIVE_OUTPUT_DIRECTORY ${c_binary_dir})
IF("${c_path}" STREQUAL "")
SET(c_path ${c_ldpath})
ENDIF("${c_path}" STREQUAL "")
ENDIF(WIN32)
SET_CORE("${c_binary_dir}")
ADD_TEST(C${is_core}_${executable}${dup} ${CMAKE_COMMAND}
-D "EXECUTABLE=${executable}${dup}"
-D "ARGUMENTS=${arguments}"
-D "LDPATH=${c_ldpath}"
-D "PATH=${c_path}"
-D "SEPARATOR=${sep}"
-P "${c_binary_dir}/TestDriverC.cmake"
)
IF(NOT "${tdep}" STREQUAL "")
SET_TESTS_PROPERTIES(C${is_core}_${executable}${dup}
PROPERTIES DEPENDS ${tdep})
ENDIF(NOT "${tdep}" STREQUAL "")
ENDMACRO(ADD_TEST_C executable)
# C MPI Test Macro
# Author: Andrew Burns
# Description: This macro builds and adds a script to execute MPI tests.
# Parameters:
# executable = script name
# files = code to be compiled and executed by the script
# tdep = test dependency (Full Test Name with Prefix)
# ${ARGN} = any arguments for the executable
MACRO(ADD_MPI_TEST_C script files)
PARSE_TEST_ARGS("${ARGN}")
set(tempfiles ${files})
WHILE(NOT "${tempfiles}" STREQUAL "")
# ${executable}
STRING(REGEX MATCH "([^ ,])+,|([^ ,])+" executable "${tempfiles}")
STRING(REGEX REPLACE "," "" executable "${executable}")
STRING(REGEX REPLACE "${executable},|${executable}" "" trimmed "${tempfiles}")
set(tempfiles ${trimmed})
IF(EXISTS ${c_source_dir}/${executable}.c)
ADD_EXECUTABLE(${executable} ${c_source_dir}/${executable}.c)
ENDIF(EXISTS ${c_source_dir}/${executable}.c)
GET_PROPERTY(c_dependencies GLOBAL PROPERTY C_TEST_DEPENDENCIES)
GET_PROPERTY(c_ldpath GLOBAL PROPERTY C_TEST_LDPATH)
GET_PROPERTY(c_path GLOBAL PROPERTY C_TEST_PATH)
TARGET_LINK_LIBRARIES(${executable} ${c_dependencies})
# Take care of windowisims
IF(WIN32)
SET_TARGET_PROPERTIES(${executable} PROPERTIES
PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${c_binary_dir}
LIBRARY_OUTPUT_DIRECTORY ${c_binary_dir}
ARCHIVE_OUTPUT_DIRECTORY ${c_binary_dir})
IF("${c_path}" STREQUAL "")
SET(c_path ${c_ldpath})
ENDIF("${c_path}" STREQUAL "")
ENDIF(WIN32)
ENDWHILE(NOT "${tempfiles}" STREQUAL "")
SET_CORE("${c_binary_dir}")
ADD_TEST(C${is_core}_${script} ${CMAKE_COMMAND}
-D "EXECUTABLE='./${script}'"
-D "ARGUMENTS=${arguments}"
-D "LDPATH=${c_ldpath}"
-D "PATH=${c_path}"
-D "SEPARATOR=${sep}"
-P "${c_binary_dir}/TestDriverC.cmake"
)
IF(NOT "${tdep}" STREQUAL "")
SET_TESTS_PROPERTIES(C${is_core}_${script}
PROPERTIES DEPENDS ${tdep} ${script})
ENDIF(NOT "${tdep}" STREQUAL "")
file(COPY
${c_source_dir}/${script}
DESTINATION ${c_binary_dir}/
)
ENDMACRO(ADD_MPI_TEST_C script files)
# C Clean Macro
# Author: Brian Panneton
# Description: This macro sets up the c test for a make clean.
# Parameters:
# executable = executable name
# ${ARGN} = files that the executable created
MACRO(CLEAN_TEST_C executable)
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES ${ARGN}
)
ENDMACRO(CLEAN_TEST_C executable)
# Configure the c 'driver' file
CONFIGURE_FILE(${TESTING_SUITE_DIR}/TestingSuite/TestDriverC.cmake.in ${c_binary_dir}/TestDriverC.cmake @ONLY)
......@@ -99,6 +99,73 @@ MACRO(ADD_TEST_CXX executable)
ENDIF(NOT "${tdep}" STREQUAL "")
ENDMACRO(ADD_TEST_CXX executable)
# CXX MPI Test Macro
# Author: Andrew Burns
# Description: This macro builds and adds a script to execute MPI tests.
# Parameters:
# executable = script name
# files = code to be compiled and executed by the script
# tdep = test dependency (Full Test Name with Prefix)
# ${ARGN} = any arguments for the executable
MACRO(ADD_MPI_TEST_CXX script files)
PARSE_TEST_ARGS("${ARGN}")
set(tempfiles ${files})
WHILE(NOT "${tempfiles}" STREQUAL "")
# ${executable}
STRING(REGEX MATCH "([^ ,])+,|([^ ,])+" executable "${tempfiles}")
STRING(REGEX REPLACE "," "" executable "${executable}")
STRING(REGEX REPLACE "${executable},|${executable}" "" trimmed "${tempfiles}")
set(tempfiles ${trimmed})
IF(EXISTS ${cxx_source_dir}/${executable}.cpp)
ADD_EXECUTABLE(${executable} ${cxx_source_dir}/${executable}.cpp)
ENDIF(EXISTS ${cxx_source_dir}/${executable}.cpp)
IF(EXISTS ${cxx_source_dir}/${executable}.cxx)
ADD_EXECUTABLE(${executable} ${cxx_source_dir}/${executable}.cxx)
ENDIF(EXISTS ${cxx_source_dir}/${executable}.cxx)
GET_PROPERTY(cxx_dependencies GLOBAL PROPERTY CXX_TEST_DEPENDENCIES)
GET_PROPERTY(cxx_ldpath GLOBAL PROPERTY CXX_TEST_LDPATH)
GET_PROPERTY(cxx_path GLOBAL PROPERTY CXX_TEST_PATH)
TARGET_LINK_LIBRARIES(${executable} ${cxx_dependencies})
# Take care of windowisims
IF(WIN32)
SET_TARGET_PROPERTIES(${executable} PROPERTIES
PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${cxx_binary_dir}
LIBRARY_OUTPUT_DIRECTORY ${cxx_binary_dir}
ARCHIVE_OUTPUT_DIRECTORY ${cxx_binary_dir})
IF("${cxx_path}" STREQUAL "")
SET(cxx_path ${cxx_ldpath})
ENDIF("${cxx_path}" STREQUAL "")
ENDIF(WIN32)
ENDWHILE(NOT "${tempfiles}" STREQUAL "")
SET_CORE("${cxx_binary_dir}")
ADD_TEST(Cxx${is_core}_${script} ${CMAKE_COMMAND}
-D "EXECUTABLE='./${script}'"
-D "ARGUMENTS=${arguments}"
-D "LDPATH=${cxx_ldpath}"
-D "PATH=${cxx_path}"
-D "SEPARATOR=${sep}"
-P "${cxx_binary_dir}/TestDriverCxx.cmake"
)
IF(NOT "${tdep}" STREQUAL "")
SET_TESTS_PROPERTIES(Cxx${is_core}_${script}
PROPERTIES DEPENDS ${tdep} ${script})
ENDIF(NOT "${tdep}" STREQUAL "")
file(COPY
${cxx_source_dir}/${script}
DESTINATION ${cxx_binary_dir}/
)
ENDMACRO(ADD_MPI_TEST_CXX script files)
# CXX Clean Macro
# Author: Brian Panneton
# Description: This macro sets up the cxx test for a make clean.
......
INCLUDE(TestingSetup)
# We should have one place that points to the fortran source directory and the fortran
# binary directory
SET(fortran_source_dir ${CMAKE_CURRENT_SOURCE_DIR})
SET(fortran_binary_dir ${CMAKE_CURRENT_BINARY_DIR})
# Fortran Add Dependencies Macro
# Author: Brian Panneton
# Description: This macro adds the fortran test dependencies.
# Note: The tests already depend on their own file
# Parameters:
# dependencies = any dependencies needed for fortran tests
MACRO(ADD_TEST_FORTRAN_DEPENDENCIES dependencies)
IF(NOT ("${dependencies}" STREQUAL ""))
SET_PROPERTY(GLOBAL APPEND PROPERTY FORTRAN_TEST_DEPENDENCIES
"${dependencies}"
)
ENDIF(NOT ("${dependencies}" STREQUAL ""))
ENDMACRO(ADD_TEST_FORTRAN_DEPENDENCIES dependencies)
# Fortran Add LDPath Macro
# Author: Brian Panneton
# Description: This macro adds the fortran test ldpaths.
# Parameters:
# ld = any ldpaths needed for fortran tests
MACRO(ADD_TEST_FORTRAN_LDPATH ld)
GET_PROPERTY(ldpath GLOBAL PROPERTY FORTRAN_TEST_LDPATH)
IF("${ld}" STRGREATER "")
SET_PROPERTY(GLOBAL PROPERTY FORTRAN_TEST_LDPATH
"${ldpath}${sep}${ld}"
)
ENDIF("${ld}" STRGREATER "")
ENDMACRO(ADD_TEST_FORTRAN_LDPATH ld)
# Fortran Add Path Macro
# Author: Brian Panneton
# Description: This macro adds the fortran test paths.
# Parameters:
# p = any paths needed for fortran tests
MACRO(ADD_TEST_FORTRAN_PATH p)
GET_PROPERTY(path GLOBAL PROPERTY FORTRAN_TEST_PATH)
IF("${p}" STRGREATER "")
SET_PROPERTY(GLOBAL PROPERTY FORTRAN_TEST_PATH
"${path}${sep}${p}"
)
ENDIF("${p}" STRGREATER "")
ENDMACRO(ADD_TEST_FORTRAN_PATH p)
# Fortran Test Macro
# Author: Brian Panneton
# Description: This macro builds and add the fortran test in one shot.
# Parameters:
# executable = executable name
# dup = duplicate number
# tdep = test dependency (Full Test Name with Prefix)
# ${ARGN} = any arguments for the executable
MACRO(ADD_TEST_FORTRAN executable)
PARSE_TEST_ARGS("${ARGN}")
IF(EXISTS ${fortran_source_dir}/${executable}.f)
ADD_EXECUTABLE(${executable} ${fortran_source_dir}/${executable}.f)
ENDIF(EXISTS ${fortran_source_dir}/${executable}.f)
IF(EXISTS ${fortran_source_dir}/${executable}.f90)
ADD_EXECUTABLE(${executable} ${fortran_source_dir}/${executable}.f90)
ENDIF(EXISTS ${fortran_source_dir}/${executable}.f90)
GET_PROPERTY(fortran_dependencies GLOBAL PROPERTY FORTRAN_TEST_DEPENDENCIES)
GET_PROPERTY(fortran_ldpath GLOBAL PROPERTY FORTRAN_TEST_LDPATH)
GET_PROPERTY(fortran_path GLOBAL PROPERTY FORTRAN_TEST_PATH)
TARGET_LINK_LIBRARIES(${executable}${dup} ${fortran_dependencies})
# Take care of windowisims
IF(WIN32)
SET_TARGET_PROPERTIES(${executable}${dup} PROPERTIES
PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${fortran_binary_dir}
LIBRARY_OUTPUT_DIRECTORY ${fortran_binary_dir}
ARCHIVE_OUTPUT_DIRECTORY ${fortran_binary_dir})
IF("${fortran_path}" STREQUAL "")
SET(fortran_path ${fortran_ldpath})
ENDIF("${fortran_path}" STREQUAL "")
ENDIF(WIN32)
SET_CORE("${fortran_binary_dir}")
ADD_TEST(FORTRAN${is_core}_${executable}${dup} ${CMAKE_COMMAND}
-D "EXECUTABLE=${executable}${dup}"
-D "ARGUMENTS=${arguments}"
-D "LDPATH=${fortran_ldpath}"
-D "PATH=${fortran_path}"
-D "SEPARATOR=${sep}"
-P "${fortran_binary_dir}/TestDriverFortran.cmake"
)
IF(NOT "${tdep}" STREQUAL "")
SET_TESTS_PROPERTIES(FORTRAN${is_core}_${executable}${dup}
PROPERTIES DEPENDS ${tdep})
ENDIF(NOT "${tdep}" STREQUAL "")
ENDMACRO(ADD_TEST_FORTRAN executable)
# Fortran MPI Test Macro
# Author: Andrew Burns
# Description: This macro builds and adds a script to execute MPI tests.
# Parameters:
# executable = script name
# files = code to be compiled and executed by the script
# tdep = test dependency (Full Test Name with Prefix)
# ${ARGN} = any arguments for the executable
MACRO(ADD_MPI_TEST_FORTRAN script files)
PARSE_TEST_ARGS("${ARGN}")
set(tempfiles ${files})
WHILE(NOT "${tempfiles}" STREQUAL "")
# ${executable}
STRING(REGEX MATCH "([^ ,])+,|([^ ,])+" executable "${tempfiles}")
STRING(REGEX REPLACE "," "" executable "${executable}")
STRING(REGEX REPLACE "${executable},|${executable}" "" trimmed "${tempfiles}")
set(tempfiles ${trimmed})
IF(EXISTS ${fortran_source_dir}/${executable}.f)
ADD_EXECUTABLE(${executable} ${fortran_source_dir}/${executable}.f)
ENDIF(EXISTS ${fortran_source_dir}/${executable}.f)
IF(EXISTS ${fortran_source_dir}/${executable}.f90)
ADD_EXECUTABLE(${executable} ${fortran_source_dir}/${executable}.f90)
ENDIF(EXISTS ${fortran_source_dir}/${executable}.f90)
GET_PROPERTY(fortran_dependencies GLOBAL PROPERTY FORTRAN_TEST_DEPENDENCIES)
GET_PROPERTY(fortran_ldpath GLOBAL PROPERTY FORTRAN_TEST_LDPATH)
GET_PROPERTY(fortran_path GLOBAL PROPERTY FORTRAN_TEST_PATH)
TARGET_LINK_LIBRARIES(${executable} ${fortran_dependencies})
# Take care of windowisims
IF(WIN32)
SET_TARGET_PROPERTIES(${executable} PROPERTIES
PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${fortran_binary_dir}
LIBRARY_OUTPUT_DIRECTORY ${fortran_binary_dir}
ARCHIVE_OUTPUT_DIRECTORY ${fortran_binary_dir})
IF("${fortran_path}" STREQUAL "")
SET(fortran_path ${fortran_ldpath})
ENDIF("${fortran_path}" STREQUAL "")
ENDIF(WIN32)
ENDWHILE(NOT "${tempfiles}" STREQUAL "")
SET_CORE("${fortran_binary_dir}")
ADD_TEST(FORTRAN${is_core}_${script} ${CMAKE_COMMAND}
-D "EXECUTABLE='./${script}'"
-D "ARGUMENTS=${arguments}"
-D "LDPATH=${fortran_ldpath}"
-D "PATH=${fortran_path}"
-D "SEPARATOR=${sep}"
-P "${fortran_binary_dir}/TestDriverFortran.cmake"
)
IF(NOT "${tdep}" STREQUAL "")
SET_TESTS_PROPERTIES(FORTRAN${is_core}_${script}
PROPERTIES DEPENDS ${tdep} ${script})
ENDIF(NOT "${tdep}" STREQUAL "")
file(COPY
${fortran_source_dir}/${script}
DESTINATION ${fortran_binary_dir}/
)
ENDMACRO(ADD_MPI_TEST_FORTRAN script files)
# Fortran Clean Macro
# Author: Brian Panneton
# Description: This macro sets up the fortran test for a make clean.
# Parameters:
# executable = executable name
# ${ARGN} = files that the executable created
MACRO(CLEAN_TEST_FORTRAN executable)
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES ${ARGN}
)
ENDMACRO(CLEAN_TEST_FORTRAN executable)
# Configure the Fortran 'driver' file
CONFIGURE_FILE(${TESTING_SUITE_DIR}/TestingSuite/TestDriverFortran.cmake.in ${fortran_binary_dir}/TestDriverFortran.cmake @ONLY)
......@@ -133,6 +133,73 @@ MACRO(ADD_TEST_PYTHON executable)
ENDMACRO(ADD_TEST_PYTHON executable)
# PYTHON MPI Test Macro
# Author: Andrew Burns
# Description: This macro builds and adds a script to execute MPI tests.
# Parameters:
# executable = script name
# files = code to be compiled and executed by the script
# tdep = test dependency (Full Test Name with Prefix)
# ${ARGN} = any arguments for the executable
MACRO(ADD_MPI_TEST_PYTHON script files)
PARSE_TEST_ARGS("${ARGN}")
GET_PROPERTY(python_file_dependencies GLOBAL
PROPERTY PYTHON_TEST_FILE_DEPENDENCIES)
GET_PROPERTY(python_pythonpath GLOBAL PROPERTY PYTHON_TEST_PYTHONPATH)
GET_PROPERTY(python_ldpath GLOBAL PROPERTY PYTHON_TEST_LDPATH)
GET_PROPERTY(python_path GLOBAL PROPERTY PYTHON_TEST_PATH)
IF(WIN32)
IF("${python_path}" STREQUAL "")
SET(python_path ${python_ldpath})
ENDIF("${python_path}" STREQUAL "")
ENDIF(WIN32)
set(tempfiles ${files})
WHILE(NOT "${tempfiles}" STREQUAL "")
# ${executable}
STRING(REGEX MATCH "([^ ,])+,|([^ ,])+" executable "${tempfiles}")
STRING(REGEX REPLACE "," "" executable "${executable}")
STRING(REGEX REPLACE "${executable},|${executable}" "" trimmed "${tempfiles}")
set(tempfiles ${trimmed})
IF(EXISTS ${python_source_dir}/${executable}.py)
file(COPY
${python_source_dir}/${executable}.py
DESTINATION ${python_binary_dir}/
)
ENDIF(EXISTS ${python_source_dir}/${executable}.py)
ENDWHILE(NOT "${tempfiles}" STREQUAL "")
SET_CORE("${python_binary_dir}")
ADD_TEST(Python${is_core}_${script} ${CMAKE_COMMAND}
-D "EXECUTABLE='./${script}'"
-D "ARGUMENTS=${arguments}"
-D "PYTHONPATH=${python_pythonpath}"
-D "LDPATH=${python_ldpath}"
-D "PATH=${python_path}"
-D "SEPARATOR=${sep}"
-P "${python_binary_dir}/TestDriverPythonScript.cmake"
)
IF(NOT "${tdep}" STREQUAL "")
SET_TESTS_PROPERTIES(Python${is_core}_${script}}
PROPERTIES DEPENDS ${tdep})
ENDIF(NOT "${tdep}" STREQUAL "")
file(COPY
${python_source_dir}/${script}
DESTINATION ${python_binary_dir}/
)
ENDMACRO(ADD_MPI_TEST_PYTHON script files)
# Python Clean Macro
# Author: Brian Panneton
# Description: This macro sets up the python test for a make clean.
......@@ -176,4 +243,5 @@ ENDMACRO(CREATE_TARGET_TEST_PYTHON)
# Configure the python 'driver' file
CONFIGURE_FILE(${TESTING_SUITE_DIR}/TestingSuite/TestDriverPython.cmake.in ${python_binary_dir}/TestDriverPython.cmake @ONLY)
CONFIGURE_FILE(${TESTING_SUITE_DIR}/TestingSuite/TestDriverPythonScript.cmake.in ${python_binary_dir}/TestDriverPythonScript.cmake @ONLY)
SET(ENV{PATH} "${PATH}${SEPARATOR}$ENV{PATH}")
SET(ENV{LD_LIBRARY_PATH} "${LDPATH}${SEPARATOR}$ENV{LD_LIBRARY_PATH}")
MESSAGE("| Calling:\t${EXECUTABLE} ${ARGUMENTS}")
EXECUTE_PROCESS(
COMMAND ${EXECUTABLE} ${ARGUMENTS}
RESULT_VARIABLE c_result
OUTPUT_VARIABLE c_output
ERROR_VARIABLE c_error
)
MESSAGE("| Call Result:\t${c_result}")
MESSAGE("| Call Output: Begin\n${c_output}")
MESSAGE("| Call Output: End")
IF(c_error)
MESSAGE("| Call Error: Begin\n${c_error}")
MESSAGE("| Call Error: End")
ENDIF(c_error)
MESSAGE("| Call Ended")
MESSAGE("----------------------------------------------------------")
# Let's make sure that if the test failed, it failed with CTest too
IF(c_error)
MESSAGE(SEND_ERROR "Test Failed.")
ENDIF(c_error)
IF(NOT ${c_result} EQUAL "0")
MESSAGE(SEND_ERROR "Test Failed.")
ENDIF(NOT ${c_result} EQUAL "0")
SET(ENV{PATH} "${PATH}${SEPARATOR}$ENV{PATH}")
SET(ENV{LD_LIBRARY_PATH} "${LDPATH}${SEPARATOR}$ENV{LD_LIBRARY_PATH}")
MESSAGE("| Calling:\t${EXECUTABLE} ${ARGUMENTS}")
EXECUTE_PROCESS(
COMMAND ${EXECUTABLE} ${ARGUMENTS}
RESULT_VARIABLE fortran_result
OUTPUT_VARIABLE fortran_output
ERROR_VARIABLE fortran_error
)
MESSAGE("| Call Result:\t${fortran_result}")
MESSAGE("| Call Output: Begin\n${fortran_output}")
MESSAGE("| Call Output: End")
IF(fortran_error)
MESSAGE("| Call Error: Begin\n${fortran_error}")
MESSAGE("| Call Error: End")
ENDIF(fortran_error)
MESSAGE("| Call Ended")
MESSAGE("----------------------------------------------------------")
# Let's make sure that if the test failed, it failed with CTest too
IF(fortran_error)
MESSAGE(SEND_ERROR "Test Failed.")
ENDIF(fortran_error)
IF(NOT ${fortran_result} EQUAL "0")
MESSAGE(SEND_ERROR "Test Failed.")
ENDIF(NOT ${fortran_result} EQUAL "0")
SET(python_runtime "@PYTHON_EXECUTABLE@")
SET(python_binary_dir "@CMAKE_CURRENT_BINARY_DIR@")
SET(ENV{PYTHONPATH} "${PYTHONPATH}${SEPARATOR}$ENV{PYTHONPATH}")
SET(ENV{PATH} "${PATH}${SEPARATOR}$ENV{PATH}")
SET(ENV{LD_LIBRARY_PATH} "${LDPATH}${SEPARATOR}$ENV{LD_LIBRARY_PATH}")
SET(ENV{PYTHON_EXECUTABLE} "${python_runtime}")
MESSAGE("| Calling:\t ${EXECUTABLE} ${ARGUMENTS}")
EXECUTE_PROCESS(
COMMAND "${EXECUTABLE}" ${ARGUMENTS}
WORKING_DIRECTORY "${python_binary_dir}"
RESULT_VARIABLE python_result
OUTPUT_VARIABLE python_output
ERROR_VARIABLE python_error
)
MESSAGE("| Call Result:\t${python_result}")
MESSAGE("| Call Output: Begin\n${python_output}")
MESSAGE("| Call Output: End")
IF(python_error)
MESSAGE("Call Error: Begin\n${python_error}")
MESSAGE("Call Error: End")
ENDIF(python_error)
MESSAGE("| Call Ended")
MESSAGE("----------------------------------------------------------")
# Let's make sure that if the test failed, it failed with CTest too
IF(python_result)
MESSAGE(SEND_ERROR "${python_result}")
ENDIF(python_result)
......@@ -29,6 +29,10 @@
#include "XdmfHDF5Controller.hpp"
#include "XdmfSystemUtils.hpp"
unsigned int XdmfHDF5Controller::mMaxOpenedFiles = 0;
static std::map<std::string, hid_t> mOpenFiles;
std::map<std::string, unsigned int> XdmfHDF5Controller::mOpenFileUsage;
shared_ptr<XdmfHDF5Controller>
XdmfHDF5Controller::New(const std::string & hdf5FilePath,
const std::string & dataSetPath,
......@@ -75,12 +79,30 @@ XdmfHDF5Controller::~XdmfHDF5Controller()
{
}
void
XdmfHDF5Controller::closeFiles()
{
for (std::map<std::string, hid_t>::iterator closeIter = mOpenFiles.begin();
closeIter != mOpenFiles.end();
++closeIter) {
H5Fclose(closeIter->second);
}
mOpenFiles.clear();
mOpenFileUsage.clear();
}
std::string
XdmfHDF5Controller::getName() const
{
return "HDF";
}
unsigned int
XdmfHDF5Controller::getMaxOpenedFiles()
{
return XdmfHDF5Controller::mMaxOpenedFiles;
}
void
XdmfHDF5Controller::read(XdmfArray * const array)
{
......@@ -91,8 +113,39 @@ void
XdmfHDF5Controller::read(XdmfArray * const array, const int fapl)
{
herr_t status;
hid_t hdf5Handle = H5Fopen(mFilePath.c_str(), H5F_ACC_RDONLY, fapl);
hid_t hdf5Handle;
if (XdmfHDF5Controller::mMaxOpenedFiles == 0) {
hdf5Handle = H5Fopen(mFilePath.c_str(), H5F_ACC_RDONLY, fapl);
}
else {
std::map<std::string, hid_t>::iterator checkOpen = mOpenFiles.find(mFilePath);
if (checkOpen == mOpenFiles.end()) {
// If the number of open files would become larger than allowed
if (mOpenFiles.size() + 1 > mMaxOpenedFiles) {
// Close least used one
std::map<std::string, unsigned int>::iterator walker = mOpenFileUsage.begin();
std::string oldestFile = walker->first;
while (walker != mOpenFileUsage.end()) {
// We want the file with the fewest accesses
// If two are tied, we use the older one
if (mOpenFileUsage[oldestFile] > walker->second) {
oldestFile = walker->first;
}
++walker;
}
status = H5Fclose(mOpenFiles[oldestFile]);
mOpenFiles.erase(oldestFile);
mOpenFileUsage.erase(oldestFile);
}
hdf5Handle = H5Fopen(mFilePath.c_str(), H5F_ACC_RDONLY, fapl);
mOpenFiles[mFilePath] = hdf5Handle;
mOpenFileUsage[mFilePath] = 1;
}
else {
hdf5Handle = checkOpen->second;
mOpenFileUsage[mFilePath]++;
}
}
hid_t dataset = H5Dopen(hdf5Handle, mDataSetPath.c_str(), H5P_DEFAULT);
hid_t dataspace = H5Dget_space(dataset);
......@@ -160,7 +213,7 @@ XdmfHDF5Controller::read(XdmfArray * const array, const int fapl)
"Unknown XdmfArrayType encountered in hdf5 "
"controller.");
}
catch (XdmfError e) {
catch (XdmfError & e) {
throw e;
}
}
......@@ -176,25 +229,24 @@ XdmfHDF5Controller::read(XdmfArray * const array, const int fapl)
XdmfError::message(XdmfError::FATAL,
errOut.str());
}
catch (XdmfError e) {
catch (XdmfError & e) {
throw e;
}
}
if(closeDatatype) {
char ** data = new char*[numVals];
status = H5Dread(dataset,
datatype,
status = H5Dread(dataset,