问题
I am trying to run a program, which works fine on my laptop, on a remote supercomputer. But the program is not compiling there. Trying to trace the problem, I reduced the program to the basic minimum, and still it is giving me a compilation error. Anyone has any ideas what might be going wrong here?
[k00603@fe01p08 python_utilities]$cat test.f90
program test
character(:), allocatable :: out
end program test
[k00603@fe01p08 python_utilities]$gfortran test.f90
In file test.f90:3
character(:), allocatable :: out
1
Error: Syntax error in CHARACTER declaration at (1)
I guess the gfortran is running fine as when I do the following, it works:
[k00603@fe01p08 python_utilities]$cat test.f90
program test
print *, "Hello World!"
end program test
[k00603@fe01p08 python_utilities]$gfortran test.f90
[k00603@fe01p08 python_utilities]$./a.out
Hello World!
The compiler on the supercomputer is:
[k00603@fe01p08 256]$gfortran --version
GNU Fortran (GCC) 4.1.2 20080704 (Red Hat 4.1.2-51)
Copyright (C) 2007 Free Software Foundation, Inc.
回答1:
CHARACTER(:)...
is a Fortran 2003 feature known as deferred length character. It was only recently added to gfortran and support in some areas (deferred length character components) is still incomplete.
Your supercomputer is probably running a older version of the compiler which lacks support for this feature.
回答2:
character(:), allocatable :: out
is declaring an allocatable scaler. This is a new feature of Fortran 2003. The compiler on the super computer likely doesn't support this newer feature.
You imply that you are using gfortran. http://gcc.gnu.org/wiki/GFortran lists allocatable scalers as added in gfortran version 4.5 (see 4.5 / Fortran 2003). The current release version is 4.7.
来源:https://stackoverflow.com/questions/15401774/fortran-syntax-error-in-character-declaration