www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/03/06/14:15:19

From: "Bill Galbraith" <BILLG AT p3 DOT enzian DOT com>
To: djgpp AT delorie DOT com
Date: Wed, 6 Mar 1996 11:22:10 EDT
Subject: problem with f_back
Message-Id: <13C3C6C6444@P3.ENZIAN.COM>

I don't speak C very well, and I use DJGPP with the Fortran-to-C 
converter F2C. I am having trouble converting a program which 
executes under DJGPP v1m4 but encounters a problem under DJGPP v2.0 .

The FORTRAN statement 

   backspace ( unit )
   
generates a C statement

   f_back ( whatever )
   
When this statement is executed, an error is generated 

   backspace: end of file
   apparent state: unit 6 (unnamed)
   last format: list io
   lately writing direct formatted external IO
   Abort!


A brief FORTRAN progran to illustrate this problem is contained in 
the file FOO.F, such as:

      Program FOO
      Character*79  Buffer
      open (1, file='foo.f' )
      read (1,*) buffer
      write (6,*) buffer
      backspace (1)
      read (1,*) buffer
      write (6,*) buffer
      end

The C code that is generated by F2C, in the file foo.c, is


/* foo.f -- translated by f2c (version 19950920).
   You must link the resulting object file with the libraries:
    -lf2c -lm   (in that order)
*/

#include "f2c.h"

/* Table of constant values */

static integer c__9 = 9;
static integer c__1 = 1;

/* Main program */ MAIN__()
{
    /* System generated locals */
    olist o__1;
    alist al__1;

    /* Builtin functions */
    integer f_open(), s_rsle(), do_lio(), e_rsle(), s_wsle(), 
e_wsle(), 
        f_back();

    /* Local variables */
    static char buffer[79];

    /* Fortran I/O blocks */
    static cilist io___1 = { 0, 1, 0, 0, 0 };
    static cilist io___3 = { 0, 6, 0, 0, 0 };
    static cilist io___4 = { 0, 1, 0, 0, 0 };
    static cilist io___5 = { 0, 6, 0, 0, 0 };


    o__1.oerr = 0;
    o__1.ounit = 1;
    o__1.ofnmlen = 5;
    o__1.ofnm = "foo.f";
    o__1.orl = 0;
    o__1.osta = 0;
    o__1.oacc = 0;
    o__1.ofm = 0;
    o__1.oblnk = 0;
    f_open(&o__1);
    s_rsle(&io___1);
    do_lio(&c__9, &c__1, buffer, 79L);
    e_rsle();
    s_wsle(&io___3);
    do_lio(&c__9, &c__1, buffer, 79L);
    e_wsle();
    al__1.aerr = 0;
    al__1.aunit = 1;
    f_back(&al__1);
    s_rsle(&io___4);
    do_lio(&c__9, &c__1, buffer, 79L);
    e_rsle();
    s_wsle(&io___5);
    do_lio(&c__9, &c__1, buffer, 79L);
    e_wsle();
} /* MAIN__ */

/* Main program alias */ int foo_ () { MAIN__ (); }


Yes, I have checked that the same code is generated with the two 
different set-ups for DJGPP I have on my disk, v1m4 and v2, and have 
checked the outputs for both F2C and F2CX.

Can anyone shed some light on my problem? Is this a problem with 
DJGPP v2.0 or with the F2C converter?

Thanks

Bill Galbraith
billg AT p3 DOT enzian DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019