Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!csri.toronto.edu!laredo From: laredo@csri.toronto.edu (Jim Alain Laredo) Newsgroups: comp.lang.fortran Subject: Fortran to C translator question. Message-ID: <1989Aug1.105428.18152@jarvis.csri.toronto.edu> Date: 1 Aug 89 14:54:29 GMT Organization: University of Toronto, CSRI Lines: 41 To those of you that have used any of the Fortran to C translators, please, tell me what the expected results for this small routine are 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 According to the FOR_C brochure (from COBALT BLUE) the coordinates of the matrices are inverted to solve the problem of the memory distribution, Fortran places the matrices column-wise as oppossed to C that does it row-wise. Therefore a reference in Fortran to A(i,j) should be translated into C as A[M*j+i]. Also, I would like to know if the translator modifies the loops, note that in the first loop , DO 20 I=1,M, both values have to be be decremented, while in the second, DO 10 J=I+1,M, only the absolute value M, should be decremented to fit into the C matrix definitions. 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; } thanks for your help, Jim Laredo laredo@csri.toronto.edu