forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple Interpolation

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Jim



Joined: 21 Jul 2006
Posts: 24
Location: USA

PostPosted: Fri Apr 15, 2016 8:39 pm    Post subject: Simple Interpolation Reply with quote

I want to do a simple linear interpolation between points. I read in the following data using

DO 50 I = 1,NUMBR,1
READ(25,*)MD(I),INC(I),AZM(I)
50 CONTINUE

Data

MD(I) INC(I) AZM(I)
0 0 0
100 0.21 24.234
200 0.255 22.873
300 0.347 37.584
400 0.459 39.115
500 0.419 28.605
600 0.586 344.075
700 0.623 341.053
800 0.59 338.811
900 0.47 354.067
1000 0.36 351.009

I use the next routine to read in points that may may or or may not equal to main point set.

DO 51 K = 1,POINTS,1
READ(25,*)MD(K)
51 CONTINUE

Data

MD(K)
150
250
350

I then use the following loop to find do a linear interpolation to find INC(K) and AZM(K). This is the routine I am using:

399 DO 400 I = 1,NUMBR,1
IF(MD(K).EQ.MD(I))MD(K)=MD(I)
INC(K)=INC(I)
AZM(K)=AZM(I)
ELSEIF(MD(K).GE.MD(I).AND.MD(K).LT.MD(I+1))THEN
DMD(K)=DMD(K)-MD(I)
INC(K)=INC(I)+((INC(I+I)-INC(I))*((MD(K)-MD(I))/DMD(I+1)))
AZM(K)=AZM(I)+((AZM(I+I)-AZM(I))*((MD(K)-MD(I))/DMD(I+1)))
ENDIF
400 CONTINUE

I get the error "Found ELSE IF without a corresponding IF statement".

Anyone have an idea of what is wrong and how do I fix the error?
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1707

PostPosted: Fri Apr 15, 2016 8:46 pm    Post subject: Reply with quote

Replace the line
Code:

IF(MD(K).EQ.MD(I))MD(K)=MD(I)

by
Code:

IF(MD(K).EQ.MD(I)) THEN
   MD(K)=MD(I)

You meant to use a block IF construct, but what you wrote is a single-line IF statement. As a result, the compiler does not find an IF(clause)THEN to match the ELSE IF (clause) THEN... and the ENDIF statements, and detects a syntax error.

Next, consider the semantics. The assignment MD(K) = MD(I) is superfluous, coming immediately after IF(MD(K).EQ.MD(I)).
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2398
Location: Sydney

PostPosted: Sat Apr 16, 2016 2:06 am    Post subject: Reply with quote

Do you mean to use MD in loop 51, as it overwrites the reference table you are wanting to use? A useful change to something like:

Code:
      DO 51 K = 1,POINTS,1
        READ(25,*) MDnew(K)
 51   CONTINUE

399   DO 400 I = 1,NUMBR-1,1
        IF (MDnew(K).EQ.MD(I)) THEN
          INCnew(K) = INC(I)
          AZMnew(K) = AZM(I)
          exit
        ELSE IF (MDnew(K).GE.MD(I) .AND.   &
                 MDnew(K).LT.MD(I+1)) THEN
          f = (MDnew(K)-MD(I)) / (MD(I+1)-MD(I))
          INCnew(K) = INC(I) + ((INC(I+I)-INC(I)) * f
          AZMnew(K) = AZM(I) + ((AZM(I+I)-AZM(I)) * f
          exit
        END IF
 400  CONTINUE
!    now test I to confirm interpolation


Will you be trying to interpolate for MDnew = 550 ?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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