- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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
링크가 복사됨
1 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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.