Should I convert FORTRAN code to C?

Bob Rose rrr at naucse.UUCP
Mon Jun 20 09:35:57 AEST 1988


In article <20340 at beta.lanl.gov>, jlg at beta.lanl.gov (Jim Giles) writes:
> In article <224 at raunvis.UUCP>, kjartan at raunvis.UUCP (Kjartan Pierre Emilsson Jardedlisfraedi) writes:
> >   Now here there seems to be a little misunderstanding.  I have never
> > understood why Fortran users keep saying that array indexing is awkward
> > in C.
> > [...]
> 
> Awkward isn't the problem.  I don't like the double bracket notation,
> but anyone can write a macro to turn ARRAY(i,j,k) into array[i][j][k].
> The Problem is that 2-d arrays are not optimizable because they are
> immediately turned into pointer-to-pointer-to-data type of constructs.

Ok, what gives. Some else post the following code (not exact but close enough)

	real a(5,2)
	...
	call foo(a)
	...
	end

	subroutine foo(a)
	real a(10)
	...

Now doesn't the following c code work to do the same

	double a[2][5]        /* <-- note [2][5] not [5][2] */
	...
	foo(a)
	...
	}

	void foo(a)
	double a[10]
	{

If it is not the same, would someone please post or email a counter
example. I would like to see what is wrong.

Note there are problems if you dynamicly allocate arrays but you cannot
dynamicly allocate arrays in fortran so this is a void arguement.

                               -bob



More information about the Comp.lang.c mailing list