- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
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.
- Etiquetas:
- Intel® Fortran Compiler
Enlace copiado
1 Responder
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
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
Responder
Opciones de temas
- Suscribirse a un feed RSS
- Marcar tema como nuevo
- Marcar tema como leído
- Flotar este Tema para el usuario actual
- Favorito
- Suscribir
- Página de impresión sencilla