From 5d1d8f2b987386e3e444043d64deff9385e4a389 Mon Sep 17 00:00:00 2001 From: Cody Balos Date: Wed, 27 Mar 2024 13:32:10 -0700 Subject: [PATCH] Bugfix: Fix c_null_ptr bug in some Fortran examples (#449) Fixed a bug in some Fortran examples where `c_null_ptr` was passed as an argument to a function pointer instead of `c_null_funptr`. --- CHANGELOG.md | 8 ++++++-- doc/shared/RecentChanges.rst | 8 ++++++-- examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 | 2 +- .../arkode/F2003_serial/ark_bruss1D_FEM_klu_f2003.f90 | 2 +- examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.f90 | 2 +- examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 | 2 +- examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 | 2 +- examples/cvode/F2003_parallel/cv_diag_kry_bbd_f2003.f90 | 2 +- examples/cvode/F2003_parallel/cv_diag_kry_f2003.f90 | 2 +- 9 files changed, 19 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8c355ad73..62512bb8b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,12 @@ Fixed a bug in the HIP execution policies where `WARP_SIZE` would not be set with ROCm 6.0.0 or newer. Changed the CMake version compatibility mode for SUNDIALS to `AnyNewerVersion` -instead of `SameMajorVersion`. This fixes the issue seen -[here](https://github.com/AMReX-Codes/amrex/pull/3835). +instead of `SameMajorVersion`. This fixes the issue seen +[here](https://github.com/AMReX-Codes/amrex/pull/3835). + +Fixed a bug in some Fortran examples where `c_null_ptr` was passed as an argument +to a function pointer instead of `c_null_funptr`. This caused compilation issues +with the Cray Fortran compiler. ## Changes to SUNDIALS in release v7.0.0 diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index b57a0aed10..7dc83fc3a4 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -10,5 +10,9 @@ Fixed a bug in the HIP execution policies where ``WARP_SIZE`` would not be set with ROCm 6.0.0 or newer. Changed the CMake version compatibility mode for SUNDIALS to ``AnyNewerVersion`` -instead of ``SameMajorVersion``. This fixes the issue seen -`here `_. +instead of ``SameMajorVersion``. This fixes the issue seen +`here `_. + +Fixed a bug in some Fortran examples where ``c_null_ptr`` was passed as an argument +to a function pointer instead of ``c_null_funptr``. This caused compilation issues +with the Cray Fortran compiler. diff --git a/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 b/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 index 18fb0f4600..50c54e0211 100644 --- a/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 +++ b/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 @@ -751,7 +751,7 @@ program driver y = 0.d0 ! Create the ARKStep timestepper module - arkode_mem = FARKStepCreate(c_null_ptr, c_funloc(frhs), t0, sunvec_y, sunctx) + arkode_mem = FARKStepCreate(c_null_funptr, c_funloc(frhs), t0, sunvec_y, sunctx) if (.not. c_associated(arkode_mem)) then print *, "Error: FARKStepCreate returned NULL" call MPI_Abort(comm, 1, ierr) 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 8adb2d54bc..6389a9e7de 100644 --- a/examples/arkode/F2003_serial/ark_bruss1D_FEM_klu_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_bruss1D_FEM_klu_f2003.f90 @@ -1143,7 +1143,7 @@ program main end do ! create ARKStep memory - arkode_mem = FARKStepCreate(c_null_ptr, c_funloc(ImpRhsFn), tstart, sunvec_y, ctx) + arkode_mem = FARKStepCreate(c_null_funptr, c_funloc(ImpRhsFn), tstart, sunvec_y, ctx) if (.not. c_associated(arkode_mem)) print *,'ERROR: arkode_mem = NULL' ! Tell ARKODE to use a sparse linear solver for both Newton and mass matrix systems. 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 2f8fdd3aa8..372cbf1642 100644 --- a/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.f90 @@ -283,7 +283,7 @@ program main end do ! create ARKStep memory - arkode_mem = FARKStepCreate(c_null_ptr, c_funloc(ImpRhsFn), tstart, sunvec_u, ctx) + arkode_mem = FARKStepCreate(c_null_funptr, c_funloc(ImpRhsFn), tstart, sunvec_u, ctx) if (.not. c_associated(arkode_mem)) print *,'ERROR: arkode_mem = NULL' ! Tell ARKODE to use a SPGMR linear solver. diff --git a/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 b/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 index e9f0d6cc4d..a57dd5f9c6 100644 --- a/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 @@ -272,7 +272,7 @@ program main call PrintHeader(rtol, avtol, yval) ! Call FARKStepCreate to initialize ARKODE memory - arkode_mem = FARKStepCreate(c_null_ptr, c_funloc(fcnirob), t0, sunvec_y, sunctx) + arkode_mem = FARKStepCreate(c_null_funptr, c_funloc(fcnirob), t0, sunvec_y, sunctx) if (.not. c_associated(arkode_mem)) print *, 'ERROR: arkode_mem = NULL' ! Call FARKStepSVtolerances to set tolerances diff --git a/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 b/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 index 2cad00ef0d..30b41329ee 100644 --- a/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 @@ -275,7 +275,7 @@ program main call PrintHeader(rtol, avtol, yval) ! Call FARKStepCreate to initialize ARKODE memory - arkode_mem = FARKStepCreate(c_null_ptr, c_funloc(fcnirob), t0, sunvec_y, sunctx) + arkode_mem = FARKStepCreate(c_null_funptr, c_funloc(fcnirob), t0, sunvec_y, sunctx) if (.not. c_associated(arkode_mem)) print *, 'ERROR: arkode_mem = NULL' ! Call FARKStepSVtolerances to set tolerances 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 6bec77fed7..1710a0d061 100644 --- a/examples/cvode/F2003_parallel/cv_diag_kry_bbd_f2003.f90 +++ b/examples/cvode/F2003_parallel/cv_diag_kry_bbd_f2003.f90 @@ -304,7 +304,7 @@ program driver mudq = 0 mldq = 0 retval = FCVBBDPrecInit(cvode_mem, nlocal, mudq, mldq, mu, ml, 0.d0, & - c_funloc(LocalgFn), c_null_ptr) + c_funloc(LocalgFn), c_null_funptr) if (retval /= 0) then print *, "Error: FCVBBDPrecInit returned ", retval call MPI_Abort(comm, 1, ierr) diff --git a/examples/cvode/F2003_parallel/cv_diag_kry_f2003.f90 b/examples/cvode/F2003_parallel/cv_diag_kry_f2003.f90 index 1d657e245f..9061936dfa 100644 --- a/examples/cvode/F2003_parallel/cv_diag_kry_f2003.f90 +++ b/examples/cvode/F2003_parallel/cv_diag_kry_f2003.f90 @@ -319,7 +319,7 @@ program driver call MPI_Abort(comm, 1, ierr) end if - retval = FCVodeSetPreconditioner(cvode_mem, c_null_ptr, c_funloc(Psolve)) + retval = FCVodeSetPreconditioner(cvode_mem, c_null_funptr, c_funloc(Psolve)) if (retval /= 0) then print *, "Error: FCVodeSetPreconditioner returned ", retval call MPI_Abort(comm, 1, ierr)