Seeking Recommendations for a Reliable DAE Solver for Fortran

Hello everyone,

I am currently working on a project where I need to solve Differential Algebraic Equations (DAEs) in Fortran. I have already tried using DDaskr (developed by Brown, Hindmarsh, and Petzold), but unfortunately, I encountered several compilation errors (around 10 errors in total). This might be related to version incompatibilities or other technical issues, as I have followed the available instructions closely.

Given this, I’m seeking recommendations for other robust and actively maintained DAE solvers that are compatible with Fortran. I would appreciate any suggestions, especially if they come with clear documentation and examples to help with integration into existing code.

Has anyone faced similar issues with DDaskr, and if so, how did you resolve them? Alternatively, are there any other solvers you’ve had success with?

Thank you in advance for your help!

Best regards,
Di

Hi Diiiiii and welcome,
The whole family dassl, daspk, daskr are among the best DAE solvers I could find. They should be pretty straightforward to build and if I recall they even extracted the dependencies from LINPACK to avoid any external dependencies.
Back in the days, I compiled daspk without any problem, but just pay attention that it is fixed-form legacy fortran 77.
Which errors did you get and which compiler do you use?

2 Likes

I just gave it a try and the following should help you:

  • Download daskr from netlib and unpack it
  • Pick the version that you want (single or double precision). Just delete the other one.
  • Open the daux.f (double precision) or saux.f (single precision) and remove/comment the lines starting with *DECK
  • Install fpm on your computer.
  • Add a file fpm.toml at the root of your daskr folder and copy the following inside:
name = "daskr"
author = "Petzold"
description = "DAE solver"
categories = ["dae","ode"]
homepage = "https://www.netlib.org/ode/"


[build]
auto-executables = false
auto-examples = false
auto-tests = false

[library]
source-dir = "solver"

[fortran]
implicit-external = true  # default: false
source-form = "fixed"  # default: "free"
implicit-typing = true  # default: false
  • From the root of your folder run fpm build --flag "-std=legacy"
  • And voilà

DASKR uses implicit typing, and external procedures to pass the residual, the jacobian and the krylov solver. You also need to instruct gfortran that it’s legacy code.

1 Like

Maybe the codes will compile with gfortran -std=legacy. Some modernized ODE packages in Fortran are listed here. Daskr was discussed in the thread Package for Bayesian inference?.

1 Like

Thanks, @davidpfister and @Beliavsky ! Turns out the problem was on my end — I forgot to add -std=legacy when compiling and was just using the default. Once I fixed that, everything worked.

Appreciate the help!

Somebody should get on modernizing this code and making it an fpm package. I die a little inside every time I see a link that goes to Netlib.

It’s doable, the code is not that big. Major issues are:

  • it issues implicite typing
  • It has hundreds of go to
  • It uses external procedures to pass residual, Jacobian and krilov solver.
  • Interface of the jacobian for the direct and krylov solver are different while passed to the same entry point.
  • Linpack linear solver should be changed for lapack

Nothing but fun here :smile:!

1 Like

Hi just mirrored daskr on github and restructured it to make it fpm compatible.
At least now, you won’t have to link to netlib :sweat_smile:

2 Likes

The University of Bari (Italy) has some pages with links to DAE solvers and test problems that you may wish to peruse.