Skip to content

Commit b7def64

Browse files
committed
implicit none (external)
1 parent a24ef33 commit b7def64

14 files changed

Lines changed: 116 additions & 29 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88
- "**/*.cmake"
99
- "**/CMakeLists.txt"
1010
pull_request:
11-
release:
1211

1312
jobs:
1413

@@ -24,9 +23,12 @@ jobs:
2423
- name: Install packages
2524
run: |
2625
sudo apt update -yq
27-
sudo apt install -yq --no-install-recommends ninja-build gfortran
26+
sudo apt install -yq --no-install-recommends ninja-build
2827
2928
- run: meson setup build
29+
env:
30+
FC: gfortran-9
31+
3032
- run: meson test -C build -v
3133
- uses: actions/upload-artifact@v1
3234
if: failure()
@@ -39,11 +41,11 @@ jobs:
3941
runs-on: ubuntu-latest
4042
steps:
4143
- uses: actions/checkout@v2
42-
- run: |
43-
sudo apt update -yq
44-
sudo apt install -yq --no-install-recommends gfortran
4544

4645
- run: cmake -B build -Drealbits=64
46+
env:
47+
FC: gfortran-9
48+
4749
- run: cmake --build build --parallel
4850

4951
- run: ctest -V
@@ -55,6 +57,9 @@ jobs:
5557
path: build/Testing/Temporary/LastTest.log
5658

5759
- run: cmake -B build -Drealbits=32
60+
env:
61+
FC: gfortran-9
62+
5863
- run: cmake --build build --parallel
5964

6065
- run: ctest -V
@@ -72,11 +77,7 @@ jobs:
7277

7378
- run: cinst -y ninja
7479

75-
- run: cmake -B build -G Ninja
76-
- run: cmake --build build --parallel
77-
78-
- run: ctest -V
79-
working-directory: build
80+
- run: ctest -S setup.cmake -VV
8081
- uses: actions/upload-artifact@v1
8182
if: failure()
8283
with:

cmake/compilers.cmake

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
1+
set(CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo;Debug" CACHE STRING "Build type selections" FORCE)
2+
13
if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
2-
if(NOT WIN32)
3-
string(APPEND CMAKE_Fortran_FLAGS " -march=native -stand f18 -traceback -warn -heap-arrays")
4-
else()
5-
string(APPEND CMAKE_Fortran_FLAGS " /arch:native /stand:f18 /traceback /warn /heap-arrays")
4+
if(WIN32)
5+
string(APPEND CMAKE_Fortran_FLAGS " /arch:native /stand:f18 /traceback /warn /heap-arrays")
6+
else()
7+
string(APPEND CMAKE_Fortran_FLAGS " -march=native -stand f18 -traceback -warn -heap-arrays")
68
endif()
79
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
10+
string(APPEND CMAKE_Fortran_FLAGS " -Wall -Wextra -fimplicit-none")
11+
string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -fcheck=all -Werror=array-bounds")
12+
# -march=native is not for all CPU arches with GCC.
13+
add_compile_options(-mtune=native)
14+
815
if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 8)
916
string(APPEND CMAKE_Fortran_FLAGS " -std=f2018")
1017
endif()
11-
# not mtune=native for CPU compatibility
12-
string(APPEND CMAKE_Fortran_FLAGS " -mtune=native -fimplicit-none -Wall -Wextra")
13-
string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -ffpe-trap=overflow -Warray-bounds")
1418
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL PGI)
1519
string(APPEND CMAKE_Fortran_FLAGS " -C -Mdclchk")
20+
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Flang)
21+
string(APPEND CMAKE_Fortran_FLAGS " -W")
1622
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL NAG)
1723
string(APPEND CMAKE_Fortran_FLAGS " -f2018 -C -colour -gline -nan -info -u")
1824
endif()
1925

26+
include(CheckFortranSourceCompiles)
27+
check_fortran_source_compiles("implicit none (external); end" f2018impnone SRC_EXT f90)
28+
if(NOT f2018impnone)
29+
message(FATAL_ERROR "Compiler does not support Fortran 2018 IMPLICIT NONE (EXTERNAL): ${CMAKE_Fortran_COMPILER_ID} ${CMAKE_Fortran_COMPILER_VERSION}")
30+
endif()
31+
2032
include(CheckFortranSourceRuns)
2133
check_fortran_source_runs("use, intrinsic :: ieee_arithmetic, only: ieee_value, ieee_quiet_nan, ieee_is_nan
2234
real :: r
2335
r = ieee_value(1., ieee_quiet_nan)
2436
if (.not.ieee_is_nan(r)) error stop
25-
end program" f03nan)
37+
end program" f03nan)

setup.cmake

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# run by:
2+
# ctest -S setup.cmake
3+
4+
# --- Project-specific -Doptions
5+
# these will be used if the project isn't already configured.
6+
set(_opts)
7+
8+
# --- boilerplate follows
9+
# site is OS name
10+
if(NOT DEFINED CTEST_SITE)
11+
set(CTEST_SITE ${CMAKE_SYSTEM_NAME})
12+
endif()
13+
14+
# if compiler specified, deduce its ID
15+
if(DEFINED ENV{FC})
16+
set(FC $ENV{FC})
17+
endif()
18+
if(DEFINED CMAKE_Fortran_COMPILER)
19+
set(FC ${CMAKE_Fortran_COMPILER})
20+
endif()
21+
if(DEFINED FC)
22+
foreach(c gfortran ifort flang pgfortran nagfor xlf ftn)
23+
string(FIND ${FC} ${c} i)
24+
if(i GREATER_EQUAL 0)
25+
if(c STREQUAL gfortran)
26+
execute_process(COMMAND gfortran -dumpversion
27+
RESULT_VARIABLE _ret
28+
OUTPUT_VARIABLE _vers OUTPUT_STRIP_TRAILING_WHITESPACE)
29+
if(_ret EQUAL 0)
30+
string(APPEND c "-${_vers}")
31+
endif()
32+
endif()
33+
set(CTEST_BUILD_NAME ${c})
34+
break()
35+
endif()
36+
endforeach()
37+
endif()
38+
39+
if(NOT DEFINED CTEST_BUILD_CONFIGURATION)
40+
set(CTEST_BUILD_CONFIGURATION "Release")
41+
endif()
42+
43+
set(CTEST_SOURCE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
44+
if(NOT DEFINED CTEST_BINARY_DIRECTORY)
45+
set(CTEST_BINARY_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/build)
46+
endif()
47+
48+
if(NOT DEFINED CTEST_CMAKE_GENERATOR)
49+
find_program(_gen NAMES ninja ninja-build samu)
50+
if(_gen)
51+
set(CTEST_CMAKE_GENERATOR "Ninja")
52+
elseif(WIN32)
53+
set(CTEST_CMAKE_GENERATOR "MinGW Makefiles")
54+
set(CTEST_BUILD_FLAGS -j)
55+
else()
56+
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
57+
set(CTEST_BUILD_FLAGS -j)
58+
endif()
59+
endif()
60+
61+
ctest_start("Experimental" ${CTEST_SOURCE_DIRECTORY} ${CTEST_BINARY_DIRECTORY})
62+
if(NOT EXISTS ${CTEST_BINARY_DIRECTORY}/CMakeCache.txt)
63+
ctest_configure(BUILD ${CTEST_BINARY_DIRECTORY} SOURCE ${CTEST_SOURCE_DIRECTORY} OPTIONS "${_opts}")
64+
endif()
65+
ctest_build(BUILD ${CTEST_BINARY_DIRECTORY} CONFIGURATION ${CTEST_BUILD_CONFIGURATION})
66+
ctest_test(BUILD ${CTEST_BINARY_DIRECTORY})
67+
# ctest_submit()

src/aer.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
submodule (maptran) aer
2-
implicit none
2+
3+
implicit none (external)
34

45
contains
56

src/ecef.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
submodule (maptran) ecef
2-
implicit none
2+
3+
implicit none (external)
34

45
contains
56

src/enu.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
submodule (maptran) enu
2-
implicit none
2+
3+
implicit none (external)
34

45
contains
56

src/maptran.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module maptran
88
use, intrinsic:: iso_fortran_env, only: wp=>real64
99
#endif
1010

11-
implicit none
11+
implicit none (external)
1212
private
1313
public :: wp, pi, ecef2geodetic, geodetic2ecef, aer2enu, enu2aer, aer2ecef, ecef2aer, &
1414
enu2ecef, ecef2enu, ecef2enuv, aer2geodetic, geodetic2enu, enu2uvw,&

src/no_sphere.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
submodule (maptran) no_sphere
2-
implicit none
2+
3+
implicit none (external)
34

45
contains
56

src/sphere.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
submodule (maptran) sphere
2-
implicit none
2+
3+
implicit none (external)
34

45
contains
56

src/tests/assert.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ module assert
44
use, intrinsic:: iso_c_binding, only: sp=>c_float, dp=>c_double
55
use, intrinsic:: iso_fortran_env, only: stderr=>error_unit, real32, real64, real128
66
use, intrinsic:: ieee_arithmetic, only: ieee_is_finite, ieee_is_nan
7-
implicit none
7+
8+
implicit none (external)
89

910
#if REALBITS==32
1011
integer,parameter :: wp=real32

0 commit comments

Comments
 (0)