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!

How to obtain monthly data for each year from daily data

Status
Not open for further replies.

ZSH

Technical User
Jul 9, 2016
2
0
0
KR
Hi Programmer

I wrote the program to add daily data to monthly data for 30 years data but my program shows only repeated results of the first year months data for all other years. How I can overcome this problem.
Thank you in advance!


program readtextfile
real, dimension (10958,2) :: A
integer :: row, col, max_row, max_col
max_row=10958
max_col=2

open(2,file='MET000143F_1.txt',status='old')

do row=1,max_row

read(2,*) (A(row,col), col=1,max_col)

!enddo
!print*, A(1,1)
do year=1,30
sumj=0.0
start=1
end1=31
J=1
do I=start, end1
sumj=sumj+A(I,J)
enddo
sumf=0.0
start=end1+1
end1=start+27
do I=start,end1
sumf=sumf+A(I,J)
enddo


summ=0.0
start=end1+1
end1=start+30
do I=start,end1
summ=summ+A(I,J)
enddo

suma=0.0
start=end1+1
end1=start+29
do I=start,end1
suma=suma+A(I,J)
enddo

summy=0.0
start=end1+1
end1=start+30
do I=start,end1
summy=summy+A(I,J)
enddo

sumju=0.0
start=end1+1
end1=start+29
do I=start,end1
sumju=sumju+A(I,J)
enddo

sumjy=0.0
start=end1+1
end1=start+30
do I=start,end1
sumjy=sumjy+A(I,J)
enddo

sumag=0.0
start=end1+1
end1=start+30
do I=start,end1
sumag=sumag+A(I,J)
enddo

sums=0.0
start=end1+1
end1=start+29
do I=start,end1
sums=sums+A(I,J)
enddo

sumo=0.0
start=end1+1
end1=start+30
do I=start,end1
sumo=sumo+A(I,J)
enddo

sumn=0.0
start=end1+1
end1=start+30
do I=start,end1
sumn=sumn+A(I,J)
enddo

sumd=0.0
start=end1+1
end1=start+30
do I=start,end1
sumd=sumd+A(I,J)
enddo

!start=end1+1
!end1=start+30

enddo
print*, sumj, sumf, summ, suma, summy, sumju, sumjy, sumag, '&'
print*, sums, sumo, sumn, sumd
enddo
end
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top