Skip to content

Commit

Permalink
Merge branch 'devel' into ctest
Browse files Browse the repository at this point in the history
  • Loading branch information
raback authored Jul 19, 2024
2 parents 78172f5 + 26de6a3 commit 092ab05
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 26 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/nix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "nix flake check"
on:
pull_request:
push:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- run: nix flake check -L
26 changes: 24 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -607,12 +607,34 @@ IF(WITH_ElmerIce)
ENDIF(WITH_ElmerIce)

IF (EXTERNAL_UMFPACK)
MESSAGE(STATUS "Using external UMFPACK instead of built-in")
FIND_PACKAGE(UMFPACK REQUIRED)
MESSAGE(STATUS "Using external UMFPACK instead of built-in")
FIND_PACKAGE(UMFPACK REQUIRED)

# Check for size of "SuiteSparse_long"
INCLUDE(CheckTypeSize)
SET(old_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
SET(old_CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES})
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${UMFPACK_INCLUDE_DIR}")
LIST(APPEND CMAKE_EXTRA_INCLUDE_FILES "umfpack.h")
CHECK_TYPE_SIZE("SuiteSparse_long" SIZEOF_SUITESPARSE_LONG LANGUAGE C)
SET(CMAKE_REQUIRED_INCLUDES ${old_CMAKE_REQUIRED_INCLUDES})
SET(CMAKE_EXTRA_INCLUDE_FILES ${old_CMAKE_EXTRA_INCLUDE_FILES})
IF (HAVE_SIZEOF_SUITESPARSE_LONG)
IF (SIZEOF_SUITESPARSE_LONG EQUAL 4)
SET(UMFPACK_LONG_FORTRAN_TYPE "C_INT32_T")
ELSE()
SET(UMFPACK_LONG_FORTRAN_TYPE "C_INT64_T")
ENDIF()
ENDIF()
ELSE()
MESSAGE(STATUS "Using built-in UMFPACK")
ADD_SUBDIRECTORY(umfpack)
ENDIF()
IF(NOT DEFINED UMFPACK_LONG_FORTRAN_TYPE)
# Old versions of UMFPACK before "SuiteSparse_long" was defined used "long"
SET(UMFPACK_LONG_FORTRAN_TYPE "C_LONG")
ENDIF()

ADD_SUBDIRECTORY(fhutiter)
ADD_SUBDIRECTORY(meshgen2d)
ADD_SUBDIRECTORY(fem)
Expand Down
3 changes: 3 additions & 0 deletions fem/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@
/* Define if you have a UMFPACK library. */
#define HAVE_UMFPACK

/* Define to the Fortran type that matches SuiteSparse_long. */
#cmakedefine UMFPACK_LONG_FORTRAN_TYPE @UMFPACK_LONG_FORTRAN_TYPE@

/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H

Expand Down
10 changes: 5 additions & 5 deletions fem/src/DirectSolve.F90
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ SUBROUTINE umf4_l_sym( m,n,rows,cols,values,symbolic,control,iinfo ) &
BIND(C,name='umf4_l_sym')
USE, INTRINSIC :: ISO_C_BINDING
!INTEGER(CAddrInt) ::m,n,rows(*),cols(*)
INTEGER(C_LONG) :: m,n,rows(*),cols(*) !TODO: m,n of are called with AddrInt kind
INTEGER(UMFPACK_LONG_FORTRAN_TYPE) :: m,n,rows(*),cols(*) !TODO: m,n of are called with AddrInt kind
INTEGER(CAddrInt) :: symbolic
REAL(C_DOUBLE) :: Values(*), control(*),iinfo(*)
END SUBROUTINE umf4_l_sym
Expand All @@ -384,7 +384,7 @@ SUBROUTINE umf4_l_num( rows,cols,values,symbolic,numeric, control,iinfo ) &
BIND(C,name='umf4_l_num')
USE, INTRINSIC :: ISO_C_BINDING
!INTEGER(CAddrInt) :: rows(*),cols(*)
INTEGER(C_LONG) :: rows(*),cols(*)
INTEGER(UMFPACK_LONG_FORTRAN_TYPE) :: rows(*),cols(*)
INTEGER(CAddrInt) :: numeric, symbolic
REAL(C_DOUBLE) :: Values(*), control(*),iinfo(*)
END SUBROUTINE umf4_l_num
Expand All @@ -393,7 +393,7 @@ SUBROUTINE umf4_l_sol( sys, x, b, numeric, control, iinfo ) &
BIND(C,name='umf4_l_sol')
USE, INTRINSIC :: ISO_C_BINDING
!INTEGER(CAddrInt) :: sys
INTEGER(C_LONG) :: sys
INTEGER(UMFPACK_LONG_FORTRAN_TYPE) :: sys
INTEGER(CAddrInt) :: numeric
REAL(C_DOUBLE) :: x(*), b(*), control(*), iinfo(*)
END SUBROUTINE umf4_l_sol
Expand All @@ -414,8 +414,8 @@ END SUBROUTINE umf4_l_fsym
INTEGER :: i, n, status, sys
REAL(KIND=dp) :: iInfo(90), Control(20)
INTEGER(KIND=AddrInt) :: symbolic, zero=0
INTEGER(KIND=C_LONG) :: ln, lsys
INTEGER(KIND=C_LONG), ALLOCATABLE :: LRows(:), LCols(:)
INTEGER(KIND=UMFPACK_LONG_FORTRAN_TYPE) :: ln, lsys
INTEGER(KIND=UMFPACK_LONG_FORTRAN_TYPE), ALLOCATABLE :: LRows(:), LCols(:)

SAVE iInfo, Control

Expand Down
6 changes: 5 additions & 1 deletion fem/src/umf4_f77wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@

#include "umfpack.h"

#if !defined(SuiteSparse_long)
#define SuiteSparse_long long
#endif

#ifdef NULL
#undef NULL
#endif
Expand Down Expand Up @@ -234,7 +238,7 @@ void STDCALLBULL FC_FUNC(umf4fsym,UMF4FSYM) (void **Symbolic)
#undef UMFPACK_solve
#undef UMFPACK_symbolic

#define Int long
#define Int SuiteSparse_long
#define UMFPACK_defaults umfpack_dl_defaults
#define UMFPACK_free_numeric umfpack_dl_free_numeric
#define UMFPACK_free_symbolic umfpack_dl_free_symbolic
Expand Down
45 changes: 27 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,13 @@
buildInputs,
cmakeFlags,
doCheck,
checkPhase ? ''
runHook preCheckPhase
ctest -j $NIX_BUILD_CORES -L fast
runHook postCheckPhase
'',
checkOptions,
...
} @ inputs: let
storepath = placeholder "out";
in
pkgs.stdenv.mkDerivation {
inherit name doCheck checkPhase storepath;
inherit name doCheck storepath;

pname = "${name}-devel";

Expand All @@ -72,8 +69,11 @@
(nix-filter.lib.matchExt "nix")
"flake.lock"
".git"
".github"
".gitignore"
".gitmodules"
".travis.yml"
".vscode"
];
};

Expand Down Expand Up @@ -111,6 +111,12 @@
]
++ inputs.cmakeFlags;

checkPhase = ''
runHook preCheckPhase
ctest -j $NIX_BUILD_CORES -L ${checkOptions}
runHook postCheckPhase
'';

autoPatchelfIgnoreMissingDeps = ["libmpi_stubs.so"];

preConfigure = ''
Expand All @@ -123,18 +129,24 @@
];
};

default = {doCheck ? false}:
default = {
doCheck ? false,
checkOptions ? "-L quick",
}:
basePkg {
inherit doCheck;
inherit doCheck checkOptions;
name = "elmer";
nativeBuildInputs = [];
buildInputs = [];
cmakeFlags = [];
};

gui = {doCheck ? false}:
gui = {
doCheck ? false,
checkOptions ? "-L quick",
}:
basePkg {
inherit doCheck;
inherit doCheck checkOptions;
name = "elmer-gui";

nativeBuildInputs = [pkgs.libsForQt5.wrapQtAppsHook];
Expand All @@ -158,9 +170,12 @@
];
};

ice = {doCheck ? false}:
ice = {
doCheck ? false,
checkOptions ? ''-L fast -E "(Hydro_Coupled)|(Hydro_SedOnly)|(Proj_South)"'',
}:
basePkg {
inherit doCheck;
inherit doCheck checkOptions;
name = "elmer-ice";

nativeBuildInputs = [];
Expand Down Expand Up @@ -208,12 +223,6 @@

"-DWITH_Trilinos:BOOL=FALSE"
];

checkPhase = ''
runHook preCheckPhase
ctest -j $NIX_BUILD_CORES -L fast -E "(Hydro_Coupled)|(Hydro_SedOnly)|(Proj_South)"
runHook postCheckPhase
'';
};
in {
checks = {
Expand Down

0 comments on commit 092ab05

Please sign in to comment.