I have a function (Simpson) that calculates the integral of a function (f (x, y = 5)). I want to use this same function (Simpson) to make a double integration of the function f (x, y):
F(x) = \int dy f(x,y) I = \int dx F(x)
Could I call the same function twice (Simpson) in Fortran? How would I do this in the example that I put down? I think the main idea of my question has already been made here but I have not found the answer. fortran, how to make several copies of a program using module or interface?
I'm not interested in making a copy of the function Simpson: Simpson1 Simpson2 neither to use an external package.
Best
This is the outline of the code that I'm using:
MODULE INTEG
IMPLICIT NONE
CONTAINS
REAL FUNCTION SIMPSON(FUNC,A,B,TOL)
REAL, INTENT(IN) :: A, B, TOL
INTERFACE
FUNCTION FUNC (X) RESULT(OUT)
IMPLICIT NONE
REAL, INTEN(IN) :: X
REAL :: OUT
END FUNCTION
END INTERFACE
........
END FUNCTION SIMPSON
END MODULE INTEG
MODULE DOING
USE INTEG
REAL :: TEMP
IMPLICIT NONE
CONTAINS
REAL FUNCTION FUNC (X,Y)
IMPLICIT NONE
REAL, INTENT(IN) :: X, Y
REAL :: OUT
FUNC = X*Y
END FUNCTION FUNC
FUNCTION F(Y) RESULT(OUT2)
REAL, INTENT(IN) :: Y
REAL :: A, B, TOL,OUT2
TEMP = Y
OUT2 = SIMPSON(I1, A, B, TOL)
CONTAINS
REAL FUNCTION I1(X) RESULT(OUT)
REAL, INTENT(IN) :: X
OUT = FUNC (X,TEMP)
END FUNCTION I1
END FUNCTION F
REAL FUNCTION I2(A2, B2, TOL2)
REAL, INTENT(IN) :: A2, B2, TOL2
I2 = SIMPSON(F, A2, B2,TOL)
END FUNCTION I2
END MODULE DOING
PROGRAM EXAMPLE
USE DOING
IMIPLICIT NONE
REAL :: A2, B2, TOL2, OUT3
OUT3 = I2(A2, B2, TOL2)
END PROGRAM EXAMPLE