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

Allocate an array from inside a subroutine

vinicius_reis
Beginner
604 Views
Is it possible to allocate an array inside a subroutine? And after use that array in my main program?
Would somebody help me out with it?
Thanks,
Vincius Reis
0 Kudos
3 Replies
anthonyrichards
New Contributor III
604 Views
If I wanted to do this, I would try defining the array as ALLOCATABLE In a module which I include in the main program and the subroutine. I would then ALLOCATE it in the subroutine and, before attempting to use it in the main program, test to see if it has been ALLOCATED or not. I do not know if the above will work, but there is no harm in trying it. Make sure you have some method of keeping track of it and DEALLOCATE it when not needed.
0 Kudos
Intel_C_Intel
Employee
604 Views
Using module works fine; I use this extensively to manage space in my stat package.
0 Kudos
vinicius_reis
Beginner
604 Views
Tank you very much. I'm a little unexperienced!
0 Kudos
Reply