! This file has been automatically generated, do not modify.

  subroutine ab_dtset_get_integer(dtsetsId, value, id, idtset, errno)
    integer, intent(in) :: dtsetsId
    integer, intent(in) :: id, idtset
    integer, intent(out) :: value
    integer, intent(out) :: errno

    type(dtsets_list), pointer :: token

    call ab_dtset_get_from_id(token, dtsetsId)
    if (.not. associated(token)) then
      errno = AB_ERROR_DTSET_OBJ
      return
    end if
    if (idtset < 0 .or. idtset > size(token%dtsets)) then
      errno = AB_ERROR_DTSET_ID
      return
    end if
    
    errno = AB_NO_ERROR
    select case (id)
    case (ab_dtset_symchi)
      value = token%dtsets(idtset)%symchi
    case (ab_dtset_parareel)
      value = token%dtsets(idtset)%parareel
    case (ab_dtset_rfstrs)
      value = token%dtsets(idtset)%rfstrs
    case (ab_dtset_isecur)
      value = token%dtsets(idtset)%isecur
    case (ab_dtset_exchn2n3d)
      value = token%dtsets(idtset)%exchn2n3d
    case (ab_dtset_nstep)
      value = token%dtsets(idtset)%nstep
    case (ab_dtset_wvl_nprccg)
      value = token%dtsets(idtset)%wvl_nprccg
    case (ab_dtset_gwgamma)
      value = token%dtsets(idtset)%gwgamma
    case (ab_dtset_nsheps)
      value = token%dtsets(idtset)%nsheps
    case (ab_dtset_norb)
      value = token%dtsets(idtset)%norb
    case (ab_dtset_prt1dm)
      value = token%dtsets(idtset)%prt1dm
    case (ab_dtset_prepanl)
      value = token%dtsets(idtset)%prepanl
    case (ab_dtset_ndtset)
      value = token%dtsets(idtset)%ndtset
    case (ab_dtset_usepawu)
      value = token%dtsets(idtset)%usepawu
    case (ab_dtset_mpw)
      value = token%dtsets(idtset)%mpw
    case (ab_dtset_occopt)
      value = token%dtsets(idtset)%occopt
    case (ab_dtset_td_mexcit)
      value = token%dtsets(idtset)%td_mexcit
    case (ab_dtset_frzfermi)
      value = token%dtsets(idtset)%frzfermi
    case (ab_dtset_rfphon)
      value = token%dtsets(idtset)%rfphon
    case (ab_dtset_prtden)
      value = token%dtsets(idtset)%prtden
    case (ab_dtset_gwpara)
      value = token%dtsets(idtset)%gwpara
    case (ab_dtset_recptrott)
      value = token%dtsets(idtset)%recptrott
    case (ab_dtset_jdtset)
      value = token%dtsets(idtset)%jdtset
    case (ab_dtset_pawprtden)
      value = token%dtsets(idtset)%pawprtden
    case (ab_dtset_gwmem)
      value = token%dtsets(idtset)%gwmem
    case (ab_dtset_npkpt)
      value = token%dtsets(idtset)%npkpt
    case (ab_dtset_nberry)
      value = token%dtsets(idtset)%nberry
    case (ab_dtset_usewvl)
      value = token%dtsets(idtset)%usewvl
    case (ab_dtset_useexexch)
      value = token%dtsets(idtset)%useexexch
    case (ab_dtset_tfkinfunc)
      value = token%dtsets(idtset)%tfkinfunc
    case (ab_dtset_ionmov)
      value = token%dtsets(idtset)%ionmov
    case (ab_dtset_npwwfn)
      value = token%dtsets(idtset)%npwwfn
    case (ab_dtset_mffmem)
      value = token%dtsets(idtset)%mffmem
    case (ab_dtset_mk1mem)
      value = token%dtsets(idtset)%mk1mem
    case (ab_dtset_nfreqsus)
      value = token%dtsets(idtset)%nfreqsus
    case (ab_dtset_prtkpt)
      value = token%dtsets(idtset)%prtkpt
    case (ab_dtset_prtcs)
      value = token%dtsets(idtset)%prtcs
    case (ab_dtset_npfft)
      value = token%dtsets(idtset)%npfft
    case (ab_dtset_ndyson)
      value = token%dtsets(idtset)%ndyson
    case (ab_dtset_ngroup_rf)
      value = token%dtsets(idtset)%ngroup_rf
    case (ab_dtset_lofwrite)
      value = token%dtsets(idtset)%lofwrite
    case (ab_dtset_spmeth)
      value = token%dtsets(idtset)%spmeth
    case (ab_dtset_mkmem)
      value = token%dtsets(idtset)%mkmem
    case (ab_dtset_getden)
      value = token%dtsets(idtset)%getden
    case (ab_dtset_prtgeo)
      value = token%dtsets(idtset)%prtgeo
    case (ab_dtset_prtfc)
      value = token%dtsets(idtset)%prtfc
    case (ab_dtset_usedmatpu)
      value = token%dtsets(idtset)%usedmatpu
    case (ab_dtset_nspinor)
      value = token%dtsets(idtset)%nspinor
    case (ab_dtset_paral_kgb)
      value = token%dtsets(idtset)%paral_kgb
    case (ab_dtset_rfmgfd)
      value = token%dtsets(idtset)%rfmgfd
    case (ab_dtset_irdden)
      value = token%dtsets(idtset)%irdden
    case (ab_dtset_getxred)
      value = token%dtsets(idtset)%getxred
    case (ab_dtset_w90prtunk)
      value = token%dtsets(idtset)%w90prtunk
    case (ab_dtset_intexact)
      value = token%dtsets(idtset)%intexact
    case (ab_dtset_get1wf)
      value = token%dtsets(idtset)%get1wf
    case (ab_dtset_useylm)
      value = token%dtsets(idtset)%useylm
    case (ab_dtset_ceksph)
      value = token%dtsets(idtset)%ceksph
    case (ab_dtset_getcell)
      value = token%dtsets(idtset)%getcell
    case (ab_dtset_kssform)
      value = token%dtsets(idtset)%kssform
    case (ab_dtset_wfoptalg)
      value = token%dtsets(idtset)%wfoptalg
    case (ab_dtset_rf1elfd)
      value = token%dtsets(idtset)%rf1elfd
    case (ab_dtset_irdwfk)
      value = token%dtsets(idtset)%irdwfk
    case (ab_dtset_pawlcutd)
      value = token%dtsets(idtset)%pawlcutd
    case (ab_dtset_prteig)
      value = token%dtsets(idtset)%prteig
    case (ab_dtset_enunit)
      value = token%dtsets(idtset)%enunit
    case (ab_dtset_irdwfq)
      value = token%dtsets(idtset)%irdwfq
    case (ab_dtset_pawstgylm)
      value = token%dtsets(idtset)%pawstgylm
    case (ab_dtset_iprcel)
      value = token%dtsets(idtset)%iprcel
    case (ab_dtset_ldgapp)
      value = token%dtsets(idtset)%ldgapp
    case (ab_dtset_restartxf)
      value = token%dtsets(idtset)%restartxf
    case (ab_dtset_irdddk)
      value = token%dtsets(idtset)%irdddk
    case (ab_dtset_spgroup)
      value = token%dtsets(idtset)%spgroup
    case (ab_dtset_npwsigx)
      value = token%dtsets(idtset)%npwsigx
    case (ab_dtset_nomegasi)
      value = token%dtsets(idtset)%nomegasi
    case (ab_dtset_nomegasf)
      value = token%dtsets(idtset)%nomegasf
    case (ab_dtset_nline)
      value = token%dtsets(idtset)%nline
    case (ab_dtset_ncenter)
      value = token%dtsets(idtset)%ncenter
    case (ab_dtset_rfmeth)
      value = token%dtsets(idtset)%rfmeth
    case (ab_dtset_useria)
      value = token%dtsets(idtset)%useria
    case (ab_dtset_userib)
      value = token%dtsets(idtset)%userib
    case (ab_dtset_useric)
      value = token%dtsets(idtset)%useric
    case (ab_dtset_userid)
      value = token%dtsets(idtset)%userid
    case (ab_dtset_userie)
      value = token%dtsets(idtset)%userie
    case (ab_dtset_ntypalch)
      value = token%dtsets(idtset)%ntypalch
    case (ab_dtset_localrdwf)
      value = token%dtsets(idtset)%localrdwf
    case (ab_dtset_prtdosm)
      value = token%dtsets(idtset)%prtdosm
    case (ab_dtset_rectesteg)
      value = token%dtsets(idtset)%rectesteg
    case (ab_dtset_ntypat)
      value = token%dtsets(idtset)%ntypat
    case (ab_dtset_icoulomb)
      value = token%dtsets(idtset)%icoulomb
    case (ab_dtset_ikhxc)
      value = token%dtsets(idtset)%ikhxc
    case (ab_dtset_outputxml)
      value = token%dtsets(idtset)%outputxml
    case (ab_dtset_nbdbuf)
      value = token%dtsets(idtset)%nbdbuf
    case (ab_dtset_natpawu)
      value = token%dtsets(idtset)%natpawu
    case (ab_dtset_rf1phon)
      value = token%dtsets(idtset)%rf1phon
    case (ab_dtset_iscf)
      value = token%dtsets(idtset)%iscf
    case (ab_dtset_ixc)
      value = token%dtsets(idtset)%ixc
    case (ab_dtset_delayperm)
      value = token%dtsets(idtset)%delayperm
    case (ab_dtset_nscforder)
      value = token%dtsets(idtset)%nscforder
    case (ab_dtset_prtpmp)
      value = token%dtsets(idtset)%prtpmp
    case (ab_dtset_rf3elfd)
      value = token%dtsets(idtset)%rf3elfd
    case (ab_dtset_suskxcrs)
      value = token%dtsets(idtset)%suskxcrs
    case (ab_dtset_iprcfc)
      value = token%dtsets(idtset)%iprcfc
    case (ab_dtset_splitsigc)
      value = token%dtsets(idtset)%splitsigc
    case (ab_dtset_nsym)
      value = token%dtsets(idtset)%nsym
    case (ab_dtset_prepgkk)
      value = token%dtsets(idtset)%prepgkk
    case (ab_dtset_prtvxc)
      value = token%dtsets(idtset)%prtvxc
    case (ab_dtset_nfftdg)
      value = token%dtsets(idtset)%nfftdg
    case (ab_dtset_paral_rf)
      value = token%dtsets(idtset)%paral_rf
    case (ab_dtset_irdscr)
      value = token%dtsets(idtset)%irdscr
    case (ab_dtset_usepaw)
      value = token%dtsets(idtset)%usepaw
    case (ab_dtset_rfuser)
      value = token%dtsets(idtset)%rfuser
    case (ab_dtset_w90nplot)
      value = token%dtsets(idtset)%w90nplot
    case (ab_dtset_npara)
      value = token%dtsets(idtset)%npara
    case (ab_dtset_prtfsurf)
      value = token%dtsets(idtset)%prtfsurf
    case (ab_dtset_npband)
      value = token%dtsets(idtset)%npband
    case (ab_dtset_nfft)
      value = token%dtsets(idtset)%nfft
    case (ab_dtset_rfasr)
      value = token%dtsets(idtset)%rfasr
    case (ab_dtset_fftgw)
      value = token%dtsets(idtset)%fftgw
    case (ab_dtset_rfelfd)
      value = token%dtsets(idtset)%rfelfd
    case (ab_dtset_prtvhxc)
      value = token%dtsets(idtset)%prtvhxc
    case (ab_dtset_mgfft)
      value = token%dtsets(idtset)%mgfft
    case (ab_dtset_dmatudiag)
      value = token%dtsets(idtset)%dmatudiag
    case (ab_dtset_nbandsus)
      value = token%dtsets(idtset)%nbandsus
    case (ab_dtset_recgratio)
      value = token%dtsets(idtset)%recgratio
    case (ab_dtset_iprctfvw)
      value = token%dtsets(idtset)%iprctfvw
    case (ab_dtset_nshwfn)
      value = token%dtsets(idtset)%nshwfn
    case (ab_dtset_pawspnorb)
      value = token%dtsets(idtset)%pawspnorb
    case (ab_dtset_npwkss)
      value = token%dtsets(idtset)%npwkss
    case (ab_dtset_prtcml)
      value = token%dtsets(idtset)%prtcml
    case (ab_dtset_gwcalctyp)
      value = token%dtsets(idtset)%gwcalctyp
    case (ab_dtset_irdsuscep)
      value = token%dtsets(idtset)%irdsuscep
    case (ab_dtset_chkprim)
      value = token%dtsets(idtset)%chkprim
    case (ab_dtset_prtefg)
      value = token%dtsets(idtset)%prtefg
    case (ab_dtset_getvel)
      value = token%dtsets(idtset)%getvel
    case (ab_dtset_pawxcdev)
      value = token%dtsets(idtset)%pawxcdev
    case (ab_dtset_prtwf)
      value = token%dtsets(idtset)%prtwf
    case (ab_dtset_nbdblock)
      value = token%dtsets(idtset)%nbdblock
    case (ab_dtset_gwcomp)
      value = token%dtsets(idtset)%gwcomp
    case (ab_dtset_mqgriddg)
      value = token%dtsets(idtset)%mqgriddg
    case (ab_dtset_inclvkb)
      value = token%dtsets(idtset)%inclvkb
    case (ab_dtset_tl_nprccg)
      value = token%dtsets(idtset)%tl_nprccg
    case (ab_dtset_ngeohist)
      value = token%dtsets(idtset)%ngeohist
    case (ab_dtset_ird1wf)
      value = token%dtsets(idtset)%ird1wf
    case (ab_dtset_rf2phon)
      value = token%dtsets(idtset)%rf2phon
    case (ab_dtset_nshsigx)
      value = token%dtsets(idtset)%nshsigx
    case (ab_dtset_nqpt)
      value = token%dtsets(idtset)%nqpt
    case (ab_dtset_pawlmix)
      value = token%dtsets(idtset)%pawlmix
    case (ab_dtset_optstress)
      value = token%dtsets(idtset)%optstress
    case (ab_dtset_positron)
      value = token%dtsets(idtset)%positron
    case (ab_dtset_smdelta)
      value = token%dtsets(idtset)%smdelta
    case (ab_dtset_bandpp)
      value = token%dtsets(idtset)%bandpp
    case (ab_dtset_getwfk)
      value = token%dtsets(idtset)%getwfk
    case (ab_dtset_getwfq)
      value = token%dtsets(idtset)%getwfq
    case (ab_dtset_nbandkss)
      value = token%dtsets(idtset)%nbandkss
    case (ab_dtset_npack)
      value = token%dtsets(idtset)%npack
    case (ab_dtset_pawmixdg)
      value = token%dtsets(idtset)%pawmixdg
    case (ab_dtset_istatshft)
      value = token%dtsets(idtset)%istatshft
    case (ab_dtset_npweps)
      value = token%dtsets(idtset)%npweps
    case (ab_dtset_awtr)
      value = token%dtsets(idtset)%awtr
    case (ab_dtset_nkptgw)
      value = token%dtsets(idtset)%nkptgw
    case (ab_dtset_npulayit)
      value = token%dtsets(idtset)%npulayit
    case (ab_dtset_rdmnb)
      value = token%dtsets(idtset)%rdmnb
    case (ab_dtset_rf3phon)
      value = token%dtsets(idtset)%rf3phon
    case (ab_dtset_nnos)
      value = token%dtsets(idtset)%nnos
    case (ab_dtset_dmatpuopt)
      value = token%dtsets(idtset)%dmatpuopt
    case (ab_dtset_natvshift)
      value = token%dtsets(idtset)%natvshift
    case (ab_dtset_signperm)
      value = token%dtsets(idtset)%signperm
    case (ab_dtset_prtstm)
      value = token%dtsets(idtset)%prtstm
    case (ab_dtset_berryopt)
      value = token%dtsets(idtset)%berryopt
    case (ab_dtset_ixcpositron)
      value = token%dtsets(idtset)%ixcpositron
    case (ab_dtset_getqps)
      value = token%dtsets(idtset)%getqps
    case (ab_dtset_timopt)
      value = token%dtsets(idtset)%timopt
    case (ab_dtset_mgfftdg)
      value = token%dtsets(idtset)%mgfftdg
    case (ab_dtset_getocc)
      value = token%dtsets(idtset)%getocc
    case (ab_dtset_iboxcut)
      value = token%dtsets(idtset)%iboxcut
    case (ab_dtset_pawntheta)
      value = token%dtsets(idtset)%pawntheta
    case (ab_dtset_nshiftk)
      value = token%dtsets(idtset)%nshiftk
    case (ab_dtset_natrd)
      value = token%dtsets(idtset)%natrd
    case (ab_dtset_intxc)
      value = token%dtsets(idtset)%intxc
    case (ab_dtset_symmorphi)
      value = token%dtsets(idtset)%symmorphi
    case (ab_dtset_spgaxor)
      value = token%dtsets(idtset)%spgaxor
    case (ab_dtset_get1den)
      value = token%dtsets(idtset)%get1den
    case (ab_dtset_irdqps)
      value = token%dtsets(idtset)%irdqps
    case (ab_dtset_optnlxccc)
      value = token%dtsets(idtset)%optnlxccc
    case (ab_dtset_jellslab)
      value = token%dtsets(idtset)%jellslab
    case (ab_dtset_ppmodel)
      value = token%dtsets(idtset)%ppmodel
    case (ab_dtset_pawoptmix)
      value = token%dtsets(idtset)%pawoptmix
    case (ab_dtset_optcell)
      value = token%dtsets(idtset)%optcell
    case (ab_dtset_pawprtdos)
      value = token%dtsets(idtset)%pawprtdos
    case (ab_dtset_kptopt)
      value = token%dtsets(idtset)%kptopt
    case (ab_dtset_w90iniprj)
      value = token%dtsets(idtset)%w90iniprj
    case (ab_dtset_nsppol)
      value = token%dtsets(idtset)%nsppol
    case (ab_dtset_nfreqre)
      value = token%dtsets(idtset)%nfreqre
    case (ab_dtset_ptgroupma)
      value = token%dtsets(idtset)%ptgroupma
    case (ab_dtset_pawnhatxc)
      value = token%dtsets(idtset)%pawnhatxc
    case (ab_dtset_pawcpxocc)
      value = token%dtsets(idtset)%pawcpxocc
    case (ab_dtset_optfreqsus)
      value = token%dtsets(idtset)%optfreqsus
    case (ab_dtset_pawusecp)
      value = token%dtsets(idtset)%pawusecp
    case (ab_dtset_nfreqsp)
      value = token%dtsets(idtset)%nfreqsp
    case (ab_dtset_idyson)
      value = token%dtsets(idtset)%idyson
    case (ab_dtset_prtpot)
      value = token%dtsets(idtset)%prtpot
    case (ab_dtset_optforces)
      value = token%dtsets(idtset)%optforces
    case (ab_dtset_brvltt)
      value = token%dtsets(idtset)%brvltt
    case (ab_dtset_ntime)
      value = token%dtsets(idtset)%ntime
    case (ab_dtset_prtvha)
      value = token%dtsets(idtset)%prtvha
    case (ab_dtset_npsp)
      value = token%dtsets(idtset)%npsp
    case (ab_dtset_symsigma)
      value = token%dtsets(idtset)%symsigma
    case (ab_dtset_prtvol)
      value = token%dtsets(idtset)%prtvol
    case (ab_dtset_nqptdm)
      value = token%dtsets(idtset)%nqptdm
    case (ab_dtset_iprcch)
      value = token%dtsets(idtset)%iprcch
    case (ab_dtset_natsph)
      value = token%dtsets(idtset)%natsph
    case (ab_dtset_getddk)
      value = token%dtsets(idtset)%getddk
    case (ab_dtset_nwfshist)
      value = token%dtsets(idtset)%nwfshist
    case (ab_dtset_nctime)
      value = token%dtsets(idtset)%nctime
    case (ab_dtset_nkpt)
      value = token%dtsets(idtset)%nkpt
    case (ab_dtset_nconeq)
      value = token%dtsets(idtset)%nconeq
    case (ab_dtset_ieig2rf)
      value = token%dtsets(idtset)%ieig2rf
    case (ab_dtset_getsuscep)
      value = token%dtsets(idtset)%getsuscep
    case (ab_dtset_icutcoul)
      value = token%dtsets(idtset)%icutcoul
    case (ab_dtset_prtspcur)
      value = token%dtsets(idtset)%prtspcur
    case (ab_dtset_natom)
      value = token%dtsets(idtset)%natom
    case (ab_dtset_prtdos)
      value = token%dtsets(idtset)%prtdos
    case (ab_dtset_spgorig)
      value = token%dtsets(idtset)%spgorig
    case (ab_dtset_nspden)
      value = token%dtsets(idtset)%nspden
    case (ab_dtset_npspalch)
      value = token%dtsets(idtset)%npspalch
    case (ab_dtset_prtnabla)
      value = token%dtsets(idtset)%prtnabla
    case (ab_dtset_pawnzlm)
      value = token%dtsets(idtset)%pawnzlm
    case (ab_dtset_nfreqim)
      value = token%dtsets(idtset)%nfreqim
    case (ab_dtset_prtwant)
      value = token%dtsets(idtset)%prtwant
    case (ab_dtset_mband)
      value = token%dtsets(idtset)%mband
    case (ab_dtset_getscr)
      value = token%dtsets(idtset)%getscr
    case (ab_dtset_optdriver)
      value = token%dtsets(idtset)%optdriver
    case (ab_dtset_prtbbb)
      value = token%dtsets(idtset)%prtbbb
    case (ab_dtset_prtacfd)
      value = token%dtsets(idtset)%prtacfd
    case (ab_dtset_prtgkk)
      value = token%dtsets(idtset)%prtgkk
    case (ab_dtset_pawprtvol)
      value = token%dtsets(idtset)%pawprtvol
    case (ab_dtset_pawnphi)
      value = token%dtsets(idtset)%pawnphi
    case (ab_dtset_recnrec)
      value = token%dtsets(idtset)%recnrec
    case (ab_dtset_accesswff)
      value = token%dtsets(idtset)%accesswff
    case (ab_dtset_kpara)
      value = token%dtsets(idtset)%kpara
    case (ab_dtset_rfthrd)
      value = token%dtsets(idtset)%rfthrd
    case (ab_dtset_recnpath)
      value = token%dtsets(idtset)%recnpath
    case (ab_dtset_nomegasrd)
      value = token%dtsets(idtset)%nomegasrd
    case (ab_dtset_istatr)
      value = token%dtsets(idtset)%istatr
    case (ab_dtset_getkss)
      value = token%dtsets(idtset)%getkss
    case (ab_dtset_nnsclo)
      value = token%dtsets(idtset)%nnsclo
    case (ab_dtset_xclevel)
      value = token%dtsets(idtset)%xclevel
    case (ab_dtset_ntyppure)
      value = token%dtsets(idtset)%ntyppure
    case (ab_dtset_mqgrid)
      value = token%dtsets(idtset)%mqgrid
    case (ab_dtset_irdkss)
      value = token%dtsets(idtset)%irdkss
    case (ab_dtset_prtdensph)
      value = token%dtsets(idtset)%prtdensph
    case (ab_dtset_getxcart)
      value = token%dtsets(idtset)%getxcart
    case (ab_dtset_chkexit)
      value = token%dtsets(idtset)%chkexit
    case (ab_dtset_vacnum)
      value = token%dtsets(idtset)%vacnum
    case (ab_dtset_ortalg)
      value = token%dtsets(idtset)%ortalg
    case (ab_dtset_fft_opt_lob)
      value = token%dtsets(idtset)%fft_opt_lob
    case (ab_dtset_mkqmem)
      value = token%dtsets(idtset)%mkqmem
    case (ab_dtset_rf2elfd)
      value = token%dtsets(idtset)%rf2elfd
    case (ab_dtset_getacfd)
      value = token%dtsets(idtset)%getacfd

    case default
      errno = AB_ERROR_DTSET_ATT
    end select
  end subroutine ab_dtset_get_integer

  subroutine ab_dtset_get_real(dtsetsId, value, id, idtset, errno)
    integer, intent(in) :: dtsetsId
    integer, intent(in) :: id, idtset
    real(dp), intent(out) :: value
    integer, intent(out) :: errno

    type(dtsets_list), pointer :: token

    call ab_dtset_get_from_id(token, dtsetsId)
    if (.not. associated(token)) then
      errno = AB_ERROR_DTSET_OBJ
      return
    end if
    if (idtset < 0 .or. idtset > size(token%dtsets)) then
      errno = AB_ERROR_DTSET_ID
      return
    end if
    
    errno = AB_NO_ERROR
    select case (id)
    case (ab_dtset_slabwsrad)
      value = token%dtsets(idtset)%slabwsrad
    case (ab_dtset_tolmxf)
      value = token%dtsets(idtset)%tolmxf
    case (ab_dtset_charge)
      value = token%dtsets(idtset)%charge
    case (ab_dtset_td_maxene)
      value = token%dtsets(idtset)%td_maxene
    case (ab_dtset_bxctmindg)
      value = token%dtsets(idtset)%bxctmindg
    case (ab_dtset_exchmix)
      value = token%dtsets(idtset)%exchmix
    case (ab_dtset_omegasrdmax)
      value = token%dtsets(idtset)%omegasrdmax
    case (ab_dtset_kptnrm)
      value = token%dtsets(idtset)%kptnrm
    case (ab_dtset_slabzbeg)
      value = token%dtsets(idtset)%slabzbeg
    case (ab_dtset_vis)
      value = token%dtsets(idtset)%vis
    case (ab_dtset_userre)
      value = token%dtsets(idtset)%userre
    case (ab_dtset_dedlnn)
      value = token%dtsets(idtset)%dedlnn
    case (ab_dtset_mdftemp)
      value = token%dtsets(idtset)%mdftemp
    case (ab_dtset_ecutsigx)
      value = token%dtsets(idtset)%ecutsigx
    case (ab_dtset_wvl_hgrid)
      value = token%dtsets(idtset)%wvl_hgrid
    case (ab_dtset_recefermi)
      value = token%dtsets(idtset)%recefermi
    case (ab_dtset_vacwidth)
      value = token%dtsets(idtset)%vacwidth
    case (ab_dtset_bmass)
      value = token%dtsets(idtset)%bmass
    case (ab_dtset_freqsuslo)
      value = token%dtsets(idtset)%freqsuslo
    case (ab_dtset_rectolden)
      value = token%dtsets(idtset)%rectolden
    case (ab_dtset_userrd)
      value = token%dtsets(idtset)%userrd
    case (ab_dtset_userra)
      value = token%dtsets(idtset)%userra
    case (ab_dtset_userrc)
      value = token%dtsets(idtset)%userrc
    case (ab_dtset_userrb)
      value = token%dtsets(idtset)%userrb
    case (ab_dtset_wvl_crmult)
      value = token%dtsets(idtset)%wvl_crmult
    case (ab_dtset_diemix)
      value = token%dtsets(idtset)%diemix
    case (ab_dtset_gwencomp)
      value = token%dtsets(idtset)%gwencomp
    case (ab_dtset_ecutsm)
      value = token%dtsets(idtset)%ecutsm
    case (ab_dtset_freqremax)
      value = token%dtsets(idtset)%freqremax
    case (ab_dtset_dielam)
      value = token%dtsets(idtset)%dielam
    case (ab_dtset_pawovlp)
      value = token%dtsets(idtset)%pawovlp
    case (ab_dtset_cpus)
      value = token%dtsets(idtset)%cpus
    case (ab_dtset_ecuteps)
      value = token%dtsets(idtset)%ecuteps
    case (ab_dtset_rcut)
      value = token%dtsets(idtset)%rcut
    case (ab_dtset_qptnrm)
      value = token%dtsets(idtset)%qptnrm
    case (ab_dtset_diemixmag)
      value = token%dtsets(idtset)%diemixmag
    case (ab_dtset_alpha)
      value = token%dtsets(idtset)%alpha
    case (ab_dtset_dielng)
      value = token%dtsets(idtset)%dielng
    case (ab_dtset_mdwall)
      value = token%dtsets(idtset)%mdwall
    case (ab_dtset_sciss)
      value = token%dtsets(idtset)%sciss
    case (ab_dtset_friction)
      value = token%dtsets(idtset)%friction
    case (ab_dtset_dosdeltae)
      value = token%dtsets(idtset)%dosdeltae
    case (ab_dtset_kptrlen)
      value = token%dtsets(idtset)%kptrlen
    case (ab_dtset_zcut)
      value = token%dtsets(idtset)%zcut
    case (ab_dtset_mditemp)
      value = token%dtsets(idtset)%mditemp
    case (ab_dtset_tfnewton)
      value = token%dtsets(idtset)%tfnewton
    case (ab_dtset_strfact)
      value = token%dtsets(idtset)%strfact
    case (ab_dtset_nelect)
      value = token%dtsets(idtset)%nelect
    case (ab_dtset_effmass)
      value = token%dtsets(idtset)%effmass
    case (ab_dtset_fixmom)
      value = token%dtsets(idtset)%fixmom
    case (ab_dtset_fband)
      value = token%dtsets(idtset)%fband
    case (ab_dtset_freqspmax)
      value = token%dtsets(idtset)%freqspmax
    case (ab_dtset_diegap)
      value = token%dtsets(idtset)%diegap
    case (ab_dtset_strprecon)
      value = token%dtsets(idtset)%strprecon
    case (ab_dtset_tphysel)
      value = token%dtsets(idtset)%tphysel
    case (ab_dtset_spnorbscl)
      value = token%dtsets(idtset)%spnorbscl
    case (ab_dtset_omegasimax)
      value = token%dtsets(idtset)%omegasimax
    case (ab_dtset_ecutwfn)
      value = token%dtsets(idtset)%ecutwfn
    case (ab_dtset_wvl_cpmult)
      value = token%dtsets(idtset)%wvl_cpmult
    case (ab_dtset_dilatmx)
      value = token%dtsets(idtset)%dilatmx
    case (ab_dtset_pawecutdg)
      value = token%dtsets(idtset)%pawecutdg
    case (ab_dtset_diemac)
      value = token%dtsets(idtset)%diemac
    case (ab_dtset_wvl_fpmult)
      value = token%dtsets(idtset)%wvl_fpmult
    case (ab_dtset_soenergy)
      value = token%dtsets(idtset)%soenergy
    case (ab_dtset_eshift)
      value = token%dtsets(idtset)%eshift
    case (ab_dtset_noseinert)
      value = token%dtsets(idtset)%noseinert
    case (ab_dtset_freqsusin)
      value = token%dtsets(idtset)%freqsusin
    case (ab_dtset_diecut)
      value = token%dtsets(idtset)%diecut
    case (ab_dtset_tolwfr)
      value = token%dtsets(idtset)%tolwfr
    case (ab_dtset_wvl_frmult)
      value = token%dtsets(idtset)%wvl_frmult
    case (ab_dtset_boxcutmin)
      value = token%dtsets(idtset)%boxcutmin
    case (ab_dtset_spbroad)
      value = token%dtsets(idtset)%spbroad
    case (ab_dtset_rhoqpmix)
      value = token%dtsets(idtset)%rhoqpmix
    case (ab_dtset_ecut)
      value = token%dtsets(idtset)%ecut
    case (ab_dtset_recrcut)
      value = token%dtsets(idtset)%recrcut
    case (ab_dtset_dtion)
      value = token%dtsets(idtset)%dtion
    case (ab_dtset_tolvrs)
      value = token%dtsets(idtset)%tolvrs
    case (ab_dtset_tsmear)
      value = token%dtsets(idtset)%tsmear
    case (ab_dtset_tl_radius)
      value = token%dtsets(idtset)%tl_radius
    case (ab_dtset_vmass)
      value = token%dtsets(idtset)%vmass
    case (ab_dtset_tolrff)
      value = token%dtsets(idtset)%tolrff
    case (ab_dtset_slabzend)
      value = token%dtsets(idtset)%slabzend
    case (ab_dtset_ppmfrq)
      value = token%dtsets(idtset)%ppmfrq
    case (ab_dtset_toldff)
      value = token%dtsets(idtset)%toldff
    case (ab_dtset_toldfe)
      value = token%dtsets(idtset)%toldfe
    case (ab_dtset_stmbias)
      value = token%dtsets(idtset)%stmbias

    case default
      errno = AB_ERROR_DTSET_ATT
    end select
  end subroutine ab_dtset_get_real

  subroutine ab_dtset_get_integer_array(dtsetsId, values, n, id, idtset, errno)
    integer, intent(in) :: dtsetsId
    integer, intent(in) :: id, idtset, n
    integer, intent(out) :: values(n)
    integer, intent(out) :: errno

    type(dtsets_list), pointer :: token
    integer :: n_dt

    call ab_dtset_get_from_id(token, dtsetsId)
    if (.not. associated(token)) then
      errno = AB_ERROR_DTSET_OBJ
      return
    end if
    if (idtset < 0 .or. idtset > size(token%dtsets)) then
      errno = AB_ERROR_DTSET_ID
      return
    end if
    
    errno = AB_NO_ERROR
    select case (id)
    case (ab_dtset_algalch)
      n_dt = product(shape(token%dtsets(idtset)%algalch))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%algalch, (/ n_dt /))
      end if
    case (ab_dtset_kptrlatt)
      n_dt = product(shape(token%dtsets(idtset)%kptrlatt))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%kptrlatt, (/ n_dt /))
      end if
    case (ab_dtset_nloalg)
      n_dt = product(shape(token%dtsets(idtset)%nloalg))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%nloalg, (/ n_dt /))
      end if
    case (ab_dtset_dsifkpt)
      n_dt = product(shape(token%dtsets(idtset)%dsifkpt))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%dsifkpt, (/ n_dt /))
      end if
    case (ab_dtset_qprtrb)
      n_dt = product(shape(token%dtsets(idtset)%qprtrb))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%qprtrb, (/ n_dt /))
      end if
    case (ab_dtset_nband)
      n_dt = product(shape(token%dtsets(idtset)%nband))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%nband, (/ n_dt /))
      end if
    case (ab_dtset_iatfix)
      n_dt = product(shape(token%dtsets(idtset)%iatfix))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%iatfix, (/ n_dt /))
      end if
    case (ab_dtset_iatsph)
      n_dt = product(shape(token%dtsets(idtset)%iatsph))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%iatsph, (/ n_dt /))
      end if
    case (ab_dtset_bdberry)
      n_dt = product(shape(token%dtsets(idtset)%bdberry))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%bdberry, (/ n_dt /))
      end if
    case (ab_dtset_symafm)
      n_dt = product(shape(token%dtsets(idtset)%symafm))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%symafm, (/ n_dt /))
      end if
    case (ab_dtset_typat)
      n_dt = product(shape(token%dtsets(idtset)%typat))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%typat, (/ n_dt /))
      end if
    case (ab_dtset_w90lplot)
      n_dt = product(shape(token%dtsets(idtset)%w90lplot))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%w90lplot, (/ n_dt /))
      end if
    case (ab_dtset_numorb)
      n_dt = product(shape(token%dtsets(idtset)%numorb))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%numorb, (/ n_dt /))
      end if
    case (ab_dtset_rf3atpol)
      n_dt = product(shape(token%dtsets(idtset)%rf3atpol))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%rf3atpol, (/ n_dt /))
      end if
    case (ab_dtset_rf1dir)
      n_dt = product(shape(token%dtsets(idtset)%rf1dir))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%rf1dir, (/ n_dt /))
      end if
    case (ab_dtset_rfatpol)
      n_dt = product(shape(token%dtsets(idtset)%rfatpol))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%rfatpol, (/ n_dt /))
      end if
    case (ab_dtset_rf1atpol)
      n_dt = product(shape(token%dtsets(idtset)%rf1atpol))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%rf1atpol, (/ n_dt /))
      end if
    case (ab_dtset_bdgw)
      n_dt = product(shape(token%dtsets(idtset)%bdgw))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%bdgw, (/ n_dt /))
      end if
    case (ab_dtset_rf3dir)
      n_dt = product(shape(token%dtsets(idtset)%rf3dir))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%rf3dir, (/ n_dt /))
      end if
    case (ab_dtset_rf2dir)
      n_dt = product(shape(token%dtsets(idtset)%rf2dir))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%rf2dir, (/ n_dt /))
      end if
    case (ab_dtset_rfdir)
      n_dt = product(shape(token%dtsets(idtset)%rfdir))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%rfdir, (/ n_dt /))
      end if
    case (ab_dtset_kberry)
      n_dt = product(shape(token%dtsets(idtset)%kberry))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%kberry, (/ n_dt /))
      end if
    case (ab_dtset_ngfftdg)
      n_dt = product(shape(token%dtsets(idtset)%ngfftdg))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%ngfftdg, (/ n_dt /))
      end if
    case (ab_dtset_supercell)
      n_dt = product(shape(token%dtsets(idtset)%supercell))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%supercell, (/ n_dt /))
      end if
    case (ab_dtset_symrel)
      n_dt = product(shape(token%dtsets(idtset)%symrel))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%symrel, (/ n_dt /))
      end if
    case (ab_dtset_so_psp)
      n_dt = product(shape(token%dtsets(idtset)%so_psp))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%so_psp, (/ n_dt /))
      end if
    case (ab_dtset_istwfk)
      n_dt = product(shape(token%dtsets(idtset)%istwfk))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%istwfk, (/ n_dt /))
      end if
    case (ab_dtset_rf2atpol)
      n_dt = product(shape(token%dtsets(idtset)%rf2atpol))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%rf2atpol, (/ n_dt /))
      end if
    case (ab_dtset_ltypeorb)
      n_dt = product(shape(token%dtsets(idtset)%ltypeorb))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%ltypeorb, (/ n_dt /))
      end if
    case (ab_dtset_lexexch)
      n_dt = product(shape(token%dtsets(idtset)%lexexch))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%lexexch, (/ n_dt /))
      end if
    case (ab_dtset_w90cplot)
      n_dt = product(shape(token%dtsets(idtset)%w90cplot))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%w90cplot, (/ n_dt /))
      end if
    case (ab_dtset_lpawu)
      n_dt = product(shape(token%dtsets(idtset)%lpawu))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%lpawu, (/ n_dt /))
      end if
    case (ab_dtset_ngfft)
      n_dt = product(shape(token%dtsets(idtset)%ngfft))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%ngfft, (/ n_dt /))
      end if

    case default
      errno = AB_ERROR_DTSET_ATT
    end select
  end subroutine ab_dtset_get_integer_array

  subroutine ab_dtset_get_real_array(dtsetsId, values, n, id, idtset, errno)
    integer, intent(in) :: dtsetsId
    integer, intent(in) :: id, idtset, n
    real(dp), intent(out) :: values(n)
    integer, intent(out) :: errno

    type(dtsets_list), pointer :: token
    integer :: n_dt

    call ab_dtset_get_from_id(token, dtsetsId)
    if (.not. associated(token)) then
      errno = AB_ERROR_DTSET_OBJ
      return
    end if
    if (idtset < 0 .or. idtset > size(token%dtsets)) then
      errno = AB_ERROR_DTSET_ID
      return
    end if
    
    errno = AB_NO_ERROR
    select case (id)
    case (ab_dtset_rtheta)
      n_dt = product(shape(token%dtsets(idtset)%rtheta))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%rtheta, (/ n_dt /))
      end if
    case (ab_dtset_boxcenter)
      n_dt = product(shape(token%dtsets(idtset)%boxcenter))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%boxcenter, (/ n_dt /))
      end if
    case (ab_dtset_qptdm)
      n_dt = product(shape(token%dtsets(idtset)%qptdm))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%qptdm, (/ n_dt /))
      end if
    case (ab_dtset_xred_orig)
      n_dt = product(shape(token%dtsets(idtset)%xred_orig))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%xred_orig, (/ n_dt /))
      end if
    case (ab_dtset_kptns)
      n_dt = product(shape(token%dtsets(idtset)%kptns))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%kptns, (/ n_dt /))
      end if
    case (ab_dtset_ptcharge)
      n_dt = product(shape(token%dtsets(idtset)%ptcharge))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%ptcharge, (/ n_dt /))
      end if
    case (ab_dtset_qmass)
      n_dt = product(shape(token%dtsets(idtset)%qmass))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%qmass, (/ n_dt /))
      end if
    case (ab_dtset_mixalch)
      n_dt = product(shape(token%dtsets(idtset)%mixalch))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%mixalch, (/ n_dt /))
      end if
    case (ab_dtset_ratsph)
      n_dt = product(shape(token%dtsets(idtset)%ratsph))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%ratsph, (/ n_dt /))
      end if
    case (ab_dtset_vcutgeo)
      n_dt = product(shape(token%dtsets(idtset)%vcutgeo))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%vcutgeo, (/ n_dt /))
      end if
    case (ab_dtset_tnons)
      n_dt = product(shape(token%dtsets(idtset)%tnons))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%tnons, (/ n_dt /))
      end if
    case (ab_dtset_kpt)
      n_dt = product(shape(token%dtsets(idtset)%kpt))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%kpt, (/ n_dt /))
      end if
    case (ab_dtset_densty)
      n_dt = product(shape(token%dtsets(idtset)%densty))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%densty, (/ n_dt /))
      end if
    case (ab_dtset_corecs)
      n_dt = product(shape(token%dtsets(idtset)%corecs))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%corecs, (/ n_dt /))
      end if
    case (ab_dtset_atvshift)
      n_dt = product(shape(token%dtsets(idtset)%atvshift))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%atvshift, (/ n_dt /))
      end if
    case (ab_dtset_genafm)
      n_dt = product(shape(token%dtsets(idtset)%genafm))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%genafm, (/ n_dt /))
      end if
    case (ab_dtset_rprimd_orig)
      n_dt = product(shape(token%dtsets(idtset)%rprimd_orig))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%rprimd_orig, (/ n_dt /))
      end if
    case (ab_dtset_occ_orig)
      n_dt = product(shape(token%dtsets(idtset)%occ_orig))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%occ_orig, (/ n_dt /))
      end if
    case (ab_dtset_qpt)
      n_dt = product(shape(token%dtsets(idtset)%qpt))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%qpt, (/ n_dt /))
      end if
    case (ab_dtset_dmatpawu)
      n_dt = product(shape(token%dtsets(idtset)%dmatpawu))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%dmatpawu, (/ n_dt /))
      end if
    case (ab_dtset_kptgw)
      n_dt = product(shape(token%dtsets(idtset)%kptgw))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%kptgw, (/ n_dt /))
      end if
    case (ab_dtset_wtatcon)
      n_dt = product(shape(token%dtsets(idtset)%wtatcon))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%wtatcon, (/ n_dt /))
      end if
    case (ab_dtset_efield)
      n_dt = product(shape(token%dtsets(idtset)%efield))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%efield, (/ n_dt /))
      end if
    case (ab_dtset_jpawu)
      n_dt = product(shape(token%dtsets(idtset)%jpawu))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%jpawu, (/ n_dt /))
      end if
    case (ab_dtset_ziontypat)
      n_dt = product(shape(token%dtsets(idtset)%ziontypat))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%ziontypat, (/ n_dt /))
      end if
    case (ab_dtset_wtk)
      n_dt = product(shape(token%dtsets(idtset)%wtk))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%wtk, (/ n_dt /))
      end if
    case (ab_dtset_rcoord)
      n_dt = product(shape(token%dtsets(idtset)%rcoord))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%rcoord, (/ n_dt /))
      end if
    case (ab_dtset_acell_orig)
      n_dt = product(shape(token%dtsets(idtset)%acell_orig))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%acell_orig, (/ n_dt /))
      end if
    case (ab_dtset_shiftk)
      n_dt = product(shape(token%dtsets(idtset)%shiftk))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%shiftk, (/ n_dt /))
      end if
    case (ab_dtset_vel_orig)
      n_dt = product(shape(token%dtsets(idtset)%vel_orig))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%vel_orig, (/ n_dt /))
      end if
    case (ab_dtset_strtarget)
      n_dt = product(shape(token%dtsets(idtset)%strtarget))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%strtarget, (/ n_dt /))
      end if
    case (ab_dtset_amu)
      n_dt = product(shape(token%dtsets(idtset)%amu))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%amu, (/ n_dt /))
      end if
    case (ab_dtset_angdeg_orig)
      n_dt = product(shape(token%dtsets(idtset)%angdeg_orig))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%angdeg_orig, (/ n_dt /))
      end if
    case (ab_dtset_rprim_orig)
      n_dt = product(shape(token%dtsets(idtset)%rprim_orig))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%rprim_orig, (/ n_dt /))
      end if
    case (ab_dtset_spinat)
      n_dt = product(shape(token%dtsets(idtset)%spinat))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%spinat, (/ n_dt /))
      end if
    case (ab_dtset_znucl)
      n_dt = product(shape(token%dtsets(idtset)%znucl))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%znucl, (/ n_dt /))
      end if
    case (ab_dtset_upawu)
      n_dt = product(shape(token%dtsets(idtset)%upawu))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%upawu, (/ n_dt /))
      end if
    case (ab_dtset_quadmom)
      n_dt = product(shape(token%dtsets(idtset)%quadmom))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%quadmom, (/ n_dt /))
      end if
    case (ab_dtset_qptn)
      n_dt = product(shape(token%dtsets(idtset)%qptn))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%qptn, (/ n_dt /))
      end if
    case (ab_dtset_vprtrb)
      n_dt = product(shape(token%dtsets(idtset)%vprtrb))
      if (n_dt /= n) then
        errno = AB_ERROR_DTSET_SIZE
      else
        values = reshape(token%dtsets(idtset)%vprtrb, (/ n_dt /))
      end if

    case default
      errno = AB_ERROR_DTSET_ATT
    end select
  end subroutine ab_dtset_get_real_array

  subroutine ab_dtset_get_shape(dtsetsId, dims, ndim, id, idtset, errno)
    integer, intent(in) :: dtsetsId
    integer, intent(in) :: id, idtset
    integer, intent(out) :: dims(7), ndim
    integer, intent(out) :: errno

    type(dtsets_list), pointer :: token

    call ab_dtset_get_from_id(token, dtsetsId)
    if (.not. associated(token)) then
      errno = AB_ERROR_DTSET_OBJ
      return
    end if
    if (idtset < 0 .or. idtset > size(token%dtsets)) then
      errno = AB_ERROR_DTSET_ID
      return
    end if
    
    errno = AB_NO_ERROR
    select case (id)
    case (ab_dtset_rtheta)
      ndim = size(shape(token%dtsets(idtset)%rtheta))
      dims(1:ndim) = shape(token%dtsets(idtset)%rtheta)
    case (ab_dtset_boxcenter)
      ndim = size(shape(token%dtsets(idtset)%boxcenter))
      dims(1:ndim) = shape(token%dtsets(idtset)%boxcenter)
    case (ab_dtset_qptdm)
      ndim = size(shape(token%dtsets(idtset)%qptdm))
      dims(1:ndim) = shape(token%dtsets(idtset)%qptdm)
    case (ab_dtset_algalch)
      ndim = size(shape(token%dtsets(idtset)%algalch))
      dims(1:ndim) = shape(token%dtsets(idtset)%algalch)
    case (ab_dtset_kptrlatt)
      ndim = size(shape(token%dtsets(idtset)%kptrlatt))
      dims(1:ndim) = shape(token%dtsets(idtset)%kptrlatt)
    case (ab_dtset_nloalg)
      ndim = size(shape(token%dtsets(idtset)%nloalg))
      dims(1:ndim) = shape(token%dtsets(idtset)%nloalg)
    case (ab_dtset_xred_orig)
      ndim = size(shape(token%dtsets(idtset)%xred_orig))
      dims(1:ndim) = shape(token%dtsets(idtset)%xred_orig)
    case (ab_dtset_kptns)
      ndim = size(shape(token%dtsets(idtset)%kptns))
      dims(1:ndim) = shape(token%dtsets(idtset)%kptns)
    case (ab_dtset_ptcharge)
      ndim = size(shape(token%dtsets(idtset)%ptcharge))
      dims(1:ndim) = shape(token%dtsets(idtset)%ptcharge)
    case (ab_dtset_qmass)
      ndim = size(shape(token%dtsets(idtset)%qmass))
      dims(1:ndim) = shape(token%dtsets(idtset)%qmass)
    case (ab_dtset_dsifkpt)
      ndim = size(shape(token%dtsets(idtset)%dsifkpt))
      dims(1:ndim) = shape(token%dtsets(idtset)%dsifkpt)
    case (ab_dtset_qprtrb)
      ndim = size(shape(token%dtsets(idtset)%qprtrb))
      dims(1:ndim) = shape(token%dtsets(idtset)%qprtrb)
    case (ab_dtset_mixalch)
      ndim = size(shape(token%dtsets(idtset)%mixalch))
      dims(1:ndim) = shape(token%dtsets(idtset)%mixalch)
    case (ab_dtset_ratsph)
      ndim = size(shape(token%dtsets(idtset)%ratsph))
      dims(1:ndim) = shape(token%dtsets(idtset)%ratsph)
    case (ab_dtset_vcutgeo)
      ndim = size(shape(token%dtsets(idtset)%vcutgeo))
      dims(1:ndim) = shape(token%dtsets(idtset)%vcutgeo)
    case (ab_dtset_tnons)
      ndim = size(shape(token%dtsets(idtset)%tnons))
      dims(1:ndim) = shape(token%dtsets(idtset)%tnons)
    case (ab_dtset_nband)
      ndim = size(shape(token%dtsets(idtset)%nband))
      dims(1:ndim) = shape(token%dtsets(idtset)%nband)
    case (ab_dtset_iatfix)
      ndim = size(shape(token%dtsets(idtset)%iatfix))
      dims(1:ndim) = shape(token%dtsets(idtset)%iatfix)
    case (ab_dtset_iatsph)
      ndim = size(shape(token%dtsets(idtset)%iatsph))
      dims(1:ndim) = shape(token%dtsets(idtset)%iatsph)
    case (ab_dtset_kpt)
      ndim = size(shape(token%dtsets(idtset)%kpt))
      dims(1:ndim) = shape(token%dtsets(idtset)%kpt)
    case (ab_dtset_bdberry)
      ndim = size(shape(token%dtsets(idtset)%bdberry))
      dims(1:ndim) = shape(token%dtsets(idtset)%bdberry)
    case (ab_dtset_symafm)
      ndim = size(shape(token%dtsets(idtset)%symafm))
      dims(1:ndim) = shape(token%dtsets(idtset)%symafm)
    case (ab_dtset_densty)
      ndim = size(shape(token%dtsets(idtset)%densty))
      dims(1:ndim) = shape(token%dtsets(idtset)%densty)
    case (ab_dtset_corecs)
      ndim = size(shape(token%dtsets(idtset)%corecs))
      dims(1:ndim) = shape(token%dtsets(idtset)%corecs)
    case (ab_dtset_typat)
      ndim = size(shape(token%dtsets(idtset)%typat))
      dims(1:ndim) = shape(token%dtsets(idtset)%typat)
    case (ab_dtset_w90lplot)
      ndim = size(shape(token%dtsets(idtset)%w90lplot))
      dims(1:ndim) = shape(token%dtsets(idtset)%w90lplot)
    case (ab_dtset_atvshift)
      ndim = size(shape(token%dtsets(idtset)%atvshift))
      dims(1:ndim) = shape(token%dtsets(idtset)%atvshift)
    case (ab_dtset_numorb)
      ndim = size(shape(token%dtsets(idtset)%numorb))
      dims(1:ndim) = shape(token%dtsets(idtset)%numorb)
    case (ab_dtset_genafm)
      ndim = size(shape(token%dtsets(idtset)%genafm))
      dims(1:ndim) = shape(token%dtsets(idtset)%genafm)
    case (ab_dtset_rf3atpol)
      ndim = size(shape(token%dtsets(idtset)%rf3atpol))
      dims(1:ndim) = shape(token%dtsets(idtset)%rf3atpol)
    case (ab_dtset_rprimd_orig)
      ndim = size(shape(token%dtsets(idtset)%rprimd_orig))
      dims(1:ndim) = shape(token%dtsets(idtset)%rprimd_orig)
    case (ab_dtset_occ_orig)
      ndim = size(shape(token%dtsets(idtset)%occ_orig))
      dims(1:ndim) = shape(token%dtsets(idtset)%occ_orig)
    case (ab_dtset_qpt)
      ndim = size(shape(token%dtsets(idtset)%qpt))
      dims(1:ndim) = shape(token%dtsets(idtset)%qpt)
    case (ab_dtset_dmatpawu)
      ndim = size(shape(token%dtsets(idtset)%dmatpawu))
      dims(1:ndim) = shape(token%dtsets(idtset)%dmatpawu)
    case (ab_dtset_rf1dir)
      ndim = size(shape(token%dtsets(idtset)%rf1dir))
      dims(1:ndim) = shape(token%dtsets(idtset)%rf1dir)
    case (ab_dtset_rfatpol)
      ndim = size(shape(token%dtsets(idtset)%rfatpol))
      dims(1:ndim) = shape(token%dtsets(idtset)%rfatpol)
    case (ab_dtset_rf1atpol)
      ndim = size(shape(token%dtsets(idtset)%rf1atpol))
      dims(1:ndim) = shape(token%dtsets(idtset)%rf1atpol)
    case (ab_dtset_kptgw)
      ndim = size(shape(token%dtsets(idtset)%kptgw))
      dims(1:ndim) = shape(token%dtsets(idtset)%kptgw)
    case (ab_dtset_bdgw)
      ndim = size(shape(token%dtsets(idtset)%bdgw))
      dims(1:ndim) = shape(token%dtsets(idtset)%bdgw)
    case (ab_dtset_wtatcon)
      ndim = size(shape(token%dtsets(idtset)%wtatcon))
      dims(1:ndim) = shape(token%dtsets(idtset)%wtatcon)
    case (ab_dtset_efield)
      ndim = size(shape(token%dtsets(idtset)%efield))
      dims(1:ndim) = shape(token%dtsets(idtset)%efield)
    case (ab_dtset_jpawu)
      ndim = size(shape(token%dtsets(idtset)%jpawu))
      dims(1:ndim) = shape(token%dtsets(idtset)%jpawu)
    case (ab_dtset_ziontypat)
      ndim = size(shape(token%dtsets(idtset)%ziontypat))
      dims(1:ndim) = shape(token%dtsets(idtset)%ziontypat)
    case (ab_dtset_rf3dir)
      ndim = size(shape(token%dtsets(idtset)%rf3dir))
      dims(1:ndim) = shape(token%dtsets(idtset)%rf3dir)
    case (ab_dtset_wtk)
      ndim = size(shape(token%dtsets(idtset)%wtk))
      dims(1:ndim) = shape(token%dtsets(idtset)%wtk)
    case (ab_dtset_rcoord)
      ndim = size(shape(token%dtsets(idtset)%rcoord))
      dims(1:ndim) = shape(token%dtsets(idtset)%rcoord)
    case (ab_dtset_acell_orig)
      ndim = size(shape(token%dtsets(idtset)%acell_orig))
      dims(1:ndim) = shape(token%dtsets(idtset)%acell_orig)
    case (ab_dtset_rf2dir)
      ndim = size(shape(token%dtsets(idtset)%rf2dir))
      dims(1:ndim) = shape(token%dtsets(idtset)%rf2dir)
    case (ab_dtset_rfdir)
      ndim = size(shape(token%dtsets(idtset)%rfdir))
      dims(1:ndim) = shape(token%dtsets(idtset)%rfdir)
    case (ab_dtset_shiftk)
      ndim = size(shape(token%dtsets(idtset)%shiftk))
      dims(1:ndim) = shape(token%dtsets(idtset)%shiftk)
    case (ab_dtset_kberry)
      ndim = size(shape(token%dtsets(idtset)%kberry))
      dims(1:ndim) = shape(token%dtsets(idtset)%kberry)
    case (ab_dtset_ngfftdg)
      ndim = size(shape(token%dtsets(idtset)%ngfftdg))
      dims(1:ndim) = shape(token%dtsets(idtset)%ngfftdg)
    case (ab_dtset_vel_orig)
      ndim = size(shape(token%dtsets(idtset)%vel_orig))
      dims(1:ndim) = shape(token%dtsets(idtset)%vel_orig)
    case (ab_dtset_strtarget)
      ndim = size(shape(token%dtsets(idtset)%strtarget))
      dims(1:ndim) = shape(token%dtsets(idtset)%strtarget)
    case (ab_dtset_supercell)
      ndim = size(shape(token%dtsets(idtset)%supercell))
      dims(1:ndim) = shape(token%dtsets(idtset)%supercell)
    case (ab_dtset_amu)
      ndim = size(shape(token%dtsets(idtset)%amu))
      dims(1:ndim) = shape(token%dtsets(idtset)%amu)
    case (ab_dtset_symrel)
      ndim = size(shape(token%dtsets(idtset)%symrel))
      dims(1:ndim) = shape(token%dtsets(idtset)%symrel)
    case (ab_dtset_so_psp)
      ndim = size(shape(token%dtsets(idtset)%so_psp))
      dims(1:ndim) = shape(token%dtsets(idtset)%so_psp)
    case (ab_dtset_istwfk)
      ndim = size(shape(token%dtsets(idtset)%istwfk))
      dims(1:ndim) = shape(token%dtsets(idtset)%istwfk)
    case (ab_dtset_angdeg_orig)
      ndim = size(shape(token%dtsets(idtset)%angdeg_orig))
      dims(1:ndim) = shape(token%dtsets(idtset)%angdeg_orig)
    case (ab_dtset_rprim_orig)
      ndim = size(shape(token%dtsets(idtset)%rprim_orig))
      dims(1:ndim) = shape(token%dtsets(idtset)%rprim_orig)
    case (ab_dtset_rf2atpol)
      ndim = size(shape(token%dtsets(idtset)%rf2atpol))
      dims(1:ndim) = shape(token%dtsets(idtset)%rf2atpol)
    case (ab_dtset_ltypeorb)
      ndim = size(shape(token%dtsets(idtset)%ltypeorb))
      dims(1:ndim) = shape(token%dtsets(idtset)%ltypeorb)
    case (ab_dtset_spinat)
      ndim = size(shape(token%dtsets(idtset)%spinat))
      dims(1:ndim) = shape(token%dtsets(idtset)%spinat)
    case (ab_dtset_znucl)
      ndim = size(shape(token%dtsets(idtset)%znucl))
      dims(1:ndim) = shape(token%dtsets(idtset)%znucl)
    case (ab_dtset_upawu)
      ndim = size(shape(token%dtsets(idtset)%upawu))
      dims(1:ndim) = shape(token%dtsets(idtset)%upawu)
    case (ab_dtset_lexexch)
      ndim = size(shape(token%dtsets(idtset)%lexexch))
      dims(1:ndim) = shape(token%dtsets(idtset)%lexexch)
    case (ab_dtset_quadmom)
      ndim = size(shape(token%dtsets(idtset)%quadmom))
      dims(1:ndim) = shape(token%dtsets(idtset)%quadmom)
    case (ab_dtset_qptn)
      ndim = size(shape(token%dtsets(idtset)%qptn))
      dims(1:ndim) = shape(token%dtsets(idtset)%qptn)
    case (ab_dtset_w90cplot)
      ndim = size(shape(token%dtsets(idtset)%w90cplot))
      dims(1:ndim) = shape(token%dtsets(idtset)%w90cplot)
    case (ab_dtset_lpawu)
      ndim = size(shape(token%dtsets(idtset)%lpawu))
      dims(1:ndim) = shape(token%dtsets(idtset)%lpawu)
    case (ab_dtset_vprtrb)
      ndim = size(shape(token%dtsets(idtset)%vprtrb))
      dims(1:ndim) = shape(token%dtsets(idtset)%vprtrb)
    case (ab_dtset_ngfft)
      ndim = size(shape(token%dtsets(idtset)%ngfft))
      dims(1:ndim) = shape(token%dtsets(idtset)%ngfft)

    case default
      errno = AB_ERROR_DTSET_ATT
    end select
  end subroutine ab_dtset_get_shape
