Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!sun-barr!cs.utexas.edu!uunet!zephyr.ens.tek.com!tekcae!ralphc From: ralphc@tekcae.CAX.TEK.COM (Ralph Carpenter) Newsgroups: comp.lang.fortran Subject: Re: Fortran to C translator question. Keywords: Cobalt Blue Message-ID: <2992@tekcae.CAX.TEK.COM> Date: 2 Aug 89 02:01:07 GMT Organization: Tektronix Inc., Beaverton, Or. Lines: 59 In response to Jim Laredo's <1989Aug1.105428.18152@jarvis.csri.toronto.edu> question about FOR_C's translation of a sample subroutine: subroutine x(a,m) integer m double precision a(m,*) integer i,j do 20 i=1,m do 10 j=i+1,m a(i,j)=a(i,j)+1 10 continue 20 continue end According to Jim: > If the translator is good, I would expect the following code or >at least something similar. > > void X(A,M) > int M; > double A[]; > { > int i,j; > for(i=0;i<=M-1,i++) > for(j=i+1;j<=M-1;j++) > A[j*M+i] = A[j*M+i]=1; > } I have a FOR_C DEMO v2.0 demo disk, (files dated 10/15/88, probably a little out of date by now,) which output the following c code: /*Translated by FOR_C, v2.0, on 08/01/89 at 18:24:20 */ /*FOR_C Options SET: none */ #include #include #include void /*FUNCTION*/ x(a, m) double *a; int *m; { #define A(I_,J_) (a+(I_)*(*m)+(J_)) int _do0, _do1, i, j; for( i = 0, _do0 = *m - 1; i <= _do0; i++ ){ for( j = (i+1) + 0, _do1 = *m - 1; j <= _do1; j++ ){ *A(j,i) = *A(j,i) + 1; } } #undef A } /* end of function */ Ralph Carpenter Tektronix, Inc.