|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
DKARAMIT
Joined: 06 May 2006 Posts: 2
|
Posted: Mon May 08, 2006 2:08 pm Post subject: ARRAY READING |
|
|
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 |
|
Back to top |
|
|
Anonymous Guest
|
Posted: Tue May 09, 2006 5:46 am Post subject: ARRAY READING |
|
|
DO I=1,MAXCOMP
DO IROW=2,MAXROW-1
TEMP=IROW+1
IF (VAL(IROW,I)==-999) THEN
DO
IF (VAL(IROW+1,I)/=(-999.000)) THEN
VAL(IROW,I)=(VAL(IROW-1,I)+VAL(IROW+1,I))/2
EXIT
ELSE
DO
TEMP=TEMP+1
IF (VAL(TEMP,I)/=-999.000) THEN
VAL(IROW,I)=(VAL(IROW-1,I)+VAL(TEMP,I))/2
EXIT
ELSE
CYCLE
END IF
END DO
EXIT
END IF
EXIT
END DO
END IF
END DO
END DO |
|
Back to top |
|
|
Anonymous Guest
|
Posted: Tue May 09, 2006 5:46 am Post subject: ARRAY READING |
|
|
DO I=1,MAXCOMP
DO IROW=2,MAXROW-1
TEMP=IROW+1
IF (VAL(IROW,I)==-999) THEN
DO
IF (VAL(IROW+1,I)/=(-999.000)) THEN
VAL(IROW,I)=(VAL(IROW-1,I)+VAL(IROW+1,I))/2
EXIT
ELSE
DO
TEMP=TEMP+1
IF (VAL(TEMP,I)/=-999.000) THEN
VAL(IROW,I)=(VAL(IROW-1,I)+VAL(TEMP,I))/2
EXIT
ELSE
CYCLE
END IF
END DO
EXIT
END IF
EXIT
END DO
END IF
END DO
END DO |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Mon May 15, 2006 1:40 am Post subject: ARRAY READING |
|
|
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 |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|