Re: How to convert integers to characters?



Thank you for all your kindly help, especially Richard Maine!

Here I still have a problem that it seems the method you demonstrated
did NOT work perfectly!

Below is the code to convert a (a real variable) to b (a character)
and then print out the length of b.

! Fortran 90 code begins
program ex
implicit none
real::a=123.4
character(len=10)::b
write(b,*)a
write(*,"(A8,1X,I3)")b, len_trim(b)
end
! Fortran 90 code ends

I use Debian Linux for i386 and have two fortran compilers installed,
g95 and gfortran.

(1) Being compiled by g95, the output is:
123.4 6
(2) Being compiled by gfortran, the output is an runtime error:
At line 5 of file ex.f90
Fortran runtime error: End of record

The actually expected length of character variable b is 5, but neither
6 nor an error!

So, is there anyone can figure out and fix the problem?

Many thanks!



.



Relevant Pages

  • Re: Suspicious Gfortran
    ... Fortran 77 compilers that exist, and thus doesn't mean anything in this ... problem is coming from a bug in your code, rather than a bug in gfortran. ...
    (comp.lang.fortran)
  • Re: Zero-size arrays
    ... were also found in ifort, gfortran, pathscale and some more which I do ... and commercial compilers in this regard; ... Fortran 90/95, but with configure check also things like Fortran ...
    (comp.lang.fortran)
  • Re: How to convert integers to characters?
    ... Fortran 90 code begins ... I use Debian Linux for i386 and have two fortran compilers installed, ... Being compiled by gfortran, the output is an runtime error: ...
    (comp.lang.fortran)
  • Re: Zero-size arrays
    ... were also found in ifort, gfortran, pathscale and some more which I do ... and commercial compilers in this regard; ... Fortran 90/95, but with configure check also things like Fortran ...
    (comp.lang.fortran)
  • Re: Unsupported Intel Fortran compiler for Linux
    ... I do not care about support; just want the ability to run the free linux intel compiler for unlimited time. ... Fortran 90/95 compilers and are free. ... gfortran is already included in GCC 4.0 onwards. ...
    (comp.lang.fortran)