Help: declaring 2D array in f90 subroutine or function...


xplorer0nr
11-14-2005, 05:41 PM
Hello all... Hope someone knows a fix these two questions. Thanks in advance...

Q1. I am having trouble creating the matrix y(n,n) below.
I got a stack overflow error whenever the prgram hits the line declaring the matrix y. the matrix a and its size are known to the subroutine and i checked this. I am using Compac Visual Fortran V 6.5. Question is: how can i fix this? I would appreciate any suggestions to this.

Subroutine ludcmp(a,indx,d)
double precision,DIMENSION(:,:),INTENT(INOUT)::a
double precision,DIMENSION(size(a),size(a))::y

Q2. The following line fails to run for me. This is the line that fails under the same Subroutine ludcmp. Again with stack overflow error. the function outerprod() is well defined but has a line similar to the one in Q1 above. I am not sure if its the parallel change in the indices or something else...
Any ideas how to fix this?

do j=1,n
a(j+1:n,j+1:n)=a(j+1:n,j+1:n)-outerprod(a(j+1:n,j),a(j,j+1:n))
enddo


Thank you very much...
/Mongi

dmolin
11-15-2005, 03:56 AM
I think I have got the same problem and it is specific to the compiler. Check your compiler settings, especially concerning the optimisation. I have experienced that if there is no optimization, some problems appears with arrays. Choosing full optimization have solved my problem. And yours ?

xplorer0nr
11-15-2005, 08:21 AM
Thaks for ur reply. I tried to change settings under Fortran tab to full optimization and checked some of the options under that, but i got the follwing error:


Compiling Fortran...
...

f90: Fatal: There has been an internal compiler error (C0000005).
...

Error executing df.exe.


I am using Compac vis Fortran 6.6. Thanks for ur help with this.
/Mongi

dmolin
11-15-2005, 10:51 AM
Sorry : I use the 6.0A under win2000 pro
Have you tried other settings expect "no optimization" ?

xplorer0nr
11-15-2005, 11:44 AM
I was able to resolve the original problem (see Q1) using
allocate(outerprod(size(a),size(b))) where outerprod was declared as a dummy pointer (:,:) in the called function.

So this is one way to do it at least.

Problem I have now is the slowness in the explicit do-loops. I was hoping to make this faster in f90. My PC is a single processor so I dont know if parallel is an option. What I am hoping to do is add or multiply matrices and vectors without the explicit do-loops. e.g.: a=b+c where a(:,:), b(:,:), c(:,:) are of the same size matrix. The intrinsic function in f90 a=mult(b,c) which is used to do matrix multiply did not work for me.

Any suggestions?

Thanks...
/Mongi

xplorer0nr
11-17-2005, 09:41 AM
I apologize but i need to make a correction to my previous post: (sorry if this is elementary to some of u)

using the intrinsic function matmul() with matrices:

1. in matmul(a,b), a and b must be conforming in shape.
2. only one of a and b can be 2-dimensional when calling matmul, the other must must be a row or column. which means u have to use a do-loop on one of the indices... If a and b are both vectors then its no problem.

Following these rules, i can now use the function successfully.

Thanks.
/Mongi