Keywords: class-user

Next: Reading a user section Up: Adding a user subsection Previous: Example Contents

## Detailed API

The following subroutines are part of the Class User Section API. The interface module named `class_user_interfaces` MUST be used in the calling program or subroutines:

- Declare the owner and title of the User Subsection:

        subroutine class_user_owner(sowner,stitle)
          character(len=*), intent(in) :: sowner  ! Section owner
          character(len=*), intent(in) :: stitle  ! Section title

- Declare the user's transfer routine

      subroutine class_user_toclass(usertoclass)
        external :: usertoclass  ! User's 'toclass' subroutine

- Send a variable to the data buffer in CLASS:

      subroutine class_user_datatoclass(var)
            integer(kind=4),  intent(in) :: var
        OR  real(kind=4),     intent(in) :: var
        OR  real(kind=8),     intent(in) :: var
        OR  character(len=*), intent(in) :: var

- Add the User Subsection to an observation:

      subroutine class_user_add(obs,sversion,sdata,error)
        type(observation), intent(inout) :: obs       ! Observation
        integer(kind=4),   intent(in)    :: sversion  ! Version number
        type( ),           intent(in)    :: sdata     ! The user data
        logical,           intent(inout) :: error     ! Logical error flag

- Update the User Subsection in the input observation:

      subroutine class_user_update(obs,sversion,sdata,error)
        type(observation), intent(inout) :: obs       ! Observation
        integer(kind=4),   intent(in)    :: sversion  ! Version number
        type( ),           intent(in)    :: sdata     ! The user data
        logical,           intent(inout) :: error     ! Logical error flag

Finally, the calling sequence of the user's transfer routine must be of the following form:

    subroutine toclass(data,version,error)
      type(  ),        intent(in)    :: data     ! The data to be transfered to Class
      integer(kind=4), intent(in)    :: version  ! The version of the data
      logical,         intent(inout) :: error    ! Logical error flag

The name of this subroutine is to be defined by the user. The data type can be of any kind provided by the user. The purpose of this routine is to send the `data` elements to CLASS in a given order. The advantage of this mechanism is to leave CLASS compute the whole `data` size and store it as its will. The counterpart is that the order must be then exactly respected in the other parts of the user code, e.g. in the reading subroutine `fromclass` defined hereafter. Furthermore, the CLASS API does not allow to read only one element in the `data`.

Next: Reading a user section Up: Adding a user subsection Previous: Example Contents