diff --git a/.github/workflows/windows-latest-intel.yml b/.github/workflows/windows-latest-intel.yml new file mode 100644 index 0000000000..88b263c6b9 --- /dev/null +++ b/.github/workflows/windows-latest-intel.yml @@ -0,0 +1,50 @@ +name: Build and Test - Windows/intel/ninja (short) + +on: + pull_request: + merge_group: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build_and_test: + runs-on: windows-latest + + steps: + - uses: fortran-lang/setup-fortran@v1 + id: setup-fortran + with: + compiler: intel + version: '2023.2' + + - name: Install Ninja + run: choco install ninja + + - uses: actions/checkout@v3 + + - name: Configure CMake (Static) + run: cmake -G "Ninja" -B ${{github.workspace}}/build_static -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_FLAGS=-Wno-deprecated-declarations -DCMAKE_C_COMPILER=icx-cl -DCMAKE_CXX_COMPILER=icx-cl -DCMAKE_Fortran_COMPILER=ifx -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_FORTRAN_MODULE_INTERFACE=ON -DSUNDIALS_BUILD_WITH_PROFILING=ON -DSUNDIALS_TEST_UNITTESTS=OFF -DEXAMPLES_ENABLE_CXX=ON + + - name: Build (Static) + run: cmake --build ${{github.workspace}}/build_static --verbose + + - name: Test (Static) + working-directory: ${{github.workspace}}/build_static + run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure + + - name: Configure CMake (Shared) + run: cmake -G "Ninja" -B ${{github.workspace}}/build_shared -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_FLAGS=-Wno-deprecated-declarations -DCMAKE_C_COMPILER=icx-cl -DCMAKE_CXX_COMPILER=icx-cl -DCMAKE_Fortran_COMPILER=ifx -DBUILD_STATIC_LIBS=OFF -DBUILD_SHARED_LIBS=ON -DBUILD_FORTRAN_MODULE_INTERFACE=ON -DSUNDIALS_BUILD_WITH_PROFILING=ON -DSUNDIALS_TEST_UNITTESTS=OFF -DEXAMPLES_ENABLE_CXX=ON + + - name: Build (Shared) + run: cmake --build ${{github.workspace}}/build_shared --verbose + + - name: Test (Shared) + working-directory: ${{github.workspace}}/build_shared + run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure diff --git a/.github/workflows/windows-latest-mingw.yml b/.github/workflows/windows-latest-mingw.yml index 49974e4e30..5a714b5133 100644 --- a/.github/workflows/windows-latest-mingw.yml +++ b/.github/workflows/windows-latest-mingw.yml @@ -10,7 +10,6 @@ concurrency: cancel-in-progress: true env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Release jobs: @@ -42,27 +41,59 @@ jobs: install: >- base-devel ${{ matrix.target-prefix }}-cmake - ${{ matrix.target-prefix }}-cc + ${{ matrix.target-prefix }}-gcc + ${{ matrix.target-prefix }}-gcc-fortran ${{ matrix.target-prefix }}-openblas ${{ matrix.target-prefix }}-suitesparse - - name: Configure CMake + - name: Configure CMake (Static) # Configure CMake in a 'build' subdirectory run: | cmake \ - -B ${GITHUB_WORKSPACE}/build \ + -G "MSYS Makefiles" \ + -B ${GITHUB_WORKSPACE}/build_static \ -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -DCMAKE_C_FLAGS=-Wno-deprecated-declarations \ + -DBUILD_FORTRAN_MODULE_INTERFACE=ON \ + -DBUILD_SHARED_LIBS=OFF \ -DSUNDIALS_BUILD_WITH_PROFILING=ON \ -DSUNDIALS_LOGGING_LEVEL=2 \ -DSUNDIALS_TEST_UNITTESTS=OFF \ -DEXAMPLES_ENABLE_CXX=ON \ -DENABLE_KLU=ON - - name: Build + - name: Build (Static) # Build program - run: cmake --build ${GITHUB_WORKSPACE}/build + run: cmake --build ${GITHUB_WORKSPACE}/build_static --verbose - - name: Test - working-directory: ${{github.workspace}}/build + - name: Test (Static) + working-directory: ${{github.workspace}}/build_static # Execute tests - run: ctest + run: ctest --output-on-failure + + # TODO(CJB): shared libraries with the fortran interfaces turned on + # fail to link correctly with this toolchain see https://github.com/LLNL/sundials/issues/507. + - name: Configure CMake (Shared) + # Configure CMake in a 'build' subdirectory + run: | + cmake \ + -G "MSYS Makefiles" \ + -B ${GITHUB_WORKSPACE}/build_shared \ + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -DCMAKE_C_FLAGS=-Wno-deprecated-declarations \ + -DBUILD_FORTRAN_MODULE_INTERFACE=OFF \ + -DBUILD_STATIC_LIBS=OFF \ + -DSUNDIALS_BUILD_WITH_PROFILING=ON \ + -DSUNDIALS_LOGGING_LEVEL=2 \ + -DSUNDIALS_TEST_UNITTESTS=OFF \ + -DEXAMPLES_ENABLE_CXX=ON \ + -DENABLE_KLU=ON + + - name: Build (Shared) + # Build program + run: cmake --build ${GITHUB_WORKSPACE}/build_shared --verbose + + - name: Test (Shared) + working-directory: ${{github.workspace}}/build_shared + # Execute tests + run: ctest --output-on-failure diff --git a/.github/workflows/windows-latest.yml b/.github/workflows/windows-latest.yml index ccfa6c2251..aa45f757c0 100644 --- a/.github/workflows/windows-latest.yml +++ b/.github/workflows/windows-latest.yml @@ -10,7 +10,6 @@ concurrency: cancel-in-progress: true env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Release jobs: @@ -21,16 +20,11 @@ jobs: - uses: actions/checkout@v3 - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_STATIC_LIBS=OFF -DSUNDIALS_BUILD_WITH_PROFILING=ON -DSUNDIALS_LOGGING_LEVEL=2 -DSUNDIALS_TEST_UNITTESTS=ON -DEXAMPLES_ENABLE_CXX=ON + run: cmake -G "Visual Studio 17 2022" -B ${{github.workspace}}/build -DSUNDIALS_BUILD_WITH_PROFILING=ON -DSUNDIALS_TEST_UNITTESTS=ON -DEXAMPLES_ENABLE_CXX=ON - name: Build - # Build your program with the given configuration - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --verbose - name: Test working-directory: ${{github.workspace}}/build - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest -C ${{env.BUILD_TYPE}} + run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure diff --git a/CHANGELOG.md b/CHANGELOG.md index d85d47def6..3b94e65798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -117,6 +117,8 @@ Fix bug on LLP64 platforms (like Windows 64-bit) where `KLU_INDEXTYPE` could be Check if size of `SuiteSparse_long` is 8 if the size of `sunindextype` is 8 when using KLU. +Fixed several build errors with the Fortran interfaces on Windows systems. + ### Deprecation Notices Numerous ARKODE stepper-specific functions are now deprecated in favor of diff --git a/cmake/SundialsBuildOptionsPre.cmake b/cmake/SundialsBuildOptionsPre.cmake index a9a3df9ea0..b78212e720 100644 --- a/cmake/SundialsBuildOptionsPre.cmake +++ b/cmake/SundialsBuildOptionsPre.cmake @@ -119,7 +119,7 @@ sundials_option(BUILD_SHARED_LIBS BOOL "Build shared libraries" ON) # Make sure we build at least one type of libraries if(NOT BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS) - print_error("Both static and shared library generation were disabled.") + message(FATAL_ERROR "Both static and shared library generation were disabled.") endif() # --------------------------------------------------------------- diff --git a/cmake/SundialsSetupFortran.cmake b/cmake/SundialsSetupFortran.cmake index 2e6e8c4de0..1daee0b7b2 100644 --- a/cmake/SundialsSetupFortran.cmake +++ b/cmake/SundialsSetupFortran.cmake @@ -19,25 +19,6 @@ # Fortran 2003 standard # --------------------------------------------------------------- -# If the Fortran compiler flags are set using environemnt variables (i.e., -# CMAKE_Fortran_FLAGS is not set), then check if both FFLAGS and FCFLAGS are -# set. If both are set and not the same then a fatal error occurs. -# -# NOTE: This check must occur before 'enable_language(Fortran)' as it will use -# the value of FFLAGS to set CMAKE_Fortran_FLAGS -set(ENV_FFLAGS "$ENV{FFLAGS}") -set(ENV_FCFLAGS "$ENV{FCFLAGS}") - -# check if environment variables are used and CMAKE_Fortran_FLAGS is not -if ((NOT "${ENV_FFLAGS}" STREQUAL "") AND (NOT "${ENV_FCFLAGS}" STREQUAL "") - AND ("${CMAKE_Fortran_FLAGS}" STREQUAL "")) - - # check if environment variables are equal - if (NOT "${ENV_FFLAGS}" STREQUAL "${ENV_FCFLAGS}") - print_error("FFLAGS='${ENV_FFLAGS}' and FCFLAGS='${ENV_FCFLAGS}' are both set but are not equal.") - endif() -endif() - # ----------------------------------------------------------------------------- # Enable Fortran # ----------------------------------------------------------------------------- diff --git a/cmake/macros/SundialsAddLibrary.cmake b/cmake/macros/SundialsAddLibrary.cmake index d8be54aac8..199f790e66 100644 --- a/cmake/macros/SundialsAddLibrary.cmake +++ b/cmake/macros/SundialsAddLibrary.cmake @@ -150,7 +150,7 @@ macro(sundials_add_library target) # -------------------------------------------------------------------------- # create the target for the object library - add_library(${obj_target} OBJECT ${sources}) + add_library(${obj_target} OBJECT ${sources} ${sundials_add_library_UNPARSED_ARGUMENTS}) set_target_properties(${obj_target} PROPERTIES FOLDER "obj") @@ -173,6 +173,19 @@ macro(sundials_add_library target) else() set(_all_libs ${sundials_add_library_LINK_LIBRARIES}) endif() + # Due to various issues in CMake, particularly https://gitlab.kitware.com/cmake/cmake/-/issues/25365, + # we create a fake custom target to enforce a build order. Without this, parallel builds + # might fail with an error about a missing '.mod' file when Fortran is enabled (see GitHub #410). + set(_stripped_all_libs ${_all_libs}) + list(FILTER _stripped_all_libs EXCLUDE REGEX "PUBLIC|INTERFACE|PRIVATE") + foreach(_item ${_stripped_all_libs}) + if(NOT TARGET ${_item}) + list(REMOVE_ITEM _stripped_all_libs ${_item}) + endif() + endforeach() + add_custom_target(fake_to_force_build_order_${obj_target}) + add_dependencies(fake_to_force_build_order_${obj_target} ${_stripped_all_libs}) + add_dependencies(${obj_target} fake_to_force_build_order_${obj_target}) target_link_libraries(${obj_target} ${_all_libs}) endif() @@ -239,11 +252,7 @@ macro(sundials_add_library target) # set target name set(_actual_target_name ${target}${_lib_suffix}) - add_library(${_actual_target_name} ${_libtype} $) - - set_target_properties(${_actual_target_name} PROPERTIES FOLDER "src") - - # add any object library dependencies + set(_object_sources $) if(sundials_add_library_OBJECT_LIBRARIES) if(${_libtype} MATCHES "STATIC") append_static_suffix(sundials_add_library_OBJECT_LIBRARIES _all_objs) @@ -251,13 +260,14 @@ macro(sundials_add_library target) set(_all_objs ${sundials_add_library_OBJECT_LIBRARIES}) endif() foreach(_tmp ${_all_objs}) - # We use target_sources since target_link_libraries does not work - # as expected with CMake 3.12 (see CMake issues 18090 and 18692). - # TODO(DJG): Update whenever we require CMake 3.14 or newer - target_sources(${_actual_target_name} PRIVATE $) + list(APPEND _object_sources $) endforeach() endif() + add_library(${_actual_target_name} ${_libtype} ${_object_sources} ${sundials_add_library_UNPARSED_ARGUMENTS}) + + set_target_properties(${_actual_target_name} PROPERTIES FOLDER "src") + # add all link libraries if(SUNDIALS_MATH_LIBRARY) target_link_libraries(${_actual_target_name} PRIVATE "${SUNDIALS_MATH_LIBRARY}") @@ -426,34 +436,41 @@ macro(sundials_add_f2003_library target) cmake_parse_arguments(sundials_add_f2003_library "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - # set target properties and target dependencies so that includes - # and links get passed on when this target is used if(CMAKE_Fortran_MODULE_DIRECTORY) set(_includes PUBLIC $ $ ) - set(_properties PROPERTIES Fortran_MODULE_DIRECTORY "${CMAKE_Fortran_MODULE_DIRECTORY}_{{libtype}}") + set(_properties PROPERTIES + Fortran_MODULE_DIRECTORY "${CMAKE_Fortran_MODULE_DIRECTORY}_{{libtype}}" + WINDOWS_EXPORT_ALL_SYMBOLS ON) else() set(_includes PUBLIC $ $ ) - set(_properties PROPERTIES Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir") + set(_properties PROPERTIES + Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir" + WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() # get the name of the C library which the fortran library interfaces to string(REPLACE "sundials_f" "sundials_" _clib_name "${target}") string(REPLACE "_mod" "" _clib_name "${_clib_name}") + if(TARGET ${_clib_name}) + set(_clib_target ${_clib_name}) + else() + set(_clib_target ) + endif() sundials_add_library(${target} SOURCES ${sundials_add_f2003_library_SOURCES} OBJECT_LIBRARIES ${sundials_add_f2003_library_OBJECT_LIBRARIES} LINK_LIBRARIES + PUBLIC ${_clib_target} # depend on the c library ${sundials_add_f2003_library_LINK_LIBRARIES} - PUBLIC ${_clib_name} # depend on the c library INCLUDE_DIRECTORIES ${sundials_add_f2003_library_INCLUDE_DIRECTORIES} ${_includes} @@ -466,7 +483,6 @@ macro(sundials_add_f2003_library target) SOVERSION ${sundials_add_f2003_library_SOVERSION} ${sundials_add_f2003_library_UNPARSED_ARGUMENTS} ) - endmacro() diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index ef32fa2bbb..adc2691e7b 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -116,6 +116,8 @@ Fix bug on LLP64 platforms (like Windows 64-bit) where ``KLU_INDEXTYPE`` could b Check if size of ``SuiteSparse_long`` is 8 if the size of ``sunindextype`` is 8 when using KLU. +Fixed several build errors with the Fortran interfaces on Windows systems. + **Deprecation Notices** Numerous ARKODE stepper-specific functions are now deprecated in favor of diff --git a/doc/shared/sundials/Fortran.rst b/doc/shared/sundials/Fortran.rst index cb483b2733..fbb6fdc0c4 100644 --- a/doc/shared/sundials/Fortran.rst +++ b/doc/shared/sundials/Fortran.rst @@ -557,8 +557,7 @@ Important notes on portability ------------------------------ The SUNDIALS Fortran 2003 interface *should* be compatible with any compiler -supporting the Fortran 2003 ISO standard. However, it has only been tested and -confirmed to be working with GNU Fortran 4.9+ and Intel Fortran 18.0.1+. +supporting the Fortran 2003 ISO standard. Upon compilation of SUNDIALS, Fortran module (``.mod``) files are generated for each Fortran 2003 interface. These files are highly compiler specific, and thus diff --git a/doc/shared/sundials/Install.rst b/doc/shared/sundials/Install.rst index f1ed3c80a8..b11ecd9621 100644 --- a/doc/shared/sundials/Install.rst +++ b/doc/shared/sundials/Install.rst @@ -294,8 +294,8 @@ default configuration: .. _Installation.CMake.Options: -Configuration options (Unix/Linux) ------------------------------------ +Configuration options +--------------------- A complete list of all available options for a CMake-based SUNDIALS configuration is provide below. Note that the default values shown @@ -590,6 +590,11 @@ illustration only. Default: ``OFF`` + .. warning:: There is a known issue with MSYS/gfortran and SUNDIALS shared libraries + that causes linking the Fortran interfaces to fail when buidling SUNDIALS. For + now the work around is to only build with static libraries when using MSYS with + gfortran on Windows. + .. cmakeoption:: SUNDIALS_LOGGING_LEVEL Set the maximum logging level for the SUNLogger runtime API. The higher this is set, @@ -669,7 +674,7 @@ illustration only. Default: "REF;OMP" - .. versionchanged: x.y.z + .. versionchanged: x.y.z The ``DPCPP`` option was changed to ``SYCL`` to align with Ginkgo's naming convention. @@ -1704,7 +1709,7 @@ header files. without any notice and relying on them may break your code. -Using SUNDIALS in your prpject +Using SUNDIALS in your project ------------------------------ After building and installing SUNDIALS, using SUNDIALS in your application involves diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a342a109eb..55b1e52db4 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -17,9 +17,9 @@ # We need this to ensure the installed templates have MPI when ENABLE_MPI=TRUE, # at least until we convert all of the templates to use the SUNDIALS CMake target. -# =============================================================== +# =================================================================== # Configure compilers for installed examples -# =============================================================== +# =================================================================== foreach(lang ${_SUNDIALS_ENABLED_LANGS}) if(ENABLE_MPI) @@ -37,7 +37,13 @@ if(ENABLE_ALL_WARNINGS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") endif() +# Initialize CMAKE_Fortran_MODULE_DIRECTORY for examples +set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + +# =================================================================== # Set variables used in generating CMake and Makefiles for examples +# =================================================================== + if(EXAMPLES_INSTALL) set(SHELL "sh") @@ -95,9 +101,9 @@ if(EXAMPLES_INSTALL) endif() -#---------------------------------------- +# =================================================================== # Add specific examples -#---------------------------------------- +# =================================================================== # Add ARKode examples if(BUILD_ARKODE) diff --git a/examples/arkode/F2003_custom/CMakeLists.txt b/examples/arkode/F2003_custom/CMakeLists.txt index 7aac6173a6..98abe2d887 100644 --- a/examples/arkode/F2003_custom/CMakeLists.txt +++ b/examples/arkode/F2003_custom/CMakeLists.txt @@ -56,7 +56,7 @@ foreach(example_tuple ${FARKODE_examples}) list(GET example_tuple 0 example) list(GET example_tuple 1 example_type) - # Install fortran modules to a unique directory to avoid naming collisions + # build fortran modules into a unique directory to avoid naming collisions set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) # example source files diff --git a/examples/arkode/F2003_custom/ark_analytic_complex_f2003.f90 b/examples/arkode/F2003_custom/ark_analytic_complex_f2003.f90 index 4a0a8a5911..83e9ac1fbf 100644 --- a/examples/arkode/F2003_custom/ark_analytic_complex_f2003.f90 +++ b/examples/arkode/F2003_custom/ark_analytic_complex_f2003.f90 @@ -39,7 +39,7 @@ module ode_mod !======= Declarations ========= implicit none - integer(c_long), parameter :: neq = 1 + integer(c_int64_t), parameter :: neq = 1 integer(c_int), parameter :: Nt = 10 complex(c_double_complex), parameter :: lambda = (-1d-2, 10.d0) real(c_double), parameter :: T0 = 0.d0 diff --git a/examples/arkode/F2003_custom/ark_brusselator1D_f2003.f90 b/examples/arkode/F2003_custom/ark_brusselator1D_f2003.f90 index 579d70479c..c195ce2d12 100644 --- a/examples/arkode/F2003_custom/ark_brusselator1D_f2003.f90 +++ b/examples/arkode/F2003_custom/ark_brusselator1D_f2003.f90 @@ -51,10 +51,10 @@ module ode_mod !======= Declarations ========= implicit none - integer(c_long), parameter :: N = 201 ! number of intervals + integer(c_int64_t), parameter :: N = 201 ! number of intervals integer(c_long), parameter :: Nt = 100 ! total number of output times - integer(c_long), parameter :: Nvar = 3 ! number of solution fields - integer(c_long), parameter :: neq = N*Nvar ! total size of solution vector + integer(c_int64_t), parameter :: Nvar = 3 ! number of solution fields + integer(c_int64_t), parameter :: neq = N*Nvar ! total size of solution vector real(c_double), parameter :: dx = 1.d0/(N-1) ! mesh spacing real(c_double), parameter :: a = 0.6d0 ! constant forcing on u real(c_double), parameter :: b = 2.d0 ! steady-state value of w @@ -97,7 +97,7 @@ integer(c_int) function RhsImplicit(tn, sunvec_y, sunvec_f, user_data) & ! local variables type(FVec), pointer :: y, f ! ptrs to Fortran vector data real(c_double) :: u, v, w - integer(c_long) :: i + integer(c_int64_t) :: i !======= Internals ============ @@ -161,7 +161,7 @@ integer(c_int) function RhsExplicit(tn, sunvec_y, sunvec_f, user_data) & ! local variables type(FVec), pointer :: y, f ! ptrs to Fortran vector data real(c_double) :: dconst(3) - integer(c_long) :: i, j + integer(c_int64_t) :: i, j !======= Internals ============ @@ -221,7 +221,7 @@ integer(c_int) function JacFn(tn, sunvec_y, sunvec_f, sunmat_J, & type(FVec), pointer :: y, f ! ptrs to Fortran vector data type(FMat), pointer :: J ! ptr to Fortran matrix data real(c_double) :: u, v, w - integer(c_long) :: i + integer(c_int64_t) :: i !======= Internals ============ diff --git a/examples/arkode/F2003_custom/fnvector_complex_mod.f90 b/examples/arkode/F2003_custom/fnvector_complex_mod.f90 index 5a4ce4548a..e762a3858d 100644 --- a/examples/arkode/F2003_custom/fnvector_complex_mod.f90 +++ b/examples/arkode/F2003_custom/fnvector_complex_mod.f90 @@ -24,7 +24,7 @@ module fnvector_complex_mod ! ---------------------------------------------------------------- type, public :: FVec logical :: own_data - integer(c_long) :: len + integer(c_int64_t) :: len complex(c_double_complex), pointer :: data(:) end type FVec ! ---------------------------------------------------------------- @@ -35,7 +35,7 @@ module fnvector_complex_mod function FN_VNew_Complex(n, sunctx) result(sunvec_y) implicit none - integer(c_long), value :: n + integer(c_int64_t), value :: n type(c_ptr), value :: sunctx type(N_Vector), pointer :: sunvec_y type(N_Vector_Ops), pointer :: ops @@ -88,7 +88,7 @@ end function FN_VNew_Complex function FN_VMake_Complex(n, data, sunctx) result(sunvec_y) implicit none - integer(c_long), value :: n + integer(c_int64_t), value :: n type(c_ptr), value :: sunctx type(N_Vector), pointer :: sunvec_y type(N_Vector_Ops), pointer :: ops @@ -191,7 +191,7 @@ subroutine FN_VDestroy_Complex(sunvec_y) bind(C) end subroutine FN_VDestroy_Complex ! ---------------------------------------------------------------- - integer(c_long) function FN_VGetLength_Complex(sunvec_y) & + integer(c_int64_t) function FN_VGetLength_Complex(sunvec_y) & bind(C) result(length) implicit none @@ -456,7 +456,7 @@ real(c_double) function FN_VWSqrSumMask_Complex(sunvec_x, sunvec_w, sunvec_id) & type(N_Vector) :: sunvec_w type(N_Vector) :: sunvec_id type(FVec), pointer :: x, w, id - integer(c_long) :: i + integer(c_int64_t) :: i ! extract Fortran vector structures to work with x => FN_VGetFVec(sunvec_x) @@ -571,7 +571,7 @@ integer(c_int) function FN_VInvTest_Complex(sunvec_x, sunvec_z) & type(N_Vector) :: sunvec_x type(N_Vector) :: sunvec_z type(FVec), pointer :: x, z - integer(c_long) :: i + integer(c_int64_t) :: i ! extract Fortran vector structures to work with x => FN_VGetFVec(sunvec_x) diff --git a/examples/arkode/F2003_custom/fnvector_fortran_mod.f90 b/examples/arkode/F2003_custom/fnvector_fortran_mod.f90 index 1f4b2851bc..3264f75a5d 100644 --- a/examples/arkode/F2003_custom/fnvector_fortran_mod.f90 +++ b/examples/arkode/F2003_custom/fnvector_fortran_mod.f90 @@ -25,8 +25,8 @@ module fnvector_fortran_mod ! ---------------------------------------------------------------- type, public :: FVec logical :: own_data - integer(c_long) :: length1 - integer(c_long) :: length2 + integer(c_int64_t) :: length1 + integer(c_int64_t) :: length2 real(c_double), pointer :: data(:,:) end type FVec ! ---------------------------------------------------------------- @@ -36,8 +36,8 @@ module fnvector_fortran_mod ! ---------------------------------------------------------------- function FN_VNew_Fortran(n1, n2, sunctx) result(sunvec_y) implicit none - integer(c_long), value :: n1 - integer(c_long), value :: n2 + integer(c_int64_t), value :: n1 + integer(c_int64_t), value :: n2 type(c_ptr), value :: sunctx type(N_Vector), pointer :: sunvec_y type(N_Vector_Ops), pointer :: ops @@ -97,8 +97,8 @@ end function FN_VNew_Fortran ! ---------------------------------------------------------------- function FN_VMake_Fortran(n1, n2, data, sunctx) result(sunvec_y) implicit none - integer(c_long), value :: n1 - integer(c_long), value :: n2 + integer(c_int64_t), value :: n1 + integer(c_int64_t), value :: n2 type(c_ptr), value :: sunctx type(N_Vector), pointer :: sunvec_y type(N_Vector_Ops), pointer :: ops @@ -206,7 +206,7 @@ subroutine FN_VDestroy_Fortran(sunvec_y) bind(C) end subroutine FN_VDestroy_Fortran ! ---------------------------------------------------------------- - integer(c_long) function FN_VGetLength_Fortran(sunvec_y) & + integer(c_int64_t) function FN_VGetLength_Fortran(sunvec_y) & bind(C) result(length) implicit none @@ -480,7 +480,7 @@ real(c_double) function FN_VWSqrSumMask_Fortran(sunvec_x, sunvec_w, sunvec_id) & type(N_Vector) :: sunvec_w type(N_Vector) :: sunvec_id type(FVec), pointer :: x, w, id - integer(c_long) :: i, j + integer(c_int64_t) :: i, j ! extract Fortran vector structures to work with x => FN_VGetFVec(sunvec_x) @@ -596,7 +596,7 @@ subroutine FN_VCompare_Fortran(c, sunvec_x, sunvec_z) bind(C) type(N_Vector) :: sunvec_x type(N_Vector) :: sunvec_z type(FVec), pointer :: x, z - integer(c_long) :: i, j + integer(c_int64_t) :: i, j ! extract Fortran vector structures to work with x => FN_VGetFVec(sunvec_x) @@ -624,7 +624,7 @@ integer(c_int) function FN_VInvTest_Fortran(sunvec_x, sunvec_z) & type(N_Vector) :: sunvec_x type(N_Vector) :: sunvec_z type(FVec), pointer :: x, z - integer(c_long) :: i, j + integer(c_int64_t) :: i, j ! extract Fortran vector structures to work with x => FN_VGetFVec(sunvec_x) @@ -654,7 +654,7 @@ integer(c_int) function FN_VConstrMask_Fortran(sunvec_c, sunvec_x, sunvec_m) & type(N_Vector) :: sunvec_x type(N_Vector) :: sunvec_m type(FVec), pointer :: c, x, m - integer(c_long) :: i, j + integer(c_int64_t) :: i, j logical :: test ! extract Fortran vector structures to work with @@ -692,7 +692,7 @@ real(c_double) function FN_VMinQuotient_Fortran(sunvec_n, sunvec_d) & type(N_Vector) :: sunvec_n type(N_Vector) :: sunvec_d type(FVec), pointer :: n, d - integer(c_long) :: i, j + integer(c_int64_t) :: i, j logical :: notEvenOnce ! extract Fortran vector structures to work with diff --git a/examples/arkode/F2003_custom/fsunlinsol_fortran_mod.f90 b/examples/arkode/F2003_custom/fsunlinsol_fortran_mod.f90 index 6939fa2795..9da06d3ea9 100644 --- a/examples/arkode/F2003_custom/fsunlinsol_fortran_mod.f90 +++ b/examples/arkode/F2003_custom/fsunlinsol_fortran_mod.f90 @@ -30,9 +30,9 @@ module fsunlinsol_fortran_mod ! ---------------------------------------------------------------- type, public :: FLinSol - integer(c_long) :: Nvar - integer(c_long) :: N - integer(c_long), allocatable :: pivots(:,:) + integer(c_int64_t) :: Nvar + integer(c_int64_t) :: N + integer(c_int64_t), allocatable :: pivots(:,:) end type FLinSol ! ---------------------------------------------------------------- @@ -42,8 +42,8 @@ module fsunlinsol_fortran_mod function FSUNLinSolNew_Fortran(Nvar, N, sunctx) result(sunls_S) implicit none - integer(c_long), value :: Nvar - integer(c_long), value :: N + integer(c_int64_t), value :: Nvar + integer(c_int64_t), value :: N type(c_ptr), value :: sunctx type(SUNLinearSolver), pointer :: sunls_S type(SUNLinearSolver_Ops), pointer :: ops @@ -135,7 +135,7 @@ integer(c_int) function FSUNLinSolSetup_Fortran(sunls_S, sunmat_A) & type(SUNMatrix) :: sunmat_A type(FLinSol), pointer :: S type(FMat), pointer :: AMat - integer(c_long) :: i, j, k, l + integer(c_int64_t) :: i, j, k, l real(c_double) :: temp real(c_double), pointer :: A(:,:) @@ -214,7 +214,7 @@ integer(c_int) function FSUNLinSolSolve_Fortran(sunls_S, sunmat_A, & type(FLinSol), pointer :: S type(FMat), pointer :: AMat type(FVec), pointer :: xvec, bvec - integer(c_long) :: i, k, pk + integer(c_int64_t) :: i, k, pk real(c_double) :: temp real(c_double), pointer :: A(:,:), x(:) diff --git a/examples/arkode/F2003_custom/fsunmatrix_fortran_mod.f90 b/examples/arkode/F2003_custom/fsunmatrix_fortran_mod.f90 index 88dfd5710d..7d6b397e99 100644 --- a/examples/arkode/F2003_custom/fsunmatrix_fortran_mod.f90 +++ b/examples/arkode/F2003_custom/fsunmatrix_fortran_mod.f90 @@ -30,8 +30,8 @@ module fsunmatrix_fortran_mod ! ---------------------------------------------------------------- type, public :: FMat logical :: own_data - integer(c_long) :: Nvar - integer(c_long) :: N + integer(c_int64_t) :: Nvar + integer(c_int64_t) :: N real(c_double), pointer :: data(:,:,:) end type FMat ! ---------------------------------------------------------------- @@ -42,8 +42,8 @@ module fsunmatrix_fortran_mod function FSUNMatNew_Fortran(Nvar, N, sunctx) result(sunmat_A) implicit none - integer(c_long), value :: Nvar - integer(c_long), value :: N + integer(c_int64_t), value :: Nvar + integer(c_int64_t), value :: N type(c_ptr), value :: sunctx type(SUNMatrix), pointer :: sunmat_A type(SUNMatrix_Ops), pointer :: ops @@ -236,7 +236,7 @@ integer(c_int) function FSUNMatScaleAddI_Fortran(c, sunmat_A) & real(c_double), value :: c type(SUNMatrix) :: sunmat_A type(FMat), pointer :: A - integer(c_long) :: i, j, k + integer(c_int64_t) :: i, j, k ! extract Fortran matrix structure to work with A => FSUNMatGetFMat(sunmat_A) @@ -267,7 +267,7 @@ integer(c_int) function FSUNMatMatvec_Fortran(sunmat_A, sunvec_x, sunvec_y) & type(N_Vector) :: sunvec_y type(FMat), pointer :: A type(FVec), pointer :: x, y - integer(c_long) :: i + integer(c_int64_t) :: i ! extract Fortran matrix and vector structures to work with A => FSUNMatGetFMat(sunmat_A) diff --git a/examples/arkode/F2003_custom/test_fnvector_complex_mod.f90 b/examples/arkode/F2003_custom/test_fnvector_complex_mod.f90 index 28c5bb0410..b9cec621a6 100644 --- a/examples/arkode/F2003_custom/test_fnvector_complex_mod.f90 +++ b/examples/arkode/F2003_custom/test_fnvector_complex_mod.f90 @@ -29,10 +29,10 @@ integer(c_int) function check_ans(val, tol, N, sunvec_x) result(failure) implicit none complex(c_double_complex), value :: val real(c_double), value :: tol - integer(c_long), value :: N + integer(c_int64_t), value :: N Type(N_Vector) :: sunvec_x Type(FVec), pointer :: x - integer(c_long) :: i + integer(c_int64_t) :: i x => FN_VGetFVec(sunvec_x) failure = 0 @@ -58,7 +58,7 @@ program main ! local variables type(c_ptr) :: sunctx integer(c_int) :: fails, i, loc - integer(c_long), parameter :: N = 1000 + integer(c_int64_t), parameter :: N = 1000 type(N_Vector), pointer :: sU, sV, sW, sX, sY, sZ type(FVec), pointer :: U, V, W, X, Y, Z complex(c_double_complex) :: Udata(N) diff --git a/examples/arkode/F2003_custom/test_fnvector_fortran_mod.f90 b/examples/arkode/F2003_custom/test_fnvector_fortran_mod.f90 index 148f95212b..ac6e69c9d6 100644 --- a/examples/arkode/F2003_custom/test_fnvector_fortran_mod.f90 +++ b/examples/arkode/F2003_custom/test_fnvector_fortran_mod.f90 @@ -28,10 +28,10 @@ integer(c_int) function check_ans(val, tol, Nvar, N, sunvec_x) result(failure) implicit none real(c_double), value :: val, tol - integer(c_long), value :: Nvar, N + integer(c_int64_t), value :: Nvar, N Type(N_Vector) :: sunvec_x Type(FVec), pointer :: x - integer(c_long) :: i, j + integer(c_int64_t) :: i, j x => FN_VGetFVec(sunvec_x) failure = 0 @@ -59,9 +59,9 @@ program main ! local variables type(c_ptr) :: sunctx integer(c_int) :: fails - integer(c_long) :: i, j, loc - integer(c_long), parameter :: N = 1000 - integer(c_long), parameter :: Nvar = 10 + integer(c_int64_t) :: i, j, loc + integer(c_int64_t), parameter :: N = 1000 + integer(c_int64_t), parameter :: Nvar = 10 type(N_Vector), pointer :: sU, sV, sW, sX, sY, sZ type(FVec), pointer :: U, V, W, X, Y, Z real(c_double), allocatable :: Udata(:,:) diff --git a/examples/arkode/F2003_custom/test_fsunlinsol_fortran_mod.f90 b/examples/arkode/F2003_custom/test_fsunlinsol_fortran_mod.f90 index 508a1c74a3..15752897ce 100644 --- a/examples/arkode/F2003_custom/test_fsunlinsol_fortran_mod.f90 +++ b/examples/arkode/F2003_custom/test_fsunlinsol_fortran_mod.f90 @@ -31,10 +31,10 @@ integer(c_int) function check_vector(sunvec_x, sunvec_y, tol, Nvar, N) result(fa implicit none real(c_double), value :: tol - integer(c_long), value :: Nvar, N + integer(c_int64_t), value :: Nvar, N Type(N_Vector) :: sunvec_x, sunvec_y Type(FVec), pointer :: x, y - integer(c_long) :: i, j + integer(c_int64_t) :: i, j x => FN_VGetFVec(sunvec_x) y => FN_VGetFVec(sunvec_y) @@ -82,8 +82,8 @@ program main ! local variables type(c_ptr) :: sunctx integer(c_int) :: fails, retval, j, k - integer(c_long), parameter :: N = 1000 - integer(c_long), parameter :: Nvar = 50 + integer(c_int64_t), parameter :: N = 1000 + integer(c_int64_t), parameter :: Nvar = 50 type(SUNMatrix), pointer :: sA type(FMat), pointer :: A type(SUNLinearSolver), pointer :: LS diff --git a/examples/arkode/F2003_custom/test_fsunmatrix_fortran_mod.f90 b/examples/arkode/F2003_custom/test_fsunmatrix_fortran_mod.f90 index 740db810e1..da5fe15966 100644 --- a/examples/arkode/F2003_custom/test_fsunmatrix_fortran_mod.f90 +++ b/examples/arkode/F2003_custom/test_fsunmatrix_fortran_mod.f90 @@ -30,10 +30,10 @@ integer(c_int) function check_matrix(sunmat_A, sunmat_B, tol, Nvar, N) result(fa implicit none real(c_double), value :: tol - integer(c_long), value :: Nvar, N + integer(c_int64_t), value :: Nvar, N Type(SUNMatrix) :: sunmat_A, sunmat_B Type(FMat), pointer :: A, B - integer(c_long) :: i, j, k + integer(c_int64_t) :: i, j, k A => FSUNMatGetFMat(sunmat_A) B => FSUNMatGetFMat(sunmat_B) @@ -53,10 +53,10 @@ integer(c_int) function check_matrix_entry(sunmat_A, val, tol, Nvar, N) result(f implicit none real(c_double), value :: tol, val - integer(c_long), value :: Nvar, N + integer(c_int64_t), value :: Nvar, N Type(SUNMatrix) :: sunmat_A Type(FMat), pointer :: A - integer(c_long) :: i, j, k + integer(c_int64_t) :: i, j, k A => FSUNMatGetFMat(sunmat_A) failure = 0 @@ -75,10 +75,10 @@ integer(c_int) function check_vector(sunvec_x, sunvec_y, tol, Nvar, N) result(fa implicit none real(c_double), value :: tol - integer(c_long), value :: Nvar, N + integer(c_int64_t), value :: Nvar, N Type(N_Vector) :: sunvec_x, sunvec_y Type(FVec), pointer :: x, y - integer(c_long) :: i, j + integer(c_int64_t) :: i, j x => FN_VGetFVec(sunvec_x) y => FN_VGetFVec(sunvec_y) @@ -127,8 +127,8 @@ program main ! local variables type(c_ptr) :: sunctx integer(c_int) :: fails, retval, i, j, k - integer(c_long), parameter :: N = 1000 - integer(c_long), parameter :: Nvar = 50 + integer(c_int64_t), parameter :: N = 1000 + integer(c_int64_t), parameter :: Nvar = 50 type(SUNMatrix), pointer :: sA, sB, sC, sD, sI type(FMat), pointer :: A, Eye type(N_Vector), pointer :: sW, sX, sY, sZ diff --git a/examples/arkode/F2003_parallel/ark_diag_kry_bbd_f2003.f90 b/examples/arkode/F2003_parallel/ark_diag_kry_bbd_f2003.f90 index 7cf6efd0f9..c7b25afe86 100644 --- a/examples/arkode/F2003_parallel/ark_diag_kry_bbd_f2003.f90 +++ b/examples/arkode/F2003_parallel/ark_diag_kry_bbd_f2003.f90 @@ -53,8 +53,8 @@ module DiagkryData ! Problem parameters integer(c_int), parameter :: iGStype = 1 integer(c_int), parameter :: iPretype0 = 1 - integer(c_long), parameter :: nlocal = 10 - integer(c_long) :: neq, mu, ml, mudq, mldq + integer(c_int64_t), parameter :: nlocal = 10 + integer(c_int64_t) :: neq, mu, ml, mudq, mldq integer(c_int) :: iPretype real(c_double) :: alpha @@ -118,7 +118,7 @@ integer(c_int) function LocalgFn(nnlocal, t, sunvec_y, sunvec_g, user_data) & ! calling variables real(c_double), value :: t ! current time - integer(c_long) :: nnlocal ! local space + integer(c_int64_t) :: nnlocal ! local space type(N_Vector) :: sunvec_y ! solution N_Vector type(N_Vector) :: sunvec_g ! output g N_Vector type(c_ptr), value :: user_data ! user-defined data diff --git a/examples/arkode/F2003_parallel/ark_diag_non_f2003.f90 b/examples/arkode/F2003_parallel/ark_diag_non_f2003.f90 index edfcf0d3b5..e05da275b0 100644 --- a/examples/arkode/F2003_parallel/ark_diag_non_f2003.f90 +++ b/examples/arkode/F2003_parallel/ark_diag_non_f2003.f90 @@ -46,8 +46,8 @@ module DiagnonData integer :: nprocs ! total number of MPI processes ! Problem parameters - integer(c_long), parameter :: nlocal = 2 - integer(c_long) :: neq + integer(c_int64_t), parameter :: nlocal = 2 + integer(c_int64_t) :: neq real(c_double) :: alpha contains diff --git a/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 b/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 index a58e0ad2d8..e8c53d66cd 100644 --- a/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 +++ b/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 @@ -671,7 +671,7 @@ program driver type(SUNLinearSolver), pointer :: sun_LS ! linear solver type(SUNMatrix), pointer :: sunmat_A ! sundials matrix type(c_ptr) :: arkode_mem ! ARKODE memory - integer(c_long) :: N, Ntot + integer(c_int64_t) :: N, Ntot integer(c_int) :: retval integer :: ierr logical :: outproc diff --git a/examples/arkode/F2003_serial/CMakeLists.txt b/examples/arkode/F2003_serial/CMakeLists.txt index 2268891857..f755a4695b 100644 --- a/examples/arkode/F2003_serial/CMakeLists.txt +++ b/examples/arkode/F2003_serial/CMakeLists.txt @@ -73,6 +73,9 @@ foreach(example_tuple ${FARKODE_examples}) list(GET example_tuple 2 example_type) if (NOT TARGET ${example}) + # Install fortran modules to a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90) @@ -81,9 +84,6 @@ foreach(example_tuple ${FARKODE_examples}) # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS}) - - # Install fortran modules to a unique directory to avoid naming collisions - set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) endif() # check if example args are provided and set the test name @@ -125,11 +125,12 @@ if(BUILD_SUNLINSOL_KLU) list(GET example_tuple 0 example) list(GET example_tuple 1 example_type) - # example source files - add_executable(${example} ${example}.f90) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # create the cmake executable target + add_executable(${example} ${example}.f90) set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) # add example to regression tests sundials_add_test(${example} ${example} @@ -140,7 +141,7 @@ if(BUILD_SUNLINSOL_KLU) # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLKLU_LIBS}) - # install example source and out files + # install example source and out files if(EXAMPLES_INSTALL) install(FILES ${example}.f90 ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F2003_serial) @@ -168,6 +169,9 @@ if(BUILD_SUNLINSOL_LAPACKDENSE) list(GET example_tuple 0 example) list(GET example_tuple 1 example_type) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90) diff --git a/examples/arkode/F2003_serial/ark_bruss1D_FEM_klu_f2003.f90 b/examples/arkode/F2003_serial/ark_bruss1D_FEM_klu_f2003.f90 index f272a56644..80908e0127 100644 --- a/examples/arkode/F2003_serial/ark_bruss1D_FEM_klu_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_bruss1D_FEM_klu_f2003.f90 @@ -71,12 +71,12 @@ module Bruss1DFEMKLU_UserData implicit none ! number of equations - integer(c_int), parameter :: neqreal = 3 + integer(c_int64_t), parameter :: neqreal = 3 ! ODE parameters - integer(c_int), parameter :: N = 201 ! number of intervals - integer(c_int), parameter :: neq = neqreal*N ! set overall problem size - integer(c_int), parameter :: nnz = 15*neq + integer(c_int64_t), parameter :: N = 201 ! number of intervals + integer(c_int64_t), parameter :: neq = neqreal*N ! set overall problem size + integer(c_int64_t), parameter :: nnz = 15*neq real(c_double), parameter :: a = 0.6d0 ! constant forcing on u real(c_double), parameter :: b = 2.d0 ! steady-state value of w real(c_double), parameter :: du = 2.5d-2 ! diffusion coeff for u @@ -89,8 +89,9 @@ module Bruss1DFEMKLU_UserData ! function that maps 2D data into 1D address space ! (0-based since CSR matrix will be sent to C solver) - integer(c_int) function idx(ix, ivar) - integer(c_int) :: ivar, ix + integer(c_int64_t) function idx(ix, ivar) + integer(c_int64_t):: ix + integer(c_int) :: ivar idx = neqreal*(ix - 1) + ivar - 1 end function idx @@ -210,7 +211,7 @@ integer(c_int) function ImpRhsFn(tn, sunvec_y, sunvec_f, user_data) & type(c_ptr), value :: user_data ! user-defined data ! Local data - integer(c_int) :: ix + integer(c_int64_t) :: ix logical :: left, right real(c_double) :: ul, ur, vl, vr, wl, wr, xl, xr, u, v, w, f1, f2, f3 @@ -413,7 +414,7 @@ integer(c_int) function Jac(tn, sunvec_y, sunvec_f, sunmat_J, user_data, & type(N_Vector) :: sunvec_t3 ! Local data - integer(c_int) :: ix, nz, Nint + integer(c_int64_t) :: ix, nz, Nint real(c_double) :: ul, uc, ur, vl, vc, vr, wl, wc, wr, xl, xc, xr real(c_double) :: u1, u2, u3, v1, v2, v3, w1, w2, w3 real(c_double) :: df1, df2, df3, dQdf1, dQdf2, dQdf3 @@ -421,8 +422,8 @@ integer(c_int) function Jac(tn, sunvec_y, sunvec_f, sunmat_J, user_data, & real(c_double), dimension(3,-1:1) :: Ju, Jv, Jw ! pointers to data in SUNDIALS vectors - integer(c_long), pointer, dimension(nnz) :: Jcolvals(:) - integer(c_long), pointer, dimension(neq+1) :: Jrowptrs(:) + integer(c_int64_t), pointer, dimension(nnz) :: Jcolvals(:) + integer(c_int64_t), pointer, dimension(neq+1) :: Jrowptrs(:) real(c_double), pointer, dimension(nnz) :: Jdata(:) real(c_double), pointer, dimension(neqreal,N) :: yvec(:,:) real(c_double), pointer, dimension(neqreal,N) :: fvec(:,:) @@ -451,9 +452,9 @@ integer(c_int) function Jac(tn, sunvec_y, sunvec_f, sunmat_J, user_data, & nz = 0 ! Dirichlet boundary at left - Jrowptrs(idx(1,1)+1) = nz - Jrowptrs(idx(1,2)+1) = nz - Jrowptrs(idx(1,3)+1) = nz + Jrowptrs(idx(1_c_int64_t,1)+1) = nz + Jrowptrs(idx(1_c_int64_t,2)+1) = nz + Jrowptrs(idx(1_c_int64_t,3)+1) = nz ! iterate through nodes, filling in matrix by rows do ix=2,N-1 @@ -868,13 +869,13 @@ integer(c_int) function Mass(tn, sunmat_M, user_data, & type(N_Vector) :: sunvec_t3 ! Local data - integer(c_int) :: ix, nz, Nint + integer(c_int64_t) :: ix, nz, Nint real(c_double) :: xl, xc, xr, Ml, Mc, Mr, ChiL1, ChiL2, ChiL3, ChiR1, ChiR2, ChiR3 logical :: left, right ! pointers to data in SUNDIALS vectors - integer(c_long), pointer, dimension(nnz) :: Mcolvals(:) - integer(c_long), pointer, dimension(neq+1) :: Mrowptrs(:) + integer(c_int64_t), pointer, dimension(nnz) :: Mcolvals(:) + integer(c_int64_t), pointer, dimension(neq+1) :: Mrowptrs(:) real(c_double), pointer, dimension(nnz) :: Mdata(:) !======= Internals ============ @@ -1050,7 +1051,7 @@ program main integer(c_int) :: outstep ! output loop counter integer(c_int) :: sparsetype ! CSR signal, here integer(c_long) :: mxsteps ! max num steps - integer :: i + integer(c_int64_t) :: i type(N_Vector), pointer :: sunvec_y ! sundials vector type(N_Vector), pointer :: sunvec_u ! sundials vector @@ -1081,28 +1082,28 @@ program main nout = ceiling(tend/dtout) ! create and assign SUNDIALS N_Vectors - sunvec_y => FN_VNew_Serial(int(neq,c_long), ctx) + sunvec_y => FN_VNew_Serial(neq, ctx) if (.not. associated(sunvec_y)) then print *, 'ERROR: sunvec = NULL' stop 1 end if yvec(1:neqreal,1:N) => FN_VGetArrayPointer(sunvec_y) - sunvec_u => FN_VNew_Serial(int(neq,c_long), ctx) + sunvec_u => FN_VNew_Serial(neq, ctx) if (.not. associated(sunvec_u)) then print *, 'ERROR: sunvec = NULL' stop 1 end if umask(1:neqreal,1:N) => FN_VGetArrayPointer(sunvec_u) - sunvec_v => FN_VNew_Serial(int(neq,c_long), ctx) + sunvec_v => FN_VNew_Serial(neq, ctx) if (.not. associated(sunvec_v)) then print *, 'ERROR: sunvec = NULL' stop 1 end if vmask(1:neqreal,1:N) => FN_VGetArrayPointer(sunvec_v) - sunvec_w => FN_VNew_Serial(int(neq,c_long), ctx) + sunvec_w => FN_VNew_Serial(neq, ctx) if (.not. associated(sunvec_w)) then print *, 'ERROR: sunvec = NULL' stop 1 @@ -1148,13 +1149,13 @@ program main ! Tell ARKODE to use a sparse linear solver for both Newton and mass matrix systems. sparsetype = 1 - sunmat_A => FSUNSparseMatrix(int(neq,c_long), int(neq,c_long), int(nnz,c_long), sparsetype, ctx) + sunmat_A => FSUNSparseMatrix(neq, neq, nnz, sparsetype, ctx) if (.not. associated(sunmat_A)) then print *, 'ERROR: sunmat_A = NULL' stop 1 end if - sunmat_M => FSUNSparseMatrix(int(neq,c_long), int(neq,c_long), int(nnz,c_long), sparsetype, ctx) + sunmat_M => FSUNSparseMatrix(neq, neq, nnz, sparsetype, ctx) if (.not. associated(sunmat_M)) then print *, 'ERROR: sunmat_M = NULL' stop 1 diff --git a/examples/arkode/F2003_serial/ark_bruss_f2003.f90 b/examples/arkode/F2003_serial/ark_bruss_f2003.f90 index 52a7121a88..d4b5185105 100644 --- a/examples/arkode/F2003_serial/ark_bruss_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_bruss_f2003.f90 @@ -46,8 +46,18 @@ module bruss_mod !======= Declarations ========= implicit none + ! Since SUNDIALS can be compiled with 32-bit or 64-bit sunindextype + ! we set the integer kind used for indices in this example based + ! on the the index size SUNDIALS was compiled with so that it works + ! in both configurations. This is not a requirement for user codes. +#if defined(SUNDIALS_INT32_T) + integer, parameter :: myindextype = selected_int_kind(8) +#elif defined(SUNDIALS_INT64_T) + integer, parameter :: myindextype = selected_int_kind(16) +#endif + ! number of equations - integer(c_long), parameter :: neq = 3 + integer(kind=myindextype), parameter :: neq = 3 ! ODE parameters real(c_double), parameter, dimension(neq) :: y0 = (/ 3.9d0, 1.1d0, 2.8d0 /) diff --git a/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.f90 b/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.f90 index c87583eb23..ab8fa486a8 100644 --- a/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.f90 @@ -54,8 +54,8 @@ module DiurnalKryBP_mod ! setup and number of equations integer(c_int), parameter :: mx = 10, my = 10 - integer(c_long), parameter :: mm = mx*my - integer(c_long), parameter :: neq = 2*mm + integer(c_int64_t), parameter :: mm = mx*my + integer(c_int64_t), parameter :: neq = 2*mm ! ODE constant parameters real(c_double), parameter :: Kh = 4.0d-6 @@ -230,7 +230,7 @@ program main real(c_double) :: cx, cy ! initialization variables integer(c_int) :: ierr ! error flag from C functions integer(c_long) :: outstep ! output step - integer(c_long) :: mu, ml ! band preconditioner constants + integer(c_int64_t) :: mu, ml ! band preconditioner constants real(c_double) :: x, y ! initialization index variables type(N_Vector), pointer :: sunvec_u ! sundials vector diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003.f90 b/examples/arkode/F2003_serial/ark_kpr_mri_f2003.f90 index 929844e792..cb0aa027d0 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003.f90 @@ -93,7 +93,7 @@ module kpr_mod real(c_double), parameter :: T0 = 0.0d0 ! initial time real(c_double), parameter :: Tf = 5.0d0 ! final time real(c_double), parameter :: dTout = 0.1d0 ! time between outputs - integer(c_long), parameter :: NEQ = 2 ! number of dependent vars. + integer(c_int64_t), parameter :: NEQ = 2 ! number of dependent vars. integer(c_int), parameter :: Nt = ceiling(Tf/dTout) ! number of output times ! parameters that can be modified via CLI args or are derived diff --git a/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 b/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 index fb58aee07f..c93a7dc06f 100644 --- a/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 @@ -41,7 +41,7 @@ module dnsL_mod !======= Declarations ========= implicit none - integer(c_long), parameter :: neq = 3 + integer(c_int64_t), parameter :: neq = 3 integer(c_long), parameter :: nout = 12 contains diff --git a/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 b/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 index 379f7a23ea..f4ef7e1984 100644 --- a/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 @@ -41,7 +41,7 @@ module dns_mod !======= Declarations ========= implicit none - integer(c_long), parameter :: neq = 3 + integer(c_int64_t), parameter :: neq = 3 integer(c_long), parameter :: nout = 12 contains diff --git a/examples/cvode/F2003_parallel/cv_diag_kry_bbd_f2003.f90 b/examples/cvode/F2003_parallel/cv_diag_kry_bbd_f2003.f90 index 685d60784c..98d9110884 100644 --- a/examples/cvode/F2003_parallel/cv_diag_kry_bbd_f2003.f90 +++ b/examples/cvode/F2003_parallel/cv_diag_kry_bbd_f2003.f90 @@ -49,8 +49,8 @@ module DiagkrybbdData ! Problem parameters integer(c_int), parameter :: iGStype = 1 integer(c_int), parameter :: iPretype0 = 1 - integer(c_long), parameter :: nlocal = 10 - integer(c_long) :: neq, mu, ml, mudq, mldq + integer(c_int64_t), parameter :: nlocal = 10 + integer(c_int64_t) :: neq, mu, ml, mudq, mldq integer(c_int) :: iPretype real(c_double) :: alpha @@ -118,7 +118,7 @@ integer(c_int) function LocalgFn(nnlocal, t, sunvec_y, sunvec_g, user_data) & ! calling variables real(c_double), value :: t ! current time - integer(c_long) :: nnlocal ! local space + integer(c_int64_t) :: nnlocal ! local space type(N_Vector) :: sunvec_y ! solution N_Vector type(N_Vector) :: sunvec_g ! output g N_Vector type(c_ptr) :: user_data ! user-defined data diff --git a/examples/cvode/F2003_parallel/cv_diag_kry_f2003.f90 b/examples/cvode/F2003_parallel/cv_diag_kry_f2003.f90 index e1266fb522..38cf788bdc 100644 --- a/examples/cvode/F2003_parallel/cv_diag_kry_f2003.f90 +++ b/examples/cvode/F2003_parallel/cv_diag_kry_f2003.f90 @@ -49,8 +49,8 @@ module DiagkryData ! Problem parameters integer(c_int), parameter :: iGStype = 1 integer(c_int), parameter :: iPretype0 = 1 - integer(c_long), parameter :: nlocal = 10 - integer(c_long) :: neq + integer(c_int64_t), parameter :: nlocal = 10 + integer(c_int64_t) :: neq integer(c_int) :: iPretype real(c_double) :: alpha @@ -149,7 +149,7 @@ integer(c_int) function Psolve(t, sunvec_y, sunvec_f, sunvec_r, sunvec_z, & ! Calculate Jacobian here ibase = myid * nlocal - istart = max(1_8, 4 - ibase) + istart = max(1_c_int64_t, 4 - ibase) do i = istart,nlocal pj = dble(ibase + i) psubi = 1.d0 + gamma * alpha * pj diff --git a/examples/cvode/F2003_parallel/cv_diag_non_p_f2003.f90 b/examples/cvode/F2003_parallel/cv_diag_non_p_f2003.f90 index 39b8abf5dc..8f200c90c7 100644 --- a/examples/cvode/F2003_parallel/cv_diag_non_p_f2003.f90 +++ b/examples/cvode/F2003_parallel/cv_diag_non_p_f2003.f90 @@ -45,8 +45,8 @@ module DiagnonData integer :: nprocs ! total number of MPI processes ! Problem parameters - integer(c_long), parameter :: nlocal = 2 - integer(c_long) :: neq + integer(c_int64_t), parameter :: nlocal = 2 + integer(c_int64_t) :: neq real(c_double) :: alpha contains diff --git a/examples/cvode/F2003_serial/cv_analytic_fp_f2003.f90 b/examples/cvode/F2003_serial/cv_analytic_fp_f2003.f90 index 28e82b79f7..83c8a46598 100644 --- a/examples/cvode/F2003_serial/cv_analytic_fp_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_analytic_fp_f2003.f90 @@ -34,7 +34,7 @@ module ode_mod implicit none ! number of equations - integer(c_long), parameter :: neq = 1 + integer(c_int64_t), parameter :: neq = 1 ! ODE parameters double precision, parameter :: lamda = -100.0d0 diff --git a/examples/cvode/F2003_serial/cv_analytic_sys_dns_f2003.f90 b/examples/cvode/F2003_serial/cv_analytic_sys_dns_f2003.f90 index 6efd6980ba..9302d65408 100644 --- a/examples/cvode/F2003_serial/cv_analytic_sys_dns_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_analytic_sys_dns_f2003.f90 @@ -55,7 +55,7 @@ module ode_mod implicit none ! number of equations - integer(c_long), parameter :: neq = 3 + integer(c_int64_t), parameter :: neq = 3 ! ODE parameters double precision, parameter :: lamda = -100.0d0 diff --git a/examples/cvode/F2003_serial/cv_analytic_sys_dns_jac_f2003.f90 b/examples/cvode/F2003_serial/cv_analytic_sys_dns_jac_f2003.f90 index f2d44c4418..bf79b5bde6 100644 --- a/examples/cvode/F2003_serial/cv_analytic_sys_dns_jac_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_analytic_sys_dns_jac_f2003.f90 @@ -55,7 +55,7 @@ module ode_mod implicit none ! number of equations - integer(c_long), parameter :: neq = 3 + integer(c_int64_t), parameter :: neq = 3 ! ODE parameters double precision, parameter :: lamda = -100.0d0 diff --git a/examples/cvode/F2003_serial/cv_analytic_sys_klu_f2003.f90 b/examples/cvode/F2003_serial/cv_analytic_sys_klu_f2003.f90 index 4f458287a5..f4360ff1c7 100644 --- a/examples/cvode/F2003_serial/cv_analytic_sys_klu_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_analytic_sys_klu_f2003.f90 @@ -55,7 +55,7 @@ module ode_mod implicit none ! number of equations - integer(c_long), parameter :: neq = 3 + integer(c_int64_t), parameter :: neq = 3 ! ODE parameters double precision, parameter :: lamda = -100.0d0 @@ -145,8 +145,8 @@ integer(c_int) function JacFn(tn, sunvec_y, sunvec_f, sunmat_J, & type(N_Vector) :: tmp1, tmp2, tmp3 ! workspace N_Vectors ! pointer to data in SUNDIALS matrix - integer(c_long), pointer :: Jidxptr(:) - integer(c_long), pointer :: Jidxval(:) + integer(c_int64_t), pointer :: Jidxptr(:) + integer(c_int64_t), pointer :: Jidxval(:) real(c_double), pointer :: Jmat(:) !======= Internals ============ diff --git a/examples/cvode/F2003_serial/cv_brusselator_dns_f2003.f90 b/examples/cvode/F2003_serial/cv_brusselator_dns_f2003.f90 index 3ec4d5ab3b..33ef0b610c 100644 --- a/examples/cvode/F2003_serial/cv_brusselator_dns_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_brusselator_dns_f2003.f90 @@ -38,7 +38,7 @@ module ode_mod implicit none ! number of equations - integer(c_long), parameter :: neq = 3 + integer(c_int64_t), parameter :: neq = 3 ! ODE parameters double precision, parameter :: a = 1.2d0 diff --git a/examples/cvode/F2003_serial/cv_diurnal_kry_bp_f2003.f90 b/examples/cvode/F2003_serial/cv_diurnal_kry_bp_f2003.f90 index 69b4016927..fe69831f05 100644 --- a/examples/cvode/F2003_serial/cv_diurnal_kry_bp_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_diurnal_kry_bp_f2003.f90 @@ -55,8 +55,8 @@ module diurnal_bp_mod ! setup and number of equations integer(c_int), parameter :: mx = 10, my = 10 - integer(c_long), parameter :: mm = mx*my - integer(c_long), parameter :: neq = 2*mm + integer(c_int64_t), parameter :: mm = mx*my + integer(c_int64_t), parameter :: neq = 2*mm ! ODE constant parameters real(c_double), parameter :: Kh = 4.0d-6 @@ -227,7 +227,7 @@ program main real(c_double) :: cx, cy ! initialization variables integer(c_int) :: ierr ! error flag from C functions integer(c_long) :: outstep ! output step - integer(c_long) :: mu, ml ! band preconditioner constants + integer(c_int64_t) :: mu, ml ! band preconditioner constants real(c_double) :: x, y ! initialization index variables type(N_Vector), pointer :: sunvec_u ! sundials vector diff --git a/examples/cvode/F2003_serial/cv_diurnal_kry_f2003.f90 b/examples/cvode/F2003_serial/cv_diurnal_kry_f2003.f90 index d9267480ac..d087b60d99 100644 --- a/examples/cvode/F2003_serial/cv_diurnal_kry_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_diurnal_kry_f2003.f90 @@ -55,8 +55,8 @@ module diurnal_mod ! setup and number of equations integer(c_int), parameter :: mx = 10, my = 10 - integer(c_long), parameter :: mm = mx*my - integer(c_long), parameter :: neq = 2*mm + integer(c_int64_t), parameter :: mm = mx*my + integer(c_int64_t), parameter :: neq = 2*mm ! ODE constant parameters real(c_double), parameter :: Kh = 4.0d-6 @@ -375,11 +375,11 @@ subroutine Prec_LU(mmm, p, ierr) implicit none integer(c_int), intent(out) :: ierr - integer(c_long), intent(in) :: mmm + integer(c_int64_t), intent(in) :: mmm real(c_double), intent(inout) :: p(2,2,mmm) ! local variable - integer(c_long) :: i + integer(c_int64_t) :: i real(c_double) :: p11, p12, p21, p22, det ! initialize return value to success @@ -426,7 +426,7 @@ subroutine Prec_Sol(mx,my, p, z) real(c_double), dimension(2,mx,my), intent(inout) :: z(:,:,:) ! local variable - integer(c_long) :: i, j + integer(c_int64_t) :: i, j real(c_double) :: z1, z2 diff --git a/examples/cvode/F2003_serial/cv_roberts_dnsL_f2003.f90 b/examples/cvode/F2003_serial/cv_roberts_dnsL_f2003.f90 index 2563680cba..2ed0a8cbed 100644 --- a/examples/cvode/F2003_serial/cv_roberts_dnsL_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_roberts_dnsL_f2003.f90 @@ -45,7 +45,7 @@ module robertsDnsL_mod implicit none integer(c_int), parameter :: nout = 12 - integer(c_long), parameter :: neq = 3 + integer(c_int64_t), parameter :: neq = 3 contains diff --git a/examples/cvode/F2003_serial/cv_roberts_dns_constraints_f2003.f90 b/examples/cvode/F2003_serial/cv_roberts_dns_constraints_f2003.f90 index 3e6a9901ad..1eb2e504be 100644 --- a/examples/cvode/F2003_serial/cv_roberts_dns_constraints_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_roberts_dns_constraints_f2003.f90 @@ -49,7 +49,7 @@ module RobertsDnsConstr_mod implicit none integer(c_int), parameter :: nout = 12 - integer(c_long), parameter :: neq = 3 + integer(c_int64_t), parameter :: neq = 3 contains diff --git a/examples/cvode/F2003_serial/cv_roberts_dns_f2003.f90 b/examples/cvode/F2003_serial/cv_roberts_dns_f2003.f90 index 751a2f2807..3a07939e64 100644 --- a/examples/cvode/F2003_serial/cv_roberts_dns_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_roberts_dns_f2003.f90 @@ -45,7 +45,7 @@ module robertsDns_mod implicit none integer(c_int), parameter :: nout = 12 - integer(c_long), parameter :: neq = 3 + integer(c_int64_t), parameter :: neq = 3 contains diff --git a/examples/cvode/F2003_serial/cv_roberts_klu_f2003.f90 b/examples/cvode/F2003_serial/cv_roberts_klu_f2003.f90 index eef7aeab8e..785d3e7c63 100644 --- a/examples/cvode/F2003_serial/cv_roberts_klu_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_roberts_klu_f2003.f90 @@ -45,8 +45,8 @@ module roberts_klu_mod implicit none integer(c_int), parameter :: nout = 12 - integer(c_long), parameter :: neq = 3 - integer(c_long), parameter :: nnz = neq * neq + integer(c_int64_t), parameter :: neq = 3 + integer(c_int64_t), parameter :: nnz = neq * neq contains @@ -164,8 +164,8 @@ integer(c_int) function jacrob(t, sunvec_y, sunvec_f, & ! pointers to data in SUNDIALS vector and matrix real(c_double), pointer, dimension(neq) :: yval(:) real(c_double), pointer, dimension(nnz) :: Jdata(:) - integer(c_long), pointer, dimension(nnz) :: Jrvals(:) - integer(c_long), pointer, dimension(neq+1) :: Jcptrs(:) + integer(c_int64_t), pointer, dimension(nnz) :: Jrvals(:) + integer(c_int64_t), pointer, dimension(neq+1) :: Jcptrs(:) !======= Internals ============ diff --git a/examples/cvodes/F2003_serial/CMakeLists.txt b/examples/cvodes/F2003_serial/CMakeLists.txt index 667a6260c6..5e5bac8953 100644 --- a/examples/cvodes/F2003_serial/CMakeLists.txt +++ b/examples/cvodes/F2003_serial/CMakeLists.txt @@ -37,6 +37,9 @@ foreach(example_tuple ${FCVODES_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # Install fortran modules to a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90) diff --git a/examples/ida/F2003_openmp/idaHeat2D_kry_omp_f2003.f90 b/examples/ida/F2003_openmp/idaHeat2D_kry_omp_f2003.f90 index 790b62326c..3e83d622e6 100644 --- a/examples/ida/F2003_openmp/idaHeat2D_kry_omp_f2003.f90 +++ b/examples/ida/F2003_openmp/idaHeat2D_kry_omp_f2003.f90 @@ -48,7 +48,7 @@ module idaHeat2DKryOMP_mod integer(c_int), parameter :: nout = 11 integer(c_int), parameter :: mgrid = 100 - integer(c_long), parameter :: neq = mgrid*mgrid + integer(c_int64_t), parameter :: neq = mgrid*mgrid real(c_double) :: dx real(c_double) :: coeff @@ -86,7 +86,7 @@ integer(c_int) function resHeat(tres, sunvec_u, sunvec_up, sunvec_r, user_data) real(c_double), pointer, dimension(mgrid,mgrid) :: r(:,:) ! local variables - integer(c_long) :: i, j + integer(c_int64_t) :: i, j !======= Internals ============ @@ -522,7 +522,7 @@ subroutine SetInitialProfile(sunvec_u, sunvec_up, sunvec_r) real(c_double), pointer, dimension(mgrid,mgrid) :: r(:,:) ! local variables - integer(c_long) :: i, j + integer(c_int64_t) :: i, j real(c_double) :: xfact, yfact integer(c_int) :: retval diff --git a/examples/ida/F2003_parallel/ida_heat2D_kry_bbd_f2003.f90 b/examples/ida/F2003_parallel/ida_heat2D_kry_bbd_f2003.f90 index b718674c52..0f76650345 100644 --- a/examples/ida/F2003_parallel/ida_heat2D_kry_bbd_f2003.f90 +++ b/examples/ida/F2003_parallel/ida_heat2D_kry_bbd_f2003.f90 @@ -76,7 +76,7 @@ module Heat2DKryBBD_mod integer :: je integer :: nxl ! local number of x grid points integer :: nyl ! local number of y grid points - integer(c_long) :: N, Ntot + integer(c_int64_t) :: N, Ntot real(c_double) :: dx ! x-directional mesh spacing real(c_double) :: dy ! y-directional mesh spacing integer, target :: comm ! communicator object @@ -93,7 +93,7 @@ module Heat2DKryBBD_mod real(c_double), dimension(:), allocatable :: Ssend ! Problem parameters - integer(c_long) :: mudq, mldq, mu, ml + integer(c_int64_t) :: mudq, mldq, mu, ml integer(c_int) :: maxl real(c_double) :: kx ! x-directional diffusion coefficient real(c_double) :: ky ! y-directional diffusion coefficient @@ -442,7 +442,7 @@ integer(c_int) function Exchange(Nloc, t, sunvec_y, sunvec_ydot, & implicit none ! calling variables - integer(c_long), value :: Nloc + integer(c_int64_t), value :: Nloc real(c_double), value :: t ! current time type(N_Vector) :: sunvec_y ! solution N_Vector type(N_Vector) :: sunvec_ydot ! rhs N_Vector @@ -647,7 +647,7 @@ integer(c_int) function LocalFn(Nloc, t, sunvec_y, sunvec_ydot, sunvec_g, & implicit none ! calling variables - integer(c_long), value :: Nloc + integer(c_int64_t), value :: Nloc real(c_double), value :: t ! current time type(N_Vector) :: sunvec_y ! solution N_Vector type(N_Vector) :: sunvec_ydot ! rhs N_Vector diff --git a/examples/ida/F2003_serial/idaHeat2D_kry_f2003.f90 b/examples/ida/F2003_serial/idaHeat2D_kry_f2003.f90 index 22c7d2d691..a8fd742d0e 100644 --- a/examples/ida/F2003_serial/idaHeat2D_kry_f2003.f90 +++ b/examples/ida/F2003_serial/idaHeat2D_kry_f2003.f90 @@ -46,7 +46,7 @@ module dae_mod integer(c_int), parameter :: nout = 11 integer(c_int), parameter :: mgrid = 10 - integer(c_long), parameter :: neq = mgrid*mgrid + integer(c_int64_t), parameter :: neq = mgrid*mgrid real(c_double) :: dx real(c_double) :: coeff @@ -84,7 +84,7 @@ integer(c_int) function resHeat(tres, sunvec_u, sunvec_up, sunvec_r, user_data) real(c_double), pointer :: r(:,:) ! local variables - integer(c_long) :: i, j + integer(c_int64_t) :: i, j !======= Internals ============ @@ -498,7 +498,7 @@ subroutine SetInitialProfile(sunvec_u, sunvec_up, sunvec_r) real(c_double), pointer :: r(:,:) ! local variables - integer(c_long) :: i, j + integer(c_int64_t) :: i, j real(c_double) :: xfact, yfact integer(c_int) :: retval diff --git a/examples/idas/F2003_serial/idasAkzoNob_ASAi_dns_f2003.f90 b/examples/idas/F2003_serial/idasAkzoNob_ASAi_dns_f2003.f90 index debacbf91a..d41404ff8f 100644 --- a/examples/idas/F2003_serial/idasAkzoNob_ASAi_dns_f2003.f90 +++ b/examples/idas/F2003_serial/idasAkzoNob_ASAi_dns_f2003.f90 @@ -419,7 +419,7 @@ program main retval = FIDASStolerancesB(mem, indexB(1), RTOLB, ATOLB) call check_retval(retval, "FIDASStolerancesB") - retval = FIDASetMaxNumStepsB(mem, indexB(1), 1000_8) + retval = FIDASetMaxNumStepsB(mem, indexB(1), 1000_c_long) call check_retval(retval, "FIDASetMaxNumStepsB") ! Create dense SUNMatrix for use in linear solves diff --git a/examples/idas/F2003_serial/idasHeat2D_kry_f2003.f90 b/examples/idas/F2003_serial/idasHeat2D_kry_f2003.f90 index 2c06761340..9ecad4f265 100644 --- a/examples/idas/F2003_serial/idasHeat2D_kry_f2003.f90 +++ b/examples/idas/F2003_serial/idasHeat2D_kry_f2003.f90 @@ -46,7 +46,7 @@ module dae_mod integer(c_int), parameter :: nout = 11 integer(c_int), parameter :: mgrid = 10 - integer(c_long), parameter :: neq = mgrid*mgrid + integer(c_int64_t), parameter :: neq = mgrid*mgrid real(c_double) :: dx real(c_double) :: coeff @@ -84,7 +84,7 @@ integer(c_int) function resHeat(tres, sunvec_u, sunvec_up, sunvec_r, user_data) real(c_double), pointer :: r(:,:) ! local variables - integer(c_long) :: i, j + integer(c_int64_t) :: i, j !======= Internals ============ @@ -500,7 +500,7 @@ subroutine SetInitialProfile(sunvec_u, sunvec_up, sunvec_r) real(c_double), pointer :: r(:,:) ! local variables - integer(c_long) :: i, j + integer(c_int64_t) :: i, j real(c_double) :: xfact, yfact integer(c_int) :: retval diff --git a/examples/kinsol/F2003_parallel/kin_diagon_kry_f2003.f90 b/examples/kinsol/F2003_parallel/kin_diagon_kry_f2003.f90 index 9c00556e7d..e0fba580a1 100644 --- a/examples/kinsol/F2003_parallel/kin_diagon_kry_f2003.f90 +++ b/examples/kinsol/F2003_parallel/kin_diagon_kry_f2003.f90 @@ -36,10 +36,10 @@ module kinDiagonKry_mod ! With MPI-3 use mpi_f08 is preferred include "mpif.h" - integer(c_long), parameter :: neq = 128 + integer(c_int64_t), parameter :: neq = 128 integer(c_int) :: ierr, retval, nprint - integer(c_long) :: i, nlocal + integer(c_int64_t) :: i, nlocal real(c_double), pointer, dimension(neq) :: u(:), scale(:), constr(:) real(c_double) :: p(neq) integer(c_int), parameter :: prectype = 2 @@ -73,7 +73,7 @@ subroutine init(sunvec_u, sunvec_s, sunvec_c) type(N_Vector) :: sunvec_c ! constraint N_Vector ! local variables - integer(c_long) :: ii + integer(c_int64_t) :: ii u(1:nlocal) => FN_VGetArrayPointer(sunvec_u) scale(1:nlocal) => FN_VGetArrayPointer(sunvec_s) @@ -118,7 +118,7 @@ integer(c_int) function func(sunvec_u, sunvec_f, user_data) & real(c_double), pointer, dimension(nlocal) :: uu(:), ff(:) ! local variables - integer(c_long) :: ii + integer(c_int64_t) :: ii !======= Internals ============ @@ -471,7 +471,7 @@ subroutine PrintOutput(uu) ! calling variable real(c_double), dimension(neq) :: uu - integer(c_long) :: ii + integer(c_int64_t) :: ii !======= Internals ============ diff --git a/examples/kinsol/F2003_serial/kinDiagon_kry_f2003.f90 b/examples/kinsol/F2003_serial/kinDiagon_kry_f2003.f90 index a69564fe1f..78c76cde4f 100644 --- a/examples/kinsol/F2003_serial/kinDiagon_kry_f2003.f90 +++ b/examples/kinsol/F2003_serial/kinDiagon_kry_f2003.f90 @@ -47,7 +47,7 @@ module kinDiagonKry_mod integer(kind=myindextype), parameter :: neq = 128 integer(c_int) :: ierr, retval - integer(c_long) :: i + integer(c_int64_t) :: i real(c_double), pointer, dimension(neq) :: u(:), scale(:), constr(:) real(c_double) :: p(neq) integer(c_int), parameter :: prectype = 2 diff --git a/examples/kinsol/F2003_serial/kinLaplace_bnd_f2003.f90 b/examples/kinsol/F2003_serial/kinLaplace_bnd_f2003.f90 index 823015cf9c..4cdf270c9b 100644 --- a/examples/kinsol/F2003_serial/kinLaplace_bnd_f2003.f90 +++ b/examples/kinsol/F2003_serial/kinLaplace_bnd_f2003.f90 @@ -31,10 +31,10 @@ module prob_mod !======= Declarations ========= implicit none - integer(c_long), parameter :: nx = 31 - integer(c_long), parameter :: ny = 31 - integer(c_long), parameter :: neq = nx*ny - integer(c_long), parameter :: skip = 3 + integer(c_int64_t), parameter :: nx = 31 + integer(c_int64_t), parameter :: ny = 31 + integer(c_int64_t), parameter :: neq = nx*ny + integer(c_int64_t), parameter :: skip = 3 real(c_double), parameter :: ftol = 1.d-12 contains @@ -66,7 +66,7 @@ integer(c_int) function func(sunvec_u, sunvec_f, user_data) & real(c_double), pointer :: u(:,:), f(:,:) ! internal variables - integer(c_long) :: i, j + integer(c_int64_t) :: i, j real(c_double) :: dx, dy, hdiff, vdiff, hdc, vdc, uij, udn, uup, ult, urt !======= Internals ============ @@ -315,7 +315,7 @@ subroutine PrintOutput(u) real(c_double), dimension(nx,ny) :: u ! internal variables - integer(c_long) :: i, j + integer(c_int64_t) :: i, j real(c_double) :: dx, dy, x, y !======= Internals ============ diff --git a/examples/kinsol/F2003_serial/kinLaplace_picard_kry_f2003.f90 b/examples/kinsol/F2003_serial/kinLaplace_picard_kry_f2003.f90 index e96dc3c5f0..9832ac97ff 100644 --- a/examples/kinsol/F2003_serial/kinLaplace_picard_kry_f2003.f90 +++ b/examples/kinsol/F2003_serial/kinLaplace_picard_kry_f2003.f90 @@ -34,10 +34,10 @@ module prob_mod !======= Declarations ========= implicit none - integer(c_long), parameter :: nx = 31 - integer(c_long), parameter :: ny = 31 - integer(c_long), parameter :: neq = nx*ny - integer(c_long), parameter :: skip = 3 + integer(c_int64_t), parameter :: nx = 31 + integer(c_int64_t), parameter :: ny = 31 + integer(c_int64_t), parameter :: neq = nx*ny + integer(c_int64_t), parameter :: skip = 3 real(c_double), parameter :: ftol = 1.d-12 contains @@ -65,7 +65,7 @@ integer(c_int) function func(sunvec_u, sunvec_f, user_data) & real(c_double), pointer :: u(:,:), f(:,:) ! internal variables - integer(c_long) :: i, j + integer(c_int64_t) :: i, j real(c_double) :: dx, dy, hdiff, vdiff, hdc, vdc, uij, udn, uup, ult, urt !======= Internals ============ @@ -137,7 +137,7 @@ integer(c_int) function jactimes(sunvec_v, sunvec_Jv, sunvec_u, new_u, user_data real(c_double), pointer :: v(:,:), Jv(:,:) ! internal variables - integer(c_long) :: i, j + integer(c_int64_t) :: i, j real(c_double) :: dx, dy, hdiff, vdiff, hdc, vdc, vij, vdn, vup, vlt, vrt !======= Internals ============ @@ -376,7 +376,7 @@ subroutine PrintOutput(u) real(c_double), dimension(nx,ny) :: u ! internal variables - integer(c_long) :: i, j + integer(c_int64_t) :: i, j real(c_double) :: dx, dy, x, y !======= Internals ============ diff --git a/examples/kinsol/F2003_serial/kinRoboKin_dns_f2003.f90 b/examples/kinsol/F2003_serial/kinRoboKin_dns_f2003.f90 index e9f56c6a3a..2399a29ea5 100644 --- a/examples/kinsol/F2003_serial/kinRoboKin_dns_f2003.f90 +++ b/examples/kinsol/F2003_serial/kinRoboKin_dns_f2003.f90 @@ -34,8 +34,8 @@ module prob_mod !======= Declarations ========= implicit none - integer(c_long), parameter :: nvar = 8 - integer(c_long), parameter :: neq = 3*nvar + integer(c_int64_t), parameter :: nvar = 8 + integer(c_int64_t), parameter :: neq = 3*nvar real(c_double), parameter :: ftol = 1.d-5 real(c_double), parameter :: stol = 1.d-5 diff --git a/examples/nvector/C_openmp/CMakeLists.txt b/examples/nvector/C_openmp/CMakeLists.txt index cfdc518d93..b332f20064 100644 --- a/examples/nvector/C_openmp/CMakeLists.txt +++ b/examples/nvector/C_openmp/CMakeLists.txt @@ -108,6 +108,9 @@ foreach(example_tuple ${nvector_openmp_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -115,7 +118,6 @@ foreach(example_tuple ${nvector_openmp_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS}) diff --git a/examples/nvector/manyvector/CMakeLists.txt b/examples/nvector/manyvector/CMakeLists.txt index e76cd90cd9..a43d1e4c15 100644 --- a/examples/nvector/manyvector/CMakeLists.txt +++ b/examples/nvector/manyvector/CMakeLists.txt @@ -105,6 +105,9 @@ foreach(example_tuple ${nvector_manyvector_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -112,7 +115,6 @@ foreach(example_tuple ${nvector_manyvector_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS}) diff --git a/examples/nvector/mpimanyvector/CMakeLists.txt b/examples/nvector/mpimanyvector/CMakeLists.txt index 32765aa29a..66c7253bc9 100644 --- a/examples/nvector/mpimanyvector/CMakeLists.txt +++ b/examples/nvector/mpimanyvector/CMakeLists.txt @@ -146,6 +146,9 @@ foreach(example_tuple ${nvector_mpimanyvector_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -153,7 +156,6 @@ foreach(example_tuple ${nvector_mpimanyvector_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS}) diff --git a/examples/nvector/mpiplusx/CMakeLists.txt b/examples/nvector/mpiplusx/CMakeLists.txt index 9b2c733540..195bcb6868 100644 --- a/examples/nvector/mpiplusx/CMakeLists.txt +++ b/examples/nvector/mpiplusx/CMakeLists.txt @@ -144,6 +144,9 @@ foreach(example_tuple ${nvector_mpiplusx_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -151,7 +154,6 @@ foreach(example_tuple ${nvector_mpiplusx_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS}) diff --git a/examples/nvector/parallel/CMakeLists.txt b/examples/nvector/parallel/CMakeLists.txt index ff13f85ce5..bfdf74eec8 100644 --- a/examples/nvector/parallel/CMakeLists.txt +++ b/examples/nvector/parallel/CMakeLists.txt @@ -133,6 +133,9 @@ foreach(example_tuple ${nvector_parallel_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -140,7 +143,6 @@ foreach(example_tuple ${nvector_parallel_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) # libraries to link against target_link_libraries(${example} diff --git a/examples/nvector/pthreads/CMakeLists.txt b/examples/nvector/pthreads/CMakeLists.txt index 586e1c3f06..e9fefd7191 100644 --- a/examples/nvector/pthreads/CMakeLists.txt +++ b/examples/nvector/pthreads/CMakeLists.txt @@ -108,6 +108,9 @@ foreach(example_tuple ${nvector_pthreads_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -115,7 +118,6 @@ foreach(example_tuple ${nvector_pthreads_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS} ${CMAKE_THREAD_LIBS_INIT}) diff --git a/examples/nvector/serial/CMakeLists.txt b/examples/nvector/serial/CMakeLists.txt index ef92e58040..6807562188 100644 --- a/examples/nvector/serial/CMakeLists.txt +++ b/examples/nvector/serial/CMakeLists.txt @@ -100,6 +100,9 @@ foreach(example_tuple ${nvector_serial_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -108,9 +111,6 @@ foreach(example_tuple ${nvector_serial_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # folder where fortran .mod files are - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS}) endif() diff --git a/examples/sunlinsol/band/CMakeLists.txt b/examples/sunlinsol/band/CMakeLists.txt index 1dd10759f5..8a6d09997e 100644 --- a/examples/sunlinsol/band/CMakeLists.txt +++ b/examples/sunlinsol/band/CMakeLists.txt @@ -97,6 +97,9 @@ foreach(example_tuple ${sunlinsol_band_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -105,9 +108,6 @@ foreach(example_tuple ${sunlinsol_band_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/dense/CMakeLists.txt b/examples/sunlinsol/dense/CMakeLists.txt index f751cd4760..03b6155811 100644 --- a/examples/sunlinsol/dense/CMakeLists.txt +++ b/examples/sunlinsol/dense/CMakeLists.txt @@ -97,6 +97,9 @@ foreach(example_tuple ${sunlinsol_dense_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -105,9 +108,6 @@ foreach(example_tuple ${sunlinsol_dense_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/klu/CMakeLists.txt b/examples/sunlinsol/klu/CMakeLists.txt index 5932da7b07..664ec266a1 100644 --- a/examples/sunlinsol/klu/CMakeLists.txt +++ b/examples/sunlinsol/klu/CMakeLists.txt @@ -98,6 +98,9 @@ foreach(example_tuple ${sunlinsol_klu_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -106,9 +109,6 @@ foreach(example_tuple ${sunlinsol_klu_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/lapackdense/CMakeLists.txt b/examples/sunlinsol/lapackdense/CMakeLists.txt index ce5739b1b5..0dd6ea947e 100644 --- a/examples/sunlinsol/lapackdense/CMakeLists.txt +++ b/examples/sunlinsol/lapackdense/CMakeLists.txt @@ -103,6 +103,9 @@ foreach(example_tuple ${sunlinsol_lapackdense_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -111,9 +114,6 @@ foreach(example_tuple ${sunlinsol_lapackdense_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/pcg/serial/CMakeLists.txt b/examples/sunlinsol/pcg/serial/CMakeLists.txt index 4a014d11e7..4d6be609ee 100644 --- a/examples/sunlinsol/pcg/serial/CMakeLists.txt +++ b/examples/sunlinsol/pcg/serial/CMakeLists.txt @@ -104,6 +104,9 @@ foreach(example_tuple ${sunlinsol_pcg_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -112,9 +115,6 @@ foreach(example_tuple ${sunlinsol_pcg_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/spbcgs/serial/CMakeLists.txt b/examples/sunlinsol/spbcgs/serial/CMakeLists.txt index 81a7330259..005f743cdf 100644 --- a/examples/sunlinsol/spbcgs/serial/CMakeLists.txt +++ b/examples/sunlinsol/spbcgs/serial/CMakeLists.txt @@ -104,6 +104,9 @@ foreach(example_tuple ${sunlinsol_spbcgs_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -112,9 +115,6 @@ foreach(example_tuple ${sunlinsol_spbcgs_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/spfgmr/serial/CMakeLists.txt b/examples/sunlinsol/spfgmr/serial/CMakeLists.txt index beba6889fd..daa7d9fca3 100644 --- a/examples/sunlinsol/spfgmr/serial/CMakeLists.txt +++ b/examples/sunlinsol/spfgmr/serial/CMakeLists.txt @@ -103,6 +103,9 @@ foreach(example_tuple ${sunlinsol_spfgmr_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -111,9 +114,6 @@ foreach(example_tuple ${sunlinsol_spfgmr_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/spgmr/serial/CMakeLists.txt b/examples/sunlinsol/spgmr/serial/CMakeLists.txt index 0ad67ecec1..3353f2a829 100644 --- a/examples/sunlinsol/spgmr/serial/CMakeLists.txt +++ b/examples/sunlinsol/spgmr/serial/CMakeLists.txt @@ -106,6 +106,9 @@ foreach(example_tuple ${sunlinsol_spgmr_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -114,9 +117,6 @@ foreach(example_tuple ${sunlinsol_spgmr_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/sptfqmr/serial/CMakeLists.txt b/examples/sunlinsol/sptfqmr/serial/CMakeLists.txt index 2d3543ed5c..c985445c51 100644 --- a/examples/sunlinsol/sptfqmr/serial/CMakeLists.txt +++ b/examples/sunlinsol/sptfqmr/serial/CMakeLists.txt @@ -104,6 +104,9 @@ foreach(example_tuple ${sunlinsol_sptfqmr_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -112,9 +115,6 @@ foreach(example_tuple ${sunlinsol_sptfqmr_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunmatrix/band/CMakeLists.txt b/examples/sunmatrix/band/CMakeLists.txt index 2502ecf508..1db5a837a3 100644 --- a/examples/sunmatrix/band/CMakeLists.txt +++ b/examples/sunmatrix/band/CMakeLists.txt @@ -98,6 +98,9 @@ foreach(example_tuple ${sunmatrix_band_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -106,9 +109,6 @@ foreach(example_tuple ${sunmatrix_band_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunmatrix/dense/CMakeLists.txt b/examples/sunmatrix/dense/CMakeLists.txt index 48365ac059..e5e5f9a346 100644 --- a/examples/sunmatrix/dense/CMakeLists.txt +++ b/examples/sunmatrix/dense/CMakeLists.txt @@ -97,13 +97,15 @@ foreach(example_tuple ${sunmatrix_dense_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 ${SUNDIALS_SOURCE_DIR}/examples/sunmatrix/test_sunmatrix.f90) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) # libraries to link against target_link_libraries(${example} diff --git a/examples/sunmatrix/sparse/CMakeLists.txt b/examples/sunmatrix/sparse/CMakeLists.txt index daff9a61d4..ee04a96b8d 100644 --- a/examples/sunmatrix/sparse/CMakeLists.txt +++ b/examples/sunmatrix/sparse/CMakeLists.txt @@ -102,13 +102,15 @@ foreach(example_tuple ${sunmatrix_sparse_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 ${SUNDIALS_SOURCE_DIR}/examples/sunmatrix/test_sunmatrix.f90) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) # libraries to link against target_link_libraries(${example} diff --git a/examples/sunnonlinsol/fixedpoint/CMakeLists.txt b/examples/sunnonlinsol/fixedpoint/CMakeLists.txt index 4906cd1a31..834af69c2e 100644 --- a/examples/sunnonlinsol/fixedpoint/CMakeLists.txt +++ b/examples/sunnonlinsol/fixedpoint/CMakeLists.txt @@ -97,6 +97,9 @@ foreach(example_tuple ${fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90) diff --git a/examples/sunnonlinsol/fixedpoint/test_fsunnonlinsol_fixedpoint_mod.f90 b/examples/sunnonlinsol/fixedpoint/test_fsunnonlinsol_fixedpoint_mod.f90 index 90213440af..7b6cfd2322 100644 --- a/examples/sunnonlinsol/fixedpoint/test_fsunnonlinsol_fixedpoint_mod.f90 +++ b/examples/sunnonlinsol/fixedpoint/test_fsunnonlinsol_fixedpoint_mod.f90 @@ -22,15 +22,17 @@ module test_fsunnonlinsol_fixedpoint implicit none integer(kind=myindextype), parameter :: NEQ = 3 ! number of equations - integer(C_INT), parameter :: MAXIT = 10 ! max nonlinear iters. + integer(C_INT), parameter :: MAXIT = 20 ! max nonlinear iters. real(C_DOUBLE), parameter :: TOL = 1.0e-4 ! nonlinear solver tolerance real(C_DOUBLE), parameter :: PI = 3.1415926535898 ! approximate solution - real(C_DOUBLE) :: Y1 = 0.5d0 - real(C_DOUBLE) :: Y2 = 0.d0 - real(C_DOUBLE) :: Y3 = -PI/6.0d0 + real(C_DOUBLE) :: XTRUE = 0.5d0 + real(C_DOUBLE) :: YTRUE = 1.0d0 + real(C_DOUBLE) :: ZTRUE = -PI/6.0d0 + + type(N_Vector), pointer :: y0 contains @@ -43,26 +45,30 @@ integer(C_INT) function unit_tests() result(retval) implicit none type(SUNNonlinearSolver), pointer :: NLS ! test nonlinear solver - type(N_Vector), pointer :: x, y0, y, w ! test vectors - real(C_DOUBLE), pointer :: ydata(:) + type(N_Vector), pointer :: ycur, ycor, w ! test vectors + real(C_DOUBLE), pointer :: data(:) integer(C_LONG) :: niters(1) integer(C_INT) :: tmp - x => FN_VNew_Serial(NEQ, sunctx) - y0 => FN_VClone(x) - y => FN_VClone(x) - w => FN_VClone(x) + y0 => FN_VNew_Serial(NEQ, sunctx) + ycor => FN_VClone(y0) + ycur => FN_VClone(y0) + w => FN_VClone(y0) - ! set weights - ydata => FN_VGetArrayPointer(y0) - ydata(1) = 0.1d0 - ydata(2) = 0.1d0 - ydata(3) = -0.1d0 + ! set initial guess + data => FN_VGetArrayPointer(y0) + data(1) = 0.1d0 + data(2) = 0.1d0 + data(3) = -0.1d0 + + ! set initial correction + call FN_VConst(0.0d0, ycor) + ! set weights call FN_VConst(1.0d0, w) ! create and test NLS - NLS => FSUNNonlinsol_FixedPoint(y, 0, sunctx) + NLS => FSUNNonlinsol_FixedPoint(y0, 0, sunctx) retval = FSUNNonlinSolSetSysFn(NLS, c_funloc(FPFunction)) if (retval /= 0) then @@ -82,37 +88,35 @@ integer(C_INT) function unit_tests() result(retval) return end if - retval = FSUNNonlinSolSolve(NLS, y0, y, w, TOL, 1, c_loc(x)) + retval = FSUNNonlinSolSolve(NLS, y0, ycor, w, TOL, 1, c_loc(y0)) if (retval /= 0) then write(*,'(A,I0)') ' >>> FAIL: FSUNNonlinSolSolve returned ', retval return end if - ! extract and print solution - ydata => FN_VGetArrayPointer(y) - - write(*,*) 'Solution:' - write(*,'(A,E14.7)') 'y1 = ', ydata(1) - write(*,'(A,E14.7)') 'y2 = ', ydata(2) - write(*,'(A,E14.7)') 'y3 = ', ydata(3) - - write(*,*) 'Solution Error:' - write(*,'(A,E14.7)') 'e1 = ', ydata(1) - Y1 - write(*,'(A,E14.7)') 'e2 = ', ydata(2) - Y2 - write(*,'(A,E14.7)') 'e3 = ', ydata(3) - Y3 + ! update the initial guess with the final correction + call FN_VLinearSum(1.0d0, y0, 1.0d0, ycor, ycur); + ! print number of iterations retval = FSUNNonlinSolGetNumIters(NLS, niters) if (retval /= 0) then write(*,'(A,I0)') ' >>> FAIL: FSUNNonlinSolGetNumIters returned ', retval return end if - write(*,'(A,I0)') 'Number of nonlinear iterations:', niters(1) + write(*,'(A,I0)') 'Number of nonlinear iterations: ', niters(1) + + ! check answer + retval = check_ans(ycur, TOL) + if (retval /= 0) then + write(*,'(A,I0)') ' >>> FAIL: check_ans failed' + return + end if ! cleanup - call FN_VDestroy(x) call FN_VDestroy(y0) - call FN_VDestroy(y) + call FN_VDestroy(ycor) + call FN_VDestroy(ycur) call FN_VDestroy(w) tmp = FSUNNonlinSolFree(NLS) @@ -122,8 +126,6 @@ integer(C_INT) function ConvTest(NLS, y, del, tol, ewt, mem) & result(retval) bind(C) use, intrinsic :: iso_c_binding - - implicit none type(SUNNonlinearSolver) :: NLS @@ -144,46 +146,87 @@ integer(C_INT) function ConvTest(NLS, y, del, tol, ewt, mem) & end function ! ----------------------------------------------------------------------------- - ! Nonlinear system + ! Nonlinear system F(x,y,z): ! - ! 3x - cos(yz) - 1/2 = 0 - ! x^2 - 81(y+0.1)^2 + sin(z) + 1.06 = 0 - ! exp(-xy) + 20z + (10 pi - 3)/3 = 0 + ! 3x - cos((y-1)z) - 1/2 = 0 + ! x^2 - 81(y-0.9)^2 + sin(z) + 1.06 = 0 + ! exp(-x(y-1)) + 20z + (10 pi - 3)/3 = 0 ! - ! Nonlinear fixed point function + ! Nonlinear fixed point function G(x,y,z): ! - ! g1(x,y,z) = 1/3 cos(yz) + 1/6 - ! g2(x,y,z) = 1/9 sqrt(x^2 + sin(z) + 1.06) - 0.1 - ! g3(x,y,z) = -1/20 exp(-xy) - (10 pi - 3) / 60 + ! G1(x,y,z) = 1/3 cos((y-1)yz) + 1/6 + ! G2(x,y,z) = 1/9 sqrt(x^2 + sin(z) + 1.06) + 0.9 + ! G3(x,y,z) = -1/20 exp(-x(y-1)) - (10 pi - 3) / 60 + ! + ! Corrector form g(x,y,z): + ! + ! g1(x,y,z) = 1/3 cos((y-1)yz) + 1/6 - x0 + ! g2(x,y,z) = 1/9 sqrt(x^2 + sin(z) + 1.06) + 0.9 - y0 + ! g3(x,y,z) = -1/20 exp(-x(y-1)) - (10 pi - 3) / 60 - z0 ! ! ---------------------------------------------------------------------------- - integer(C_INT) function FPFunction(y, f, mem) & + integer(C_INT) function FPFunction(ycor, f, mem) & result(retval) bind(C) use, intrinsic :: iso_c_binding - - implicit none - type(N_Vector) :: y, f + type(N_Vector) :: ycor, f type(C_PTR), value :: mem - real(C_DOUBLE), pointer :: ydata(:), fdata(:) - real(C_DOUBLE) :: y1, y2, y3 + real(C_DOUBLE), pointer :: data(:), fdata(:) + real(C_DOUBLE) :: x, y, z - ydata => FN_VGetArrayPointer(y) + data => FN_VGetArrayPointer(ycor) fdata => FN_VGetArrayPointer(f) - y1 = ydata(1) - y2 = ydata(2) - y3 = ydata(3) + x = data(1) + y = data(2) + z = data(3) - fdata(1) = (1/3.0d0) * cos(y2*y3) + (1/6.0d0) - fdata(2) = (1/9.0d0) * sqrt(y1*y1 + sin(y3) + 1.06d0) - 0.1d0 - fdata(3) = -(1/20.d0) * exp(-y1*y2) - (10.d0 * PI - 3.0d0) / 60.d0 + fdata(1) = (1.0d0/3.0d0) * cos((y - 1.0d0) * z) + (1.0d0/6.0d0) + fdata(2) = (1.0d0/9.0d0) * sqrt(x*x + sin(z) + 1.06d0) + 0.9d0 + fdata(3) = -(1/20.d0) * exp(-x*(y-1.0d0)) - (10.d0 * PI - 3.0d0) / 60.0d0 + + call FN_VLinearSum(1.0d0, f, -1.0d0, y0, f) retval = 0 end function + integer(C_INT) function check_ans(ycor, tol) & + result(retval) bind(C) + use, intrinsic :: iso_c_binding + implicit none + + type(N_Vector) :: ycor + real(C_DOUBLE), value :: tol + real(C_DOUBLE) :: ex, ey, ez + real(C_DOUBLE), pointer :: data(:) + + ! extract and print solution + data => FN_VGetArrayPointer(ycor) + + write(*,*) 'Solution:' + write(*,'(A,E14.7)') ' x = ', data(1) + write(*,'(A,E14.7)') ' y = ', data(2) + write(*,'(A,E14.7)') ' z = ', data(3) + + ex = data(1) - XTRUE + ey = data(2) - YTRUE + ez = data(3) - ZTRUE + + write(*,*) 'Solution Error:' + write(*,'(A,E14.7)') ' ex = ', ex + write(*,'(A,E14.7)') ' ey = ', ey + write(*,'(A,E14.7)') ' ez = ', ez + + tol = tol * 10.0d0 + if (ex > tol .or. ey > tol .or. ez > tol) then + retval = 1 + end if + + retval = 0 + end function + end module program main @@ -198,7 +241,7 @@ program main integer(C_INT) :: fails = 0 !============== Introduction ============= - print *, 'fixedpoint SUNNonlinearSolver Fortran 2003 interface test' + write(*,*) 'SUNNonlinearSolver_FixedPoint Fortran 2003 interface test' call Test_Init(SUN_COMM_NULL) diff --git a/examples/sunnonlinsol/newton/CMakeLists.txt b/examples/sunnonlinsol/newton/CMakeLists.txt index 08870d929f..2f3413bd0b 100644 --- a/examples/sunnonlinsol/newton/CMakeLists.txt +++ b/examples/sunnonlinsol/newton/CMakeLists.txt @@ -98,6 +98,9 @@ foreach(example_tuple ${fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90) diff --git a/include/cvodes/cvodes.h b/include/cvodes/cvodes.h index 813ded3c7f..8af98fc26c 100644 --- a/include/cvodes/cvodes.h +++ b/include/cvodes/cvodes.h @@ -579,7 +579,8 @@ SUNDIALS_EXPORT int CVodeGetAdjCheckPointsInfo(void* cvode_mem, CVadjCheckPointRec* ckpnt); /* CVLS interface function that depends on CVRhsFn */ -int CVodeSetJacTimesRhsFnB(void* cvode_mem, int which, CVRhsFn jtimesRhsFn); +SUNDIALS_EXPORT int CVodeSetJacTimesRhsFnB(void* cvode_mem, int which, + CVRhsFn jtimesRhsFn); /* Undocumented Optional Output Functions For Backward Problems */ diff --git a/src/nvector/serial/fmod_int32/CMakeLists.txt b/src/nvector/serial/fmod_int32/CMakeLists.txt index 293239b9fb..ebf2ec0182 100644 --- a/src/nvector/serial/fmod_int32/CMakeLists.txt +++ b/src/nvector/serial/fmod_int32/CMakeLists.txt @@ -19,7 +19,6 @@ sundials_add_f2003_library(sundials_fnvecserial_mod fnvector_serial_mod.f90 fnvector_serial_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fnvecserial_mod VERSION diff --git a/src/sunadaptcontroller/imexgus/fmod_int32/CMakeLists.txt b/src/sunadaptcontroller/imexgus/fmod_int32/CMakeLists.txt index 0c9fd4f2c2..0c4142417c 100644 --- a/src/sunadaptcontroller/imexgus/fmod_int32/CMakeLists.txt +++ b/src/sunadaptcontroller/imexgus/fmod_int32/CMakeLists.txt @@ -17,7 +17,6 @@ sundials_add_f2003_library(sundials_fsunadaptcontrollerimexgus_mod fsunadaptcontroller_imexgus_mod.f90 fsunadaptcontroller_imexgus_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunadaptcontrollerimexgus_mod OBJECT_LIB_ONLY diff --git a/src/sunadaptcontroller/imexgus/fmod_int64/CMakeLists.txt b/src/sunadaptcontroller/imexgus/fmod_int64/CMakeLists.txt index 0c9fd4f2c2..0c4142417c 100644 --- a/src/sunadaptcontroller/imexgus/fmod_int64/CMakeLists.txt +++ b/src/sunadaptcontroller/imexgus/fmod_int64/CMakeLists.txt @@ -17,7 +17,6 @@ sundials_add_f2003_library(sundials_fsunadaptcontrollerimexgus_mod fsunadaptcontroller_imexgus_mod.f90 fsunadaptcontroller_imexgus_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunadaptcontrollerimexgus_mod OBJECT_LIB_ONLY diff --git a/src/sunadaptcontroller/soderlind/fmod_int32/CMakeLists.txt b/src/sunadaptcontroller/soderlind/fmod_int32/CMakeLists.txt index 44aa8a4922..cdf9d3825e 100644 --- a/src/sunadaptcontroller/soderlind/fmod_int32/CMakeLists.txt +++ b/src/sunadaptcontroller/soderlind/fmod_int32/CMakeLists.txt @@ -17,7 +17,6 @@ sundials_add_f2003_library(sundials_fsunadaptcontrollersoderlind_mod fsunadaptcontroller_soderlind_mod.f90 fsunadaptcontroller_soderlind_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunadaptcontrollersoderlind_mod OBJECT_LIB_ONLY diff --git a/src/sunadaptcontroller/soderlind/fmod_int64/CMakeLists.txt b/src/sunadaptcontroller/soderlind/fmod_int64/CMakeLists.txt index 44aa8a4922..cdf9d3825e 100644 --- a/src/sunadaptcontroller/soderlind/fmod_int64/CMakeLists.txt +++ b/src/sunadaptcontroller/soderlind/fmod_int64/CMakeLists.txt @@ -17,7 +17,6 @@ sundials_add_f2003_library(sundials_fsunadaptcontrollersoderlind_mod fsunadaptcontroller_soderlind_mod.f90 fsunadaptcontroller_soderlind_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunadaptcontrollersoderlind_mod OBJECT_LIB_ONLY diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt index bde159761c..b8a19e2ff2 100644 --- a/src/sundials/CMakeLists.txt +++ b/src/sundials/CMakeLists.txt @@ -32,6 +32,7 @@ set(sundials_HEADERS sundials_dense.h sundials_direct.h sundials_errors.h + sundials_futils.h sundials_iterative.h sundials_linearsolver.h sundials_linearsolver.hpp @@ -53,10 +54,6 @@ set(sundials_HEADERS sundials_version.h ) -if(BUILD_FORTRAN_MODULE_INTERFACE) - list(APPEND sundials_HEADERS sundials_futils.h) -endif() - if(ENABLE_MPI) list(APPEND sundials_HEADERS sundials_mpi_errors.h) endif() @@ -88,6 +85,7 @@ set(sundials_SOURCES sundials_dense.c sundials_direct.c sundials_errors.c + sundials_futils.c sundials_hashmap.c sundials_iterative.c sundials_linearsolver.c @@ -106,10 +104,6 @@ if(ENABLE_MPI) list(APPEND sundials_SOURCES sundials_mpi_errors.c) endif() -if(BUILD_FORTRAN_MODULE_INTERFACE) - list(APPEND sundials_SOURCES sundials_futils.c) -endif() - # Add prefix with complete path to the source files add_prefix(${SUNDIALS_SOURCE_DIR}/src/sundials/ sundials_SOURCES) diff --git a/src/sundials/fmod_int32/CMakeLists.txt b/src/sundials/fmod_int32/CMakeLists.txt index 74fe6c96ee..957328e8ff 100644 --- a/src/sundials/fmod_int32/CMakeLists.txt +++ b/src/sundials/fmod_int32/CMakeLists.txt @@ -22,6 +22,4 @@ set(sundials_SOURCES sundials_add_f2003_library(sundials_fcore_mod SOURCES ${sundials_SOURCES} - LINK_LIBRARIES - PUBLIC sundials_core ) diff --git a/src/sundials/fmod_int32/fsundials_core_mod.c b/src/sundials/fmod_int32/fsundials_core_mod.c index ad1f31a295..62e0215249 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.c +++ b/src/sundials/fmod_int32/fsundials_core_mod.c @@ -291,13 +291,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { #include "sundials/sundials_adaptcontroller.h" - -SWIGEXPORT SWIGEXTERN int const _wrap_SUN_COMM_NULL = (int)(0); - -SWIGEXPORT SWIGEXTERN int const _wrap_SUNFALSE = (int)(0); - -SWIGEXPORT SWIGEXTERN int const _wrap_SUNTRUE = (int)(1); - SWIGEXPORT void _wrap_FSUNLogErrHandlerFn(int const *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, SwigArrayWrapper *farg4, int const *farg5, void *farg6, void *farg7) { int arg1 ; char *arg2 = (char *) 0 ; diff --git a/src/sundials/fmod_int32/fsundials_core_mod.f90 b/src/sundials/fmod_int32/fsundials_core_mod.f90 index f47a3141f2..2bda4cb0fe 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int32/fsundials_core_mod.f90 @@ -44,14 +44,11 @@ module fsundials_core_mod include "mpif.h" integer(C_INT), protected, public :: SUN_COMM_NULL = MPI_COMM_NULL #else - integer(C_INT), protected, public, & - bind(C, name="_wrap_SUN_COMM_NULL") :: SUN_COMM_NULL + integer(C_INT), parameter, public :: SUN_COMM_NULL = 0_C_INT #endif - integer(C_INT), protected, public, & - bind(C, name="_wrap_SUNFALSE") :: SUNFALSE - integer(C_INT), protected, public, & - bind(C, name="_wrap_SUNTRUE") :: SUNTRUE + integer(C_INT), parameter, public :: SUNFALSE = 0_C_INT + integer(C_INT), parameter, public :: SUNTRUE = 1_C_INT ! typedef enum SUNOutputFormat enum, bind(c) enumerator :: SUN_OUTPUTFORMAT_TABLE diff --git a/src/sundials/fmod_int64/CMakeLists.txt b/src/sundials/fmod_int64/CMakeLists.txt index 74fe6c96ee..957328e8ff 100644 --- a/src/sundials/fmod_int64/CMakeLists.txt +++ b/src/sundials/fmod_int64/CMakeLists.txt @@ -22,6 +22,4 @@ set(sundials_SOURCES sundials_add_f2003_library(sundials_fcore_mod SOURCES ${sundials_SOURCES} - LINK_LIBRARIES - PUBLIC sundials_core ) diff --git a/src/sundials/fmod_int64/fsundials_core_mod.c b/src/sundials/fmod_int64/fsundials_core_mod.c index 9fa73f722b..2478b92d68 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.c +++ b/src/sundials/fmod_int64/fsundials_core_mod.c @@ -291,13 +291,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { #include "sundials/sundials_adaptcontroller.h" - -SWIGEXPORT SWIGEXTERN int const _wrap_SUN_COMM_NULL = (int)(0); - -SWIGEXPORT SWIGEXTERN int const _wrap_SUNFALSE = (int)(0); - -SWIGEXPORT SWIGEXTERN int const _wrap_SUNTRUE = (int)(1); - SWIGEXPORT void _wrap_FSUNLogErrHandlerFn(int const *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, SwigArrayWrapper *farg4, int const *farg5, void *farg6, void *farg7) { int arg1 ; char *arg2 = (char *) 0 ; diff --git a/src/sundials/fmod_int64/fsundials_core_mod.f90 b/src/sundials/fmod_int64/fsundials_core_mod.f90 index c51487dd30..7096d0c6ce 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int64/fsundials_core_mod.f90 @@ -44,14 +44,11 @@ module fsundials_core_mod include "mpif.h" integer(C_INT), protected, public :: SUN_COMM_NULL = MPI_COMM_NULL #else - integer(C_INT), protected, public, & - bind(C, name="_wrap_SUN_COMM_NULL") :: SUN_COMM_NULL + integer(C_INT), parameter, public :: SUN_COMM_NULL = 0_C_INT #endif - integer(C_INT), protected, public, & - bind(C, name="_wrap_SUNFALSE") :: SUNFALSE - integer(C_INT), protected, public, & - bind(C, name="_wrap_SUNTRUE") :: SUNTRUE + integer(C_INT), parameter, public :: SUNFALSE = 0_C_INT + integer(C_INT), parameter, public :: SUNTRUE = 1_C_INT ! typedef enum SUNOutputFormat enum, bind(c) enumerator :: SUN_OUTPUTFORMAT_TABLE diff --git a/src/sundials/sundials_nvector.c b/src/sundials/sundials_nvector.c index 46791fa66c..9b15332993 100644 --- a/src/sundials/sundials_nvector.c +++ b/src/sundials/sundials_nvector.c @@ -284,8 +284,8 @@ N_Vector N_VClone(N_Vector w) { N_Vector result = NULL; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(w)); - result = w->ops->nvclone(w); - result->sunctx = w->sunctx; + result = w->ops->nvclone(w); + if (result) { result->sunctx = w->sunctx; } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(w)); return result; } @@ -294,8 +294,8 @@ N_Vector N_VCloneEmpty(N_Vector w) { N_Vector result; SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(w)); - result = w->ops->nvcloneempty(w); - result->sunctx = w->sunctx; + result = w->ops->nvcloneempty(w); + if (result) { result->sunctx = w->sunctx; } SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(w)); return result; } diff --git a/src/sunlinsol/band/fmod_int32/CMakeLists.txt b/src/sunlinsol/band/fmod_int32/CMakeLists.txt index 250f17c914..8b6e38724e 100644 --- a/src/sunlinsol/band/fmod_int32/CMakeLists.txt +++ b/src/sunlinsol/band/fmod_int32/CMakeLists.txt @@ -18,10 +18,7 @@ sundials_add_f2003_library(sundials_fsunlinsolband_mod SOURCES fsunlinsol_band_mod.f90 fsunlinsol_band_mod.c LINK_LIBRARIES - PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES - LINK_LIBRARIES - PUBLIC sundials_fsunmatrixband_mod + PUBLIC sundials_fsunmatrixband_mod sundials_fcore_mod OUTPUT_NAME sundials_fsunlinsolband_mod VERSION diff --git a/src/sunlinsol/dense/fmod_int32/CMakeLists.txt b/src/sunlinsol/dense/fmod_int32/CMakeLists.txt index 61bdf87108..3a1329e120 100644 --- a/src/sunlinsol/dense/fmod_int32/CMakeLists.txt +++ b/src/sunlinsol/dense/fmod_int32/CMakeLists.txt @@ -18,10 +18,7 @@ sundials_add_f2003_library(sundials_fsunlinsoldense_mod SOURCES fsunlinsol_dense_mod.f90 fsunlinsol_dense_mod.c LINK_LIBRARIES - PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES - LINK_LIBRARIES - PUBLIC sundials_fsunmatrixdense_mod + PUBLIC sundials_fsunmatrixdense_mod sundials_fcore_mod OUTPUT_NAME sundials_fsunlinsoldense_mod VERSION diff --git a/src/sunlinsol/klu/fmod_int64/CMakeLists.txt b/src/sunlinsol/klu/fmod_int64/CMakeLists.txt index 4a0323d921..683f76cc3b 100644 --- a/src/sunlinsol/klu/fmod_int64/CMakeLists.txt +++ b/src/sunlinsol/klu/fmod_int64/CMakeLists.txt @@ -18,10 +18,7 @@ sundials_add_f2003_library(sundials_fsunlinsolklu_mod SOURCES fsunlinsol_klu_mod.f90 fsunlinsol_klu_mod.c LINK_LIBRARIES - PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES - LINK_LIBRARIES - PUBLIC sundials_fsunmatrixsparse_mod + PUBLIC sundials_fsunmatrixsparse_mod sundials_fcore_mod OUTPUT_NAME sundials_fsunlinsolklu_mod VERSION diff --git a/src/sunlinsol/lapackdense/fmod_int32/CMakeLists.txt b/src/sunlinsol/lapackdense/fmod_int32/CMakeLists.txt index 12bcb2fae2..72b9d5acda 100644 --- a/src/sunlinsol/lapackdense/fmod_int32/CMakeLists.txt +++ b/src/sunlinsol/lapackdense/fmod_int32/CMakeLists.txt @@ -19,10 +19,7 @@ sundials_add_f2003_library(sundials_fsunlinsollapackdense_mod SOURCES fsunlinsol_lapackdense_mod.f90 fsunlinsol_lapackdense_mod.c LINK_LIBRARIES - PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES - LINK_LIBRARIES - PUBLIC sundials_fsunmatrixdense_mod + PUBLIC sundials_fsunmatrixdense_mod sundials_fcore_mod OUTPUT_NAME sundials_fsunlinsollapackdense_mod VERSION diff --git a/src/sunlinsol/pcg/fmod_int32/CMakeLists.txt b/src/sunlinsol/pcg/fmod_int32/CMakeLists.txt index 535741e7d6..e863f286ee 100644 --- a/src/sunlinsol/pcg/fmod_int32/CMakeLists.txt +++ b/src/sunlinsol/pcg/fmod_int32/CMakeLists.txt @@ -19,7 +19,6 @@ sundials_add_f2003_library(sundials_fsunlinsolpcg_mod fsunlinsol_pcg_mod.f90 fsunlinsol_pcg_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunlinsolpcg_mod VERSION diff --git a/src/sunlinsol/spbcgs/fmod_int32/CMakeLists.txt b/src/sunlinsol/spbcgs/fmod_int32/CMakeLists.txt index d1b588396f..d05fdd7d0c 100644 --- a/src/sunlinsol/spbcgs/fmod_int32/CMakeLists.txt +++ b/src/sunlinsol/spbcgs/fmod_int32/CMakeLists.txt @@ -19,7 +19,6 @@ sundials_add_f2003_library(sundials_fsunlinsolspbcgs_mod fsunlinsol_spbcgs_mod.f90 fsunlinsol_spbcgs_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunlinsolspbcgs_mod VERSION diff --git a/src/sunlinsol/spfgmr/fmod_int64/CMakeLists.txt b/src/sunlinsol/spfgmr/fmod_int64/CMakeLists.txt index c2cbd50123..4a236368f8 100644 --- a/src/sunlinsol/spfgmr/fmod_int64/CMakeLists.txt +++ b/src/sunlinsol/spfgmr/fmod_int64/CMakeLists.txt @@ -19,7 +19,6 @@ sundials_add_f2003_library(sundials_fsunlinsolspfgmr_mod fsunlinsol_spfgmr_mod.f90 fsunlinsol_spfgmr_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunlinsolspfgmr_mod VERSION diff --git a/src/sunlinsol/spgmr/fmod_int64/CMakeLists.txt b/src/sunlinsol/spgmr/fmod_int64/CMakeLists.txt index 9ea74e0e45..005f891f6c 100644 --- a/src/sunlinsol/spgmr/fmod_int64/CMakeLists.txt +++ b/src/sunlinsol/spgmr/fmod_int64/CMakeLists.txt @@ -19,7 +19,6 @@ sundials_add_f2003_library(sundials_fsunlinsolspgmr_mod fsunlinsol_spgmr_mod.f90 fsunlinsol_spgmr_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunlinsolspgmr_mod VERSION diff --git a/src/sunlinsol/sptfqmr/fmod_int64/CMakeLists.txt b/src/sunlinsol/sptfqmr/fmod_int64/CMakeLists.txt index ff3dc41956..2aa92f9022 100644 --- a/src/sunlinsol/sptfqmr/fmod_int64/CMakeLists.txt +++ b/src/sunlinsol/sptfqmr/fmod_int64/CMakeLists.txt @@ -19,7 +19,6 @@ sundials_add_f2003_library(sundials_fsunlinsolsptfqmr_mod fsunlinsol_sptfqmr_mod.f90 fsunlinsol_sptfqmr_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunlinsolsptfqmr_mod VERSION diff --git a/src/sunmatrix/band/fmod_int32/CMakeLists.txt b/src/sunmatrix/band/fmod_int32/CMakeLists.txt index 465260d783..6026568af8 100644 --- a/src/sunmatrix/band/fmod_int32/CMakeLists.txt +++ b/src/sunmatrix/band/fmod_int32/CMakeLists.txt @@ -19,7 +19,6 @@ sundials_add_f2003_library(sundials_fsunmatrixband_mod fsunmatrix_band_mod.f90 fsunmatrix_band_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunmatrixband_mod VERSION diff --git a/src/sunmatrix/dense/fmod_int64/CMakeLists.txt b/src/sunmatrix/dense/fmod_int64/CMakeLists.txt index 987102b9f6..6b11defa31 100644 --- a/src/sunmatrix/dense/fmod_int64/CMakeLists.txt +++ b/src/sunmatrix/dense/fmod_int64/CMakeLists.txt @@ -19,7 +19,6 @@ sundials_add_f2003_library(sundials_fsunmatrixdense_mod fsunmatrix_dense_mod.f90 fsunmatrix_dense_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunmatrixdense_mod VERSION diff --git a/src/sunmatrix/sparse/fmod_int32/CMakeLists.txt b/src/sunmatrix/sparse/fmod_int32/CMakeLists.txt index fb0ed79b4c..407bddff70 100644 --- a/src/sunmatrix/sparse/fmod_int32/CMakeLists.txt +++ b/src/sunmatrix/sparse/fmod_int32/CMakeLists.txt @@ -19,7 +19,6 @@ sundials_add_f2003_library(sundials_fsunmatrixsparse_mod fsunmatrix_sparse_mod.f90 fsunmatrix_sparse_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunmatrixsparse_mod VERSION diff --git a/src/sunnonlinsol/fixedpoint/fmod_int64/CMakeLists.txt b/src/sunnonlinsol/fixedpoint/fmod_int64/CMakeLists.txt index bb2f0097b6..6e24d5269c 100644 --- a/src/sunnonlinsol/fixedpoint/fmod_int64/CMakeLists.txt +++ b/src/sunnonlinsol/fixedpoint/fmod_int64/CMakeLists.txt @@ -20,7 +20,6 @@ sundials_add_f2003_library(sundials_fsunnonlinsolfixedpoint_mod fsunnonlinsol_fixedpoint_mod.f90 fsunnonlinsol_fixedpoint_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunnonlinsolfixedpoint_mod VERSION diff --git a/src/sunnonlinsol/newton/fmod_int32/CMakeLists.txt b/src/sunnonlinsol/newton/fmod_int32/CMakeLists.txt index 46be1ab585..883fac35ed 100644 --- a/src/sunnonlinsol/newton/fmod_int32/CMakeLists.txt +++ b/src/sunnonlinsol/newton/fmod_int32/CMakeLists.txt @@ -20,7 +20,6 @@ sundials_add_f2003_library(sundials_fsunnonlinsolnewton_mod fsunnonlinsol_newton_mod.f90 fsunnonlinsol_newton_mod.c LINK_LIBRARIES PUBLIC sundials_fcore_mod - OBJECT_LIBRARIES OUTPUT_NAME sundials_fsunnonlinsolnewton_mod VERSION diff --git a/swig/Makefile b/swig/Makefile index f8aabe16ba..eb772623e9 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -14,6 +14,8 @@ # Makefile to generate SUNDIALS fortran interfaces with swig # --------------------------------------------------------------- +SWIG ?= swig + ARKODE=farkode_mod farkode_arkstep_mod farkode_erkstep_mod farkode_sprkstep_mod farkode_mristep_mod CVODE=fcvode_mod CVODES=fcvodes_mod @@ -48,77 +50,77 @@ modules: core arkode cvode cvodes ida idas kinsol nvector sunmatrix sunlinsol su core: $(CORE:%:sundials/%.i) @for i in ${CORE} ; do \ set -x; \ - swig -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/sundials/fmod_int${INT_SIZE} -o ../src/sundials/fmod_int${INT_SIZE}/$${i}.c ${INCLUDES} sundials/$${i}.i; \ + ${SWIG} -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/sundials/fmod_int${INT_SIZE} -o ../src/sundials/fmod_int${INT_SIZE}/$${i}.c ${INCLUDES} sundials/$${i}.i; \ done arkode: $(ARKODE:%:arkode/%.i) @for i in ${ARKODE} ; do \ set -x; \ - swig -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/arkode/fmod_int${INT_SIZE} -o ../src/arkode/fmod_int${INT_SIZE}/$${i}.c ${INCLUDES} arkode/$${i}.i; \ + ${SWIG} -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/arkode/fmod_int${INT_SIZE} -o ../src/arkode/fmod_int${INT_SIZE}/$${i}.c ${INCLUDES} arkode/$${i}.i; \ done cvode: $(CVODE:%:cvode/%.i) @for i in ${CVODE} ; do \ set -x; \ - swig -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/cvode/fmod_int${INT_SIZE} -o ../src/cvode/fmod_int${INT_SIZE}/$${i}.c ${INCLUDES} cvode/$${i}.i; \ + ${SWIG} -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/cvode/fmod_int${INT_SIZE} -o ../src/cvode/fmod_int${INT_SIZE}/$${i}.c ${INCLUDES} cvode/$${i}.i; \ done cvodes: $(CVODE:%:cvodes/%.i) @for i in ${CVODES} ; do \ set -x; \ - swig -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/cvodes/fmod_int${INT_SIZE} -o ../src/cvodes/fmod_int${INT_SIZE}/$${i}.c ${INCLUDES} cvodes/$${i}.i; \ + ${SWIG} -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/cvodes/fmod_int${INT_SIZE} -o ../src/cvodes/fmod_int${INT_SIZE}/$${i}.c ${INCLUDES} cvodes/$${i}.i; \ done ida: $(IDA:%:ida/%.i) @for i in ${IDA} ; do \ set -x; \ - swig -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/ida/fmod_int${INT_SIZE} -o ../src/ida/fmod_int${INT_SIZE}/$${i}.c ${INCLUDES} ida/$${i}.i; \ + ${SWIG} -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/ida/fmod_int${INT_SIZE} -o ../src/ida/fmod_int${INT_SIZE}/$${i}.c ${INCLUDES} ida/$${i}.i; \ done idas: $(IDAS:%:idas/%.i) @for i in ${IDAS} ; do \ set -x; \ - swig -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/idas/fmod_int${INT_SIZE} -o ../src/idas/fmod_int${INT_SIZE}/$${i}.c ${INCLUDES} idas/$${i}.i; \ + ${SWIG} -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/idas/fmod_int${INT_SIZE} -o ../src/idas/fmod_int${INT_SIZE}/$${i}.c ${INCLUDES} idas/$${i}.i; \ done kinsol: $(KINSOL:%:kinsol/%.i) @for i in ${KINSOL} ; do \ set -x; \ - swig -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/kinsol/fmod_int${INT_SIZE} -o ../src/kinsol/fmod_int${INT_SIZE}/$${i}.c ${INCLUDES} kinsol/$${i}.i; \ + ${SWIG} -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/kinsol/fmod_int${INT_SIZE} -o ../src/kinsol/fmod_int${INT_SIZE}/$${i}.c ${INCLUDES} kinsol/$${i}.i; \ done nvector: $(NVECTOR:%:nvector/fnvector_%_mod.i) mpimanyvector @for i in ${NVECTOR} ; do \ set -x; \ - swig -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/nvector/$${i}/fmod_int${INT_SIZE} -o ../src/nvector/$${i}/fmod_int${INT_SIZE}/fnvector_$${i}_mod.c ${INCLUDES} nvector/fnvector_$${i}_mod.i; \ + ${SWIG} -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/nvector/$${i}/fmod_int${INT_SIZE} -o ../src/nvector/$${i}/fmod_int${INT_SIZE}/fnvector_$${i}_mod.c ${INCLUDES} nvector/fnvector_$${i}_mod.i; \ done mpimanyvector: nvector/fnvector_mpimanyvector_mod.i set -x; \ - swig -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/nvector/manyvector/fmod_int${INT_SIZE} -o ../src/nvector/manyvector/fmod_int${INT_SIZE}/fnvector_mpimanyvector_mod.c ${INCLUDES} nvector/fnvector_mpimanyvector_mod.i; + ${SWIG} -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/nvector/manyvector/fmod_int${INT_SIZE} -o ../src/nvector/manyvector/fmod_int${INT_SIZE}/fnvector_mpimanyvector_mod.c ${INCLUDES} nvector/fnvector_mpimanyvector_mod.i; sunmatrix: $(SUNMATRIX:%:sunmatrix/fsunmatrix_%_mod.i) @for i in ${SUNMATRIX} ; do \ set -x; \ - swig -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/sunmatrix/$${i}/fmod_int${INT_SIZE} -o ../src/sunmatrix/$${i}/fmod_int${INT_SIZE}/fsunmatrix_$${i}_mod.c ${INCLUDES} sunmatrix/fsunmatrix_$${i}_mod.i; \ + ${SWIG} -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/sunmatrix/$${i}/fmod_int${INT_SIZE} -o ../src/sunmatrix/$${i}/fmod_int${INT_SIZE}/fsunmatrix_$${i}_mod.c ${INCLUDES} sunmatrix/fsunmatrix_$${i}_mod.i; \ done sunlinsol: $(SUNLINSOL:%:sunlinsol/fsunlinsol_%_mod.i) @for i in ${SUNLINSOL} ; do \ set -x; \ - swig -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/sunlinsol/$${i}/fmod_int${INT_SIZE} -o ../src/sunlinsol/$${i}/fmod_int${INT_SIZE}/fsunlinsol_$${i}_mod.c ${INCLUDES} sunlinsol/fsunlinsol_$${i}_mod.i; \ + ${SWIG} -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/sunlinsol/$${i}/fmod_int${INT_SIZE} -o ../src/sunlinsol/$${i}/fmod_int${INT_SIZE}/fsunlinsol_$${i}_mod.c ${INCLUDES} sunlinsol/fsunlinsol_$${i}_mod.i; \ done sunnonlinsol: $(SUNNONLINSOL:%:sunnonlinsol/fsunnonlinsol_%_mod.i) @for i in ${SUNNONLINSOL} ; do \ set -x; \ - swig -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/sunnonlinsol/$${i}/fmod_int${INT_SIZE} -o ../src/sunnonlinsol/$${i}/fmod_int${INT_SIZE}/fsunnonlinsol_$${i}_mod.c ${INCLUDES} sunnonlinsol/fsunnonlinsol_$${i}_mod.i; \ + ${SWIG} -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/sunnonlinsol/$${i}/fmod_int${INT_SIZE} -o ../src/sunnonlinsol/$${i}/fmod_int${INT_SIZE}/fsunnonlinsol_$${i}_mod.c ${INCLUDES} sunnonlinsol/fsunnonlinsol_$${i}_mod.i; \ done sunadaptcontroller: $(SUNADAPTCONTROLLER:%:sunadaptcontroller/fsunadaptcontroller_%_mod.i) @for i in ${SUNADAPTCONTROLLER} ; do \ set -x; \ - swig -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/sunadaptcontroller/$${i}/fmod_int${INT_SIZE} -o ../src/sunadaptcontroller/$${i}/fmod_int${INT_SIZE}/fsunadaptcontroller_$${i}_mod.c ${INCLUDES} sunadaptcontroller/fsunadaptcontroller_$${i}_mod.i; \ + ${SWIG} -DGENERATE_INT${INT_SIZE} -fortran -outdir ../src/sunadaptcontroller/$${i}/fmod_int${INT_SIZE} -o ../src/sunadaptcontroller/$${i}/fmod_int${INT_SIZE}/fsunadaptcontroller_$${i}_mod.c ${INCLUDES} sunadaptcontroller/fsunadaptcontroller_$${i}_mod.i; \ done clean: diff --git a/swig/sundials/fsundials_types.i b/swig/sundials/fsundials_types.i index 248ec9d5e7..0f61838b50 100644 --- a/swig/sundials/fsundials_types.i +++ b/swig/sundials/fsundials_types.i @@ -15,6 +15,9 @@ // Swig interface file // --------------------------------------------------------------- +// By default, wrap all constants as native fortran PARAMETERs +%fortranconst; + %include #ifdef GENERATE_INT32 @@ -85,17 +88,12 @@ // (1) SWIG expands SUN_COMM_NULL to its value // (2) We need it to be equivalent to MPI_COMM_NULL when MPI is enabled -%insert("wrapper") %{ -SWIGEXPORT SWIGEXTERN int const _wrap_SUN_COMM_NULL = (int)(0); -%} - %insert("fdecl") %{ #if SUNDIALS_MPI_ENABLED include "mpif.h" integer(C_INT), protected, public :: SUN_COMM_NULL = MPI_COMM_NULL #else - integer(C_INT), protected, public, & - bind(C, name="_wrap_SUN_COMM_NULL") :: SUN_COMM_NULL + integer(C_INT), parameter, public :: SUN_COMM_NULL = 0_C_INT #endif %}