Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- passing additional parameters to RHS function of ODE solver

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

Bo_Q_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-03-2014
09:07 PM

63 Views

passing additional parameters to RHS function of ODE solver

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

mecej4

Black Belt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-04-2014
09:18 AM

63 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:

WRITE(*,'(A)',advance='no')' Enter K : '

READ (*,*) K

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.

Link Copied

1 Reply

mecej4

Black Belt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-04-2014
09:18 AM

64 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:

WRITE(*,'(A)',advance='no')' Enter K : '

READ (*,*) K

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.

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

For more complete information about compiler optimizations, see our Optimization Notice.