I'm using the visual studio 2017 compilier and intel parallel studio 2018.
I wonder if there is a way to use a scalar dummy argument when the actual argument is an arbitrary size of array.
Although assignment operation is allowed to scalar to be assigned to an array, for example, the following is valid,
B (an array) = 0.d0
similar subroutine augmentation gives error due to mismatch of shape.
The following is the simple minimal example of the issue is presented in the below.
I want to know the way to use scalar dummy argument for array-type actual argument.
DOUBLE PRECISION A(5),B(5),C(5)
A = 1.D0
B = 2.D0
CALL TEST_SUM(0.D0,B,C) ! error!!
DOUBLE PRECISION A(5)
DOUBLE PRECISION B(5)
DOUBLE PRECISION C(5)
C = A + B
Well the simple answer is passing a scalar to and array is not allowed. There are some cludgy way you could get around this but it is best not going there. A couple of thing below that can be applied.
CALL TEST_SUM( [0.D0,0.D0,0.D0,0.D0,0.D0], B, C ) ! array constuctor block double precision :: A(5) ! this is a new temp A and only exists within the block A = 0.d0 ! assign array CALL TEST_SUM( A, B, C) end block