Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add Fortran Compiler Warnings #487

Merged
merged 13 commits into from
May 29, 2024
13 changes: 13 additions & 0 deletions cmake/SundialsSetupCompilers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ if(ENABLE_ALL_WARNINGS)

set(CMAKE_C_FLAGS "-Wall -Wpedantic -Wextra -Wshadow -Wno-unused-parameter -Wno-unused-function ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wall -Wpedantic -Wextra -Wshadow -Wno-unused-parameter -Wno-unused-function ${CMAKE_CXX_FLAGS}")

# TODO(DJG): Add -fcheck=all,no-pointer,no-recursion once Jenkins is updated
# to use gfortran > 5.5 which segfaults with -fcheck=array-temps,bounds,do,mem
# no- options were added in gfortran 6
#
# Exclude run-time pointer checks (no-pointer) because passing null objects
# to SUNDIALS functions (e.g., sunmat => null() to SetLinearSolver) causes a
# run-time error with this check
#
# Exclude checks for subroutines and functions not marked as recursive
# (no-recursion) e.g., ark_brusselator1D_task_local_nls_f2003 calls
# SUNNonlinsolFree from within a custom nonlinear solver implementation of
# SUNNonlinsolFree which causes a run-time error with this check
set(CMAKE_Fortran_FLAGS "-Wall -Wpedantic -Wno-unused-dummy-argument -Wno-c-binding-type -ffpe-summary=none ${CMAKE_Fortran_FLAGS}")
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ module ode_mod
integer, parameter :: Nvar = 3

! MPI variables
integer, target :: comm ! communicator
integer :: myid ! process ID
integer :: nprocs ! total number of processes
integer :: reqS ! MPI send request handle
integer :: reqR ! MPI receive request handle
integer, target :: comm ! communicator
integer :: myid ! process ID
integer :: nprocs ! total number of processes
integer :: reqS ! MPI send request handle
integer :: reqR ! MPI receive request handle

! Excahnge buffers
real(c_double) :: Wsend(Nvar), Wrecv(Nvar)
Expand Down Expand Up @@ -346,7 +346,6 @@ module prec_mod
! Preconditioner functions
! --------------------------------------------------------------


! Sets P = I - gamma * J
integer(c_int) function PSetup(t, sunvec_y, sunvec_f, jok, jcurPtr, gamma, &
user_data) result(ierr) bind(C)
Expand Down Expand Up @@ -462,7 +461,6 @@ integer(c_int) function PSolve(t, sunvec_y, sunvec_f, sunvec_r, sunvec_z, &

!======= Inclusions ===========
use, intrinsic :: iso_c_binding

use fnvector_mpiplusx_mod

!======= Declarations =========
Expand Down Expand Up @@ -758,7 +756,6 @@ integer(SUNNonlinearSolver_Type) function TaskLocalNewton_GetType(sunnls) &
!======= Inclusions ===========
use, intrinsic :: iso_c_binding


!======= Declarations =========
implicit none

Expand All @@ -778,7 +775,6 @@ integer(c_int) function TaskLocalNewton_Initialize(sunnls) &
!======= Inclusions ===========
use, intrinsic :: iso_c_binding


!======= Declarations =========
implicit none

Expand Down Expand Up @@ -817,8 +813,6 @@ integer(c_int) function TaskLocalNewton_Solve(sunnls, sunvec_y0, sunvec_ycor, &

!======= Inclusions ===========
use, intrinsic :: iso_c_binding


use fnvector_mpiplusx_mod

use ode_mod, only : comm
Expand Down Expand Up @@ -880,10 +874,6 @@ integer(c_int) function TaskLocalNewton_Free(sunnls) &
!======= Inclusions ===========
use, intrinsic :: iso_c_binding





!======= Declarations =========
implicit none

Expand Down Expand Up @@ -911,7 +901,6 @@ integer(c_int) function TaskLocalNewton_SetSysFn(sunnls, SysFn) &
!======= Inclusions ===========
use, intrinsic :: iso_c_binding


!======= Declarations =========
implicit none

Expand All @@ -932,7 +921,6 @@ integer(c_int) function TaskLocalNewton_SetConvTestFn(sunnls, CTestFn, &
!======= Inclusions ===========
use, intrinsic :: iso_c_binding


!======= Declarations =========
implicit none

Expand All @@ -954,7 +942,6 @@ integer(c_int) function TaskLocalNewton_GetNumConvFails(sunnls, nconvfails) &
!======= Inclusions ===========
use, intrinsic :: iso_c_binding


!======= Declarations =========
implicit none

Expand All @@ -976,9 +963,7 @@ function TaskLocalNewton(arkode_mem, sunvec_y) result(sunnls)

!======= Inclusions ===========
use, intrinsic :: iso_c_binding

use fnvector_serial_mod

use fsunnonlinsol_newton_mod
use fsunlinsol_dense_mod
use fsunmatrix_dense_mod
Expand All @@ -995,7 +980,7 @@ function TaskLocalNewton(arkode_mem, sunvec_y) result(sunnls)
type(SUNNonlinearSolver), pointer :: sunnls ! SUNDIALS nonlinear solver
type(SUNNonlinearSolver_Ops), pointer :: nlsops ! solver operations

integer :: ierr ! MPI error status
integer :: ierr ! MPI error status

!======= Internals ============

Expand Down Expand Up @@ -1258,6 +1243,9 @@ subroutine EvolveProblemIMEX(sunvec_y)
end if

! Create the (non)linear solver
sun_NLS => null()
sun_LS => null()

if (global) then

! Create nonlinear solver
Expand Down Expand Up @@ -1948,6 +1936,7 @@ subroutine ExchangeAllEnd()

!======= Inclusions ===========
use, intrinsic :: iso_c_binding

use ode_mod, only : comm, reqS, reqR, c

!======= Declarations =========
Expand Down Expand Up @@ -1983,9 +1972,6 @@ subroutine SetupProblem()

!======= Inclusions ===========
use, intrinsic :: iso_c_binding



use fnvector_serial_mod
use fnvector_mpiplusx_mod
use fnvector_mpimanyvector_mod
Expand Down Expand Up @@ -2252,6 +2238,7 @@ subroutine FreeProblem()
!======= Inclusions ===========
use, intrinsic :: iso_c_binding
use fsundials_core_mod

use ode_mod, only : sunctx, logger, myid, nout, umask_s, umask, vmask, wmask

!======= Declarations =========
Expand Down
4 changes: 0 additions & 4 deletions test/env/default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ if [ "$compilername" == "gcc" ]; then
export CUDAFLAGS="-g -O3"
fi

# TODO(CJB): add this back after we upgrade the GNU compiler stack on the Jenkins box
# Currently this causes the compiler to segfault on many of the Fortran example codes.
# export FFLAGS="${FFLAGS} -fbounds-check"

else

COMPILER_ROOT="$(spack location -i "llvm@$compilerversion")"
Expand Down
8 changes: 2 additions & 6 deletions test/env/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,8 @@ if [ "$compilername" == "gcc" ]; then
export CUDAFLAGS="-g -O3"
fi

# append additional warning flags
if [[ "$SUNDIALS_PRECISION" == "double" && "$SUNDIALS_INDEX_SIZE" == "32" ]]; then
export CFLAGS="${CFLAGS} -Wconversion -Wno-sign-conversion"
export CXXFLAGS="${CXXFLAGS} -Wconversion -Wno-sign-conversion"
fi

# additional Fortran flags not currently added by ENABLE_ALL_WARNINGS
export FFLAGS="${FFLAGS} -fcheck=all,no-pointer,no-recursion"
fi

# ------------------------------------------------------------------------------
Expand Down
Loading