home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / fortran / 4818 < prev    next >
Encoding:
Text File  |  1992-12-21  |  1.6 KB  |  43 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!pmafire!news.dell.com!natinst.com!cs.utexas.edu!sdd.hp.com!spool.mu.edu!darwin.sura.net!mlb.semi.harris.com!travis.csd.harris.com!grouper!!brent
  3. From: brent@ssd.csd.harris.com (Brent Benson)
  4. Subject: Re: Dynamic Memory Allocation in FORTRAN, Question
  5. Organization: Harris Computer Systems
  6. Date: Mon, 21 Dec 1992 15:54:22 GMT
  7. Message-ID: <BRENT.92Dec21105422@amber.ssd.csd.harris.com>
  8. In-Reply-To: xiong@spade.rutgers.edu's message of 20 Dec 92 07:22:20 GMT
  9. References: <Dec.20.02.22.20.1992.7312@spade.rutgers.edu>
  10. Sender: news@grouper.mkt.csd.harris.com (Network News)
  11. Lines: 30
  12.  
  13. xiong@spade.rutgers.edu (Xiong) writes:
  14.  
  15. > Hi, I am wondering if it is possible to allocate memory dynomically
  16. > in FORTRAN as in C?
  17.  
  18. Not in standard FORTRAN.  There are sometimes vendor extensions to do
  19. this sort of thing.  For example, we have recently implemented (after
  20. a customer request) something called pointer blocks in our f77
  21. compiler.  These are similar to common blocks, but are dynamic rather
  22. than static in nature.  The name of the pointer block needs to be an
  23. integer*4 variable which will hold the address of the allocated memory
  24. for the block.  We also provide a malloc() function for allocated the
  25. space and a sizeofblock() function for automatically determining the
  26. size of a given pointer block.
  27.  
  28. > I am loooking for something equivalent to: 
  29. > int * a; a = (int *) malloc (numx * sizeof (int)); 
  30. > in C.
  31.  
  32.     integer*4 ptr1, numx
  33.     pointer /ptr1/ numx
  34.  
  35.     external malloc
  36.     integer*4 malloc
  37.  
  38.     ptr = malloc(sizeofblock(ptr1))
  39.     
  40. --
  41. Brent Benson                     
  42. Harris Computer Systems
  43.