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

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

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

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

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

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.

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