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