This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Fortran 77 code and Data statements...


I am trying to port some old fortran code to linux from AIX.  The code
compiled without errors in AIX with xlf.  However, in linux, g77 seems
to dislike the array-initializing DATA statements.   Here is a small
sample program I wrote:


          INTEGER*2
     &  ELEPHANT(3,10,27),
     &  I, J, K

          DATA ((ELEPHANT(1,I,25),I=1,3) /3 * 23/
          DATA ((ELEPHANT(2,J,K),J=1,2),K=26,27) /4 * 34/
          ELEPHANT(2,1,3) = 4
          DO 15 K=7,10
              DO 20 L=1,3
                 ELEPHANT(2,K,L) = 9888
 20        CONTINUE
 15    CONTINUE

          END

And these are the error mesages i get when i compile my file (tutu.f)
with g77 and NO options:

> g77 tutu.f
tutu.f: In program `MAIN__':
tutu.f:5:
             DATA ((ELEPHANT(1,I,25),I=1,3) /3 * 23/
                               ^
Invalid declaration of or reference to symbol `i' at (^) [initially seen
at (^)]
tutu.f:5:
             DATA ((ELEPHANT(1,I,25),I=1,3) /3 * 23/
                    ^
Expression at (^) has incorrect data type or rank for its context
tutu.f:5:
             DATA ((ELEPHANT(1,I,25),I=1,3) /3 * 23/
                  1                         2
Unexpected token at (2) in implied-DO construct at (1) -- form of
implied-DO is `(item-list,do-var=start,end[,incr])'
tutu.f:6:
             DATA ((ELEPHANT(2,J,K),J=1,2),K=26,27) /4 * 34/
                               ^
Invalid declaration of or reference to symbol `j' at (^) [initially seen
at (^)]
tutu.f:6:
             DATA ((ELEPHANT(2,J,K),J=1,2),K=26,27) /4 * 34/
                                 ^
Invalid declaration of or reference to symbol `k' at (^) [initially seen
at (^)]
tutu.f:6:
             DATA ((ELEPHANT(2,J,K),J=1,2),K=26,27) /4 * 34/
                    ^
Expression at (^) has incorrect data type or rank for its context

As you can see, the compiler will only compile the Explicit do loop
intialization and not the fortran 77 extension implicit do loop way of
intializing the array. This would be a fine solution if I didn't have
about 50 lines of these DATA statements to re-write into 5 line Do
loops. Can anyone tell me where the source of the problem is (I have
tried compiling with various compiler options but this doesn't seem to
help)?  Can anyone recommend a better solution than the explicit do-loop
code I have written?
Thanks


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]