Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site ecsvax.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!mcnc!ecsvax!dgary
From: dgary@ecsvax.UUCP (D Gary Grady)
Newsgroups: net.lang.c,net.lang.f77
Subject: Re: Converting FORTRAN to C
Message-ID: <396@ecsvax.UUCP>
Date: Wed, 19-Dec-84 10:13:26 EST
Article-I.D.: ecsvax.396
Posted: Wed Dec 19 10:13:26 1984
Date-Received: Sun, 23-Dec-84 00:22:17 EST
References: <390@ecsvax.UUCP>
Organization: Duke U Comp Ctr
Lines: 34
Xref: watmath net.lang.c:3556 net.lang.f77:189

<>
There is a real problem in converting FORTRAN to C, because there is one
FORTRAN feature that is widely used and not duplicated in C:  the
ability to pass varying-sized arrays as parameters.  That is, the
following is not legal C, but the equivalent is legal FORTRAN:

C:				FORTRAN:

subr(array, size)		SUBROUTINE SUBR(ARRAY,ISIZE)
int size;			INTEGER ISIZE
float array[size][];		REAL ARRAY(1,ISIZE)
{ ...				...
}				RETURN
				END

(I don't believe C formally specifies the order of array elements, but
in practice the row-major form is used, I think.  FORTRAN, of course,
stores column-major.)

It is possible to pass variant-sized arrays in C by passing an array of
pointers to arrays, or by simulating a 2-dimensional array by means of a
one-dimensional one (handling the subscript computation with a #define
or a subroutine would be easiest here).  But I would like to see this
simple feature added to C; I doubt it would break any existing programs.

D Gary Grady, Duke University Computation Center (dgary@ecsvax)
{...!(ihnp4,decvax,etc)!mcnc!ecsvax!dgary}

-- 

D Gary Grady
Duke University Computation Center, Durham, NC  27706
(919) 684-4146
USENET:  {decvax,ihnp4,akgua,etc.}!mcnc!ecsvax!dgary