program angle
implicit none
real::x(3),y(3),z(3),angle,A,B,C,D
integer::i,j,k
write(*,*) 'Input the name of xyz:(e.g. a)'
read(*,*) name
name1=trim(name)//'.xyz'
open(12,file=name1)
open(13,file='result.txt')
do i=1,3
write(*,"(I1)") 'Input the atom number',i ,':(e.g.1)'
read(*,*) j
write(*,*)
if (j==1) then
read(12,"(11x,3(f12.6)") xi,yi,zi
else
do k=1,j-1
write(*,*)
end do
end if
read(12,"(11x,3(f12.6))") xi,yi,zi
rewind(12)
end do
A=(x1-x2)+(y1-y2)+(z1-z2) //!first vector
B=(x3-x2)+(y3-y2)+(z3-z2) //!second vector
C=dsqrt((x1-x2)**2+(y1-y2)**2+(z1-z2)**2) //!quantities of first vector
D=dsqrt((x3-x2)**2+(y3-y2)**2+(z3-z2)**2) //!quantities of second vector
angle=acos(A*B/C/D)
write(13,"(a,f12.4)") "The angle is:",angle/3.141592653589793238462d0*180
end program
24.19 KB, 下载次数: 2
Program www_fcode_cn
Implicit None
Real(kind=kind(0.0d0))::x(3),y(3),z(3),angle,A,B,C,D
Integer::i,k
Character(len=30) :: cstr
write(*,*) 'Input the name of xyz:(e.g. a)'
read(*,*) cstr
cstr=trim(cstr)//'.xyz'
open(12,file=cstr)
read(12,*)
open(13,file='result.txt')
do i=1,3
read(12,*) k , cstr , x(i),y(i),z(i)
end do
A=(x(1)-x(2))+(y(1)-y(2))+(z(1)-z(2)) !//!first vector
B=(x(3)-x(2))+(y(3)-y(2))+(z(3)-z(2)) !//!second vector
C=sqrt((x(1)-x(2))**2+(y(1)-y(2))**2+(z(1)-z(2))**2) !//!quantities of first vector
D=sqrt((x(3)-x(2))**2+(y(3)-y(2))**2+(z(3)-z(2))**2) !//!quantities of second vector
angle=acos(A*B/C/D)
write(13,"(a,f12.4)") "The angle is:",angle/3.141592653589793238462d0*180
end program www_fcode_cn
vvt 发表于 2016-1-14 11:45
[mw_shl_code=fortran,true]Program www_fcode_cn
Implicit None
Real(kind=kind(0.0d0))::x(3),y(3),z ...
Program www_fcode_cn
Implicit None
Real(kind=kind(0.0d0))::x(3),y(3),z(3),angle,A,B,C,D
Integer::i,j,k
Character(len=30) :: cstr
write(*,*) 'Input the name of xyz:(e.g. a)'
read(*,*) cstr
cstr=trim(cstr)//'.xyz'
open(12,file=cstr)
read(12,*)
open(13,file='result.txt')
do i=1,3
write(*,"(a,i1,a)") 'Input the atom number',i ,':(e.g.1)'
read(*,*) j
Do k = 1 , j-1
read(12,*)
End Do
read(12,*) k , cstr , x(i),y(i),z(i)
rewind(12)
read(12,*)
end do
A=(x(1)-x(2))+(y(1)-y(2))+(z(1)-z(2)) !//!first vector
B=(x(3)-x(2))+(y(3)-y(2))+(z(3)-z(2)) !//!second vector
C=sqrt((x(1)-x(2))**2+(y(1)-y(2))**2+(z(1)-z(2))**2) !//!quantities of first vector
D=sqrt((x(3)-x(2))**2+(y(3)-y(2))**2+(z(3)-z(2))**2) !//!quantities of second vector
angle=acos(A*B/C/D)
write(13,"(a,f12.4)") "The angle is:",angle/3.141592653589793238462d0*180
end program www_fcode_cn
vvt 发表于 2016-1-14 14:00
[mw_shl_code=fortran,true]Program www_fcode_cn
Implicit None
Real(kind=kind(0.0d0))::x(3),y(3),z ...
ninepss 发表于 2024-6-11 21:23
有个小问题想问一下,这段程序的A和B是代表什么意思,怎么感觉好像写错了
...
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |