Skip to content

Commit 57cfaf0

Browse files
authored
Merge pull request #565 from awvwgk/kinds
Make support for quadruple precision optional
2 parents 6033397 + d09b639 commit 57cfaf0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+391
-142
lines changed

.github/workflows/CI.yml

+20-14
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,18 @@ jobs:
2121
matrix:
2222
os: [ubuntu-latest, macos-latest]
2323
gcc_v: [9, 10, 11] # Version of GFortran we want to use.
24+
build: [cmake]
25+
include:
26+
- os: ubuntu-latest
27+
gcc_v: 10
28+
build: cmake-inline
29+
- os: ubuntu-latest
30+
gcc_v: 10
31+
build: make
2432
env:
2533
FC: gfortran-${{ matrix.gcc_v }}
2634
GCC_V: ${{ matrix.gcc_v }}
35+
BUILD_DIR: ${{ matrix.build == 'cmake' && 'build' || '.' }}
2736

2837
steps:
2938
- name: Checkout code
@@ -58,35 +67,32 @@ jobs:
5867
brew link gcc@${GCC_V}
5968
6069
- name: Configure with CMake
70+
if: ${{ contains(matrix.build, 'cmake') }}
6171
run: >-
6272
cmake -Wdev
6373
-DCMAKE_BUILD_TYPE=Release
6474
-DCMAKE_MAXIMUM_RANK:String=4
6575
-DCMAKE_INSTALL_PREFIX=$PWD/_dist
66-
-S . -B build
76+
-S . -B ${{ env.BUILD_DIR }}
6777
6878
- name: Build and compile
69-
run: cmake --build build --parallel
79+
if: ${{ contains(matrix.build, 'cmake') }}
80+
run: cmake --build ${{ env.BUILD_DIR }} --parallel
7081

7182
- name: catch build fail
72-
run: cmake --build build --verbose --parallel 1
73-
if: failure()
83+
run: cmake --build ${{ env.BUILD_DIR }} --verbose --parallel 1
84+
if: ${{ failure() && contains(matrix.build, 'cmake') }}
7485

7586
- name: test
76-
run: ctest --test-dir build --parallel --output-on-failure
87+
if: ${{ contains(matrix.build, 'cmake') }}
88+
run: ctest --test-dir ${{ env.BUILD_DIR }} --parallel --output-on-failure
7789

7890
- name: Install project
79-
run: cmake --install build
80-
81-
- name: Test in-tree builds
82-
if: contains( matrix.gcc_v, '10') # Only test one compiler on each platform
83-
run: |
84-
cmake -DCMAKE_MAXIMUM_RANK=4 .
85-
cmake --build .
86-
cmake --build . --target test
91+
if: ${{ contains(matrix.build, 'cmake') }}
92+
run: cmake --install ${{ env.BUILD_DIR }}
8793

8894
- name: Test manual makefiles
89-
if: contains(matrix.os, 'ubuntu') && contains(matrix.gcc_v, '10')
95+
if: ${{ matrix.build == 'make' }}
9096
run: |
9197
make -f Makefile.manual FYPPFLAGS="-DMAXRANK=4" -j
9298
make -f Makefile.manual test

CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
2424
add_compile_options(-Wall)
2525
add_compile_options(-Wextra)
2626
add_compile_options(-Wimplicit-procedure)
27-
add_compile_options(-Wconversion-extra)
2827
# -pedantic-errors triggers a false positive for optional arguments of elemental functions,
2928
# see test_optval and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95446
3029
if(CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 11.0)

ci/fpm-deployment.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ fypp="${FYPP:-$(which fypp)}"
1212
fyflags="${FYFLAGS:--DMAXRANK=4}"
1313

1414
# Number of parallel jobs for preprocessing
15-
njob="$(nproc)"
15+
if [ $(uname) = "Darwin" ]; then
16+
njob="$(sysctl -n hw.ncpu)"
17+
else
18+
njob="$(nproc)"
19+
fi
1620

1721
# Additional files to include
1822
include=(

ci/fpm.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ copyright = "2019-2021 stdlib contributors"
77

88
[dev-dependencies]
99
test-drive.git = "https://github.com/fortran-lang/test-drive"
10+
test-drive.tag = "v0.4.0"

config/CMakeLists.txt

+18
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ endif()
1313
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1414
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE)
1515

16+
# Check for available features
17+
# Note: users can overwrite the automatic check by setting the value at configure time
18+
include(CheckFortranSourceRuns)
19+
if (NOT DEFINED WITH_QP)
20+
check_fortran_source_runs(
21+
"if (selected_real_kind(33) == -1) stop 1; end"
22+
WITH_QP
23+
)
24+
set(WITH_QP ${WITH_QP} PARENT_SCOPE)
25+
endif()
26+
if (NOT DEFINED WITH_XDP)
27+
check_fortran_source_runs(
28+
"if (any(selected_real_kind(18) == [-1, selected_real_kind(33)])) stop 1; end"
29+
WITH_XDP
30+
)
31+
set(WITH_XDP ${WITH_XDP} PARENT_SCOPE)
32+
endif()
33+
1634
# Export a pkg-config file
1735
configure_file(
1836
"${CMAKE_CURRENT_SOURCE_DIR}/template.pc"

config/cmake/Findtest-drive.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ foreach(method ${${_pkg}_FIND_METHOD})
136136
FetchContent_Declare(
137137
"${_lib}"
138138
GIT_REPOSITORY "${_url}"
139-
GIT_TAG "HEAD"
139+
GIT_TAG "v0.4.0"
140140
)
141141
FetchContent_MakeAvailable("${_lib}")
142142

config/template.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
@PACKAGE_INIT@
22

3+
set("@PROJECT_NAME@_WITH_QP" @WITH_QP@)
4+
set("@PROJECT_NAME@_WITH_XDP" @WITH_XDP@)
5+
36
if(NOT TARGET "@PROJECT_NAME@::@PROJECT_NAME@")
47
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
58
endif()

doc/specs/stdlib_kinds.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,28 @@ The `stdlib_kinds` module provides kind parameters for the Fortran intrinsic dat
1616

1717
### `sp`
1818

19-
Alias for intrinsic named constant `real32` imported from `iso_fortran_env`.
19+
Single precision real kind parameter.
20+
Provides real kind parameter for floating point numbers with a minimal precision of 6 significant digits.
2021

2122

2223
### `dp`
2324

24-
Alias for intrinsic named constant `real64` imported from `iso_fortran_env`.
25+
Double precision real kind parameter.
26+
Provides real kind parameter for floating point numbers with a minimal precision of 15 significant digits.
27+
28+
29+
### `xdp`
30+
31+
Extended double precision real kind parameter.
32+
Provides real kind parameter for floating point numbers with a minimal precision of 18 significant digits.
33+
If not available it has value `-1`.
2534

2635

2736
### `qp`
2837

29-
Alias for intrinsic named constant `real128` imported from `iso_fortran_env`.
38+
Quadruple precision real kind parameter.
39+
Provides real kind parameter for floating point numbers with a minimal precision of 33 significant digits.
40+
If not available it has value `-1`.
3041

3142

3243
### `int8`

src/CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set(fppFiles
77
stdlib_bitsets_64.fypp
88
stdlib_bitsets_large.fypp
99
stdlib_io.fypp
10+
stdlib_kinds.fypp
1011
stdlib_linalg.fypp
1112
stdlib_linalg_diag.fypp
1213
stdlib_linalg_outer_product.fypp
@@ -50,11 +51,16 @@ else()
5051
set(fyppFlags "-DVERSION90")
5152
endif()
5253

54+
list(
55+
APPEND fyppFlags
56+
"-DWITH_QP=$<BOOL:${WITH_QP}>"
57+
"-DWITH_XDP=$<BOOL:${WITH_XDP}>"
58+
)
59+
5360
fypp_f90("${fyppFlags}" "${fppFiles}" outFiles)
5461

5562
set(SRC
5663
stdlib_error.f90
57-
stdlib_kinds.f90
5864
stdlib_logger.f90
5965
stdlib_system.F90
6066
stdlib_specialfunctions.f90

src/Makefile.manual

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ SRCFYPP = \
44
stdlib_bitsets_large.fypp \
55
stdlib_bitsets.fypp \
66
stdlib_io.fypp \
7+
stdlib_kinds.fypp \
78
stdlib_linalg.fypp \
89
stdlib_linalg_diag.fypp \
910
stdlib_linalg_outer_product.fypp \
@@ -41,7 +42,6 @@ SRC = f18estop.f90 \
4142
stdlib_specialfunctions.f90 \
4243
stdlib_specialfunctions_legendre.f90 \
4344
stdlib_io.f90 \
44-
stdlib_kinds.f90 \
4545
stdlib_logger.f90 \
4646
stdlib_quadrature_gauss.f90 \
4747
stdlib_strings.f90 \

src/common.fypp

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
#:mute
22

3+
#! Support for quadruple precision floating point numbers
4+
#:if not defined("WITH_QP")
5+
#:set WITH_QP = False
6+
#:endif
7+
8+
#! Support for extended double precision floating point numbers
9+
#:if not defined("WITH_XDP")
10+
#:set WITH_XDP = False
11+
#:endif
12+
313
#! Real kinds to be considered during templating
4-
#:set REAL_KINDS = ["sp", "dp", "qp"]
14+
#:set REAL_KINDS = ["sp", "dp"]
15+
#:if WITH_XDP
16+
#:set REAL_KINDS = REAL_KINDS + ["xdp"]
17+
#:endif
18+
#:if WITH_QP
19+
#:set REAL_KINDS = REAL_KINDS + ["qp"]
20+
#:endif
521

622
#! Real types to be considered during templating
723
#:set REAL_TYPES = ["real({})".format(k) for k in REAL_KINDS]
@@ -10,7 +26,13 @@
1026
#:set REAL_KINDS_TYPES = list(zip(REAL_KINDS, REAL_TYPES))
1127

1228
#! Complex kinds to be considered during templating
13-
#:set CMPLX_KINDS = ["sp", "dp", "qp"]
29+
#:set CMPLX_KINDS = ["sp", "dp"]
30+
#:if WITH_XDP
31+
#:set CMPLX_KINDS = CMPLX_KINDS + ["xdp"]
32+
#:endif
33+
#:if WITH_QP
34+
#:set CMPLX_KINDS = CMPLX_KINDS + ["qp"]
35+
#:endif
1436

1537
#! Complex types to be considered during templating
1638
#:set CMPLX_TYPES = ["complex({})".format(k) for k in CMPLX_KINDS]

src/stdlib_io.fypp

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module stdlib_io
66
!! Provides a support for file handling
77
!! ([Specification](../page/specs/stdlib_io.html))
88

9-
use stdlib_kinds, only: sp, dp, qp, &
9+
use stdlib_kinds, only: sp, dp, xdp, qp, &
1010
int8, int16, int32, int64
1111
use stdlib_error, only: error_stop
1212
use stdlib_optval, only: optval
@@ -24,9 +24,11 @@ module stdlib_io
2424
FMT_INT = '(*(i0,1x))', &
2525
FMT_REAL_SP = '(*(es15.8e2,1x))', &
2626
FMT_REAL_DP = '(*(es24.16e3,1x))', &
27+
FMT_REAL_XDP = '(*(es26.18e3,1x))', &
2728
FMT_REAL_QP = '(*(es44.35e4,1x))', &
2829
FMT_COMPLEX_SP = '(*(es15.8e2,1x,es15.8e2))', &
2930
FMT_COMPLEX_DP = '(*(es24.16e3,1x,es24.16e3))', &
31+
FMT_COMPLEX_XDP = '(*(es26.18e3,1x,es26.18e3))', &
3032
FMT_COMPLEX_QP = '(*(es44.35e4,1x,es44.35e4))'
3133

3234
interface loadtxt

src/stdlib_kinds.f90

-14
This file was deleted.

src/stdlib_kinds.fypp

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#:include "common.fypp"
2+
!> Version: experimental
3+
!>
4+
!> The specification of this module is available [here](../page/specs/stdlib_kinds.html).
5+
module stdlib_kinds
6+
use iso_fortran_env, only: int8, int16, int32, int64
7+
use iso_c_binding, only: c_bool
8+
implicit none
9+
private
10+
public :: sp, dp, xdp, qp, int8, int16, int32, int64, lk, c_bool
11+
12+
!> Single precision real numbers
13+
integer, parameter :: sp = selected_real_kind(6)
14+
15+
!> Double precision real numbers
16+
integer, parameter :: dp = selected_real_kind(15)
17+
18+
!> Extended double precision real numbers
19+
integer, parameter :: xdp = #{if WITH_XDP}#selected_real_kind(18)#{else}#-1#{endif}#
20+
21+
!> Quadruple precision real numbers
22+
integer, parameter :: qp = #{if WITH_QP}#selected_real_kind(33)#{else}#-1#{endif}#
23+
24+
!> Default logical kind parameter
25+
integer, parameter :: lk = kind(.true.)
26+
27+
end module stdlib_kinds

src/stdlib_linalg.fypp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module stdlib_linalg
44
!!Provides a support for various linear algebra procedures
55
!! ([Specification](../page/specs/stdlib_linalg.html))
6-
use stdlib_kinds, only: sp, dp, qp, &
6+
use stdlib_kinds, only: sp, dp, xdp, qp, &
77
int8, int16, int32, int64
88
use stdlib_optval, only: optval
99
implicit none

src/stdlib_math.fypp

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
#:set RC_KINDS_TYPES = REAL_KINDS_TYPES + CMPLX_KINDS_TYPES
44

55
module stdlib_math
6-
use stdlib_kinds, only: int8, int16, int32, int64, sp, dp, qp
6+
use stdlib_kinds, only: int8, int16, int32, int64, sp, dp, xdp, qp
77
use stdlib_optval, only: optval
88

99
implicit none
1010
private
1111
public :: clip, gcd, linspace, logspace
12-
public :: EULERS_NUMBER_SP, EULERS_NUMBER_DP, EULERS_NUMBER_QP
12+
public :: EULERS_NUMBER_SP, EULERS_NUMBER_DP
13+
#:if WITH_QP
14+
public :: EULERS_NUMBER_QP
15+
#:endif
1316
public :: DEFAULT_LINSPACE_LENGTH, DEFAULT_LOGSPACE_BASE, DEFAULT_LOGSPACE_LENGTH
1417
public :: arange
1518

@@ -20,7 +23,9 @@ module stdlib_math
2023
! Useful constants for lnspace
2124
real(sp), parameter :: EULERS_NUMBER_SP = exp(1.0_sp)
2225
real(dp), parameter :: EULERS_NUMBER_DP = exp(1.0_dp)
26+
#:if WITH_QP
2327
real(qp), parameter :: EULERS_NUMBER_QP = exp(1.0_qp)
28+
#:endif
2429

2530
interface clip
2631
#:for k1, t1 in IR_KINDS_TYPES

src/stdlib_optval.fypp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module stdlib_optval
1616
!!
1717
!! It is an error to call `optval` with a single actual argument.
1818
!!
19-
use stdlib_kinds, only: sp, dp, qp, int8, int16, int32, int64
19+
use stdlib_kinds, only: sp, dp, xdp, qp, int8, int16, int32, int64
2020
implicit none
2121

2222

src/stdlib_quadrature.fypp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#:include "common.fypp"
22
module stdlib_quadrature
33
!! ([Specification](../page/specs/stdlib_quadrature.html#description))
4-
use stdlib_kinds, only: sp, dp, qp
4+
use stdlib_kinds, only: sp, dp, xdp, qp
55

66
implicit none
77

src/stdlib_sorting.fypp

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ module stdlib_sorting
121121
int64, &
122122
sp, &
123123
dp, &
124+
xdp, &
124125
qp
125126

126127
use stdlib_optval, only: optval

src/stdlib_specialfunctions.f90

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module stdlib_specialfunctions
2-
use stdlib_kinds, only: sp, dp, qp
2+
use stdlib_kinds, only: sp, dp, xdp, qp
33

44
implicit none
55

src/stdlib_stats.fypp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module stdlib_stats
77
!! Provides support for various statistical methods. This includes currently
88
!! descriptive statistics
99
!! ([Specification](../page/specs/stdlib_stats.html))
10-
use stdlib_kinds, only: sp, dp, qp, &
10+
use stdlib_kinds, only: sp, dp, xdp, qp, &
1111
int8, int16, int32, int64
1212
implicit none
1313
private

0 commit comments

Comments
 (0)