TABLE OF CONTENTS


ABINIT/chkinp [ Functions ]

[ Top ] [ Functions ]

NAME

 chkinp

FUNCTION

 Check consistency of input data against itself.
 Please: use the alphabetic order
 Please: use the routines chkint_eq, chkint_ne, chkint_ge, chkint_le, and chkdpr

INPUTS

  dtsets(0:ndtset_alloc)=<type datafiles_type>contains all input variables
  iout=unit number for output file
  mpi_enregs(0:ndtset_alloc)=informations about MPI parallelization
  ndtset=number of datasets
  ndtset_alloc=number of datasets, corrected for allocation of at least one data set.
  npsp=number of pseudopotentials
  pspheads(npsp)=<type pspheader_type>all the important information from the
   pseudopotential file header, as well as the psp file name

OUTPUT

SIDE EFFECTS

PARENTS

      abinit

CHILDREN

      chkdpr,chkgrp,chkint,chkint_eq,chkint_ge,chkint_le,chkint_ne,chkorthsy
      dtset_copy,dtset_free,metric,wrtout,xmpi_sum

SOURCE

  90 subroutine chkinp(dtsets,iout,mpi_enregs,ndtset,ndtset_alloc,npsp,pspheads)
  91 
  92 
  93 !This section has been created automatically by the script Abilint (TD).
  94 !Do not modify the following lines by hand.
  95 #undef ABI_FUNC
  96 #define ABI_FUNC 'chkinp'
  97 !End of the abilint section
  98 
  99  implicit none
 100 
 101 !Arguments ------------------------------------
 102 !scalars
 103  integer,intent(in) :: iout,ndtset,ndtset_alloc,npsp
 104  type(MPI_type),intent(in) :: mpi_enregs(0:ndtset_alloc)
 105 !arrays
 106  type(dataset_type),intent(in) :: dtsets(0:ndtset_alloc)
 107  type(pspheader_type),intent(in) :: pspheads(npsp)
 108 
 109 !Local variables-------------------------------
 110 !scalars
 111  logical :: twvl,allow
 112  logical :: wvlbigdft=.false.
 113  integer :: ttoldfe,ttoldff,ttolrff,ttolvrs,ttolwfr
 114  integer :: bantot,ia,iatom,ib,iband,idtset,ierr,iexit,ii,iimage,ikpt,ilang,intimage,ierrgrp
 115  integer :: ipsp,isppol,isym,itypat,iz,jdtset,jj,kk,maxiatsph,maxidyn,minplowan_iatom,maxplowan_iatom
 116  integer :: mband,mgga,miniatsph,minidyn,mod10,mpierr
 117  integer :: mu,natom,nfft,nfftdg,nkpt,nloc_mem,nlpawu,nproc,nspden,nspinor,nsppol,optdriver,response,usepaw,usewvl
 118  integer :: fftalg !,fftalga,fftalgc,
 119  real(dp) :: delta,dz,sumalch,summix,sumocc,ucvol,wvl_hgrid,zatom
 120  character(len=1000) :: message,msg
 121  type(dataset_type) :: dt
 122 !arrays
 123  integer :: cond_values(4),nprojmax(0:3)
 124  integer :: gpu_devices(5)=(/-2,-2,-2,-2,-2/)
 125  integer,allocatable :: ierr_dtset(:)
 126  real(dp) :: gmet(3,3),gprimd(3,3),rmet(3,3),rprimd(3,3)
 127  real(dp),allocatable :: frac(:,:)
 128  character(len=32) :: cond_string(4)
 129  character(len=32) :: input_name
 130 
 131 ! *************************************************************************
 132 
 133  DBG_ENTER("COLL")
 134 
 135 !Some initialisations
 136  cond_string(1:4)='#####'
 137  cond_values(1:4)=(/0,0,0,0/)
 138  ABI_ALLOCATE(ierr_dtset,(ndtset_alloc))
 139  ierr_dtset=0
 140 
 141 !Do loop on idtset (allocate statements are present)
 142  do idtset=1,ndtset_alloc
 143    if(mpi_enregs(idtset)%me<0) cycle
 144    jdtset=dtsets(idtset)%jdtset
 145    if(ndtset==0)jdtset=0
 146    ierr=0
 147 
 148    if(jdtset/=0)then
 149      write(message, '(a,a,a,i4,a)' ) ch10,&
 150 &     ' chkinp: Checking input parameters for consistency,',&
 151 &     ' jdtset=',jdtset,'.'
 152    else
 153      write(message, '(a,a)' ) ch10,&
 154 &     ' chkinp: Checking input parameters for consistency.'
 155    end if
 156    call wrtout(iout,message,'COLL')
 157    call wrtout(std_out,  message,'COLL')
 158 
 159 !  Will test directly on the dataset "dt"
 160    call dtset_copy(dt, dtsets(idtset))
 161 
 162 !  Copy or initialize locally a few input dataset values
 163    fftalg   =dt%ngfft(7)
 164    !fftalga  =fftalg/100; fftalgc=mod(fftalg,10)
 165    natom    =dt%natom
 166    nkpt     =dt%nkpt
 167    nspden   =dt%nspden
 168    nspinor  =dt%nspinor
 169    nsppol   =dt%nsppol
 170    optdriver=dt%optdriver
 171    usepaw   =dt%usepaw
 172    usewvl   =dt%usewvl
 173    intimage=1 ; if(dtsets(idtset)%nimage>2)intimage=2
 174    rprimd(:,:)=dtsets(idtset)%rprimd_orig(:,:,intimage)    ! For the purpose of checking symmetries
 175    response=0
 176    if(dt%rfelfd/=0.or.dt%rfphon/=0.or.dt%rfstrs/=0.or.dt%rfddk/=0.or.dt%rfuser/=0 &
 177 &   .or.dt%rf2_dkdk/=0.or.dt%rf2_dkde/=0.or.dt%rfmagn/=0.or.dt%d3e_pert1_elfd/=0 &
 178 &   .or.dt%d3e_pert2_elfd/=0.or.dt%d3e_pert3_elfd/=0.or.dt%d3e_pert1_phon/=0 &
 179 &   .or.dt%d3e_pert2_phon/=0.or.dt%d3e_pert3_phon/=0) response=1
 180    call metric(gmet,gprimd,-1,rmet,rprimd,ucvol)
 181    nproc=mpi_enregs(idtset)%nproc
 182    mgga=0;if(dt%ixc>=31.and.dt%ixc<=34)mgga=1
 183    if (dt%ixc<0.and.libxc_functionals_ismgga()) mgga=1
 184 
 185 !  =====================================================================================================
 186 !  Check the values of variables, using alphabetical order
 187 !  PLEASE : use the routines chkint_eq, chkint_ne, chkint_ge, chkint_le, chkdpr
 188 
 189 !  iomode
 190 !  Must be one of 0, 1, 3
 191    call chkint_eq(0,0,cond_string,cond_values,ierr,'iomode',dt%iomode,3,&
 192 &   [IO_MODE_FORTRAN,IO_MODE_MPI,IO_MODE_ETSF],iout)
 193 !  However, if mpi_io is not enabled, must be one of 0, 3.
 194    if(xmpi_mpiio==0)then
 195      cond_string(1)='enable_mpi_io' ;  cond_values(1)=0
 196 !    Make sure that iomode is 0 or 3
 197      call chkint_eq(1,1,cond_string,cond_values,ierr,'iomode',dt%iomode,2,[IO_MODE_FORTRAN,IO_MODE_ETSF],iout)
 198    end if
 199    if (dt%iomode == IO_MODE_NETCDF .and. dt%npspinor == 2) then
 200      MSG_ERROR_NOSTOP("npspinor == 2 not compatible with netcdf", ierr)
 201    end if
 202 
 203 !  accuracy
 204    call chkint_eq(0,0,cond_string,cond_values,ierr,'accuracy',dt%accuracy,7,(/0,1,2,3,4,5,6/),iout)
 205 
 206 !  adpimd
 207    call chkint_eq(0,0,cond_string,cond_values,ierr,'accuracy',dt%adpimd,2,(/0,1/),iout)
 208 
 209 !  amu
 210 !  Check that atomic masses are > 0 if ionmov = 1
 211    do iimage=1,dt%nimage
 212      if (dt%ionmov==1) then
 213        do itypat=1,dt%ntypat
 214          cond_string(1)='ionmov' ; cond_values(1)=1
 215          write(input_name,'(a4,i2,a1,i2,a1)')'amu(',itypat,',',iimage,')'
 216          call chkdpr(1,1,cond_string,cond_values,ierr,input_name,dt%amu_orig(itypat,iimage),1,tol8,iout)
 217        end do
 218      end if
 219    end do
 220 
 221 !  autoparal
 222    call chkint_eq(0,0,cond_string,cond_values,ierr,'autoparal',dt%autoparal,5,(/0,1,2,3,4/),iout)
 223 
 224 !  auxc_scal
 225    call chkdpr(0,0,cond_string,cond_values,ierr,'auxc_scal',dt%auxc_scal,1,0.0_dp,iout)
 226 
 227 !  bdberry
 228    if(dt%berryopt>0.and.dt%nberry>0.and.&
 229 &   dt%berryopt/= 4.and.dt%berryopt/= 6.and.dt%berryopt/= 7.and.&
 230 &   dt%berryopt/=14.and.dt%berryopt/=16.and.dt%berryopt/=17) then
 231      do ii=1,2*nsppol
 232        cond_string(1)='berryopt' ; cond_values(1)=dt%berryopt
 233        cond_string(2)='nberry'   ; cond_values(2)=dt%nberry
 234        write(input_name,'(a4,i1,a1)')'bdberry(',ii,')'
 235        call chkint_ge(2,2,cond_string,cond_values,ierr,input_name,dt%bdberry(ii),1,iout)
 236      end do
 237 !    bdberry(2) must be greater than bdberry(1)
 238      cond_string(1)='berryopt' ; cond_values(1)=dt%berryopt
 239      cond_string(2)='nberry'   ; cond_values(2)=dt%nberry
 240      cond_string(3)='bdberry(1)'   ; cond_values(3)=dt%bdberry(1)
 241      call chkint_ge(3,3,cond_string,cond_values,ierr,'bdberry(2)',dt%bdberry(2),dt%bdberry(1),iout)
 242      if(nsppol==2)then
 243 !      bdberry(4) must be greater than bdberry(3)
 244        cond_string(1)='berryopt' ; cond_values(1)=dt%berryopt
 245        cond_string(2)='nberry'   ; cond_values(2)=dt%nberry
 246        cond_string(3)='bdberry(3)'   ; cond_values(3)=dt%bdberry(3)
 247        call chkint_ge(3,3,cond_string,cond_values,ierr,'bdberry(4)',dt%bdberry(4),dt%bdberry(3),iout)
 248      end if
 249 !    Make sure all nband(nkpt) are >= bdberry
 250      do isppol=1,nsppol
 251        do ikpt=1,nkpt
 252          if (dt%nband(ikpt+(isppol-1)*nkpt)<=dt%bdberry(2*isppol)) then
 253            cond_string(1)='ikpt'   ; cond_values(1)=ikpt
 254            cond_string(2)='isppol' ; cond_values(2)=isppol
 255            cond_string(3)='nband'  ; cond_values(3)=dt%nband(ikpt+(isppol-1)*nkpt)
 256            call chkint_le(0,3,cond_string,cond_values,ierr,&
 257 &           'bdberry',dt%bdberry(2*isppol),dt%nband(ikpt+(isppol-1)*nkpt),iout)
 258            if(ierr==1)exit
 259          end if
 260        end do
 261      end do
 262    end if
 263 
 264 !  berryopt
 265 !  berryopt must be between -3 to +4, 6,7,14,16,17
 266    call chkint_eq(0,0,cond_string,cond_values,ierr,&
 267 &   'berryopt',dt%berryopt,13,(/-3,-2,-1,0,1,2,3,4,6,7,14,16,17/),iout)
 268 !  berryopt must be positive when mkmem==0
 269    if(dt%mkmem==0)then
 270      cond_string(1)='mkmem' ; cond_values(1)=dt%mkmem
 271      call chkint_ge(1,1,cond_string,cond_values,ierr,'berryopt',dt%berryopt,0,iout)
 272    end if
 273 !  berryopt must be positive when occopt/=1
 274    if(dt%occopt/=1)then
 275      cond_string(1)='occopt' ; cond_values(1)=dt%occopt
 276      call chkint_ge(1,1,cond_string,cond_values,ierr,'berryopt',dt%berryopt,0,iout)
 277    end if
 278 !  berryopt cannot be 4,6,7,14,16,17 when toldfe, tolvrs, toldff and tolrff are zero or negative
 279    if ((dt%toldfe < tiny(one)).and.(dt%tolvrs < tiny(one)).and.&
 280 &   (dt%toldff < tiny(one)).and.(dt%tolrff < tiny(one))) then
 281      cond_string(1)='toldfe' ; cond_values(1)=dt%toldfe
 282      cond_string(2)='toldff' ; cond_values(2)=dt%toldff
 283      cond_string(3)='tolrff' ; cond_values(3)=dt%tolrff
 284      cond_string(4)='tolvrs' ; cond_values(4)=dt%tolvrs
 285      call chkint_ne(4,4,cond_string,cond_values,ierr,'berryopt',dt%berryopt,1,(/4/),iout)
 286      cond_string(1)='toldfe' ; cond_string(2)='toldff' ; cond_string(3)='tolrff' ; cond_string(4)='tolvrs'
 287      call chkint_ne(4,4,cond_string,cond_values,ierr,'berryopt',dt%berryopt,1,(/6/),iout)
 288      cond_string(1)='toldfe' ; cond_string(2)='toldff' ; cond_string(3)='tolrff' ; cond_string(4)='tolvrs'
 289      call chkint_ne(4,4,cond_string,cond_values,ierr,'berryopt',dt%berryopt,1,(/7/),iout)
 290      cond_string(1)='toldfe' ; cond_string(2)='toldff' ; cond_string(3)='tolrff' ; cond_string(4)='tolvrs'
 291      call chkint_ne(4,4,cond_string,cond_values,ierr,'berryopt',dt%berryopt,1,(/14/),iout)
 292      cond_string(1)='toldfe' ; cond_string(2)='toldff' ; cond_string(3)='tolrff' ; cond_string(4)='tolvrs'
 293      call chkint_ne(4,4,cond_string,cond_values,ierr,'berryopt',dt%berryopt,1,(/16/),iout)
 294      cond_string(1)='toldfe' ; cond_string(2)='toldff' ; cond_string(3)='tolrff' ; cond_string(4)='tolvrs'
 295      call chkint_ne(4,4,cond_string,cond_values,ierr,'berryopt',dt%berryopt,1,(/17/),iout)
 296    end if
 297 !  Non-zero berryopt and usepaw==1 cannot be done unless response==0
 298    if (usepaw==1.and.dt%berryopt/=0) then
 299      cond_string(1)='usepaw' ; cond_values(1)=1
 300      cond_string(2)='berryopt' ; cond_values(2)=dt%berryopt
 301      call chkint_eq(1,2,cond_string,cond_values,ierr,'response',response,1,(/0/),iout)
 302    end if
 303 !  Non-zero berryopt and usepaw==1 and kptopt/=3 cannot be done unless symmorphi=0
 304 !  (that is, nonsymmorphic symmetries do not work yet
 305 !  Update MT 2017-05-31: nonsymmorphic symmetries seem also to be an issue for NCPP
 306    if (usepaw==1.and.dt%berryopt/=0.and.dt%kptopt/=3) then
 307   !if (dt%berryopt/=0.and.dt%kptopt/=3) then
 308      cond_string(1)='usepaw'; cond_values(1)=1
 309      cond_string(2)='berryopt'; cond_values(2)=dt%berryopt
 310      cond_string(3)='kptopt'; cond_values(3)=dt%kptopt
 311      call chkint_eq(1,3,cond_string,cond_values,ierr,'symmorphi',dt%symmorphi,1,(/0/),iout)
 312    end if
 313 !  Restrictions for berryopt=4,6,7,14,16,17
 314    if (usepaw==1.and.&
 315 &   (dt%berryopt== 4.or.dt%berryopt== 6.or.dt%berryopt== 7.or.&
 316 &   dt%berryopt==14.or.dt%berryopt==16.or.dt%berryopt==17)) then
 317 !     if (nsppol==2.and.nproc>1) then
 318 !       write(message,'(3a)') &
 319 !&       'For berryopt = 4,6,7,14,16,17 and nsppol=2, nproc must = 1 ',ch10,&
 320 !&       'Action: change number of processes'
 321 !       MSG_ERROR_NOSTOP(message,ierr)
 322 !     end if
 323    end if
 324 !  Non-zero berryopt and usepaw==1 and kpt // requires nproc to be a divisor of nkpt
 325    if (usepaw==1.and.dt%berryopt/=0.and.nproc>1.and.mod(dt%nkpt,nproc)/=0) then
 326      write(message, '(3a)' )&
 327 &     'For berryopt /= 0 with PAW in parallel, nproc must be a divisor of nkpt ',ch10,&
 328 &     'Action: change number of processes or kpts such that nproc divides nkpt evenly'
 329      MSG_ERROR_NOSTOP(message,ierr)
 330    end if
 331 
 332 !  Finite electric/displacement field checks
 333    if (dt%berryopt==4) then
 334      if (maxval(abs(dt%dfield(1:3)))>tiny(0.0_dp).or.&
 335 &     maxval(abs(dt%red_dfield(1:3)))>tiny(0.0_dp).or.&
 336 &     maxval(abs(dt%red_efield(1:3)))>tiny(0.0_dp).or.&
 337 &     maxval(abs(dt%red_efieldbar(1:3)))>tiny(0.0_dp)) then
 338        write(message,'(5a)' ) &
 339 &       'When berryopt==4, only efield is needed, other input field',ch10,&
 340 &       '(dfield,red_dfield,red_efield,red_efieldbar) should be zero.',ch10,&
 341 &       'Action: delete unneeded field in input file.'
 342        MSG_ERROR_NOSTOP(message,ierr)
 343      end if
 344    end if
 345    if (dt%berryopt==14) then
 346      if (maxval(abs(dt%dfield(1:3)))>tiny(0.0_dp).or.&
 347 &     maxval(abs(dt%red_dfield(1:3)))>tiny(0.0_dp).or.&
 348 &     maxval(abs(dt%red_efield(1:3)))>tiny(0.0_dp).or.&
 349 &     maxval(abs(dt%efield(1:3)))>tiny(0.0_dp)) then
 350        write(message,'(5a)') &
 351 &       'When berryopt==14, only red_efieldbar is needed, other input field',ch10,&
 352 &       '(dfield,red_dfield,efield,red_efield) should be zero.',ch10,&
 353 &       'Action: delete unneeded field in input file.'
 354        MSG_ERROR_NOSTOP(message,ierr)
 355      end if
 356    end if
 357    if (dt%berryopt==6) then
 358      if (maxval(abs(dt%red_dfield(1:3)))>tiny(0.0_dp).or.&
 359 &     maxval(abs(dt%red_efield(1:3)))>tiny(0.0_dp).or.&
 360 &     maxval(abs(dt%red_efieldbar(1:3)))>tiny(0.0_dp)) then
 361        write(message,'(5a)') &
 362 &       'When berryopt==6, only dfield and efield are needed, other input field',ch10,&
 363 &       '(red_dfield,red_efield,red_efieldbar) should be zero.',ch10,&
 364 &       'Action: delete unneeded field in input file.'
 365        MSG_ERROR_NOSTOP(message,ierr)
 366      end if
 367    end if
 368    if (dt%berryopt==16) then
 369      if (maxval(abs(dt%dfield(1:3)))>tiny(0.0_dp).or.&
 370 &     maxval(abs(dt%efield(1:3)))>tiny(0.0_dp).or.&
 371 &     maxval(abs(dt%red_efieldbar(1:3)))>tiny(0.0_dp)) then
 372        write(message,'(5a)')  &
 373 &       'When berryopt==16, only red_dfield and red_efield are needed, other input field',ch10,&
 374 &       '(dfield,efield,red_efieldbar) should be zero.',ch10,&
 375 &       'Action: delete unneeded field in input file.'
 376        MSG_ERROR_NOSTOP(message,ierr)
 377      end if
 378    end if
 379    if (dt%berryopt==17) then
 380      if (maxval(abs(dt%dfield(1:3)))>tiny(0.0_dp).or.&
 381 &     maxval(abs(dt%efield(1:3)))>tiny(0.0_dp).or.&
 382 &     maxval(abs(dt%red_efield(1:3)))>tiny(0.0_dp)) then
 383        write(message,'(5a)') &
 384 &       'When berryopt==17, only red_dfield and red_efieldbar are needed, other input field',ch10,&
 385 &       '(dfield,efield,red_efield) should be zero.',ch10,&
 386 &       'Action: delete unneeded field in input file.'
 387        MSG_ERROR_NOSTOP(message,ierr)
 388      end if
 389      if ((dt%jfielddir(1)/=1.and.dt%jfielddir(1)/=2).or.&
 390 &     (dt%jfielddir(2)/=1.and.dt%jfielddir(2)/=2).or.&
 391 &     (dt%jfielddir(3)/=1 .and.dt%jfielddir(3)/=2)) then
 392        write(message,'(5a)') &
 393 &       'When berryopt==17, jfielddir can only be 1 or 2 to controls whether reduced electric field',ch10,&
 394 &       '(jfielddir=1) or reduced electric displacement field (jfielddir=2) is chosen to be fixed', ch10,&
 395 &       'Action: change jfielddir to be 1 or 2 in input file.'
 396        MSG_ERROR_NOSTOP(message,ierr)
 397      end if
 398    end if
 399 
 400 !  berrystep
 401    call chkint_ge(0,0,cond_string,cond_values,ierr,'berrystep',dt%berrystep,1,iout)
 402    if(nproc>1)then
 403      cond_string(1)='nproc'; cond_values(1)=mpi_enregs(idtset)%nproc
 404      call chkint_eq(1,1,cond_string,cond_values,ierr,'berrystep',dt%berrystep,1,(/1/),iout)
 405    end if
 406 
 407 !  boxcutmin
 408    call chkdpr(0,0,cond_string,cond_values,ierr,'dilatmx',dt%dilatmx,1,zero,iout)
 409 !  if(response==1)then
 410 !    cond_string(1)='response' ; cond_values(1)=1
 411 !    call chkdpr(1,1,cond_string,cond_values,ierr,'boxcutmin',dt%boxcutmin,1,two,iout)
 412 !  end if
 413 
 414 !  builtintest
 415    call chkint_eq(0,0,cond_string,cond_values,ierr,'builtintest',dt%builtintest,8,(/0,1,2,3,4,5,6,7/),iout)
 416 
 417 !  chkdilatmx
 418    call chkint_eq(0,0,cond_string,cond_values,ierr,'chkdilatmx',dt%chkdilatmx,2,(/0,1/),iout)
 419 
 420 !  chksymbreak
 421    call chkint_eq(0,0,cond_string,cond_values,ierr,'chksymbreak',dt%chksymbreak,3,(/0,1,-1/),iout)
 422    if(dt%chksymbreak==1)then
 423 !    Check the values of tnons
 424      do isym=1,dt%nsym
 425        do ii=1,3
 426          delta=dt%tnons(ii,isym)*eight
 427          if(abs(delta-nint(delta))>tol6)then
 428            delta=dt%tnons(ii,isym)*three*four
 429            if(abs(delta-nint(delta))>tol6)then
 430              write(message, '(8a,i4,2a,9i3,2a,3es16.6,4a)' ) ch10,&
 431 &             ' chkinp: WARNING -',ch10,&
 432 &             '   Chksymbreak=1 . Found potentially symmetry-breaking value of tnons, ', ch10,&
 433 &             '   which is neither a rational fraction in 1/8th nor in 1/12th :', ch10,&
 434 &             '   for the symmetry number ',isym,ch10,&
 435 &             '   symrel is ',dt%symrel(1:3,1:3,isym),ch10,&
 436 &             '   tnons is ',dt%tnons(1:3,isym),ch10,&
 437 &             '   Please, read the description of the input variable chksymbreak,',ch10,&
 438 &             '   then, if you feel confident, you might switch it to zero, or consult with the forum.'
 439              call wrtout(iout,message,'COLL')
 440              call wrtout(std_out,message,'COLL')
 441              !ierr=ierr+1 ! moved this to a warning: for slab geometries arbitrary tnons can appear along the vacuum direction
 442            end if
 443          end if
 444        end do
 445      end do
 446    end if
 447 
 448 !  densfor_pred
 449    if(dt%iscf>0)then
 450      cond_string(1)='iscf';cond_values(1)=dt%iscf
 451      call chkint_le(0,1,cond_string,cond_values,ierr,'densfor_pred',dt%densfor_pred,6,iout)
 452      call chkint_ge(0,1,cond_string,cond_values,ierr,'densfor_pred',dt%densfor_pred,-6,iout)
 453      if (dt%densfor_pred<0.and.mod(dt%iprcel,100)>=61.and.(dt%iprcel<71.or.dt%iprcel>79)) then
 454        cond_string(1)='iscf';cond_values(1)=dt%iscf
 455        cond_string(2)='iprcel';cond_values(2)=dt%iprcel
 456        call chkint_ge(1,2,cond_string,cond_values,ierr,'densfor_pred',dt%densfor_pred,0,iout)
 457      end if
 458    end if
 459 
 460 !  diecut
 461    if(dt%iscf==-1)then
 462      cond_string(1)='iscf' ; cond_values(1)=-1
 463      cond_string(2)='4*ecut' ; cond_values(1)=4*dt%ecut
 464 !    Checks that presently diecut is 4*ecut
 465      call chkdpr(1,1,cond_string,cond_values,ierr,'diecut',dt%diecut,0,4*dt%ecut,iout)
 466    end if
 467 
 468 !  diemac
 469    call chkdpr(0,0,cond_string,cond_values,ierr,'diemac',dt%diemac,1,0.01_dp,iout)
 470 
 471 !  dilatmx
 472    call chkdpr(0,0,cond_string,cond_values,ierr,'dilatmx',dt%dilatmx,1,zero,iout)
 473    if(dt%chkdilatmx==1)then
 474      cond_string(1)='chkdilatmx' ; cond_values(1)=1
 475 !    Checks that presently chkdilatmx is smaller than 1.15
 476      call chkdpr(1,1,cond_string,cond_values,ierr,'dilatmx',dt%dilatmx,-1,1.15_dp,iout)
 477    end if
 478 
 479 !  dmatpuopt
 480    if (dt%usepawu==1.or.dt%usepawu==2.or.dt%usepawu==3.or.dt%usepawu==4.or.dt%usepawu==10.or.dt%usepawu==14) then
 481      cond_string(1)='usepawu' ; cond_values(1)=1
 482      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmatpuopt',dt%dmatpuopt,10,(/1,2,3,4,5,6,7,8,9,10/),iout)
 483    end if
 484 
 485 !  dmatudiag
 486    if (dt%usepawu==1.or.dt%usepawu==2.or.dt%usepawu==3.or.dt%usepawu==4.or.dt%usepawu==10.or.dt%usepawu==14) then
 487      cond_string(1)='usepawu' ; cond_values(1)=1
 488      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmatudiag',dt%dmatudiag,3,(/0,1,2/),iout)
 489    end if
 490 
 491 
 492 !  dmftbandi, dmftbandf
 493    if (dt%usedmft>0) then
 494      call chkint_eq(0,1,cond_string,cond_values,ierr,'dmftcheck',dt%dmftcheck,4,(/-1,0,1,2/),iout)
 495      if(dt%dmftcheck/=-1) then
 496        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
 497        call chkint_eq(1,1,cond_string,cond_values,ierr,'occopt',dt%occopt,1,(/3/),iout)
 498        cond_string(1)='usedmft' ; cond_values(1)=1
 499        call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftbandi',dt%dmftbandi,1,iout)
 500        cond_string(1)='usedmft' ; cond_values(1)=1
 501        call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftbandf',dt%dmftbandf,dt%dmftbandi,iout)
 502        cond_string(1)='mband' ; cond_values(1)=dt%mband
 503        call chkint_le(0,1,cond_string,cond_values,ierr,'dmftbandi',dt%dmftbandi,dt%mband,iout)
 504        cond_string(1)='mband' ; cond_values(1)=dt%mband
 505        call chkint_le(0,1,cond_string,cond_values,ierr,'dmftbandf',dt%dmftbandf,dt%mband,iout)
 506        cond_string(1)='usedmft' ; cond_values(1)=1
 507        call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_entropy',dt%dmft_entropy,0,iout)
 508        cond_string(1)='usedmft' ; cond_values(1)=1
 509        call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_iter',dt%dmft_iter,0,iout)
 510        if((dt%dmft_solv<6.or.dt%dmft_solv>7).and.dt%ucrpa==0) then
 511          cond_string(1)='usedmft' ; cond_values(1)=1
 512          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_nwlo',dt%dmft_nwlo,1,iout)
 513          cond_string(1)='usedmft' ; cond_values(1)=1
 514          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_nwli',dt%dmft_nwli,1,iout)
 515        end if
 516        cond_string(1)='usedmft' ; cond_values(1)=1
 517        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_read_occnd',dt%dmft_read_occnd,3,(/0,1,2/),iout)
 518        cond_string(1)='usedmft' ; cond_values(1)=1
 519        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_rslf',dt%dmft_rslf,3,(/-1,0,1/),iout)
 520        cond_string(1)='usedmft' ; cond_values(1)=1
 521        call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_mxsf',dt%dmft_mxsf,1,zero,iout)
 522        cond_string(1)='usedmft' ; cond_values(1)=1
 523        call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_mxsf',dt%dmft_mxsf,-1,one,iout)
 524        cond_string(1)='usedmft' ; cond_values(1)=1
 525        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_solv',dt%dmft_solv,8,(/-1,0,1,2,5,6,7,8/),iout)
 526        cond_string(1)='usedmft' ; cond_values(1)=1
 527        call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_tolfreq',dt%dmft_tolfreq,-1,0.01_dp,iout)
 528        cond_string(1)='usedmft' ; cond_values(1)=1
 529        call chkdpr(0,1,cond_string,cond_values,ierr,'dmft_tollc',dt%dmft_tollc,-1,tol5,iout)
 530        if(dt%usepawu==14) then
 531          cond_string(1)='usepawu' ; cond_values(1)=14
 532          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_dc',dt%dmft_dc,1,(/5/),iout)
 533        endif
 534        cond_string(1)='usedmft' ; cond_values(1)=1
 535        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_dc',dt%dmft_dc,4,(/0,1,2,5/),iout)
 536        if(dt%getwfk==0.and.dt%irdwfk==0.and.dt%irdden==0.and.dt%getden==0.and.dt%ucrpa==0) then
 537          write(message,'(3a,i3,a,i3,a,i3,a,i3,a)' )&
 538 &         'When usedmft==1, A WFC file or a DEN file have to be read. In the current calculation:',ch10, &
 539 &         '  getwfk =',dt%getwfk, &
 540 &         '  irdwfk =',dt%irdwfk, &
 541 &         '  getden =',dt%getden, &
 542 &         '  irdden =',dt%irdden, &
 543 &         '  Action: use a restart density or wfc file'
 544          if(dt%iscf>0) MSG_ERROR(message)
 545        end if
 546        cond_string(1)='usedmft' ; cond_values(1)=1
 547        call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_t2g',dt%dmft_t2g,2,(/0,1/),iout)
 548        if (dt%dmft_solv>=4.and.dt%ucrpa==0) then
 549          cond_string(1)='usedmft' ; cond_values(1)=1
 550          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftqmc_l',dt%dmftqmc_l,1,iout)
 551          cond_string(1)='usedmft' ; cond_values(1)=1
 552          call chkdpr(0,1,cond_string,cond_values,ierr,'dmftqmc_n',dt%dmftqmc_n,1,one,iout)
 553          cond_string(1)='usedmft' ; cond_values(1)=1
 554          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftqmc_seed',dt%dmftqmc_seed,0,iout)
 555          cond_string(1)='usedmft' ; cond_values(1)=1
 556          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftqmc_therm',dt%dmftqmc_therm,1,iout)
 557        end if
 558        if (dt%dmft_solv>=5) then
 559          cond_string(1)='dmft_solv' ; cond_values(1)=5
 560          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmftctqmc_basis',dt%dmftctqmc_basis,3,(/0,1,2/),iout)
 561          cond_string(1)='dmft_solv' ; cond_values(1)=5
 562          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmftctqmc_check',dt%dmftctqmc_check,4,(/0,1,2,3/),iout)
 563          cond_string(1)='dmft_solv' ; cond_values(1)=5
 564          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftctqmc_gmove',dt%dmftctqmc_gmove,0,iout)
 565          cond_string(1)='dmft_solv' ; cond_values(1)=5
 566          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftctqmc_meas',dt%dmftctqmc_meas,1,iout)
 567 #if defined HAVE_TRIQS_v2_0 || defined HAVE_TRIQS_v1_4
 568          if (dt%dmft_solv>=6) then
 569            cond_string(1)='dmft_solv' ; cond_values(1)=5
 570            call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_qmc_l',dt%dmftqmc_l,2*dt%dmft_nwli+1,iout)
 571            cond_string(1)='usedmft' ; cond_values(1)=1
 572            call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftctqmc_triqs_nleg',dt%dmftctqmc_triqs_nleg,1,iout)
 573          end if
 574 #endif
 575        end if
 576        if (dt%dmft_solv==5) then
 577          cond_string(1)='dmft_solv' ; cond_values(1)=5
 578          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmftctqmc_correl',dt%dmftctqmc_correl,2,(/0,1/),iout)
 579          cond_string(1)='dmft_solv' ; cond_values(1)=5
 580          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmftctqmc_grnns',dt%dmftctqmc_grnns,2,(/0,1/),iout)
 581          cond_string(1)='dmft_solv' ; cond_values(1)=5
 582          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftctqmc_mrka',dt%dmftctqmc_mrka,0,iout)
 583          cond_string(1)='dmft_solv' ; cond_values(1)=5
 584          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmftctqmc_mov',dt%dmftctqmc_mov,2,(/0,1/),iout)
 585          cond_string(1)='dmft_solv' ; cond_values(1)=5
 586          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmftctqmc_order',dt%dmftctqmc_order,0,iout)
 587          cond_string(1)='dmft_solv' ; cond_values(1)=5
 588          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_nwlo',dt%dmft_nwlo,2*dt%dmftqmc_l,iout)
 589        end if
 590        if (dt%dmft_entropy>=1) then
 591          cond_string(1)='dmft_solv' ; cond_values(1)=5
 592          call chkint_ge(0,1,cond_string,cond_values,ierr,'dmft_nlambda',dt%dmft_nlambda,3,iout)
 593          cond_string(1)='dmft_solv' ; cond_values(1)=5
 594          call chkint_le(0,1,cond_string,cond_values,ierr,'dmft_entropy',dt%dmft_entropy,dt%dmft_nlambda,iout)
 595          cond_string(1)='dmft_solv' ; cond_values(1)=5
 596          call chkint_eq(0,1,cond_string,cond_values,ierr,'dmft_dc',dt%dmft_dc,1,(/1/),iout)
 597          if (dt%dmft_solv /= 5 ) then
 598            write(message,'(3a,i3,a,i3,a,i3,a,i3,a)' )&
 599 &           'When dmft_entropy>=1, the impurity solver has to be currently  dmft_solv=5:',ch10, &
 600 &           'Action: change your dmft_solv input'
 601            MSG_ERROR(message)
 602          end if
 603        end if
 604      end if
 605    end if
 606 
 607 #if !defined HAVE_TRIQS_v2_0 && !defined HAVE_TRIQS_v1_4
 608    if(dt%dmft_solv>=6.and.dt%dmft_solv<=7) then
 609      write(message, '(a,a,a)' )&
 610 &     ' dmft_solv=6, or 7 is only relevant if the TRIQS library is linked',ch10,&
 611 &     ' Action: check compilation options'
 612      MSG_ERROR(message)
 613    end if
 614 #endif
 615 
 616 !  dosdeltae
 617    call chkdpr(0,0,cond_string,cond_values,ierr,'dosdeltae',dt%dosdeltae,1,0.0_dp,iout)
 618 
 619 !  dynimage between 0 and 1
 620    maxidyn=maxval(dt%dynimage(:))
 621    minidyn=minval(dt%dynimage(:))
 622    call chkint_ge(0,0,cond_string,cond_values,ierr,'dynimage',minidyn,0,iout)
 623    call chkint_le(0,0,cond_string,cond_values,ierr,'dynimage',maxidyn,1,iout)
 624 
 625 !  ecut
 626 !  With planewaves, one must use positive ecut
 627    if(usewvl==0)then
 628      if (abs(dt%ecut+1._dp)<tol8) then
 629        write(message, '(3a)' )&
 630 &       'The input keyword "ecut" is compulsory !',ch10,&
 631 &       'Action: add a value for "ecut" in the input file.'
 632        MSG_ERROR_NOSTOP(message,ierr)
 633      else
 634        cond_string(1)='usewvl' ; cond_values(1)=usewvl
 635        call chkdpr(1,1,cond_string,cond_values,ierr,'ecut',dt%ecut,1,tol8,iout)
 636      end if
 637    end if
 638 
 639 !  pawecutdg (placed here to stop before ngfftdg)
 640    if (usepaw==1) then
 641      if(usewvl==0) then
 642        call chkdpr(1,0,cond_string,cond_values,ierr,'pawecutdg',dt%pawecutdg,1,tol8,iout)
 643        cond_string(1)='ecut' ; cond_values(1)=dt%ecut
 644        call chkdpr(1,1,cond_string,cond_values,ierr,'pawecutdg',dt%pawecutdg,1,dt%ecut,iout)
 645      else
 646        if(dt%pawecutdg > 0.d0) then
 647          MSG_ERROR('In PAW+WVL do not use pawecutdg')
 648        end if
 649      end if
 650    end if
 651 
 652 !  ecuteps
 653    if( ANY(optdriver == [RUNL_SCREENING]) )then
 654      call chkdpr(0,0,cond_string,cond_values,ierr,'ecuteps',dt%ecuteps,1,0.0_dp,iout)
 655      if (dt%ecuteps <= 0) then
 656        MSG_ERROR_NOSTOP("ecuteps must be > 0 if optdriver == 3", ierr)
 657      end if
 658      if(dt%fftgw<20 .and. dt%fftgw/=0)then
 659        if(dt%ecutwfn<dt%ecuteps-tol8)then
 660          write(message,'(a,es16.6,a,es16.6,a,6a)')&
 661 &         'The values of ecutwfn and ecuteps are ', dt%ecutwfn,' and ',dt%ecuteps,ch10,&
 662 &         'With fftgw lower than 20, one expect ecuteps to be smaller or equal to ecutwfn.',ch10,&
 663 &         'Indeed, one is wasting memory without gaining CPU time or accuracy.',ch10,&
 664 &         'Action: use another value of fftgw (e.g. 21), or adjust ecutwfn with ecuteps.'
 665          MSG_ERROR_NOSTOP(message,ierr)
 666        end if
 667      end if
 668    end if
 669 
 670 !  ecutsigx
 671 !  @MG FIXME reinstate this check, after having rewritten FFT treatment in GW
 672    if( ANY( optdriver==(/RUNL_SIGMA/) ) .and..FALSE.)then
 673      call chkdpr(0,0,cond_string,cond_values,ierr,'ecutsigx',dt%ecutsigx,1,0.0_dp,iout)
 674      if(dt%fftgw<20)then
 675        if(dt%ecutwfn<dt%ecutsigx-tol8)then
 676          write(message,'(a,es16.6,a,es16.6,a,6a)')&
 677 &         'The values of ecutwfn and ecutsigx are ', dt%ecutwfn,' and ',dt%ecutsigx,ch10,&
 678 &         'With fftgw lower than 20, one expect ecutsigx to be smaller or equal to ecutwfn.',ch10,&
 679 &         'Indeed, one is wasting memory without gaining CPU time or accuracy.',ch10,&
 680 &         'Action: use another value of fftgw (e.g. 21), or adjust ecutwfn with ecutsigx.'
 681          MSG_ERROR_NOSTOP(message,ierr)
 682        end if
 683      end if
 684    end if
 685 
 686    if ( optdriver==RUNL_BSE) then
 687      ! Check for BSE calculations that are not implemented.
 688      if (dt%nspinor == 2) then
 689        MSG_ERROR_NOSTOP("BSE with nspinor 2 not implemented", ierr)
 690      end if
 691    end if
 692 
 693    ! Check for GW calculations that are not implemented.
 694    if (ANY(optdriver == [RUNL_SCREENING, RUNL_SIGMA])) then
 695      if (dt%nspinor == 2) then
 696        if (dt%usepaw == 1) then
 697          MSG_ERROR_NOSTOP("GW with PAW and nspinor 2 not implemented", ierr)
 698        end if
 699        !if (optdriver == RUNL_SCREENING .and. dt%symchi == 1) then
 700        !  MSG_ERROR_NOSTOP("Screening with symchi 1 and nspinor 2 not implemented", ierr)
 701        !end if
 702        !if (optdriver == RUNL_SIGMA .and. dt%symsigma == 1) then
 703        !  MSG_ERROR_NOSTOP("Self-energy with symsigma 1 and nspinor 2 not implemented", ierr)
 704        !end if
 705        if (optdriver == RUNL_SIGMA .and. &
 706        any(mod(dt%gwcalctyp, 10) == [SIG_GW_AC, SIG_QPGW_PPM, SIG_QPGW_CD])) then
 707          MSG_ERROR_NOSTOP("analytic-continuation, model GW with nspinor 2 are not implemented", ierr)
 708        end if
 709        !if (optdriver == RUNL_SIGMA .and. mod(dt%gwcalctyp, 100) >= 10) then
 710        !  MSG_ERROR_NOSTOP("Self-consistent GW with nspinor == 2 not implemented", ierr)
 711        !end if
 712        if (dt%gwcomp /= 0) then
 713          MSG_ERROR_NOSTOP("gwcomp /= 0 with nspinor 2 not implemented", ierr)
 714        end if
 715      end if ! nspinor 2
 716 
 717      if (maxval(abs(dt%istwfk(1:nkpt))) > 1 .and. mod(dt%gwcalctyp, 100) >= 20) then
 718        write(msg, "(3a)")"Self-consistent GW with istwfk > 1 not supported.",ch10, &
 719        "Please regenerate your WFK file with istwfk *1"
 720        MSG_ERROR_NOSTOP(msg, ierr)
 721      end if
 722 
 723      ! Avoid wasting CPUs if nsppol==2.
 724      if (dt%nsppol==2 .and. .not. iseven(nproc) .and. nproc > 1) then
 725        write(msg,'(3a)') "Spin-polarized GW calculations should be run with an even number of processors ",ch10,&
 726 &       " for achieving an optimal distribution of memory and CPU load. Change the number of processors."
 727        MSG_ERROR_NOSTOP(msg, ierr)
 728      end if
 729    end if
 730 
 731 !  ecutsm
 732    call chkdpr(0,0,cond_string,cond_values,ierr,'ecutsm',dt%ecutsm,1,0.0_dp,iout)
 733 !  With non-zero optcell, one must use non-zero ecutsm
 734    if(dt%optcell/=0 )then
 735      cond_string(1)='optcell' ; cond_values(1)=dt%optcell
 736      call chkdpr(1,1,cond_string,cond_values,ierr,'ecutsm',dt%ecutsm,1,tol8,iout)
 737    end if
 738 
 739 !  ecutwfn <= ecut. This is also needed for the correct evaluation
 740 !  of the Kleynman-Bylander form factors as the spline in Psps% is done with ecut
 741 !  while we need |q+G| up to ecut. enlargement due to the q is already
 742 !  taken into account by enlarging the spline mesh by around 20%.
 743    if ( ANY(optdriver == [RUNL_SCREENING, RUNL_SIGMA, RUNL_BSE]) ) then
 744      call chkdpr(0,0,cond_string,cond_values,ierr,'ecutwfn',dt%ecuteps,1,0.0_dp,iout)
 745      if(dt%ecut<dt%ecutwfn-tol8)then
 746        write(message,'(a,es16.6,a,es16.6,a,6a)')&
 747 &       'The values of ecut and ecutwfn are ', dt%ecut,' and ',dt%ecutwfn,ch10,&
 748 &       'One expects ecutwfn to be smaller or equal to ecut.',ch10,&
 749 &       'Action: adjust ecutwfn with ecut.'
 750        MSG_ERROR_NOSTOP(message,ierr)
 751      end if
 752    end if
 753 
 754 !  efmas
 755    if(optdriver==RUNL_RESPFN) then !.and.usepaw==1)then
 756      cond_string(1)='optdriver' ; cond_values(1)=1
 757      cond_string(2)='usepaw'    ; cond_values(2)=0 !usepaw
 758      cond_string(3)='ieig2rf'   ; cond_values(3)=1
 759      cond_string(4)='nsym'      ; cond_values(4)=1
 760      !cond_string(5)='useylm'    ; cond_values(5)=1
 761      call chkint_eq(1,4,cond_string,cond_values,ierr,'efmas',dt%efmas,2,(/0,1/),iout)
 762      if (dt%paral_rf==1) then
 763        cond_string(1)='paral_rf' ; cond_values(1)=1
 764        call chkint_eq(1,1,cond_string,cond_values,ierr,'efmas',dt%efmas,1,(/0/),iout)
 765      end if
 766    end if
 767 
 768 !  efmas_calc_dirs
 769    if(dt%efmas==1) then
 770      call chkint_eq(0,0,cond_string,cond_values,ierr,'efmas_calc_dirs',dt%efmas_calc_dirs,7,(/-3,-2,-1,0,1,2,3/),iout)
 771    end if
 772 
 773 !  efmas_deg
 774    if(dt%efmas==1) then
 775      call chkint_eq(0,0,cond_string,cond_values,ierr,'efmas_deg',dt%efmas_deg,2,(/0,1/),iout)
 776    end if
 777 
 778 !  efmas_deg_tol
 779    if(dt%efmas==1) then
 780      call chkdpr(0,0,cond_string,cond_values,ierr,'efmas_deg_tol',dt%efmas_deg_tol,1,0.0_dp,iout)
 781    end if
 782 
 783 !  efmas_dim
 784    if(dt%efmas==1) then
 785      call chkint_eq(0,0,cond_string,cond_values,ierr,'efmas_dim',dt%efmas_dim,3,(/1,2,3/),iout)
 786    end if
 787 
 788 !  efmas_n_dirs
 789    if(dt%efmas==1) then
 790      call chkint_ge(0,0,cond_string,cond_values,ierr,'efmas_n_dirs',dt%efmas_n_dirs,0,iout)
 791    end if
 792 
 793 !  efmas_ntheta
 794    if(dt%efmas==1) then
 795      call chkint_ge(0,0,cond_string,cond_values,ierr,'efmas_ntheta',dt%efmas_ntheta,1,iout)
 796    end if
 797 
 798 !  enable_mpi_io
 799    if(dt%iomode==IO_MODE_MPI) then
 800      cond_string(1)='iomode' ; cond_values(1)=1
 801      call chkint_eq(1,1,cond_string,cond_values,ierr,'enable_mpi_io',xmpi_mpiio,1,(/1/),iout)
 802    end if
 803 
 804    ! eph variables
 805    if (optdriver==RUNL_EPH) then
 806      cond_string(1)='optdriver' ; cond_values(1)=RUNL_EPH
 807      call chkint_eq(1,1,cond_string,cond_values,ierr,'eph_task',dt%eph_task,7,[0,1,2,3,4,5,6],iout)
 808 
 809      if (any(dt%ddb_ngqpt <= 0)) then
 810        MSG_ERROR_NOSTOP("ddb_ngqpt must be specified when performing EPH calculations.", ierr)
 811      end if
 812      if (dt%eph_task==2 .and. dt%irdwfq==0 .and. dt%getwfq==0) then
 813        MSG_ERROR_NOSTOP('Either getwfq or irdwfq must be non-zero in order to compute the gkk', ierr)
 814      end if
 815 
 816      if (all(dt%eph_task /= [5, 6]) .and. any(dt%istwfk(1:nkpt) /= 1)) then
 817        MSG_ERROR_NOSTOP('EPH code does not yet support istwfk != 1. Regenerate WFK with istwfk = *1', ierr)
 818      end if
 819 
 820      cond_string(1)='optdriver' ; cond_values(1)=RUNL_EPH
 821      call chkint_eq(1,1,cond_string,cond_values,ierr,'eph_frohlichm',dt%eph_frohlichm,2,[0,1],iout)
 822 
 823    end if
 824 
 825 !  exchmix
 826    call chkdpr(0,0,cond_string,cond_values,ierr,'exchmix',dt%exchmix,1,0.0_dp,iout)
 827 
 828 !  extrapwf
 829    call chkint_eq(0,0,cond_string,cond_values,ierr,'extrapwf',dt%extrapwf,2,(/0,1/),iout)
 830    if (dt%extrapwf>0.and.dt%densfor_pred<5) then
 831      write(message,'(3a)')&
 832 &     'extrapwf keyword (extrapolation of WF) is only compatible with',ch10,&
 833 &     'densfor_pred=5 or 6; please change densfor_pred value.'
 834      MSG_ERROR_NOSTOP(message,ierr)
 835 !    MT oct 14: Should use chkint_eq but the msg is not clear enough
 836    end if
 837 
 838 !  fermie_nest
 839    call chkdpr(0,0,cond_string,cond_values,ierr,'fermie_nest',dt%fermie_nest,1,0.0_dp,iout)
 840 
 841 !  fftgw
 842    call chkint_eq(0,0,cond_string,cond_values,ierr,'fftgw',dt%fftgw,8, [00,01,10,11,20,21,30,31],iout)
 843 
 844 !  fockoptmix
 845    call chkint_eq(0,0,cond_string,cond_values,ierr,'fockoptmix',&
 846 &   dt%fockoptmix,12,(/0,1,11,201,211,301,401,501,601,701,801,901/),iout)
 847    if(dt%paral_kgb/=0)then
 848      cond_string(1)='paral_kgb' ; cond_values(1)=dt%paral_kgb
 849 !    Make sure that dt%fockoptmix is 0, 1 or 11 (wfmixalg==0)
 850      call chkint_eq(1,1,cond_string,cond_values,ierr,'fockoptmix',dt%fockoptmix,3,(/0,1,11/),iout)
 851    end if
 852 
 853 !  frzfermi
 854    call chkint_eq(0,0,cond_string,cond_values,ierr,'frzfermi',dt%frzfermi,2,(/0,1/),iout)
 855 
 856 !  fxcartfactor
 857    call chkdpr(0,0,cond_string,cond_values,ierr,'fxcartfactor',dt%fxcartfactor,1,zero,iout)
 858 
 859 !  ga_algor
 860    call chkint_eq(0,0,cond_string,cond_values,ierr,'ga_algor',dt%ga_algor,3,(/1,2,3/),iout)
 861 
 862 !  ga_fitness
 863    call chkint_eq(0,0,cond_string,cond_values,ierr,'ga_fitness',dt%ga_fitness,3,(/1,2,3/),iout)
 864 
 865 !  ga_opt_percent
 866    call chkdpr(0,0,cond_string,cond_values,ierr,'ga_opt_percent',dt%ga_opt_percent,1,tol8,iout)
 867 
 868 !  getxred
 869    if(dt%getxcart/=0)then
 870      cond_string(1)='getxcart' ; cond_values(1)=dt%getxcart
 871 !    Make sure that dt%getxred is 0
 872      call chkint_eq(1,1,cond_string,cond_values,ierr,'getxred',dt%getxred,1,(/0/),iout)
 873    end if
 874 
 875 !  goprecon
 876    call chkint_eq(0,0,cond_string,cond_values,ierr,'goprecon',dt%goprecon,4,(/0,1,2,3/),iout)
 877 
 878 !  gpu_devices
 879    if (dt%use_gpu_cuda==1) then
 880      if (all(gpu_devices(:)==-2)) then
 881        gpu_devices(:)=dt%gpu_devices(:)
 882      else if (any(dt%gpu_devices(:)/=gpu_devices(:))) then
 883        write(message,'(3a)')&
 884 &       'GPU device(s) selection cannot be different from one dataset to another!',ch10,&
 885 &       'Action: change gpu_devices in input file.'
 886        MSG_ERROR_NOSTOP(message, ierr)
 887      end if
 888    end if
 889 
 890 !  gw_invalid_freq
 891    call chkint_eq(0,0,cond_string,cond_values,ierr,'gw_invalid_freq',dt%gw_invalid_freq,3,(/0,1,2/),iout)
 892 
 893 !  gw_sctype
 894    call chkint_eq(0,0,cond_string,cond_values,ierr,'gw_sctype',dt%gw_sctype,&
 895 &   4,(/GWSC_one_shot,GWSC_only_W,GWSC_only_G,GWSC_both_G_and_W/),iout)
 896 
 897 !  gw_sigxcore
 898    call chkint_eq(0,0,cond_string,cond_values,ierr,'gw_sigxcore',dt%gw_sigxcore,2,[0,1],iout)
 899 
 900 !  gwcomp
 901    call chkint_eq(0,0,cond_string,cond_values,ierr,'gwcomp',dt%gwcomp,2,[0,1],iout)
 902    if (dt%gwcomp/=0) then
 903      if (optdriver==RUNL_SCREENING .and. (dt%awtr /=1 .or. dt%spmeth /=0)) then
 904        write(message,'(3a)' )&
 905 &       'When gwcomp/=0, the Adler-Wiser formula with time-reversal should be used',ch10,&
 906 &       'Action: set awtr to 1 or/and spmeth to 0'
 907        MSG_ERROR_NOSTOP(message,ierr)
 908      end if
 909 
 910 !    Extrapolar trick with HF, SEX and COHSEX is meaningless for Sigma
 911      if(optdriver==RUNL_SIGMA) then
 912        mod10=MOD(dt%gwcalctyp,10)
 913        if ( ANY(mod10 == [SIG_HF, SIG_SEX, SIG_COHSEX]) ) then
 914          write(message,'(3a)' )&
 915          'gwcomp/=0, is meaningless in the case of HF, SEX or COHSEX calculations. ',ch10,&
 916          'Action: set gwcomp to 0 or change gwcalctyp'
 917          MSG_ERROR_NOSTOP(message,ierr)
 918        end if
 919      end if
 920      if (optdriver==RUNL_SIGMA .and. ALL( dt%ppmodel /= [0,1,2] )) then
 921        write(message,'(a,i0,a)')&
 922 &       'The completeness trick cannot be used when ppmodel is ',dt%ppmodel,'. It should be set to 0, 1 or 2. '
 923        MSG_ERROR_NOSTOP(message,ierr)
 924      end if
 925    end if
 926 
 927 !  gwmem
 928    call chkint_eq(0,0,cond_string,cond_values,ierr,'gwmem',dt%gwmem,4,[0,1,10,11],iout)
 929 
 930 !  gwpara
 931    call chkint_eq(0,0,cond_string,cond_values,ierr,'gwpara',dt%gwpara,3,[0,1,2],iout)
 932 
 933 !  gwrpacorr
 934    if(dt%gwrpacorr>0) then
 935      mod10=MOD(dt%gwcalctyp,10)
 936      if (optdriver /= RUNL_SCREENING) then
 937        write(message,'(3a)' )&
 938        'gwrpacorr>0 can only be used when calculating the screening',ch10,&
 939        'Action: set gwrpacorr to 0 or optdriver to 3'
 940        MSG_ERROR_NOSTOP(message,ierr)
 941      end if
 942      if( mod10 /= SIG_GW_AC ) then
 943        write(message,'(3a)' )&
 944        'gwrpacorr>0 can only be used with purely imaginary frequencies',ch10,&
 945        'Action: set gwrpacorr to 0 or change gwcalctyp'
 946        MSG_ERROR_NOSTOP(message,ierr)
 947      end if
 948    end if
 949 
 950 !  gwls_stern_kmax
 951    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_stern_kmax',dt%gwls_stern_kmax,1,iout)
 952 
 953 !  gwls_npt_gauss_quad
 954    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_npt_gauss_quad',dt%gwls_npt_gauss_quad,1,iout)
 955 
 956 ! gwls_diel_model
 957    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_diel_model',dt%gwls_diel_model,1,iout)
 958    call chkint_le(0,0,cond_string,cond_values,ierr,'gwls_diel_model',dt%gwls_diel_model,3,iout)
 959 
 960 ! gwls_model_parameter
 961    call chkdpr(0,0,cond_string,cond_values,ierr,'gwls_model_parameter',dt%gwls_model_parameter,1,zero,iout)
 962 
 963 ! gwls_print_debug
 964    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_print_debug',dt%gwls_print_debug,0,iout)
 965 
 966 ! gwls_nseeds
 967    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_nseeds',dt%gwls_nseeds,1,iout)
 968 
 969 ! gwls_kmax_complement
 970    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_kmax_complement',dt%gwls_kmax_complement,0,iout)
 971 
 972 ! gwls_kmax_poles
 973    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_kmax_poles',dt%gwls_kmax_poles,0,iout)
 974 
 975 ! gwls_kmax_analytic
 976    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_kmax_analytic',dt%gwls_kmax_analytic,0,iout)
 977 
 978 ! gwls_kmax_numeric
 979    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_kmax_numeric',dt%gwls_kmax_numeric,0,iout)
 980 
 981 ! gwls_band_index
 982    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_band_index',dt%gwls_band_index,1,iout)
 983 
 984 ! gwls_exchange
 985    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_exchange',dt%gwls_exchange,0,iout)
 986 
 987 ! gwls_correlation
 988    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_correlation',dt%gwls_correlation,0,iout)
 989 
 990 ! gwls_first_seed
 991    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_first_seed',dt%gwls_first_seed,1,iout)
 992 
 993 ! gwls_recycle
 994    call chkint_ge(0,0,cond_string,cond_values,ierr,'gwls_recycle',dt%gwls_recycle,0,iout)
 995    call chkint_le(0,0,cond_string,cond_values,ierr,'gwls_recycle',dt%gwls_recycle,2,iout)
 996 
 997 !  iatsph between 1 and natom
 998    maxiatsph=maxval(dt%iatsph(1:dt%natsph))
 999    miniatsph=minval(dt%iatsph(1:dt%natsph))
1000    call chkint_ge(0,0,cond_string,cond_values,ierr,'iatsph',miniatsph,1,iout)
1001    call chkint_le(0,0,cond_string,cond_values,ierr,'iatsph',maxiatsph,natom,iout)
1002 
1003 !  icoulomb
1004    call chkint_eq(0,0,cond_string,cond_values,ierr,'icoulomb',dt%icoulomb,3,(/0,1,2/),iout)
1005    if (dt%nspden > 2) then
1006      cond_string(1)='nspden' ; cond_values(1)=nspden
1007      call chkint_eq(1,1,cond_string,cond_values,ierr,'icoulomb',dt%icoulomb,1,(/0/),iout)
1008    end if
1009 
1010 !  ieig2rf
1011    if(optdriver==RUNL_RESPFN.and.usepaw==1)then
1012      cond_string(1)='optdriver' ; cond_values(1)=1
1013      cond_string(2)='usepaw'    ; cond_values(2)=usepaw
1014      call chkint_eq(1,2,cond_string,cond_values,ierr,'ieig2rf',dt%ieig2rf,1,(/0/),iout)
1015    end if
1016    if(optdriver==RUNL_RESPFN.and.dt%paral_rf==1)then
1017      cond_string(1)='paral_rf' ; cond_values(1)=1
1018      call chkint_eq(1,1,cond_string,cond_values,ierr,'ieig2rf',dt%ieig2rf,1,(/0/),iout)
1019    end if
1020 
1021 !  imgmov
1022    call chkint_eq(0,0,cond_string,cond_values,ierr,'imgmov',dt%imgmov,9,(/0,1,2,4,5,6,9,10,13/),iout)
1023    if (dt%imgmov>0 .and. dt%imgmov/=6) then ! when imgmov>0, except imgmov==6, allow only ionmov0 and optcell 0 (temporary)
1024      cond_string(1)='imgmov' ; cond_values(1)=dt%imgmov
1025      call chkint_eq(1,1,cond_string,cond_values,ierr,'ionmov',dt%ionmov,1,(/0/),iout)
1026      if (dt%imgmov==9.or.dt%imgmov==10.or.dt%imgmov==13) then
1027        cond_string(1)='imgmov' ; cond_values(1)=dt%imgmov
1028        !Temporarily deactivate NPT algorithms (not yet usable)
1029        call chkint_eq(1,1,cond_string,cond_values,ierr,'optcell',dt%optcell,1,(/0/),iout)
1030      else
1031        cond_string(1)='imgmov' ; cond_values(1)=dt%imgmov
1032        call chkint_eq(1,1,cond_string,cond_values,ierr,'optcell',dt%optcell,1,(/0/),iout)
1033      end if
1034    end if
1035 
1036 !  imgwfstor
1037    call chkint_eq(0,0,cond_string,cond_values,ierr,'imgwfstor',dt%imgwfstor,2,(/0,1/),iout)
1038    if (dt%extrapwf/=0) then ! extrapwf/=0 not allowed presently with imgwfstor
1039      cond_string(1)='extrapwf' ; cond_values(1)=dt%extrapwf
1040      call chkint_eq(1,1,cond_string,cond_values,ierr,'imgwfstor',dt%imgwfstor,1,(/0/),iout)
1041    endif
1042    if (dt%ntimimage<=1) then ! imgwfstor activate only when there is more than one time step for images
1043      cond_string(1)='ntimimage' ; cond_values(1)=dt%ntimimage
1044      call chkint_eq(1,1,cond_string,cond_values,ierr,'imgwfstor',dt%imgwfstor,1,(/0/),iout)
1045    endif
1046 
1047 !  intxc
1048    if(dt%iscf==-1)then
1049      cond_string(1)='iscf' ; cond_values(1)=-1
1050 !    Make sure that dt%intxc is 0
1051      call chkint_eq(1,1,cond_string,cond_values,ierr,'intxc',dt%intxc,1,(/0/),iout)
1052    end if
1053 !  TEMPORARY
1054    if(optdriver==RUNL_RESPFN)then ! Make sure that dt%intxc is 0
1055      cond_string(1)='optdriver' ; cond_values(1)=1
1056      call chkint_eq(1,1,cond_string,cond_values,ierr,'intxc',dt%intxc,1,(/0/),iout)
1057    end if
1058 
1059 !  ionmov
1060    call chkint_eq(0,0,cond_string,cond_values,ierr,'ionmov',&
1061 &   dt%ionmov,24,(/0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,20,21,22,23,24,25,26,27/),iout)
1062 
1063 !  When optcell/=0, ionmov must be 2, 3, 13, 22 or 25 (except if imgmov>0)
1064    if(dt%optcell/=0)then
1065      if (dt%imgmov==0) then
1066        cond_string(1)='optcell' ; cond_values(1)=dt%optcell
1067        call chkint_eq(1,1,cond_string,cond_values,ierr,'ionmov',dt%ionmov,6,(/2,3,13,15,22,25/),iout)
1068      else
1069        cond_string(1)='optcell' ; cond_values(1)=dt%optcell
1070        call chkint_eq(1,1,cond_string,cond_values,ierr,'ionmov',dt%ionmov,1,(/0/),iout)
1071      end if
1072    end if
1073    if (dt%ionmov == 13) then
1074      cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
1075 !    Make sure that nnos is not null
1076      call chkint_ge(1,1,cond_string,cond_values,ierr,'nnos',dt%nnos,1,iout)
1077    end if
1078 
1079 !  iprcel
1080    call chkint(0,0,cond_string,cond_values,ierr,'iprcel',dt%iprcel,1,(/0/),1,21,iout)   !  0 or superior to 21
1081    if(nsppol==2 .and. (dt%occopt>=3 .and. dt%occopt<=8).and.mod(dt%iprcel,10)>49 )then
1082      write(message,'(5a)')&
1083 &     'For spin-polarized metallic systems (occopt>3),',ch10,&
1084 &     'only RPA dielectric matrix can be evaluated) !',ch10,&
1085 &     'Action: change iprcel value in input file (mod(iprcel,100)<50) !'
1086      MSG_ERROR_NOSTOP(message, ierr)
1087    end if
1088    if(dt%npspinor>1.and.dt%iprcel>0)then
1089      write(message,'(5a)')&
1090 &     'When parallelization over spinorial components is activated (npspinor>1),',ch10,&
1091 &     'only model dielectric function is allowed (iprcel=0) !',ch10,&
1092 &     'Action: change iprcel value in input file !'
1093      MSG_ERROR_NOSTOP(message, ierr)
1094    end if
1095 
1096 !  irandom
1097    call chkint_eq(0,0,cond_string,cond_values,ierr,'irandom',dt%irandom,3,(/1,2,3/),iout)
1098 
1099 !  iscf
1100    if (usewvl ==0) then
1101      call chkint_eq(0,0,cond_string,cond_values,ierr,&
1102 &     'iscf',dt%iscf,18,(/-3,-2,-1,1,2,3,4,5,6,7,11,12,13,14,15,16,17,22/),iout)
1103    else
1104 !    If usewvl: wvlbigdft indicates that the BigDFT workflow will be followed
1105      wvlbigdft=(dt%usewvl==1.and.dt%wvl_bigdft_comp==1)
1106      cond_string(1)='wvl_bigdft_comp' ; cond_values(1)=dt%wvl_bigdft_comp
1107      if(wvlbigdft) then
1108        call chkint_eq(1,1,cond_string,cond_values,ierr,&
1109 &       'iscf',dt%iscf,15,(/0,1,2,3,4,5,6,7,11,12,13,14,15,16,17/),iout)
1110      else
1111        call chkint_eq(1,1,cond_string,cond_values,ierr,&
1112 &       'iscf',dt%iscf,18,(/-3,-2,-1,1,2,3,4,5,6,7,11,12,13,14,15,16,17,22/),iout)
1113      end if
1114 !    If wvl+metal, iscf cannot be 0
1115      if (dt%occopt>2) then
1116        cond_string(1)='occopt' ; cond_values(1)=dt%occopt
1117        call chkint_eq(1,1,cond_string,cond_values,ierr,&
1118 &       'iscf',dt%iscf,18,(/-3,-2,-1,1,2,3,4,5,6,7,11,12,13,14,15,16,17,22/),iout)
1119      end if
1120    end if
1121 !  If ionmov==4, iscf must be 2, 12, 5 or 6.
1122    if(dt%ionmov==4)then
1123      cond_string(1)='ionmov' ; cond_values(1)=4
1124      call chkint_eq(1,1,cond_string,cond_values,ierr,'iscf',dt%iscf,4,(/2,12,5,6/),iout)
1125    end if
1126 !  If PAW, iscf cannot be -1, 11
1127    if (usepaw==1 .and. usewvl==0) then
1128      cond_string(1)='PAW' ; cond_values(1)=1
1129      call chkint_eq(1,1,cond_string,cond_values,ierr,'iscf',dt%iscf,11,(/-3,-2,2,3,4,7,12,13,14,17,22/),iout)
1130    end if
1131 !  Mixing on density is only allowed for GS calculations or for drivers where it is not used.
1132    if(optdriver /= RUNL_GSTATE .and. all(optdriver/=[RUNL_SCREENING,RUNL_SIGMA,RUNL_BSE,RUNL_EPH,&
1133 &     RUNL_WFK,RUNL_NONLINEAR])) then
1134      cond_string(1)='optdriver' ; cond_values(1)=optdriver
1135      call chkint_le(1,1,cond_string,cond_values,ierr,'iscf',dt%iscf,9,iout)
1136    end if
1137 !  When pawoptmix=1 and nspden=4, iscf must be >=10
1138    if(dt%pawoptmix/=0.and.nspden==4)then
1139      cond_string(1)='nspden'    ; cond_values(1)=nspden
1140      cond_string(2)='pawoptmix' ; cond_values(2)=dt%pawoptmix
1141      call chkint_ge(2,2,cond_string,cond_values,ierr,'iscf',dt%iscf,10,iout)
1142    end if
1143 
1144 !  When usepawu=4, iscf must be <=9 (the reason needs to be studied)
1145    if (dt%usepawu==4) then
1146      cond_string(1)='usepawu' ; cond_values(1)=4
1147      call chkint_le(1,1,cond_string,cond_values,ierr,'iscf',dt%iscf,9,iout)
1148    end if
1149 
1150 !  istatimg
1151    call chkint_eq(0,0,cond_string,cond_values,ierr,'istatimg',dt%istatimg,2,(/0,1/),iout)
1152    if (dt%string_algo==2) then
1153      cond_string(1)='string_algo' ; cond_values(1)=dt%string_algo
1154      call chkint_eq(1,1,cond_string,cond_values,ierr,'istatimg',dt%istatimg,1,(/1/),iout)
1155    end if
1156 
1157 !  istwfk
1158    if(dt%usefock==1 .and. dt%optdriver/=RUNL_SIGMA .and. mod(dt%wfoptalg,10)/=5 .and. maxval( abs(dt%istwfk(1:nkpt)-1) ) >0)then
1159      write(message,'(3a)' )&
1160 &     'When usefock==1, unless sigma calculation, all the components of istwfk must be 1.',ch10,&
1161 &     'Action: set istwfk to 1 for all k-points'
1162      MSG_ERROR_NOSTOP(message,ierr)
1163    end if
1164 
1165    if(dt%usewvl==1 .and. maxval( abs(dt%istwfk(1:nkpt)-1) ) >0)then
1166      write(message,'(3a)' )&
1167 &     'When usewvl==1, all the components of istwfk must be 1.',ch10,&
1168 &     'Action: set istwfk to 1 for all k-points'
1169      MSG_ERROR_NOSTOP(message,ierr)
1170    end if
1171 
1172    if(response==1 .and. maxval( abs(dt%istwfk(1:nkpt)-1) ) >0)then
1173 !    Force istwfk to be 1 for RF calculations
1174 !    Other choices cannot be realized yet, because of the ddk perturbation.
1175      write(message,'(5a)' )&
1176 &     'When response==1, all the components of istwfk must be 1.',ch10,&
1177 &     'Not yet programmed for time-reversal symmetry.',ch10,&
1178 &     'Action: set istwfk to 1 for all k-points'
1179      MSG_ERROR_NOSTOP(message,ierr)
1180    end if
1181    if(dt%nbandkss/=0 .and. dt%kssform/=3 .and. maxval( abs(dt%istwfk(1:nkpt)-1) ) >0)then
1182      write(message,'(5a)' )&
1183 &     'When nbandkss/=0 and kssform/=3 all the components of istwfk must be 1.',ch10,&
1184 &     'Not yet programmed for time-reversal symmetry.',ch10,&
1185 &     'Action: set istwfk to 1 for all k-points'
1186      MSG_ERROR_NOSTOP(message,ierr)
1187    end if
1188    if(dt%berryopt/=0 .and. maxval(dt%istwfk(:))/=1)then
1189      write(message,'(5a)' )&
1190 &     'When berryopt/=0, all the components of istwfk must be 1.',ch10,&
1191 &     'Not yet programmed for time-reversal symmetry.',ch10,&
1192 &     'Action: set istwfk to 1 for all k-points'
1193      MSG_ERROR_NOSTOP(message,ierr)
1194    end if
1195    if (dt%optdriver==RUNL_GSTATE) then
1196      if ((dt%wfoptalg==4.or.dt%wfoptalg==14.or.dt%wfoptalg==114).and.maxval(dt%istwfk(:)-2)>0) then
1197        write(message, '(a,a,a,a,a)' )&
1198 &       'Only the gamma point can use time-reversal and wfoptalg=4 or 14',ch10,&
1199 &       'Action: put istwfk to 1 or remove k points with half integer coordinates ',ch10,&
1200 &       'Also contact ABINIT group to say that you need that option.'
1201        MSG_ERROR_NOSTOP(message,ierr)
1202      end if
1203 !     if ((dt%wfoptalg==4.or.dt%wfoptalg==14).and.any(dt%istwfk(:)==2) .and.dt%paral_kgb==1.and.fftalg/=401.and.fftalg/=312) then
1204 !       write(message, '(a,i3,a,a,a)' )&
1205 !&       ' For istwfk=2, the value fftalg= ',fftalg, &
1206 !&       ' is not allowed in case of wfoptalg=4 or 14 !', ch10,&
1207 !&       ' Change if to fftalg=401.'
1208 !       MSG_ERROR_NOSTOP(message,ierr)
1209 !     end if
1210    end if
1211 
1212 !  ixc
1213    call chkint(0,0,cond_string,cond_values,ierr,&
1214 &   'ixc',dt%ixc,33,(/0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,20,21,22,23,24,26,27,31,32,33,34,40,41,42,50/),-1,0,iout) ! One of the values, or negative
1215    if(dt%iscf==-1)then
1216      cond_string(1)='iscf' ; cond_values(1)=-1
1217 !    Make sure that ixc is 1, 7, 8, 20, 21 or 22 or negative
1218      call chkint(1,1,cond_string,cond_values,ierr,'ixc',dt%ixc,6,(/1,7,8,20,21,22/),-1,0,iout)
1219    end if
1220    if(response==1)then
1221      cond_string(1)='response' ; cond_values(1)=1
1222 !    Make sure that ixc is between 0 and 9, or 11, 12, 14, 15, 23 or 24 or negative
1223      call chkint(1,1,cond_string,cond_values,ierr,&
1224 &     'ixc',dt%ixc,16,(/0,1,2,3,4,5,6,7,8,9,11,12,14,15,23,24/),-1,0,iout)
1225    end if
1226    if(nspden/=1)then
1227      cond_string(1)='nspden' ; cond_values(1)=nspden
1228 !    Make sure that ixc is 0, 1 , the gga, or Fermi-Amaldi, or negative
1229      call chkint(1,1,cond_string,cond_values,ierr,&
1230 &     'ixc',dt%ixc,24,(/0,1,7,8,9,11,12,13,14,15,16,17,20,23,24,26,27,31,32,33,34,40,41,42/),-1,0,iout)
1231    end if
1232    if(dt%usepaw>0.and.dt%ixc<0) then
1233      if (libxc_functionals_is_hybrid()) then
1234        message='Meta-GGA functionals are not compatible with PAW!'
1235        MSG_ERROR_NOSTOP(message,ierr)
1236      end if
1237    end if
1238    if (dt%usepaw>0.and.(dt%ixc==-427.or.dt%ixc==-428)) then
1239      message='Range-separated Hybrid Functionals have not been extensively tested in PAW!!!'
1240      MSG_WARNING(message)
1241    end if
1242    allow=(dt%ixc > 0).and.(dt%ixc /= 3).and.(dt%ixc /= 7).and.(dt%ixc /= 8)
1243    if(.not.allow)then
1244      allow=(dt%ixc < 0).and.(libxc_functionals_is_hybrid().or.libxc_functionals_ismgga())
1245    end if
1246    if(allow)then
1247      cond_string(1)='ixc' ; cond_values(1)=dt%ixc
1248      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_NONLINEAR/),iout)
1249    end if
1250 
1251 !  ixcpositron
1252    call chkint_eq(0,0,cond_string,cond_values,ierr,'ixcpositron',dt%ixcpositron,8,(/0,-1,1,11,2,3,31,4/),iout)
1253 
1254 !  ixcrot
1255    call chkint_eq(0,0,cond_string,cond_values,ierr,'ixcrot',dt%ixcrot,3,(/1,2,3/),iout)
1256 
1257 !  tim1rev
1258    call chkint_eq(0,0,cond_string,cond_values,ierr,'tim1rev',dt%tim1rev,2,(/0,1/),iout)
1259 
1260 !  kptnrm and kpt
1261 !  Coordinates components must be between -1 and 1.
1262    if(dt%kptnrm<1.0-1.0d-10)then
1263      write(message, '(a,es22.14,a,a,a)' )&
1264 &     'The input variable kptnrm is',dt%kptnrm,' while it must be >=1.0_dp.',ch10,&
1265 &     'Action: change the input variable kptnrm.'
1266      MSG_ERROR_NOSTOP(message,ierr)
1267    end if
1268    do ikpt=1,nkpt
1269      do mu=1,3
1270        if ( abs(dt%kpt(mu,ikpt))> dt%kptnrm*1.0000001_dp ) then
1271          write(message, '(a,i5,a,a,a,a,3es22.14,a,a,a,a)' )&
1272 &         'For k point number',ikpt,'  the reduced coordinates',ch10,&
1273 &         'generated by the input variables kpt and kptnrm are',ch10,&
1274 &         dt%kpt(1,ikpt)/dt%kptnrm,dt%kpt(2,ikpt)/dt%kptnrm,dt%kpt(3,ikpt)/dt%kptnrm,ch10,&
1275 &         'while they must be between -1.0_dp and 1.0_dp (included).',ch10,&
1276 &         'Action: check kpt and kptnrm in the input file.'
1277          MSG_ERROR_NOSTOP(message,ierr)
1278        end if
1279      end do
1280    end do
1281 
1282 !  jellslab
1283    call chkint_eq(0,0,cond_string,cond_values,ierr,'jellslab',dt%jellslab,2,(/0,1/),iout)
1284 
1285    if (dt%jellslab==1) then
1286      if(dt%nimage>1)then
1287        cond_string(1)='nimage' ; cond_values(1)=dt%nimage
1288        call chkint_eq(1,1,cond_string,cond_values,ierr,'jellslab',dt%jellslab,1,(/0/),iout)
1289      end if
1290 !    slabwsrad must be positive
1291      cond_string(1)='jellslab' ; cond_values(1)=dt%jellslab
1292      call chkdpr(1,0,cond_string,cond_values,ierr,'slabwsrad',dt%slabwsrad,1,zero,iout)
1293 !    slabzbeg must be positive
1294      call chkdpr(1,0,cond_string,cond_values,ierr,'slabzbeg',dt%slabzbeg,1,zero,iout)
1295 !    slabzend must be bigger than slabzbeg
1296      call chkdpr(1,0,cond_string,cond_values,ierr,'slabzend',dt%slabzend,1,dt%slabzbeg,iout)
1297 !    rprimd(3,3) must be bigger than slabzend
1298      call chkdpr(1,0,cond_string,cond_values,ierr,'rprimd33',rprimd(3,3),1,dt%slabzend,iout)
1299 !    Third real space primitive translation has to be orthogonal to the other ones,
1300 !    actually, for convenience it is useful that rprimd is something like:
1301 !    a  b  0
1302 !    c  d  0
1303 !    0  0  e
1304      if(abs(rprimd(1,3))+abs(rprimd(2,3))+abs(rprimd(3,1))+abs(rprimd(3,2))>tol12) then
1305        write(message,'(a,a,a)')&
1306 &       'Third real space vector is not orthogonal to the other ones,',ch10,&
1307 &       'this is needed to use jellium'
1308        MSG_ERROR_NOSTOP(message, ierr)
1309      end if
1310 
1311 !    Atoms have to be placed in the vacuum space
1312      do iatom=1,natom
1313        zatom=(dt%xred_orig(3,iatom,intimage)-anint(dt%xred_orig(3,iatom,intimage)-half+tol6))*rprimd(3,3)
1314        if(abs(zatom-dt%slabzbeg)<tol8 .or. abs(zatom-dt%slabzend)<tol8) then
1315          if(dt%znucl(dt%typat(iatom))>tol6) then
1316            write(message,'(a,i0,a)')'atom number=',iatom,' lies precisely on the jellium edge !'
1317            MSG_WARNING(message)
1318          end if
1319          cycle
1320        end if
1321        if(zatom>dt%slabzbeg .and. zatom<dt%slabzend) then
1322          write(message,'(a,i0,a)')' atom number=',iatom,' is inside the jellium slab.'
1323          MSG_ERROR_NOSTOP(message, ierr)
1324        end if
1325      end do
1326    end if
1327 
1328 !  kssform
1329    call chkint_eq(0,0,cond_string,cond_values,ierr,'kssform',dt%kssform,3,(/0,1,3/),iout)
1330 
1331    if (dt%kssform/=0 .and. dt%nbandkss/=0) then ! Check for outkss limitations.
1332      call wrtout(std_out," Checking if input is consistent with KSS generation",'COLL')
1333      call chkint_eq(0,0,cond_string,cond_values,ierr,'paral_kgb',dt%paral_kgb,1,(/0/),iout)
1334      call chkint_eq(0,0,cond_string,cond_values,ierr,'iomode',dt%iomode,2,(/IO_MODE_FORTRAN,IO_MODE_ETSF/),iout)
1335    end if
1336 
1337 !  localrdwf
1338    call chkint_eq(0,0,cond_string,cond_values,ierr,'localrdwf',dt%localrdwf,2,(/0,1/),iout)
1339    if(dt%mkmem==0)then
1340      cond_string(1)='mkmem' ; cond_values(1)=dt%mkmem
1341      call chkint_eq(1,1,cond_string,cond_values,ierr,'localrdwf',dt%localrdwf,1,(/1/),iout)
1342    end if
1343    if(dt%mkqmem==0)then
1344      cond_string(1)='mkqmem' ; cond_values(1)=dt%mkqmem
1345      call chkint_eq(1,1,cond_string,cond_values,ierr,'localrdwf',dt%localrdwf,1,(/1/),iout)
1346    end if
1347    if(dt%mk1mem==0)then
1348      cond_string(1)='mk1mem' ; cond_values(1)=dt%mk1mem
1349      call chkint_eq(1,1,cond_string,cond_values,ierr,'localrdwf',dt%localrdwf,1,(/1/),iout)
1350    end if
1351    if(dt%iomode==IO_MODE_MPI)then
1352      cond_string(1)='iomode' ; cond_values(1)=dt%iomode
1353      call chkint_eq(1,1,cond_string,cond_values,ierr,'localrdwf',dt%localrdwf,1,(/1/),iout)
1354    end if
1355 
1356 
1357 !  LOTF
1358 #if defined HAVE_LOTF
1359    if (dt%ionmov==23) then
1360      write(message, '(a,a)' ) ch10,&
1361 &     '=== LOTF METHOD ================================================================'
1362      call wrtout(ab_out,message,'COLL')
1363      cond_string(1)='ionmov' ; cond_values(1)=23
1364      call chkint_eq(0,1,cond_string,cond_values,ierr,'lotf_classic',dt%lotf_classic,1,(/5/),iout)
1365      cond_string(1)='ionmov' ; cond_values(1)=23
1366      call chkint_ge(0,1,cond_string,cond_values,ierr,'lotf_nitex',dt%lotf_nitex,1,iout)
1367      cond_string(1)='ionmov' ; cond_values(1)=23
1368      call chkint_ge(0,1,cond_string,cond_values,ierr,'lotf_nneigx',dt%lotf_nneigx,2,iout)
1369      cond_string(1)='ionmov' ; cond_values(1)=23
1370      call chkint_eq(0,1,cond_string,cond_values,ierr,'lotf_version',dt%lotf_version,1,(/2/),iout)
1371    end if
1372 #endif
1373 
1374 !  magconon
1375    call chkint_eq(0,0,cond_string,cond_values,ierr,'magconon',dt%magconon,3,(/0,1,2/),iout)
1376 !!  impose nspden 4 for the moment and spinors
1377 !   if (dt%magconon == 1) then
1378 !     if (dt%nspinor /= 2 .or. dt%nspden /= 4) then
1379 !       write (message, '(4a)') &
1380 !&       ' magnetization direction constraint is only compatible with non-collinear calculations', ch10,&
1381 !&       ' Action: set nspinor 2 and nspden 4 in the input file.'
1382 !       MSG_ERROR_NOSTOP(message,ierr)
1383 !     end if
1384 !   end if
1385 
1386 !  macro_uj
1387    if(dt%macro_uj/=0) then
1388      if (dt%ionmov/=0) then
1389        write(message, '(3a,i2,2a,i2,3a)' )&
1390 &       'Determination of U can not be combined with ionic movements.',ch10,&
1391 &       'Here  ionmov= ',dt%ionmov,ch10,&
1392 &       'and macro_uj=',dt%macro_uj,'.',ch10,&
1393 &       'Action: change ionmov in input file.'
1394        MSG_ERROR_NOSTOP(message,ierr)
1395      else if (dt%nstep<3) then
1396        write(message, '(3a,i1,2a,i2,3a)' )&
1397 &       'Determination of U needs at least 3 scf steps:',ch10,&
1398 &       ' nstep = ',dt%nstep,ch10,&
1399 &       ' and macro_uj=',dt%macro_uj,'.',ch10,&
1400 &       'Action: increase nstep in input file.'
1401        MSG_ERROR_NOSTOP(message,ierr)
1402      end if
1403    end if
1404 
1405 !  mep_solver
1406    call chkint_eq(0,0,cond_string,cond_values,ierr,'mep_solver',dt%mep_solver,5,(/0,1,2,3,4/),iout)
1407 !  String method
1408    if(dt%imgmov==2) then
1409      cond_string(1)='imgmov'      ; cond_values(1)=dt%imgmov
1410      if(dt%string_algo==0)then
1411        cond_string(2)='string_algo' ; cond_values(2)=dt%string_algo
1412        call chkint_eq(1,1,cond_string,cond_values,ierr,'mep_solver',dt%mep_solver,1,(/0/),iout)
1413      end if
1414      if(dt%string_algo==1.or.dt%string_algo==2)then
1415        cond_string(2)='string_algo' ; cond_values(2)=dt%string_algo
1416        call chkint_eq(1,1,cond_string,cond_values,ierr,'mep_solver',dt%mep_solver,2,(/0,4/),iout)
1417      end if
1418    end if
1419 !  NEB
1420    if(dt%imgmov==5)then
1421      cond_string(1)='imgmov' ; cond_values(1)=dt%imgmov
1422      call chkint_eq(1,1,cond_string,cond_values,ierr,'mep_solver',dt%mep_solver,4,(/0,1,2,3/),iout)
1423    end if
1424 
1425 !  mffmem
1426    call chkint_eq(0,0,cond_string,cond_values,ierr,'mffmem',dt%mffmem,2,(/0,1/),iout)
1427 
1428 !  mixalch_orig
1429 !  For each type of atom, the sum of the psp components must be one.
1430    do iimage=1,dt%nimage
1431      if(dt%ntypalch>0)then
1432        do itypat=1,dt%ntypalch
1433          sumalch=sum(dt%mixalch_orig(:,itypat,iimage))
1434          if(abs(sumalch-one)>tol10)then
1435            if(dt%npspalch<=6)then
1436              write(message, '(2a,6es12.4)' )ch10,' chkinp : mixalch(:,itypat,iimage)=',dt%mixalch_orig(:,itypat,iimage)
1437            end if
1438            call wrtout(iout,message,'COLL')
1439            call wrtout(std_out,  message,'COLL')
1440            write(message, '(a,i4,2a,i4,2a,f8.2,4a)' )&
1441 &           'For the alchemical atom number',itypat,ch10,&
1442 &           'image number',iimage,ch10,&
1443 &           'the sum of the pseudopotential coefficients is',sumalch,ch10,&
1444 &           'while it should be one.',ch10,&
1445 &           'Action: check the content of the input variable mixalch.'
1446            MSG_ERROR_NOSTOP(message,ierr)
1447          end if
1448        end do
1449      end if
1450    end do
1451 
1452 !  mixesimgf
1453 !  The sum of the mixing image factors must be one
1454    if(dt%imgmov==6)then
1455      summix=sum(dt%mixesimgf(1:dt%nimage))
1456      if(abs(summix-one)>tol10)then
1457        write(message, '(2a,20es12.4)' )ch10,' chkinp : mixesimgf(1:dt%nimage)=',dt%mixesimgf(1:dt%nimage)
1458        call wrtout(iout,message,'COLL')
1459        call wrtout(std_out,  message,'COLL')
1460        write(message, '(a,es12.4,4a)' )&
1461 &        'The sum of the mixing image factors is',summix,ch10,&
1462 &        'while it should be one.',ch10,&
1463 &        'Action: check the content of the input variable mixesimgf.'
1464        MSG_ERROR_NOSTOP(message,ierr)
1465      end if
1466    end if
1467 
1468 !  natom
1469    if(dt%prtgeo>0)then
1470      cond_string(1)='prtgeo' ; cond_values(1)=dt%prtgeo
1471      call chkint_le(1,1,cond_string,cond_values,ierr,'natom',natom,9999,iout)
1472    end if
1473 
1474 !  nband
1475 !  Make sure all nband(nkpt) are > 0
1476    do isppol=1,nsppol
1477      do ikpt=1,nkpt
1478        if (dt%nband(ikpt+(isppol-1)*nkpt)<=0) then
1479          cond_string(1)='ikpt' ; cond_values(1)=ikpt
1480          cond_string(2)='isppol' ; cond_values(2)=isppol
1481          call chkint_ge(0,2,cond_string,cond_values,ierr,'nband',dt%nband(ikpt+(isppol-1)*nkpt),1,iout)
1482        end if
1483      end do
1484    end do
1485    if(nproc/=1.and.nsppol==2.and.usewvl==0)then
1486      do ikpt=1,nkpt
1487        if (dt%nband(ikpt)/=dt%nband(ikpt+nkpt)) then
1488          write(message, '(5a,i4,a,2i5,a)' )&
1489 &         'the number of bands in the spin up case must be equal to',ch10,&
1490 &         'the number of bands in the spin down case.',ch10,&
1491 &         'This is not the case for the k point number :',ikpt,&
1492 &         'The number of bands spin up and down are :',dt%nband(ikpt),dt%nband(ikpt+nkpt),&
1493 &         'Action: change nband, or use the sequential version of ABINIT.'
1494          MSG_ERROR_NOSTOP(message,ierr)
1495        end if
1496      end do
1497    end if
1498 
1499 !  nbandkss
1500 !  Must be greater or equal to -1
1501    call chkint_ge(0,0,cond_string,cond_values,ierr,'nbandkss',dt%nbandkss,-1,iout)
1502 !  When ionmov/=0
1503    if(dt%ionmov/=0 .and. dt%nbandkss/=0)then
1504      write(message,'(11a)')&
1505 &     'Ions (or cell) are allowed to move (ionmov/=0),',ch10,&
1506 &     'and a _KSS file is requested (nbandkss/=0).',ch10,&
1507 &     'A _KSS file will be created at each geometry-optimisation step.',ch10,&
1508 &     'Note that this is time consuming !',ch10,&
1509 &     'Action: use datasets (one for geometry optimisation,',ch10,&
1510 &     '        one for states output).'
1511      MSG_WARNING(message)
1512    end if
1513 
1514 !  nbdblock
1515 !  Must be greater or equal to 1
1516    call chkint_ge(0,0,cond_string,cond_values,ierr,'nbdblock',dt%nbdblock,1,iout)
1517 !  When wfoptalg==0, nbdblock must be 1
1518    if(mod(dt%wfoptalg,10)==0)then
1519      cond_string(1)='wfoptalg' ; cond_values(1)=0
1520      call chkint_eq(1,1,cond_string,cond_values,ierr,'nbdblock',dt%nbdblock,1,(/1/),iout)
1521    end if
1522 !  When wfoptalg==2, nbdblock must be 1
1523    if(dt%wfoptalg==2)then
1524      cond_string(1)='wfoptalg' ; cond_values(1)=2
1525      call chkint_eq(1,1,cond_string,cond_values,ierr,'nbdblock',dt%nbdblock,1,(/1/),iout)
1526    end if
1527 !  When wfoptalg==3, nbdblock must be 1, and iscf must be -2
1528    if(dt%wfoptalg==3)then
1529      cond_string(1)='wfoptalg' ; cond_values(1)=3
1530      call chkint_eq(1,1,cond_string,cond_values,ierr,'nbdblock',dt%nbdblock,1,(/1/),iout)
1531      call chkint_eq(1,1,cond_string,cond_values,ierr,'iscf',dt%iscf,1,(/-2/),iout)
1532    end if
1533 !  When wfoptalg==4, nbdblock must be a divisor of nband
1534    if(mod(dt%wfoptalg,10)==4.and.dt%optdriver==RUNL_GSTATE)then
1535      do isppol=1,nsppol
1536        do ikpt=1,nkpt
1537          if(mod(dt%nband(ikpt+(isppol-1)*nkpt),dt%nbdblock)/=0) then
1538            write(message, '(5a)' )&
1539 &           'For the moment, when wfoptalg=4,',ch10,&
1540 &           'nband must be a multiple of nbdblock.',ch10,&
1541 &           'Action: check the value of the input variable nbdblock.'
1542            MSG_ERROR_NOSTOP(message,ierr)
1543          end if
1544        end do
1545      end do
1546    end if
1547 
1548 !  nberry
1549 !  must be between 0 and 20
1550    if(dt%berryopt/=0)then
1551      call chkint_ge(0,0,cond_string,cond_values,ierr,'nberry',dt%nberry,0,iout)
1552      call chkint_le(0,0,cond_string,cond_values,ierr,'nberry',dt%nberry,20,iout)
1553      if(xmpi_paral==1)then
1554 !      MPI Parallel case
1555        if (dt%nberry/=0.and.dt%berryopt>0.and.&
1556 &       dt%berryopt/= 4.and.dt%berryopt/= 5.and.dt%berryopt/= 6.and.dt%berryopt/= 7.and.&
1557 &       dt%berryopt/=14.and.dt%berryopt/=15.and.dt%berryopt/=16.and.dt%berryopt/=17) then
1558          write(message,'(a,a,a,a,a,i4,a,a,a)')&
1559 &         'Berry phase calculation of polarisation with positive berryopt is not',ch10,&
1560 &         'allowed in the parallel version of ABINIT.',ch10,&
1561 &         'So, the value of nberry=',dt%nberry,' is not allowed,',ch10,&
1562 &         'Action: change berryopt to negative values or change nberry, or use the sequential version.'
1563          MSG_ERROR_NOSTOP(message,ierr)
1564        end if
1565      end if
1566    end if
1567 
1568    if (dt%optcell /=0 .and. dt%berryopt == 4)  then
1569      write(message,'(a,a,a,a,a,a,a,a,a,a,a,a,a)') ch10,&
1570 &     ' chkinp : WARNING -',ch10,&
1571 &     '  Constant unreduced E calculation with relaxation of cell parameters is allowed.',ch10,&
1572 &     '  But we strongly recommend users to use reduced ebar calculation (berryopt=14)',ch10,&
1573 &     '  with the relaxation of cell parameters, for internal consistency purpose.',ch10, &
1574 &     '  For more information, please refer to "M. Stengel, N.A. Spaldin and D.Vanderbilt,', ch10, &
1575 &     '  Nat. Phys., 5, 304,(2009)" and its supplementary notes.', ch10 ! [[cite:Stengel2009]]
1576      call wrtout(ab_out,message,'COLL')
1577      call wrtout(std_out,message,'COLL')
1578    end if
1579 
1580    if (dt%optcell /=0 .and. (dt%berryopt == 6 ))  then
1581      write(message,'(12a)') ch10,&
1582 &     ' chkinp : WARNING -',ch10,&
1583 &     '  Constant unreduced D calculation with relaxation of cell parameters is allowed.',ch10,&
1584 &     '  But we strongly recommend users to use reduced d calculation (berryopt=16)',ch10,&
1585 &     '  with the relaxation of cell parameters, for internal consistency purpose.',ch10, &
1586 &     '  For more information, please refer to "M. Stengel, N.A. Spaldin and D.Vanderbilt,', ch10, &
1587 &     '  Nat. Phys., 5, 304,(2009)" and its supplementary notes.' ! [[cite:Stengel2009]]
1588      call wrtout(ab_out,message,'COLL')
1589      call wrtout(std_out,message,'COLL')
1590    end if
1591 
1592 !  ndynimage
1593 !  Must be greater or equal to 1
1594    call chkint_ge(0,0,cond_string,cond_values,ierr,'ndynimage',dt%ndynimage,1,iout)
1595 
1596 !  neb_algo
1597    call chkint_eq(0,0,cond_string,cond_values,ierr,'neb_algo',dt%neb_algo,4,(/0,1,2,3/),iout)
1598 
1599 !  nfft and nfftdg
1600 !  Must have nfft<=nfftdg
1601    if (usepaw==1) then
1602      nfft  =dt%ngfft(1)  *dt%ngfft(2)  *dt%ngfft(3)
1603      nfftdg=dt%ngfftdg(1)*dt%ngfftdg(2)*dt%ngfftdg(3)
1604      cond_string(1)='nfft' ; cond_values(1)=nfft
1605      call chkint(1,1,cond_string,cond_values,ierr,'nfftdg',nfftdg,1,(/0/),1,nfft,iout) ! Must be 0 or nfft
1606    end if
1607 
1608 !  diismemory
1609 !  Must be greater or equal to 1
1610    call chkint_ge(0,0,cond_string,cond_values,ierr,'diismemory',dt%diismemory,1,iout)
1611 
1612 !  nimage
1613 !  Must be greater or equal to 1
1614    call chkint_ge(0,0,cond_string,cond_values,ierr,'nimage',dt%nimage,1,iout)
1615    if (usewvl==1) then
1616      cond_string(1)='usewvl' ; cond_values(1)=usewvl
1617      call chkint_eq(1,1,cond_string,cond_values,ierr,'nimage',dt%nimage,1,(/1/),iout)
1618    end if
1619    if (optdriver/=RUNL_GSTATE) then
1620      cond_string(1)='optdriver' ; cond_values(1)=optdriver
1621      call chkint_eq(1,1,cond_string,cond_values,ierr,'nimage',dt%nimage,1,(/1/),iout)
1622    end if
1623    if (dt%tfkinfunc==2) then
1624      cond_string(1)='tfkinfunc' ; cond_values(1)=dt%tfkinfunc
1625      call chkint_eq(1,1,cond_string,cond_values,ierr,'nimage',dt%nimage,1,(/1/),iout)
1626    end if
1627    if (dt%prtxml==1) then
1628      cond_string(1)='prtxml' ; cond_values(1)=dt%prtxml
1629      call chkint_eq(1,1,cond_string,cond_values,ierr,'nimage',dt%nimage,1,(/1/),iout)
1630    end if
1631    if (dt%imgmov==9.or.dt%imgmov==13) then
1632      if (dt%pitransform==1.and.(mod(dt%nimage,2)/=0)) then
1633        write(message,'(6a)')ch10,&
1634 &       'Path-Integral Molecular Dynamics (imgmov=9,13)',ch10,&
1635 &       'in normal mode tranformation (pitransform=1).',ch10,&
1636 &       'requires nimage to be even!'
1637        MSG_ERROR_NOSTOP(message,ierr)
1638      end if
1639    end if
1640    if (dt%imgmov==10.and.dt%pitransform>0) then
1641      write(message,'(4a)')ch10,&
1642 &     'Path-Integral Molecular Dynamics (imgmov=10) with QTB',ch10,&
1643 &     'requires primitive coordinates (pitransform=0).'
1644      MSG_ERROR_NOSTOP(message,ierr)
1645    end if
1646 
1647 !  nkpt
1648 !  Must be greater or equal to 1
1649    call chkint_ge(0,0,cond_string,cond_values,ierr,'nkpt',nkpt,1,iout)
1650 !  If prtdos>=2, nkpt must be greater or equal to 2
1651    if(dt%prtdos>=2)then
1652      cond_string(1)='prtdos' ; cond_values(1)=dt%prtdos
1653      call chkint_ge(1,1,cond_string,cond_values,ierr,'nkpt',nkpt,2,iout)
1654    end if
1655 !  Must be smaller than 50 if iscf=-2 (band structure)
1656 !  while prteig=0 and prtvol<2, except if kptopt>0
1657    if(dt%iscf==-2 .and. dt%prteig==0 .and. dt%prtvol<2 .and. dt%kptopt<=0)then
1658      cond_string(1)='iscf'   ; cond_values(1)=dt%iscf
1659      cond_string(2)='prteig' ; cond_values(2)=dt%prteig
1660      cond_string(3)='prtvol' ; cond_values(3)=dt%prtvol
1661      call chkint_le(1,3,cond_string,cond_values,ierr,'nkpt',nkpt,50,iout)
1662    end if
1663 
1664 !  nloalg(1)= nloc_alg
1665 !  Must be 2, 3, 4
1666    call chkint_eq(0,0,cond_string,cond_values,ierr,'nloc_alg',dt%nloalg(1),3,(/2,3,4/),iout)
1667 
1668 !  nloc_mem= nloalg(2)*(nloalg(3)+1)
1669 !  nloalg(2) must be -1 or 1 ; nloalg(3) is 0 or 1.
1670    nloc_mem=dt%nloalg(2)*(dt%nloalg(3)+1)
1671    call chkint_eq(0,0,cond_string,cond_values,ierr,'nloc_mem',nloc_mem,4,(/-2,-1,1,2/),iout)
1672 
1673 !  npband
1674 !  Must be greater or equal to 1
1675    call chkint_ge(0,0,cond_string,cond_values,ierr,'npband',dt%npband,1,iout)
1676 
1677 !  npfft
1678 !  Must be greater or equal to 1
1679    call chkint_ge(0,0,cond_string,cond_values,ierr,'npfft',dt%npfft,1,iout)
1680 !  If usepaw==1 and pawmixdg==0, npfft must be equal to 1
1681    if(usepaw==1 .and. dt%pawmixdg==0)then
1682      cond_string(1)='usepaw  ' ; cond_values(1)=usepaw
1683      cond_string(2)='pawmixdg' ; cond_values(2)=dt%pawmixdg
1684      call chkint_eq(1,2,cond_string,cond_values,ierr,'npfft',dt%npfft,1,(/1/),iout)
1685    end if
1686 #ifdef HAVE_OPENMP
1687    if (dt%wfoptalg==114) then
1688      if ( xomp_get_num_threads(.true.) > 1 .and. dt%npfft > 1 ) then
1689        write(message,'(4a,i4,a,i4,a)') "When compilied with OpenMP, the FFT parallelization is not ",&
1690 &       "compatible with multiple threads.",ch10,"Please set npfft to 1 (currently npfft=",&
1691 &       dt%npfft, ") or export OMP_NUM_THREADS=1 (currently ",xomp_get_num_threads(.true.),")"
1692        MSG_ERROR_NOSTOP(message, ierr)
1693      end if
1694    end if
1695 #endif
1696 
1697 !  npimage
1698 !  Must be greater or equal to 1
1699    call chkint_ge(0,0,cond_string,cond_values,ierr,'npimage',dt%npimage,1,iout)
1700 !  At present, parallelism over images is not coded ...
1701 !  call chkint_eq(0,0,cond_string,cond_values,ierr,'npimage',dt%npimage,1,(/1/),iout)
1702 
1703 !  npkpt
1704 !  Must be greater or equal to 1
1705    call chkint_ge(0,0,cond_string,cond_values,ierr,'npkpt',dt%npkpt,1,iout)
1706 
1707 !  nppert
1708    cond_string(1)='paral_rf' ; cond_values(1)=1
1709    call chkint_ge(1,1,cond_string,cond_values,ierr,'nppert',dt%nppert,1,iout)
1710 
1711 !  nproc
1712    if (response==1.and.nsppol==2.and.nproc>1.and.modulo(nproc,2)>0) then
1713      write(message,'(8a)' ) &
1714 &     'For DFPT parallel calculations on spin-polarized systems (nsppol=2),',ch10,&
1715 &     'the number of processors must be even !'
1716      MSG_ERROR_NOSTOP(message,ierr)
1717    end if
1718 
1719 !  nproj
1720 !  If there is more than one projector for some angular momentum
1721 !  channel of some pseudopotential
1722    do ilang=0,3
1723 !    nprojmax(ilang)=maxval(pspheads(1:npsp)%nproj(ilang)) ! Likely problems with HP compiler
1724      nprojmax(ilang)=pspheads(1)%nproj(ilang)
1725      if(npsp>=2)then
1726 
1727        do ii=2,npsp
1728          nprojmax(ilang)=max(pspheads(ii)%nproj(ilang),nprojmax(ilang))
1729        end do
1730      end if
1731    end do
1732 
1733 !  npspinor
1734 !  Must be equal to 1 or 2
1735    call chkint_eq(0,0,cond_string,cond_values,ierr,'npspinor',dt%npspinor,2,(/1,2/),iout)
1736 !  If nspinor==1, npspinor must be equal to 1
1737    if(dt%nspinor==1 )then
1738      cond_string(1)='nspinor' ; cond_values(1)=dt%nspinor
1739      call chkint_eq(0,1,cond_string,cond_values,ierr,'npspinor',dt%npspinor,1,(/1/),iout)
1740    end if
1741 
1742 !  npimage
1743 
1744 !  npvel (must be positive)
1745    call chkint_ge(0,0,cond_string,cond_values,ierr,'npvel',dt%npvel,0,iout)
1746 
1747 !  npwkss
1748 !  Must be greater or equal to -1
1749    call chkint_ge(0,0,cond_string,cond_values,ierr,'npwkss',dt%npwkss,-1,iout)
1750 
1751 !  nqpt
1752    call chkint_eq(0,0,cond_string,cond_values,ierr,'nqpt',dt%nqpt,2,(/0,1/),iout)
1753 
1754 !  nscforder
1755    call chkint_eq(0,0,cond_string,cond_values,ierr,'nscforder',dt%nscforder,10,(/8,14,16,20,24,30,40,50,60,100/),iout)
1756 
1757 !  nspden
1758    call chkint_eq(0,0,cond_string,cond_values,ierr,'nspden',nspden,3,(/1,2,4/),iout)
1759 
1760    if(nsppol==2)then  !  When nsppol=2, nspden must be 2
1761      cond_string(1)='nsppol' ; cond_values(1)=2
1762      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspden',nspden,1,(/2/),iout)
1763    end if
1764    if(nspden==2 .and. nsppol==1 .and. response==1)then
1765      write(message,'(13a)')&
1766 &     'nspden==2 together with nsppol==1 is not allowed',ch10,&
1767 &     'for response function calculations.',ch10,&
1768 &     'For antiferromagnetic materials, use nspden==2 and nsppol=2.',ch10,&
1769 &     'In this case, Shubnikov symmetries will be used to decrease',ch10,&
1770 &     'the number of perturbations. In a future version, it will also be',ch10,&
1771 &     'used to decrease the number of spin components (to be coded).',ch10,&
1772 &     'Action: change nsppol to 1, or check nspden.'
1773      MSG_ERROR_NOSTOP(message,ierr)
1774    end if
1775    if(nspden==4.and.response==1)then
1776      write(message,'(3a)')&
1777 &     'nspden==4 allowed in response formalism.',ch10,&
1778 &     'BUT Non collinear magnetism under development in perturbative treatment.'
1779      MSG_WARNING(message)
1780    end if
1781 !  TR symmetry not allowed for NC magnetism, in the present version
1782 !  (to be investigated further)
1783    if (nspden==4.and.(dt%kptopt==1.or.dt%kptopt==2)) then
1784      write(message, '(8a)' ) ch10,&
1785 &     'When non-collinear magnetism is activated (nspden=4),',ch10,&
1786 &     'time-reversal symmetry cannot be used in the present',ch10,&
1787 &     'state of the code (to be checked and validated).',ch10,&
1788 &     'Action: choose kptopt different from 1 or 2.'
1789      MSG_ERROR_NOSTOP(message, ierr)
1790    end if
1791 !  When densfor_pred<0 or 3, nspden must be 1 or 2
1792    if(dt%densfor_pred<0.or.dt%densfor_pred==3)then
1793      cond_string(1)='densfor_pred' ; cond_values(1)=dt%densfor_pred
1794      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspden',nspden,2,(/1,2/),iout)
1795    end if
1796 !  When ionmov=4 and iscf>10, nspden must be 1 or 2
1797    if(dt%ionmov==4.and.dt%iscf>10)then
1798      cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
1799      cond_string(1)='iscf' ; cond_values(1)=dt%iscf
1800      call chkint_eq(1,2,cond_string,cond_values,ierr,'nspden',nspden,2,(/1,2/),iout)
1801    end if
1802 !  When iprcel>49, nspden must be 1 or 2
1803    if(mod(dt%iprcel,100)>49)then
1804      cond_string(1)='iprcel' ; cond_values(1)=dt%iprcel
1805      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspden',nspden,2,(/1,2/),iout)
1806    end if
1807    if(mgga==1.and.nspden==4)then
1808      write(message, '(3a)' )&
1809 &     'The meta-GGA XC kernel is not yet implemented for non-colinear magnetism case',ch10, &
1810 &     'Please use "nspden=1 or 2".'
1811      MSG_ERROR(message)
1812    end if
1813 
1814 !  nspinor
1815    call chkint_eq(0,0,cond_string,cond_values,ierr,'nspinor',nspinor,2,(/1,2/),iout)
1816    if(nspden==2)then !  When nspden=2, nspinor must be 1
1817      cond_string(1)='nspden' ; cond_values(1)=2
1818      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspinor',nspinor,1,(/1/),iout)
1819    end if
1820 
1821    if(nspden==4)then  !  When nspden=4, nspinor must be 2
1822      cond_string(1)='nspden' ; cond_values(1)=4
1823      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspinor',nspinor,1,(/2/),iout)
1824    end if
1825 !  When iscf=-1, nspinor must be 1
1826    if(dt%iscf==-1)then
1827      cond_string(1)='iscf' ; cond_values(1)=-1
1828 !    Make sure that nsppol is 1
1829      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspinor',nspinor,1,(/1/),iout)
1830    end if
1831 !  spin-orbit is not implemented for the strain perturbation
1832    if(dt%rfstrs/=0)then
1833      cond_string(1)='rfstrs' ; cond_values(1)=dt%rfstrs
1834      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspinor',nspinor,1,(/1/),iout)
1835    end if
1836 !  When usepawu=2, nspinor must be 1
1837    if(dt%usepawu==2)then
1838      cond_string(1)='usepawu' ; cond_values(1)=2
1839 !    Make sure that nspinor is 1
1840      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspinor',nspinor,1,(/1/),iout)
1841    end if
1842 
1843 !  nsppol
1844    call chkint_eq(0,0,cond_string,cond_values,ierr,'nsppol',nsppol,2,(/1,2/),iout)
1845 
1846 !  nsym
1847    call chkint_ge(0,0,cond_string,cond_values,ierr,'nsym',dt%nsym,1,iout)
1848 !  check if nsym=1 in phonon calculation in finite electric field
1849    if (response==1.and.&
1850 &   (dt%berryopt== 4.or.dt%berryopt== 6.or.dt%berryopt== 7.or.&
1851 &   dt%berryopt==14.or.dt%berryopt==16.or.dt%berryopt==17)) then
1852      cond_string(1)='response' ; cond_values(1)=1
1853      cond_string(2)='berryopt' ; cond_values(2)=4
1854      call chkint_eq(1,2,cond_string,cond_values,ierr,'nsym',dt%nsym,1,(/1/),iout)
1855    end if
1856 
1857 !  ntime
1858    call chkint_ge(0,0,cond_string,cond_values,ierr,'ntime',dt%ntime,0,iout)
1859 
1860 !  ntimimage
1861    call chkint_ge(0,0,cond_string,cond_values,ierr,'ntimimage',dt%ntimimage,1,iout)
1862 
1863 !  ntypalch
1864    if (usepaw==1) then
1865      cond_string(1)='pspcod' ; cond_values(1)=7;cond_values(2)=17
1866      call chkint_eq(1,2,cond_string,cond_values,ierr,'ntypalch',dt%ntypalch,1,(/0/),iout)
1867    end if
1868 
1869 !  nucdipmom
1870 
1871    if (any(abs(dt%nucdipmom)>0)) then
1872 
1873 !    nucdipmom requires PAW
1874      if(usepaw/=1)then
1875        write(message, '(3a)' )&
1876 &       ' Nuclear dipole moments (variable nucdipmom) input as nonzero but PAW not activated => stop',ch10,&
1877 &       'Action: re-run with PAW '
1878        MSG_ERROR_NOSTOP(message,ierr)
1879      end if
1880 
1881 !    nucdipmom requires complex rhoij
1882      if(dt%pawcpxocc/=2)then
1883        write(message, '(3a)' )&
1884 &       ' Nuclear dipole moments (variable nucdipmom) require complex rhoij => stop',ch10,&
1885 &       'Action: re-run with pawcpxocc = 2 '
1886        MSG_ERROR_NOSTOP(message,ierr)
1887      end if
1888 
1889 !    nucdipmom requires no force or stress calculation
1890      if(dt%optforces/=0 .OR. dt%optstress/=0)then
1891        write(message, '(3a)' )&
1892 &       ' Nuclear dipole moments (variable nucdipmom) cannot be used with force or stress calculations => stop',ch10,&
1893 &       'Action: re-run with optforces = 0 and optstress = 0 '
1894        MSG_ERROR_NOSTOP(message,ierr)
1895      end if
1896 
1897 !    nucdipmom requires kptopt > 2
1898      if(dt%kptopt<=2) then
1899        write(message, '(a,i4,a,a,a)' )&
1900 &       ' Nuclear dipole moments (variable nucdipmom) break time reveral symmetry but kptopt = ',dt%kptopt,&
1901 &       ' => stop ',ch10,&
1902 &       'Action: re-run with kptopt greater than 2 '
1903        MSG_ERROR_NOSTOP(message,ierr)
1904      end if
1905 
1906    end if
1907 
1908 !  nzchempot
1909    call chkint_ge(0,0,cond_string,cond_values,ierr,'nzchempot',dt%nzchempot,0,iout)
1910 !  Cannot be used with response functions at present
1911    if (response==1) then
1912      cond_string(1)='response' ; cond_values(1)=1
1913      call chkint_eq(1,1,cond_string,cond_values,ierr,'nzchempot',dt%nzchempot,1,(/0/),iout)
1914    end if
1915    if(dt%nzchempot>0)then
1916      do itypat=1,dt%ntypat
1917        do iz=2,dt%nzchempot
1918          dz=dt%chempot(1,iz,itypat)-dt%chempot(1,iz-1,itypat)
1919          if(dz<-tol12)then
1920            write(message, '(a,2i6,a,a,d17.10,a,a, a,d17.10,a,a, a,a,a)' )&
1921 &           ' For izchempot,itypat=',iz,itypat,ch10,&
1922 &           ' chempot(1,izchempot-1,itypat) = ',dt%chempot(1,iz-1,itypat),' and', ch10,&
1923 &           ' chempot(1,izchempot  ,itypat) = ',dt%chempot(1,iz  ,itypat),',',ch10,&
1924 &           ' while they should be ordered in increasing values =>stop',ch10,&
1925 &           'Action: correct chempot(1,*,itypat) in input file.'
1926            MSG_ERROR_NOSTOP(message,ierr)
1927          end if
1928        end do
1929        dz=dt%chempot(1,dt%nzchempot,itypat)-dt%chempot(1,1,itypat)
1930        if(dz>one)then
1931          write(message, '(a,2i6,a,a,d17.10,a,a, a,d17.10,a,a, a,a,a)' )&
1932 &         ' For nzchempot,itypat=',dt%nzchempot,itypat,ch10,&
1933 &         ' chempot(1,1,itypat) = ',dt%chempot(1,1,itypat),' and', ch10,&
1934 &         ' chempot(1,nzchempot  ,itypat) = ',dt%chempot(1,dt%nzchempot,itypat),'.',ch10,&
1935 &         ' However, the latter should, at most, be one more than the former =>stop',ch10,&
1936 &         'Action: correct chempot(1,nzchempot,itypat) in input file.'
1937          MSG_ERROR_NOSTOP(message,ierr)
1938        end if
1939      end do
1940    end if
1941 
1942 !  occ
1943 !  Do following tests only for occopt==0 or 2, when occupation numbers are needed
1944    if ((dt%iscf>0.or.dt%iscf==-1.or.dt%iscf==-3) .and. (dt%occopt==0 .or. dt%occopt==2) ) then
1945      do iimage=1,dt%nimage
1946 !      make sure occupation numbers (occ(n)) were defined:
1947        sumocc=zero
1948        bantot=0
1949        do isppol=1,nsppol
1950          do ikpt=1,nkpt
1951            do iband=1,dt%nband(ikpt+(isppol-1)*nkpt)
1952              bantot=bantot+1
1953              sumocc=sumocc+dt%occ_orig(bantot,iimage)
1954              if (dt%occ_orig(bantot,iimage)<-tol8) then
1955                write(message, '(a,3i6,a,e20.10,a,a,a)' )&
1956 &               'iband,ikpt,iimage=',iband,ikpt,iimage,' has negative occ=',dt%occ_orig(bantot,iimage),' =>stop',ch10,&
1957 &               'Action: correct this occupation number in input file.'
1958                MSG_ERROR_NOSTOP(message,ierr)
1959              end if
1960            end do
1961          end do
1962        end do
1963        if (sumocc<=1.0d-8) then
1964          write(message, '(a,1p,e20.10,a,a,a)')&
1965 &         'Sum of occ=',sumocc, ' =>occ not defined => stop',ch10,&
1966 &         'Action: correct the array occ in input file.'
1967          MSG_ERROR_NOSTOP(message, ierr)
1968        end if
1969      enddo
1970    end if
1971 
1972 !  occopt
1973    call chkint_eq(0,0,cond_string,cond_values,ierr,'occopt',dt%occopt,9,(/0,1,2,3,4,5,6,7,8/),iout)
1974 !  When prtdos==1 or 4, occopt must be between 3 and 8
1975    if(dt%prtdos==1.or.dt%prtdos==4)then
1976      write(cond_string(1), "(A)") 'prtdos'
1977      cond_values(1)=dt%prtdos
1978 !    Make sure that occopt is 3,4,5,6,7, or 8
1979      call chkint_eq(1,1,cond_string,cond_values,ierr,'occopt',dt%occopt,6,(/3,4,5,6,7,8/),iout)
1980    end if
1981 !  When nsppol==2 and spinmagntarget is the default value (-99.99d0), occopt cannot be 1.
1982    if(nsppol==2.and.dt%occopt==1.and.abs(dt%spinmagntarget+99.99d0)<tol8)then
1983      if(natom/=1 .or. abs(dt%znucl(dt%typat(1))-one)>tol8)then
1984        write(message,'(a,i3,2a,i3,4a,f7.2,7a)' )&
1985 &       'This is a calculation with spin-up and spin-down wavefunctions,         ... nsppol=',nsppol,ch10,&
1986 &       'in which the occupation numbers are to be determined automatically.     ... occopt=',dt%occopt,ch10,&
1987 &       'However, in this case, the target total spin magnetization',ch10,&
1988 &       'must be specified, while the default value is observed.                 ... spinmagntarget=',dt%spinmagntarget,ch10,&
1989 &       'Action: if you are doing an antiferromagnetic calculation, please use nsppol=1 with nspden=2 ;',ch10,&
1990 &       'on the other hand, if you are doing a ferromagnetic calculation, either specify your own spinmagntarget,',ch10,&
1991 &       'or let the code determine the total spin-polarization, by using a metallic value for occopt (e.g. 7 or 4 ...).'
1992        MSG_ERROR_NOSTOP(message, ierr)
1993      end if
1994    end if
1995 
1996 !  optcell
1997    call chkint_eq(0,0,cond_string,cond_values,ierr,'optcell',dt%optcell,10,(/0,1,2,3,4,5,6,7,8,9/),iout)
1998 !  With dt%berryopt=4, one must have optcell==0
1999 !  if(dt%berryopt==4)then
2000 !  cond_string(1)='berryopt' ; cond_values(1)=dt%berryopt
2001 !  call chkint_eq(1,1,cond_string,cond_values,ierr,'optcell',dt%optcell,1,(/0/),iout)
2002 !  end if
2003 
2004 !  optdriver
2005    call chkint_eq(0,0,cond_string,cond_values,ierr,'optdriver',optdriver,9,&
2006 &   [RUNL_GSTATE,RUNL_RESPFN,RUNL_SCREENING,RUNL_SIGMA,RUNL_NONLINEAR,RUNL_BSE, RUNL_GWLS, RUNL_WFK,RUNL_EPH],iout)
2007    if (response==1.and.all(dt%optdriver/=[RUNL_RESPFN,RUNL_NONLINEAR])) then
2008      write(message,'(a,i3,3a,14(a,i2),4a)' )&
2009 &     'The input variable optdriver=',dt%optdriver,ch10,&
2010 &     'This is in conflict with the values of the other input variables,',ch10,&
2011 &     'rfphon=',dt%rfphon,' rfddk=',dt%rfddk,' rf2_dkdk=',dt%rf2_dkdk,' rf2_dkde=',dt%rf2_dkde,&
2012 &     ' rfelfd=',dt%rfelfd,'  rfmagn=',dt%rfmagn,' rfstrs=',dt%rfstrs,' rfuser=',dt%rfuser,&
2013 &     ' d3e_pert1_elfd=',dt%d3e_pert1_elfd,' d3e_pert2_elfd=',dt%d3e_pert2_elfd,' d3e_pert3_elfd=',dt%d3e_pert3_elfd,&
2014 &     ' d3e_pert1_phon=',dt%d3e_pert1_phon,' d3e_pert2_phon=',dt%d3e_pert2_phon,' d3e_pert3_phon=',dt%d3e_pert3_phon,ch10,&
2015 &     'Action: check the values of optdriver, rfphon, rfddk, rf2dkdk, rf2dkde, rfelfd, rfmagn, rfstrs, rfuser,',ch10,&
2016 &     'd3e_pert1_elfd, d3e_pert2_elfd, d3e_pert3_elfd, d3e_pert1_phon, d3e_pert2_phon, and d3e_pert3_phon in your input file.'
2017      MSG_ERROR_NOSTOP(message, ierr)
2018    end if
2019    if(usepaw==1)then
2020      ! Is optdriver compatible with PAW?
2021      cond_string(1)='usepaw' ; cond_values(1)=usepaw
2022      call chkint_eq(1,1,cond_string,cond_values,ierr,&
2023 &     'optdriver',optdriver,7,[RUNL_GSTATE,RUNL_RESPFN,RUNL_SCREENING,RUNL_SIGMA,RUNL_BSE, RUNL_WFK,RUNL_NONLINEAR],iout)
2024    end if
2025 
2026 !  Linear and Non-linear response calculations
2027    !Non-linear response not compatible with spinors
2028    if(nspinor/=1)then
2029      cond_string(1)='nspinor' ; cond_values(1)=nspinor
2030      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_NONLINEAR/),iout)
2031    end if
2032    !Non-linear response only for insulators
2033    if(dt%occopt/=1 .and. dt%occopt/=2)then
2034      cond_string(1)='occopt' ; cond_values(1)=dt%occopt
2035      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_NONLINEAR/),iout)
2036    end if
2037    !Non-linear response not compatible with mkmem=0
2038    if(dt%mkmem==0)then
2039      cond_string(1)='mkmem' ; cond_values(1)=dt%mkmem
2040      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_NONLINEAR/),iout)
2041    end if
2042    !Response function need all k-points
2043    if(dt%kptopt==1 .or. dt%kptopt==4) then
2044      cond_string(1)='kptopt' ; cond_values(1)=dt%kptopt
2045      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,2,(/RUNL_RESPFN,RUNL_NONLINEAR/),iout)
2046    end if
2047    !dkdk and dkde non-linear response only for occopt=1 (insulators)
2048    if (dt%rf2_dkdk==1) then
2049      cond_string(1)='rf2_dkdk' ; cond_values(1)=dt%rf2_dkdk
2050      call chkint_eq(1,1,cond_string,cond_values,ierr,'occopt',dt%occopt,1,(/1/),iout)
2051    end if
2052    if (dt%rf2_dkde==1) then
2053      cond_string(1)='rf2_dkde' ; cond_values(1)=dt%rf2_dkde
2054      call chkint_eq(1,1,cond_string,cond_values,ierr,'occopt',dt%occopt,1,(/1/),iout)
2055    end if
2056    !PEAD non-linear response only for occopt=1 (insulators)
2057    if(dt%usepead==0.and.dt%optdriver==RUNL_NONLINEAR)then
2058      cond_string(1)='usepead'   ; cond_values(1)=dt%usepead
2059      cond_string(2)='optdriver' ; cond_values(2)=dt%optdriver
2060      call chkint_eq(1,2,cond_string,cond_values,ierr,'occopt',dt%occopt,1,(/1/),iout)
2061    end if
2062    !PAW non-linear response only with DFPT (PEAD not allowed)
2063    if(usepaw==1.and.dt%optdriver==RUNL_NONLINEAR)then
2064      cond_string(1)='usepaw'    ; cond_values(1)=usepaw
2065      cond_string(2)='optdriver' ; cond_values(2)=dt%optdriver
2066      call chkint_eq(1,2,cond_string,cond_values,ierr,'usepead',dt%usepead,1,(/0/),iout)
2067      cond_string(1)='usepaw'    ; cond_values(1)=usepaw
2068      cond_string(2)='optdriver' ; cond_values(2)=dt%optdriver
2069      call chkint_eq(1,2,cond_string,cond_values,ierr,'pawxcdev',dt%pawxcdev,1,(/0/),iout)
2070    end if
2071    !Non-linear response not compatible with autoparal
2072    if(dt%optdriver==RUNL_NONLINEAR)then
2073      cond_string(1)='optdriver' ; cond_values(1)=dt%optdriver
2074      call chkint_eq(1,1,cond_string,cond_values,ierr,'autoparal',dt%autoparal,1,(/0/),iout)
2075    end if
2076    !Linear Response function only for LDA/GGA
2077    allow=(dt%ixc>0).and.((dt%ixc>16.and.dt%ixc<23).or.(dt%ixc>=40))
2078    if(.not.allow) allow=(dt%ixc<0).and.libxc_functionals_ismgga()
2079    if(allow)then
2080      cond_string(1)='ixc' ; cond_values(1)=dt%ixc
2081      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_RESPFN/),iout)
2082    end if
2083    !PAW+Linear Response+GGA function restricted to pawxcdev=0
2084    if (dt%usepaw==1.and.dt%optdriver==RUNL_RESPFN) then
2085      allow=(dt%ixc>0).and.((dt%ixc>=11.and.dt%ixc<=16).or.(dt%ixc>=23.and.dt%ixc<=39))
2086      if(.not.allow) allow=(dt%ixc<0).and.libxc_functionals_isgga()
2087      if(allow) then
2088        if (dt%pawxcdev/=0)then
2089          write(message,'(7a)' )&
2090 &         'You are performing a DFPT+PAW calculation using a GGA XC functional:',ch10,&
2091 &         '  This is restricted to pawxcdev=0!',ch10,&
2092 &         '  Action: change pawxcdev value in your input file!',ch10,&
2093 &         '    and be careful to run the preparatory Ground-State calculations also with pawxcdev=0!'
2094          MSG_ERROR_NOSTOP(message, ierr)
2095        else
2096          write(message,'(5a)' )&
2097 &         'You are performing a DFPT+PAW calculation using a GGA XC functional:',ch10,&
2098 &         '  - This is restricted to pawxcdev=0!',ch10,&
2099 &         '  - Be careful to run the preparatory Ground-State calculations also with pawxcdev=0!'
2100          MSG_WARNING(message)
2101        end if
2102      end if
2103    end if
2104    !Non linear Response function only for LDA (restricted to ixc=3/7/8)
2105    allow=(dt%ixc>0).and.(dt%ixc/=3.and.dt%ixc/=7.and.dt%ixc/=8)
2106    if(.not.allow) allow=(dt%ixc<0).and.(libxc_functionals_isgga().or.libxc_functionals_ismgga())
2107    if(allow)then
2108      cond_string(1)='ixc' ; cond_values(1)=dt%ixc
2109      call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',dt%optdriver,1,(/RUNL_NONLINEAR/),iout)
2110    end if
2111 
2112 !  optforces
2113 !  When ionmov>0, optforces must be >0
2114    if(dt%ionmov>0)then
2115      cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
2116      call chkint_eq(1,1,cond_string,cond_values,ierr,'optforces',dt%optforces,2,(/1,2/),iout)
2117    end if
2118 !  When imgmov>0, optforces must be >0
2119    if(dt%imgmov>0)then
2120      cond_string(1)='imgmov' ; cond_values(1)=dt%imgmov
2121      call chkint_eq(1,1,cond_string,cond_values,ierr,'optforces',dt%optforces,2,(/1,2/),iout)
2122    end if
2123 !  When iscf=22, optforces must be 0 or 2
2124    if(dt%iscf==22)then
2125      cond_string(1)='iscf' ; cond_values(1)=dt%iscf
2126      call chkint_eq(1,1,cond_string,cond_values,ierr,'optforces',dt%optforces,2,(/0,2/),iout)
2127    end if
2128 
2129 !  optstress
2130 !  When optcell>0, optstress must be >0
2131    if(dt%optcell>0)then
2132      cond_string(1)='optcell' ; cond_values(1)=dt%optcell
2133      call chkint_eq(1,1,cond_string,cond_values,ierr,'optstress',dt%optstress,1,(/1/),iout)
2134    end if
2135 
2136   !  orbmag
2137   ! only values of 0 (default) 1, 2, 3 are allowed
2138   call chkint_eq(0,0,cond_string,cond_values,ierr,'orbmag',dt%orbmag,4,(/0,1,2,3/),iout)
2139   ! when orbmag /= 0, symmorphi must be 0 (no tnons)
2140    if(dt%orbmag .NE. 0) then
2141      cond_string(1)='orbmag';cond_values(1)=dt%orbmag
2142      call chkint_eq(1,1,cond_string,cond_values,ierr,'symmorphi',dt%symmorphi,1,(/0/),iout)
2143    end if
2144   ! only kptopt 4 and 3 are allowed
2145    if(dt%orbmag .NE. 0) then
2146      cond_string(1)='orbmag';cond_values(1)=dt%orbmag
2147      call chkint_eq(1,1,cond_string,cond_values,ierr,'kptopt',dt%kptopt,2,(/3,4/),iout)
2148    end if
2149   ! only nproc 1 for now
2150    if(dt%orbmag .NE. 0) then
2151      cond_string(1)='orbmag';cond_values(1)=dt%orbmag
2152      call chkint_eq(1,1,cond_string,cond_values,ierr,'nproc',nproc,1,(/1/),iout)
2153    end if
2154   ! require usexcnhat 0
2155   if(dt%orbmag .NE. 0) then
2156      cond_string(1)='orbmag';cond_values(1)=dt%orbmag
2157      call chkint_eq(1,1,cond_string,cond_values,ierr,'usexcnhat',dt%usexcnhat_orig,1,(/0/),iout)
2158   end if
2159   ! require PAW
2160   if(dt%orbmag .NE. 0) then
2161      cond_string(1)='orbmag';cond_values(1)=dt%orbmag
2162      call chkint_eq(1,1,cond_string,cond_values,ierr,'usepaw',dt%usepaw,1,(/1/),iout)
2163   end if
2164 
2165 !  paral_atom
2166    call chkint_eq(0,0,cond_string,cond_values,ierr,'paral_atom',dt%paral_atom,2,(/0,1/),iout)
2167    if (dt%paral_atom/=0) then
2168      if (dt%optdriver/=RUNL_GSTATE.and.dt%optdriver/=RUNL_RESPFN) then
2169        write(message, '(5a)' )&
2170 &       'Parallelisation over atoms is only compatible with',ch10,&
2171 &       'ground-state or response function calculations !',ch10,&
2172 &       'Action: change paral_atom in input file.'
2173        MSG_ERROR_NOSTOP(message, ierr)
2174      end if
2175      if (dt%optdriver==RUNL_NONLINEAR) then
2176        cond_string(1)='optdriver' ; cond_values(1)=dt%optdriver
2177        call chkint_eq(1,1,cond_string,cond_values,ierr,'paral_atom',dt%paral_atom,1,(/0/),iout)
2178      end if
2179      if (dt%usedmft==1) then
2180        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
2181        call chkint_eq(1,1,cond_string,cond_values,ierr,'paral_atom',dt%paral_atom,1,(/0/),iout)
2182      end if
2183      if (dt%prtden>1.and.dt%paral_kgb==0) then
2184        cond_string(1)='paral_kgb' ; cond_values(1)=dt%paral_kgb
2185        cond_string(2)='prtden' ; cond_values(2)=dt%prtden-1
2186        call chkint_eq(1,2,cond_string,cond_values,ierr,'paral_atom',dt%paral_atom,1,(/0/),iout)
2187      end if
2188    end if
2189 
2190 !  paral_kgb
2191    call chkint_eq(0,0,cond_string,cond_values,ierr,'paral_kgb',dt%paral_kgb,2,(/0,1/),iout)
2192 !  Warning
2193    if(dt%paral_kgb==1.and.dt%iomode/=IO_MODE_MPI) then
2194      write(message,'(11a)' )&
2195 &     'When k-points/bands/FFT parallelism is activated',ch10,&
2196 &     '(paral_kgb=1), only MPI-IO input/output is allowed !',ch10,&
2197 &     'iomode/=1 in your input file',ch10,&
2198 &     'You will not be able to perform input/output !'
2199      MSG_WARNING(message)
2200    end if
2201    if(dt%paral_kgb==1.and.dt%nstep==0) then
2202      message='When k-points/bands/FFT parallelism is activated, nstep=0 is not allowed!'
2203      MSG_ERROR_NOSTOP(message,ierr)
2204    end if
2205    if(dt%paral_kgb==1.and.dt%usefock>0) then
2206      message='Hartree-Fock or Hybrid Functionals are not compatible with bands/FFT parallelism!'
2207      MSG_ERROR_NOSTOP(message,ierr)
2208    end if
2209 
2210 
2211 !  paral_rf
2212    if ((response==0).and.(dt%paral_rf/=0)) then
2213      write(message,'(a,i3,3a,14(a,i2),4a)' )&
2214 &     'The input variable optdriver=',dt%optdriver,ch10,&
2215 &     'This is in conflict with the values of the other input variables,',ch10,&
2216 &     'rfphon=',dt%rfphon,' rfddk=',dt%rfddk,' rf2_dkdk=',dt%rf2_dkdk,' rf2_dkde=',dt%rf2_dkde,&
2217 &     ' rfelfd=',dt%rfelfd,'  rfmagn=',dt%rfmagn,' rfstrs=',dt%rfstrs,' rfuser=',dt%rfuser,&
2218 &     ' d3e_pert1_elfd=',dt%d3e_pert1_elfd,' d3e_pert2_elfd=',dt%d3e_pert2_elfd,' d3e_pert3_elfd=',dt%d3e_pert3_elfd,&
2219 &     ' d3e_pert1_phon=',dt%d3e_pert1_phon,' d3e_pert2_phon=',dt%d3e_pert2_phon,' d3e_pert3_phon=',dt%d3e_pert3_phon,ch10,&
2220 &     'Action: check the values of optdriver, rfphon, rfddk, rf2dkdk, rf2dkde, rfelfd, rfmagn, rfstrs, rfuser,',ch10,&
2221 &     'd3e_pert1_elfd, d3e_pert2_elfd, d3e_pert3_elfd, d3e_pert1_phon, d3e_pert2_phon, and d3e_pert3_phon in your input file.'
2222      MSG_ERROR_NOSTOP(message, ierr)
2223    end if
2224 
2225 !  pawcpxocc
2226    if (usepaw==1) then
2227      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawcpxocc',dt%pawcpxocc,2,(/1,2/),iout)
2228      if (dt%usepawu>=1.and.nspinor==2.and.dt%pawcpxocc==1) then
2229        write(message, '(5a)' )&
2230 &       'When non-collinear magnetism is activated ,',ch10,&
2231 &       'and LDA+U activated ',ch10,&
2232 &       'PAW occupancies must be complex !'
2233        MSG_ERROR_NOSTOP(message, ierr)
2234      else if (dt%pawspnorb==1.and.(dt%kptopt==0.or.dt%kptopt>=3).and.dt%pawcpxocc==1) then
2235        if (optdriver==RUNL_GSTATE.and.dt%iscf<10) then
2236          write(message, '(11a)' )&
2237 &         'When spin-orbit coupling is activated (pawspnorb=1),',ch10,&
2238 &         'and time-reversal symmetry is broken (kptopt/=1 and kptopt/=2)',ch10,&
2239 &         'PAW occupancies are complex !',ch10,&
2240 &         'Their imaginary part is used to evaluate total energy by direct',ch10,&
2241 &         'scheme, needed here because SCF potential mixing has been chosen (iscf<10).',ch10,&
2242 &         'Action: put pawcpxocc=2 in input file, or choose SCF density mixing (iscf>=10).'
2243          MSG_ERROR_NOSTOP(message, ierr)
2244        else if (optdriver==RUNL_GSTATE.and.dt%iscf>=10) then
2245          write(message, '(11a)' )&
2246 &         'When spin-orbit coupling is activated (pawspnorb=1),',ch10,&
2247 &         'and time-reversal symmetry is broken (kptopt/=1 and kptopt/=2)',ch10,&
2248 &         'PAW occupancies are complex !',ch10,&
2249 &         'By setting pawcpxocc=1 in input file, their imaginary part',ch10,&
2250 &         'is not computed. As a consequence, total energy computed',ch10,&
2251 &         'is not available. Put pawcpxocc=2 in input file if you want it.'
2252          MSG_WARNING(message)
2253        else
2254          write(message, '(11a)' )&
2255 &         'When spin-orbit coupling is activated (pawspnorb=1),',ch10,&
2256 &         'and time-reversal symmetry is broken (kptopt/=1 and kptopt/=2)',ch10,&
2257 &         'PAW occupancies are complex !',ch10,&
2258 &         'Action: put pawcpxocc=2 in input file to compute their imaginary part.'
2259          MSG_ERROR_NOSTOP(message, ierr)
2260        end if
2261      end if
2262      if (dt%pawspnorb==1.and.dt%kptopt==0) then
2263        write(message, '(7a)' )&
2264 &       'When spin-orbit coupling is activated (pawspnorb=1),',ch10,&
2265 &       'time-reversal symmetry might be broken.',ch10,&
2266 &       'Using kptopt=0 might be risky: if (kx,ky,kz) is present in k-points list,',ch10,&
2267 &       '(-kx,-ky,-kz) (or equivalent) should also be present.'
2268        MSG_WARNING(message)
2269      end if
2270    end if
2271 
2272 !  pawcross
2273    if (usepaw==1) then
2274      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawcross',dt%pawcross,2,(/0,1/),iout)
2275    end if
2276 
2277 !  pawfatbnd
2278    call chkint_eq(0,0,cond_string,cond_values,ierr,'pawfatbnd',dt%pawfatbnd,3,(/0,1,2/),iout)
2279    if(usepaw/=1.and.dt%pawfatbnd>1) then
2280      message = 'pawfatbnd without PAW is not possible'
2281      MSG_ERROR_NOSTOP(message,ierr)
2282    end if
2283    if(dt%prtdosm==1.and.dt%pawfatbnd>0)then
2284      message = 'pawfatbnd>0  and prtdosm=1 are not compatible '
2285      MSG_ERROR_NOSTOP(message,ierr)
2286    end if
2287 !  for the moment pawfatbnd is not compatible with fft or band parallelization
2288    !if (dt%pawfatbnd > 0 .and. (dt%npfft > 1 .or. dt%npband > 1)) then
2289    !  message = 'pawfatbnd and FFT or band parallelization are not compatible yet. Set pawfatbnd to 0  '
2290    !  MSG_ERROR_NOSTOP(message,ierr)
2291    !end if
2292 
2293 !  pawlcutd
2294    if (usepaw==1) then
2295      call chkint_ge(0,0,cond_string,cond_values,ierr,'pawlcutd',dt%pawlcutd,0,iout)
2296    end if
2297 
2298 !  pawlmix
2299    if (usepaw==1) then
2300      call chkint_ge(0,0,cond_string,cond_values,ierr,'pawlmix',dt%pawlmix,0,iout)
2301    end if
2302 
2303 !  pawmixdg
2304    if (usepaw==1) then
2305      if(dt%ionmov==4)then
2306        cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
2307        call chkint_eq(1,1,cond_string,cond_values,ierr,'pawmixdg',dt%pawmixdg,1,(/1/),iout)
2308      end if
2309      if(dt%iscf==5.or.dt%iscf==6.or.dt%iscf==15.or.dt%iscf==16)then
2310        cond_string(1)='iscf' ; cond_values(1)=dt%iscf
2311        call chkint_eq(1,1,cond_string,cond_values,ierr,'pawmixdg',dt%pawmixdg,1,(/1/),iout)
2312      end if
2313      if(usewvl==1)then
2314        cond_string(1)='usewvl' ; cond_values(1)=1
2315        call chkint_eq(1,1,cond_string,cond_values,ierr,'pawmixdg',dt%pawmixdg,1,(/1/),iout)
2316      end if
2317    end if
2318 
2319 !  pawnhatxc
2320    if (usepaw==1) then
2321      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawnhatxc',dt%pawnhatxc,2,(/0,1/),iout)
2322    end if
2323 
2324 !  pawnzlm
2325    if (usepaw==1) then
2326      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawnzlm',dt%pawnzlm,2,(/0,1/),iout)
2327    end if
2328 
2329 !  pawoptmix
2330    if (usepaw==1) then
2331      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawoptmix',dt%pawoptmix,2,(/0,1/),iout)
2332    end if
2333 
2334 !  pawprtdos
2335    if (usepaw==1) then
2336      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawprtdos',dt%pawprtdos,3,(/0,1,2/),iout)
2337    end if
2338 
2339 !  pawprtvol
2340    if (usepaw==1) then
2341      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawprtvol',dt%pawprtvol,7,(/-3,-2,-1,0,1,2,3/),iout)
2342    end if
2343 
2344 !  pawspnorb
2345    if (usepaw==1) then
2346      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawspnorb',dt%pawspnorb,2,(/0,1/),iout)
2347      if (dt%pawspnorb==1.and.(dt%kptopt==1.or.dt%kptopt==2)) then
2348        write(message, '(7a)' )&
2349 &       'When spin-orbit coupling is activated (pawspnorb=1),',ch10,&
2350 &       'time-reversal symmetry is broken; k-points cannot',ch10,&
2351 &       'be generated using TR-symmetry.',ch10,&
2352 &       'Action: choose kptopt different from 1 or 2.'
2353        MSG_ERROR_NOSTOP(message, ierr)
2354      end if
2355    end if
2356 
2357 !  pawstgylm, pawsushat
2358    if (usepaw==1) then
2359      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawstgylm',dt%pawstgylm,2,(/0,1/),iout)
2360      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawsushat',dt%pawstgylm,2,(/0,1/),iout)
2361    end if
2362 
2363 !  pawusecp
2364    if (usepaw==1) then
2365      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawusecp',dt%pawusecp,2,(/0,1/),iout)
2366 !      if (dt%mkmem/=0)then
2367 !        cond_string(1)='mkmem' ; cond_values(1)=dt%mkmem
2368 !        call chkint_eq(1,1,cond_string,cond_values,ierr,'pawusecp',dt%pawusecp,1,(/1/),iout)
2369 !      end if
2370 !      if (dt%mk1mem/=0)then
2371 !        cond_string(1)='mk1mem' ; cond_values(1)=dt%mk1mem
2372 !        call chkint_eq(1,1,cond_string,cond_values,ierr,'pawusecp',dt%pawusecp,1,(/1/),iout)
2373 !      end if
2374 !      if (dt%mkqmem/=0)then
2375 !        cond_string(1)='mkqmem' ; cond_values(1)=dt%mkqmem
2376 !        call chkint_eq(1,1,cond_string,cond_values,ierr,'pawusecp',dt%pawusecp,1,(/1/),iout)
2377 !      end if
2378    end if
2379 
2380 !  pawxcdev
2381    if (usepaw==1) then
2382      call chkint_eq(0,0,cond_string,cond_values,ierr,'pawxcdev',dt%pawxcdev,3,(/0,1,2/),iout)
2383    end if
2384 
2385 !  pimass
2386 !  Check that masses are > 0 if imgmov = 9 or 13
2387    if (dt%imgmov==9.or.dt%imgmov==13) then
2388      do itypat=1,dt%ntypat
2389        cond_string(1)='imgmov' ; cond_values(1)=dt%imgmov
2390        write(input_name,'(a4,i1,a1)')'pimass(',itypat,')'
2391        call chkdpr(1,1,cond_string,cond_values,ierr,input_name,dt%pimass(itypat),1,tol8,iout)
2392      end do
2393    end if
2394 
2395 !  pimd_constraint
2396    call chkint_eq(0,0,cond_string,cond_values,ierr,'pimd_constraint',dt%pimd_constraint,2,(/0,1/),iout)
2397    if(dt%pimd_constraint==1.and.dt%nconeq>1 )then
2398      cond_string(1)='pimd_constraint' ; cond_values(1)=dt%pimd_constraint
2399 !    Make sure that nconeq=1
2400      call chkint_eq(1,1,cond_string,cond_values,ierr,'nconeq',dt%nconeq,1,(/1/),iout)
2401    end if
2402 
2403 !  pitransform
2404    call chkint_eq(0,0,cond_string,cond_values,ierr,'pitransform',dt%pitransform,3,(/0,1,2/),iout)
2405 !  When imgmov is not one of 9 or 13, pitransform must be 0
2406    if(dt%imgmov/=9 .and. dt%imgmov/=13 )then
2407      cond_string(1)='imgmov' ; cond_values(1)=dt%imgmov
2408 !    Make sure that pitransform=0
2409      call chkint_eq(1,1,cond_string,cond_values,ierr,'pitransform',dt%pitransform,1,(/0/),iout)
2410    end if
2411    if(dt%pimd_constraint/=0 )then
2412      cond_string(1)='pimd_constraint' ; cond_values(1)=dt%pimd_constraint
2413 !    Make sure that pitransform=0
2414      call chkint_eq(1,1,cond_string,cond_values,ierr,'pitransform',dt%pitransform,1,(/0/),iout)
2415    end if
2416 
2417 !  plowan_compute
2418    cond_string(1)='usepaw' ; cond_values(1)=1
2419    call chkint_eq(1,1,cond_string,cond_values,ierr,'plowan_compute',dt%plowan_compute,3,(/0,1,2/),iout)
2420    if(dt%plowan_compute>0) then
2421 !    plowan_bandi/plowan_bandf
2422      call chkint_ge(0,0,cond_string,cond_values,ierr,'plowan_bandi',dt%plowan_bandi,              1,iout)
2423      call chkint_ge(0,0,cond_string,cond_values,ierr,'plowan_bandf',dt%plowan_bandf,dt%plowan_bandi,iout)
2424 
2425      call chkint_le(0,0,cond_string,cond_values,ierr,'plowan_bandi',dt%plowan_bandi,dt%plowan_bandf,iout)
2426      call chkint_le(0,0,cond_string,cond_values,ierr,'plowan_bandi',dt%plowan_bandf,dt%mband       ,iout)
2427 
2428      call chkint_ge(0,0,cond_string,cond_values,ierr,'plowan_natom',dt%plowan_natom,              0,iout)
2429 
2430      maxplowan_iatom=maxval(dt%plowan_iatom(1:dt%plowan_natom))
2431      minplowan_iatom=minval(dt%plowan_iatom(1:dt%plowan_natom))
2432      call chkint_ge(0,0,cond_string,cond_values,ierr,'plowan_iatom',minplowan_iatom,              1,iout)
2433      call chkint_le(0,0,cond_string,cond_values,ierr,'plowan_iatom',maxplowan_iatom,          natom,iout)
2434 
2435      kk=0
2436      do jj = 1, dt%plowan_natom
2437        do ii = 1, dt%plowan_nbl(jj)
2438          kk=kk+1
2439          cond_string(1)='usepaw' ; cond_values(1)=1
2440          call chkint_eq(1,1,cond_string,cond_values,ierr,'plowan_lcalc',dt%plowan_lcalc(kk),4,(/0,1,2,3/),iout)
2441        end do
2442      end do
2443 
2444      call chkint_ge(0,0,cond_string,cond_values,ierr,'plowan_nt'   ,dt%plowan_nt,                 0,iout)
2445      cond_string(1)='usepaw' ; cond_values(1)=1
2446      call chkint_eq(1,1,cond_string,cond_values,ierr,'plowan_realspace',dt%plowan_realspace,3,(/0,1,2/),iout)
2447    end if
2448 
2449 !  posdoppler
2450    call chkint_eq(0,0,cond_string,cond_values,ierr,'posdoppler',dt%posdoppler,2,(/0,1/),iout)
2451 
2452 !  positron
2453    call chkint_eq(0,0,cond_string,cond_values,ierr,'positron',dt%positron,7,(/-20,-10,-2,-1,0,1,2/),iout)
2454    if ((dt%positron==2.or.dt%positron<0).and.(dt%ixcpositron==3.or.dt%ixcpositron==31)) then
2455      if ((dt%ixc<11.or.dt%ixc>17).and.dt%ixc/=23.and.dt%ixc/=26.and.dt%ixc/=27) then
2456        write(message, '(7a)' )&
2457 &       'For the electronic ground-state calculation in presence of a positron,',ch10,&
2458 &       'when GGA is selected for electron-positron correlation (ixcpositron=3 or 31),',ch10,&
2459 &       'electron-electron XC must also be GGA !',ch10,&
2460 &       'Action: choose another psp file.'
2461        MSG_ERROR_NOSTOP(message, ierr)
2462      end if
2463    end if
2464    if (dt%positron/=0.and.dt%ionmov==5) then
2465      cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
2466      call chkint_eq(1,1,cond_string,cond_values,ierr,'positron',dt%positron,1,(/0/),iout)
2467    end if
2468    if (dt%positron<0.and.usepaw==0) then
2469      write(message, '(5a)' )&
2470 &     'You cannot use positron<0 (automatic two-component DFT)',ch10,&
2471 &     'with norm-conserving pseudopotentials !',ch10,&
2472 &     'Action: choose PAW.'
2473      MSG_ERROR_NOSTOP(message, ierr)
2474    end if
2475    if ((dt%positron==1.or.dt%positron<0).and.dt%iscf<10.and.dt%tolvrs>tiny(one)) then
2476      write(message, '(7a)' )&
2477 &     'You cannot perform a positronic ground-state calculation (positron=1 or <0)',ch10,&
2478 &     'using SCF potential mixing (iscf<10) and tolvrs !',ch10,&
2479 &     '(in that case, the potential is constant)',ch10,&
2480 &     'Action: change iscf or select another convergence criterion.'
2481      MSG_ERROR_NOSTOP(message, ierr)
2482    end if
2483 
2484 !  posocc
2485    call chkdpr(0,0,cond_string,cond_values,ierr,'posocc',dt%posocc,-1,one,iout)
2486 
2487 !  postoldfe, postoldff
2488    call chkdpr(0,0,cond_string,cond_values,ierr,'postoldff',dt%postoldff,1,zero,iout)
2489    if (dt%positron<0) then
2490      if ( (abs(dt%postoldfe)> tiny(0.0_dp).and.abs(dt%postoldff)> tiny(0.0_dp)).or.&
2491 &     (abs(dt%postoldfe)<=tiny(0.0_dp).and.abs(dt%postoldff)<=tiny(0.0_dp))) then
2492        write(message,'(5a)' )&
2493 &       'One and only one of the input tolerance criteria postoldfe or postoldff',ch10,&
2494 &       'must differ from zero !',ch10,&
2495 &       'Action: change postoldfe or postldff in input file.'
2496        MSG_ERROR_NOSTOP(message, ierr)
2497      end if
2498      if (abs(dt%postoldff)>tiny(0.0_dp).and.dt%optforces/=1)then
2499        write(message,'(3a)' )&
2500 &       'When postoldff is set to a non-zero value, optforces must be set to 1 !',ch10,&
2501 &       'Action: change your input file.'
2502        MSG_ERROR_NOSTOP(message, ierr)
2503      end if
2504    end if
2505 
2506 !  prepanl
2507 !  Must have prtden=1 to prepare a nonlinear calculation
2508    if (dt%prtden /= 1) then
2509      cond_string(1)='prtden' ; cond_values(1)=dt%prtden
2510      call chkint_ne(1,1,cond_string,cond_values,ierr,'prepanl',dt%prepanl,1,(/1/),iout)
2511    end if
2512 
2513 !  prtbbb
2514 !  Not allowed for PAW
2515    if(usepaw==1.and.dt%prtbbb==1)then
2516      cond_string(1)='usepaw' ; cond_values(1)=usepaw
2517      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtbbb',dt%prtbbb,1,(/0/),iout)
2518    end if
2519 
2520 !  prtden
2521    if (usepaw==1) then
2522      call chkint_le(0,0,cond_string,cond_values,ierr,'prtden',dt%prtden,7,iout)
2523    else
2524      call chkint_le(0,0,cond_string,cond_values,ierr,'prtden',dt%prtden,1,iout)
2525    end if
2526 
2527 !  prtdensph
2528    if (usepaw==1) then
2529      call chkint_eq(0,0,cond_string,cond_values,ierr,'prtdensph',dt%prtdensph,2,(/0,1/),iout)
2530    end if
2531 
2532 !  prtdos
2533    call chkint_eq(0,0,cond_string,cond_values,ierr,'prtdos',dt%prtdos,6,(/0,1,2,3,4,5/),iout)
2534 
2535 ! for the moment prtdos 3,4,5 are not compatible with fft or band parallelization
2536    if (dt%prtdos > 3 .and. (dt%npfft > 1 .or. dt%npband > 1)) then
2537      message = 'prtdos>3 and FFT or band parallelization are not compatible yet. Set prtdos <= 2'
2538      MSG_ERROR_NOSTOP(message, ierr)
2539    end if
2540 
2541 ! prtdos 5 only makes sense for nspinor == 2. Otherwise reset to prtdos 2
2542    if (dt%prtdos == 5 .and. dt%nspinor /= 2) then
2543      dt%prtdos = 2
2544      MSG_WARNING('prtdos==5 is only useful for nspinor 2. Has been reset to 2')
2545    end if
2546    if (dt%prtdos == 5 .and. dt%npspinor /= 1) then
2547      MSG_ERROR_NOSTOP('prtdos==5 not available with npspinor==2', ierr)
2548    end if
2549    ! Consistency check for prtdos 5 with PAW
2550    if (dt%prtdos == 5 .and. dt%usepaw == 1) then
2551      if (dt%pawprtdos == 2) then
2552        MSG_ERROR_NOSTOP('prtdos==5 is not compatible with pawprtdos 2', ierr)
2553      end if
2554      MSG_ERROR_NOSTOP('prtdos==5 is not available with PAW', ierr)
2555    end if
2556 
2557 !  prtdosm
2558    call chkint_eq(0,0,cond_string,cond_values,ierr,'prtdosm',dt%prtdosm,3,(/0,1,2/),iout)
2559    if(usepaw==1.and.dt%pawprtdos==1)then
2560      cond_string(1)='pawprtdos' ; cond_values(1)=dt%pawprtdos
2561      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtdosm',dt%prtdosm,1,(/0/),iout)
2562    end if
2563    if(usepaw==1.and.dt%prtdosm>=1)then
2564      cond_string(1)='prtdosm' ; cond_values(1)=dt%prtdosm
2565      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtdos',dt%prtdos,1,(/3/),iout)
2566    end if
2567    if(dt%prtdosm==2.and.dt%pawprtdos/=2)then
2568      message = ' pawprtdos/=2  and prtdosm=2 are not compatible '
2569      MSG_ERROR(message)
2570    end if
2571 
2572 !  prtefmas
2573    call chkint_eq(0,0,cond_string,cond_values,ierr,'prtefmas',dt%prtefmas,2,(/0,1/),iout)
2574    if(optdriver/=RUNL_RESPFN)then
2575      cond_string(1)='optdriver' ; cond_values(1)=optdriver
2576      call chkint_eq(0,1,cond_string,cond_values,ierr,'prtefmas',dt%prtefmas,1,(/0/),iout)
2577    end if
2578 
2579 !  prtelf
2580    call chkint_ge(0,0,cond_string,cond_values,ierr,'prtelf',dt%prtkden,0,iout)
2581    if(optdriver/=RUNL_GSTATE)then
2582      cond_string(1)='optdriver' ; cond_values(1)=optdriver
2583      call chkint_eq(0,1,cond_string,cond_values,ierr,'prtelf',dt%prtelf,1,(/0/),iout)
2584    end if
2585    if(usepaw/=0)then
2586      cond_string(1)='usepaw' ; cond_values(1)=usepaw
2587      call chkint_eq(0,1,cond_string,cond_values,ierr,'prtelf',dt%prtelf,1,(/0/),iout)
2588    end if
2589 
2590 !  prtfsurf only one shift allowed (gamma)
2591    if (dt%prtfsurf == 1) then
2592 
2593      if (abs(dt%kptrlatt(1,2))+abs(dt%kptrlatt(1,3))+abs(dt%kptrlatt(2,3))+&
2594 &     abs(dt%kptrlatt(2,1))+abs(dt%kptrlatt(3,1))+abs(dt%kptrlatt(3,2)) /= 0 ) then
2595        write(message,'(4a)')ch10,&
2596 &       'prtfsurf does not work with non-diagonal kptrlatt ', ch10,&
2597 &       'Action: set nshift 1 and shiftk 0 0 0'
2598        MSG_ERROR_NOSTOP(message, ierr)
2599      end if
2600      if (dt%nshiftk > 1) then
2601        write(message,'(4a)') ch10,&
2602 &       'prtfsurf does not work with multiple kpt shifts ', ch10, &
2603 &       'Action: set nshift 1 and shiftk 0 0 0'
2604        MSG_ERROR_NOSTOP(message, ierr)
2605      end if
2606      if (sum(abs(dt%shiftk(:,1:dt%nshiftk))) > tol8) then
2607        write(message,'(4a)')ch10,&
2608 &       'prtfsurf does not work with non-zero kpt shift ',ch10,&
2609 &       'Action: set nshift 1 and shiftk 0 0 0'
2610        MSG_ERROR_NOSTOP(message, ierr)
2611      end if
2612 
2613 !    Occcupations, Fermi level and k weights have to be calculated correctly.
2614      if (.not.(dt%iscf>1.or.dt%iscf==-3)) then
2615        write(message,'(4a)')ch10,&
2616 &       'prtfsurf==1 requires either iscf>1 or iscf==-3 ',ch10,&
2617 &       'Action: change iscf in the input file. '
2618        MSG_ERROR_NOSTOP(message, ierr)
2619      end if
2620 
2621 !    Make sure all nband are equal (well it is always enforced for metals)
2622      if (any(dt%nband(1:nkpt*nsppol) /= maxval(dt%nband(1:nkpt*nsppol)) )) then
2623        write(message,'(3a)')&
2624 &       'The number of bands has to be constant for the output of the Fermi surface.',ch10,&
2625 &       'Action: set all the nbands to the same value in your input file'
2626        MSG_ERROR_NOSTOP(message,ierr)
2627      end if
2628    end if ! prtfsurf==1
2629 
2630 !  prtgden
2631    call chkint(0,0,cond_string,cond_values,ierr,&
2632 &   'prtgden',dt%prtgden,1,(/0/),1,0,iout)
2633    if(optdriver/=RUNL_GSTATE)then
2634      cond_string(1)='optdriver' ; cond_values(1)=optdriver
2635      call chkint(0,1,cond_string,cond_values,ierr,&
2636 &     'prtgden',dt%prtgden,1,(/0/),0,0,iout)
2637    end if
2638    if(usepaw/=0)then
2639      cond_string(1)='usepaw' ; cond_values(1)=usepaw
2640      call chkint(0,1,cond_string,cond_values,ierr,&
2641 &     'prtgden',dt%prtgden,1,(/0/),0,0,iout)
2642    end if
2643 
2644 !  prtkden
2645    call chkint_ge(0,0,cond_string,cond_values,ierr,'prtkden',dt%prtkden,0,iout)
2646    if(optdriver/=RUNL_GSTATE)then
2647      cond_string(1)='optdriver' ; cond_values(1)=optdriver
2648      call chkint_eq(0,1,cond_string,cond_values,ierr,'prtkden',dt%prtkden,1,(/0/),iout)
2649    end if
2650    if(usepaw/=0)then
2651      cond_string(1)='usepaw' ; cond_values(1)=usepaw
2652      call chkint_eq(0,1,cond_string,cond_values,ierr,'prtkden',dt%prtkden,1,(/0/),iout)
2653    end if
2654 
2655 !  prtlden
2656    call chkint(0,0,cond_string,cond_values,ierr,&
2657 &   'prtlden',dt%prtlden,1,(/0/),1,0,iout)
2658    if(optdriver/=RUNL_GSTATE)then
2659      cond_string(1)='optdriver' ; cond_values(1)=optdriver
2660      call chkint(0,1,cond_string,cond_values,ierr,&
2661 &     'prtlden',dt%prtlden,1,(/0/),0,0,iout)
2662    end if
2663    if(usepaw/=0)then
2664      cond_string(1)='usepaw' ; cond_values(1)=usepaw
2665      call chkint(0,1,cond_string,cond_values,ierr,&
2666 &     'prtlden',dt%prtlden,1,(/0/),0,0,iout)
2667    end if
2668 
2669 !  prtstm
2670    call chkint_ge(0,0,cond_string,cond_values,ierr,'prtstm',dt%prtstm,0,iout)
2671    if(optdriver/=RUNL_GSTATE)then
2672      cond_string(1)='optdriver' ; cond_values(1)=optdriver
2673      call chkint_eq(0,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
2674    end if
2675    if(dt%occopt/=7)then
2676      cond_string(1)='occopt' ; cond_values(1)=dt%occopt
2677      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
2678    end if
2679    if(dt%nstep/=1)then
2680      cond_string(1)='nstep' ; cond_values(1)=dt%nstep
2681      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
2682    end if
2683    if(dt%ionmov/=0)then
2684      cond_string(1)='ionmov' ; cond_values(1)=dt%ionmov
2685      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
2686    end if
2687 !  tolwfr must be 0 to make a problem (another tol variable is used). Here, check that it is very very small.
2688    if(abs(dt%tolwfr)<tol16*tol16)then
2689      cond_string(1)='tolwfr' ; cond_values(1)=0
2690      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
2691    end if
2692    if(dt%prtden/=0)then
2693      cond_string(1)='prtden' ; cond_values(1)=dt%prtden
2694      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
2695    end if
2696    if(dt%prtnabla>0)then
2697      cond_string(1)='prtnabla' ; cond_values(1)=dt%prtnabla
2698      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
2699    end if
2700    if(dt%prtvxc>0)then
2701      cond_string(1)='prtvxc' ; cond_values(1)=dt%prtvxc
2702      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
2703    end if
2704    if(dt%prtvha>0)then
2705      cond_string(1)='prtvha' ; cond_values(1)=dt%prtvha
2706      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
2707    end if
2708    if(dt%prtvhxc>0)then
2709      cond_string(1)='prtvhxc' ; cond_values(1)=dt%prtvhxc
2710      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtstm',dt%prtstm,1,(/0/),iout)
2711    end if
2712 
2713 !  prtvclmb - needs prtvha as well
2714    if(dt%prtvclmb > 0)then
2715      cond_string(1)='prtvclmb' ; cond_values(1)=dt%prtvclmb
2716      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtvha',dt%prtvha,1,(/1/),iout)
2717    end if
2718 
2719 !  prtvolimg
2720    call chkint_eq(0,0,cond_string,cond_values,ierr,'prtvolimg',dt%prtvolimg,3,(/0,1,2/),iout)
2721 
2722 !  prtwant
2723    if (dt%prtwant/=0) then
2724      cond_string(1)='prtwant' ; cond_values(1)=dt%prtwant
2725      call chkint_eq(0,0,cond_string,cond_values,ierr,'paral_kgb',dt%paral_kgb,1,(/0/),iout)
2726    end if
2727 #if !defined HAVE_WANNIER90
2728    if(dt%prtwant==2) then
2729      write(message, '(a,a,a)' )&
2730 &     ' prtwant==2 is only relevant if wannier90 library is linked',ch10,&
2731 &     ' Action: check compilation options'
2732      MSG_ERROR_NOSTOP(message,ierr)
2733    end if
2734 #endif
2735 
2736 !  prtwf
2737    call chkint_eq(0,0,cond_string,cond_values,ierr,'prtwf',dt%prtwf,5,[-1,0,1,2,3],iout)
2738 
2739    if (dt%prtkbff == 1 .and. dt%useylm /= 0) then
2740      MSG_ERROR_NOSTOP("prtkbff == 1 requires useylm == 0", ierr)
2741    end if
2742 
2743 !  random_atpos
2744    call chkint_eq(0,0,cond_string,cond_values,ierr,'random_atpos',dt%random_atpos,5,(/0,1,2,3,4/),iout)
2745 
2746 !  ratsph
2747 !  If PAW and (prtdos==3 or dt%prtdensph==1), must be greater than PAW radius
2748    if(usepaw==1.and.(dt%prtdos==3.or.dt%prtdensph==1))then
2749      do itypat=1,dt%ntypat
2750        if (pspheads(itypat)%pawheader%rpaw>dt%ratsph(itypat)) then
2751          write(message, '(7a,i2,a,f15.12,3a)' )&
2752 &         'Projected DOS/density is required in the framework of PAW !',ch10,&
2753 &         'The radius of spheres in which DOS/density has to be projected',ch10,&
2754 &         'must be greater or equal than the (max.) PAW radius !',ch10,&
2755 &         'Rpaw(atom_type ',itypat,')= ',pspheads(itypat)%pawheader%rpaw,' au',ch10,&
2756 &         'Action: modify value of ratsph in input file.'
2757          MSG_ERROR_NOSTOP(message, ierr)
2758        end if
2759      end do
2760    end if
2761 
2762 
2763 !  recgratio
2764    if (dt%tfkinfunc==2) then
2765      write(message, '(a,a)' ) ch10,&
2766 &     '=== RECURSION METHOD ==========================================================='
2767      call wrtout(ab_out,message,'COLL')
2768      cond_string(1)='tfkinfunc' ; cond_values(1)=2
2769      call chkint_ge(0,1,cond_string,cond_values,ierr,'recgratio',dt%recgratio,1,iout)
2770      if(dt%recgratio>1) then
2771        write(message, '(a,a)' )&
2772 &       '=== Coarse Grid is used in recursion ==========================================='
2773        call wrtout(ab_out,message,'COLL')
2774        write(message, '(a,i3,a,a,i3,a,i3,a,i3)' ) 'grid ratio =',dt%recgratio,&
2775 &       ch10,'fine grid =   ',dt%ngfft(1),' ',dt%ngfft(2),' ',dt%ngfft(3)
2776        call wrtout(ab_out,message,'COLL')
2777        write(message, '(a,i2,a,i2,a,i2)' ) 'coarse grid = ',&
2778 &       dt%ngfft(1)/dt%recgratio,' ',dt%ngfft(2)/dt%recgratio,' ',dt%ngfft(3)/dt%recgratio
2779        call wrtout(ab_out,message,'COLL')
2780      else
2781        write(message, '(a,i2,a,i2,a,i2)' ) 'fine grid =   ',dt%ngfft(1),' ',dt%ngfft(2),' ',dt%ngfft(3)
2782        call wrtout(ab_out,message,'COLL')
2783 
2784      end if
2785    end if
2786 
2787 
2788 !  rfatpol
2789    call chkint_ge(0,0,cond_string,cond_values,ierr,'rfatpol(1)',dt%rfatpol(1),1,iout)
2790    cond_string(1)='natom' ; cond_values(1)=natom
2791    call chkint_le(1,1,cond_string,cond_values,ierr,'rfatpol(2)',dt%rfatpol(2),natom,iout)
2792 
2793 !  rfmeth
2794    call chkint_eq(0,0,cond_string,cond_values,ierr,'rfmeth',dt%rfmeth,6,(/-3,-2,-1,1,2,3/),iout)
2795 
2796 !  rprimd
2797 !  With optcell beyond 4, one has constraints on rprimd.
2798    if(dt%optcell==4 .or. dt%optcell==7 )then
2799      cond_string(1)='optcell' ; cond_values(1)=4
2800      if(dt%optcell==7)cond_values(1)=7
2801      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(1,2)',rprimd(1,2),0,0.0_dp,iout)
2802      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(1,3)',rprimd(1,3),0,0.0_dp,iout)
2803      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(2,1)',rprimd(2,1),0,0.0_dp,iout)
2804      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(3,1)',rprimd(3,1),0,0.0_dp,iout)
2805    else if(dt%optcell==5 .or. dt%optcell==8 )then
2806      cond_string(1)='optcell' ; cond_values(1)=5
2807      if(dt%optcell==8)cond_values(1)=8
2808      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(2,1)',rprimd(2,1),0,0.0_dp,iout)
2809      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(2,3)',rprimd(2,3),0,0.0_dp,iout)
2810      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(1,2)',rprimd(1,2),0,0.0_dp,iout)
2811      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(3,2)',rprimd(3,2),0,0.0_dp,iout)
2812    else if(dt%optcell==6 .or. dt%optcell==9 )then
2813      cond_string(1)='optcell' ; cond_values(1)=6
2814      if(dt%optcell==9)cond_values(1)=9
2815      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(3,1)',rprimd(3,1),0,0.0_dp,iout)
2816      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(3,2)',rprimd(3,2),0,0.0_dp,iout)
2817      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(1,3)',rprimd(1,3),0,0.0_dp,iout)
2818      call chkdpr(1,1,cond_string,cond_values,ierr,'rprimd(2,3)',rprimd(2,3),0,0.0_dp,iout)
2819    end if
2820 
2821 !  so_psp
2822    if(usepaw==0)then
2823      do ipsp=1,npsp
2824 !      Check that so_psp is between 0 and 3
2825        if ( dt%so_psp(ipsp)<0 .or. dt%so_psp(ipsp)>3 ) then
2826          write(message, '(a,i3,a,i3,a,a,a,a,a)' )&
2827 &         'so_psp(',ipsp,' ) was input as ',dt%so_psp(ipsp),' .',ch10,&
2828 &         'Input value must be 0, 1, 2, or 3.',ch10,&
2829 &         'Action: modify value of so_psp (old name : so_typat) in input file.'
2830          MSG_ERROR_NOSTOP(message, ierr)
2831        end if
2832 !      If nspinor=1, the spin-orbit contribution cannot be taken into account
2833        if ( nspinor==1 .and. (dt%so_psp(ipsp)==2 .or. dt%so_psp(ipsp)==3) ) then
2834          write(message, '(a,i2,a,i3,a,a,a,a,a)' )&
2835 &         'so_psp(',ipsp,') was input as ',dt%so_psp(ipsp),', with nspinor=1 and usepaw=0.',ch10,&
2836 &         'When nspinor=1, so_psp cannot be required to be 2 or 3.',ch10,&
2837 &         'Action: modify value of so_psp (old name : so_typat) or nspinor in input file.'
2838          MSG_ERROR_NOSTOP(message, ierr)
2839        end if
2840 !      If nspinor=2, the spin-orbit contribution should be present in the pseudopotentials,
2841 !      unless the user explicitly allows not to treat it.
2842        if ( nspinor==2 .and. dt%so_psp(ipsp)/=0 .and. pspheads(ipsp)%pspso==0 ) then
2843          write(message, '(a,i2,a,i3,9a)' )&
2844 &         'so_psp(',ipsp,') was input as ',dt%so_psp(ipsp),', with nspinor=2 and usepaw=0.',ch10,&
2845 &         'This requires a treatment of the spin-orbit interaction. However, it has been detected ',ch10,&
2846 &         'that the pseudopotential that you want to use does not specify the spin-orbit coupling.',ch10,&
2847 &         'Action: choose a pseudopotential that contains information about the spin-orbit interaction,',ch10,&
2848 &         ' or deliberately switch off the spin-orbit interaction by setting so_psp=0 for that pseudopotential in the input file.'
2849          MSG_ERROR_NOSTOP(message, ierr)
2850        end if
2851      end do ! ipsp
2852    end if ! usepaw==0
2853 
2854 !  spinmagntarget
2855    if(abs(dt%spinmagntarget+99.99d0)>tol8 .and. abs(dt%spinmagntarget)>tol8)then
2856      if(nsppol==1)then
2857        write(message, '(a,f8.2,4a)' )&
2858 &       'spinmagntarget was input as ',dt%spinmagntarget,ch10,&
2859 &       'When nsppol=1, spinmagntarget is required to be 0.0d0 or the default value.',ch10,&
2860 &       'Action: modify value spinmagntarget or nsppol in input file.'
2861        MSG_ERROR_NOSTOP(message, ierr)
2862      end if
2863      if(optdriver==RUNL_RESPFN)then
2864        write(message, '(a,f8.2,4a)' )&
2865 &       'spinmagntarget was input as ',dt%spinmagntarget,ch10,&
2866 &       'For a response function run, spinmagntarget is required to be 0.0d0 or the default value.',ch10,&
2867 &       'Action: modify value spinmagntarget or nsppol in input file.'
2868        MSG_ERROR_NOSTOP(message, ierr)
2869      end if
2870      if(dt%prtdos==1)then
2871        write(message, '(a,f8.2,4a)' )&
2872 &       'spinmagntarget was input as ',dt%spinmagntarget,ch10,&
2873 &       'When prtdos==1, spinmagntarget is required to be 0.0d0 or the default value.',ch10,&
2874 &       'Action: modify value spinmagntarget or nsppol in input file.'
2875        MSG_ERROR_NOSTOP(message, ierr)
2876      end if
2877    end if
2878 !  If nsppol==2 and spinmagntarget==0.0 , suggest to use anti-ferromagnetic capability of ABINIT.
2879    if(nsppol==2.and.abs(dt%spinmagntarget)<tol8)then
2880      write(message,'(a,i3,2a,f7.2,6a)' )&
2881 &     ' This is a calculation with spin-up and spin-down wavefunctions,         ... nsppol=',nsppol,ch10,&
2882 &     ' in which the target spin-polarization is zero.                  ... spinmagntarget=',dt%spinmagntarget,ch10,&
2883 &     ' Tip ... It might be possible that the ground state is either non-spin-polarized, or antiferromagnetic.',ch10,&
2884 &     ' In the former case, it is advantageous to use nsppol=1 and nspden=1,',ch10,&
2885 &     ' while in the latter  case, it is advantageous to use nsppol=1 and nspden=2.'
2886      call wrtout(iout,message,'COLL')
2887    end if
2888 
2889 !  stmbias
2890    cond_string(1)='prtstm' ; cond_values(1)=dt%prtstm
2891    if(dt%prtstm/=0)then
2892 !    If non-zero prtstm, stmbias cannot be zero : test is positive or zero
2893      if(dt%stmbias>-tol10)then
2894 !      Then, enforce positive
2895        call chkdpr(1,1,cond_string,cond_values,ierr,'stmbias',dt%stmbias,1,2*tol10,iout)
2896      end if
2897    else
2898      call chkdpr(1,1,cond_string,cond_values,ierr,'stmbias',dt%stmbias,0,zero,iout)
2899    end if
2900 
2901 !  string_algo
2902    call chkint_eq(0,0,cond_string,cond_values,ierr,'string_algo',dt%string_algo,2,(/1,2/),iout)
2903 
2904 !  symafm
2905    if(nsppol==1 .and. nspden==2)then
2906 !    At least one of the symmetry operations must be antiferromagnetic
2907      if(minval(dt%symafm(1:dt%nsym))/=-1)then
2908        write(message, '(5a)' )&
2909 &       'When nsppol==1 and nspden==2, at least one of the symmetry operations',ch10,&
2910 &       'must be anti-ferromagnetic (symafm=-1), in order to deduce the spin-down density',ch10,&
2911 &       'from the spin-up density.'
2912        call wrtout(iout,message,'COLL')
2913        call wrtout(std_out,  message,'COLL')
2914        write(message, '(7a)' ) &
2915 &       'However, it is observed that none of the symmetry operations is anti-ferromagnetic.',ch10,&
2916 &       'Action: Check the atomic positions, the input variables spinat, symrel, tnons, symafm.',ch10,&
2917 &       '        In case your system is not antiferromagnetic (it might be ferrimagnetic ...),',ch10,&
2918 &       '        you must use nsppol=2 with nspden=2 (the latter being the default when nsppol=2).'
2919        MSG_ERROR_NOSTOP(message,ierr)
2920      end if
2921    end if
2922 
2923 !  symrel and tnons
2924 !  Check the point group closure (TODO should check the spatial group closure !!)
2925    call chkgrp(dt%nsym,dt%symafm,dt%symrel,ierrgrp)
2926    if (ierrgrp==1) ierr=ierr+1
2927 
2928 !  Check the orthogonality of the symmetry operations
2929 !  (lengths and absolute values of scalar products should be preserved)
2930    iexit=0
2931 
2932    call chkorthsy(gprimd,iexit,dt%nsym,rmet,rprimd,dt%symrel)
2933 
2934 !  symchi
2935    if (all(dt%symchi /= [0, 1])) then
2936      write(message, '(a,i0,2a)' )'symchi was input as ',dt%symchi,ch10,'Input value must be 0, 1.'
2937      MSG_ERROR_NOSTOP(message, ierr)
2938    end if
2939 
2940 !  symsigma
2941    if (dt%symsigma/=0.and.dt%symsigma/=1.and.dt%symsigma/=2) then
2942      write(message, '(a,i0,a,a,a,a)' )&
2943 &     'symsigma  was input as',dt%symsigma,ch10,&
2944 &     'Input value must be 0, 1, or 2.',ch10,&
2945 &     'Action: modify value of symsigma in input file.'
2946      MSG_ERROR_NOSTOP(message, ierr)
2947    end if
2948 
2949 !  MG now it is possible to perform a GW calculation with non-symmorphic operations if required by the user
2950 !  tnons
2951    if (dt%symmorphi==0) then
2952      if(dt%nbandkss/=0)then
2953        do isym=1,dt%nsym
2954          if(sum(dt%tnons(:,isym)**2)>tol6)then
2955            write(message, '(3a,i3,a,3f8.4,3a)' )&
2956 &           'When nbandkss/=0, all the components of tnons must be zero.',ch10,&
2957 &           'However, for the symmetry operation number ',isym,', tnons =',dt%tnons(:,isym),'.',ch10,&
2958 &           'Action: use the symmetry finder (nsym=0) with symmorphi==0.'
2959            MSG_ERROR_NOSTOP(message,ierr)
2960          end if
2961        end do
2962      end if
2963      if (ANY(optdriver ==[RUNL_SCREENING,RUNL_SIGMA])) then
2964        do isym=1,dt%nsym
2965          if (sum(dt%tnons(:,isym)**2)>tol6) then
2966            write(message,'(3a,i3,a,3f8.4,3a)')&
2967 &           'When optdriver==RUNL_SCREENING or RUNL_SIGMA, all the components of tnons must be zero.',ch10,&
2968 &           'However, for the symmetry operation number ',isym,', tnons =',dt%tnons(:,isym),'.',ch10,&
2969 &           'Action: use the symmetry finder (nsym=0) with symmorphi==0.'
2970            MSG_ERROR_NOSTOP(message, ierr)
2971          end if
2972        end do
2973      end if
2974    end if !of symmorphi
2975 
2976 !  tfwkinfunc
2977    call chkint_eq(0,0,cond_string,cond_values,ierr,'tfwkinfunc',dt%tfkinfunc,5,(/0,1,2,11,12/),iout)
2978    if(dt%ionmov==4)then
2979      cond_string(1)='ionmov' ; cond_values(1)=4
2980      call chkint_eq(1,1,cond_string,cond_values,ierr,'tkinfunc',dt%tfkinfunc,1,(/0/),iout)
2981    end if
2982 
2983 !  tolmxde
2984    call chkdpr(0,0,cond_string,cond_values,ierr,'tolmxde',dt%tolmxde,1,zero,iout)
2985 
2986 !  toldff
2987    call chkdpr(0,0,cond_string,cond_values,ierr,'toldff',dt%toldff,1,zero,iout)
2988 
2989 !  tolimg
2990    call chkdpr(0,0,cond_string,cond_values,ierr,'tolimg',dt%tolimg,1,zero,iout)
2991 
2992 !  tolrde
2993    call chkdpr(0,0,cond_string,cond_values,ierr,'tolrde',dt%tolrde,1,zero,iout)
2994 
2995 !  tolrff
2996    call chkdpr(0,0,cond_string,cond_values,ierr,'tolrff',dt%tolrff,1,zero,iout)
2997 
2998 !  tolwfr
2999    call chkdpr(0,0,cond_string,cond_values,ierr,'tolwfr',dt%tolwfr,1,zero,iout)
3000 
3001 !  tsmear
3002    call chkdpr(0,0,cond_string,cond_values,ierr,'tsmear',dt%tsmear,1,zero,iout)
3003 !  Check that tsmear is non-zero positive for metallic occupation functions
3004    if(3<=dt%occopt .and. dt%occopt<=8)then
3005      cond_string(1)='occopt' ; cond_values(1)=dt%occopt
3006      call chkdpr(1,1,cond_string,cond_values,ierr,'tsmear',dt%tsmear,1,tol8,iout)
3007    end if
3008 
3009 !  ucrpa
3010    call chkint_eq(0,0,cond_string,cond_values,ierr,'ucrpa',dt%ucrpa,5,(/0,1,2,3,4/),iout)
3011    if (dt%ucrpa>=1) then
3012      cond_string(1)='ucrpa' ; cond_values(1)=dt%ucrpa
3013      call chkint_eq(1,1,cond_string,cond_values,ierr,'nspinor',dt%nspinor,1,(/1/),iout)
3014    end if
3015 
3016 !  usedmatpu
3017    if (usepaw==1.and.dt%usepawu==1) then
3018 !    abs(dt%usedmatpu)<=nstep
3019      cond_string(1)='nstep' ; cond_values(1)=dt%nstep
3020      call chkint_le(1,1,cond_string,cond_values,ierr,'abs(usedmatpu)',abs(dt%usedmatpu),dt%nstep,iout)
3021 !    lpawu must be constant or -1
3022      if (dt%usedmatpu/=0) then
3023        do itypat=1,dt%ntypat
3024          if (dt%lpawu(itypat)/=-1.and.dt%lpawu(itypat)/=maxval(dt%lpawu(:))) then
3025            write(message, '(3a)' )&
3026 &           'When usedmatpu/=0 (use of an initial density matrix for LDA+U),',ch10,&
3027 &           'lpawu must be equal for all types of atoms on which +U is applied !'
3028            MSG_ERROR_NOSTOP(message,ierr)
3029          end if
3030        end do
3031      end if
3032    end if
3033 
3034 !  usedmft
3035    if (dt%usedmft>0) then
3036      cond_string(1)='usedmft' ; cond_values(1)=1
3037      call chkint_eq(0,1,cond_string,cond_values,ierr,'usedmft',dt%usedmft,2,(/0,1/),iout)
3038      if (dt%paral_kgb>0) then
3039        cond_string(1)='usedmft' ; cond_values(1)=dt%usedmft
3040        call chkint_eq(1,1,cond_string,cond_values,ierr,'npspinor',dt%npspinor,1,(/1/),iout)
3041      end if
3042 !    call chkint_eq(1,1,cond_string,cond_values,ierr,'paral_kgb',dt%paral_kgb,1,(/0/),iout)
3043    end if
3044 
3045 !  useexexch and lexexch
3046 !  Local exact-exchange and restrictions
3047    if(dt%useexexch/=0)then
3048      cond_string(1)='useexexch' ; cond_values(1)=dt%useexexch
3049      call chkint_eq(1,1,cond_string,cond_values,ierr,'useexexch',dt%useexexch,1,(/1/),iout)
3050      cond_string(1)='useexexch' ; cond_values(1)=dt%useexexch
3051      call chkint_eq(1,1,cond_string,cond_values,ierr,'usepaw',usepaw,1,(/1/),iout)
3052      cond_string(1)='useexexch' ; cond_values(1)=dt%useexexch
3053      call chkint_eq(1,1,cond_string,cond_values,ierr,'pawxcdev',dt%pawxcdev,2,(/1,2/),iout)
3054      cond_string(1)='useexexch' ; cond_values(1)=dt%useexexch
3055      call chkint_eq(1,1,cond_string,cond_values,ierr,'ixc',dt%ixc,2,(/11,23/),iout)
3056      do itypat=1,dt%ntypat
3057        cond_string(1)='lexexch' ; cond_values(1)=dt%lexexch(itypat)
3058        call chkint_eq(1,1,cond_string,cond_values,ierr,'lexexch',dt%lexexch(itypat),5,(/-1,0,1,2,3/),iout)
3059      end do
3060    end if
3061 
3062 !  usekden
3063    call chkint_eq(0,0,cond_string,cond_values,ierr,'usekden',dt%usekden,2,(/0,1/),iout)
3064    if(dt%usekden==0)then
3065      cond_string(1)='usekden' ; cond_values(1)=dt%usekden
3066      call chkint_eq(1,1,cond_string,cond_values,ierr,'prtkden',dt%prtkden,1,(/0/),iout)
3067      if(mgga==1)then
3068        write(message, '(3a)' )&
3069 &       'The functional is a MGGA, but the kinetic energy density',ch10, &
3070 &       'is not present. Please set "usekden 1" in the input file.'
3071        MSG_ERROR(message)
3072      end if
3073    else if(dt%usekden/=0)then
3074      cond_string(1)='usekden' ; cond_values(1)=dt%usekden
3075      call chkint_eq(1,1,cond_string,cond_values,ierr,'usewvl',usewvl,1,(/0/),iout)
3076      cond_string(1)='usekden' ; cond_values(1)=dt%usekden
3077      call chkint_eq(1,1,cond_string,cond_values,ierr,'usepaw',usepaw,1,(/0/),iout)
3078      cond_string(1)='usekden' ; cond_values(1)=dt%usekden
3079      call chkint_eq(1,1,cond_string,cond_values,ierr,'intxc',dt%intxc,1,(/0/),iout)
3080      do ipsp=1,npsp
3081 !      Check that xccc is zero (metaGGAs cannot be used at present with non-linear core corrections)
3082        if ( pspheads(ipsp)%xccc/=0 ) then
3083          write(message, '(3a,i0,3a)' )&
3084 &         'When usekden is non-zero, it is not possible to use pseudopotentials with a non-linear core correction.',ch10,&
3085 &         'However, for pseudopotential number ',ipsp,', there is such a core correction.',ch10,&
3086 &         'Action: either set usekden=0 in input file, or change this pseudopotential file.'
3087          MSG_ERROR_NOSTOP(message, ierr)
3088        end if
3089      end do
3090    end if
3091 
3092 !  usepawu and lpawu
3093 !  PAW+U and restrictions
3094    call chkint_eq(0,0,cond_string,cond_values,ierr,'usepawu',dt%usepawu,9,(/0,1,2,3,4,5,6,10,14/),iout)
3095    if(dt%usepawu/=0)then
3096      cond_string(1)='usepawu' ; cond_values(1)=dt%usepawu
3097      call chkint_eq(1,1,cond_string,cond_values,ierr,'usepaw',usepaw,1,(/1/),iout)
3098      do itypat=1,dt%ntypat
3099        cond_string(1)='lpawu' ; cond_values(1)=dt%lpawu(itypat)
3100        call chkint_eq(1,1,cond_string,cond_values,ierr,'lpawu',dt%lpawu(itypat),5,(/-1,0,1,2,3/),iout)
3101      end do
3102      if(dt%pawspnorb>0) then
3103        write(message,'(3a)' ) &
3104 &       '  LDA+U+SpinOrbit is still on test ',ch10,&
3105 &       '  (not yet in production)'
3106        MSG_WARNING(message)
3107      end if
3108    end if
3109 
3110 !  useexexch AND usepawu
3111 !  Restriction when use together
3112    if(dt%useexexch>0.and.dt%usepawu>0)then
3113      do itypat=1,dt%ntypat
3114        if (dt%lpawu(itypat)/=dt%lexexch(itypat).and.&
3115 &       dt%lpawu(itypat)/=-1.and.dt%lexexch(itypat)/=-1) then
3116          write(message, '(5a,i2,3a)' )&
3117 &         'When PAW+U (usepawu>0) and local exact-exchange (useexexch>0)',ch10,&
3118 &         'are selected together, they must apply on the same',ch10,&
3119 &         'angular momentum (lpawu/=lexexch forbidden, here for typat=',itypat,') !',ch10,&
3120 &         'Action: correct your input file.'
3121          MSG_ERROR_NOSTOP(message,ierr)
3122        end if
3123      end do
3124    end if
3125 
3126 !  usedmft/usepawu and lpawu
3127 !  Restriction when use together
3128    if(dt%usedmft>0.or.dt%usepawu>0)then
3129      nlpawu=0
3130      do itypat=1,dt%ntypat
3131        if (dt%lpawu(itypat)/=-1) then
3132          nlpawu=nlpawu+1
3133        end if
3134      end do
3135      if(nlpawu==0) then
3136        write(message, '(6a)' )&
3137 &       'When DFT+U or DFT+DMFT is used',ch10,&
3138 &       'at least one value of lpawu should be different from -1',ch10,&
3139 &       'Action: correct your input file.'
3140        MSG_ERROR(message)
3141      end if
3142    end if
3143 
3144 !  usepotzero
3145    if(dt%usepotzero/=0)then
3146      if(dt%iscf<10) then
3147        write(message, '(3a)' )&
3148 &       'usepotzero can only be used with density mixing (not implemented yet)',ch10,&
3149 &       'Action: choose iscf > 10 '
3150        MSG_ERROR_NOSTOP(message,ierr)
3151      end if
3152    end if
3153 
3154 !  usexcnhat
3155    call chkint_eq(0,0,cond_string,cond_values,ierr,'usexcnhat',dt%usexcnhat_orig,3,(/-1,0,1/),iout)
3156 
3157 !  useylm
3158    call chkint_eq(0,0,cond_string,cond_values,ierr,'useylm',dt%useylm,2,(/0,1/),iout)
3159    if (usepaw==1) then
3160      if(usewvl==0) then
3161        write(cond_string(1), "(A)") 'pspcod'
3162        cond_values(1)=7;cond_values(2)=17
3163        call chkint_eq(1,2,cond_string,cond_values,ierr,'useylm',dt%useylm,1,(/1/),iout)
3164      else
3165        write(cond_string(1), "(A)") 'usewvl'
3166        cond_values(1)=1
3167        call chkint_eq(1,1,cond_string,cond_values,ierr,'useylm',dt%useylm,1,(/0/),iout)
3168      end if
3169    end if
3170 
3171 !  use_gpu_cuda
3172    call chkint_eq(0,0,cond_string,cond_values,ierr,'use_gpu_cuda',dt%use_gpu_cuda,2,(/0,1/),iout)
3173    if (dt%use_gpu_cuda==1) then
3174      if (dt%nspinor==2) then
3175        write(message,'(3a)')&
3176 &       'Use of GPU is not allowed when nspinor==2 !',ch10,&
3177 &       'Action: impose use_gpu_cuda=0 in your input file.'
3178        MSG_ERROR_NOSTOP(message, ierr)
3179      end if
3180 !    if (dt%optdriver==RUNL_GSTATE.and.mod(dt%wfoptalg,10)/=4) then
3181 !    write(message,'(6a)') ch10,&
3182 !    &       ' chkinp : ERROR -',ch10,&
3183 !    &       '  When GPU is in use (use_gpu_cuda=1), wfoptalg must be 4 or 14 !',ch10,&
3184 !    &       '  Action: change wfoptalg in your input file.'
3185 !    call wrtout(std_out,message,'COLL')
3186 !    ierr=ierr+1
3187 !    end if
3188      if (dt%useylm==0) then
3189        write(message,'(3a)')&
3190 &       'Use of GPU is not allowed when useylm==0 !',ch10,&
3191 &       'Action: impose uselym=1 in your input file.'
3192        MSG_ERROR_NOSTOP(message, ierr)
3193      end if
3194      if (dt%tfkinfunc>0) then
3195        write(message,'(5a)')&
3196 &       'use_gpu_cuda=1 is not allowed when tfkinfunc>0 !',ch10,&
3197 &       'Action: suppress use_gpu_cuda=0 from your input file',ch10,&
3198 &       '        (GPU will be used but with another mechanism)'
3199        MSG_ERROR_NOSTOP(message, ierr)
3200      end if
3201      if (dt%ngfft(4)/=dt%ngfft(1).or.dt%ngfft(5)/=dt%ngfft(2).or.dt%ngfft(6)/=dt%ngfft(3)) then
3202        write(message,'(3a)')&
3203 &       'When GPU is in use (use_gpu_cuda=1), ngfft(4:6) must be equal to ngfft(1:3) !',ch10,&
3204 &       'Action: suppress ngfft in input file or change it.'
3205        MSG_ERROR_NOSTOP(message, ierr)
3206      end if
3207 #ifndef HAVE_GPU_CUDA
3208      write(message,'(6a)') ch10,&
3209 &     ' invars0: ERROR -',ch10,&
3210 &     '   Input variables use_gpu_cuda is on but abinit hasn''t been built with gpu mode enabled !',ch10,&
3211 &     '   Action: change the input variable use_gpu_cuda or re-compile ABINIT with Cuda enabled.'
3212      call wrtout(std_out,message,'COLL')
3213      ierr=ierr+1
3214 #endif
3215 #ifndef HAVE_GPU_CUDA_DP
3216      write(message,'(10a)') ch10,&
3217 &     ' invars0: ERROR -',ch10,&
3218 &     '   Input variables use_gpu_cuda is on but abinit hasn''t been built',ch10,&
3219 &     '   with gpu mode in DOUBLE PRECISION enabled !',ch10,&
3220 &     '   Action: change the input variable use_gpu_cuda',ch10,&
3221 &     '   or re-compile ABINIT with double precision Cuda enabled.'
3222      call wrtout(std_out,message,'COLL')
3223      ierr=ierr+1
3224 #endif
3225    end if
3226 
3227 !  use_slk
3228    if (dt%paral_kgb==1) then
3229      call chkint_eq(0,0,cond_string,cond_values,ierr,'use_slk',dt%use_slk,2,(/0,1/),iout)
3230    end if
3231 
3232 !  vdw_xc
3233    call chkint_eq(0,1,cond_string,cond_values,ierr,'vdw_xc',dt%vdw_xc,9,(/0,1,2,5,6,7,10,11,14/),iout)
3234    if (dt%usepaw==1.and.(.not.(dt%vdw_xc==0.or.dt%vdw_xc==5.or.dt%vdw_xc==6.or.dt%vdw_xc==7))) then
3235      write(message,'(a,i2,a)')&
3236 &     'vdw_xc=',dt%vdw_xc,' is not yet available with Projector Augmented-Wave (PAW) formalism!'
3237      MSG_ERROR_NOSTOP(message, ierr)
3238    end if
3239 
3240 !  vdw DFT-D2
3241    if (dt%vdw_xc==5.or.dt%vdw_xc==6.or.dt%vdw_xc==7) then
3242 !    Only for GS or RF calculations
3243      if(optdriver/=RUNL_GSTATE.and.optdriver/=RUNL_RESPFN) then
3244        cond_string(1)='vdw_xc' ; cond_values(1)=dt%vdw_xc
3245        call chkint_ne(1,1,cond_string,cond_values,ierr,'optdriver',optdriver,2,(/RUNL_GSTATE,RUNL_RESPFN/),iout)
3246      end if
3247 !    Restriction for DFT-D2
3248      if (dt%vdw_xc==5) then
3249 !    Only with PBE, BP86  or BLYP GGA XC
3250        if(dt%ixc/=11.and.dt%ixc/=-101130.and.dt%ixc/=-130101.and. &
3251 &       dt%ixc/=18.and.dt%ixc/=-106131.and.dt%ixc/=-131106.and. &
3252 &       dt%ixc/=19.and.dt%ixc/=-106132.and.dt%ixc/=-132106.and. &
3253 &       dt%ixc/=-202231.and.dt%ixc/=-231202) then
3254          write(message,'(8a)') ch10,&
3255 &         ' chkinp : ERROR -',ch10,&
3256 &         '  Van der Waals DFT-D2 correction (vdw_xc=5) only available for the following XC functionals:',ch10,&
3257 &         '      GGA-PBE, GGA-BLYP, GGA-BP86, mGGA-TPSS',ch10,&
3258 &         '  Action: change your pseudopotential file.'
3259          call wrtout(std_out,message,'COLL')
3260          ierr=ierr+1
3261        end if
3262 !       Only for the first 5 lines of the periodic table
3263        do itypat=1,dt%ntypat
3264          if (dt%znucl(itypat)<0.or.dt%znucl(itypat)>54) then
3265            write(message,'(4a,f5.1,a)') ch10,&
3266 &           ' chkinp : ERROR -',ch10,&
3267 &           '  Van der Waals DFT-D2 correction (vdw_xc=5) not available for atom type Z=',dt%znucl(itypat),' !'
3268            call wrtout(std_out,message,'COLL')
3269            ierr=ierr+1
3270          end if
3271        end do
3272      end if
3273 !    Restriction for DFT-D3/DFT-D3(BJ)
3274      if (dt%vdw_xc==6.or.dt%vdw_xc==7) then
3275 !    Only with PBE, BP86  or BLYP GGA XC
3276        if(dt%ixc/=11.and.dt%ixc/=-101130.and.dt%ixc/=-130101.and. &
3277 &       dt%ixc/=18.and.dt%ixc/=-106131.and.dt%ixc/=-131106.and. &
3278 &       dt%ixc/=19.and.dt%ixc/=-106132.and.dt%ixc/=-132106.and. &
3279 &       dt%ixc/=-202231.and.dt%ixc/=-231202.and.&
3280 &       dt%ixc/=14.and.dt%ixc/=-102130.and.dt%ixc/=-130102.and. &
3281 &       dt%ixc/=-170.and.dt%ixc/=41.and.dt%ixc/=-406) then
3282          write(message,'(4a,i2,5a)') ch10,&
3283 &         ' chkinp : ERROR -',ch10,&
3284 &         '  Van der Waals DFT-D correction (vdw_xc=',dt%vdw_xc,') only available for the following XC functionals:',ch10,&
3285 &         '      GGA-PBE, GGA-BLYP, GGA-BP86, mGGA-TPSS, GGA-RevPBE, PBE0',ch10,&
3286 &         '  Action: change your pseudopotential file.'
3287          call wrtout(std_out,message,'COLL')
3288          ierr=ierr+1
3289        end if
3290 !       Only up to chemical species 96
3291        do itypat=1,dt%ntypat
3292          if (dt%znucl(itypat)<0.or.dt%znucl(itypat)>96) then
3293            write(message,'(4a,i2,1a,f5.1,a)') ch10,&
3294 &           ' chkinp : ERROR -',ch10,&
3295 &           '  Van der Waals DFT-D correction (vdw_xc=',dt%vdw_xc,') not available for atom type Z=',dt%znucl(itypat),' !'
3296            call wrtout(std_out,message,'COLL')
3297            ierr=ierr+1
3298          end if
3299        end do
3300      end if
3301    end if
3302 
3303 !  wfoptalg
3304 !  Must be greater or equal to 0
3305    call chkint_ge(0,0,cond_string,cond_values,ierr,'wfoptalg',dt%wfoptalg,0,iout)
3306 !  wfoptalg==0,1,4,10 or 14 if PAW
3307    if (usepaw==1) then
3308      write(cond_string(1), "(A)") 'usepaw'
3309      cond_values(1)=1
3310      call chkint_eq(0,1,cond_string,cond_values,ierr,'wfoptalg',dt%wfoptalg,6,(/0,1,4,10,14,114/),iout)
3311    end if
3312 
3313    ! Check if FFT library supports MPI-FFT.
3314    if (dt%npfft > 1 .and..not. fftalg_has_mpi(fftalg)) then
3315      write(message,"(a,i0,a)")"fftalg: ",fftalg," cannot be used in MPI-FFT mode (npfft > 1)"
3316      MSG_ERROR_NOSTOP(message,ierr)
3317    end if
3318 
3319    ! Chebyshev
3320    if(dt%wfoptalg == 1) then
3321      if(dt%nspinor > 1) then
3322        message='Nspinor > 1 not yet compatible with wfoptalg 1'
3323        MSG_ERROR_NOSTOP(message, ierr)
3324      end if
3325      !! TODO obsolete?
3326      if(dt%usefock > 0) then
3327        message='Fock not yet compatible with wfoptalg 1 (use Fock-level parallelism)'
3328        MSG_ERROR_NOSTOP(message, ierr)
3329      end if
3330      if(maxval(abs(dt%istwfk(1:nkpt))) > 2) then
3331        message='Istwfk > 2 not compatible with wfoptalg 1'
3332        MSG_ERROR_NOSTOP(message, ierr)
3333      end if
3334      if(dt%ecutsm > 0) then
3335        message='Ecutsm > 0 not yet compatible with wfoptalg 1'
3336        MSG_ERROR_NOSTOP(message, ierr)
3337      end if
3338      !! TODO check bandpp instead of overwriting it
3339    end if
3340 
3341 !  np_slk
3342    call chkint_ge(0,0,cond_string,cond_values,ierr,'np_slk',dt%np_slk,0,iout)
3343    if (dt%np_slk>0 .and. dt%wfoptalg /= 114 ) then
3344      if(dt%np_slk <= dt%npfft*dt%npband*dt%npspinor .and. MOD(dt%npfft*dt%npband*dt%npspinor, dt%np_slk) /= 0) then
3345        MSG_ERROR_NOSTOP('np_slk must divide npfft*npband*npspinor.',ierr)
3346      end if
3347    end if
3348 !  slk_rankpp
3349    call chkint_ge(0,0,cond_string,cond_values,ierr,'slk_rankpp',dt%slk_rankpp,0,iout)
3350 
3351 
3352 !  wtk
3353 !  Check that no k point weight is < 0:
3354    do ikpt=1,nkpt
3355      if (dt%wtk(ikpt)< -tiny(0.0_dp) ) then
3356        write(message, '(a,i5,a,1p,e12.4,a,a,a)' )&
3357 &       'At k point number',ikpt,'  wtk=',dt%wtk(ikpt),' <0.',ch10,&
3358 &       'Action: check wtk in input file. Each wtk must be >=0.'
3359        MSG_ERROR_NOSTOP(message,ierr)
3360      end if
3361    end do
3362 
3363 !  xc_denpos
3364    call chkdpr(0,0,cond_string,cond_values,ierr,'xc_denpos',dt%xc_denpos,1,tiny(one),iout)
3365 
3366 !  xc_tb09_c
3367    call chkdpr(0,0,cond_string,cond_values,ierr,'xc_tb09_c',dt%xc_tb09_c,1,0.0_dp,iout)
3368 
3369 !  xred
3370 !  Check that two atoms are not on top of each other
3371    do iimage=1,dt%nimage
3372      if(natom>1)then
3373        ABI_ALLOCATE(frac,(3,natom))
3374        do ia=1,natom
3375 !        Map reduced coordinate xred(mu,ia) into [0,1)
3376          frac(1,ia)=dt%xred_orig(1,ia,iimage)-aint(dt%xred_orig(1,ia,iimage))+0.5_dp-sign(0.5_dp,dt%xred_orig(1,ia,iimage))
3377          frac(2,ia)=dt%xred_orig(2,ia,iimage)-aint(dt%xred_orig(2,ia,iimage))+0.5_dp-sign(0.5_dp,dt%xred_orig(2,ia,iimage))
3378          frac(3,ia)=dt%xred_orig(3,ia,iimage)-aint(dt%xred_orig(3,ia,iimage))+0.5_dp-sign(0.5_dp,dt%xred_orig(3,ia,iimage))
3379        end do
3380        do ia=1,natom-1
3381          do ib=ia+1,natom
3382            if( abs(frac(1,ia)-frac(1,ib))<1.0d-6 .and. &
3383 &           abs(frac(2,ia)-frac(2,ib))<1.0d-6 .and. &
3384 &           abs(frac(3,ia)-frac(3,ib))<1.0d-6         ) then
3385              if(iimage>1)then
3386                write(message,'(2a,i5)') ch10,' The following was observed for image=',iimage
3387                call wrtout(iout,message,'COLL')
3388                call wrtout(std_out,message,'COLL')
3389              end if
3390              write(message, '(a,i4,a,i4,a,a,a,a,a,a)' )&
3391 &             'Atoms number',ia,' and',ib,' are located at the same point',' of the unit cell',ch10,&
3392 &             '(periodic images are taken into account).',ch10,&
3393 &             'Action: change the coordinate of one of these atoms in the input file.'
3394              MSG_ERROR_NOSTOP(message,ierr)
3395            end if
3396          end do
3397        end do
3398        ABI_DEALLOCATE(frac)
3399      end if
3400    end do
3401 
3402 !  znucl
3403 !  Check that znucl and znuclpsp agree
3404    do ipsp=1,npsp
3405      if (abs(dt%znucl(ipsp)-pspheads(ipsp)%znuclpsp)> tol12 ) then
3406        write(message, '(a,i0,a,es12.4,a,a,es12.4,2a)' )&
3407 &       'For pseudopotential ',ipsp,'  znucl from user input file= ',dt%znucl(ipsp),ch10,&
3408 &       'while znucl from pseudopotential file=',pspheads(ipsp)%znuclpsp,ch10,&
3409 &       'Action: check znucl in input file, or check psp file. They must agree.'
3410        MSG_ERROR_NOSTOP(message,ierr)
3411      end if
3412    end do
3413 
3414 !  bandFFT
3415    if(dt%paral_kgb==1.and.dt%optdriver==RUNL_GSTATE) then
3416      if (mod(dt%wfoptalg,10) /= 4 .and. dt%wfoptalg /= 1) then
3417        write(message,'(a,i0,a,a,a,a)')&
3418 &       'The value of wfoptalg is found to be ',dt%wfoptalg,ch10,&
3419 &       'This is not allowed in the case of band-FFT parallelization.',ch10,&
3420 &       'Action: put wfoptalg = 4, 14 or 114 in your input file'
3421        MSG_ERROR_NOSTOP(message,ierr)
3422      end if
3423 !    Make sure all nband are equal
3424      if (any(dt%nband(1:nkpt*nsppol) /= maxval(dt%nband(1:nkpt*nsppol)) )) then
3425        write(message,'(a,a,a)')&
3426 &       'The number of bands have to remain constant in the case of band-FFT parallelization.',ch10,&
3427 &       'Action: set all the nbands to the same value in your input file'
3428        MSG_ERROR_NOSTOP(message,ierr)
3429      end if
3430      if(maxval(abs(dt%istwfk(1:nkpt)-1)) > 1)then
3431        write(message,'(5a)' )&
3432 &       'One of the components of istwfk is not equal to 1 or 2.',ch10,&
3433 &       'Time-reversal symmetry is not yet programmed in the case of band-FFT parallelization.',ch10,&
3434 &       'Action: set istwfk to 1 or 2 for all k-points'
3435        MSG_ERROR_NOSTOP(message,ierr)
3436      end if
3437      if (dt%mkmem == 0) then
3438        write(message,'(a,i0,a,a,a,a)')&
3439 &       'The value of mkmem is found to be ',dt%mkmem,ch10,&
3440 &       'An out-of-core solution can''t be used in the case of band-FFT parallelization.',ch10,&
3441 &       'Action: put mkmem = nkpt in your input file'
3442        MSG_ERROR_NOSTOP(message,ierr)
3443      end if
3444    end if
3445 
3446 !  WVL - wavelets checks and limitations
3447    if(dt%usewvl == 1) then
3448      if (dt%wvl_hgrid <= 0) then
3449        write(message,'(a,i0,a,a,a,a)')&
3450 &       'The value of wvl_hgrid is found to be ',dt%wvl_hgrid,ch10,&
3451 &       'This value is mandatory and must be positive.',ch10,&
3452 &       'Action: put wvl_hgrid to a positive value in your input file'
3453        MSG_ERROR_NOSTOP(message,ierr)
3454      end if
3455      if (dt%nsym /= 1 .and. dt%icoulomb == 1) then
3456        write(message,'(a,i0,a,a,a,a)')&
3457 &       'The value of nsym is found to be ',dt%nsym,ch10,&
3458 &       'No symetry operations are allowed for isolated systems.',ch10,&
3459 &       'Action: put nsym = 1 in your input file'
3460        MSG_ERROR_NOSTOP(message,ierr)
3461      end if
3462      if (dt%optstress > 0) then
3463        write(message,'(a,i0,a,a,a,a)')&
3464 &       'The value of optstress is found to be ', dt%optstress, ch10,&
3465 &       'There is no stress computation available with the wavelet code.',ch10,&
3466 &       'Action: put optstress = 0 in your input file'
3467        MSG_ERROR_NOSTOP(message,ierr)
3468      end if
3469      if (usepaw == 1) then
3470        MSG_WARNING('WVL+PAW is under development')
3471      end if
3472      if (dt%nspden > 2) then
3473        write(message,'(a,i0,a,a,a,a)')&
3474 &       'The value of nspden is found to be ', dt%nspden, ch10, &
3475 &       'The wavelet computation is not allowed with non-colinear spin.',ch10,&
3476 &       'Action: put nspden = 1 or 2 in your input file'
3477        MSG_ERROR_NOSTOP(message,ierr)
3478      end if
3479      if (dt%nspden /= dt%nsppol) then
3480        write(message,'(a,i0,a,a,i0,a,a)')&
3481 &       'The value of nspden is found to be ', dt%nspden, ch10, &
3482 &       'and the one of nsppol is found to be ', dt%nsppol, ch10, &
3483 &       'In wavelet computation, nspden and nsppol must be equal.'
3484        MSG_ERROR_NOSTOP(message,ierr)
3485      end if
3486 !    We check the consistency of occupation, empty bands are not allowed.
3487      if (dt%nsppol == 2) then
3488        mband = dt%nelect
3489      else
3490        mband = dt%mband
3491      end if
3492      do iimage=1,dt%nimage
3493        do ii = 1, mband, 1
3494          if (dt%occ_orig(ii,iimage) < tol8 .and. dt%iscf == 0) then
3495            write(message,'(a,f7.4,a,a,a,a,a,a)')&
3496 &           'One value of occ is found to be ', dt%occ_orig(ii,iimage), ch10, &
3497 &           'The direct minimization is not allowed with empty bands.',ch10,&
3498 &           'Action: use occopt = 1 for automatic band filling or', ch10, &
3499 &           'change occ value in your input file'
3500            MSG_ERROR_NOSTOP(message,ierr)
3501          end if
3502        end do
3503      enddo
3504      if (npsp /= dt%ntypat) then
3505        write(message, '(a,a,a,a,I0,a,I0,a,a,a)' ) ch10,&
3506 &       'wvl_wfs_set:  consistency checks failed,', ch10, &
3507 &       'dtset%npsp (', npsp, ') /= dtset%ntypat (', dt%ntypat, ').', ch10, &
3508 &       'No alchemy pseudo are allowed with wavelets.'
3509        MSG_ERROR_NOSTOP(message,ierr)
3510      end if
3511    end if
3512 
3513    ! Test on tolerances (similar tests are performed in scprqt, so keep the two versions in synch)
3514    if (any(optdriver == [RUNL_GSTATE, RUNL_RESPFN])) then
3515      ttolwfr=0 ; ttoldff=0 ; ttoldfe=0 ; ttolvrs=0; ttolrff=0
3516      if(abs(dt%tolwfr)>tiny(zero))ttolwfr=1
3517      if(abs(dt%toldff)>tiny(zero))ttoldff=1
3518      if(abs(dt%tolrff)>tiny(zero))ttolrff=1
3519      if(abs(dt%toldfe)>tiny(zero))ttoldfe=1
3520      if(abs(dt%tolvrs)>tiny(zero))ttolvrs=1
3521 
3522      ! If non-scf calculations, tolwfr must be defined
3523      if(ttolwfr /= 1 .and. ((dt%iscf<0 .and. dt%iscf/=-3) .or. dt%rf2_dkdk/=0 .or. dt%rf2_dkde/=0))then
3524        write(message,'(a,a,a,es14.6,a,a)')&
3525 &       'when iscf <0 and /= -3, or when rf2_dkdk/=0 or rf2_dkde/=0, tolwfr must be strictly',ch10,&
3526 &       'positive, while it is ',dt%tolwfr,ch10,&
3527 &       'Action: change tolwfr in your input file and resubmit the job.'
3528        MSG_ERROR_NOSTOP(message, ierr)
3529      end if
3530      !  toldff only allowed when prtfor==1
3531      !if((ttoldff == 1 .or. ttolrff == 1) .and. dt%prtfor==0 )then
3532      !  MSG_ERROR_NOSTOP('toldff only allowed when prtfor=1!', ierr)
3533      !end if
3534 
3535      ! If SCF calculations, one and only one of these can differ from zero
3536      ! FIXME: this test should be done on input, not during calculation
3537      if(ttolwfr+ttoldff+ttoldfe+ttolvrs+ttolrff /= 1 .and. (dt%iscf>0 .or. dt%iscf==-3))then
3538        write(message,'(6a,es14.6,a,es14.6,a,es14.6,a,es14.6,a,a,es14.6,a,a,a)' )&
3539 &       'For the SCF case, one and only one of the input tolerance criteria ',ch10,&
3540 &       'tolwfr, toldff, tolrff, toldfe or tolvrs ','must differ from zero, while they are',ch10,&
3541 &       'tolwfr=',dt%tolwfr,', toldff=',dt%toldff,', tolrff=',dt%tolrff,', toldfe=',dt%toldfe,ch10,&
3542 &       'and tolvrs=',dt%tolvrs,' .',ch10,&
3543 &       'Action: change your input file and resubmit the job.'
3544        MSG_ERROR_NOSTOP(message, ierr)
3545      end if
3546    end if
3547 
3548 
3549 !  If molecular dynamics or structural optimization is being done
3550 !  (dt%ionmov>0), make sure not all atoms are fixed
3551 !  if (dt%ionmov > 0) then
3552 !  if (natfix == natom) then
3553 !  write(message, '(a,a,a,a,i4,a,i5,a,a,i5,a,a,a,a,a,a)' ) ch10,&
3554 !  &   ' setup1: ERROR -',ch10,&
3555 !  &   '  ionmov is ',dt%ionmov,' and number of fixed atoms is ',natfix,ch10,&
3556 !  &   '  while number of atoms natom is ',natom,'.',ch10,&
3557 !  &   '  Thus all atoms are fixed and option ionmov to move atoms',&
3558 !  &           ' is inconsistent.',ch10,&
3559 !  &   '  Action: change ionmov or natfix and iatfix in input file and resubmit.'
3560 !  call wrtout(std_out,message,"COLL")
3561 !  ierr = ierr + 1
3562 !  end if
3563 !  end if
3564 
3565 !  Should check that the symmetry operations are consistent with iatfixx,
3566 !  iatfixy and iatfixz (diagonal symmetry operations)
3567 
3568 !  Should check values of fftalg
3569 
3570 !  rfasr=2 possible only when electric field response is computed.
3571 
3572 !  Must have nqpt=1 for rfphon=1
3573 
3574 !  ** Here ends the checking section **************************************
3575 
3576    call dtset_free(dt)
3577    ierr_dtset(idtset)=ierr
3578 
3579  end do !  End do loop on idtset
3580 
3581  if (maxval(dtsets(:)%usewvl) > 0) then
3582    write(message,'(4a)') ch10,&
3583 &   ' Comparison between wvl_hgrid and ecut',ch10,&
3584 &   '  real-space mesh | eq. Ec around atoms | eq. Ec further from atoms'
3585    MSG_COMMENT(message)
3586    wvl_hgrid = zero
3587    twvl = .false.
3588    do idtset=1,ndtset_alloc
3589 !    Give an indication to the equivalent ecut corresponding to
3590 !    given hgrid.
3591      if (dtsets(idtset)%usewvl == 1 .and. &
3592 &     wvl_hgrid /= dtsets(idtset)%wvl_hgrid) then
3593        write(message,'(F11.3,A,F16.1,A,F16.1,A)') &
3594 &       dtsets(idtset)%wvl_hgrid, " bohr  |", &
3595 &       two * pi * pi / (dtsets(idtset)%wvl_hgrid ** 2), " Ht  | ", &
3596 &       half * pi * pi / (dtsets(idtset)%wvl_hgrid ** 2), " Ht"
3597        call wrtout(std_out,message,'COLL')
3598        wvl_hgrid = dtsets(idtset)%wvl_hgrid
3599      end if
3600      twvl = twvl .or. (dtsets(idtset)%usewvl == 1 .and. dtsets(idtset)%iomode /= IO_MODE_ETSF)
3601    end do
3602    if (twvl) then
3603      write(message,'(5a)') &
3604 &     'Restart files from wavelets in non ETSF format does not follow', ch10, &
3605 &     'the ABINIT standards.', ch10, &
3606 &     'Put iomode to 3 to use ETSF retart files.'
3607      MSG_WARNING(message)
3608    end if
3609  end if
3610 
3611 !If there was a problem, then stop.
3612  call xmpi_sum(ierr_dtset,xmpi_world,mpierr)
3613  ierr=sum(ierr_dtset(1:ndtset_alloc)/mpi_enregs(1:ndtset_alloc)%nproc)
3614 
3615  if (ierr==1) then
3616    write(message,'(a,i0,3a)')&
3617 &   'Checking consistency of input data against itself gave ',ierr,' inconsistency.',ch10,&
3618 &   'The details of the problem can be found above.'
3619    MSG_ERROR(message)
3620  end if
3621  if (ierr>1) then
3622    write(message,'(a,i0,3a)')&
3623 &   'Checking consistency of input data against itself gave ',ierr,' inconsistencies.',ch10,&
3624 &   'The details of the problems can be found above.'
3625    MSG_ERROR(message)
3626  end if
3627 
3628  ABI_DEALLOCATE(ierr_dtset)
3629 
3630  if (ndtset_alloc /= 1 .and. get_timelimit() > zero) then
3631    MSG_ERROR("--timelimit option cannot be used when ndtset > 1")
3632  end if
3633 
3634  DBG_EXIT("COLL")
3635 
3636 end subroutine chkinp

ABINIT/m_chkinp [ Modules ]

[ Top ] [ Modules ]

NAME

  m_chkinp

FUNCTION

 Check consistency of Abinit input data against itself.

COPYRIGHT

  Copyright (C) 1998-2018 ABINIT group (DCA, XG, GMR, MKV, DRH, MVer)
  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_chkinp
28 
29  use defs_basis
30  use defs_datatypes
31  use defs_abitypes
32  use m_gwdefs
33  use m_abicore
34  use m_errors
35  use m_xmpi
36  use m_xomp
37  use libxc_functionals
38 
39  use m_numeric_tools,  only : iseven
40  use m_symtk,          only : chkgrp, chkorthsy
41  use m_geometry,       only : metric
42  use m_fftcore,        only : fftalg_has_mpi
43  use m_dtset,          only : dtset_copy, dtset_free
44  use m_exit,           only : get_timelimit
45  use m_parser,         only : chkdpr, chkint, chkint_eq, chkint_ge, chkint_le, chkint_ne
46 
47  implicit none
48 
49  private