Skip to content

Commit 26f23a5

Browse files
committed
add CMAKE_MAXIMUM_RANK
1 parent dedc284 commit 26f23a5

File tree

7 files changed

+38
-20
lines changed

7 files changed

+38
-20
lines changed

.github/workflows/CI.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
run: brew install gcc@${GCC_V} || brew upgrade gcc@${GCC_V} || true
5858

5959
- name: Configure with CMake
60-
run: cmake -Wdev -DCMAKE_BUILD_TYPE=Release -S . -B build
60+
run: cmake -Wdev -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAXIMUM_RANK=5 -S . -B build
6161

6262
- name: Build and compile
6363
run: cmake --build build
@@ -80,6 +80,6 @@ jobs:
8080
- name: Test manual makefiles
8181
if: contains(matrix.os, 'ubuntu') && contains(matrix.gcc_v, '9')
8282
run: |
83-
make -f Makefile.manual
83+
make -f Makefile.manual FYPPFLAGS="-DMAXRANK=5"
8484
make -f Makefile.manual test
8585
make -f Makefile.manual clean

.github/workflows/ci_windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Install fypp
1919
run: pip install fypp
2020

21-
- run: cmake -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND" -Wdev -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_Fortran_FLAGS_DEBUG="-Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all -fbacktrace"
21+
- run: cmake -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND" -Wdev -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_Fortran_FLAGS_DEBUG="-Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all -fbacktrace" -DCMAKE_MAXIMUM_RANK=5
2222

2323
env:
2424
FC: gfortran

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ check_fortran_source_compiles("error stop i; end" f18errorstop SRC_EXT f90)
1818
check_fortran_source_compiles("real, allocatable :: array(:, :, :, :, :, :, :, :, :, :); end" f03rank SRC_EXT f90)
1919
check_fortran_source_runs("use, intrinsic :: iso_fortran_env, only : real128; real(real128) :: x; x = x+1; end" f03real128)
2020

21+
if(DEFINED CMAKE_MAXIMUM_RANK)
22+
set(CMAKE_MAXIMUM_RANK ${CMAKE_MAXIMUM_RANK})
23+
endif()
24+
2125
add_subdirectory(src)

src/CMakeLists.txt

+19-13
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,25 @@ foreach(infileName IN LISTS fppFiles)
1919
set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${infileName}")
2020

2121
# Custom command to do the processing
22-
if(f03rank)
23-
add_custom_command(
24-
OUTPUT "${outfile}"
25-
COMMAND fypp "${infile}" "${outfile}"
26-
MAIN_DEPENDENCY "${infile}"
27-
VERBATIM)
28-
else()
29-
add_custom_command(
30-
OUTPUT "${outfile}"
31-
COMMAND fypp -DVERSION90 "${infile}" "${outfile}"
32-
MAIN_DEPENDENCY "${infile}"
33-
VERBATIM)
34-
endif()
22+
if(DEFINED CMAKE_MAXIMUM_RANK)
23+
add_custom_command(
24+
OUTPUT "${outfile}"
25+
COMMAND fypp -DMAXRANK=${CMAKE_MAXIMUM_RANK} "${infile}" "${outfile}"
26+
MAIN_DEPENDENCY "${infile}"
27+
VERBATIM)
28+
elseif(f03rank)
29+
add_custom_command(
30+
OUTPUT "${outfile}"
31+
COMMAND fypp "${infile}" "${outfile}"
32+
MAIN_DEPENDENCY "${infile}"
33+
VERBATIM)
34+
else()
35+
add_custom_command(
36+
OUTPUT "${outfile}"
37+
COMMAND fypp -DVERSION90 "${infile}" "${outfile}"
38+
MAIN_DEPENDENCY "${infile}"
39+
VERBATIM)
40+
endif()
3541

3642
# Finally add output file to a list
3743
set(outFiles ${outFiles} "${outfile}")

src/stdlib_experimental_stats.fypp

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ interface mean
6666
#{if rank > 0}#(${":" + ",:" * (rank - 1)}$)#{endif}#
6767
#:enddef
6868

69-
#:if VERSION90
69+
#:if defined('MAXRANK')
70+
#:set ranks = range(3,MAXRANK+1)
71+
#:elif VERSION90
7072
#:set ranks = range(3,8)
7173
#:else
7274
#:set ranks = range(3,16)

src/stdlib_experimental_stats_mean.fypp

+3-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ end function mean_2_${k1}$_dp
9595
#{if rank > 0}#(${":" + ",:" * (rank - 1)}$)#{endif}#
9696
#:enddef
9797

98-
#:if VERSION90
98+
#:if defined('MAXRANK')
99+
#:set ranks = range(3,MAXRANK+1)
100+
#:elif VERSION90
99101
#:set ranks = range(3,8)
100102
#:else
101103
#:set ranks = range(3,16)

src/tests/stats/CMakeLists.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
ADDTEST(mean)
22

3-
if(f03rank)
4-
ADDTEST(mean_f03)
3+
if(DEFINED CMAKE_MAXIMUM_RANK)
4+
if(${CMAKE_MAXIMUM_RANK} GREATER 7)
5+
ADDTEST(mean_f03)
6+
endif()
7+
elseif(f03rank)
8+
ADDTEST(mean_f03)
59
endif()

0 commit comments

Comments
 (0)