Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29233 Discussions

adjustable array as a formal parameter

dnoack
Beginner
479 Views

Hello,

I would like to give anarray as a formal parameter to a subroutine in the following way

subroutine sub(b)
double precision, dimension(:) :: b
write(*,*) b
end subroutine sub

program arrayDelivery
double precision, dimension(3) :: a
a=987654.321
call sub(a)
end

Althoughifort compiles the code without any errors,the program does not deliver the correct results. Instead of the values for b it prints only a blank line. I think, that the delivery of the formal parameter is not correct.

Please can anyone explain to me the reason.

Thanks

dino

0 Kudos
1 Reply
Steven_L_Intel1
Employee
479 Views
That's not an adjustable array (where you would pass the bound as a separate parameterr and declare it in the subroutine as a(n)), it's an assumed-shape array and an explicit interface is required to be visible to the caller. If you make sub a "contained" procedure of the main program, that would do it, otherwise sub needs to be in a module or you have to write an INTERFACE block.
0 Kudos
Reply