Resizing of Multi-Dimensional Arrays when Passed

后端 未结 2 1582
礼貌的吻别
礼貌的吻别 2021-01-16 10:53

All references to arrays in this post are multi-dimensional.

I came to know that when an array is passed a subroutine, it can be declared with different dimensions/s

2条回答
  •  暖寄归人
    2021-01-16 11:28

    From the Fortran 2008 standard (12.5.2.11.4):

    An actual argument that represents an element sequence and corresponds to a dummy argument that is an array is sequence associated with the dummy argument if the dummy argument is an explicit-shape or assumed-size array. The rank and shape of the actual argument need not agree with the rank and shape of the dummy argument, but the number of elements in the dummy argument shall not exceed the number of elements in the element sequence of the actual argument. If the dummy argument is assumed-size, the number of elements in the dummy argument is exactly the number of elements in the element sequence.

    It is completely legal to use a different shape and rank of the array in the subroutine, just do not reference more elements in the subroutine than the array actually has. Array temporary may be necessary, but often it is not.

提交回复
热议问题