Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
6590 Discussions

## passing additional parameters to RHS function of ODE solver

Beginner
153 Views

Hi,

I am trying to use the Intel's ODE solver to solver a system of equations. Below is the how the RHS function is supposed to be defined (from manual):

subroutine <name>(n, t, y, f)
integer n
double precision t, y(n), f(n)
..................
f(i) = .....
..................
return
end

The problem is I need to pass additional parameters to the RHS function. Is there a way to do that?

Thanks!

Bo

1 Solution
Black Belt
153 Views

Declare the additional parameters and variables in a module. USE that module in the main program, and read/assign values to the module variables as needed. In the subroutine that implements the specific ODE, USE the module and access the variables as needed.

For example, you can modify the van der Pol example that is included with the Intel ODE solver to take a parameter K in place of 1.0d6 in the equation: y” - K * [ ( 1 - y*y ) * y’ + K * y = 0. Then, the module contains:

MODULE PARS_MOD
double precision :: K
END MODULE

Add "USE PARS_MOD" to all subprograms that need to set/get the value of K.

In the main program, you can do:

In subroutine rhs_v_d_p, change to

f(2)=K*((1.d0-y(1)*y(1))*y(2)-y(1))

and, in subroutine jacmat_v_d_p, change to

a(2,1)=-K*(1.d0+2.d0*y(1)*y(2))
a(2,2)= K*(1.d0-y(1)* y(1))

You will probably need to deactivate all the result checks, since they use pre-computed results that are correct only for the specific case K = 1.0d6.

Black Belt
154 Views

Declare the additional parameters and variables in a module. USE that module in the main program, and read/assign values to the module variables as needed. In the subroutine that implements the specific ODE, USE the module and access the variables as needed.

For example, you can modify the van der Pol example that is included with the Intel ODE solver to take a parameter K in place of 1.0d6 in the equation: y” - K * [ ( 1 - y*y ) * y’ + K * y = 0. Then, the module contains:

MODULE PARS_MOD
double precision :: K
END MODULE

Add "USE PARS_MOD" to all subprograms that need to set/get the value of K.

In the main program, you can do: