Support for implicit none external

All,

As of Fortran 2018, this:

program main
   implicit none(type, external)
end program main

is valid Fortran. And that code is compiled by GCC 13.2, Intel ifort 2021.12, Intel ifx 2024.1, and NAG 7.2.

But with nvfortran 24.3:

@$ nvfortran -V

nvfortran 24.3-0 64-bit target on x86-64 Linux -tp broadwell
NVIDIA Compilers and Tools
Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES.  All rights reserved.
@$ nvfortran test.F90
NVFORTRAN-S-0034-Syntax error at or near ( (test.F90: 2)
  0 inform,   0 warnings,   1 severes, 0 fatal for main

Is there a flag one can use to enable this?

I tried suffixing the file with .f18 extension. Interestingly, the 24.3 compiler didn’t fail, but it didn’t generate a .o file, either.

Huh. I guess I didn’t know different extensions did different things with nvfortran. Is that how nvfortran handles what standard you wish to apply to a Fortran code? I know some compilers do things like -std=f18 or whatever.

(And, as far as I remember, the Standard does not specify what a Fortran file will be named. I just know there is a convention that .f is fixed-format and .f90 is free-format.)

Hi Matt,

nvfortran only supports a few F2018 features such as DO CONCURRENT. Our focus is to add F2018 features to the flang F18 effort (aka “new” flang). Once mature enough, our plan is to then replace nvfortran with our build of flang.

Unless engineering changed something on me, the suffix should only matter in defaulting the formatting, i.e. “.f” for fixed, and “.f90” for free, then an upper case “F” says to enable preprocessing by default.

The suffix, including other suffixes, “.f95”, “.f03”, “.f18”, do not denote the standard version, at least for the compiler, and treated the same as “.f90” (i.e. free format).

-Mat

For what is worth, flang-new compiles this code.

Welp. Maybe it’s time to try building flang again. @mfatica is this:

https://flang.llvm.org/docs/GettingStarted.html

still the best resource for building flang? The last time I tried following that, it failed…but that was a while ago.

I started from this script:

and added these lines (on MacOS):

if [ uname -s == Darwin ] ; then
ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd $LLVH_HOME/latest/lib
fi

1 Like

Streamlined version of the Flang LLVM build script: build script for LLVM & Flang-f18 Fortran compiler · GitHub

Ooh. Thanks @mhirsch. I’ll give that a try (with appropriate edits so I don’t explode my home quota :) )

Thanks for noting that, I added Disk Usage to the script Readme