From 289cf31fb4fedba150f1892caf5d90f1343dce32 Mon Sep 17 00:00:00 2001 From: yisangriB Date: Thu, 24 Oct 2024 12:29:55 -0700 Subject: [PATCH 1/2] sy - fixing missing dakota.err error in dcv --- modules/performUQ/SimCenterUQ/UQengine.py | 12 +- .../nataf_gsa/CMakeLists.txtUBUNTU_docker | 189 ++++++++++++++++++ .../performUQ/SimCenterUQ/surrogateBuild.py | 15 +- 3 files changed, 207 insertions(+), 9 deletions(-) create mode 100644 modules/performUQ/SimCenterUQ/nataf_gsa/CMakeLists.txtUBUNTU_docker diff --git a/modules/performUQ/SimCenterUQ/UQengine.py b/modules/performUQ/SimCenterUQ/UQengine.py index 6478d423d..9662105a6 100644 --- a/modules/performUQ/SimCenterUQ/UQengine.py +++ b/modules/performUQ/SimCenterUQ/UQengine.py @@ -79,12 +79,12 @@ def cleanup_workdir(self): # noqa: C901, D102 for del_pkl in del_pkls: os.remove(del_pkl) # noqa: PTH107 - try: - del_errs = glob.glob(os.path.join(self.work_dir, '*err')) # noqa: PTH118, PTH207 - for del_err in del_errs: - os.remove(del_err) # noqa: PTH107 - except: # noqa: S110, E722 - pass + #try: + # del_errs = glob.glob(os.path.join(self.work_dir, '*err')) # noqa: PTH118, PTH207 + # for del_err in del_errs: + # os.remove(del_err) # noqa: PTH107 + #except: # noqa: S110, E722 + # pass if glob.glob(os.path.join(self.work_dir, 'templatedir', 'results.out')): # noqa: PTH118, PTH207 try: diff --git a/modules/performUQ/SimCenterUQ/nataf_gsa/CMakeLists.txtUBUNTU_docker b/modules/performUQ/SimCenterUQ/nataf_gsa/CMakeLists.txtUBUNTU_docker new file mode 100644 index 000000000..293f24488 --- /dev/null +++ b/modules/performUQ/SimCenterUQ/nataf_gsa/CMakeLists.txtUBUNTU_docker @@ -0,0 +1,189 @@ +cmake_minimum_required(VERSION 3.10) + +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + # + # Only for debugging... I need mkl + # + project(nataf_gsa_project) + enable_language(Fortran) + + if(UNIX) + if(NOT APPLE) + set(LINUX TRUE) + endif() + endif() + + + if(LINUX) + set ( PARALLEL_LIB "MPI_RUN") + else() + set ( PARALLEL_LIB "OPENMP_RUN") + endif() + + + # sy- # Find mp package + + if(PARALLEL_LIB STREQUAL "MPI_RUN") + find_package(MPI REQUIRED) + else() + find_package(OpenMP REQUIRED) # Find the package + endif() + + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED True) + + + # sy - optimization flags + #if(MSVC) + # add_compile_options("/W4" "$<$:/O2>") + #endif() + + # sy - to check if filesystem is working + + if(LINUX) + try_compile(HAS_FS "${CMAKE_BINARY_DIR}/temp" + "${CMAKE_SOURCE_DIR}/tmp/has_filesystem.cc" + CMAKE_FLAGS -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON + LINK_LIBRARIES stdc++fs) + if(HAS_FS) + message(STATUS "Compiler has filesystem support") + else() + message(FATAL_ERROR "Compiler is missing filesystem capabilities") + endif(HAS_FS) + endif() + + + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_basic_setup(TARGETS) + + add_subdirectory("${PROJECT_SOURCE_DIR}/ARPACK") + set (ARPACK_LIBRARIES ARPACK) + + # for visual studio, do on commandline: conan install . -s build_type=Debug -if=C:/Users/SimCenter/Sangri/nataf_gsa_cpp_mpi/out/build/x64-Debug/ + + set(SOURCES main.cpp + ERADist.cpp + exponentialDist.cpp + normalDist.cpp + ERANataf.cpp + gammaDist.cpp + runGSA.cpp + runForward.cpp + runMFMC.cpp + RVDist.cpp + gumbelDist.cpp + truncExponentialDist.cpp + betaDist.cpp + jsonInput.cpp + uniformDist.cpp + chiSquaredDist.cpp + lognormalDist.cpp + weibullDist.cpp + discreteDist.cpp + writeErrors.cpp) + + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib_armadillo/armadillo-10.1.0/include) + + if(PARALLEL_LIB STREQUAL "MPI_RUN") + include_directories(${MPI_INCLUDE_PATH}) + add_executable(nataf_gsa ${SOURCES}) + target_link_libraries(nataf_gsa + CONAN_PKG::boost + CONAN_PKG::jsonformoderncpp + CONAN_PKG::nlopt + CONAN_PKG::eigen + CONAN_PKG::mkl-static + ${MPI_LIBRARIES} + stdc++fs + ${ARPACK_LIBRARIES} + ) + add_compile_definitions(MPI_RUN) + + else() + add_executable(nataf_gsa ${SOURCES}) + target_link_libraries(nataf_gsa + CONAN_PKG::boost + CONAN_PKG::jsonformoderncpp + CONAN_PKG::nlopt + CONAN_PKG::eigen + CONAN_PKG::mkl-static + OpenMP::OpenMP_CXX + ${ARPACK_LIBRARIES} + ) + add_compile_definitions(OPENMP_RUN) + endif() + + install(TARGETS nataf_gsa DESTINATION ../..) + #add_compile_definitions($<$:_ITERATOR_DEBUG_LEVEL=0>) + +else() + + ADD_DEFINITIONS("-DBOOST_ALL_NO_LIB") + + # Because we need CXX_STANDARD 17 instead of 14, we don't use simcenter_add_executable() here. + find_package(OpenMP) + if (OpenMP_FOUND) + set (PARALLEL_LIB "OPENMP_RUN") + endif() + + + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED True) + + # for visual studio IDE, do on commandline: conan install . -s build_type=Debug -if=C:/Users/SimCenter/Sangri/SimCenterBackendApplications/modules/performUQ/SimCenterUQ/nataf_gsa/out/build/x64-Debug/ + + set(SOURCES main.cpp + ERADist.cpp + exponentialDist.cpp + normalDist.cpp + ERANataf.cpp + gammaDist.cpp + runGSA.cpp + runForward.cpp + runMFMC.cpp + RVDist.cpp + gumbelDist.cpp + truncExponentialDist.cpp + betaDist.cpp + jsonInput.cpp + uniformDist.cpp + chiSquaredDist.cpp + lognormalDist.cpp + weibullDist.cpp + discreteDist.cpp + writeErrors.cpp) + + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib_armadillo/armadillo-10.1.0/include) + + if(OpenMP_FOUND) + + find_package(LAPACK REQUIRED) + message(STATUS "nataf_gsa: OpenMP") + add_executable(nataf_gsa ${SOURCES}) + target_link_libraries(nataf_gsa + CONAN_PKG::boost + CONAN_PKG::jsonformoderncpp + CONAN_PKG::nlopt + CONAN_PKG::eigen + ${LAPACK_LIBRARIES} + OpenMP::OpenMP_CXX) + + add_definitions(-DOPENMP_RUN) + + else() + + find_package(LAPACK REQUIRED) + message(STATUS "nataf_gsa: no MPI or OpenMP") + add_executable(nataf_gsa ${SOURCES}) + target_link_libraries(nataf_gsa + CONAN_PKG::boost + CONAN_PKG::jsonformoderncpp + CONAN_PKG::nlopt + CONAN_PKG::eigen + ${LAPACK_LIBRARIES}) + + endif() + + install(TARGETS nataf_gsa DESTINATION ${PROJECT_SOURCE_DIR}/applications/performUQ/SimCenterUQ) + +endif() diff --git a/modules/performUQ/SimCenterUQ/surrogateBuild.py b/modules/performUQ/SimCenterUQ/surrogateBuild.py index 8bc55ae10..a4853a3e0 100644 --- a/modules/performUQ/SimCenterUQ/surrogateBuild.py +++ b/modules/performUQ/SimCenterUQ/surrogateBuild.py @@ -86,17 +86,26 @@ print('Failed to import module:' + moduleName) # noqa: T201 -errFileName = os.path.join(os.getcwd(),'dakota.err') # noqa: N816 -develop_mode = (len(sys.argv)==7) # a flag for develeopmode + +print("Initializing error log file..") +print(f"Current working dir (getcwd): {os.getcwd()}") + +work_dir_tmp = sys.argv[1].replace(os.sep, '/') +errFileName = os.path.join(work_dir_tmp,'dakota.err') # noqa: N816 + +develop_mode = (len(sys.argv)==8) # a flag for develeopmode if develop_mode: # import matplotlib # matplotlib.use('TkAgg') import matplotlib.pyplot as plt - print("developer mode") + print("Developer mode") else: with open(errFileName, 'w') as f: f.write("") sys.stderr = open(errFileName, 'w') # noqa: SIM115, PTH123 + print(f"Error file created at: {errFileName}") + + # # Modify GPy package From d5d50b60b3126f50974fc9a277fcc4579e2d8276 Mon Sep 17 00:00:00 2001 From: yisangriB Date: Thu, 24 Oct 2024 12:31:51 -0700 Subject: [PATCH 2/2] sy - removing something that was just added by mistake --- .../nataf_gsa/CMakeLists.txtUBUNTU_docker | 189 ------------------ 1 file changed, 189 deletions(-) delete mode 100644 modules/performUQ/SimCenterUQ/nataf_gsa/CMakeLists.txtUBUNTU_docker diff --git a/modules/performUQ/SimCenterUQ/nataf_gsa/CMakeLists.txtUBUNTU_docker b/modules/performUQ/SimCenterUQ/nataf_gsa/CMakeLists.txtUBUNTU_docker deleted file mode 100644 index 293f24488..000000000 --- a/modules/performUQ/SimCenterUQ/nataf_gsa/CMakeLists.txtUBUNTU_docker +++ /dev/null @@ -1,189 +0,0 @@ -cmake_minimum_required(VERSION 3.10) - -if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - # - # Only for debugging... I need mkl - # - project(nataf_gsa_project) - enable_language(Fortran) - - if(UNIX) - if(NOT APPLE) - set(LINUX TRUE) - endif() - endif() - - - if(LINUX) - set ( PARALLEL_LIB "MPI_RUN") - else() - set ( PARALLEL_LIB "OPENMP_RUN") - endif() - - - # sy- # Find mp package - - if(PARALLEL_LIB STREQUAL "MPI_RUN") - find_package(MPI REQUIRED) - else() - find_package(OpenMP REQUIRED) # Find the package - endif() - - set(CMAKE_CXX_STANDARD 17) - set(CMAKE_CXX_STANDARD_REQUIRED True) - - - # sy - optimization flags - #if(MSVC) - # add_compile_options("/W4" "$<$:/O2>") - #endif() - - # sy - to check if filesystem is working - - if(LINUX) - try_compile(HAS_FS "${CMAKE_BINARY_DIR}/temp" - "${CMAKE_SOURCE_DIR}/tmp/has_filesystem.cc" - CMAKE_FLAGS -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON - LINK_LIBRARIES stdc++fs) - if(HAS_FS) - message(STATUS "Compiler has filesystem support") - else() - message(FATAL_ERROR "Compiler is missing filesystem capabilities") - endif(HAS_FS) - endif() - - - include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - conan_basic_setup(TARGETS) - - add_subdirectory("${PROJECT_SOURCE_DIR}/ARPACK") - set (ARPACK_LIBRARIES ARPACK) - - # for visual studio, do on commandline: conan install . -s build_type=Debug -if=C:/Users/SimCenter/Sangri/nataf_gsa_cpp_mpi/out/build/x64-Debug/ - - set(SOURCES main.cpp - ERADist.cpp - exponentialDist.cpp - normalDist.cpp - ERANataf.cpp - gammaDist.cpp - runGSA.cpp - runForward.cpp - runMFMC.cpp - RVDist.cpp - gumbelDist.cpp - truncExponentialDist.cpp - betaDist.cpp - jsonInput.cpp - uniformDist.cpp - chiSquaredDist.cpp - lognormalDist.cpp - weibullDist.cpp - discreteDist.cpp - writeErrors.cpp) - - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib_armadillo/armadillo-10.1.0/include) - - if(PARALLEL_LIB STREQUAL "MPI_RUN") - include_directories(${MPI_INCLUDE_PATH}) - add_executable(nataf_gsa ${SOURCES}) - target_link_libraries(nataf_gsa - CONAN_PKG::boost - CONAN_PKG::jsonformoderncpp - CONAN_PKG::nlopt - CONAN_PKG::eigen - CONAN_PKG::mkl-static - ${MPI_LIBRARIES} - stdc++fs - ${ARPACK_LIBRARIES} - ) - add_compile_definitions(MPI_RUN) - - else() - add_executable(nataf_gsa ${SOURCES}) - target_link_libraries(nataf_gsa - CONAN_PKG::boost - CONAN_PKG::jsonformoderncpp - CONAN_PKG::nlopt - CONAN_PKG::eigen - CONAN_PKG::mkl-static - OpenMP::OpenMP_CXX - ${ARPACK_LIBRARIES} - ) - add_compile_definitions(OPENMP_RUN) - endif() - - install(TARGETS nataf_gsa DESTINATION ../..) - #add_compile_definitions($<$:_ITERATOR_DEBUG_LEVEL=0>) - -else() - - ADD_DEFINITIONS("-DBOOST_ALL_NO_LIB") - - # Because we need CXX_STANDARD 17 instead of 14, we don't use simcenter_add_executable() here. - find_package(OpenMP) - if (OpenMP_FOUND) - set (PARALLEL_LIB "OPENMP_RUN") - endif() - - - set(CMAKE_CXX_STANDARD 17) - set(CMAKE_CXX_STANDARD_REQUIRED True) - - # for visual studio IDE, do on commandline: conan install . -s build_type=Debug -if=C:/Users/SimCenter/Sangri/SimCenterBackendApplications/modules/performUQ/SimCenterUQ/nataf_gsa/out/build/x64-Debug/ - - set(SOURCES main.cpp - ERADist.cpp - exponentialDist.cpp - normalDist.cpp - ERANataf.cpp - gammaDist.cpp - runGSA.cpp - runForward.cpp - runMFMC.cpp - RVDist.cpp - gumbelDist.cpp - truncExponentialDist.cpp - betaDist.cpp - jsonInput.cpp - uniformDist.cpp - chiSquaredDist.cpp - lognormalDist.cpp - weibullDist.cpp - discreteDist.cpp - writeErrors.cpp) - - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib_armadillo/armadillo-10.1.0/include) - - if(OpenMP_FOUND) - - find_package(LAPACK REQUIRED) - message(STATUS "nataf_gsa: OpenMP") - add_executable(nataf_gsa ${SOURCES}) - target_link_libraries(nataf_gsa - CONAN_PKG::boost - CONAN_PKG::jsonformoderncpp - CONAN_PKG::nlopt - CONAN_PKG::eigen - ${LAPACK_LIBRARIES} - OpenMP::OpenMP_CXX) - - add_definitions(-DOPENMP_RUN) - - else() - - find_package(LAPACK REQUIRED) - message(STATUS "nataf_gsa: no MPI or OpenMP") - add_executable(nataf_gsa ${SOURCES}) - target_link_libraries(nataf_gsa - CONAN_PKG::boost - CONAN_PKG::jsonformoderncpp - CONAN_PKG::nlopt - CONAN_PKG::eigen - ${LAPACK_LIBRARIES}) - - endif() - - install(TARGETS nataf_gsa DESTINATION ${PROJECT_SOURCE_DIR}/applications/performUQ/SimCenterUQ) - -endif()