home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / sgi / 18624 < prev    next >
Encoding:
Internet Message Format  |  1993-01-08  |  2.0 KB

  1. Path: sparky!uunet!olivea!sgigate!sgi!twilight!dinkum!calvin
  2. From: calvin@dinkum.mti.sgi.com (Calvin H. Vu)
  3. Newsgroups: comp.sys.sgi
  4. Subject: Re: Fortran Structure and Data Usage
  5. Message-ID: <ukqk9ns@twilight.wpd.sgi.com>
  6. Date: 8 Jan 93 23:30:27 GMT
  7. References: <7853@dove.nist.gov>
  8. Sender: news@twilight.wpd.sgi.com ( CNews Account at twilight.wpd.sgi.com )
  9. Organization: Silicon Graphics, Inc.  Mountain View, CA
  10. Lines: 54
  11.  
  12. In <7853@dove.nist.gov> fred@poly2.nist.gov (Frederick R. Phelan Jr.) writes:
  13.  
  14. >Heres a small code prototype of my problem:
  15.  
  16. >      program test_35
  17.  
  18. >      structure /geom/
  19. >        integer ngprops
  20. >      end structure
  21. >      record /geom/ g1,g2
  22.  
  23. >c     uncomment these for compiler havoc
  24. >c      data g1.ngprops /3/
  25. >c      data g2.ngprops /5/
  26.  
  27.     In the documentation for RECORD declaration in the
  28.     Fortran Language Reference manual, it says:
  29.     "record-name can be used in COMMON and DIMENSION statements, but not in
  30.     DATA, EQUIVALENCE, NAMELIST, or SAVE statements.  Record created by
  31.     the RECORD statements are initialially undefined unless the values are
  32.     defined in the related structure declaration"
  33.  
  34.     So, implementation-wise, you don't seem to have any way to intialize
  35.     different records with the same structure to different initial values
  36.     using DATA statements.  I don't know why the restriction is there as
  37.     it seems rather unreasonable, but that's the way it is.
  38.  
  39. >c     these are ok when uncommented
  40. >c     g1.ngprops=3
  41. >c     g2.ngprops=5
  42.  
  43. >      write(*,1000) g1.ngprops
  44. > 1000 format('g1=',i2)
  45. >      write(*,1001) g2.ngprops
  46. > 1001 format('g2=',i2)
  47.  
  48. >      stop
  49. >      end
  50.  
  51. >Ok, so I have a structure, and I want to initialize
  52. >g1.ngprops and g2.ngprops to differnent values.
  53.  
  54. >Compiling with the data statements uncommented gives:
  55.  
  56. >        f77 test_35.f -o test_35.exe
  57. >Error on line 6 of test_35.f: syntax error
  58. >Error on line 6 of test_35.f: syntax error
  59. >*** Error code 1
  60.  
  61. >How can you use structure variables in data statements?
  62.  
  63. >Fred
  64.  
  65. - calvin
  66.