What is wrong with array(2:)(::2) in fortran?

67 Views Asked by At

I am learning Fortran08 and am puzzled as to why I cannot execute the following

integer :: array(8)
READ(*, *) array
array(2:)(::2)

, but the following works fine

integer :: array(8)
integer :: temp(7)
READ(*, *) array
temp = array(2:)
temp(::2)
1

There are 1 best solutions below

1
Vladimir F Героям слава On

The answer is simple, but I don't know if that much useful. It simply is not legal Fortran syntax.

Why is it so? Because the standard says so. And why? Because the committee designed it that way. Why? You have to ask them, but note that there may be a clash with string array indexing.

Fortran simply does not use consecutive array indexing parentheses, unlike C. The array syntax of Fortran and C is very different in multiple aspects.

Doesn't array(2::2) achieve what you need?