I want to return an array to a function.
My program is like this:
MODULE DIRECT_METHODS_FOR_SOLUTION_OF_LINEAR_ALGEBRAIC_EQUATIONS CONTAINS
FUNCTION CroutDecomp(AA,total_rows,total_columns,no_of_equations) !This routine decomposes the 'A' matrix of Ax=b into an upper and lower triangular matrix
!It is to be noted that this function fills in only the combined matrix of 'alpha's' and 'beta's' ; where alpha is the upper triangular matrix and beta is the lower triangular matrix.
!Crout's decomposition carries out 2 steps: !1) First, for i=1,2,---,j use , beta(i,j)= a(i,j)-(summation over k=1 to i-1)[alpha(i,k)beta(k,j) !2)Second, for i=j+1,--N use, alpha(i,k)= 1/beta(j,j)((a(i,j)-summation over k=1 to j-1 [ alpha(i,k)*beta(k,j)]
INTEGER::total_rows,total_columns ,no_of_equations
INTEGER:: i,j,k REAL ::sum1 REAL8 alpha(total_rows,total_columns),beta(total_rows,total_columns),decomposed(total_rows,total_columns) REAL8,DIMENSION(100,100)::AA,x
!!!The program calculates a 3 x 3 array **'decomposed'**CroutDecomp = decomposed
END FUNCTION CroutDecomp
END MODULE DIRECT_METHODS_FOR_SOLUTION_OF_LINEAR_ALGEBRAIC_EQUATIONS
PROGRAM LINEAR_EQUATIONS_SOLVER USE DIRECT_METHODS_FOR_SOLUTION_OF_LINEAR_ALGEBRAIC_EQUATIONS !IMPLICIT NONE REAL8,DIMENSION(100,100)::AA,x REAL8,DIMENSION(100)b INTEGERtotal_rows,total_columns,no_of_equations,i,j PRINT*, 'ENTER THE TOTAL NUMBER OF ROWS AND COLUMNS' READ*, total_rows,total_columns PRINT*, 'ENTER THE TOTAL NUMBER OF EQUATIONS' READ*, no_of_equations PRINT*, 'ENTER THE A MATRIX OF Ax = b' ROW_LOOP:DO i=1,total_rows COLUMN_LOOP:DO j=1,total_columns READ*,AA(i,j) END DO COLUMN_LOOP END DO ROW_LOOP PRINT*, 'ENTER THE b MATRIX OF Ax = b' ROW_LOOP:DO i=1,total_rows READ*,b(i) END DO ROW_LOOP
**x= CroutDecomp(AA,total_rows,total_columns,no_of_equations) **
!!!I dont get the array calculated above retruned here.Pls can anyone help?
END PROGRAM LINEAR_EQUATIONS_SOLVER