home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / fortran / 4701 < prev    next >
Encoding:
Text File  |  1992-12-14  |  3.0 KB  |  64 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!stanford.edu!unixhub!slacvx.slac.stanford.edu!fairfield
  3. From: fairfield@slacvx.slac.stanford.edu
  4. Subject: Re: Need help with named common blocks
  5. Message-ID: <1992Dec13.211623.1@slacvx.slac.stanford.edu>
  6. Lines: 51
  7. Sender: news@unixhub.SLAC.Stanford.EDU
  8. Organization: Stanford Linear Accelerator Center
  9. References: <jumper.724304615@fritz.catt.ncsu.edu>
  10. Distribution: comp
  11. Date: Mon, 14 Dec 1992 05:16:23 GMT
  12.  
  13. In article <jumper.724304615@fritz.catt.ncsu.edu>, jumper@fritz.catt.ncsu.edu (Michael Lanham) writes:
  14. [...]
  15. > I have several program src files.  In the file with the BLOCK DATA segment,
  16. > the COMMON block is named and shaped as follows:
  17. >       IMPLICIT INTEGER (A-Z)
  18. >       COMMON/SHARE1/TABLE(1770),NOPU(54),FLHS(54),UNUSE0(122),
  19. >      -           XLATE(127),KWT1(50),KWT2(50),STACK1(50),STACK2(50),
  20. >      -           SYMBOL(8),VALUE(8),UNUSE5(16),CHAR(80),VALUXY(12),
  21. >      -           LISTX(61),INTERX(70),SYNTAB(2,26),CHARX(26),TAG(50),
  22. >      -           (50)
  23. > In most of the other modules the common block share1 is entered the same way.
  24. > Now I found an additional SHARE1 that is different.
  25. >       COMMON/SHARE1/NSVT(1000),OSVT(1000),
  26. >      -             OPND(3),LINE(133),UNUSE3(574),
  27. >      -             OUTTAB(50,4),SUPP(100,2),SYMBL(2),UNUSE2(18)
  28. > Is an accurate way of thinking of SHARE1 is the first declaration plus the
  29. > second concatenated to the end of the second?  I need to know this so I can
  30.          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  31. > correctly build my union in C to accurately reflect the SHARE1 structure.
  32.  
  33.     No.  In FORTRAN, the named common is a single storage area.  A mis-feature
  34. of FORTRAN is that common blocks may be declared differently in different
  35. program sections, but each still refers to the same storage area.  Thus, in
  36. the example above, NSVT(1) is the same storage location as TABLE(1), etc.
  37.  
  38.     Note that the first declaration makes COMMON/SHARE1/ 3130 4-byte integers
  39. long (barring other declaration following, and inacurracies in my arithmetic),
  40. while the second declaration is only 2710 long.  Well, that's probably 
  41. unlikely since something like CHAR(80) is most likely declared later to be
  42. of type CHARACTER*1 (or BYTE or INTEGER*1 or LOGICAL*1)...  The point is
  43. that most compilers allow the total length of a common to be different in
  44. different program sections.  Some will (nicely) take the longest declared
  45. length as the total, others (not so nice) will take the _last_ declared
  46. length.
  47.  
  48.     In any case, you may want to investigate how /SHARE1/ is being used in
  49. the odd-man-out routine to be sure it's not an out-and-out error...
  50.  
  51.         Cheers, Ken
  52. -- 
  53.  Dr. Kenneth H. Fairfield    |  Internet: Fairfield@Slac.Stanford.Edu
  54.  SLAC, P.O.Box 4349, MS 98   |  DECnet:   45537::FAIRFIELD (45537=SLACVX)
  55.  Stanford, CA   94309        |  BITNET    Fairfield@Slacvx
  56.  ----------------------------------------------------------------------------
  57.  These opinions are mine, not SLAC's, Stanford's, nor the DOE's...
  58.