forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem calling a subroutine

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Plato
View previous topic :: View next topic  
Author Message
Kalashnikov



Joined: 25 May 2006
Posts: 7

PostPosted: Sat May 27, 2006 9:06 am    Post subject: Problem calling a subroutine Reply with quote

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(Smile
INTEGER,INTENT(OUT)::kdiag(Smile
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(Smile
INTEGER,INTENT(OUT)::kdiag(Smile
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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6688
Location: Salford, UK

PostPosted: Mon May 29, 2006 12:26 am    Post subject: Problem calling a subroutine Reply with quote

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
View user's profile Send private message AIM Address
Kalashnikov



Joined: 25 May 2006
Posts: 7

PostPosted: Mon May 29, 2006 4:21 am    Post subject: Problem calling a subroutine Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6688
Location: Salford, UK

PostPosted: Mon May 29, 2006 4:33 am    Post subject: Problem calling a subroutine Reply with quote

Maybe kdiag should be INTENT(INOUT).
Back to top
View user's profile Send private message AIM Address
Kalashnikov



Joined: 25 May 2006
Posts: 7

PostPosted: Mon May 29, 2006 4:40 am    Post subject: Problem calling a subroutine Reply with quote

Of course! I should have spotted this.

Thank you very much again!

Mikhail Kalashnikov
_________________
Mikhail Kalashnikov
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Plato All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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