0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.