Re: Converting string to Integer, Real, etc...
- From: Paul van Delst <Paul.vanDelst@xxxxxxxx>
- Date: Wed, 27 Dec 2006 12:14:16 -0500
Jeremy wrote:
How can I convert a string to an integer and other types? What about the reverse? I do not see an intrinsic for it.
Use internal files.
program blah
character(20) :: c
real :: x, x2
integer :: i, i2
x=3.1415
i=100
! "Convert" x to char and back again
write(c,'(f6.4)') x
print *, '>',c,'<'
print *, '>',trim(c),'<'
read(c,*) x2
print *, x2
! "Convert" i to char and back again
write(c,'(i0)') i
print *, '>',c,'<'
print *, '>',trim(c),'<'
read(c,*) i2
print *, i2
end program blah
lnx:tmp : lf95 blah.f90
Encountered 0 errors, 0 warnings in file blah.f90.
lnx:tmp : a.out
>3.1415 <
>3.1415<
3.14150000
>100 <
>100<
100
cheers,
paulv
--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
.
- References:
- Converting string to Integer, Real, etc...
- From: Jeremy
- Converting string to Integer, Real, etc...
- Prev by Date: Re: READ and delimited format
- Next by Date: Re: Converting string to Integer, Real, etc...
- Previous by thread: Converting string to Integer, Real, etc...
- Next by thread: Re: Converting string to Integer, Real, etc...
- Index(es):