I'm working on a project so i would be glad if someone answer as soon as possible. The thing is that i need to read some lines and re-write only a specific column, i already get the 'unique' column but on it appears just one line... the first
Here it's...
----------------------------
program
implicit none
real Charge, coord_x, coord_y, coord_z, mass
integer Atom, Z, flag, prim, iend
character c_sn*1
open (File='enter.txt',Unit=40,Status='OLD',&
form='FORMATTED', access='direct', recl=150)
prim = 001
flag=.false.
rewind 40
do
read(40,20,iostat=iend) Atom, Z, c_sn, Charge, c_sn,&
coord_x, c_sn, coord_y, c_sn, coord_z, mass
20 format (i3, 2x, i2, 4x,&
a1, f8.6, 6x, a1, f7.5, 4x,&
a1, f7.5, 4x, a1, f7.5, 6x, f8.5)
if(Atom.eq.prim)then
flag =.true.
exit
endif
if(iend.lt.0)exit
if(flag)then
read(40,20) Atom, Z, c_sn, Charge, c_sn,&
coord_x, c_sn, coord_y, c_sn, coord_z, mass
endif
enddo
write(*,*)' ' !blank line
write(50,10) c_sn, Charge
10 format('Charge',//,a1,f8.6)
close (50)
close (40)
stop
end
----------------------------
i need to read a archive like this...
NET CHARGES AND COORDINATES
Atom Z Charge Coordinates(Angstrom) Mass
x y z
1 6 -0.115485 0.00006 -0.00008 -0.00001 12.01100
2 6 -0.033024 1.38997 -0.00012 0.00000 12.01100
3 6 -0.449862 2.11881 1.18739 0.00001 12.01100
4 6 -0.050770 1.42026 2.39266 0.00824 12.01100
but only the third column. So please tell what am i doing wrong?
Here it's...
----------------------------
program
implicit none
real Charge, coord_x, coord_y, coord_z, mass
integer Atom, Z, flag, prim, iend
character c_sn*1
open (File='enter.txt',Unit=40,Status='OLD',&
form='FORMATTED', access='direct', recl=150)
prim = 001
flag=.false.
rewind 40
do
read(40,20,iostat=iend) Atom, Z, c_sn, Charge, c_sn,&
coord_x, c_sn, coord_y, c_sn, coord_z, mass
20 format (i3, 2x, i2, 4x,&
a1, f8.6, 6x, a1, f7.5, 4x,&
a1, f7.5, 4x, a1, f7.5, 6x, f8.5)
if(Atom.eq.prim)then
flag =.true.
exit
endif
if(iend.lt.0)exit
if(flag)then
read(40,20) Atom, Z, c_sn, Charge, c_sn,&
coord_x, c_sn, coord_y, c_sn, coord_z, mass
endif
enddo
write(*,*)' ' !blank line
write(50,10) c_sn, Charge
10 format('Charge',//,a1,f8.6)
close (50)
close (40)
stop
end
----------------------------
i need to read a archive like this...
NET CHARGES AND COORDINATES
Atom Z Charge Coordinates(Angstrom) Mass
x y z
1 6 -0.115485 0.00006 -0.00008 -0.00001 12.01100
2 6 -0.033024 1.38997 -0.00012 0.00000 12.01100
3 6 -0.449862 2.11881 1.18739 0.00001 12.01100
4 6 -0.050770 1.42026 2.39266 0.00824 12.01100
but only the third column. So please tell what am i doing wrong?