Reputation: 22460
I encountered the following Fortran code which cannot be compiled using gfortran
:
CHARACTER(LEN=20) :: filename(max_xoms,2)
DATA(filename = RESHAPE(SOURCE=(/'XobsXOM0.txt','XobsXOM1.txt','XobsXOM2.txt','XobsXOM3.txt','XobsXOM4.txt', &
'XobsXOM5.txt','XobsXOM6.txt','XobsXOM7.txt','XobsXOM8.txt','XobsXOM9.txt', &
'XobsXOS0.txt','XobsXOS1.txt','XobsXOS2.txt','XobsXOS3.txt','XobsXOS4.txt', &
'XobsXOS5.txt','XobsXOS6.txt','XobsXOS7.txt','XobsXOS8.txt','XobsXOS9.txt'/), &
SHAPE=(/max_xoms,2/)))
The makefile
that comes with the code uses ifort
. I changed the compiler to gfortran
and got an error message while compiling the above:
gfortran -c -fbacktrace -ffree-line-length-none -Wall hype_indata.f90
hype_indata.f90:48.16:
DATA(filename = RESHAPE(SOURCE=(/'XobsXOM0.txt','XobsXOM1.txt','XobsXOM2.txt'
1
Error: Syntax error in DATA statement at (1)
I've tried removing =
at 1
, but that doesn't fix the statement.
Can anyone please explain how should I fix this statement?
Thanks
BTW, gfortran --version
returns:
GNU Fortran (tdm64-2) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
Upvotes: 0
Views: 112
Reputation: 59998
if max_oms
is a parameter
(i.e. a constant, and it probably is one) you can do:
CHARACTER(LEN=20) :: filename(max_xoms,2) = RESHAPE(SOURCE=(/'XobsXOM0.txt','XobsXOM1.txt','XobsXOM2.txt','XobsXOM3.txt','XobsXOM4.txt', &
'XobsXOM5.txt','XobsXOM6.txt','XobsXOM7.txt','XobsXOM8.txt','XobsXOM9.txt', &
'XobsXOS0.txt','XobsXOS1.txt','XobsXOS2.txt','XobsXOS3.txt','XobsXOS4.txt', &
'XobsXOS5.txt','XobsXOS6.txt','XobsXOS7.txt','XobsXOS8.txt','XobsXOS9.txt'/), &
SHAPE=(/max_xoms,2/))
otherwise move
filename = RESHAPE(SOURCE=(/'XobsXOM0.txt','XobsXOM1.txt','XobsXOM2.txt','XobsXOM3.txt','XobsXOM4.txt', &
'XobsXOM5.txt','XobsXOM6.txt','XobsXOM7.txt','XobsXOM8.txt','XobsXOM9.txt', &
'XobsXOS0.txt','XobsXOS1.txt','XobsXOS2.txt','XobsXOS3.txt','XobsXOS4.txt', &
'XobsXOS5.txt','XobsXOS6.txt','XobsXOS7.txt','XobsXOS8.txt','XobsXOS9.txt'/), &
SHAPE=(/max_xoms,2/))
to the position of a first executable statement.
Generally, avoid DATA
in Fortran 90 and later.
Upvotes: 1