gfortran (v4.0) redirected output `feature'?

Juan Gallego Little.Boss@physics.mcgill.ca
Tue Jun 21 18:06:00 GMT 2005


greetings all,

i'm trying to build ATLAS (3.7.10) with GCC 4.0, and i've hit a peculiar
`feature': during the configuration phase, ATLAS complains that it
can not determine the fortran naming conventions.  after some careful
digging, i've found the problem (which seems rather strange, at least
for me).

consider these 2 files (taken directly from ATLAS):

--- begin fname.f ---
*
      PROGRAM NAMTST
      EXTERNAL C_ROUTINE
*
      CALL C_ROUTINE()
*
      STOP
      END
--- end ---

and 

--- begin cname.c ---

#include <stdio.h>
void c_routine_(void)  { printf("-DAdd_\n"); }
void c_routine(void)   { printf("-DNoChange\n"); }
void C_ROUTINE(void)  { printf("-DUpCase\n"); }
void c_routine__(void) { printf("-DAdd__\n"); }

--- end ---

compiled respectively with (leading `> ' is the prompt):

> gfortran -c fname.f

and

> cc -c cname.c

and linked with:

> gfortran -o ./xfcnam fname.o cname.o

i run the executable:

> ./xfcnam 
-DAdd__
STOP 0

as expected. but if stdout is redirected to a file, c_routine's output
disappears:
  
> ./xfcnam > t
STOP 0
> cat t
> ls -l t
-rw-r--r--    1 juan     users           0 Jun 21 13:47 t

same thing if the output is piped to another command (say cat).

if i modify fname.c to call ABORT() after calling c_routine, c_routine's
output (redirected or not) survives:

> ./xfcnam.abort > t
> cat t
-DAdd__
> ls -l t
-rw-r--r--    1 juan     users           8 Jun 21 13:51 t

so gfortran seems to be destroying/mangling the output stream on exit.

is this `feature' part of the standard (alas, i'm F90/F95 illiterate)? is it
gfortran specific? is this an ATLAS abuse of the language? or it isn't a
`feature' at all, but a bug?

i've googled and perused the ml archives, but i haven't found anything
relevant (or my searching leaves much to be desired).

any insight/suggestion/comment/anything?

many tia,
-- 
juan



More information about the Fortran mailing list