diff --git a/README.md b/README.md index b4a32cc..a284e61 100644 --- a/README.md +++ b/README.md @@ -103,9 +103,14 @@ fpm test --compiler ifx --profile release --flag "-coarray -DASSERT_MULTI_IMAGE" ``` ### Building and testing with the LLVM `flang-new` compiler +#### LLVM 19 Version ``` fpm test --compiler flang-new --flag "-mmlir -allow-assumed-rank -O3" ``` +#### LLVM 20 or later +``` +fpm test --compiler flang-new --flag "-O3" +``` ### Building and testing with the Numerical Algorithms Group (NAG) compiler ``` diff --git a/include/assert_macros.h b/include/assert_macros.h index 63e014b..43ee1a5 100644 --- a/include/assert_macros.h +++ b/include/assert_macros.h @@ -13,18 +13,18 @@ ! Deal with stringification issues: ! https://gcc.gnu.org/legacy-ml/fortran/2009-06/msg00131.html -#ifndef STRINGIFY +#ifndef CPP_STRINGIFY_SOURCE # if defined(__GFORTRAN__) || defined(_CRAYFTN) || defined(NAGFOR) -# define STRINGIFY(x) "x" +# define CPP_STRINGIFY_SOURCE(x) "x" # else -# define STRINGIFY(x) #x +# define CPP_STRINGIFY_SOURCE(x) #x # endif #endif #if ASSERTIONS -# define call_assert(assertion) call assert_always(assertion, "call_assert(" // STRINGIFY(assertion) // ") in file " // __FILE__ // ", line " // string(__LINE__)) -# define call_assert_describe(assertion, description) call assert_always(assertion, description // " in file " // __FILE__ // ", line " // string(__LINE__)) -# define call_assert_diagnose(assertion, description, diagnostic_data) call assert_always(assertion, description // " in file " // __FILE__ // ", line " // string(__LINE__), diagnostic_data) +# define call_assert(assertion) call assert_always(assertion, "call_assert(" // CPP_STRINGIFY_SOURCE(assertion) // ") in file " // __FILE__ // ", line " // fortran_stringify_integer(__LINE__)) +# define call_assert_describe(assertion, description) call assert_always(assertion, description // " in file " // __FILE__ // ", line " // fortran_stringify_integer(__LINE__)) +# define call_assert_diagnose(assertion, description, diagnostic_data) call assert_always(assertion, description // " in file " // __FILE__ // ", line " // fortran_stringify_integer(__LINE__), diagnostic_data) #else # define call_assert(assertion) # define call_assert_describe(assertion, description) diff --git a/src/assert/string_m.f90 b/src/assert/fortran_stringify_integer_m.f90 similarity index 62% rename from src/assert/string_m.f90 rename to src/assert/fortran_stringify_integer_m.f90 index 2385c75..2f5fc92 100644 --- a/src/assert/string_m.f90 +++ b/src/assert/fortran_stringify_integer_m.f90 @@ -1,16 +1,16 @@ -module string_m +module fortran_stringify_integer_m implicit none contains - pure function string(number) result(number_as_string) + pure function fortran_stringify_integer(number) result(number_as_string) integer, intent(in) :: number integer, parameter :: max_len=128 character(len=max_len) :: untrimmed_string character(len=:), allocatable :: number_as_string - write(untrimmed_string, *) number + write(untrimmed_string, '(i0)') number number_as_string = trim(adjustl(untrimmed_string)) end function -end module string_m +end module diff --git a/src/assert_m.f90 b/src/assert_m.f90 index 0bd7b34..6561bd8 100644 --- a/src/assert_m.f90 +++ b/src/assert_m.f90 @@ -1,7 +1,15 @@ module assert_m - use intrinsic_array_m - use assert_subroutine_m - use characterizable_m - use string_m, only : string + !! Public interface + use intrinsic_array_m, only : intrinsic_array_t + use assert_subroutine_m, only : assert, assert_always + use characterizable_m, only : characterizable_t + + ! The function below is public only to support automated + ! invocation via `assert_macros.h`. For a more broadly useful + ! function to convert numeric data to string format, please + ! consider using the functions that can be accessed via the + ! `string_t` generic interface in the Julienne framework at + ! https://go.lbl.gov/julienne. + use fortran_stringify_integer_m, only : fortran_stringify_integer implicit none -end module assert_m +end module