From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <199712111807.NAA05630@brg0> Date: Thu, 11 Dec 1997 13:07:41 -0500 From: yue-feng sun Subject: problems with compilers bundled with RH Linux? ---------- X-Sun-Data-Type: text X-Sun-Data-Description: text X-Sun-Data-Name: text X-Sun-Charset: us-ascii X-Sun-Content-Lines: 27 Hello there, I have had no luck with both RH Linux/Intel and now RH Linux/ALpha to compile the following attached combination of C++, C, and fortran programs, while there have been no problems using Slackware Linux/Intel and Solaris. My problems are : 1. When it compiles a fortran subroutine of matrix multiplication with parameter and dimension statements, the compilation fails: The error message is : floating exception during constant evaluation; cannot recover. 2. If I don't use that subroutine, I still cannot get through. The error is /usr/lib/libf2c.so: undefined reference to 'MAIN__' You can save the 6 files: Makefile, cppmain.C, cstuff.c, fstuff.f, time_keeper.c, and time_keeper.h, as named under a directory. I usually simply type make and everything is fine but not on RH Linux. If you can successfully test it using RH Linux, please let me know how you did. Thanks. Yue-Feng Sun ---------- X-Sun-Data-Type: Makefile X-Sun-Data-Description: Makefile X-Sun-Data-Name: Makefile X-Sun-Charset: us-ascii X-Sun-Content-Lines: 52 # # Y.F. Sun, sunyf@ldeo.columbia.edu FLAGPLATFORM = FFLAGS = CFLAGS = C++FLAGS = -O INCDIRS = CPP = g++ -DCPP CC = gcc -DCC FC = g77 -DFOR LKL = g77 ##### Local vairable definitions ##### PROG1 = cftest OBJS1 = cppmain.o cstuff.o fstuff.o time_keeper.o PROGRAMS = $(PROG1) FLAGS = $(FLAGPLATFORM) $(FFLAGS) $(CFLAGS) $(C++FLAGS) LIBS = ##### Rules and their local targets ##### .c.o: $(CC) -c $(INCDIRS) $(FLAGPLATFORM) $(CFLAGS) $< .C.o: $(CPP) -c $(INCDIRS) $(FLAGPLATFORM) $(C++FLAGS) $< .f.o: $(FC) -c $(INCDIRS) $(FFLAGS) $< ##### Rules and their goal targets ##### default: make targets targets: $(PROGRAMS) $(PROG1): $(OBJS1) $(LKL) $(FLAGS) -o $@ $(OBJS1) $(LIBS) cleanall: rm -f *.o *.a core $(PROGRAMS) ---------- X-Sun-Data-Type: default X-Sun-Data-Description: default X-Sun-Data-Name: cppmain.C X-Sun-Charset: us-ascii X-Sun-Content-Lines: 32 /* c2f.C, Y.F. Sun*/ #include #include #include #include #include "time_keeper.h" extern "C" cprint(int , float *); extern "C" void f2c_(int *, float *); int main(int argc, char *argv[]) { int dv1d; float *v1df; int i; dv1d = 10; v1df = (float *) malloc(dv1d*sizeof(float)); for(i=0; i< dv1d;i++) v1df[i] = i; start_time(); f2c_(&dv1d,v1df); cprint(dv1d,v1df); free ( (char *) v1df); prn_time(); printf("done.\a\a\a\n"); } ---------- X-Sun-Data-Type: c-file X-Sun-Data-Description: c-file X-Sun-Data-Name: cstuff.c X-Sun-Charset: us-ascii X-Sun-Content-Lines: 23 /* cstuff.c, Y.F. Sun */ #include #include #include #include void cprint(int lx, float *x) { int i; for(i=0; i< lx;i++) printf("%d %f\n", i, x[i]); printf("\n"); } void fcallc_(int *lx,float *x) { int i; for( i = 0; i < *lx; i++) x[i] += 1000.; } ---------- X-Sun-Data-Type: default X-Sun-Data-Description: default X-Sun-Data-Name: fstuff.f X-Sun-Charset: us-ascii X-Sun-Content-Lines: 52 c Y.F. Sun subroutine f2c(lx,x) real x(*) external fcallc c do i=1,lx x(i) = x(i) + 100. enddo call fcallc(lx,x) call matrixmulc() return end c*************************************************************** c*************************************************************** subroutine matrixmulc() c parameter(lx1 = 1000, lx2 = 500, lx3 = 500) real a(lx1,lx2), b(lx2,lx3), c(lx1,lx3) real at(lx2,lx1) external fcallc c print *, 'C matrix multiplication: C = AB, Cmn, m,n = ',lx1,lx3 do j=1,lx2 do i=1,lx1 a(i,j) = 0.000 if(i .eq. j) a(i,j) = 1. enddo enddo do j=1,lx2 do k=1,lx3 b(j,k) = j*0.0001+k enddo enddo c transpose of A do j=1,lx1 do i=1,lx2 at(i,j) = a(j,i) enddo enddo do j=1,lx3 do i=1,lx1 c(i,j) = 0. do m=1, lx2 c(i,j) = c(i,j) + at(m,i) * b(m,j) enddo if(j .eq. lx3 .and. i .le. 10) $ write(*, 100) ' c(',i,',',j,') = ', c(i,j) enddo enddo 100 format(a,I4,a,I4,a,f15.4) return end ---------- X-Sun-Data-Type: c-file X-Sun-Data-Description: c-file X-Sun-Data-Name: time_keeper.c X-Sun-Charset: us-ascii X-Sun-Content-Lines: 41 #include #include #include #define MAXSTRING 100 typedef struct { clock_t begin_clock, save_clock; time_t begin_time, save_time; } time_keeper; static time_keeper tk; void start_time() { tk.begin_clock = tk.save_clock = clock(); tk.begin_time = tk.save_time = time(NULL); } double prn_time() { char s1[MAXSTRING], s2[MAXSTRING]; double clocks_per_second = (double) CLOCKS_PER_SEC, user_time, real_time; user_time = (clock() - tk.save_clock) / clocks_per_second; real_time = difftime(time(NULL), tk.save_time); tk.save_clock = clock(); tk.save_time = time(NULL); sprintf(s1, "%.5f", user_time); sprintf(s2, "%.5f", real_time); printf("%s%.5f%s\n\n", "User time: ", user_time, " seconds"); printf("%s%.5f%s\n\n", "Real time: ", real_time, " seconds"); return user_time; } ---------- X-Sun-Data-Type: h-file X-Sun-Data-Description: h-file X-Sun-Data-Name: time_keeper.h X-Sun-Charset: us-ascii X-Sun-Content-Lines: 16 /* time_keeper.h */ #include #include #include #if defined CC extern void start_time(); extern double prn_time(); #endif #if defined CPP extern "C" void start_time(); extern "C" double prn_time(); #endif -- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com