To enable the legacy integrator to evaluate
functions that are not defined in the same fashion as the
FunctionModule above (i.e., such that they define the
eval method or equivalent interface that takes a
FunctionParams_t argument and a real argument) is
to create another FunctionModule that allows a
FunctionPort to be used for the function
evaluation.
file:$STUDENT_SRC/legacy/f90/FunctionModuleWrapper.f90 module FunctionModule ! This module replaces the FunctionModule used by the legacy integrator. ! Thus, we need to makes sure that this module is first in the module ! search path when building the integrator component. ! We need to include the function port definitions use function_FunctionPort_typeuse function_FunctionPort implicit none type FunctionParams_t sequence ! required for component version type(function_FunctionPort_t) funcPort
end type FunctionParams_t interface eval
! This is the one called by the legacy Integrator module procedure evalFunction end interface contains subroutine setFunctionPort(params, port) type(FunctionParams_t), intent(OUT) :: params type(function_FunctionPort_t), intent(IN) :: port params%funcPort = port end subroutine setFunctionPort real function evalFunction(params, x) use function_FunctionPort ! input parameters: type(FunctionParams_t), intent(IN) :: params real, intent(IN) :: x ! local variablesreal real (selected_real_kind(15, 307)) :: xx real (selected_real_kind(15, 307)) :: retval ! Compute value by calling the function evaluation in FunctionModule xx = x call evaluate(params%funcPort, xx, retval)
evalFunction = retval end function evalFunction end module FunctionModule
Notes on the FunctionModuleWrapper.f90
file
![]() |
The
|
![]() |
The FunctionParams_t type that was originally defined in LegacyFunctionModule.f90. |
![]() |
The legacy
|
![]() |
This is the
call to the
|
![]() |
Note |
|---|---|
|
In one of the first steps of this tutorial, the entire tutorial
tree was built (see Appendix C, Building the Tutorial and Student Code Trees),
including the sources in the |