home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / fortran / 2856 < prev    next >
Encoding:
Text File  |  1992-07-28  |  2.4 KB  |  64 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!decwrl!deccrl!news.crl.dec.com!pa.dec.com!e2big.mko.dec.com!quark.enet.dec.com!lionel
  3. From: lionel@quark.enet.dec.com (Steve Lionel)
  4. Subject: Re: adjustable arrays
  5. Message-ID: <1992Jul28.175947.4626@e2big.mko.dec.com>
  6. Lines: 51
  7. Sender: guest@e2big.mko.dec.com (Guest (DECnet))
  8. Reply-To: lionel@quark.enet.dec.com (Steve Lionel)
  9. Organization: Digital Equipment Corporation, Nashua NH
  10. References:  <simon.712286479@giaeb>
  11. Date: Tue, 28 Jul 92 17:59:47 GMT
  12.  
  13.  
  14. In article <simon.712286479@giaeb>, simon@giaec.cc.monash.edu.au 
  15. (simon shields) writes:
  16. |>I'm using a 
  17. |>HP-UX giaec A.08.07 A 9000/720 2001133857
  18. |>machine. I have programs that I wrote that make use of adjustable
  19. |>dimensions. They worked fine on our previous HP800 type machine, but
  20. |>come up with a declaration error on the 720's. Do I need a special
  21. |>switch to enable me to use adjustable dimensions with the f77 command
  22. |>?
  23. |>
  24. |>Thanks
  25. |>
  26. |>This is the subroutine that makes use of the adjustable dimension
  27. |>facility.
  28. |>
  29. |>      SUBROUTINE graph (coords, curves, fname)
  30. |>      EXTERNAL fill the array
  31. |>      INTEGER coords, curves
  32. |>      LOGICAL fill the array
  33. |>      CHARACTER fname*(*)
  34. |>      REAL xdra (coords,curves), ydra (coords, curves),tr(curves)
  35. |>ERROR  __________^^^^^^^^^^
  36. |>      IF (fill the array (xdra, ydra,tr, coords, curves, fname)) THEN
  37. |>          CALL graph the array (xdra, ydra,tr, coords, curves, fname)
  38. |>          CALL do plt
  39. |>      ELSE
  40. |>          PRINT *,"Couldn't fill the array so graph was NOT done !!"
  41. |>          PRINT *,"Sorry about that !!"
  42. |>      ENDIF
  43. |>      RETURN
  44. |>      END
  45.  
  46. The Fortran language requires arrays with adjustable bounds to be formal
  47. arguments themselves.  That is, XDRA must be a formal argument to the
  48. subroutine.  (In addition, the bounds expressions must not contain elements
  49. other than constants or variables which are themselves formals or in
  50. COMMON.)
  51.  
  52. What you have tried to do (and also in your subsequent posting) is dynamic
  53. allocation, which is not supported in most Fortran implementations.  If your
  54. implementation has support for pointers (also non-standard), you can couple
  55. these with a call to the operating system's memory allocation services
  56. (eg. C's malloc) to get what you want.
  57. --
  58.  
  59. Steve Lionel                    lionel@quark.enet.dec.com
  60. Languages Group
  61. Digital Equipment Corporation
  62. 110 Spit Brook Road
  63. Nashua, NH 03062
  64.