Each GCC release comes with specific Fortran improvements. This is a place to announce or discuss these new GFortran features. And global GCC improvements can of course also be discussed.
GCC 11 adds support for non-rectangular loop nests in OpenMP constructs and the allocator routines of OpenMP 5.0, including initial allocate clause support in C/C++. The OMP_TARGET_OFFLOAD environment variable and the active-levels routines are now supported. For C/C++, the declare variant and map support has been extended. For Fortran, OpenMP 4.5 is now fully supported and OpenMP 5.0 support has been extended, including the following features which were before only available in C and C++: order(concurrent) , device_type , memorder-clauses for flush , lastprivate with conditional modifier, atomic construct and reduction clause extensions of OpenMP 5.0, if clause with simd and cancel modifiers, target data without map clause, and limited support for the requires construct.
Version 2.6 of the OpenACC specification continues to be maintained and improved in the C, C++ and Fortran compilers. See the implementation status section on the OpenACC wiki page and the run-time library documentation for further information.
Fortran: Added DEPRECATED to !GCC$ 's attributes directive.
OpenMP 5.0 support has been extended: The close map modifier and the affinity clause are now supported. In addition Fortran gained additionally the following features which were available in C and C++ before: declare variant is now available, depobj , mutexinoutset and iterator can now also be used with the depend clause, defaultmap has been updated for OpenMP 5.0, and the loop directive and combined directives involving the master directive have been added.
The following OpenMP 5.1 features have been added: support for expressing OpenMP directives as C++ 11 attributes, the masked and scope construct, the nothing and error directives, and using primary with the proc_bind clause and OMP_PROC_BIND environment variable, the reproducible and unconstrained modifiers to the order clause, and, for C/C++ only, the align and allocator modifiers to the allocate clause and the atomic extensions are now available. The OMP_PLACE environment variable supports the OpenMP 5.1 features. In addition the OMP_NUM_TEAMS and OMP_TEAMS_THREAD_LIMIT environment variables and their associated API routines are now supported as well as the memory-allocation routines added for Fortran and extended for C/C++ in OpenMP 5.1. In Fortran code, strictly structured blocks can be used.
Fortran: OpenMP code using the omp_lib.h include file can no longer be compiled with -std=f95 but now requires at least -std=f2003 . Alternatively, use the omp_lib module, which still supports -std=f95 and is recommended to be used instead in general.
Fortran
WG5/N1942, “TS 29113 Further Interoperability of Fortran with C”, is now fully supported. In addition to implementing previously missing functionality, such as support for character arguments of length greater than one in functions marked bind(c) and gaps in the handling for assumed-rank arrays, numerous other bugs have been fixed, and an extensive set of new conformance test cases has been added.
GCC 12 now uses OPERATION as the name of the function to the CO_REDUCE intrinsic for the pairwise reduction, thus conforming to the Fortran 2018 standard. Previous versions used OPERATOR which conforms to TS 18508.
The problem with GCC is that only extreme rolling distributions in the “bleeding edge” actually provide the latest version in their repositories. More conventional distributions are usually some versions behind. For example, Debian “stable” is at GCC 10.2 and won’t change until their next stable version. I am mainly using Slackware and Slackware-current based distributions (named Salix and Slackel, respectively). Slackware stable was stuck at GCC 5.5.0 for years, and only recently they switched to GCC 11.2 in the new Slackware version (they skipped everything between 5.5 and 11.2). Slackware-current is a rolling distribution so it’s more up-to-date, but still not a bleeding edge distribution. I am guessing it will take a few months for them to move to GCC 12.0.1, and by then GCC 12.1 or more will be out.
A solution to the problem is to download and compile the GCC bundle yourself (I typically compile only what’s needed for gfortran). It is not hard to do that, but it’s not easy either (like 1-2 hours of intense compiling using every single thread your CPU has, and typically with computer’s fans spinning fast). Not to mention a new GCC version may or may not change something in the configuration files, so you have to deeply dive into their READMEs to see if anything has to be configured differently than the previous version.
To easily stay on the open source cutting edge, at least for Fortran, you can use Windows :). From equation.com you can download a gfortran binary snapshot, currently
GNU Fortran (GCC) 12.0.1 20220213 (experimental)
I have used the gfortran binaries from this site for years.
Yes, of course it is a distribution problem. You can use external packagers, but usually I either wait for the next distribution release, or use Slackware-current, or Void Linux. In this particular case, I had to do so, because they delayed next version more than they usually do. Imagine, GCC 5.5 for almost six years… It didn’t even support submodules.
I tried Slackware a long time ago, at the end of the 90’s. It was courageous , as it was my first Linux distro! And hardware problems were frequent in those days… I don’t remember how much time I was able to stick with it…
Slackware was for… adventurous people back in the 90s. Nowadays, it is much easier. There is a saying, “if you install distro X, you learn distro X, if you install Slackware, you learn Linux”.
However, I do not use Slackware itself. Salix is derived from Slackware, but adds several improvements while still being 100% compatible with Slackware. Slackel does the same, but for Slackware-current, which in general is stable even though it’s a “testing” distribution, and GCC is close to up-to-date there (GCC 11.2 right now). And there is also Void Linux which is not a fork but its own thing, and a “stable rolling distribution”. Void Linux has GCC 10.2.1 right now. So you can stay relatively close to the latest GCC version, but unless you choose to live on the cutting edge with a distribution that updates like crazy (I don’t), you will have to either compile the latest GCC version or use an external packager, which I consider dangerous.
The issue appears to be the unnecessary _ in the original link shared by Beliavsky (it does not work on any browser). This link appears to work on at least three browsers that I just checked. The website responds very slowly. Googling the website name also gives a direct link to the website.
You can (probably) install Homebrew in any Linux (I do have it on MX21 Linux) which comes (I guess, I do not have it at hand) with 11.2.0 - at least this is the version MacOS Homebrew offers.
@Pap I think the equivalent for adventurous people nowadays would be Arch Linux?
For me, I personally use Spack, which looks like it’s becoming the de facto standard of deploying software in HPC circles. I can simply issue spack install gcc@master and it will fetch and compile GCC master branch from the official Git tree.
module m
implicit none
public :: mean,avg
! older way to have same name for function with multiple ranks
! is an interface with module procedures
interface avg
module procedure avg_0,avg_1,avg_2
end interface avg
contains
function mean(x) result(y)
real, intent(in) :: x(..) ! assumed rank argument
real :: y
select rank (x)
rank (0) ; y = x ! scalar case
rank (1) ; y = sum(x)/max(1,size(x))
rank (2) ; y = sum(x)/max(1,size(x))
rank default ; stop "mean not implemented for rank > 2"
end select
end function mean
!
function avg_0(x) result(y) ! rank 0 argument
real, intent(in) :: x
real :: y
y = x
end function avg_0
!
function avg_1(x) result(y) ! rank 1 argument
real, intent(in) :: x(:)
real :: y
y = sum(x)/max(1,size(x))
end function avg_1
!
function avg_2(x) result(y) ! rank 2 argument
real, intent(in) :: x(:,:)
real :: y
y = sum(x)/max(1,size(x))
end function avg_2
end module m
!
program test_assumed_rank
use m, only: avg ! interface with module procedures
use m, only: mean ! function with assumed rank argument
implicit none
integer, parameter :: n1 = 1000, n2 = 5
real :: x(n1,n2)
character (len=*), parameter :: fmt="(*(f6.3))"
call random_seed()
call random_number(x)
! demonstrate rank 0, 1, 2 cases
print "(*(a6))","avg","mean","check"
print fmt,avg(x(1,1)),mean(x(1,1)),x(1,1) ! scalar
print fmt,avg(x(:,1)),mean(x(:,1)),sum(x(:,1))/n1 ! 1D
print fmt,avg(x),mean(x),sum(x)/(n1*n2) ! 2D
end program test_assumed_rank
! works with gfortran and Intel Fortran
! sample output:
! avg mean check
! 0.662 0.662 0.662
! 0.507 0.507 0.507
! 0.506 0.506 0.506
On Windows it compiles with gfortran 12.0.1 from Equation. On WSL2 gfortran --version says GNU Fortran (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 and it cannot compile the code. It does compile and run with gfortran-10. I don’t see the word “rank” at GCC 10 Release Series — Changes, New Features, and Fixes - GNU Project, but I do see entries for Assumed rank and SELECT RANK Chart of Fortran 2018 Features supported by GNU Fortran. So that site and the analogous sites for F2008 and F2003 seem most informative about gfortran.
Although the 2018 Status page was updated on the 2021-10-29, I am not sure the whole page is up to date: for example, exploring co-arrays, I have used this_image() and num_images() with GFortran 10.2.
Yes, this is a problem at times. The GCC team does however publish container images for the different releases. I think compiling source code using the desired GCC version in a container is a good solution. In terms of reproducibility it is also extremely advantageous.
I haven’t done any extensive timing comparisons, but I don’t think there’s any significant impact on speed. Containers share the Linux kernel with the host (i.e. the operating system you’re running) so it’s very lightweight compared to virtual machines.
gcc 12.1 has been released, which includes gfortran 12.1.
Here are the sections relevant to Fortran in the changes file:
Fortran:
WG5/N1942, “TS 29113 Further Interoperability of Fortran with C”, is
now fully supported. In addition to implementing previously missing
functionality, such as support for character arguments of length
greater than one in functions marked bind(c) and gaps in the handling
for assumed-rank arrays, numerous other bugs have been fixed, and an
extensive set of new conformance test cases has been added.
GCC 12 now uses OPERATION as the name of the function to the
CO_REDUCE intrinsic for the pairwise reduction, thus conforming to
the Fortran 2018 standard. Previous versions used OPERATOR which
conforms to TS 18508.
On POWER systems which support it, the -mabi=ieeelongdouble option
now selects the IEEE 128-bit floating point format for REAL(KIND=16).
R16_IBM and R16_IEEE have been added to the -fconvert option, the
CONVERT specifyer of the OPEN statement and the GFORTRAN_CONVERT_UNIT
environment variable.
OpenMP:
o OpenMP 5.0 support has been extended: The close map modifier
and the affinity clause are now supported. In addition Fortran
gained additionally the following features which were available
in C and C++ before: declare variant is now available, depobj,
mutexinoutset and iterator can now also be used with the depend
clause, defaultmap has been updated for OpenMP 5.0, and the
loop directive and combined directives involving the master
directive have been added.
o The following OpenMP 5.1 features have been added: support for
expressing OpenMP directives as C++ 11 attributes, the masked
and scope construct, the nothing and error directives, and
using primary with the proc_bind clause and OMP_PROC_BIND
environment variable, the reproducible and unconstrained
modifiers to the order clause, and, for C/C++ only, the align
and allocator modifiers to the allocate clause and the atomic
extensions are now available. The OMP_PLACE environment
variable supports the OpenMP 5.1 features. In addition the
OMP_NUM_TEAMS and OMP_TEAMS_THREAD_LIMIT environment variables
and their associated API routines are now supported as well as
the memory-allocation routines added for Fortran and extended
for C/C++ in OpenMP 5.1. In Fortran code, strictly structured
blocks can be used.
o The OpenMP_Implementation_Status can be found in the libgomp
manual.