home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!sgigate!sgi!twilight!dinkum!calvin
- From: calvin@dinkum.mti.sgi.com (Calvin H. Vu)
- Newsgroups: comp.sys.sgi
- Subject: Re: Fortran Structure and Data Usage
- Message-ID: <ukqk9ns@twilight.wpd.sgi.com>
- Date: 8 Jan 93 23:30:27 GMT
- References: <7853@dove.nist.gov>
- Sender: news@twilight.wpd.sgi.com ( CNews Account at twilight.wpd.sgi.com )
- Organization: Silicon Graphics, Inc. Mountain View, CA
- Lines: 54
-
- In <7853@dove.nist.gov> fred@poly2.nist.gov (Frederick R. Phelan Jr.) writes:
-
- >Heres a small code prototype of my problem:
-
- > program test_35
-
- > structure /geom/
- > integer ngprops
- > end structure
- > record /geom/ g1,g2
-
- >c uncomment these for compiler havoc
- >c data g1.ngprops /3/
- >c data g2.ngprops /5/
-
- In the documentation for RECORD declaration in the
- Fortran Language Reference manual, it says:
- "record-name can be used in COMMON and DIMENSION statements, but not in
- DATA, EQUIVALENCE, NAMELIST, or SAVE statements. Record created by
- the RECORD statements are initialially undefined unless the values are
- defined in the related structure declaration"
-
- So, implementation-wise, you don't seem to have any way to intialize
- different records with the same structure to different initial values
- using DATA statements. I don't know why the restriction is there as
- it seems rather unreasonable, but that's the way it is.
-
- >c these are ok when uncommented
- >c g1.ngprops=3
- >c g2.ngprops=5
-
- > write(*,1000) g1.ngprops
- > 1000 format('g1=',i2)
- > write(*,1001) g2.ngprops
- > 1001 format('g2=',i2)
-
- > stop
- > end
-
- >Ok, so I have a structure, and I want to initialize
- >g1.ngprops and g2.ngprops to differnent values.
-
- >Compiling with the data statements uncommented gives:
-
- > f77 test_35.f -o test_35.exe
- >Error on line 6 of test_35.f: syntax error
- >Error on line 6 of test_35.f: syntax error
- >*** Error code 1
-
- >How can you use structure variables in data statements?
-
- >Fred
-
- - calvin
-