不读取输入文件以运行压力自相关函数

时间:2015-08-30 17:43:33

标签: fortran fortran90

我正在尝试运行压力自相关函数代码来计算应力自相关函数,然后从那里我想用Green -Kubo方程计算粘度。现在我的Fortran代码没有读出我的压力数据来计算压力auot-correlarion函数。有人可以帮我这个。我附上了我想要关联的代码和数据。希望你早日来到这里。

这是错误

./a.out
**** Program Stress_autocorrelation ****
Calculation of time Correlation Functions
Enter data file name
DFILE
Enter results file name
RFILE
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
At line 106 of file main.f95 (unit = 10, file = 'DFILE')
Fortran runtime error: Bad value during floating point read      

代码及以下是输入数据:

  ! Program to claculate pressure autocorrelation function

    program stress_autocorrelation
      implicit none

    common / block1 / STORA, STORB, STORC, STORD,STORE,STORF,STORG, STORH, STORI
    common / block2 / PA, PB, PC, PD, PE, PF, PG, PH , PI
    common / block3 / PACF, ANORM

    ! *******************************************************************
    ! ............  PRINCIPAL VARIABLES............
    !
    ! ** integer  N               Number of atoms
    ! ** integer  NSTEP           Number of  steps on the tape
    ! ** integer  IOR             Interval for time origins
    ! ** integer  NT              Correlation length, Including T=0
    ! ** integer  NTIMOR          Number of time origin
    ! ** integer  NLABEL          Label for step (1,2,3.....Nstep)
    !
    !
    ! ** real PACF(NT)            The pressure correlation function
    ! ** NSTEP and NT should be multiples of IOR.
    ! ** PA,PB,PC = Pxx,Pxy,Pxz
    ! ** PD,PE,PF = Pyx,Pyy,Pyz
    ! ** PG,PH,PI = Pzx,Pzy,Pzz
    !
    !
    ! ...............ROUTINES REFERENCED..........................
    !
    ! ....Subroutine Store (J1)..........
    !Routine to store the data for correlation
    ! .....Subroutine Corr (J1,J2,IT).........
    !Routine to correlate the stored time origin
    !
    !
    ! .....................USAGE..............................
    !
    ! Data in file DFILE on fortrran UNIT DUNIT
    ! Results in File RFILE on fortran UNIT RUNIT
    ! *******************************************************************

    integer N, NSTEP, IOR, NT, NDIM, DUNIT, RUNIT, NTIMOR
    integer FULLUP
    parameter ( N = 78, NSTEP = 10, IOR = 4, NT = 8 )
    parameter ( DUNIT = 10, RUNIT = 11 )
    parameter ( NDIM = NT / IOR + 1, NTIMOR = NSTEP / IOR )
    parameter ( FULLUP = NDIM - 1 )


    real PA(N), PB(N), PC(N), PD(N), PE(N), PF(N), PG(N), PH(N), PI(N)
    real STORA(NDIM,N), STORB(NDIM,N), STORC(NDIM,N),STORD(NDIM,N), STORE(NDIM,N),STORF(NDIM,N),STORG(NDIM,N),STORH(NDIM,N)
    real STORI(NDIM,N)
    REAL PACF(NT), ANORM(NT)

    integer S(NTIMOR), TM(NTIMOR)
    integer TS, TSS, L, NINCOR, K, R, JA, IB, IN, IA, JO, I
    integer NLABEL

    character DUMMY * 5
    character DFILE * 115
    character RFILE * 115

    ! *******************************************************************

    write(*,'('' **** Program Stress_autocorrelation **** '')')
    write(*,'('' Calculation of time Correlation Functions '')')

    !.....READ IN FILE NAMES.........

    write(*,'('' Enter data file name'')')
    read (*,'(A)') DFILE
    write (*,'('' Enter results file name'')')
    read (*,'(A)') RFILE

    !......INITIALIZE COUNTERS.......

    NINCOR = FULLUP
    JA = 1
    IA = 1
    IB = 1

    !........ZERO ARRAYS.............

    do 5 I = 1, NT
    PACF(I) = 0.0
    ANORM(I) = 0.0
    write(*,*) PACF(I)
    5 continue


    !..........OPEN DATA FILE AND RESULTS FILE...........

    open ( UNIT = DUNIT, FILE = DFILE, STATUS = 'OLD', FORM = 'FORMATTED')

    open ( UNIT = RUNIT, FILE = RFILE, STATUS = 'NEW' )

    !.........CALCULATION BEGINS............

    do 40 L = 1, NTIMOR

    JA = JA + 1
    S(L) = JA - 1

    read ( DUNIT, '(A5,I4)') DUMMY, NLABEL
    do 7 R = 1, N
    read (DUNIT,'(F9.6,8(9X,F9.6))')PA(R),PB(R),PC(R),PD(R),PE(R),PF(R),PG(R),PH(R),PI(R)
    7 continue

    TM(L) = NLABEL
    write(*,*) TM(L)

    !.......STORE STEP AS A TIME ORIGIN......

    call STOREE ( JA )

    !........CORRELATE THE ORIGINS IN STORE......

    do 10 IN = IA, L

    TSS = TM(L) - TM(IN)
    TS = TSS + 1
    JO = S(IN) + 1
    call CORR ( JO, JA, TS )

    10 continue

    !Read IN data between time origins. This can
    !Be conveniently stored IN element 1 of the
    !Array storx etc. and can then ben correlated
    !With the time origins

    do 30 K = 1, IOR - 1

    read ( DUNIT, '(A5,I4)') DUMMY, NLABEL
    do 15 R = 1, N
    read ( DUNIT,'(F17.14,8(13X,F17.14))')PA(R),PB(R),PC(R),PD(R),PE(R),PF(R),PG(R),PH(R),PI(R)
    15 continue

    call STOREE ( 1 )

    do 20 IN = IA, L

    TSS = NLABEL - TM(IN)
    TS = TSS + 1
    JO = S(IN) + 1
    call CORR ( JO, 1, TS )

    20 continue

    30 continue

    if ( L .GE. FULLUP ) then
    if ( L .EQ. NINCOR ) then
    NINCOR = NINCOR + FULLUP
    JA = 1
    endif

    IA = IA + 1

    endif

    40 continue

    close ( DUNIT )

    !.....NORMALISE CORRELATION FUNCTIONS.......

    PACF(1) = PACF(1) / ANORM(1) / REAL ( N )

    do 50 I = 2, NT

    PACF(I) = PACF(I) / ANORM(I) / REAL ( N ) / PACF(1)

    50 continue

    write ( RUNIT, '('' Pressure ACF '')')
    write ( RUNIT, '(I6,E15.6)') ( I, PACF(I), I = 1, NT )

    close ( RUNIT )

    stop
    end



    subroutine STOREE ( J1 )
    common / BLOCK1 / STORA, STORB, STORC, STORD,STORE,STORF,STORG,STORH,STORI
    common/ BLOCK2 / PA, PB, PC, PD, PE, PF, PG, PH, PI


    ! *******************************************************************
    !.........SUBROUTINE TO STORE TIME ORIGINS..............
    ! *******************************************************************


    integer J1
    integer N, NT, IOR, NDIM
    parameter ( N = 78, NT = 8, IOR =4 )
    parameter ( NDIM = NT / IOR + 1 )

    real STORA(NDIM,N), STORB(NDIM,N), STORC(NDIM,N),STORD(NDIM,N)
    real STORE(NDIM,N),STORF(NDIM,N),STORG(NDIM,N),STORH(NDIM,N),STORI(NDIM,N)
    real PA(N), PB(N), PC(N), PD(N), PE(N), PF(N),PG(N), PH(N), PI(N)
    integer I


    do 10 I = 1, N

    STORA(J1,I) = PA(I)
    STORB(J1,I) = PB(I)
    STORC(J1,I) = PC(I)
    STORD(J1,I) = PD(I)
    STORE(J1,I) = PE(I)
    STORF(J1,I) = PF(I)
    STORG(J1,I) = PG(I)
    STORH(J1,I) = PH(I)
    STORI(J1,I) = PI(I)
    10 continue

    return
    end


    subroutine CORR ( J1, J2, IT )
    common / block1 / STORA, STORB, STORC, STORD,STORE,STORF,STORG,STORH,STORI
    common/ block3 / PACF, ANORM

    ! *******************************************************************
    !......SUBROUTINE TO CORRELATE TIME ORIGINS....
    ! *******************************************************************

    integer J1, J2, IT
    integer N, NT, IOR, NDIM
    parameter ( N = 78, NT = 8, IOR = 4 )
    parameter ( NDIM = NT / IOR + 1 )

    real STORA(NDIM,N), STORB(NDIM,N), STORC(NDIM,N),STORD(NDIM,N)
    real STORE(NDIM,N),STORF(NDIM,N),STORG(NDIM,N),STORH(NDIM,N),STORI(NDIM,N)

    real PACF(NT), ANORM(NT)
    integer I

    !********************************************************************

    do 10 I = 1, N

    PACF(IT) = PACF(IT) + STORA(J1,I) * STORA(J2,I) &
                        + STORB(J1,I) * STORB(J2,I) &
                        + STORC(J1,I) * STORC(J2,I) &
                        + STORD(J1,I) * STORD(J2,I) &
                        + STORE(J1,I) * STORE(J2,I) &
                        + STORF(J1,I) * STORF(J2,I) &
                        + STORG(J1,I) * STORG(J2,I) &
                        + STORH(J1,I) * STORH(J2,I) &
                        + STORI(J1,I) * STORI(J2,I)
    10 continue

    ANORM(IT) = ANORM(IT) + 1.0

    return
    end

数据:有9列

        -9.568336E+00 -1.615161E+00 1.042644E+00 -1.615161E+00 -1.131916E+01 -6.979813E-01 1.042644E+00 -6.979813E-01 -1.182917E+01
        -4.765572E-01 9.005122E-01 -2.282920E+00 9.005122E-01 -3.827857E+00 -3.206736E+00 -2.282920E+00 -3.206736E+00 -6.252462E+00
        -1.012710E+01 4.672368E-01 8.791873E-02 4.672368E-01 -4.680832E+00 -5.271814E-01 8.791873E-02 -5.271814E-01 -1.898345E-01
        -7.699012E+00 -9.906154E-01 7.450304E-01 -9.906154E-01 -1.061230E+00 -3.546956E+00 7.450304E-01 -3.546956E+00 -6.843898E+00
        -3.544260E+00 4.254020E+00 -1.963602E+00 4.254020E+00 3.740858E+00 -4.587760E+00 -1.963602E+00 -4.587760E+00 -6.776258E+00
        1.755595E-01 -9.625855E-01 -2.395960E+00 -9.625855E-01 -1.701399E+00 -8.483695E-01 -2.395960E+00 -8.483695E-01 -4.165223E+00
        -3.244186E+00 5.540608E+00 -4.951768E-01 5.540608E+00 3.068601E+00 -1.613010E-01 -4.951768E-01 -1.613010E-01 -5.641277E+00
        -8.985849E+00 1.870244E+00 -2.295795E-01 1.870244E+00 -4.635924E+00 -4.787461E+00 -2.295795E-01 -4.787461E+00 -3.014272E+00
        -1.651073E-01 -6.326584E-01 -3.028051E+00 -6.326584E-01 -2.621833E+00 -2.640439E+00 -3.028051E+00 -2.640439E+00 1.668877E+00
        1.250349E+00 3.054784E+00 -2.898975E+00 3.054784E+00 8.419503E-01 9.620184E-01 -2.898975E+00 9.620184E-01 1.479256E+00
        -7.796195E-01 1.942983E+00 -2.736569E+00 1.942983E+00 6.073043E+00 -2.520281E+00 -2.736569E+00 -2.520281E+00 -9.600832E-01
        4.697066E-01 3.138124E+00 -1.092573E+00 3.138124E+00 -2.099285E+00 -1.581031E+00 -1.092573E+00 -1.581031E+00 -6.285002E-01
        3.017532E-01 -9.701574E-02 1.611936E+00 -9.701574E-02 -1.762075E+00 -3.401961E+00 1.611936E+00 -3.401961E+00 -6.889746E-01
        1.177410E-01 5.090611E-01 1.452691E-01 5.090611E-01 5.695570E+00 -3.573245E+00 1.452691E-01 -3.573245E+00 -1.099615E+00
        -5.180126E+00 -1.876409E-01 -2.067182E+00 -1.876409E-01 1.611177E+00 5.458450E-01 -2.067182E+00 5.458450E-01 1.026071E+00
        1.477567E+00 1.598949E+00 -1.577546E+00 1.598949E+00 3.933810E+00 -2.698132E+00 -1.577546E+00 -2.698132E+00 3.485029E+00
        -2.533324E+00 1.753033E+00 1.425241E-01 1.753033E+00 2.406501E+00 -1.147217E+00 1.425241E-01 -1.147217E+00 3.065603E-01
        -2.360274E+00 1.312721E+00 -3.711419E-01 1.312721E+00 2.556935E+00 3.152605E-01 -3.711419E-01 3.152605E-01 3.378170E+00
        -1.698217E+00 1.105760E+00 3.780822E-01 1.105760E+00 2.736574E+00 7.920578E-01 3.780822E-01 7.920578E-01 -6.596856E-01
        -5.099544E+00 1.647542E-01 -1.036544E+00 1.647542E-01 3.845429E+00 -1.034068E+00 -1.036544E+00 -1.034068E+00 -3.152053E+00
        -2.686567E+00 1.335786E+00 -1.889911E-01 1.335786E+00 9.755267E-01 9.322043E-01 -1.889911E-01 9.322043E-01 3.229615E-01
        1.542994E-01 3.104663E+00 -1.634353E-01 3.104663E+00 4.090105E+00 -1.128244E+00 -1.634353E-01 -1.128244E+00 -2.909383E-01
        -4.235419E-01 1.554157E+00 3.475430E+00 1.554157E+00 4.701173E+00 -1.789414E+00 3.475430E+00 -1.789414E+00 1.517218E+00
        -8.054924E-01 -1.167935E+00 -1.123460E+00 -1.167935E+00 1.169303E+00 -2.171076E+00 -1.123460E+00 -2.171076E+00 -5.636150E+00

0 个答案:

没有答案