Silverfrost Forums

Welcome to our forums

ARRAY READING

8 May 2006 1:08 #660

I am sorry to annoy you once again in three days with my questions but i beg for your understanding. Let's suppose we have an array with many different values and among them some -999 values like below: 12 I need to make a program which replaces the first (-999) value that it reads with the average of the exact before of that 14 ←------ number and the next non (-999)value that there is -999 ←---------For example this -999 should be replaced with (14+34)/2 -999 -999 -999 34 ←-----next 45 -999 10 Also we make the hypothesis that -999 cant be found on the first and the last array box... Array's dimension is not known ... I would be grateful once again if you could reply to my post Dimitris

Dimitris

15 May 2006 12:40 #679

Wht not just:

skip = 0 DO I=1,MAXCOMP DO IROW=2,MAXROW-1 if (irow ⇐ skip) cycle IF (VAL(IROW,I)/-999) cycle DO temp = irow+1,maxrow IF (VAL(TEMP,I)/-999) exit END DO VAL(IROW,I)=(VAL(IROW-1,I)+VAL(TEMP,I))/2 skip = temp ! include if to skip multiple -999 END DO END DO

Two points,

  1. What do you want to do with repeated -999's, skip or also replace
  2. the test for -999 should be changed if 'VAL' is real to IF ( ABS(VAL(IROW,I)+999.0) > 0.1) cycle ! error to +/- 0.1
Please login to reply.