LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-19-2011, 10:21 AM   #1
fu3lc3ll$
LQ Newbie
 
Registered: May 2011
Posts: 6

Rep: Reputation: Disabled
Post Help with fortran program--encountered run time error


Hi, i am graduate student and my X colleague gave me this Fortran 77 program to run my result files with. She is no longer reachable. I compiled the following program with gfortran, it compiled well but, when i run it, gave me end of file error. My output file (which is the input file for this program (DFILE1) ) has about 78,000 lines of velocities of atoms (Vx, Vy, Vz with 1000 steps.. an example of some of the atom's velocities in the 1st step is given at the end of this program). I will be highly obliged if any one can help me with this. Thanks in advance.
I run this program on opensuse linux 11.3 version /32 bit/i586

error message:
Code:
 At line 124 of file v.autocorrelation.f (unit = 10, file = 'DFILE1')
 Fortran runtime error: End of file
Code:
      PROGRAM TCORR

      COMMON / BLOCK1 / STORX, STORY, STORZ
      COMMON / BLOCK2 / VX, VY, VZ
      COMMON / BLOCK3 / VACF, ANORM

C *******************************************************************
C ** CALCULATION OF TIME CORRELATION FUNCTIONS. **
C ** **
C ** THIS PROGRAM ANALYZES DATA TO CALCULATE A TIME CORRELATION **
C ** FUNCTION IN ONE SWEEP (LOW MEMORY REQUIREMENT). IN THIS **
C ** EXAMPLE THE VELOCITY AUTO-CORRELATION FUNCTION IS CALCULATED. **
C ** **
C ** PRINCIPAL VARIABLES: **
C ** **
C ** INTEGER N NUMBER OF ATOMS
C ** INTEGER NSTEP NUMBER OF STEPS ON THE TAPE
C ** INTEGER IOR INTERVAL FOR TIME ORIGINS
C ** INTEGER NT CORRELATION LENGTH, INCLUDING T=0
C ** INTEGER NTIMOR NUMBER OF TIME ORIGINS
C ** INTEGER NLABEL LABEL FOR STEP (1,2,3...NSTEP)
C ** REAL VX(N),VY(N),VZ(N) VELOCITIES
C ** REAL VACF(NT) THE CORRELATION FUNCTION
C ** NSTEP AND NT SHOULD BE MULTIPLES OF IOR.

C ** ROUTINES REFERENCED:
C ** **
C ** SUBROUTINE STORE (J1)
C ROUTINE TO STORE THE DATA FOR CORRELATION **
C SUBROUTINE CORR ( J1, J2, IT )
C ROUTINE TO CORRELATE THE STORED TIME ORIGINS **
C USAGE: **
C ** **
C DATA IN FILE DFILE ON FORTRAN UNIT DUNIT. **
C RESULTS IN FILE RFILE ON FORTRAN UNIT RUNIT. **
C *******************************************************************

      INTEGER N, NSTEP, IOR, NT, NDIM, DUNIT, RUNIT, NTIMOR
      INTEGER FULLUP
      PARAMETER ( N = 78, NSTEP = 1000, IOR = 4, NT = 200 )
      PARAMETER ( DUNIT = 10, RUNIT = 11 )
      PARAMETER ( NDIM = NT / IOR + 1, NTIMOR = NSTEP / IOR )
      PARAMETER ( FULLUP = NDIM - 1 )

      REAL VX(N), VY(N), VZ(N)
      REAL STORX(NDIM,N), STORY(NDIM,N), STORZ(NDIM,N)
      REAL VACF(NT), ANORM(NT)
      INTEGER S(NTIMOR), TM(NTIMOR)
      INTEGER TS, TSS, L, NINCOR, K, JA, IB, IN, IA, JO, I
      INTEGER NLABEL
      CHARACTER DFILE * 30
      CHARACTER RFILE * 30

C *******************************************************************

      WRITE(*,'('' **** PROGRAM TCORR **** '')')
      WRITE(*,'('' CALCULATION OF TIME CORRELATION FUNCTIONS '')')

C ** READ IN FILE NAMES **

      WRITE(*,'('' ENTER DATA FILE NAME '')')
      READ (*,'(A)') DFILE
      WRITE (*,'('' ENTER RESULTS FILE NAME '')')
      READ (*,'(A)') RFILE

C ** INITIALIZE COUNTERS **

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

C ** ZERO ARRAYS **

      DO 5 I = 1, NT

      VACF(I) = 0.0
      ANORM(I) = 0.0
      write(*,*) VACF(I)
    5 CONTINUE


C ** OPEN DATA FILE AND RESULTS FILE **

      OPEN ( UNIT = DUNIT, FILE = DFILE, ACCESS = 'SEQUENTIAL',
     : STATUS = 'OLD', FORM = 'UNFORMATTED' )

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

C ** CALCULATION BEGINS **

      DO 40 L = 1, NTIMOR

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

      READ ( DUNIT ) NLABEL, VX, VY, VZ

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

C ** STORE STEP AS A TIME ORIGIN **
      CALL STORE ( JA )

C ** 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

C ** READ IN DATA BETWEEN TIME ORIGINS. THIS CAN **
C ** BE CONVENIENTLY STORED IN ELEMENT 1 OF THE **
C ** ARRAYS STORX ETC. AND CAN THEN BE CORRELATED **
C ** WITH THE TIME ORIGINS. **

      DO 30 K = 1, IOR - 1

      READ ( DUNIT ) NLABEL, VX, VY, VZ

      CALL STORE ( 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 )

C ** NORMALISE CORRELATION FUNCTIONS **

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

      DO 50 I = 2, NT

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

   50 CONTINUE

      WRITE ( RUNIT, '('' VELOCITY ACF '')')
      WRITE ( RUNIT, '(I6,E15.6)') ( I, VACF(I), I = 1, NT )

      CLOSE ( RUNIT )

      STOP
      END



      SUBROUTINE STORE ( J1 )

      COMMON/ BLOCK1 / STORX, STORY, STORZ
      COMMON/ BLOCK2 / VX, VY, VZ

C *******************************************************************
C ** SUBROUTINE TO STORE TIME ORIGINS **
C *******************************************************************

      INTEGER J1
      INTEGER N, NT, IOR, NDIM
      PARAMETER ( N = 78, NT = 200, IOR =4 )
      PARAMETER ( NDIM = NT / IOR + 1 )

      REAL STORX(NDIM,N), STORY(NDIM,N), STORZ(NDIM,N)
      REAL VX(N), VY(N), VZ(N)
      INTEGER I


      DO 10 I = 1, N

      STORX(J1,I) = VX(I)
      STORY(J1,I) = VY(I)
      STORZ(J1,I) = VZ(I)

   10 CONTINUE

      RETURN
      END



      SUBROUTINE CORR ( J1, J2, IT )

      COMMON/ BLOCK1 / STORX, STORY, STORZ
      COMMON/ BLOCK3 / VACF, ANORM

C *******************************************************************
C ** SUBROUTINE TO CORRELATE TIME ORIGINS **
C *******************************************************************

      INTEGER J1, J2, IT
      INTEGER N, NT, IOR, NDIM
      PARAMETER ( N = 78, NT = 200, IOR = 4 )
      PARAMETER ( NDIM = NT / IOR + 1 )

      REAL STORX(NDIM,N), STORY(NDIM,N), STORZ(NDIM,N)
      REAL VACF(NT), ANORM(NT)
      INTEGER I

C ********************************************************************

      DO 10 I = 1, N

      VACF(IT) = VACF(IT) + STORX(J1,I) * STORX(J2,I)
     : + STORY(J1,I) * STORY(J2,I)
     : + STORZ(J1,I) * STORZ(J2,I)

   10 CONTINUE

      ANORM(IT) = ANORM(IT) + 1.0

      RETURN
      END
SAMPLE OUTPUT FILE:
Code:
 STEP 1
  0.00000000000000        0.00000000000000        0.00000000000000
  0.00000000000000        0.00000000000000        0.00000000000000
  0.00000000000000        0.00000000000000        0.00000000000000
  0.00010703812381       -0.00017907303145        0.00012845544357
  0.00007086879372       -0.00020989410868       -0.00012629189678
 -0.00000514347034       -0.00032707162009       -0.00004409049289
  0.00010881028378       -0.00013028912781       -0.00026799460440
  0.00010384640076       -0.00022617983701        0.00011577020987
 -0.00015678637226        0.00005965340793        0.00005029434091
  0.00015091005383       -0.00035119896993        0.00014458338425
 -0.00004205347437        0.00029641535287       -0.00006770444703
  0.00011338315538        0.00013223598310        0.00014689456032
  0.00011067923208       -0.00009236400923       -0.00018006605952
  0.00016677654543        0.00007468766858       -0.00015708050793
 -0.00016800034306        0.00011715755585       -0.00005385990548
 -0.00012758947505        0.00034184939153       -0.00007527207307
  0.00016554976345       -0.00009563065736        0.00018662536130
 -0.00006948416537        0.00016769314119        0.00013296122527
 -0.00034022427066        0.00015155888921        0.00009935843630
 -0.00002290036769        0.00036132208826        0.00009322287779
 -0.00017492144969       -0.00009626061525       -0.00032768588604
  0.00002414332684        0.00028883133680        0.00003090088868
 -0.00016996529288       -0.00026967223565        0.00002331239997
 -0.00029563522200        0.00009852992182        0.00015414288839
  0.00024382505384        0.00002346883776       -0.00023879045369
 -0.00020625919333       -0.00008003782300       -0.00009528399534
  0.00038570317083        0.00010689841994       -0.00017293826161
  0.00004995896360       -0.00000340669559       -0.00002612357520
  0.00038439074731        0.00003253744541       -0.00022375122129
  0.00008312965358        0.00021757437537       -0.00014023499040
 -0.00026017680900       -0.00010531590550       -0.00012004661330
 -0.00008294077354       -0.00004230746251        0.00034237886167
  0.00019634060895        0.00010458542454        0.00015609080822
  0.00005835557701       -0.00007147979058        0.00010682626912
 -0.00030254724716       -0.00007214654468        0.00025565648907
  0.00022806230721       -0.00010430883203        0.00014991724863
 -0.00002282045675        0.00006863347916        0.00013350231732
  0.00034128092108       -0.00003642469066       -0.00010183704091

Last edited by colucix; 05-19-2011 at 02:03 PM.
 
Old 05-19-2011, 02:03 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Hi and welcome to LinuxQuestions! First an advice: to post a piece of code you can use the CODE tags that greatly improve the readability and preserve the original formatting (spaces and indentation) of the original code. Since I can do it, this time I have edited the post for you. To use CODE tags either switch to Advanced Mode and use the # button, or put code tags explicitly in your text like this:
[CODE]C *** This is a line of code[/CODE]
which results in
Code:
C *** This is a line of code
Regarding your question, the first thing catched by my eyes is:
Code:
      OPEN ( UNIT = DUNIT, FILE = DFILE, ACCESS = 'SEQUENTIAL',
     : STATUS = 'OLD', FORM = 'UNFORMATTED' )
which tries to open the input file as UNFORMATTED. This means a pure binary (not ASCII) file. Moreover the keyword SEQUENTIAL means it has to be created by another fortran program or at least every record stored into it should begin and terminate with a 32bit unsigned integer specifying the size in bytes of the record. Said that, does your input file matches this requirement or is it an ASCII file as in your example?


Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.

Last edited by colucix; 05-19-2011 at 02:07 PM.
 
1 members found this post helpful.
Old 05-20-2011, 02:51 AM   #3
fu3lc3ll$
LQ Newbie
 
Registered: May 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Hi, thanks a lot for the reply.
As for your question, i got the 'trajectory' file that stores the velocities and co ordinates of atoms in ASCII format and not in Binary.
 
Old 05-20-2011, 03:06 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Therefore you have to modify the code to read an ASCII file OR convert the ASCII to a sequential binary. The first option is the most straightforward. If in doubt about how to do that, please provide a detailed description of the input file structure. Eventually you can attach a gzipped input file (max size 256k) to your post (if allowed to your LQ account), so that we can take a closer look.
 
Old 05-20-2011, 08:24 AM   #5
fu3lc3ll$
LQ Newbie
 
Registered: May 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Post DFILE1.txt

Hi, thanks a lot for the reply.
After i read your post, i modified the code little bit and now the error i am getting is

At line 98 of file v.autocorrelation.f (unit = 10, file = 'DFILE1')
Fortran runtime error: Direct access data transfer requires record number
****************************************************
Modified part:
&&&&&&&&&&&&&&&&&&&&
** OPEN DATA FILE AND RESULTS FILE **

OPEN ( UNIT = DUNIT, FILE = DFILE, ACCESS = 'DIRECT',
: STATUS = 'OLD', FORM = 'FORMATTED',RECL = 78 )

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

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Please note that i have changed in OPEN access from "sequential" to 'direct' and unformatted to 'formatted' and added record length =78; I assumed the record length is length of single step or number of atoms, which in my case is 78. Is my assumption correct or do i need to see length of the real number in my file??if so, how do i do that??
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
I don't know where to add the record number in the code ?? what does record number mean?
step number??
&&&&&&&&&&&
P.S: Due to limit (256kB) in attaching file and my file size being 5Mb, i just copied and pasted 10 steps from my output file and attached here for your kind perusal.
thanks a lot.
Attached Files
File Type: txt DFILE.txt (52.2 KB, 56 views)

Last edited by fu3lc3ll$; 05-20-2011 at 08:53 AM. Reason: adding file
 
Old 05-20-2011, 04:40 PM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Code:
        OPEN ( UNIT = DUNIT, FILE = DFILE, ACCESS = 'DIRECT',
     :         STATUS = 'OLD', FORM = 'FORMATTED',RECL = 78 )
The DIRECT access is still referred to unformatted files. In Fortran you have two methods for reading binary files: sequential that is like reading a stream of data from a tape, direct access that is like reading data from a hard disk. In direct access the record number is a sort of address to specify in which position of the file the data are stored. Every record has the same length in bytes and this is the value you can provide using the RECL keyword in the OPEN statement.

Said that, your OPEN statement should be something like
Code:
      OPEN ( UNIT = DUNIT, FILE = DFILE, STATUS = 'OLD', FORM = 'FORMATTED')
Looking at your code, I can see that you have to read a certain number of time origins
Code:
NTIMOR = NSTEP / IOR = 1000 / 4 = 250
and after every time origin you have to read a certain number of time steps
Code:
IOR - 1 = 4 - 1 = 3
In practice the code reads 4 steps at each iteration (the first step being a time origin) and computes the time correlation. Then reads in the next 4 steps and compute the time correlation and so on to the end of the file. Can you confirm this is the correct behavior?

Finally notice that the three arrays VX, VY, VZ have size N = 78 and NLABEL is a scalar integer
Code:
      REAL VX(N), VY(N), VZ(N)
      INTEGER NLABEL
therefore the READ statement in the original code:
Code:
      READ ( DUNIT ) NLABEL, VX, VY, VZ
reads an integer followed by 78 + 78 + 78 values at once. In Fortran this is possible only when reading unformatted files. Instead a formatted ASCII file can be read only line by line. For this reason you have to put the READ statement inside a loop to get all the N = 78 lines of each step.

Better to show than explain:
Code:
      PROGRAM TCORR

      COMMON / BLOCK1 / STORX, STORY, STORZ
      COMMON / BLOCK2 / VX, VY, VZ
      COMMON / BLOCK3 / VACF, ANORM

C *******************************************************************
C ** CALCULATION OF TIME CORRELATION FUNCTIONS. **
C ** **
C ** THIS PROGRAM ANALYZES DATA TO CALCULATE A TIME CORRELATION **
C ** FUNCTION IN ONE SWEEP (LOW MEMORY REQUIREMENT). IN THIS **
C ** EXAMPLE THE VELOCITY AUTO-CORRELATION FUNCTION IS CALCULATED. **
C ** **
C ** PRINCIPAL VARIABLES: **
C ** **
C ** INTEGER N NUMBER OF ATOMS
C ** INTEGER NSTEP NUMBER OF STEPS ON THE TAPE
C ** INTEGER IOR INTERVAL FOR TIME ORIGINS
C ** INTEGER NT CORRELATION LENGTH, INCLUDING T=0
C ** INTEGER NTIMOR NUMBER OF TIME ORIGINS
C ** INTEGER NLABEL LABEL FOR STEP (1,2,3...NSTEP)
C ** REAL VX(N),VY(N),VZ(N) VELOCITIES
C ** REAL VACF(NT) THE CORRELATION FUNCTION
C ** NSTEP AND NT SHOULD BE MULTIPLES OF IOR.

C ** ROUTINES REFERENCED:
C ** **
C ** SUBROUTINE STORE (J1)
C ROUTINE TO STORE THE DATA FOR CORRELATION **
C SUBROUTINE CORR ( J1, J2, IT )
C ROUTINE TO CORRELATE THE STORED TIME ORIGINS **
C USAGE: **
C ** **
C DATA IN FILE DFILE ON FORTRAN UNIT DUNIT. **
C RESULTS IN FILE RFILE ON FORTRAN UNIT RUNIT. **
C *******************************************************************

      INTEGER N, NSTEP, IOR, NT, NDIM, DUNIT, RUNIT, NTIMOR
      INTEGER FULLUP
      PARAMETER ( N = 78, NSTEP = 1000, IOR = 4, NT = 200 )
      PARAMETER ( DUNIT = 10, RUNIT = 11 )
      PARAMETER ( NDIM = NT / IOR + 1, NTIMOR = NSTEP / IOR )
      PARAMETER ( FULLUP = NDIM - 1 )

      REAL VX(N), VY(N), VZ(N)
      REAL STORX(NDIM,N), STORY(NDIM,N), STORZ(NDIM,N)
      REAL VACF(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 * 30
      CHARACTER RFILE * 30

C *******************************************************************

      WRITE(*,'('' **** PROGRAM TCORR **** '')')
      WRITE(*,'('' CALCULATION OF TIME CORRELATION FUNCTIONS '')')

C ** READ IN FILE NAMES **

      WRITE(*,'('' ENTER DATA FILE NAME '')')
      READ (*,'(A)') DFILE
      WRITE (*,'('' ENTER RESULTS FILE NAME '')')
      READ (*,'(A)') RFILE

C ** INITIALIZE COUNTERS **

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

C ** ZERO ARRAYS **

      DO 5 I = 1, NT

      VACF(I) = 0.0
      ANORM(I) = 0.0
      write(*,*) VACF(I)
    5 CONTINUE


C ** OPEN DATA FILE AND RESULTS FILE **

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

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

C ** 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, '(1X,F17.14,2(7X,F17.14))' ) VX(R), VY(R), VZ(R)
    7 CONTINUE

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

C ** STORE STEP AS A TIME ORIGIN **
      CALL STORE ( JA )

C ** 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

C ** READ IN DATA BETWEEN TIME ORIGINS. THIS CAN **
C ** BE CONVENIENTLY STORED IN ELEMENT 1 OF THE **
C ** ARRAYS STORX ETC. AND CAN THEN BEN CORRELATED **
C ** WITH THE TIME ORIGINS. **

      DO 30 K = 1, IOR - 1

      READ ( DUNIT, '(A5,I4)') DUMMY, NLABEL
      DO 15 R = 1, N
        READ ( DUNIT, '(1X,F17.14,2(7X,F17.14))' ) VX(R), VY(R), VZ(R)
   15 CONTINUE

      CALL STORE ( 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 )

C ** NORMALISE CORRELATION FUNCTIONS **

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

      DO 50 I = 2, NT

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

   50 CONTINUE

      WRITE ( RUNIT, '('' VELOCITY ACF '')')
      WRITE ( RUNIT, '(I6,E15.6)') ( I, VACF(I), I = 1, NT )

      CLOSE ( RUNIT )

      STOP
      END



      SUBROUTINE STORE ( J1 )

      COMMON/ BLOCK1 / STORX, STORY, STORZ
      COMMON/ BLOCK2 / VX, VY, VZ

C *******************************************************************
C ** SUBROUTINE TO STORE TIME ORIGINS **
C *******************************************************************

      INTEGER J1
      INTEGER N, NT, IOR, NDIM
      PARAMETER ( N = 78, NT = 200, IOR =4 )
      PARAMETER ( NDIM = NT / IOR + 1 )

      REAL STORX(NDIM,N), STORY(NDIM,N), STORZ(NDIM,N)
      REAL VX(N), VY(N), VZ(N)
      INTEGER I


      DO 10 I = 1, N

      STORX(J1,I) = VX(I)
      STORY(J1,I) = VY(I)
      STORZ(J1,I) = VZ(I)

   10 CONTINUE

      RETURN
      END



      SUBROUTINE CORR ( J1, J2, IT )

      COMMON/ BLOCK1 / STORX, STORY, STORZ
      COMMON/ BLOCK3 / VACF, ANORM

C *******************************************************************
C ** SUBROUTINE TO CORRELATE TIME ORIGINS **
C *******************************************************************

      INTEGER J1, J2, IT
      INTEGER N, NT, IOR, NDIM
      PARAMETER ( N = 78, NT = 200, IOR = 4 )
      PARAMETER ( NDIM = NT / IOR + 1 )

      REAL STORX(NDIM,N), STORY(NDIM,N), STORZ(NDIM,N)
      REAL VACF(NT), ANORM(NT)
      INTEGER I

C ********************************************************************

      DO 10 I = 1, N

      VACF(IT) = VACF(IT) + STORX(J1,I) * STORX(J2,I)
     : + STORY(J1,I) * STORY(J2,I)
     : + STORZ(J1,I) * STORZ(J2,I)

   10 CONTINUE

      ANORM(IT) = ANORM(IT) + 1.0

      RETURN
      END
The parts in blue are those ones I modified. Also notice that in your sample file, two VX, VY, VZ triplets were erroneously written on the same row. I don't know if it was a copy/paste typo, but better to check the correct format of the input file before running the fortran code. Just my .
 
1 members found this post helpful.
Old 05-21-2011, 06:25 AM   #7
fu3lc3ll$
LQ Newbie
 
Registered: May 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Smile Working Fine.

Hi, thanks a lot. The programs works fine now
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I get an error using a namelist in a fortran 90 program? kells Programming 1 08-26-2010 09:33 PM
How to run a program at boot time crazylegs SUSE / openSUSE 2 12-12-2007 09:08 PM
How to test a run-time of a C program frankie_DJ Programming 2 10-07-2006 04:03 AM
g77 Fortran - run time error (fmt: read unexpected character) rajeshdorai Programming 1 08-16-2006 07:07 AM
call other program at run time Xiangbuilder Programming 4 10-01-2003 09:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration