# How to switch between non-stiff ODE solver and stiff ODE solver?

**URL:** <https://fortran-lang.discourse.group/t/how-to-switch-between-non-stiff-ode-solver-and-stiff-ode-solver/2847>\
**Category:** Uncategorized\
**Created:** [February 22, 2022, 6:50am UTC](https://fortran-lang.discourse.group/t/how-to-switch-between-non-stiff-ode-solver-and-stiff-ode-solver/2847 "2022-02-22T06:50:22Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![CRquantum](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/crquantum/32/730_2.png) [@CRquantum](https://fortran-lang.discourse.group/u/CRquantum)\
**Post date:** [February 24, 2022, 12:28am UTC](https://fortran-lang.discourse.group/t/how-to-switch-between-non-stiff-ode-solver-and-stiff-ode-solver/2847/5 "2022-02-24T00:28:37Z")

</div>

Damn! That is decent! Thank you @Pap !

I see, in this example you mentioned, I know that with ITASK = 1 and I set the initial x = 0, final x = 20000. So LSODA solve the whole range and automatically switch between non-stiff and stiff during the process.

Now, just one question.  
If I use the interpolation function DINTDY in LSODA to solve for the whole x range you mentioned in your above example. Can LSODA still automatically switch between non-stiff and stiff during the process?

I mean like, I set the initial x = 0, final x = 20000. I set ITASK = 2 in LSODA, so it solve one-step at a time, and I can use DINTDY to do interpolation at the points I want from 0 to 20000. Say I interpolate at x = 0, 100, 200, 300, 400, …, 19900, 20000. So you know what I mean. I am just saying with interpolation enabled, can LSODA automatically switch between non-stiff and stiff during the process? Thanks you very much!

PS.  
By the way, about interpolation function, @ivanpribec has a nice example about dvode and perhaps RKC solver too,

> [@Has anyone used DVODE and is it good?](https://fortran-lang.discourse.group/t/has-anyone-used-dvode-and-is-it-good/2281/23):
>
> Here’s an example of using dvindy for dense output. 
> 
> > **Example**
> >
> > program droplet implicit none integer, parameter :: dp = kind(1.0d0) real(dp), parameter :: pi = 4.0\_dp\*atan(1.0\_dp) integer, parameter :: neq = 3 integer :: itol, itask, istate, iopt, mf, iflag, n, ngrid real(dp) :: rtol, s, send, ds real(dp), dimension(neq) :: atol, y real(dp), allocatable :: ygrid(:,:), sgrid(slight_smile real(dp), allocatable :: rwork(slight_smile integer, allocatable :: iwork(slight_smile integer :: lrw, liw real…

The mechanism of interpolation for different solvers are more less the same.

---

_[View the full topic](https://fortran-lang.discourse.group/t/how-to-switch-between-non-stiff-ode-solver-and-stiff-ode-solver/2847)._
