Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!orstcs!statware!scf From: scf@statware.UUCP (Steve Fullerton) Newsgroups: comp.lang.fortran Subject: Re: Fortran to C translator question. Keywords: Cobalt Blue Message-ID: <3799@statware.UUCP> Date: 3 Aug 89 20:19:41 GMT References: <2992@tekcae.CAX.TEK.COM> Reply-To: scf@statware.UUCP (Steve Fullerton) Organization: Statware, Corvallis, Oregon Lines: 72 In article <2992@tekcae.CAX.TEK.COM> ralphc@tekcae.CAX.TEK.COM (Ralph Carpenter) writes: > >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 > Here are several FOR_C translations I did on the code using version v2.2 under SCO XENIX. For the first translation, I specified options to disable the creation of temporaries for the DO test parameter and requested optimization of common subexpressions. /*Translated by FOR_C, v2.2, on 08/03/89 at 13:14:57 */ /*FOR_C Options SET: no=d op=a */ #include #include #include void /*FUNCTION*/ x(a, m) double *a; int *m; { #define A(I_,J_) (a+(I_)*(*m)+(J_)) int i, i_, j, j_; for( i = 1; i <= *m; i++ ){ i_ = i - 1; for( j = i + 1; j <= *m; j++ ){ j_ = j - 1; *A(j_,i_) += 1; } } #undef A } /* end of function */ This next translation used an addition option to prevent the creation of a reduced DO index variable. /*Translated by FOR_C, v2.2, on 08/03/89 at 13:14:16 */ /*FOR_C Options SET: no=dr op=a */ #include #include #include void /*FUNCTION*/ x(a, m) double *a; int *m; { #define A(I_,J_) (a+(I_)*(*m)+(J_)) int i, j; for( i = 1; i <= *m; i++ ){ for( j = i + 1; j <= *m; j++ ){ *A(j - 1,i - 1) += 1; } } #undef A } /* end of function */ -- Steve Fullerton Statware, Inc. scf%statware.uucp@cs.orst.edu 260 SW Madison Ave, Suite 109 orstcs!statware!scf Corvallis, OR 97333 503/753-5382