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