From f6439bdf33e26560bf0c5da9241f14d4ed430169 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 22 Jan 2015 18:33:17 -0500 Subject: [PATCH 1/8] fixed petsc version 3.4 and 3.5 compatibility --- src/solver_interface.F90 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/solver_interface.F90 b/src/solver_interface.F90 index 043b3fd116..3f9580bf3a 100644 --- a/src/solver_interface.F90 +++ b/src/solver_interface.F90 @@ -7,6 +7,8 @@ module solver_interface #ifdef PETSC use petscksp use petscsnes +# include +# include #endif implicit none @@ -67,6 +69,11 @@ module solver_interface #ifdef PETSC integer :: petsc_err ! petsc error code +# if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR <= 4) + PetscReal :: PETSC_DEFAULT_DOUBLE = PETSC_DEFAULT_DOUBLE_PRECISION +# else + PetscReal :: PETSC_DEFAULT_DOUBLE = PETSC_DEFAULT_REAL +# endif #endif contains @@ -86,7 +93,7 @@ contains call KSPCreate(PETSC_COMM_WORLD, self % ksp_, petsc_err) call KSPSetTolerances(self % ksp_, rtol, atol, & - PETSC_DEFAULT_DOUBLE_PRECISION, PETSC_DEFAULT_INTEGER, petsc_err) + PETSC_DEFAULT_DOUBLE, PETSC_DEFAULT_INTEGER, petsc_err) call KSPSetType(self % ksp_, 'gmres', petsc_err) call KSPSetInitialGuessNonzero(self % ksp_, PETSC_TRUE, petsc_err) call KSPGetPC(self % ksp_, self % pc_, petsc_err) From b82c3798033d08dc32b01ecb9ce3209c0f4095d9 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 22 Jan 2015 18:43:05 -0500 Subject: [PATCH 2/8] updated libraries to latest version --- tests/run_tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/run_tests.py b/tests/run_tests.py index cad3731e2a..661f8c50a4 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -42,10 +42,10 @@ parser.add_option("-s", "--script", action="store_true", dest="script", # Default compiler paths FC='gfortran' -MPI_DIR='/opt/mpich/3.1-gnu' -HDF5_DIR='/opt/hdf5/1.8.12-gnu' -PHDF5_DIR='/opt/phdf5/1.8.12-gnu' -PETSC_DIR='/opt/petsc/3.4.4-gnu' +MPI_DIR='/opt/mpich/3.1.3-gnu' +HDF5_DIR='/opt/hdf5/1.8.14-gnu' +PHDF5_DIR='/opt/phdf5/1.8.14-gnu' +PETSC_DIR='/opt/petsc/3.5.2-gnu' # Script mode for extra capability script_mode = False From 111f9feed1eacd5d99bdcf2a8c39c8b74b615ca0 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 22 Jan 2015 18:47:40 -0500 Subject: [PATCH 3/8] added comment for petsc version checking of default real --- src/solver_interface.F90 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/solver_interface.F90 b/src/solver_interface.F90 index 3f9580bf3a..2cb881802f 100644 --- a/src/solver_interface.F90 +++ b/src/solver_interface.F90 @@ -69,11 +69,17 @@ module solver_interface #ifdef PETSC integer :: petsc_err ! petsc error code + +! This handles the variable change from PETSc 3.4 to PETSc 3.5 +! Developers should use PETSC_DEFAULT_DOUBLE when they want to +! use PETSC_DEFAULT_REAL so that we have compatiblity with +! PETSc < 3.5. # if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR <= 4) PetscReal :: PETSC_DEFAULT_DOUBLE = PETSC_DEFAULT_DOUBLE_PRECISION # else PetscReal :: PETSC_DEFAULT_DOUBLE = PETSC_DEFAULT_REAL # endif + #endif contains From 561dbc367b239388d82a0d9367dab3ae2f5fb45c Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 22 Jan 2015 19:48:05 -0500 Subject: [PATCH 4/8] removed unused variable size_offset_kind from write_source_bank --- src/output_interface.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/src/output_interface.F90 b/src/output_interface.F90 index fc31b8307b..d8134aa583 100644 --- a/src/output_interface.F90 +++ b/src/output_interface.F90 @@ -1942,7 +1942,6 @@ contains #ifdef MPI # ifndef HDF5 integer(MPI_OFFSET_KIND) :: offset ! offset of data - integer :: size_offset_kind ! the data offset kind integer :: size_bank ! size of bank to write integer :: datatype # endif From 58552c2ae9acafb769e07cbc59aa0ccb07c4c1f8 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 22 Jan 2015 19:56:28 -0500 Subject: [PATCH 5/8] fixed indentation of PETSC_DOUBLE variable --- src/solver_interface.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/solver_interface.F90 b/src/solver_interface.F90 index 2cb881802f..5f5dbb4467 100644 --- a/src/solver_interface.F90 +++ b/src/solver_interface.F90 @@ -75,9 +75,9 @@ module solver_interface ! use PETSC_DEFAULT_REAL so that we have compatiblity with ! PETSc < 3.5. # if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR <= 4) - PetscReal :: PETSC_DEFAULT_DOUBLE = PETSC_DEFAULT_DOUBLE_PRECISION + PetscReal :: PETSC_DEFAULT_DOUBLE = PETSC_DEFAULT_DOUBLE_PRECISION # else - PetscReal :: PETSC_DEFAULT_DOUBLE = PETSC_DEFAULT_REAL + PetscReal :: PETSC_DEFAULT_DOUBLE = PETSC_DEFAULT_REAL # endif #endif From 3d5270d1dbf57a0cb7fe4a97b4bb809cd50198a1 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Fri, 23 Jan 2015 23:27:03 -0500 Subject: [PATCH 6/8] removed MatStructure argument in KSPSetOperators and Jacobian user routine --- src/solver_interface.F90 | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/solver_interface.F90 b/src/solver_interface.F90 index 5f5dbb4467..9673684063 100644 --- a/src/solver_interface.F90 +++ b/src/solver_interface.F90 @@ -7,7 +7,6 @@ module solver_interface #ifdef PETSC use petscksp use petscsnes -# include # include #endif @@ -70,16 +69,10 @@ module solver_interface #ifdef PETSC integer :: petsc_err ! petsc error code -! This handles the variable change from PETSc 3.4 to PETSc 3.5 -! Developers should use PETSC_DEFAULT_DOUBLE when they want to -! use PETSC_DEFAULT_REAL so that we have compatiblity with -! PETSc < 3.5. -# if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR <= 4) - PetscReal :: PETSC_DEFAULT_DOUBLE = PETSC_DEFAULT_DOUBLE_PRECISION -# else - PetscReal :: PETSC_DEFAULT_DOUBLE = PETSC_DEFAULT_REAL +! Checks for PETSc version to handle 3.5 changes +# if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR > 4) +# define PETSC_GREATER_34 # endif - #endif contains @@ -98,8 +91,13 @@ contains real(8) :: atol = 1.0e-10_8 call KSPCreate(PETSC_COMM_WORLD, self % ksp_, petsc_err) +#ifdef PETSC_GREATER_34 call KSPSetTolerances(self % ksp_, rtol, atol, & - PETSC_DEFAULT_DOUBLE, PETSC_DEFAULT_INTEGER, petsc_err) + PETSC_DEFAULT_REAL, PETSC_DEFAULT_INTEGER, petsc_err) +#else + call KSPSetTolerances(self % ksp_, rtol, atol, & + PETSC_DEFAULT_DOUBLE_PRECISION, PETSC_DEFAULT_INTEGER, petsc_err) +#endif call KSPSetType(self % ksp_, 'gmres', petsc_err) call KSPSetInitialGuessNonzero(self % ksp_, PETSC_TRUE, petsc_err) call KSPGetPC(self % ksp_, self % pc_, petsc_err) @@ -118,8 +116,13 @@ contains type(Matrix), intent(inout) :: prec_mat ! preconditioner matrix type(Matrix), intent(inout) :: mat_in ! coefficient matrix +#ifdef PETSC_GREATER_34 + call KSPSetOperators(self % ksp_, mat_in % petsc_mat, prec_mat % petsc_mat, & + petsc_err) +#else call KSPSetOperators(self % ksp_, mat_in % petsc_mat, prec_mat % petsc_mat, & SAME_NONZERO_PATTERN, petsc_err) +#endif call KSPSetUp(self % ksp_, petsc_err) end subroutine petsc_gmres_set_oper @@ -272,17 +275,25 @@ contains ! PETSC_JFNK_COMPUTE_JACOBIAN buffer routine to user specified jacobian routine !=============================================================================== +#ifdef PETSC_GREATER_34 + subroutine petsc_jfnk_compute_jacobian(snes_, x, jac_mf, jac_prec, & + ctx, ierr) +#else subroutine petsc_jfnk_compute_jacobian(snes_, x, jac_mf, jac_prec, flag, & ctx, ierr) +#endif type(snes), intent(inout) :: snes_ ! PETSc snes instance type(vec), intent(inout) :: x ! PETSc solution vector type(mat), intent(inout) :: jac_mf ! PETSc matrix free jacobian type(mat), intent(inout) :: jac_prec ! PETSc matrix jacobian precond. - integer, intent(inout) :: flag ! unused madatory flag type(Jfnk_ctx), intent(inout) :: ctx ! JFNK context instance integer, intent(inout) :: ierr ! error code +#ifndef PETSC_GREATER_34 + integer, intent(inout) :: flag ! unused madatory flag +#endif + type(Vector) :: xvec ! solution vector ! Again, we use the vector that comes from Petsc to build the Jacobian From 2e906f454bc431251f176c1573728ff2f5a621d1 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Fri, 30 Jan 2015 15:03:05 -0500 Subject: [PATCH 7/8] added libssl and libcrypto manually to PETSC libs --- src/CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d2c4a6064d..06c044e42c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -195,6 +195,20 @@ if(petsc) list(INSERT PETSC_PACKAGE_LIBS 0 ${PETSC_RT_LIB}) endif() + # If libssl wasn't found, search /usr/lib64 + if(PETSC_SSL_LIB STREQUAL "PETSC_SSL_LIB-NOTFOUND") + find_library(PETSC_SSL_LIB libssl.so /usr/lib64) + list(REMOVE_ITEM PETSC_PACKAGE_LIBS PETSC_SSL_LIB-NOTFOUND) + list(INSERT PETSC_PACKAGE_LIBS 0 ${PETSC_SSL_LIB}) + endif() + + # If libcrypto wasn't found, search /usr/lib64 + if(PETSC_CRYPTO_LIB STREQUAL "PETSC_CRYPTO_LIB-NOTFOUND") + find_library(PETSC_CRYPTO_LIB libcrypto.so /usr/lib64) + list(REMOVE_ITEM PETSC_PACKAGE_LIBS PETSC_CRYPTO_LIB-NOTFOUND) + list(INSERT PETSC_PACKAGE_LIBS 0 ${PETSC_CRYPTO_LIB}) + endif() + message("-- Using PETSC: ${libpetsc}") add_definitions(-DPETSC) include_directories($ENV{PETSC_DIR}/include) From 42f8cd0d85bf67ab952fc8e0fef2eac493d973dc Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 30 Jan 2015 20:49:12 -0500 Subject: [PATCH 8/8] Remove unused variable in output_interface module. --- src/output_interface.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/src/output_interface.F90 b/src/output_interface.F90 index fc31b8307b..d8134aa583 100644 --- a/src/output_interface.F90 +++ b/src/output_interface.F90 @@ -1942,7 +1942,6 @@ contains #ifdef MPI # ifndef HDF5 integer(MPI_OFFSET_KIND) :: offset ! offset of data - integer :: size_offset_kind ! the data offset kind integer :: size_bank ! size of bank to write integer :: datatype # endif