From 39010da2858961059a6bd8ef44f3a4d4b86e2fc7 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Sat, 4 Jan 2020 21:58:49 -0500 Subject: [PATCH] add missing implicit none, set compiler flags to force implicit none also set minimum CMake version to 3.14 per prior discussion and add example check requiring 3.14: real128 --- CMakeLists.txt | 17 +++++++++++++++-- src/f08estop.f90 | 2 ++ src/f18estop.f90 | 2 ++ src/tests/ascii/test_ascii.f90 | 2 ++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea26fc41a..ffd1c0def 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,25 @@ -cmake_minimum_required(VERSION 3.5.0) +cmake_minimum_required(VERSION 3.14.0) project(stdlib Fortran) enable_testing() # this avoids stdlib and projects using stdlib from having to introspect stdlib's directory structure +# FIXME: this eventually needs to be handled more precisely, as this spills all .mod/.smod into one directory +# and thereby can clash if module/submodule names are the same in different parts of library set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}) -# compiler feature checks +# --- compiler options +if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU) + add_compile_options(-fimplicit-none) +elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Intel) + add_compile_options(-warn declarations) +elseif(CMAKE_Fortran_COMPILER_ID STREQUAL PGI) + add_compile_options(-Mdclchk) +endif() + +# --- compiler feature checks include(CheckFortranSourceCompiles) +include(CheckFortranSourceRuns) check_fortran_source_compiles("error stop i; end" f18errorstop SRC_EXT f90) +check_fortran_source_runs("use, intrinsic :: iso_fortran_env, only : real128; real(real128) :: x; x = x+1; end" f03real128) add_subdirectory(src) diff --git a/src/f08estop.f90 b/src/f08estop.f90 index d50197866..0ff97ca14 100644 --- a/src/f08estop.f90 +++ b/src/f08estop.f90 @@ -1,5 +1,7 @@ submodule (stdlib_experimental_error) estop +implicit none + contains module procedure error_stop diff --git a/src/f18estop.f90 b/src/f18estop.f90 index ea83de79f..5a41ba775 100644 --- a/src/f18estop.f90 +++ b/src/f18estop.f90 @@ -1,5 +1,7 @@ submodule (stdlib_experimental_error) estop +implicit none + contains module procedure error_stop diff --git a/src/tests/ascii/test_ascii.f90 b/src/tests/ascii/test_ascii.f90 index 3c29956f3..add28c698 100644 --- a/src/tests/ascii/test_ascii.f90 +++ b/src/tests/ascii/test_ascii.f90 @@ -8,6 +8,8 @@ program test_ascii is_control, is_punctuation, is_graphical, is_printable, is_ascii, & to_lower, to_upper, LF, TAB, NUL, DEL + implicit none + print *, "Lowercase letters: ", lowercase print *, "Uppercase letters: ", uppercase print *, "Digits: ", digits