- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need function, which will be dependent from some real parameter and also
can be determinated from some integer, like that:
Function SomeFunction (A, b)
A: real(8), b- integer (type of function)
My problem is that I couldn`t make it with case selection.
Looks like:
Case(I) then i=1
SomeFunction=A*2
Case(I) then i=2
SomeFunction=exp(A)
Help me please.
can be determinated from some integer, like that:
Function SomeFunction (A, b)
A: real(8), b- integer (type of function)
My problem is that I couldn`t make it with case selection.
Looks like:
Case(I) then i=1
SomeFunction=A*2
Case(I) then i=2
SomeFunction=exp(A)
Help me please.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have tried it and it works for me. My code is:
PROGRAM casee INTERFACE REAL*8 FUNCTION Funkce(A,b) REAL*8 A INTEGER b END FUNCTION END INTERFACE REAL*8 A,res INTEGER b, ii A=2.3D0 DO 5 ii=1,5 res=Funkce(A,ii) WRITE (*,'(a,F10.5)') 'Result = ',res 5 CONTINUE STOP END REAL*8 FUNCTION Funkce(A,b) REAL*8 A INTEGER b SELECT CASE (b) CASE(1) Funkce=3*A+2.1 CASE(2) Funkce=A**2+9 CASE(3) Funkce=exp(A) CASE(4) Funkce=sin(A) CASE(5) Funkce=abs(A) END SELECT RETURN END FUNCTION

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page