Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating of correlation function using Fortran code which hangs after inserting inputs! 1

Status
Not open for further replies.

lehloks

Programmer
Jul 12, 2013
40
ZA
Dear forum users
I have this Fortran code which compiles nicely,it does not complain about anything but hangs after asking me to insert certain inputs parameters : I have a data with nine columns that I want to correlate I have included it below.

Regards
Lehloks

program correl1

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


implicit real*8(a-h,o-z)

parameter (ndiv=500,mxcols=15,mxcorr=10000000)

character*4 name

dimension sample(mxcols),c(ndiv),u(ndiv),v(ndiv),t(ndiv)
dimension icol(mxcorr),jcol(mxcorr)


!declare how many correlation functions are required
!and how many columns of data there in the input data
!(excluding the time column)

write(*,'(a)')'enter number of required correlation functions'
read(*,*)npairs
write(*,'(a)')'enter number of data columns in input file'
read(*,*)ncols
ncols=min(mxcols,ncols)
npairs=min(mxcorr,npairs)

!specify which columns in the input data are to be correlated

write(*,'(a)')'enter ids of column pairs to be correlated'
read(*,*)(icol(i),jcol(i),i=1,npairs)


!now process each correlation function in turn

do ipairs=1,npairs


!open the file containing the columns of data

open(7,file='DFILE.txt')


!now read the required columns (note first column is time)

do i=1,ndiv
read(7,*,end=100)t(i),(sample(j),j=1,ncols)
u(i)=sample(icol(ipairs))
v(i)=sample(jcol(ipairs))
enddo

100 m=i-1


!close data file

close(7)

dtim=t(2)-t(1)
!calculate column averages

sumu=0.d0
sumv=0.d0

do i=1,m
sumu=sumu+u(i)
sumv=sumv+v(i)
enddo

sumu=sumu/dble(m)
sumv=sumv/dble(m)


!subtract averages from columns

do i=1,m
u(i)=u(i)-sumu
v(i)=v(i)-sumv
enddo


!calculate correlation function

do i=1,m
c(i)=0.d0
do j=1,m+1-i
c(i)=c(i)+u(j)*v(i+j-1)
enddo
enddo

DATA FILE

DFILE.txt
1 2 3 4 5 6 7 8 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
-1.617491E+00 4.003700E+00 1.378316E+00 4.003700E+00 -1.665934E+00 1.498592E-01 1.378316E+00 1.498592E-01 -1.206797E+00
5.260921E-01 1.651686E+00 -2.646774E-01 1.651686E+00 -1.762373E-01 -9.632670E-02 -2.646774E-01 -9.632670E-02 1.977057E+00
9.813598E-01 1.625447E+00 2.023088E+00 1.625447E+00 2.490276E+00 -2.670705E-01 2.023088E+00 -2.670705E-01 -1.870441E+00
-5.655597E+00 1.939740E+00 2.297268E+00 1.939740E+00 -8.480003E-02 -3.918615E+00 2.297268E+00 -3.918615E+00 -3.121072E+00
-7.801742E-01 1.287923E+00 -4.939918E-01 1.287923E+00 -2.809879E-02 -2.932175E+00 -4.939918E-01 -2.932175E+00 -4.770079E+00
2.002557E-01 8.336137E-01 -1.590110E-01 8.336137E-01 2.130667E+00 5.596286E-01 -1.590110E-01 5.596286E-01 -1.750873E-01
-3.372541E+00 4.301007E-01 1.537803E+00 4.301007E-01 5.802335E+00 -1.827391E+00 1.537803E+00 -1.827391E+00 -1.537462E+00
-4.435659E+00 2.030894E+00 1.370509E+00 2.030894E+00 1.393425E-01 -1.055499E+00 1.370509E+00 -1.055499E+00 1.771206E+00
2.098158E+00 2.583661E+00 8.791438E-01 2.583661E+00 9.032831E-01 -2.215565E+00 8.791438E-01 -2.215565E+00 2.043297E+00
-1.698410E+00 4.167409E+00 2.647075E-01 4.167409E+00 4.222395E+00 -3.055763E+00 2.647075E-01 -3.055763E+00 -1.391421E+00
 
lehloks said:
...but hangs after asking me to insert certain inputs parameters ...
You probably have not entered the correct number and/or types of input parameters. The program may wait for additional input.
 
Hi mikrom
Yes thats a possibility. But I think I give it what it request! I have have been trying to do it for the past 24hours.
 
1. The code you posted doesn't compile.
For example where is the end of this loop
Code:
 do ipairs=1,npairs
 ...

2. The program doesn't write the computed results.

Please, next time post the program source and data betwen the [pre]
Code:
[/pre][pre]
[/pre] tags
 
Hi
Here is the original code:


program correl1
c
c***********************************************************************
c wl
c 1996/02/15 14:33:29
c 1.1.1.1
c Exp
c
c***********************************************************************
c

implicit real*8(a-h,o-z)

parameter (ndiv=500,mxcols=15,mxcorr=10)

character*4 name

dimension sample(mxcols),c(ndiv),u(ndiv),v(ndiv),t(ndiv)
dimension icol(mxcorr),jcol(mxcorr)

c
c declare how many correlation functions are required
c and how many columns of data there in the input data
c (excluding the time column)

write(*,'(a)')'enter number of required correlation functions'
read(*,*)npairs
write(*,'(a)')'enter number of data columns in input file'
read(*,*)ncols
ncols=min(mxcols,ncols)
npairs=min(mxcorr,npairs)

c
c specify which columns in the input data are to be correlated

write(*,'(a)')'enter ids of column pairs to be correlated'
read(*,*)(icol(i),jcol(i),i=1,npairs)

c
c now process each correlation function in turn

do ipairs=1,npairs

c
c open the file containing the columns of data

open(7,file='input.data')

c
c now read the required columns (note first column is time)

do i=1,ndiv
read(7,*,end=100)t(i),(sample(j),j=1,ncols)
u(i)=sample(icol(ipairs))
v(i)=sample(jcol(ipairs))
enddo

100 m=i-1

c
c close data file

close(7)

dtim=t(2)-t(1)

c
c calculate column averages

sumu=0.d0
sumv=0.d0

do i=1,m
sumu=sumu+u(i)
sumv=sumv+v(i)
enddo

sumu=sumu/dble(m)
sumv=sumv/dble(m)

c
c subtract averages from columns

do i=1,m
u(i)=u(i)-sumu
v(i)=v(i)-sumv
enddo

c
c calculate correlation function

do i=1,m
c(i)=0.d0
do j=1,m+1-i
c(i)=c(i)+u(j)*v(i+j-1)
enddo
enddo

c
c normalise the correlation function

do i=1,m
u(i)=c(i)/dble(m+1-i)
enddo

c
c open output file to receive correlation function

namfil=100*icol(ipairs)+jcol(ipairs)
write(name,'(i4.4)')namfil
open(8,file='x'//name)

c
c write out correlation function

do i=1,m
tim=dble(i-1)*dtim
write(8,'(f10.6,1p,e15.7)')tim,u(i)
enddo

c
c close correlation function file

close(8)

enddo

stop
end
 
You didn't post it between the tags:[pre]
Code:
 [/pre] and [pre]
[/pre]
 
I slightly modified the source you posted, to be better readable:
correl1.f95
Code:
[COLOR=#a020f0]program[/color] correl1
  [COLOR=#0000ff]! [/color]
  [COLOR=#0000ff]!***********************************************************************[/color]
  [COLOR=#0000ff]! wl[/color]
  [COLOR=#0000ff]! 1996/02/15 14:33:29[/color]
  [COLOR=#0000ff]! 1.1.1.1[/color]
  [COLOR=#0000ff]! Exp[/color]
  [COLOR=#0000ff]![/color]
  [COLOR=#0000ff]!***********************************************************************[/color]
  [COLOR=#0000ff]! [/color]

  [COLOR=#2e8b57][b]implicit real[/b][/color][COLOR=#804040][b]*[/b][/color][COLOR=#ff00ff]8[/color](a[COLOR=#804040][b]-[/b][/color]h,o[COLOR=#804040][b]-[/b][/color]z)

  [COLOR=#2e8b57][b]parameter[/b][/color] (ndiv[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]500[/color],mxcols[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]15[/color],mxcorr[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]10[/color])

  [COLOR=#2e8b57][b]character[/b][/color][COLOR=#804040][b]*[/b][/color][COLOR=#ff00ff]4[/color] [COLOR=#804040][b]name[/b][/color]

  [COLOR=#2e8b57][b]dimension[/b][/color] sample(mxcols),c(ndiv),u(ndiv),v(ndiv),t(ndiv)
  [COLOR=#2e8b57][b]dimension[/b][/color] icol(mxcorr),jcol(mxcorr)

  [COLOR=#0000ff]! [/color]
  [COLOR=#0000ff]! declare how many correlation functions are required[/color]
  [COLOR=#0000ff]! and how many columns of data there in the input data[/color]
  [COLOR=#0000ff]! (excluding the time column)[/color]

  [COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#ff00ff]'(a)'[/color])[COLOR=#ff00ff]'enter number of required correlation functions'[/color]
  [COLOR=#804040][b]read[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color])npairs
  [COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#ff00ff]'(a)'[/color])[COLOR=#ff00ff]'enter number of data columns in input file'[/color]
  [COLOR=#804040][b]read[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color])ncols
  ncols[COLOR=#804040][b]=[/b][/color][COLOR=#008080]min[/color](mxcols,ncols)
  npairs[COLOR=#804040][b]=[/b][/color][COLOR=#008080]min[/color](mxcorr,npairs)

  [COLOR=#0000ff]! [/color]
  [COLOR=#0000ff]! specify which columns in the input data are to be correlated[/color]

  [COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#ff00ff]'(a)'[/color])[COLOR=#ff00ff]'enter ids of column pairs to be correlated'[/color]
  [COLOR=#804040][b]read[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color])(icol(i),jcol(i),i[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]1[/color],npairs)

  [COLOR=#0000ff]! [/color]
  [COLOR=#0000ff]! now process each correlation function in turn[/color]

  [COLOR=#804040][b]do[/b][/color] ipairs[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]1[/color],npairs

    [COLOR=#0000ff]! [/color]
    [COLOR=#0000ff]! open the file containing the columns of data[/color]

    [COLOR=#804040][b]open[/b][/color]([COLOR=#ff00ff]7[/color],[COLOR=#804040][b]file[/b][/color][COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]'correl_input.txt'[/color])

    [COLOR=#0000ff]! [/color]
    [COLOR=#0000ff]! now read the required columns (note first column is time)[/color]

    [COLOR=#804040][b]do[/b][/color] i[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]1[/color],ndiv
      [COLOR=#804040][b]read[/b][/color]([COLOR=#ff00ff]7[/color],[COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]end[/b][/color][COLOR=#804040][b]=[/b][/color][COLOR=#804040][b]100[/b][/color])t(i),(sample(j),j[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]1[/color],ncols)
      u(i)[COLOR=#804040][b]=[/b][/color]sample(icol(ipairs))
      v(i)[COLOR=#804040][b]=[/b][/color]sample(jcol(ipairs))
    [COLOR=#804040][b]enddo[/b][/color]

    [COLOR=#ff00ff]100[/color] m[COLOR=#804040][b]=[/b][/color]i[COLOR=#804040][b]-[/b][/color][COLOR=#ff00ff]1[/color]

    [COLOR=#0000ff]! [/color]
    [COLOR=#0000ff]! close data file[/color]

    [COLOR=#804040][b]close[/b][/color]([COLOR=#ff00ff]7[/color])

    dtim[COLOR=#804040][b]=[/b][/color]t([COLOR=#ff00ff]2[/color])[COLOR=#804040][b]-[/b][/color]t([COLOR=#ff00ff]1[/color])

    [COLOR=#0000ff]! [/color]
    [COLOR=#0000ff]! calculate column averages[/color]

    sumu[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]0.d0[/color]
    sumv[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]0.d0[/color]

    [COLOR=#804040][b]do[/b][/color] i[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]1[/color],m
      sumu[COLOR=#804040][b]=[/b][/color]sumu[COLOR=#804040][b]+[/b][/color]u(i)
      sumv[COLOR=#804040][b]=[/b][/color]sumv[COLOR=#804040][b]+[/b][/color]v(i)
    [COLOR=#804040][b]enddo[/b][/color]

    sumu[COLOR=#804040][b]=[/b][/color]sumu[COLOR=#804040][b]/[/b][/color][COLOR=#008080]dble[/color](m)
    sumv[COLOR=#804040][b]=[/b][/color]sumv[COLOR=#804040][b]/[/b][/color][COLOR=#008080]dble[/color](m)

    [COLOR=#0000ff]! [/color]
    [COLOR=#0000ff]! subtract averages from columns[/color]

    [COLOR=#804040][b]do[/b][/color] i[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]1[/color],m
      u(i)[COLOR=#804040][b]=[/b][/color]u(i)[COLOR=#804040][b]-[/b][/color]sumu
      v(i)[COLOR=#804040][b]=[/b][/color]v(i)[COLOR=#804040][b]-[/b][/color]sumv
    [COLOR=#804040][b]enddo[/b][/color]

    [COLOR=#0000ff]! [/color]
    [COLOR=#0000ff]! calculate correlation function[/color]

    [COLOR=#804040][b]do[/b][/color] i[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]1[/color],m
      c(i)[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]0.d0[/color]
      [COLOR=#804040][b]do[/b][/color] j[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]1[/color],m[COLOR=#804040][b]+[/b][/color][COLOR=#ff00ff]1[/color][COLOR=#804040][b]-[/b][/color]i
        c(i)[COLOR=#804040][b]=[/b][/color]c(i)[COLOR=#804040][b]+[/b][/color]u(j)[COLOR=#804040][b]*[/b][/color]v(i[COLOR=#804040][b]+[/b][/color]j[COLOR=#804040][b]-[/b][/color][COLOR=#ff00ff]1[/color])
      [COLOR=#804040][b]enddo[/b][/color]
    [COLOR=#804040][b]enddo[/b][/color]

    [COLOR=#0000ff]! [/color]
    [COLOR=#0000ff]! normalise the correlation function[/color]

    [COLOR=#804040][b]do[/b][/color] i[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]1[/color],m
      u(i)[COLOR=#804040][b]=[/b][/color]c(i)[COLOR=#804040][b]/[/b][/color][COLOR=#008080]dble[/color](m[COLOR=#804040][b]+[/b][/color][COLOR=#ff00ff]1[/color][COLOR=#804040][b]-[/b][/color]i)
    [COLOR=#804040][b]enddo[/b][/color]

    [COLOR=#0000ff]! [/color]
    [COLOR=#0000ff]! open output file to receive correlation function[/color]

    namfil[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]100[/color][COLOR=#804040][b]*[/b][/color]icol(ipairs)[COLOR=#804040][b]+[/b][/color]jcol(ipairs)
    [COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]name[/b][/color],[COLOR=#ff00ff]'(i4.4)'[/color])namfil
    [COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#ff00ff]'(2A)'[/color]) [COLOR=#ff00ff]'output file: '[/color], [COLOR=#ff00ff]'x'[/color][COLOR=#804040][b]//[/b][/color][COLOR=#804040][b]name[/b][/color][COLOR=#804040][b]//[/b][/color][COLOR=#ff00ff]'.txt'[/color]
    [COLOR=#804040][b]open[/b][/color]([COLOR=#ff00ff]8[/color],[COLOR=#804040][b]file[/b][/color][COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]'x'[/color][COLOR=#804040][b]//[/b][/color][COLOR=#804040][b]name[/b][/color][COLOR=#804040][b]//[/b][/color][COLOR=#ff00ff]'.txt'[/color])

    [COLOR=#0000ff]! [/color]
    [COLOR=#0000ff]! write out correlation function[/color]

    [COLOR=#804040][b]do[/b][/color] i[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]1[/color],m
      tim[COLOR=#804040][b]=[/b][/color][COLOR=#008080]dble[/color](i[COLOR=#804040][b]-[/b][/color][COLOR=#ff00ff]1[/color])[COLOR=#804040][b]*[/b][/color]dtim
      [COLOR=#804040][b]write[/b][/color]([COLOR=#ff00ff]8[/color],[COLOR=#ff00ff]'(f10.6,1p,e15.7)'[/color])tim,u(i)
    [COLOR=#804040][b]enddo[/b][/color]

    [COLOR=#0000ff]! [/color]
    [COLOR=#0000ff]! close correlation function file[/color]

    [COLOR=#804040][b]close[/b][/color]([COLOR=#ff00ff]8[/color])

  [COLOR=#804040][b]enddo[/b][/color]

  [COLOR=#804040][b]stop[/b][/color]
[COLOR=#a020f0]end[/color]

The input data file with 9 columns is here
correl_input.txt
Code:
-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
-1.617491E+00 4.003700E+00 1.378316E+00 4.003700E+00 -1.665934E+00 1.498592E-01 1.378316E+00 1.498592E-01 -1.206797E+00
5.260921E-01 1.651686E+00 -2.646774E-01 1.651686E+00 -1.762373E-01 -9.632670E-02 -2.646774E-01 -9.632670E-02 1.977057E+00
9.813598E-01 1.625447E+00 2.023088E+00 1.625447E+00 2.490276E+00 -2.670705E-01 2.023088E+00 -2.670705E-01 -1.870441E+00
-5.655597E+00 1.939740E+00 2.297268E+00 1.939740E+00 -8.480003E-02 -3.918615E+00 2.297268E+00 -3.918615E+00 -3.121072E+00
-7.801742E-01 1.287923E+00 -4.939918E-01 1.287923E+00 -2.809879E-02 -2.932175E+00 -4.939918E-01 -2.932175E+00 -4.770079E+00
2.002557E-01 8.336137E-01 -1.590110E-01 8.336137E-01 2.130667E+00 5.596286E-01 -1.590110E-01 5.596286E-01 -1.750873E-01
-3.372541E+00 4.301007E-01 1.537803E+00 4.301007E-01 5.802335E+00 -1.827391E+00 1.537803E+00 -1.827391E+00 -1.537462E+00
-4.435659E+00 2.030894E+00 1.370509E+00 2.030894E+00 1.393425E-01 -1.055499E+00 1.370509E+00 -1.055499E+00 1.771206E+00
2.098158E+00 2.583661E+00 8.791438E-01 2.583661E+00 9.032831E-01 -2.215565E+00 8.791438E-01 -2.215565E+00 2.043297E+00
-1.698410E+00 4.167409E+00 2.647075E-01 4.167409E+00 4.222395E+00 -3.055763E+00 2.647075E-01 -3.055763E+00 -1.391421E+00
 
Now how the program works :)

It reads the input data from the file correl_input.txt and writes output files with results computed - for example:
Code:
$ g95 correl1.f95 -o correl1

$ correl1
enter number of required correlation functions
1
enter number of data columns in input file
9
enter ids of column pairs to be correlated
1 2
output file: x0102.txt
This creates one output file x0102.txt which contains computed correlation between columns 1 and 2 of the input data file and looks like this:
x0102.txt
Code:
 -0.000000 -7.9447255E-02
 -0.558764  8.0202714E-02
 -1.117528 -1.3830491E+00
 -1.676292  8.4113256E-01
 -2.235056  3.5263902E-01
 -2.793820 -5.1996687E-01
 -3.352584 -4.7299232E-01
 -3.911348 -2.3026650E-01
 -4.470112  1.0362424E+00
 -5.028876  7.4670756E-01
 -5.587640  1.3470729E+00
 -6.146404 -1.9303205E+00
 -6.705168 -6.8206495E-01
 -7.263932  4.4499140E-01
 -7.822696  8.3866504E-01
 -8.381460 -2.6463499E+00
 -8.940224 -2.4416933E+00

This other example
Code:
$ correl1
enter number of required correlation functions
3
enter number of data columns in input file
9
enter ids of column pairs to be correlated
1 2
1 3
7 9
output file: x0102.txt
output file: x0103.txt
output file: x0709.txt
creates 3 output files which contain correlations between the colums 1-2, 1-3 and 7-9 of the input data file.

I hope you have understand.
 
P.S.: The data file you provided is probably not correct because acoording to comments in your fortran source, the first collumn shoud be time.
 
Hi mikrom

Once again thank you. Yes there is one column of data missing which is the time. But I will extract and addd it when I perform the calculations.

Thank you

Best regards
Lehloks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top