View Full Version : Strange E Format Specifier
maynard
03-16-2004, 06:02 PM
Has anybody ever come across a format specifier that will output scientific notion without including the "E"? For example, instead of printing out "1.234E+05" I need "1.234+05". I'm needing to generate a set of input parameters that uses this format (I know that the E format will read it in, but it won't print it out).
Thanks.
tzeis
03-16-2004, 09:06 PM
You are going to have to compose the output using the character type. The process involves doing an internal write of the value, and composing the right form of the output. One way to do this might look like:
implicit none
character(10) :: str
real :: a
integer :: i
a = 1.234e+10
write(str,'(es10.3)') a ! internal write
i = index(str, "E") ! i contains the location of the E we want to remove
str = str(:i-1) // str(i+1:) ! remove the E
write(*,*) trim(str) ! writes "1.234+10"
end
vBulletin® v3.6.8, Copyright ©2000-2010, Jelsoft Enterprises Ltd.