COMPILER_VERSION(3) - [COMPILER:INQUIRY] Compiler version string
result = compiler_version()
character(len=:) function compiler_version()
o The return value is a default-kind scalar character with system-dependent length.
COMPILER_VERSION(3) returns a string containing the name and version of the compiler.
None.
The return value contains the name of the compiler and its version number used to compile the file containing the COMPILER_VERSION(3) call.
Sample program:
program demo_compiler_version use, intrinsic :: iso_fortran_env, only : compiler_version implicit none print (4a), This file was compiled by , compiler_version() end program demo_compiler_versionResults (plain):
> This file was compiled by GCC version 10.3.0An extended version that wraps the version to a width of 80 columns and attempts to show the options used one per line:> This file was compiled by Intel(R) Fortran Intel(R) 64 Compiler Classic for > applications running on Intel(R) 64, Version 2021.3.0 Build 20210609_000000
> This file was compiled by nvfortran 21.5-0 LLVM
program extended_compiler_version implicit none call platform() containsResults (fancy):subroutine platform() use, intrinsic :: iso_fortran_env, only : compiler_version use, intrinsic :: iso_fortran_env, only : compiler_options implicit none character(len=:),allocatable :: version, options character(len=*),parameter :: nl=new_line(a) integer :: where, start, break, i, last, col version=compiler_version()// options= //compiler_options() start=1 do where=index(options(start:), -) if(where.eq.0)exit break=where+start-1 options(break:break)=nl start=where enddo if(start.eq.1)then do where=index(options(start:), /) if(where.eq.0)exit break=where+start-1 options(break:break)=nl start=where enddo endif last=len_trim(version)+1 col=0 do i=1,len_trim(version) col=col+1 if(version(i:i).eq. )last=i if(col.gt.76)then version(last:last)=nl col=0 endif enddo print (a,/,3x,*(a)), This file was compiled by :, inset(version) if(options.ne.)then print (*(a)), using the options :, inset(options) endif end subroutine platform
function inset(string) result(longer) character(len=*),intent(in) :: string character(len=:),allocatable :: longer character(len=*),parameter :: nl=new_line(a) integer :: i longer= do i=1,len(string) longer=longer//string(i:i) if(string(i:i).eq.nl)then longer=longer// endif enddo end function inset
end program extended_compiler_version
> This file was compiled by : > GCC version 16.0.0 20250727 (experimental) > using the options : > -mtune=generic > -march=x86-64
Fortran 2008
COMPILER_OPTIONS(3), ISO_FORTRAN_ENV(7)
Fortran intrinsic descriptions (license: MIT) @urbanjost
