TABLE OF CONTENTS


ABINIT/m_outvar_o_z [ Modules ]

[ Top ] [ Modules ]

NAME

  m_outvar_o_z

FUNCTION

COPYRIGHT

  Copyright (C) 1998-2018 ABINIT group (DCA, XG, GMR, MM)
  This file is distributed under the terms of the
  GNU General Public License, see ~abinit/COPYING
  or http://www.gnu.org/copyleft/gpl.txt .

PARENTS

CHILDREN

SOURCE

21 #if defined HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24 
25 #include "abi_common.h"
26 
27 module m_outvar_o_z
28 
29  use defs_basis
30  use defs_abitypes
31  use m_errors
32  use m_results_out
33  use m_abicore
34  use m_xmpi
35 
36  use m_geometry,     only : mkrdim, xred2xcart
37  use m_parser,       only : prttagm, prttagm_images
38 
39  implicit none
40 
41  private

ABINIT/outvar_o_z [ Functions ]

[ Top ] [ Functions ]

NAME

 outvar_o_z

FUNCTION

 Echo variables between acell and gw_ ... (by alphabetic order) for the ABINIT code.

INPUTS

  choice= 1 if echo of preprocessed variables, 2 if echo after call driver
  dtsets(0:ndtset_alloc)=<type datafiles_type>contains all input variables
  iout=unit number for echoed output
  jdtset_(0:ndtset_alloc)=actual index of the dataset (equal to dtsets(:)%jdtset)
  marr=maximum number of numbers in an array (might need to be increased ... !)
  multivals= <type ab_dimensions>  either 0 or 1 , depending whether the
     dimension has different values for different datasets
  mxvals= <type ab_dimensions>
     maximum size of some arrays along all datasets, including
         lpawu      =maximal value of input lpawu for all the datasets
         gw_nqlwl   =maximal value of input gw_nqlwl for all the datasets
         mband      =maximum number of bands
         natom      =maximal value of input natom for all the datasets
         natpawu    =maximal value of number of atoms on which +U is applied for all the datasets
         natsph     =maximal value of input natsph for all the datasets
         natvshift  =maximal value of input natvshift for all the datasets
         nconeq     =maximal value of input nconeq for all the datasets
         nimage     =maximal value of input nimage for all the datasets
         nkptgw     =maximal value of input nkptgw for all the datasets
         nkpt       =maximal value of input nkpt for all the datasets
         nnos       =maximal value of input nnos for all the datasets
         nqptdm     =maximal value of input nqptdm for all the datasets
         nspinor    =maximal value of input nspinor for all the datasets
         nsppol     =maximal value of input nsppol for all the datasets
         nsym       =maximum number of symmetries
         ntypat     =maximum number of type of atoms
         nzchempot  =maximal value of input nzchempot for all the datasets
  ncid= NetCDF handler
  ndtset=number of datasets
  ndtset_alloc=number of datasets, corrected for allocation of at least
      one data set. Use for most dimensioned arrays.
  npsp=number of pseudopotentials
  prtvol_glob= if 0, minimal output volume, if 1, no restriction.
  results_out(0:ndtset_alloc)=<type results_out_type>contains the results
   needed for outvars, including evolving variables
  timopt=input variable to modulate the timing

OUTPUT

NOTES

 Note that this routine is called only by the processor me==0 .
 In consequence, no use of message and wrtout routine.
 The lines of code needed to output the defaults are preserved
 (see last section of the routine, but are presently disabled)

  Note that acell, occ, rprim, xred and vel might have been modified by the
  computation, so that their values if choice=1 or choice=2 will differ.

PARENTS

      outvars

CHILDREN

      mkrdim,prtocc,prttagm,prttagm_images,xred2xcart

SOURCE

 114  subroutine outvar_o_z(choice,dtsets,iout,&
 115 & jdtset_,marr,multivals,mxvals,ncid,ndtset,ndtset_alloc,npsp,prtvol_glob,&
 116 & results_out,strimg,timopt)
 117 
 118 
 119 !This section has been created automatically by the script Abilint (TD).
 120 !Do not modify the following lines by hand.
 121 #undef ABI_FUNC
 122 #define ABI_FUNC 'outvar_o_z'
 123 !End of the abilint section
 124 
 125  implicit none
 126 
 127 !Arguments ------------------------------------
 128 !scalars
 129  integer,intent(in) :: choice,iout,marr,ndtset
 130  integer,intent(in) :: ndtset_alloc,prtvol_glob,ncid,npsp,timopt
 131 !arrays
 132  integer,intent(in) :: jdtset_(0:ndtset_alloc)
 133  type(ab_dimensions),intent(in) :: multivals,mxvals
 134  type(dataset_type),intent(in) :: dtsets(0:ndtset_alloc)
 135  type(results_out_type),intent(in) :: results_out(0:ndtset_alloc)
 136  character(len=8),intent(in) :: strimg(mxvals%nimage)
 137 
 138 !Local variables-------------------------------
 139 !scalars
 140  integer,parameter :: nkpt_max=50
 141  integer :: iat,icount,idtset,ii,iimage,ndtset_alloc_tmp
 142  integer :: narr!,jdtset
 143  integer :: multi_kptopt
 144  integer :: natom
 145  integer :: nimage,nnos,nsym
 146  integer :: ntypalch,ntypat,size1,size2,tnkpt,timopt_default,tmpimg0
 147  logical :: compute_static_images
 148 ! character(len=4) :: appen
 149  character(len=1) :: firstchar_gpu
 150 !arrays
 151  integer,allocatable :: narrm(:)
 152  integer,allocatable :: nimagem(:),prtimg(:,:)
 153  integer,allocatable :: intarr(:,:)
 154  real(dp) :: rprimd(3,3)
 155  real(dp),allocatable :: dprarr(:,:),dprarr_images(:,:,:)
 156  real(dp),allocatable :: xangst(:,:),xcart(:,:),xred(:,:)
 157  real(dp),allocatable :: xangst_(:,:,:,:),xcart_(:,:,:,:)
 158 
 159 ! *************************************************************************
 160 
 161 !###########################################################
 162 !### 01. Initial allocations and initialisations.
 163 
 164  ABI_ALLOCATE(dprarr,(marr,0:ndtset_alloc))
 165  ABI_ALLOCATE(dprarr_images,(marr,mxvals%nimage,0:ndtset_alloc))
 166  ABI_ALLOCATE(intarr,(marr,0:ndtset_alloc))
 167  ABI_ALLOCATE(narrm,(0:ndtset_alloc))
 168  ABI_ALLOCATE(nimagem,(0:ndtset_alloc))
 169  ABI_ALLOCATE(prtimg,(mxvals%nimage,0:ndtset_alloc))
 170 
 171  do idtset=0,ndtset_alloc
 172    nimagem(idtset)=dtsets(idtset)%nimage
 173  end do
 174 
 175  firstchar_gpu=' ';if (maxval(dtsets(1:ndtset_alloc)%use_gpu_cuda)>0) firstchar_gpu='-'
 176 
 177 !if(multivals%natom==0)natom=dtsets(1)%natom
 178  natom=dtsets(1)%natom
 179 !if(multivals%nimage==0)nimage=dtsets(1)%nimage
 180  nimage=dtsets(1)%nimage
 181 !if(multivals%nnos==0)nnos=dtsets(1)%nnos
 182  nnos=dtsets(1)%nnos
 183 !if(multivals%nsym==0)nsym=dtsets(1)%nsym
 184  nsym=-1;nsym=dtsets(1)%nsym
 185 !if(multivals%ntypalch==0)ntypalch=dtsets(1)%ntypalch
 186  ntypalch=dtsets(1)%ntypalch
 187 !if(multivals%ntypat==0)ntypat=dtsets(1)%ntypat
 188  ntypat=dtsets(1)%ntypat
 189 
 190 !###########################################################
 191 !### 02. Specific treatment for occopt, xangst, xcart, xred
 192 
 193 !Must compute xangst and xcart
 194  ABI_ALLOCATE(xangst_,(3,mxvals%natom,mxvals%nimage,0:ndtset_alloc))
 195  ABI_ALLOCATE(xcart_,(3,mxvals%natom,mxvals%nimage,0:ndtset_alloc))
 196  xangst_(:,:,:,:)=0.0_dp ; xcart_(:,:,:,:)=0.0_dp
 197 
 198  do idtset=1,ndtset_alloc
 199    natom=dtsets(idtset)%natom
 200    ABI_ALLOCATE(xred,(3,natom))
 201    ABI_ALLOCATE(xangst,(3,natom))
 202    ABI_ALLOCATE(xcart,(3,natom))
 203    do iimage=1,dtsets(idtset)%nimage
 204      xred(:,1:natom)=results_out(idtset)%xred(:,1:natom,iimage)
 205      call mkrdim(results_out(idtset)%acell(:,iimage),results_out(idtset)%rprim(:,:,iimage),rprimd)
 206 !    Compute xcart from xred and rprimd
 207      call xred2xcart(natom,rprimd,xcart,xred)
 208 !    Compute xangst from xcart
 209      xangst(:,:)=xcart(:,:)*Bohr_Ang
 210 !    Save the data
 211      xangst_(1:3,1:natom,iimage,idtset)=xangst(:,:)
 212      xcart_(1:3,1:natom,iimage,idtset)=xcart(:,:)
 213    end do
 214    if(dtsets(idtset)%nimage/=mxvals%nimage)then
 215      xangst_(1:3,1:natom,dtsets(idtset)%nimage+1:mxvals%nimage,idtset)=zero
 216      xcart_(1:3,1:natom,dtsets(idtset)%nimage+1:mxvals%nimage,idtset)=zero
 217    end if
 218    ABI_DEALLOCATE(xred)
 219    ABI_DEALLOCATE(xangst)
 220    ABI_DEALLOCATE(xcart)
 221  end do
 222 
 223 !###########################################################
 224 !### 03. Print all the input variables (O)
 225 !##
 226 
 227 !occ
 228 !The use of prttagm for occ if occopt>=2 is not possible because
 229 !the different k-point and spins must be separated on different lines ...
 230 !Also, if prtvol=-1 and NC file has been created, only print one dataset
 231  ndtset_alloc_tmp=ndtset_alloc
 232  if(ncid<0)ndtset_alloc_tmp=1
 233  call prtocc(dtsets,iout,jdtset_,mxvals,ndtset_alloc_tmp,nimagem,prtvol_glob,results_out,strimg)
 234 
 235  intarr(1,:)=dtsets(:)%occopt
 236  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'occopt','INT',0)
 237 
 238  dprarr(1,:)=dtsets(:)%omegasimax
 239  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'omegasimax','ENE',0)
 240 
 241  dprarr(1,:)=dtsets(:)%omegasrdmax
 242  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'omegasrdmax','ENE',0)
 243 
 244  intarr(1,:)=dtsets(:)%optcell
 245  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'optcell','INT',0)
 246 
 247  intarr(1,:)=dtsets(:)%optdriver
 248  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'optdriver','INT',0)
 249 
 250  intarr(1,:)=dtsets(:)%optforces
 251  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'optforces','INT',0)
 252 
 253  intarr(1,:)=dtsets(:)%optnlxccc
 254  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'optnlxccc','INT',0)
 255 
 256  intarr(1,:)=dtsets(:)%optstress
 257  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'optstress','INT',0)
 258 
 259  intarr(1,:)=dtsets(:)%orbmag
 260  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'orbmag','INT',0)
 261 
 262  intarr(1,:)=dtsets(:)%ortalg
 263  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'ortalg','INT',0,firstchar=firstchar_gpu)
 264 
 265 !###########################################################
 266 !### 03. Print all the input variables (P)
 267 !##
 268 
 269  intarr(1,:)=dtsets(:)%paral_atom
 270  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'paral_atom','INT',0, firstchar="-")
 271  !call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'paral_atom','INT',0)
 272 
 273  intarr(1,:)=dtsets(:)%paral_kgb
 274  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'paral_kgb','INT',0)
 275 
 276  intarr(1,:)=dtsets(:)%paral_rf
 277  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'paral_rf','INT',0)
 278 
 279  intarr(1,:)=dtsets(:)%pawcpxocc
 280  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawcpxocc','INT',0)
 281 
 282  intarr(1,:)=dtsets(:)%pawcross
 283  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawcross','INT',0)
 284 
 285  dprarr(1,:)=dtsets(:)%pawecutdg
 286  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'pawecutdg','ENE',0)
 287 
 288  intarr(1,:)=dtsets(:)%pawfatbnd
 289  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawfatbnd','INT',0)
 290 
 291  intarr(1,:)=dtsets(:)%pawlcutd
 292  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawlcutd','INT',0)
 293 
 294  intarr(1,:)=dtsets(:)%pawlmix
 295  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawlmix','INT',0)
 296 
 297  intarr(1,:)=dtsets(:)%pawmixdg
 298  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawmixdg','INT',0)
 299 
 300  intarr(1,:)=dtsets(:)%pawnhatxc
 301  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawnhatxc','INT',0)
 302 
 303  intarr(1,:)=dtsets(:)%pawnphi
 304  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawnphi','INT',0)
 305 
 306  intarr(1,:)=dtsets(:)%pawntheta
 307  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawntheta','INT',0)
 308 
 309  intarr(1,:)=dtsets(:)%pawnzlm
 310  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawnzlm','INT',0)
 311 
 312  intarr(1,:)=dtsets(:)%pawoptmix
 313  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawoptmix','INT',0)
 314 
 315  intarr(1,:)=dtsets(:)%pawoptosc
 316  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawoptosc','INT',0)
 317 
 318  dprarr(1,:)=dtsets(:)%pawovlp
 319  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawovlp','DPR',0)
 320 
 321  intarr(1,:)=dtsets(:)%pawprtdos
 322  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawprtdos','INT',0)
 323 
 324  intarr(1,:)=dtsets(:)%pawprtvol
 325  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawprtvol','INT',0)
 326 
 327  intarr(1,:)=dtsets(:)%pawprtwf
 328  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawprtwf','INT',0)
 329 
 330  intarr(1,:)=dtsets(:)%pawprt_b
 331  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawprt_b','INT',0)
 332 
 333  intarr(1,:)=dtsets(:)%pawprt_k
 334  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawprt_k','INT',0)
 335 
 336  intarr(1,:)=dtsets(:)%pawspnorb
 337  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawspnorb','INT',0)
 338 
 339  intarr(1,:)=dtsets(:)%pawstgylm
 340  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawstgylm','INT',0)
 341 
 342  intarr(1,:)=dtsets(:)%pawsushat
 343  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawsushat','INT',0)
 344 
 345  intarr(1,:)=dtsets(:)%pawujat
 346  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawujat','INT',0)
 347 
 348  dprarr(1,:)=dtsets(:)%pawujrad
 349  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawujrad','LEN',0)
 350 
 351  dprarr(1,:)=dtsets(:)%pawujv
 352  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawujv','ENE',0)
 353 
 354  intarr(1,:)=dtsets(:)%pawusecp
 355  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawusecp','INT',0)
 356 
 357  intarr(1,:)=dtsets(:)%pawxcdev
 358  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pawxcdev','INT',0)
 359 
 360 !pimass
 361  icount=0
 362  do idtset=0, ndtset_alloc
 363    do ii = 1, ntypat
 364      dprarr(ii,idtset) = dtsets(idtset)%pimass(ii)
 365      if (dtsets(idtset)%pimass(ii)/=dtsets(idtset)%amu_orig(ii,1)) icount=1
 366    end do ! end loop over ntypat
 367  end do ! end loop over datasets
 368  if (icount/=0) then
 369    call prttagm(dprarr,intarr,iout,jdtset_,1,marr,ntypat,narrm,ncid,ndtset_alloc,'pimass','DPR',0)
 370  end if
 371 
 372  intarr(1,:)=dtsets(:)%pimd_constraint
 373  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pimd_constraint','INT',0)
 374 
 375  intarr(1,:)=dtsets(:)%pitransform
 376  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'pitransform','INT',0)
 377 
 378  dprarr(1,:)=dtsets(:)%polcen(1)
 379  dprarr(2,:)=dtsets(:)%polcen(2)
 380  dprarr(3,:)=dtsets(:)%polcen(3)
 381  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,3,narrm,ncid,ndtset_alloc,'polcen','DPR',0)
 382 
 383  intarr(1,:)=dtsets(:)%plowan_bandi
 384  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'plowan_bandi','INT',0)
 385 
 386  intarr(1,:)=dtsets(:)%plowan_bandf
 387  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'plowan_bandf','INT',0)
 388 
 389  intarr(1,:)=dtsets(:)%plowan_compute
 390  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'plowan_compute','INT',0)
 391 
 392  intarr(1,:)=dtsets(:)%plowan_natom
 393  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'plowan_natom','INT',0)
 394 
 395  intarr(1,:)=dtsets(:)%plowan_nt
 396  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'plowan_nt','INT',0)
 397 
 398  intarr(1,:)=dtsets(:)%plowan_realspace
 399  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'plowan_realspace','INT',0)
 400 
 401 
 402 !plowan_it
 403  narr=100
 404  do idtset=0,ndtset_alloc       ! specific size for each dataset
 405    narrm(idtset)=3*dtsets(idtset)%plowan_nt
 406    if(idtset==0)narrm(idtset)=100
 407    if (narrm(idtset)>0.and.dtsets(idtset)%plowan_compute>0) then
 408      intarr(1:narrm(idtset),idtset)=dtsets(idtset)%plowan_it(1:narrm(idtset))
 409    end if
 410  end do
 411  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,narr,narrm,ncid,ndtset_alloc,'plowan_it','INT',1)
 412 
 413 !plowan_iatom
 414  narr=mxvals%natom
 415  do idtset=0,ndtset_alloc       ! specific size for each dataset
 416    narrm(idtset)=dtsets(idtset)%plowan_natom
 417    if(idtset==0)narrm(idtset)=mxvals%natom
 418    if (narrm(idtset)>0.and.dtsets(idtset)%plowan_compute>0) then
 419      intarr(1:narrm(idtset),idtset)=dtsets(idtset)%plowan_iatom(1:narrm(idtset))
 420    end if
 421  end do
 422  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,narr,narrm,ncid,ndtset_alloc,'plowan_iatom','INT',1)
 423 
 424 !plowan_nbl
 425  narr=mxvals%natom
 426  do idtset=0,ndtset_alloc       ! specific size for each dataset
 427    narrm(idtset)=dtsets(idtset)%plowan_natom
 428    if(idtset==0)narrm(idtset)=mxvals%natom
 429    if (narrm(idtset)>0.and.dtsets(idtset)%plowan_compute>0) then
 430      intarr(1:narrm(idtset),idtset)=dtsets(idtset)%plowan_nbl(1:narrm(idtset))
 431    end if
 432  end do
 433  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,narr,narrm,ncid,ndtset_alloc,'plowan_nbl','INT',1)
 434 
 435 !plowan_lcalc
 436  narr=12*mxvals%natom
 437  do idtset=0,ndtset_alloc       ! specific size for each dataset
 438    narrm(idtset)=sum(dtsets(idtset)%plowan_nbl(1:dtsets(idtset)%plowan_natom))
 439    if(idtset==0)narrm(idtset)=12*mxvals%natom
 440    if (narrm(idtset)>0.and.dtsets(idtset)%plowan_compute>0) then
 441      intarr(1:narrm(idtset),idtset)=dtsets(idtset)%plowan_lcalc(1:narrm(idtset))
 442    end if
 443  end do
 444  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,narr,narrm,ncid,ndtset_alloc,'plowan_lcalc','INT',1)
 445 
 446 !plowan_projcalc
 447  narr=12*mxvals%natom
 448  do idtset=0,ndtset_alloc       ! specific size for each dataset
 449    narrm(idtset)=sum(dtsets(idtset)%plowan_nbl(1:dtsets(idtset)%plowan_natom))
 450    if(idtset==0)narrm(idtset)=12*mxvals%natom
 451    if (narrm(idtset)>0.and.dtsets(idtset)%plowan_compute>0) then
 452      intarr(1:narrm(idtset),idtset)=dtsets(idtset)%plowan_projcalc(1:narrm(idtset))
 453    end if
 454  end do
 455  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,narr,narrm,ncid,ndtset_alloc,'plowan_projcalc','INT',1)
 456 
 457 
 458  intarr(1,:)=dtsets(:)%posdoppler
 459  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'posdoppler','INT',0)
 460 
 461  intarr(1,:)=dtsets(:)%positron
 462  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'positron','INT',0)
 463 
 464  intarr(1,:)=dtsets(:)%posnstep
 465  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'posnstep','INT',0)
 466 
 467  dprarr(1,:)=dtsets(:)%posocc
 468  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'posocc','DPR',0)
 469 
 470  dprarr(1,:)=dtsets(:)%postoldfe
 471  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'postoldfe','ENE',0)
 472 
 473  dprarr(1,:)=dtsets(:)%postoldff
 474  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'postoldff','DPR',0)
 475 
 476  dprarr(1,:)=dtsets(:)%ppmfrq
 477  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'ppmfrq','ENE',0)
 478 
 479  intarr(1,:)=dtsets(:)%ppmodel
 480  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'ppmodel','INT',0)
 481 
 482 
 483  intarr(1,:)=dtsets(:)%prepanl
 484  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prepanl','INT',0)
 485 
 486  intarr(1,:)=dtsets(:)%prepgkk
 487  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prepgkk','INT',0)
 488 
 489 !prtatlist
 490  if(multivals%natom==0)then
 491    do idtset=0,ndtset_alloc
 492      intarr(1:natom,idtset)=dtsets(idtset)%prtatlist(1:natom)
 493    end do
 494    intarr(1:mxvals%natom,0)=(/ (ii,ii=1,mxvals%natom) /)
 495    call prttagm(dprarr,intarr,iout,jdtset_,4,marr,natom,narrm,ncid,ndtset_alloc,'prtatlist','INT',0)
 496  else
 497 !  This thing will disapear with new generalized prttagm
 498  end if
 499 
 500  intarr(1,:)=dtsets(:)%prtbbb
 501  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtbbb','INT',0)
 502 
 503  intarr(1,:)=dtsets(:)%prtbltztrp
 504  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtbltztrp','INT',0)
 505 
 506  intarr(1,:)=dtsets(:)%prtcif
 507  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtcif','INT',0)
 508 
 509  intarr(1,:)=dtsets(:)%prtden
 510  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtden','INT',0)
 511 
 512  intarr(1,:)=dtsets(:)%prtdensph
 513  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtdensph','INT',0)
 514 
 515  intarr(1,:)=dtsets(:)%prtdos
 516  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtdos','INT',0)
 517 
 518  intarr(1,:)=dtsets(:)%prtdosm
 519  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtdosm','INT',0)
 520 
 521  intarr(1,:)=dtsets(:)%prtebands
 522  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtebands','INT',0)
 523 
 524  intarr(1,:)=dtsets(:)%prtefg
 525  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtefg','INT',0)
 526 
 527  intarr(1,:)=dtsets(:)%prtefmas
 528  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtefmas','INT',0)
 529 
 530  intarr(1,:)=dtsets(:)%prteig
 531  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prteig','INT',0)
 532 
 533  intarr(1,:)=dtsets(:)%prtelf
 534  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtelf','INT',0)
 535 
 536  intarr(1,:)=dtsets(:)%prtfc
 537  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtfc','INT',0)
 538 
 539  intarr(1,:)=dtsets(:)%prtfull1wf
 540  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtfull1wf','INT',0)
 541 
 542  intarr(1,:)=dtsets(:)%prtfsurf
 543  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtfsurf','INT',0)
 544 
 545  intarr(1,:)=dtsets(:)%prtgden
 546  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtgden','INT',0)
 547 
 548  intarr(1,:)=dtsets(:)%prtgeo
 549  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtgeo','INT',0)
 550 
 551  intarr(1,:)=dtsets(:)%prtgkk
 552  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtgkk','INT',0)
 553 
 554  intarr(1,:)=dtsets(:)%prtgsr
 555  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtgsr','INT',0)
 556 
 557  intarr(1,:)=dtsets(:)%prtkden
 558  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtkden','INT',0)
 559 
 560  intarr(1,:)=dtsets(:)%prtlden
 561  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtlden','INT',0)
 562 
 563  intarr(1,:)=dtsets(:)%prtnabla
 564  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtnabla','INT',0)
 565 
 566 
 567  intarr(1,:)=dtsets(:)%prtphbands
 568  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtphbands','INT',0)
 569 
 570  intarr(1,:)=dtsets(:)%prtphdos
 571  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtphdos','INT',0)
 572 
 573  intarr(1,:)=dtsets(:)%prtphsurf
 574  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtphsurf','INT',0)
 575 
 576  intarr(1,:)=dtsets(:)%prtposcar
 577  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtposcar','INT',0)
 578 
 579  intarr(1,:)=dtsets(:)%prtpot
 580  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtpot','INT',0)
 581 
 582  intarr(1,:)=dtsets(:)%prtpsps
 583  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtpsps','INT',0)
 584 
 585  intarr(1,:)=dtsets(:)%prtspcur
 586  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtspcur','INT',0)
 587 
 588  intarr(1,:)=dtsets(:)%prtstm
 589  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtstm','INT',0)
 590 
 591  intarr(1,:)=dtsets(:)%prtsuscep
 592  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtsuscep','INT',0)
 593 
 594  intarr(1,:)=dtsets(:)%prtvclmb
 595  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtvclmb','INT',0)
 596 
 597  intarr(1,:)=dtsets(:)%prtvha
 598  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtvha','INT',0)
 599 
 600  intarr(1,:)=dtsets(:)%prtvhxc
 601  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtvhxc','INT',0)
 602 
 603  intarr(1,:)=dtsets(:)%prtkbff
 604  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtkbff','INT',0)
 605 
 606  intarr(1,:)=dtsets(:)%prtvol
 607  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtvol','INT',0)
 608 
 609  intarr(1,:)=dtsets(:)%prtvolimg
 610  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtvolimg','INT',0)
 611 
 612  intarr(1,:)=dtsets(:)%prtvpsp
 613  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtvpsp','INT',0)
 614 
 615  intarr(1,:)=dtsets(:)%prtvxc
 616  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtvxc','INT',0)
 617 
 618  intarr(1,:)=dtsets(:)%prtwant
 619  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtwant','INT',0)
 620 
 621  intarr(1,:)=dtsets(:)%prtwf
 622  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtwf','INT',0)
 623 
 624  intarr(1,:)=dtsets(:)%prtwf_full
 625  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtwf_full','INT',0)
 626 
 627  intarr(1,:)=dtsets(:)%prtxml
 628  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prtxml','INT',0)
 629 
 630 !prt1dm
 631  intarr(1,:)=dtsets(:)%prt1dm
 632  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'prt1dm','INT',0)
 633 
 634  do idtset=0, ndtset_alloc
 635    do ii = 1, ntypat
 636      dprarr(ii,idtset) = dtsets(idtset)%ptcharge(ii)
 637    end do ! end loop over ntypat
 638  end do ! end loop over datasets
 639  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,ntypat,narrm,ncid,ndtset_alloc,'ptcharge','DPR',0)
 640 
 641  intarr(1,:)=dtsets(:)%ptgroupma
 642  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'ptgroupma','INT',0)
 643 
 644  dprarr(1,:)=dtsets(:)%pvelmax(1)
 645  dprarr(2,:)=dtsets(:)%pvelmax(2)
 646  dprarr(3,:)=dtsets(:)%pvelmax(3)
 647  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,3,narrm,ncid,ndtset_alloc,'pvelmax','DPR',0)
 648 
 649  dprarr(1,:)=dtsets(:)%pw_unbal_thresh
 650  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'pw_unbal_thresh','DPR',0)
 651 
 652 !###########################################################
 653 !### 03. Print all the input variables (Q)
 654 !##
 655 
 656 !qmass
 657  narr=nnos ! default size for all datasets
 658  do idtset=0,ndtset_alloc       ! specific size for each dataset
 659    narrm(idtset)=dtsets(idtset)%nnos
 660    if(idtset==0)narrm(idtset)=mxvals%nnos
 661    if (narrm(idtset)>0) then
 662      dprarr(1:narrm(idtset),idtset)=dtsets(idtset)%qmass(1:narrm(idtset))
 663    end if
 664  end do
 665  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,narr,&
 666 & narrm,ncid,ndtset_alloc,'qmass','DPR',&
 667 & multivals%nnos)
 668 
 669  intarr(1,:)=dtsets(:)%qprtrb(1)
 670  intarr(2,:)=dtsets(:)%qprtrb(2)
 671  intarr(3,:)=dtsets(:)%qprtrb(3)
 672  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,3,narrm,ncid,ndtset_alloc,'qprtrb','INT',0)
 673 
 674  dprarr(1,:)=dtsets(:)%qptn(1)
 675  dprarr(2,:)=dtsets(:)%qptn(2)
 676  dprarr(3,:)=dtsets(:)%qptn(3)
 677  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,3,narrm,ncid,ndtset_alloc,'qpt','DPR',0)
 678 
 679 !qptdm
 680  narr=3*dtsets(1)%nqptdm ! default size for all datasets
 681  do idtset=0,ndtset_alloc       ! specific size for each dataset
 682    if(idtset/=0)then
 683      narrm(idtset)=3*dtsets(idtset)%nqptdm
 684      if (narrm(idtset)>0)&
 685 &     dprarr(1:narrm(idtset),idtset)=&
 686 &     reshape(dtsets(idtset)%qptdm(1:3,&
 687 &     1:dtsets(idtset)%nqptdm),&
 688 &     (/ narrm(idtset) /) )
 689    else
 690      narrm(idtset)=3*mxvals%nqptdm
 691      if (narrm(idtset)>0)&
 692 &     dprarr(1:narrm(idtset),idtset)=&
 693 &     reshape(dtsets(idtset)%qptdm(1:3,&
 694 &     1:mxvals%nqptdm),&
 695 &     (/ narrm(idtset) /) )
 696    end if
 697  end do
 698  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,narr,&
 699 & narrm,ncid,ndtset_alloc,'qptdm','DPR',&
 700 & multivals%nqptdm)
 701 
 702  do idtset=0, ndtset_alloc
 703    do ii = 1, ntypat
 704      dprarr(ii,idtset) = dtsets(idtset)%quadmom(ii)
 705    end do ! end loop over ntypat
 706  end do ! end loop over datasets
 707  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,ntypat,narrm,ncid,ndtset_alloc,'quadmom','DPR',0)
 708 
 709 !###########################################################
 710 !### 03. Print all the input variables (R)
 711 !##
 712 
 713 !variables used for the random positions in unit cell
 714  intarr(1,:)=dtsets(:)%random_atpos
 715  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'random_atpos','INT',0)
 716 
 717  do idtset=0, ndtset_alloc
 718    do ii = 1, ntypat
 719      dprarr(ii,idtset) = dtsets(idtset)%ratsph(ii)
 720    end do ! end loop over ntypat
 721  end do ! end loop over datasets
 722  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,ntypat,narrm,ncid,ndtset_alloc,'ratsph','LEN',0)
 723 
 724  dprarr = zero
 725  dprarr(1,:) = dtsets(:)%ratsph_extra
 726  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'ratsph_extra','LEN',0)
 727 
 728  dprarr(1,:)=dtsets(:)%rcut
 729  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'rcut','LEN',0)
 730 
 731 !Variables used for recursion method
 732  dprarr(1,:)=dtsets(:)%recefermi
 733  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'recefermi','ENE',0)
 734 
 735  intarr(1,0:ndtset_alloc)=dtsets(0:ndtset_alloc)%recgratio
 736  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'recgratio','INT',0)
 737 
 738  intarr(1,:)=dtsets(:)%recnpath
 739  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'recnpath','INT',0)
 740 
 741  intarr(1,:)=dtsets(:)%recnrec
 742  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'recnrec','INT',0)
 743 
 744  intarr(1,:)=dtsets(:)%recptrott
 745  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'recptrott','INT',0)
 746 
 747  dprarr(1,:)=dtsets(:)%recrcut
 748  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'recrcut','LEN',0)
 749 
 750  intarr(1,:)=dtsets(:)%rectesteg
 751  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'rectesteg','INT',0)
 752 
 753  dprarr(1,:)=dtsets(:)%rectolden
 754  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'rectolden','DPR',0)
 755 
 756  dprarr(1,:)=dtsets(:)%red_dfield(1)    !!HONG
 757  dprarr(2,:)=dtsets(:)%red_dfield(2)
 758  dprarr(3,:)=dtsets(:)%red_dfield(3)
 759  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,3,narrm,ncid,ndtset_alloc,'red_dfield','DPR',0)
 760 
 761 
 762  dprarr(1,:)=dtsets(:)%red_efield(1)    !!HONG
 763  dprarr(2,:)=dtsets(:)%red_efield(2)
 764  dprarr(3,:)=dtsets(:)%red_efield(3)
 765  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,3,narrm,ncid,ndtset_alloc,'red_efield','DPR',0)
 766 
 767  dprarr(1,:)=dtsets(:)%red_efieldbar(1)   !!HONG
 768  dprarr(2,:)=dtsets(:)%red_efieldbar(2)
 769  dprarr(3,:)=dtsets(:)%red_efieldbar(3)
 770  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,3,narrm,ncid,ndtset_alloc,'red_efieldbar','DPR',0)
 771 
 772  intarr(1,:)=dtsets(:)%restartxf
 773  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'restartxf','INT',0)
 774 
 775  intarr(1,:)=dtsets(:)%rfasr
 776  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'rfasr','INT',0)
 777 
 778  intarr(1,:)=dtsets(:)%rfatpol(1)
 779  intarr(2,:)=dtsets(:)%rfatpol(2)
 780  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,2,narrm,ncid,ndtset_alloc,'rfatpol','INT',0)
 781 
 782  intarr(1,:)=dtsets(:)%rfddk
 783  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'rfddk','INT',0)
 784 
 785  intarr(1,:)=dtsets(:)%rfdir(1)
 786  intarr(2,:)=dtsets(:)%rfdir(2)
 787  intarr(3,:)=dtsets(:)%rfdir(3)
 788  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,3,narrm,ncid,ndtset_alloc,'rfdir','INT',0)
 789 
 790  intarr(1,:)=dtsets(:)%rfelfd
 791  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'rfelfd','INT',0)
 792 
 793  intarr(1,:)=dtsets(:)%rfmagn
 794  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'rfmagn','INT',0)
 795 
 796  intarr(1,:)=dtsets(:)%rfmeth
 797  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'rfmeth','INT',0)
 798 
 799  intarr(1,:)=dtsets(:)%rfphon
 800  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'rfphon','INT',0)
 801 
 802  intarr(1,:)=dtsets(:)%rfstrs
 803  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'rfstrs','INT',0)
 804 
 805  intarr(1,:)=dtsets(:)%rfuser
 806  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'rfuser','INT',0)
 807 
 808  intarr(1,:)=dtsets(:)%rf2_dkdk
 809  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'rf2_dkdk','INT',0)
 810 
 811  intarr(1,:)=dtsets(:)%rf2_dkde
 812  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'rf2_dkde','INT',0)
 813 
 814  intarr(1,:)=dtsets(:)%rf2_pert1_dir(1)
 815  intarr(2,:)=dtsets(:)%rf2_pert1_dir(2)
 816  intarr(3,:)=dtsets(:)%rf2_pert1_dir(3)
 817  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,3,narrm,ncid,ndtset_alloc,'rf2_pert1_dir','INT',0)
 818 
 819  intarr(1,:)=dtsets(:)%rf2_pert2_dir(1)
 820  intarr(2,:)=dtsets(:)%rf2_pert2_dir(2)
 821  intarr(3,:)=dtsets(:)%rf2_pert2_dir(3)
 822  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,3,narrm,ncid,ndtset_alloc,'rf2_pert2_dir','INT',0)
 823 
 824  dprarr(1,:)=dtsets(:)%rhoqpmix
 825  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'rhoqpmix','DPR',0)
 826 
 827 !rprim
 828  prtimg(:,:)=1
 829  do idtset=0,ndtset_alloc
 830    narrm(idtset)=9
 831    do iimage=1,nimagem(idtset)
 832      if (narrm(idtset)>0) then
 833        dprarr_images(1:narrm(idtset),iimage,idtset)=&
 834 &       reshape(results_out(idtset)%rprim(1:3,1:3,iimage), (/ narrm(idtset) /) )
 835      end if
 836    end do
 837  end do
 838  call prttagm_images(dprarr_images,iout,jdtset_,-2,marr,narrm,ncid,ndtset_alloc,'rprim','DPR',&
 839 & mxvals%nimage,nimagem,ndtset,prtimg,strimg,forceprint=2)
 840 
 841 
 842 !###########################################################
 843 !### 03. Print all the input variables (S)
 844 !##
 845 
 846 !shiftk (printed only when kptopt>0)
 847  if(sum((dtsets(1:ndtset_alloc)%kptopt)**2)/=0)then
 848    multi_kptopt=0
 849    dprarr(:,0)=0.0_dp
 850    narr=3*dtsets(1)%nshiftk ! default size for all datasets
 851    do idtset=1,ndtset_alloc       ! specific size for each dataset
 852      narrm(idtset)=3*dtsets(idtset)%nshiftk
 853      if (narrm(idtset)>0) then
 854        dprarr(1:narrm(idtset),idtset)=&
 855 &       reshape(dtsets(idtset)%shiftk(1:3,1:dtsets(idtset)%nshiftk),&
 856 &       (/ narrm(idtset) /) )
 857      end if
 858      if(dtsets(idtset)%kptopt<=0)then
 859        narrm(idtset)=0
 860        multi_kptopt=1
 861      end if
 862    end do
 863    call prttagm(dprarr,intarr,iout,jdtset_,1,marr,narr,&
 864 &   narrm,ncid,ndtset_alloc,'shiftk','DPR',&
 865 &   multivals%nshiftk)
 866 !  End of test to see whether kptopt/=0 for some dataset
 867  end if
 868 
 869  intarr(1,:)=dtsets(:)%signperm
 870  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'signperm','INT',0)
 871 
 872  dprarr(1,:)=dtsets(:)%slabwsrad
 873  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'slabwsrad','DPR',0)
 874 
 875  dprarr(1,:)=dtsets(:)%slabzbeg
 876  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'slabzbeg','DPR',0)
 877 
 878  dprarr(1,:)=dtsets(:)%slabzend
 879  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'slabzend','DPR',0)
 880 
 881  intarr(1,:)=dtsets(:)%slk_rankpp
 882  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'slk_rankpp','INT',0)
 883 
 884  intarr(1,:)=dtsets(:)%smdelta
 885  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'smdelta','INT',0)
 886 
 887  do idtset=0,ndtset_alloc
 888    intarr(1:npsp,idtset)=dtsets(idtset)%so_psp(1:npsp)
 889  end do
 890  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,npsp,narrm,ncid,ndtset_alloc,'so_psp','INT',0)
 891 
 892  dprarr(1,:)=dtsets(:)%spbroad
 893  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'spbroad','ENE',0)
 894 
 895  intarr(1,:)=dtsets(:)%spgroup
 896  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'spgroup','INT',0)
 897 
 898 !spinat
 899  dprarr(:,0)=0.0_dp
 900  narr=3*natom ! default size for all datasets
 901  do idtset=1,ndtset_alloc       ! specific size for each dataset
 902    narrm(idtset)=3*dtsets(idtset)%natom
 903    if (narrm(idtset)>0) then
 904      dprarr(1:narrm(idtset),idtset)=&
 905 &     reshape(dtsets(idtset)%spinat(1:3,1:dtsets(idtset)%natom),&
 906 &     (/ narrm(idtset) /) )
 907    end if
 908    if(sum(abs( dtsets(idtset)%spinat(1:3,1:dtsets(idtset)%natom))) < tol12 )then
 909      narrm(idtset)=0
 910    end if
 911  end do
 912  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,narr,&
 913 & narrm,ncid,ndtset_alloc,'spinat','DPR',&
 914 & multivals%natom)
 915 
 916  dprarr(1,:)=dtsets(:)%spinmagntarget
 917  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'spinmagntarget','DPR',0)
 918 
 919  intarr(1,:)=dtsets(:)%spmeth
 920  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'spmeth','INT',0)
 921 
 922  dprarr(1,:)=dtsets(:)%spnorbscl
 923  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'spnorbscl','DPR',0)
 924 
 925  dprarr(1,:)=dtsets(:)%stmbias
 926  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'stmbias','DPR',0)
 927 
 928  dprarr(1,:)=dtsets(:)%strfact
 929  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'strfact','DPR',0)
 930 
 931  intarr(1,:)=dtsets(:)%string_algo
 932  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'string_algo','INT',0)
 933 
 934  do ii=1,6
 935    dprarr(ii,:)=dtsets(:)%strtarget(ii)
 936  end do
 937  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,6,narrm,ncid,ndtset_alloc,'strtarget','DPR',0)
 938 
 939 !strten
 940  if(choice==2)then
 941    prtimg(:,:)=1
 942    do idtset=0,ndtset_alloc       ! specific size for each dataset
 943      compute_static_images=(dtsets(idtset)%istatimg>0)
 944      narrm(idtset)=6
 945      if(dtsets(idtset)%iscf>=0)then
 946        do iimage=1,dtsets(idtset)%nimage
 947          if (narrm(idtset)>0) then
 948            dprarr_images(1:narrm(idtset),iimage,idtset)=&
 949 &           results_out(idtset)%strten(:,iimage)
 950          end if
 951          if(.not.(dtsets(idtset)%dynimage(iimage)==1.or.compute_static_images))then
 952            prtimg(iimage,idtset)=0
 953          end if
 954        end do
 955      else
 956        narrm(idtset)=0
 957      end if
 958    end do
 959 !  This is a trick to force printing of strten even if zero, still not destroying the value of nimagem(0).
 960    tmpimg0=nimagem(0)
 961    nimagem(0)=0
 962    call prttagm_images(dprarr_images,iout,jdtset_,2,&
 963 &   marr,narrm,ncid,ndtset_alloc,'strten','DPR',&
 964 &   mxvals%nimage,nimagem,ndtset,prtimg,strimg)
 965    nimagem(0)=tmpimg0
 966  end if
 967 
 968 !symafm
 969  intarr(:,0)=1
 970  narr=nsym ! default size for all datasets
 971  do idtset=1,ndtset_alloc       ! specific size for each dataset
 972    narrm(idtset)=dtsets(idtset)%nsym
 973    if (narrm(idtset)>0) then
 974      intarr(1:narrm(idtset),idtset)=&
 975 &     dtsets(idtset)%symafm(1:narrm(idtset))
 976    end if
 977  end do
 978  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,narr,narrm,ncid,ndtset_alloc,'symafm','INT', multivals%nsym)
 979 
 980  intarr(1,:)=dtsets(:)%symchi
 981  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'symchi','INT',0)
 982 
 983  intarr(1,:)=dtsets(:)%symdynmat
 984  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'symdynmat','INT',0)
 985 
 986  intarr(1,:)=dtsets(:)%symmorphi
 987  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'symmorphi','INT',0)
 988 
 989 !symrel
 990  intarr(1:9,0)=(/ 1,0,0, 0,1,0, 0,0,1 /)
 991  narr=9*nsym ! default size for all datasets
 992  do idtset=1,ndtset_alloc       ! specific size for each dataset
 993    narrm(idtset)=9*dtsets(idtset)%nsym
 994    if (narrm(idtset)>0) then
 995      intarr(1:narrm(idtset),idtset)=&
 996 &     reshape(dtsets(idtset)%symrel(1:3,1:3,1:dtsets(idtset)%nsym), [narrm(idtset)] )
 997    end if
 998  end do
 999  call prttagm(dprarr,intarr,iout,jdtset_,3,marr,narr,narrm,ncid,ndtset_alloc,'symrel','INT', multivals%nsym)
1000 
1001  intarr(1,:)=dtsets(:)%symsigma
1002  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'symsigma','INT',0)
1003 
1004 !###########################################################
1005 !### 03. Print all the input variables (T)
1006 !##
1007 
1008  dprarr(1,:)=dtsets(:)%td_maxene
1009  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'td_maxene','DPR',0)
1010 
1011  intarr(1,0:ndtset_alloc)=dtsets(0:ndtset_alloc)%td_mexcit
1012  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'td_mexcit','INT',0)
1013 
1014  intarr(1,0:ndtset_alloc)=dtsets(0:ndtset_alloc)%tfkinfunc
1015  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'tfkinfunc','INT',0)
1016 
1017  dprarr(1,:)=dtsets(:)%tfw_toldfe
1018  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'tfw_toldfe','ENE',0)
1019 
1020  intarr(1,:)=dtsets(:)%tim1rev
1021  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'tim1rev','INT',0)
1022 
1023 
1024 !timopt
1025  timopt_default=1
1026 !MPI parallel case
1027  if(xmpi_paral==1)then
1028    timopt_default=0
1029  end if
1030  if(timopt/=timopt_default)then
1031    intarr(1,:)=timopt
1032    intarr(1,0)=timopt_default
1033    call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'timopt','INT',0)
1034  end if
1035 
1036 !WVL - tails related variables
1037  intarr(1,:)=dtsets(:)%tl_nprccg
1038  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'tl_nprccg','INT',0)
1039  dprarr(1,:)=dtsets(:)%tl_radius
1040  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'tl_radius','DPR',0)
1041 
1042 !tnons
1043  dprarr(:,0)=0.0_dp
1044  narr=3*nsym ! default size for all datasets
1045  do idtset=1,ndtset_alloc       ! specific size for each dataset
1046    narrm(idtset)=3*dtsets(idtset)%nsym
1047    if (narrm(idtset)>0) then
1048      dprarr(1:narrm(idtset),idtset)=reshape(dtsets(idtset)%tnons(1:3,1:dtsets(idtset)%nsym), [narrm(idtset)])
1049    end if
1050  end do
1051  call prttagm(dprarr,intarr,iout,jdtset_,-3,marr,narr,narrm,ncid,ndtset_alloc,'tnons','DPR',multivals%nsym)
1052 
1053  dprarr(1,:)=dtsets(:)%toldfe
1054  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'toldfe','ENE',0)
1055 
1056  dprarr(1,:)=dtsets(:)%tolmxde
1057  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'tolmxde','ENE',0)
1058 
1059  dprarr(1,:)=dtsets(:)%toldff
1060  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'toldff','DPR',0)
1061 
1062  dprarr(1,:)=dtsets(:)%tolimg
1063  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'tolimg','ENE',0)
1064 
1065  dprarr(1,:)=dtsets(:)%tolmxf
1066  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'tolmxf','DPR',0)
1067 
1068  dprarr(1,:)=dtsets(:)%tolrde
1069  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'tolrde','DPR',0)
1070 
1071  dprarr(1,:)=dtsets(:)%tolrff
1072  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'tolrff','DPR',0)
1073 
1074  dprarr(1,:)=dtsets(:)%tolsym
1075  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'tolsym','DPR',0)
1076 
1077  dprarr(1,:)=dtsets(:)%tolvrs
1078  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'tolvrs','DPR',0)
1079 
1080  dprarr(1,:)=dtsets(:)%tolwfr
1081  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'tolwfr','DPR',0)
1082 
1083  dprarr(1,:)=dtsets(:)%tphysel
1084  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'tphysel','ENE',0)
1085 
1086  dprarr(1,:) = dtsets(:)%tmesh(1); dprarr(2,:) = dtsets(:)%tmesh(2); dprarr(3,:) = dtsets(:)%tmesh(3)
1087  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,3,narrm,ncid,ndtset_alloc,'tmesh','DPR',0)
1088 
1089  dprarr(1,:)=dtsets(:)%tsmear
1090  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'tsmear','ENE',0)
1091 
1092 !typat
1093  narr=natom                      ! default size for all datasets
1094  do idtset=0,ndtset_alloc       ! specific size for each dataset
1095    narrm(idtset)=dtsets(idtset)%natom
1096    if(idtset==0)narrm(idtset)=mxvals%natom
1097    if (narrm(idtset)>0) then
1098      intarr(1:narrm(idtset),idtset)=dtsets(idtset)%typat(1:narrm(idtset))
1099    end if
1100  end do
1101  call prttagm(dprarr,intarr,iout,jdtset_,4,marr,narr,&
1102 & narrm,ncid,ndtset_alloc,'typat','INT',multivals%natom,forceprint=2)
1103 
1104 !###########################################################
1105 !### 03. Print all the input variables (U)
1106 !##
1107  intarr(1,:)=dtsets(:)%ucrpa
1108  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'ucrpa','INT',0)
1109 
1110  intarr(1,:)=dtsets(:)%ucrpa_bands(1)
1111  intarr(2,:)=dtsets(:)%ucrpa_bands(2)
1112  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,2,narrm,ncid,ndtset_alloc,'ucrpa_bands','INT',0)
1113 
1114  dprarr(1,:)=dtsets(:)%ucrpa_window(1)
1115  dprarr(2,:)=dtsets(:)%ucrpa_window(2)
1116  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,2,narrm,ncid,ndtset_alloc,'ucrpa_window','ENE',0)
1117 
1118 !upawu
1119  prtimg(:,:)=1
1120  do idtset=0,ndtset_alloc
1121    narrm(idtset)=dtsets(idtset)%ntypat
1122    if (idtset==0) narrm(idtset)=mxvals%ntypat
1123    do iimage=1,nimagem(idtset)
1124      if (narrm(idtset)>0) then
1125        dprarr_images(1:narrm(idtset),iimage,idtset)=dtsets(idtset)%upawu(1:narrm(idtset),iimage)
1126      end if
1127    end do
1128  end do
1129  call prttagm_images(dprarr_images,iout,jdtset_,1,marr,narrm,&
1130 & ncid,ndtset_alloc,'upawu','ENE',mxvals%nimage,nimagem,ndtset,prtimg,strimg)
1131 
1132  intarr(1,:)=dtsets(:)%usedmatpu
1133  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'usedmatpu','INT',0)
1134 
1135  intarr(1,:)=dtsets(:)%usedmft
1136  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'usedmft','INT',0)
1137 
1138  intarr(1,:)=dtsets(:)%useexexch
1139  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'useexexch','INT',0)
1140 
1141  intarr(1,:)=dtsets(:)%usefock
1142  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'usefock','INT',0)
1143 
1144  intarr(1,:)=dtsets(:)%usepotzero
1145  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'usepotzero','INT',0)
1146 
1147  intarr(1,:)=dtsets(:)%usekden
1148  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'usekden','INT',0)
1149 
1150  intarr(1,:)=dtsets(:)%use_gemm_nonlop
1151  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'use_gemm_nonlop','INT',0)
1152 
1153  intarr(1,:)=dtsets(:)%use_nonscf_gkk
1154  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'use_nonscf_gkk','INT',0)
1155 
1156  intarr(1,:)=dtsets(:)%usepawu
1157  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'usepawu','INT',0)
1158 
1159  intarr(1,:)=dtsets(:)%usepead
1160  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'usepead','INT',0)
1161 
1162  intarr(1,:)=dtsets(:)%useria
1163  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'useria','INT',0)
1164 
1165  intarr(1,:)=dtsets(:)%userib
1166  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'userib','INT',0)
1167 
1168  intarr(1,:)=dtsets(:)%useric
1169  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'useric','INT',0)
1170 
1171  intarr(1,:)=dtsets(:)%userid
1172  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'userid','INT',0)
1173 
1174  intarr(1,:)=dtsets(:)%userie
1175  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'userie','INT',0)
1176 
1177  dprarr(1,:)=dtsets(:)%userra
1178  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'userra','DPR',0)
1179 
1180  dprarr(1,:)=dtsets(:)%userrb
1181  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'userrb','DPR',0)
1182 
1183  dprarr(1,:)=dtsets(:)%userrc
1184  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'userrc','DPR',0)
1185 
1186  dprarr(1,:)=dtsets(:)%userrd
1187  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'userrd','DPR',0)
1188 
1189  dprarr(1,:)=dtsets(:)%userre
1190  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'userre','DPR',0)
1191 
1192  intarr(1,:)=dtsets(:)%usewvl
1193  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'usewvl','INT',0)
1194 
1195  intarr(1,0:ndtset_alloc)=dtsets(0:ndtset_alloc)%usexcnhat_orig
1196  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'usexcnhat','INT',0)
1197 
1198  intarr(1,0:ndtset_alloc)=dtsets(0:ndtset_alloc)%useylm
1199  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'useylm','INT',0,firstchar=firstchar_gpu)
1200 
1201  intarr(1,:)=dtsets(:)%use_gpu_cuda
1202  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'use_gpu_cuda','INT',0,firstchar=firstchar_gpu)
1203 
1204  intarr(1,:)=dtsets(:)%use_slk
1205  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'use_slk','INT',0, firstchar="-")
1206 
1207 
1208 !###########################################################
1209 !### 03. Print all the input variables (V)
1210 !##
1211 
1212  dprarr(1,:)=dtsets(:)%vcutgeo(1)
1213  dprarr(2,:)=dtsets(:)%vcutgeo(2)
1214  dprarr(3,:)=dtsets(:)%vcutgeo(3)
1215  call prttagm(dprarr,intarr,iout,jdtset_,3,marr,3,narrm,ncid,ndtset_alloc,'vcutgeo','DPR',0)
1216 
1217  if(sum(dtsets(1:ndtset_alloc)%prtwant) >1)then
1218 !  van der Waals correction with MLWFs related variables
1219    if(any(dtsets(1:ndtset_alloc)%vdw_xc==10).or.any(dtsets(1:ndtset_alloc)%vdw_xc==11).or.&
1220 &   any(dtsets(1:ndtset_alloc)%vdw_xc==14))then
1221      intarr(1,:)=dtsets(:)%vdw_nfrag
1222      call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'vdw_nfrag','INT',0)
1223    end if !vdw_xc==10,11,14
1224    if(any(dtsets(1:ndtset_alloc)%vdw_xc==10).or.any(dtsets(1:ndtset_alloc)%vdw_xc==11).or.&
1225 &   any(dtsets(1:ndtset_alloc)%vdw_xc==14))then
1226      intarr(1,:)=dtsets(:)%vdw_supercell(1)
1227      intarr(2,:)=dtsets(:)%vdw_supercell(2)
1228      intarr(3,:)=dtsets(:)%vdw_supercell(3)
1229      call prttagm(dprarr,intarr,iout,jdtset_,2,marr,3,narrm,ncid,ndtset_alloc,'vdw_supercell','INT',0)
1230    end if !vdw_xc==10,11,14
1231  end if !prtwant>1
1232 
1233  dprarr(1,:)=dtsets(:)%vdw_tol
1234  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'vdw_tol','DPR',0)
1235  dprarr(1,:)=dtsets(:)%vdw_tol_3bt
1236  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'vdw_tol_3bt','DPR',0)
1237 
1238  if(sum(dtsets(1:ndtset_alloc)%prtwant) >1)then
1239 !  van der Waals correction with MLWFs related variables
1240    if(any(dtsets(1:ndtset_alloc)%vdw_xc==10).or.any(dtsets(1:ndtset_alloc)%vdw_xc==11))then
1241      do iat=1,mxvals%natom
1242        intarr(iat,:)=dtsets(:)%vdw_typfrag(iat)
1243      end do
1244      call prttagm(dprarr,intarr,iout,jdtset_,2,marr,mxvals%natom,narrm,ncid,ndtset_alloc,'vdw_typfrag','INT',0)
1245    end if !vdw_xc==10 or xc==11
1246  end if !prtwant>1
1247 
1248  intarr(1,:)=dtsets(:)%vdw_xc
1249  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'vdw_xc','INT',0)
1250 
1251  if(sum(dtsets(1:ndtset_alloc)%prtvdw) >1)then
1252    if(any(dtsets(1:ndtset_alloc)%vdw_xc<10))then
1253      dprarr(1,:)=dtsets(:)%vdw_df_threshold
1254      call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'vdw_df_threshold','ENE',0)
1255    end if
1256  end if
1257 
1258 !vel
1259  prtimg(:,:)=1
1260  do idtset=0,ndtset_alloc
1261    if(idtset/=0)then
1262      size1=dtsets(idtset)%natom
1263    else
1264      size1=mxvals%natom
1265    end if
1266    narrm(idtset)=3*size1
1267    do iimage=1,nimagem(idtset)
1268      if (narrm(idtset)>0) then
1269        dprarr_images(1:narrm(idtset),iimage,idtset)=&
1270 &       reshape(results_out(idtset)%vel(1:3,1:size1,iimage), (/ narrm(idtset) /) )
1271      end if
1272    end do
1273  end do
1274  call prttagm_images(dprarr_images,iout,jdtset_,2,marr,narrm,ncid,ndtset_alloc,'vel','DPR',&
1275 & mxvals%nimage,nimagem,ndtset,prtimg,strimg)
1276 
1277 
1278 !vel_cell
1279 !At present, vel_cell does not depend on image... but this might change in the future.
1280  prtimg(:,:)=1
1281  if (.true.) then
1282 !  if(mxvals%nimage==1)then
1283    do idtset=0,ndtset_alloc
1284      dprarr(1:9,idtset)= reshape(results_out(idtset)%vel_cell(:,:,1),(/9/))
1285    end do
1286    call prttagm(dprarr,intarr,iout,jdtset_,2,marr,9,narrm,ncid,ndtset_alloc,'vel_cell','DPR',0)
1287 !  else
1288 !  do idtset=1,ndtset_alloc       ! specific size for each dataset
1289 !  nimagem(idtset)=dtsets(idtset)%nimage
1290 !  narrm(idtset)=9
1291 !  do iimage=1,dtsets(idtset)%nimage
1292 !  if (narrm(idtset)>0) then
1293 !  dprarr_images(1:narrm(idtset),iimage,idtset)=&
1294 !  &         reshape(results_out(idtset)%vel_cell(1:3,1:3,iimage),&
1295 !  &         (/ narrm(idtset) /) )
1296 !  end if
1297 !  end do
1298 !  end do
1299 !  call prttagm_images(dprarr_images,iout,jdtset_,&
1300 !  &   marr,narrm,ncid,ndtset_alloc,'vel_cell',&
1301 !  &   mxvals%nimage,nimagem,ndtset,prtimg,strimg)
1302  end if
1303 
1304  dprarr(1,:)=dtsets(:)%vis
1305  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'vis','DPR',0)
1306 
1307  dprarr(1,:)=dtsets(:)%vprtrb(1)
1308  dprarr(2,:)=dtsets(:)%vprtrb(2)
1309  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,2,narrm,ncid,ndtset_alloc,'vprtrb','ENE',0)
1310 
1311 
1312 !###########################################################
1313 !### 03. Print all the input variables (W)
1314 !##
1315 
1316  dprarr(1,:)=dtsets(:)%wfmix
1317  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'wfmix','DPR',0)
1318 
1319  intarr(1,0:ndtset_alloc)=dtsets(0:ndtset_alloc)%wfk_task
1320  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'wfk_task','INT',0)
1321 
1322  intarr(1,0:ndtset_alloc)=dtsets(0:ndtset_alloc)%wfoptalg
1323  call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'wfoptalg','INT',0,firstchar=firstchar_gpu)
1324 
1325 !wtatcon
1326  narr=3*natom*dtsets(1)%nconeq ! default size for all datasets
1327  do idtset=0,ndtset_alloc       ! specific size for each dataset
1328    if(idtset/=0)then
1329      narrm(idtset)=3*dtsets(idtset)%natom*dtsets(idtset)%nconeq
1330      if (narrm(idtset)>0)&
1331 &     dprarr(1:narrm(idtset),idtset)=&
1332 &     reshape(dtsets(idtset)%wtatcon(1:3,1:dtsets(idtset)%natom,&
1333 &     1:dtsets(idtset)%nconeq),&
1334 &     (/ narrm(idtset) /) )
1335    else
1336      narrm(idtset)=3*mxvals%natom*mxvals%nconeq
1337      if (narrm(idtset)>0)&
1338 &     dprarr(1:narrm(idtset),idtset)=&
1339 &     reshape(dtsets(idtset)%wtatcon(1:3,1:mxvals%natom,&
1340 &     1:mxvals%nconeq),&
1341 &     (/ narrm(idtset) /) )
1342    end if
1343  end do
1344  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,narr,&
1345 & narrm,ncid,ndtset_alloc,'wtatcon','DPR',&
1346 & multivals%natom+multivals%nconeq)
1347 
1348 !wtk
1349  tnkpt=0
1350  dprarr(:,0)=1
1351  narr=dtsets(1)%nkpt            ! default size for all datasets
1352  if(prtvol_glob==0 .and. narr>nkpt_max)then
1353    narr=nkpt_max
1354    tnkpt=1
1355  end if
1356  do idtset=1,ndtset_alloc       ! specific size for each dataset
1357    narrm(idtset)=dtsets(idtset)%nkpt
1358    if (narrm(idtset)>0) then
1359      dprarr(1:narrm(idtset),idtset)=dtsets(idtset)%wtk(1:narrm(idtset))+tol12
1360    end if
1361 
1362    if(prtvol_glob==0 .and. narrm(idtset)>nkpt_max)then
1363      narrm(idtset)=nkpt_max
1364      tnkpt=1
1365    end if
1366  end do
1367  call prttagm(dprarr,intarr,iout,jdtset_,4,marr,narr,&
1368 & narrm,ncid,ndtset_alloc,'wtk','DPR',multivals%nkpt)
1369 
1370  if(tnkpt==1) write(iout,'(23x,a,i3,a)' ) &
1371 & 'outvars : Printing only first ',nkpt_max,' k-points.'
1372 
1373 !WVL - wavelets variables
1374  if (any(dtsets(:)%usewvl==1)) then
1375    intarr(1,:)=dtsets(:)%wvl_bigdft_comp
1376    call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'wvl_bigdft_comp','INT',0)
1377    dprarr(1,:)=dtsets(:)%wvl_crmult
1378    call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'wvl_crmult','DPR',0)
1379    dprarr(1,:)=dtsets(:)%wvl_frmult
1380    call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'wvl_frmult','DPR',0)
1381    dprarr(1,:)=dtsets(:)%wvl_hgrid
1382    call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'wvl_hgrid','DPR',0)
1383    intarr(1,:)=dtsets(:)%wvl_nprccg
1384    call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'wvl_nprccg','INT',0)
1385  end if
1386 
1387 !Wannier90 interface related variables
1388  if(sum(dtsets(1:ndtset_alloc)%prtwant) >1)then
1389    intarr(1,:)=dtsets(:)%w90iniprj
1390    call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'w90iniprj','INT',0)
1391    intarr(1,:)=dtsets(:)%w90prtunk
1392    call prttagm(dprarr,intarr,iout,jdtset_,2,marr,1,narrm,ncid,ndtset_alloc,'w90prtunk','INT',0)
1393  end if !prtwant>1
1394 
1395 !###########################################################
1396 !### 03. Print all the input variables (X)
1397 !##
1398 
1399 !xangst
1400  prtimg(:,:)=1
1401  do idtset=0,ndtset_alloc
1402    if(idtset/=0)then
1403      size1=dtsets(idtset)%natom
1404    else
1405      size1=mxvals%natom
1406    end if
1407    narrm(idtset)=3*size1
1408    do iimage=1,nimagem(idtset)
1409      if (narrm(idtset)>0) then
1410        dprarr_images(1:narrm(idtset),iimage,idtset)=&
1411 &       reshape(xangst_(1:3,1:size1,iimage,idtset), (/ narrm(idtset) /) )
1412      end if
1413    end do
1414  end do
1415  call prttagm_images(dprarr_images,iout,jdtset_,-2,marr,narrm,ncid,ndtset_alloc,'xangst','DPR',&
1416 & mxvals%nimage,nimagem,ndtset,prtimg,strimg)
1417 
1418 !xcart
1419  prtimg(:,:)=1
1420  do idtset=0,ndtset_alloc
1421    if(idtset/=0)then
1422      size1=dtsets(idtset)%natom
1423    else
1424      size1=mxvals%natom
1425    end if
1426    narrm(idtset)=3*size1
1427    do iimage=1,nimagem(idtset)
1428      if (narrm(idtset)>0) then
1429        dprarr_images(1:narrm(idtset),iimage,idtset)=&
1430 &       reshape(xcart_(1:3,1:size1,iimage,idtset), (/ narrm(idtset) /) )
1431      end if
1432    end do
1433  end do
1434  call prttagm_images(dprarr_images,iout,jdtset_,-2,marr,narrm,ncid,ndtset_alloc,'xcart','DPR',&
1435 & mxvals%nimage,nimagem,ndtset,prtimg,strimg)
1436 
1437 
1438  dprarr(1,:)=dtsets(:)%xc_denpos
1439  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'xc_denpos','DPR',0)
1440 
1441  dprarr(1,:)=dtsets(:)%xc_tb09_c
1442  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'xc_tb09_c','DPR',0)
1443 
1444 !xred
1445  prtimg(:,:)=1
1446  do idtset=0,ndtset_alloc
1447    if(idtset/=0)then
1448      size2=dtsets(idtset)%natom
1449    else
1450      size2=mxvals%natom
1451    end if
1452    narrm(idtset)=3*size2
1453    do iimage=1,nimagem(idtset)
1454      if (narrm(idtset)>0) then
1455        dprarr_images(1:narrm(idtset),iimage,idtset)=&
1456 &       reshape(results_out(idtset)%xred(:,1:size2,iimage), (/ narrm(idtset) /) )
1457      end if
1458    end do
1459  end do
1460  call prttagm_images(dprarr_images,iout,jdtset_,-2,marr,narrm,ncid,ndtset_alloc,'xred','DPR',&
1461 & mxvals%nimage,nimagem,ndtset,prtimg,strimg,forceprint=2)
1462 
1463 !xredsph_extra
1464  do idtset=0,ndtset_alloc
1465    if(idtset/=0)then
1466      size2=dtsets(idtset)%natsph_extra
1467    else
1468      size2=0
1469    end if
1470    narrm(idtset)=3*size2
1471    if (narrm(idtset)>0) then
1472      dprarr(1:narrm(idtset),idtset)=&
1473 &     reshape(dtsets(idtset)%xredsph_extra(:,1:size2), (/ narrm(idtset) /) )
1474    end if
1475  end do
1476  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,3,narrm,ncid,ndtset_alloc,'xredsph_extra','DPR',1)
1477 
1478 
1479 
1480 !###########################################################
1481 !### 03. Print all the input variables (Y)
1482 !##
1483 
1484 !###########################################################
1485 !### 03. Print all the input variables (Z)
1486 !##
1487 
1488  dprarr(1,:)=dtsets(:)%zcut
1489  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,1,narrm,ncid,ndtset_alloc,'zcut','ENE',0)
1490 
1491 !zeemanfield
1492  dprarr(1,:)=dtsets(:)%zeemanfield(1)
1493  dprarr(2,:)=dtsets(:)%zeemanfield(2)
1494  dprarr(3,:)=dtsets(:)%zeemanfield(3)
1495  call prttagm(dprarr,intarr,iout,jdtset_,1,marr,3,narrm,ncid,ndtset_alloc,'zeemanfield','BFI',0)
1496 
1497 !ziontypat   ! After all, should always echo this value
1498  if(sum(dtsets(:)%ntypalch)>0)then   ! After all, should always echo this value ...
1499 
1500 
1501    narr=ntypat                      ! default size for all datasets
1502    do idtset=0,ndtset_alloc       ! specific size for each dataset
1503      narrm(idtset)=dtsets(idtset)%ntypat
1504      if(idtset==0)narrm(idtset)=mxvals%ntypat
1505      if (narrm(idtset)>0) then
1506        dprarr(1:narrm(idtset),idtset)=dtsets(idtset)%ziontypat(1:narrm(idtset))
1507      end if
1508    end do
1509    call prttagm(dprarr,intarr,iout,jdtset_,1,marr,narr,&
1510 &   narrm,ncid,ndtset_alloc,'ziontypat','DPR',multivals%ntypat,forceprint=2)
1511 
1512  end if
1513 
1514  do idtset=0,ndtset_alloc
1515    dprarr(1:npsp,idtset)=dtsets(idtset)%znucl(1:npsp)
1516  end do
1517  call prttagm(dprarr,intarr,iout,jdtset_,4,marr,npsp,narrm,ncid,ndtset_alloc,'znucl','DPR',0,&
1518 & forceprint=2)
1519 
1520 !###########################################################
1521 !## Deallocation for generic arrays, and for n-z variables
1522 
1523  ABI_DEALLOCATE(dprarr)
1524  ABI_DEALLOCATE(intarr)
1525  ABI_DEALLOCATE(narrm)
1526  ABI_DEALLOCATE(nimagem)
1527  ABI_DEALLOCATE(dprarr_images)
1528  ABI_DEALLOCATE(prtimg)
1529 
1530  ABI_DEALLOCATE(xangst_)
1531  ABI_DEALLOCATE(xcart_)
1532 
1533 contains

ABINIT/prtocc [ Functions ]

[ Top ] [ Functions ]

NAME

 prtocc

FUNCTION

 Print the content of occ.
 Due to the need to distinguish between different k-points and
 different spin polarisations, prttagm.f cannot be used.
 So, need a dedicated routine.

INPUTS

  dtsets(0:ndtset_alloc)=<type datafiles_type>contains all input variables
  iout=unit number for echoed output
  jdtset_(0:ndtset_alloc)=list of dataset indices.
  ndtset_alloc=govern second dimension of intarr and dprarr
  prtvol_glob= if 0, minimal output volume, if 1, no restriction.
  results_out(0:ndtset_alloc)=<type results_out_type>contains the results
   needed for outvars, including occ, an evolving variable

OUTPUT

  (only writing)

PARENTS

      outvar_o_z

CHILDREN

      appdig

SOURCE

1567 subroutine prtocc(dtsets,iout,jdtset_,mxvals,ndtset_alloc,nimagem,prtvol_glob,results_out,strimg)
1568 
1569 
1570 !This section has been created automatically by the script Abilint (TD).
1571 !Do not modify the following lines by hand.
1572 #undef ABI_FUNC
1573 #define ABI_FUNC 'prtocc'
1574 !End of the abilint section
1575 
1576  implicit none
1577 
1578 !Arguments ------------------------------------
1579 !scalars
1580  integer,intent(in) :: iout,ndtset_alloc,prtvol_glob
1581 !arrays
1582  integer,intent(in) :: jdtset_(0:ndtset_alloc)
1583  integer,intent(in) :: nimagem(0:ndtset_alloc)
1584  type(ab_dimensions),intent(in) :: mxvals
1585  type(dataset_type),intent(in) :: dtsets(0:ndtset_alloc)
1586  type(results_out_type),intent(in) :: results_out(0:ndtset_alloc)
1587  character(len=8),intent(in) :: strimg(mxvals%nimage)
1588 
1589 !Local variables-------------------------------
1590  character(len=*), parameter :: f_occ    ="(1x,a16,1x,(t22,6f10.6))"
1591  character(len=*), parameter :: f_occa   ="(1x,a16,a,1x,(t22,6f10.6))"
1592  character(len=*), parameter :: token='occ'
1593 !scalars
1594  integer,parameter :: nkpt_max=50
1595  integer :: generic,iban,idtset,ikpsp,ikpt,isppol,jdtset,multi,multi_nband
1596  integer :: multi_nimage
1597  integer :: multi_nkpt,multi_nsppol,multi_occopt,nban,nkpt,nkpt_eff
1598  integer :: multi_tsmear
1599  integer :: print,tnkpt
1600  logical, allocatable :: test_multiimages(:)
1601  character(len=4) :: appen
1602  character(len=16) :: keywd
1603  character(len=500) :: message
1604 
1605 ! *************************************************************************
1606 
1607  if(ndtset_alloc<1)then
1608    write(message, '(a,i0,a)' )' ndtset_alloc=',ndtset_alloc,', while it should be >= 1.'
1609    MSG_BUG(message)
1610  end if
1611 
1612  if(ndtset_alloc>9999)then
1613    write(message, '(a,i0,a)' )' ndtset_alloc=',ndtset_alloc,', while it must be lower than 100.'
1614    MSG_BUG(message)
1615  end if
1616 
1617 !It is important to take iscf into account, since when it is -2, occupation numbers must be ignored
1618 
1619  multi_occopt=0
1620  if(ndtset_alloc>1)then
1621    do idtset=1,ndtset_alloc
1622      if(dtsets(1)%occopt/=dtsets(idtset)%occopt .and. dtsets(idtset)%iscf/=-2 )multi_occopt=1
1623    end do
1624  end if
1625 
1626  multi_tsmear=0
1627  if(ndtset_alloc>1)then
1628    do idtset=1,ndtset_alloc
1629      if(dtsets(1)%tsmear/=dtsets(idtset)%tsmear .and. dtsets(idtset)%iscf/=-2 )multi_tsmear=1
1630    end do
1631  end if
1632 
1633  multi_nkpt=0
1634  if(ndtset_alloc>1)then
1635    do idtset=1,ndtset_alloc
1636      if(dtsets(1)%nkpt/=dtsets(idtset)%nkpt .and. dtsets(idtset)%iscf/=-2 )multi_nkpt=1
1637    end do
1638  end if
1639  if(multi_nkpt==0)nkpt=dtsets(1)%nkpt
1640 
1641  multi_nsppol=0
1642  if(ndtset_alloc>1)then
1643    do idtset=1,ndtset_alloc
1644      if(dtsets(1)%nsppol/=dtsets(idtset)%nsppol .and. dtsets(idtset)%iscf/=-2 )multi_nsppol=1
1645    end do
1646  end if
1647 
1648  if(multi_nsppol==0 .and. multi_nkpt==0)then
1649    multi_nband=0
1650    if(ndtset_alloc>1)then
1651      do idtset=1,ndtset_alloc
1652        if(dtsets(idtset)%iscf/=-2)then
1653          do ikpsp=1,dtsets(1)%nkpt*dtsets(1)%nsppol
1654            if(dtsets(1)%nband(ikpsp)/=dtsets(idtset)%nband(ikpsp))multi_nband=1
1655          end do
1656        end if
1657      end do
1658    end if
1659  else
1660    multi_nband=1
1661  end if
1662 
1663 !DEBUG
1664 ! write(std_out,*)' prtocc : 1 '
1665 !ENDDEBUG
1666 
1667  multi_nimage=0
1668  if(ndtset_alloc>1)then
1669    do idtset=1,ndtset_alloc
1670      if(dtsets(1)%nimage/=dtsets(idtset)%nimage .and. dtsets(idtset)%iscf/=-2 )multi_nimage=1
1671    end do
1672  end if
1673 
1674 !DEBUG
1675 ! write(std_out,*)' prtocc : 2, multi_nimage= ',multi_nimage
1676 !ENDDEBUG
1677 
1678 !Test whether for this variable, the content of different images differ.
1679 !test_multiimages(idtset)=.false. if, for that dataset, the content for different
1680 !images is identical.
1681  ABI_MALLOC(test_multiimages,(0:ndtset_alloc))
1682  test_multiimages=.false.
1683  do idtset=1,ndtset_alloc
1684    if(nimagem(idtset)>1)then
1685      nban=sum(dtsets(idtset)%nband(1:dtsets(idtset)%nsppol*dtsets(idtset)%nkpt))
1686      do iban=1,nban
1687        if(sum(abs( results_out(idtset)%occ(iban,2:nimagem(idtset))- &
1688 &       results_out(idtset)%occ(iban,1)))>tol12)then
1689          test_multiimages(idtset)=.true.
1690        end if
1691      end do
1692    end if
1693  end do
1694  if(nimagem(0)==0)test_multiimages(0)=.true.
1695 
1696 !DEBUG
1697 ! write(std_out,*)' prtocc : 3, test_multiimages= ',test_multiimages
1698 ! write(std_out,*)' prtocc : multi_occopt, multi_nband, multi_nimage=',multi_occopt, multi_nband, multi_nimage
1699 ! write(std_out,*)' prtocc : test_multiimages(1:ndtset_alloc)=',test_multiimages(1:ndtset_alloc)
1700 ! write(std_out,*)' prtocc : any(test_multiimages(1:ndtset_alloc))=',any(test_multiimages(1:ndtset_alloc))
1701 !ENDDEBUG
1702 
1703 !There is a possibility of a single generic occupation-number set (common to all datasets) if
1704 !multi_occopt==0 and multi_nband==0  and (multi_nimage==0  or the content of the different images is always the same)
1705 !This might occur even if occupation numbers differ for different images.
1706  multi=1
1707  if(multi_occopt==0 .and. multi_nband==0 .and. (multi_nimage==0 .or. .not. any(test_multiimages(1:ndtset_alloc)))) then
1708    nban=sum(dtsets(1)%nband(1:dtsets(1)%nsppol*dtsets(1)%nkpt))
1709    multi=0
1710    if(ndtset_alloc>1)then
1711      do idtset=1,ndtset_alloc
1712        if(dtsets(idtset)%iscf/=-2)then
1713 !        nban counts all bands and kpoints and spins: see above
1714          do iimage=1,nimagem(idtset)
1715            if(iimage==1 .or. test_multiimages(idtset))then
1716              do iban=1,nban
1717 !              Use of tol8, because the format for multi=1 is f16.6, so will not
1718 !              discriminate between relative values, or absolute values that
1719 !              agree within more than 6 digits
1720                if( abs(results_out(1)%occ(iban,iimage)-results_out(idtset)%occ(iban,iimage)) > tol8) multi=1
1721              end do
1722            end if
1723          end do
1724        end if
1725      end do
1726    end if
1727  end if
1728 
1729 !DEBUG
1730 ! write(std_out,*)' prtocc : 4, multi= ',multi
1731 !ENDDEBUG
1732 
1733 !At this stage, if multi==1, the occ must be printed
1734 !if multi==0, then it might be that we have the default values.
1735 !Since the default is all zeros, it only happens when iscf=-2
1736 !Also initialize the number of a idtset that can be used as generic
1737 !(this might not be the case for idtset=1 !)
1738 
1739  generic=0
1740  print=0
1741  do idtset=1,ndtset_alloc
1742    if(dtsets(idtset)%iscf/=-2)then
1743      print=1
1744      generic=idtset
1745    end if
1746  end do
1747 
1748 !DEBUG
1749 ! write(std_out,*)' prtocc : 5, print= ',print
1750 !ENDDEBUG
1751 
1752 !Now, print occ in the generic occupation-number set case (occ is independent of the dtset).
1753  if(print==1 .and. multi==0)then
1754 !  Might restrict the number of k points to be printed
1755    tnkpt=0
1756    nkpt_eff=dtsets(1)%nkpt
1757    if(prtvol_glob==0 .and. nkpt_eff>nkpt_max)then
1758      nkpt_eff=nkpt_max
1759      tnkpt=1
1760    end if
1761 
1762 !DEBUG
1763 ! write(std_out,*)' prtocc : 6, do-loop over iimage '
1764 !ENDDEBUG
1765 
1766    do iimage=1,nimagem(generic)
1767      if(iimage==1 .or. test_multiimages(generic) )then
1768        keywd=token//trim(strimg(iimage))
1769 !      The quantity of data to be output vary with occopt
1770        if(dtsets(generic)%occopt>=2)then
1771          iban=1
1772          do isppol=1,dtsets(generic)%nsppol
1773            do ikpt=1,nkpt_eff
1774              ikpsp=ikpt+dtsets(generic)%nkpt*(isppol-1)
1775              nban=dtsets(generic)%nband(ikpsp)
1776              if(ikpsp==1)then
1777                write(iout, '(1x,a16,1x,(t22,6f10.6))' )&
1778 &               trim(keywd),results_out(generic)%occ(iban:iban+nban-1,iimage)
1779              else
1780                write(iout, '((t22,6f10.6))' )results_out(generic)%occ(iban:iban+nban-1,iimage)
1781              end if
1782              iban=iban+nban
1783            end do
1784            if(tnkpt==1) write(iout,'(23x,a)' ) 'prtocc : prtvol=0, do not print more k-points.'
1785          end do
1786        else
1787 !        The number of bands is identical for all k points and spin
1788          nban=dtsets(generic)%nband(1)
1789          write(iout, '(1x,a16,1x,(t22,6f10.6))' )trim(keywd),results_out(generic)%occ(1:nban,iimage)
1790 !        if occopt==1, the occ might differ with the spin
1791          if(dtsets(generic)%nsppol/=1)then
1792            write(iout,'((t22,6f10.6))')results_out(generic)%occ(nban*dtsets(generic)%nkpt+1:&
1793 &           nban*dtsets(generic)%nkpt+nban,iimage)
1794          end if
1795        end if
1796      end if
1797    end do
1798  end if
1799 
1800 !DEBUG
1801 ! write(std_out,*)' prtocc : 7, finished do-loop over iimage '
1802 !ENDDEBUG
1803 
1804 !Now, print occ in the other cases (occ depends on the dataset)
1805  if(print==1 .and. multi==1)then
1806    do idtset=1,ndtset_alloc
1807 !    Might restrict the number of k points to be printed
1808      tnkpt=0
1809      nkpt_eff=dtsets(idtset)%nkpt
1810      if(prtvol_glob==0 .and. nkpt_eff>nkpt_max)then
1811        nkpt_eff=nkpt_max
1812        tnkpt=1
1813      end if
1814      if(dtsets(idtset)%iscf/=-2)then
1815        jdtset=jdtset_(idtset)
1816        call appdig(jdtset,'',appen)
1817        do iimage=1,nimagem(idtset)
1818          if(iimage==1 .or. test_multiimages(idtset) )then
1819            keywd=trim(token)//trim(strimg(iimage))
1820 !          The quantity of data to be output vary with occopt
1821            if(dtsets(idtset)%occopt>=2)then
1822              iban=1
1823              do isppol=1,dtsets(idtset)%nsppol
1824                do ikpt=1,nkpt_eff
1825                  ikpsp=ikpt+dtsets(idtset)%nkpt*(isppol-1)
1826                  nban=dtsets(idtset)%nband(ikpsp)
1827                  if(ikpsp==1)then
1828                    write(iout, '(1x,a16,a,1x,(t22,6f10.6))' )&
1829 &                   trim(keywd),appen,results_out(idtset)%occ(iban:iban+nban-1,iimage)
1830                  else
1831                    write(iout, '((t22,6f10.6))' )results_out(idtset)%occ(iban:iban+nban-1,iimage)
1832                  end if
1833                  iban=iban+nban
1834                end do
1835                if(tnkpt==1) write(iout,'(23x,a)' ) 'prtocc : prtvol=0, do not print more k-points.'
1836              end do
1837            else
1838 !            The number of bands is identical for all k points and spin
1839              nban=dtsets(idtset)%nband(1)
1840              write(iout, '(1x,a16,a,1x,(t22,6f10.6))' )&
1841 &             trim(keywd),appen,results_out(idtset)%occ(1:nban,iimage)
1842 !            if occopt==1, the occ might differ with the spin
1843              if(dtsets(idtset)%nsppol/=1)then
1844                write(iout, '((t22,6f10.6))' ) &
1845 &               results_out(idtset)%occ(nban*dtsets(idtset)%nkpt+1:nban*dtsets(idtset)%nkpt+nban,iimage)
1846              end if
1847            end if
1848          end if
1849        enddo
1850      end if
1851 !    Endloop on idtset
1852    end do
1853  end if
1854 
1855  ABI_DEALLOCATE(test_multiimages)
1856 
1857 end subroutine prtocc