Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

integer array to string 1

Status
Not open for further replies.

erore

IS-IT--Management
Oct 15, 2006
4
0
0
CZ
Can anyone help with conversion of an array of x(1:n) to a string?
If x(1) = 1, x(2) = 5, x(3) = -2, ..., x(n) = 0
then I want the generated string myString to look like:
myString = '1,5,-2,...,0'
 
Code:
program t62
  character(1024) :: string
  integer :: array(4)=(/1,5,-2,0/)
  write(string,"(1000(I0,:,','))") array
  write(*,'(A)') TRIM(string)
end

Result :

Code:
[lcoul@localhost test]$ ifort t62.f90
[lcoul@localhost test]$ ./a.out
1,5,-2,0

François Jacq
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top