Thursday, June 10, 2010

int2str and str2num in fortran, How convert string to integer number of vice versa.

To convert a number/integer to a string, you need to write the variable into the string character.

Integer I
Character* str
I = 9999
Write( str, '(i10)' ) I
End


To convert a string to number or integer, you need to read the strign and assign it to the integer

Integer I
Character* str
I = 9999
read( str, '(i10)' ) I
End

6 comments:

  1. Thanks, this helped me!

    ReplyDelete
  2. Thanks, this helped me out. Fortran can be a little stubborn on this type of thing.

    ReplyDelete
  3. very helpful , thanks !

    ReplyDelete
  4. Thanks a lot for this right to the point help. I will consider this blog first for future questions.

    ReplyDelete