## problem in constructing problem

## problem in constructing problem

(OP)

Hello I'm new here i need some help with a program. I have a file (ava.dat) which contains 6.000.000 integer numbers (non zero). There is a threshold value (mthres). I want to find which elements are greater or equal from this threshold and to make a calculation which will concern the next 10000 elements. I;m starting like this

.....

nmax=6000000

mthres=220970869

open(1,file='ava.dat')

do i=1,nmax

read(1,*)s(i)

if (s(i).ge.mthres) then

...

How can define the steps i+1,i+10000 where i is the position in which τηε criterio s(i).ge.mthres holds???

Any help would be appreciated

.....

nmax=6000000

mthres=220970869

open(1,file='ava.dat')

do i=1,nmax

read(1,*)s(i)

if (s(i).ge.mthres) then

...

How can define the steps i+1,i+10000 where i is the position in which τηε criterio s(i).ge.mthres holds???

Any help would be appreciated

## RE: problem in constructing problem

## CODE

## RE: problem in constructing problem

When i read the element s(i) which is greater or equal to mthres, i want to calculate the sum for the next 10000 steps :

cum=0.0

1st calculation: cum=cum+s(i+1)=s(i+1)

2nd calculation: cum=s(i+1)+s(i+2)

...

100000st calculation: cum=cum+s(i+10000)

I want to follow this procedure for each s(i).ge.mthres

Thanx!!!!!

## RE: problem in constructing problem

I'm just guessing that you want to do something like this.

## CODE

## RE: problem in constructing problem

In a time series comprising 6.000.000 (file='ava.dat.2500') events i calculate the quantity k1 with the program described below ypolk1.f90. This program gives me exactly the results i expect and want.

Let me now define a threshold value, mthres. I want to read the file ava.dat.2500 which is a one dimension array of 6.000.000 elements. I want to find each element of this array which is greater or equal than mthres and to apply the program ypolk1.f90 for the next 10.000 elements (the element which is greater or equal than mthres is not included). In the file 'ava.dat.2500' there are 2216 elements greater than mthres so the procedure described by the following program should run 2216 times i guess.

program ypolk1

double precision k1(6000000),avx(6000000),avx2(6000000),a(6000000),b,c,ath,n(6000000),x

integer i,nmax

nmax=6000000

ath=0.0

open(10,file='ava.dat.2500')

do i=1,nmax

read(10,*) x

a(i)=x

ath=ath+x

n(i)=ath

end do

close (10)

avx(1)=1.0

avx2(1)=1.0

k1(1)=0.0

do i=1,nmax

b=dble(i)/dble(i+1)

c=n(i)/(n(i)+a(i+1))

avx(i+1)=b*c*avx(i)+a(i+1)/(n(i)+a(i+1))

avx2(i+1)=(b**2)*c*avx2(i)+a(i+1)/(n(i)+a(i+1))

k1(i+1)=avx2(i+1)-avx(i+1)*avx(i+1)

end do

do i=1,nmax

print*,i

write(13,*) i,k1(i)

end do

close(13)

end

Thanks again!!!!!!!!!!!

## RE: problem in constructing problem

## RE: problem in constructing problem

1st time series : k1(i+1) k1(i+2).....k1(i+10000)

2nd time series : k1(i+1) k1(i+2).....k1(i+10000)

...........................................

5th time series : k1(i+1) k1(i+2).....k1(i+10000)

Of course, the i is different in each time series.

Finally, i want to write the average k1 in each step: k1(i+1)/5 etc

## RE: problem in constructing problem

Also I don't quite understand the last bit on k1(i+1)/5.

## RE: problem in constructing problem

I really thank you again!!

## RE: problem in constructing problem

## CODE