oneel@heawk1.gsfc.nasa.gov ( Bruce Oneel ) (06/12/91)
I have a problem with f2c. I compile the following program as follows.... % f2c f2cbug.f % cc -o f2cbug f2cbug.c -L/home/heasfs/oneel/lib -lf2c -I/home/heasfs/oneel/include -g It hangs with the following output (f20.4) 9.9990012E-03 <hang here> System Sun Sparc 4/490, Sun OS 4.1.1, c compiler which came with. Now, if I remove the err= clause from the write statment I get an error about off the end of the record. If I then make cval bigger (50) I still get the same error message... What's wrong? Is it something in fortran I'm missing? Is it f2c or libf2c? Thanks for any and all help. I'll post a summary. Thanks bruce program follows character*20 cval character*10 form real*4 val form='(f20.4)' val = 9.9999e-03 print *,cval print *,form print *,val write(cval,form,err=900)val print *,cval print *,form print *,val stop 900 continue print *,'error' stop end The c translation /* f2cbug.f -- translated by f2c (version of 16 May 1991 13:06:06). You must link the resulting object file with the libraries: -lF77 -lI77 -lm -lc (in that order) */ #include "f2c.h" /* Table of constant values */ static integer c__9 = 9; static integer c__1 = 1; static integer c__4 = 4; /* Main program */ MAIN__() { /* System generated locals */ integer i__1; /* Builtin functions */ /* Subroutine */ int s_copy(); integer s_wsle(), do_lio(), e_wsle(), s_wsfi(), do_fio(), e_wsfi(); /* Subroutine */ int s_stop(); /* Local variables */ static char cval[20], form[10]; static real val; /* Fortran I/O blocks */ static cilist io___3 = { 0, 6, 0, 0, 0 }; static cilist io___5 = { 0, 6, 0, 0, 0 }; static cilist io___6 = { 0, 6, 0, 0, 0 }; static icilist io___7 = { 1, cval, 0, form, 20, 1 }; static cilist io___8 = { 0, 6, 0, 0, 0 }; static cilist io___9 = { 0, 6, 0, 0, 0 }; static cilist io___10 = { 0, 6, 0, 0, 0 }; static cilist io___11 = { 0, 6, 0, 0, 0 }; s_copy(form, "(f20.4)", 10L, 7L); val = (float).0099999; s_wsle(&io___3); do_lio(&c__9, &c__1, cval, 20L); e_wsle(); s_wsle(&io___5); do_lio(&c__9, &c__1, form, 10L); e_wsle(); s_wsle(&io___6); do_lio(&c__4, &c__1, (char *)&val, (ftnlen)sizeof(real)); e_wsle(); i__1 = s_wsfi(&io___7); if (i__1 != 0) { goto L900; } i__1 = do_fio(&c__1, (char *)&val, (ftnlen)sizeof(real)); if (i__1 != 0) { goto L900; } i__1 = e_wsfi(); if (i__1 != 0) { goto L900; } s_wsle(&io___8); do_lio(&c__9, &c__1, cval, 20L); e_wsle(); s_wsle(&io___9); do_lio(&c__9, &c__1, form, 10L); e_wsle(); s_wsle(&io___10); do_lio(&c__4, &c__1, (char *)&val, (ftnlen)sizeof(real)); e_wsle(); s_stop("", 0L); L900: s_wsle(&io___11); do_lio(&c__9, &c__1, "error", 5L); e_wsle(); s_stop("", 0L); } /* MAIN__ */ -- Bruce O'Neel oneel@heasfs.gsfc.nasa.gov NASA/GSFC/STX/Code 664