Dave Korn | 1 Sep 2009 01:34

Re: [PATCH, Fortran] Re-fix PR 31292

Steve Kargl wrote:

> If the above explicit 'intrinsic sin' statement is missing, then ...

  I believe it is the official dogma of the Catholic Church that none of us
are without intrinsic sin ....  ;-)

    cheers,
      DaveK

Stephan Buchert | 1 Sep 2009 14:53
Picon

FORTRAN IV DATA statements

Hi,

gfortran fails to compile the
C     -----------
C        Neutral Atmosphere Empirical Model from the surface to lower
C        exosphere

The offending lines are
      COMMON/DATIME/ISDATE(3),ISTIME(2),NAME(2)
      DATA ISDATE/'01-F','EB-0','2   '/,ISTIME/'15:4','9:27'/
and the like (ISDATE implicitly declared a 3 element integer array and
expected to hold a 12 character long string).

(the complete code can be downloaded from
ftp://hanna.ccmc.gsfc.nasa.gov/pub/modelweb/atmospheric/msis/nrlmsise00/
and a description of the model is at
http://www.nrl.navy.mil/content.php?P=03REVIEW105 )

I believe that such DATA statements were allowed in FORTRAN IV and
FORTRAN 66, at least I have seen them frequently in the past. They seem
to be illegal in FORTRAN 77:

http://www.fortran.com/F77_std/rjcnf-9.html#sh-9.2

However, g77 does compile the NRLMSISE-00 code (albeit with warnings due
to other "clever" constructs).

Is there a way to get the NRLMSISE-00 code compiled with gfortran or is
the no longer maintained g77 presently the only option within gcc? If
yes, I would suggest to add an option to gfortran that allows to compile
(Continue reading)

Janus Weil | 1 Sep 2009 15:42
Picon
Favicon
Gravatar

Re: FORTRAN IV DATA statements

Hi Stephan,

> The offending lines are
>      COMMON/DATIME/ISDATE(3),ISTIME(2),NAME(2)
>      DATA ISDATE/'01-F','EB-0','2   '/,ISTIME/'15:4','9:27'/
> and the like (ISDATE implicitly declared a 3 element integer array and
> expected to hold a 12 character long string).

you don't say what the error message is, but when I compile your two
lines with gfortran 4.5 (current trunk), I get:

test.f90:5.36:

  DATA ISDATE/'01-F','EB-0','2   '/,ISTIME/'15:4','9:27'/
                                    1
Error: Incompatible types in DATA statement at (1); attempted
conversion of CHARACTER(1) to INTEGER(4)
test.f90:5.6:

  DATA ISDATE/'01-F','EB-0','2   '/,ISTIME/'15:4','9:27'/
      1
Error: Incompatible types in DATA statement at (1); attempted
conversion of CHARACTER(1) to INTEGER(4)

This can easily be cured by something like

CHARACTER*4 :: ISDATE,ISTIME

or an equivalent IMPLICIT statement.
Note: When compiling with -std=f95, one gets the error:
(Continue reading)

Tim Prince | 1 Sep 2009 16:00
Picon
Favicon

Re: FORTRAN IV DATA statements

Janus Weil wrote:
> Hi Stephan,
> 
> 
>> The offending lines are
>>      COMMON/DATIME/ISDATE(3),ISTIME(2),NAME(2)
>>      DATA ISDATE/'01-F','EB-0','2   '/,ISTIME/'15:4','9:27'/
>> and the like (ISDATE implicitly declared a 3 element integer array and
>> expected to hold a 12 character long string).
> 
> you don't say what the error message is, but when I compile your two
> lines with gfortran 4.5 (current trunk), I get:
> 
> test.f90:5.36:
> 
>   DATA ISDATE/'01-F','EB-0','2   '/,ISTIME/'15:4','9:27'/
>                                     1
> Error: Incompatible types in DATA statement at (1); attempted
> conversion of CHARACTER(1) to INTEGER(4)
> test.f90:5.6:
> 
>   DATA ISDATE/'01-F','EB-0','2   '/,ISTIME/'15:4','9:27'/
>       1
> Error: Incompatible types in DATA statement at (1); attempted
> conversion of CHARACTER(1) to INTEGER(4)
> 
> This can easily be cured by something like
> 
> CHARACTER*4 :: ISDATE,ISTIME
> 
(Continue reading)

Tobias Burnus | 1 Sep 2009 16:17
Picon

Re: FORTRAN IV DATA statements

Hi Stephan,

On 09/01/2009 02:53 PM, Stephan Buchert wrote:
> The offending lines are
>       COMMON/DATIME/ISDATE(3),ISTIME(2),NAME(2)
>       DATA ISDATE/'01-F','EB-0','2   '/,ISTIME/'15:4','9:27'/
> and the like (ISDATE implicitly declared a 3 element integer array and
> expected to hold a 12 character long string). [...]
>
> I believe that such DATA statements were allowed in FORTRAN IV and
> FORTRAN 66

I think that this is some kind of vendor extension. The reason is that
Fortran 66 did not have character strings (only Hollerith, which were
new in F66) while F77 added the character data type but seemingly does
not allow this.

(For the Fortran 66 standard [and other Fortran standards], see
http://gcc.gnu.org/wiki/GFortranStandards and for the Fortran history
see http://en.wikipedia.org/wiki/Fortran#FORTRAN_66 )

> However, g77 does compile the NRLMSISE-00 code (albeit with warnings due
> to other "clever" constructs).
> Is there a way to get the NRLMSISE-00 code compiled with gfortran or is
> the no longer maintained g77 presently the only option within gcc? If
> yes, I would suggest to add an option to gfortran that allows to compile
> even FORTRAN 66/IV programs, if that is not too much work.

gfortran currently does not support this thus g77 seems to be the only
option in GCC. I think one can consider adding support for it in
(Continue reading)

Tobias Burnus | 1 Sep 2009 16:35
Picon

Re: FORTRAN IV DATA statements

Hi Stephan,

>> The offending lines are
>>      COMMON/DATIME/ISDATE(3),ISTIME(2),NAME(2)
>>      DATA ISDATE/'01-F','EB-0','2   '/,ISTIME/'15:4','9:27'/
>> and the like (ISDATE implicitly declared a 3 element integer array and
>> expected to hold a 12 character long string).
>>     
> CHARACTER*4 :: ISDATE,ISTIME
>
>   

As the program is small, I would just apply the following patch and
compile the program with gfortran.

Tobias

--- orig.for    2009-09-01 16:34:52.766683989 +0200
+++ nrlmsise00_sub.for  2009-09-01 16:31:03.529682582 +0200
 <at>  <at>  -132,6 +132,7  <at>  <at> 
 C
 C        To get current values of SW: CALL TRETRV(SW)
 C
+      CHARACTER(len=4) :: ISDATE(3),ISTIME(2),NAME(2)
       DIMENSION D(9),T(2),AP(7),DS(9),TS(2)
       DIMENSION ZN3(5),ZN2(4),SV(25)
       COMMON/GTS3C/TLB,S,DB04,DB16,DB28,DB32,DB40,DB48,DB01,ZA,T0,Z0
 <at>  <at>  -1651,6 +1652,7  <at>  <at> 
 C-----------------------------------------------------------------------
       BLOCK DATA GTD7BK
(Continue reading)

Steve Kargl | 1 Sep 2009 16:39
Picon

Re: FORTRAN IV DATA statements

On Tue, Sep 01, 2009 at 04:17:47PM +0200, Tobias Burnus wrote:
> Hi Stephan,
> 
> On 09/01/2009 02:53 PM, Stephan Buchert wrote:
> > The offending lines are
> >       COMMON/DATIME/ISDATE(3),ISTIME(2),NAME(2)
> >       DATA ISDATE/'01-F','EB-0','2   '/,ISTIME/'15:4','9:27'/
> > and the like (ISDATE implicitly declared a 3 element integer array and
> > expected to hold a 12 character long string). [...]
> >
> > I believe that such DATA statements were allowed in FORTRAN IV and
> > FORTRAN 66
> 
> > However, g77 does compile the NRLMSISE-00 code (albeit with warnings due
> > to other "clever" constructs).
> > Is there a way to get the NRLMSISE-00 code compiled with gfortran or is
> > the no longer maintained g77 presently the only option within gcc? If
> > yes, I would suggest to add an option to gfortran that allows to compile
> > even FORTRAN 66/IV programs, if that is not too much work.
> 
> gfortran currently does not support this thus g77 seems to be the only
> option in GCC. I think one can consider adding support for it in
> gfortran using the -std=legacy option. There are two reasons for adding
> it: (a) It is supported by g77 and gfortran strives for compatibility
> with g77 and (b) it is reasonably clear what the result should be and it
> is relatively easy to implement.
> 
> Can you fill a bugreport?

Please, no.  gfortran should not become a cesspool of
(Continue reading)

Tim Prince | 1 Sep 2009 19:43
Picon
Favicon

Re: FORTRAN IV DATA statements

Tobias Burnus wrote:
> Hi Stephan,
> 
> On 09/01/2009 02:53 PM, Stephan Buchert wrote:
>> The offending lines are
>>       COMMON/DATIME/ISDATE(3),ISTIME(2),NAME(2)
>>       DATA ISDATE/'01-F','EB-0','2   '/,ISTIME/'15:4','9:27'/
>> and the like (ISDATE implicitly declared a 3 element integer array and
>> expected to hold a 12 character long string). [...]
>>
>> I believe that such DATA statements were allowed in FORTRAN IV and
>> FORTRAN 66
> 
> I think that this is some kind of vendor extension. The reason is that
> Fortran 66 did not have character strings (only Hollerith, which were
> new in F66) while F77 added the character data type but seemingly does
> not allow this.
> 
Hollerith constant expressed with apostrophes was a vendor extension to 
f66, typically supported by IBM and HP but few others. Its use was often 
a sign of intentional non-portability. In order to support the extension 
in f77, it involved the new extension of supporting character strings to 
assign and initialize Hollerith.

Stephan Buchert | 2 Sep 2009 14:12
Picon

Re: FORTRAN IV DATA statements

Thanks for all the answers. I have modified my copy of the NRLMSISE-00
Fortran code, such that gfortran compiles it. And I can inform the
maintainers of the MSIS model about the problem. The code is actively
used by perhaps 100-1000 people in the world (eg to model air drag on
space craft, radiation levels from cosmic radiation, and electrical
currents in the ionosphere). It was last updated in 2004, but offending
lines were probably there in previous versions as well. Google does not
bring up any other user complaints about the code, neither have I heard
of any. So most FORTRAN compilers seem to compile the code, or so far
all the affected users have fixed the issue silently for themselves.

As it was noted in some of the answers the lines

      COMMON/DATIME/ISDATE(3),ISTIME(2),NAME(2)
      DATA ISDATE/'01-F','EB-0','2   '/,ISTIME/'15:4','9:27'/

make use of literal constants, enclosed in apostrophes, which is a
feature in FORTRAN IV, a standard by IBM:
http://www.fh-jena.de/~kleine/history/languages/GC28-6515-10-FORTRAN-IV-Language.pdf

If I change the lines to

      COMMON/DATIME/ISDATE(3),ISTIME(2),NAME(2)
      DATA ISDATE/4H01-F,4HEB-0,4H2   /,ISTIME/4H15:4,4H9:27/

which is valid FORTRAN 66 with Hollerith constants, but invalid FORTRAN
77 because of the incompatible types, then gfortran does indeed compile
the code with warnings like

      DATA ISDATE/4H01-F,4HEB-0,4H2   /,ISTIME/4H15:4,4H9:27/           
(Continue reading)

Tim Prince | 2 Sep 2009 14:24
Picon
Favicon

Re: FORTRAN IV DATA statements

Stephan Buchert wrote:
>  FORTRAN IV, a standard by IBM:
> http://www.fh-jena.de/~kleine/history/languages/GC28-6515-10-FORTRAN-IV-Language.pdf
No, the compiler I learned on was an f66 compiler, also called Fortran 
IV, but with no major extensions besides NAMELIST, and with a manual 
including quotes from an IBM manual for an earlier version of "Fortran 
IV" on an earlier architecture (which did not support the quoted 
Hollerith strings).  How is Fortran IV "standard" when it changed from 
one IBM platform to another?
Unless your meaning of "standard" is "number 1 ranked in degree of usage 
[in some unspecified year]."


Gmane