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

Creating a matrix in a subroutine

kalaei
Beginner
363 Views
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
0 Kudos
1 Reply
Steven_L_Intel1
Employee
363 Views
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.
0 Kudos
Reply