Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ames!mailrus!tut.cis.ohio-state.edu!rutgers!columbia!cubsun!shenkin From: shenkin@cubsun.BIO.COLUMBIA.EDU (Peter Shenkin) Newsgroups: comp.lang.fortran Subject: Re: Fortran versus C for numerical analysis Message-ID: <83@cubsun.BIO.COLUMBIA.EDU> Date: 16 Sep 88 02:40:07 GMT References: <13567@mimsy.UUCP> <3630@lanl.gov> Reply-To: shenkin@cubsun.UUCP (Peter Shenkin) Organization: Dept. of Biology, Columbia Univ., New York, NY Lines: 50 In article <3630@lanl.gov> jlg@lanl.gov (Jim Giles) writes: > ... I can't declare an array in C without getting >one or more pointers declared into the bargain. Sorry, but int a[10]; declares space for 10 ints and no pointers. If you want a pointer, too, you have to say, in addition, int *pa = &*a[0]; or some such. Of course, if you call a function with x = func( a ); what is passed to the function is the address of a[0], as in FORTRAN, but no extra storage has been declared. > ...(The Cray Fortran compiler has >had pointers for years. Everything you can do with C pointers you can >do with Fortran pointers. Arrays can be dynamically allocated.... A nice feature. And the common availability of this feature in many Fortrans is testimony to its usefulness. The fact that Fortran 8x, if it ever makes it, has a good chance of including it is further testimony. But standard (f77) Fortran doesn't have it, and most of us don't work on Crays, and many of us work on multiple machines. > ... In C, >the declaration of a dynamically allocated (multi-D) array is completely >different from the declaration for a statically allocated one... An unfortunate aspect of C. But at least we can do the allocation and use the array within the original definition of the C, assuming only the run-time library functions that are supplied with virtually all implementations of C that the numerical analyst, in any case, is likely to see. This is not true of Fortran. The proposed 8x standard indicates that those who find the feature useful wish to have it standardized; the mere fact that it is available one way or another in most good implementations is not enough for such users, despite the fact that, as Giles points out, some programmers use various preprocessors. At least C does provide a standard and source-code portable way of doing this, although I admit that C makes you stand on your head to create and use true (contiguous) dynamic multidimensional arrays whose shape (size and/or dimensionality) is not known until run-time. I agree with Giles that this is unfortunate. But I fail to see why he doesn't agree that the virtually universal availability of dynamic allocation in C, using the same syntactical convention, doesn't count in favor of C (over Fortran) in his eyes. -- ******************************************************************************* Peter S. Shenkin, Department of Chemistry, Barnard College, Columbia University New York, NY 10027 Tel: (212) 280-5517 (work); (212) 829-5363 (home) shenkin@cubsun.bio.columbia.edu shenkin%cubsun.bio.columbia.edu@cuvmb.BITNET