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

  1. Path: sparky!uunet!dove!poly2.nist.gov!fred
  2. From: fred@poly2.nist.gov (Frederick R. Phelan Jr.)
  3. Newsgroups: comp.lang.fortran
  4. Subject: Structure and Data Statement Usage
  5. Message-ID: <7876@dove.nist.gov>
  6. Date: 8 Jan 93 18:04:15 GMT
  7. Sender: news@dove.nist.gov
  8. Lines: 72
  9.  
  10. Heres a small code prototype of my problem:
  11.  
  12.       program test_35
  13.  
  14.       structure /geom/
  15.         integer ngprops
  16.       end structure
  17.       record /geom/ g1,g2
  18.  
  19. c     uncomment these for compiler havoc
  20. c      data g1.ngprops /3/
  21. c      data g2.ngprops /5/
  22.  
  23. c     these are ok when uncommented
  24. c     g1.ngprops=3
  25. c     g2.ngprops=5
  26.  
  27.       write(*,1000) g1.ngprops
  28.  1000 format('g1=',i2)
  29.       write(*,1001) g2.ngprops
  30.  1001 format('g2=',i2)
  31.  
  32.       stop
  33.       end
  34.  
  35. Ok, so I have a structure, and I want to initialize
  36. g1.ngprops and g2.ngprops to differnent values.
  37.  
  38. Compiling with the data statements uncommented gives:
  39.  
  40.         f77 test_35.f -o test_35.exe
  41. Error on line 6 of test_35.f: syntax error
  42. Error on line 6 of test_35.f: syntax error
  43. *** Error code 1
  44.  
  45. Stop.
  46.  
  47.  
  48. Note: The record statement is line 6.  
  49.  
  50. The program works ok with the lines 
  51.  
  52.      g1.ngprops=3
  53.      g2.ngprops=5
  54.  
  55. uncommented.
  56.  
  57. I know you can say:
  58.  
  59.       structure /geom/
  60.         integer ngprops /5/
  61.       end structure
  62.  
  63. but then g1.ngprops and g2.ngprops are initialized to the same 
  64. value.
  65.  
  66. How can you use structure variables in data statements?
  67.  
  68. Fred
  69. ---
  70. Fred Phelan
  71. fred@poly2.nist.gov
  72.  
  73.  
  74. PS: This is on a Silicon Graphics machine.
  75.  
  76. PPS: Anyone care to comment on how common f77 extensions
  77.      like structures have become on other platforms? I'll
  78.      summarize if there is sufficient replies and/or
  79.      interest.
  80.  
  81.  
  82.