character read


dn123
09-21-2011, 02:10 AM
hi ..all
i m trying to read a data file in which there are missing values
for eg

17-aug -9 0 55

in the above example there are 6 columns and every column is seperated by a tab bcoz its in txt(tab delimited) form..and for 3rd and sixth column there is no value.i want to replace this missing thing with -9 so my output looks like

17-aug -9 -9 0 55 -9

any suggestions ???
regards
durgesh:confused::confused:

brahman
10-26-2011, 06:07 AM
Hi dn123,

There is a naive idea that is you try to read a line of the input file into an array of 4 variables str, n1, n2, n3 :

character(len=6) :: str
integer :: n1,n2,n3,n4,n5

then you open the file (e.g. unit=1) and perform

read(1,*), str, n1, n2, n4

after that, write it out (e.g. screen, unit=*) with adding two terms at 3rd and sixth column as follows

write(*,*), str, n1, n2, n3, n4, n5

where n4=-9, n5=-9 or something else. In order to get though the file, we need a loop.

Bonus: I will write an efficient code for you if you give herein the whole input file.

Cheers!