Article View: comp.lang.fortran
Article #4616Re: Block Data
From: Steve Lionel
Date: Tue, 12 Jan 1993 17:12
Date: Tue, 12 Jan 1993 17:12
33 lines
2157 bytes
2157 bytes
In article <C0pDpw.AxK@fs7.ece.cmu.edu>, winstead@faraday.ece.cmu.edu (Charles Holden Winstead) writes: |> |>This is probably an easy question, but I didn't find it in either of my |>FORTRAN 77 texts. I have a program which has a section labelled BLOCK DATA |>where it defines a bunch of variables as common and fills them with data. |>My question is when is this done, before execution? Is there any official |>description of this? Also this program contains a bunch of subroutines |>that I'd like to place into separate files and link their object files at |>compilation, and I was wondering how to handle common blocks and this |>block data section. |> According to the FORTRAN 77 standard (and also Fortran 90), the only place that a variable in a COMMON block may be data-initialized is in a BLOCK DATA subprogram. So if you want your COMMON data to have an initial value when the program starts, use a BLOCK DATA; a BLOCK DATA subprogram has no executable part and is "linked" in with the rest of your program. The initialization typically happens at compile-time, though all that's required is that it happen before execution starts. Many implementations allow you to data-initialize COMMONs outside of a BLOCK DATA. If you use this extension, make very sure that ONE AND ONLY ONE program unit initializes a given COMMON block, or else you're sure to see some rather interesting and unpredictable results. -- Steve Lionel lionel@quark.enet.dec.com SDT Languages Group Digital Equipment Corporation 110 Spit Brook Road Nashua, NH 03062
Technical Details
Message-ID:
<1993Jan12.171228.29679@dbased.nuo.dec.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!decuac!pa.dec.com!engage.pko.dec.com!nntpd.lkg.dec.com!dbased.nuo.dec.com!quark.enet.dec.com!lionelReferences:
<C0pDpw.AxK@fs7.ece.cmu.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.fortran Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!decuac!pa.dec.com!engage.pko.dec.com!nntpd.lkg.dec.com!dbased.nuo.dec.com!quark.enet.dec.com!lionel From: lionel@quark.enet.dec.com (Steve Lionel) Subject: Re: Block Data Message-ID: <1993Jan12.171228.29679@dbased.nuo.dec.com> Lines: 33 Sender: news@dbased.nuo.dec.com (USENET News System) Reply-To: lionel@quark.enet.dec.com (Steve Lionel) Organization: Digital Equipment Corporation, Nashua NH References: <C0pDpw.AxK@fs7.ece.cmu.edu> Date: Tue, 12 Jan 1993 17:12:28 GMT