如何定义输入路径和输出路径(两者是不同的位置)和输入文件名和输出文件名是否相同?
我想添加输入和输出目录以获取并保存相应目录的输入和输出,但输入和输出文件名将相同。
简单地说,我想修改我的代码以从输入目录文件夹中获取输入文件并将输出保存在输出目录文件夹中。
现在我的代码正在运行,但一次只有一个文件,我想为多个文件运行相同的代码。
来源:
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
c
c iaa: residue name
c iat: atom name
CHARACTER iaa*4,iat*4,chain*1
DIMENSION iaa(199),iat(199),chain(199)
c
c xpr,ypr,zpr: orthogonal coordinates
c irn: residue number
DIMENSION xpr(199),ypr(199),zpr(199),irn(199),taa(5)
c
c set pi value and rad to deg conversion factor
pi = 0.4D+01*DATAN(0.1D+01)
rad2deg = 0.18D+03/pi
deg2rad = pi/0.18D+03
c
fprec = 2.0*(sin(36.0*deg2rad)+sin(72.0*deg2rad))
c
c open the input file
OPEN (1,FILE="1e3i_A.txt")
c
c read the xyzs, atom and res name and res #
i = 1
396 READ (1,500,END=398) iat(i),iaa(i),chain(i),irn(i),xpr(i),
1 ypr(i),zpr(i)
c WRITE(*,500) iat(i),iaa(i),chain(i),irn(i),xpr(i),ypr(i),zpr(i)
i = i+1
c
c ensure arrays do not overflow
IF (i .GT. 199) THEN
WRITE(*,618)
STOP
ENDIF
c
c loop back and read the next atom entry
GO TO 396
c
c set the number of atoms, nat; close input file
398 nat = i-1
IF (nat .NE. 40) THEN
WRITE(*,632) nat
STOP
ENDIF
CLOSE(1)
c
c open output file
OPEN (3,FILE="output.dat")
c
c loop over all atoms; first get B of A-B-C-D
c
c irt = count of ring torsion angles
irt = 0
DO 716 i1 = 1,nat,4
j1 = i1
j2 = i1+1
j3 = i1+2
j4 = i1+3
c
c calculate the relevant vectors: j1-j2, j2-j3, j3-j4
d11 = xpr(j2) - xpr(j1)
d12 = ypr(j2) - ypr(j1)
d13 = zpr(j2) - zpr(j1)
d21 = xpr(j3) - xpr(j2)
d22 = ypr(j3) - ypr(j2)
d23 = zpr(j3) - zpr(j2)
d31 = xpr(j4) - xpr(j3)
d32 = ypr(j4) - ypr(j3)
d33 = zpr(j4) - zpr(j3)
c
c normals to j1-j2-j3 AND j2-j3-j4
c cross product of j1-j2 and j2-j3 AND of j2-j3 and j3-j4
p1 = d12*d23 - d13*d22
p2 = d13*d21 - d11*d23
p3 = d11*d22 - d12*d21
q1 = d22*d33 - d23*d32
q2 = d23*d31 - d21*d33
q3 = d21*d32 - d22*d31
c
c calculate cos-of-TA: angle between vectos p and q
ta = (p1*q1+p2*q2+p3*q3)/(dsqrt(p1*p1+p2*p2+p3*p3)*
1 dsqrt(q1*q1+q2*q2+q3*q3))
IF (DABS(ta) .GT. 1.0) ta = 1.0
c
c calculate magnitude of TA and convert to degrees
c ta = DACOS(ta)*rad2deg
ta = DACOS(ta)
c
c find sign of TA: find cross product of p and q
x1 = p2*q3 - p3*q2
y1 = p3*q1 - p1*q3
z1 = p1*q2 - p2*q1
c
c if not a null vector, find if parallel to j2-j3 or antiparallel
IF (DABS(x1)+DABS(y1)+DABS(z1) .NE. 0.0) THEN
xx = x1*d21 + y1*d22 + z1*d23
IF (xx .LT. 0.0) ta = -ta
ENDIF
irt = irt+1
taa(irt) = ta
IF (irt .EQ. 5) THEN
fnum = taa(5)+taa(2)-taa(4)-taa(1)
fden = fprec*taa(3)
tanp = fnum/fden
phase = DATAN(tanp)*rad2deg
IF (taa(3) .LT. 0) phase = phase+180.0
IF (phase .LT. 0) phase = phase+360.0
WRITE(*,624) phase
irt = 0
ENDIF
c
c output the value
c WRITE(3,606) iat(j1),irn(j1),iat(j2),irn(j2),iat(j3),
c 2 irn(j3),iat(j4),irn(j4),ta
716 CONTINUE
c
c close output file and exit
CLOSE(3)
c WRITE(*,620)
c
STOP
500 FORMAT(13X,2A4,A1,I4,4X,3F8.3)
502 FORMAT(A20)
606 FORMAT(1X,A4,I4,'... ',A4,I4,'... ',A4,I4,'... ',A4,I4,F12.3)
618 FORMAT(/' ERROR: number of atoms > 199'/)
620 FORMAT(/' Bye...Bye....'/)
622 FORMAT(/' Input: number of atoms ',I4,
3 ' is not a multiple of 4'/)
624 FORMAT(F12.3)
632 FORMAT(/' No. of atoms is',I4,' but expected only 40'/)
END