!Exemplo int2char www.gnuscience.org
program int2char_GNUscience
character string*10
integer t

t=1

call int2char(t,string) 
open(1,file="file"//string//".dat")
  write(1,*) "exemplo int2char www.GNUscience.org"
close(1)
end program int2char_GNUscience
!------------------------------------------------------------------------------
subroutine int2char(x,string)
  !transforma integer em character + zeros
  !autor: www.GNUscience.org

  !input
  !x      => integer

  !output
  !string => character*10

  implicit none
  character aux*9,string*10,xchar*10
  integer pos_char,x

  aux="000000000";pos_char=0

  write(xchar,'(I10)') x
  pos_char=scan(xchar," ",back=.true.)
  string=aux(1:pos_char)//xchar((pos_char+1):10)

end subroutine


