Why doesn't f2c produce printf? 
Author Message
 Why doesn't f2c produce printf?

Does anyone know why f2c produces C code for standard-out using some
library function called do_lio()? Why doesn't it just produce printf()
statements? Is there a flag I can specify that will produce printf()?
Thanks for any help.



Sat, 26 Aug 2000 03:00:00 GMT  
 Why doesn't f2c produce printf?



Quote:
>Does anyone know why f2c produces C code for standard-out using some
>library function called do_lio()? Why doesn't it just produce printf()
>statements? Is there a flag I can specify that will produce printf()?
>Thanks for any help.

Maybe it's because the semantics of formatted printing in fortran aren't
well matched to printf?


Sat, 26 Aug 2000 03:00:00 GMT  
 Why doesn't f2c produce printf?

: Does anyone know why f2c produces C code for standard-out using some
: library function called do_lio()? Why doesn't it just produce printf()
: statements? Is there a flag I can specify that will produce printf()?
: Thanks for any help.

Probably because f2c has to correctly emulate the carriage control
rules in Fortran.  Remember, 0 as the first character means skip a
line, 1 means form feed, + means overstrike, and blank means just do
the next line.

Paul Hughett



Sun, 27 Aug 2000 03:00:00 GMT  
 Why doesn't f2c produce printf?


Quote:


>>Does anyone know why f2c produces C code for standard-out using some
>>library function called do_lio()? Why doesn't it just produce printf()
>>statements? Is there a flag I can specify that will produce printf()?
>>Thanks for any help.

>Maybe it's because the semantics of formatted printing in Fortran aren't
>well matched to printf?

On top of that, printf doesn't support some of the standard (read "required")
features of fortran formatted print.  One such example is the T descriptor:
T40 means tab to column 40 no matter what column you started on.  The
equivalent descriptor in C (%40t) means insert 40 blanks starting at the
current column.

M. Von Hendy



Sun, 27 Aug 2000 03:00:00 GMT  
 Why doesn't f2c produce printf?

Quote:


> : Does anyone know why f2c produces C code for standard-out using some
> : library function called do_lio()? Why doesn't it just produce printf()
> : statements? Is there a flag I can specify that will produce printf()?
> : Thanks for any help.

> Probably because f2c has to correctly emulate the carriage control
> rules in Fortran.  Remember, 0 as the first character means skip a
> line, 1 means form feed, + means overstrike, and blank means just do
> the next line.

> Paul Hughett

But this is such a minor deal. You can do these with printf().
The use of the f2c library function do_lio() is making the resultant
code extremely difficult to read.


Sun, 27 Aug 2000 03:00:00 GMT  
 Why doesn't f2c produce printf?

: Does anyone know why f2c produces C code for standard-out using some
: library function called do_lio()? Why doesn't it just produce printf()
: statements? Is there a flag I can specify that will produce printf()?  
: Thanks for any help.

Quote:
>> Probably because f2c has to correctly emulate the carriage
>> control rules in Fortran.  Remember, 0 as the first character
>> means skip a line, 1 means form feed, + means overstrike, and
>> blank means just do the next line.

: But this is such a minor deal. You can do these with printf().  The
: use of the f2c library function do_lio() is making the resultant code
: extremely difficult to read.

Read http://cm.bell-labs.com/netlib/f2c/f2c.ps.gz .  It explains that
f2c wants to make calls to fortran 77 i/o subroutines declared in
fortran 77 i/o libraries.  Not to printf in libc.

Incidentally, Sun has sort of done their own thing with f77.   Its not
obvious to me how they do this.  But it doesn't look like they use
fortran 77 i/o libraries.  They might use a common io library for
their c and fortran compilers.

-Derek



Sun, 27 Aug 2000 03:00:00 GMT  
 Why doesn't f2c produce printf?



Quote:
> Does anyone know why f2c produces C code for standard-out using some
> library function called do_lio()? Why doesn't it just produce printf()
> statements? Is there a flag I can specify that will produce printf()?
> Thanks for any help.

I have read somewhere that f2c was designed to produce the exact same .obj
files as did the original Fortran compiler from which f2c was derived (i.e.
when the generated C code was compiled, the .obj files would be identical
to those generated by the original Fortran compiler). This was supposedly
the way f2c could be verified to produce correct code, simply by comparing
the .obj files. Of course, this had to have some cost, namely readability.
This illustrates that f2c is useful as a second-class fortran compiler, but
not as a code conversion tool. The code produced is likely to be much less
readable than the original.

Nothing comes for free.

Carsten Arnholm



Sun, 27 Aug 2000 03:00:00 GMT  
 Why doesn't f2c produce printf?


Quote:



>> Does anyone know why f2c produces C code for standard-out using some
>> library function called do_lio()? Why doesn't it just produce printf()
>> statements? Is there a flag I can specify that will produce printf()?
>> Thanks for any help.

>I have read somewhere that f2c was designed to produce the exact same .obj
>files as did the original Fortran compiler from which f2c was derived (i.e.
>when the generated C code was compiled, the .obj files would be identical
>to those generated by the original Fortran compiler).

That is a laughably ridiculous fairy tale.  I just don't see how it
can even be possible! It is unlikely that this is possible without
changing the C compiler.

Even if the C compiler managed to somehow emit exactly the same code
for every instance of a f2c translated program, it could be shown that
it is incorrectly translating C. If the ``original'' Fortran compiler
(whichever one that may be) was able to optimize access to array
parameters under the assumption that the arrays don't overlap, the
C compiler would have to emit a translation which violates the rules of the
language in order to match the Fortran compiler's machine code.



Sun, 27 Aug 2000 03:00:00 GMT  
 Why doesn't f2c produce printf?

[Why f2c generates]

Quote:
>code extremely difficult to read.

The resulting code is not intended to be read, it is intended
to be compiled on machines with C, but no FORTRAN compilers.

Kurt

--
| Kurt Watzka                             Phone : +49-89-2178-2781



Sun, 27 Aug 2000 03:00:00 GMT  
 Why doesn't f2c produce printf?

Quote:



> > : Does anyone know why f2c produces C code for standard-out using some
> > : library function called do_lio()? Why doesn't it just produce printf()
> > : statements? Is there a flag I can specify that will produce printf()?
> > : Thanks for any help.

> > Probably because f2c has to correctly emulate the carriage control
> > rules in Fortran.  Remember, 0 as the first character means skip a
> > line, 1 means form feed, + means overstrike, and blank means just do
> > the next line.

> > Paul Hughett

> But this is such a minor deal. You can do these with printf().
> The use of the f2c library function do_lio() is making the resultant
> code extremely difficult to read.

The reason f2c does not use printf is because when it was originally
designed and implemented it was required to produce exactly the same
object files as the fortran compiler on a DEC platform of some sort. If
you read the f2c manual (f2c.ps) provided with the distribution
obtained from netlib there is a description of this there.

If you want maintainable C code from fortran, you are probably better
off with a commercial conversion product tha will produce readable and
maintainable C code.

Kevin

-----------------------------------------------------------------------
Kevin R. Gehringer, Graduate Student
University of Washington            
College of Forest Resources

Seattle, WA  98195-2100                Phone: (206) 616-5785
Mail Stop: Anderson Hall 115           Office: Anderson Hall, Room 301
-----------------------------------------------------------------------
    "It's turtles all the way down."



Sun, 27 Aug 2000 03:00:00 GMT  
 Why doesn't f2c produce printf?



Quote:
>The reason f2c does not use printf is because when it was originally
>designed and implemented it was required to produce exactly the same
>object files as the fortran compiler on a DEC platform of some sort. If
>you read the f2c manual (f2c.ps) provided with the distribution
>obtained from netlib there is a description of this there.

What, it's actually true? ;)


Sun, 27 Aug 2000 03:00:00 GMT  
 Why doesn't f2c produce printf?

Quote:


> > Probably because f2c has to correctly emulate the carriage control
> > rules in Fortran.  Remember, 0 as the first character means skip a
> > line, 1 means form feed, + means overstrike, and blank means just do
> > the next line.

> But this is such a minor deal. You can do these with printf().
> The use of the f2c library function do_lio() is making the resultant
> code extremely difficult to read.

You can do overstrike with printf()? Which conversion specifier is that?

--
(initiator of the campaign for grumpiness where grumpiness is due in c.l.c)

Attempting to write in a hybrid which can be compiled by either a C compiler
or a C++ compiler produces a compromise language which combines the drawbacks
of both with the advantages of neither.



Sun, 27 Aug 2000 03:00:00 GMT  
 Why doesn't f2c produce printf?

 > But this is such a minor deal. You can do these with printf().
 > The use of the f2c library function do_lio() is making the resultant
 > code extremely difficult to read.

How would you in that case translate something like:
1     FORMAT(10(1X, I5), /, (6X, 9(1X, I5)))
      WRITE(*, 1) ((A(I, J), I = 1, N), J = 1, M)
using printf?
--
dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn  amsterdam, nederland; http://www.cwi.nl/~dik/



Mon, 28 Aug 2000 03:00:00 GMT  
 Why doesn't f2c produce printf?

Quote:

> But this is such a minor deal. You can do these with printf().
> The use of the f2c library function do_lio() is making the resultant
> code extremely difficult to read.

f2c is not really a program to translate C into Fortran.  It is a
Fortran compiler which happens to produce C code instead of assembly
or machine language.  Among other things, this means that it uses the
Fortran standard libraries instead of the C standard libraries.  This
helps to ensure that a program will work in the same way as if it had
been compiled with a standard Fortran compiler.

IIRC, the manual discusses exactly what f2c is trying to achieve.

--

            http://www.tardis.ed.ac.uk/~broonie/
EUFS        http://www.ed.ac.uk/~filmsoc/



Mon, 28 Aug 2000 03:00:00 GMT  
 Why doesn't f2c produce printf?



Quote:




> >> Does anyone know why f2c produces C code for standard-out using some
> >> library function called do_lio()? Why doesn't it just produce printf()
> >> statements? Is there a flag I can specify that will produce printf()?
> >> Thanks for any help.

> >I have read somewhere that f2c was designed to produce the exact same
obj
> >files as did the original Fortran compiler from which f2c was derived
(i.e.
> >when the generated C code was compiled, the .obj files would be
identical
> >to those generated by the original Fortran compiler).

> That is a laughably ridiculous fairy tale.  I just don't see how it
> can even be possible!

The fact that you don't see how things can be possible does not make them
"ridiculous fairy tales".

Quote:
> It is unlikely that this is possible without
> changing the C compiler.

Are we a bit uncertain here?

Quote:

> Even if the C compiler managed to somehow emit exactly the same code
> for every instance of a f2c translated program, it could be shown that
> it is incorrectly translating C.

So please show us what the "incorrect translations" are like.

Quote:
> If the ``original'' Fortran compiler
> (whichever one that may be) was able to optimize access to array
> parameters under the assumption that the arrays don't overlap, the
> C compiler would have to emit a translation which violates the rules of
the
> language in order to match the Fortran compiler's machine code.

And what's your problem ? If the compiled code produces correct results you
can argue as much as you like. It simply proves that f2c is a Fortran
compiler that happens to use C syntax as an intermediate representation of
the program. No-one claimed it is generating good C. It underscores my
point that f2c should not be used as a tool for converting Fortran source
code to C source code, because the C representation is less maintainable
than the original Fortran code.

Carsten Arnholm



Mon, 28 Aug 2000 03:00:00 GMT  
 
 [ 25 post ]  Go to page: [1] [2]

 Relevant Pages 

1. why doesn't printf work right?

2. doesn't printf need stdio.h?

3. Don't know why this doesn't work, but

4. replacing printf with my printf, then calling C lib's printf

5. VC7: cstdio doesn't put printf in std

6. printf %E format doesn't work on PockePC

7. Why you should use puts(3) when you don't need printf(3)

8. why my dropdownlist doesn't return right value

9. Doesn't compile local classes, why?

10. Why doesn't this function work?

11. Why doesn't this work!?!??!

12. why doesn't Type.IsSubclassOf work for interfaces

 

 
Powered by phpBB® Forum Software