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 ////////
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 :
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,