diff --git a/examples/arkode/F2003_parallel/ark_brusselator1D_task_local_nls_f2003.f90 b/examples/arkode/F2003_parallel/ark_brusselator1D_task_local_nls_f2003.f90 index 2241af2648..620206eb78 100644 --- a/examples/arkode/F2003_parallel/ark_brusselator1D_task_local_nls_f2003.f90 +++ b/examples/arkode/F2003_parallel/ark_brusselator1D_task_local_nls_f2003.f90 @@ -668,7 +668,7 @@ integer(c_int) function TaskLocalLSolve(sunvec_delta, arkode_mem) & type(c_ptr), value :: arkode_mem ! ARKODE memory structure ! residual data - type(c_ptr), value :: user_data + type(c_ptr) :: user_data real(c_double) :: tcur(1) ! current time real(c_double) :: gam(1) ! current gamma 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 785c95994b..e62fecdfa9 100644 --- a/examples/arkode/F2003_parallel/ark_diag_kry_bbd_f2003.f90 +++ b/examples/arkode/F2003_parallel/ark_diag_kry_bbd_f2003.f90 @@ -206,7 +206,6 @@ program driver integer(c_long) :: lenrwbbd(1) ! band preconditioner real/int workspace size integer(c_long) :: leniwbbd(1) integer :: i, ioutput - integer, pointer :: commptr real(c_double) :: errmax, erri, gerrmax ! Initialize MPI variables @@ -236,8 +235,7 @@ program driver alpha = 10.0d0 ! Create SUNDIALS simulation context, now that comm has been configured - commptr => comm - retval = FSUNContext_Create(c_loc(commptr), sunctx) + retval = FSUNContext_Create(comm, sunctx) if (retval /= 0) then print *, "Error: FSUNContext_Create returned ",retval call MPI_Abort(comm, 1, ierr) diff --git a/examples/arkode/F2003_parallel/ark_diag_non_f2003.f90 b/examples/arkode/F2003_parallel/ark_diag_non_f2003.f90 index 38bcf6ef40..bcba262ecc 100644 --- a/examples/arkode/F2003_parallel/ark_diag_non_f2003.f90 +++ b/examples/arkode/F2003_parallel/ark_diag_non_f2003.f90 @@ -147,7 +147,6 @@ program driver integer(c_long) :: nfe(1) ! number of explicit RHS evals integer(c_long) :: netf(1) ! number of error test fails integer :: i, ioutput - integer, pointer :: commptr real(c_double) :: errmax, erri, gerrmax ! Initialize MPI variables @@ -177,8 +176,7 @@ program driver alpha = 10.0d0 / neq ! Create SUNDIALS simulation context, now that comm has been configured - commptr => comm - retval = FSUNContext_Create(c_loc(commptr), sunctx) + retval = FSUNContext_Create(comm, sunctx) if (retval /= 0) then print *, "Error: FSUNContext_Create returned ",retval call MPI_Abort(comm, 1, ierr) diff --git a/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 b/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 index 780c7951bd..ccefdff80f 100644 --- a/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 +++ b/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 @@ -699,7 +699,6 @@ program driver integer(c_long) :: npsol(1) ! number of preconditioner solves integer :: i, j, ioutput character*100 :: outname - integer, pointer :: commptr ! initialize MPI call MPI_Init(ierr) @@ -730,8 +729,7 @@ program driver end if ! Create SUNDIALS simulation context, now that comm has been configured - commptr => comm - retval = FSUNContext_Create(c_loc(commptr), sunctx) + retval = FSUNContext_Create(comm, sunctx) if (retval /= 0) then print *, "Error: FSUNContext_Create returned ",retval 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 637288d534..e182891083 100644 --- a/examples/arkode/F2003_serial/ark_bruss1D_FEM_klu_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_bruss1D_FEM_klu_f2003.f90 @@ -1028,6 +1028,7 @@ program main !======= Inclusions =========== use, intrinsic :: iso_c_binding + use fsundials_types_mod use bruss1D_ode_mod ! custom problem-specification module use farkode_mod ! Fortran interface to the ARKODE module use farkode_arkstep_mod ! Fortran interface to the ARKStep module @@ -1079,7 +1080,7 @@ program main !======= Internals ============ ! create the SUNDIALS context - ierr = FSUNContext_Create(c_null_ptr, ctx) + ierr = FSUNContext_Create(SUN_COMM_NULL, ctx) ! initialize ODE tstart = 0.0d0 diff --git a/examples/arkode/F2003_serial/ark_bruss_f2003.f90 b/examples/arkode/F2003_serial/ark_bruss_f2003.f90 index 978e2c66c9..aaa13b050d 100644 --- a/examples/arkode/F2003_serial/ark_bruss_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_bruss_f2003.f90 @@ -233,6 +233,7 @@ program main !======= Inclusions =========== use, intrinsic :: iso_c_binding + use fsundials_types_mod use farkode_mod ! Fortran interface to the ARKODE module use farkode_arkstep_mod ! Fortran interface to the ARKStep module use fsundials_nvector_mod ! Fortran interface to the generic N_Vector @@ -274,7 +275,7 @@ program main !======= Internals ============ ! create the SUNDIALS context - ierr = FSUNContext_Create(c_null_ptr, sunctx) + ierr = FSUNContext_Create(SUN_COMM_NULL, sunctx) ! initialize ODE tstart = 0.0d0 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 a61341e81d..8922336714 100644 --- a/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.f90 @@ -213,6 +213,7 @@ program main !======= Inclusions =========== use, intrinsic :: iso_c_binding + use fsundials_types_mod use farkode_mod ! Fortran interface to the ARKODE module use farkode_arkstep_mod ! Fortran interface to the ARKStep module use fsundials_nvector_mod ! Fortran interface to the generic N_Vector @@ -251,7 +252,7 @@ program main !======= Internals ============ ! create the SUNDIALS context - ierr = FSUNContext_Create(c_null_ptr, ctx) + ierr = FSUNContext_Create(SUN_COMM_NULL, ctx) ! initialize ODE tstart = 0.0d0 diff --git a/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 b/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 index 83e3ef3304..2cb70b62fb 100644 --- a/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 @@ -244,7 +244,7 @@ program main !======= Internals ============ ! create the SUNDIALS context - retval = FSUNContext_Create(c_null_ptr, sunctx) + retval = FSUNContext_Create(SUN_COMM_NULL, sunctx) ! initialize solution vectors and tolerances yval(1) = 1.d0 diff --git a/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 b/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 index 523e53ed74..3975a9ee51 100644 --- a/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 @@ -204,6 +204,7 @@ program main !======= Inclusions =========== use, intrinsic :: iso_c_binding + use fsundials_types_mod use farkode_mod ! Fortran interface to ARKODE use farkode_arkstep_mod ! Fortran interface to the ARKStep module use fsundials_context_mod ! Fortran interface to SUNContext @@ -245,7 +246,7 @@ program main !======= Internals ============ ! create the SUNDIALS context - retval = FSUNContext_Create(c_null_ptr, sunctx) + retval = FSUNContext_Create(SUN_COMM_NULL, sunctx) ! initialize solution vectors and tolerances yval(1) = 1.d0 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 d1335f4bd1..6bec77fed7 100644 --- a/examples/cvode/F2003_parallel/cv_diag_kry_bbd_f2003.f90 +++ b/examples/cvode/F2003_parallel/cv_diag_kry_bbd_f2003.f90 @@ -25,28 +25,28 @@ module DiagkrybbdData ! Description: ! Module containing problem-defining parameters. !--------------------------------------------------------------- - + !======= Inclusions =========== use, intrinsic :: iso_c_binding - + use fsundials_nvector_mod - + !======= Declarations ========= implicit none - + ! With MPI-3 use mpi_f08 is preferred include "mpif.h" - + save - + ! SUNDIALS simulation context type(c_ptr) :: sunctx - + ! MPI domain decomposition information integer, target :: comm ! communicator object integer :: myid ! MPI process ID integer :: nprocs ! total number of MPI processes - + ! Problem parameters integer(c_int), parameter :: iGStype = 1 integer(c_int), parameter :: iPretype0 = 1 @@ -54,99 +54,99 @@ module DiagkrybbdData integer(c_long) :: neq, mu, ml, mudq, mldq integer(c_int) :: iPretype real(c_double) :: alpha - + contains - - - + + + !----------------------------------------------------------------- ! ODE RHS function f(t,y) (implicit). !----------------------------------------------------------------- integer(c_int) function firhs(t, sunvec_y, sunvec_ydot, user_data) & result(retval) bind(C) - + !======= Inclusions =========== use, intrinsic :: iso_c_binding use fsundials_nvector_mod - + !======= Declarations ========= implicit none - + ! calling variables real(c_double), value :: t ! current time type(N_Vector) :: sunvec_y ! solution N_Vector type(N_Vector) :: sunvec_ydot ! rhs N_Vector type(c_ptr) :: user_data ! user-defined data - + ! pointers to data in SUNDIALS vectors real(c_double), pointer :: y(:) real(c_double), pointer :: ydot(:) - + ! local data integer :: i - + !======= Internals ============ - + ! Get data arrays from SUNDIALS vectors y(1:nlocal) => FN_VGetArrayPointer(sunvec_y) ydot(1:nlocal) => FN_VGetArrayPointer(sunvec_ydot) - + ! Initialize ydot to zero ydot = 0.d0 - + ! Fill ydot with rhs function do i = 1,nlocal ydot(i) = -alpha * (myid * nlocal + i) * y(i) end do - + retval = 0 ! Return with success return end function firhs !----------------------------------------------------------------- - + !----------------------------------------------------------------- ! ODE RHS function used for BBD preconditioner. !----------------------------------------------------------------- integer(c_int) function LocalgFn(nnlocal, t, sunvec_y, sunvec_g, user_data) & result(retval) bind(C) - + !======= Inclusions =========== use, intrinsic :: iso_c_binding use fsundials_nvector_mod - + !======= Declarations ========= implicit none - + ! calling variables real(c_double), value :: t ! current time integer(c_long) :: 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 - + ! local data integer :: ierr - + ierr = firhs(t, sunvec_y, sunvec_g, user_data) if (ierr /= 0) then write(0,*) "Error in firhs user-defined function, ierr = ", ierr stop 1 end if - + retval = 0 ! Return with success return end function LocalgFn !----------------------------------------------------------------- - + end module DiagkrybbdData !----------------------------------------------------------------- - - + + !----------------------------------------------------------------- ! Main driver program !----------------------------------------------------------------- program driver - + ! inclusions use, intrinsic :: iso_c_binding use fsundials_futils_mod ! Fortran utilities @@ -158,12 +158,12 @@ program driver use fsundials_linearsolver_mod ! Fortran interface to generic SUNLinearSolver use fsunlinsol_spgmr_mod ! Fortran interface to spgmr SUNLinearSolver use fsundials_context_mod ! Access sundials context - + use DiagkrybbdData - + !======= Declarations ========= implicit none - + ! Declarations ! general problem parameters integer, parameter :: Nt = 10 ! total number of output times @@ -171,7 +171,7 @@ program driver real(c_double), parameter :: Tf = 1.d0 ! final time real(c_double), parameter :: rtol = 1.d-5 ! relative and absolute tolerances real(c_double), parameter :: atol = 1.d-10 - + ! solution vector and other local variables type(SUNLinearSolver), pointer :: sunls ! sundials linear solver type(SUNMatrix), pointer :: sunmat_A ! sundials matrix (empty) @@ -191,7 +191,7 @@ program driver integer(c_long) :: ncfl(1) ! number of linear convergence fails integer(c_long) :: nli(1) ! number of linear iters integer(c_long) :: npre(1) ! number of preconditioner setups - integer(c_long) :: npsol(1) ! number of preconditioner solves + integer(c_long) :: npsol(1) ! number of preconditioner solves integer(c_long) :: lenrw(1) ! main solver real/int workspace size integer(c_long) :: leniw(1) integer(c_long) :: lenrwls(1) ! linear solver real/int workspace size @@ -201,14 +201,13 @@ program driver integer(c_long) :: lenrwbbd(1) ! band preconditioner real/int workspace size integer(c_long) :: leniwbbd(1) integer :: i, ioutput - integer, pointer :: commptr real(c_double) :: errmax, erri, gerrmax - + ! Initialize MPI variables comm = MPI_COMM_WORLD myid = 0 nprocs = 0 - + ! initialize MPI call MPI_Init(ierr) if (ierr /= MPI_SUCCESS) then @@ -225,19 +224,18 @@ program driver write(0,*) "Error in MPI_Comm_rank = ", ierr call MPI_Abort(comm, 1, ierr) end if - + ! Set input arguments neq and alpha neq = nprocs * nlocal alpha = 10.0d0 - + ! Create SUNDIALS simulation context, now that comm has been configured - commptr => comm - retval = FSUNContext_Create(c_loc(commptr), sunctx) + retval = FSUNContext_Create(comm, sunctx) if (retval /= 0) then print *, "Error: FSUNContext_Create returned ", retval call MPI_Abort(comm, 1, ierr) end if - + ! Initial problem output outproc = (myid == 0) if (outproc) then @@ -254,12 +252,12 @@ program driver write(6,*) " Precond is band-block-diagonal, using CVBBDPRE" write(6,*) " " endif - + ! Create solution vector, point at its data, and set initial condition sunvec_y => FN_VNew_Parallel(comm, nlocal, neq, sunctx) y(1:nlocal) => FN_VGetArrayPointer(sunvec_y) y = 1.d0 - + ! Create the CVode timestepper module cvode_mem = FCVodeCreate(CV_BDF, sunctx) if (.not. c_associated(cvode_mem)) then @@ -272,14 +270,14 @@ program driver print *, "Error: FCVodeInit returned ", retval call MPI_Abort(comm, 1, ierr) end if - + ! Tell CVODE to use a SPGMR linear solver. sunls => FSUNLinSol_SPGMR(sunvec_y, iPretype0, 0, sunctx) if (.not. associated(sunls)) then print *, 'ERROR: sunls = NULL' call MPI_Abort(comm, 1, ierr) end if - + ! Attach the linear solver (with NULL SUNMatrix object) sunmat_A => null() retval = FCVodeSetLinearSolver(cvode_mem, sunls, sunmat_A) @@ -287,20 +285,20 @@ program driver print *, 'Error in FCVodeSetLinearSolver, retval = ', retval call MPI_Abort(comm, 1, ierr) end if - + retval = FSUNLinSol_SPGMRSetGSType(sunls, iGStype) if (retval /= 0) then print *, 'Error in FSUNLinSol_SPGMRSetGSType, retval = ', retval call MPI_Abort(comm, 1, ierr) end if - + ! Specify tolerances retval = FCVodeSStolerances(cvode_mem, rtol, atol) if (retval /= 0) then print *, "Error: FCVodeSStolerances returned ", retval call MPI_Abort(comm, 1, ierr) end if - + mu = 0 ml = 0 mudq = 0 @@ -311,37 +309,37 @@ program driver print *, "Error: FCVBBDPrecInit returned ", retval call MPI_Abort(comm, 1, ierr) end if - + do iPretype = 1,2 - + if (iPretype == 2) then - + y = 1.d0 - + retval = FCVodeReInit(cvode_mem, t0, sunvec_y) if (retval /= 0) then print *, "Error in FCVodeReInit, retval = ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FCVBBDPrecReInit(cvode_mem, mudq, mldq, 0.d0) if (retval /= 0) then print *, "Error in FCVBBDPrecReInit, retval = ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FSUNLinSol_SPGMRSetPrecType(sunls, iPretype) if (retval /= 0) then print *, "Error in FSUNLinSol_SPGMRSetPrecType, retval = ", retval call MPI_Abort(comm, 1, ierr) end if - + if (outproc) write(6,*) " Preconditioning on right:" - + end if - + if (iPretype == 1 .and. outproc) write(6,*) " Preconditioning on left:" - + ! Main time-stepping loop: calls CVode to perform the integration, then ! prints results. Stops when the final time has been reached t(1) = T0 @@ -352,42 +350,42 @@ program driver write(6,*) " --------------------------------" end if do ioutput=1,Nt - + ! Integrate to output time retval = FCVode(cvode_mem, tout, sunvec_y, t, CV_NORMAL) if (retval /= 0) then print *, "Error: FCVode returned ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FCVodeGetNumSteps(cvode_mem, nst) if (retval /= 0) then print *, "Error: FCVodeGetNumSteps returned ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FCVodeGetNumRhsEvals(cvode_mem, nfe) if (retval /= 0) then print *, "Error: FCVodeGetNumRhsEvals returned ", retval call MPI_Abort(comm, 1, ierr) end if - + ! print solution stats and update internal time if (outproc) write(6,'(3x,f10.6,3(3x,i6))') t, nst, nfe tout = min(tout + dTout, Tf) - + end do if (outproc) then write(6,*) " --------------------------------" end if - + ! Get max. absolute error in the local vector. errmax = 0.d0 do i = 1,nlocal erri = y(i) - exp(-alpha * (myid * nlocal + i) * t(1)) errmax = max(errmax, abs(erri)) end do - + ! Get global max. error from MPI_Reduce call. call MPI_Reduce(errmax, gerrmax, 1, MPI_DOUBLE, MPI_MAX, & 0, comm, ierr) @@ -395,91 +393,91 @@ program driver print *, "Error in MPI_Reduce = ", ierr call MPI_Abort(comm, 1, ierr) end if - + ! Print global max. error if (outproc) print '(a,es10.2)', "Max. absolute error is ", gerrmax - + ! Get final statistics retval = FCVodeGetNumSteps(cvode_mem, nst) if (retval /= 0) then print *, "Error: FCVodeGetNumSteps returned ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FCVodeGetNumRhsEvals(cvode_mem, nfe) if (retval /= 0) then print *, "Error: FCVodeGetNumRhsEvals returned ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FCVodeGetNumPrecEvals(cvode_mem, npre) if (retval /= 0) then print *, "Error: FCVodeGetNumPrecEvals returned ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FCVodeGetNumPrecSolves(cvode_mem, npsol) if (retval /= 0) then print *, "Error: FCVodeGetNumPrecSolves returned ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FCVodeGetNumNonlinSolvIters(cvode_mem, nni) if (retval /= 0) then print *, "Error: FCVodeGetNumNonlinSolvIters returned ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FCVodeGetNumLinIters(cvode_mem, nli) if (retval /= 0) then print *, "Error: FCVodeGetNumLinIters returned ", retval call MPI_Abort(comm, 1, ierr) end if - + avdim = dble(nli) / dble(nni) - + retval = FCVodeGetNumNonlinSolvConvFails(cvode_mem, ncfn) if (retval /= 0) then print *, "Error: FCVodeGetNumNonlinSolvConvFails returned ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FCVodeGetNumLinConvFails(cvode_mem, ncfl) if (retval /= 0) then print *, "Error: FCVodeGetNumLinSolvConvFails returned ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FCVodeGetNumErrTestFails(cvode_mem, netf) if (retval /= 0) then print *, "Error: FCVodeGetNumErrTestFails returned ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FCVodeGetWorkSpace(cvode_mem, lenrw, leniw) if (retval /= 0) then print *, "Error: FCVodeGetWorkSpace returned ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FCVodeGetLinWorkSpace(cvode_mem, lenrwls, leniwls) if (retval /= 0) then print *, "Error: FCVodeGetLinWorkSpace returned ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FCVBBDPrecGetWorkSpace(cvode_mem, lenrwbbd, leniwbbd) if (retval /= 0) then print *, "Error: FCVBBDPrecGetWorkSpace returned ", retval call MPI_Abort(comm, 1, ierr) end if - + retval = FCVBBDPrecGetNumGfnEvals(cvode_mem, ngebbd) if (retval /= 0) then print *, "Error: FCVBBDPrecGetNumGfnEvals returned ", retval call MPI_Abort(comm, 1, ierr) end if - + ! Print some final statistics if (outproc) then write(6,*) " " @@ -503,13 +501,12 @@ program driver write(6,'(A)') " " end if end do - + ! Clean up and return with successful completion call FCVodeFree(cvode_mem) ! free integrator memory call FN_VDestroy(sunvec_y) ! free vector memory call MPI_Barrier(comm, ierr) call MPI_Finalize(ierr) ! Finalize MPI - + end program driver !----------------------------------------------------------------- - \ No newline at end of file diff --git a/examples/cvode/F2003_parallel/cv_diag_kry_f2003.f90 b/examples/cvode/F2003_parallel/cv_diag_kry_f2003.f90 index a2d0ddc5b7..1d657e245f 100644 --- a/examples/cvode/F2003_parallel/cv_diag_kry_f2003.f90 +++ b/examples/cvode/F2003_parallel/cv_diag_kry_f2003.f90 @@ -221,7 +221,6 @@ program driver integer(c_long) :: leniwls(1) real(c_double) :: avdim(1) ! avg Krylov subspace dim (NLI/NNI) integer :: i, ioutput - integer, pointer :: commptr real(c_double) :: errmax, erri, gerrmax ! Initialize MPI variables @@ -251,8 +250,7 @@ program driver alpha = 10.0d0 ! Create SUNDIALS simulation context, now that comm has been configured - commptr => comm - retval = FSUNContext_Create(c_loc(commptr), sunctx) + retval = FSUNContext_Create(comm, sunctx) if (retval /= 0) then print *, "Error: FSUNContext_Create returned ", retval call MPI_Abort(comm, 1, ierr) diff --git a/examples/cvode/F2003_parallel/cv_diag_non_f2003.f90 b/examples/cvode/F2003_parallel/cv_diag_non_f2003.f90 index cef38f19b1..c390f65de3 100644 --- a/examples/cvode/F2003_parallel/cv_diag_non_f2003.f90 +++ b/examples/cvode/F2003_parallel/cv_diag_non_f2003.f90 @@ -145,7 +145,6 @@ program driver integer(c_long) :: nfe(1) ! number of RHS evals integer(c_long) :: netf(1) ! number of error test fails integer :: i, ioutput - integer, pointer :: commptr real(c_double) :: errmax, erri, gerrmax ! Initialize MPI variables @@ -175,8 +174,7 @@ program driver alpha = 10.0d0 / neq ! Create SUNDIALS simulation context, now that comm has been configured - commptr => comm - retval = FSUNContext_Create(c_loc(commptr), sunctx) + retval = FSUNContext_Create(comm, sunctx) if (retval /= 0) then print *, "Error: FSUNContext_Create returned ", retval call MPI_Abort(comm, 1, ierr) diff --git a/examples/cvode/F2003_serial/cv_advdiff_bnd_f2003.f90 b/examples/cvode/F2003_serial/cv_advdiff_bnd_f2003.f90 index c2934c47c2..3e3fc003b6 100644 --- a/examples/cvode/F2003_serial/cv_advdiff_bnd_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_advdiff_bnd_f2003.f90 @@ -213,6 +213,7 @@ program main !======= Inclusions =========== use, intrinsic :: iso_c_binding + use fsundials_types_mod use fcvode_mod ! Fortran interface to the CVode module use fsundials_nvector_mod ! Fortran interface to the generic N_Vector use fsundials_matrix_mod ! Fortran interface to generic SUNMatrix @@ -246,7 +247,7 @@ program main !======= Internals ============ ! create the SUNDIALS context - ierr = FSUNContext_Create(c_null_ptr, ctx) + ierr = FSUNContext_Create(SUN_COMM_NULL, ctx) ! initialize ODE tstart = 0.0d0 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 7813a17904..76095f219b 100644 --- a/examples/cvode/F2003_serial/cv_diurnal_kry_bp_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_diurnal_kry_bp_f2003.f90 @@ -211,6 +211,7 @@ program main !======= Inclusions =========== use, intrinsic :: iso_c_binding + use fsundials_types_mod use fcvode_mod ! Fortran interface to the CVode module use fsundials_nvector_mod ! Fortran interface to the generic N_Vector use fsundials_matrix_mod ! Fortran interface to generic SUNMatrix @@ -248,7 +249,7 @@ program main !======= Internals ============ ! create the SUNDIALS context - ierr = FSUNContext_Create(c_null_ptr, ctx) + ierr = FSUNContext_Create(SUN_COMM_NULL, ctx) ! initialize ODE tstart = 0.0d0 diff --git a/examples/cvode/F2003_serial/cv_diurnal_kry_f2003.f90 b/examples/cvode/F2003_serial/cv_diurnal_kry_f2003.f90 index 0ff2517a13..dbf8dd4a0f 100644 --- a/examples/cvode/F2003_serial/cv_diurnal_kry_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_diurnal_kry_f2003.f90 @@ -452,6 +452,7 @@ program main !======= Inclusions =========== use, intrinsic :: iso_c_binding + use fsundials_types_mod use fcvode_mod ! Fortran interface to the ARKode module use fsundials_futils_mod ! Fortran utilities use fsundials_nvector_mod ! Fortran interface to the generic N_Vector @@ -489,7 +490,7 @@ program main !======= Internals ============ ! create the SUNDIALS context - ierr = FSUNContext_Create(c_null_ptr, ctx) + ierr = FSUNContext_Create(SUN_COMM_NULL, ctx) ! initialize ODE tstart = 0.0d0 diff --git a/examples/cvode/F2003_serial/cv_roberts_dnsL_f2003.f90 b/examples/cvode/F2003_serial/cv_roberts_dnsL_f2003.f90 index 6f1ef6c3b0..3b4af0cb4d 100644 --- a/examples/cvode/F2003_serial/cv_roberts_dnsL_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_roberts_dnsL_f2003.f90 @@ -249,7 +249,7 @@ program main !======= Internals ============ - retval = FSUNContext_Create(c_null_ptr, sunctx) + retval = FSUNContext_Create(SUN_COMM_NULL, sunctx) ! initialize solution vectors and tolerances yval(1) = 1.d0 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 1ca95ae0a8..1cfa17a2c4 100644 --- a/examples/cvode/F2003_serial/cv_roberts_dns_constraints_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_roberts_dns_constraints_f2003.f90 @@ -216,6 +216,7 @@ program main !======= Inclusions =========== use, intrinsic :: iso_c_binding + use fsundials_types_mod use fcvode_mod ! Fortran interface to CVODE use fsundials_context_mod ! Fortran interface to SUNContext use fnvector_serial_mod ! Fortran interface to serial N_Vector @@ -254,7 +255,7 @@ program main !======= Internals ============ - retval = FSUNContext_Create(c_null_ptr, sunctx) + retval = FSUNContext_Create(SUN_COMM_NULL, sunctx) ! initialize solution vectors and tolerances yval(1) = 1.d0 diff --git a/examples/cvode/F2003_serial/cv_roberts_dns_f2003.f90 b/examples/cvode/F2003_serial/cv_roberts_dns_f2003.f90 index 4b0825782e..c4d6135326 100644 --- a/examples/cvode/F2003_serial/cv_roberts_dns_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_roberts_dns_f2003.f90 @@ -209,6 +209,7 @@ program main !======= Inclusions =========== use, intrinsic :: iso_c_binding + use fsundials_types_mod use fcvode_mod ! Fortran interface to CVODE use fsundials_context_mod ! Fortran interface to SUNContext use fnvector_serial_mod ! Fortran interface to serial N_Vector @@ -247,7 +248,7 @@ program main !======= Internals ============ - retval = FSUNContext_Create(c_null_ptr, sunctx) + retval = FSUNContext_Create(SUN_COMM_NULL, sunctx) ! initialize solution vectors and tolerances yval(1) = 1.0d0 diff --git a/examples/cvode/F2003_serial/cv_roberts_klu_f2003.f90 b/examples/cvode/F2003_serial/cv_roberts_klu_f2003.f90 index 1d413be1c7..63eab3ace9 100644 --- a/examples/cvode/F2003_serial/cv_roberts_klu_f2003.f90 +++ b/examples/cvode/F2003_serial/cv_roberts_klu_f2003.f90 @@ -231,6 +231,7 @@ program main !======= Inclusions =========== use, intrinsic :: iso_c_binding + use fsundials_types_mod use fcvode_mod ! Fortran interface to CVODE use fsundials_context_mod ! Fortran interface to SUNContext use fsundials_nvector_mod ! Fortran interface to generic N_Vector @@ -267,7 +268,7 @@ program main !======= Internals ============ - retval = FSUNContext_Create(c_null_ptr, sunctx) + retval = FSUNContext_Create(SUN_COMM_NULL, sunctx) ! initialize solution vectors and tolerances yval(1) = 1.0d0 diff --git a/examples/ida/F2003_openmp/idaHeat2D_kry_omp_f2003.f90 b/examples/ida/F2003_openmp/idaHeat2D_kry_omp_f2003.f90 index dd5d25cb2f..03a2090a45 100644 --- a/examples/ida/F2003_openmp/idaHeat2D_kry_omp_f2003.f90 +++ b/examples/ida/F2003_openmp/idaHeat2D_kry_omp_f2003.f90 @@ -228,6 +228,7 @@ program main !======= Inclusions =========== use, intrinsic :: iso_c_binding + use fsundials_types_mod use fida_mod ! Fortran interface to IDA use fsundials_context_mod ! Fortran interface to SUNContext use fnvector_openmp_mod ! Fortran interface to serial N_Vector @@ -260,7 +261,7 @@ program main real(c_double), dimension(mgrid,mgrid) :: uu, up, res, constraints !======= Internals ============ - retval = FSUNContext_Create(c_null_ptr, sunctx) + retval = FSUNContext_Create(SUN_COMM_NULL, sunctx) ! get the number of threads passed in as a command line argument (if applicable) nargs = command_argument_count() 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 55d5adc214..b3ee8dbff4 100644 --- a/examples/ida/F2003_parallel/ida_heat2D_kry_bbd_f2003.f90 +++ b/examples/ida/F2003_parallel/ida_heat2D_kry_bbd_f2003.f90 @@ -778,7 +778,6 @@ program driver real(c_double) :: t(1), dTout, tout, ymax integer :: i, j, ioutput character*100 :: outname - integer, pointer :: commptr ! initialize MPI call MPI_Init(ierr) @@ -809,8 +808,7 @@ program driver end if ! Create SUNDIALS simulation context, now that comm has been configured - commptr => comm - retval = FSUNContext_Create(c_loc(commptr), sunctx) + retval = FSUNContext_Create(comm, sunctx) if (retval /= 0) then print *, "Error: FSUNContext_Create returned ",retval call MPI_Abort(comm, 1, ierr) diff --git a/examples/kinsol/F2003_parallel/kin_diagon_kry_f2003.f90 b/examples/kinsol/F2003_parallel/kin_diagon_kry_f2003.f90 index 9bec36e49b..dcc6b09bbb 100644 --- a/examples/kinsol/F2003_parallel/kin_diagon_kry_f2003.f90 +++ b/examples/kinsol/F2003_parallel/kin_diagon_kry_f2003.f90 @@ -318,7 +318,7 @@ program main end if ! ------------------------- - retval = FSUNContext_Create(c_null_ptr, sunctx) + retval = FSUNContext_Create(SUN_COMM_NULL, sunctx) if (retval /= 0) then print *, 'ERROR in FSUNContext_Create' stop 1 diff --git a/examples/kinsol/F2003_serial/kinDiagon_kry_f2003.f90 b/examples/kinsol/F2003_serial/kinDiagon_kry_f2003.f90 index a555e58203..e94349cba5 100644 --- a/examples/kinsol/F2003_serial/kinDiagon_kry_f2003.f90 +++ b/examples/kinsol/F2003_serial/kinDiagon_kry_f2003.f90 @@ -230,6 +230,7 @@ end module kinDiagonKry_mod program main !======= Inclusions =========== + use fsundials_types_mod use fsundials_context_mod use fkinsol_mod ! Fortran interface to KINSOL use fsundials_nvector_mod ! Fortran interface to generic N_Vector @@ -269,7 +270,7 @@ program main print '(a,i3)', "Problem size: neq = ", neq ! ------------------------- - retval = FSUNContext_Create(c_null_ptr, sunctx) + retval = FSUNContext_Create(SUN_COMM_NULL, sunctx) if (retval /= 0) then print *, 'ERROR in FSUNContext_Create' stop 1