Hello eyeryone,
i've tried to calculate an average of hourly meteorological values to a daily value.
here is an example of the ascii file:
pres2 wdsp
12100 2000010106 0.5 -0.3 -9.0 -9.0 2 -9.0 1.5 0.0 1.0
12100 2000010107 0.2 -0.6 -9.0 -9.0 4 -9.0 -99.0 -99.0 -5.0
12100 2000010108 0.2 -0.6 -9.0 1023.3 3 -9.0 -99.0 -99.0 -5.0
12100 2000010109 0.2 -0.6 -9.0 -9.0 3 -9.0 -99.0 -99.0 -5.0
12100 2000010110 0.6 -0.2 -9.0 -9.0 3 -9.0 -99.0 -99.0 -5.0
12100 2000010111 0.9 -0.1 1021.9 -9.0 3 -9.0 -99.0 -99.0 -5.0
12100 2000010112 1.1 0.1 -9.0 -9.0 4 -9.0 -99.0 -99.0 -5.0
12100 2000010113 1.2 0.0 -9.0 1023.3 4 -9.0 -99.0 -99.0 -5.0
12100 2000010114 1.2 0.0 -9.0 -9.0 2 -9.0 -99.0 -99.0 -5.0
12100 2000010115 1.0 0.3 -9.0 -9.0 3 -9.0 -99.0 -99.0 -5.0
12100 2000010116 0.8 0.0 -9.0 -9.0 3 -9.0 -99.0 -99.0 -5.0
12100 2000010117 0.6 0.1 -9.0 1019.8 3 -9.0 -99.0 -99.0 -5.0
12100 2000010118 0.5 -0.3 -9.0 -9.0 3 -9.0 1.4 -0.1 -5.0
12100 2000010206 2.4 2.2 1023.3 1022.6 2 -9.0 2.5 0.0 2.5
12100 2000010207 3.2 3.0 1023.8 1023.1 2 -9.0 -99.0 -99.0 -5.0
12100 2000010208 3.4 2.9 -9.0 -9.0 4 -9.0 -99.0 -99.0 -5.0
12100 2000010209 3.6 2.9 1024.5 1023.8 2 -9.0 -99.0 -99.0 -5.0
12100 2000010210 3.5 3.0 1024.0 1023.3 4 -9.0 -99.0 -99.0 -5.0
I want the daily value of the 6th and 7th column. So I write a fortran program. Here's an extract:
days=0
valu=pres2(0)
5 CONTINUE
DO j=1,length
IF (pres2(j) <= 0) THEN
GOTO 5
IF (day(j) == day(j-1) .AND. j /= length) THEN
counter=counter+1
valu=valu+pres2(j)
ELSEIF (day(j) /= day(j-1) .OR. j == length) THEN
days=days+1
tgl(days)=valu/REAL(counter)
y(days)=year(j-1)
m(days)=month(j-1)
d(days)=day(j-1)
counter=1
valu=pres2(j)
ENDIF
ENDIF
ENDDO
days=0
valu=wdsp(0)
DO j=1,length
IF (day(j) == day(j-1) .AND. j /= length) THEN
counter=counter+1
valu=valu+wdsp(j)
ELSEIF (day(j) /= day(j-1) .OR. j == length) THEN
days=days+1
tgl(days)=wert/REAL(counter)
y(days)=jahr(j-1)
m(days)=monat1(j-1)
d(days)=tag1(j-1)
counter=1
wert=wdsp1(j)
ENDIF
ENDDO
When I run the program i get this outfile:
00000 NaN 0.00 0.00
20000101 12100. 3.08 228.85
20000102 12100. 2.50 764.75
The 7th column is calculate correctly but the 6th isn't. It's because of the -9.0 values (-9.0 values mean there are no values for this hour so the program should skip this value)
How can I solve this problem correctly?
Thank you in advance
i've tried to calculate an average of hourly meteorological values to a daily value.
here is an example of the ascii file:
pres2 wdsp
12100 2000010106 0.5 -0.3 -9.0 -9.0 2 -9.0 1.5 0.0 1.0
12100 2000010107 0.2 -0.6 -9.0 -9.0 4 -9.0 -99.0 -99.0 -5.0
12100 2000010108 0.2 -0.6 -9.0 1023.3 3 -9.0 -99.0 -99.0 -5.0
12100 2000010109 0.2 -0.6 -9.0 -9.0 3 -9.0 -99.0 -99.0 -5.0
12100 2000010110 0.6 -0.2 -9.0 -9.0 3 -9.0 -99.0 -99.0 -5.0
12100 2000010111 0.9 -0.1 1021.9 -9.0 3 -9.0 -99.0 -99.0 -5.0
12100 2000010112 1.1 0.1 -9.0 -9.0 4 -9.0 -99.0 -99.0 -5.0
12100 2000010113 1.2 0.0 -9.0 1023.3 4 -9.0 -99.0 -99.0 -5.0
12100 2000010114 1.2 0.0 -9.0 -9.0 2 -9.0 -99.0 -99.0 -5.0
12100 2000010115 1.0 0.3 -9.0 -9.0 3 -9.0 -99.0 -99.0 -5.0
12100 2000010116 0.8 0.0 -9.0 -9.0 3 -9.0 -99.0 -99.0 -5.0
12100 2000010117 0.6 0.1 -9.0 1019.8 3 -9.0 -99.0 -99.0 -5.0
12100 2000010118 0.5 -0.3 -9.0 -9.0 3 -9.0 1.4 -0.1 -5.0
12100 2000010206 2.4 2.2 1023.3 1022.6 2 -9.0 2.5 0.0 2.5
12100 2000010207 3.2 3.0 1023.8 1023.1 2 -9.0 -99.0 -99.0 -5.0
12100 2000010208 3.4 2.9 -9.0 -9.0 4 -9.0 -99.0 -99.0 -5.0
12100 2000010209 3.6 2.9 1024.5 1023.8 2 -9.0 -99.0 -99.0 -5.0
12100 2000010210 3.5 3.0 1024.0 1023.3 4 -9.0 -99.0 -99.0 -5.0
I want the daily value of the 6th and 7th column. So I write a fortran program. Here's an extract:
days=0
valu=pres2(0)
5 CONTINUE
DO j=1,length
IF (pres2(j) <= 0) THEN
GOTO 5
IF (day(j) == day(j-1) .AND. j /= length) THEN
counter=counter+1
valu=valu+pres2(j)
ELSEIF (day(j) /= day(j-1) .OR. j == length) THEN
days=days+1
tgl(days)=valu/REAL(counter)
y(days)=year(j-1)
m(days)=month(j-1)
d(days)=day(j-1)
counter=1
valu=pres2(j)
ENDIF
ENDIF
ENDDO
days=0
valu=wdsp(0)
DO j=1,length
IF (day(j) == day(j-1) .AND. j /= length) THEN
counter=counter+1
valu=valu+wdsp(j)
ELSEIF (day(j) /= day(j-1) .OR. j == length) THEN
days=days+1
tgl(days)=wert/REAL(counter)
y(days)=jahr(j-1)
m(days)=monat1(j-1)
d(days)=tag1(j-1)
counter=1
wert=wdsp1(j)
ENDIF
ENDDO
When I run the program i get this outfile:
00000 NaN 0.00 0.00
20000101 12100. 3.08 228.85
20000102 12100. 2.50 764.75
The 7th column is calculate correctly but the 6th isn't. It's because of the -9.0 values (-9.0 values mean there are no values for this hour so the program should skip this value)
How can I solve this problem correctly?
Thank you in advance