input.dat文件的Fortran运行时错误

时间:2016-11-25 17:45:20

标签: fortran gfortran

以前曾问过类似的question,但我的问题有所不同:我一直在尝试使用旧的fortran代码在我的mac上执行 gfortran 。输入文件由于某种原因不起作用 - 我不知道它是否是代码或输入文件的缺点。源代码和输入文件位于同一目录中。这是代码:

C***************** M.R.T.M *********************************************
C
      IMPLICIT REAL*8(A-H,O-Z)
      CHARACTER*64 FNAMEI,FNAMEO
      COMMON/L1/ C(101),DC(101),DU(101),DL(101),E(101),S1(101),S2(101) 
      COMMON/L2/ SIR(101),CX(101),S1X(101),S2X(101)
      COMMON/L3/ X(101),S3(101),S3X(101)
      COMMON/L4/ TH,ROU,COL,WFLX,CI,CS,D,K1,K2,W,K3,K4,U,KS,K5,K6,KD 
      COMMON/L5/ NEQ,IT,N,NM1,NP1
      COMMON/L6/ TPULSE,TTOTAL,TPRINT,DT,DX,GAMMA,BETA
      CHARACTER*64 USER,SOIL,SOLUTE,DATE
      REAL*8 K1,K2,K3,K4,K5,K6,KS,KD,NEQ
C
C
C------ READ  INPUT  PARAMETERS----------------
C
      WRITE(*,*) 'PLEASE ENTER USER NAME (OPTIONAL):'
      READ(*,800) USER
      WRITE(*,*) ' PLEASE ENTER NAME OF SOIL (OPTIONAL):'
      READ(*,800) SOIL
      WRITE(*,*) ' PLEASE ENTER NAME OF SOLUTE (OPTIONAL):'
      READ(*,800) SOLUTE
      WRITE(*,*) ' ENTER DATE OR OTHER IDENTIFICATION (OPTIONAL):'
      READ(*,800) DATE
      WRITE(*,*) ' '
      WRITE(*,*)
     $'--------- INPUT PARAMETERS SECTION -------------'
      WRITE(*,*) ' '
      WRITE(*,*) ' INPUT PARAMETERS CAN BE PROVIDED IN TWO WAYS; '
      WRITE(*,*) '  ENTER 1 if you wish to enter the input data using'
      WRITE(*,*) '               the keyboard (i.e. interactively) '
      WRITE(*,*) ' '
      WRITE(*,*) '     OR '
      WRITE(*,*) ' '
      WRITE(*,*) '     ENTER 2 if an input data file is to be provided '
      WRITE(*,*)
     $'       PLEASE ENTER EITHER 1 OR 2'
      READ(*,950) IFLAG
      IF(IFLAG.NE.1) THEN
      WRITE(*,'(A)') ' PLEASE ENTER NAME OF INPUT FILE?'
      WRITE(*,*) '(for example A:XX.DAT or C:UU.DAT for hard disk)'
      READ(*,'(A)') FNAMEI
      OPEN(5,FILE=FNAMEI)
C
C
      READ(5,700) TH,ROU,COL,WFLX
      READ(5,700) CI,CS,D
      READ(5,700) KD,NEQ
      READ(5,700) K1,K2,W 
      READ(5,700) K3,K4,U 
      READ(5,700) KS
      READ(5,700) K5,K6
      READ(5,750) IT
      READ(5,700) TPULSE,TTOTAL,TPRINT,DT,DX
      ELSE
C
      WRITE(*,*)
     $'PLEASE ENTER THE FOLLOWING INPUT PARAMETERS  :'
      WRITE(*,*) '  '
      WRITE(*,*)
     $' (1) MOISTURE CONTENT, CM3/CM3 (TH) ='
      WRITE(*,*)
     $' (Values usually less than 0.65 cm3/cm3). Enter your value NOW'
      READ(*,900) TH
      WRITE(*,*)
     $' (2) BULK DENSITY, G/CM3 (ROU)  ='
      WRITE(*,*)
     $' (Range of values 1.1 - 1.7 g/cm3). Enter your value NOW' 
      READ(*,900) ROU
      WRITE(*,*)
     $' (3) PROFILE OR SOIL COLUMN LENGTH, CM (COL) ='
      READ(*,900) COL
      WRITE(*,*)
     $' (4) WATER FLUX, CM/HOUR (WFLX) ='
      WRITE(*,*)
     $'(Range of values 0.01 - 5 cm/hr). Enter your value NOW'
      READ(*,900) WFLX
      WRITE(*,*)
     $' (5) INITIAL CONCENTRATION, MG/L (CI)='
      READ(*,900) CI
      WRITE(*,*)
     $' (6) APPLIED CONCENTRATION, MG/L (CS)='
      READ(*,900) CS
      WRITE(*,*)
     $' (7) DISPERSION COEFFICIENT,D, CM2/HOUR (D) ='
      WRITE(*,*)
     $'(Range of values 0.1 - 1.5 cm2/hour). Enter your value NOW'
      READ(*,900) D 
      WRITE(*,*)
     $' (8) DISTRIBUTION COEFFICIENT, KD (KD) =' 
      WRITE(*,*)
     $' (Range of values 0 - 300 cm3/g) Enter your value NOW' 
      READ(*,900) KD
      WRITE(*,*)
     $' (9) NONLINEAR FREUNDLICH PARAMETER, N (NEQ)='
      WRITE(*,*) '(Range of values 0.3 - 0.9). Enter your value NOW' 
      READ(*,900) NEQ
      WRITE(*,*)
     $' (10) FORWARD RATE REACTION, K1, HR-1 (K1) ='
      WRITE(*,*) '(Range of values 0.01 - 2 hr-1). Enter your value NOW' 
      READ(*,900) K1
      WRITE(*,*)
     $' (11) BACKWARD RATE REACTION, K2, HR-1 (K2) ='
      WRITE(*,*) '(Range of values 0.01 - 5 hr-1). Enter your value NOW' 
      READ(*,900) K2
      WRITE(*,*)
     $' (12) NONLINEAR KINETIC PARAMETER, W, (W)='
      WRITE(*,*) '(Range of values 0.3 - 0.9). Enter your value NOW'
      READ(*,900) W 
      WRITE(*,*)
     $' (13) FORWARD RATE REACTION, K3, HR-1 (K3)='
      WRITE(*,*) '(Ranges from 0.0001 - 0.1 hr-1). Enter your value NOW' 
      READ(*,900) K3
      WRITE(*,*)
     $' (14) BACKWARD RATE REACTION, K4, HR-1 (K4)=' 
      WRITE(*,*) '(Ranges from 0.01 - 0.1 hr-1). Enter your value NOW'
      READ(*,900) K4
      WRITE(*,*)
     $' (15) NONLINEAR KINETIC PARAMETER, U, (U) ='
      WRITE(*,*) '(Range of values 0.3 - 0.9). Enter your value NOW'
      READ (*,900) U
      WRITE(*,*)
     $' (16) IRREVERSIBLE REACTION PATE,KS,HR-1 (KS) ='
      WRITE(*,*) '(Range is 0.0001 - 0.01 hr-1). Enter your value NOW' 
      READ(*,900) KS
      WRITE(*,*)
     $' (17) FORWARD RATE REACTION, K5,HR-1 (K5)  ='
      WRITE(*, *) '(Range is 0.0001 - 0.01 hr-1). Enter your value NOW' 
      READ(*,900) K5
      WRITE(*,*)
     $' (18) BACKWARD RATE REACTION, K6, HR-1 (K6) ='
      WRITE(*,*) '(Range is 0.001 - 0.1 hr-1). Enter your value NOW' 
      READ(*,900) K6
      WRITE(*,*)
     $' (19) NUMBER OF ITERATIONS (IT) AN INTEGER (FROM 0 TO 9)' 
      READ(*,950) IT
      WRITE(*,*)
     $' (20) INPUT PULSE DURATION, HOURS (TPULSE) =' 
      READ(*,900) TPULSE
      WRITE(*,*)
     $' (21) TOTAL SIMULATION TIME, HOURS (TTOTAL) =' 
      READ(*,900) TTOTAL
      WRITE(*,*)
     $' (22) PRINTOUT TIME DESIRED, HOURS (TPRINT) ='
      READ(*, 900) TPRINT
      WRITE(*,*)
     $' (23) INCREMENTAL TIME STEP, HOURS (DT) ='
      WRITE(*,*)
     $'  A default value of DT=0.02 is given' 
      READ(*,900) DDT
      WRITE(*,*)
     $' (24) INCREMENTAL DEPTH, CM (DX)='
      WRITE(*,*)
     $'  A default value of DX=1.00 is given   ' 
      READ(*,900) DDX
      ENDIF
C
      XIN=1.00
      IF(DDX.NE.0.0) THEN 
      DX=DDX
      ELSE
      DX=XIN
      ENDIF
C
      PIN=0.02 
      IF(DDT.NE.0.0) THEN
      DT=DDT
      ELSE
      DT=PIN
      ENDIF
      WRITE(*,'(A)') 'PLEASE ENTER NAME OF THE OUTPUT FILE (FOR EXAMPLE
     *  B:ZZ.DAT)'
      READ(*,'(A)') FNAMEO
      OPEN (6,FILE=FNAMEO,STATUS='UNKNOWN')
      PV=WFLX/TH
      RS=NEQ*ROU*KD/TH
      C0=CS
C
      TIME=0.0D0
      EF=0.0D0
   5  CONTINUE
      GAMMA=DT/(2.D0*DX*DX)
      BETA=DT/DX
      IF((BETA*PV).GT.0.50D0) GO TO 7 
      IF((GAMMA*D/(BETA*PV)).LT.0.5D0) GO TO 6
      GO TO 8
   6  DX=DX/2
      GO TO 5
   7  DT=DT/2
      GO TO 5
   8  CONTINUE
      N=INT(COL/DX)
      NM1=N-1
      NM2=N-2
      NP1=N+1 
      GAMMA=DT/(2*DX*DX)
      BETA=DT/DX
C
      IF(N.LT.500) GO TO 9 
      WRITE(*,*) 'W A R N I N G'
      WRITE(*,*)
     &'Dimension of variables exceeds 500. Did you increase array sizes'
      WRITE(*,*)
     &' If not, the program will terminate abruptly (see text).'
   9  CONTINUE
C
C--- WRITE TITLE HEADING  --------------- 
      WRITE(6,800) USER 
      WRITE(6,800) SOIL 
      WRITE(6,800) SOLUTE 
      WRITE(6,800) DATE
      WRITE(6,300) TH,ROU,COL,WFLX,CI,CS,D,K1,K2,B,K3,K4,W,KS
      WRITE(6,310) K5,K6,IT,KD,NEQ
     &,TPULSE,TTOTAL,TPRINT
      WRITE(6,400) DX,DT 
C
      DO 10 I=1,NP1 
      S1(I)=0.0D0 
      S2(I)=0.0D0 
      S3(I)=0.0D0 
      SIR(I)=0.0D0 
      S1X(I)=0.0D0 
      S2X(I)=0.0D0 
      S3X(I)=0.0D0 
      CX(I)=CI 
  10  C(I)=CI 
      WRITE(*,*) '------INITIAL CONDITIONS COMPLETED --------'
C
      WRITE(*,*) '------Execution Begins Please Wait---------------'
      WRITE(*,*) '------Please Wait -------------'
      IT=IT+1
      FF=2*DX 
      NKK=INT(TPRINT/DT+0.50D0) 
      KLM=INT(TTOTAL/DT+0.50D0) 
      KK=INT(KLM/NKK+0.5D0)
C
      L=0
      SINT=TPULSE*CS*WFLX 
      DO 50 JJ=1,KK
      DO 20 LL=1,NKK 
      TT=LL*DT+(JJ-1)*TPRINT 
      IF(DABS(TT-TPULSE).LT.0.01D0) CS=0.0D0
      L=L+1
      CALL SMRTM 
      EF=C(N)+EF 
  20  CONTINUE 
      TIME=JJ*TPRINT
C
      WRITE(6,500) TIME 
      VV0=WFLX*TIME/(COL*TH)
      CC0=C(N)/C0
      WRITE(6,525) VV0,CC0
      WRITE(*, 650) TIME,VV0,CC0
      WRITE(*,*) '--------Execution Continues--------'
      WRITE(*,*) '--------Please Wait---------'
      WRITE (6, 550)
      DO 30 I=1, NP1
      DEPTH=DX*(I-1)
      SEQ=KD*C(I)**NEQ
      TOTAL=SEQ+S1(I)+S2(I)+S3(I)+SIR(I)
  30  WRITE(6,600) DEPTH, C(I),SEQ,S1(I),S2(I),S3(I),SIR(I),TOTAL 
      CALL INTEG(DX,C,X,NP1)
      TSWATR=TH*X(NP1)
C
      DO 40 I=1,NP1
  40  E(I)=C(I)**NEQ
      CALL INTEG(DX, E, X, NP1)
      TSEQ=ROU*KD*X(NP1)
      SINP=TIME*CS*WFLX
      IF(SINP.GT.SINT) SINP=SINT
      IF(CS.EQ.0.D0) SINP=SINT
C
      CALL INTEG(DX,S1,X,NP1) 
      TSKIN1=ROU*X(NP1)
C
      CALL INTEG(DX,S2,X,NP1)
      TSKIN2=ROU*X(NP1)
C
      CALL INTEG(DX,S3,X,NP1)
      TSKIN3=ROU*X(NP1)
C
      TEFFL=DT*WFLX*EF
C
      CALL INTEG(DX,SIR,X,NP1) 
      TSIR=ROU*X(NP1)
      BAL=(TEFFL+TSKIN1+TSKIN2+TSKIN3+TSIR+TSEQ+TSWATR)*100.0D0/SINP 
  50  WRITE(6,200) SINP,TSWATR,TSEQ,TSKIN1,TSKIN2,TSKIN3,TSIR,TEFFL,BAL
      CONTINUE
C
 200  FORMAT(//,2X,'S A L T    B A L A N C E:',//
     &7X, 'TOTAL INPUT SOLUTE FROM PULSE      (MG) = ',F10.4,/
     &7X, 'TOTAL SOLUTE SOIL SOLUTION PHASE   (MG) = ',F10.4,/,
     &7X, 'TOTAL SORBED IN (EQUILIB) PHASE SE (MG) = ',F10.4,/,
     &7X, 'TOTAL SORBED IN (KINETIC) PHASE S1 (MG) = ',F10.4,/,
     &7X, 'TOTAL SORBED IN (KINETIC) PHASE S2 (MG) = ',F10.4,/,
     &7X, 'TOTAL SORBED IN (KINETIC) PHASE S3 (MG) = ',F10.4,/,
     &7X, 'TOTAL SORBED IN IRREVERSIBLE PHASE (MG) = ',F10.4,/,
     &7X, 'TOTAL SORBED IN THE EFFLUENT       (MG) = ',F10.4,/,
     &7X, 'MASS BALANCE (CALC.OUTPUT/INPUT)    (%) = ',F10.4,/)
 300  FORMAT(//,
     $2X, 'INPUT PARAMETERS   :',//
     $5X,'1.  MOISTURE CONTENT, CM3/CM3            (TH) = ',F10.5,/
     $5X,'2.  BULK DENSITY, G/CM3                 (ROU) = ',F10.5,/
     $5X,'3.  COLUMN LENGTH, CM                   (COL) = ',F10.5,/
     $5X,'4.  WATER FLUX, CM/HOUR                (WFLX) = ',F10.5,/
     $5X,'5.  INITIAL CONCENTRATION, MG/L          (CI) = ',F10.5,/
     $5X,'6.  CONCEN.IN INPUT PULSE, MG/L          (CS) = ',F10.5,/
     $5X,'7.  DISPERSION COEFFICIENT, CM2/HR        (D) = ',F10.5,/
     $5X,'8.  FOWARD RATE REACTION, K1,HR-1        (K1) = ',F10.5,/
     $5X,'9.  BACKWARD RATE REACTION, K2,HR-1      (K2) = ',F10.5,/
     $4X,'10.  NONLINEAR KINETIC PARAMETER, W,      (W) = ',F10.5,/
     $4X,'11.  FORWARD RATE REACTION, K3/HR-1      (K3) = ',F10.5,/
     $4X,'12.  BACKWARD RATE REACTION, K4/HR-1     (K4) = ',F10.5,/
     $4X,'13.  NONLINEAR KINETIC PARAMETER, U,      (U) = ',F10.5,/
     $4X,'14.  IRREVERSIBLE REACTION RATE, KS/HR-1 (KS) = ',F10.5,/)
 310  FORMAT(
     $4X,'15. FORWARD RATE REACTION, K5,HR-1  (K5) = ',F10.5,/
     $4X,'16. BACKWARD RATE REACTION, K6,HR-1  (K6) = ',F10.5,/
     $4X,'17. NUMBER OF ITERATIONS             (IT) = ',I10.5,/
     $4X,'18. DISTRIBUTION COEFFICIENT FOR EQUILIBRIUM',/
     $4X,'           SORPTION, KD, CM3/G       (KD) = ',F10.5,/
     $4X,'19. NONLINEAR PARAMETER FOR EQUILIBRIRUM',/
     $4X,'           Mechanism, NEQ            (NEQ) = ',F10.5,/
     $4X,'20. INPUT PULSE DURATION, HR     (TPULSE) = ',F10.5,/
     $4X,'21. TOTAL SIMULATION TIME, HR    (TTOTAL) = ',F10.5,/
     $4X,'22. PRINTOUT TIME DESIRED,HR     (TPRINT) = ',F10.5,////)
 400  FORMAT(2X, 'THE INCREMENTS USED WERE : ',//
     $5X,'1. SIMULATION DEPTH INTERVAL, CM  (DX)=',F10.5,/
     $5X,'2. INCREMENTAL TIME STEP,HR       (DT)=',F10.5,///)
 500  FORMAT(/////////,
     $2X'S I M U L A T I O N    T I M E (HOUR) = ',F8.2/)
 525  FORMAT(
     $2X'PORE VOLUMES (V/V0) = ',F10.2,8X,'REL. CONCENTRATION (C/C0) =',
     &F8.4)
 550  FORMAT(///1H, 72(1H*)//1H, 20X, 'CONCENTRATION DISTRIBUTION',
     *//1H , 172(1H*)//1H, 2X,
     *'DEPTH  SOLUT EQUIL  KINETIC  KINETIC  KINETIC  IRREV.
     *TOTAL'/, 9X, 'CONC.', 4X,
     *'PHASE  PHASE 1  PHASE 2  PHASE 3  SINK  SORBED'/,
     *'  X       C       SE       S1      S2      S3      SIR
     *     S'//,1X
     1,'   CM  ',2X,'--MG/L--',2X,
     1'--------------------- MG/KG ---------------------'/)
 600  FORMAT(1X,F6.2,1X,F9.4,1X,F8.4,1X,F8.3,
     *1X,3(F9.3,1X),F7.3)
 650  FORMAT(/////,2X,'SIMULATIONS ARE NOW COMPLETE UP TO',///,5X,
     $'S I M U L A T I O N   T I M E  (HOUR) = ',F8.2,//2X,
     $'PORE VOLUMES (V/V0) = ',F10.2,8X,'REL CONCENTRATION (C/C0)=',
     &F8.4//)
 700  FORMAT(50X, E10.6)
 750  FORMAT(50X,I3)
 800  FORMAT(A64)
 900  FORMAT(F12.0)
 950  FORMAT(I1)
      WRITE(*,*)
      WRITE(*,*)  '------ Requested Simulations Completed ------'
      WRITE(*,*)
      WRITE(*,*) '------- MRTM TERMINATED SUCCESSFULLY -------'
      WRITE(*,*) 
      WRITE(*,*) '------- THANK YOU FOR USING MRTM --------'
      END
C
C
C     **************************************************************
C     SUBROUNTINE SMRTM GIVES A SOLUTION OF THE FINITE DIFFERENCE EQ.
C     OF THE CONVECTIVE-DISPERSION AND MULTIREACTION SYSTEM
C     ***************************************************************
C
      SUBROUTINE SMRTM
      IMPLICIT REAL*8 (A-H,O-Z)
      COMMON/LI/ C(101),DC(101),DU(101),DL(101),E(101),S1(101),S2(101)
      COMMON/L2/ SIR(101),CX(101),S1X(101),S2X(101)
      COMMON/L3/ X(101) ,S3(101) ,S3X(101)
      COMMON/L4/ TH,ROU,COL,WFLX,CI,CS,D,K1,K2,W,K3,K4,U,KS,K5,K6,KD 
      COMMON/L5/ NEQ,IT,N,NM1,NP1
      COMMON/L6/ TPULSE,TTOTAL,TPRINT,DT,DX,GAMMA,BETA
      REAL*8 K1,K2,K3,K4,K5,K6,KS,KD,NEQ
C
C
      FF=2*DX
      PV=WFLX/TH
      RS=NEQ*ROU*KD/TH
      C(1)=(WFLX*FF*CS+D*TH*C(3))/(WFLX*FF+D*TH)
      DO 35 IJ=1,IT
      M=2
      DO 10 I=1,NM1
      DC(I) =1.0D0+2.D0*GAMMA*D-BETA*PV
      DU(I)=BETA*PV-GAMMA*D
      E(I)=C(M)+GAMMA*D*(C(M+1) -2.0D0*C(M) + C(M-1)) 
      DL(I)=-GAMMA*D
      M=I+2
  10  CONTINUE
      M=N
      DC(NM1)=1.D0+GAMMA*D
      E(1)=E(1)+GAMMA*D*C(1)
C
C     INCORPORATION OF NONLINEAR KINETIC AND EQUILIBRIUM PROCESSES
C     (REVERSIBLE) IN MAIN DIAGONAL ELEMENTS AND RHS VECTOR
C
      DO 20 I=1,NM1
      DC(I)=DC(I)+DT*KS/2
      R=0.0D0
      H1=0.0D0
      H2=0.0D0
      IF((C(I+1).LT.1.0D-4) .OR. (CX(I+1).LE.1.0D-4)) GO TO 15
      R =RS*(0.50D0*(C(I+1)+CX(I+1)))**(NEQ-1.0D0)
      H1=(0.50D0*(C(I+1)+CX(I+1)))**W
      H2=(0.50D0*(C(I+1)+CX(I+1)))**U
  15  DC(I)=DC(I)+R
      E(I)=E(I)-DT*(K1*H1-K2*(ROU/TH)*(S1(I+1)+S1X(I+1))/2)
     &-DT*(K3*H2-K4*(ROU/TH)*(S2(I+1)+S2X(I+1))/2)
  20  E(I)=E(I)+C(I+1)*R-DT*(KS/2)*((C(I+1)+CX(I+1))/2)
C
      CALL TRIDM(DC,DU,DL,E,NM1)
      DO 25 I=2,N
  25  CX(I)=E(I-1) 
      CX(NP1)=CX(N)
      CX(1)=C(1)
      DO 30 I=1,NP1
      H1=0.0D0
      H2=0.0D0
      IF(C(I).GT.1.0D-4) H1=((C(I)+CX(I))/2)**W
      IF(C(I).GT.1.0D-4) H2=((C(I)+CX(I))/2)**U
      S1X(I) =S1(I)+ DT*(K1*(TH/ROU)*H1-K2*(S1(I)+S1X(I))/2)
      S2X(I) =S2(I) + DT*K3*(TH/ROU)*H2-(K4+K5)*DT*(S2(I)+S2X(I))/2
     $+DT*K6*S3(I)
  30  CONTINUE 
  35  CONTINUE
C
C
      DO 50 I=1, NP1 
      C(I)=CX(I) 
      S1(I)=S1X(I) 
      S2(I)=S2X(I)
      S3(I)=S3(I)+DT*K5*S2(I) 
     $-DT*K6*S3(I)
  50  SIR(I)=SIR(I) + DT*KS*(TH/ROU)*C(I) 
      RETURN
      END
C
C     *****************************************************************
C     SUBROUNTINE TRIDM GIVES A SOLUTION OF A TRIDIAGONAL MATRIX-VECTOR
C     EQUATION USING THOMAS ALGORITHM
C     ***************************************************************
C
      SUBROUTINE TRIDM(A,B,C,D,N)
      IMPLICIT REAL*8(A-H,O-Z)
      DIMENSION A(N),B(N),C(N),D(N)
      DO 1 I=2,N 
      C(I)=C(I)/A(I-1) 
      A(I)=A(I)-(C(I)*B(I-1))
   1  CONTINUE
      DO 2 I=2, N 
      D(I)=D(I)-(C(I)*D(I-1)) 
   2  CONTINUE
      D(N)=D(N)/A(N)
      DO 3 I=2, N
      D(N+1-I)=(D(N+1-I)-(B(N+1-I)*D(N+2-I)))/A(N+1-I)
   3  CONTINUE
      RETURN
      END
C
C     *****************************************************************
C     SUBROUNTINE INTEG PERFORMS INTEGRATION OF A TABULAR FUNCTION Y
C     GIVEN AT EQUAL DISTANCES H USING TRAPEZOIDAL RULE
C     ***************************************************************
C
      SUBROUTINE INTEG(H,Y,Z,N) 
      IMPLICIT REAL*8(A-H,O-Z) 
      DIMENSION Y(N),Z(N) 
      S2=0.0D0
      IF(N-1) 40,30,10
  10  HH=H/2.0D0 
      DO 20 I=2,N
      S1=S2 
      S2=S2+HH*(Y(I)+Y(I-1)) 
  20  Z(I-1)=S1
  30  Z(N)=S2 
  40  RETURN 
      END

这是输入文件:

1.  MOISTURE CONTENT,CM3/CM3             (TH) =   0.400E00
2.  BULK DENSITY,G/CM3                  (ROU) =   1.250E00
3.  COLUMN LENGTH,CM                    (COL) =   10.000E00
4.  WATER FLUX,CM/HR                   (WFLX) =   1.000E00
5.  INITIAL CONCENTRATION,MG/L           (CI) =   0.000E00
6.  CONCEN.IN INPUT PULSE, MG/L          (CS) =   10.000E00
7.  DISPERSION COEFFICIENT,D,CM2/HR       (D) =   1.000E00
8.  DISTRIB. COEFF.FOR EQL. SORP,CM3/G   (KD) =   1.000E00
9.  NONLINEAR PARAM.FOR EQUL. MECH.     (NEQ) =   1.000E00
10. FORWARD RATE REACTION, K1,HR-1       (K1) =   0.100E00
11. BACKWARD RATE REACTION, K2,HR-1      (K2) =   0.100E00
12. NONLINEAR KINETIC PARAMETER, W,       (W) =   0.500E00
13. FORWARD RATE REACTION, K3,HR-1       (K3) =   0.000E00
14. BACKWARD RATE REACTION, K4,HR-1      (K4) =   0.000E00
15. NONLINEAR KINETIC PARAMETER, U,       (U) =   0.000E00
16. IRREVERSIBLE REACTION RATE,KS,HR-1   (KS) =   0.000E00
17. FORWARD RATE REACTION, K5,HR-1       (K5) =   0.000E00
18. BACKWARD RATE REACTION, K6,HR-1      (K6) =   0.000E00
19. NUMBER OF ITERATIONS (M)             (IT) = 000
20. INPUT PULSE DURATION,HR          (TPULSE) =  12.000E00
21. TOTAL SIMULATION TIME,HR         (TTOTAL) =  16.000E00
22. PRINTOUT TIME DESIRED,HR         (TPRINT) =   4.000E00
23. INCREMENTAL TIME STEP,HR             (DT) =   0.200E00
24. INCREMENTAL DEPTH, CM                (DX) =   1.000E00

我收到的错误:

Ms-MacBook-Pro-2:~ Tonoy$ gfortran mrtm.f
Ms-MacBook-Pro-2:~ Tonoy$ ./a.out
 PLEASE ENTER USER NAME (OPTIONAL):
rm
  PLEASE ENTER NAME OF SOIL (OPTIONAL):
bd
  PLEASE ENTER NAME OF SOLUTE (OPTIONAL):
cr
  ENTER DATE OR OTHER IDENTIFICATION (OPTIONAL):
2015

 --------- INPUT PARAMETERS SECTION -------------

  INPUT PARAMETERS CAN BE PROVIDED IN TWO WAYS; 
   ENTER 1 if you wish to enter the input data using
                the keyboard (i.e. interactively) 

      OR 

      ENTER 2 if an input data file is to be provided 
        PLEASE ENTER EITHER 1 OR 2
2
 PLEASE ENTER NAME OF INPUT FILE?
 (for example A:XX.DAT or C:UU.DAT for hard disk)
input.DAT
PLEASE ENTER NAME OF THE OUTPUT FILE (FOR EXAMPLE   B:ZZ.DAT)
At line 173 of file mrtm.f (unit = 5, file = 'input.DAT')
Fortran runtime error: End of file

Error termination. Backtrace:
#0  0x10c688729
#1  0x10c6893f5
#2  0x10c689b59
#3  0x10c751f8b
#4  0x10c752527
#5  0x10c74f5c3
#6  0x10c7545b4
#7  0x10c679590
#8  0x10c67b2a0
Ms-MacBook-Pro-2:~ Tonoy$ 

给出输入的预期结果应给出(16小时内的前8小时): enter image description here enter image description here

1 个答案:

答案 0 :(得分:0)

在Unix机器上的FORTRAN约定中,当程序统计时,单元5连接到标准输入。

第45行的声明

OPEN(5,FILE=FNAMEI)

碰巧断开标准输入并将输入文件附加到标准输入,以便后续READ(*,FORMAT)语句尝试从此文件读取并遇到其结束。这会导致您报告的输入/输出错误。

如果您在评论中遵循建议given by francescalus,并将第45行和第48-56行的第5单元替换为第15单元,则此错误将消失。

如果使用选项suggested by Vladimir进行编译,即

gfortran -Wall -g -fbacktrace -fcheck=all mrtm.for -o mrtm

程序运行完成并产生一些输出。

:~> ./mrtm 
 PLEASE ENTER USER NAME (OPTIONAL):
rm
  PLEASE ENTER NAME OF SOIL (OPTIONAL):
bd
  PLEASE ENTER NAME OF SOLUTE (OPTIONAL):
cr
  ENTER DATE OR OTHER IDENTIFICATION (OPTIONAL):
2015

 --------- INPUT PARAMETERS SECTION -------------

  INPUT PARAMETERS CAN BE PROVIDED IN TWO WAYS; 
   ENTER 1 if you wish to enter the input data using
                the keyboard (i.e. interactively) 

      OR 

      ENTER 2 if an input data file is to be provided 
        PLEASE ENTER EITHER 1 OR 2
2
 PLEASE ENTER NAME OF INPUT FILE?
 (for example A:XX.DAT or C:UU.DAT for hard disk)
input.dat
PLEASE ENTER NAME OF THE OUTPUT FILE (FOR EXAMPLE   B:ZZ.DAT)
zz.dat

如果没有-fcheck=all,则程序会因第253行的Segmentation fault - invalid memory reference而失败。