- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need help with passing allocatable arrays among different subroutines where the dummy arguments within subroutines have the same name as the actual arguments.
Regards,
Currently this is what I am doing
! ************ Code sample begins here ***********!
Main_Subroutine
use mod ! (mod contains the declarations to the global variables. m and n assigned in a different subroutine)
real,dimension(:,:),allocatable :: arg1,arg2
allocate(arg1(m,n),arg2(m,n))
call Sub1(arg1,arg2)
end Main_Subroutine
!--------------------------------------------------------------!
subroutine Sub1(arg1,arg2)
use mod
real,dimension(:,:),allocatable :: arg1,arg2
allocate(arg1(m,n),arg2(m,n))
!! processing code
end Sub1
! ************ Code sample ends here ***********!
The code compiles correctly when this is done, but I get the following warning message
Warning: In the call to SUB1, actual argument #1 does not match the type and kind of the corresponding dummy argument.
Warning: In the call to SUB1, actual argument #2 does not match the type and kind of the corresponding dummy argument. Could someone tell me as to where am I going wrong here ? Is there a way to proceed without changing the variable name of the dummy arguments, as i have numerous subroutines with the same dummy arguments declared and changing them is going to be really tedious.
Thank you,
Regards,
Sangeetha Chandrasekaran
Univerisity of Illinois
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First, you are doubly allocating arg1 and arg2. Once before the call to Sub1 and once at the beginning of Sub1. You must decide where you want to do the allocations.
Second, in order to pass an array descriptor (required for allocatable array to be allocated within Sub1), Sub1 needs to have an interface block. You could place the interface block into module mod or in some other module (mod_subs) used for this purpose.
Jim Dempsey
Second, in order to pass an array descriptor (required for allocatable array to be allocated within Sub1), Sub1 needs to have an interface block. You could place the interface block into module mod or in some other module (mod_subs) used for this purpose.
Jim Dempsey

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