2.6. Setting up new problems

Problem description

Each problem should provide a initproblem.F90 file with module initproblem and three subroutines:

problem_initial_conditions

This routine fills the grid with initial conditions, according to the parameters read in read_problem_par .

It is not called when the code starts from the restart file.

read_problem_par

This routine reads the PROBLEM_CONTROL namelist by master process and communicates read parameters to other processes. It can also calculate things that might be needed by the problem, except the initial conditions.

Attention: Pointers assignment dependent on parameters from problem.par file should be placed at the end of this routine.

This routine is called before it is decided whether to read restart file or start from scratch.

problem_pointers

This routine is called very early, just after init_mpi and is supposed to set up procedure pointers, if necessary. Such approach allows implementation of problem-specific hacks also during the initialization of the Piernik code. In extreme cases it is possible to change behavior of the Piernik code quite radically, without precompiler directives.

There are to sets of procedure pointers for users:

imported from user_hooks module:
problem_customize_solution
A routine that is called after each 3 sweeps. Intended to enforce solution inside computational domain (carefully!). Can be used to run checks for special events.
finalize_problem
A routine called at the end of simulation before last output is written.
cleanup_problem
A routine called at the end of run to deallocate arrays.
problem_refine_derefine
Implementation of user refinement criteria.

imported from dataio_user module:

user_attrs_pre
Attributs preparation before writing to a file
user_attrs_rd
Specifying attributes to be read
user_attrs_wr
Specifying attributes to be written down
user_vars_hdf5
Specifying variable arrays to be written down
user_tsl
Specifying data to be written to the TSL files
user_post_write_data
A routine called after writing data

It assumes that all procedure pointers are initialized to Null(). Warning Pointers assignment may be dependent on parameters from problem.par file (unrecommended). In such a case they must be assigned not before read_problem_par routine is called.