- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is a small program:
program aa
implicite none
double precision, allocatable:: XX(:,:),XX2(:,:)
Allocate XX(3,4)
....
..
Call TET(XX,XX2)
...
END
Subroutine TET (X,X2)
...
...
Allocate X2(2,3)
..
End subroutine
The problem is that X2 can not be allocate in the subroutin. Is there any way that I can allocate the X2 in a subroutin not in the main program.
Thx
program aa
implicite none
double precision, allocatable:: XX(:,:),XX2(:,:)
Allocate XX(3,4)
....
..
Call TET(XX,XX2)
...
END
Subroutine TET (X,X2)
...
...
Allocate X2(2,3)
..
End subroutine
The problem is that X2 can not be allocate in the subroutin. Is there any way that I can allocate the X2 in a subroutin not in the main program.
Thx
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes. X2 must be declared in the subroutine exactly as it is in the main program, with ALLOCATABLE and a dimension of (:,:). And... an explicit interface to TET must be visible to the caller. Either put TET in a module and USE the module., or make TET a contained routine of the main program.

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