next up previous contents
Next: API Up: User hook for command Previous: User hook for command   Contents


When CLASS does not know about the User Subsection, it will not accept to instantiate the SIC structure R%USER%:

LAS90> set variable user
E-SETVAR,  No user function set for SET VAR USER
LAS90> exa r%user%
E-EXAMINE,  No such variable R%USER

The following subroutines show basically what should be done by the section owner to allow CLASS to instantiate SIC variables pointing to the User Subsection when the command SET VARIABLE USER is invoked.

subroutine mysetvar_init
  ! Preliminary declarations
  ! 1) Tell Class who I am
  call class_user_owner('OWNER','TITLE')
  ! 2) Declare my instantiation routine
  call class_user_setvar(mysetvar)
  ! Nothing more: return and wait for Class to ask for my User
  ! Subsection instantiation.
end subroutine mysetvar_init

subroutine mysetvar(version,error)
  use mytypes
  ! Define SIC variables in the structure R%USER%OWNER% which map the
  ! subsection content.
  integer(kind=4), intent(in)    :: version  ! The version of the data
  logical,         intent(inout) :: error    ! Logical error flag
  ! Local
  logical :: error
  integer(kind=4) :: ndim,dims
  error = .false.
  ndim = 0
  call class_user_def_inte('DATAI4',ndim,dims,error)
  call class_user_def_real('DATAR4',ndim,dims,error)
  call class_user_def_dble('DATAR8',ndim,dims,error)
  call class_user_def_strn('DATAC4',ndim,dims,error)
  if (error)  return
end subroutine mysetvar

With these routines, CLASS is now able to instantiate the SIC variables:

MYPROG> set variable user
MYPROG> exa r%user%
R%USER%        ! Structure GLOBAL
R%USER%OWNER%DATAC4 = ABCD                     ! Character*4 GLOBAL RO
R%USER%OWNER%DATAR8 =     333.0000000000000    ! Double  GLOBAL RO
R%USER%OWNER%DATAR4 =    222.0000              ! Real    GLOBAL RO
R%USER%OWNER%DATAI4 =          111             ! Integer GLOBAL RO

Gildas manager 2014-07-01