Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran: declaration in sub-sub??

Status
Not open for further replies.

ogx

Technical User
Mar 16, 2010
1
DE
Hey, I've got a question to a fortran code.

I have to write a subroutine as part of a main programm. Now i have the following arrangement causing me trouble:


Main Programm
-----------------------
subroutine MySub(...)
!here a variable x is set (with parameter) which is used to
!set the size of a matrix in a sub-sub

implizit none

integer x
parameter (x=5)

...
call subroutine Subsub(x)
...

end


-----------------------
subroutine Subsub(x)

implicit none

integer x
real*8 aa(x,x)

...

end
-----------------------


With this I have the problem that the size of the matrix is correctly dimensioned, but it is not usable. In the debugger I get only "invalid floating point" entries. Not even initialization is working.
Is this arrangement generally possible? A declaration in a sub-sub without declarating in the superior sub? I just need it in the sub-sub and i did not want it actually to hand it over.
Although the debugger says that x contain the right numer in the sub-sub.
While changing the code to dimension with a simple number (e.g. 5 that was the value of the parameter) and not by a parameter-variable it works.
But I have to write the code variable-dependant.

Hope someone could help me
ogx
 
Declare a as

real*8, dimension:),:):: a

Allocate the space using

allocate(a(x,x))

When you've finished with it, deallocate the space using

deallocate(a)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top