pdb file structure and I would like to change the number from 5427 and you could see that number in the same column are not in a sequential manner我是Fortran的新手。我想改变从特定行开始的列编号,在我的情况下是5427.在num(h)列中此行之后的数字不是按顺序方式,我希望它按顺序排列,例如它将是5428,5429等。有人可以建议我这样做吗? 我试图通过将num(h)值与5427进行比较来使用if循环来比较它们,如果它发现我希望它从下一行改变但我的尝试没有成功。
program read_pdb
implicit none
!read the pdb file and fefine individual columns
character(len=4),Dimension(22986)::atom,restype
character(len=3),Dimension(22986)::resname
integer,Dimension(22986)::num,atomnum
!integer(len=4),Dimension(22986)::atomnum
real,Dimension(22986)::x,y,z
character(len=11),Dimension(22986)::chamass
integer::h
!format for printing out the file
character(len=65),parameter::format="(A4,2X,I5,1X,A4,1X,A3,2X,I4,4X,F8.3,F8.3,F8.3,1X,A11)"
!read the file
open(unit=11, file="FVIII_v1.pdb", status="old", action="read")
! write the file
!open(unit=12,file="FVIII_v11.pdb",status="new",action="write")
do h=1,22986
read(11,format)atom(h),num(h),restype(h),resname(h),atomnum(h),x(h),y(h),z(h),chamass(h)
!write(*,format)atom(h),num(h),restype(h),resname(h),atomnum(h),x(h),y(h),z(h),chamass(h)
end do
! write only till 5426
do h=1,5426
write(*,format)atom(h),num(h),restype(h),resname(h),atomnum(h),x(h),y(h),z(h),chamass(h)
end do
! pick up from 5427 and start chaning the the number by adding 1 from the num
do h=5427,22986
write(*,format)atom(h),num(h)+1,restype(h),resname(h),atomnum(h),x(h),y(h),z(h),chamass(h)
end do
close(11)
end program read_pdb