|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Dič
Joined: 21 Sep 2008 Posts: 3 Location: french
|
Posted: Thu Jan 01, 2009 10:51 am Post subject: Calcul an integrale with winio+and fortran95 |
|
|
Good morning
I thank LitusSaxonicum for his help to do my program
Now i have this program
WINAPP
INCLUDE<windows.ins>
DOUBLE PRECISION A,B,somme
CHARACTER*50 s
COMMON A,B,somme,N
INTEGER i,w,N
EXTERNAL TRAP
A=0.0E0
B=0.0E0
somme=0.0E0
N=0
i=winio@('%ca[Calcule une integrale]&')
s='{integral A;B} (X+1)dx=somme'
w=winio@('%ob%eq@%cb&',s,0,0)
w=winio@('&')
i=winio@('%5tl&',1,2,3,4,5)
i=winio@('%ffA=%ta&')
i=winio@('%rf&',A)
i=winio@('%ffB=%ta&')
i=winio@('%rf&',B)
i=winio@('%ffsomme=%ta&')
i=winio@('%rf&',somme)
i=winio@('%ffN=%ta&')
i=winio@('%rd&',N)
i=winio@('%ta%`^12bt[INTEGRATION]',TRAP)
END
FUNCTION F(T)
REAL(SELECTED_REAL_KIND(15,307))T
F=T+1
RETURN
END
INTEGER FUNCTION TRAP()
INTEGER I,N
COMMON A,B,somme,N
REAL (SELECTED_REAL_KIND(15,307))X,B,A,somme
DX=(B-A)/N
TRAP=(F(A)+F(B))/2
X=A
DO 10 I=1,N-1
X=X+DX
TRAP=TRAP+F(X)
10 CONTINUE
TRAP=TRAP*DX
somme=TRAP
CALL window_update@(somme)
RETURN
END
The program is running and gives results
I have run many examples but results are always lower than the right result
With the example i send you the result is 175 for 181.5
Your very truly |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7916 Location: Salford, UK
|
Posted: Thu Jan 01, 2009 12:13 pm Post subject: |
|
|
Part of the problem is that TRAP is declared as INTEGER when it should be REAL. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Thu Jan 01, 2009 8:13 pm Post subject: |
|
|
To amplify Paul's comments: your use of Integer function TRAP in a callback is OK, but it should return integer 1 or 0. In that function, you should not be using the variable TRAP as if it was a general purpose real variable - use something else. In fact as a general rule I make my callback function names something I wouldn't accidentally use as anything else.
Glad to have helped the previous time.
Eddie |
|
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
|