TABLE OF CONTENTS


ABINIT/invars2 [ Functions ]

[ Top ] [ Functions ]

NAME

 invars2

FUNCTION

 Initialize variables for the ABINIT code, for one particular
 dataset, characterized by jdtset.
 Note: some parameters have already been read in invars0 and invars1,
 and were used to dimension the arrays needed here.

INPUTS

 bravais(11): bravais(1)=iholohedry
              bravais(2)=center
              bravais(3:11)=coordinates of rprim in the axes
               of the conventional bravais lattice (*2 if center/=0)
 iout=unit number for echoed output
 jdtset=number of the dataset looked for
 lenstr=actual length of the string
 mband=maximum number of bands for any k-point
 msym=default maximal number of symmetries
 npsp=number of pseudopotentials
 string*(*)=character string containing all the input data.
  Initialized previously in instrng.
 usepaw= 0 for non paw calculation; =1 for paw calculation
 zionpsp(npsp)=valence charge of each type of atom (coming from the psp files)

OUTPUT

  (see side effects)

SIDE EFFECTS

 Input/Output:
  dtset=<type datafiles_type>contains all input variables,
   some of which are initialized here, while other were already
 All rest of arguments given alphabetically from acell (length scales)
 to wtk (k-point weights), used to control running of the main routine.
 See abinit_help for definitions of these variables.
 These values become defined by being read from string,
 that contains all information from the input file,
 in a compressed, standardized, format
 At the input, they already contain a default value.

NOTES

PARENTS

      invars2m,m_ab7_invars_f90

CHILDREN

      dtset_chkneu,get_auxc_ixc,get_kpt_fullbz,get_xclevel,intagm_img,inkpts
      intagm,invacuum,libxc_functionals_end
      libxc_functionals_get_hybridparams,libxc_functionals_init,matr3inv
      sort_int,timab,wrtout

SOURCE

 249 subroutine invars2(bravais,dtset,iout,jdtset,lenstr,&
 250 & mband,msym,npsp,string,usepaw,zionpsp)
 251 
 252 
 253 !This section has been created automatically by the script Abilint (TD).
 254 !Do not modify the following lines by hand.
 255 #undef ABI_FUNC
 256 #define ABI_FUNC 'invars2'
 257 !End of the abilint section
 258 
 259  implicit none
 260 
 261 !Arguments ------------------------------------
 262 !scalars
 263  integer,intent(in) :: iout,jdtset,lenstr,mband,msym,npsp,usepaw
 264  character(len=*),intent(in) :: string
 265  type(dataset_type),intent(inout) :: dtset
 266 !arrays
 267  integer,intent(in) :: bravais(11)
 268  real(dp),intent(in) :: zionpsp(npsp)
 269 
 270 !Local variables-------------------------------
 271 !scalars
 272  integer :: bantot,berryopt,dmatsize,ndim,getocc
 273  integer :: iat,iatom,iband,ii,iimage,ikpt,intimage,ionmov,isppol,ixc_current
 274  integer :: densfor_pred,ipsp,iscf,isiz,itypat,jj,kptopt,lpawu,marr,natom,nband1,nberry
 275  integer :: niatcon,nimage,nkpt,nkpthf,npspalch,nqpt,nsp,nspinor,nsppol,nsym,ntypalch,ntypat,ntyppure
 276  integer :: occopt,occopt_tmp,response,sumnbl,tfband,tnband,tread,tread_alt,tread_dft,tread_fock,tread_key
 277  integer :: itol, itol_gen, ds_input, ifreq,ncerr !nkpt_fullbz,
 278  real(dp) :: areaxy,charge,fband,kptrlen,nelectjell
 279  real(dp) :: rhoavg,zelect,zval
 280  real(dp) :: toldfe_, tolrff_, toldff_, tolwfr_, tolvrs_
 281  real(dp) :: tolmxde_, tolmxf_
 282  character(len=500) :: message
 283  character(len=fnlen) :: key_value
 284 !arrays
 285  integer :: vacuum(3) !rlatt(3,3),
 286  integer,allocatable :: iatcon(:),natcon(:)
 287  integer,allocatable :: intarr(:) !Dummy arguments for subroutine 'intagm' to parse input file
 288  real(dp) :: tsec(2) !gprimd(3,3),kpt_cart(3),
 289  real(dp),allocatable :: dmatpawu_tmp(:)
 290  real(dp),allocatable :: dprarr(:) !Dummy arguments for subroutine 'intagm' to parse input file
 291  !real(dp),allocatable :: kpt_fullbz(:,:)
 292 
 293 ! *************************************************************************
 294 
 295  call timab(191,1,tsec)
 296 
 297 !Compute the maximum size of arrays intarr and dprarr
 298  natom=dtset%natom
 299  nimage=dtset%nimage
 300  nkpt=dtset%nkpt
 301  nkpthf=dtset%nkpthf
 302  npspalch=dtset%npspalch
 303  nspinor=dtset%nspinor
 304  nsppol=dtset%nsppol
 305  ntypat=dtset%ntypat
 306  ntypalch=dtset%ntypalch
 307  ntyppure=dtset%ntyppure
 308 
 309  dmatsize=0
 310  if (dtset%usepawu>0.and.dtset%usedmatpu/=0) then
 311    do iatom=1,natom
 312      lpawu=dtset%lpawu(dtset%typat(iatom))
 313      if (lpawu/=-1) dmatsize=dmatsize+nsppol*nspinor*(2*lpawu+1)**2
 314    end do
 315  end if
 316 
 317  marr=max(3*natom,&
 318 & nkpt*nsppol*mband,&
 319 & 2*dtset%nkptgw*nsppol,&
 320 & dmatsize,&
 321 & 3*nkpt,&
 322 & npsp,&
 323 & ntypat,&
 324 & 9*msym,&
 325 & 60,100,&
 326 & 3*dtset%nconeq*natom,&
 327 & nimage,&
 328 & 3*dtset%nqptdm,&
 329 & 3*dtset%natsph_extra,&
 330 & dtset%natvshift*nsppol*natom,&
 331 & 3*dtset%nzchempot*ntypat)
 332  ABI_ALLOCATE(intarr,(marr))
 333  ABI_ALLOCATE(dprarr,(marr))
 334 
 335 !----------------------------------------------------------------------------
 336 
 337 !****   Read parameters which set remaining array dimensions ****
 338 
 339 !Note : some parameters have already been read in invars0 and invars1
 340 !Also, some checking is needed here.
 341 
 342 !Read ngfft(1), ngfft(2), and ngfft(3),
 343 !then ngfft(7)=fftalg and ngfft(8)=fftcache.
 344 !Read ngfftdg(1:3)
 345 
 346  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'ngfft',tread,'INT')
 347  if(tread==1) dtset%ngfft(1:3)=intarr(1:3)
 348 
 349  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fftalg',tread,'INT')
 350  if(tread==1) then
 351    dtset%ngfft(7)=intarr(1)
 352    if (usepaw==1) dtset%ngfftdg(7)=intarr(1)
 353  end if
 354 
 355  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fftcache',tread,'INT')
 356 
 357  if(tread==1) then
 358    dtset%ngfft(8)=intarr(1)
 359    if (usepaw==1) dtset%ngfftdg(8)=intarr(1)
 360  end if
 361 
 362  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'ngfftdg',tread,'INT')
 363  if(tread==1) dtset%ngfftdg(1:3)=intarr(1:3)
 364 
 365  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mqgrid',tread,'INT')
 366  if(tread==1) dtset%mqgrid=intarr(1)
 367 
 368  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mqgriddg',tread,'INT')
 369  if(tread==1) dtset%mqgriddg=intarr(1)
 370 
 371 !Make special arrangements to check nband: may be a scalar
 372 !(for occopt=0, 1 or 3, 4, 5, 6, 7, 8) or may be an array (for occopt=2)
 373 
 374  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'occopt',tread,'INT')
 375  if(tread==1) dtset%occopt=intarr(1)
 376  occopt=dtset%occopt
 377 
 378 !check for variables related to genetic algorithm. ga_n_rules has been already read
 379 
 380  if (dtset%imgmov==4) then
 381    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ga_algor',tread,'INT')
 382    if(tread==1) dtset%ga_algor=intarr(1)
 383 
 384    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ga_fitness',tread,'INT')
 385    if(tread==1) dtset%ga_fitness=intarr(1)
 386 
 387    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ga_opt_percent',tread,'ENE')
 388    if(tread==1) dtset%ga_opt_percent=dprarr(1)
 389 
 390    call intagm(dprarr,intarr,jdtset,marr,dtset%ga_n_rules,string(1:lenstr),'ga_rules',tread,'INT')
 391    if(tread==1)then
 392      dtset%ga_rules(1:dtset%ga_n_rules)=intarr(1:dtset%ga_n_rules)
 393      do ii=1,dtset%ga_n_rules
 394        if(dtset%ga_rules(ii)<0)then
 395          write(message, '(a,i4,a)' )&
 396 &         'All values for Genetic rules must be greater than 0.',ch10,&
 397 &         'Action: check the values of ga_rules.'
 398          MSG_ERROR(message)
 399        end if
 400      end do
 401    end if
 402  end if
 403 
 404 
 405  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwcalctyp',tread,'INT')
 406  if(tread==1) dtset%gwcalctyp=intarr(1)
 407 
 408  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwcomp',tread,'INT')
 409  if(tread==1) dtset%gwcomp=intarr(1)
 410 
 411  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwencomp',tread,'ENE')
 412  if(tread==1) dtset%gwencomp=dprarr(1)
 413 
 414  if (usepaw==1) then
 415    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_sigxcore',tread,'INT')
 416    if(tread==1) dtset%gw_sigxcore=intarr(1)
 417  end if
 418 
 419  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwmem',tread,'INT')
 420  if(tread==1) dtset%gwmem=intarr(1)
 421 
 422  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_sctype',tread,'INT')
 423  if(tread==1) dtset%gw_sctype=intarr(1)
 424 
 425  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_nstep',tread,'INT')
 426  if(tread==1) dtset%gw_nstep=intarr(1)
 427 
 428  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_toldfeig',tread,'ENE')
 429  if(tread==1) dtset%gw_toldfeig=dprarr(1)
 430 
 431 
 432  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_stern_kmax',tread,'INT')
 433  if(tread==1) dtset%gwls_stern_kmax=intarr(1)
 434 
 435  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_npt_gauss_quad',tread,'INT')
 436  if(tread==1) dtset%gwls_npt_gauss_quad=intarr(1)
 437 
 438  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_diel_model',tread,'INT')
 439  if(tread==1) dtset%gwls_diel_model=intarr(1)
 440 
 441  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_model_parameter',tread,'ENE')
 442  if(tread==1) dtset%gwls_model_parameter=dprarr(1)
 443 
 444  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_recycle',tread,'INT')
 445  if(tread==1) dtset%gwls_recycle=intarr(1)
 446 
 447  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_print_debug',tread,'INT')
 448  if(tread==1) dtset%gwls_print_debug=intarr(1)
 449 
 450  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_nseeds',tread,'INT')
 451  if(tread==1) dtset%gwls_nseeds=intarr(1)
 452 
 453  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_kmax_complement',tread,'INT')
 454  if(tread==1) dtset%gwls_kmax_complement=intarr(1)
 455 
 456  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_kmax_poles',tread,'INT')
 457  if(tread==1) dtset%gwls_kmax_poles=intarr(1)
 458 
 459  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_kmax_analytic',tread,'INT')
 460  if(tread==1) dtset%gwls_kmax_analytic=intarr(1)
 461 
 462  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_kmax_numeric',tread,'INT')
 463  if(tread==1) dtset%gwls_kmax_numeric=intarr(1)
 464 
 465  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_exchange',tread,'INT')
 466  if(tread==1) dtset%gwls_exchange=intarr(1)
 467 
 468  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_correlation',tread,'INT')
 469  if(tread==1) dtset%gwls_correlation=intarr(1)
 470 
 471  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_band_index',tread,'INT')
 472  if(tread==1) dtset%gwls_band_index=intarr(1)
 473 
 474  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_first_seed',tread,'INT')
 475  if(tread==1) then
 476    dtset%gwls_first_seed=intarr(1)
 477  else
 478    dtset%gwls_first_seed=dtset%gwls_band_index
 479  end if
 480 
 481 
 482  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rhoqpmix',tread,'DPR')
 483  if(tread==1) dtset%rhoqpmix=dprarr(1)
 484 
 485  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nfreqim',tread,'INT')
 486  if(tread==1) dtset%nfreqim=intarr(1)
 487  if (dtset%cd_customnimfrqs/=0) then
 488    write(message, '(a,a,a)' )&
 489 &   'cd_customnimfrqs not equal to zero and not equal to nfreqim',ch10,&
 490 &   'setting nfreqim = cd_customnimfrqs'
 491    MSG_WARNING(message)
 492    dtset%nfreqim = dtset%cd_customnimfrqs
 493  end if
 494 
 495  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'freqim_alpha',tread,'DPR')
 496  if(tread==1) dtset%freqim_alpha=dprarr(1)
 497 
 498  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'freqremin',tread,'ENE')
 499  if(tread==1) dtset%freqremin=dprarr(1)
 500 
 501  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'freqremax',tread,'ENE')
 502  if(tread==1) dtset%freqremax=dprarr(1)
 503 
 504  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nfreqre',tread,'INT')
 505  if(tread==1) dtset%nfreqre=intarr(1)
 506 
 507  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nfreqsp',tread,'INT')
 508  if(tread==1) dtset%nfreqsp=intarr(1)
 509 
 510  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'freqspmax',tread,'ENE')
 511  if(tread==1) dtset%freqspmax=dprarr(1)
 512 
 513  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'freqspmin',tread,'ENE')
 514  if(tread==1) then ! If found, set it
 515    dtset%freqspmin=dprarr(1)
 516  else ! Else give it the value -freqspmax
 517    dtset%freqspmin=-dtset%freqspmax
 518  end if
 519 
 520  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_frqim_inzgrid',tread,'INT')
 521  if(tread==1) dtset%gw_frqim_inzgrid=intarr(1)
 522 
 523  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_frqre_inzgrid',tread,'INT')
 524  if(tread==1) dtset%gw_frqre_inzgrid=intarr(1)
 525 
 526  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_frqre_tangrid',tread,'INT')
 527  if(tread==1) dtset%gw_frqre_tangrid=intarr(1)
 528 
 529  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_invalid_freq',tread,'INT')
 530  if(tread==1) dtset%gw_invalid_freq=intarr(1)
 531 
 532  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_qprange',tread,'INT')
 533  if(tread==1) dtset%gw_qprange=intarr(1)
 534 
 535  if(dtset%cd_customnimfrqs/=0) then
 536    call intagm(dprarr,intarr,jdtset,marr,dtset%cd_customnimfrqs,string(1:lenstr),'cd_imfrqs',tread,'ENE')
 537    if(tread==1) then
 538      dtset%cd_imfrqs(1:dtset%cd_customnimfrqs)=dprarr(1:dtset%cd_customnimfrqs)
 539      do ifreq=1,dtset%cd_customnimfrqs-1
 540        if (dtset%cd_imfrqs(ifreq+1)<dtset%cd_imfrqs(ifreq)) then
 541          write(message, '(a,a,a)' )&
 542 &         'The frequencies specified in cd_imfrqs must be strictly increasing',ch10,&
 543 &         'Action: Correct this in your input file'
 544          MSG_ERROR(message)
 545        end if
 546      end do
 547    end if
 548  end if
 549 
 550  if(dtset%gw_customnfreqsp/=0) then
 551    call intagm(dprarr,intarr,jdtset,marr,dtset%gw_customnfreqsp,string(1:lenstr),'gw_freqsp',tread,'ENE')
 552    if(tread==1) then
 553      dtset%gw_freqsp(1:dtset%gw_customnfreqsp)=dprarr(1:dtset%gw_customnfreqsp)
 554      do ifreq=1,dtset%gw_customnfreqsp-1
 555        if (dtset%gw_freqsp(ifreq+1)<dtset%gw_freqsp(ifreq)) then
 556          write(message, '(a,a,a)' )&
 557 &         'The frequencies specified in gw_freqsp must be strictly increasing',ch10,&
 558 &         'Action: Correct this in your input file'
 559          MSG_ERROR(message)
 560        end if
 561      end do
 562    end if
 563  end if
 564 
 565  if(dtset%gwls_n_proj_freq/=0) then
 566    call intagm(dprarr,intarr,jdtset,marr,dtset%gwls_n_proj_freq,string(1:lenstr),'gwls_list_proj_freq',tread,'ENE')
 567    if(tread==1) then
 568      dtset%gwls_list_proj_freq(1:dtset%gwls_n_proj_freq)=dprarr(1:dtset%gwls_n_proj_freq)
 569    end if
 570  end if
 571 
 572  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cd_full_grid',tread,'INT')
 573  if(tread==1) dtset%cd_full_grid=intarr(1)
 574 
 575  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cd_frqim_method',tread,'INT')
 576  if(tread==1) dtset%cd_frqim_method=intarr(1)
 577 
 578  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cd_halfway_freq',tread,'ENE')
 579  if(tread==1) dtset%cd_halfway_freq=dprarr(1)
 580 
 581  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cd_max_freq',tread,'ENE')
 582  if(tread==1) dtset%cd_max_freq=dprarr(1)
 583 
 584  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'cd_subset_freq',tread,'INT')
 585  if(tread==1) dtset%cd_subset_freq(1:2)=intarr(1:2)
 586 
 587  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwrpacorr',tread,'INT')
 588  if(tread==1) dtset%gwrpacorr=intarr(1)
 589 
 590 !RESPFN integer input variables (needed here to get the value of response)
 591 !Warning : rfddk,rfelfd,rfmagn,rfphon,rfstrs,rfuser,rf2_dkdk and rf2_dkde are also read in invars1
 592  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfasr',tread,'INT')
 593  if(tread==1) dtset%rfasr=intarr(1)
 594 
 595  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'rfatpol',tread,'INT')
 596  if(tread==1) dtset%rfatpol(1:2)=intarr(1:2)
 597 
 598  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'rfdir',tread,'INT')
 599  if(tread==1) dtset%rfdir(1:3)=intarr(1:3)
 600 
 601  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfddk',tread,'INT')
 602  if(tread==1) dtset%rfddk=intarr(1)
 603 
 604  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfelfd',tread,'INT')
 605  if(tread==1) dtset%rfelfd=intarr(1)
 606 
 607  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfmagn',tread,'INT')
 608  if(tread==1) dtset%rfmagn=intarr(1)
 609 
 610  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfmeth',tread,'INT')
 611  if(tread==1) dtset%rfmeth=intarr(1)
 612 
 613  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfphon',tread,'INT')
 614  if(tread==1) dtset%rfphon=intarr(1)
 615 
 616  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfstrs',tread,'INT')
 617  if(tread==1) dtset%rfstrs=intarr(1)
 618 
 619  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfuser',tread,'INT')
 620  if(tread==1) dtset%rfuser=intarr(1)
 621 
 622  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rf2_dkdk',tread,'INT')
 623  if(tread==1) dtset%rf2_dkdk=intarr(1)
 624 
 625  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rf2_dkde',tread,'INT')
 626  if(tread==1) dtset%rf2_dkde=intarr(1)
 627 
 628  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'rf2_pert1_dir',tread,'INT')
 629  if(tread==1) dtset%rf2_pert1_dir(1:3)=intarr(1:3)
 630 
 631  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'rf2_pert2_dir',tread,'INT')
 632  if(tread==1) dtset%rf2_pert2_dir(1:3)=intarr(1:3)
 633 
 634 !Set value of response to 1 and also set rfdir to 1 1 1 if we are doing
 635 !response calculation but rfdir was left at default 0 0 0 value.
 636 !For rf2_dkdk and rf2_dkde, we do the same for rf2_pert1_dir and rf2_pert2_dir
 637  response=0
 638  if(dtset%rfddk/=0 .or. dtset%rf2_dkdk/=0 .or. dtset%rf2_dkde/=0 .or. dtset%rfelfd/=0 .or. &
 639 & dtset%rfphon/=0 .or. dtset%rfstrs/=0 .or. dtset%rfuser/=0 ) then
 640    response=1
 641    if( (dtset%rfdir(1) == 0) .and. &
 642 &   (dtset%rfdir(2) == 0) .and. &
 643 &   (dtset%rfdir(3) == 0) ) dtset%rfdir(1:3) = 1
 644    if (dtset%rf2_dkdk/=0 .or. dtset%rf2_dkde/=0) then
 645      if (sum(abs(dtset%rf2_pert1_dir)) == 0) dtset%rf2_pert1_dir(:) = 1
 646      if (sum(abs(dtset%rf2_pert2_dir)) == 0) dtset%rf2_pert2_dir(:) = 1
 647    end if
 648  end if
 649 
 650  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nonlinear_info',tread,'INT')
 651  if(tread==1) dtset%nonlinear_info=intarr(1)
 652 
 653 !NONLINEAR integer input variables (same definition as for rfarr)
 654 !Presently, rf?asr, rf?meth,rf?strs and rf?thrd are not used
 655 !--Keep the old input variables for backward compatibility
 656  if(dtset%optdriver==RUNL_NONLINEAR) then
 657    tread_key=0
 658 
 659    call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'d3e_pert1_atpol',tread,'INT')
 660    call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'rf1atpol',tread_alt,'INT')
 661    if(tread==1.or.tread_alt==1) dtset%d3e_pert1_atpol(1:2)=intarr(1:2)
 662    if (tread_alt==1) tread_key=1
 663 
 664    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'d3e_pert1_dir',tread,'INT')
 665    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'rf1dir',tread_alt,'INT')
 666    if(tread==1.or.tread_alt==1) dtset%d3e_pert1_dir(1:3)=intarr(1:3)
 667    if (tread_alt==1) tread_key=1
 668 
 669    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert1_elfd',tread,'INT')
 670    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rf1elfd',tread_alt,'INT')
 671    if(tread==1.or.tread_alt==1) dtset%d3e_pert1_elfd=intarr(1)
 672    if (tread_alt==1) tread_key=1
 673 
 674    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert1_phon',tread,'INT')
 675    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rf1phon',tread_alt,'INT')
 676    if(tread==1.or.tread_alt==1) dtset%d3e_pert1_phon=intarr(1)
 677    if (tread_alt==1) tread_key=1
 678 
 679    call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'d3e_pert2_atpol',tread,'INT')
 680    call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'rf2atpol',tread_alt,'INT')
 681    if(tread==1.or.tread_alt==1) dtset%d3e_pert2_atpol(1:2)=intarr(1:2)
 682    if (tread_alt==1) tread_key=1
 683 
 684    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'d3e_pert2_dir',tread,'INT')
 685    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'rf2dir',tread_alt,'INT')
 686    if(tread==1.or.tread_alt==1) dtset%d3e_pert2_dir(1:3)=intarr(1:3)
 687    if (tread_alt==1) tread_key=1
 688 
 689    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert2_elfd',tread,'INT')
 690    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rf2elfd',tread_alt,'INT')
 691    if(tread==1.or.tread_alt==1) dtset%d3e_pert2_elfd=intarr(1)
 692    if (tread_alt==1) tread_key=1
 693 
 694    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert2_phon',tread,'INT')
 695    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rf2phon',tread_alt,'INT')
 696    if(tread==1.or.tread_alt==1) dtset%d3e_pert2_phon=intarr(1)
 697    if (tread_alt==1) tread_key=1
 698 
 699    call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'d3e_pert3_atpol',tread,'INT')
 700    call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'rf3atpol',tread_alt,'INT')
 701    if(tread==1.or.tread_alt==1) dtset%d3e_pert3_atpol(1:2)=intarr(1:2)
 702    if (tread_alt==1) tread_key=1
 703 
 704    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'d3e_pert3_dir',tread,'INT')
 705    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'rf3dir',tread_alt,'INT')
 706    if(tread==1.or.tread_alt==1) dtset%d3e_pert3_dir(1:3)=intarr(1:3)
 707    if (tread_alt==1) tread_key=1
 708 
 709    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert3_elfd',tread,'INT')
 710    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rf3elfd',tread_alt,'INT')
 711    if(tread==1.or.tread_alt==1) dtset%d3e_pert3_elfd=intarr(1)
 712    if (tread_alt==1) tread_key=1
 713 
 714    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'d3e_pert3_phon',tread,'INT')
 715    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rf3phon',tread_alt,'INT')
 716    if(tread==1.or.tread_alt==1) dtset%d3e_pert3_phon=intarr(1)
 717    if (tread_alt==1) tread_key=1
 718 
 719    if (tread_key==1) then
 720      message='The following input keywords are obsolete:'//ch10//&
 721 &     '  rfxatpol, rfxdir, rfxrlfd, rfxphon (with x=1,2,3)'//ch10//&
 722 &     'Action: change to the d3e_pertx_*** input parameters!'
 723      MSG_WARNING(message)
 724    end if
 725 
 726    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'usepead',tread,'INT')
 727    if(tread==1) dtset%usepead=intarr(1)
 728 
 729  end if
 730 
 731  response=0
 732  if(dtset%rfddk/=0 .or. dtset%rfphon/=0 .or. dtset%rfelfd/=0 .or. &
 733 & dtset%rfstrs/=0 .or. dtset%rfuser/=0 .or. &
 734 & dtset%rf2_dkdk/=0 .or. dtset%rf2_dkde/=0 .or. &
 735 & dtset%d3e_pert1_elfd/=0 .or. dtset%d3e_pert1_phon/=0 .or. &
 736 & dtset%d3e_pert2_elfd/=0 .or. dtset%d3e_pert2_phon/=0 .or. &
 737 & dtset%d3e_pert3_elfd/=0 .or. dtset%d3e_pert3_phon/=0 ) response=1
 738 
 739  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prepanl',tread,'INT')
 740  if(tread==1) dtset%prepanl=intarr(1)
 741 
 742  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prepgkk',tread,'INT')
 743  if(tread==1) dtset%prepgkk=intarr(1)
 744 
 745  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'use_nonscf_gkk',tread,'INT')
 746  if(tread==1) dtset%use_nonscf_gkk=intarr(1)
 747 
 748  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'use_gemm_nonlop',tread,'INT')
 749  if(tread==1) dtset%use_gemm_nonlop=intarr(1)
 750 
 751 !real(dp) input variables
 752  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'boxcutmin',tread,'DPR')
 753  if(tread==1) dtset%boxcutmin=dprarr(1)
 754 
 755  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'charge',tread,'DPR')
 756  if(tread==1) dtset%charge=dprarr(1)
 757 
 758  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dosdeltae',tread,'ENE')
 759  if(tread==1) dtset%dosdeltae=dprarr(1)
 760 
 761  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dtion',tread,'DPR')
 762  if(tread==1) dtset%dtion=dprarr(1)
 763 
 764  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ecut',tread,'ENE')
 765  if(tread==1) dtset%ecut=dprarr(1)
 766 
 767  call intagm(dprarr,intarr,jdtset,marr,size(dtset%einterp),string(1:lenstr),'einterp',tread,'DPR')
 768  if(tread==1) dtset%einterp=dprarr(1:size(dtset%einterp))
 769 
 770  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'elph2_imagden',tread,'ENE')
 771  if(tread==1) dtset%elph2_imagden=dprarr(1)
 772 
 773  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'esmear',tread,'ENE')
 774  if(tread==1) dtset%esmear=dprarr(1)
 775 
 776  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fermie_nest',tread,'ENE')
 777  if(tread==1) dtset%fermie_nest=dprarr(1)
 778 
 779  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dfpt_sciss',tread,'ENE')
 780  if(tread==1) dtset%dfpt_sciss=dprarr(1)
 781 
 782  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'tmesh',tread,'DPR')
 783  if(tread==1) dtset%tmesh=dprarr(1:3)
 784  ABI_CHECK(all(dtset%tmesh >= zero), sjoin("Invalid tmesh:", ltoa(dtset%tmesh)))
 785  ABI_CHECK(dtset%tmesh(2) >= dtset%tmesh(1), "tmesh(2) < tmesh(1)")
 786 
 787  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tsmear',tread,'ENE')
 788  if(tread==1) dtset%tsmear=dprarr(1)
 789 
 790  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vis',tread,'DPR')
 791  if(tread==1) dtset%vis=dprarr(1)
 792 
 793  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ecutsm',tread,'ENE')
 794  if(tread==1) dtset%ecutsm=dprarr(1)
 795 
 796  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'exchmix',tread,'DPR')
 797  if(tread==1) dtset%exchmix=dprarr(1)
 798 
 799  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dilatmx',tread,'DPR')
 800  if(tread==1) dtset%dilatmx=dprarr(1)
 801 
 802  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fxcartfactor',tread,'DPR')
 803  if(tread==1) dtset%fxcartfactor=dprarr(1)
 804 
 805  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'strfact',tread,'DPR')
 806  if(tread==1) dtset%strfact=dprarr(1)
 807 
 808  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'effmass_free',tread,'DPR')
 809  if(tread==1) dtset%effmass_free=dprarr(1)
 810 
 811  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'mdtemp',tread,'DPR')
 812  if(tread==1) dtset%mdtemp(1:2)=dprarr(1:2)
 813 
 814 !Recursion input variables
 815 
 816  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tfkinfunc',tread,'INT')
 817  if(tread==1) dtset%tfkinfunc=intarr(1)
 818 
 819  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'recgratio',tread,'INT')
 820  if(tread==1) dtset%recgratio=intarr(1)
 821 
 822  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'recefermi',tread,'ENE')
 823  if(tread==1) dtset%recefermi=dprarr(1)
 824 
 825  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'recnpath',tread,'INT')
 826  if(tread==1) dtset%recnpath=intarr(1)
 827 
 828  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'recnrec',tread,'INT')
 829  if(tread==1) dtset%recnrec=intarr(1)
 830 
 831  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'recrcut',tread,'LEN')
 832  if(tread==1) dtset%recrcut=dprarr(1)
 833 
 834  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'recptrott',tread,'INT')
 835  if(tread==1) dtset%recptrott=intarr(1)
 836 
 837  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rectesteg',tread,'INT')
 838  if(tread==1) dtset%rectesteg=intarr(1)
 839 
 840  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rectolden',tread,'DPR')
 841  if(tread==1) dtset%rectolden=dprarr(1)
 842 
 843 !Constant NPT Molecular Dynamics Input variables
 844  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'noseinert',tread,'DPR')
 845  if(tread==1) dtset%noseinert=dprarr(1)
 846 
 847  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bmass',tread,'DPR')
 848  if(tread==1) dtset%bmass=dprarr(1)
 849 
 850  call intagm(dprarr,intarr,jdtset,marr,dtset%nnos,string(1:lenstr),'qmass',tread,'DPR')
 851  if(tread==1) dtset%qmass(:)=dprarr(1:dtset%nnos)
 852 
 853  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tphysel',tread,'ENE')
 854  if(tread==1) dtset%tphysel=dprarr(1)
 855 
 856  call intagm(dprarr,intarr,jdtset,marr,6,string(1:lenstr),'strtarget',tread,'DPR')
 857  if(tread==1) dtset%strtarget(1:6)=dprarr(1:6)
 858 
 859  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'vcutgeo',tread,'DPR')
 860  if(tread==1) dtset%vcutgeo(1:3)=dprarr(1:3)
 861 
 862  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'friction',tread,'DPR')
 863  if(tread==1) dtset%friction=dprarr(1)
 864 
 865  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mdwall',tread,'LEN')
 866  if(tread==1) dtset%mdwall=dprarr(1)
 867 
 868 
 869 !Path-Integral Molecular Dynamics Input variables
 870  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'adpimd',tread,'INT')
 871  if(tread==1) dtset%adpimd=intarr(1)
 872 
 873  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'adpimd_gamma',tread,'DPR')
 874  if(tread==1) dtset%adpimd_gamma=dprarr(1)
 875 
 876  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pimd_constraint',tread,'INT')
 877  if(tread==1) dtset%pimd_constraint=intarr(1)
 878 
 879  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pitransform',tread,'INT')
 880  if(tread==1) dtset%pitransform=intarr(1)
 881 
 882 !Default for pimass is amu
 883  dtset%pimass(1:ntypat)=dtset%amu_orig(1:ntypat,1)   ! NOTE : initialisation with the first image only. TO BE MODIFIED ....
 884  call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'pimass',tread,'DPR')
 885  if(tread==1) dtset%pimass(1:ntypat)=dprarr(1:ntypat)
 886 
 887  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spinmagntarget',tread,'DPR')
 888  if(tread==1) dtset%spinmagntarget=dprarr(1)
 889 
 890  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eshift',tread,'ENE')
 891  if(tread==1) dtset%eshift=dprarr(1)
 892 
 893  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'boxcenter',tread,'DPR')
 894  if(tread==1) dtset%boxcenter(1:3)=dprarr(1:3)
 895 
 896  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ecuteps',tread,'ENE')
 897  if(tread==1) dtset%ecuteps=dprarr(1)
 898 
 899  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ecutsigx',tread,'ENE')
 900  if(tread==1) dtset%ecutsigx=dprarr(1)
 901 
 902  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ecutwfn',tread,'ENE')
 903  if(tread==1) then
 904    dtset%ecutwfn=dprarr(1)
 905  else
 906    if(dtset%optdriver==RUNL_SCREENING .or. dtset%optdriver==RUNL_SIGMA) dtset%ecutwfn=dtset%ecut
 907  end if
 908  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'omegasimax',tread,'ENE')
 909  if(tread==1) dtset%omegasimax=dprarr(1)
 910 
 911  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'omegasrdmax',tread,'ENE')
 912  if(tread==1) dtset%omegasrdmax=dprarr(1)
 913 
 914  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mbpt_sciss',tread,'ENE')
 915  if(tread==1) dtset%mbpt_sciss=dprarr(1)
 916 
 917  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spbroad',tread,'ENE')
 918  if(tread==1) dtset%spbroad=dprarr(1)
 919 
 920  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'stmbias',tread,'ENE')
 921  if(tread==1) dtset%stmbias=dprarr(1)
 922 
 923  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'awtr',tread,'INT')
 924  if(tread==1) dtset%awtr=intarr(1)
 925 
 926  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'inclvkb',tread,'INT')
 927  if(tread==1) dtset%inclvkb=intarr(1)
 928  if (dtset%inclvkb == 1) then
 929    MSG_ERROR("inclvkb == 1 is not allowed anymore. Choose between 0 and 1.")
 930  end if
 931 
 932  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nomegasf',tread,'INT')
 933  if(tread==1) dtset%nomegasf=intarr(1)
 934 
 935  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spmeth',tread,'INT')
 936  if(tread==1) dtset%spmeth=intarr(1)
 937 
 938  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'symchi',tread,'INT')
 939  if(tread==1) dtset%symchi=intarr(1)
 940 
 941  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getefmas',tread,'INT')
 942  if(tread==1) dtset%getefmas=intarr(1)
 943 
 944  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getscr',tread,'INT')
 945  if(tread==1) dtset%getscr=intarr(1)
 946 
 947  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwgamma',tread,'INT')
 948  if(tread==1) dtset%gwgamma=intarr(1)
 949 
 950  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdefmas',tread,'INT')
 951  if(tread==1) dtset%irdefmas=intarr(1)
 952 
 953  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdsuscep',tread,'INT')
 954  if(tread==1) dtset%irdsuscep=intarr(1)
 955 
 956  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdscr',tread,'INT')
 957  if(tread==1) dtset%irdscr=intarr(1)
 958 
 959  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nomegasi',tread,'INT')
 960  if(tread==1) dtset%nomegasi=intarr(1)
 961 
 962  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ppmodel',tread,'INT')
 963  if(tread==1) dtset%ppmodel=intarr(1)
 964 
 965  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'symsigma',tread,'INT')
 966  if(tread==1) dtset%symsigma=intarr(1)
 967 
 968  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fftgw',tread,'INT')
 969  if(tread==1) dtset%fftgw=intarr(1)
 970 
 971  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getsuscep',tread,'INT')
 972  if(tread==1) dtset%getsuscep=intarr(1)
 973 
 974  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getqps',tread,'INT')
 975  if(tread==1) dtset%getqps=intarr(1)
 976 
 977  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwpara',tread,'INT')
 978  if(tread==1) dtset%gwpara=intarr(1)
 979 
 980  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdqps',tread,'INT')
 981  if(tread==1) dtset%irdqps=intarr(1)
 982 
 983  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ppmfrq',tread,'ENE')
 984  if(tread==1) dtset%ppmfrq=dprarr(1)
 985 
 986  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rcut',tread,'LEN')
 987  if(tread==1) dtset%rcut=dprarr(1)
 988 
 989  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'zcut',tread,'ENE')
 990  if(tread==1) dtset%zcut=dprarr(1)
 991 
 992 !q-points for long wave-length limit.
 993  if (dtset%gw_nqlwl>0) then
 994    call intagm(dprarr,intarr,jdtset,marr,3*dtset%gw_nqlwl,string(1:lenstr),'gw_qlwl',tread,'DPR')
 995    if(tread==1) dtset%gw_qlwl(1:3,1:dtset%gw_nqlwl) = reshape(dprarr(1:3*dtset%gw_nqlwl),(/3,dtset%gw_nqlwl/))
 996  end if
 997 
 998 !@bethe_salpeter
 999 
1000 !integer scalars
1001  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_nstates',tread,'INT')
1002  if(tread==1) dtset%bs_nstates=intarr(1)
1003 
1004  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_algorithm',tread,'INT')
1005  if(tread==1) dtset%bs_algorithm=intarr(1)
1006 
1007  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_haydock_niter',tread,'INT')
1008  if(tread==1) dtset%bs_haydock_niter=intarr(1)
1009 
1010  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_hayd_term',tread,'INT')
1011  if(tread==1) dtset%bs_hayd_term=intarr(1)
1012 
1013  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_exchange_term',tread,'INT')
1014  if(tread==1) dtset%bs_exchange_term=intarr(1)
1015 
1016  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_calctype',tread,'INT')
1017  if(tread==1) dtset%bs_calctype=intarr(1)
1018 
1019  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_coulomb_term',tread,'INT')
1020  if(tread==1) dtset%bs_coulomb_term=intarr(1)
1021 
1022  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_coupling',tread,'INT')
1023  if(tread==1) dtset%bs_coupling=intarr(1)
1024 
1025  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdbseig',tread,'INT')
1026  if(tread==1) dtset%irdbseig=intarr(1)
1027 
1028 !call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdbsr',tread,'INT')
1029 !if(tread==1) dtset%irdbsr=intarr(1)
1030 
1031 !call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdbsc',tread,'INT')
1032 !if(tread==1) dtset%irdbsc=intarr(1)
1033 
1034  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getbseig',tread,'INT')
1035  if(tread==1) dtset%getbseig=intarr(1)
1036 
1037  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getbsreso',tread,'INT')
1038  if(tread==1) dtset%getbsreso=intarr(1)
1039 
1040  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getbscoup',tread,'INT')
1041  if(tread==1) dtset%getbscoup=intarr(1)
1042 
1043  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gethaydock',tread,'INT')
1044  if(tread==1) dtset%gethaydock=intarr(1)
1045 
1046  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_interp_method',tread,'INT')
1047  if(tread==1) dtset%bs_interp_method=intarr(1)
1048 
1049  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_interp_mode',tread,'INT')
1050  if(tread==1) dtset%bs_interp_mode=intarr(1)
1051 
1052  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_interp_prep',tread,'INT')
1053  if(tread==1) dtset%bs_interp_prep=intarr(1)
1054 
1055  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bs_interp_m3_width',tread,'DPR')
1056  if(tread==1) dtset%bs_interp_m3_width=dprarr(1)
1057 
1058 !integer arrays
1059  call intagm(dprarr,intarr,jdtset,marr,dtset%nsppol,string(1:lenstr),'bs_loband',tread,'INT')
1060  if(tread==1) dtset%bs_loband=intarr(1:dtset%nsppol)
1061 
1062  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'bs_interp_kmult',tread,'INT')
1063  if(tread==1) dtset%bs_interp_kmult(1:3) = intarr(1:3)
1064 
1065 !real arrays
1066  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'bs_eh_cutoff',tread,'ENE')
1067  if(tread==1) dtset%bs_eh_cutoff(1:2)=dprarr(1:2)
1068 
1069  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'bs_freq_mesh',tread,'ENE')
1070  if(tread==1) dtset%bs_freq_mesh(1:3)=dprarr(1:3)
1071 
1072  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'bs_haydock_tol',tread,'DPR')
1073  if(tread==1) dtset%bs_haydock_tol=dprarr(1:2)
1074 
1075  ntypalch=dtset%ntypalch
1076  npspalch=dtset%npspalch
1077 
1078 !Compute ziontypat. When the pseudo-atom is pure, simple copy
1079  if(ntyppure>0)then
1080    do itypat=1,ntyppure
1081      dtset%ziontypat(itypat)=zionpsp(itypat)
1082    end do
1083  end if
1084 !When the pseudo-atom is alchemical, must make mixing
1085  if(ntypalch>0)then
1086    do itypat=ntyppure+1,ntypat
1087      dtset%ziontypat(itypat)=zero
1088      do ipsp=ntyppure+1,npsp
1089        dtset%ziontypat(itypat)=dtset%ziontypat(itypat) &
1090 &       +dtset%mixalch_orig(ipsp-ntyppure,itypat-ntyppure,1)*zionpsp(ipsp)
1091      end do
1092    end do
1093  end if
1094 
1095  charge=dtset%charge
1096 
1097  if (occopt==0 .or. occopt==1 .or. (occopt>=3 .and. occopt<=8) ) then
1098 
1099    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nband',tnband,'INT')
1100    if(tnband==1) then
1101      nband1=intarr(1)
1102    else
1103 !    Default value in the metallic case, or in the insulating case
1104      fband=0.5_dp
1105      if(occopt==1)fband=0.125_dp
1106      if((occopt/=1).and.(dtset%accuracy==5.or.dtset%accuracy==6)) fband =0.75_dp
1107      if (dtset%usewvl == 1) fband = zero
1108      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fband',tfband,'DPR')
1109      if(tfband==1)then
1110        fband=dprarr(1)
1111        write(message, '(a,es16.8,a)' )' invars2: read the value of fband=',fband,' from input file.'
1112      else
1113        write(message, '(a,es16.8)' )' invars2: take the default value of fband=',fband
1114      end if
1115      dtset%fband=fband
1116      call wrtout(std_out,message,'COLL')
1117 !    First compute the total valence charge
1118      zval=0.0_dp
1119      do iatom=1,natom
1120        zval=zval+dtset%ziontypat(dtset%typat(iatom))
1121      end do
1122      zelect=zval-charge
1123 !    Then select the minimum number of bands, and add the required number
1124 !    Note that this number might be smaller than the one computed
1125 !    by a slightly different formula in invars1
1126      nband1=dtset%nspinor * ((ceiling(zelect-1.0d-10)+1)/2 + ceiling( fband*natom - 1.0d-10 ))
1127    end if
1128 
1129 !  Set nband to same input number for each k point and spin
1130 !  where nband1 is the eventual input, computed value, or default
1131    do ikpt=1,nkpt*nsppol
1132      dtset%nband(ikpt)=nband1
1133    end do
1134 
1135  else if (occopt==2) then
1136 !  Give nband explicitly for each k point and spin
1137 
1138    call intagm(dprarr,intarr,jdtset,nkpt*nsppol,nkpt*nsppol,string(1:lenstr),'nband',tnband,'INT')
1139    if(tnband==1) dtset%nband(1:nkpt*nsppol)=intarr(1:nkpt*nsppol)
1140 
1141  else
1142    write(message, '(a,i0,3a)' )&
1143 &   'occopt=',occopt,' not allowed.',ch10,&
1144 &   'Action: correct your input file.'
1145    MSG_ERROR(message)
1146  end if
1147 
1148 !----------------------------------------------------------------------------
1149 
1150 !****   Read other parameters  ****
1151 
1152 !All checking should be done in chkinp.f
1153 
1154  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'auxc_scal',tread,'DPR')
1155  if(tread==1) dtset%auxc_scal=dprarr(1)
1156 
1157  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'builtintest',tread,'INT')
1158  if(tread==1) dtset%builtintest=intarr(1)
1159 
1160  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'chkdilatmx',tread,'INT')
1161  if(tread==1) dtset%chkdilatmx=intarr(1)
1162 
1163  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'chksymbreak',tread,'INT')
1164  if(tread==1) dtset%chksymbreak=intarr(1)
1165 
1166  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fockoptmix',tread,'INT')
1167  if(tread==1) dtset%fockoptmix=intarr(1)
1168 
1169 !Get array
1170  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getocc',tread,'INT')
1171  if(tread==1) dtset%getocc=intarr(1)
1172 
1173  getocc=dtset%getocc
1174  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getwfk',tread,'INT')
1175  if(tread==1) dtset%getwfk=intarr(1)
1176 
1177  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getwfkfine',tread,'INT')
1178  if(tread==1) dtset%getwfkfine=intarr(1)
1179 
1180  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getxcart',tread,'INT')
1181  if(tread==1) dtset%getxcart=intarr(1)
1182 
1183  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getxred',tread,'INT')
1184  if(tread==1) dtset%getxred=intarr(1)
1185 
1186  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getddb',tread,'INT')
1187  if(tread==1) dtset%getddb=intarr(1)
1188 
1189  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getden',tread,'INT')
1190  if(tread==1) dtset%getden=intarr(1)
1191 
1192  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getpawden',tread,'INT')
1193  if(tread==1) dtset%getpawden=intarr(1)
1194 
1195  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getcell',tread,'INT')
1196  if(tread==1) dtset%getcell=intarr(1)
1197 
1198  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getgam_eig2nkq',tread,'INT')
1199  if(tread==1) dtset%getgam_eig2nkq=intarr(1)
1200 
1201  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getwfq',tread,'INT')
1202  if(tread==1) dtset%getwfq=intarr(1)
1203 
1204  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'get1wf',tread,'INT')
1205  if(tread==1) dtset%get1wf=intarr(1)
1206 
1207  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getddk',tread,'INT')
1208  if(tread==1) dtset%getddk=intarr(1)
1209 
1210  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getdelfd',tread,'INT')
1211  if(tread==1) dtset%getdelfd=intarr(1)
1212 
1213  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getdkdk',tread,'INT')
1214  if(tread==1) dtset%getdkdk=intarr(1)
1215 
1216  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getdkde',tread,'INT')
1217  if(tread==1) dtset%getdkde=intarr(1)
1218 
1219  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getvel',tread,'INT')
1220  if(tread==1) dtset%getvel=intarr(1)
1221 
1222  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'get1den',tread,'INT')
1223  if(tread==1) dtset%get1den=intarr(1)
1224 
1225  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'iomode',tread,'INT')
1226  if(tread==1) dtset%iomode=intarr(1)
1227 
1228  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'enunit',tread,'INT')
1229  if(tread==1) dtset%enunit=intarr(1)
1230 
1231 ! eph variables
1232  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'asr',tread,'INT')
1233  if(tread==1) dtset%asr=intarr(1)
1234 
1235  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dipdip',tread,'INT')
1236  if(tread==1) dtset%dipdip=intarr(1)
1237 
1238  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'chneut',tread,'INT')
1239  if(tread==1) dtset%chneut=intarr(1)
1240 
1241  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'symdynmat',tread,'INT')
1242  if(tread==1) dtset%symdynmat=intarr(1)
1243 
1244  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_mustar',tread,'DPR')
1245  if(tread==1) dtset%eph_mustar=dprarr(1)
1246 
1247  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_intmeth',tread,'INT')
1248  if(tread==1) dtset%eph_intmeth=intarr(1)
1249 
1250  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_extrael',tread,'DPR')
1251  if(tread==1) dtset%eph_extrael=dprarr(1)
1252 
1253  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_fermie',tread,'ENE')
1254  if(tread==1) dtset%eph_fermie=dprarr(1)
1255 
1256  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_frohlichm',tread,'INT')
1257  if(tread==1) dtset%eph_frohlichm=intarr(1)
1258 
1259  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_fsmear',tread,'ENE')
1260  if(tread==1) dtset%eph_fsmear=dprarr(1)
1261 
1262  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_fsewin',tread,'ENE')
1263  if(tread==1) dtset%eph_fsewin=dprarr(1)
1264 
1265  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'eph_ngqpt_fine',tread,'INT')
1266  if(tread==1) dtset%eph_ngqpt_fine=intarr(1:3)
1267 
1268  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_task',tread,'INT')
1269  if(tread==1) dtset%eph_task=intarr(1)
1270 
1271  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eph_transport',tread,'INT')
1272  if(tread==1) dtset%eph_transport=intarr(1)
1273 
1274  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_wstep',tread,'ENE')
1275  if(tread==1) dtset%ph_wstep=dprarr(1)
1276 
1277  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_intmeth',tread,'INT')
1278  if(tread==1) dtset%ph_intmeth=intarr(1)
1279 
1280  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_smear',tread,'ENE')
1281  if(tread==1) dtset%ph_smear=dprarr(1)
1282 
1283  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'ddb_ngqpt',tread,'INT')
1284  if(tread==1) dtset%ddb_ngqpt=intarr(1:3)
1285 
1286  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'ddb_shiftq',tread,'DPR')
1287  if(tread==1) dtset%ddb_shiftq=dprarr(1:3)
1288 
1289  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_freez_disp_addStrain',tread,'INT')
1290  if(tread==1) dtset%ph_freez_disp_addStrain=intarr(1)
1291 
1292  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_freez_disp_option',tread,'INT')
1293  if(tread==1) dtset%ph_freez_disp_option=intarr(1)
1294 
1295  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_freez_disp_nampl',tread,'INT')
1296  if(tread==1) dtset%ph_freez_disp_nampl=intarr(1)
1297 
1298  if(dtset%ph_freez_disp_nampl > 0)then
1299    ABI_MALLOC(dtset%ph_freez_disp_ampl, (5, dtset%ph_freez_disp_nampl))
1300    ABI_CHECK(5 * dtset%ph_freez_disp_nampl <= marr, "5 * dtset%ph_nampl > marr!")
1301    call intagm(dprarr,intarr,jdtset,marr,5*dtset%ph_freez_disp_nampl,string(1:lenstr),&
1302 &   'ph_freez_disp_ampl',tread,'DPR')
1303    if (tread==0) then
1304      MSG_ERROR("When ph_freez_disp_nampl > 0, ph_freez_disp_ampl should be specified")
1305    end if
1306    dtset%ph_freez_disp_ampl=reshape(dprarr(1:5*dtset%ph_freez_disp_nampl),[5,dtset%ph_freez_disp_nampl])
1307  end if
1308 
1309  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_ndivsm',tread,'INT')
1310  if(tread==1) dtset%ph_ndivsm=intarr(1)
1311 
1312  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_nqpath',tread,'INT')
1313  if(tread==1) dtset%ph_nqpath=intarr(1)
1314 
1315  if (dtset%ph_nqpath > 0) then
1316    ! Read qpath for phonons
1317    ABI_MALLOC(dtset%ph_qpath, (3, dtset%ph_nqpath))
1318    ABI_CHECK(3 * dtset%ph_nqpath <= marr, "3 * dtset%ph_nqpath > marr!")
1319    call intagm(dprarr,intarr,jdtset,marr,3*dtset%ph_nqpath,string(1:lenstr),'ph_qpath',tread,'DPR')
1320    if (tread==0) then
1321      MSG_ERROR("When ph_nqpath > 0, ph_qpath should be specified")
1322    end if
1323    dtset%ph_qpath = reshape(dprarr(1:3*dtset%ph_nqpath), [3, dtset%ph_nqpath])
1324  end if
1325 
1326  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ph_nqshift',tread,'INT')
1327  if(tread==1) dtset%ph_nqshift=intarr(1)
1328 
1329  if (dtset%ph_nqshift > 0) then
1330    ! Read ph_qshift for phonons default is [0,0,0]
1331    ABI_CALLOC(dtset%ph_qshift, (3, dtset%ph_nqshift))
1332    if (tread == 1) then
1333      ABI_CHECK(3 * dtset%ph_nqshift <= marr, "3 * dtset%ph_nqshift > marr!")
1334      call intagm(dprarr,intarr,jdtset,marr,3*dtset%ph_nqshift,string(1:lenstr),'ph_qshift',tread,'DPR')
1335      if (tread == 0) then
1336        MSG_ERROR("When ph_nqshift > 0, ph_qshift should be specified")
1337      end if
1338      dtset%ph_qshift = reshape(dprarr(1:3*dtset%ph_nqshift), [3, dtset%ph_nqshift])
1339    end if
1340  end if
1341 
1342  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'ph_ngqpt',tread,'INT')
1343  if(tread==1) dtset%ph_ngqpt=intarr(1:3)
1344 !end e-ph variables
1345 
1346  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'exchn2n3d',tread,'INT')
1347  if(tread==1) dtset%exchn2n3d=intarr(1)
1348 
1349  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'extrapwf',tread,'INT')
1350  if(tread==1) dtset%extrapwf=intarr(1)
1351 
1352  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'iboxcut',tread,'INT')
1353  if(tread==1) dtset%iboxcut=intarr(1)
1354 
1355  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'icutcoul',tread,'INT')
1356  if(tread==1) dtset%icutcoul=intarr(1)
1357 
1358  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'imgwfstor',tread,'INT')
1359  if(tread==1) dtset%imgwfstor=intarr(1)
1360 
1361  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mdf_epsinf',tread,'DPR')
1362  if(tread==1) dtset%mdf_epsinf=dprarr(1)
1363 
1364  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mem_test',tread,'INT')
1365  if(tread==1) dtset%mem_test=intarr(1)
1366 
1367  if (dtset%imgmov==0.or.dtset%imgmov==2.or.dtset%imgmov==5) then
1368    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mep_mxstep',tread,'LEN')
1369    if(tread==1) then
1370      dtset%mep_mxstep=dprarr(1)
1371    else if(dtset%imgmov==5) then
1372      dtset%mep_mxstep=0.4_dp
1373    end if
1374  end if
1375  if (dtset%imgmov==2.or.dtset%imgmov==5) then
1376    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mep_solver',tread,'INT')
1377    if(tread==1) then
1378      dtset%mep_solver=intarr(1)
1379    else if(dtset%imgmov==2) then
1380      dtset%mep_solver=0
1381    else if(dtset%imgmov==5) then
1382      dtset%mep_solver=0
1383    end if
1384    if (dtset%imgmov==2) then
1385      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'string_algo',tread,'INT')
1386      if(tread==1) dtset%string_algo=intarr(1)
1387    end if
1388    if (dtset%imgmov==5) then
1389      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'neb_algo',tread,'INT')
1390      if(tread==1) dtset%neb_algo=intarr(1)
1391      call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'neb_spring',tread,'DPR')
1392      if(tread==1) then
1393        dtset%neb_spring(1:2)=dprarr(1:2)
1394      else if (dtset%neb_algo==2) then
1395        dtset%neb_spring(1:2)=(/0.02_dp,0.15_dp/)
1396      end if
1397      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cineb_start',tread,'INT')
1398      if(tread==1) dtset%cineb_start=intarr(1)
1399    end if
1400  end if
1401 
1402  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'istatimg',tread,'INT')
1403  if(tread==1) dtset%istatimg=intarr(1)
1404 
1405 !variables for random positions in unit cell
1406  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'random_atpos',tread,'INT')
1407  if(tread==1) dtset%random_atpos=intarr(1)
1408 
1409  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ionmov',tread,'INT')
1410  if(tread==1) dtset%ionmov=intarr(1)
1411 
1412  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'intxc',tread,'INT')
1413  if(tread==1) dtset%intxc=intarr(1)
1414 
1415  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'densfor_pred',tread,'INT')
1416  if(tread==1) then
1417    dtset%densfor_pred=intarr(1)
1418  else
1419    if (dtset%paral_kgb==1) dtset%densfor_pred=6
1420  end if
1421 
1422  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'hmcsst',tread,'INT')
1423  if(tread==1) dtset%hmcsst=intarr(1)
1424 
1425  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'hmctt',tread,'INT')
1426  if(tread==1) dtset%hmctt=intarr(1)
1427 
1428 !--For the moment LOTF does not use different from 2
1429  if(dtset%ionmov==23) then
1430 #ifdef HAVE_LOTF
1431    if(dtset%densfor_pred/=2)then
1432      densfor_pred=2
1433      dtset%densfor_pred=densfor_pred
1434      write(message, '(4a)' )&
1435 &     'When ionmov==23, densfor_pred must be 2.',ch10,&
1436 &     'Set densfor_pred to 2.',ch10
1437      MSG_COMMENT(message)
1438    end if
1439 #else
1440    dtset%ionmov=12
1441    write(message, '(4a)' )&
1442 &   'LOTF is disabled, ionmov can not be 23.',ch10,&
1443 &   'Set ionmov to 12.',ch10
1444    MSG_COMMENT(message)
1445 #endif
1446  end if
1447 
1448  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'iprcel',tread,'INT')
1449  if(tread==1) dtset%iprcel=intarr(1)
1450 
1451  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'iprcfc',tread,'INT')
1452  if(tread==1) dtset%iprcfc=intarr(1)
1453 
1454  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irandom',tread,'INT')
1455  if(tread==1) dtset%irandom=intarr(1)
1456 
1457  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdddb',tread,'INT')
1458  if(tread==1) dtset%irdddb=intarr(1)
1459 
1460  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdden',tread,'INT')
1461  if(tread==1) dtset%irdden=intarr(1)
1462 
1463  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdpawden',tread,'INT')
1464  if(tread==1) dtset%irdpawden=intarr(1)
1465 
1466  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdhaydock',tread,'INT')
1467  if(tread==1) dtset%irdhaydock=intarr(1)
1468 
1469  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdvdw',tread,'INT')
1470  if(tread==1) dtset%irdvdw=intarr(1)
1471 
1472  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdwfk',tread,'INT')
1473  if(tread==1) dtset%irdwfk=intarr(1)
1474 
1475  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdwfkfine',tread,'INT')
1476  if(tread==1) dtset%irdwfkfine=intarr(1)
1477 
1478  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'iscf',tread,'INT')
1479  if(tread==1) then
1480    dtset%iscf=intarr(1)
1481    if (dtset%usewvl==1) then
1482      !wvl_bigdft_comp should be 1 for iscf=0, 0 for iscf>0, except if it is set by the user
1483      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wvl_bigdft_comp',tread,'INT')
1484      if (tread==0.and.dtset%iscf==0) dtset%wvl_bigdft_comp=1
1485      if (tread==0.and.dtset%iscf >0) dtset%wvl_bigdft_comp=0
1486    end if
1487  else if (dtset%optdriver==RUNL_RESPFN.and.dtset%iscf>=10) then
1488    dtset%iscf=dtset%iscf-10
1489  else if (dtset%optdriver==RUNL_GWLS) then
1490    dtset%iscf=-2
1491  end if
1492 
1493  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'isecur',tread,'INT')
1494  if(tread==1) dtset%isecur=intarr(1)
1495 
1496 !Reading ixc must be immediately followed by reading xcname
1497  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ixc',tread,'INT')
1498  if(tread==1) dtset%ixc=intarr(1)
1499  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),"xcname",tread_key,'KEY',key_value=key_value)
1500  if(tread_key==1)then
1501    if(tread==1)then
1502      write(message, '(5a)' )&
1503 &     'ixc and xcname cannot be specified simultaneously',ch10,&
1504 &     'for the same dataset.',ch10,&
1505 &     'Action: check the input file.'
1506      MSG_ERROR(message)
1507    else
1508 !    Note that xcname is a 'key' variable : its value is stored in keyw at output of intagm
1509      if(trim(key_value)=='PW92')dtset%ixc=7
1510      tread=1
1511    end if
1512  end if
1513  ixc_current=dtset%ixc
1514 
1515  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ixcrot',tread,'INT')
1516  if(tread==1) dtset%ixcrot=intarr(1)
1517 
1518 !Read the ixc for an advanced functional
1519 !If present, and relevant (only specific values for gcalctyp), the other internal variable will be adjusted to this other functional)
1520  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ixc_sigma',tread,'INT')
1521  if(tread==1)then
1522    dtset%ixc_sigma=intarr(1)
1523    if( dtset%optdriver==RUNL_SIGMA .and. mod(dtset%gwcalctyp,10)==5)ixc_current=dtset%ixc_sigma
1524  end if
1525 
1526 !Initialize xclevel and usefock
1527  call get_xclevel(ixc_current,dtset%xclevel,dtset%usefock)
1528 
1529  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'auxc_ixc',tread,'INT')
1530  if(tread==1) dtset%auxc_ixc=intarr(1)
1531 !If the default value had been given, possibly switch on the auxc_ixc corresponding to ixc, if the latter is an hybrid
1532  if(dtset%auxc_ixc==0)then
1533    call get_auxc_ixc(dtset%auxc_ixc,ixc_current)
1534  end if
1535 
1536 !Now take care of the parameters for hybrid functionals
1537  if(dtset%usefock==1)then
1538 
1539    if(ixc_current ==40 .or. ixc_current ==41 .or. ixc_current ==42)then
1540      dtset%hyb_mixing_sr=zero
1541      dtset%hyb_range_dft=zero ; dtset%hyb_range_fock=zero
1542      if(ixc_current==40)dtset%hyb_mixing=one
1543      if(ixc_current==41)dtset%hyb_mixing=quarter
1544      if(ixc_current==42)dtset%hyb_mixing=third
1545    else if(ixc_current==-427)then   ! Special case of HSE03
1546      dtset%hyb_mixing=zero  ; dtset%hyb_mixing_sr=quarter
1547      dtset%hyb_range_dft=0.15_dp*two**third  ; dtset%hyb_range_fock=0.15_dp*sqrt(half)
1548    else if (ixc_current<0) then
1549      call libxc_functionals_init(ixc_current,dtset%nspden)
1550      call libxc_functionals_get_hybridparams(hyb_mixing=dtset%hyb_mixing,hyb_mixing_sr=dtset%hyb_mixing_sr,&
1551 &     hyb_range=dtset%hyb_range_dft)
1552      call libxc_functionals_end()
1553      dtset%hyb_range_fock=dtset%hyb_range_dft
1554    end if
1555 
1556 !  Warning : the user-defined parameters for hybrids are by convention stored as negative numbers
1557 !  This trick will allow to echo them, and only them.
1558    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'hyb_mixing',tread,'DPR')
1559    if(tread==1)then
1560      if(dprarr(1)<-tol14)then
1561        write(message, '(5a)' )&
1562 &       ' A negative value for hyb_mixing is not allowed, while at input hyb_mixing=',dprarr(1),ch10,&
1563 &       ' Action: modify hyb_mixing in the input file.'
1564        MSG_ERROR(message)
1565      end if
1566      dtset%hyb_mixing=-dprarr(1) ! Note the minus sign
1567    end if
1568 
1569    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'hyb_mixing_sr',tread,'DPR')
1570    if(tread==1)then
1571      if(dprarr(1)<-tol14)then
1572        write(message, '(5a)' )&
1573 &       ' A negative value for hyb_mixing_sr is not allowed, while at input hyb_mixing_sr=',dprarr(1),ch10,&
1574 &       ' Action: modify hyb_mixing_sr in the input file.'
1575        MSG_ERROR(message)
1576      end if
1577      dtset%hyb_mixing_sr=-dprarr(1) ! Note the minus sign
1578    end if
1579 
1580    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'hyb_range_dft',tread_dft,'DPR')
1581    if(tread_dft==1)then
1582      if(dprarr(1)<-tol14)then
1583        write(message, '(5a)' )&
1584 &       ' A negative value for hyb_range_dft is not allowed, while at input hyb_range_dft=',dprarr(1),ch10,&
1585 &       ' Action: modify hyb_range_dft in the input file.'
1586        MSG_ERROR(message)
1587      end if
1588      dtset%hyb_range_dft=-dprarr(1) ! Note the minus sign
1589    end if
1590 
1591    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'hyb_range_fock',tread_fock,'DPR')
1592    if(tread_fock==1)then
1593      if(dprarr(1)<-tol14)then
1594        write(message, '(5a)' )&
1595 &       ' A negative value for hyb_range_fock is not allowed, while at input hyb_range_fock=',dprarr(1),ch10,&
1596 &       ' Action: modify hyb_range_fock in the input file.'
1597        MSG_ERROR(message)
1598      end if
1599      dtset%hyb_range_fock=-dprarr(1) ! Note the minus sign
1600    end if
1601 
1602    if(tread_fock==1 .and. tread_dft==0)dtset%hyb_range_dft=dtset%hyb_range_fock
1603    if(tread_fock==0 .and. tread_dft==1)dtset%hyb_range_fock=dtset%hyb_range_dft
1604 
1605  end if
1606 
1607  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_acutmin',tread,'DPR')
1608  if(tread==1) dtset%vdw_df_acutmin=dprarr(1)
1609  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_aratio',tread,'DPR')
1610  if(tread==1) dtset%vdw_df_aratio=dprarr(1)
1611  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_damax',tread,'DPR')
1612  if(tread==1) dtset%vdw_df_damax=dprarr(1)
1613  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_damin',tread,'DPR')
1614  if(tread==1) dtset%vdw_df_damin=dprarr(1)
1615  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_dcut',tread,'DPR')
1616  if(tread==1) dtset%vdw_df_dcut=dprarr(1)
1617  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_dratio',tread,'DPR')
1618  if(tread==1) dtset%vdw_df_dratio=dprarr(1)
1619  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_dsoft',tread,'DPR')
1620  if(tread==1) dtset%vdw_df_dsoft=dprarr(1)
1621  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_gcut',tread,'DPR')
1622  if(tread==1) dtset%vdw_df_gcut=dprarr(1)
1623  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_ndpts',tread,'INT')
1624  if(tread==1) dtset%vdw_df_ndpts=intarr(1)
1625  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_ngpts',tread,'INT')
1626  if(tread==1) dtset%vdw_df_ngpts=intarr(1)
1627  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_nqpts',tread,'INT')
1628  if(tread==1) dtset%vdw_df_nqpts=intarr(1)
1629  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_nrpts',tread,'INT')
1630  if(tread==1) dtset%vdw_df_nrpts=intarr(1)
1631  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_nsmooth',tread,'INT')
1632  if(tread==1) dtset%vdw_df_nsmooth=intarr(1)
1633  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_phisoft',tread,'DPR')
1634  if(tread==1) dtset%vdw_df_phisoft=dprarr(1)
1635  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_qcut',tread,'DPR')
1636  if(tread==1) dtset%vdw_df_qcut=dprarr(1)
1637  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_qratio',tread,'DPR')
1638  if(tread==1) dtset%vdw_df_qratio=dprarr(1)
1639  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_rcut',tread,'DPR')
1640  if(tread==1) dtset%vdw_df_rcut=dprarr(1)
1641  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_rsoft',tread,'DPR')
1642  if(tread==1) dtset%vdw_df_rsoft=dprarr(1)
1643  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_tolerance',tread,'DPR')
1644  if(tread==1) dtset%vdw_df_tolerance=dprarr(1)
1645  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_threshold',tread,'DPR',ds_input)
1646  if(tread==1) dtset%vdw_df_threshold=dprarr(1)
1647  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_tweaks',tread,'INT')
1648  if(tread==1) dtset%vdw_df_tweaks=intarr(1)
1649  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_df_zab',tread,'DPR')
1650  if(tread==1) dtset%vdw_df_zab=dprarr(1)
1651  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_xc',tread,'INT')
1652  if(tread==1) dtset%vdw_xc=intarr(1)
1653 
1654  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'posdoppler',tread,'INT')
1655  if(tread==1) dtset%posdoppler=intarr(1)
1656 
1657  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'positron',tread,'INT')
1658  if(tread==1) dtset%positron=intarr(1)
1659 
1660  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ixcpositron',tread,'INT')
1661  if(tread==1) dtset%ixcpositron=intarr(1)
1662 
1663  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'posnstep',tread,'INT')
1664  if(tread==1) dtset%posnstep=intarr(1)
1665 
1666  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'posocc',tread,'DPR')
1667  if(tread==1) dtset%posocc=dprarr(1)
1668 
1669  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'frzfermi',tread,'INT')
1670  if(tread==1) dtset%frzfermi=intarr(1)
1671 
1672  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nqpt',tread,'INT')
1673  if(tread==1) dtset%nqpt=intarr(1)
1674 
1675  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efmas',tread,'INT')
1676  if(tread==1) dtset%efmas=intarr(1)
1677 
1678  if(dtset%efmas>0) then
1679    call intagm(dprarr,intarr,jdtset,marr,2*nkpt,string(1:lenstr),'efmas_bands',tread,'INT')
1680    if(tread==1) then
1681      dtset%efmas_bands(1:2,1:nkpt)=reshape(intarr(1:2*nkpt),(/2,nkpt/))
1682    else
1683      dtset%efmas_bands(1,:)=1
1684      dtset%efmas_bands(2,:)=dtset%nband(:)
1685    end if
1686  end if
1687 
1688  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efmas_deg',tread,'INT')
1689  if(tread==1) dtset%efmas_deg=intarr(1)
1690 
1691  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efmas_deg_tol',tread,'ENE')
1692  if(tread==1) dtset%efmas_deg_tol=dprarr(1)
1693 
1694  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efmas_dim',tread,'INT')
1695  if(tread==1) dtset%efmas_dim=intarr(1)
1696 
1697  if(dtset%efmas_calc_dirs/=0 .and. dtset%efmas_n_dirs>0) then
1698    ndim=2+MERGE(1,0,ABS(dtset%efmas_calc_dirs)<3)
1699    call intagm(dprarr,intarr,jdtset,marr,ndim*dtset%efmas_n_dirs,string(1:lenstr),'efmas_dirs',tread,'DPR')
1700    if(tread==1) then
1701      dtset%efmas_dirs(1:ndim,1:dtset%efmas_n_dirs)=reshape(dprarr(1:ndim*dtset%efmas_n_dirs),(/ndim,dtset%efmas_n_dirs/))
1702    end if
1703  end if
1704 
1705  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efmas_ntheta',tread,'INT')
1706  if(tread==1) dtset%efmas_ntheta=intarr(1)
1707 
1708  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ieig2rf',tread,'INT')
1709  if(tread==1) dtset%ieig2rf=intarr(1)
1710 
1711  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'smdelta',tread,'INT')
1712  if(tread==1) dtset%smdelta=intarr(1)
1713 
1714  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bdeigrf',tread,'INT')
1715  if(tread==1) dtset%bdeigrf=intarr(1)
1716 
1717  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'restartxf',tread,'INT')
1718  if(tread==1) dtset%restartxf=intarr(1)
1719  if (dtset%restartxf == 1) then
1720    MSG_ERROR("restartxf == 1 has been removed in Abinit8. Use 0,-1,-2-3")
1721  end if
1722 
1723  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'optcell',tread,'INT')
1724  if(tread==1) dtset%optcell=intarr(1)
1725 
1726  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdwfq',tread,'INT')
1727  if(tread==1) dtset%irdwfq=intarr(1)
1728 
1729  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ird1den',tread,'INT')
1730  if(tread==1) dtset%ird1den=intarr(1)
1731 
1732  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ird1wf',tread,'INT')
1733  if(tread==1) dtset%ird1wf=intarr(1)
1734 
1735  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdddk',tread,'INT')
1736  if(tread==1) dtset%irdddk=intarr(1)
1737 
1738  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'kptopt',tread,'INT')
1739  if(tread==1) dtset%kptopt=intarr(1)
1740 
1741  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'chkexit',tread,'INT')
1742  if(tread==1) dtset%chkexit=intarr(1)
1743 
1744  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nbdblock',tread,'INT')
1745  if(tread==1) dtset%nbdblock=intarr(1)
1746 
1747  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nbdbuf',tread,'INT')
1748  if(tread==1)then
1749    dtset%nbdbuf=intarr(1)
1750  else
1751    if(response/=1 .and. dtset%iscf<0)dtset%nbdbuf=2*dtset%nspinor
1752    if(response==1 .and. 3<=occopt .and. occopt<=8 )dtset%nbdbuf=2*dtset%nspinor
1753  end if
1754 
1755  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'localrdwf',tread,'INT')
1756  if(tread==1) dtset%localrdwf=intarr(1)
1757 
1758  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'magconon',tread,'INT')
1759  if(tread==1) dtset%magconon=intarr(1)
1760 
1761  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'magcon_lambda',tread,'DPR')
1762  if(tread==1) dtset%magcon_lambda=dprarr(1)
1763 
1764  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'optforces',tread,'INT')
1765  if(tread==1) dtset%optforces=intarr(1)
1766  if(dtset%usedmft>0.and.dtset%optforces/=0) then
1767    write(message, '(3a,i0)' )&
1768 &   'When DFT+DMFT is activated ', ch10, &
1769 &   'optforces must be equal to 0 instead of',dtset%optforces
1770    MSG_ERROR(message)
1771  end if
1772 
1773  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'optstress',tread,'INT')
1774  if(tread==1) dtset%optstress=intarr(1)
1775 
1776  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'optnlxccc',tread,'INT')
1777  if(tread==1) dtset%optnlxccc=intarr(1)
1778 
1779  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nberry',tread,'INT')
1780  if(tread==1) dtset%nberry=intarr(1)
1781 
1782  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nc_xccc_gspace',tread,'INT')
1783  if(tread==1) dtset%nc_xccc_gspace=intarr(1)
1784 
1785  call intagm(dprarr,intarr,jdtset,marr,2*nsppol,string(1:lenstr),'bdberry',tread,'INT')
1786  if(tread==1) then
1787    dtset%bdberry(1)=intarr(1); dtset%bdberry(2)=intarr(2)
1788    if(nsppol==2)then
1789      dtset%bdberry(3)=intarr(3); dtset%bdberry(4)=intarr(4)
1790    end if
1791  end if
1792 
1793  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'berrystep',tread,'INT')
1794  if(tread==1) dtset%berrystep=intarr(1)
1795 
1796  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'delayperm',tread,'INT')
1797  if(tread==1) dtset%delayperm=intarr(1)
1798 
1799  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'signperm',tread,'INT')
1800  if(tread==1) dtset%signperm=intarr(1)
1801 
1802  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nbandkss',tread,'INT')
1803  if(tread==1) dtset%nbandkss=intarr(1)
1804  if ( dtset%usedmft > 0  .and. dtset%nbandkss==0) then
1805    if (dtset%usepawu==4.or.dtset%usepawu==14)  dtset%usepawu=14
1806    if (dtset%usepawu/=4.and.dtset%usepawu/=14) dtset%usepawu=10
1807  end if
1808 
1809  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'npwkss',tread,'INT')
1810  if(tread==1) dtset%npwkss=intarr(1)
1811 
1812  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'kssform',tread,'INT')
1813  if(tread==1) dtset%kssform=intarr(1)
1814 
1815  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_mexcit',tread,'INT')
1816  if(tread==1) dtset%td_mexcit=intarr(1)
1817 
1818  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'npvel',tread,'INT')
1819  if(tread==1) dtset%npvel=intarr(1)
1820 
1821  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'npulayit',tread,'INT')
1822  if(tread==1) dtset%npulayit=intarr(1)
1823 
1824  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'diismemory',tread,'INT')
1825  if(tread==1) dtset%diismemory=intarr(1)
1826 
1827  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'goprecon',tread,'INT')
1828  if(tread==1) dtset%goprecon=intarr(1)
1829 
1830  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'goprecprm',tread,'DPR')
1831  if(tread==1) dtset%goprecprm(1:3)=dprarr(1:3)
1832 
1833  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nwfshist',tread,'INT')
1834  if(tread==1) dtset%nwfshist=intarr(1)
1835 
1836  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'nscforder', tread, 'INT')
1837  if (tread == 1) dtset%nscforder = intarr(1)
1838 
1839  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nomegasrd',tread,'INT')
1840  if(tread==1) dtset%nomegasrd=intarr(1)
1841 
1842  call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'corecs',tread,'DPR')
1843  if(tread==1)then
1844    dtset%corecs(1:ntypat)=dprarr(1:ntypat)
1845  end if
1846 
1847  call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'ptcharge',tread,'DPR')
1848  if(tread==1)then
1849    dtset%ptcharge(1:ntypat)=dprarr(1:ntypat)
1850  end if
1851 
1852  call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'quadmom',tread,'DPR')
1853  if(tread==1)then
1854    dtset%quadmom(1:ntypat)=dprarr(1:ntypat)
1855  end if
1856 
1857  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawcpxocc',tread,'INT')
1858  if(tread==1) then
1859    dtset%pawcpxocc=intarr(1)
1860  else if (dtset%nspinor==2.and.(dtset%usepawu>=1.or.dtset%usedmft>0)) then
1861    dtset%pawcpxocc=2
1862  else if (dtset%pawspnorb>0.and.(dtset%kptopt<=0.or.dtset%kptopt>=3)) then
1863    if (dtset%optdriver/=RUNL_GSTATE.or.dtset%ionmov<6.or.dtset%iscf<10) dtset%pawcpxocc=2
1864  end if
1865 
1866  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawcross',tread,'INT')
1867  if(tread==1) dtset%pawcross=intarr(1)
1868 
1869  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawecutdg',tread,'ENE')
1870  if(tread==1) then
1871    dtset%pawecutdg=dprarr(1)
1872  else if (dtset%accuracy==1.or.dtset%accuracy==2) then
1873    dtset%pawecutdg=dtset%ecut
1874  else if (dtset%accuracy==3.) then
1875    dtset%pawecutdg=1.2_dp*dtset%ecut
1876  else if (dtset%accuracy==4) then
1877    dtset%pawecutdg=1.5_dp*dtset%ecut
1878  else if (dtset%accuracy==5.or.dtset%accuracy==6) then
1879    dtset%pawecutdg=two*dtset%ecut
1880 ! NOT YET ACTIVATED
1881 ! else if (dtset%accuracy==0.and.usepaw==1.and.dtset%usewvl==0) then
1882 !  dtset%pawecutdg=1.5_dp*dtset%ecut
1883  end if
1884  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawlcutd',tread,'INT')
1885  if(tread==1) dtset%pawlcutd=intarr(1)
1886 
1887  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawlmix',tread,'INT')
1888  if(tread==1) dtset%pawlmix=intarr(1)
1889 
1890  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawmixdg',tread,'INT')
1891  if(tread==1) then
1892    dtset%pawmixdg=intarr(1)
1893  else if (dtset%npfft>1.and.usepaw==1) then
1894    dtset%pawmixdg=1
1895  else if (dtset%usewvl==1.and.usepaw==1) then
1896    dtset%pawmixdg=1
1897  end if
1898 
1899  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawnhatxc',tread,'INT')
1900  if(tread==1) dtset%pawnhatxc=intarr(1)
1901 
1902  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawntheta',tread,'INT')
1903  if(tread==1) dtset%pawntheta=intarr(1)
1904 
1905  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawnphi',tread,'INT')
1906  if(tread==1) dtset%pawnphi=intarr(1)
1907 
1908  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawnzlm',tread,'INT')
1909  if(tread==1) dtset%pawnzlm=intarr(1)
1910 
1911  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawoptmix',tread,'INT')
1912  if(tread==1) then
1913    dtset%pawoptmix=intarr(1)
1914  else
1915    if (usepaw==1.and.dtset%iscf<10.and.(dtset%positron==1.or.dtset%positron<0)) dtset%pawoptmix=1
1916  end if
1917 
1918  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawoptosc',tread,'INT')
1919  if(tread==1) dtset%pawoptosc=intarr(1)
1920 
1921  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawovlp',tread,'DPR')
1922  if(tread==1) dtset%pawovlp=dprarr(1)
1923 
1924  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawprtdos',tread,'INT')
1925  if(tread==1) dtset%pawprtdos=intarr(1)
1926 
1927  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawprtvol',tread,'INT')
1928  if(tread==1) dtset%pawprtvol=intarr(1)
1929 
1930  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawprtwf',tread,'INT')
1931  if(tread==1) dtset%pawprtwf=intarr(1)
1932 
1933  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawprt_k',tread,'INT')
1934  if(tread==1) dtset%pawprt_k=intarr(1)
1935 
1936  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawprt_b',tread,'INT')
1937  if(tread==1) dtset%pawprt_b=intarr(1)
1938 
1939  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawstgylm',tread,'INT')
1940  if(tread==1) dtset%pawstgylm=intarr(1)
1941 
1942  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawsushat',tread,'INT')
1943  if(tread==1) dtset%pawsushat=intarr(1)
1944 
1945  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawusecp',tread,'INT')
1946  if(tread==1) dtset%pawusecp=intarr(1)
1947 
1948  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawxcdev',tread,'INT')
1949  if(tread==1) dtset%pawxcdev=intarr(1)
1950 
1951  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spnorbscl',tread,'DPR')
1952  if(tread==1) dtset%spnorbscl=dprarr(1)
1953 
1954  if (dtset%usedmft>0) then
1955    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_dc',tread,'INT')
1956    if(tread==1) dtset%dmft_dc=intarr(1)
1957    if (dtset%usepawu==14.and.dtset%dmft_dc/=5) then
1958      write(message, '(a,a,a)' )&
1959 &     'usepawu==4 and usedmft=1, dmft_dc should be equal to 5  ',ch10,&
1960 &     'impose dmft_dc = 5'
1961      MSG_WARNING(message)
1962      dtset%dmft_dc=5
1963    end if
1964    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_iter',tread,'INT')
1965    if(tread==1) dtset%dmft_iter=intarr(1)
1966    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_mxsf',tread,'DPR')
1967    if(tread==1) dtset%dmft_mxsf=dprarr(1)
1968    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_nwli',tread,'INT')
1969    if(tread==1) dtset%dmft_nwli=intarr(1)
1970    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_nwlo',tread,'INT')
1971    if(tread==1) dtset%dmft_nwlo=intarr(1)
1972    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_read_occnd',tread,'INT')
1973    if(tread==1) dtset%dmft_read_occnd=intarr(1)
1974    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_rslf',tread,'INT')
1975    if(tread==1) dtset%dmft_rslf=intarr(1)
1976    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_solv',tread,'INT')
1977    if(tread==1) dtset%dmft_solv=intarr(1)
1978    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_t2g',tread,'INT')
1979    if(tread==1) dtset%dmft_t2g=intarr(1)
1980    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_tolfreq',tread,'DPR')
1981    if(tread==1) dtset%dmft_tolfreq=dprarr(1)
1982    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_tollc',tread,'DPR')
1983    if(tread==1) dtset%dmft_tollc=dprarr(1)
1984    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftbandi',tread,'INT')
1985    if(tread==1) dtset%dmftbandi=intarr(1)
1986    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftbandf',tread,'INT')
1987    if(tread==1) dtset%dmftbandf=intarr(1)
1988    if((dtset%dmftbandf-dtset%dmftbandi+1)<2*maxval(dtset%lpawu(:))+1.and.(dtset%dmft_t2g==0)) then
1989      write(message, '(4a,i2,2a)' )&
1990      '   dmftbandf-dmftbandi+1)<2*max(lpawu(:))+1)',ch10, &
1991 &     '   Number of bands to construct Wannier functions is not', &
1992 &     ' sufficient to build Wannier functions for l=',maxval(dtset%lpawu(:)),ch10, &
1993 &     '   Action: select a correct number of KS bands with dmftbandi and dmftbandf.'
1994      MSG_ERROR(message)
1995    end if
1996 
1997    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftcheck',tread,'INT')
1998    if(tread==1) dtset%dmftcheck=intarr(1)
1999    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_entropy',tread,'INT')
2000    if(tread==1) dtset%dmft_entropy=intarr(1)
2001    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmft_nlambda',tread,'INT')
2002    if(tread==1) dtset%dmft_nlambda=intarr(1)
2003    if(dtset%dmft_solv>=4) then
2004      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftqmc_n',tread,'DPR')
2005      if(tread==1) then
2006        dtset%dmftqmc_n=dprarr(1)
2007      else if(dtset%ucrpa==0) then
2008      else
2009        write(message, '(5a)' )&
2010 &       'When DFT+DMFT is activated and one of QMC solvers is used,', ch10, &
2011 &       'dmftqmc_n MUST be defined.',ch10,&
2012 &       'Action: add dmftqmc_n keyword in input file.'
2013        MSG_ERROR(message)
2014      end if
2015      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftqmc_l',tread,'INT')
2016      if(tread==1) then
2017        dtset%dmftqmc_l=intarr(1)
2018      else if(dtset%ucrpa==0) then
2019        write(message, '(5a)' )&
2020 &       'When DFT+DMFT is activated and one of QMC solvers is used,', ch10, &
2021 &       'dmftqmc_l MUST be defined.',ch10,&
2022 &       'Action: add dmftqmc_l keyword in input file.'
2023        MSG_ERROR(message)
2024      end if
2025      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftqmc_seed',tread,'INT')
2026      if(tread==1) dtset%dmftqmc_seed=intarr(1)
2027      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftqmc_therm',tread,'INT')
2028      if(tread==1) then
2029        dtset%dmftqmc_therm=intarr(1)
2030      else if(dtset%ucrpa==0) then
2031        write(message, '(5a)' )&
2032 &       'When DFT+DMFT is activated and one of QMC solvers is used,', ch10, &
2033 &       'dmftqmc_therm MUST be defined.',ch10,&
2034 &       'Action: add dmftqmc_therm keyword in input file.'
2035        MSG_ERROR(message)
2036      end if
2037      if(dtset%dmft_solv==5.or.dtset%dmft_solv==8) then
2038     ! if(dtset%dmft_solv==5) then
2039        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_basis',tread,'INT')
2040        if(tread==1) dtset%dmftctqmc_basis  =intarr(1)
2041        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_check',tread,'INT')
2042        if(tread==1) dtset%dmftctqmc_check  =intarr(1)
2043        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_correl',tread,'INT')
2044        if(tread==1) dtset%dmftctqmc_correl =intarr(1)
2045        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_gmove',tread,'INT')
2046        if(tread==1) dtset%dmftctqmc_gmove  =intarr(1)
2047        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_grnns',tread,'INT')
2048        if(tread==1) dtset%dmftctqmc_grnns  =intarr(1)
2049        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_meas',tread,'INT')
2050        if(tread==1) dtset%dmftctqmc_meas   =intarr(1)
2051        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_mrka',tread,'INT')
2052        if(tread==1) dtset%dmftctqmc_mrka   =intarr(1)
2053        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_mov',tread,'INT')
2054        if(tread==1) dtset%dmftctqmc_mov    =intarr(1)
2055        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_order',tread,'INT')
2056        if(tread==1) dtset%dmftctqmc_order  =intarr(1)
2057      end if
2058      if(dtset%dmft_solv>=6.and.dtset%dmft_solv<=7) then
2059        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmftctqmc_triqs_nleg',tread,'INT')
2060        if(tread==1) dtset%dmftctqmc_triqs_nleg  =intarr(1)
2061      end if
2062    end if
2063  end if
2064 
2065  if (dtset%usepawu>0.or.dtset%usedmft>0) then
2066    call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'f4of2_sla',tread,'ENE')
2067    if(tread==1)then
2068      dtset%f4of2_sla(1:ntypat)=dprarr(1:ntypat)
2069    end if
2070    call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'f6of2_sla',tread,'ENE')
2071    if(tread==1)then
2072      dtset%f6of2_sla(1:ntypat)=dprarr(1:ntypat)
2073    end if
2074    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmatpuopt',tread,'INT')
2075    if(tread==1) dtset%dmatpuopt=intarr(1)
2076    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dmatudiag',tread,'INT')
2077    if(tread==1) dtset%dmatudiag=intarr(1)
2078  end if
2079 
2080  if (dtset%macro_uj>0) then
2081    dtset%pawujat=minval(pack((/ (ii,ii=1,dtset%natom) /) ,dtset%lpawu(dtset%typat(:))>0))
2082    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawujat',tread,'INT')
2083    if(tread==1) dtset%pawujat=intarr(1)
2084 
2085    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawujrad',tread,'LEN')
2086    if(tread==1) dtset%pawujrad=dprarr(1)
2087 
2088    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawujv',tread,'ENE')
2089    if(tread==1) dtset%pawujv=dprarr(1)
2090  end if
2091 
2092  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawfatbnd',tread,'INT')
2093  if(tread==1) dtset%pawfatbnd=intarr(1)
2094 
2095  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bxctmindg',tread,'DPR')
2096  if(tread==1) then
2097    dtset%bxctmindg=dprarr(1)
2098  else if(usepaw==1.and.dtset%accuracy==0)then
2099    dtset%bxctmindg=dtset%boxcutmin
2100  end if
2101 
2102  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'usexcnhat',tread,'INT')
2103  if(tread==1) dtset%usexcnhat_orig=intarr(1)
2104 
2105  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'useylm',tread,'INT')
2106  if(tread==1) then
2107    dtset%useylm=intarr(1)
2108    if ((usepaw==1).and.(dtset%useylm==0)) then
2109      write(message, '(a,a,a,a,a)' )&
2110 &     'Pseudopotential file is PAW format (pspcod=7 or 17) while',ch10,&
2111 &     'input variable "useylm" has the incompatible value 0 !',ch10,&
2112 &     'Action: change psp format or "useylm" value in your input file.'
2113      MSG_ERROR(message)
2114    end if
2115    if ((dtset%tfkinfunc==2).and.(dtset%useylm==0)) then
2116      write(message, '(a,a,a,a,a)' )&
2117 &     'You are using recursion method (tfkinfunc=2)  while',ch10,&
2118 &     'input variable "useylm" has the incompatible value 0 !',ch10,&
2119 &     'Action: change  "useylm" value in your input file.'
2120      MSG_ERROR(message)
2121    end if
2122    if ((dtset%efmas==1).and.(dtset%useylm==0)) then
2123      write(message, '(a,a,a,a,a)' )&
2124 &     'The calculation of effective masses requires the input variable, ',ch10,&
2125 &     '"useylm" to be 1, while in your input file, useylm=0',ch10,&
2126 &     'Action: change "useylm" value in your input file.'
2127      MSG_ERROR(message)
2128    end if
2129    if ((dtset%rf2_dkdk/=0).and.(dtset%useylm==0)) then
2130      write(message, '(a,a,a,a,a)' )&
2131 &     'The calculation of 2nd order k perturbation requires the input variable, ',ch10,&
2132 &     '"useylm" to be 1, while in your input file, useylm=0',ch10,&
2133 &     'Action: change "useylm" value in your input file.'
2134      MSG_ERROR(message)
2135    end if
2136    if ((dtset%rf2_dkde/=0).and.(dtset%useylm==0)) then
2137      write(message, '(a,a,a,a,a)' )&
2138 &     'The calculation of the 2nd order k/Efield perturbation requires the input variable, ',ch10,&
2139 &     '"useylm" to be 1, while in your input file, useylm=0',ch10,&
2140 &     'Action: change "useylm" value in your input file.'
2141      MSG_ERROR(message)
2142    end if
2143  end if
2144  if (usepaw==1) dtset%useylm=1
2145  if (usepaw==1 .and. dtset%usewvl==1) then
2146    dtset%useylm=0
2147  end if
2148  if (dtset%efmas==1.or.dtset%use_gpu_cuda==1.or.dtset%rf2_dkdk/=0.or.dtset%rf2_dkde/=0) dtset%useylm=1
2149 
2150  if(dtset%tfkinfunc==2 .and. dtset%usewvl==0 ) then
2151    dtset%useylm=1
2152    dtset%userec=1
2153  end if
2154 
2155  ionmov=dtset%ionmov ; densfor_pred=dtset%densfor_pred ; iscf=dtset%iscf ; nqpt=dtset%nqpt
2156  kptopt=dtset%kptopt; nberry=dtset%nberry ; berryopt=dtset%berryopt
2157 
2158 !Dielectric real(dp) input variables
2159 !Reading of diemix/diemixmag must be inserted after iprcel
2160  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'diecut',tread,'ENE')
2161  if(tread==1) dtset%diecut=dprarr(1)
2162 !Special treatment if iscf==-1
2163  if(iscf==-1) dtset%diecut=four*dtset%ecut
2164  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dielng',tread,'LEN')
2165  if(tread==1) dtset%dielng=dprarr(1)
2166  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'diemac',tread,'DPR')
2167  if(tread==1) dtset%diemac=dprarr(1)
2168 
2169  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'diemix',tread,'DPR')
2170  if(tread==1) then
2171    dtset%diemix=dprarr(1)
2172  else
2173    if (mod(dtset%iprcel,100)>19) dtset%diemix=one
2174  end if
2175 
2176  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'diemixmag',tread,'DPR')
2177  if(tread==1) then
2178    dtset%diemixmag=dprarr(1)
2179  else
2180    if (dtset%iscf<10.or.dtset%nspden==1.or.dtset%iprcel==0.or.(dtset%iprcel>70.and.dtset%iprcel<80)) then
2181      dtset%diemixmag=dtset%diemix
2182    else
2183      dtset%diemixmag=-dtset%diemix
2184    end if
2185  end if
2186 
2187  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'diegap',tread,'ENE')
2188  if(tread==1) dtset%diegap=dprarr(1)
2189 
2190  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dielam',tread,'DPR')
2191  if(tread==1) dtset%dielam=dprarr(1)
2192 
2193  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'maxestep',tread,'DPR')
2194  if(tread==1) dtset%maxestep=dprarr(1)
2195 
2196  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'td_maxene',tread,'DPR')
2197  if(tread==1) dtset%td_maxene=dprarr(1)
2198 
2199  if((iscf==5.or.iscf==6) .and. ionmov==4 .and. densfor_pred/=3 )then
2200    densfor_pred=3
2201    dtset%densfor_pred=densfor_pred
2202    write(message, '(3a)' )&
2203 &   '  When ionmov==4 and iscf==5 or 6, densfor_pred must be 3.',ch10,&
2204 &   '  Set densfor_pred to 3.'
2205    MSG_COMMENT(message)
2206  end if
2207 
2208  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'mffmem',tread,'INT')
2209  if(tread==1) dtset%mffmem=intarr(1)
2210 
2211 !Set default values of 0 for occupation numbers and k pt wts
2212  bantot=0
2213 
2214 !nkpt and nband must be defined to execute following loop
2215  if ( tnband == 1 ) then
2216    do ikpt=1,nkpt*nsppol
2217      do ii=1,dtset%nband(ikpt)
2218        bantot=bantot+1
2219        dtset%occ_orig(bantot,:)=zero
2220      end do
2221    end do
2222  end if
2223 
2224  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nloc_alg',tread,'INT')
2225  if(tread==1) then
2226    dtset%nloalg(1)=intarr(1)
2227  end if
2228 
2229  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nloc_mem',tread,'INT')
2230  if(tread==1) then
2231    dtset%nloalg(2)=1 ; if(intarr(1)<0)dtset%nloalg(2)=-1
2232    dtset%nloalg(3)=abs(intarr(1))-1
2233  end if
2234 
2235 !LOOP variables
2236  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nline',tread,'INT')
2237  if(tread==1) dtset%nline=intarr(1)
2238 
2239  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nnsclo',tread,'INT')
2240  if(tread==1) dtset%nnsclo=intarr(1)
2241 
2242  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nnsclohf',tread,'INT')
2243  if(tread==1) dtset%nnsclohf=intarr(1)
2244 
2245  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nstep',tread,'INT')
2246  if(tread==1) dtset%nstep=intarr(1)
2247 
2248  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ntime',tread,'INT')
2249  if(tread==1) dtset%ntime=intarr(1)
2250 
2251  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nctime',tread,'INT')
2252  if(tread==1) dtset%nctime=intarr(1)
2253 
2254  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'orbmag',tread,'INT')
2255  if(tread==1) dtset%orbmag=intarr(1)
2256 
2257  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ortalg',tread,'INT')
2258  if(tread==1) then
2259    dtset%ortalg=intarr(1)
2260  else if (dtset%wfoptalg>=10 .and. dtset%ortalg>0) then
2261    dtset%ortalg=-dtset%ortalg
2262  end if
2263 
2264 !Print variables
2265  call intagm(dprarr,intarr,jdtset,marr,natom,string(1:lenstr),'prtatlist',tread,'INT')
2266  if(tread==1) then
2267    dtset%prtatlist=intarr(1:natom)
2268    call sort_int(natom,dtset%prtatlist,intarr)
2269  end if
2270 
2271  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtbbb',tread,'INT')
2272  if(tread==1) dtset%prtbbb=intarr(1)
2273 
2274  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtbltztrp',tread,'INT')
2275  if(tread==1) dtset%prtbltztrp=intarr(1)
2276 
2277  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtcif',tread,'INT')
2278  if(tread==1) dtset%prtcif=intarr(1)
2279 
2280  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtden',tread,'INT')
2281  if(tread==1) dtset%prtden=intarr(1)
2282 
2283  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtdipole',tread,'INT')
2284  if(tread==1) dtset%prtdipole=intarr(1)
2285 
2286  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtdos',tread,'INT')
2287  if(tread==1) dtset%prtdos=intarr(1)
2288 
2289  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtdosm',tread,'INT')
2290  if(tread==1) dtset%prtdosm=intarr(1)
2291 
2292  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtebands',tread,'INT')
2293  if(tread==1) dtset%prtebands=intarr(1)
2294 
2295  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtefg',tread,'INT')
2296  if(tread==1) dtset%prtefg=intarr(1)
2297 
2298  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtefmas',tread,'INT')
2299  if(tread==1) dtset%prtefmas=intarr(1)
2300 
2301  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prteig',tread,'INT')
2302  if(tread==1) dtset%prteig=intarr(1)
2303 
2304  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtelf',tread,'INT')
2305  if(tread==1) dtset%prtelf=intarr(1)
2306 
2307  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtfc',tread,'INT')
2308  if(tread==1) dtset%prtfc=intarr(1)
2309 
2310  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtfull1wf',tread,'INT')
2311  if(tread==1) dtset%prtfull1wf=intarr(1)
2312 
2313  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtfsurf',tread,'INT')
2314  if(tread==1) dtset%prtfsurf=intarr(1)
2315 
2316  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtgsr',tread,'INT')
2317  if(tread==1) dtset%prtgsr=intarr(1)
2318 
2319  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtgden',tread,'INT')
2320  if(tread==1) dtset%prtgden=intarr(1)
2321 
2322  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtgeo',tread,'INT')
2323  if(tread==1) dtset%prtgeo=intarr(1)
2324 
2325  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtgkk',tread,'INT')
2326  if(tread==1) dtset%prtgkk=intarr(1)
2327 
2328  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtkden',tread,'INT')
2329  if(tread==1) dtset%prtkden=intarr(1)
2330 
2331  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtlden',tread,'INT')
2332  if(tread==1) dtset%prtlden=intarr(1)
2333 
2334  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtnabla',tread,'INT')
2335  if(tread==1) dtset%prtnabla=intarr(1)
2336 
2337  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtnest',tread,'INT')
2338  if(tread==1) dtset%prtnest=intarr(1)
2339 
2340  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtphbands',tread,'INT')
2341  if(tread==1) dtset%prtphbands=intarr(1)
2342 
2343  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtphdos',tread,'INT')
2344  if(tread==1) dtset%prtphdos=intarr(1)
2345 
2346  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtphsurf',tread,'INT')
2347  if(tread==1) dtset%prtphsurf=intarr(1)
2348 
2349  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtposcar',tread,'INT')
2350  if(tread==1) dtset%prtposcar=intarr(1)
2351 
2352  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtpot',tread,'INT')
2353  if(tread==1) dtset%prtpot=intarr(1)
2354 
2355  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtpsps',tread,'INT')
2356  if(tread==1) dtset%prtpsps=intarr(1)
2357 
2358  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtspcur',tread,'INT')
2359  if(tread==1) dtset%prtspcur=intarr(1)
2360 
2361  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtsuscep',tread,'INT')
2362  if(tread==1) dtset%prtsuscep=intarr(1)
2363 
2364  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtstm',tread,'INT')
2365  if(tread==1) dtset%prtstm=intarr(1)
2366 
2367  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prt1dm',tread,'INT')
2368  if(tread==1) dtset%prt1dm=intarr(1)
2369 
2370  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvclmb',tread,'INT')
2371  if(tread==1) dtset%prtvclmb=intarr(1)
2372 
2373  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvdw',tread,'INT')
2374  if(tread==1) dtset%prtvdw=intarr(1)
2375 
2376  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvha',tread,'INT')
2377  if(tread==1) dtset%prtvha=intarr(1)
2378 
2379  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvhxc',tread,'INT')
2380  if(tread==1) dtset%prtvhxc=intarr(1)
2381 
2382  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtkbff',tread,'INT')
2383  if(tread==1) dtset%prtkbff=intarr(1)
2384 
2385  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvol',tread,'INT')
2386  if(tread==1) dtset%prtvol=intarr(1)
2387 
2388  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvolimg',tread,'INT')
2389  if(tread==1) dtset%prtvolimg=intarr(1)
2390 
2391  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvpsp',tread,'INT')
2392  if(tread==1) dtset%prtvpsp=intarr(1)
2393 
2394  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtvxc',tread,'INT')
2395  if(tread==1) dtset%prtvxc=intarr(1)
2396 
2397  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtwant',tread,'INT')
2398  if(tread==1) dtset%prtwant=intarr(1)
2399 
2400  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtwf',tread,'INT')
2401  if(tread==1) then
2402    dtset%prtwf=intarr(1)
2403    if ((dtset%tfkinfunc==2).and.(dtset%prtwf==1)) then
2404      write(message, '(a,a,a,a,a)' )&
2405 &     'You are using recursion method (tfkinfunc=2)  while',ch10,&
2406 &     'input variable "prtwf" has the incompatible value 1 !',ch10,&
2407 &     'Action: change  "prtwf=0" value in your input file.'
2408      MSG_ERROR(message)
2409    end if
2410  end if
2411  if (dtset%tfkinfunc==2) dtset%prtwf=0
2412 
2413  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtwf_full',tread,'INT')
2414  if (tread==1) dtset%prtwf_full=intarr(1)
2415 
2416  if (dtset%prtwf_full == 1 .and. dtset%prtwf == 0) then
2417    write(message, '(3a)' )&
2418    'You are using prtwf_full=1 while prtwf=0',ch10,&
2419    'Action: set "prtwf=0" in your input file.'
2420    MSG_ERROR(message)
2421  end if
2422 
2423  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtxml',tread,'INT')
2424  if(tread==1) dtset%prtxml=intarr(1)
2425 
2426  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ratsph_extra',tread,'DPR')
2427  if(tread==1) dtset%ratsph_extra=dprarr(1)
2428 
2429  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'qprtrb',tread,'INT')
2430  if(tread==1) dtset%qprtrb(:)=intarr(1:3)
2431 
2432  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'strprecon',tread,'DPR')
2433  if(tread==1) dtset%strprecon=dprarr(1)
2434 
2435  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tim1rev',tread,'INT')
2436  if (tread==1) dtset%tim1rev=intarr(1)
2437 
2438  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'xc_denpos',tread,'DPR')
2439  if(tread==1) dtset%xc_denpos=dprarr(1)
2440 
2441  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'xc_tb09_c',tread,'DPR')
2442  if(tread==1) dtset%xc_tb09_c=dprarr(1)
2443 
2444  call intagm(dprarr,intarr,jdtset,marr,3*dtset%natsph_extra,string(1:lenstr),'xredsph_extra',tread,'DPR')
2445  if(tread==1) dtset%xredsph_extra=reshape(dprarr(1:3*dtset%natsph_extra), (/3,dtset%natsph_extra/))
2446 
2447  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wfmix',tread,'DPR')
2448  if(tread==1) dtset%wfmix=dprarr(1)
2449 
2450 
2451 !WVL - Wavelets related values
2452 
2453  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wvl_hgrid',tread,'DPR')
2454  if(tread==1) dtset%wvl_hgrid=dprarr(1)
2455 
2456  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wvl_crmult',tread,'DPR')
2457  if(tread==1) dtset%wvl_crmult=dprarr(1)
2458 
2459  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wvl_frmult',tread,'DPR')
2460  if(tread==1) dtset%wvl_frmult=dprarr(1)
2461 
2462  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'wvl_ngauss',tread,'INT')
2463  if(tread==1) dtset%wvl_ngauss(1:2)=intarr(1:2)
2464 
2465  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wvl_nprccg',tread,'INT')
2466  if(tread==1) dtset%wvl_nprccg=intarr(1)
2467 
2468  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tl_nprccg',tread,'INT')
2469  if(tread==1) dtset%tl_nprccg=intarr(1)
2470 
2471  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tl_radius',tread,'DPR')
2472  if(tread==1) dtset%tl_radius=dprarr(1)
2473 
2474 !Wannier90 interface related variables
2475  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'w90iniprj',tread,'INT')
2476  if(tread==1) then
2477    dtset%w90iniprj=intarr(1)
2478    if ( usepaw == 0 .and. ( dtset%w90iniprj /= 2  .and. dtset%w90iniprj/=0 .and. dtset%w90iniprj /= 1 )) then
2479      write(message, '(a,i4,2a)' )&
2480 &     'w90iniprj should be set to 0, 1 or 2, however, it was ',dtset%w90iniprj,ch10,&
2481 &     'Action: check the values of w90iniprj.'
2482      MSG_ERROR(message)
2483    end if
2484    if ( usepaw == 1 .and. ( dtset%w90iniprj < 2 .or. dtset%w90iniprj>6 ) &
2485 &   .and. ( dtset%w90iniprj /= 1 .and. dtset%w90iniprj/=0 )) then
2486      write(message, '(a,i4,2a)' )&
2487 &     'In the PAW case, the only valid values for w90iniprj are 0, 1, 2, 5 and 6 however, it was ',dtset%w90iniprj,ch10,&
2488 &     'Action: check the values of w90iniprj.'
2489      MSG_ERROR(message)
2490    end if
2491  end if
2492 !w90prtunk
2493  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'w90prtunk',tread,'INT')
2494  if(tread==1) then
2495    dtset%w90prtunk=intarr(1)
2496    if ( dtset%w90prtunk < 0 ) then
2497      write(message, '(4a)' )&
2498 &     'w90prtunk should be greater or equal to zero, however, it was ',dtset%w90prtunk,ch10,&
2499 &     'Action: check the values of w90prtunk.'
2500      MSG_ERROR(message)
2501    end if
2502  end if
2503 
2504 !Wannier90 - GW quasiparticle interface
2505  if(dtset%prtwant==3) then
2506    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'getqps',tread,'INT')
2507    if(tread==1) dtset%getqps=intarr(1)
2508    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'irdqps',tread,'INT')
2509    if(tread==1) dtset%irdqps=intarr(1)
2510  end if
2511 
2512 !van der Waals with DFT-D approach
2513  if(dtset%vdw_xc==5.or.dtset%vdw_xc==6.or.dtset%vdw_xc==7) then
2514    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_tol',tread,'DPR')
2515    if(tread==1) dtset%vdw_tol=dprarr(1)
2516    if (dtset%vdw_xc==6.or.dtset%vdw_xc==7) then
2517      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_tol_3bt',tread,'DPR')
2518      if(tread==1) dtset%vdw_tol_3bt=dprarr(1)
2519    end if
2520  end if
2521 
2522 !van der Waals with Wannier functions (Silvestrelli's approach versions 1,2 and 3)
2523  if(dtset%vdw_xc==10.or.dtset%vdw_xc==11.or.dtset%vdw_xc==12.or.dtset%vdw_xc==14) then
2524    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'vdw_nfrag',tread,'INT')
2525    if(tread==1)then
2526      dtset%vdw_nfrag=intarr(1)
2527    end if
2528 
2529    call intagm(dprarr,intarr,jdtset,marr,dtset%natom,string(1:lenstr),'vdw_typfrag',tread,'INT')
2530    if(tread==1)then
2531      dtset%vdw_typfrag(1:dtset%natom)=intarr(1:dtset%natom)
2532      do ii=1,dtset%natom
2533        if(dtset%vdw_typfrag(ii)<0)then
2534          write(message, '(a,a,a,i0,a,i0,a,a)' )&
2535 &         'All the components of vdw_typfrag must be greater than 0.',ch10,&
2536 &         'The component',ii,' is equal to ',dtset%vdw_typfrag(ii),ch10,&
2537 &         'Action: check the values of vdw_typfrag.'
2538          MSG_ERROR(message)
2539        end if
2540      end do
2541    end if
2542  end if
2543  if(dtset%vdw_xc==10.or.dtset%vdw_xc==11.or.dtset%vdw_xc==12.or.dtset%vdw_xc==14) then
2544    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'vdw_supercell',tread,'INT')
2545    if(tread==1)then
2546      dtset%vdw_supercell(1:3)=intarr(1:3)
2547      if (dtset%vdw_supercell(1)<zero.and.dtset%vdw_supercell(2)<zero) then
2548        write(message, '(7a)' )&
2549 &       ' only one component of vdw_supercell could be < 0, however, it was ',ch10,&
2550 &       dtset%vdw_supercell(1),dtset%vdw_supercell(2),dtset%vdw_supercell(3),ch10,&
2551 &       'Action: check the components of vdw_supercell.'
2552        MSG_ERROR(message)
2553      end if
2554      if (dtset%vdw_supercell(2)<zero.and.dtset%vdw_supercell(3)<zero) then
2555        write(message, '(7a)' )&
2556 &       'only one component of vdw_supercell could be < 0, however, it was ',ch10,&
2557 &       dtset%vdw_supercell(1),dtset%vdw_supercell(2),dtset%vdw_supercell(3),ch10,&
2558 &       'Action: check the components of vdw_supercell.'
2559        MSG_ERROR(message)
2560      end if
2561      if (dtset%vdw_supercell(1)<zero.and.dtset%vdw_supercell(3)<zero) then
2562        write(message, '(7a)' )&
2563 &       'only one component of vdw_supercell could be < 0, however, it was ',ch10,&
2564 &       dtset%vdw_supercell(1),dtset%vdw_supercell(2),dtset%vdw_supercell(3),ch10,&
2565 &       'Action: check the components of vdw_supercell.'
2566        MSG_ERROR(message)
2567      end if
2568    end if
2569 
2570  end if !vdw_xc==10 or vdw_xc==11 or vdw_xc==12 or vdw_xc==14
2571 
2572  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ucrpa',tread,'INT')
2573  if(tread==1) dtset%ucrpa=intarr(1)
2574 
2575  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'ucrpa_bands',tread_key,'INT')
2576  if(tread_key==1) then
2577    if(dtset%nsym/=1) then
2578      write(message,"(a,i0,3a)")&
2579 &     'Value of nsym different from 1 when ucrpa_bands is used is under test ',dtset%nsym,&
2580 &     ' (because symmetry is not yet used)',ch10,&
2581 &     'Action: check your calculation  with nsym=1'
2582      MSG_WARNING(message)
2583    end if
2584    dtset%ucrpa_bands(1:2)=intarr(1:2)
2585  end if
2586 
2587  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'ucrpa_window',tread,'ENE')
2588  if(tread==1) then
2589    if(dtset%nsym/=1) then
2590      write(message,*)&
2591 &     'Value of nsym different from 1 when ucrpa_windows is used is under test ',dtset%nsym,&
2592 &     ' (because symmetry is not yet used)',ch10,&
2593 &     'Action: check your calculation  with nsym=1'
2594      MSG_WARNING(message)
2595    end if
2596    dtset%ucrpa_window(1:2)=dprarr(1:2)
2597  end if
2598 
2599  if(tread==1.and.tread_key==1) then
2600    write(message, '(a,a,a,a,a)' )&
2601 &   'ucrpa_bands and ucrpa_window cannot be specified simultaneously',ch10,&
2602 &   'for the same dataset.',ch10,&
2603 &   'Action: check the input file.'
2604    MSG_ERROR(message)
2605  end if
2606 
2607 !Tolerance variables
2608  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolimg',tread,'ENE')
2609  if(tread==1) dtset%tolimg=dprarr(1)
2610 
2611 !find which tolerance is used for the ionic relaxations
2612  tolmxde_=dtset%tolmxde
2613  tolmxf_=dtset%tolmxf
2614  itol=0
2615  itol_gen=0
2616 
2617  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolmxde',tread,'ENE',ds_input)
2618  if(tread==1) then
2619    if (ds_input == 0) then
2620      tolmxde_=dprarr(1)
2621      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
2622    else
2623      dtset%tolmxde=dprarr(1)
2624      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
2625    end if
2626  end if
2627 
2628  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolmxf',tread,'DPR',ds_input)
2629  if(tread==1) then
2630    if (ds_input == 0) then
2631      tolmxf_=dprarr(1)
2632      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
2633    else
2634      dtset%tolmxf=dprarr(1)
2635      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
2636    end if
2637  else
2638    itol_gen=itol_gen+1
2639  end if
2640 
2641 !check for definitions of tolmxf and tolmxde for the present dataset
2642  if (itol > 1 .or. itol_gen > 1) then
2643    write(message, '(5a)' )&
2644 &   'Only one of the tolmxf/tolmxde variables may be defined at once.',ch10,&
2645 &   'Action: check values of tolmxf, tolmxde. If you want to use ',ch10,&
2646 &   '        tolmxde, you should explicitly put tolmxf to 0.0.'
2647    MSG_ERROR(message)
2648  end if
2649 
2650 !if no value is given for jdtset, use defaults
2651  if (itol == 0 .and. itol_gen == 1) then
2652    dtset%tolmxde=tolmxde_
2653    dtset%tolmxf=tolmxf_
2654  end if
2655 
2656  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'focktoldfe',tread,'DPR')
2657  if(tread==1) dtset%focktoldfe=dprarr(1)
2658 
2659  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolrde',tread,'DPR')
2660  if(tread==1) dtset%tolrde=dprarr(1)
2661 
2662 !find which tolXXX are defined generically and for this jdtset
2663  tolwfr_=zero
2664  toldfe_=zero
2665  toldff_=zero
2666  tolrff_=zero
2667  tolvrs_=zero
2668  itol=0
2669  itol_gen=0
2670  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolwfr',tread,'DPR',ds_input)
2671  if(tread==1) then
2672    if (ds_input == 0) then
2673      tolwfr_=dprarr(1)
2674      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
2675    else
2676      dtset%tolwfr=dprarr(1)
2677      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
2678    end if
2679  end if
2680 
2681  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'toldff',tread,'DPR',ds_input)
2682  if(tread==1) then
2683    if (ds_input == 0) then
2684      toldff_=dprarr(1)
2685      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
2686    else
2687      dtset%toldff=dprarr(1)
2688      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
2689    end if
2690    dtset%optforces=1
2691  end if
2692 
2693  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolrff',tread,'DPR',ds_input)
2694  if(tread==1) then
2695    if (ds_input == 0) then
2696      tolrff_=dprarr(1)
2697      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
2698    else
2699      dtset%tolrff=dprarr(1)
2700      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
2701    end if
2702    dtset%optforces=1
2703  end if
2704 
2705  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'toldfe',tread,'ENE',ds_input)
2706  if(tread==1) then
2707    if (ds_input == 0) then
2708      toldfe_=dprarr(1)
2709      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
2710    else
2711      dtset%toldfe=dprarr(1)
2712      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
2713    end if
2714  end if
2715 
2716  if((dtset%accuracy>0).and.(itol>0.or.itol_gen>0)) tolvrs_=zero
2717 
2718  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolvrs',tread,'DPR',ds_input)
2719  if(tread==1) then
2720    if (ds_input == 0) then
2721      tolvrs_=dprarr(1)
2722      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
2723    else
2724      dtset%tolvrs=dprarr(1)
2725      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
2726    end if
2727  end if
2728 
2729 !check for multiple definitions of tolXXX for the present dataset
2730  if (itol > 1 .or. itol_gen > 1) then
2731    write(message, '(3a)' )&
2732 &   'Only one of the tolXXX variables may be defined at once.',ch10,&
2733 &   'Action: check values of tolvrs, toldfe, tolrff, tolwfr, and toldff.'
2734    MSG_ERROR(message)
2735  end if
2736 
2737 !if no value is given for jdtset, use defaults
2738  if (itol == 0 .and. itol_gen == 1) then
2739    dtset%tolwfr=tolwfr_
2740    dtset%toldfe=toldfe_
2741    dtset%toldff=toldff_
2742    dtset%tolrff=tolrff_
2743    dtset%tolvrs=tolvrs_
2744  end if
2745 
2746 !Tolerance variable for TFW initialization step
2747  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tfw_toldfe',tread,'ENE',ds_input)
2748  if(tread==1) then
2749    dtset%tfw_toldfe=dprarr(1)
2750  else if (dtset%tfkinfunc>10.and.dtset%toldfe>tiny(0._dp)) then
2751    dtset%tfw_toldfe=dtset%toldfe
2752  end if
2753 
2754 !Tolerance variables for electrons-positron tc-dft
2755  toldfe_=zero;toldff_=zero
2756  itol=0;itol_gen=0
2757  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'postoldff',tread,'DPR',ds_input)
2758  if(tread==1) then
2759    if (ds_input == 0) then
2760      toldff_=dprarr(1)
2761      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
2762    else
2763      dtset%postoldff=dprarr(1)
2764      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
2765    end if
2766    dtset%postoldfe=zero
2767  end if
2768 
2769  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'postoldfe',tread,'ENE',ds_input)
2770  if(tread==1) then
2771    if (ds_input == 0) then
2772      toldfe_=dprarr(1)
2773      if(abs(dprarr(1))>tiny(0._dp))itol_gen=itol_gen+1
2774    else
2775      dtset%postoldfe=dprarr(1)
2776      if(abs(dprarr(1))>tiny(0._dp))itol=itol+1
2777    end if
2778  end if
2779  if (itol > 1.or.itol_gen >1) then
2780    write(message, '(3a)' )&
2781 &   'Only one of the postolXXX variables may be defined at once.',ch10,&
2782 &   'Action: check values of postoldfe and postoldff.'
2783    MSG_ERROR(message)
2784  end if
2785  if (itol==0.and.itol_gen==1) then
2786    dtset%postoldfe=toldfe_
2787    dtset%postoldff=toldff_
2788  end if
2789 
2790  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'usekden',tread,'INT')
2791  if(tread==1) dtset%usekden=intarr(1)
2792 
2793  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'vprtrb',tread,'ENE')
2794  if(tread==1) dtset%vprtrb(:)=dprarr(1:2)
2795 
2796 !TODO : should this test be just on natsph without caring about the others? natsph might be used for other purposes
2797  if((dtset%pawfatbnd>0.or.dtset%prtdos==3) .and. dtset%natsph>0)then
2798    call intagm(dprarr,intarr,jdtset,marr,dtset%natsph,string(1:lenstr),'iatsph',tread,'INT')
2799    if(tread==1) dtset%iatsph(1:dtset%natsph)=intarr(1:dtset%natsph)
2800  end if
2801 
2802  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtdensph',tread,'INT')
2803  if(tread==1) then
2804    dtset%prtdensph=intarr(1)
2805  else if (dtset%nsppol==1.and.dtset%nspden==2) then
2806    dtset%prtdensph=1
2807  end if
2808 
2809 !Initialize atvshift
2810  if(dtset%natvshift>0)then
2811    call intagm(dprarr,intarr,jdtset,marr,dtset%natvshift*nsppol*dtset%natom,string(1:lenstr),'atvshift',tread,'ENE')
2812    if(tread==1) dtset%atvshift(1:dtset%natvshift,1:nsppol,1:dtset%natom)=&
2813 &   reshape(dprarr(1:dtset%natvshift*nsppol*dtset%natom),(/dtset%natvshift,nsppol,dtset%natom/))
2814  end if
2815 
2816 !Initialize wtatcon
2817  if(dtset%nconeq>0)then
2818 
2819 !  Read and check natcon
2820    ABI_ALLOCATE(natcon,(dtset%nconeq))
2821    call intagm(dprarr,intarr,jdtset,marr,dtset%nconeq,string(1:lenstr),'natcon',tread,'INT')
2822    if(tread==1)then
2823      natcon(:)=intarr(1:dtset%nconeq)
2824    else
2825      write(message, '(3a)' )&
2826 &     'When nconeq is positive, natcon MUST be defined.',ch10,&
2827 &     'Action: check the values of nconeq and natcon.'
2828      MSG_ERROR(message)
2829    end if
2830    do ii=1,dtset%nconeq
2831      if(natcon(ii)<0)then
2832        write(message, '(a,a,a,i4,a,i4,a,a)' )&
2833 &       'All the components of natcon must be greater than 0.',ch10,&
2834 &       'The component',ii,' is equal to ',natcon(ii),ch10,&
2835 &       'Action: check the values of natcon.'
2836        MSG_ERROR(message)
2837      end if
2838    end do
2839    niatcon=sum(natcon(:))
2840 
2841 !  Read and check iatcon
2842    ABI_ALLOCATE(iatcon,(niatcon))
2843    call intagm(dprarr,intarr,jdtset,marr,niatcon,string(1:lenstr),'iatcon',tread,'INT')
2844    if(tread==1)then
2845      iatcon(:)=intarr(1:niatcon)
2846    else
2847      write(message, '(3a)' )&
2848 &     'When nconeq is positive, natcon MUST be defined.',ch10,&
2849 &     'Action: check the values of nconeq and natcon.'
2850      MSG_ERROR(message)
2851    end if
2852    do ii=1,niatcon
2853      if(iatcon(ii)<0)then
2854        write(message, '(a,a,a,i4,a,i4,a,a)' )&
2855 &       'All the components of iatcon must be greater than 0.',ch10,&
2856 &       'The component',ii,' is equal to ',iatcon(ii),ch10,&
2857 &       'Action: check the values of iatcon.'
2858        MSG_ERROR(message)
2859      end if
2860    end do
2861 
2862 !  Read wtatcon, and unfold it.
2863    call intagm(dprarr,intarr,jdtset,marr,3*niatcon,string(1:lenstr),'wtatcon',tread,'DPR')
2864    if(tread/=1)then
2865      write(message, '(3a)' )&
2866 &     'When nconeq is positive, wtatcon MUST be defined.',ch10,&
2867 &     'Action: check the values of nconeq and wtatcon.'
2868      MSG_ERROR(message)
2869    end if
2870    iat=0
2871    do ii=1,dtset%nconeq
2872      do jj=1,natcon(ii)
2873        dtset%wtatcon(1:3,iatcon(jj+iat),ii)=dprarr(1+3*(jj+iat-1):3+3*(jj+iat-1))
2874      end do
2875      iat=iat+natcon(ii)
2876    end do
2877 
2878    ABI_DEALLOCATE(iatcon)
2879    ABI_DEALLOCATE(natcon)
2880  end if
2881 
2882 !Initialize chempot
2883  if(dtset%nzchempot>0)then
2884    call intagm(dprarr,intarr,jdtset,marr,3*dtset%nzchempot*ntypat,string(1:lenstr),'chempot',tread,'DPR')
2885    if(tread==1) dtset%chempot(1:3,1:dtset%nzchempot,1:ntypat)=&
2886 &   reshape(dprarr(1:3*dtset%nzchempot*ntypat),(/3,dtset%nzchempot,ntypat/))
2887  end if
2888 
2889 !Initialize the list of k points, as well as wtk and istwfk
2890  intimage=1 ; if(nimage>2)intimage=(1+nimage)/2
2891  call invacuum(jdtset,lenstr,natom,dtset%rprimd_orig(1:3,1:3,intimage),string,vacuum,dtset%xred_orig(1:3,1:natom,intimage))
2892 
2893 !reset rfdir to 1 1 1 in case it was left at the default of 0 0 0 for berryopt -1
2894  if( (dtset%berryopt == -1) .AND. &
2895 & (dtset%rfdir(1) == 0) .AND. &
2896 & (dtset%rfdir(2) == 0) .AND. &
2897 & (dtset%rfdir(3) == 0) ) dtset%rfdir(1:3) = 1
2898 
2899 !In case of a Berryphase calculation put response = 1
2900 !in order to set istwfk = 1 at all k-points
2901  if ( dtset%berryopt/=0 ) then
2902    response = 1
2903  end if
2904 
2905  nsym=dtset%nsym
2906  ii=0;if (mod(dtset%wfoptalg,10)==4) ii=2
2907  if(dtset%ngfft(7)==314)ii=1
2908  if(dtset%usefock==1.and.dtset%optdriver/=RUNL_SIGMA.and.mod(dtset%wfoptalg,10)/=5) ii=1
2909 
2910  call inkpts(bravais,dtset%chksymbreak,dtset%fockdownsampling,iout,iscf,dtset%istwfk(1:nkpt),jdtset,&
2911 & dtset%kpt(:,1:nkpt),dtset%kptns_hf(:,1:nkpthf),kptopt,dtset%kptnrm,&
2912 & dtset%kptrlatt_orig,dtset%kptrlatt,kptrlen,lenstr,nsym,&
2913 & nkpt,nkpthf,nqpt,dtset%ngkpt,dtset%nshiftk,dtset%nshiftk_orig,dtset%shiftk_orig,nsym,&
2914 & occopt,dtset%qptn,response,dtset%rprimd_orig(1:3,1:3,intimage),dtset%shiftk,string,&
2915 & dtset%symafm(1:nsym),dtset%symrel(:,:,1:nsym),vacuum,dtset%wtk(1:nkpt),&
2916 & impose_istwf_1=ii)
2917 
2918  dtset%kptrlen=kptrlen
2919 
2920  dtset%kptns(:,1:nkpt)=dtset%kpt(:,1:nkpt)/dtset%kptnrm
2921  if(nqpt>=1 .and. dtset%optdriver/=RUNL_RESPFN)then
2922    dtset%kptns(1,1:nkpt)=dtset%kptns(1,1:nkpt)+dtset%qptn(1)
2923    dtset%kptns(2,1:nkpt)=dtset%kptns(2,1:nkpt)+dtset%qptn(2)
2924    dtset%kptns(3,1:nkpt)=dtset%kptns(3,1:nkpt)+dtset%qptn(3)
2925  end if
2926 
2927  if(nkpthf/=0)then
2928    dtset%kptns_hf(:,1:nkpthf)=dtset%kptns_hf(:,1:nkpthf)/dtset%kptnrm
2929  end if
2930 
2931  ! Read variables defining the k-path
2932  ! If kptopt < 0  --> Band structure and kptbounds size is given by abs(kptopt)
2933  ! If kptopt >= 0 --> We may have a k-path specified by nkpath and kptbounds (used by post-processing tools)
2934  ! TODO: ndivk?
2935 
2936  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ndivsm',tread,'INT')
2937  if (tread == 1) dtset%ndivsm = intarr(1)
2938 
2939  if (dtset%kptopt < 0) then
2940    dtset%nkpath = abs(dtset%kptopt)
2941  else
2942    dtset%nkpath = 0
2943    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nkpath',tread,'INT')
2944    if (tread==1) dtset%nkpath = intarr(1)
2945  end if
2946 
2947  if (dtset%nkpath /= 0) then
2948    call intagm(dprarr,intarr,jdtset,marr,3*dtset%nkpath,string(1:lenstr),'kptbounds',tread,'DPR')
2949 
2950    if (tread == 1) then
2951      ABI_MALLOC(dtset%kptbounds, (3, dtset%nkpath))
2952      dtset%kptbounds = reshape(dprarr(1:3*dtset%nkpath), [3, dtset%nkpath])
2953    else
2954      MSG_ERROR("When nkpath /= 0 or kptopt < 0, kptbounds must be defined in the input file.")
2955    end if
2956  else
2957    ABI_MALLOC(dtset%kptbounds, (0,0))
2958  end if
2959 
2960 ! This part has been commented out as get_kpt_fullbz is not able to handle kptrlatt with shifts e.g.
2961 ! kptrlatt
2962 !   0 6 0
2963 !   0 0 6
2964 !   3 3 3
2965 !nshiftk 1
2966 !shiftk 0.0 1.0 0.5
2967 ! A test (v8/t03.in) has been added to make sure the job does not stop at the level of the parser.
2968 
2969 #if 0
2970 !Echo the information about the k point grid
2971  call matr3inv(dtset%rprimd_orig(1:3,1:3,intimage),gprimd)
2972  write(std_out,'(3a)')' ',ch10,' invars2 : Printing the k point grid (values of kptns - max 100 of them)'
2973  write(std_out,'(a,2i8)')' nkpt=',nkpt
2974  write(std_out,'(a)')&
2975 & '     ikpt istwfk    wtk       --------- reduced coordinates ---------  --------- cartesian coordinates ---------'
2976  do ikpt=1,min(nkpt,100)
2977    kpt_cart(:)=dtset%kptns(1,ikpt)*gprimd(:,1)+&
2978 &   dtset%kptns(2,ikpt)*gprimd(:,2)+&
2979 &   dtset%kptns(3,ikpt)*gprimd(:,3)
2980    write(std_out,'(i8,i6,7es14.6)')ikpt,dtset%istwfk(ikpt),dtset%wtk(ikpt),dtset%kptns(:,ikpt),kpt_cart(:)
2981  end do
2982 
2983  if(sum(abs(dtset%kptrlatt(:,1)))/=0 .and. sum(abs(dtset%kptrlatt(:,2)))/=0 .and. sum(abs(dtset%kptrlatt(:,3)))/=0)then
2984    write(std_out,'(5a)')' ',ch10,&
2985 &   ' invars2 : Printing the k point grid from kptrlatt, shifted with shiftk and qptn, in the full Brillouin zone.',ch10,&
2986 &   '   Maximum 100 of them. No use of symmetries'
2987    rlatt(:,:)=dtset%kptrlatt(:,:)
2988    nkpt_fullbz=(rlatt(1,1)*(rlatt(2,2)*rlatt(3,3)-rlatt(2,3)*rlatt(3,2)) &
2989 &   +rlatt(1,2)*(rlatt(2,3)*rlatt(3,1)-rlatt(2,1)*rlatt(3,3)) &
2990 &   +rlatt(1,3)*(rlatt(3,2)*rlatt(2,1)-rlatt(3,1)*rlatt(2,2)))*dtset%nshiftk
2991    ABI_ALLOCATE(kpt_fullbz,(3,nkpt_fullbz))
2992    call get_kpt_fullbz(kpt_fullbz,dtset%kptrlatt,nkpt_fullbz,dtset%nshiftk,dtset%shiftk)
2993    write(std_out,'(a,2i8)')' nkpt_fullbz=',nkpt_fullbz
2994    write(std_out,'(a)')&
2995 &   '     ikpt      --------------- reduced coordinates ---------------  --------- cartesian coordinates ---------'
2996    do ikpt=1,min(nkpt_fullbz,100)
2997      kpt_fullbz(:,ikpt)=kpt_fullbz(:,ikpt)+dtset%qptn(:)
2998      kpt_cart(:)=kpt_fullbz(1,ikpt)*gprimd(:,1)+&
2999 &     kpt_fullbz(2,ikpt)*gprimd(:,2)+&
3000 &     kpt_fullbz(3,ikpt)*gprimd(:,3)
3001      write(std_out,'(i8,a,3es18.10,3es14.6)')ikpt,'     ',kpt_fullbz(:,ikpt),kpt_cart(:)
3002    end do
3003    ABI_DEALLOCATE(kpt_fullbz)
3004  end if
3005 #endif
3006 
3007 !if prtkpt==-2, write the k-points in netcdf format and exit here so that AbiPy can read the data.
3008  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtkpt',tread,'INT')
3009  if (tread == 1 .and. intarr(1) == -2) then
3010 #ifdef HAVE_NETCDF
3011    ncerr= nctk_write_ibz("kpts.nc", dtset%kptns(:,1:nkpt), dtset%wtk(1:nkpt))
3012    NCF_CHECK(ncerr)
3013 #endif
3014    MSG_ERROR_NODUMP("kpts.nc file written. Aborting now")
3015  end if
3016 
3017  if(dtset%nkptgw>0) then
3018    ! Read bdgw.
3019    call intagm(dprarr,intarr,jdtset,marr,2*dtset%nkptgw*dtset%nsppol,string(1:lenstr),'bdgw',tread,'INT')
3020    if(tread==1) then
3021      dtset%bdgw(1:2,1:dtset%nkptgw,1:dtset%nsppol) =  &
3022 &     reshape(intarr(1:2*dtset%nkptgw*dtset%nsppol),[2,dtset%nkptgw,dtset%nsppol])
3023    end if
3024 
3025    ! Test bdgw values.
3026    if (dtset%optdriver == RUNL_SIGMA) then
3027      if (any(dtset%bdgw(1:2,1:dtset%nkptgw,1:dtset%nsppol) <= 0)) then
3028        MSG_ERROR("bdgw entries cannot be <= 0. Check input file")
3029      end if
3030      if (any(dtset%bdgw(1,1:dtset%nkptgw,1:dtset%nsppol) > dtset%bdgw(2,1:dtset%nkptgw,1:dtset%nsppol))) then
3031        MSG_ERROR("First band index in bdgw cannot be greater than the second index")
3032      end if
3033    end if
3034 
3035    call intagm(dprarr,intarr,jdtset,marr,3*dtset%nkptgw,string(1:lenstr),'kptgw',tread,'DPR')
3036    if(tread==1) dtset%kptgw(1:3,1:dtset%nkptgw) = reshape(dprarr(1:3*dtset%nkptgw),(/3,dtset%nkptgw/))
3037  end if
3038 
3039  if(dtset%nqptdm>0) then
3040    call intagm(dprarr,intarr,jdtset,marr,3*dtset%nqptdm,string(1:lenstr),'qptdm',tread,'DPR')
3041    if(tread==1) dtset%qptdm(1:3,1:dtset%nqptdm)=reshape(dprarr(1:3*dtset%nqptdm),(/3,dtset%nqptdm/))
3042  end if
3043 
3044  if(dtset%npvel>0) then
3045    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'pvelmax',tread,'DPR')
3046    if(tread==1) dtset%pvelmax(1:3)=dprarr(1:3)
3047  end if
3048 
3049  if(dtset%imgmov==6)then
3050    call intagm(dprarr,intarr,jdtset,marr,dtset%nimage,string(1:lenstr),'mixesimgf',tread,'DPR')
3051    if(tread==1)dtset%mixesimgf(1:dtset%nimage)=dprarr(1:dtset%nimage)
3052  endif
3053 
3054 !Read remaining input variables depending on images : occ_orig, upawu, jpawu.
3055 !MT oct 15: these lines are inspired from invars1 but are not really understood
3056  intimage=2 ; if(dtset%nimage==1)intimage=1
3057  do ii=1,dtset%nimage+1
3058    iimage=ii
3059    if(dtset%nimage==1 .and. ii==2)exit
3060    if(dtset%nimage==2 .and. ii==3)exit
3061    if(dtset%nimage> 2 .and. ii==intimage)cycle ! Will do the intermediate reference image at the last reading
3062    if(dtset%nimage>=2 .and. ii==dtset%nimage+1)iimage=intimage
3063 
3064 !  Only read occ if (iscf >0 or iscf=-1 or iscf=-3) and (occopt==0 or occopt==2)
3065    if  (iscf>=0.or.iscf==-1.or.iscf==-3)  then
3066      if (occopt==2 .and. getocc==0) then
3067 !      Read occ(nband(kpt)*nkpt*nsppol) explicitly
3068        call wrtout(std_out,' invars2: reading occ(nband*nkpt*nsppol) explicitly','COLL')
3069        call intagm(dprarr,intarr,jdtset,marr,bantot,string(1:lenstr),'occ',tread,'DPR')
3070        if(tread==1) dtset%occ_orig(1:bantot,iimage)=dprarr(1:bantot)
3071        call intagm_img(dprarr(1:bantot),iimage,jdtset,lenstr,dtset%nimage,bantot,string,'occ',tread_alt,'DPR')
3072        if(tread_alt==1) dtset%occ_orig(1:bantot,iimage)=dprarr(1:bantot)
3073      else if(occopt==0) then
3074        nband1=dtset%nband(1)
3075 !      Read usual occupancy--same for all k points but might differ for spins
3076        call intagm(dprarr,intarr,jdtset,marr,nband1*nsppol,string(1:lenstr),'occ',tread,'DPR')
3077        if(tread==1) dtset%occ_orig(1:nband1*nsppol,iimage)=dprarr(1:nband1*nsppol)
3078        call intagm_img(dprarr(1:nband1*nsppol),iimage,jdtset,lenstr,dtset%nimage,nband1*nsppol,string,'occ',tread_alt,'DPR')
3079        if(tread_alt==1) dtset%occ_orig(1:nband1*nsppol,iimage)=dprarr(1:nband1*nsppol)
3080 !      Fill in full occ array using input values for each k and spin
3081 !      (make a separate copy for each k point and spin)
3082        if(nkpt>1)then
3083          do isppol=nsppol,1,-1
3084            do ikpt=2,nkpt
3085              dtset%occ_orig(1+(ikpt-1)*nband1+nkpt*nband1*(isppol-1):ikpt*nband1+nkpt*nband1*(isppol-1),iimage)=&
3086 &             dtset%occ_orig(1+nband1*(isppol-1):nband1*isppol,iimage)
3087            end do
3088          end do
3089        endif
3090      end if
3091    end if
3092 
3093    if (dtset%usepawu>0.or.dtset%usedmft>0) then
3094 
3095      dprarr(1:ntypat)=dtset%upawu(1:ntypat,iimage)
3096      call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'upawu',tread,'ENE')
3097      if(tread==1) dtset%upawu(1:ntypat,iimage)=dprarr(1:ntypat)
3098      call intagm_img(dprarr(1:ntypat),iimage,jdtset,lenstr,dtset%nimage,ntypat,string,'upawu',tread_alt,'ENE')
3099      if(tread_alt==1) dtset%upawu(1:ntypat,iimage)=dprarr(1:ntypat)
3100 
3101      dprarr(1:ntypat)=dtset%jpawu(1:ntypat,iimage)
3102      call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'jpawu',tread,'ENE')
3103      if(tread==1) dtset%jpawu(1:ntypat,iimage)=dprarr(1:ntypat)
3104      call intagm_img(dprarr(1:ntypat),iimage,jdtset,lenstr,dtset%nimage,ntypat,string,'jpawu',tread_alt,'ENE')
3105      if(tread_alt==1) dtset%jpawu(1:ntypat,iimage)=dprarr(1:ntypat)
3106 
3107      if (dtset%usedmatpu/=0.and.dmatsize>0) then
3108        nsp=nsppol*nspinor
3109        call intagm(dprarr,intarr,jdtset,marr,dmatsize,string(1:lenstr),'dmatpawu',tread,'DPR')
3110        if(tread==1) then
3111          iat=1;jj=1
3112          do iatom=1,natom
3113            lpawu=dtset%lpawu(dtset%typat(iatom))
3114            if (lpawu/=-1) then
3115              isiz=nsp*(2*lpawu+1)**2
3116              dtset%dmatpawu(1:2*lpawu+1,1:2*lpawu+1,1:nsp,iat,iimage)= &
3117 &             reshape(dprarr(jj:jj+isiz),(/2*lpawu+1,2*lpawu+1,nsp/))
3118              iat=iat+1;jj=jj+isiz
3119            end if
3120          end do
3121        end if
3122 
3123        ABI_ALLOCATE(dmatpawu_tmp,(dmatsize))
3124        iat=1;jj=1
3125        do iatom=1,natom
3126          lpawu=dtset%lpawu(dtset%typat(iatom))
3127          if (lpawu/=-1) then
3128            isiz=nsp*(2*lpawu+1)**2
3129            dmatpawu_tmp(jj:jj+isiz-1)= &
3130 &           reshape(dtset%dmatpawu(1:2*lpawu+1,1:2*lpawu+1,1:nsp,iat,iimage),(/isiz/))
3131            iat=iat+1;jj=jj+isiz
3132          end if
3133        end do
3134        call intagm_img(dmatpawu_tmp,iimage,jdtset,lenstr,dtset%nimage,dmatsize, &
3135 &       string,'dmatpawu',tread_alt,'DPR')
3136        if(tread_alt==1) then
3137          iat=1;jj=1
3138          do iatom=1,natom
3139            lpawu=dtset%lpawu(dtset%typat(iatom))
3140            if (lpawu/=-1) then
3141              isiz=nsp*(2*lpawu+1)**2
3142              dtset%dmatpawu(1:2*lpawu+1,1:2*lpawu+1,1:nsp,iat,iimage)= &
3143 &             reshape(dmatpawu_tmp(jj:jj+isiz-1),(/2*lpawu+1,2*lpawu+1,nsp/))
3144              iat=iat+1;jj=jj+isiz
3145            end if
3146          end do
3147        end if
3148        ABI_DEALLOCATE(dmatpawu_tmp)
3149 
3150        if (tread/=1.and.tread_alt/=1) then
3151          write(message, '(3a)' )&
3152 &         'When LDA/GGA+U is activated and usedmatpu/=0, dmatpawu MUST be defined.',ch10,&
3153 &         'Action: add dmatpawu keyword in input file.'
3154          MSG_ERROR(message)
3155        end if
3156      end if
3157 
3158    end if
3159 
3160  end do
3161 
3162  if(dtset%jellslab/=0)then
3163    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'slabwsrad',tread,'LEN')
3164    if(tread==1) dtset%slabwsrad=dprarr(1)
3165 
3166 !  Update number of electrons taking into account jellium
3167 !  Suppose that the cell has z axis perpendicular to x and y axes.
3168 !  This will be checked later
3169    areaxy=abs(dtset%rprimd_orig(1,1,1)*dtset%rprimd_orig(2,2,1)-dtset%rprimd_orig(1,2,1)*dtset%rprimd_orig(2,1,1))
3170    rhoavg=three/(four_pi*dtset%slabwsrad**3)
3171    nelectjell=areaxy*(dtset%slabzend-dtset%slabzbeg)*rhoavg
3172    charge=charge-nelectjell
3173  end if
3174 
3175 !Initialize occ if occopt==1 or 3 ... 8,
3176 !while if getocc/=0, make a fake initialization
3177 !If iscf>0, check the charge of the system, and compute nelect.
3178  occopt_tmp=occopt
3179  if(getocc/=0)occopt_tmp=1
3180  call dtset_chkneu(charge,dtset,occopt_tmp)
3181 
3182 !Now that the occupation numbers have been initialized, can meaningfully define nbandhf.
3183  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nbandhf',tread,'INT')
3184  if(tread==1) then
3185    dtset%nbandhf=intarr(1)
3186  else
3187 !  If the occupation numbers might change, must keep the maximum number of bands
3188    if(occopt>=3 .and. occopt<=8)then
3189      dtset%nbandhf=maxval(dtset%nband(1:nkpt*nsppol))
3190    else if(occopt==0 .or. occopt==1 .or. occopt==2) then ! Eliminate all the bands that are never occupied
3191      nband1=0 ; bantot=0
3192      do isppol=1,dtset%nsppol
3193        do ikpt=1,dtset%nkpt
3194          do iband=1,dtset%nband(ikpt+(isppol-1)*dtset%nkpt)
3195            bantot=bantot+1
3196            if(maxval(abs(dtset%occ_orig(bantot,:)))>tol8)then
3197              if(iband>nband1)nband1=iband
3198            end if
3199          end do
3200        end do
3201      end do
3202      dtset%nbandhf=nband1
3203    else
3204      write(message, '(a,i0,3a)' )&
3205 &     'occopt=',occopt,' not allowed.',ch10,&
3206 &     'Action: correct your input file.'
3207      MSG_ERROR(message)
3208    end if
3209  end if
3210 
3211 !Initialize Berry phase vectors
3212 !Should check that nberry is smaller than 20
3213  if(berryopt>0 .and. nberry>0)then
3214    call intagm(dprarr,intarr,jdtset,marr,3*nberry,string(1:lenstr),'kberry',tread,'INT')
3215    if(tread==1) dtset%kberry(1:3,1:nberry)=reshape(intarr(1:3*nberry), (/3,nberry/))
3216  end if
3217 
3218  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ddamp',tread,'DPR')
3219  if (tread==1) dtset%ddamp = dprarr(1)
3220 
3221  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'polcen',tread,'DPR')
3222  if (tread==1) dtset%polcen(1:3) = dprarr(1:3)
3223 
3224  call intagm(dprarr,intarr,jdtset,marr,ntypat,string(1:lenstr),'densty',tread,'DPR')
3225  if(tread==1) dtset%densty(1:ntypat,1)=dprarr(1:ntypat)
3226 
3227  call intagm(dprarr,intarr,jdtset,marr,npsp,string(1:lenstr),'so_psp',tread,'INT')
3228  if(tread==1.and.dtset%usepaw==0)then
3229    dtset%so_psp(1:npsp)=intarr(1:npsp)
3230  end if
3231 
3232 !LOTF variables
3233 #if defined HAVE_LOTF
3234  if(dtset%ionmov==23) then
3235    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lotf_classic',tread,'INT')
3236    if(tread==1) dtset%lotf_classic=intarr(1)
3237 
3238    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lotf_nitex',tread,'INT')
3239    if(tread==1) dtset%lotf_nitex=intarr(1)
3240 
3241    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lotf_nneigx',tread,'INT')
3242    if(tread==1) dtset%lotf_nneigx=intarr(1)
3243 
3244    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lotf_version',tread,'INT')
3245    if(tread==1) dtset%lotf_version=intarr(1)
3246  end if
3247 #endif
3248 
3249 !Read input variables related to Projected Local Orbitals Wannier functions (plowan)
3250  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'plowan_bandi',tread,'INT')
3251  if(tread==1) dtset%plowan_bandi=intarr(1)
3252  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'plowan_bandf',tread,'INT')
3253  if(tread==1) dtset%plowan_bandf=intarr(1)
3254  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'plowan_realspace',tread,'INT')
3255  if(tread==1) dtset%plowan_realspace=intarr(1)
3256  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'plowan_natom',tread,'INT')
3257  if(tread==1) dtset%plowan_natom=intarr(1)
3258  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'plowan_nt',tread,'INT')
3259  if(tread==1) dtset%plowan_nt=intarr(1)
3260 
3261  if (dtset%plowan_compute>0) then
3262    call intagm(dprarr,intarr,jdtset,marr,3*dtset%plowan_nt,string(1:lenstr),'plowan_it',tread,'INT')
3263    if(tread==1) dtset%plowan_it(1:3*dtset%plowan_nt)=intarr(1:3*dtset%plowan_nt)
3264 
3265    call intagm(dprarr,intarr,jdtset,marr,dtset%plowan_natom,string(1:lenstr),'plowan_iatom',tread,'INT')
3266    if(tread==1) dtset%plowan_iatom(1:dtset%plowan_natom)=intarr(1:dtset%plowan_natom)
3267 
3268    call intagm(dprarr,intarr,jdtset,marr,dtset%plowan_natom,string(1:lenstr),'plowan_nbl',tread,'INT')
3269    if(tread==1) dtset%plowan_nbl(1:dtset%plowan_natom)=intarr(1:dtset%plowan_natom)
3270    sumnbl=sum(dtset%plowan_nbl(:))
3271 
3272    call intagm(dprarr,intarr,jdtset,marr,sumnbl,string(1:lenstr),'plowan_lcalc',tread,'INT')
3273    if(tread==1) dtset%plowan_lcalc(1:sumnbl)=intarr(1:sumnbl)
3274 
3275    call intagm(dprarr,intarr,jdtset,marr,sumnbl,string(1:lenstr),'plowan_projcalc',tread,'INT')
3276    if(tread==1) dtset%plowan_projcalc(1:sumnbl)=intarr(1:sumnbl)
3277  end if
3278 
3279  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),"wfk_task",tread,'KEY',key_value=key_value)
3280  if (tread==1) then
3281    dtset%wfk_task = str2wfktask(tolower(rmquotes(key_value)))
3282  end if
3283  if (dtset%optdriver == RUNL_WFK .and. dtset%wfk_task == WFK_TASK_NONE) then
3284    MSG_ERROR(sjoin("wfk_task must be specified when optdriver=",itoa(dtset%optdriver)))
3285  end if
3286 
3287  ABI_DEALLOCATE(intarr)
3288  ABI_DEALLOCATE(dprarr)
3289 
3290  call timab(191,2,tsec)
3291 
3292 end subroutine invars2

ABINIT/invars2m [ Functions ]

[ Top ] [ Functions ]

NAME

 invars2m

FUNCTION

 Initialisation phase - main input routine.
 Big loop on the datasets :
 - for each of the datasets, write one line about the crystallographic data
 - call invars2, that read the eventual single dataset input values ;
 - compute mgfft,mpw,nfft,... for this data set ;
 - compute quantities for the susceptibility computation
 - compute the memory needs for this data set.

INPUTS

  bravais_(11,0:ndtset_alloc)=characteristics of Bravais lattice
  iout=unit number of output file
  lenstr=actual length of string
  mband_upper_(0:ndtset_alloc)=list of mband_upper values
  msym=default maximal number of symmetries
  ndtset= number of datasets to be read; if 0, no multi-dataset mode
  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
  string*(*)=character string containing all the input data.
   Initialized previously in instrng.

OUTPUT

  dtsets(0:ndtset_alloc)=<type datafiles_type>contains all input variables,
   some of which are initialized here, while other were already
   initialized previously.

NOTES

 The outputs of this routine are the values of input variables,
 their default value is stored at the index 0 of the last dimension
 of their multi-dataset representation.

PARENTS

      m_ab7_invars_f90

CHILDREN

      invars2,metric,mkrdim,setshells

SOURCE

111 subroutine invars2m(dtsets,iout,lenstr,mband_upper_,msym,ndtset,ndtset_alloc,npsp,pspheads,string)
112 
113 
114 !This section has been created automatically by the script Abilint (TD).
115 !Do not modify the following lines by hand.
116 #undef ABI_FUNC
117 #define ABI_FUNC 'invars2m'
118 !End of the abilint section
119 
120  implicit none
121 
122 !Arguments ------------------------------------
123 !scalars
124  integer,intent(in) :: iout,lenstr,msym,ndtset,ndtset_alloc,npsp
125  character(len=*),intent(in) :: string
126 !arrays
127  integer,intent(in) :: mband_upper_(0:ndtset_alloc)
128  type(dataset_type),intent(inout) :: dtsets(0:ndtset_alloc)
129  type(pspheader_type),intent(in) :: pspheads(npsp)
130 
131 !Local variables -------------------------------
132 !scalars
133  integer :: idtset,jdtset,mband_upper,nsheps,nshsigx,nshwfn,usepaw
134  real(dp) :: ucvol
135 !arrays
136  integer :: bravais(11)
137  real(dp) :: gmet(3,3),gprimd(3,3),rmet(3,3),rprimd(3,3)
138  real(dp),allocatable :: zionpsp(:)
139 
140 !*************************************************************************
141 
142  do idtset=1,ndtset_alloc
143    jdtset=dtsets(idtset)%jdtset ; if(ndtset==0)jdtset=0
144    bravais(:)=dtsets(idtset)%bravais(:)
145    mband_upper  =mband_upper_(idtset)
146    usepaw=dtsets(idtset)%usepaw
147 !  Allocate arrays
148    ABI_ALLOCATE(zionpsp,(npsp))
149    zionpsp(:)=pspheads(1:npsp)%zionpsp
150 
151 !  Here, nearly all the remaining input variables are initialized
152    call invars2(bravais,dtsets(idtset),iout,jdtset,lenstr,&
153 &   mband_upper,msym,npsp,string,usepaw,zionpsp)
154 
155    ABI_DEALLOCATE(zionpsp)
156 
157    call mkrdim(dtsets(idtset)%acell_orig(1:3,1),dtsets(idtset)%rprim_orig(1:3,1:3,1),rprimd)
158    call metric(gmet,gprimd,-1,rmet,rprimd,ucvol)
159 
160 !  For GW or BSE calculations, we only use (npwwfn|ecutwfn) G-vectors read from the KSS file,
161 !  therefore the FFT box for the density should be defined according to ecut=ecutwfn.
162    if ( ANY(dtsets(idtset)%optdriver == (/RUNL_SCREENING,RUNL_SIGMA,RUNL_BSE/)) ) then
163 
164      nshwfn=0
165      call setshells(dtsets(idtset)%ecutwfn,dtsets(idtset)%npwwfn,nshwfn,&
166 &     dtsets(idtset)%nsym,gmet,gprimd,dtsets(idtset)%symrel,'wfn',ucvol)
167 
168 !    MG: Hack to avoid portability problems under gfortran and g95:
169 !    getng and getmpw are indeed quite sensitive if ecut is small
170 !    and, in the GW tests, mpw and ngfft might depend on the compiler used.
171 !    the problem shows up if we use npwwfn instead of ecutwfn, a good
172 !    reason for removing npwwfn!
173      dtsets(idtset)%ecutwfn=dtsets(idtset)%ecutwfn-tol14
174 !    MG: This is a kind of a hack, but the problem is ecutwfn that is too much redundant!
175      dtsets(idtset)%ecut=dtsets(idtset)%ecutwfn
176 
177 !    Close the shell for (W|chi0)
178      nsheps=0
179      call setshells(dtsets(idtset)%ecuteps,dtsets(idtset)%npweps,nsheps,&
180 &     dtsets(idtset)%nsym,gmet,gprimd,dtsets(idtset)%symrel,'eps',ucvol)
181 
182 !    Close the shell for the exchange term.
183      nshsigx=0
184      call setshells(dtsets(idtset)%ecutsigx,dtsets(idtset)%npwsigx,nshsigx,&
185 &     dtsets(idtset)%nsym,gmet,gprimd,dtsets(idtset)%symrel,'sigx',ucvol)
186 
187    end if ! (SIGMA|SCREENING|SCGW|BSE)
188 
189  end do
190 
191 end subroutine invars2m

ABINIT/m_invars2 [ Modules ]

[ Top ] [ Modules ]

NAME

  m_invars2

FUNCTION

COPYRIGHT

  Copyright (C) 1999-2018 ABINIT group (XG)
  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_invars2
28 
29  use defs_basis
30  use defs_datatypes
31  use defs_abitypes
32  use m_abicore
33  use m_errors
34  use m_nctk
35  use m_sort
36  use libxc_functionals
37 #ifdef HAVE_NETCDF
38  use netcdf
39 #endif
40 
41  use m_time,      only : timab
42  use m_fstrings,  only : sjoin, itoa, ltoa, tolower, rmquotes
43  use m_symtk,     only : matr3inv
44  use m_parser,    only : intagm
45  use m_geometry,   only : mkrdim, metric
46  use m_gsphere,    only : setshells
47  use m_intagm_img, only : intagm_img
48  use m_dtset,     only : dtset_chkneu
49  use m_xcdata,    only : get_auxc_ixc, get_xclevel
50  use m_inkpts,    only : inkpts
51  use m_ingeo,     only : invacuum
52 
53  implicit none
54 
55  private