- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page