Note that there are some explanatory texts on larger screens.

plurals
  1. POFortran subroutine fails on return
    primarykey
    data
    text
    <p>I have a Fortran numerical code that calls a subroutine from an external module. This code has been running fine for me until I tried to compile and run on a different machine. On the new machine, my program crashes fairly quickly.</p> <p>Using debug print statements, I have isolated that the crash occurs on return from the external subroutine. The main program calls the subroutine several times, and the crash occurs on return from the second call to the subroutine (the first call works fine). It always crashes on the second subroutine call with this set of input data, but with another set of input data (roughly 1/3 the size of the first), it crashes on return from the fifth subroutine call.</p> <p>The symptoms suggest to me that something is getting stored in memory each time and accumulates over each subroutine call until it runs out of space, but I'm not sure what that is or how that would occur. The code is hard to simplify to a minimal working example, but I have posted the relevant portion below. Let me know if there is something else that would be helpful to see. It is basically fixed form Fortran 90.</p> <pre><code> use fd implicit none integer, parameter :: ms = 2000 integer n real(dp), dimension(ms) :: s real(dp), dimension(ms) :: e real(dp), dimension(ms) :: f real(dp), dimension(ms) :: d1f real(dp), dimension(ms) :: d2f real(dp), dimension(ms) :: c, d real(dp), dimension(ms) :: a real(dp), dimension(ms) :: b real(dp), dimension(ms) :: temp integer w integer k real(dp) th do i = 1,n temp(i) = a(i) end do call lprsmf(s(1:n),temp(1:n),n,w,k,th,a(1:n),d1f(1:n), * d2f(1:n)) do i = 1,n temp(i) = b(i) end do call lprsmf(s(1:n),temp(1:n),n,w,k,th,b(1:n),d1f(1:n), * d2f(1:n)) do i = 1,n temp(i) = c(i) end do call lprsmf(s(1:n),temp(1:n),n,w,k,th,c(1:n),d1f(1:n), * d2f(1:n)) do i = 1,n temp(i) = d(i) end do call lprsmf(s(1:n),temp(1:n),n,w,k,th,d(1:n),d1f(1:n), * d2f(1:n)) do i = 1,n temp(i) = e(i) end do call lprsmf(s(1:n),temp(1:n),n,w,k,th,e(1:n),d1f(1:n), * d2f(1:n)) do i = 1,n temp(i) = f(i) end do call lprsmf(s(1:n),temp(1:n),n,w,k,th,f(1:n),d1f(1:n), * d2f(1:n)) </code></pre> <p>module <code>fd</code>:</p> <pre><code> module fd ! Double precision real kind integer, parameter :: dp = selected_real_kind(15) contains subroutine lprsmf(x,y,n,w,k,th,s,d1,d2) ! INPUTS: ! x, y, n, w, k, th ! OUTPUTS: ! s, d1, d2 implicit none real(dp), dimension(n) :: x,y,s,d1,d2 integer n,w,k real(dp) th ! ... code here ... end subroutine lprsmf end module fd </code></pre> <p>My compiler is gfortran 4.6.1. Besides getting the code to stop crashing, I really would like to understand what is fundamentally going on with the argument passing (as I assume the problem lies with the array slices being passed out of the program). Note that <code>a,b,c,d,e,f,s,temp,d1f,d2f</code> have length 2000, while <code>n</code>, which represents the range of valid data, is in the range 100-500, depending on the input data length.</p> <p><strong>EDIT:</strong> The error message is Windows putting up a dialog informing me that the program has stopped working.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload