Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gfortran does not allow character arrays with varying component lengths

See the example below

 program test

 character(10),dimension(5):: models = (/"feddes.swp", "jarvis89.swp", "jarvis10.swp" ,   "pem.swp", "van.swp"/)

end

The following error is returned:

Different CHARACTER lengths (10/12) in array constructor at (1)

There is no error with ifort compiler. Why does it happen with gfortran and is there any way to circumvent this problem?

like image 678
Marcos Alex Avatar asked Feb 04 '14 12:02

Marcos Alex


1 Answers

You have some lengths 12 in the constructor, so it may be better to use length 12.

Also, use instead

character(len=12), dimension(5) :: models = [character(len=12) :: "feddes.swp", &
                "jarvis89.swp", "jarvis10.swp", "pem.swp", "van.swp"]

Possibly even better, if you have compiler support, is

character(len=*), dimension(*) :: ...
like image 88
francescalus Avatar answered Sep 28 '22 08:09

francescalus