home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / fortran / 4982 < prev    next >
Encoding:
Text File  |  1993-01-12  |  2.1 KB  |  46 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: 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
  3. From: lionel@quark.enet.dec.com (Steve Lionel)
  4. Subject: Re: Block Data
  5. Message-ID: <1993Jan12.171228.29679@dbased.nuo.dec.com>
  6. Lines: 33
  7. Sender: news@dbased.nuo.dec.com (USENET News System)
  8. Reply-To: lionel@quark.enet.dec.com (Steve Lionel)
  9. Organization: Digital Equipment Corporation, Nashua NH
  10. References:  <C0pDpw.AxK@fs7.ece.cmu.edu>
  11. Date: Tue, 12 Jan 1993 17:12:28 GMT
  12.  
  13.  
  14. In article <C0pDpw.AxK@fs7.ece.cmu.edu>, winstead@faraday.ece.cmu.edu 
  15. (Charles Holden Winstead) writes:
  16. |>
  17. |>This is probably an easy question, but I didn't find it in either of my
  18. |>FORTRAN 77 texts.  I have a program which has a section labelled BLOCK DATA
  19. |>where it defines a bunch of variables as common and fills them with data.
  20. |>My question is when is this done, before execution?  Is there any official 
  21. |>description of this?  Also this program contains a bunch of subroutines
  22. |>that I'd like to place into separate files and link their object files at
  23. |>compilation, and I was wondering how to handle common blocks and this 
  24. |>block data section.
  25. |>
  26.  
  27. According to the FORTRAN 77 standard (and also Fortran 90), the only place
  28. that a variable in a COMMON block may be data-initialized is in a BLOCK DATA
  29. subprogram.  So if you want your COMMON data to have an initial value when the
  30. program starts, use a BLOCK DATA; a BLOCK DATA subprogram has no executable
  31. part and is "linked" in with the rest of your program.  The initialization
  32. typically happens at compile-time, though all that's required is that it
  33. happen before execution starts.
  34.  
  35. Many implementations allow you to data-initialize COMMONs outside of a
  36. BLOCK DATA.  If you use this extension, make very sure that ONE AND ONLY ONE
  37. program unit initializes a given COMMON block, or else you're sure to see
  38. some rather interesting and unpredictable results.
  39. --
  40.  
  41. Steve Lionel                    lionel@quark.enet.dec.com
  42. SDT Languages Group
  43. Digital Equipment Corporation
  44. 110 Spit Brook Road
  45. Nashua, NH 03062
  46.