문제

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?

도움이 되었습니까?

해결책

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(*) :: ...

다른 팁

The original code is accepted by ifort but it is not standard fortran, hence the error from gfortran. If you supply the option -std to ifort it will print warnings when the compiler allows extensions such as this.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top