Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Workarounds for NAG #108

Copy link
Copy link
@certik

Description

@certik
Issue body actions

For NAG 6.2 and the latest master (f300f4a):

  1. Does not seem to support submodules.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 72b3d25..6a11a43 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -9,12 +9,6 @@ set(SRC
 
 add_library(fortran_stdlib ${SRC})
 
-if(f18errorstop)
-  target_sources(fortran_stdlib PRIVATE f18estop.f90)
-else()
-  target_sources(fortran_stdlib PRIVATE f08estop.f90)
-endif()
-
 add_subdirectory(tests)
 
 install(TARGETS fortran_stdlib
diff --git a/src/stdlib_experimental_error.f90 b/src/stdlib_experimental_error.f90
index 3d932d6..b35083b 100644
--- a/src/stdlib_experimental_error.f90
+++ b/src/stdlib_experimental_error.f90
@@ -3,16 +3,46 @@ use, intrinsic :: iso_fortran_env, only: stderr=>error_unit
 implicit none
 private
 
-interface ! f{08,18}estop.f90
-module subroutine error_stop(msg, code)
+public :: assert, error_stop
+
+contains
+
+subroutine error_stop(msg, code)
 character(*), intent(in) :: msg
 integer, intent(in), optional :: code
-end subroutine error_stop
-end interface
 
-public :: assert, error_stop
+! Aborts the program with nonzero exit code
+! this is a fallback for Fortran 2008 error stop (e.g. Intel 19.1/2020 compiler)
+!
+! The "stop <character>" statement generally has return code 0.
+! To allow non-zero return code termination with character message,
+! error_stop() uses the statement "error stop", which by default
+! has exit code 1 and prints the message to stderr.
+! An optional integer return code "code" may be specified.
+!
+! Example
+! -------
+!
+! call error_stop("Invalid argument")
 
-contains
+write(stderr,*) msg
+
+if(present(code)) then
+  select case (code)
+  case (1)
+    error stop 1
+  case (2)
+    error stop 2
+  case (77)
+    error stop 77
+  case default
+    write(stderr,*) 'ERROR: code ',code,' was specified.'
+    error stop
+  end select
+else
+  error stop
+endif
+end subroutine
 
 subroutine assert(condition, code)
 ! If condition == .false., it aborts the program.
  1. Can't find modules compiled before (fixed by Update CMakeLists handling of .mod files #109). Workaround is to specify -I manually:
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_Fortran_FLAGS_DEBUG="-I$HOME/repos/stdlib" .

Everything then builds and tests pass (including quadruple precision).

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler: nagforSpecific to NAG Fortran compilerSpecific to NAG Fortran compiler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.