Silverfrost Forums

Welcome to our forums

Fortran 2003 and 2008 features

18 Nov 2022 4:08 #29642

John

read80 is -1 for /64 and for this value ISO_FORTRAN_ENV only gives the correct result for /64. This is because at the moment I can't think of a simple way to make read80 correct for both 32 and 64 bits.

read80 = -1 means that 80 bit reals are not available.

integer128 = -1 for both 32 and 64 bit FTN95.

If the compiler was configured by the user (via /config) to make /64 the default then /-64 would revert to the compiler default. In this context it might be helpful to have /32 as an alternative to /-64.

19 Nov 2022 7:30 #29643

John

This issue has now been resolved. ISO_FORTRAN_ENV will give the relevant KINDs for both 32 bit and 64 bit FTN95.

/32 has been added as an alternative to /-64.

19 Nov 2022 8:13 #29644

Paul,

Thanks for these changes.

I think that /32 is a good addition, especially for clearer documenting of compile options in my .bat builds.

Also, my test from Fri Nov 18 did not identify 'integer_kinds' as being available. Hopefully I did not mis-spell. Is it available ?

How does /ALT_KINDS work with these ? ( I see that '1.0_K must use the default KIND values'

I will test the next FTN95 version.

19 Nov 2022 9:07 #29645

integer_kinds was missing and has been added for the next full release.

The KIND values in ISO_FORTRAN_ENV are the native KINDs, not the /ALT_KINDS values. They are constants that are external to the compiler. As things are, they don't change when /ALT_KINDS is used.

21 Nov 2022 7:05 #29646

FTN95 has been extended so that in future ISO_FORTRAN_ENV will give the correct values for /ALT_KINDS.

21 Nov 2022 11:52 #29647

z%re and z%im for complex z (from the 2008 Standard) has been added for the next release of FTN95.

22 Nov 2022 4:03 #29648

Paul, Thanks for implementing the 2008 Standard support for complex z. This will be very useful. Ken

24 Nov 2022 12:54 #29649

HYPOT has now been added to FTN95 and the DLLs for the next release.

30 Nov 2022 1:11 #29650

simon

The SOURCE keyword (Fortran 2003) for the ALLOCATE statement has now been implemented (for arrays only) and will included in the next release of FTN95.

5 Dec 2022 8:47 #29667

All of the new 2003 and 2008 features that have been suggested on this thread have now been implemented (at least for the next release of FTN95) with the exception of ASSOCIATE.

Further suggestions are welcome so that the order of implementation can be prioritised, implementing first those features that our users would find most helpful.

Since this thread is now rather long, please start a new post for any further suggestions of this kind.

ASSOCIATE currently has a low priority. FTN95 users who understand and want to employ this feature should present a case for its early implementation.

5 Dec 2022 11:28 #29671

So soon this compiler will join this six-pack list to compile this widely used F2003 code of your neighbor university? Here is its Makefile:

# Specify a particular compiler with 'make COMPILER=pgi', etc.
# Specify debugging flags with 'make MODE=debug'
# If floating-point consistency is required then set the flag 'CONS=1'
# Alternatively, these options can be specified as environment variables
# eg. 'export COMPILER=gfortran' can be added to $HOME/.bashrc

# Compiler specific flags

# PGI
# ===
ifeq ($(strip $(COMPILER)),pgi)
  FFLAGS = -r8 -fast -fastsse -O3 -Mipa=fast,inline -Minfo # Optimised

# Intel
# =====
ifeq ($(strip $(COMPILER)),intel)
  FFLAGS = -O3 -g -stand f03

# gfortran
# ========
ifeq ($(strip $(COMPILER)),gfortran)
  FFLAGS = -O3 -g -std=f2003

# g95
# ========
ifeq ($(strip $(COMPILER)),g95)
  FFLAGS = -O3

# IBM Bluegene
# ============
ifeq ($(strip $(COMPILER)),ibm)
  FFLAGS = -O5 -qhot -qipa # Optimised
  # IBM compiler needs a -WF to recognise preprocessor directives
  D = -WF,-D
endif

# ARCHER (also works for HECToR)
# ========
ifeq ($(strip $(COMPILER)),archer)
  FFLAGS = -O3 -hipa2

# The following are a list of pre-processor defines which can be added to
# the above line modifying the code behaviour at compile time.

# Set every pseudoparticle in a species to represent the same number of
# real particles.
#DEFINES += $(D)PER_SPECIES_WEIGHT

# Use second order particle weighting (default is third order).
#DEFINES += $(D)PARTICLE_SHAPE_TOPHAT

# Use fifth order particle weighting (default is third order).
#DEFINES += $(D)PARTICLE_SHAPE_BSPLINE3

https://github.com/Warwick-Plasma/epoch

I think the best way to decide which new Standard's features to add is to compile broadly used modern codes. Only this will widen the pool of new customers because it will ensure that the compiler is future proof and hence it will be appealing to the younger generation.

By the way all these compilers despite support of the 2003-2008 features either not heard of any debuggers in Linux or use debuggers which are not far from punchcards era . You waste 10x more time with them making your code working. With this code I started my attempts to modify it to my needs in January and only now succeeded with gFortran.

Due to the same problem of absence of good debuggers on all other compilers and the fact that FTN95 was not compiling another large and pretty brain breaking code which has exactly this ASSOCIATE feature i failed so far to get through this another PIC code. It is even not clear if this F2003 feature was really necessary but it was among things which stopped the code to compile.

https://gitlab.com/MD-CWI-NL/afivo-pic

With the debugger like SDBG you would just get through the running code step by step and get everything in one day. Without debuggers in some cases you will be getting stuck like in an encrypted web. And learning new complex language features without debuggers is a pure hell.

It is obvious that ALL 15 and 20 years old Standard's features have to be implemented. What the point to implement only part of existing Standards ? Imagine some arbitrary compiler which only supports part of F2018 Standard, part of F2008 Standard, part of F2003, part of F1995, part of F1977, part of F1966 then it will essentially run just the Fortran4 codes gathering around only appropriate declining legacy codes public.

5 Jan 2023 11:42 #29745

Paul, One to look at when you get the opportunity (a very minor issue).

complex z1
z1%re = 3.0 ; z1%im = 4.0
end

The Compiler says (Ver 8.95): 'Warning 298 - Variable Z1 has been used without being given an initial value', which is not true in this case.

5 Jan 2023 12:53 #29751

OK. Thanks.

5 Jan 2023 3:24 #29753

There is at least one more situation where a similar spurious warning is given -- parts of expressions wherein a variable name is required by the language rules but only the type of the variable matters. Here is an example:

program test

REAL    :: R4
Integer :: I4R

data I4R/Z'3F800000'/

print *,transfer(I4R,R4)

end program

The compiler warns that R4 is used without being given an initial value.

5 Jan 2023 4:34 #29756

mecej4

I will make a note of this.

6 Feb 2023 6:06 #29926

I was pleased to see that Source= has become available for the allocate statement. But when I get a rather unclear error message for the following code:

Module m
   Integer, Dimension(:), Allocatable :: a
   Integer, Dimension(5)              :: b
End Module m
!
Program p
   Use m
   Allocate (a, Source=b)
End Program p

When the documentation qualifies 'for arrays only' what exactly does that mean?

7 Feb 2023 7:51 #29927

Simon

Your code reveals a bug in the new FTN95 feature. At the moment it doesn't work when the arrays are declared in a module. I will log this as a bug that needs fixing.

The new feature has not yet been programmed for scalars so the following code will fail at runtime.

   integer,allocatable::a
   integer::b
   b = 7
   Allocate(a, source=b)
7 Feb 2023 8:28 #29928

Simon

The failure for arrays declared in a module has now been fixed for the next release of FTN95.

28 Feb 2023 8:06 #29966

Could we please get Nint, Aint and Anint added to the list of intrinsic functions that can be used in an initialisation expression.

1 Mar 2023 8:07 #29968

Simon

Thanks. These have now been added for the next release of FTN95.

Please login to reply.