From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1094ba,1ef3b84ca62fad7b X-Google-Attributes: gid1094ba,public X-Google-Thread: fee84,1ef3b84ca62fad7b X-Google-Attributes: gidfee84,public From: Steve Lionel Subject: Re: fortran error? Date: 1998/03/16 Message-ID: <6ejfii$kbd@usenet.pa.dec.com>#1/1 X-Deja-AN: 334563625 References: <3507A4A5.F8A7DDC2@matd.tu-graz.ac.at> Reply-To: Steve Lionel Distribution: world Organization: Digital Equipment Corporation, Nashua NH Newsgroups: comp.lang.fortran,comp.unix.osf.osf1 In article <3507A4A5.F8A7DDC2@matd.tu-graz.ac.at>, Armin Leuprecht writes: |>Dynamic allocation using DEC Fortran is working in general. |>For some strange reason sometimes a programm like the following |>will crash with a segmentation fault while allocating the memory |>in line 3 of the subroutine. |>Though I couldn't reproduce the error with this little program |>(not even for large values, i.e. more than physical installed |>memory) I cannot locate another source of failure in my application. |> |> SUBROUTINE sub(n) |> INTEGER n |> REAL*4 a(n) |> END |> |> PROGRAM test |> INTEGER n |> n = 1234 |> CALL sub(n) |> END This is not really "dynamic allocation" - a term usually reserved for variables allocated with ALLOCATE (or malloc). What you have instead are "automatic arrays", which get allocated on the stack on routine entry. This requires sufficient stack space. Unfortunately, the default stacksize limit on DIGITAL UNIX (OSF/1) tends to be on the small side and it is easy to exceed it with modest programs. Usually, the shell command: limit stacksize unlimited (or "ulimit", depending on what your shell is), will take care of this. This does not actually set the size to be "unlimited", but rather raises it to the system configuration maximum. While I'm here, I'll mention that you can see the same problem using DIGITAL Visual Fortran, since the MS linker allocates the stack at a fixed size. You can set the stack size in a linker option. It tends NOT to be a problem on OpenVMS which has done automatic stack expansion since 1980. -- Steve Lionel mailto:Steve.Lionel@digital.com Fortran Development http://www.digital.com/info/slionel.html Digital Equipment Corporation 110 Spit Brook Road, ZKO2-3/N30 Nashua, NH 03062-2698 "Free advice is worth every cent" For information on DIGITAL Fortran, see http://www.digital.com/fortran