gfortran question about optional subroutine arguments

Tobias Burnus burnus@net-b.de
Thu Mar 14 16:02:00 GMT 2013


Mark Hounschell wrote:
> On 03/14/2013 10:03 AM, Tim Prince wrote:
>> On 3/14/2013 9:39 AM, Mark Hounschell wrote:
>>> When I use -std=f95 this fortran77 code will not compile. Many
>>> different complaints but the most serious are normal variable
>>> declarations:
>>>         INTEGER*8 TOTTIME(0:MAXTASK)            ! Task total exec time (
>>> Error: Nonstandard type declaration INTEGER*8 at (1)
[...]
>
> No I'm not hoping to amend any standard. I have been using different
> vendors flavours of fortran 77 since the mid 70s. This is how it's done
> on every one I ever used.  I assumed it was standard and can hardly
> believe it isn't.

No, it is not in the Fortran standard; however, INTEGER*8, REAL*8 and 
COMPLEX*16 are very common vendor extensions. Thus, with default options 
(= -std=gnu), it is supported. Only if you explicitly ask for Fortran 95 
conformance checks, it is rejected.

> The point is, Tobias  said that anything that builds using -std=legacy
> should also build using -std=f95.

That's not what I meant. Rather the other way around:

Every program which builds with -std=f95 also build with -std=f2008, 
every program which builds with -std=f2008 also builds with -std=gnu 
(the default), and if it builds with -std=gnu, it also builds with 
-std=legacy.

In addition, any* valid Fortran 66 or Fortran 77 program builds with 
-std=f95 (or -std=f2003 or ...). Except that many such programs aren't 
standard conform as they use vendor extensions.

If the program uses a vendor extension, you might need -std=gnu or 
-std=legacy. But it only helps if a certain vendor extension is supported.


Regarding INTEGER(8): Fortran 95's intrinsic types support the syntax
   REAL(kind=<constant integer expression>) :: ...

Many compilers use the byte-size for the number, e.g. INTEGER(8) for an 
8-byte integer. However, using "8" directly is even less portable than 
INTEGER*8. One should better use it by selected_real_kind() or via a 
pre-defined constant such as real64. In any case, it makes it easier to 
change the precision of the code by changing a single constant in some 
module.



Tobias

* With the possible exception with -std=f95/f2003/f2008 for features 
which were deleted in Fortran 95. (Maybe the compiler also only warns 
for those.)



More information about the Gcc-help mailing list