LCOV - code coverage report
Current view: top level - src/57_iovars - m_invars1.F90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 90.0 % 1759 1583
Test Date: 2026-11-11 18:45:25 Functions: 100.0 % 5 5
Branches: 68.1 % 2972 2025

             Branch data     Line data    Source code
       1                 :             : !!****m* ABINIT/m_invars1
       2                 :             : !! NAME
       3                 :             : !!  m_invars1
       4                 :             : !!
       5                 :             : !! FUNCTION
       6                 :             : !!
       7                 :             : !!
       8                 :             : !! COPYRIGHT
       9                 :             : !! Copyright (C) 1998-2026 ABINIT group (DCA, XG, GMR, AR, MKV, FF, MM)
      10                 :             : !!  This file is distributed under the terms of the
      11                 :             : !!  GNU General Public License, see ~abinit/COPYING
      12                 :             : !!  or http://www.gnu.org/copyleft/gpl.txt .
      13                 :             : !!
      14                 :             : !! SOURCE
      15                 :             : 
      16                 :             : #if defined HAVE_CONFIG_H
      17                 :             : #include "config.h"
      18                 :             : #endif
      19                 :             : 
      20                 :             : #include "abi_common.h"
      21                 :             : 
      22                 :             : module m_invars1
      23                 :             : 
      24                 :             :  use defs_basis
      25                 :             :  use m_abicore
      26                 :             :  use m_xmpi
      27                 :             :  use m_errors
      28                 :             :  use m_atomdata
      29                 :             :  use m_dtset
      30                 :             :  use m_nctk
      31                 :             :  use m_xomp
      32                 :             :  use netcdf
      33                 :             :  use m_gwdefs
      34                 :             : #if defined DEV_YP_VDWXC
      35                 :             :  use m_xc_vdw
      36                 :             : #endif
      37                 :             : #if defined HAVE_GPU
      38                 :             :  use m_gpu_toolbox
      39                 :             : #endif
      40                 :             : 
      41                 :             :  use m_fstrings, only : inupper, itoa, endswith, strcat, sjoin, startswith
      42                 :             :  use m_geometry, only : mkrdim, cart2spinaxis
      43                 :             :  use m_parser,   only : intagm, intagm_img, chkint_ge, ab_dimensions, geo_t, geo_from_abivar_string
      44                 :             :  use m_inkpts,   only : inkpts, inqpt
      45                 :             :  use m_ingeo,    only : ingeo, invacuum, checkspvec
      46                 :             :  use m_matrix,   only : mati3det
      47                 :             :  use m_mep,      only : MEP_SOLVER_STEEPEST,NEB_ALGO_IMPROVED_TAN,NEB_CELL_ALGO_NONE,STRING_ALGO_SIMPLIFIED_EQUAL
      48                 :             :  use m_fftcore,      only : get_cache_kb, fftalg_for_npfft
      49                 :             : 
      50                 :             :  implicit none
      51                 :             : 
      52                 :             :  private
      53                 :             : !!***
      54                 :             : 
      55                 :             :  public :: invars0
      56                 :             :  public :: invars1
      57                 :             :  public :: invars1m
      58                 :             :  public :: indefo
      59                 :             : !!***
      60                 :             : 
      61                 :             : contains
      62                 :             : !!***
      63                 :             : 
      64                 :             : !!****f* ABINIT/invars0
      65                 :             : !! NAME
      66                 :             : !! invars0
      67                 :             : !!
      68                 :             : !! FUNCTION
      69                 :             : !! Initialisation phase: prepare the main input subroutine call by
      70                 :             : !! reading most of the NO MULTI variables, as well as natom, nimage, and ntypat,
      71                 :             : !! needed for allocating some input arrays in abinit, and also useri
      72                 :             : !! and userr. The variable usewvl is also read here for later reading
      73                 :             : !! of input path for the atomic orbital file (if required).
      74                 :             : !! Also initialize as soon as possible GPU related parameters
      75                 :             : !!
      76                 :             : !! INPUTS
      77                 :             : !!  lenstr=actual length of string
      78                 :             : !!  ndtset= number of datasets to be read; if 0, no multi-dataset mode
      79                 :             : !!  ndtset_alloc=number of datasets, corrected for allocation of at least one data set.
      80                 :             : !!  string*(*)=string of characters containing all input variables and data
      81                 :             : !!  comm= MPI communicator
      82                 :             : !!
      83                 :             : !! OUTPUT
      84                 :             : !!  dtsets(0:ndtset_alloc)=<type datafiles_type>contains all input variables,
      85                 :             : !!   some of which are initialized here:
      86                 :             : !!   cpus,jdtset,natom,nimage,npsp,ntypat,useri*,userr*
      87                 :             : !!  istatr=repetition rate for status file
      88                 :             : !!  istatshft=shift of the repetition rate for status file
      89                 :             : !!  msym=maximal value of input msym for all the datasets
      90                 :             : !!  mxnatom=maximal value of input natom for all the datasets
      91                 :             : !!  mxnimage=maximal value of input nimage for all the datasets
      92                 :             : !!  mxntypat=maximal value of input ntypat for all the datasets
      93                 :             : !!  npsp=number of pseudopotentials
      94                 :             : !!  pseudo_paths(npsp): List of paths to pseudopotential files as read from input file.
      95                 :             : !!   List of empty strings if we are legacy "files file" mode. Allocated here, caller should free memory.
      96                 :             : !!
      97                 :             : !! SOURCE
      98                 :             : 
      99                 :        1456 : subroutine invars0(dtsets, istatr, istatshft, lenstr, msym, mxnatom, mxnimage, mxntypat, ndtset, ndtset_alloc, &
     100                 :             :     npsp, pseudo_paths, papiopt, timopt, string, comm)
     101                 :             : 
     102                 :             : !Arguments ------------------------------------
     103                 :             : !scalars
     104                 :             :  integer,intent(in) :: lenstr,ndtset,ndtset_alloc, comm
     105                 :             :  integer,intent(out) :: istatr,istatshft,msym,mxnatom,mxnimage,mxntypat,npsp,papiopt
     106                 :             :  integer,intent(inout) :: timopt
     107                 :             :  character(len=*),intent(in) :: string
     108                 :             : !arrays
     109                 :             :  type(dataset_type),intent(inout) :: dtsets(0:ndtset_alloc) !vz_i
     110                 :             :  character(len=fnlen),allocatable,intent(out) :: pseudo_paths(:)
     111                 :             : 
     112                 :             : !Local variables-------------------------------
     113                 :             : !scalars
     114                 :             :  integer :: i1,i2,idtset,ii,jdtset,marr,multiplicity,tjdtset,tread,treadh,treadm
     115                 :             :  integer :: tread_pseudos,cnt,tread_geo,tread_gpu_option,treads, idev,gpu_option
     116                 :             :  real(dp) :: cpus
     117                 :             :  character(len=500) :: msg
     118                 :             :  character(len=fnlen) :: pp_dirpath,gpu_option_string
     119                 :             :  character(len=20*fnlen) :: pseudos_string ! DO NOT decrease len
     120                 :        1456 :  character(len=len(string)) :: geo_string
     121                 :        1456 :  type(geo_t) :: geo
     122                 :             : !arrays
     123                 :        1456 :  integer,allocatable :: intarr(:), sidx(:)
     124                 :        1456 :  real(dp),allocatable :: dprarr(:)
     125                 :             : !******************************************************************
     126                 :             : 
     127                 :             : !write(std_out,"(3a)")" m_invars1%invars0 : enter with string:", ch10, trim(string)
     128                 :             : 
     129                 :        1456 :  marr=max(9,ndtset_alloc,2)
     130   [ -  +  +  -  :        4368 :  ABI_MALLOC(dprarr,(marr))
          +  -  -  +  -  
                      + ]
     131   [ -  +  +  -  :        4368 :  ABI_MALLOC(intarr,(marr))
          +  -  -  +  -  
                      + ]
     132                 :             : 
     133                 :             :  ! Set up jdtset
     134         [ +  + ]:        1456 :  if (ndtset/=0) then
     135                 :             :    ! Default values
     136                 :        1042 :    dtsets(0)%jdtset = -1 ! unused value
     137   [ +  -  +  +  :       14262 :    dtsets(1:ndtset_alloc)%jdtset=(/ (ii,ii=1,ndtset_alloc) /)
                   +  + ]
     138                 :             : 
     139                 :             :    ! Read explicitly the jdtset array
     140                 :        1042 :    call intagm(dprarr,intarr,0,marr,ndtset,string(1:lenstr),'jdtset',tjdtset,'INT')
     141   [ +  +  +  + ]:        1564 :    if(tjdtset==1) dtsets(1:ndtset)%jdtset=intarr(1:ndtset)
     142                 :             : 
     143                 :             :    ! Read the udtset array
     144                 :        1042 :    call intagm(dprarr,intarr,0,marr,2,string(1:lenstr),'udtset',tread,'INT')
     145                 :             : 
     146                 :             :    ! jdtset and udtset cannot be defined together
     147   [ +  +  -  + ]:        1042 :    if(tjdtset==1 .and. tread==1)then
     148                 :             :      write(msg, '(3a)' )&
     149                 :           0 :      'jdtset and udtset cannot be defined both in the input file.',ch10,&
     150                 :           0 :      'Action: remove one of them from your input file.'
     151                 :           0 :      ABI_ERROR(msg)
     152                 :             :    end if
     153                 :             : 
     154                 :             :    ! Check values of udtset
     155         [ +  + ]:        1042 :    if(tread==1)then
     156         [ -  + ]:          55 :      if(intarr(1)<1 .or. intarr(1)>999)then
     157                 :             :        write(msg, '(a,i0,3a)' )&
     158                 :           0 :        'udtset(1) must be between 1 and 999, but it is ',intarr(1),'.',ch10,&
     159                 :           0 :        'Action: change the value of udtset(1) in your input file.'
     160                 :           0 :        ABI_ERROR(msg)
     161                 :             :      end if
     162         [ -  + ]:          55 :      if(intarr(2)<1 .or. intarr(2)>9)then
     163                 :             :        write(msg, '(a,i0,3a)' )&
     164                 :           0 :        'udtset(2) must be between 1 and 9, but it is ',intarr(2),'.',ch10,&
     165                 :           0 :        'Action: change the value of udtset(2) in your input file.'
     166                 :           0 :        ABI_ERROR(msg)
     167                 :             :      end if
     168         [ -  + ]:          55 :      if(intarr(1)*intarr(2) /= ndtset)then
     169                 :             :        write(msg, '(3a,i0,3a,i0,a,i0,3a,i0,3a)' )&
     170                 :           0 :        'udtset(1)*udtset(2) must be equal to ndtset,',ch10,&
     171                 :           0 :        'but it is observed that udtset(1) = ',intarr(1),',',ch10,&
     172                 :           0 :        'and udtset(2) = ',intarr(2),' so that their product is ',intarr(1)*intarr(2),',',ch10,&
     173                 :           0 :        'while ndtset is ',ndtset,'.',ch10,&
     174                 :           0 :        'Action: change udtset or ndtset in your input file.'
     175                 :           0 :        ABI_ERROR(msg)
     176                 :             :      end if
     177                 :          55 :      idtset=0
     178         [ +  + ]:         359 :      do i1=1,intarr(1)
     179         [ +  + ]:        1219 :        do i2=1,intarr(2)
     180                 :         860 :          idtset=idtset+1
     181                 :        1164 :          dtsets(idtset)%jdtset=i1*10+i2
     182                 :             :        end do
     183                 :             :      end do
     184                 :             :    end if
     185                 :             : 
     186                 :             :    ! Final check on the jdtset values
     187         [ +  + ]:        7652 :    do idtset=1,ndtset
     188         [ -  + ]:        7652 :      if(dtsets(idtset)%jdtset<1 .or. dtsets(idtset)%jdtset>9999)then
     189                 :             :        write(msg, '(3a,i0,a,i0,a,a)' )&
     190                 :           0 :        'The components of jdtset must be between 1 and 9999.',ch10,&
     191                 :           0 :        'However, the input value of the component ',idtset,' of jdtset is ',dtsets(idtset)%jdtset,ch10,&
     192                 :           0 :        'Action: correct jdtset in your input file.'
     193                 :           0 :        ABI_ERROR(msg)
     194                 :             :      end if
     195                 :             :    end do
     196                 :             : 
     197                 :             :  else
     198                 :         414 :    dtsets(1)%jdtset=0
     199                 :             :  end if
     200                 :             : 
     201                 :        1456 :  papiopt = 0
     202                 :        1456 :  call intagm(dprarr,intarr,0,1,1,string(1:lenstr),'papiopt',tread,'INT')
     203         [ -  + ]:        1456 :  if(tread==1) papiopt=intarr(1)
     204                 :             : 
     205                 :             :  ! Read timopt and pass it to timab
     206                 :        1456 :  call intagm(dprarr,intarr,0,1,1,string(1:lenstr),'timopt',tread,'INT')
     207         [ +  + ]:        1456 :  if(tread==1) timopt=intarr(1)
     208                 :             : 
     209                 :        1456 :  istatr=0
     210                 :        1456 :  dtsets(0)%istatr=istatr
     211                 :        1456 :  call intagm(dprarr,intarr,0,marr,1,string(1:lenstr),'istatr',tread,'INT')
     212         [ +  + ]:        1456 :  if(tread==1) istatr=intarr(1)
     213         [ +  + ]:        8480 :  dtsets(1:)%istatr=istatr
     214                 :             : 
     215                 :        1456 :  istatshft=1
     216                 :        1456 :  dtsets(0)%istatshft=istatshft
     217                 :        1456 :  call intagm(dprarr,intarr,0,marr,1,string(1:lenstr),'istatshft',tread,'INT')
     218         [ +  + ]:        1456 :  if(tread==1) istatshft=intarr(1)
     219         [ +  + ]:        8480 :  dtsets(1:)%istatshft=istatshft
     220                 :             : 
     221                 :        1456 :  cpus=zero
     222                 :        1456 :  call intagm(dprarr,intarr,0,marr,1,string(1:lenstr),'cpus ',treads,'DPR')
     223         [ -  + ]:        1456 :  if(treads==1) cpus=dprarr(1)
     224                 :        1456 :  call intagm(dprarr,intarr,0,marr,1,string(1:lenstr),'cpum ',treadm,'DPR')
     225         [ -  + ]:        1456 :  if(treadm==1) cpus=dprarr(1)*60.0_dp
     226                 :        1456 :  call intagm(dprarr,intarr,0,marr,1,string(1:lenstr),'cpuh ',treadh,'DPR')
     227                 :             : 
     228         [ -  + ]:        1456 :  if(treadh==1) cpus=dprarr(1)*3600.0_dp
     229         [ -  + ]:        1456 :  if(treads+treadm+treadh>1)then
     230                 :             :    write(msg, '(5a)' )&
     231                 :           0 :    'More than one input variable is used to defined the CPU time limit.',ch10,&
     232                 :           0 :    'This is not allowed.',ch10,&
     233                 :           0 :    'Action: in the input file, suppress either cpus, cpum or cpuh.'
     234                 :           0 :    ABI_ERROR(msg)
     235                 :             :  end if
     236         [ +  + ]:        9936 :  dtsets(:)%cpus=cpus
     237                 :             : 
     238                 :             :  ! Default for natom, nimage, ntypat, useri and userr
     239         [ +  + ]:        9936 :  dtsets(:)%natom=1
     240         [ +  + ]:        9936 :  dtsets(:)%nimage=1
     241         [ +  + ]:        9936 :  dtsets(:)%ntypat=1 ; dtsets(0)%ntypat=0    ! Will always echo ntypat
     242         [ +  + ]:        9936 :  dtsets(:)%macro_uj=0
     243         [ +  + ]:        9936 :  dtsets(:)%maxnsym=384
     244         [ +  + ]:        9936 :  dtsets(:)%useria=0
     245         [ +  + ]:        9936 :  dtsets(:)%userib=0
     246         [ +  + ]:        9936 :  dtsets(:)%useric=0
     247         [ +  + ]:        9936 :  dtsets(:)%userid=0
     248         [ +  + ]:        9936 :  dtsets(:)%userie=0
     249         [ +  + ]:        9936 :  dtsets(:)%userra=zero
     250         [ +  + ]:        9936 :  dtsets(:)%userrb=zero
     251         [ +  + ]:        9936 :  dtsets(:)%userrc=zero
     252         [ +  + ]:        9936 :  dtsets(:)%userrd=zero
     253         [ +  + ]:        9936 :  dtsets(:)%userre=zero
     254         [ +  + ]:        9936 :  dtsets(:)%usewvl = 0
     255         [ +  + ]:        9936 :  dtsets(:)%plowan_compute=0
     256                 :             : 
     257                 :             :  ! Loop on datasets, to find natom and mxnatom, as well as useri and userr
     258         [ +  + ]:        8480 :  do idtset=1,ndtset_alloc
     259         [ +  + ]:        7024 :    jdtset=dtsets(idtset)%jdtset ; if(ndtset==0)jdtset=0
     260                 :             : 
     261                 :             :    !  Generate the supercell if supercell_latt is specified and update string
     262         [ +  + ]:       28096 :    dtsets(idtset)%supercell_latt(:) = 0
     263         [ +  + ]:       28096 :    do ii=1,3
     264                 :       28096 :      dtsets(idtset)%supercell_latt(ii) = 1
     265                 :             :    end do
     266                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),"supercell_latt",tread,'INT')
     267   [ +  +  +  + ]:        7027 :    if (tread==1) dtsets(idtset)%supercell_latt(:)=intarr(1:3)
     268                 :             :    !This test should be update if in the future we allow non-diagonal supercell
     269   [ +  +  +  -  :       28096 :    if (any(dtsets(idtset)%supercell_latt(:) < tol10 )) then
                   -  + ]
     270                 :             :      write(msg, '(5a)' )&
     271                 :           0 :       'supercell_latt must have positive parameters and diagonal part',ch10,&
     272                 :           0 :       'This is not allowed.  ',ch10,&
     273                 :           0 :       'Action: modify supercell_latt in the input file.'
     274                 :           0 :      ABI_ERROR(msg)
     275                 :             :    end if
     276                 :             :    ! Compute the multiplicity of the supercell
     277                 :             :    multiplicity=dtsets(idtset)%supercell_latt(1)  &
     278                 :             : &   *dtsets(idtset)%supercell_latt(2)  &
     279                 :        7024 : &   *dtsets(idtset)%supercell_latt(3)
     280                 :             : !  call mati3det(dtsets(idtset)%supercell_latt,multiplicity)
     281                 :             : 
     282                 :             :    ! Read natom from string
     283                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'natom',tread,'INT')
     284                 :             : 
     285                 :             :    ! or get it from the structure variable
     286                 :             :    call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'structure', tread_geo, &
     287                 :        7024 :                'KEY', key_value=geo_string)
     288                 :             : 
     289         [ +  + ]:        7024 :    if (tread_geo /= 0) then
     290   [ -  +  -  +  :          55 :      geo = geo_from_abivar_string(geo_string, comm)
                   -  + ]
     291         [ -  + ]:          55 :      if (tread /= 0) then
     292         [ #  # ]:           0 :        ABI_CHECK(intarr(1) == geo%natom, "natom from variable and from structure do not agree with each other")
     293                 :             :      end if
     294                 :          55 :      intarr(1) = geo%natom
     295                 :          55 :      tread = 1
     296                 :             :    end if
     297                 :             : 
     298                 :             :    !  Might also initialize natom from XYZ file
     299         [ +  + ]:        7024 :    if (tread==0) call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'_natom',tread,'INT')
     300                 :             : 
     301         [ +  - ]:        7024 :    if (tread==1) then
     302                 :        7024 :      dtsets(idtset)%natom=intarr(1)
     303                 :             :    else
     304                 :             :      write(msg, '(a,i0,2a)' )&
     305                 :           0 :       'Input natom must be defined, but was absent for dataset ',jdtset,ch10,&
     306                 :           0 :       'Action: check the input file.'
     307                 :           0 :      ABI_ERROR(msg)
     308                 :             :    end if
     309                 :             : 
     310                 :             :    ! Check that natom is greater than 0
     311         [ -  + ]:        7024 :    if (dtsets(idtset)%natom<=0) then
     312                 :             :      write(msg, '(a,i0,2a,i0,3a)' )&
     313                 :           0 :       'Input natom must be > 0, but was ',dtsets(idtset)%natom,ch10,&
     314                 :           0 :       'for dataset ',jdtset,'. This is not allowed.',ch10,&
     315                 :           0 :       'Action: check the input file.'
     316                 :           0 :      ABI_ERROR(msg)
     317                 :             :    end if
     318                 :             : 
     319         [ +  + ]:        7024 :    if(multiplicity > 1)then
     320                 :           1 :      dtsets(idtset)%natom = dtsets(idtset)%natom * multiplicity
     321                 :             :    end if
     322                 :             : 
     323                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nimage',tread,'INT')
     324         [ +  + ]:        7024 :    if(tread==1) dtsets(idtset)%nimage=intarr(1)
     325                 :             : 
     326                 :             :    ! Check that nimage is greater than 0
     327         [ -  + ]:        7024 :    if (dtsets(idtset)%nimage<=0) then
     328                 :             :      write(msg, '(a,i0,4a)' )&
     329                 :           0 :       'nimage must be > 0, but was ',dtsets(idtset)%nimage,ch10,&
     330                 :           0 :       'This is not allowed.',ch10,&
     331                 :           0 :       'Action: check the input file.'
     332                 :           0 :      ABI_ERROR(msg)
     333                 :             :    end if
     334                 :             : 
     335                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ntypat',tread,'INT')
     336         [ +  + ]:        7024 :    if (tread==1) dtsets(idtset)%ntypat=intarr(1)
     337                 :             : 
     338         [ +  + ]:        7024 :    if (tread_geo /= 0) then
     339         [ -  + ]:          55 :      if (tread == 1) then
     340         [ #  # ]:           0 :        ABI_CHECK(geo%ntypat == dtsets(idtset)%ntypat, "ntypat and geo%ntypat do not agree with each other")
     341                 :             :      end if
     342                 :          55 :      dtsets(idtset)%ntypat = geo%ntypat
     343                 :             :    end if
     344                 :             : 
     345                 :             :    ! Check that ntypat is greater than 0
     346         [ -  + ]:        7024 :    if (dtsets(idtset)%ntypat<=0) then
     347                 :             :      write(msg, '(a,i0,2a,i0,3a)' )&
     348                 :           0 :       'Input ntypat must be > 0, but was ',dtsets(idtset)%ntypat,ch10,&
     349                 :           0 :       'for dataset ',jdtset,'. This is not allowed.',ch10,&
     350                 :           0 :       'Action: check the input file.'
     351                 :           0 :      ABI_ERROR(msg)
     352                 :             :    end if
     353                 :             : 
     354                 :             :    ! Read msym from string
     355                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'maxnsym',tread,'INT')
     356         [ +  + ]:        7024 :    if(tread==1)dtsets(idtset)%maxnsym=intarr(1)
     357                 :             :    !  Check that maxnsym is greater than 1
     358         [ -  + ]:        7024 :    if (dtsets(idtset)%maxnsym<1) then
     359                 :             :      write(msg, '(a,i0,2a,i0,3a)' )&
     360                 :           0 :       'Input maxnsym must be > 1, but was ',dtsets(idtset)%maxnsym,ch10,&
     361                 :           0 :       'for dataset ',jdtset,'. This is not allowed.',ch10,&
     362                 :           0 :       'Action: check the input file.'
     363                 :           0 :      ABI_ERROR(msg)
     364                 :             :    end if
     365                 :             : 
     366                 :             :    ! Read plowan_compute
     367                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'plowan_compute',tread,'INT')
     368         [ -  + ]:        7024 :    if(tread==1) dtsets(idtset)%plowan_compute=intarr(1)
     369                 :             : 
     370                 :             :    ! Read extfpmd calculations
     371                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'useextfpmd',tread,'INT')
     372         [ +  + ]:        7024 :    if(tread==1) dtsets(idtset)%useextfpmd=intarr(1)
     373                 :             : 
     374                 :             :    ! Read user* variables
     375                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'useria',tread,'INT')
     376         [ +  + ]:        7024 :    if(tread==1) dtsets(idtset)%useria=intarr(1)
     377                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'userib',tread,'INT')
     378         [ -  + ]:        7024 :    if(tread==1) dtsets(idtset)%userib=intarr(1)
     379                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'useric',tread,'INT')
     380         [ -  + ]:        7024 :    if(tread==1) dtsets(idtset)%useric=intarr(1)
     381                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'userid',tread,'INT')
     382         [ -  + ]:        7024 :    if(tread==1) dtsets(idtset)%userid=intarr(1)
     383                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'userie',tread,'INT')
     384         [ -  + ]:        7024 :    if(tread==1) dtsets(idtset)%userie=intarr(1)
     385                 :             : 
     386                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'userra',tread,'DPR')
     387         [ -  + ]:        7024 :    if(tread==1) dtsets(idtset)%userra=dprarr(1)
     388                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'userrb',tread,'DPR')
     389         [ -  + ]:        7024 :    if(tread==1) dtsets(idtset)%userrb=dprarr(1)
     390                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'userrc',tread,'DPR')
     391         [ -  + ]:        7024 :    if(tread==1) dtsets(idtset)%userrc=dprarr(1)
     392                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'userrd',tread,'DPR')
     393         [ -  + ]:        7024 :    if(tread==1) dtsets(idtset)%userrd=dprarr(1)
     394                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'userre',tread,'DPR')
     395         [ -  + ]:        7024 :    if(tread==1) dtsets(idtset)%userre=dprarr(1)
     396                 :             : 
     397                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'usewvl',tread,'INT')
     398         [ -  + ]:        7024 :    if(tread==1) dtsets(idtset)%usewvl=intarr(1)
     399                 :             : 
     400                 :        8480 :    call geo%free()
     401                 :             :  end do ! idtset
     402                 :             : 
     403                 :             : !mxnatom =maxval(dtsets(1:ndtset_alloc)%natom)
     404                 :             : !mxntypat =maxval(dtsets(1:ndtset_alloc)%ntypat)
     405                 :             : !msym =maxval(dtsets(1:ndtset_alloc)%maxnsym)
     406                 :             : !There is a bug in the HP compiler, the following should execute properly
     407                 :        1456 :  mxnatom=dtsets(1)%natom ; mxnimage=dtsets(1)%nimage
     408                 :        1456 :  mxntypat=dtsets(1)%ntypat ; msym=dtsets(1)%maxnsym
     409         [ +  + ]:        1456 :  if(ndtset_alloc>1)then
     410         [ +  + ]:        6578 :    do idtset=2,ndtset_alloc
     411                 :        5568 :      mxnatom =max(dtsets(idtset)%natom,mxnatom)
     412                 :        5568 :      mxnimage=max(dtsets(idtset)%nimage,mxnimage)
     413                 :        5568 :      mxntypat=max(dtsets(idtset)%ntypat,mxntypat)
     414                 :        6578 :      msym    =max(dtsets(idtset)%maxnsym,msym)
     415                 :             :    end do
     416                 :             :  end if
     417                 :             : 
     418         [ +  + ]:        1456 :  if(mxnimage>1)then
     419         [ +  + ]:          51 :    do idtset=2,ndtset_alloc
     420         [ -  + ]:          51 :      if(mxnatom/=dtsets(idtset)%natom)then
     421                 :             :        write(msg,'(5a,i0,a,i0,3a,i0,a)')&
     422                 :           0 :        'When there exist one dataset with more than one image,',ch10,&
     423                 :           0 :        'the number of atoms in each dataset must be the same.',ch10,&
     424                 :           0 :        'However, it has been found that for dataset= ',idtset,ch10,&
     425                 :           0 :        'natom= ',dtsets(idtset)%natom,' differs from the maximum number',ch10,&
     426                 :           0 :        'of atoms, mxnatom= ',mxnatom,&
     427                 :           0 :        'Action: check the input variables natom for different datasets.'
     428                 :           0 :        ABI_ERROR(msg)
     429                 :             :      end if
     430                 :             :    end do
     431                 :             :  end if
     432                 :             : 
     433                 :             :  ! Set up npsp
     434                 :        1456 :  npsp=mxntypat   ! Default value
     435                 :        1456 :  call intagm(dprarr,intarr,0,marr,1,string(1:lenstr),'npsp',tread,'INT')
     436                 :             : 
     437         [ +  + ]:        1456 :  if(tread==1)then
     438                 :          29 :    npsp=intarr(1)
     439                 :             :  else
     440         [ +  + ]:        1427 :    if(ndtset_alloc>1)then
     441         [ +  + ]:        7482 :      do idtset=1,ndtset_alloc
     442         [ -  + ]:        6499 :        if(dtsets(idtset)%ntypat/=mxntypat)then
     443                 :             :          write(msg, '(5a,i0,a,i0,2a,i0,2a)' )&
     444                 :           0 :           ' When npsp is not defined, the input variable ntypat must be',ch10,&
     445                 :           0 :           ' the same for all datasets. However, it has been found that for',ch10,&
     446                 :           0 :           ' jdtset: ',dtsets(idtset)%jdtset,', ntypat= ',dtsets(idtset)%ntypat,ch10,&
     447                 :           0 :           ' differs from the maximum value of ntypat= ',mxntypat,ch10,&
     448                 :           0 :           ' Action: check the input variables npsp and ntypat.'
     449                 :           0 :          ABI_ERROR(msg)
     450                 :             :        end if
     451         [ -  + ]:        7482 :        if(dtsets(idtset)%ntypat>npsp)then
     452                 :             :          write(msg, '(5a,i0,a,i0,a,i0,2a)' )&
     453                 :           0 :           ' The number of pseudopotentials, npsp, must never be smaller than ntypat.',ch10,&
     454                 :           0 :           ' However, it has been found that for',ch10,&
     455                 :           0 :           ' jdtset: ',dtsets(idtset)%jdtset,', ntypat= ',dtsets(idtset)%ntypat,' and npsp=',npsp,ch10,&
     456                 :           0 :           ' Action: check the input variables npsp and ntypat.'
     457                 :           0 :          ABI_ERROR(msg)
     458                 :             :        endif
     459                 :             :      end do
     460                 :             :    end if
     461                 :             :  end if
     462                 :        1456 :  dtsets(0)%npsp = mxntypat   ! Default value
     463         [ +  + ]:        8480 :  dtsets(1:ndtset_alloc)%npsp = npsp
     464                 :             : 
     465                 :             :  ! Read pseudopotential directory and pseudo paths from input.
     466                 :             :  ! Remember that in "files file mode", this info is passed through the files file so these variables are optional
     467                 :        1456 :  pp_dirpath = ""
     468                 :        1456 :  call intagm(dprarr, intarr, 0, marr, 1, string(1:lenstr), 'pp_dirpath', tread, 'KEY', key_value=pp_dirpath)
     469         [ +  + ]:        1456 :  if (tread == 1) then
     470   [ +  +  +  - ]:        1454 :    if (.not. endswith(pp_dirpath, "/")) pp_dirpath = strcat(pp_dirpath, "/")
     471                 :             :  end if
     472                 :             : 
     473                 :             :  ! String must be large enough to contain ntypat filepaths.
     474                 :        1456 :  pseudos_string = ""
     475                 :        1456 :  call intagm(dprarr, intarr, 0, marr, 1, string(1:lenstr), "pseudos", tread_pseudos, 'KEY', key_value=pseudos_string)
     476                 :             : 
     477   [ -  +  +  -  :        4368 :  ABI_MALLOC(pseudo_paths, (npsp))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     478         [ +  + ]:        3428 :  pseudo_paths = ""
     479                 :             : 
     480         [ +  + ]:        1456 :  if (tread_pseudos == 1) then
     481                 :             :    ! Split pseudos_string using comma and transfer results to pseudos_paths
     482                 :             :    ! Make sure string length is large enough and input string is consistent with npsp
     483                 :             :    ! Lot of checks must be done here!
     484                 :             :    !print *, "pseudos_string: ", trim(pseudos_string)
     485   [ +  -  -  +  :        7784 :    ABI_ICALLOC(sidx, (npsp + 1))
          +  -  +  -  +  
          -  -  +  -  +  
                   +  + ]
     486                 :        1454 :    sidx(1) = 1; sidx(npsp + 1) = len(pseudos_string)
     487                 :        1454 :    cnt = 1
     488         [ +  + ]:    11633454 :    do ii=1,len(pseudos_string)
     489         [ +  + ]:    11633454 :      if (pseudos_string(ii:ii) == ",") then
     490                 :         514 :        pseudos_string(ii:ii) = " "
     491                 :         514 :        cnt = cnt + 1
     492                 :         514 :        sidx(cnt) = ii
     493         [ -  + ]:         514 :        ABI_CHECK(cnt <= npsp, "Too many commas in pseudos string!")
     494                 :             :      end if
     495                 :             :    end do
     496         [ -  + ]:        1454 :    if (cnt /= npsp) then
     497                 :             :      write(msg,'(4a)')&
     498                 :           0 :       "Not enough pseudopotentials in input `pseudos` string, expecting npsp: ",itoa(npsp),ch10,&
     499                 :           0 :       "Perhaps the separator (=a comma) is missing between pseudopotentials in input `pseudos` string."
     500                 :           0 :      ABI_ERROR(msg)
     501                 :             :    end if
     502                 :             : 
     503         [ +  + ]:        3422 :    do ii=1,npsp
     504                 :        1968 :      i1 = sidx(ii)
     505                 :        1968 :      i2 = sidx(ii + 1)
     506         [ +  - ]:        1968 :      cnt = len(adjustl(trim(pseudos_string(i1:i2))))
     507         [ -  + ]:        1968 :      ABI_CHECK(cnt <= fnlen, "pseudo path too small, increase fnlen")
     508   [ +  -  +  - ]:        1968 :      pseudo_paths(ii) = adjustl(trim(pseudos_string(i1:i2)))
     509         [ -  + ]:        3422 :      if (len_trim(pp_dirpath) > 0) then
     510         [ -  + ]:        1968 :        if (len_trim(pp_dirpath) + len_trim(pseudo_paths(ii)) > fnlen) then
     511                 :           0 :          ABI_ERROR(sjoin("String of len fnlen:", itoa(fnlen), " too small to contain full pseudo path"))
     512                 :             :        end if
     513         [ +  - ]:        1968 :        pseudo_paths(ii) = strcat(pp_dirpath, pseudo_paths(ii))
     514                 :             :      end if
     515                 :             :    end do
     516                 :        1454 :    ABI_FREE(sidx)
     517                 :             :    !print *, "pp_dirpath: ", trim(pp_dirpath), "pseudos: ", trim(pseudos_string)
     518                 :             :  end if
     519                 :             : 
     520                 :             :  ! KGB parallelism information (needed at this stage)
     521         [ +  + ]:        9936 :  dtsets(:)%paral_kgb=0
     522         [ +  + ]:        8480 :  do idtset=1,ndtset_alloc
     523         [ +  + ]:        7024 :    jdtset=dtsets(idtset)%jdtset ; if(ndtset==0)jdtset=0
     524                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'paral_kgb',tread,'INT')
     525         [ +  + ]:        7024 :    if(tread==1)dtsets(idtset)%paral_kgb=intarr(1)
     526                 :             : 
     527         [ -  + ]:        8480 :    if (dtsets(idtset)%paral_kgb<0 .or. dtsets(idtset)%paral_kgb>1) then
     528                 :             :      write(msg,'(a,i0,2a,i0,3a)')&
     529                 :           0 :       'Input paral_kgb must be 0 or 1, but was ',dtsets(idtset)%paral_kgb,ch10,&
     530                 :           0 :       'for dataset ',jdtset,'. This is not allowed.',ch10,&
     531                 :           0 :       'Action: check the input file.'
     532                 :           0 :      ABI_ERROR(msg)
     533                 :             :    end if
     534                 :             :  end do
     535                 :             : 
     536                 :             :  ! GPU related parameters
     537         [ +  + ]:        9936 :  dtsets(:)%gpu_option=ABI_GPU_DISABLED
     538                 :             : #if defined HAVE_GPU
     539                 :             :  call Get_ndevice(idev)
     540                 :             :  if (idev>0) then
     541                 :             :    do i1=1,ndtset_alloc
     542                 :             :      dtsets(i1)%gpu_option=ABI_GPU_UNKNOWN
     543                 :             :    end do
     544                 :             :  end if
     545                 :             : #else
     546                 :             :  ABI_UNUSED(idev)
     547                 :             : #endif
     548                 :             : 
     549                 :        1456 :  gpu_option=ABI_GPU_DISABLED
     550         [ +  + ]:        8480 :  do idtset=1,ndtset_alloc
     551         [ +  + ]:        7024 :    jdtset=dtsets(idtset)%jdtset ; if(ndtset==0)jdtset=0
     552                 :             : 
     553                 :        7024 :    gpu_option_string = "" ; intarr(1)=0
     554                 :             :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),"gpu_option",tread_gpu_option,'INT_OR_KEY',&
     555                 :        7024 :                key_value=gpu_option_string)
     556         [ +  + ]:        7024 :    if (tread_gpu_option==1) then
     557         [ -  + ]:           1 :      if (len(trim(gpu_option_string))>0) then
     558                 :           0 :        call inupper(gpu_option_string)
     559         [ #  # ]:           0 :        if (trim(gpu_option_string)=="GPU_DISABLED") dtsets(idtset)%gpu_option=ABI_GPU_DISABLED
     560         [ #  # ]:           0 :        if (trim(gpu_option_string)=="GPU_LEGACY")   dtsets(idtset)%gpu_option=ABI_GPU_LEGACY
     561         [ #  # ]:           0 :        if (trim(gpu_option_string)=="GPU_KOKKOS")   dtsets(idtset)%gpu_option=ABI_GPU_KOKKOS
     562         [ #  # ]:           0 :        if (trim(gpu_option_string)=="GPU_OPENMP")   dtsets(idtset)%gpu_option=ABI_GPU_OPENMP
     563                 :             :      else
     564                 :           1 :        dtsets(idtset)%gpu_option=intarr(1)
     565                 :             :      end if
     566                 :             :    end if
     567                 :             : 
     568         [ -  + ]:        8480 :    if (dtsets(idtset)%gpu_option/=ABI_GPU_DISABLED) gpu_option=dtsets(idtset)%gpu_option
     569                 :             :  end do
     570                 :             : 
     571         [ -  + ]:        1456 :  if (gpu_option/=ABI_GPU_DISABLED) then
     572                 :             : #if defined HAVE_GPU
     573                 :             :    if (idev<=0) then
     574                 :             :      write(msg,'(5a)')&
     575                 :             :      'Input variable gpu_option is on (/=0),',ch10,&
     576                 :             :      'but no available GPU device has been detected !',ch10,&
     577                 :             :      'Action: change the input variable gpu_option.'
     578                 :             :      ABI_ERROR(msg)
     579                 :             :    end if
     580                 :             :    if(gpu_option==ABI_GPU_OPENMP) then
     581                 :             : #if !defined HAVE_OPENMP_OFFLOAD
     582                 :             :      write(msg,'(7a)')&
     583                 :             :      'Input variable gpu_option is set to use OpenMP GPU backend but abinit hasn''t been built',ch10,&
     584                 :             :      'with OpenMP GPU offloading enabled!',ch10,&
     585                 :             :      'Action: change the input variable gpu_option',ch10,&
     586                 :             :      '        or re-compile ABINIT with OpenMP GPU offloading enabled.'
     587                 :             :      ABI_ERROR(msg)
     588                 :             : #endif
     589                 :             : #if defined HAVE_OPENMP_OFFLOAD
     590                 :             :      if(xomp_get_num_devices() == 0) then
     591                 :             :        write(msg,'(13a)')&
     592                 :             :        'Input variable gpu_option is set to use OpenMP GPU backend ',ch10,&
     593                 :             :        'but no GPU is visible by OpenMP.',ch10,&
     594                 :             :        'It usually happens when env variable OMP_TARGET_OFFLOAD is set to DISABLED (not default) ',ch10,&
     595                 :             :        'or if there are inconsistencies between GPU driver and compiler ',ch10,&
     596                 :             :        'as to which CUDA version is supported.',ch10,&
     597                 :             :        'Action: check the value OMP_TARGET_OFFLOAD is not set to DISABLED,',ch10,&
     598                 :             :        '        otherwise make sure CUDA/HIP version you use is supported by BOTH your driver and compiler.'
     599                 :             :        ABI_ERROR(msg)
     600                 :             :      end if
     601                 :             : #endif
     602                 :             :    else if(gpu_option==ABI_GPU_KOKKOS) then
     603                 :             : #if !defined HAVE_KOKKOS || !defined HAVE_YAKL
     604                 :             :      write(msg,'(7a)')&
     605                 :             :      'Input variable gpu_option is set to use Kokkos backend but abinit hasn''t been built',ch10,&
     606                 :             :      'with Kokkos and/or YAKL dependencies enabled!',ch10,&
     607                 :             :      'Action: change the input variable gpu_option',ch10,&
     608                 :             :      '        or re-compile ABINIT with BOTH Kokkos and YAKL enabled.'
     609                 :             :      ABI_ERROR(msg)
     610                 :             : #endif
     611                 :             :    end if
     612                 :             : #else
     613                 :             :    write(msg,'(7a)')&
     614                 :           0 :    'Input variable gpu_option is on',ch10,&
     615                 :           0 :    'but ABINIT hasn''t been built with GPU mode enabled!',ch10,&
     616                 :           0 :    'Action: change the input variable gpu_option',ch10,&
     617                 :           0 :    '        or re-compile ABINIT with GPU enabled.'
     618                 :           0 :    ABI_ERROR(msg)
     619                 :             : #endif
     620                 :             :  end if
     621                 :             : 
     622                 :             : !Set gpu_option default value
     623                 :             : !gpu_option=ABI_GPU_UNKNOWN means undetermined
     624         [ +  + ]:        8480 :  do idtset=1,ndtset_alloc
     625         [ -  + ]:        8480 :    if (dtsets(idtset)%gpu_option==ABI_GPU_UNKNOWN) then
     626                 :             :      !FIXME We may want to have GPU enabled by default if a GPU device is available.
     627                 :             :      !      Now, we use CPU to stay safe, as some code section aren't checked for GPU use yet.
     628                 :             : 
     629                 :             : !#if defined HAVE_OPENMP_OFFLOAD
     630                 :             : !     dtsets(idtset)%gpu_option=ABI_GPU_OPENMP
     631                 :             : !#elif defined HAVE_KOKKOS && defined HAVE_YAKL
     632                 :             : !     dtsets(idtset)%gpu_option=ABI_GPU_KOKKOS
     633                 :             : !#elif defined HAVE_GPU_CUDA
     634                 :             : !     dtsets(idtset)%gpu_option=ABI_GPU_LEGACY
     635                 :             : !#else
     636                 :           0 :      dtsets(idtset)%gpu_option=ABI_GPU_DISABLED
     637                 :             : !#endif
     638                 :             :    end if
     639                 :             :  end do
     640                 :             : 
     641         [ -  + ]:        1456 :  ABI_FREE(dprarr)
     642         [ -  + ]:        1456 :  ABI_FREE(intarr)
     643                 :             : 
     644                 :             :  ! We allocate the internal array, depending on the computed values.
     645                 :             :  ! WARNING: do not forget to deallocate these arrays in the routine dtset_free
     646                 :             :  ! (should make a separate subroutine for allocating/deallocating these records)
     647         [ +  + ]:        9936 :  do idtset=0,ndtset_alloc
     648   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%acell_orig,(3,mxnimage))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     649   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%algalch,(mxntypat))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     650   [ -  +  +  -  :       33920 :    ABI_MALLOC(dtsets(idtset)%amu_orig,(mxntypat,mxnimage))
          -  +  +  -  +  
          -  +  -  -  +  
             -  +  -  + ]
     651   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%atndlist,(3,mxnatom))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     652   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%cellcharge,(mxnimage))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     653   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%chrgat,(mxnatom))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     654   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%constraint_kind,(mxntypat))
          -  +  -  +  -  
                      + ]
     655   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%corecs,(mxntypat))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     656   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%densty,(mxntypat,4))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     657   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%dmft_nominal,(mxnatom))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     658   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%dmft_orbital,(mxntypat))
          -  +  -  +  -  
                      + ]
     659   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%dmft_shiftself,(mxnatom))
          -  +  -  +  -  
                      + ]
     660   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%dynimage,(mxnimage))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     661   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%iatfix,(3,mxnatom))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     662   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%iatnd,(mxnatom))
          -  +  -  +  -  
                      + ]
     663   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%f4of2_sla,(mxntypat))
          -  +  -  +  -  
                      + ]
     664   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%f6of2_sla,(mxntypat))
          -  +  -  +  -  
                      + ]
     665   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%jpawu,(mxntypat,mxnimage))
          -  +  +  -  -  
             +  -  +  -  
                      + ]
     666   [ -  +  -  + ]:        8480 :    ABI_MALLOC(dtsets(idtset)%kberry,(3,20))
     667   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%lambsig,(mxntypat))
          -  +  -  +  -  
                      + ]
     668   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%lexexch,(mxntypat))
          -  +  -  +  -  
                      + ]
     669   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%ldaminushalf,(mxntypat))
          -  +  -  +  -  
                      + ]
     670   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%lpawu,(mxntypat))
          -  +  -  +  -  
                      + ]
     671   [ -  +  +  -  :       42400 :    ABI_MALLOC(dtsets(idtset)%mixalch_orig,(npsp,mxntypat,mxnimage))
          -  +  +  -  -  
          +  +  -  +  -  
          +  -  -  +  -  
                +  -  + ]
     672   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%mixesimgf,(mxnimage))
          -  +  -  +  -  
                      + ]
     673   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%nucdipmom,(3,mxnatom))
          -  +  -  +  -  
                      + ]
     674   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%pimass,(mxntypat))
          -  +  -  +  -  
                      + ]
     675   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%ptcharge,(mxntypat))
          -  +  -  +  -  
                      + ]
     676   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%prtatlist,(mxnatom))
          -  +  -  +  -  
                      + ]
     677   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%quadmom,(mxntypat))
          -  +  -  +  -  
                      + ]
     678   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%ratsph,(mxntypat))
          -  +  -  +  -  
                      + ]
     679   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%rprim_orig,(3,3,mxnimage))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     680   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%rprimd_orig,(3,3,mxnimage))
          -  +  -  +  -  
                      + ]
     681   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%so_psp,(npsp))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     682   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%spinat,(3,mxnatom))
          -  +  -  +  -  
                      + ]
     683   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%spinat_cart,(3,mxnatom))
          -  +  -  +  -  
                      + ]
     684   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%spinat_in,(3,mxnatom))
          -  +  -  +  -  
                      + ]
     685   [ -  +  -  + ]:        8480 :    ABI_MALLOC(dtsets(idtset)%shiftk,(3,MAX_NSHIFTK))
     686   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%typat,(mxnatom))
          -  +  -  +  -  
                      + ]
     687   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%upawu,(mxntypat,mxnimage))
          -  +  +  -  -  
             +  -  +  -  
                      + ]
     688   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%plowan_iatom,(mxnatom))
          -  +  -  +  -  
                      + ]
     689   [ -  +  -  + ]:        8480 :    ABI_MALLOC(dtsets(idtset)%plowan_it,(100*3))
     690   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%plowan_nbl,(mxnatom))
          -  +  -  +  -  
                      + ]
     691   [ +  -  -  +  :       25440 :    ABI_MALLOC(dtsets(idtset)%plowan_lcalc,(12*mxnatom))
          +  -  +  -  +  
          -  -  +  -  +  
                   -  + ]
     692   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%plowan_projcalc,(12*mxnatom))
          -  +  -  +  -  
                      + ]
     693   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%rcpaw_rctypat,(mxntypat))
          -  +  -  +  -  
                      + ]
     694   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%rcpaw_sc,(mxntypat))
          -  +  -  +  -  
                      + ]
     695   [ -  +  +  -  :       33920 :    ABI_MALLOC(dtsets(idtset)%vel_orig,(3,mxnatom,mxnimage))
          -  +  +  -  +  
          -  +  -  -  +  
             -  +  -  + ]
     696   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%vel_cell_orig,(3,3,mxnimage))
          -  +  -  +  -  
                      + ]
     697   [ -  +  +  -  :       25440 :    ABI_MALLOC(dtsets(idtset)%xred_orig,(3,mxnatom,mxnimage))
          -  +  +  -  -  
             +  -  +  -  
                      + ]
     698   [ -  +  +  -  :       16960 :    ABI_MALLOC(dtsets(idtset)%ziontypat,(mxntypat))
          -  +  -  +  -  
                      + ]
     699   [ -  +  +  -  :       26896 :    ABI_MALLOC(dtsets(idtset)%znucl,(npsp))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     700                 :             :  end do
     701                 :             : 
     702                 :             :  !write(std_out,*)' invars0 : nimage, mxnimage = ',dtsets(:)%nimage, mxnimage
     703                 :             :  !write(std_out,*)' invars0 : natom = ',dtsets(:)%natom
     704                 :             :  !write(std_out,*)' invars0 : mxnatom = ',mxnatom
     705                 :             :  !write(std_out,*)' m_invars1%invars0 : exit '; call flush(std_out)
     706                 :             : 
     707   [ -  +  -  +  :        1456 : end subroutine invars0
                   -  + ]
     708                 :             : !!***
     709                 :             : 
     710                 :             : !!****f* ABINIT/invars1m
     711                 :             : !! NAME
     712                 :             : !! invars1m
     713                 :             : !!
     714                 :             : !! FUNCTION
     715                 :             : !! Initialisation phase: prepare the main input subroutine call by
     716                 :             : !! reading all the NO MULTI variables, as well as the dimensions
     717                 :             : !! needed for allocating the input arrays in abinit.
     718                 :             : !!
     719                 :             : !! INPUTS
     720                 :             : !!  iout=unit number of output file
     721                 :             : !!  lenstr=actual length of string
     722                 :             : !!  msym=default maximal number of symmetries
     723                 :             : !!  mxnatom=maximal value of input natom for all the datasets
     724                 :             : !!  mxnimage=maximal value of input nimage for all the datasets
     725                 :             : !!  ndtset= number of datasets to be read; if 0, no multi-dataset mode
     726                 :             : !!  ndtset_alloc=number of datasets, corrected for allocation of at least one data set.
     727                 :             : !!  npsp= number of pseudopotential files
     728                 :             : !!  string*(*)=string of characters containing all input variables and data
     729                 :             : !!  zionpsp(npsp)= valence charge over all psps
     730                 :             : !!  comm=MPI communicator
     731                 :             : !!
     732                 :             : !! OUTPUT
     733                 :             : !!  dmatpuflag=flag controlling the use of an initial density matrix in PAW+U (max. value over datasets)
     734                 :             : !!  mband_upper_(0:ndtset_alloc)=list of mband_upper values
     735                 :             : !!
     736                 :             : !! SIDE EFFECTS
     737                 :             : !!  dtsets(0:ndtset_alloc)=<type datafiles_type>contains all input variables,
     738                 :             : !!   some of which are initialized here (see invars1.f for more details on the initialized records)
     739                 :             : !!  mx<ab_dimensions>=datatype storing the maximal dimensions. Partly initialized in input.
     740                 :             : !!
     741                 :             : !! SOURCE
     742                 :             : 
     743                 :        1456 : subroutine invars1m(dmatpuflag, dtsets, iout, lenstr, mband_upper_, mx,&
     744                 :        1456 :                     msym, ndtset, ndtset_alloc, string, npsp, zionpsp, comm)
     745                 :             : 
     746                 :             : !Arguments ------------------------------------
     747                 :             : !scalars
     748                 :             :  integer,intent(in) :: iout,lenstr,msym,ndtset,ndtset_alloc,npsp, comm
     749                 :             :  integer,intent(out) :: dmatpuflag
     750                 :             :  character(len=*),intent(inout) :: string
     751                 :             :  type(ab_dimensions),intent(inout) :: mx
     752                 :             : !arrays
     753                 :             :  integer,intent(out) :: mband_upper_(0:ndtset_alloc)
     754                 :             :  type(dataset_type),intent(inout) :: dtsets(0:ndtset_alloc)
     755                 :             :  real(dp),intent(in) :: zionpsp(npsp)
     756                 :             : 
     757                 :             : !Local variables-------------------------------
     758                 :             : !scalars
     759                 :             :  integer :: idtset,ii,jdtset,lpawu,mband_upper,iatom,nat,nsp
     760                 :             : !arrays
     761                 :        1456 :  integer,allocatable :: symafm_(:,:),symrel_(:,:,:,:), symafm(:),symrel(:,:,:)
     762                 :        1456 :  real(dp),allocatable :: tnons_(:,:,:),tnons(:,:)
     763                 :             : !******************************************************************
     764                 :             : 
     765                 :             :  !write(std_out,'(a)')' m_invars1%invars1m : enter '; call flush(std_out)
     766                 :             : 
     767                 :             :  ! Here, allocation of the arrays that depend on msym.
     768   [ -  +  +  -  :        5824 :  ABI_MALLOC(symrel_,(3,3,msym,0:ndtset_alloc))
          -  +  +  -  +  
          -  +  -  -  +  
                   -  + ]
     769   [ -  +  +  -  :        5824 :  ABI_MALLOC(symafm_,(msym,0:ndtset_alloc))
          -  +  +  -  +  
          -  +  -  -  +  
                   -  + ]
     770   [ -  +  +  -  :        5824 :  ABI_MALLOC(tnons_,(3,msym,0:ndtset_alloc))
          -  +  +  -  +  
          -  +  -  -  +  
                   -  + ]
     771   [ -  +  +  -  :        4368 :  ABI_MALLOC(symafm,(msym))
          +  -  +  -  -  
                +  -  + ]
     772   [ -  +  +  -  :        4368 :  ABI_MALLOC(symrel,(3,3,msym))
          +  -  +  -  -  
                +  -  + ]
     773   [ -  +  +  -  :        4368 :  ABI_MALLOC(tnons,(3,msym))
          +  -  +  -  -  
                +  +  - ]
     774                 :             : 
     775                 :             :  ! Set up default values (note that the default acell, amu mkmem, mkmem1,mkqmem, and nkpt must be overcome
     776         [ +  + ]:        9936 :  do idtset=0,ndtset_alloc
     777                 :        9936 :    call indefo1(dtsets(idtset))
     778                 :             :  end do
     779                 :             : 
     780                 :             :  ! natom and nimage are already initialized in invars0
     781                 :        1456 :  dtsets(0)%natom=-1
     782                 :        1456 :  dtsets(0)%nimage=1
     783                 :             : 
     784                 :             : !Initialization for parallelization data has changed
     785                 :             : !these lines aim to keep old original default values
     786                 :        1456 :  dtsets(0)%npimage=1
     787                 :        1456 :  dtsets(0)%np_spkpt=1
     788                 :        1456 :  dtsets(0)%npspinor=1
     789                 :        1456 :  dtsets(0)%npfft=1
     790                 :        1456 :  dtsets(0)%npband=1
     791                 :        1456 :  dtsets(0)%bandpp=1
     792                 :        1456 :  dtsets(0)%nblock_lobpcg=1
     793                 :             : 
     794         [ +  + ]:      560224 :  symafm_(:,0)=1
     795   [ +  +  +  +  :     7265440 :  symrel_(:,:,:,0)=0
                   +  + ]
     796   [ +  +  +  +  :     1680672 :  symrel_(1,1,:,0)=1 ; symrel_(2,2,:,0)=1 ; symrel_(3,3,:,0)=1
                   +  + ]
     797   [ +  +  +  + ]:     2236528 :  tnons_(:,:,0)=0.0_dp
     798                 :             : 
     799                 :             :  ! Loop on datasets
     800         [ +  + ]:        8466 :  do idtset=1,ndtset_alloc
     801         [ +  + ]:        7024 :    jdtset=dtsets(idtset)%jdtset ; if(ndtset==0)jdtset=0
     802                 :        7024 :    write(std_out,'(2a)') ch10,'======================================================= '
     803                 :        7024 :    write(std_out,'(a,i0)') ' invars1m : enter jdtset= ',jdtset
     804                 :             : 
     805                 :             :    ! Input default values
     806         [ +  + ]:       84288 :    dtsets(idtset)%bravais(:)=0
     807         [ +  + ]:     2703232 :    symafm(:)=symafm_(:,0)
     808   [ +  +  +  +  :    35057728 :    symrel(:,:,:)=symrel_(:,:,:,0)
                   +  + ]
     809   [ +  +  +  + ]:    10791856 :    tnons(:,:)=tnons_(:,:,0)
     810                 :             : 
     811                 :             :    call invars1(dtsets(idtset)%bravais,dtsets(idtset),iout,jdtset,lenstr,&
     812                 :        7024 :                 mband_upper,msym,npsp,string,symafm,symrel,tnons,zionpsp, comm)
     813                 :             : 
     814                 :        7010 :    mband_upper_ (idtset)=mband_upper
     815         [ +  + ]:     2697842 :    symafm_(:,idtset)=symafm(:)
     816   [ +  +  +  +  :    34987826 :    symrel_(:,:,:,idtset)=symrel(:,:,:)
                   +  + ]
     817   [ +  +  +  + ]:    10771780 :    tnons_(:,:,idtset)=tnons(:,:)
     818                 :             :  end do
     819                 :             : 
     820         [ +  + ]:        8452 :  mx%mband_upper = maxval(mband_upper_ (1:ndtset_alloc))
     821                 :             : 
     822                 :        1442 :  dmatpuflag = 0; mx%natpawu = 0; mx%lpawu = 0
     823                 :        1442 :  mx%natsph = dtsets(1)%natsph
     824                 :        1442 :  mx%natsph_extra = dtsets(1)%natsph_extra
     825                 :        1442 :  mx%natvshift = dtsets(1)%natvshift
     826                 :        1442 :  mx%nconeq = dtsets(1)%nconeq
     827                 :        1442 :  mx%n_efmas_dirs=0
     828                 :        1442 :  mx%ga_n_rules = dtsets(1)%ga_n_rules
     829                 :        1442 :  mx%gw_nqlwl = dtsets(1)%gw_nqlwl
     830                 :        1442 :  mx%nimfrqs = 0
     831                 :        1442 :  mx%nfreqsp = 0
     832                 :        1442 :  mx%n_projection_frequencies = 0
     833                 :        1442 :  mx%nkpt  = dtsets(1)%nkpt
     834                 :        1442 :  mx%nkptgw = dtsets(1)%nkptgw
     835                 :        1442 :  mx%nkpthf = dtsets(1)%nkpthf
     836                 :        1442 :  mx%nnos  = dtsets(1)%nnos
     837                 :        1442 :  mx%nqptdm = dtsets(1)%nqptdm
     838                 :        1442 :  mx%nspinor = dtsets(1)%nspinor
     839                 :        1442 :  mx%nsppol = dtsets(1)%nsppol
     840                 :        1442 :  mx%ntypat = dtsets(1)%ntypat
     841                 :        1442 :  mx%nzchempot = dtsets(1)%nzchempot
     842                 :        1442 :  mx%nberry = 20   ! This is presently a fixed value. Should be changed.
     843                 :             : 
     844                 :             :  ! Get MAX dimension over datasets
     845         [ +  + ]:        8452 :  do ii=1,ndtset_alloc
     846                 :        7010 :    mx%natsph = max(dtsets(ii)%natsph, mx%natsph)
     847                 :        7010 :    mx%natsph_extra=max(dtsets(ii)%natsph_extra, mx%natsph_extra)
     848                 :        7010 :    mx%nconeq=max(dtsets(ii)%nconeq, mx%nconeq)
     849                 :        7010 :    mx%n_efmas_dirs = max(dtsets(ii)%efmas_n_dirs, mx%n_efmas_dirs)
     850                 :        7010 :    mx%ga_n_rules = max(dtsets(ii)%ga_n_rules,mx%ga_n_rules)
     851                 :        7010 :    mx%gw_nqlwl = max(dtsets(ii)%gw_nqlwl,mx%gw_nqlwl)
     852                 :        7010 :    mx%nimfrqs = max(dtsets(ii)%cd_customnimfrqs, mx%nimfrqs)
     853                 :        7010 :    mx%nfreqsp = max(dtsets(ii)%gw_customnfreqsp, mx%nfreqsp)
     854                 :        7010 :    mx%n_projection_frequencies = max(dtsets(ii)%gwls_n_proj_freq, mx%n_projection_frequencies)
     855                 :        7010 :    mx%nkpt  = max(dtsets(ii)%nkpt, mx%nkpt)
     856                 :        7010 :    mx%nkptgw = max(dtsets(ii)%nkptgw, mx%nkptgw)
     857                 :        7010 :    mx%nkpthf = max(dtsets(ii)%nkpthf, mx%nkpthf)
     858                 :        7010 :    mx%nnos  = max(dtsets(ii)%nnos, mx%nnos)
     859                 :        7010 :    mx%nqptdm = max(dtsets(ii)%nqptdm, mx%nqptdm)
     860                 :        7010 :    mx%nspinor = max(dtsets(ii)%nspinor, mx%nspinor)
     861                 :        7010 :    mx%nsppol = max(dtsets(ii)%nsppol, mx%nsppol)
     862                 :        7010 :    mx%ntypat = max(dtsets(ii)%ntypat, mx%ntypat)
     863                 :        7010 :    mx%nzchempot = max(dtsets(ii)%nzchempot, mx%nzchempot)
     864         [ +  + ]:        7010 :    if (dtsets(ii)%usepawu/=0) then
     865   [ +  +  +  + ]:         155 :      if (dtsets(ii)%usepawu>0.and.dtsets(ii)%usedmatpu/=0) dmatpuflag=1
     866         [ +  + ]:         392 :      lpawu=maxval(dtsets(ii)%lpawu(:))
     867                 :         155 :      mx%lpawu=max(lpawu,mx%lpawu)
     868                 :             :      !dtsets(ii)%natpawu=count(dtsets(ii)%lpawu(dtsets(ii)%typat((/(i1,i1=1,dtsets(ii)%natom)/)))/=-1)
     869                 :             :      ! Old fashion way that should do fine
     870                 :         155 :      dtsets(ii)%natpawu = 0
     871         [ +  + ]:         506 :      do iatom=1, dtsets(ii)%natom
     872         [ +  + ]:         506 :        if (dtsets(ii)%lpawu(dtsets(ii)%typat(iatom)) /= -1 ) dtsets(ii)%natpawu = dtsets(ii)%natpawu + 1
     873                 :             :      end do
     874                 :         155 :      mx%natpawu = max(dtsets(ii)%natpawu, mx%natpawu)
     875         [ +  + ]:         155 :      if (dtsets(ii)%macro_uj/=0) dtsets(ii)%natvshift=lpawu*2+1
     876                 :             :    end if
     877                 :        8452 :    mx%natvshift = max(dtsets(ii)%natvshift, mx%natvshift)
     878                 :             :  end do
     879                 :             : 
     880                 :             : !mx%nsym=maxval(dtsets(1:ndtset_alloc)%nsym) ! This might not work properly with HP compiler
     881                 :        1442 :  mx%nsym=dtsets(1)%nsym
     882         [ +  + ]:        8452 :  do idtset=1,ndtset_alloc
     883                 :        8452 :    mx%nsym = max(dtsets(idtset)%nsym, mx%nsym)
     884                 :             :  end do
     885                 :             : 
     886         [ +  + ]:        9894 :  do idtset=0,ndtset_alloc
     887   [ +  +  +  -  :       42260 :    ABI_MALLOC(dtsets(idtset)%atvshift, (mx%natvshift, mx%nsppol, mx%natom))
          -  +  +  -  -  
          +  +  -  +  -  
          +  +  -  +  -  
                +  -  + ]
     888   [ -  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%bs_loband,(mx%nsppol))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     889   [ +  +  +  -  :       33808 :    ABI_MALLOC(dtsets(idtset)%bdgw,(2, mx%nkptgw, mx%nsppol))
          -  +  +  -  +  
          -  +  +  -  +  
             -  +  -  + ]
     890   [ +  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%cd_imfrqs,(mx%nimfrqs))
          +  -  +  +  -  
             +  -  +  -  
                      + ]
     891   [ +  +  +  -  :       33808 :    ABI_MALLOC(dtsets(idtset)%chempot,(3, mx%nzchempot, mx%ntypat))
          -  +  +  -  +  
          -  +  +  -  +  
             -  +  -  + ]
     892                 :        8452 :    nsp = max(mx%nsppol, mx%nspinor); nat = mx%natpawu*dmatpuflag
     893   [ +  -  -  +  :       59164 :    ABI_MALLOC(dtsets(idtset)%dmatpawu,(2*mx%lpawu+1,2*mx%lpawu+1,nsp,nat, mx%nimage))
          +  -  -  +  +  
          -  -  +  +  -  
          +  +  +  -  -  
          +  +  -  +  -  
          +  +  -  +  -  
                +  -  + ]
     894   [ -  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%efmas_bands,(2, mx%nkpt))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     895   [ +  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%efmas_dirs,(3, mx%n_efmas_dirs))
          +  -  +  +  -  
             +  -  +  -  
                      + ]
     896   [ +  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%gw_freqsp, (mx%nfreqsp))
          +  -  +  +  -  
             +  -  +  -  
                      + ]
     897   [ +  -  -  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%gwls_list_proj_freq, (mx%n_projection_frequencies))
          +  -  -  +  -  
             +  -  +  -  
                      + ]
     898   [ +  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%gw_qlwl,(3,mx%gw_nqlwl))
          +  -  +  +  -  
             +  -  +  -  
                      + ]
     899   [ -  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%kpt,(3, mx%nkpt))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     900   [ +  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%kptgw,(3, mx%nkptgw))
          +  -  +  +  -  
             +  -  +  -  
                      + ]
     901   [ -  +  +  -  :       16904 :    ABI_MALLOC(dtsets(idtset)%kptns,(3, mx%nkpt))
          -  +  -  +  -  
                      + ]
     902   [ +  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%kptns_hf,(3, mx%nkpthf))
          +  -  +  +  -  
             +  -  +  -  
                      + ]
     903   [ -  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%iatsph,(mx%natsph))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     904   [ -  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%istwfk, (mx%nkpt))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     905   [ -  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%nband, (mx%nkpt*mx%nsppol))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     906   [ -  +  +  -  :       33808 :    ABI_MALLOC(dtsets(idtset)%occ_orig,(mx%mband_upper*mx%nkpt*mx%nsppol, mx%nimage))
          -  +  +  -  +  
          -  +  -  -  +  
             -  +  -  + ]
     907   [ +  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%qmass, (mx%nnos))
          +  -  +  +  -  
             +  -  +  -  
                      + ]
     908   [ +  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%qptdm,(3, mx%nqptdm))
          +  -  +  +  -  
             +  -  +  -  
                      + ]
     909   [ -  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%symafm, (mx%nsym))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     910   [ -  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%symrel,(3,3,mx%nsym))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     911   [ -  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%tnons,(3,mx%nsym))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     912   [ -  +  +  -  :       33808 :    ABI_MALLOC(dtsets(idtset)%wtatcon,(3,mx%natom, mx%nconeq))
          +  +  +  -  +  
          -  +  +  -  +  
             -  +  -  + ]
     913   [ -  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%wtk, (mx%nkpt))
          +  -  +  -  -  
             +  -  +  -  
                      + ]
     914   [ +  +  +  -  :       25356 :    ABI_MALLOC(dtsets(idtset)%xredsph_extra,(3, mx%natsph_extra))
          +  -  +  +  -  
             +  -  +  -  
                      + ]
     915   [ +  +  +  +  :     2967408 :    dtsets(idtset)%symrel(:,:,:)=symrel_(:,:,1:mx%nsym,idtset)
                   +  + ]
     916         [ +  + ]:      236064 :    dtsets(idtset)%symafm(:)    =symafm_(1:mx%nsym,idtset)
     917   [ +  +  +  + ]:      920342 :    dtsets(idtset)%tnons (:,:)  =tnons_ (:,1:mx%nsym,idtset)
     918                 :             :  end do
     919                 :             : 
     920         [ -  + ]:        1442 :  ABI_FREE(symafm_)
     921         [ -  + ]:        1442 :  ABI_FREE(symrel_)
     922         [ -  + ]:        1442 :  ABI_FREE(tnons_)
     923         [ -  + ]:        1442 :  ABI_FREE(symafm)
     924         [ -  + ]:        1442 :  ABI_FREE(symrel)
     925         [ -  + ]:        1442 :  ABI_FREE(tnons)
     926                 :             : 
     927                 :             :  !write(std_out,'(a)')' m_invars1%invars1m : exit '; call flush(std_out)
     928                 :             : 
     929                 :        1442 : end subroutine invars1m
     930                 :             : !!***
     931                 :             : 
     932                 :             : !!****f* ABINIT/indefo1
     933                 :             : !! NAME
     934                 :             : !! indefo1
     935                 :             : !!
     936                 :             : !! FUNCTION
     937                 :             : !! Initialisation phase: defaults values for a first batch of input variables
     938                 :             : !! (especially dimensions, needed to allocate other parts of dtsets, as well
     939                 :             : !!  as other input variables whose existence is needed for other initialisations to proceed).
     940                 :             : !!
     941                 :             : !! INPUTS
     942                 :             : !!
     943                 :             : !! OUTPUT
     944                 :             : !!  dtset=<type datafiles_type>contains all input variables for one dataset,
     945                 :             : !!   some of which are given a default value here.
     946                 :             : !!
     947                 :             : !! SOURCE
     948                 :             : 
     949                 :        8480 : subroutine indefo1(dtset)
     950                 :             : 
     951                 :             : !Arguments ------------------------------------
     952                 :             : !scalars
     953                 :             :  type(dataset_type),intent(inout) :: dtset
     954                 :             : 
     955                 :             : !Local variables -------------------------------
     956                 :             : !scalars
     957                 :             :  !integer :: ii
     958                 :             : !******************************************************************
     959                 :             : 
     960                 :             : !Set up default values. All variables to be output in outvars.f
     961                 :             : !should have a default, even if a nonsensible one can be chosen to guarantee print in that routine.
     962                 :             : 
     963                 :             :  DBG_ENTER("COLL")
     964                 :             : 
     965                 :             : !Use alphabetic order
     966                 :             : 
     967                 :             : !A
     968   [ +  +  +  + ]:       44004 :  dtset%acell_orig(:,:)=zero
     969         [ +  + ]:       19126 :  dtset%algalch(:)=1
     970   [ +  +  +  + ]:      249120 :  dtset%atndlist(:,:)=zero
     971   [ +  +  +  + ]:       28740 :  dtset%amu_orig(:,:)=-one
     972                 :        8480 :  dtset%autoparal=0
     973                 :             : !B
     974                 :        8480 :  dtset%bandpp=1
     975                 :        8480 :  dtset%berryopt=0
     976                 :        8480 :  dtset%berrysav=0
     977         [ +  + ]:       33920 :  dtset%bfield(:)=zero
     978                 :             : !C
     979                 :        8480 :  dtset%cd_customnimfrqs=0
     980                 :        8480 :  dtset%chkprim=1
     981         [ +  + ]:       68640 :  dtset%chrgat(:)=zero
     982         [ +  + ]:       19126 :  dtset%constraint_kind(:)=0
     983                 :             : !D
     984   [ +  +  +  + ]:       84984 :  dtset%densty(:,:)=zero
     985         [ +  + ]:       33920 :  dtset%dfield(:)=zero    !!HONG
     986         [ +  + ]:       17361 :  dtset%dynimage(:)=1
     987                 :             : !E
     988         [ +  + ]:       33920 :  dtset%efield(:)=zero
     989                 :        8480 :  dtset%efmas_calc_dirs=0
     990                 :        8480 :  dtset%efmas_n_dirs=0
     991                 :             : !F
     992         [ +  + ]:       33920 :  dtset%field_red(:)=zero
     993         [ +  + ]:       33920 :  dtset%field_red_axial(:)=zero
     994                 :             : !G
     995                 :        8480 :  dtset%ga_n_rules=1
     996                 :        8480 :  dtset%gw_customnfreqsp=0
     997                 :        8480 :  dtset%gw_nqlwl=0
     998                 :        8480 :  dtset%gwls_n_proj_freq=0
     999                 :             : !H
    1000         [ +  + ]:       33920 :  dtset%hspinfield(:)=zero
    1001         [ +  + ]:       33920 :  dtset%hspinfield_cart(:)=zero
    1002         [ +  + ]:       33920 :  dtset%hspinfield_in(:)=zero
    1003                 :             : !I
    1004   [ +  +  +  + ]:      249120 :  dtset%iatfix(:,:)=0
    1005         [ +  + ]:       68640 :  dtset%iatnd(:)=0
    1006                 :        8480 :  dtset%icoulomb=0
    1007                 :        8480 :  dtset%imgmov=0
    1008                 :        8480 :  dtset%ivalence=0
    1009                 :             : !J
    1010                 :        8480 :  dtset%jellslab=0
    1011         [ +  + ]:       33920 :  dtset%jfielddir(:)=0
    1012                 :             : !K
    1013                 :        8480 :  dtset%kptopt=0
    1014                 :             : !L
    1015         [ +  + ]:       19126 :  dtset%lexexch(:)=-1
    1016         [ +  + ]:       19126 :  dtset%ldaminushalf(:)=0
    1017         [ +  + ]:       19126 :  dtset%lpawu(:)=-1
    1018                 :             : !M
    1019                 :        8480 :  dtset%maxestep=0.005d0
    1020   [ +  +  +  +  :       45594 :  dtset%mixalch_orig(:,:,:)=zero
                   +  + ]
    1021                 :        8480 :  dtset%mkmem=-1
    1022                 :        8480 :  dtset%mkqmem=-1
    1023                 :        8480 :  dtset%mk1mem=-1
    1024                 :             : !N
    1025                 :        8480 :  dtset%natnd=0
    1026                 :        8480 :  dtset%natpawu=0
    1027                 :        8480 :  dtset%natsph=0
    1028                 :        8480 :  dtset%natsph_extra=0
    1029                 :        8480 :  dtset%natvshift=0
    1030                 :        8480 :  dtset%nblock_lobpcg=1
    1031                 :        8480 :  dtset%nconeq=0
    1032                 :        8480 :  dtset%ndynimage=1
    1033                 :        8480 :  dtset%ne_qFD=zero
    1034                 :        8480 :  dtset%nh_qFD=zero
    1035                 :        8480 :  dtset%nkpt=-1
    1036                 :        8480 :  dtset%nkptgw=0
    1037                 :        8480 :  dtset%nkpthf=0
    1038                 :        8480 :  dtset%nnos=0
    1039                 :        8480 :  dtset%npband=1
    1040                 :        8480 :  dtset%npfft=1
    1041                 :        8480 :  dtset%nphf=1
    1042                 :        8480 :  dtset%npimage=1
    1043                 :        8480 :  dtset%np_spkpt=1
    1044                 :        8480 :  dtset%nppert=1
    1045                 :        8480 :  dtset%npspalch=0
    1046                 :        8480 :  dtset%npspinor=1
    1047                 :        8480 :  dtset%np_slk=1000000
    1048                 :        8480 :  dtset%nslice=2
    1049                 :        8480 :  dtset%nstep_mixed=0
    1050                 :        8480 :  dtset%nqptdm=0
    1051                 :        8480 :  dtset%nspden=1
    1052                 :        8480 :  dtset%nspinor=1
    1053                 :        8480 :  dtset%nsppol=1
    1054                 :        8480 :  dtset%nsym=0     ! Actually, this default value is not used : it is to be reimposed before each call to ingeo in invars1
    1055                 :        8480 :  dtset%ntimimage=1
    1056                 :        8480 :  dtset%ntypalch=0
    1057                 :        8480 :  dtset%ntyppure=-1
    1058   [ +  +  +  + ]:      249120 :  dtset%nucdipmom(:,:)=zero
    1059                 :        8480 :  dtset%nzchempot=0
    1060                 :             : !O
    1061                 :        8480 :  dtset%optdriver=0
    1062                 :             : !P
    1063                 :        8480 :  dtset%paral_rf=0
    1064                 :        8480 :  dtset%paral_slice=0
    1065                 :             : !dtset%paral_kgb ! Is even initialized earlier.
    1066                 :        8480 :  dtset%pawspnorb=0  ! will be changed to 1 as soon as usepaw==1 and nspinor==2
    1067         [ +  + ]:       19126 :  dtset%pimass(:)=-one
    1068                 :             : !Q
    1069         [ +  + ]:       33920 :  dtset%qptn=zero
    1070                 :             : !R
    1071         [ +  + ]:       33920 :  dtset%red_efield(:)=zero
    1072         [ +  + ]:       33920 :  dtset%red_dfield(:)=zero
    1073         [ +  + ]:       33920 :  dtset%red_efieldbar(:)=zero
    1074   [ +  +  +  +  :      123933 :  dtset%rprim_orig(:,:,:)=zero
                   +  + ]
    1075         [ +  + ]:       17361 :  dtset%rprim_orig(1,1,:)=one
    1076         [ +  + ]:       17361 :  dtset%rprim_orig(2,2,:)=one
    1077         [ +  + ]:       17361 :  dtset%rprim_orig(3,3,:)=one
    1078                 :             : !S
    1079                 :        8480 :  dtset%slabzbeg=zero
    1080                 :        8480 :  dtset%slabzend=zero
    1081         [ +  + ]:       19154 :  dtset%so_psp(:)=1
    1082   [ +  +  +  + ]:      249120 :  dtset%spinat(:,:)=zero
    1083   [ +  +  +  + ]:      249120 :  dtset%spinat_cart(:,:)=zero
    1084   [ +  +  +  + ]:      249120 :  dtset%spinat_in(:,:)=zero
    1085         [ +  + ]:       25440 :  dtset%spinaxis(1:2)=zero
    1086                 :        8480 :  dtset%spinaxis(3)=1
    1087                 :             : !T
    1088                 :        8480 :  dtset%tfkinfunc=0
    1089         [ +  + ]:       68640 :  dtset%typat(:)=0  ! This init is important because dimension of typat is mx%natom (and not natom).
    1090                 :             : !U
    1091                 :        8480 :  dtset%use_gbt=0
    1092                 :        8480 :  dtset%usedmatpu=0
    1093                 :        8480 :  dtset%usedmft=0
    1094                 :        8480 :  dtset%useexexch=0
    1095                 :        8480 :  dtset%usepawu=0
    1096                 :        8480 :  dtset%usepotzero=0
    1097                 :        8480 :  dtset%use_slk=0
    1098                 :        8480 :  dtset%use_oldchi=1
    1099                 :             : !V
    1100   [ +  +  +  +  :      262393 :  dtset%vel_orig(:,:,:)=zero
                   +  + ]
    1101   [ +  +  +  +  :      123933 :  dtset%vel_cell_orig(:,:,:)=zero
                   +  + ]
    1102                 :             : !W
    1103                 :        8480 :  dtset%wtq=zero
    1104         [ +  + ]:        8480 :  if (dtset%usepaw==0) dtset%wfoptalg=0
    1105         [ +  + ]:        8480 :  if (dtset%usepaw/=0) dtset%wfoptalg=10
    1106         [ +  + ]:        8480 :  if (dtset%optdriver==RUNL_GSTATE.and.dtset%paral_kgb>0) dtset%wfoptalg=14
    1107                 :        8480 :  dtset%wvl_bigdft_comp=1
    1108                 :             : 
    1109                 :             : !X
    1110   [ +  +  +  +  :      262393 :  dtset%xred_orig(:,:,:)=zero
                   +  + ]
    1111                 :             : !Y
    1112                 :             : !Z
    1113                 :        8480 :  dtset%zora=0
    1114                 :             : 
    1115                 :             :  DBG_EXIT("COLL")
    1116                 :             : 
    1117                 :        8480 : end subroutine indefo1
    1118                 :             : !!***
    1119                 :             : 
    1120                 :             : !!****f* ABINIT/invars1
    1121                 :             : !! NAME
    1122                 :             : !! invars1
    1123                 :             : !!
    1124                 :             : !! FUNCTION
    1125                 :             : !! Initialize the dimensions needed to allocate the input arrays
    1126                 :             : !! for one dataset characterized by jdtset, by taking from string the necessary data.
    1127                 :             : !! Perform some preliminary checks and echo these dimensions.
    1128                 :             : !!
    1129                 :             : !! INPUTS
    1130                 :             : !!  iout=unit number of output file
    1131                 :             : !!  jdtset=number of the dataset looked for
    1132                 :             : !!  lenstr=actual length of string
    1133                 :             : !!  msym=default maximal number of symmetries
    1134                 :             : !!  npsp1= number of pseudopotential files
    1135                 :             : !!  zionpsp(npsp1)= valence charge over all psps
    1136                 :             : !!  comm= MPI communicator
    1137                 :             : !!
    1138                 :             : !! OUTPUT
    1139                 :             : !!  mband_upper=estimation of the maximum number of bands for any k-point
    1140                 :             : !!
    1141                 :             : !! SIDE EFFECTS
    1142                 :             : !! Input/Output (the default value is given in the calling routine)
    1143                 :             : !!  dtset=<type datafiles_type>contains all input variables,
    1144                 :             : !!   some of which are initialized here, while other were already
    1145                 :             : !!   initialized, while some others will still be initialized later.
    1146                 :             : !!   The list of records of dtset initialized in the present routine is:
    1147                 :             : !!
    1148                 :             : !!       acell_orig,chrgat,densty,iatfix,kptopt,kptrlatt,
    1149                 :             : !!       mkmem,mkqmem,mk1mem,natsph,natvshift,nconeq,nkpt,nkptgw,nkpthf,
    1150                 :             : !!       nqptdm,nshiftk,nucdipmom,nzchempot,optdriver,
    1151                 :             : !!       rprim_orig,rprimd_orig,shiftk,
    1152                 :             : !!       spgroup,spinat,typat,vel_orig,vel_cell_orig,xred_orig
    1153                 :             : !!
    1154                 :             : !!  bravais(11)=characteristics of Bravais lattice (see symlatt.F90)
    1155                 :             : !!  symafm(1:msym)=(anti)ferromagnetic part of symmetry operations
    1156                 :             : !!  symrel(3,3,1:msym)=symmetry operations in real space in terms of primitive translations
    1157                 :             : !!  tnons(3,1:msym)=nonsymmorphic translations for symmetry operations
    1158                 :             : !!  string*(*)=string of characters containing all input variables and data
    1159                 :             : !!
    1160                 :             : !! NOTES
    1161                 :             : !! Must set up the geometry of the system, needed to compute k point grids in an automatic fashion.
    1162                 :             : !! Treat separately mband_upper, since fband, cellcharge and zionpsp must be known for being able to initialize it.
    1163                 :             : !!
    1164                 :             : !! Defaults are provided in the calling routine.
    1165                 :             : !! Defaults are also provided here for the following variables:
    1166                 :             : !!
    1167                 :             : !!      mband_upper, occopt, fband, cellcharge
    1168                 :             : !!
    1169                 :             : !! They should be kept consistent with defaults of the same variables provided to the invars routines.
    1170                 :             : !!
    1171                 :             : !! SOURCE
    1172                 :             : 
    1173                 :        7024 : subroutine invars1(bravais,dtset,iout,jdtset,lenstr,mband_upper,msym,npsp1,&
    1174                 :        7024 : & string,symafm,symrel,tnons,zionpsp, comm)
    1175                 :             : 
    1176                 :             : !Arguments ------------------------------------
    1177                 :             : !scalars
    1178                 :             :  integer,intent(in) :: iout,jdtset,lenstr,msym,npsp1, comm
    1179                 :             :  integer,intent(out) :: mband_upper
    1180                 :             :  character(len=*),intent(inout) :: string
    1181                 :             :  type(dataset_type),intent(inout) :: dtset
    1182                 :             : !arrays
    1183                 :             :  integer,intent(inout) :: bravais(11),symafm(msym),symrel(3,3,msym)
    1184                 :             :  real(dp),intent(inout) :: tnons(3,msym)
    1185                 :             :  real(dp),intent(in) :: zionpsp(npsp1)
    1186                 :             : 
    1187                 :             : !Local variables-------------------------------
    1188                 :             : !scalars
    1189                 :             :  integer,parameter :: master = 0
    1190                 :             :  integer :: chksymbreak,expert_user,found,ierr,iatom,ii,ikpt,iimage,index_blank,index_lower, tread_geo
    1191                 :             :  integer :: index_typsymb,index_upper,ipsp,iscf,intimage,itypat,leave,marr
    1192                 :             :  integer :: natnd,natom,nkpt,nkpthf,npsp,npspalch, ncid
    1193                 :             :  integer :: nqpt,nspinor,nsppol,ntypat,ntypalch,ntyppure,occopt,response
    1194                 :             :  integer :: rfddk,rfelfd,rfphon,rfstrs,rf2_dkdk,rf2_dkde,rfmagn
    1195                 :             :  integer :: tfband,tnband,tread,tread_alt,tread_cart, my_rank, nprocs
    1196                 :             :  real(dp) :: cellcharge,cellcharge_min, fband,kptnrm,kptrlen,sum_spinat,zelect,zval
    1197                 :             :  character(len=1) :: blank=' ',string1
    1198                 :             :  character(len=2) :: string2,symbol
    1199                 :             :  character(len=500) :: msg
    1200                 :             :  type(atomdata_t) :: atom
    1201                 :             : !arrays
    1202                 :             :  integer :: cond_values(4),vacuum(3), units(2)
    1203                 :        7024 :  integer,allocatable :: iatfix(:,:),iatnd(:),intarr(:),istwfk(:),nband(:),typat(:)
    1204                 :             :  real(dp) :: acell(3),rprim(3,3),field_loc(3),field_cart(3),hloc(3,1),hcart(3,1)
    1205                 :        7024 :  real(dp),allocatable :: amu(:),atndlist(:,:),chrgat(:),dprarr(:),kpt(:,:),kpthf(:,:),mixalch(:,:)
    1206                 :        7024 :  real(dp),allocatable :: nucdipmom(:,:),ratsph(:),reaalloc(:),spinat(:,:),spinat_cart(:,:)
    1207                 :        7024 :  real(dp),allocatable :: vel(:,:),vel_cell(:,:),wtk(:),xred(:,:),znucl(:)
    1208                 :             :  character(len=32) :: cond_string(4)
    1209                 :             :  character(len=fnlen) :: key_value
    1210                 :        7024 :  character(len=len(string)) :: geo_string
    1211                 :        7024 :  type(geo_t) :: geo
    1212                 :             : !************************************************************************
    1213                 :             : 
    1214                 :             :  !write(std_out,'(a)')' m_invars1%invars1 : enter '; call flush(std_out)
    1215                 :             : 
    1216                 :        7024 :  my_rank = xmpi_comm_rank(comm); nprocs = xmpi_comm_size(comm)
    1217         [ +  + ]:       21072 :  units = [std_out, ab_out]
    1218                 :             : 
    1219                 :             :  ! This counter is incremented when we find a non-critical error.
    1220                 :             :  ! The code outputs a warning and stops at end.
    1221                 :        7024 :  leave = 0
    1222                 :             : 
    1223                 :             :  ! Some initialisations
    1224                 :        7024 :  ierr=0
    1225         [ +  + ]:       35120 :  cond_string(1:4)=' '
    1226                 :        7024 :  cond_values(1:4)=(/0,0,0,0/)
    1227                 :             : 
    1228                 :             :  ! Read parameters
    1229         [ +  + ]:        7024 :  marr=dtset%npsp;if (dtset%npsp<3) marr=3
    1230                 :        7024 :  marr=max(marr,dtset%nimage)
    1231   [ -  +  +  -  :       21072 :  ABI_MALLOC(intarr,(marr))
          +  -  +  -  -  
                +  -  + ]
    1232   [ -  +  +  -  :       21072 :  ABI_MALLOC(dprarr,(marr))
          +  -  +  -  -  
                +  -  + ]
    1233                 :             : 
    1234                 :             : !---------------------------------------------------------------------------
    1235                 :             : 
    1236                 :        7024 :  rfddk=0; rfelfd=0; rfphon=0; rfmagn=0; rfstrs=0; rf2_dkdk=0; rf2_dkde=0
    1237                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfddk',tread,'INT')
    1238         [ +  + ]:        7024 :  if(tread==1) rfddk=intarr(1)
    1239                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfelfd',tread,'INT')
    1240         [ +  + ]:        7024 :  if(tread==1) rfelfd=intarr(1)
    1241                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfmagn',tread,'INT')
    1242         [ +  + ]:        7024 :  if(tread==1) rfmagn=intarr(1)
    1243                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfphon',tread,'INT')
    1244         [ +  + ]:        7024 :  if(tread==1) rfphon=intarr(1)
    1245                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfstrs',tread,'INT')
    1246         [ +  + ]:        7024 :  if(tread==1) rfstrs=intarr(1)
    1247                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rf2_dkdk',tread,'INT')
    1248         [ +  + ]:        7024 :  if(tread==1) rf2_dkdk=intarr(1)
    1249                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rf2_dkde',tread,'INT')
    1250         [ +  + ]:        7024 :  if(tread==1) rf2_dkde=intarr(1)
    1251                 :             : 
    1252                 :        7024 :  response=0
    1253         [ +  + ]:        7024 :  if(rfddk/=0.or.rf2_dkdk/=0.or.rf2_dkde/=0.or.rfelfd/=0.or.rfphon/=0.or.rfstrs/=0.or.rfmagn/=0)response=1
    1254                 :             : 
    1255                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'optdriver',tread,'INT')
    1256         [ +  + ]:        7024 :  if (tread==1) then
    1257                 :         645 :    dtset%optdriver=intarr(1)
    1258                 :             :  else
    1259                 :             :    ! If optdriver was not read, while response=1, set optdriver to 1
    1260         [ +  + ]:        6379 :    if(response==1)dtset%optdriver=1
    1261                 :             :  end if
    1262                 :             : 
    1263                 :             : !---------------------------------------------------------------------------
    1264                 :             : !For now, waiting express parallelisation for recursion
    1265                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tfkinfunc',tread,'INT')
    1266         [ +  + ]:        7024 :  if(tread==1) dtset%tfkinfunc=intarr(1)
    1267                 :             : 
    1268                 :             : !---------------------------------------------------------------------------
    1269                 :             : ! wvl_bigdft_comp, done here since default values of nline, nwfshist and iscf depend on its value (see indefo)
    1270         [ -  + ]:        7024 :  if(dtset%usewvl==1) then
    1271                 :           0 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wvl_bigdft_comp',tread,'INT')
    1272         [ #  # ]:           0 :    if(tread==1) dtset%wvl_bigdft_comp=intarr(1)
    1273                 :             :  end if
    1274                 :             : 
    1275                 :             : !---------------------------------------------------------------------------
    1276                 :             : 
    1277                 :        7024 :  natom=dtset%natom
    1278                 :        7024 :  npsp=dtset%npsp
    1279                 :        7024 :  ntypat=dtset%ntypat
    1280                 :             : 
    1281                 :             :  call intagm(dprarr, intarr, jdtset, marr, 1, string(1:lenstr), 'structure', tread_geo, &
    1282                 :        7024 :              'KEY', key_value=geo_string)
    1283                 :             : 
    1284         [ +  + ]:        7024 :  if (tread_geo == 0) then
    1285                 :             :    ! No default value for znucl
    1286                 :        6969 :    call intagm(dprarr,intarr,jdtset,marr,dtset%npsp,string(1:lenstr),'znucl',tread,'DPR')
    1287   [ +  -  +  + ]:       15557 :    if(tread==1) dtset%znucl(1:dtset%npsp)=dprarr(1:dtset%npsp)
    1288                 :             : 
    1289         [ -  + ]:        6969 :    if(tread/=1)then
    1290                 :             :      write(msg, '(3a)' )&
    1291                 :           0 :      'The array znucl MUST be initialized in the input file while this is not done.',ch10,&
    1292                 :           0 :      'Action: initialize znucl in your input file.'
    1293                 :           0 :      ABI_ERROR(msg)
    1294                 :             :    end if
    1295                 :             : 
    1296                 :             :  else
    1297                 :          55 :    call wrtout(std_out, sjoin(" Initializing lattice and positions from:", geo_string))
    1298   [ -  +  -  +  :          55 :    geo = geo_from_abivar_string(geo_string, comm)
                   -  + ]
    1299         [ +  + ]:         169 :    dtset%znucl(1:dtset%ntypat) = geo%znucl
    1300                 :          55 :    call geo%free()
    1301                 :             :  end if
    1302                 :             : 
    1303                 :             :  ! The default for ratsph has already been initialized
    1304                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,dtset%ntypat,string(1:lenstr),'ratsph',tread,'LEN')
    1305         [ +  + ]:        7024 :  if(tread==1)then
    1306         [ +  + ]:         151 :    do ii=1,dtset%ntypat
    1307                 :         151 :      dtset%ratsph(ii)=dprarr(ii)
    1308                 :             :    end do
    1309                 :             :  end if
    1310   [ -  +  +  -  :       21072 :  ABI_MALLOC(ratsph,(dtset%ntypat))
          +  -  +  -  -  
                +  -  + ]
    1311         [ +  + ]:       15706 :  do ii=1,dtset%ntypat
    1312                 :       15706 :    ratsph(ii)=dtset%ratsph(ii)
    1313                 :             :  end do
    1314                 :             : 
    1315                 :             : !Special treatment of _TYPAX (from a XYZ file), taking into account
    1316                 :             : !the fact that znucl does NOT depend on the dataset
    1317                 :             : !Examine all occurrences of '_TYPAX'
    1318                 :             : 
    1319                 :             :  do
    1320                 :        7025 :    index_typsymb=index(string(1:lenstr),'_TYPAX')
    1321         [ +  + ]:        7025 :    if(index_typsymb==0)exit
    1322                 :             : !  Replace '_TYPAX' by '_TYPAT'
    1323                 :           1 :    string(index_typsymb:index_typsymb+5)='_TYPAT'
    1324                 :           1 :    index_upper=index_typsymb+5
    1325                 :             : !  Must start from the first blank after the tag (including possible dtset_char)
    1326                 :           1 :    index_upper=index(string(index_upper:lenstr),blank)+index_upper-1
    1327                 :           1 :    index_lower=index_upper
    1328                 :             : 
    1329                 :             : !  Examine all atoms (the end of the symbol string is delimited by a XX )
    1330                 :             :    do
    1331                 :           6 :      index_blank=index(string(index_upper:lenstr),blank)+index_upper-1
    1332                 :           6 :      string2=string(index_blank+1:index_blank+2)
    1333         [ +  + ]:           6 :      if(string2=="XX")exit
    1334                 :           5 :      found=0
    1335                 :             : !    Find the matching symbol
    1336         [ +  + ]:          15 :      do ipsp=1,dtset%npsp
    1337                 :          10 :        call atomdata_from_znucl(atom,dtset%znucl(ipsp))
    1338                 :          10 :        symbol = atom%symbol
    1339                 :          10 :        call inupper(symbol)
    1340                 :          10 :        call inupper(string2)
    1341                 :             : !      write(std_out,'(a)')' invars1 : before test, trim(adjustl(symbol)),trim(adjustl(string2))'
    1342                 :             : !      write(std_out,'(5a)' )'"',trim(adjustl(symbol)),'","',trim(adjustl(string2)),'"'
    1343         [ +  + ]:          25 :        if(trim(adjustl(symbol))==trim(adjustl(string2)))then
    1344                 :           5 :          found=1
    1345                 :           5 :          index_upper=index_blank+1
    1346                 :             :          ! Cannot deal properly with more that 9 psps
    1347         [ -  + ]:           5 :          if(ipsp>=10)then
    1348                 :           0 :            ABI_ERROR('Need to use a pseudopotential with number larger than 9. Not allowed yet.')
    1349                 :             :          end if
    1350                 :             : 
    1351                 :             :          ! write(std_out,*)' invars1 : found ipsp=',ipsp
    1352                 :           5 :          write(string1,'(i1)')ipsp
    1353                 :           5 :          string(index_lower:index_lower+1)=blank//string1
    1354                 :           5 :          index_lower=index_lower+2
    1355                 :             :        end if
    1356                 :             :      end do ! ipsp
    1357                 :             : !    if not found ...
    1358         [ +  - ]:           6 :      if(found==0)then
    1359                 :             :        write(msg,'(6a)' )&
    1360                 :           0 : &       'Did not find matching pseudopotential for XYZ atomic symbol,',ch10,&
    1361                 :           0 : &       'with value ',string2,ch10,&
    1362                 :           0 : &       'Action: check that the atoms required by the XYZ file correspond to one psp file.'
    1363                 :           0 :        ABI_ERROR(msg)
    1364                 :             :      end if
    1365                 :             :    end do ! Loop on atoms
    1366                 :             : !  One should find blanks after the last significant type value
    1367   [ -  +  +  - ]:        7025 :    string(index_lower:index_blank+2)=blank
    1368                 :             :  end do ! loop to identify _TYPAX
    1369                 :             : 
    1370                 :             : !---------------------------------------------------------------------------
    1371                 :             : 
    1372                 :             : ! Here, set up quantities that are related to geometrical description of the system (acell,rprim,xred), as well as
    1373                 :             : ! initial velocity(vel), cellcharge (to compute mband_upper) and spin of atoms (chrgat,spinat), nuclear dipole moments of atoms (nucdipmom),
    1374                 :             : ! the symmetries (symrel,symafm, and tnons) and the list of fixed atoms (iatfix,iatfixx,iatfixy,iatfixz).
    1375                 :             : ! Arrays have already been dimensioned thanks to the knowledge of msym and mx%natom
    1376                 :             : 
    1377                 :             : !ji: We need to read the electric field before calling ingeo
    1378                 :             : !****** Temporary ******
    1379                 :             : 
    1380                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'berryopt',tread,'INT')
    1381         [ +  + ]:        7024 :  if(tread==1) dtset%berryopt=intarr(1)
    1382                 :             : 
    1383                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'berrysav',tread,'INT')
    1384         [ -  + ]:        7024 :  if(tread==1) dtset%berrysav=intarr(1)
    1385                 :             : 
    1386                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'bfield',tread,'DPR')
    1387   [ +  +  +  + ]:        7075 :  if (tread==1) dtset%bfield(1:3) = dprarr(1:3)
    1388                 :             : 
    1389                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'dfield',tread,'DPR')
    1390   [ -  +  -  - ]:        7024 :  if (tread==1) dtset%dfield(1:3) = dprarr(1:3)
    1391                 :             : 
    1392                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'efield',tread,'DPR')
    1393   [ +  +  +  + ]:        7111 :  if (tread==1) dtset%efield(1:3) = dprarr(1:3)
    1394                 :             : 
    1395                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'red_dfield',tread,'DPR')
    1396   [ -  +  -  - ]:        7024 :  if (tread==1) dtset%red_dfield(1:3) = dprarr(1:3)
    1397                 :             : 
    1398                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'red_efield',tread,'DPR')
    1399   [ -  +  -  - ]:        7024 :  if (tread==1) dtset%red_efield(1:3) = dprarr(1:3)
    1400                 :             : 
    1401                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'red_efieldbar',tread,'DPR')
    1402   [ -  +  -  - ]:        7024 :  if (tread==1) dtset%red_efieldbar(1:3) = dprarr(1:3)
    1403                 :             : 
    1404                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'jfielddir',tread,'INT')
    1405   [ -  +  -  - ]:        7024 :  if(tread==1) dtset%jfielddir(1:3)=intarr(1:3)
    1406                 :             : 
    1407                 :             :  ! read in natnd and initialize iatnd, atndlist helper variables
    1408                 :             :  ! these provide a simpler alternative to inputting the full nucdipmom list
    1409                 :        7024 :  natnd=0
    1410                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'natnd',tread,'INT')
    1411         [ +  + ]:        7024 :  if(tread==1) natnd=intarr(1)
    1412                 :        7024 :  dtset%natnd=natnd
    1413   [ +  +  +  -  :       21072 :  ABI_MALLOC(iatnd,(natnd))
          +  -  +  +  -  
                +  -  + ]
    1414   [ +  +  +  -  :       21072 :  ABI_MALLOC(atndlist,(3,natnd))
          +  -  +  +  -  
                +  -  + ]
    1415   [ +  +  +  +  :        7114 :  iatnd(:)=0; atndlist(:,:)=zero
                   +  + ]
    1416                 :             : 
    1417                 :             :  ! We need to know nsppol/nspinor/nspden before calling ingeo
    1418                 :        7024 :  nsppol=dtset%nsppol
    1419                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nsppol',tread,'INT')
    1420         [ +  + ]:        7024 :  if(tread==1) nsppol=intarr(1)
    1421                 :             : 
    1422                 :             : !Alternate SIESTA definition of nsppol
    1423                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'SpinPolarized',tread_alt,'LOG')
    1424         [ +  + ]:        7024 :  if(tread_alt==1)then
    1425         [ -  + ]:           1 :    if(tread==1)then
    1426                 :           0 :      msg = 'nsppol and SpinPolarized cannot be specified simultaneously for the same dataset.'
    1427                 :           0 :      ABI_ERROR_NOSTOP(msg, leave)
    1428                 :             :    else
    1429                 :             : !    Note that SpinPolarized is a logical input variable
    1430                 :           1 :      nsppol=1
    1431         [ +  - ]:           1 :      if(intarr(1)==1)nsppol=2
    1432                 :             :      tread=1
    1433                 :             :    end if
    1434                 :             :  end if
    1435                 :        7024 :  dtset%nsppol=nsppol
    1436                 :             : 
    1437                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'spinaxis',tread,'DPR')
    1438   [ +  +  +  + ]:        7030 :  if (tread==1) dtset%spinaxis(1:3) = dprarr(1:3)
    1439                 :             : 
    1440                 :             : ! here are ZORA, nspinor, pawspnorb flags
    1441                 :             : ! flag for ZORA (zeroth order regularized approximation for relativistic terms)
    1442                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'zora',tread,'INT')
    1443         [ +  + ]:        7024 :  if (tread == 1) dtset%zora = intarr(1)
    1444                 :             : 
    1445                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nspinor',tread,'INT')
    1446         [ +  + ]:        7024 :  if(tread==1) dtset%nspinor=intarr(1)
    1447                 :             : 
    1448                 :             : !Has to read pawspnorb now, in order to adjust nspinor
    1449                 :             : !Also, if nspinor=2, turn on spin-orbit coupling by default, here for the PAW case. NC case is treated elsewhere.
    1450         [ +  + ]:        7024 :  if (dtset%usepaw>0)then
    1451                 :             : !  Change the default value
    1452         [ +  + ]:        1214 :    if(dtset%nspinor==2)dtset%pawspnorb=1
    1453                 :        1214 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'pawspnorb',tread,'INT')
    1454         [ +  + ]:        1214 :    if(tread==1)then
    1455                 :          64 :      dtset%pawspnorb=intarr(1)
    1456         [ +  + ]:          64 :      if(dtset%pawspnorb>0) dtset%nspinor=2
    1457                 :             :    else
    1458         [ +  + ]:        1150 :      if(dtset%nspinor==2)then
    1459                 :          97 :        write(msg, '(4a)' ) ch10,&
    1460                 :          97 :        ' invars1: COMMENT -',ch10,&
    1461                 :         194 :        '  With nspinor=2 and usepaw=1, pawspnorb=1 has been switched on by default.'
    1462                 :          97 :        call wrtout(iout, msg,'COLL')
    1463                 :             :      end if
    1464                 :             :    end if
    1465                 :             :  end if
    1466         [ +  + ]:        7024 :  if ( (dtset%zora .GT. 1) .OR. (dtset%zora < 0) ) then
    1467                 :          14 :    dtset%nspinor=2
    1468                 :          14 :    dtset%pawspnorb=1
    1469                 :             :  end if
    1470                 :        7024 :  nspinor=dtset%nspinor
    1471                 :             : 
    1472                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nspden',tread,'INT')
    1473         [ +  + ]:        7024 :  if(tread==1) then
    1474                 :         510 :    dtset%nspden=intarr(1)
    1475                 :             :  else
    1476                 :        6514 :    dtset%nspden=dtset%nsppol
    1477                 :             :  end if
    1478                 :             : 
    1479                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ntypalch',tread,'INT')
    1480         [ +  + ]:        7024 :  if(tread==1) dtset%ntypalch=intarr(1)
    1481                 :             : 
    1482                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nzchempot',tread,'INT')
    1483         [ +  + ]:        7024 :  if(tread==1) dtset%nzchempot=intarr(1)
    1484                 :             : 
    1485                 :        7024 :  ntypalch=dtset%ntypalch
    1486         [ -  + ]:        7024 :  if(ntypalch>ntypat)then
    1487                 :             :    write(msg, '(3a,i0,a,i0,a,a)' )&
    1488                 :           0 :     'The input variable ntypalch must be smaller than ntypat, while it is',ch10,&
    1489                 :           0 :     'ntypalch=',dtset%ntypalch,', and ntypat=',ntypat,ch10,&
    1490                 :           0 :     'Action: check ntypalch vs ntypat in your input file.'
    1491                 :           0 :    ABI_ERROR(msg)
    1492                 :             :  end if
    1493                 :             : 
    1494                 :        7024 :  ntyppure=ntypat-ntypalch
    1495                 :        7024 :  dtset%ntyppure=ntyppure
    1496                 :        7024 :  npspalch=npsp-ntyppure
    1497                 :        7024 :  dtset%npspalch=npspalch
    1498         [ -  + ]:        7024 :  if(npspalch<0)then
    1499                 :             :    write(msg, '(a,i0,2a,i0,a,a)' )&
    1500                 :           0 :     'The number of available pseudopotentials, npsp=',npsp,ch10,&
    1501                 :           0 :     'is smaller than the requested number of types of pure atoms, ntyppure=',ntyppure,ch10,&
    1502                 :           0 :     'Action: check ntypalch versus ntypat and npsp in your input file.'
    1503                 :           0 :    ABI_ERROR(msg)
    1504                 :             :  end if
    1505                 :             : 
    1506         [ +  + ]:        7024 :  if(ntypalch>0)then
    1507                 :          20 :    call intagm(dprarr,intarr,jdtset,marr,ntypalch,string(1:lenstr),'algalch',tread,'INT')
    1508   [ +  +  +  + ]:          23 :    if(tread==1) dtset%algalch(1:ntypalch)=intarr(1:ntypalch)
    1509         [ -  + ]:          20 :    if (tread_geo /= 0) then
    1510                 :           0 :      ABI_ERROR("Alchemical mixing cannot be used with geo variable, use typat, znucl etc.")
    1511                 :             :    end if
    1512                 :             :  end if
    1513                 :             : 
    1514                 :             : !Read the hspinfield
    1515                 :        7024 :  field_loc(:) = zero; field_cart(:) = zero
    1516                 :        7024 :  hloc(:,1) = zero; hcart(:,1) = zero
    1517                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'hspinfield',tread,'BFI')
    1518         [ +  + ]:        7024 :  if(tread==0) then
    1519                 :        7012 :    call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'zeemanfield',tread,'BFI')
    1520         [ -  + ]:        7012 :    if (tread == 1) then
    1521                 :             :      write(msg, '(3a)')&
    1522                 :           0 :       'Input variable "zeemanfield" is deprecated.', ch10, &
    1523                 :           0 :       'Its value has been assigned to "hspinfield", please update your input.'
    1524                 :           0 :      ABI_COMMENT(msg)
    1525                 :             :    end if
    1526                 :             :  end if
    1527                 :             : 
    1528         [ +  + ]:        7024 :  if (tread == 1) then
    1529         [ +  + ]:          48 :    field_loc(1:3) = dprarr(1:3)
    1530         [ +  + ]:          48 :    dtset%hspinfield_in(1:3)=field_loc(1:3)
    1531                 :             :  end if
    1532                 :             : 
    1533                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'hspinfield_cart',tread_cart,'BFI')
    1534         [ -  + ]:        7024 :  if (tread_cart==1) then
    1535         [ #  # ]:           0 :    field_cart(1:3) = dprarr(1:3)
    1536         [ #  # ]:           0 :    dtset%hspinfield_cart(1:3) = field_cart(1:3)
    1537                 :             :  end if
    1538                 :             : 
    1539                 :        7024 :  hloc(:,1)  = field_loc(:); hcart(:,1) = field_cart(:)
    1540                 :        7024 :  call checkspvec('hspinfield',1,dtset%spinaxis,tread,tread_cart,hloc,hcart)
    1541         [ +  + ]:       28096 :  dtset%hspinfield(1:3) = hloc(:,1)
    1542   [ +  +  -  +  :        7024 :  if (tread == 0 .and. tread_cart == 1) dtset%hspinfield_in(1:3) = hloc(:,1)
                   -  - ]
    1543   [ +  +  +  -  :        7060 :  if (tread == 1 .and. tread_cart == 0) dtset%hspinfield_cart(1:3) = hcart(:,1)
                   +  + ]
    1544                 :             : 
    1545   [ +  +  -  + ]:        7024 :  if(tread==1 .or. tread_cart==1) then
    1546         [ +  + ]:          12 :    if(dtset%nspden == 2)then
    1547                 :             :      write(msg,'(7a)')&
    1548                 :           2 :       'A spin magnetic field (hspinfield) has been specified without noncollinear spins.',ch10,&
    1549                 :           4 :       'Only the z-component of the magnetic field will be used.'
    1550                 :           2 :      ABI_WARNING(msg)
    1551         [ -  + ]:          10 :    else if (dtset%nspden == 1)then
    1552                 :             :      write(msg, '(a,a,a)' )&
    1553                 :           0 :       'A spin magnetic field (hspinfield) has been specified for a non-spin-polarized calculation.',ch10,&
    1554                 :           0 :       'Action: check the input file.'
    1555                 :           0 :      ABI_ERROR(msg)
    1556                 :             :    end if
    1557                 :             :  end if
    1558                 :             : 
    1559                 :             : !Initialize geometry of the system, for different images. Also initialize cellcharge_min to be used later for estimating mband_upper..
    1560   [ -  +  +  -  :       21072 :  ABI_MALLOC(amu,(ntypat))
          +  -  +  -  -  
                +  -  + ]
    1561   [ +  +  +  -  :       28096 :  ABI_MALLOC(mixalch,(npspalch,ntypalch))
          +  +  +  -  +  
          -  +  +  -  +  
                   -  + ]
    1562   [ -  +  +  -  :       21072 :  ABI_MALLOC(vel,(3,natom))
          +  -  +  -  -  
                +  -  + ]
    1563         [ -  + ]:        7024 :  ABI_MALLOC(vel_cell,(3,3))
    1564   [ -  +  +  -  :       14048 :  ABI_MALLOC(xred,(3,natom))
             -  +  -  + ]
    1565                 :             : !Only take into account negative cellcharge, to compute maximum number of bands, so initialize cellcharge_min to zero
    1566                 :        7024 :  cellcharge_min=zero
    1567         [ +  + ]:        7024 :  intimage=2 ; if(dtset%nimage==1)intimage=1
    1568         [ +  + ]:       14353 :  do ii=1,dtset%nimage+1
    1569                 :       14308 :    iimage=ii
    1570   [ +  +  +  + ]:       14308 :    if(dtset%nimage==1 .and. ii==2)exit
    1571   [ +  +  +  + ]:        7334 :    if(dtset%nimage==2 .and. ii==3)exit
    1572   [ +  +  +  + ]:        7329 :    if(dtset%nimage> 2 .and. ii==intimage)cycle ! Will do the intermediate reference image at the last reading
    1573   [ +  +  +  + ]:        7284 :    if(dtset%nimage>=2 .and. ii==dtset%nimage+1)iimage=intimage
    1574                 :             : 
    1575         [ +  + ]:        7284 :    if (dtset%nimage /= 1) call wrtout(std_out, sjoin(' invars1: treat image number: ',itoa(iimage)))
    1576                 :             : 
    1577                 :             : !  Need to reset nsym to default value for each image
    1578                 :        7284 :    dtset%nsym=0
    1579                 :             : 
    1580                 :             : !  Call ingeo for each image in turn, with the possible default values
    1581         [ +  + ]:       29136 :    acell=dtset%acell_orig(1:3,iimage)
    1582   [ +  -  -  +  :       23722 :    amu=dtset%amu_orig(1:ntypat,iimage)
             -  -  +  + ]
    1583   [ +  -  +  -  :       14646 :    mixalch=dtset%mixalch_orig(1:npspalch,1:ntypalch,iimage)
          -  +  -  -  +  
                +  +  + ]
    1584   [ +  +  +  + ]:       94692 :    rprim=dtset%rprim_orig(1:3,1:3,iimage)
    1585   [ +  -  -  +  :      169940 :    vel=dtset%vel_orig(1:3,1:natom,iimage)
          -  -  +  +  +  
                      + ]
    1586   [ -  +  +  +  :      101976 :    vel_cell=dtset%vel_cell_orig(1:3,1:3,iimage)
                   +  + ]
    1587   [ +  -  -  +  :      169940 :    xred=dtset%xred_orig(1:3,1:natom,iimage)
          -  -  +  +  +  
                      + ]
    1588                 :             : 
    1589                 :             : ! if getxred or getxcart we need to import xred before entering ingeo.
    1590                 :             : ! NB: xred/cart might be re-updated at runtime after running source dtset
    1591                 :             : !   call intagm(dprarr,intarr,source_dtset,marr,3,string(1:lenstr),'getxred',tread,'INT')
    1592                 :             : !   if (tread==1 .or. tread_geo==1)
    1593                 :             : !     source_dtset =
    1594                 :             : !     if (== -1) source_dtset = jdtset-1
    1595                 :             : !   end if
    1596                 :             : !   call intagm(dprarr,intarr,source_dtset,marr,3,string(1:lenstr),'getxcart',tread_geo,'INT')
    1597                 :             : !
    1598                 :             : 
    1599   [ -  +  +  -  :       21852 :    ABI_MALLOC(chrgat,(natom))
          +  -  +  -  -  
                +  -  + ]
    1600   [ -  +  +  -  :       21852 :    ABI_MALLOC(iatfix,(3,natom))
          +  -  +  -  -  
                +  -  + ]
    1601   [ -  +  +  -  :       21852 :    ABI_MALLOC(nucdipmom,(3,natom))
          +  -  +  -  -  
                +  -  + ]
    1602   [ -  +  +  -  :       14568 :    ABI_MALLOC(spinat,(3,natom))
             -  +  -  + ]
    1603   [ -  +  +  -  :       14568 :    ABI_MALLOC(spinat_cart,(3,natom))
             -  +  -  + ]
    1604   [ -  +  +  -  :       21852 :    ABI_MALLOC(typat,(natom))
          +  -  +  -  -  
                +  -  + ]
    1605   [ -  +  +  -  :       21852 :    ABI_MALLOC(znucl,(dtset%npsp))
          +  -  +  -  -  
                +  -  + ]
    1606         [ +  + ]:       46127 :    chrgat(1:natom)=dtset%chrgat(1:natom)
    1607   [ +  +  +  + ]:      162656 :    nucdipmom(1:3,1:natom)=dtset%nucdipmom(1:3,1:natom)
    1608   [ +  +  +  + ]:      162656 :    spinat(1:3,1:natom)=dtset%spinat(1:3,1:natom)
    1609   [ +  +  +  + ]:      162656 :    spinat_cart(1:3,1:natom)=dtset%spinat_cart(1:3,1:natom)
    1610         [ +  + ]:       16464 :    znucl(1:dtset%npsp)=dtset%znucl(1:dtset%npsp)
    1611                 :             : 
    1612                 :             :    !write(std_out,'(a)')' m_invars1%invars1 : before ingeo '; call flush(std_out)
    1613                 :             : 
    1614                 :             :    call ingeo(acell,amu,atndlist,bravais,chrgat,dtset,dtset%field_red(1:3),&
    1615                 :             :     dtset%field_red_axial(1:3),dtset%genafm(1:3),iatfix,&
    1616                 :             :     iatnd,dtset%icoulomb,iimage,iout,jdtset,dtset%jellslab,lenstr,mixalch,&
    1617                 :             :     msym,natnd,natom,dtset%nimage,dtset%npsp,npspalch,dtset%nspden,&
    1618                 :             :     dtset%nsym,ntypalch,dtset%ntypat,nucdipmom,dtset%nzchempot,&
    1619                 :             :     dtset%pawspnorb,dtset%ptgroupma,ratsph,&
    1620                 :             :     rprim,dtset%slabzbeg,dtset%slabzend,dtset%spgroup,spinat,spinat_cart,&
    1621                 :             :     string,dtset%supercell_latt,symafm,dtset%symmorphi,symrel,tnons,dtset%tolsym,&
    1622                 :        7284 :     typat,vel,vel_cell,xred,znucl, comm)
    1623                 :             : 
    1624                 :             :    !write(std_out,'(a)')' m_invars1%invars1 : after ingeo '; call flush(std_out)
    1625                 :             : 
    1626         [ +  + ]:       46127 :    dtset%chrgat(1:natom)=chrgat(1:natom)
    1627   [ +  +  +  + ]:      162656 :    dtset%iatfix(1:3,1:natom)=iatfix(1:3,1:natom)
    1628   [ +  +  +  + ]:      162656 :    dtset%nucdipmom(1:3,1:natom)=nucdipmom(1:3,1:natom)
    1629   [ +  +  +  + ]:      162656 :    dtset%spinat(1:3,1:natom)=spinat(1:3,1:natom)
    1630   [ +  +  +  + ]:      162656 :    dtset%spinat_cart(1:3,1:natom)=spinat_cart(1:3,1:natom)
    1631         [ +  + ]:       46127 :    dtset%typat(1:natom)=typat(1:natom)
    1632         [ -  + ]:        7284 :    ABI_FREE(chrgat)
    1633         [ -  + ]:        7284 :    ABI_FREE(iatfix)
    1634         [ -  + ]:        7284 :    ABI_FREE(nucdipmom)
    1635         [ -  + ]:        7284 :    ABI_FREE(spinat)
    1636         [ -  + ]:        7284 :    ABI_FREE(spinat_cart)
    1637         [ -  + ]:        7284 :    ABI_FREE(typat)
    1638         [ -  + ]:        7284 :    ABI_FREE(znucl)
    1639         [ +  + ]:       29136 :    dtset%acell_orig(1:3,iimage)=acell
    1640         [ +  + ]:       16438 :    dtset%amu_orig(1:ntypat,iimage)=amu
    1641   [ +  +  +  + ]:        7362 :    dtset%mixalch_orig(1:npspalch,1:ntypalch,iimage)=mixalch
    1642   [ +  +  +  + ]:       94692 :    dtset%rprim_orig(1:3,1:3,iimage)=rprim
    1643   [ +  +  +  + ]:      162656 :    dtset%vel_orig(1:3,1:natom,iimage)=vel
    1644   [ +  +  +  + ]:       94692 :    dtset%vel_cell_orig(1:3,1:3,iimage)=vel_cell
    1645   [ +  +  +  + ]:      162656 :    dtset%xred_orig(1:3,1:natom,iimage)=xred
    1646   [ -  +  -  -  :        7284 :    call mkrdim(dtset%acell_orig(1:3,iimage),dtset%rprim_orig(1:3,1:3,iimage),dtset%rprimd_orig(1:3,1:3,iimage))
          -  -  -  +  -  
             +  -  -  -  
                      - ]
    1647                 :             : 
    1648         [ +  - ]:        7284 :    if(allocated(dtset%iatnd)) then
    1649                 :        7284 :      ABI_FREE(dtset%iatnd)
    1650                 :             :    end if
    1651   [ +  +  +  -  :       21852 :    ABI_MALLOC(dtset%iatnd,(natnd))
          +  -  +  +  -  
             +  -  +  -  
                      + ]
    1652         [ +  + ]:        7302 :    dtset%iatnd(1:natnd)=iatnd(1:natnd)
    1653         [ +  - ]:        7284 :    if(allocated(dtset%atndlist)) then
    1654                 :        7284 :      ABI_FREE(dtset%atndlist)
    1655                 :             :    end if
    1656   [ +  +  +  -  :       21852 :    ABI_MALLOC(dtset%atndlist,(3,natnd))
          +  -  +  +  -  
             +  -  +  -  
                      + ]
    1657   [ +  +  +  + ]:        7356 :    dtset%atndlist(1:3,1:natnd)=atndlist(1:3,1:natnd)
    1658                 :             : 
    1659                 :             : !  Read cellcharge for each image, but use it only to initialize cellcharge_min
    1660                 :             : !  The old name 'charge' is still tolerated. Will be removed in due time.
    1661                 :        7284 :    cellcharge=zero
    1662                 :             : !  Initialize cellcharge with the value for the first image
    1663                 :        7284 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cellcharge',tread,'DPR')
    1664         [ +  + ]:        7284 :    if(tread==1)then
    1665                 :          34 :      cellcharge=dprarr(1)
    1666                 :             :    else
    1667                 :        7250 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'charge',tread,'DPR')
    1668         [ +  + ]:        7250 :      if(tread==1) cellcharge=dprarr(1)
    1669                 :             :    endif
    1670                 :             : !  Possibly overwrite cellcharge from the first image with a specific value for the current image
    1671                 :        7284 :    call intagm_img(dprarr,iimage,jdtset,lenstr,dtset%nimage,1,string,'cellcharge',tread_alt,'DPR')
    1672         [ +  + ]:        7284 :    if(tread_alt==1)then
    1673                 :           4 :      cellcharge=dprarr(1)
    1674                 :             :    else
    1675                 :        7280 :      call intagm_img(dprarr,iimage,jdtset,lenstr,dtset%nimage,1,string,'charge',tread_alt,'DPR')
    1676         [ -  + ]:        7280 :      if(tread_alt==1) cellcharge=dprarr(1)
    1677                 :             :    endif
    1678                 :             : 
    1679                 :        7024 :    if(cellcharge < cellcharge_min)cellcharge_min=cellcharge
    1680                 :             :  end do
    1681                 :             : 
    1682         [ +  - ]:        7024 :  if(allocated(iatnd)) then
    1683                 :        7024 :    ABI_FREE(iatnd)
    1684                 :             :  end if
    1685         [ +  - ]:        7024 :  if(allocated(atndlist)) then
    1686                 :        7024 :    ABI_FREE(atndlist)
    1687                 :             :  end if
    1688                 :             : 
    1689         [ -  + ]:        7024 :  ABI_FREE(amu)
    1690         [ -  + ]:        7024 :  ABI_FREE(mixalch)
    1691         [ -  + ]:        7024 :  ABI_FREE(vel)
    1692         [ -  + ]:        7024 :  ABI_FREE(vel_cell)
    1693         [ -  + ]:        7024 :  ABI_FREE(xred)
    1694                 :             : 
    1695                 :             :  ! Examine whether there is some vacuum space in the unit cell
    1696                 :             :  call invacuum(jdtset,lenstr,natom,dtset%rprimd_orig(1:3,1:3,intimage),string,vacuum,&
    1697   [ -  +  -  -  :        7024 :                 dtset%xred_orig(1:3,1:natom,intimage))
          -  -  -  +  -  
          -  -  -  -  -  
                   -  + ]
    1698                 :             : 
    1699                 :             : !write(std_out,'(a)')' m_invars1%invars1 : after invacuum '; call flush(std_out)
    1700                 :             : 
    1701                 :             : !write(std_out,*)' invars1: before inkpts, dtset%mixalch_orig(1:npspalch,1:ntypalch,:)=',&
    1702                 :             : !dtset%mixalch_orig(1:npspalch,1:ntypalch,1:dtset%nimage)
    1703                 :             : 
    1704                 :             : !---------------------------------------------------------------------------
    1705                 :             : 
    1706                 :             : !Set up k point grid number
    1707                 :             : !First, get additional information
    1708                 :        7024 :  dtset%kptopt=1
    1709         [ +  + ]:        7024 :  if(dtset%nspden==4)dtset%kptopt=4
    1710                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'kptopt',tread,'INT')
    1711         [ +  + ]:        7024 :  if(tread==1) dtset%kptopt=intarr(1)
    1712                 :             : 
    1713                 :             :  ! In EPH we may want to change qptopt when generating the IBZ for phonons and DFPT potentials.
    1714                 :             :  ! Typical example: we have a DDB/DDVB with q/-q and we want to reintroduce TR for testing purposes.
    1715                 :             :  ! For this reason, the default value of qptopt is set to zero if RUNL_EPH.
    1716                 :             :  ! EPH will use this value as sentinel to understand if qptopt should be set equal to kptopt
    1717                 :             :  ! or if it should be taken from the input file.
    1718                 :             : 
    1719                 :        7024 :  dtset%qptopt=1
    1720         [ +  + ]:        7024 :  if (dtset%optdriver == RUNL_EPH) dtset%qptopt = 0
    1721                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'qptopt',tread,'INT')
    1722         [ +  + ]:        7024 :  if(tread==1) dtset%qptopt=intarr(1)
    1723                 :             : 
    1724                 :        7024 :  iscf=5
    1725                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'iscf',tread,'INT')
    1726         [ +  + ]:        7024 :  if(tread==1) iscf=intarr(1)
    1727                 :             : 
    1728                 :        7024 :  dtset%natsph=dtset%natom
    1729                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'natsph',tread,'INT')
    1730         [ +  + ]:        7024 :  if(tread==1) dtset%natsph=intarr(1)
    1731                 :             : 
    1732                 :        7024 :  dtset%natsph_extra=0
    1733                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'natsph_extra',tread,'INT')
    1734         [ +  + ]:        7024 :  if(tread==1) dtset%natsph_extra=intarr(1)
    1735                 :             : 
    1736                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'natvshift',tread,'INT')
    1737         [ +  + ]:        7024 :  if(tread==1) dtset%natvshift=intarr(1)
    1738                 :             : 
    1739                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nconeq',tread,'INT')
    1740         [ +  + ]:        7024 :  if(tread==1) dtset%nconeq=intarr(1)
    1741                 :             : 
    1742                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nkptgw',tread,'INT')
    1743         [ +  + ]:        7024 :  if(tread==1) dtset%nkptgw=intarr(1)
    1744         [ -  + ]:        7024 :  if (dtset%nkptgw<0) then
    1745                 :             :    write(msg, '(a,i0,4a)' )&
    1746                 :           0 :    'Input nkptgw must be >= 0, but was ',dtset%nkptgw,ch10,&
    1747                 :           0 :    'This is not allowed.',ch10,'Action: check the input file.'
    1748                 :           0 :    ABI_ERROR(msg)
    1749                 :             :  end if
    1750                 :             : 
    1751                 :             :  ! Number of points for long wavelength limit. Default is dtset%gw_nqlwl=0
    1752                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_nqlwl',tread,'INT')
    1753         [ +  + ]:        7024 :  if(tread==1) dtset%gw_nqlwl=intarr(1)
    1754         [ -  + ]:        7024 :  if (dtset%gw_nqlwl<0) then
    1755                 :             :    write(msg, '(a,i0,4a)' )&
    1756                 :           0 :    'Input gw_nqlwl must be > 0, but was ',dtset%gw_nqlwl,ch10,&
    1757                 :           0 :    'This is not allowed.',ch10,'Action: check the input file.'
    1758                 :           0 :    ABI_ERROR(msg)
    1759                 :             :  end if
    1760                 :             : 
    1761                 :             :  ! Read number of k-points from input file (if specified)
    1762                 :        7024 :  nkpt=0
    1763         [ +  + ]:        7024 :  if(dtset%kptopt==0)nkpt=1
    1764                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nkpt',tread,'INT')
    1765         [ +  + ]:        7024 :  if(tread==1) nkpt=intarr(1)
    1766                 :             : 
    1767                 :             :  ! or from KERANGE file.
    1768                 :        7024 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr), "getkerange_filepath", tread, 'KEY', key_value=key_value)
    1769         [ +  + ]:        7024 :  if (tread==1) dtset%getkerange_filepath = key_value
    1770                 :             : 
    1771         [ +  + ]:        7024 :  if (dtset%getkerange_filepath /= ABI_NOFILE) then
    1772                 :             :    ! Get number of k-points in sigma_erange energy windows.
    1773                 :             :    !dtset%kptopt = 0
    1774         [ +  - ]:           2 :    if (my_rank == master) then
    1775         [ -  + ]:           2 :      NCF_CHECK(nctk_open_read(ncid, dtset%getkerange_filepath, xmpi_comm_self))
    1776         [ -  + ]:           2 :      NCF_CHECK(nctk_get_dim(ncid, "nkpt_inerange", nkpt, datamode=.True.))
    1777         [ -  + ]:           2 :      NCF_CHECK(nf90_close(ncid))
    1778                 :             :    end if
    1779                 :           2 :    call xmpi_bcast(nkpt, master, comm, ierr)
    1780                 :             :  end if
    1781                 :             : 
    1782                 :        7024 :  dtset%nkpt = nkpt
    1783                 :             : 
    1784                 :        7024 :  call chkint_ge(0,0,cond_string,cond_values,ierr,'nkpt',nkpt,0,iout)
    1785         [ +  + ]:        7024 :  if (dtset%kptopt==0) then
    1786                 :        3188 :    cond_string(1)='kptopt'; cond_values(1)=0
    1787                 :        3188 :    call chkint_ge(1,1,cond_string,cond_values,ierr,'nkpt',nkpt,1,iout)
    1788                 :             :  end if
    1789                 :             : 
    1790                 :        7024 :  nkpthf=nkpt
    1791                 :        7024 :  dtset%nkpthf=nkpt
    1792                 :             : 
    1793                 :             :  ! Will compute the actual value of nkpt, if needed. Otherwise,
    1794                 :             :  ! test that the value of nkpt is OK, if kptopt/=0
    1795                 :             :  ! Set up dummy arrays istwfk, kpt, wtk
    1796                 :             : 
    1797                 :             :  !write(std_out,'(a)')' m_invars1%invars1 : before nkpt/=0 '; call flush(std_out)
    1798                 :             : 
    1799   [ +  +  +  - ]:        7024 :  if(nkpt/=0 .or. dtset%kptopt/=0)then
    1800   [ +  +  +  -  :       21072 :    ABI_MALLOC(istwfk,(nkpt))
          +  -  +  +  -  
                +  -  + ]
    1801   [ +  +  +  -  :       21072 :    ABI_MALLOC(kpt,(3,nkpt))
          +  -  +  +  -  
                +  -  + ]
    1802   [ +  +  +  -  :       14048 :    ABI_MALLOC(kpthf,(3,nkpthf))
             -  +  -  + ]
    1803   [ +  +  +  -  :       21072 :    ABI_MALLOC(wtk,(nkpt))
          +  -  +  +  -  
                +  -  + ]
    1804                 :             :    ! Here, occopt is also a dummy argument
    1805   [ +  +  +  + ]:       91312 :    occopt=1; dtset%nshiftk=1; dtset%kptrlatt(:,:)=0
    1806                 :             : 
    1807         [ +  + ]:       21537 :    kptrlen=20.0_dp ; wtk(:)=1.0_dp
    1808   [ +  +  +  + ]:     5907184 :    dtset%shiftk(:,:)=half
    1809                 :             : 
    1810                 :        7024 :    nqpt=0
    1811                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nqpt',tread,'INT')
    1812         [ +  + ]:        7024 :    if(tread==1) nqpt=intarr(1)
    1813                 :             : 
    1814                 :        7024 :    expert_user=0
    1815                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'expert_user',tread,'INT')
    1816         [ +  + ]:        7024 :    if (tread==1) expert_user=intarr(1)
    1817                 :             : 
    1818                 :             :    ! The default value of chksymbreak depends on expert_user but we still allow user to specify it.
    1819         [ +  - ]:        7024 :    chksymbreak=1; if (expert_user > 0) chksymbreak = 0
    1820                 :        7024 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'chksymbreak',tread,'INT')
    1821         [ +  + ]:        7024 :    if(tread==1) chksymbreak=intarr(1)
    1822                 :             : 
    1823                 :             :    ! Use the first image to predict k and/or q points, except if an intermediate image is available
    1824         [ +  + ]:        7024 :    intimage=1; if(dtset%nimage>2)intimage=(1+dtset%nimage)/2
    1825                 :             : 
    1826                 :             :    !write(std_out,'(a)')' m_invars1%invars1 : before inqpt'; call flush(std_out)
    1827                 :             : 
    1828                 :             :    ! Find the q-point, if any.
    1829         [ +  + ]:        7024 :    if(nqpt/=0)then
    1830                 :             :      call inqpt(chksymbreak,std_out,jdtset,lenstr,msym,natom,dtset%qptn,dtset%wtq,&
    1831                 :             :        dtset%rprimd_orig(1:3,1:3,intimage),dtset%spinat,string,dtset%typat,&
    1832   [ -  +  -  -  :         714 :        vacuum,dtset%xred_orig(1:3,1:natom,intimage),dtset%qptrlatt)
          -  -  -  +  -  
          -  -  -  -  -  
                   -  + ]
    1833                 :             :    endif
    1834                 :             : 
    1835                 :             :    ! Find the k point grid
    1836                 :             :    call inkpts(bravais,chksymbreak,dtset%fockdownsampling,iout,iscf,istwfk,jdtset,&
    1837                 :             :      kpt,kpthf,dtset%kptopt,kptnrm,dtset%kptrlatt_orig,dtset%kptrlatt,kptrlen,lenstr,msym, dtset%getkerange_filepath, &
    1838                 :             :      nkpt,nkpthf,nqpt,dtset%ngkpt,dtset%nshiftk,dtset%nshiftk_orig,dtset%shiftk_orig,dtset%nsym,&
    1839                 :             :      occopt,dtset%qptn,response,dtset%rprimd_orig(1:3,1:3,intimage),dtset%shiftk,&
    1840   [ -  +  -  -  :        7024 :      string,symafm,symrel,vacuum,wtk,comm)
                   -  - ]
    1841                 :             : 
    1842                 :             :    !write(std_out,'(a)')' m_invars1%invars1 : after inkpts'; call flush(std_out)
    1843                 :             : 
    1844         [ -  + ]:        7010 :    ABI_FREE(istwfk)
    1845         [ -  + ]:        7010 :    ABI_FREE(kpt)
    1846         [ -  + ]:        7010 :    ABI_FREE(kpthf)
    1847         [ -  + ]:        7010 :    ABI_FREE(wtk)
    1848                 :             : 
    1849                 :             :    ! nkpt and nkpthf have been computed, as well as the k point grid, if needed
    1850                 :        7010 :    dtset%nkpt=nkpt
    1851                 :        7010 :    dtset%nkpthf=nkpthf
    1852                 :             :  end if
    1853                 :             : 
    1854                 :             :  !write(std_out,'(a)')' m_invars1%invars1 : after nkpt/=0 '; call flush(std_out)
    1855                 :             : 
    1856                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nqptdm',tread,'INT')
    1857         [ +  + ]:        7010 :  if(tread==1) dtset%nqptdm=intarr(1)
    1858                 :             : 
    1859         [ -  + ]:        7010 :  if (dtset%nqptdm<-1) then
    1860                 :             :    write(msg, '(a,i0,4a)' )&
    1861                 :           0 :     'Input nqptdm must be >= 0, but was ',dtset%nqptdm,ch10,&
    1862                 :           0 :     'This is not allowed.',ch10,'Action: check the input file.'
    1863                 :           0 :    ABI_ERROR(msg)
    1864                 :             :  end if
    1865                 :             : 
    1866                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nzchempot',tread,'INT')
    1867         [ +  + ]:        7010 :  if(tread==1) dtset%nzchempot=intarr(1)
    1868                 :             : 
    1869                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cd_customnimfrqs',tread,'INT')
    1870         [ +  + ]:        7010 :  if(tread==1) dtset%cd_customnimfrqs=intarr(1)
    1871                 :             : 
    1872         [ -  + ]:        7010 :  if (dtset%cd_customnimfrqs<0) then
    1873                 :             :    write(msg, '(a,i0,4a)' )&
    1874                 :           0 :     'Input cd_customnimfrqs must be >= 0, but was ',dtset%cd_customnimfrqs,ch10,&
    1875                 :           0 :     'This is not allowed.',ch10,'Action: check the input file.'
    1876                 :           0 :    ABI_ERROR(msg)
    1877                 :             :  end if
    1878                 :             : 
    1879                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gw_customnfreqsp',tread,'INT')
    1880         [ +  + ]:        7010 :  if(tread==1) dtset%gw_customnfreqsp=intarr(1)
    1881                 :             : 
    1882         [ -  + ]:        7010 :  if (dtset%gw_customnfreqsp<0) then
    1883                 :             :    write(msg, '(a,i0,4a)' )&
    1884                 :           0 :     'Input gw_customnfreqsp must be >= 0, but was ',dtset%gw_customnfreqsp,ch10,&
    1885                 :           0 :     'This is not allowed.',ch10,'Action: check the input file.'
    1886                 :           0 :    ABI_ERROR(msg)
    1887                 :             :  end if
    1888                 :             : 
    1889                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'gwls_n_proj_freq',tread,'INT')
    1890         [ +  + ]:        7010 :  if(tread==1) dtset%gwls_n_proj_freq=intarr(1)
    1891                 :             : 
    1892         [ -  + ]:        7010 :  if (dtset%gwls_n_proj_freq<0) then
    1893                 :             :    write(msg, '(a,i0,4a)' )&
    1894                 :           0 :    'Input gwls_n_proj_freq must be >= 0, but was ',dtset%gwls_n_proj_freq,ch10,&
    1895                 :           0 :    'This is not allowed.',ch10,'Action: check the input file.'
    1896                 :           0 :    ABI_ERROR(msg)
    1897                 :             :  end if
    1898                 :             : 
    1899                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efmas_calc_dirs',tread,'INT')
    1900         [ +  + ]:        7010 :  if(tread==1) dtset%efmas_calc_dirs=intarr(1)
    1901                 :             : 
    1902         [ -  + ]:        7010 :  if (ABS(dtset%efmas_calc_dirs)>3) then
    1903                 :             :    write(msg, '(a,i0,4a)' )&
    1904                 :           0 :    'Input efmas_calc_dirs must be between -3 and 3, but was ',dtset%efmas_calc_dirs,ch10,&
    1905                 :           0 :    'This is not allowed.',ch10,'Action: check the input file.'
    1906                 :           0 :    ABI_ERROR(msg)
    1907                 :             :  end if
    1908                 :             : 
    1909                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efmas_n_dirs',tread,'INT')
    1910         [ +  + ]:        7010 :  if(tread==1) dtset%efmas_n_dirs=intarr(1)
    1911                 :             : 
    1912         [ -  + ]:        7010 :  if (dtset%efmas_n_dirs<0) then
    1913                 :             :    write(msg, '(a,i0,4a)' )&
    1914                 :           0 :    'Input efmas_n_dirs must be >= 0, but was ',dtset%efmas_n_dirs,ch10,&
    1915                 :           0 :    'This is not allowed.',ch10,'Action: check the input file.'
    1916                 :           0 :    ABI_ERROR(msg)
    1917                 :             :  end if
    1918                 :             : 
    1919                 :             : !---------------------------------------------------------------------------
    1920                 :             : 
    1921                 :             :  !write(std_out,'(a)')' m_invars1%invars1 : before nnos '; call flush(std_out)
    1922                 :             : 
    1923                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nnos',tread,'INT')
    1924         [ +  + ]:        7010 :  if(tread==1) dtset%nnos=intarr(1)
    1925                 :             : 
    1926                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ga_n_rules',tread,'INT')
    1927         [ +  + ]:        7010 :  if(tread==1) dtset%ga_n_rules=intarr(1)
    1928                 :             : 
    1929                 :             :  ! Perform the first checks
    1930                 :             :  ! Check that nkpt is greater than 0
    1931         [ -  + ]:        7010 :  if (nkpt<=0) then
    1932                 :           0 :    write(msg, '(a,i0)' )'After inkpts, nkpt must be > 0, but was ',nkpt
    1933                 :           0 :    ABI_ERROR_NOSTOP(msg, leave)
    1934                 :             :  end if
    1935                 :             : 
    1936                 :             :  ! Check that nsppol is 1 or 2
    1937         [ -  + ]:        7010 :  if (nsppol/=1 .and. nsppol/=2) then
    1938                 :           0 :    write(msg, '(a,i0)' )'Input nsppol must be 1 or 2, but was ',nsppol
    1939                 :           0 :    ABI_ERROR_NOSTOP(msg, leave)
    1940                 :             :  end if
    1941                 :             : 
    1942                 :             :  ! Check that nspinor is 1 or 2
    1943         [ -  + ]:        7010 :  if (nspinor/=1 .and. nspinor/=2) then
    1944                 :           0 :    write(msg, '(a,i0)' )'Input nspinor must be 1 or 2, but was ',nspinor
    1945                 :           0 :    ABI_ERROR_NOSTOP(msg, leave)
    1946                 :             :  end if
    1947                 :             : 
    1948                 :             :  ! Check that nspinor and nsppol are not 2 together
    1949   [ +  +  -  + ]:        7010 :  if (nsppol==2 .and. nspinor==2) then
    1950                 :           0 :    ABI_ERROR_NOSTOP('nspinor and nsppol cannot be 2 together!', leave)
    1951                 :             :  end if
    1952                 :             : 
    1953                 :             :  ! Here, leave if an error has been detected earlier
    1954         [ -  + ]:        7010 :  if (leave /= 0) then
    1955                 :           0 :    ABI_ERROR('Errors are present in the input file. See ABOVE messages')
    1956                 :             :  end if
    1957                 :             : 
    1958                 :             :  ! Now, take care of mband_upper
    1959                 :        7010 :  mband_upper=1
    1960                 :        7010 :  occopt=1
    1961                 :        7010 :  fband=0.5_dp
    1962                 :             : 
    1963                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'occopt',tread,'INT')
    1964         [ +  + ]:        7010 :  if(tread==1) occopt=intarr(1)
    1965                 :             : 
    1966                 :             :  ! Also read fband, that is an alternative to nband. The default
    1967                 :             :  ! is different for occopt==1 and for metallic occupations.
    1968         [ +  + ]:        7010 :  if(occopt==1)fband=0.125_dp
    1969                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fband',tfband,'DPR')
    1970         [ +  + ]:        7010 :  if(tfband==1)fband=dprarr(1)
    1971                 :             : 
    1972                 :             :  ! fband cannot be used when occopt==0 or occopt==2
    1973   [ +  +  -  + ]:        7010 :  if(tfband==1 .and. (occopt==0 .or. occopt==2) )then
    1974                 :             :    write(msg, '(3a)' )&
    1975                 :           0 :    'fband cannot be used if occopt==0 or occopt==2 ',ch10,&
    1976                 :           0 :    'Action: correct your input file, suppress fband, or change occopt.'
    1977                 :           0 :    ABI_ERROR(msg)
    1978                 :             :  end if
    1979                 :             : 
    1980   [ -  +  +  -  :       21030 :  ABI_MALLOC(nband,(nkpt*nsppol))
          +  -  +  -  -  
                +  -  + ]
    1981                 :        7010 :  tnband=0
    1982                 :             : 
    1983                 :             :  ! Compute ziontypat
    1984                 :             :  ! When the pseudo-atom is pure, simple copy
    1985         [ +  + ]:        7010 :  if(ntyppure>0)then
    1986         [ +  + ]:       15648 :    do itypat=1,ntyppure
    1987                 :       15648 :      dtset%ziontypat(itypat)=zionpsp(itypat)
    1988                 :             :    end do
    1989                 :             :  end if
    1990                 :             : 
    1991                 :             :  ! When the pseudo-atom is alchemical, must make mixing
    1992         [ +  + ]:        7010 :  if(ntypalch>0)then
    1993         [ +  + ]:          40 :    do itypat=ntyppure+1,ntypat
    1994                 :          20 :      dtset%ziontypat(itypat)=zero
    1995         [ +  + ]:          80 :      do ipsp=ntyppure+1,npsp
    1996                 :             :        dtset%ziontypat(itypat)=dtset%ziontypat(itypat) &
    1997                 :          60 : &       +dtset%mixalch_orig(ipsp-ntyppure,itypat-ntyppure,1)*zionpsp(ipsp)
    1998                 :             :      end do
    1999                 :             :    end do
    2000                 :             :  end if
    2001                 :             : 
    2002         [ +  + ]:        7010 :  if (occopt==0 .or. occopt==1 .or. (occopt>=3 .and. occopt<=9) ) then
    2003                 :        6796 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nband',tnband,'INT')
    2004                 :             :    ! Note: mband_upper is initialized, not nband
    2005         [ +  + ]:        6796 :    if(tnband==1) mband_upper=intarr(1)
    2006                 :             : 
    2007   [ +  +  -  + ]:        6796 :    if(tfband==1 .and. tnband==1)then
    2008                 :             :      write(msg, '(3a)' )&
    2009                 :           0 :      'fband and nband cannot be used together. ',ch10,&
    2010                 :           0 :      'Action: correct your input file, suppress either fband or nband.'
    2011                 :           0 :      ABI_ERROR(msg)
    2012                 :             :    end if
    2013                 :             : 
    2014                 :             :    ! In case nband was not read, use fband, either read, or the default,
    2015                 :             :    ! to provide an upper limit for mband_upper
    2016         [ +  + ]:        6796 :    if(tnband==0)then
    2017                 :             : 
    2018                 :             : !     mband_upper=nspinor*((nint(zion_max)*natom+1)/2 - floor(cellcharge_min/2.0_dp)&
    2019                 :             : !&     + ceiling(fband*natom-1.0d-10))
    2020                 :        2184 :      zval=zero
    2021                 :        2184 :      sum_spinat=zero
    2022         [ +  + ]:       29232 :      do iatom=1,natom
    2023                 :       27048 :        zval=zval+dtset%ziontypat(dtset%typat(iatom))
    2024                 :       29232 :        sum_spinat=sum_spinat+dtset%spinat(3,iatom)
    2025                 :             :      end do
    2026                 :        2184 :      zelect=zval-cellcharge_min
    2027                 :             :      mband_upper=nspinor * ((ceiling(zelect-tol10)+1)/2 + ceiling( fband*natom - tol10 )) &
    2028   [ -  +  +  +  :        2184 : &     + (nsppol-1)*(ceiling(half*(sum_spinat -tol10)))
                   +  + ]
    2029         [ +  + ]:        9032 :      nband(:)=mband_upper
    2030                 :             : 
    2031                 :             : !    write(std_out,*)' invars1 : zion_max,natom,fband,mband_upper '
    2032                 :             : !    write(std_out,*)zion_max,natom,fband,mband_upper
    2033                 :             :    end if
    2034                 :             : 
    2035         [ +  + ]:      124088 :    nband(:)=mband_upper
    2036                 :             : 
    2037         [ +  - ]:         214 :  else if (occopt==2) then
    2038   [ -  +  +  -  :         642 :    ABI_MALLOC(reaalloc,(nkpt*nsppol))
          +  -  +  -  -  
                +  -  + ]
    2039                 :         214 :    call intagm(reaalloc,nband,jdtset,nkpt*nsppol,nkpt*nsppol,string(1:lenstr),'nband',tnband,'INT')
    2040         [ +  - ]:         214 :    if(tnband==1)then
    2041         [ +  + ]:         728 :      do ikpt=1,nkpt*nsppol
    2042         [ +  + ]:         728 :        if (nband(ikpt)>mband_upper) mband_upper=nband(ikpt)
    2043                 :             :      end do
    2044                 :             :    end if
    2045         [ -  + ]:         214 :    ABI_FREE(reaalloc)
    2046                 :             :  else
    2047                 :           0 :    write(msg, '(a,i0,3a)' )'occopt=',occopt,' is not an allowed value.',ch10,'Action: correct your input file.'
    2048                 :           0 :    ABI_ERROR(msg)
    2049                 :             :  end if
    2050                 :             : 
    2051                 :             :  ! Check that mband_upper is greater than 0
    2052         [ -  + ]:        7010 :  if (mband_upper<=0) then
    2053                 :             :    write(msg, '(a,i0,4a)' )&
    2054                 :           0 :    'Maximal nband must be > 0, but was ',mband_upper,ch10,&
    2055                 :           0 :    'This is not allowed.',ch10,'Action: check the input file.'
    2056                 :           0 :    ABI_ERROR(msg)
    2057                 :             :  end if
    2058                 :             : 
    2059                 :             :  ! The following 3 values are needed to dimension the parallelism over images
    2060                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'imgmov',tread,'INT')
    2061         [ +  + ]:        7010 :  if(tread==1) dtset%imgmov=intarr(1)
    2062                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ntimimage',tread,'INT')
    2063         [ +  + ]:        7010 :  if(tread==1) dtset%ntimimage=intarr(1)
    2064                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,dtset%nimage,string(1:lenstr),'dynimage',tread,'INT')
    2065         [ +  + ]:        7010 :  if(tread==1)then
    2066         [ +  + ]:         292 :    dtset%dynimage(1:dtset%nimage)=intarr(1:dtset%nimage)
    2067         [ -  + ]:        6973 :  else if (dtset%imgmov==2.or.dtset%imgmov==5) then
    2068                 :           0 :    dtset%dynimage(1)=0;dtset%dynimage(dtset%nimage)=0
    2069                 :             :  end if
    2070   [ +  +  +  + ]:       14280 :  dtset%ndynimage=count(dtset%dynimage(1:dtset%nimage)/=0)
    2071                 :             : 
    2072                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'wfoptalg',tread,'INT')
    2073         [ +  + ]:        7010 :  if(tread==1) then
    2074                 :         372 :    dtset%wfoptalg=intarr(1)
    2075                 :             :  else
    2076         [ +  + ]:        6638 :    if (dtset%usepaw==0)    dtset%wfoptalg=0
    2077         [ +  + ]:        6638 :    if (dtset%usepaw/=0)    dtset%wfoptalg=10
    2078         [ +  + ]:        6638 :    if (dtset%optdriver==RUNL_GSTATE) then
    2079         [ +  + ]:        5304 :      if (dtset%paral_kgb/=0) dtset%wfoptalg=14
    2080                 :             :    end if
    2081                 :             :  end if
    2082                 :             : 
    2083                 :             :  ! Read use_gbt
    2084                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'use_gbt',tread,'INT')
    2085         [ +  + ]:        7010 :  if (tread==1) dtset%use_gbt=intarr(1)
    2086                 :             : 
    2087                 :             : !---------------------------------------------------------------------------
    2088                 :             : !Some PAW+DMFT keywords
    2089                 :        7010 :  dtset%usedmft=0
    2090                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'usedmft',tread,'INT')
    2091         [ +  + ]:        7010 :  if(tread==1) dtset%usedmft=intarr(1)
    2092                 :             : 
    2093                 :             : !Some ucrpa keywords
    2094                 :        7010 :  dtset%ucrpa=0
    2095                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ucrpa',tread,'INT')
    2096         [ -  + ]:        7010 :  if(tread==1) dtset%ucrpa=intarr(1)
    2097                 :             : 
    2098   [ -  +  -  - ]:        7010 :  if (dtset%ucrpa > 0 .and. (dtset%usedmft > 0 .and. dtset%usedmft /= 10)) then
    2099                 :             :    write(msg, '(9a)' )&
    2100                 :           0 :    'usedmft and ucrpa are both activated in the input file ',ch10,&
    2101                 :           0 :    'In the following, abinit assume you are doing a ucrpa calculation and ',ch10,&
    2102                 :           0 :    'you define Wannier functions as in DFT+DMFT calculation',ch10,&
    2103                 :           0 :    'If instead, you want to do a full dft+dmft calculation and not only the Wannier construction, use ucrpa=0',ch10,&
    2104                 :           0 :    'This keywords are depreciated, please use the new keywords to perform cRPA calculation'
    2105                 :           0 :    ABI_WARNING(msg)
    2106                 :             :  end if
    2107                 :             : 
    2108                 :             : !Some PAW+U keywords
    2109                 :        7010 :  dtset%usepawu=0
    2110                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'usepawu',tread,'INT')
    2111         [ +  + ]:        7010 :  if(tread==1) dtset%usepawu=intarr(1)
    2112                 :             : !if(dtset%usedmft>0.and.(dtset%usepawu==14.or.dtset%usepawu==4)) then
    2113                 :             : !   dtset%usepawu=14
    2114                 :             : !else if(dtset%usedmft>0.and.dtset%usepawu>=0) then
    2115                 :             : !   dtset%usepawu=1
    2116                 :             : !endif
    2117                 :             : 
    2118                 :             : 
    2119                 :        7010 :  dtset%usedmatpu=0
    2120         [ +  + ]:       15678 :  dtset%lpawu(1:dtset%ntypat)=-1
    2121                 :        7010 :  dtset%optdcmagpawu=3
    2122   [ +  +  -  + ]:        7010 :  if (dtset%usepawu/=0.or.(dtset%usedmft>0.and.dtset%usedmft/=10)) then
    2123                 :         155 :    call intagm(dprarr,intarr,jdtset,marr,dtset%ntypat,string(1:lenstr),'lpawu',tread,'INT')
    2124   [ +  -  +  + ]:         392 :    if(tread==1) dtset%lpawu(1:dtset%ntypat)=intarr(1:dtset%ntypat)
    2125                 :             : 
    2126                 :         155 :    call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'usedmatpu',tread,'INT')
    2127         [ +  + ]:         155 :    if(tread==1) dtset%usedmatpu=intarr(1)
    2128         [ +  + ]:         155 :    if (dtset%nspden==4) then
    2129                 :          25 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'optdcmagpawu',tread,'INT')
    2130         [ +  + ]:          25 :      if(tread==1) dtset%optdcmagpawu=intarr(1)
    2131                 :             :    end if
    2132                 :             :  end if
    2133                 :             : 
    2134                 :             : !Some PAW+Exact exchange keywords
    2135                 :        7010 :  dtset%useexexch=0
    2136                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'useexexch',tread,'INT')
    2137         [ +  + ]:        7010 :  if(tread==1) dtset%useexexch=intarr(1)
    2138                 :             : 
    2139         [ +  + ]:       15678 :  dtset%lexexch(1:dtset%ntypat)=-1
    2140                 :             : 
    2141         [ +  + ]:        7010 :  if (dtset%useexexch/=0) then
    2142                 :           1 :    call intagm(dprarr,intarr,jdtset,marr,dtset%ntypat,string(1:lenstr),'lexexch',tread,'INT')
    2143   [ +  -  +  + ]:           3 :    if(tread==1) dtset%lexexch(1:dtset%ntypat)=intarr(1:dtset%ntypat)
    2144                 :             :  end if
    2145                 :             : 
    2146                 :             : !LDA minus half keyword
    2147                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,dtset%ntypat,string(1:lenstr),'ldaminushalf',tread,'INT')
    2148   [ +  +  +  + ]:        7011 :  if(tread==1) dtset%ldaminushalf(1:dtset%ntypat)=intarr(1:dtset%ntypat)
    2149                 :             : 
    2150                 :             : !Some plowan data
    2151                 :        7010 :  dtset%plowan_natom=0
    2152                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'plowan_natom',tread,'INT')
    2153         [ -  + ]:        7010 :  if(tread==1) dtset%plowan_natom=intarr(1)
    2154                 :             : 
    2155                 :        7010 :  dtset%plowan_nt=0
    2156                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'plowan_nt',tread,'INT')
    2157         [ -  + ]:        7010 :  if(tread==1) dtset%plowan_natom=intarr(1)
    2158                 :             : 
    2159                 :             :  !if (dtset%ucrpa > 0 .and. dtset%plowan_compute==0) then
    2160                 :             :    !dtset%plowan_natom=1
    2161                 :             :    !dtset%plowan_nt=1
    2162                 :             :  !endif
    2163                 :             : 
    2164                 :             : !PAW potential zero keyword
    2165                 :        7010 :  dtset%usepotzero=0
    2166                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'usepotzero',tread,'INT')
    2167         [ +  + ]:        7010 :  if(tread==1) dtset%usepotzero=intarr(1)
    2168                 :             : 
    2169                 :             : !Macro_uj (determination of U in PAW+U), governs also allocation of atvshift
    2170                 :        7010 :  dtset%macro_uj = 0
    2171                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'macro_uj',tread,'INT')
    2172         [ +  + ]:        7010 :  if(tread==1) dtset%macro_uj=intarr(1)
    2173                 :             : 
    2174                 :             : !Constraint DFT keyword
    2175                 :        7010 :  call intagm(dprarr,intarr,jdtset,marr,dtset%ntypat,string(1:lenstr),'constraint_kind',tread,'INT')
    2176   [ +  +  +  + ]:        7084 :  if(tread==1) dtset%constraint_kind(1:dtset%ntypat)=intarr(1:dtset%ntypat)
    2177                 :             : 
    2178                 :             : !Some special cases are not compatible with GPU implementation
    2179                 :             : !Warn user if value is changed at runtime.
    2180                 :             : !We don't stop the code because we may want to run the test suite in GPU mode.
    2181   [ +  +  +  + ]:        7010 :  if (all(dtset%optdriver /= [RUNL_GSTATE, RUNL_RESPFN, RUNL_GWR, RUNL_EPH])) then
    2182         [ -  + ]:         504 :    if (dtset%gpu_option /= ABI_GPU_DISABLED) then
    2183                 :           0 :      call wrtout(units, "- WARNING: GPU only compatible with GS, RESPFN, GWR, EPH. gpu_option has been set to 0!")
    2184                 :             :    end if
    2185                 :         504 :    dtset%gpu_option=ABI_GPU_DISABLED
    2186                 :             :  end if
    2187   [ +  +  +  - ]:        7010 :  if (dtset%optdriver==RUNL_RESPFN .and. dtset%gpu_option/=ABI_GPU_OPENMP) then
    2188         [ -  + ]:         721 :    if (dtset%gpu_option /= ABI_GPU_DISABLED) then
    2189                 :           0 :      call wrtout(units, "- WARNING: RESPFN on GPU only implemented with OpenMP. gpu_option has been set to 0!")
    2190                 :             :    end if
    2191                 :         721 :    dtset%gpu_option=ABI_GPU_DISABLED
    2192                 :             :  end if
    2193         [ +  + ]:        7010 :  if (dtset%tfkinfunc/=0) dtset%gpu_option=ABI_GPU_DISABLED  ! Recursion method has its own GPU implementation
    2194         [ +  + ]:        7010 :  if (dtset%nspinor/=1) then
    2195         [ -  + ]:         355 :    if (dtset%gpu_option/=ABI_GPU_DISABLED .and. dtset%gpu_option/=ABI_GPU_OPENMP) then
    2196                 :           0 :      dtset%gpu_option=ABI_GPU_DISABLED
    2197                 :           0 :      call wrtout(units, "- WARNING: nspinor=2 not supported outside of CPU and OpenMP GPU. gpu_option has been set to 0!")
    2198                 :             :    end if
    2199                 :             :  end if
    2200                 :             : 
    2201         [ -  + ]:        7010 :  ABI_FREE(nband)
    2202         [ -  + ]:        7010 :  ABI_FREE(ratsph)
    2203         [ -  + ]:        7010 :  ABI_FREE(intarr)
    2204         [ -  + ]:        7010 :  ABI_FREE(dprarr)
    2205                 :             : 
    2206                 :             : !write(std_out,'(a)')' m_invars1%invars1 : exit '; call flush(std_out)
    2207                 :             : 
    2208   [ -  +  -  +  :        7010 : end subroutine invars1
                   -  + ]
    2209                 :             : !!***
    2210                 :             : 
    2211                 :             : !!****f* ABINIT/indefo
    2212                 :             : !! NAME
    2213                 :             : !! indefo
    2214                 :             : !!
    2215                 :             : !! FUNCTION
    2216                 :             : !! Initialisation phase: default values for most input variables
    2217                 :             : !! (some are initialized earlier, see indefo1 routine, or even
    2218                 :             : !!  at the definition of the input variables (m_dtset.F90))
    2219                 :             : !!
    2220                 :             : !! INPUTS
    2221                 :             : !!  ndtset_alloc=number of datasets, corrected for allocation of at least one data set.
    2222                 :             : !!  nprocs=Number of MPI processors available.
    2223                 :             : !!
    2224                 :             : !! OUTPUT
    2225                 :             : !!  dtsets(0:ndtset_alloc)=<type datafiles_type>contains all input variables,
    2226                 :             : !!   some of which are given a default value here.
    2227                 :             : !!   The dataset with number 0 should be the reference default value in the remaining of the code.
    2228                 :             : !!
    2229                 :             : !! NOTES
    2230                 :             : !! The outputs of this routine are the defaults values of input
    2231                 :             : !! variables, stored at the index 0 of the last dimension of their multi-dataset representation.
    2232                 :             : !!
    2233                 :             : !! NOTE that Scalars and static arrays can be initialized directly at the level of the datatype declaration
    2234                 :             : !! provided the value does not depend on runtime conditions.
    2235                 :             : !!
    2236                 :             : !! SOURCE
    2237                 :             : 
    2238                 :        1442 : subroutine indefo(dtsets, ndtset_alloc, nprocs)
    2239                 :             : 
    2240                 :             : !Arguments ------------------------------------
    2241                 :             : !scalars
    2242                 :             :  integer,intent(in) :: ndtset_alloc,nprocs
    2243                 :             : !arrays
    2244                 :             :  type(dataset_type),intent(inout) :: dtsets(0:ndtset_alloc)
    2245                 :             : 
    2246                 :             : !Local variables -------------------------------
    2247                 :             : !scalars
    2248                 :             :  integer :: idtset,ii,jdtset,paral_atom_default
    2249                 :             :  logical :: wvl_bigdft
    2250                 :             : #if defined DEV_YP_VDWXC
    2251                 :             :  type(xc_vdw_type) :: vdw_defaults
    2252                 :             : #endif
    2253                 :             : !******************************************************************
    2254                 :             : 
    2255                 :             :  DBG_ENTER("COLL")
    2256                 :             : 
    2257                 :             : !Set up default values. All variables to be output in outvars.f
    2258                 :             : !should have a default, even if a nonsensible one can be chosen to guarantee print in that routine.
    2259                 :             : !Some default values are also set at the definition of the input variables (m_dtset.F90).
    2260                 :             : 
    2261                 :             : !These variables have already been initialized, for idtset/=0
    2262                 :        1442 :  dtsets(0)%istatr=0
    2263                 :        1442 :  dtsets(0)%istatshft=1
    2264   [ +  +  +  + ]:       18746 :  dtsets(0)%kptrlatt(1:3,1:3)=0
    2265                 :             :  !dtsets(0)%kptrlatt_orig=0
    2266   [ +  +  +  + ]:       18746 :  dtsets(0)%qptrlatt(1:3,1:3)=0
    2267                 :        1442 :  dtsets(0)%ptgroupma=0
    2268                 :        1442 :  dtsets(0)%spgroup=0
    2269   [ +  +  +  + ]:     1212722 :  dtsets(0)%shiftk(:,:)=half
    2270                 :             : !XG20200801 Changed the default value. This default value is also defined in m_ingeo.F90 . Must be coherent !
    2271                 :             : !dtsets(0)%tolsym=tol8
    2272                 :        1442 :  dtsets(0)%tolsym=tol5
    2273         [ +  + ]:        3400 :  dtsets(0)%znucl(:)=zero
    2274                 :        1442 :  dtsets(0)%ucrpa=0
    2275                 :        1442 :  dtsets(0)%usedmft=0
    2276                 :             : 
    2277                 :        1442 :  paral_atom_default=0
    2278   [ +  +  +  +  :        9894 :  if (nprocs>1.and.maxval(dtsets(:)%usepaw)>0) paral_atom_default=1
                   +  + ]
    2279                 :             : 
    2280                 :             : !WARNING: set default in all datasets, including idtset=0 !!!
    2281                 :             : !Use alphabetic order
    2282                 :             : 
    2283         [ +  + ]:        9894 :  do idtset=0,ndtset_alloc
    2284                 :        8452 :    jdtset=dtsets(idtset)%jdtset
    2285                 :             : 
    2286                 :        8452 :    wvl_bigdft=.false.
    2287   [ +  -  -  - ]:        8452 :    if(dtsets(idtset)%usewvl==1 .and. dtsets(idtset)%wvl_bigdft_comp==1) wvl_bigdft=.true.
    2288                 :             : 
    2289                 :             : !  A
    2290                 :             : !  Here we change the default value of iomode according to the configuration options.
    2291                 :             : !  Ideally, all the sequential tests should pass independently of the default value.
    2292                 :             : !  The parallel tests may require IO_MODE_MPI or, alternatively, IO_MODE_ETSF with HDF5 support.
    2293                 :             : !  MG FIXME Sun Sep 6 2015: Many tests fail if IO_MODE_MPI is used as default. IO errors in v1, v2 ...
    2294                 :             : !  with np=1 and wonderful deadlocks if np>1.
    2295                 :             : 
    2296                 :             : !  Note that this default value might be overridden for specific datasets later, in case of parallelism
    2297                 :             :    dtsets(idtset)%iomode=IO_MODE_FORTRAN
    2298                 :             : #ifdef HAVE_NETCDF_DEFAULT
    2299                 :        8452 :    dtsets(idtset)%iomode=IO_MODE_ETSF
    2300                 :             : #endif
    2301                 :             : #ifdef HAVE_MPI_IO_DEFAULT
    2302                 :             :    dtsets(idtset)%iomode=IO_MODE_MPI
    2303                 :             : #endif
    2304                 :             : 
    2305                 :        8452 :    dtsets(idtset)%adpimd=0
    2306                 :        8452 :    dtsets(idtset)%adpimd_gamma=one
    2307                 :        8452 :    dtsets(idtset)%accuracy=0
    2308                 :        8452 :    dtsets(idtset)%asr=1
    2309   [ +  +  +  +  :      153098 :    dtsets(idtset)%atvshift(:,:,:)=zero
                   +  + ]
    2310                 :        8452 :    dtsets(idtset)%auxc_ixc=11
    2311                 :        8452 :    dtsets(idtset)%auxc_scal=one
    2312                 :             : !  B
    2313         [ +  + ]:       42260 :    dtsets(idtset)%bdberry(1:4)=0
    2314                 :        8452 :    dtsets(idtset)%bdeigrf=-1
    2315   [ +  +  +  +  :       23630 :    dtsets(idtset)%bdgw=0
                   +  + ]
    2316                 :        8452 :    dtsets(idtset)%berrystep=1
    2317                 :        8452 :    dtsets(idtset)%bmass=ten
    2318         [ +  + ]:       33808 :    dtsets(idtset)%boxcenter(1:3)=half
    2319                 :        8452 :    dtsets(idtset)%boxcutmin=two
    2320                 :        8452 :    dtsets(idtset)%brvltt=0
    2321                 :        8452 :    dtsets(idtset)%bs_nstates=0
    2322                 :        8452 :    dtsets(idtset)%bs_hayd_term=1
    2323                 :        8452 :    dtsets(idtset)%builtintest=0
    2324                 :        8452 :    dtsets(idtset)%bxctmindg=two
    2325                 :             : !  C
    2326                 :        8452 :    dtsets(idtset)%cd_halfway_freq=3.674930883_dp !(100 eV)
    2327         [ +  + ]:        8468 :    dtsets(idtset)%cd_imfrqs(:) = zero
    2328         [ +  + ]:       25356 :    dtsets(idtset)%cd_subset_freq(1:2)=0
    2329                 :        8452 :    dtsets(idtset)%cd_frqim_method=1
    2330                 :        8452 :    dtsets(idtset)%cd_full_grid=0
    2331         [ +  + ]:       17305 :    dtsets(idtset)%cellcharge(:)=zero
    2332                 :        8452 :    dtsets(idtset)%chebfi_oracle=0
    2333   [ +  +  +  +  :       19326 :    dtsets(idtset)%chempot(:,:,:)=zero
                   +  + ]
    2334                 :        8452 :    dtsets(idtset)%chkdilatmx=1
    2335                 :        8452 :    dtsets(idtset)%chkexit=0
    2336                 :        8452 :    dtsets(idtset)%chkparal=1
    2337                 :        8452 :    dtsets(idtset)%chksymbreak=1
    2338                 :        8452 :    dtsets(idtset)%chksymtnons=1
    2339                 :        8452 :    dtsets(idtset)%chneut=1
    2340                 :        8452 :    dtsets(idtset)%cineb_start=7
    2341         [ +  + ]:       19070 :    dtsets(idtset)%corecs(:) = zero
    2342                 :        8452 :    dtsets(idtset)%cprj_in_memory=0
    2343                 :        8452 :    dtsets(idtset)%cprj_update_lvl=3
    2344                 :             : !  D
    2345                 :        8452 :    dtsets(idtset)%ddamp=0.1_dp
    2346                 :        8452 :    dtsets(idtset)%delayperm=0
    2347                 :        8452 :    dtsets(idtset)%densfor_pred=2
    2348   [ +  +  +  - ]:        8452 :    if (dtsets(idtset)%paral_kgb>0.and.idtset>0) dtsets(idtset)%densfor_pred=6 ! Recommended for band-FFT parallelism
    2349                 :        8452 :    dtsets(idtset)%dfpt_sciss=zero
    2350                 :        8452 :    dtsets(idtset)%diecut=2.2_dp
    2351                 :        8452 :    dtsets(idtset)%dielng=1.0774841_dp
    2352                 :        8452 :    dtsets(idtset)%diemac=1.0d6
    2353         [ +  + ]:        8452 :    if (dtsets(idtset)%usepaw==0) then
    2354                 :        6842 :      dtsets(idtset)%diemix=one
    2355                 :             :    else
    2356                 :        1610 :      dtsets(idtset)%diemix=0.7_dp
    2357                 :             :    end if
    2358                 :        8452 :    dtsets(idtset)%diemixmag=dtsets(idtset)%diemix
    2359                 :        8452 :    dtsets(idtset)%diegap=0.1_dp
    2360                 :        8452 :    dtsets(idtset)%dielam=half
    2361                 :        8452 :    dtsets(idtset)%diismemory=8
    2362                 :        8452 :    dtsets(idtset)%dilatmx=one
    2363                 :        8452 :    dtsets(idtset)%dmatpuopt=2
    2364   [ +  +  +  +  :       11272 :    if (size(dtsets(idtset)%dmatpawu,4)>0) dtsets(idtset)%dmatpawu=-10._dp
          +  +  +  +  +  
                +  +  + ]
    2365                 :        8452 :    dtsets(idtset)%dmatudiag=0
    2366                 :        8452 :    dtsets(idtset)%dmft_charge_prec=tol6
    2367                 :        8452 :    dtsets(idtset)%dmft_dc=1
    2368                 :        8452 :    dtsets(idtset)%dmft_entropy=0
    2369                 :        8452 :    dtsets(idtset)%dmft_fermi_step=0.02_dp
    2370                 :        8452 :    dtsets(idtset)%dmft_hybri_limit=0
    2371                 :        8452 :    dtsets(idtset)%dmft_iter=10
    2372                 :        8452 :    dtsets(idtset)%dmft_kspectralfunc=0
    2373                 :        8452 :    dtsets(idtset)%dmft_magnfield=0
    2374                 :             :    if (dtsets(idtset)%dmft_magnfield .gt. 0) dtsets(idtset)%dmft_magnfield_b=0.0_dp
    2375                 :        8452 :    dtsets(idtset)%dmft_mxsf=0.6_dp
    2376                 :        8452 :    dtsets(idtset)%dmft_nlambda=6
    2377         [ +  + ]:       68576 :    dtsets(idtset)%dmft_nominal(:)=0
    2378                 :        8452 :    dtsets(idtset)%dmft_nwli=0
    2379                 :        8452 :    dtsets(idtset)%dmft_nwlo=0
    2380                 :        8452 :    dtsets(idtset)%dmft_occnd_imag=1
    2381         [ +  + ]:       19070 :    dtsets(idtset)%dmft_orbital(:)=1
    2382                 :        8452 :    dtsets(idtset)%dmft_prt_maxent=1
    2383                 :        8452 :    dtsets(idtset)%dmft_prtself=0
    2384                 :        8452 :    dtsets(idtset)%dmft_prtwan=0
    2385                 :        8452 :    dtsets(idtset)%dmft_read_occnd=0
    2386                 :        8452 :    dtsets(idtset)%dmft_rslf=1
    2387         [ +  + ]:       68576 :    dtsets(idtset)%dmft_shiftself(:)=0.0_dp
    2388                 :        8452 :    dtsets(idtset)%dmft_solv=5
    2389   [ -  +  -  - ]:        8452 :    if(dtsets(idtset)%ucrpa>0.and.dtsets(idtset)%usedmft==1) dtsets(idtset)%dmft_solv=0
    2390                 :        8452 :    dtsets(idtset)%dmft_t2g=0
    2391                 :        8452 :    dtsets(idtset)%dmft_tolfreq=tol4
    2392                 :        8452 :    dtsets(idtset)%dmft_tollc=tol5
    2393                 :        8452 :    dtsets(idtset)%dmft_triqs_basis=-1
    2394                 :        8452 :    dtsets(idtset)%dmft_triqs_chiloc=0
    2395                 :             :    if (dtsets(idtset)%dmft_triqs_chiloc > 0 ) dtsets(idtset)%dmft_triqs_chiloc_ins = 10
    2396                 :        8452 :    dtsets(idtset)%dmft_triqs_compute_integral=1
    2397                 :        8452 :    dtsets(idtset)%dmft_triqs_det_init_size=100
    2398                 :        8452 :    dtsets(idtset)%dmft_triqs_det_n_operations_before_check=10000
    2399                 :        8452 :    dtsets(idtset)%dmft_triqs_det_precision_error=1.0d-5
    2400                 :        8452 :    dtsets(idtset)%dmft_triqs_det_precision_warning=1.0d-8
    2401                 :        8452 :    dtsets(idtset)%dmft_triqs_det_singular_threshold=-1.0_dp
    2402                 :        8452 :    dtsets(idtset)%dmft_triqs_dlr_epsilon=-1.0_dp
    2403                 :        8452 :    dtsets(idtset)%dmft_triqs_dlr_wmax=-1.0_dp
    2404                 :        8452 :    dtsets(idtset)%dmft_triqs_entropy=0
    2405                 :        8452 :    dtsets(idtset)%dmft_triqs_gaussorder=-1
    2406                 :        8452 :    dtsets(idtset)%dmft_triqs_imag_threshold=1.0d-13
    2407                 :        8452 :    dtsets(idtset)%dmft_triqs_length_cycle=0
    2408                 :        8452 :    dtsets(idtset)%dmft_triqs_loc_n_min=0
    2409                 :        8452 :    dtsets(idtset)%dmft_triqs_loc_n_max=huge(0)
    2410                 :        8452 :    dtsets(idtset)%dmft_triqs_measure_density_matrix=1
    2411                 :        8452 :    dtsets(idtset)%dmft_triqs_measure_g_l=0
    2412                 :        8452 :    dtsets(idtset)%dmft_triqs_move_double=0
    2413                 :        8452 :    dtsets(idtset)%dmft_triqs_move_shift=1
    2414                 :        8452 :    dtsets(idtset)%dmft_triqs_n_cycles=0
    2415                 :        8452 :    dtsets(idtset)%dmft_triqs_n_iw=0
    2416                 :        8452 :    dtsets(idtset)%dmft_triqs_n_l=0
    2417                 :        8452 :    dtsets(idtset)%dmft_triqs_n_tau=0
    2418                 :        8452 :    dtsets(idtset)%dmft_triqs_n_warmup_cycles_init=-1
    2419                 :        8452 :    dtsets(idtset)%dmft_triqs_n_warmup_cycles_restart=-1
    2420                 :        8452 :    dtsets(idtset)%dmft_triqs_nsubdivisions=0
    2421                 :        8452 :    dtsets(idtset)%dmft_triqs_off_diag=-1
    2422                 :        8452 :    dtsets(idtset)%dmft_triqs_pauli_prob=0.8
    2423                 :        8452 :    dtsets(idtset)%dmft_triqs_prt_entropy=0
    2424                 :        8452 :    dtsets(idtset)%dmft_triqs_random_seed_a=34788
    2425                 :        8452 :    dtsets(idtset)%dmft_triqs_random_seed_b=928374
    2426                 :        8452 :    dtsets(idtset)%dmft_triqs_read_ctqmcdata=1
    2427                 :        8452 :    dtsets(idtset)%dmft_triqs_shift_mu=0.0_dp
    2428                 :        8452 :    dtsets(idtset)%dmft_triqs_time_invariance=1
    2429                 :        8452 :    dtsets(idtset)%dmft_triqs_tol_block=tol12
    2430                 :        8452 :    dtsets(idtset)%dmft_triqs_use_norm_as_weight=1
    2431                 :        8452 :    dtsets(idtset)%dmft_full_chipsi=0
    2432                 :        8452 :    dtsets(idtset)%dmft_wanorthnorm=3
    2433                 :        8452 :    dtsets(idtset)%dmft_wanrad=-1.0_dp
    2434                 :        8452 :    dtsets(idtset)%dmft_x2my2d=0
    2435                 :        8452 :    dtsets(idtset)%dmft_yukawa_epsilon=-1.0_dp
    2436                 :        8452 :    dtsets(idtset)%dmft_yukawa_lambda=-1.0_dp
    2437                 :        8452 :    dtsets(idtset)%dmft_yukawa_param=1
    2438                 :        8452 :    dtsets(idtset)%dmftbandf=0
    2439                 :        8452 :    dtsets(idtset)%dmftbandi=0
    2440                 :        8452 :    dtsets(idtset)%dmftcheck=0
    2441                 :        8452 :    dtsets(idtset)%dmftctqmc_basis=1
    2442                 :        8452 :    dtsets(idtset)%dmftctqmc_check=0
    2443                 :        8452 :    dtsets(idtset)%dmftctqmc_correl=0
    2444                 :        8452 :    dtsets(idtset)%dmftctqmc_gmove=0
    2445                 :        8452 :    dtsets(idtset)%dmftctqmc_grnns=0
    2446                 :        8452 :    dtsets(idtset)%dmftctqmc_localprop=0
    2447                 :        8452 :    dtsets(idtset)%dmftctqmc_meas=1
    2448                 :        8452 :    dtsets(idtset)%dmftctqmc_mov=0
    2449                 :        8452 :    dtsets(idtset)%dmftctqmc_mrka=0
    2450                 :        8452 :    dtsets(idtset)%dmftctqmc_chains=xomp_get_max_threads()
    2451                 :        8452 :    dtsets(idtset)%dmftctqmc_order=0
    2452                 :        8452 :    dtsets(idtset)%dmftqmc_l=0
    2453                 :        8452 :    dtsets(idtset)%dmftqmc_n=0.0_dp
    2454                 :        8452 :    dtsets(idtset)%dmftqmc_seed=jdtset
    2455                 :        8452 :    dtsets(idtset)%dmftqmc_therm=0
    2456                 :        8452 :    dtsets(idtset)%dosdeltae=0.0
    2457                 :        8452 :    dtsets(idtset)%dtion=100.0_dp
    2458                 :        8452 :    dtsets(idtset)%dtele=0.1_dp
    2459         [ +  + ]:       25356 :    dtsets(idtset)%d3e_pert1_atpol(1:2)=-1
    2460         [ +  + ]:       33808 :    dtsets(idtset)%d3e_pert1_dir(1:3)=1
    2461                 :        8452 :    dtsets(idtset)%d3e_pert1_elfd=0
    2462         [ +  + ]:       25356 :    dtsets(idtset)%d3e_pert1_magat(1:2)=-1
    2463         [ +  + ]:       33808 :    dtsets(idtset)%d3e_pert1_magdir(1:3)=1
    2464                 :        8452 :    dtsets(idtset)%d3e_pert1_magn=0
    2465                 :        8452 :    dtsets(idtset)%d3e_pert1_phon=0
    2466         [ +  + ]:       25356 :    dtsets(idtset)%d3e_pert2_atpol(1:2)=-1
    2467         [ +  + ]:       33808 :    dtsets(idtset)%d3e_pert2_dir(1:3)=1
    2468                 :        8452 :    dtsets(idtset)%d3e_pert2_elfd=0
    2469         [ +  + ]:       25356 :    dtsets(idtset)%d3e_pert2_magat(1:2)=-1
    2470         [ +  + ]:       33808 :    dtsets(idtset)%d3e_pert2_magdir(1:3)=1
    2471                 :        8452 :    dtsets(idtset)%d3e_pert2_magn=0
    2472                 :        8452 :    dtsets(idtset)%d3e_pert2_phon=0
    2473                 :        8452 :    dtsets(idtset)%d3e_pert2_strs=0
    2474         [ +  + ]:       25356 :    dtsets(idtset)%d3e_pert3_atpol(1:2)=-1
    2475         [ +  + ]:       33808 :    dtsets(idtset)%d3e_pert3_dir(1:3)=1
    2476                 :        8452 :    dtsets(idtset)%d3e_pert3_elfd=0
    2477                 :        8452 :    dtsets(idtset)%d3e_pert3_phon=0
    2478                 :             : !  E
    2479                 :        8452 :    dtsets(idtset)%ecut=-one
    2480                 :        8452 :    dtsets(idtset)%ecuteps=zero
    2481                 :        8452 :    dtsets(idtset)%ecutsigx=zero ! If ecutsigx is not defined explicitly, npwsigx will be initialized from ecutwfn.
    2482                 :        8452 :    dtsets(idtset)%ecutsm=zero
    2483                 :        8452 :    dtsets(idtset)%ecutwfn=zero ! The true default value is ecut. This is defined in invars2.F90
    2484                 :        8452 :    dtsets(idtset)%effmass_free=one
    2485                 :        8452 :    dtsets(idtset)%efmas=0
    2486   [ +  +  +  + ]:      641680 :    dtsets(idtset)%efmas_bands=0 ! The true default is nband. This is defined in invars2.F90
    2487                 :        8452 :    dtsets(idtset)%efmas_deg=1
    2488                 :        8452 :    dtsets(idtset)%efmas_deg_tol=tol5
    2489                 :        8452 :    dtsets(idtset)%efmas_dim=3
    2490   [ +  +  +  + ]:        9468 :    dtsets(idtset)%efmas_dirs=zero
    2491                 :        8452 :    dtsets(idtset)%efmas_ntheta=1000
    2492                 :        8452 :    dtsets(idtset)%elph2_imagden=zero
    2493                 :        8452 :    dtsets(idtset)%enunit=0
    2494                 :        8452 :    dtsets(idtset)%eshift=zero
    2495                 :        8452 :    dtsets(idtset)%esmear=0.01_dp
    2496                 :        8452 :    dtsets(idtset)%exchn2n3d=0
    2497                 :        8452 :    dtsets(idtset)%extrapwf=0
    2498                 :        8452 :    dtsets(idtset)%exchmix=quarter
    2499                 :        8452 :    dtsets(idtset)%expert_user=0
    2500                 :             : !  F
    2501                 :        8452 :    dtsets(idtset)%focktoldfe=zero
    2502                 :        8452 :    dtsets(idtset)%fockoptmix=0
    2503         [ +  + ]:       33808 :    dtsets(idtset)%fockdownsampling(:)=1
    2504                 :        8452 :    dtsets(idtset)%fock_icutcoul=0  ! Spherical-cutoff for legacy reasons
    2505                 :        8452 :    dtsets(idtset)%fock_rcut=zero   ! Spencer-Alavi by default
    2506                 :        8452 :    dtsets(idtset)%freqim_alpha=five
    2507                 :        8452 :    dtsets(idtset)%friction=0.001_dp
    2508                 :        8452 :    dtsets(idtset)%frictionbar=0.001_dp
    2509                 :        8452 :    dtsets(idtset)%frzfermi=0
    2510                 :        8452 :    dtsets(idtset)%fxcartfactor=one ! Should be adjusted to the H2 conversion factor
    2511                 :             : !  G
    2512                 :        8452 :    dtsets(idtset)%ga_algor =1
    2513                 :        8452 :    dtsets(idtset)%ga_fitness =1
    2514                 :        8452 :    dtsets(idtset)%ga_opt_percent =0.2_dp
    2515         [ +  + ]:      262012 :    dtsets(idtset)%ga_rules(:) =1
    2516                 :        8452 :    dtsets(idtset)%geoopt = "none"
    2517                 :        8452 :    dtsets(idtset)%ggtrcut=0.001_dp
    2518                 :        8452 :    dtsets(idtset)%goprecon =0
    2519         [ +  + ]:       33808 :    dtsets(idtset)%goprecprm(:)=0
    2520         [ +  + ]:      109876 :    dtsets(idtset)%gpu_devices=(/-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1/)
    2521                 :        8452 :    dtsets(idtset)%gpu_nfft_blocks=0
    2522                 :        8452 :    dtsets(idtset)%gpu_kokkos_nthrd=xomp_get_max_threads()
    2523                 :        8452 :    dtsets(idtset)%gpu_linalg_limit=2000000
    2524                 :        8452 :    dtsets(idtset)%gpu_nl_distrib=0
    2525                 :        8452 :    dtsets(idtset)%gpu_nl_splitsize=0
    2526                 :        8452 :    dtsets(idtset)%gpu_thread_limit=0
    2527         [ -  + ]:        8452 :    if(dtsets(idtset)%gpu_option/=ABI_GPU_DISABLED) then
    2528                 :           0 :      dtsets(idtset)%gpu_thread_limit=min(4,xomp_get_max_threads())
    2529                 :             :    end if
    2530   [ +  +  +  + ]:        8467 :    if (dtsets(idtset)%gw_customnfreqsp/=0) dtsets(idtset)%gw_freqsp(:) = zero
    2531         [ +  + ]:        8452 :    if ( dtsets(idtset)%gw_nqlwl > 0 ) then
    2532   [ +  +  +  + ]:           5 :      dtsets(idtset)%gw_qlwl(:,:)=zero
    2533                 :           1 :      dtsets(idtset)%gw_qlwl(1,1)=0.00001_dp
    2534                 :           1 :      dtsets(idtset)%gw_qlwl(2,1)=0.00002_dp
    2535                 :           1 :      dtsets(idtset)%gw_qlwl(3,1)=0.00003_dp
    2536                 :             :    end if
    2537                 :        8452 :    dtsets(idtset)%gw_frqim_inzgrid=0
    2538                 :        8452 :    dtsets(idtset)%gw_frqre_inzgrid=0
    2539                 :        8452 :    dtsets(idtset)%gw_frqre_tangrid=0
    2540                 :        8452 :    dtsets(idtset)%gw_invalid_freq=0
    2541                 :        8452 :    dtsets(idtset)%gw_icutcoul=6
    2542                 :        8452 :    dtsets(idtset)%gw_qprange=0
    2543                 :        8452 :    dtsets(idtset)%gw_rcut=zero   ! Spencer-Alavi value by default
    2544                 :        8452 :    dtsets(idtset)%gw_sigxcore=1
    2545                 :        8452 :    dtsets(idtset)%gwls_stern_kmax=1
    2546                 :        8452 :    dtsets(idtset)%gwls_model_parameter=1.0_dp
    2547                 :        8452 :    dtsets(idtset)%gwls_npt_gauss_quad=10
    2548                 :        8452 :    dtsets(idtset)%gwls_diel_model=2
    2549                 :        8452 :    dtsets(idtset)%gwls_print_debug=0
    2550   [ -  +  -  - ]:        8452 :    if (dtsets(idtset)%gwls_n_proj_freq/=0) dtsets(idtset)%gwls_list_proj_freq(:) = zero
    2551                 :        8452 :    dtsets(idtset)%gwls_nseeds=1
    2552                 :        8452 :    dtsets(idtset)%gwls_recycle=2
    2553                 :        8452 :    dtsets(idtset)%gwls_kmax_complement=1
    2554                 :        8452 :    dtsets(idtset)%gwls_kmax_poles=4
    2555                 :        8452 :    dtsets(idtset)%gwls_kmax_analytic=8
    2556                 :        8452 :    dtsets(idtset)%gwls_kmax_numeric=16
    2557                 :        8452 :    dtsets(idtset)%gwls_band_index=1
    2558                 :        8452 :    dtsets(idtset)%gwls_exchange=1
    2559                 :        8452 :    dtsets(idtset)%gwls_correlation=3
    2560                 :        8452 :    dtsets(idtset)%gwls_first_seed=0
    2561                 :             : !  H
    2562                 :        8452 :    dtsets(idtset)%hmcsst=3
    2563                 :        8452 :    dtsets(idtset)%hmctt=4
    2564                 :        8452 :    dtsets(idtset)%hyb_mixing=-999.0_dp
    2565                 :        8452 :    dtsets(idtset)%hyb_mixing_sr=-999.0_dp
    2566                 :        8452 :    dtsets(idtset)%hyb_range_dft=-999.0_dp
    2567                 :        8452 :    dtsets(idtset)%hyb_range_fock=-999.0_dp
    2568                 :             : !  I
    2569         [ +  + ]:        8452 :    if(dtsets(idtset)%natsph/=0) then
    2570                 :             : !    do not use iatsph(:) but explicit boundaries
    2571                 :             : !    to avoid to read to far away in the built array (/ ... /)
    2572   [ +  -  +  +  :       83268 :      dtsets(idtset)%iatsph(1:dtsets(idtset)%natsph)=(/ (ii,ii=1,dtsets(idtset)%natsph) /)
                   +  + ]
    2573                 :             :    else
    2574         [ +  + ]:        6697 :      dtsets(idtset)%iatsph(:)=0
    2575                 :             :    end if
    2576                 :        8452 :    dtsets(idtset)%iboxcut=0
    2577                 :        8452 :    dtsets(idtset)%icutcoul=3
    2578                 :        8452 :    dtsets(idtset)%ieig2rf=0
    2579                 :        8452 :    dtsets(idtset)%imgwfstor=0
    2580                 :        8452 :    dtsets(idtset)%intxc=0
    2581                 :             :    ! if (dtsets(idtset)%paral_kgb>0.and.idtset>0) dtsets(idtset)%intxc=0
    2582                 :        8452 :    dtsets(idtset)%invovl_algo=0
    2583                 :        8452 :    dtsets(idtset)%invovl_blksliced=1
    2584                 :        8452 :    dtsets(idtset)%invovl_dyn_prec=0
    2585                 :        8452 :    dtsets(idtset)%invovl_precision=1e-16
    2586                 :        8452 :    dtsets(idtset)%invovl_prec_ceil=1e-8
    2587         [ -  + ]:        8452 :    if(dtsets(idtset)%gpu_option/=ABI_GPU_DISABLED.and.dtsets(idtset)%gpu_option/=ABI_GPU_LEGACY) then
    2588         [ #  # ]:           0 :      if (dtsets(idtset)%usepaw==1) dtsets(idtset)%invovl_blksliced=0
    2589                 :             :    end if
    2590                 :        8452 :    dtsets(idtset)%ionmov=0
    2591                 :        8452 :    dtsets(idtset)%densfor_pred=2
    2592   [ +  +  +  - ]:        8452 :    if (dtsets(idtset)%paral_kgb>0.and.idtset>0) dtsets(idtset)%densfor_pred=6 ! Recommended for band-FFT parallelism
    2593                 :        8452 :    dtsets(idtset)%iprcel=0
    2594                 :        8452 :    dtsets(idtset)%iprcfc=0
    2595                 :        8452 :    dtsets(idtset)%irandom=3
    2596                 :             : !iscf
    2597         [ -  + ]:        8452 :    if(wvl_bigdft) then
    2598                 :           0 :      dtsets(idtset)%iscf=0
    2599                 :             :    else
    2600         [ +  + ]:        8452 :      if(dtsets(idtset)%usepaw==0) then
    2601                 :        6842 :        dtsets(idtset)%iscf=7
    2602                 :             :      else
    2603                 :        1610 :        dtsets(idtset)%iscf=17
    2604                 :             :      end if
    2605                 :             :    end if
    2606                 :        8452 :    dtsets(idtset)%isecur=0
    2607                 :        8452 :    dtsets(idtset)%istatimg = 1
    2608         [ +  + ]:      219528 :    dtsets(idtset)%istwfk(:)=0
    2609                 :        8452 :    dtsets(idtset)%ixc=1
    2610                 :        8452 :    dtsets(idtset)%ixc_sigma=1
    2611                 :        8452 :    dtsets(idtset)%ixcpositron=1
    2612                 :        8452 :    dtsets(idtset)%ixcrot=1
    2613                 :             : !  J
    2614         [ +  + ]:       19070 :    dtsets(idtset)%f4of2_sla(:)=-one
    2615         [ +  + ]:       19070 :    dtsets(idtset)%f6of2_sla(:)=-one
    2616   [ +  +  +  + ]:       28656 :    dtsets(idtset)%jpawu(:,:)=zero
    2617                 :             : !  K
    2618   [ +  +  +  + ]:      684612 :    dtsets(idtset)%kberry(1:3,:)=0
    2619   [ +  +  +  + ]:      852756 :    dtsets(idtset)%kpt(:,:)=zero
    2620   [ +  +  +  + ]:       14460 :    dtsets(idtset)%kptgw(:,:)=zero
    2621                 :        8452 :    dtsets(idtset)%kptnrm=one
    2622   [ +  +  +  + ]:     5597560 :    dtsets(idtset)%kptns_hf(:,:)=zero
    2623                 :        8452 :    dtsets(idtset)%kptopt=1
    2624         [ +  + ]:        8452 :    if(dtsets(idtset)%nspden==4)dtsets(idtset)%kptopt=4
    2625                 :        8452 :    dtsets(idtset)%kptrlen=30.0_dp
    2626                 :             : !  L
    2627                 :             : 
    2628                 :             : #if defined HAVE_LOTF
    2629                 :             :    dtsets(idtset)%lotf_classic=5
    2630                 :             :    dtsets(idtset)%lotf_nitex=10
    2631                 :             :    dtsets(idtset)%lotf_nneigx=40
    2632                 :             :    dtsets(idtset)%lotf_version=2
    2633                 :             : #endif
    2634         [ +  + ]:       19070 :    dtsets(idtset)%lambsig(:) = zero
    2635                 :        8452 :    dtsets(idtset)%lw_qdrpl=0
    2636                 :        8452 :    dtsets(idtset)%lw_flexo=0
    2637                 :        8452 :    dtsets(idtset)%lw_natopt=0
    2638                 :             : !  M
    2639                 :        8452 :    dtsets(idtset)%magconon = 0
    2640                 :        8452 :    dtsets(idtset)%magcon_lambda = 0.01_dp
    2641                 :        8452 :    dtsets(idtset)%magpen = zero
    2642                 :        8452 :    dtsets(idtset)%mband = -1
    2643         [ +  + ]:       25356 :    dtsets(idtset)%mdtemp(:)=300.0_dp
    2644                 :        8452 :    dtsets(idtset)%mdeg_filter = 6
    2645                 :        8452 :    dtsets(idtset)%mdwall=10000_dp
    2646                 :        8452 :    dtsets(idtset)%mep_mxstep=100._dp
    2647                 :        8452 :    dtsets(idtset)%mep_solver=MEP_SOLVER_STEEPEST
    2648                 :        8452 :    dtsets(idtset)%mffmem=1
    2649                 :        8452 :    dtsets(idtset)%mgfft = -1
    2650                 :        8452 :    dtsets(idtset)%mgfftdg = -1
    2651         [ +  + ]:       17305 :    dtsets(idtset)%mixesimgf(:)=zero
    2652         [ +  + ]:       25356 :    dtsets(idtset)%mpatpol(1:2)=-1
    2653         [ +  + ]:       33808 :    dtsets(idtset)%mpdir(1:3)=0
    2654                 :        8452 :    dtsets(idtset)%moldyn = "none"
    2655                 :        8452 :    dtsets(idtset)%mpw = -1
    2656                 :        8452 :    dtsets(idtset)%mqgrid=0
    2657                 :        8452 :    dtsets(idtset)%mqgriddg=0
    2658                 :             : !  N
    2659                 :        8452 :    dtsets(idtset)%natrd = -1
    2660         [ +  + ]:      226257 :    dtsets(idtset)%nband(:)=0
    2661                 :        8452 :    dtsets(idtset)%nbandhf=0
    2662                 :        8452 :    dtsets(idtset)%nbdblock=1
    2663                 :        8452 :    dtsets(idtset)%nbdbuf=0
    2664                 :        8452 :    dtsets(idtset)%nberry=1
    2665         [ +  + ]:        8452 :    if (dtsets(idtset)%usepaw == 0) then
    2666                 :        6842 :      dtsets(idtset)%nc_xccc_gspace = 0
    2667                 :             :    else
    2668                 :        1610 :      dtsets(idtset)%nc_xccc_gspace = 1
    2669                 :             :    end if
    2670                 :        8452 :    dtsets(idtset)%nctime = 0
    2671                 :        8452 :    dtsets(idtset)%ncout = 1
    2672                 :        8452 :    dtsets(idtset)%ndtset = -1
    2673                 :        8452 :    dtsets(idtset)%neb_algo = NEB_ALGO_IMPROVED_TAN
    2674                 :        8452 :    dtsets(idtset)%neb_cell_algo = NEB_CELL_ALGO_NONE
    2675         [ +  + ]:       25356 :    dtsets(idtset)%neb_spring(1:2) = (/0.05_dp,0.05_dp/)
    2676                 :        8452 :    dtsets(idtset)%nfft = -1
    2677                 :        8452 :    dtsets(idtset)%nfftdg = -1
    2678                 :             : 
    2679                 :        8452 :    dtsets(idtset)%npulayit=7
    2680                 :             : 
    2681                 :             : !  ngfft is a special case
    2682         [ +  + ]:       76068 :    dtsets(idtset)%ngfft(1:8)=0
    2683                 :        8452 :    dtsets(idtset)%ngfft(7) = fftalg_for_npfft(1)
    2684                 :             : !  fftcache=ngfft(8) is machine-dependent.
    2685                 :        8452 :    dtsets(idtset)%ngfft(8) = get_cache_kb()
    2686                 :             : 
    2687         [ +  + ]:      160588 :    dtsets(idtset)%ngfftdg(:)=dtsets(idtset)%ngfft(:)
    2688                 :             : !
    2689                 :             :    !nline
    2690                 :        8452 :    dtsets(idtset)%nline=4
    2691                 :             :    !For Chebyshev filtering algo, nline is the degree of the Chebyshev polynomial
    2692         [ +  + ]:        8452 :    if (mod(dtsets(idtset)%wfoptalg,10) == 1) then
    2693                 :         216 :      dtsets(idtset)%nline = dtsets(idtset)%mdeg_filter
    2694                 :             :    end if
    2695                 :             :    !Specific value for wavelets
    2696   [ -  +  -  - ]:        8452 :    if(dtsets(idtset)%usewvl==1 .and. .not. wvl_bigdft) then
    2697         [ #  # ]:           0 :      if(dtsets(idtset)%usepaw==1) dtsets(idtset)%nline=4
    2698         [ #  # ]:           0 :      if(dtsets(idtset)%usepaw/=1) dtsets(idtset)%nline=2
    2699                 :             :    end if
    2700                 :             : 
    2701                 :             : !  nloalg is also a special case
    2702                 :        8452 :    dtsets(idtset)%nloalg(1)=4
    2703                 :        8452 :    dtsets(idtset)%nloalg(2)=1
    2704                 :        8452 :    dtsets(idtset)%nloalg(3)=dtsets(idtset)%usepaw
    2705                 :             :    !if (dtsets(idtset)%optdriver == RUNL_EPH) dtsets(idtset)%nloalg(3) = 1
    2706         [ +  + ]:       33808 :    dtsets(idtset)%ngkpt=0
    2707                 :        8452 :    dtsets(idtset)%nnsclo=0
    2708                 :        8452 :    dtsets(idtset)%nnsclohf=0
    2709                 :        8452 :    dtsets(idtset)%nonlinear_info=0
    2710                 :        8452 :    dtsets(idtset)%noseinert=1.0d5
    2711                 :        8452 :    dtsets(idtset)%npvel=0
    2712                 :        8452 :    dtsets(idtset)%nqpt=0
    2713                 :        8452 :    dtsets(idtset)%nscforder=16
    2714                 :        8452 :    dtsets(idtset)%nshiftk=1
    2715                 :        8452 :    dtsets(idtset)%nshiftk_orig=1
    2716                 :        8452 :    dtsets(idtset)%nstep=30
    2717                 :        8452 :    dtsets(idtset)%ntime=1
    2718                 :        8452 :    dtsets(idtset)%nwfshist=0
    2719   [ -  +  -  - ]:        8452 :    if(dtsets(idtset)%usewvl==1 .and. .not. wvl_bigdft) then
    2720         [ #  # ]:           0 :      if(dtsets(idtset)%usepaw==1) then
    2721                 :           0 :        dtsets(idtset)%nwfshist=4
    2722                 :             :      else
    2723                 :           0 :        dtsets(idtset)%nwfshist=2
    2724                 :             :      end if
    2725                 :             :    end if
    2726                 :             : !  O
    2727                 :        8452 :    dtsets(idtset)%occopt=1
    2728   [ +  +  +  + ]:     1826975 :    dtsets(idtset)%occ_orig(:,:)=zero
    2729                 :        8452 :    dtsets(idtset)%optcell=0
    2730                 :        8452 :    dtsets(idtset)%optforces=2
    2731         [ +  + ]:        8452 :    if(dtsets(idtset)%usedmft>0 .and. dtsets(idtset)%usedmft/=0) dtsets(idtset)%optforces=0
    2732                 :        8452 :    dtsets(idtset)%optstress=1
    2733                 :        8452 :    dtsets(idtset)%optnlxccc=1
    2734                 :        8452 :    dtsets(idtset)%oracle_factor=0.1_dp
    2735                 :        8452 :    dtsets(idtset)%oracle_min_occ=0.0001_dp
    2736                 :        8452 :    dtsets(idtset)%orbmag=0
    2737         [ +  + ]:        8452 :    if (dtsets(idtset)%usepaw==0) then
    2738                 :        6842 :      dtsets(idtset)%ortalg=2
    2739                 :             :    else
    2740                 :        1610 :      dtsets(idtset)%ortalg=-2
    2741                 :             :    end if
    2742                 :             : !  P
    2743                 :        8452 :    dtsets(idtset)%paral_atom=paral_atom_default
    2744                 :        8452 :    dtsets(idtset)%paw_add_core=0
    2745                 :        8452 :    dtsets(idtset)%pawcpxocc=1
    2746                 :        8452 :    dtsets(idtset)%pawcross=0
    2747                 :        8452 :    dtsets(idtset)%pawecutdg=-one
    2748                 :        8452 :    dtsets(idtset)%pawfatbnd=0
    2749                 :        8452 :    dtsets(idtset)%pawlcutd=10
    2750                 :        8452 :    dtsets(idtset)%pawlmix=10
    2751                 :        8452 :    dtsets(idtset)%pawmixdg=0 ! Will be set to 1 when npfft>1
    2752                 :        8452 :    dtsets(idtset)%pawnhatxc=1
    2753                 :        8452 :    dtsets(idtset)%pawntheta=12
    2754                 :        8452 :    dtsets(idtset)%pawnphi=13
    2755                 :        8452 :    dtsets(idtset)%pawnzlm=1
    2756                 :        8452 :    dtsets(idtset)%pawoptmix=0
    2757                 :        8452 :    dtsets(idtset)%pawoptosc=0
    2758                 :        8452 :    dtsets(idtset)%pawovlp=5._dp
    2759                 :        8452 :    dtsets(idtset)%pawprtdos=0
    2760                 :        8452 :    dtsets(idtset)%pawprtvol=0
    2761                 :        8452 :    dtsets(idtset)%pawprtwf=0
    2762                 :        8452 :    dtsets(idtset)%pawprt_k=0
    2763                 :        8452 :    dtsets(idtset)%pawprt_b=0
    2764                 :        8452 :    dtsets(idtset)%pawstgylm=1
    2765                 :        8452 :    dtsets(idtset)%pawsushat=0
    2766                 :        8452 :    dtsets(idtset)%pawujat=1
    2767                 :        8452 :    dtsets(idtset)%pawujrad=20.0_dp
    2768                 :        8452 :    dtsets(idtset)%pawujv=0.1_dp/Ha_eV
    2769                 :        8452 :    dtsets(idtset)%pawusecp=1
    2770                 :        8452 :    dtsets(idtset)%pawxcdev=1
    2771                 :        8452 :    dtsets(idtset)%pimd_constraint=0
    2772                 :        8452 :    dtsets(idtset)%pitransform=0
    2773         [ +  + ]:       19070 :    dtsets(idtset)%ptcharge(:) = zero
    2774                 :             :    !dtsets(idtset)%plowan_compute=0
    2775                 :        8452 :    dtsets(idtset)%plowan_bandi=0
    2776                 :        8452 :    dtsets(idtset)%plowan_bandf=0
    2777                 :             :    !if(dtsets(idtset)%plowan_compute>0) then
    2778         [ +  + ]:     2544052 :    dtsets(idtset)%plowan_it(:)=0
    2779         [ +  + ]:       68576 :    dtsets(idtset)%plowan_iatom(:)=0
    2780         [ +  + ]:      729940 :    dtsets(idtset)%plowan_lcalc(:)=-1
    2781         [ +  + ]:      729940 :    dtsets(idtset)%plowan_projcalc(:)=0
    2782         [ +  + ]:       68576 :    dtsets(idtset)%plowan_nbl(:)=0
    2783                 :             :    !end if
    2784                 :        8452 :    dtsets(idtset)%plowan_natom=0
    2785                 :        8452 :    dtsets(idtset)%plowan_nt=0
    2786                 :        8452 :    dtsets(idtset)%plowan_realspace=0
    2787         [ +  + ]:       33808 :    dtsets(idtset)%pol(:)=zero
    2788         [ +  + ]:       33808 :    dtsets(idtset)%polcen(:)=zero
    2789                 :        8452 :    dtsets(idtset)%posdoppler=0
    2790                 :        8452 :    dtsets(idtset)%positron=0
    2791                 :        8452 :    dtsets(idtset)%posnstep=50
    2792                 :        8452 :    dtsets(idtset)%posocc=one
    2793                 :        8452 :    dtsets(idtset)%postoldfe=0.000001_dp
    2794                 :        8452 :    dtsets(idtset)%postoldff=zero
    2795                 :        8452 :    dtsets(idtset)%precon_in_memory=1
    2796                 :        8452 :    dtsets(idtset)%precon_ls_maxite=20
    2797                 :        8452 :    dtsets(idtset)%precon_ls_rtol=tol6
    2798                 :        8452 :    dtsets(idtset)%precon_tsmear=0.01_dp
    2799                 :        8452 :    dtsets(idtset)%precon_verbose=0
    2800                 :        8452 :    dtsets(idtset)%prepalw=0
    2801                 :        8452 :    dtsets(idtset)%prepanl=0
    2802                 :        8452 :    dtsets(idtset)%prtcurrent=0
    2803         [ +  + ]:        8452 :    dtsets(idtset)%prtden=1    ; if (dtsets(idtset)%nimage>1) dtsets(idtset)%prtden=0
    2804         [ +  + ]:        8452 :    dtsets(idtset)%prtebands=1 ; if (dtsets(idtset)%nimage>1) dtsets(idtset)%prtebands=0
    2805         [ +  + ]:        8452 :    dtsets(idtset)%prteig=1    ; if (dtsets(idtset)%nimage>1) dtsets(idtset)%prteig=0
    2806                 :        8452 :    dtsets(idtset)%prtevk=0
    2807         [ +  + ]:        8452 :    dtsets(idtset)%prtgsr=1    ; if (dtsets(idtset)%nimage>1) dtsets(idtset)%prtgsr=0
    2808                 :        8452 :    dtsets(idtset)%prtkpt = -1
    2809                 :        8452 :    dtsets(idtset)%prt1mag = 0
    2810                 :        8452 :    dtsets(idtset)%prtocc=0
    2811         [ +  + ]:        8452 :    dtsets(idtset)%prtwf=1     ; if (dtsets(idtset)%nimage>1) dtsets(idtset)%prtwf=0
    2812                 :             :    !if (dtsets%(idtset)%optdriver == RUNL_RESPFN and all(dtsets(:)%optdriver /= RUNL_NONLINEAR) dtsets(idtset)%prtwf = -1
    2813         [ +  + ]:       46609 :    do ii=1,dtsets(idtset)%natom,1
    2814                 :       46609 :      dtsets(idtset)%prtatlist(ii)=ii
    2815                 :             :    end do
    2816                 :        8452 :    dtsets(idtset)%pulayhiststore=0
    2817         [ +  + ]:       33808 :    dtsets(idtset)%pvelmax(:)=one
    2818                 :        8452 :    dtsets(idtset)%pw_unbal_thresh=40._dp
    2819                 :             : !  Q
    2820         [ +  + ]:        8508 :    dtsets(idtset)%qmass(:)=ten
    2821                 :        8452 :    dtsets(idtset)%qgbt(3)=zero
    2822                 :        8452 :    dtsets(idtset)%qgbt_cart(3)=zero
    2823         [ +  + ]:       33808 :    dtsets(idtset)%qprtrb(1:3)=0
    2824   [ +  +  +  + ]:        8512 :    dtsets(idtset)%qptdm(:,:)=zero
    2825         [ +  + ]:       19070 :    dtsets(idtset)%quadmom(:) = zero
    2826                 :             : !  R
    2827                 :        8452 :    dtsets(idtset)%random_atpos=0
    2828                 :        8452 :    dtsets(idtset)%ratopt=1
    2829                 :        8452 :    dtsets(idtset)%ratsm=zero
    2830   [ +  +  +  +  :       17050 :    if (any(dtsets(idtset)%constraint_kind(1:dtsets(idtset)%ntypat)>0)) dtsets(idtset)%ratsm=0.05_dp
                   +  + ]
    2831                 :        8452 :    dtsets(idtset)%ratsph_extra=two
    2832                 :        8452 :    dtsets(idtset)%recefermi=zero
    2833                 :        8452 :    dtsets(idtset)%recgratio=1
    2834                 :        8452 :    dtsets(idtset)%recnpath=500
    2835                 :        8452 :    dtsets(idtset)%recnrec=10
    2836                 :        8452 :    dtsets(idtset)%recrcut=zero
    2837                 :        8452 :    dtsets(idtset)%recptrott=0
    2838                 :        8452 :    dtsets(idtset)%rectesteg=0
    2839                 :        8452 :    dtsets(idtset)%rectolden=zero
    2840         [ +  + ]:       19070 :    dtsets(idtset)%rcpaw_sc(:)=two
    2841         [ +  + ]:       19070 :    dtsets(idtset)%rcpaw_rctypat(:)=1
    2842                 :        8452 :    dtsets(idtset)%rcut=zero
    2843                 :        8452 :    dtsets(idtset)%restartxf=0
    2844                 :             : !  dtsets(idtset)%rfasr=0
    2845         [ +  + ]:       25356 :    dtsets(idtset)%rfatpol(1:2)=-1
    2846                 :        8452 :    dtsets(idtset)%rfddk=0
    2847         [ +  + ]:       33808 :    dtsets(idtset)%rfdir(1:3)=1
    2848                 :        8452 :    dtsets(idtset)%rfelfd=0
    2849                 :        8452 :    dtsets(idtset)%rfeta=zero
    2850                 :        8452 :    dtsets(idtset)%rfmagn=0
    2851                 :        8452 :    dtsets(idtset)%rfmeth=1
    2852                 :        8452 :    dtsets(idtset)%rfomega=zero
    2853                 :        8452 :    dtsets(idtset)%rfphon=0
    2854                 :        8452 :    dtsets(idtset)%rfstrs=0
    2855                 :        8452 :    dtsets(idtset)%rfstrs_ref=0
    2856                 :        8452 :    dtsets(idtset)%rf2_dkdk=0
    2857                 :        8452 :    dtsets(idtset)%rf2_dkde=0
    2858         [ +  + ]:       33808 :    dtsets(idtset)%rf2_pert1_dir(1:3)=1
    2859         [ +  + ]:       33808 :    dtsets(idtset)%rf2_pert2_dir(1:3)=1
    2860                 :        8452 :    dtsets(idtset)%rhoqpmix=one
    2861                 :             : !  S
    2862   [ +  +  +  + ]:     7108132 :    dtsets(idtset)%shiftk_orig(:,:)=one
    2863                 :        8452 :    dtsets(idtset)%signperm=1
    2864                 :        8452 :    dtsets(idtset)%slabwsrad=zero
    2865                 :        8452 :    dtsets(idtset)%slk_rankpp=1000
    2866                 :        8452 :    dtsets(idtset)%smdelta=0
    2867                 :        8452 :    dtsets(idtset)%spbroad=0.1_dp
    2868                 :        8452 :    dtsets(idtset)%spgaxor = -1
    2869                 :        8452 :    dtsets(idtset)%spgorig = -1
    2870                 :        8452 :    dtsets(idtset)%spinmagntarget=-99.99_dp
    2871                 :        8452 :    dtsets(idtset)%spnorbscl=one
    2872                 :        8452 :    dtsets(idtset)%stmbias=zero
    2873                 :        8452 :    dtsets(idtset)%strfact=100.0_dp
    2874                 :        8452 :    dtsets(idtset)%string_algo=STRING_ALGO_SIMPLIFIED_EQUAL
    2875                 :        8452 :    dtsets(idtset)%strprecon=one
    2876         [ +  + ]:       59164 :    dtsets(idtset)%strtarget(1:6)=zero
    2877                 :             : !  T
    2878                 :        8452 :    dtsets(idtset)%td_exp_order=4
    2879                 :        8452 :    dtsets(idtset)%td_maxene=zero
    2880                 :        8452 :    dtsets(idtset)%td_mexcit=0
    2881                 :        8452 :    dtsets(idtset)%td_scnmax=6
    2882                 :        8452 :    dtsets(idtset)%td_prtstr=1
    2883                 :        8452 :    dtsets(idtset)%td_restart=0
    2884                 :        8452 :    dtsets(idtset)%td_propagator=0
    2885                 :        8452 :    dtsets(idtset)%td_scthr=1e-7_dp
    2886                 :        8452 :    dtsets(idtset)%td_ef_type=0
    2887                 :        8452 :    dtsets(idtset)%td_ef_induced_vecpot=0
    2888                 :        8452 :    dtsets(idtset)%td_ef_tzero=zero
    2889                 :        8452 :    dtsets(idtset)%td_ef_tau=1.0_dp
    2890         [ +  + ]:       33808 :    dtsets(idtset)%td_ef_pol=[1.0_dp,0.0_dp,0.0_dp]
    2891                 :        8452 :    dtsets(idtset)%td_ef_lambda=10000.0_dp
    2892                 :        8452 :    dtsets(idtset)%td_ef_ezero=0.1_dp
    2893                 :        8452 :    dtsets(idtset)%tfw_toldfe=0.000001_dp
    2894                 :        8452 :    dtsets(idtset)%timdisp=0
    2895                 :        8452 :    dtsets(idtset)%tim1rev = 1
    2896                 :        8452 :    dtsets(idtset)%tl_nprccg = 30
    2897                 :        8452 :    dtsets(idtset)%tl_radius = zero
    2898                 :        8452 :    dtsets(idtset)%tphysel=zero
    2899                 :        8452 :    dtsets(idtset)%toldfe=zero
    2900                 :        8452 :    dtsets(idtset)%tolmxde=zero
    2901                 :        8452 :    dtsets(idtset)%toldff=zero
    2902                 :        8452 :    dtsets(idtset)%toldmag=zero
    2903                 :        8452 :    dtsets(idtset)%tolimg=5.0d-5
    2904                 :        8452 :    dtsets(idtset)%tolrde=0.005_dp
    2905                 :        8452 :    dtsets(idtset)%tolrff=zero
    2906                 :        8452 :    dtsets(idtset)%tolmxf=5.0d-5
    2907                 :        8452 :    dtsets(idtset)%tolvrs=zero
    2908                 :        8452 :    dtsets(idtset)%tolwfr=zero
    2909                 :        8452 :    dtsets(idtset)%tolwfr_diago=zero
    2910                 :             : 
    2911                 :        8452 :    dtsets(idtset)%tsmear=0.01_dp
    2912                 :             : !  U
    2913         [ +  + ]:       25356 :    dtsets(idtset)%ucrpa_bands(:)=-1
    2914         [ +  + ]:       25356 :    dtsets(idtset)%ucrpa_window(:)=-1.0_dp
    2915   [ +  +  +  + ]:       28656 :    dtsets(idtset)%upawu(:,:)=zero
    2916                 :        8452 :    dtsets(idtset)%usepead=1
    2917                 :        8452 :    dtsets(idtset)%usefock=0
    2918                 :        8452 :    dtsets(idtset)%usekden=0
    2919                 :        8452 :    dtsets(idtset)%use_gemm_nonlop=0
    2920                 :        8452 :    dtsets(idtset)%use_nonscf_gkk=0 !1 ! deactivate by default, for now 6 Oct 2013
    2921                 :        8452 :    dtsets(idtset)%userec=0
    2922                 :        8452 :    dtsets(idtset)%usexcnhat_orig=-1
    2923                 :        8452 :    dtsets(idtset)%useylm=0
    2924                 :             : !  V
    2925                 :        8452 :    dtsets(idtset)%vacnum = -1
    2926                 :        8452 :    dtsets(idtset)%vcutgeo(3)=zero
    2927                 :        8452 :    dtsets(idtset)%vdw_nfrag = 1
    2928                 :             : #if defined DEV_YP_VDWXC
    2929                 :             :    dtsets(idtset)%vdw_df_acutmin = vdw_defaults%acutmin
    2930                 :             :    dtsets(idtset)%vdw_df_aratio = vdw_defaults%aratio
    2931                 :             :    dtsets(idtset)%vdw_df_damax = vdw_defaults%damax
    2932                 :             :    dtsets(idtset)%vdw_df_damin = vdw_defaults%damin
    2933                 :             :    dtsets(idtset)%vdw_df_dcut = vdw_defaults%dcut
    2934                 :             :    dtsets(idtset)%vdw_df_dratio = vdw_defaults%dratio
    2935                 :             :    dtsets(idtset)%vdw_df_dsoft = vdw_defaults%dsoft
    2936                 :             :    dtsets(idtset)%vdw_df_gcut = vdw_defaults%gcut
    2937                 :             :    dtsets(idtset)%vdw_df_ndpts = vdw_defaults%ndpts
    2938                 :             :    dtsets(idtset)%vdw_df_ngpts = vdw_defaults%ngpts
    2939                 :             :    dtsets(idtset)%vdw_df_nqpts = vdw_defaults%nqpts
    2940                 :             :    dtsets(idtset)%vdw_df_nrpts = vdw_defaults%nrpts
    2941                 :             :    dtsets(idtset)%vdw_df_nsmooth = vdw_defaults%nsmooth
    2942                 :             :    dtsets(idtset)%vdw_df_phisoft = vdw_defaults%phisoft
    2943                 :             :    dtsets(idtset)%vdw_df_qcut = vdw_defaults%qcut
    2944                 :             :    dtsets(idtset)%vdw_df_qratio = vdw_defaults%qratio
    2945                 :             :    dtsets(idtset)%vdw_df_rcut = vdw_defaults%rcut
    2946                 :             :    dtsets(idtset)%vdw_df_rsoft = vdw_defaults%rsoft
    2947                 :             :    dtsets(idtset)%vdw_df_tolerance = vdw_defaults%tolerance
    2948                 :             :    dtsets(idtset)%vdw_df_tweaks = vdw_defaults%tweaks
    2949                 :             :    dtsets(idtset)%vdw_df_zab = vdw_defaults%zab
    2950                 :             :    dtsets(idtset)%vdw_df_threshold = 1.0d-2
    2951                 :             : #endif
    2952         [ +  + ]:       33808 :    dtsets(idtset)%vdw_supercell(:) = 0
    2953                 :        8452 :    dtsets(idtset)%vdw_tol = tol10
    2954                 :        8452 :    dtsets(idtset)%vdw_tol_3bt = -1
    2955         [ +  + ]:      853652 :    dtsets(idtset)%vdw_typfrag(:) = 1
    2956                 :        8452 :    dtsets(idtset)%vdw_xc = 0
    2957                 :        8452 :    dtsets(idtset)%vis=100.0_dp
    2958         [ +  + ]:       25356 :    dtsets(idtset)%vprtrb(1:2)=zero
    2959                 :             : !  W
    2960   [ +  +  +  +  :        8622 :    dtsets(idtset)%wtatcon(:,:,:)=zero
                   +  + ]
    2961                 :        8452 :    dtsets(idtset)%wfmix=one
    2962                 :        8452 :    dtsets(idtset)%wfk_task=0
    2963         [ +  + ]:      219528 :    dtsets(idtset)%wtk=one
    2964                 :        8452 :    dtsets(idtset)%wvl_crmult  = 6._dp
    2965                 :        8452 :    dtsets(idtset)%wvl_frmult  = 10._dp
    2966                 :        8452 :    dtsets(idtset)%wvl_hgrid   = 0.5_dp
    2967         [ +  + ]:       25356 :    dtsets(idtset)%wvl_ngauss  =(/1,100/)
    2968                 :        8452 :    dtsets(idtset)%wvl_nprccg  = 10
    2969                 :        8452 :    dtsets(idtset)%w90iniprj   = 1
    2970                 :        8452 :    dtsets(idtset)%w90prtunk   = 0
    2971                 :        8452 :    dtsets(idtset)%write_files = "default"
    2972                 :             : !  X
    2973                 :        8452 :    dtsets(idtset)%xclevel  = 0
    2974                 :        8452 :    dtsets(idtset)%xg_nonlop_option  = 0
    2975                 :        8452 :    dtsets(idtset)%xc_denpos = tol14
    2976                 :        8452 :    dtsets(idtset)%xc_taupos = tol14
    2977                 :        8452 :    dtsets(idtset)%xc_tb09_c = 99.99_dp
    2978   [ +  +  +  + ]:        8548 :    dtsets(idtset)%xredsph_extra(:,:)=zero
    2979                 :             : !  Y
    2980                 :             : !  Z
    2981                 :        8452 :    dtsets(idtset)%zcut=3.67493260d-03  ! = 0.1eV
    2982         [ +  + ]:        8452 :    if(dtsets(idtset)%optdriver == RUNL_GWLS) dtsets(idtset)%zcut=zero
    2983                 :             :    !if(dtsets(idtset)%optdriver == RUNL_EPH) dtsets(idtset)%zcut = 0.01 * eV_Ha
    2984         [ +  + ]:       19070 :    dtsets(idtset)%ziontypat(:)=zero
    2985                 :             : 
    2986         [ +  + ]:       20500 :    dtsets(idtset)%bs_loband=0
    2987                 :             : 
    2988                 :             :    !dtsets(idtset)%eph_restart = 0
    2989                 :             :    !print *, dtsets(idtset)%optdriver
    2990                 :             :    !print *, dtsets(idtset)%eph_task
    2991                 :             :    !if (dtsets(idtset)%optdriver == RUNL_EPH) then
    2992                 :             :    !  if (any(dtsets(idtset)%eph_task == [13, -13])) then
    2993                 :             :    !    ! In VARPEQ, restart must be activated explicitly.
    2994                 :             :    !    dtsets(idtset)%eph_restart = 0
    2995                 :             :    !    stop "hello"
    2996                 :             :    !  end if
    2997                 :             :    !  !dtsets(idtset)%mixprec = 1
    2998                 :             :    !  !dtsets(idtset)%boxcutmin = 1.1_dp
    2999                 :             :    !end if
    3000                 :             :  end do
    3001                 :             :  !stop
    3002                 :             : 
    3003                 :             :  DBG_EXIT("COLL")
    3004                 :             : 
    3005                 :        1442 : end subroutine indefo
    3006                 :             : !!***
    3007                 :             : 
    3008                 :             : end module m_invars1
    3009                 :             : !!***
        

Generated by: LCOV version 2.3-1