|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Kalashnikov
Joined: 25 May 2006 Posts: 7
|
Posted: Sat May 27, 2006 9:06 am Post subject: Problem calling a subroutine |
|
|
Hi
Me again. Sorry.
Thanks for the advice thus far. Based on your last reply, I have provided interfaces for my subroutines which are passing "assumed shape" arrays and also routines with "optional" statements. These routines are being called successfully but now I've run into another problem.
I am trying to call the following subroutine:
SUBROUTINE fkdiag(kdiag,g)
IMPLICIT NONE
INTEGER,INTENT(IN)::g(
INTEGER,INTENT(OUT)::kdiag(
INTEGER::idof,i,iwp1,j,im,k
idof=SIZE(g)
DO i=1,idof
iwp1=1
IF(g(i)/=0)THEN
DO j=1,idof
IF(g(j)/=0)THEN
im=g(i)-g(j)+1
IF(im>iwp1)iwp1=im
END IF
END DO
k=g(i)
IF(iwp1>kdiag(k))kdiag(k)=iwp1
END IF
END DO
RETURN
END SUBROUTINE fkdiag
I have provided the following interface for FKDIAG:
INTERFACE FEDOR
subroutine fkdiag(kdiag,g)
INTEGER,INTENT(IN)::g(
INTEGER,INTENT(OUT)::kdiag(
end subroutine
END INTERFACE
...and the arguments I'm trying to pass are as follows:
g = (0,1,2,3,0,6)
kdiag : This has been allocated for 12 integer entries.
When FKDIAG is called, the following error message appears:
"*** Error 112, Reference to undefined variable, array element or function result (/UNDEF)"
The problematic line in the FKDIAG subroutine is identified as the following:
IF(iwp1>kdiag(k))kdiag(k)=iwp1
This being the case, it seems to be having difficulty with the integer array kdiag(12), even though it has already been declared and allocated.
Can anyone let me know if they know the solution to this problem?
Thanks very much in advance.
Mikhail Kalashnikov _________________ Mikhail Kalashnikov |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Mon May 29, 2006 12:26 am Post subject: Problem calling a subroutine |
|
|
Mikhail
I have not tested your code but as well as declaring the array and allocating memory for it, you must provide a value for every element of the array that you use. |
|
Back to top |
|
|
Kalashnikov
Joined: 25 May 2006 Posts: 7
|
Posted: Mon May 29, 2006 4:21 am Post subject: Problem calling a subroutine |
|
|
Yes, I forgot to mention that after the array KDIAG was declared and allocated, and before it was passed into the routine FKDIAG, all entries were set to zero with the following line:
kdiag=0
In light of this, is there any other possible reason why I'm getting this error message?
Mikhail Kalashnikov _________________ Mikhail Kalashnikov |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Mon May 29, 2006 4:33 am Post subject: Problem calling a subroutine |
|
|
Maybe kdiag should be INTENT(INOUT). |
|
Back to top |
|
|
Kalashnikov
Joined: 25 May 2006 Posts: 7
|
Posted: Mon May 29, 2006 4:40 am Post subject: Problem calling a subroutine |
|
|
Of course! I should have spotted this.
Thank you very much again!
Mikhail Kalashnikov _________________ Mikhail Kalashnikov |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|