Print

Print


Hi,

You don't say what kind of system you're on, but what you're
seeing is typical if your stack limit is set too low.  If
you're on a UNIX box, try using the "limit" or "ulimit" 
command to raise the stacksize to the maximum allowable
value.

	-P.

On Tue, 4 Jan 2000, Yunkai Zhou wrote:

> 
> Hi Everybody,
> 
> First of all, Happy New Year!
> 
> I ran into "Segmentation fault" for big "n" when trying to overload
> operators, the results I got are all correct for "n" not too big.
> After several tests I found my problem can be simplified as the the 
> following simple test program:
> 
> for example, if n < 700, the program works fine,
>              but if n >= 800,  I got "Segmentation fault"
> 
> the other problem is: 
>     if I comment out the line:   print *, 'max_diff=', maxval(A-S)
>     then the program works for bigger n, for example, n=1000 is fine,
>     but for even larger n,  say n > 1500, there is still
>     "Segmentation fault"
> 
> my other observation is:
>     if I change A, Q, S into allocatable arrays, with dimension
>     (n, n), n from user input, then there seems not any problem
>     (to save your trouble of typing, I also attached the code using 
>      allocatable array at the end)
> 
> I am a beginner of Fortran90, so I don't know what essentially
> goes wrong with the following program, your assistance will be
> highly appreciated.
> 
> --
> Yunkai Zhou
> Computational & Applied Math Dept
> Rice University
> 
> 
> 
> !=================================================================
> 
>  Program  TEST
>    
>    Implicit None
> 
>    Call  auto_array_test
> 
>  Contains
>   
>   Subroutine auto_array_test()
> 
>     Integer, Parameter :: n =1000    
>                        !! please change n here and recompile 
> 
>     Double Precision, Dimension(n,n) :: A, Q, S
>     Integer :: i
> 
>     print *, 'n =', n
>     
>     do i =1,n
>        call  random_number(A(i,:))
>     end do
> 
>     S = A;  Q =A
>     A = dtest(Q,S)
>     S = S + Q 
>     print *, 'max_diff=', maxval(A-S)
> 
> !   S = S + Q - A
> !   print *, 'max_diff=', maxval(S)
> 
>   End Subroutine auto_array_test
> 
> 
>   Function  dtest(A,B)
> 
>      Double Precision, Intent(IN)    ::  A(:,:) 
>      Double Precision, Intent(IN)    ::  B(:,:)
>      Double Precision  ::  dtest(size(A,1),size(B,2))
>  
>      dtest = A + B
>  
>   End Function dtest
> 
> 
>  End Program TEST
> 
> 
> 
> !=================================================================
> 
>  Program  TEST2
>    
>    Implicit None
>    Call  auto_array_test
> 
>  Contains
>   
>   Subroutine auto_array_test()
> 
>     Double Precision, Dimension(:,:), Allocatable :: A, Q, S
>     Integer :: n, i
> 
>     print *, 'input n = '
>     read *,  n
> 
>     Allocate(A(n,n), Q(n,n), S(n,n))
>     
>     do i =1,n
>        call  random_number(A(i,:))
>     end do
> 
>     S = A;  Q =A
>     A = dtest(Q,S)
>     S = S + Q 
>     print *, 'max_diff=', maxval(A-S)
> 
>     Deallocate(A,Q,S)
> 
>   End Subroutine auto_array_test
> 
>   Function  dtest(A,B)
> 
>      Double Precision, Intent(IN)    ::  A(:,:) 
>      Double Precision, Intent(IN)    ::  B(:,:)
>      Double Precision  ::  dtest(size(A,1),size(B,2))
>  
>      dtest = A + B
>  
>   End Function dtest
> 
>  End Program TEST2
> 

--
** Whether the playing field is level depends on the coordinate system. ***
********* Peter S. Shenkin; Schrodinger, Inc.; (201)433-2014 x111 *********
*********** [log in to unmask]; http://www.schrodinger.com ***********



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%