Gfortran does not allow character arrays with different component lengths

See 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 lengths of CHARACTER (10/12) in the array constructor with (1)

There is no error in the ifort compiler. Why is this happening with gfortran and is there a way around this problem?

+4
source share
2 answers

You have a length of 12 in the constructor, so it's best to use a length of 12.

Also use instead

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

Perhaps even better if you have compiler support,

character(len=*), dimension(*) :: ...
+9
source

ifort, fortran, , gfortran. -std ifort, , , .

0

Source: https://habr.com/ru/post/1525215/


All Articles