Skip to content

Creating a main program

A main program built on the SDK generally follows this sequence:

  1. Read parameters from input files. You may also hard-code every parameter and read nothing.
  2. Normalise the parameters. This is purely for numerical benefit: avoiding the multiplication of very large by very small values improves solver accuracy.
  3. Set up the simulation system using the normalised parameters.
  4. Run the main iteration loop.
  5. Finalise.

We recommend TOML for input parameters. Call mupro_toml_read_file and then get_value to obtain each parameter.

Some SDK routines are called directly; others are type-bound procedures of a derived type.

These are either global routines that need to be called once, or input readers — thin wrappers around the toml-f library:

  • mupro_size_setup
  • mupro_fft_setup
  • mupro_toml_read_file
  • get_value
  • mupro_toml_evaluate_value

Most SDK routines are attached to a derived type, because they need a specific data context and that data is held in the type. For example:

  • setup on type_mupro_electricContext
  • solve on type_mupro_electricContext

There are many more. The module reference lists, for each solver, what it computes, what its context requires, and what it currently cannot do. Contexts, validation and status describes the pattern all of them follow — including how to ask a context whether it is complete before you commit to a run.