Mixing C and Fortran90 with GNU compilers: problems !
Sébastien Le Roux
Tue Apr 21 20:08:00 GMT 2009
SÃ©bastien Le Roux a Ã©crit :
> Dear GCC and Gfortran users and developers,
> I am developing a scientific application mixing C and Fortran90
> with a GTK+ interface.
> The reason of this choice is that I have already written a Fortran90
> code (rings-code.sourceforge.net)
> computing almost everything I am interested in and I wanted to improve
> it and to create a GUI.
> I must say that so far everything was fine, but I have noticed a
> problem that I can not overcome
> by myself.
> The main routine is a C routine which initialises the GTK + interface.
> Then I am calling the fortran routines for the physic/chemistry
> In a first time I have noticed that it is impossible to print (write
> statement) a real
> or a double precision variable in the Fortran part of the code, ex:
> SUBROUTINE printdata
> REAL :: val=6.15
> write (6, 001) val
> 001 FORMAT (f4.2)
> When mixing C/Fortran90 compiled with the GNU compilers (gcc v4.3.2
> 20081105 or
> gcc version 3.4.6 20060404, and gfortran-gcc version 4.3.2 20081105
> and linked with gfortran)
> the previous statement fails with the following error message.:
> (unit = 6, file = 'stdout')
> Internal Error: printf is broken
> I was not able to figure out what the problem was so I decided not
> print information from the fortran90
> part of the code.
> If anyone has a clue about that I would love to ear about it.
> Nevertheless this is not my main problem, but may be related somehow
> to the fact that I can not either
> read real or double precision variable from the Fortran90 part of the
> SUBROUTINE readdata
> REAL :: x, y, z
> open (unit=20, file='positions.xyz', action='read', status='old')
> read (20, *) x, y, z
> close (20)
> Then the program will not fail but will only read integer data, for
> instance if in the file is:
> 6.4567 3.4524 8.5644
> then the code will store 6, 3 and 8 for the values of x, y and z ...
> no way to read real or double data.
> And this is really a problem for me ... does anyone have a clue to
> help me to solve that.
> The results I describe here have been obtained on Linux as well as
> Windows using the MinGW version
> of gcc and the Win32 version of gfortran.
> PS: I tried to subscribe the gcc-help mailing list without success so
> so can you please respond to this message to my personal email.
Hello all GCC/Gfortran users,
I have just find out that the problem I describe here is not related to
between the C and the fortran compilers.
In fact GCC and Gfortran work fine here.
The problems comes from the LANG environment variable of my computer (in
When running the program under a Fr environment then the error describe
appear, and in a us env (LANG=en_US.UTF-8) everything is fine.
I have even notice that the errors are reproducible in C (I have
re-written the reading routine
in C) in the french environment.
I wonder now if there is a way to suppress that LANG dependency of the
This problem I guess comes from the GTK+ part of the program.
Dr. SÃ©bastien Le Roux
Department of Physics
201 Dow Science
Central Michigan University
Mt. Pleasant, MI 48859, USA
RINGS project: http://rings-code.sourceforge.net/
Fax: +1 (989) 774 2697
Phone: +1 (989) 774 3180
More information about the Gcc-help