# Adding a user subsection to an observation

In order to add a new user subsection to an observation, the external program has first to define a Fortran derived type containing the data. Scalar, 1D, or 2D-array values of types INTEGER(4), REAL(4) and REAL(8) are supported. Scalar CHARACTER(LEN=*) strings are also supported, but their length must be a multiple of 4. The component names, their number, and their order is defined by the programmer. The derived type used by the external program does not need to have a Fortran sequence statement: the way its elements are ordered in memory is also free.

The external program can add its user section to an observation in 3 steps:

1. tell CLASS which subsection it owns thanks to the subroutine class_user_owner,
2. declare with class_user_toclass the subroutine which knows how to order and transfer to CLASS the user data,
3. finally send the data to CLASS with the subroutine class_user_add (for a new user subsection) or class_user_update (if the subsection already exists).

The 2 first steps can be done only once, while the last has to be repeated each time a new user section has to be added. The transfer subroutine declared at step 2 is mandatory to indicate to CLASS which elements are present in the data and in which order they have to be written.

Subsections

- Example
- Detailed API