replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Procedure argument assignment
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 

Procedure argument assignment

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



Joined: 27 Jun 2007
Posts: 19

PostPosted: Sat Aug 08, 2009 7:05 pm    Post subject: Procedure argument assignment Reply with quote

Dear community members,

I'm experiencing a difficulty with one-dim array passed in procedure as argument.
Even though I have allocated the memory and set each element in array to zero
, while debugging compiler raises the exception "Error 112, reference to
undefined variable array element or function result". I'm sure that each element in
array is initialzed and nullified properly before passing it, but in passed procedure
the elements of array is still "undefined"? Generally the compiler should deal with it
depending of the prefix of agrument is "IN", "OUT" or "INOUT".

THE BODY OF PROGRAM
////////
Code:
INTEGER,ALLOCATABLE::kdiag(:)
! Code omitted here
ALLOCATE(kdiag(neq),loads(0:neq))
! Code omitted here

 kdiag=0.0  ! HERE THE ARRAY ELEMENTS ARE NULLIFIED
 elements_1: DO iel=1,nels
   num=g_num(:,iel)
   CALL num_to_g(num,nf,g)
   g_g(:,iel)=g
   CALL fkdiag(kdiag,g)
 END DO elements_1



The implementation of "fkdiag" is :

Code:
SUBROUTINE fkdiag(kdiag,g)
 IMPLICIT NONE
 INTEGER,INTENT(IN)::g(:)
 INTEGER,INTENT(OUT)::kdiag(:)
 INTEGER::idof,i,iwp1,j,im,k
 kdiag = 0.0
 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

Any help in advance will be appreciated.

Regards,
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sun Aug 09, 2009 7:43 am    Post subject: Reply with quote

I suspect that you will need to use an INTERFACE for fkdiag in the code where it is called.
Back to top
View user's profile Send private message AIM Address
Ronan



Joined: 27 Jun 2007
Posts: 19

PostPosted: Sun Aug 09, 2009 9:09 am    Post subject: Procedure argument assignment Reply with quote

Quote:
I suspect that you will need to use an INTERFACE for fkdiag in the code where it is called.


I couldn't understand that and sorry for not being clear to express the situtation. Actullay each core-code snippet (e.g. fkdiag, in that case) resides in seperate file and they are bundled together in an interfaced module, which is compiled/build as Fortran library "module.lib" and later added as reference in main program. If that's what you mean with "INTERFACE' I've already used it ?

Regards,
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sun Aug 09, 2009 2:50 pm    Post subject: Reply with quote

I am suggesting that in your main program should include

Code:
INTERFACE
 SUBROUTINE fkdiag(kdiag,g)
 INTEGER,INTENT(IN)::g(:)
 INTEGER,INTENT(OUT)::kdiag(:)
 END SUBROUTINE fkdiag
END INTERFACE


unless fkdiag is defined in a MODULE and your main program has a corresponding USE statement.
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Mon Aug 10, 2009 2:17 am    Post subject: Reply with quote

From my impression of your code, you have kdiag being updated for each element, but also initialised for each element call.
In subroutine FKDIAG, shouldn't you have
INTEGER,INTENT(INOUT)::kdiag(Smile
and also not initialise kdiag to zero for each call.

(also initialise with "kdiag = 0" rather than 0.0 which is a real)
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 -> Support 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