LCOV - code coverage report
Current view: top level - src/78_effpot - m_multibinit_dataset.F90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 54.8 % 2081 1141
Test Date: 2026-09-19 17:42:43 Functions: 72.7 % 11 8

            Line data    Source code
       1              : !!****m* ABINIT/m_multibinit_dataset
       2              : !! NAME
       3              : !!  m_multibinit_dataset
       4              : !!
       5              : !! FUNCTION
       6              : !!  module with the type for the input of multibinit (should be clean)
       7              : !!
       8              : !! COPYRIGHT
       9              : !!  Copyright (C) 2014-2026 ABINIT group (AM)
      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_multibinit_dataset
      23              : 
      24              :  use defs_basis
      25              :  use m_abicore
      26              :  use m_errors
      27              : 
      28              :  use m_xmpi
      29              :  use m_parser, only : intagm, instrng
      30              :  use m_fstrings,   only : replace, inupper
      31              :  use m_dtset,      only : chkvars
      32              :  use m_ddb,    only : DDB_QTOL
      33              :  use m_scup_dataset
      34              : 
      35              :  implicit none
      36              : 
      37              :  private
      38              : 
      39              :  public :: multibinit_dtset_type
      40              :  public :: multibinit_dtset_init
      41              :  public :: multibinit_dtset_free
      42              :  public :: outvars_multibinit
      43              :  public :: invars_multibinit_filenames
      44              :  public :: invars_multibinit_filenames_from_input_file
      45              :  public :: invars10
      46              : !!***
      47              : 
      48              : !----------------------------------------------------------------------
      49              : 
      50              : !!****t* m_multibinit_dataset/multibinit_dtset_type
      51              : !! NAME
      52              : !! multibinit_dtset_type
      53              : !!
      54              : !! FUNCTION
      55              : !! The multibinit_dtset_type structured datatype
      56              : !! gather all the input variables for the multibinit code.
      57              : !!
      58              : !! SOURCE
      59              : 
      60              :  type multibinit_dtset_type
      61              : 
      62              : ! Integer
      63              :   integer :: asr
      64              :   integer :: analyze_anh_pot
      65              :   integer :: brav
      66              :   integer :: chneut
      67              :   integer :: confinement
      68              :   integer :: conf_power_disp
      69              :   integer :: conf_power_strain
      70              :   integer :: dipdip
      71              :   integer :: eivec
      72              :   integer :: elphflag
      73              :   integer :: enunit
      74              :   integer :: bound_model
      75              :   integer :: bound_maxCoeff
      76              :   integer :: bound_SPCoupling
      77              :   integer :: bound_AnhaStrain
      78              :   integer :: bound_step
      79              :   integer :: bound_option
      80              :   integer :: fit_anhaStrain
      81              :   integer :: fit_dispterms
      82              :   integer :: fit_SPCoupling
      83              :   integer :: fit_SPC_maxS
      84              :   integer :: fit_generateCoeff
      85              :   integer :: fit_iatom
      86              :   integer :: fit_initializeData
      87              :   integer :: fit_coeff
      88              :   integer :: fit_option
      89              :   integer :: fit_ncoeff
      90              :   integer :: fit_ncoeff_per_iatom
      91              :   integer :: fit_ncoeff_per_cycle
      92              :   integer :: fit_nbancoeff
      93              :   integer :: fit_nfixcoeff
      94              :   integer :: fit_nimposecoeff
      95              :   integer :: fit_EFS(3)
      96              :   integer :: sel_EFS(3)
      97              :   integer :: opt_EFS(3)
      98              :   integer :: bound_EFS(3)
      99              :   integer :: opt_effpot
     100              :   integer :: opt_ncoeff
     101              :   integer :: ts_option
     102              :   integer :: hmctt
     103              :   integer :: hmcsst
     104              :   integer :: ifcana
     105              :   integer :: ifcflag
     106              :   integer :: ifcout
     107              :   ! TODO hexu: why integer dtion?
     108              :   integer :: dtion
     109              :   integer :: dynamics
     110              :   integer :: dyn_chksym
     111              :   integer :: natifc
     112              :   integer :: natom
     113              :   integer :: ncoeff
     114              :   integer :: nctime
     115              :   integer :: nefield
     116              :   integer :: ntime
     117              :   integer :: nnos
     118              :   integer :: nph1l
     119              :   integer :: nph2l
     120              :   integer :: nqshft
     121              :   integer :: nsphere
     122              :   integer :: optcell
     123              :   integer :: prt_model
     124              :   integer :: dipdip_prt
     125              :   integer :: coeff_file_rw
     126              :   integer :: prt_phfrq
     127              :   integer :: prt_ifc
     128              :   integer :: randomseed
     129              :   integer :: strcpling  ! Print the 3rd order in xml file
     130              :   integer :: prtsrlr  ! print the short-range/long-range decomposition of phonon freq.
     131              :   integer :: rfmeth
     132              :   integer :: restartxf
     133              :   integer :: symdynmat
     134              :   integer :: sys_dim
     135              :   integer :: test_effpot
     136              :   integer :: test_prt_ph
     137              :   integer :: dipdip_range(3)
     138              :   integer :: fit_grid(3)
     139              :   integer :: fit_rangePower(2)
     140              :   integer :: bound_rangePower(2)
     141              :   integer :: bound_cell(3)
     142              :   integer :: ncell(3)
     143              :   integer :: ncellmat(3,3)
     144              :   integer :: ngqpt(9)             ! ngqpt(9) instead of ngqpt(3) is needed in wght9.f
     145              :   integer :: ng2qpt(3)
     146              :   integer :: kptrlatt(3,3)
     147              :   integer :: kptrlatt_fine(3,3)
     148              :   integer :: qrefine(3)
     149              :   logical :: prt_GF_csv
     150              : 
     151              :   ! parameter for lattice
     152              :   integer :: latt_var_temperature
     153              :   integer :: latt_temperature_nstep
     154              : 
     155              :   ! parameter for hybrid lattice_lwf
     156              :   integer :: latt_lwf_anharmonic
     157              : 
     158              : 
     159              :   ! parameters for lwf
     160              :   integer :: lwf_constraint
     161              :   integer :: lwf_dynamics
     162              :   integer :: lwf_init_state
     163              :   integer :: lwf_ntime
     164              :   integer :: lwf_nctime
     165              :   !integer :: lwf_self_bound_order
     166              :   integer :: lwf_temperature_nstep    ! var temperature number of steps
     167              :   integer :: lwf_var_temperature
     168              : 
     169              :   ! parameters for spin
     170              :  ! integer :: spin_calc_traj_obs
     171              :   integer :: spin_calc_thermo_obs
     172              :   !integer :: spin_calc_correlation_obs
     173              :   integer :: spin_dipdip
     174              :   integer :: spin_dynamics
     175              :   integer :: spin_init_state
     176              :   integer :: spin_nctime
     177              :   integer :: spin_ntime_pre
     178              :   integer :: spin_ntime
     179              : !  integer :: spin_nmatom !TODO hexu: is it needed?
     180              : !  integer :: spin_n1l
     181              : !  integer :: spin_n2l
     182              :   integer :: spin_sia_add
     183              :   integer :: spin_temperature_nstep    ! var temperature number of steps
     184              :   integer :: spin_var_temperature
     185              :   integer :: spin_write_traj
     186              :   integer :: efield_type
     187              : 
     188              :   ! parameters for spin-lattice coupling
     189              :   integer :: slc_coupling
     190              : 
     191              : ! Real(dp)
     192              : ! Inhomogeneous electric Field variables --Fernando Start
     193              :   real(dp) :: efield_period
     194              :   real(dp) :: efield_gmean(3)
     195              :   real(dp) :: efield_gvel(3)
     196              :   real(dp) :: efield_sigma
     197              :   real(dp) :: efield_background(3)
     198              : ! Inhomogeneous electric Field variables --Fernando End
     199              :   real(dp) :: bmass
     200              :   real(dp) :: conf_power_fact_disp
     201              :   real(dp) :: conf_power_fact_strain
     202              :   real(dp) :: delta_df
     203              :   real(dp) :: dyn_tolsym
     204              :   real(dp) :: energy_reference
     205              :   !real(dp) :: efield(3)
     206              :   real(dp) :: bound_cutoff
     207              :   real(dp) :: bound_Temp
     208              :   real(dp) :: fit_cutoff
     209              : !  real(dp):: fit_min_bound_coeff
     210              :   real(dp):: fit_drop_rate
     211              :   real(dp) :: fit_tolMSDF
     212              :   real(dp) :: fit_tolMSDS
     213              :   real(dp) :: fit_tolMSDE
     214              :   real(dp) :: fit_tolMSDFS
     215              :   real(dp) :: fit_tolGF
     216              :   real(dp) :: strprecon
     217              :   real(dp) :: strfact
     218              :   real(dp) :: temperature
     219              :   real(dp) :: rifcsph
     220              :   real(dp) :: conf
     221              :   real(dp) :: tolmxf
     222              :   real(dp) :: acell(3)
     223              :   real(dp) :: fit_factors(3)
     224              :   real(dp) :: fit_weight_T
     225              :   real(dp) :: opt_factors(3)
     226              :   real(dp) :: bound_factors(3)
     227              :   real(dp) :: bound_penalty
     228              :   real(dp) :: strten_reference(6)
     229              :   real(dp) :: strtarget(6)
     230              :   real(dp) :: conf_cutoff_strain(6)
     231              :   real(dp) :: rprim(3,3)
     232              : 
     233              :   ! lattice (new) related
     234              :   real(dp) :: latt_friction ! langevin dynamics friction
     235              :   real(dp) :: latt_taut     ! Berendsen taut
     236              :   !real(dp) :: latt_taup     !
     237              :   !real(dp) :: latt_compressibility
     238              :   !integer :: latt_mask(3)
     239              :   real(dp) :: latt_temperature_start
     240              :   real(dp) :: latt_temperature_end
     241              : 
     242              :   ! lwf related
     243              :   real(dp) :: lwf_dt
     244              :   real(dp) :: lwf_mc_avg_amp
     245              :   real(dp) :: lwf_taut
     246              :   real(dp) :: lwf_temperature
     247              :   !real(dp) :: lwf_self_bound_coeff
     248              :   real(dp) :: lwf_temperature_start   ! var temperature start
     249              :   real(dp) :: lwf_temperature_end     ! var temperature end
     250              : 
     251              :   !  parameters for spin
     252              :   real(dp) :: spin_dt
     253              :   real(dp) :: spin_damping
     254              :   real(dp) :: spin_sia_k1amp
     255              :   real(dp) :: spin_temperature
     256              :   ! TODO hexu: add spin convergence tol. (or remove it)
     257              :   real(dp) :: spin_temperature_start   ! var temperature start
     258              :   real(dp) :: spin_temperature_end     ! var temperature end
     259              :   !real(dp) :: spin_tolavg !average
     260              :   !real(dp) :: spin_tolvar !covariance
     261              : 
     262              :   real(dp) :: spin_mag_field(3)  ! external magnetic field
     263              :   real(dp) :: spin_projection_qpoint(3) ! qpoint to check if spin configuration is random
     264              :   real(dp) :: spin_sia_k1dir(3)
     265              :   real(dp) :: spin_init_qpoint(3) ! qpoint to specify initial spin configuration
     266              :   real(dp) :: spin_init_rotate_axis(3) ! rotation axis to specify initial spin configuration
     267              :   real(dp) :: spin_init_orientation(3) ! spin orientation in primitive cell which is then rotated
     268              : 
     269              : ! Integer arrays
     270              :   integer, allocatable :: atifc(:)
     271              :   ! atifc(natom)
     272              :   integer, allocatable :: fit_fixcoeff(:)
     273              :   ! fit_fixcoeffs(fit_nfixcoeff)
     274              :   integer, allocatable :: fit_imposecoeff(:)
     275              :   ! fit_fixcoeffs(fit_nimposecoeff)
     276              : 
     277              :   integer, allocatable :: fit_bancoeff(:)
     278              :   ! fit_bancoeffs(fit_nbancoeff)
     279              : 
     280              :   integer, allocatable :: iatfix(:,:)
     281              :   ! iatfix(3,natom) atom fix contraints for Broyden
     282              : 
     283              :   integer, allocatable :: fit_max_nbody_inrange(:)
     284              :   integer, allocatable :: fit_max_nbody(:)
     285              : 
     286              : 
     287              :   integer, allocatable :: opt_coeff(:)
     288              :   ! opt_coeff(opt_ncoeff)
     289              : 
     290              :   !integer, allocatable :: spin_sublattice(:) ! TODO hexu: difficult to use, better in xml?
     291              : 
     292              : ! Logical array
     293              :   logical :: fit_on(3)
     294              :   ! fit_on(1) == TRUE, fit on energy, fit_on(2,3)=TRUE fit on forces stresses, fit_on(1,2,3)=TRUE fit on EFS
     295              : 
     296              :   logical :: sel_on(3)
     297              :   ! sel_on(1) == TRUE, select on energy, sel_on(2,3)=TRUE select on forces stresses, sel_on(1,2,3)=TRUE select on EFS
     298              : 
     299              :   logical :: opt_on(3)
     300              :   ! opt_on(1) == TRUE, optimize on energy, sel_on(2,3)=TRUE optimize on forces stresses, opt_on(1,2,3)=TRUE optimize on EFS
     301              : 
     302              :   real(dp), allocatable :: qmass(:)
     303              :   ! qmass(nnos)
     304              : 
     305              : 
     306              : 
     307              : ! Real arrays
     308              :   real(dp), allocatable :: coefficients(:)
     309              :   ! coefficients(ncoeff)
     310              : 
     311              :   real(dp), allocatable :: conf_cutoff_disp(:)
     312              :   ! conf_cuttoff(natom)
     313              : 
     314              :   real(dp),allocatable  :: q1shft(:,:)
     315              :   !q1shft(3,nqshft)  SHIFT for Q point
     316              : 
     317              :   real(dp), allocatable :: qnrml1(:)
     318              :   ! qnrml1(nph1l)
     319              : 
     320              :   real(dp), allocatable :: qnrml2(:)
     321              :   ! qnrml1(nph1l)
     322              : 
     323              :   real(dp), allocatable :: qph1l(:,:)
     324              :   ! qph1l(3,nph1l)
     325              : 
     326              :   real(dp), allocatable :: qph2l(:,:)
     327              :   ! qph2l(3,nph2l)
     328              : 
     329              :   real(dp), allocatable :: efield(:, :)
     330              :   ! efield(3,nefield)
     331              : 
     332              :   real(dp), allocatable :: efield_lambda(:,:)
     333              :   ! efield_lambda(3,nefield)
     334              : 
     335              :   real(dp), allocatable :: efield_phase(:)
     336              :   ! efield_phase(nefield)
     337              : 
     338              : 
     339              : 
     340              :   !MS all variables for scale-up are put into their one type
     341              :   type(scup_dtset_type) :: scup_dtset
     342              : 
     343              :   ! spin part
     344              :   !real(dp), allocatable :: gilbert_damping ! if not provided in xml or override is needed.
     345              :   !real(dp), allocatable :: gyro_ratio(:) ! if not provided in xml
     346              : 
     347              :   !real(dp), allocatable :: qspin1l(:,:)
     348              :   !real(dp), allocatable :: qspin2l(:,:)
     349              : ! characters
     350              :   character(len=fnlen) :: latt_init_hist_fname
     351              :   character(len=fnlen) :: latt_pot_fname
     352              :   character(len=fnlen) :: latt_harm_pot_fname
     353              :   character(len=fnlen) :: latt_anharm_pot_fname
     354              :   character(len=fnlen) :: latt_training_set_fname
     355              :   character(len=fnlen) :: latt_test_set_fname
     356              :   character(len=fnlen) :: latt_ddb_fnames(12)
     357              : 
     358              :   character(len=fnlen) :: lwf_init_hist_fname
     359              :   character(len=fnlen) :: lwf_pot_fname
     360              : 
     361              :   character(len=fnlen) :: outdata_prefix
     362              : 
     363              :   character(len=fnlen) :: spin_pot_fname
     364              :   character(len=fnlen) :: spin_init_hist_fname
     365              : 
     366              :   character(len=fnlen) :: slc_pot_fname
     367              : 
     368              :  end type multibinit_dtset_type
     369              : !!***
     370              : 
     371              : contains
     372              : !!***
     373              : 
     374              : !!****f* m_multibinit_dataset/multibinit_dtset_init
     375              : !!
     376              : !! NAME
     377              : !! multibinit_dtset_init
     378              : !!
     379              : !! FUNCTION
     380              : !! Init the dtset datatype
     381              : !!
     382              : !! INPUTS
     383              : !! natom=number of atoms, needed for atifc
     384              : !!
     385              : !! OUTPUT
     386              : !! multibinit_dtset <type(multibinit_dtset_type)> = datatype with all the input variables
     387              : !!
     388              : !! NOTES
     389              : !! Should be executed by one processor only.
     390              : !!
     391              : !! SOURCE
     392              : 
     393            0 : subroutine multibinit_dtset_init(multibinit_dtset,natom)
     394              : 
     395              : !Arguments -------------------------------
     396              : !scalars
     397              :  integer,intent(in) :: natom
     398              :  type(multibinit_dtset_type),intent(inout) :: multibinit_dtset
     399              : !Local variables -------------------------
     400              : !scalars
     401              : !arrays
     402              : 
     403              : !*********************************************************************
     404              : 
     405              : !copy natom to multibinit_dtset
     406            0 :  multibinit_dtset%natom=natom
     407              : 
     408              : !=====================================================================
     409              : !Scalars
     410              : !=====================================================================
     411            0 :  multibinit_dtset%asr=2
     412            0 :  multibinit_dtset%analyze_anh_pot=0
     413            0 :  multibinit_dtset%brav=1
     414            0 :  multibinit_dtset%bmass=0
     415              : ! Inhomogeneous electric Field variables --Fernando Start
     416            0 :  multibinit_dtset%efield_period=1000000000000000.0
     417            0 :  multibinit_dtset%efield_gmean(:)=(/0.0,0.0,0.0/)
     418            0 :  multibinit_dtset%efield_gvel(:)=(/0.0,0.0,0.0/)
     419            0 :  multibinit_dtset%efield_type=0
     420            0 :  multibinit_dtset%efield_sigma=0.01
     421            0 :  multibinit_dtset%efield_background(:)= (/0.0,0.0,0.0/)
     422              : ! Inhomogeneous electric Field variables --Fernando End
     423            0 :  multibinit_dtset%chneut=0
     424            0 :  multibinit_dtset%confinement=0
     425            0 :  multibinit_dtset%conf_power_disp=0
     426            0 :  multibinit_dtset%conf_power_strain=0
     427            0 :  multibinit_dtset%conf_power_fact_disp=100
     428            0 :  multibinit_dtset%conf_power_fact_strain=100
     429            0 :  multibinit_dtset%delta_df= 1d-02
     430            0 :  multibinit_dtset%dipdip=1
     431            0 :  multibinit_dtset%dipdip_prt=0
     432            0 :  multibinit_dtset%dtion=100
     433            0 :  multibinit_dtset%dynamics=0
     434            0 :  multibinit_dtset%dyn_chksym=0
     435            0 :  multibinit_dtset%dyn_tolsym=1d-10
     436            0 :  multibinit_dtset%eivec=0
     437            0 :  multibinit_dtset%energy_reference= zero
     438            0 :  multibinit_dtset%enunit=0
     439            0 :  multibinit_dtset%fit_anhaStrain=0
     440            0 :  multibinit_dtset%bound_model=0
     441            0 :  multibinit_dtset%bound_penalty=1.001d+0
     442            0 :  multibinit_dtset%bound_anhaStrain=0
     443            0 :  multibinit_dtset%bound_cutoff=0
     444            0 :  multibinit_dtset%bound_maxCoeff=4
     445            0 :  multibinit_dtset%bound_temp=325
     446            0 :  multibinit_dtset%bound_step=1000
     447            0 :  multibinit_dtset%bound_SPCoupling=1
     448            0 :  multibinit_dtset%fit_coeff=0
     449              : ! multibinit_dtset%fit_min_bound_coeff=0.0_dp
     450            0 :  multibinit_dtset%fit_drop_rate=0.0_dp
     451            0 :  multibinit_dtset%fit_cutoff=0
     452            0 :  multibinit_dtset%fit_nbancoeff=0
     453            0 :  multibinit_dtset%fit_ncoeff=0
     454            0 :  multibinit_dtset%fit_ncoeff_per_iatom=0
     455            0 :  multibinit_dtset%fit_ncoeff_per_cycle=1
     456            0 :  multibinit_dtset%fit_weight_T=-0.1_dp
     457              : 
     458            0 :  multibinit_dtset%fit_iatom=0
     459            0 :  multibinit_dtset%ts_option=0
     460            0 :  multibinit_dtset%fit_nfixcoeff=0
     461            0 :  multibinit_dtset%fit_nimposecoeff=0
     462            0 :  multibinit_dtset%fit_EFS = (/ 0, 1, 1 /)
     463            0 :  multibinit_dtset%sel_EFS = (/ 0, 1, 1 /)
     464            0 :  multibinit_dtset%opt_EFS = (/ 0, 1, 1 /)
     465            0 :  multibinit_dtset%bound_EFS = (/ 0, 1, 1 /)
     466            0 :  multibinit_dtset%fit_option=0
     467            0 :  multibinit_dtset%fit_SPCoupling=1
     468            0 :  multibinit_dtset%fit_dispterms=1
     469            0 :  multibinit_dtset%fit_SPC_maxS=1
     470            0 :  multibinit_dtset%fit_generateCoeff=1
     471            0 :  multibinit_dtset%fit_initializeData=0
     472            0 :  multibinit_dtset%fit_tolMSDE=zero
     473            0 :  multibinit_dtset%fit_tolMSDS=zero
     474            0 :  multibinit_dtset%fit_tolMSDF=zero
     475            0 :  multibinit_dtset%fit_tolMSDFS=zero
     476            0 :  multibinit_dtset%fit_tolGF=zero
     477            0 :  multibinit_dtset%ifcana=0
     478            0 :  multibinit_dtset%ifcflag=1
     479            0 :  multibinit_dtset%ifcout=-1
     480            0 :  multibinit_dtset%hmctt=0
     481            0 :  multibinit_dtset%hmcsst=0
     482            0 :  multibinit_dtset%prtsrlr=0
     483              :  ! Langevin friction
     484            0 :  multibinit_dtset%latt_friction=1d-4
     485              :  ! Berendsen taut
     486            0 :  multibinit_dtset%latt_taut=1000.0
     487              :  !multibinit_dtset%latt_taup=1000.0
     488              :  !multibinit_dtset%latt_compressibility=0.0
     489              : 
     490              : 
     491            0 :  multibinit_dtset%nefield=1
     492            0 :  multibinit_dtset%ntime=200
     493            0 :  multibinit_dtset%nctime=1
     494            0 :  multibinit_dtset%natifc=natom
     495            0 :  multibinit_dtset%ncoeff=0
     496            0 :  multibinit_dtset%nph1l=1
     497            0 :  multibinit_dtset%nph2l=0
     498            0 :  multibinit_dtset%nqshft=1
     499            0 :  multibinit_dtset%nnos=0
     500            0 :  multibinit_dtset%nsphere=0
     501            0 :  multibinit_dtset%optcell=0
     502            0 :  multibinit_dtset%opt_effpot=0
     503              :  !multibinit_dtset%opt_coeff=0
     504            0 :  multibinit_dtset%prt_model=0
     505            0 :  multibinit_dtset%prt_phfrq=0
     506            0 :  multibinit_dtset%prt_ifc = 0
     507            0 :  multibinit_dtset%prt_GF_csv = .FALSE.
     508            0 :  multibinit_dtset%randomseed = 0
     509            0 :  multibinit_dtset%strcpling = -1
     510            0 :  multibinit_dtset%qrefine=1
     511            0 :  multibinit_dtset%restartxf=0
     512            0 :  multibinit_dtset%rfmeth=1
     513            0 :  multibinit_dtset%rifcsph=zero
     514            0 :  multibinit_dtset%strfact=100.0d0
     515            0 :  multibinit_dtset%strprecon=1.0d0
     516            0 :  multibinit_dtset%symdynmat=1
     517            0 :  multibinit_dtset%sys_dim=1
     518            0 :  multibinit_dtset%temperature=325
     519            0 :  multibinit_dtset%test_effpot=0
     520            0 :  multibinit_dtset%test_prt_ph=0
     521            0 :  multibinit_dtset%tolmxf=2.0d-5
     522            0 :  multibinit_dtset%latt_temperature_start=0.0
     523            0 :  multibinit_dtset%latt_temperature_end=0.0
     524            0 :  multibinit_dtset%latt_temperature_nstep=0
     525            0 :  multibinit_dtset%latt_var_temperature=0
     526              : 
     527            0 :  multibinit_dtset%latt_lwf_anharmonic = 0
     528              : 
     529            0 :  multibinit_dtset%lwf_constraint = 0
     530            0 :  multibinit_dtset%lwf_dynamics = 0
     531            0 :  multibinit_dtset%lwf_nctime = 1
     532            0 :  multibinit_dtset%lwf_ntime = 0
     533            0 :  multibinit_dtset%lwf_init_state = 0
     534            0 :  multibinit_dtset%lwf_init_hist_fname=""
     535              : 
     536            0 :  multibinit_dtset%latt_init_hist_fname=""
     537            0 :  multibinit_dtset%latt_pot_fname=""
     538            0 :  multibinit_dtset%latt_harm_pot_fname=""
     539            0 :  multibinit_dtset%latt_anharm_pot_fname=""
     540            0 :  multibinit_dtset%latt_training_set_fname=""
     541            0 :  multibinit_dtset%latt_test_set_fname=""
     542            0 :  multibinit_dtset%latt_ddb_fnames(12)=""
     543              : 
     544              : 
     545            0 :  multibinit_dtset%lwf_pot_fname=""
     546            0 :  multibinit_dtset%slc_pot_fname=""
     547            0 :  multibinit_dtset%lwf_dt=0
     548              :  !multibinit_dtset%lwf_self_bound_order=0
     549            0 :  multibinit_dtset%lwf_taut=0.0_dp
     550            0 :  multibinit_dtset%lwf_temperature=0.0_dp
     551            0 :  multibinit_dtset%lwf_mc_avg_amp=0.0_dp
     552              :  !multibinit_dtset%lwf_self_bound_coeff=0.0_dp
     553            0 :  multibinit_dtset%lwf_temperature_start=0.0
     554            0 :  multibinit_dtset%lwf_temperature_end= 0.0
     555            0 :  multibinit_dtset%lwf_temperature_nstep= 0
     556            0 :  multibinit_dtset%lwf_var_temperature=0
     557              : 
     558            0 :  multibinit_dtset%spin_init_hist_fname=""
     559            0 :  multibinit_dtset%spin_pot_fname=""
     560              : 
     561              :  !multibinit_dtset%spin_calc_traj_obs=0
     562            0 :  multibinit_dtset%spin_calc_thermo_obs=1
     563              :  !multibinit_dtset%spin_calc_correlation_obs=0
     564            0 :  multibinit_dtset%spin_dipdip=0
     565            0 :  multibinit_dtset%spin_dt=100
     566            0 :  multibinit_dtset%spin_dynamics=0
     567            0 :  multibinit_dtset%spin_init_hist_fname=""
     568            0 :  multibinit_dtset%spin_init_state=1
     569            0 :  multibinit_dtset%spin_ntime_pre=0
     570            0 :  multibinit_dtset%spin_ntime=10000
     571            0 :  multibinit_dtset%spin_nctime=100
     572              : !multibinit_dtset%spin_nmatom=0
     573              : !multibinit_dtset%spin_n1l=1
     574              : !multibinit_dtset%spin_n2l=0
     575              : 
     576              : 
     577            0 :  multibinit_dtset%spin_damping=-1.0
     578            0 :  multibinit_dtset%spin_sia_add=0
     579            0 :  multibinit_dtset%spin_sia_k1amp=zero
     580            0 : multibinit_dtset%spin_temperature=325
     581            0 : multibinit_dtset%spin_temperature_start=0.0
     582            0 : multibinit_dtset%spin_temperature_end= 0.0
     583            0 : multibinit_dtset%spin_temperature_nstep= 0
     584              : !multibinit_dtset%spin_tolavg=1d-2 ! TODO hexu: to be decided. should it be a function of temperature?
     585              : !multibinit_dtset%spin_tolvar=1d-3 ! TODO hexu: as above.
     586              : 
     587            0 : multibinit_dtset%spin_var_temperature=0
     588            0 : multibinit_dtset%spin_write_traj=1
     589              : 
     590            0 : multibinit_dtset%slc_pot_fname=""
     591            0 : multibinit_dtset%slc_coupling=0
     592              : 
     593            0 : multibinit_dtset%outdata_prefix=""
     594              : !=======================================================================
     595              : !Arrays
     596              : !=======================================================================
     597            0 :  multibinit_dtset%acell(:) = one
     598            0 :  multibinit_dtset%conf_cutoff_strain(1:6) = zero
     599            0 :  multibinit_dtset%dipdip_range(:)= (/0,0,0/)
     600              :  !multibinit_dtset%efield(:)= (/0,0,0/)
     601            0 :  multibinit_dtset%fit_grid(:)= 1
     602            0 :  multibinit_dtset%fit_rangePower(:)= (/3,4/)
     603            0 :  multibinit_dtset%bound_rangePower(:)= (/6,6/)
     604            0 :  multibinit_dtset%bound_cell(:)= (/6,6,6/)
     605            0 :  multibinit_dtset%ncell(:)= 0
     606            0 :  multibinit_dtset%ncellmat(:,:)= 0
     607            0 :  multibinit_dtset%ngqpt(:) = 0
     608            0 :  multibinit_dtset%ng2qpt(:)= 0
     609            0 :  multibinit_dtset%strtarget(1:6) = zero
     610            0 :  multibinit_dtset%qmass(:)= zero
     611            0 :  multibinit_dtset%rprim(:,:)= zero
     612            0 :  multibinit_dtset%strten_reference(:)= zero
     613              : 
     614            0 :  multibinit_dtset%spin_mag_field(:)=zero
     615            0 :  multibinit_dtset%spin_projection_qpoint(:)=zero
     616            0 :  multibinit_dtset%spin_init_qpoint(:)=zero
     617            0 :  multibinit_dtset%spin_init_rotate_axis(:)=(/1.0, 0.0, 0.0/)
     618            0 :  multibinit_dtset%spin_init_orientation(:)=(/0.0, 0.0, 1.0/)
     619              : 
     620              : 
     621            0 :  multibinit_dtset%spin_sia_k1dir(:)=(/0.0,0.0,1.0/)
     622              : 
     623              : 
     624            0 :  ABI_MALLOC(multibinit_dtset%atifc,(natom))
     625            0 :  multibinit_dtset%atifc(:)=0
     626            0 :  ABI_MALLOC(multibinit_dtset%conf_cutoff_disp,(multibinit_dtset%natom))
     627            0 :  multibinit_dtset%conf_cutoff_disp(:)=zero
     628            0 :  ABI_MALLOC(multibinit_dtset%q1shft,(3,multibinit_dtset%nqshft))
     629            0 :  multibinit_dtset%q1shft(:,:) = zero
     630            0 :  ABI_MALLOC(multibinit_dtset%iatfix,(3,natom))
     631              : 
     632              : ! multibinit_dtset%latt_mask(:) = 0
     633              : 
     634            0 : end subroutine multibinit_dtset_init
     635              : !!***
     636              : 
     637              : !!****f* m_multibinit_dataset/multibinit_dtset_free
     638              : !!
     639              : !! NAME
     640              : !!  multibinit_dtset_free
     641              : !!
     642              : !! FUNCTION
     643              : !!  deallocate remaining arrays in the multibinit_dtset datastructure
     644              : !!
     645              : !! INPUTS
     646              : !!  multibinit_dtset <type(multibinit_dtset_type)> = multibinit_dataset structure
     647              : !!
     648              : !! OUTPUTS
     649              : !!  multibinit_dtset <type(multibinit_dtset_type)> = multibinit_dataset structure
     650              : !!
     651              : !! SOURCE
     652              : 
     653           73 : subroutine multibinit_dtset_free(multibinit_dtset)
     654              : 
     655              : !Arguments ------------------------------------
     656              : !scalars
     657              :  type(multibinit_dtset_type), intent(inout) :: multibinit_dtset
     658              : 
     659              : ! *************************************************************************
     660              : 
     661           73 :  ABI_SFREE(multibinit_dtset%atifc)
     662           73 :  ABI_SFREE(multibinit_dtset%conf_cutoff_disp)
     663           73 :  ABI_SFREE(multibinit_dtset%fit_fixcoeff)
     664           73 :  ABI_SFREE(multibinit_dtset%fit_imposecoeff)
     665           73 :  ABI_SFREE(multibinit_dtset%fit_bancoeff)
     666           73 :  ABI_SFREE(multibinit_dtset%opt_coeff)
     667              : 
     668           73 :  ABI_SFREE(multibinit_dtset%fit_max_nbody)
     669           73 :  ABI_SFREE(multibinit_dtset%fit_max_nbody_inrange)
     670              : 
     671           73 :  ABI_SFREE(multibinit_dtset%qmass)
     672           73 :  ABI_SFREE(multibinit_dtset%coefficients)
     673           73 :  ABI_SFREE(multibinit_dtset%qnrml1)
     674           73 :  ABI_SFREE(multibinit_dtset%qnrml2)
     675           73 :  ABI_SFREE(multibinit_dtset%qph1l)
     676           73 :  ABI_SFREE(multibinit_dtset%qph2l)
     677              : 
     678           73 :  ABI_SFREE(multibinit_dtset%q1shft)
     679           73 :  ABI_SFREE(multibinit_dtset%iatfix)
     680              : 
     681           73 :  ABI_SFREE(multibinit_dtset%efield)
     682           73 :  ABI_SFREE(multibinit_dtset%efield_lambda)
     683           73 :  ABI_SFREE(multibinit_dtset%efield_phase)
     684              : 
     685              : 
     686              :  !ABI_SFREE(multibinit_dtset%gilbert_damping)
     687              :  !ABI_SFREE(multibinit_dtset%gyro_ratio)
     688              :  !ABI_SFREE(multibinit_dtset%qph1l_spin)
     689              :  !ABI_SFREE(multibinit_dtset%qph2l_spin)
     690              : 
     691              : !=====================================================================
     692              : !Free Scale-up dataset
     693              : !=====================================================================
     694              : 
     695           73 :  call scup_dtset_free(multibinit_dtset%scup_dtset)
     696              : 
     697           73 : end subroutine multibinit_dtset_free
     698              : !!***
     699              : 
     700              : !----------------------------------------------------------------------
     701              : !===============================================================
     702              : ! Parsing of input variables for Multibinit
     703              : ! read only the latt_inp_ddb_fname, and the outdata_prefix.
     704              : ! It contains the reference structure, so that the natom can be decided
     705              : !> @ fname: the name of the ddb file
     706              : !> @ string: the input file in string
     707              : !> @ lenstr: the length of string
     708              : !===============================================================
     709           73 : subroutine invars_multibinit_filenames( string, lenstr, outdata_prefix, sys_fname )
     710              :   character(len=fnlen), optional, intent(inout) :: outdata_prefix, sys_fname
     711              :   character(len=*), intent(inout) :: string
     712              :   integer, intent(in) :: lenstr
     713              :   integer :: jdtset,marr,tread
     714              :   !arrays
     715           73 :   integer,allocatable :: intarr(:)
     716           73 :   real(dp),allocatable :: dprarr(:)
     717           73 :   marr=300
     718           73 :   ABI_MALLOC(intarr,(marr))
     719           73 :   ABI_MALLOC(dprarr,(marr))
     720           73 :   jdtset=1
     721              : 
     722           73 :   if(present(outdata_prefix)) then
     723           73 :      outdata_prefix=""
     724              :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'outdata_prefix',tread,'KEY',&
     725           73 :           & key_value=outdata_prefix)
     726           73 :      if(.not. tread==1) outdata_prefix=""
     727              :   end if
     728              : 
     729           73 :   if(present(sys_fname)) then
     730           73 :      sys_fname=""
     731              :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_harm_pot_fname',tread,'KEY',&
     732           73 :           & key_value=sys_fname)
     733           73 :      if(.not. tread==1) then
     734              :        call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_pot_fname',tread,'KEY',&
     735            6 :           & key_value=sys_fname)
     736            6 :         if(.not. tread==1) then
     737            1 :         sys_fname=""
     738              :         end if
     739              :     end if
     740              :   end if
     741           73 :   ABI_SFREE(intarr)
     742           73 :   ABI_SFREE(dprarr)
     743           73 : end subroutine invars_multibinit_filenames
     744              : 
     745              : 
     746           73 : subroutine invars_multibinit_filenames_from_input_file(input_path, outdata_prefix, sys_fname)
     747              :   character(len=fnlen), optional, intent(inout) :: outdata_prefix, sys_fname, input_path
     748              :   character(len=strlen)  :: string, raw_string
     749              :   integer :: lenstr, option
     750              : 
     751              :   integer :: master, my_rank, comm, nproc, ierr
     752              :   logical :: iam_master
     753           73 :   master = 0
     754           73 :   comm = xmpi_world
     755           73 :   nproc = xmpi_comm_size(comm)
     756           73 :   my_rank = xmpi_comm_rank(comm)
     757           73 :   iam_master = (my_rank == master)
     758              : 
     759              : 
     760           73 :   option=1
     761           73 :   if (iam_master) then
     762           49 :      call instrng (input_path,lenstr,option,strlen,string, raw_string)
     763              :      !To make case-insensitive, map characters to upper case:
     764           49 :      call inupper(string(1:lenstr))
     765              :      !Check whether the string only contains valid keywords
     766           49 :      call chkvars(string)
     767              :   end if
     768           73 :   call xmpi_bcast(string, master, comm, ierr)
     769           73 :   call xmpi_bcast(raw_string, master, comm, ierr)
     770           73 :   call xmpi_bcast(lenstr, master, comm, ierr)
     771              : 
     772              :   ! Save input string in global variable so that we can access it in ntck_open_create
     773           73 :   ABI_MALLOC_TYPE_SCALAR(character(len=len_trim(string)), INPUT_STRING)
     774           73 :   INPUT_STRING = string(1:len_trim(string))
     775              : 
     776           73 :   call invars_multibinit_filenames( string=string, lenstr=lenstr, sys_fname=sys_fname, outdata_prefix=outdata_prefix)
     777           73 : end subroutine invars_multibinit_filenames_from_input_file
     778              : 
     779              : !!****f* m_multibinit_dataset/invars10
     780              : !!
     781              : !! NAME
     782              : !! invars10
     783              : !!
     784              : !! FUNCTION
     785              : !! Open input file for the multibinit code, then reads or echoes the input information.
     786              : !!
     787              : !! INPUTS
     788              : !! lenstr=actual length of string
     789              : !! natom=number of atoms, needed for atifc
     790              : !! string*(*)=string of characters containing all input variables and data
     791              : !!
     792              : !! OUTPUT
     793              : !! multibinit_dtset <type(multibinit_dtset_type)> = datatype with all the input variables
     794              : !!
     795              : !! NOTES
     796              : !! Should be executed by one processor only.
     797              : !!
     798              : !! SOURCE
     799              : 
     800           73 : subroutine invars10(multibinit_dtset,lenstr,natom,string)
     801              : 
     802              : !Arguments -------------------------------
     803              : !scalars
     804              :  integer,intent(in) :: lenstr,natom
     805              :  character(len=*),intent(in) :: string
     806              :  type(multibinit_dtset_type),intent(inout) :: multibinit_dtset
     807              : 
     808              : !Local variables -------------------------
     809              : !Dummy arguments for subroutine 'intagm' to parse input file
     810              : !Set routine version number here:
     811              : !scalars
     812              :  integer :: iatifc,ii,iph1,iph2,jdtset,jj,marr,tread,idir,natfix,iatom
     813              :  integer :: natom_sc
     814              :  character(len=500) :: message
     815              : !arrays
     816              :  integer,allocatable :: intarr(:)
     817           73 :  real(dp),allocatable :: dprarr(:),work(:)
     818              :  ! strings
     819              :  character(len=fnlen*12) :: lattddb_string
     820              :  integer :: sidx(13), cnt, i1, i2
     821              : 
     822           73 : real(dp), allocatable ::  dptmp(:)
     823              : 
     824              : !*********************************************************************
     825           73 :  marr=30
     826           73 :  ABI_MALLOC(intarr,(marr))
     827           73 :  ABI_MALLOC(dprarr,(marr))
     828              : 
     829           73 :  jdtset=1
     830              : 
     831              : !copy natom to multibinit_dtset
     832           73 :  multibinit_dtset%natom=natom
     833              : 
     834              : !=====================================================================
     835              : !start reading in dimensions and non-dependent variables
     836              : !=====================================================================
     837              : 
     838              : !A
     839           73 :  multibinit_dtset%asr=2
     840           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'asr',tread,'INT')
     841           73 :  if(tread==1) multibinit_dtset%asr=intarr(1)
     842           73 :  if(multibinit_dtset%asr<-2.or.multibinit_dtset%asr>6)then
     843              :    write(message, '(a,i8,a,a,a,a,a)' )&
     844            0 : &   'asr is',multibinit_dtset%asr,', but the only allowed values',ch10,&
     845            0 : &   'are 0, 1, 2, 3, 4, 5, 6, -1 or -2 .',ch10,&
     846            0 : &   'Action: correct asr in your input file.'
     847              : !  Note : negative values are allowed when the acoustic sum rule
     848              : !  is to be applied after the analysis of IFCs
     849              : !  3,4 are for rotational invariance (under development)
     850              : !  5 is for hermitian imposition of the ASR
     851            0 :    ABI_ERROR(message)
     852              :  end if
     853              : 
     854           73 :  multibinit_dtset%analyze_anh_pot=0
     855           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'analyze_anh_pot',tread,'INT')
     856           73 :  if(tread==1) multibinit_dtset%analyze_anh_pot=intarr(1)
     857           73 :  if(multibinit_dtset%analyze_anh_pot < 0 .or. multibinit_dtset%analyze_anh_pot > 1)then
     858              :    write(message, '(a,i8,a,a,a,a,a)' )&
     859            0 : &   'analyze_anh_pot is',multibinit_dtset%analyze_anh_pot,', but the only allowed values',ch10,&
     860            0 : &   'are 0 and 1 .',ch10,&
     861            0 : &   'Action: correct analyze_anh_pot in your input file.'
     862            0 :    ABI_ERROR(message)
     863              :  end if
     864              : 
     865              : !B
     866           73 :  multibinit_dtset%brav=1
     867           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'brav',tread,'INT')
     868           73 :  if(tread==1) multibinit_dtset%brav=intarr(1)
     869           73 :  if(multibinit_dtset%brav/=1)then
     870              :    write(message, '(a,i8,a,a,a,a,a)' )&
     871            0 : &   'brav is',multibinit_dtset%brav,', but the only allowed values',ch10,&
     872            0 : &   'are 1 for multibinit (not implemented) .',ch10,&
     873            0 : &   'Action: correct brav in your input file.'
     874            0 :    ABI_ERROR(message)
     875              :  end if
     876              : 
     877           73 :  multibinit_dtset%bmass=0
     878           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bmass',tread,'DPR')
     879           73 :  if(tread==1) multibinit_dtset%bmass=dprarr(1)
     880           73 :  if(multibinit_dtset%bmass<0)then
     881              :    write(message, '(a,f10.2,a,a,a,a,a)' )&
     882            0 : &   'bmass is',multibinit_dtset%bmass,', but the only allowed values',ch10,&
     883            0 : &   'is superior to 0.',ch10,&
     884            0 : &   'Action: correct bmass in your input file.'
     885            0 :    ABI_ERROR(message)
     886              :  end if
     887              : 
     888              : ! Inhomogeneous electric Field variables --Fernando Start
     889              : 
     890           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'efield_gmean',tread,'TIM')
     891           76 :  if(tread==1) multibinit_dtset%efield_gmean(1:3)= dprarr(1:3)
     892          292 :   do ii=1,3
     893          292 :    if(multibinit_dtset%efield_gmean(ii)<0)then
     894              :      write(message, '(a,i0,a,i0,4a,i0,a)' )&
     895            0 : &     'efield_gmean(',ii,') is ',multibinit_dtset%efield_gmean(ii),', which is lower',&
     896            0 : &     ' than 0',&
     897            0 : &     ch10,'Action: correct efield_gmean(',ii,') in your input file.'
     898            0 :      ABI_ERROR(message)
     899              :    end if
     900              :  end do
     901          292 :  multibinit_dtset%efield_gvel= (/0.0,0.0,0.0/)
     902           73 :  if(3>marr)then
     903            0 :    marr=3
     904            0 :    ABI_FREE(intarr)
     905            0 :    ABI_FREE(dprarr)
     906            0 :    ABI_MALLOC(intarr,(marr))
     907            0 :    ABI_MALLOC(dprarr,(marr))
     908              :  end if
     909              : 
     910           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'efield_gvel',tread,'TIM')
     911           76 :  if(tread==1) multibinit_dtset%efield_gvel(1:3)= dprarr(1:3)
     912          292 :   do ii=1,3
     913          292 :    if(multibinit_dtset%efield_gvel(ii)<0)then
     914              :      write(message, '(a,i0,a,i0,4a,i0,a)' )&
     915            0 : &     'efield_gvel(',ii,') is ',multibinit_dtset%efield_gvel(ii),', which is lower',&
     916            0 : &     ' than 0',&
     917            0 : &     ch10,'Action: correct efield_gvel(',ii,') in your input file.'
     918            0 :      ABI_ERROR(message)
     919              :    end if
     920              :  end do
     921              : 
     922           73 :  multibinit_dtset%efield_type=0
     923           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efield_type',tread,'INT')
     924           73 :  if(tread==1) multibinit_dtset%efield_type=intarr(1)
     925           73 :  if(multibinit_dtset%efield_type<0.or.multibinit_dtset%efield_type>6)then
     926              :    write(message, '(a,i8,a,a,a,a,a)' )&
     927            0 : &   'efield_type is',multibinit_dtset%efield_type,', but the only allowed values',ch10,&
     928            0 : &   'are 0, 1 or 2, 3, 4, 5 or 6  .',ch10,&
     929            0 : &   'Action: correct efield_type in your input file.'
     930            0 :    ABI_ERROR(message)
     931              :  end if
     932              : 
     933           73 : if (multibinit_dtset%efield_type/=6 .and. multibinit_dtset%efield_type/=0)then
     934            5 :   multibinit_dtset%nefield=1
     935           68 : else if (multibinit_dtset%efield_type==6)then
     936            1 :   multibinit_dtset%nefield=2
     937            1 :   call read_int_var( multibinit_dtset%nefield, 'nefield')
     938            1 :   if (multibinit_dtset%nefield/=2)then
     939              :      write(message, '(a,i0,a,a,a)' )&
     940            0 :      &  'nefield is',multibinit_dtset%nefield, &
     941            0 :      &  ', which can only be 2 for efield_type=6 .',ch10,&
     942            0 :      &  'Action: correct nefield in your input file.'
     943            0 :      ABI_ERROR(message)
     944              : end if
     945              : 
     946              : end if
     947              : ! read efield
     948              : call read_dpr_array_var(dptmp, size=multibinit_dtset%nefield*3, &
     949           73 : &                    var_name='efield', type='DPR', default=0.0_dp)
     950          219 : ABI_MALLOC(multibinit_dtset%efield, (3,multibinit_dtset%nefield))
     951          320 : multibinit_dtset%efield= reshape(dptmp, (/3,multibinit_dtset%nefield/))
     952           73 : ABI_FREE(dptmp)
     953              : 
     954              : 
     955              : ! read efield_phase
     956              : call read_dpr_array_var( multibinit_dtset%efield_phase,  &
     957           73 : &           size=multibinit_dtset%nefield, var_name='efield_phase', type='DPR', default=0.0_dp)
     958              : 
     959              : ! read efield_lambda
     960              : call read_dpr_array_var(dptmp,  size=multibinit_dtset%nefield*3, var_name='efield_lambda', &
     961           73 : &           type='DPR', default=0.0_dp)
     962          219 : ABI_MALLOC(multibinit_dtset%efield_lambda, (3,multibinit_dtset%nefield))
     963          320 : multibinit_dtset%efield_lambda= reshape(dptmp, (/3,multibinit_dtset%nefield/))
     964           73 : ABI_FREE(dptmp)
     965              : 
     966              : 
     967              : 
     968           73 :  multibinit_dtset%efield_period=1000000000000000.0
     969           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efield_period',tread,'TIM')
     970           73 :  if(tread==1) multibinit_dtset%efield_period=dprarr(1)
     971           73 :  if(multibinit_dtset%efield_period<0)then
     972              :    write(message, '(a,f10.2,a,a,a,a,a)' )&
     973            0 : &   'efield_period is',multibinit_dtset%efield_period,', but the only allowed values',ch10,&
     974            0 : &   'is superior to 0.',ch10,&
     975            0 : &   'Action: correct efield_period in your input file.'
     976            0 :    ABI_ERROR(message)
     977              :  end if
     978              : 
     979           73 :  multibinit_dtset%efield_sigma=0.01
     980           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'efield_sigma',tread,'TIM')
     981           73 :  if(tread==1) multibinit_dtset%efield_sigma=dprarr(1)
     982           73 :  if(multibinit_dtset%efield_period<0)then
     983              :    write(message, '(a,f10.2,a,a,a,a,a)' )&
     984            0 : &   'efield_sigma is',multibinit_dtset%efield_sigma,', but the only allowed values',ch10,&
     985            0 : &   'is superior to 0.',ch10,&
     986            0 : &   'Action: correct efield_sigma in your input file.'
     987            0 :    ABI_ERROR(message)
     988              :  end if
     989          292 :  multibinit_dtset%efield_background= zero
     990           73 :  if(3>marr)then
     991            0 :    marr=3
     992            0 :    ABI_FREE(intarr)
     993            0 :    ABI_FREE(dprarr)
     994            0 :    ABI_MALLOC(intarr,(marr))
     995            0 :    ABI_MALLOC(dprarr,(marr))
     996              :  end if
     997           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'efield_background',tread,'DPR')
     998           88 :  if(tread==1) multibinit_dtset%efield_background(1:3)= dprarr(1:3)
     999              : 
    1000              : ! Inhomogeneous electric Field variables --Fernando End
    1001              : 
    1002          292 :  multibinit_dtset%bound_EFS=(/0,1,1/)
    1003           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'bound_EFS',tread,'INT')
    1004           73 :  if(tread==1) multibinit_dtset%bound_EFS(1:3)=intarr(1:3)
    1005          584 :  if(any(multibinit_dtset%bound_EFS<0) .or. any(multibinit_dtset%bound_EFS>1))then
    1006              :    write(message, '(a,i8,a,a,a)' )&
    1007            0 : &   'bound_EFS is',multibinit_dtset%bound_EFS,', but the only allowed values are 0 and 1',ch10,&
    1008            0 : &   'Action: correct bound_EFS in your input file.'
    1009            0 :    ABI_ERROR(message)
    1010              :  end if
    1011              : 
    1012          292 :  multibinit_dtset%bound_factors=(/1,1,1/)
    1013           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'bound_factors',tread,'DPR')
    1014           76 :  if(tread==1) multibinit_dtset%bound_factors(1:3)=dprarr(1:3)
    1015          292 :  if(any(multibinit_dtset%bound_factors<0))then
    1016              :    write(message, '(a,i8,a,a,a)' )&
    1017            0 : &   'bound_factors is',multibinit_dtset%bound_factors,', but the only allowed values are positive',ch10,&
    1018            0 : &   'Action: correct bound_factors in your input file.'
    1019            0 :    ABI_ERROR(message)
    1020              :  end if
    1021              : 
    1022              : 
    1023              : !C
    1024           73 :  multibinit_dtset%chneut=0
    1025           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'chneut',tread,'INT')
    1026           73 :  if(tread==1) multibinit_dtset%chneut=intarr(1)
    1027           73 :  if(multibinit_dtset%chneut<0.or.multibinit_dtset%chneut>2)then
    1028              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1029            0 : &   'chneut is',multibinit_dtset%chneut,', but the only allowed values',ch10,&
    1030            0 : &   'are 0, 1 or 2 .',ch10,&
    1031            0 : &   'Action: correct chneut in your input file.'
    1032            0 :    ABI_ERROR(message)
    1033              :  end if
    1034              : 
    1035           73 :  multibinit_dtset%confinement=0
    1036           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'confinement',tread,'INT')
    1037           73 :  if(tread==1) multibinit_dtset%confinement=intarr(1)
    1038           73 :  if(multibinit_dtset%confinement<0.or.multibinit_dtset%confinement>2)then
    1039              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1040            0 : &   'confinement is',multibinit_dtset%confinement,', but the only allowed values',ch10,&
    1041            0 : &   'are 0, 1 or 2 .',ch10,&
    1042            0 : &   'Action: correct confinement in your input file.'
    1043            0 :    ABI_ERROR(message)
    1044              :  end if
    1045              : 
    1046           73 :  multibinit_dtset%conf_power_disp=0
    1047           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'conf_power_disp',tread,'INT')
    1048           73 :  if(tread==1) multibinit_dtset%conf_power_disp=intarr(1)
    1049           73 :  if(multibinit_dtset%conf_power_disp<0)then
    1050              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1051            0 : &   'conf_power_disp is',multibinit_dtset%conf_power_disp,', but the only allowed values',ch10,&
    1052            0 : &   'positive .',ch10,&
    1053            0 : &   'Action: correct conf_power_disp in your input file.'
    1054            0 :    ABI_ERROR(message)
    1055              :  end if
    1056              : 
    1057           73 :  multibinit_dtset%conf_power_strain=0
    1058           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'conf_power_strain',tread,'INT')
    1059           73 :  if(tread==1) multibinit_dtset%conf_power_strain=intarr(1)
    1060           73 :  if(multibinit_dtset%conf_power_strain<0)then
    1061              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1062            0 : &   'conf_power_strain is',multibinit_dtset%conf_power_strain,', but the only allowed values',ch10,&
    1063            0 : &   'are positive .',ch10,&
    1064            0 : &   'Action: correct conf_power_strain in your input file.'
    1065            0 :    ABI_ERROR(message)
    1066              :  end if
    1067              : 
    1068           73 :  multibinit_dtset%conf_power_fact_disp=100
    1069           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'conf_power_fact_disp',tread,'DPR')
    1070           73 :  if(tread==1) multibinit_dtset%conf_power_fact_disp=dprarr(1)
    1071              : 
    1072           73 :  multibinit_dtset%conf_power_fact_strain=100
    1073           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'conf_power_fact_strain',tread,'DPR')
    1074           73 :  if(tread==1) multibinit_dtset%conf_power_fact_strain=dprarr(1)
    1075              : 
    1076              : !D
    1077              : 
    1078           73 :  multibinit_dtset%dipdip=1
    1079           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dipdip',tread,'INT')
    1080           73 :  if(tread==1) multibinit_dtset%dipdip=intarr(1)
    1081              : ! if(multibinit_dtset%dipdip>1.or.multibinit_dtset%dipdip<0)then
    1082              : !   write(message, '(a,i8,a,a,a,a,a)' )&
    1083              : !&   'dipdip is',multibinit_dtset%dipdip,', but the only allowed values',ch10,&
    1084              : !&   'is 1.',ch10,&
    1085              : !&   'Action: correct dipdip in your input file.'
    1086              : !   ABI_ERROR(message)
    1087              : ! end if
    1088              : 
    1089              : 
    1090              : 
    1091           73 :  multibinit_dtset%dipdip_prt=0
    1092           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dipdip_prt',tread,'INT')
    1093           73 :  if(tread==1) multibinit_dtset%dipdip_prt=intarr(1)
    1094           73 :  if(multibinit_dtset%dipdip_prt<0.or.multibinit_dtset%dipdip_prt>1)then
    1095              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1096            0 : &   'dipdip_prt is',multibinit_dtset%prtsrlr,', but the only allowed values',ch10,&
    1097            0 :     'are 0 or 1.',ch10,&
    1098            0 : &   'Action: correct dipdip_prt in your input file.'
    1099            0 :    ABI_ERROR(message)
    1100              :  end if
    1101              : 
    1102           73 :   multibinit_dtset%coeff_file_rw=0
    1103              : ! call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'coeff_file_rw',tread,'INT')
    1104              : ! if(tread==1) multibinit_dtset%coeff_file_rw=intarr(1)
    1105              : ! if(multibinit_dtset%coeff_file_rw<0.or.multibinit_dtset%coeff_file_rw>2)then
    1106              : !   write(message, '(a,i8,a,a,a,a,a)' )&
    1107              : !&   'coeff_file_rw is',multibinit_dtset%prtsrlr,', but the only allowed values',ch10,&
    1108              : !    'are 0 or 1 2.',ch10,&
    1109              : !&   'Action: correct coeff_file_rw in your input file.'
    1110              : !   ABI_ERROR(message)
    1111              : ! end if
    1112              : 
    1113           73 :  multibinit_dtset%dtion=100
    1114           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dtion',tread,'INT')
    1115           73 :  if(tread==1) multibinit_dtset%dtion=intarr(1)
    1116           73 :  if(multibinit_dtset%dtion<1)then
    1117              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1118            0 : &   'dtion is',multibinit_dtset%dtion,', but the only allowed values',ch10,&
    1119            0 : &   'is superior to 1.',ch10,&
    1120            0 : &   'Action: correct dtion in your input file.'
    1121            0 :    ABI_ERROR(message)
    1122              :  end if
    1123              : 
    1124              : 
    1125           73 :  multibinit_dtset%delta_df= 1d-02
    1126           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'delta_df',tread,'DPR')
    1127           73 :  if(tread==1) multibinit_dtset%delta_df=dprarr(1)
    1128           73 :  if(multibinit_dtset%delta_df<0)then
    1129              :    write(message, '(a,es10.2,a,a,a,a,a)' )&
    1130            0 : &   'delta_df is',multibinit_dtset%delta_df,', but the only allowed values',ch10,&
    1131            0 : &   'are superior to 0  .',ch10,&
    1132            0 : &   'Action: correct delta_df in your input file.'
    1133            0 :    ABI_ERROR(message)
    1134              :  end if
    1135              : 
    1136              : !E
    1137           73 :  multibinit_dtset%energy_reference= zero
    1138           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'energy_reference',tread,'DPR')
    1139           73 :  if(tread==1) multibinit_dtset%energy_reference=dprarr(1)
    1140              : 
    1141           73 :  multibinit_dtset%enunit=0
    1142           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'enunit',tread,'INT')
    1143           73 :  if(tread==1) multibinit_dtset%enunit=intarr(1)
    1144           73 :  if(multibinit_dtset%enunit<0.or.multibinit_dtset%enunit>2)then
    1145              :    write(message, '(a,i0,a,a,a,a,a)' )&
    1146            0 : &   'enunit is',multibinit_dtset%enunit,', but the only allowed values',ch10,&
    1147            0 : &   'are 0, 1 or 2.',ch10,&
    1148            0 : &   'Action: correct enunit in your input file.'
    1149            0 :    ABI_ERROR(message)
    1150              :  end if
    1151              : 
    1152              : !F
    1153           73 :  multibinit_dtset%fit_option=0
    1154           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_option',tread,'INT')
    1155           73 :  if(tread==1) multibinit_dtset%fit_option=intarr(1)
    1156           73 :  if(multibinit_dtset%fit_option<0.or.multibinit_dtset%fit_option>2)then
    1157              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1158            0 : &   'fit_option is',multibinit_dtset%fit_option,', but the only allowed values',ch10,&
    1159            0 : &   'are 0, 1 or 2 for multibinit.',ch10,&
    1160            0 : &   'Action: correct fit_option in your input file.'
    1161            0 :    ABI_ERROR(message)
    1162              :  end if
    1163              : 
    1164           73 :  multibinit_dtset%fit_iatom=0
    1165           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_iatom',tread,'INT')
    1166           73 :  if(tread==1) multibinit_dtset%fit_iatom=intarr(1)
    1167           73 :  if(multibinit_dtset%fit_iatom<-2)then
    1168              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1169            0 : &   'fit_iatom is',multibinit_dtset%fit_iatom,', but the only allowed values',ch10,&
    1170            0 : &   'are larger than -1 for multibinit.',ch10,&
    1171            0 : &   'Action: correct fit_iatom in your input file.'
    1172            0 :    ABI_ERROR(message)
    1173              :  end if
    1174              : 
    1175           73 :  multibinit_dtset%fit_ncoeff=0
    1176           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_ncoeff',tread,'INT')
    1177           73 :  if(tread==1) multibinit_dtset%fit_ncoeff=intarr(1)
    1178           73 :  if(multibinit_dtset%fit_ncoeff<0)then
    1179              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1180            0 : &   'fit_ncoeff is',multibinit_dtset%fit_ncoeff,', but the only allowed values',ch10,&
    1181            0 : &   'are positives for multibinit.',ch10,&
    1182            0 : &   'Action: correct fit_ncoeff in your input file.'
    1183            0 :    ABI_ERROR(message)
    1184              :  end if
    1185              : 
    1186           73 :  multibinit_dtset%fit_ncoeff_per_cycle=1
    1187              :  !call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_ncoeff_per_cycle',tread,'INT')
    1188              :  !if(tread==1) multibinit_dtset%fit_ncoeff_per_cycle=intarr(1)
    1189              :  !if(multibinit_dtset%fit_ncoeff_per_cycle<0)then
    1190              :  !  write(message, '(a,i8,a,a,a,a,a)' )&
    1191              :  !    &   'fit_ncoeff_per_cycle is',multibinit_dtset%fit_ncoeff_per_cycle,', but the only allowed values',ch10,&
    1192              :  !    &   'are positives for multibinit.',ch10,&
    1193              :  !    &   'Action: correct fit_ncoeff_per_cycle in your input file.'
    1194              :  !  ABI_ERROR(message)
    1195              :  !end if
    1196              : 
    1197           73 :  multibinit_dtset%fit_ncoeff_per_iatom=0
    1198           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_ncoeff_per_iatom',tread,'INT')
    1199           73 :  if(tread==1) multibinit_dtset%fit_ncoeff_per_iatom=intarr(1)
    1200           73 :  if(multibinit_dtset%fit_ncoeff_per_iatom<0)then
    1201              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1202            0 : &   'fit_ncoeff_per_iatom is',multibinit_dtset%fit_ncoeff_per_iatom,', but the only allowed values',ch10,&
    1203            0 : &   'are positives for multibinit.',ch10,&
    1204            0 : &   'Action: correct fit_ncoeff_per_iatom in your input file.'
    1205            0 :    ABI_ERROR(message)
    1206              :  end if
    1207              : 
    1208              : 
    1209           73 :  multibinit_dtset%fit_nbancoeff=0
    1210           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_nbancoeff',tread,'INT')
    1211           73 :  if(tread==1) multibinit_dtset%fit_nbancoeff=intarr(1)
    1212           73 :  if(multibinit_dtset%fit_nbancoeff<0)then
    1213              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1214            0 : &   'fit_nbancoeff is',multibinit_dtset%fit_nbancoeff,', but the only allowed values',ch10,&
    1215            0 : &   'are 0 or positive values for multibinit.',ch10,&
    1216            0 : &   'Action: correct fit_nbancoeff in your input file.'
    1217            0 :    ABI_ERROR(message)
    1218              :  end if
    1219              : 
    1220           73 :  multibinit_dtset%fit_nfixcoeff=0
    1221           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_nfixcoeff',tread,'INT')
    1222           73 :  if(tread==1) multibinit_dtset%fit_nfixcoeff=intarr(1)
    1223           73 :  if(multibinit_dtset%fit_nfixcoeff<-2)then
    1224              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1225            0 : &   'fit_nfixcoeff is',multibinit_dtset%fit_nfixcoeff,', but the only allowed values',ch10,&
    1226            0 : &   'are -1 or positives for multibinit.',ch10,&
    1227            0 : &   'Action: correct fit_nfixcoeff in your input file.'
    1228            0 :    ABI_ERROR(message)
    1229              :  end if
    1230              : 
    1231           73 :  multibinit_dtset%fit_nimposecoeff=0
    1232           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_nimposecoeff',tread,'INT')
    1233           73 :  if(tread==1) multibinit_dtset%fit_nimposecoeff=intarr(1)
    1234           73 :  if(multibinit_dtset%fit_nimposecoeff<-2)then
    1235              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1236            0 : &   'fit_nimposecoeff is',multibinit_dtset%fit_nimposecoeff,', but the only allowed values',ch10,&
    1237            0 : &   'are -1 or positives for multibinit.',ch10,&
    1238            0 : &   'Action: correct fit_nimposecoeff in your input file.'
    1239            0 :    ABI_ERROR(message)
    1240              :  end if
    1241              : 
    1242          292 :  multibinit_dtset%fit_EFS=(/0,1,1/)
    1243          292 :  multibinit_dtset%fit_on = (/ .TRUE.,.TRUE.,.FALSE. /)
    1244           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'fit_EFS',tread,'INT')
    1245           79 :  if(tread==1) multibinit_dtset%fit_EFS(1:3)=intarr(1:3)
    1246           73 :  if(multibinit_dtset%fit_EFS(1) == 1)multibinit_dtset%fit_on(3) = .TRUE.
    1247           73 :  if(multibinit_dtset%fit_EFS(2) == 0)multibinit_dtset%fit_on(1) = .FALSE.
    1248           73 :  if(multibinit_dtset%fit_EFS(3) == 0)multibinit_dtset%fit_on(2) = .FALSE.
    1249          584 :  if(any(multibinit_dtset%fit_EFS<0) .or. any(multibinit_dtset%fit_EFS>1))then
    1250              :    write(message, '(a,i8,a,a,a)' )&
    1251            0 : &   'fit_EFS is',multibinit_dtset%fit_EFS,', but the only allowed values are 0 and 1',ch10,&
    1252            0 : &   'Action: correct fit_EFS in your input file.'
    1253            0 :    ABI_ERROR(message)
    1254              :  end if
    1255              : 
    1256          292 :  multibinit_dtset%fit_factors=(/1,1,1/)
    1257           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'fit_factors',tread,'DPR')
    1258           76 :  if(tread==1) multibinit_dtset%fit_factors(1:3)=dprarr(1:3)
    1259          292 :  if(any(multibinit_dtset%fit_factors<0))then
    1260              :    write(message, '(a,i8,a,a,a)' )&
    1261            0 : &   'fit_factors is',multibinit_dtset%fit_factors,', but the only allowed values are positive',ch10,&
    1262            0 : &   'Action: correct fit_factors in your input file.'
    1263            0 :    ABI_ERROR(message)
    1264              :  end if
    1265          292 :  multibinit_dtset%sel_EFS=(/0,1,1/)
    1266          292 :  multibinit_dtset%sel_on = (/ .TRUE.,.TRUE.,.FALSE. /)
    1267           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'sel_EFS',tread,'INT')
    1268           79 :  if(tread==1) multibinit_dtset%sel_EFS(1:3)=intarr(1:3)
    1269           73 :  if(multibinit_dtset%sel_EFS(1) == 1)multibinit_dtset%sel_on(3) = .TRUE.
    1270           73 :  if(multibinit_dtset%sel_EFS(2) == 0)multibinit_dtset%sel_on(1) = .FALSE.
    1271           73 :  if(multibinit_dtset%sel_EFS(3) == 0)multibinit_dtset%sel_on(2) = .FALSE.
    1272          584 :  if(any(multibinit_dtset%sel_EFS<0) .or. any(multibinit_dtset%sel_EFS>1))then
    1273              :    write(message, '(a,i8,a,a,a)' )&
    1274            0 : &   'sel_EFS is',multibinit_dtset%sel_EFS,', but the only allowed values are 0 and 1',ch10,&
    1275            0 : &   'Action: correct sel_EFS in your input file.'
    1276            0 :    ABI_ERROR(message)
    1277              :  end if
    1278              : 
    1279           73 :  multibinit_dtset%ts_option=0
    1280           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ts_option',tread,'INT')
    1281           73 :  if(tread==1) multibinit_dtset%ts_option=intarr(1)
    1282           73 :  if(multibinit_dtset%ts_option<0.or.multibinit_dtset%ts_option>1)then
    1283              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1284            0 : &   'ts_option is',multibinit_dtset%ts_option,', but the only allowed values',ch10,&
    1285            0 : &   'are zero and one for multibinit.',ch10,&
    1286            0 : &   'Action: correct ts_option in your input file.'
    1287            0 :    ABI_ERROR(message)
    1288              :  end if
    1289              : 
    1290           73 :  multibinit_dtset%ifcana=0
    1291           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ifcana',tread,'INT')
    1292           73 :  if(tread==1) multibinit_dtset%ifcana=intarr(1)
    1293           73 :  if(multibinit_dtset%ifcana<0.or.multibinit_dtset%ifcana>1)then
    1294              :    write(message, '(a,i0,a,a,a,a,a)' )&
    1295            0 : &   'ifcana is',multibinit_dtset%ifcana,', but the only allowed values',ch10,&
    1296            0 : &   'are 0 or 1.',ch10,&
    1297            0 : &   'Action: correct ifcana in your input file.'
    1298            0 :    ABI_ERROR(message)
    1299              :  end if
    1300              : 
    1301           73 :  multibinit_dtset%ifcflag=1
    1302           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ifcflag',tread,'INT')
    1303           73 :  if(tread==1) multibinit_dtset%ifcflag=intarr(1)
    1304           73 :  if(multibinit_dtset%ifcflag<0.or.multibinit_dtset%ifcflag>1)then
    1305              :    write(message, '(a,i0,a,a,a,a,a)' )&
    1306            0 : &   'ifcflag is',multibinit_dtset%ifcflag,', but the only allowed values',ch10,&
    1307            0 : &   'are 0 or 1.',ch10,&
    1308            0 : &   'Action: correct ifcflag in your input file.'
    1309            0 :    ABI_ERROR(message)
    1310              :  end if
    1311              : 
    1312           73 :  multibinit_dtset%prtsrlr=0
    1313           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtsrlr',tread,'INT')
    1314           73 :  if(tread==1) multibinit_dtset%prtsrlr=intarr(1)
    1315           73 :  if(multibinit_dtset%prtsrlr<0.or.multibinit_dtset%prtsrlr>1)then
    1316              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1317            0 : &   'prtsrlr is',multibinit_dtset%prtsrlr,', but the only allowed values',ch10,&
    1318            0 : &   'are 0 or 1.',ch10,&
    1319            0 : &   'Action: correct prtsrlr in your input file.'
    1320            0 :    ABI_ERROR(message)
    1321              :  end if
    1322              : 
    1323           73 :  multibinit_dtset%ifcout=2000000 ! or -1 -> max number of ifc
    1324           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ifcout',tread,'INT')
    1325           73 :  if(tread==1) multibinit_dtset%ifcout=intarr(1)
    1326           73 :  if(multibinit_dtset%ifcout<-1)then
    1327              :    write(message, '(a,i0,a,a,a)' )&
    1328            0 : &   'ifcout is',multibinit_dtset%ifcout,', which is lower than -1 (default = all ifc) .',ch10,&
    1329            0 : &   'Action: correct ifcout in your input file.'
    1330            0 :    ABI_ERROR(message)
    1331              :  end if
    1332           73 :  multibinit_dtset%hmctt=0 ! or -1 -> max number of ifc
    1333           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'hmctt',tread,'INT')
    1334           73 :  if(tread==1) multibinit_dtset%hmctt=intarr(1)
    1335           73 :  if(multibinit_dtset%hmctt< 0)then
    1336              :    write(message, '(a,i0,a,a,a)' )&
    1337            0 : &   'hmctt is',multibinit_dtset%hmctt,', but only positive values are allowed .',ch10,&
    1338            0 : &   'Action: correct hmctt in your input file.'
    1339            0 :    ABI_ERROR(message)
    1340              :  end if
    1341              : 
    1342           73 :  multibinit_dtset%hmcsst=0 ! or -1 -> max number of ifc
    1343           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'hmcsst',tread,'INT')
    1344           73 :  if(tread==1) multibinit_dtset%hmcsst=intarr(1)
    1345           73 :  if(multibinit_dtset%hmcsst<0)then
    1346              :    write(message, '(a,i0,a,a,a)' )&
    1347            0 : &   'hmcsst is',multibinit_dtset%hmcsst,', but only positive values are allowed .',ch10,&
    1348            0 : &   'Action: correct hmcsst in your input file.'
    1349            0 :    ABI_ERROR(message)
    1350              :  end if
    1351              : 
    1352           73 :  multibinit_dtset%nctime=1
    1353           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nctime',tread,'INT')
    1354           73 :  if(tread==1) multibinit_dtset%nctime=intarr(1)
    1355           73 :  if(multibinit_dtset%nctime<=0)then
    1356              :    write(message, '(a,i0,a,a,a)' )&
    1357            0 : &   'nctime is',multibinit_dtset%ntime,', which is not positive .',ch10,&
    1358            0 : &   'Action: correct nctime in your input file.'
    1359            0 :    ABI_ERROR(message)
    1360              :  end if
    1361              : 
    1362              : 
    1363              : 
    1364           73 :  multibinit_dtset%ntime=200
    1365           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ntime',tread,'INT')
    1366           73 :  if(tread==1) multibinit_dtset%ntime=intarr(1)
    1367           73 :  if(multibinit_dtset%ntime<0)then
    1368              :    write(message, '(a,i0,a,a,a)' )&
    1369            0 : &   'ntime is',multibinit_dtset%ntime,', which is lower than 0 .',ch10,&
    1370            0 : &   'Action: correct ntime in your input file.'
    1371            0 :    ABI_ERROR(message)
    1372              :  end if
    1373              : 
    1374           73 :  multibinit_dtset%dynamics=0
    1375           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dynamics',tread,'INT')
    1376           73 :  if(tread==1) multibinit_dtset%dynamics=intarr(1)
    1377              :  ! >100: the builtin multibinit lattice movers
    1378              :  if(multibinit_dtset%dynamics/=0.and.multibinit_dtset%dynamics/=6.and.&
    1379              :       &   multibinit_dtset%dynamics/=12.and.multibinit_dtset%dynamics/=13.and.&
    1380              :       &   multibinit_dtset%dynamics/=27.and.&
    1381              :       &   multibinit_dtset%dynamics/=9.and.&
    1382              :       &   multibinit_dtset%dynamics/=7.and.&
    1383              :       &   multibinit_dtset%dynamics/=1.and.&
    1384              :       &   multibinit_dtset%dynamics/=2.and.&
    1385              :       &   multibinit_dtset%dynamics/=22.and.&
    1386              :       &   multibinit_dtset%dynamics/=24.and.multibinit_dtset%dynamics/=25 .and. &
    1387              :       &   multibinit_dtset%dynamics/=101.and.multibinit_dtset%dynamics/=102 .and. &
    1388           73 :       &   multibinit_dtset%dynamics/=103.and.multibinit_dtset%dynamics/=120    &
    1389              :     ) then
    1390              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1391            0 : &   'dynamics is ',multibinit_dtset%dynamics,', but the only allowed values',ch10,&
    1392            0 : &   'are 1,2,6,7,9,12,13, 22,24,25,101,102, 103 or 120 (see ionmov in abinit documentation).',ch10,&
    1393            0 : &   'Action: correct dynamics in your input file.'
    1394            0 :    ABI_ERROR(message)
    1395              :  end if
    1396              : 
    1397           73 :  if(multibinit_dtset%dynamics==120) then
    1398              :     write(message, '(a,i8,a)' )&
    1399            0 :          &   'dynamics is ',multibinit_dtset%dynamics,'The atoms will not move. For test only!'
    1400            0 :     ABI_WARNING(message)
    1401              :  end if
    1402              : 
    1403           73 :  multibinit_dtset%dyn_chksym=0
    1404           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dyn_chksym',tread,'INT')
    1405           73 :  if(tread==1) multibinit_dtset%dyn_chksym=intarr(1)
    1406           73 :  if(multibinit_dtset%dyn_chksym<0 .or. multibinit_dtset%dyn_chksym>1)then
    1407              :    write(message, '(a,i0,a,a,a)' )&
    1408            0 : &   'dyn_chksym is',multibinit_dtset%dyn_chksym,', but the only allowed values are 0 and 1.',ch10,&
    1409            0 : &   'Action: correct dyn_chksym in your input file.'
    1410            0 :    ABI_ERROR(message)
    1411              :  end if
    1412              : 
    1413           73 :  multibinit_dtset%dyn_tolsym=1d-10
    1414           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'dyn_tolsym',tread,'DPR')
    1415           73 :  if(tread==1) multibinit_dtset%dyn_tolsym=dprarr(1)
    1416           73 :  if(multibinit_dtset%dyn_tolsym<0)then
    1417              :    write(message, '(a,i0,a,a,a)' )&
    1418            0 : &   'dyn_tolsym is',multibinit_dtset%dyn_tolsym,', but the only allowed values are positive.',ch10,&
    1419            0 : &   'Action: correct dyn_tolsym in your input file.'
    1420            0 :    ABI_ERROR(message)
    1421              :  end if
    1422              : !L
    1423              : ! multibinit_dtset%latt_compressibility=0.0
    1424              : ! call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_compressibility',tread,'DPR')
    1425              : ! if(tread==1) multibinit_dtset%latt_compressibility=dprarr(1)
    1426              : 
    1427           73 :  multibinit_dtset%latt_friction=1e-4
    1428           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_friction',tread,'DPR')
    1429           73 :  if(tread==1) multibinit_dtset%latt_friction=dprarr(1)
    1430           73 :  multibinit_dtset%latt_lwf_anharmonic=0
    1431           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_lwf_anharmonic',tread,'INT')
    1432           73 :  if(tread==1) multibinit_dtset%latt_lwf_anharmonic=intarr(1)
    1433           73 :  if( .not. (0 <= multibinit_dtset%latt_lwf_anharmonic .and. multibinit_dtset%latt_lwf_anharmonic< 2) ) then
    1434              :     write(message, '(a,i8,a,a,a,a,a)' )&
    1435            0 :          &   'latt_lwf_anharmonic is ',multibinit_dtset%latt_lwf_anharmonic,', but the only allowed values',ch10,&
    1436            0 :          &   'are 0 and 1',ch10,&
    1437            0 :          &   'Action: correct latt_lwf_anharmonic in your input file.'
    1438            0 :     ABI_ERROR(message)
    1439              :  end if
    1440              : 
    1441           73 :  multibinit_dtset%latt_taut=0.0
    1442           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_taut',tread,'TIM')
    1443           73 :  if(tread==1) multibinit_dtset%latt_taut=dprarr(1)
    1444           73 :  if(multibinit_dtset%latt_taut<0)then
    1445              :     write(message, '(a,f10.1,a,a,a,a,a)' )&
    1446            0 :          &   'latt_taut is ',multibinit_dtset%latt_taut,'. The only allowed values',ch10,&
    1447            0 :          &   'are non-negative values.',ch10,&
    1448            0 :          &   'Action: correct latt_taut in your input file.'
    1449            0 :     ABI_ERROR(message)
    1450              :  end if
    1451              : 
    1452              : 
    1453              : 
    1454              : 
    1455           73 : multibinit_dtset%latt_temperature_start=0.0
    1456           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_temperature_start',tread,'DPR')
    1457           73 :  if(tread==1) multibinit_dtset%latt_temperature_start=dprarr(1)
    1458           73 :  if(multibinit_dtset%latt_temperature_start<0.0)then
    1459              :     write(message, '(a,f10.1,a,a,a,a,a)' )&
    1460            0 :          &   'latt_temperature_start is ',multibinit_dtset%latt_temperature_start,'. The only allowed values',ch10,&
    1461            0 :          &   'are positives values.',ch10,&
    1462            0 :          &   'Action: correct latt_semperature_start in your input file.'
    1463            0 :     ABI_ERROR(message)
    1464              :  end if
    1465              : 
    1466           73 :  multibinit_dtset%latt_temperature_end=0.0
    1467           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_temperature_end',tread,'DPR')
    1468           73 :  if(tread==1) multibinit_dtset%latt_temperature_end=dprarr(1)
    1469           73 :  if(multibinit_dtset%latt_temperature_end<0)then
    1470              :     write(message, '(a,f10.1,a,a,a,a,a)' )&
    1471            0 :          &   'latt_temperature_end is ',multibinit_dtset%latt_temperature_end,'. The only allowed values',ch10,&
    1472            0 :          &   'are positives values.',ch10,&
    1473            0 :          &   'Action: correct latt_semperature_end in your input file.'
    1474            0 :     ABI_ERROR(message)
    1475              :  end if
    1476              : 
    1477           73 :  multibinit_dtset%latt_temperature_nstep=1
    1478           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_temperature_nstep',tread,'INT')
    1479           73 :  if(tread==1) multibinit_dtset%latt_temperature_nstep=intarr(1)
    1480           73 :  if(multibinit_dtset%latt_temperature_nstep<=0)then
    1481              :     write(message, '(a,i0,a,a,a,a)' )&
    1482            0 :          &   'latt_temperature_nstep is',multibinit_dtset%latt_temperature_nstep,', while it should be larger than 0',ch10,&
    1483            0 :          &   'Action: correct latt_temperature_nstep in your input file.'
    1484            0 :     ABI_ERROR(message)
    1485              :  end if
    1486              : 
    1487           73 :  multibinit_dtset%latt_var_temperature=0
    1488           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_var_temperature',tread,'INT')
    1489           73 :  if(tread==1) multibinit_dtset%latt_var_temperature=intarr(1)
    1490           73 :  if(multibinit_dtset%latt_var_temperature/=0.and.multibinit_dtset%latt_var_temperature/=1)then
    1491              :     write(message, '(a,i0,a,a,a,a,a)' )&
    1492            0 :          &   'latt_var_temperature is',multibinit_dtset%latt_var_temperature,'. The only allowed values',ch10,&
    1493            0 :          &   'are 0, or 1.',ch10,&
    1494            0 :          &   'Action: correct latt_var_temperature in your input file.'
    1495            0 :     ABI_ERROR(message)
    1496              :  end if
    1497              : 
    1498              : ! multibinit_dtset%latt_taup=1000
    1499              : ! call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_taup',tread,'TIM')
    1500              : ! if(tread==1) multibinit_dtset%latt_taup=dprarr(1)
    1501              : 
    1502           73 :  multibinit_dtset%lwf_dt= 1d-16
    1503           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_dt',tread,'TIM')
    1504           73 :  if(tread==1) multibinit_dtset%lwf_dt=dprarr(1)
    1505           73 :  if(multibinit_dtset%lwf_dt<0)then
    1506              :     write(message, '(a,es10.2,a,a,a,a,a)' )&
    1507            0 :          &   'lwf_dt is',multibinit_dtset%lwf_dt,', but the only allowed values',ch10,&
    1508            0 :          &   'are superior to 0  .',ch10,&
    1509            0 :          &   'Action: correct lwf_dt in your input file.'
    1510            0 :     ABI_ERROR(message)
    1511              :  end if
    1512              : 
    1513           73 :  multibinit_dtset%lwf_init_state=0
    1514           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_init_state',tread,'INT')
    1515           73 :  if(tread==1) multibinit_dtset%lwf_init_state=intarr(1)
    1516           73 :  if( .not. (multibinit_dtset%lwf_init_state <= 4) ) then
    1517              :     write(message, '(a,i8,a,a,a,a,a)' )&
    1518            0 :          &   'lwf_init_state is ',multibinit_dtset%lwf_init_state,', but the only allowed values',ch10,&
    1519            0 :          &   'are 0, 1,2,3,4 and negative values.',ch10,&
    1520            0 :          &   'Action: correct lwf_init_state in your input file.'
    1521            0 :     ABI_ERROR(message)
    1522              :  end if
    1523              : 
    1524              : 
    1525           73 :  multibinit_dtset%lwf_init_hist_fname=""
    1526              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_init_hist_fname',tread,'KEY',&
    1527           73 :       & key_value=multibinit_dtset%lwf_init_hist_fname)
    1528           73 :  if(.not. tread==1) multibinit_dtset%lwf_init_hist_fname="lwf_init_hist.nc"
    1529              : 
    1530              : 
    1531           73 :  multibinit_dtset%spin_init_hist_fname=""
    1532              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_init_hist_fname',tread,'KEY',&
    1533           73 :       & key_value=multibinit_dtset%spin_init_hist_fname)
    1534           73 :  if(.not. tread==1) multibinit_dtset%spin_init_hist_fname="spin_init_hist.nc"
    1535              : 
    1536           73 :  multibinit_dtset%latt_init_hist_fname=""
    1537              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_init_hist_fname',tread,'KEY',&
    1538           73 :       & key_value=multibinit_dtset%latt_init_hist_fname)
    1539           73 :  if(.not. tread==1) multibinit_dtset%latt_init_hist_fname="latt_init_hist.nc"
    1540              : 
    1541              : 
    1542              : 
    1543              : 
    1544           73 :  multibinit_dtset%slc_pot_fname=""
    1545              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'slc_pot_fname',tread,'KEY',&
    1546           73 :       & key_value=multibinit_dtset%slc_pot_fname)
    1547              : 
    1548              : 
    1549           73 :  multibinit_dtset%lwf_constraint=0
    1550           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_constraint',tread,'INT')
    1551           73 :  if(tread==1) multibinit_dtset%lwf_constraint=intarr(1)
    1552           73 :  if( .not. (multibinit_dtset%lwf_constraint == 0 .or. multibinit_dtset%lwf_constraint == 1) ) then
    1553              :     write(message, '(a,i8,a,a,a,a,a)' )&
    1554            0 :          &   'lwf_constraint is ',multibinit_dtset%lwf_constraint,', but the only allowed values',ch10,&
    1555            0 :          &   'are 0 or 1',ch10,&
    1556            0 :          &   'Action: correct lwf_constraint in your input file.'
    1557            0 :     ABI_ERROR(message)
    1558              :  end if
    1559              : 
    1560              : 
    1561           73 :  multibinit_dtset%lwf_dynamics=0
    1562           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_dynamics',tread,'INT')
    1563           73 :  if(tread==1) multibinit_dtset%lwf_dynamics=intarr(1)
    1564           73 :  if( .not. (multibinit_dtset%lwf_dynamics <= 3) ) then
    1565              :     write(message, '(a,i8,a,a,a,a,a)' )&
    1566            0 :          &   'lwf_dynamics is ',multibinit_dtset%lwf_dynamics,', but the only allowed values',ch10,&
    1567            0 :          &   'are 0, 1, 2, 3 and negative values.',ch10,&
    1568            0 :          &   'Action: correct lwf_dynamics in your input file.'
    1569            0 :     ABI_ERROR(message)
    1570              :  end if
    1571              : 
    1572           73 :  multibinit_dtset%lwf_mc_avg_amp=0.05
    1573           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_mc_avg_amp',tread,'DPR')
    1574           73 :  if(tread==1) multibinit_dtset%lwf_mc_avg_amp=dprarr(1)
    1575           73 :  if(multibinit_dtset%lwf_mc_avg_amp<0)then
    1576              :     write(message, '(a,f10.1,a,a,a,a,a)' )&
    1577            0 :          &   'lwf_mc_avg_amp is ',multibinit_dtset%lwf_mc_avg_amp,'. The only allowed values',ch10,&
    1578            0 :          &   'are non-negative values.',ch10,&
    1579            0 :          &   'Action: correct lwf_mc_avg_amp in your input file.'
    1580            0 :     ABI_ERROR(message)
    1581              :  end if
    1582              : 
    1583              : 
    1584              : 
    1585              : 
    1586           73 :  multibinit_dtset%lwf_nctime=1
    1587           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_nctime',tread,'INT')
    1588           73 :  if(tread==1) multibinit_dtset%lwf_nctime=intarr(1)
    1589           73 :  if( .not. (multibinit_dtset%lwf_nctime >= 0) ) then
    1590              :     write(message, '(a,i8,a,a,a,a,a)' )&
    1591            0 :          &   'lwf_nctime is ',multibinit_dtset%lwf_nctime,', but the only non-negative values allowed.'
    1592            0 :     ABI_ERROR(message)
    1593              :  end if
    1594              : 
    1595              : 
    1596           73 :  multibinit_dtset%lwf_ntime=0
    1597           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_ntime',tread,'INT')
    1598           73 :  if(tread==1) multibinit_dtset%lwf_ntime=intarr(1)
    1599           73 :  if( .not. (multibinit_dtset%lwf_ntime >= 0) ) then
    1600              :     write(message, '(a,i8,a,a,a,a,a)' )&
    1601            0 :          &   'lwf_ntime is ',multibinit_dtset%lwf_ntime,', but the only non-negative values allowed.'
    1602            0 :     ABI_ERROR(message)
    1603              :  end if
    1604              : 
    1605              : 
    1606              :  !multibinit_dtset%lwf_self_bound_order=0
    1607              :  !call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_self_bound_order',tread,'INT')
    1608              :  !if(tread==1) multibinit_dtset%lwf_self_bound_order=intarr(1)
    1609              : 
    1610              : 
    1611              :  !multibinit_dtset%lwf_self_bound_coeff=0.0
    1612              :  !call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_self_bound_coeff',tread,'DPR')
    1613              :  !if(tread==1) multibinit_dtset%lwf_self_bound_coeff=dprarr(1)
    1614              : 
    1615           73 :  multibinit_dtset%lwf_taut=0.0
    1616           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_taut',tread,'TIM')
    1617           73 :  if(tread==1) multibinit_dtset%lwf_taut=dprarr(1)
    1618           73 :  if(multibinit_dtset%lwf_taut<0)then
    1619              :     write(message, '(a,f10.1,a,a,a,a,a)' )&
    1620            0 :          &   'lwf_taut is ',multibinit_dtset%lwf_taut,'. The only allowed values',ch10,&
    1621            0 :          &   'are non-negative values.',ch10,&
    1622            0 :          &   'Action: correct lwf_taut in your input file.'
    1623            0 :     ABI_ERROR(message)
    1624              :  end if
    1625              : 
    1626              : 
    1627           73 :  multibinit_dtset%lwf_temperature=0.0
    1628           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_temperature',tread,'DPR')
    1629           73 :  if(tread==1) multibinit_dtset%lwf_temperature=dprarr(1)
    1630           73 :  if(multibinit_dtset%lwf_temperature<0)then
    1631              :     write(message, '(a,f10.1,a,a,a,a,a)' )&
    1632            0 :          &   'lwf_temperature is ',multibinit_dtset%lwf_temperature,'. The only allowed values',ch10,&
    1633            0 :          &   'are non-negative values.',ch10,&
    1634            0 :          &   'Action: correct lwf_temperature in your input file.'
    1635            0 :     ABI_ERROR(message)
    1636              :  end if
    1637              : 
    1638           73 : multibinit_dtset%lwf_temperature_start=0.0
    1639           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_temperature_start',tread,'DPR')
    1640           73 :  if(tread==1) multibinit_dtset%lwf_temperature_start=dprarr(1)
    1641           73 :  if(multibinit_dtset%lwf_temperature_start<0.0)then
    1642              :     write(message, '(a,f10.1,a,a,a,a,a)' )&
    1643            0 :          &   'lwf_temperature_start is ',multibinit_dtset%lwf_temperature_start,'. The only allowed values',ch10,&
    1644            0 :          &   'are positives values.',ch10,&
    1645            0 :          &   'Action: correct lwf_semperature_start in your input file.'
    1646            0 :     ABI_ERROR(message)
    1647              :  end if
    1648              : 
    1649           73 :  multibinit_dtset%lwf_temperature_end=0.0
    1650           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_temperature_end',tread,'DPR')
    1651           73 :  if(tread==1) multibinit_dtset%lwf_temperature_end=dprarr(1)
    1652           73 :  if(multibinit_dtset%lwf_temperature_end<0)then
    1653              :     write(message, '(a,f10.1,a,a,a,a,a)' )&
    1654            0 :          &   'lwf_temperature_end is ',multibinit_dtset%lwf_temperature_end,'. The only allowed values',ch10,&
    1655            0 :          &   'are positives values.',ch10,&
    1656            0 :          &   'Action: correct lwf_semperature_end in your input file.'
    1657            0 :     ABI_ERROR(message)
    1658              :  end if
    1659              : 
    1660           73 :  multibinit_dtset%lwf_temperature_nstep=1
    1661           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_temperature_nstep',tread,'INT')
    1662           73 :  if(tread==1) multibinit_dtset%lwf_temperature_nstep=intarr(1)
    1663           73 :  if(multibinit_dtset%lwf_temperature_nstep<=0)then
    1664              :     write(message, '(a,i0,a,a,a,a)' )&
    1665            0 :          &   'lwf_temperature_nstep is',multibinit_dtset%lwf_temperature_nstep,', while it should be larger than 0',ch10,&
    1666            0 :          &   'Action: correct lwf_temperature_nstep in your input file.'
    1667            0 :     ABI_ERROR(message)
    1668              :  end if
    1669              : 
    1670           73 :  multibinit_dtset%lwf_var_temperature=0
    1671           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_var_temperature',tread,'INT')
    1672           73 :  if(tread==1) multibinit_dtset%lwf_var_temperature=intarr(1)
    1673           73 :  if(multibinit_dtset%lwf_var_temperature/=0.and.multibinit_dtset%lwf_var_temperature/=1)then
    1674              :     write(message, '(a,i0,a,a,a,a,a)' )&
    1675            0 :          &   'lwf_var_temperature is',multibinit_dtset%lwf_var_temperature,'. The only allowed values',ch10,&
    1676            0 :          &   'are 0, or 1.',ch10,&
    1677            0 :          &   'Action: correct lwf_var_temperature in your input file.'
    1678            0 :     ABI_ERROR(message)
    1679              :  end if
    1680              : 
    1681              : 
    1682              : 
    1683           73 :  multibinit_dtset%spin_init_hist_fname=""
    1684              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_init_hist_fname',tread,'KEY',&
    1685           73 :       & key_value=multibinit_dtset%spin_init_hist_fname)
    1686           73 :  if(.not. tread==1) multibinit_dtset%spin_init_hist_fname="spin_init_hist.nc"
    1687              : 
    1688           73 :  multibinit_dtset%latt_init_hist_fname=""
    1689              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_init_hist_fname',tread,'KEY',&
    1690           73 :       & key_value=multibinit_dtset%latt_init_hist_fname)
    1691           73 :  if(.not. tread==1) multibinit_dtset%latt_init_hist_fname="latt_init_hist.nc"
    1692              : 
    1693              : 
    1694              : 
    1695           73 :  multibinit_dtset%spin_pot_fname=""
    1696              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_pot_fname',tread,'KEY',&
    1697           73 :       & key_value=multibinit_dtset%spin_pot_fname)
    1698           73 :  if(.not. tread==1) multibinit_dtset%spin_pot_fname=""
    1699              : 
    1700           73 :  multibinit_dtset%latt_pot_fname=""
    1701              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_pot_fname',tread,'KEY',&
    1702           73 :       & key_value=multibinit_dtset%latt_pot_fname)
    1703           73 :  if(.not. tread==1) multibinit_dtset%latt_pot_fname=""
    1704              : 
    1705           73 :  multibinit_dtset%latt_harm_pot_fname=""
    1706              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_harm_pot_fname',tread,'KEY',&
    1707           73 :       & key_value=multibinit_dtset%latt_harm_pot_fname)
    1708           73 :  if(.not. tread==1) multibinit_dtset%latt_harm_pot_fname=""
    1709              : 
    1710           73 :  multibinit_dtset%latt_anharm_pot_fname=""
    1711              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_anharm_pot_fname',tread,'KEY',&
    1712           73 :       & key_value=multibinit_dtset%latt_anharm_pot_fname)
    1713           73 :  if(.not. tread==1) multibinit_dtset%latt_anharm_pot_fname=""
    1714              : 
    1715           73 :  multibinit_dtset%latt_training_set_fname=""
    1716              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_training_set_fname',tread,'KEY',&
    1717           73 :       & key_value=multibinit_dtset%latt_training_set_fname)
    1718           73 :  if(.not. tread==1) multibinit_dtset%latt_training_set_fname=""
    1719              : 
    1720           73 :  multibinit_dtset%latt_test_set_fname=""
    1721              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_test_set_fname',tread,'KEY',&
    1722           73 :       & key_value=multibinit_dtset%latt_test_set_fname)
    1723           73 :  if(.not. tread==1) multibinit_dtset%latt_test_set_fname=""
    1724              : 
    1725              : 
    1726          949 :  multibinit_dtset%latt_ddb_fnames=""
    1727              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_ddb_fnames',tread,'KEY',&
    1728           73 :       & key_value=lattddb_string)
    1729           73 :  if(.not. tread==1) then
    1730           73 :     lattddb_string=""
    1731          949 :     multibinit_dtset%latt_ddb_fnames(:)=""
    1732              :  else
    1733            0 :     sidx(1) = 1; sidx(13) = len(lattddb_string)
    1734            0 :     cnt = 1
    1735            0 :     do ii=1,len(lattddb_string)
    1736            0 :        if (lattddb_string(ii:ii) == ",") then
    1737            0 :           lattddb_string(ii:ii) = " "
    1738            0 :           cnt = cnt + 1
    1739            0 :           sidx(cnt) = ii
    1740            0 :           ABI_CHECK(cnt <= 12, "Too many commas in latt_ddb_fnames!")
    1741              :        end if
    1742              :     end do
    1743              : 
    1744            0 :     do ii=1,cnt
    1745            0 :        i1 = sidx(ii)
    1746            0 :        i2 = sidx(ii + 1)
    1747            0 :        cnt = len(adjustl(trim(lattddb_string(i1:i2))))
    1748            0 :        ABI_CHECK(cnt <= fnlen, "latt_ddb_fnames path too small, increase fnlen")
    1749            0 :        multibinit_dtset%latt_ddb_fnames(ii) = adjustl(trim(lattddb_string(i1:i2)))
    1750              :        ! if (len_trim(pp_dirpath) > 0) then
    1751              :        !   if (len_trim(pp_dirpath) + len_trim(pseudo_paths(ii)) > fnlen) then
    1752              :        !     MSG_ERROR(sjoin("String of len fnlen:", itoa(fnlen), " too small to contain full pseudo path"))
    1753              :        !   end if
    1754              :        !   pseudo_paths(ii) = strcat(pp_dirpath, pseudo_paths(ii))
    1755              :        !end if
    1756              :     end do
    1757              :  end if
    1758              : 
    1759           73 :  multibinit_dtset%lwf_pot_fname=""
    1760              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'lwf_pot_fname',tread,'KEY',&
    1761           73 :       & key_value=multibinit_dtset%lwf_pot_fname)
    1762           73 :  if(.not. tread==1) multibinit_dtset%lwf_pot_fname=""
    1763              : 
    1764           73 :  multibinit_dtset%slc_pot_fname=""
    1765              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'slc_pot_fname',tread,'KEY',&
    1766           73 :       & key_value=multibinit_dtset%slc_pot_fname)
    1767           73 :  if(.not. tread==1) multibinit_dtset%slc_pot_fname=""
    1768              : 
    1769           73 :  multibinit_dtset%outdata_prefix=""
    1770              :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'outdata_prefix',tread,'KEY',&
    1771           73 :       & key_value=multibinit_dtset%outdata_prefix)
    1772           73 :  if(.not. tread==1) multibinit_dtset%outdata_prefix="multibinit"
    1773              : 
    1774              : !N
    1775           73 :  multibinit_dtset%natifc=natom
    1776           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'natifc',tread,'INT')
    1777           73 :  if(tread==1) multibinit_dtset%natifc=intarr(1)
    1778           73 :  if(multibinit_dtset%natifc<0)then
    1779              :    write(message, '(a,i0,a,a,a)' )&
    1780            0 : &   'natifc is',multibinit_dtset%natifc,', which is lower than 0 .',ch10,&
    1781            0 : &   'Action: correct natifc in your input file.'
    1782            0 :    ABI_ERROR(message)
    1783              :  end if
    1784              : 
    1785           73 :  if(multibinit_dtset%natifc>natom)then
    1786              :    write(message, '(a,i0,a,a,a,i0,a,a,a)' )&
    1787            0 : &   'The number of atom ifc in the input files',multibinit_dtset%natifc,',',ch10,&
    1788            0 : &   'is larger than the number of atoms',natom,'.',ch10,&
    1789            0 : &   'Action: change natifc in the input file.'
    1790            0 :    ABI_ERROR(message)
    1791              :  end if
    1792              : 
    1793           73 :  multibinit_dtset%ncoeff=0
    1794           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ncoeff',tread,'INT')
    1795           73 :  if(tread==1) multibinit_dtset%ncoeff=intarr(1)
    1796           73 :  if(multibinit_dtset%ncoeff<0)then
    1797              :    write(message, '(a,i0,a,a,a)' )&
    1798            0 : &   'ncoeff is',multibinit_dtset%ncoeff,', which is lower than 0 .',ch10,&
    1799            0 : &   'Action: correct ncoeff in your input file.'
    1800            0 :    ABI_ERROR(message)
    1801              :  end if
    1802              : 
    1803          292 :  multibinit_dtset%ng2qpt(:)=0
    1804           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'ng2qpt',tread,'INT')
    1805           73 :  if(tread==1) multibinit_dtset%ng2qpt(:)=intarr(1:3)
    1806          292 :  do ii=1,3
    1807          292 :    if(multibinit_dtset%ng2qpt(ii)<0)then
    1808              :      write(message, '(a,i0,a,i0,a,a,a,i0,a)' )&
    1809            0 : &     'ng2qpt(',ii,') is',multibinit_dtset%ng2qpt(ii),', which is lower than 0 .',ch10,&
    1810            0 : &     'Action: correct ng2qpt(',ii,') in your input file.'
    1811            0 :      ABI_ERROR(message)
    1812              :    end if
    1813              :  end do
    1814              : 
    1815          292 :  multibinit_dtset%ncell(:)= 1
    1816           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'ncell',tread,'INT')
    1817          241 :  if(tread==1) multibinit_dtset%ncell(1:3)=intarr(1:3)
    1818          292 :  do ii=1,3
    1819          292 :    if(multibinit_dtset%ncell(ii)<0.or.multibinit_dtset%ncell(ii)>150)then
    1820              :      write(message, '(a,i0,a,i0,3a,i0,a)' )&
    1821            0 : &     'ncell(',ii,') is ',multibinit_dtset%ncell(ii),', which is lower than 0 of superior than 150.',&
    1822            0 : &     ch10,'Action: correct ncell(',ii,') in your input file.'
    1823            0 :      ABI_ERROR(message)
    1824              :    end if
    1825              :  end do
    1826              : 
    1827              :  ! Set to diagonal ncell. Then if it is specified, overwrite.
    1828              :  multibinit_dtset%ncellmat(:,:)= reshape([multibinit_dtset%ncell(1), 0, 0,&
    1829              :         & 0, multibinit_dtset%ncell(2), 0, &
    1830         1606 :         & 0, 0, multibinit_dtset%ncell(3) ], [3,3])
    1831           73 :  call intagm(dprarr,intarr,jdtset,marr,9,string(1:lenstr),'ncellmat',tread,'INT')
    1832           73 :  if(tread==1) then
    1833           13 :     multibinit_dtset%ncellmat=transpose(reshape(intarr(1:9), [3,3]))
    1834              :  end if
    1835              : 
    1836          730 :  multibinit_dtset%ngqpt(:)= 1
    1837           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'ngqpt',tread,'INT')
    1838          145 :  if(tread==1) multibinit_dtset%ngqpt(1:3)=intarr(1:3)
    1839          292 :  do ii=1,3
    1840          292 :    if(multibinit_dtset%ngqpt(ii)<0)then
    1841              :      write(message, '(a,i0,a,i0,a,a,a,i0,a)' )&
    1842            0 : &     'ngqpt(',ii,') is',multibinit_dtset%ngqpt(ii),', which is lower than 0 .',ch10,&
    1843            0 : &     'Action: correct ngqpt(',ii,') in your input file.'
    1844            0 :      ABI_ERROR(message)
    1845              :    end if
    1846              :  end do
    1847              : 
    1848           73 :  multibinit_dtset%nph1l=1
    1849           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nph1l',tread,'INT')
    1850           73 :  if(tread==1) multibinit_dtset%nph1l=intarr(1)
    1851           73 :  if(multibinit_dtset%nph1l<0) then
    1852              :    write(message, '(a,i0,a,a,a)' )&
    1853            0 : &   'nph1l is',multibinit_dtset%nph1l,', which is lower than 0 .',ch10,&
    1854            0 : &   'Action: correct nph1l in your input file.'
    1855            0 :    ABI_ERROR(message)
    1856              :  end if
    1857              : 
    1858           73 :  multibinit_dtset%nph2l=0
    1859           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nph2l',tread,'INT')
    1860           73 :  if(tread==1) multibinit_dtset%nph2l=intarr(1)
    1861           73 :  if(multibinit_dtset%nph2l<0)then
    1862              :    write(message, '(a,i0,a,a,a)' )&
    1863            0 : &   'nph2l is',multibinit_dtset%nph2l,', which is lower than 0 .',ch10,&
    1864            0 : &   'Action: correct nph2l in your input file.'
    1865            0 :    ABI_ERROR(message)
    1866              :  end if
    1867              : 
    1868           73 :  multibinit_dtset%nqshft=1
    1869           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nqshft',tread,'INT')
    1870           73 :  if(tread==1) multibinit_dtset%nqshft=intarr(1)
    1871           73 :  if(multibinit_dtset%nqshft<0 .or. multibinit_dtset%nqshft==3 .or.&
    1872              : & multibinit_dtset%nqshft>=5 )then
    1873              :    write(message, '(a,i0,a,a,a,a,a)' )&
    1874            0 : &   'nqshft is',multibinit_dtset%nqshft,', but the only allowed values',ch10,&
    1875            0 : &   'are 1, 2 or 4 .',ch10,&
    1876            0 : &   'Action: correct nqshft in your input file.'
    1877            0 :    ABI_ERROR(message)
    1878              :  end if
    1879              : 
    1880           73 :  multibinit_dtset%nnos=0
    1881           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nnos',tread,'INT')
    1882           73 :  if(tread==1) multibinit_dtset%nnos=intarr(1)
    1883           73 :  if(multibinit_dtset%nnos<0)then
    1884              :    write(message, '(a,i0,a,a,a)' )&
    1885            0 : &   'nnos is',multibinit_dtset%nnos,', which is lower than 0',ch10,&
    1886            0 : &   'Action: correct nnos in your input file.'
    1887            0 :    ABI_ERROR(message)
    1888              :  end if
    1889              : 
    1890              : 
    1891           73 :  multibinit_dtset%nsphere=0
    1892           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nsphere',tread,'INT')
    1893           73 :  if(tread==1) multibinit_dtset%nsphere=intarr(1)
    1894           73 :  if(multibinit_dtset%nsphere<0)then
    1895              :    write(message, '(a,i0,a,a,a)' )&
    1896            0 : &   'nsphere is',multibinit_dtset%nsphere,', which is lower than 0',ch10,&
    1897            0 : &   'Action: correct nsphere in your input file.'
    1898            0 :    ABI_ERROR(message)
    1899              :  end if
    1900              : 
    1901              : !O
    1902              : 
    1903           73 :  multibinit_dtset%optcell=0
    1904           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'optcell',tread,'INT')
    1905           73 :  if(tread==1) multibinit_dtset%optcell=intarr(1)
    1906           73 :  if(multibinit_dtset%optcell<0.or.multibinit_dtset%optcell>9)then
    1907              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1908            0 : &   'optcell is',multibinit_dtset%optcell,', but the only allowed values',ch10,&
    1909            0 : &   'are 0, 1, 2, 3, 4, 5, 6 , 7, 8, 9.',ch10,&
    1910            0 : &   'Action: correct optcell in your input file.'
    1911            0 :    ABI_ERROR(message)
    1912              :  end if
    1913              : 
    1914              : 
    1915           73 :  multibinit_dtset%opt_effpot=0
    1916           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'opt_effpot',tread,'INT')
    1917           73 :  if(tread==1) multibinit_dtset%opt_effpot=intarr(1)
    1918              :  if(multibinit_dtset%opt_effpot<0 .and. multibinit_dtset%opt_effpot>1)then
    1919              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1920              : &   'opt_effpot is',multibinit_dtset%opt_effpot,', but the only allowed values',ch10,&
    1921              : &   'are 0 and 1.',ch10,&
    1922              : &   'Action: correct opt_effpot in your input file.'
    1923              :    ABI_ERROR(message)
    1924              :  end if
    1925              : 
    1926              : 
    1927           73 :  multibinit_dtset%opt_ncoeff=0
    1928           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'opt_ncoeff',tread,'INT')
    1929           73 :  if(tread==1) multibinit_dtset%opt_ncoeff=intarr(1)
    1930           73 :  if(multibinit_dtset%opt_ncoeff<0)then
    1931              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1932            0 : &   'opt_ncoeff is',multibinit_dtset%opt_ncoeff,', but the only positive values',ch10,&
    1933            0 : &   'are allowed for multibinit.',ch10,&
    1934            0 : &   'Action: correct opt_ncoeff in your input file.'
    1935            0 :    ABI_ERROR(message)
    1936              :  end if
    1937              : 
    1938          292 :  multibinit_dtset%opt_EFS=(/0,1,1/)
    1939          292 :  multibinit_dtset%opt_on = (/ .TRUE.,.TRUE.,.FALSE. /)
    1940           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'opt_EFS',tread,'INT')
    1941           73 :  if(tread==1) multibinit_dtset%opt_EFS(1:3)=intarr(1:3)
    1942           73 :  if(multibinit_dtset%opt_EFS(1) == 1)multibinit_dtset%opt_on(3) = .TRUE.
    1943           73 :  if(multibinit_dtset%opt_EFS(2) == 0)multibinit_dtset%opt_on(1) = .FALSE.
    1944           73 :  if(multibinit_dtset%opt_EFS(3) == 0)multibinit_dtset%opt_on(2) = .FALSE.
    1945          584 :  if(any(multibinit_dtset%opt_EFS<0) .or. any(multibinit_dtset%opt_EFS>1))then
    1946              :    write(message, '(a,i8,a,a,a)' )&
    1947            0 : &   'opt_EFS is',multibinit_dtset%opt_EFS,', but the only allowed values are 0 and 1',ch10,&
    1948            0 : &   'Action: correct opt_EFS in your input file.'
    1949            0 :    ABI_ERROR(message)
    1950              :  endif
    1951              : 
    1952          292 :  multibinit_dtset%opt_factors=(/1,1,1/)
    1953           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'opt_factors',tread,'DPR')
    1954           73 :  if(tread==1) multibinit_dtset%opt_factors(1:3)=dprarr(1:3)
    1955          292 :  if(any(multibinit_dtset%opt_factors<0))then
    1956              :    write(message, '(a,i8,a,a,a)' )&
    1957            0 : &   'opt_factors is',multibinit_dtset%opt_factors,', but the only allowed values are positive',ch10,&
    1958            0 : &   'Action: correct opt_factors in your input file.'
    1959            0 :    ABI_ERROR(message)
    1960              :  end if
    1961              : 
    1962              : !P
    1963           73 :  multibinit_dtset%prt_model=0
    1964           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prt_model',tread,'INT')
    1965           73 :  if(tread==1) multibinit_dtset%prt_model=intarr(1)
    1966           73 :  if(multibinit_dtset%prt_model<0.or.multibinit_dtset%prt_model>4)then
    1967              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1968            0 : &   'prt_model is',multibinit_dtset%prt_model,', but the only allowed values',ch10,&
    1969            0 : &   'are 0, 1 or 2.',ch10,&
    1970            0 : &   'Action: correct prt_model in your input file.'
    1971            0 :    ABI_ERROR(message)
    1972              :  end if
    1973              : 
    1974              : 
    1975           73 :  multibinit_dtset%prt_phfrq=0
    1976           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prt_phfrq',tread,'INT')
    1977           73 :  if(tread==1) multibinit_dtset%prt_phfrq=intarr(1)
    1978           73 :  if(multibinit_dtset%prt_phfrq<0.or.multibinit_dtset%prt_phfrq>2)then
    1979              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1980            0 : &   'prt_phfrq is',multibinit_dtset%prt_phfrq,', but the only allowed values',ch10,&
    1981            0 : &   'are 0, 1 or 2.',ch10,&
    1982            0 : &   'Action: correct prt_phfrq in your input file.'
    1983            0 :    ABI_ERROR(message)
    1984              :  end if
    1985              : 
    1986           73 :  multibinit_dtset%fit_initializeData=0
    1987           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_initializeData',tread,'INT')
    1988           73 :  if(tread==1) multibinit_dtset%fit_initializeData=intarr(1)
    1989           73 :  if(multibinit_dtset%fit_initializeData<0.or.multibinit_dtset%fit_initializeData>1)then
    1990              :    write(message, '(a,i8,a,a,a,a,a)' )&
    1991            0 : &   'fit_initializeData is',multibinit_dtset%fit_initializeData,', but the only allowed values',ch10,&
    1992            0 : &   'are 0, 1 or 2.',ch10,&
    1993            0 : &   'Action: correct fit_initializeData in your input file.'
    1994            0 :    ABI_ERROR(message)
    1995              :  end if
    1996              : 
    1997              : 
    1998           73 :  multibinit_dtset%fit_generateCoeff=1
    1999           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_generateCoeff',tread,'INT')
    2000           73 :  if(tread==1) multibinit_dtset%fit_generateCoeff=intarr(1)
    2001           73 :  if(multibinit_dtset%fit_generateCoeff<0.or.multibinit_dtset%fit_generateCoeff>1)then
    2002              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2003            0 : &   'fit_generateCoeff is',multibinit_dtset%fit_generateCoeff,', but the only allowed values',ch10,&
    2004            0 : &   'are 0, 1 or 2.',ch10,&
    2005            0 : &   'Action: correct fit_generateCoeff in your input file.'
    2006            0 :    ABI_ERROR(message)
    2007              :  end if
    2008              : 
    2009              : !Default is no output of GF values per processor to csv file
    2010           73 :  multibinit_dtset%prt_GF_csv = .FALSE.
    2011           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prt_GF_csv',tread,'INT')
    2012           73 :  if(tread==1)then
    2013            1 :     if(intarr(1) == 1) multibinit_dtset%prt_GF_csv = .TRUE.
    2014            1 :     if(intarr(1) == 0) multibinit_dtset%prt_GF_csv = .FALSE.
    2015            1 :     if(intarr(1) < 0 .or. intarr(1) > 1) then
    2016              :       write(message, '(a,i0,a,a,a,a,a)' )&
    2017            0 : &     'prt_GF_csv is',intarr(1),'. The only allowed values',ch10,&
    2018            0 : &     'are 0 (no output) or 1 (print GF values per processor into csv files)',ch10,  &
    2019            0 : &     'Action: correct prt_GF_csv in your input file.'
    2020            0 :       ABI_ERROR(message)
    2021              :     end if
    2022              :  endif
    2023              : !Default is no output of the real space IFC to file
    2024           73 :  multibinit_dtset%prt_ifc = 0
    2025           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prt_ifc',tread,'INT')
    2026           73 :  if(tread==1) multibinit_dtset%prt_ifc = intarr(1)
    2027           73 :  if(multibinit_dtset%prt_ifc < 0 .or. multibinit_dtset%prt_ifc > 1) then
    2028              :    write(message, '(a,i0,a,a,a,a,a)' )&
    2029            0 : &   'prtf_ifc is',multibinit_dtset%prt_ifc,'. The only allowed values',ch10,&
    2030            0 : &   'are 0 (no output) or 1 (AI2PS format)',ch10,  &
    2031            0 : &   'Action: correct prt_ifc in your input file.'
    2032            0 :    ABI_ERROR(message)
    2033              :  end if
    2034              : 
    2035              : 
    2036           73 :  multibinit_dtset%randomseed= 0
    2037           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'randomseed',tread,'INT')
    2038           73 :  if(tread==1) multibinit_dtset%randomseed= intarr(1)
    2039              : 
    2040           73 :  if(multibinit_dtset%randomseed /=0) then
    2041              :     write(message, "(a, a, a, a)") &
    2042            6 :     "The random seed is set to an fixed number, which might lead to wrong result if you're", &
    2043            6 : &   "performing a series of Monte Carlo/dynamics calculation as the random number will repeat. Only", &
    2044            6 : &   "do this when you want to repeat previous results. And note that it is only meaningful when", &
    2045           12 : &    "the number of cpu cores is consistent."
    2046            6 :     ABI_WARNING(message)
    2047              :  end if
    2048              : 
    2049              : 
    2050              : 
    2051              : 
    2052              : !Default is no output of the 3rd derivative
    2053           73 :  multibinit_dtset%strcpling = -1
    2054           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'strcpling',tread,'INT')
    2055           73 :  if(tread==1) multibinit_dtset%strcpling = intarr(1)
    2056           73 :  if(multibinit_dtset%strcpling < -1 .or. multibinit_dtset%strcpling > 2) then
    2057              :    write(message, '(a,i0,a,a,a,a,a,a,a)' )&
    2058            0 : &   'prtf_3rd is ',multibinit_dtset%strcpling,'. The only allowed values',ch10,&
    2059            0 : &   'are 0 (no computation), 1 (only computation)',ch10,&
    2060            0 : &   'or 2 (computation and print in xml file)',ch10,  &
    2061            0 : &   'Action: correct strcpling in your input file.'
    2062            0 :    ABI_ERROR(message)
    2063              :  end if
    2064              : 
    2065              : !Q
    2066          292 :  multibinit_dtset%qrefine=1 ! default is no refinement
    2067           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'qrefine',tread,'INT')
    2068           73 :  if(tread==1) multibinit_dtset%qrefine = intarr(1:3)
    2069          292 :  do ii=1,3
    2070          292 :    if(multibinit_dtset%qrefine(ii) < 1) then
    2071              :      write(message, '(a,3i0,a,a,a,a,a)' )&
    2072            0 : &     'qrefine is',multibinit_dtset%qrefine,' The only allowed values',ch10,&
    2073            0 : &     'are integers >= 1 giving the refinement of the ngqpt grid',ch10,&
    2074            0 : &     'Action: correct qrefine in your input file.'
    2075            0 :      ABI_ERROR(message)
    2076              :    end if
    2077              :  end do
    2078              : 
    2079              : !R
    2080           73 :  multibinit_dtset%restartxf=0
    2081           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'restartxf',tread,'INT')
    2082           73 :  if(tread==1) multibinit_dtset%restartxf=intarr(1)
    2083           73 :  if(multibinit_dtset%restartxf < -3 .or. multibinit_dtset%restartxf > 0)then
    2084              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2085            0 : &   'restartxf is',multibinit_dtset%restartxf,', but the only allowed values',ch10,&
    2086            0 : &   'is -2 or 0.',ch10,&
    2087            0 : &   'Action: correct restartxf in your input file.'
    2088            0 :    ABI_ERROR(message)
    2089              :  end if
    2090              : 
    2091           73 :  multibinit_dtset%rfmeth=1
    2092           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rfmeth',tread,'INT')
    2093           73 :  if(tread==1) multibinit_dtset%rfmeth=intarr(1)
    2094           73 :  if(multibinit_dtset%rfmeth<1.or.multibinit_dtset%rfmeth>2)then
    2095              :    write(message, '(a,i0,a,a,a,a,a)' )&
    2096            0 : &   'rfmeth is',multibinit_dtset%rfmeth,', but the only allowed values',ch10,&
    2097            0 : &   'are 1 or 2 . ',ch10,&
    2098            0 : &   'Action: correct rfmeth in your input file.'
    2099            0 :    ABI_ERROR(message)
    2100              :  end if
    2101              : 
    2102           73 :  multibinit_dtset%rifcsph=zero
    2103           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'rifcsph',tread,'DPR')
    2104           73 :  if(tread==1) multibinit_dtset%rifcsph=dprarr(1)
    2105           73 :  if(multibinit_dtset%rifcsph<-tol12)then
    2106              :    write(message, '(a,f10.3,a,a,a)' )&
    2107            0 : &   'rifcsph is',multibinit_dtset%rifcsph,', which is lower than zero.',ch10,&
    2108            0 : &   'Action: correct rifcsph in your input file.'
    2109            0 :    ABI_ERROR(message)
    2110              :  end if
    2111              : ! R
    2112              : !  multibinit_dtset%random_seed=-1
    2113              : !  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'random_seed',tread,'INT')
    2114              : !  if(tread==1) multibinit_dtset%random_seed=intarr(1)
    2115              : 
    2116              : !S
    2117              : 
    2118           73 :  multibinit_dtset%spin_damping=-1.0
    2119           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_damping',tread,'DPR')
    2120           73 :  if(tread==1) multibinit_dtset%spin_damping=dprarr(1)
    2121              : 
    2122              : ! multibinit_dtset%spin_calc_correlation_obs=0
    2123              : ! call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_calc_correlation_obs',tread,'INT')
    2124              : ! if(tread==1) multibinit_dtset%spin_calc_correlation_obs=intarr(1)
    2125              : ! if(multibinit_dtset%spin_calc_correlation_obs>1.or.multibinit_dtset%spin_calc_correlation_obs<0)then
    2126              : !    write(message, '(a,i8,a,a,a,a,a)' )&
    2127              : !         &   'spin_calc_correlation_obs is',multibinit_dtset%spin_calc_correlation_obs,', but the only allowed values',ch10,&
    2128              : !         &   'is 0 or 1.',ch10,&
    2129              : !         &   'Action: correct spin_calc_correlation_obs in your input file.'
    2130              : !    ABI_ERROR(message)
    2131              : ! end if
    2132              : !
    2133           73 :  multibinit_dtset%spin_calc_thermo_obs=1
    2134           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_calc_thermo_obs',tread,'INT')
    2135           73 :  if(tread==1) multibinit_dtset%spin_calc_thermo_obs=intarr(1)
    2136           73 :  if(multibinit_dtset%spin_calc_thermo_obs>1.or.multibinit_dtset%spin_calc_thermo_obs<0)then
    2137              :     write(message, '(a,i8,a,a,a,a,a)' )&
    2138            0 :          &   'spin_calc_thermo_obs is',multibinit_dtset%spin_calc_thermo_obs,', but the only allowed values',ch10,&
    2139            0 :          &   'is 0 or 1.',ch10,&
    2140            0 :          &   'Action: correct spin_calc_thermo_obs in your input file.'
    2141            0 :     ABI_ERROR(message)
    2142              :  end if
    2143              : 
    2144              : 
    2145              : ! multibinit_dtset%spin_calc_traj_obs=0
    2146              : ! call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_calc_traj_obs',tread,'INT')
    2147              : ! if(tread==1) multibinit_dtset%spin_calc_traj_obs=intarr(1)
    2148              : ! if(multibinit_dtset%spin_calc_traj_obs>1.or.multibinit_dtset%spin_calc_traj_obs<0)then
    2149              : !    write(message, '(a,i8,a,a,a,a,a)' )&
    2150              : !         &   'spin_calc_traj_obs is',multibinit_dtset%spin_calc_traj_obs,', but the only allowed values',ch10,&
    2151              : !         &   'is 0 or 1.',ch10,&
    2152              : !         &   'Action: correct spin_calc_traj_obs in your input file.'
    2153              : !    ABI_ERROR(message)
    2154              : ! end if
    2155              : 
    2156              : 
    2157           73 :  multibinit_dtset%spin_dipdip=0
    2158           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_dipdip',tread,'INT')
    2159           73 :  if(tread==1) multibinit_dtset%spin_dipdip=intarr(1)
    2160           73 :  if(multibinit_dtset%spin_dipdip>1.or.multibinit_dtset%spin_dipdip<0)then
    2161              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2162            0 : &   'spin_dipdip is',multibinit_dtset%spin_dipdip,', but the only allowed values',ch10,&
    2163            0 : &   'is 0 or 1.',ch10,&
    2164            0 : &   'Action: correct spin_dipdip in your input file.'
    2165            0 :    ABI_ERROR(message)
    2166              :  end if
    2167              : 
    2168              : 
    2169           73 :  multibinit_dtset%spin_dt= 1d-16
    2170           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_dt',tread,'TIM')
    2171           73 :  if(tread==1) multibinit_dtset%spin_dt=dprarr(1)
    2172           73 :  if(multibinit_dtset%spin_dt<0)then
    2173              :     write(message, '(a,es10.2,a,a,a,a,a)' )&
    2174            0 :          &   'spin_dt is',multibinit_dtset%spin_dt,', but the only allowed values',ch10,&
    2175            0 :          &   'are superior to 0  .',ch10,&
    2176            0 :          &   'Action: correct spin_dt in your input file.'
    2177            0 :     ABI_ERROR(message)
    2178              :  end if
    2179              : 
    2180              : 
    2181           73 :  multibinit_dtset%spin_dynamics=0
    2182           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_dynamics',tread,'INT')
    2183           73 :  if(tread==1) multibinit_dtset%spin_dynamics=intarr(1)
    2184           73 :  if( .not. (multibinit_dtset%spin_dynamics <= 3 .or. multibinit_dtset%spin_dynamics==20) ) then
    2185              :     write(message, '(a,i8,a,a,a,a,a)' )&
    2186            0 :          &   'spin_dynamics is ',multibinit_dtset%spin_dynamics,', but the only allowed values',ch10,&
    2187            0 :          &   'are 0, 1, 2, 3 and 20 and negative values.',ch10,&
    2188            0 :          &   'Action: correct spin_dynamics in your input file.'
    2189            0 :     ABI_ERROR(message)
    2190              :  end if
    2191              : 
    2192           73 :  if(multibinit_dtset%spin_dynamics == 20) then
    2193              :     write(message, '(a,i8,a)' )&
    2194            0 :          &   'spin_dynamics is ',multibinit_dtset%spin_dynamics,', spins will not move. For test only!!'
    2195            0 :     ABI_WARNING(message)
    2196              :  end if
    2197              : 
    2198              : 
    2199              : 
    2200           73 :  multibinit_dtset%spin_init_state=1
    2201           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_init_state',tread,'INT')
    2202           73 :  if(tread==1) multibinit_dtset%spin_init_state=intarr(1)
    2203           73 :  if(multibinit_dtset%spin_init_state<1 .or. &
    2204              :       &   multibinit_dtset%spin_init_state>4) then
    2205              :     write(message, '(a,i8,a,a,a,a,a)' )&
    2206            0 :          &   'spin_init_state is',multibinit_dtset%spin_init_state,', but the only allowed values',ch10,&
    2207            0 :          &   'are 1, 2, 3, and 4.',ch10,&
    2208            0 :          &   'Action: correct spin_init_state in your input file.'
    2209            0 :     ABI_ERROR(message)
    2210              :  end if
    2211              : 
    2212              : 
    2213              : 
    2214          292 :  multibinit_dtset%spin_mag_field= zero
    2215           73 :  if(3>marr)then
    2216            0 :     marr=3
    2217            0 :     ABI_FREE(intarr)
    2218            0 :     ABI_FREE(dprarr)
    2219            0 :     ABI_MALLOC(intarr,(marr))
    2220            0 :     ABI_MALLOC(dprarr,(marr))
    2221              :  end if
    2222           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'spin_mag_field',tread,'BFI')
    2223           79 :  if(tread==1) multibinit_dtset%spin_mag_field(1:3)= dprarr(1:3)
    2224              : 
    2225           73 :  multibinit_dtset%spin_nctime=100
    2226           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_nctime',tread,'INT')
    2227           73 :  if(tread==1) multibinit_dtset%spin_nctime=intarr(1)
    2228           73 :  if(multibinit_dtset%spin_nctime<=0)then
    2229              :     write(message, '(a,i0,a,a,a)' )&
    2230            0 :          &   'spin_nctime is ',multibinit_dtset%spin_nctime,', which is lower than 1 .',ch10,&
    2231            0 :          &   'Action: correct spin_nctime in your input file.'
    2232            0 :     ABI_ERROR(message)
    2233              :  end if
    2234              : 
    2235           73 :  multibinit_dtset%spin_ntime_pre=0
    2236           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_ntime_pre',tread,'INT')
    2237           73 :  if(tread==1) multibinit_dtset%spin_ntime_pre=intarr(1)
    2238           73 :  if(multibinit_dtset%spin_ntime_pre<0)then
    2239              :     write(message, '(a,i0,a,a,a)' )&
    2240            0 :          &   'spin_ntime_pre is',multibinit_dtset%spin_ntime_pre,', which is lower than 0 .',ch10,&
    2241            0 :          &   'Action: correct spin_ntime_pre in your input file.'
    2242            0 :     ABI_ERROR(message)
    2243              :  end if
    2244              : 
    2245              : 
    2246              : 
    2247           73 :  multibinit_dtset%spin_ntime=10000
    2248           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_ntime',tread,'INT')
    2249           73 :  if(tread==1) multibinit_dtset%spin_ntime=intarr(1)
    2250           73 :  if(multibinit_dtset%spin_ntime<0)then
    2251              :     write(message, '(a,i0,a,a,a)' )&
    2252            0 :          &   'spin_ntime is',multibinit_dtset%spin_ntime,', which is lower than 0 .',ch10,&
    2253            0 :          &   'Action: correct spin_ntime in your input file.'
    2254            0 :     ABI_ERROR(message)
    2255              :  end if
    2256              : 
    2257              : 
    2258              : ! multibinit_dtset%spin_n1l=1
    2259              : ! call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_n1l',tread,'INT')
    2260              : ! if(tread==1) multibinit_dtset%spin_n1l=intarr(1)
    2261              : ! if(multibinit_dtset%spin_n1l<0)then
    2262              : !    write(message, '(a,i0,a,a,a)' )&
    2263              : !         &   'spin_n1l is',multibinit_dtset%spin_n1l,', which is lower than 0 .',ch10,&
    2264              : !         &   'Action: correct spin_n1l in your input file.'
    2265              : !    ABI_ERROR(message)
    2266              : ! end if
    2267              : !
    2268              : ! multibinit_dtset%spin_n2l=0
    2269              : ! call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_n2l',tread,'INT')
    2270              : ! if(tread==1) multibinit_dtset%spin_n2l=intarr(1)
    2271              : ! if(multibinit_dtset%spin_n2l<0)then
    2272              : !    write(message, '(a,i0,a,a,a)' )&
    2273              : !         &   'spin_n2l is',multibinit_dtset%spin_n2l,', which is lower than 0 .',ch10,&
    2274              : !         &   'Action: correct spin_n2l in your input file.'
    2275              : !    ABI_ERROR(message)
    2276              : ! end if
    2277              : 
    2278          292 :  multibinit_dtset%spin_init_orientation= [0.0, 0.0, 1.0]
    2279           73 :  if(3>marr)then
    2280            0 :     marr=3
    2281            0 :     ABI_FREE(intarr)
    2282            0 :     ABI_FREE(dprarr)
    2283            0 :     ABI_MALLOC(intarr,(marr))
    2284            0 :     ABI_MALLOC(dprarr,(marr))
    2285              :  end if
    2286           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'spin_init_orientation',tread,'DPR')
    2287           79 :  if(tread==1) multibinit_dtset%spin_init_orientation(1:3)= dprarr(1:3)
    2288              : 
    2289          292 :  multibinit_dtset%spin_projection_qpoint= zero
    2290           73 :  if(3>marr)then
    2291            0 :     marr=3
    2292            0 :     ABI_FREE(intarr)
    2293            0 :     ABI_FREE(dprarr)
    2294            0 :     ABI_MALLOC(intarr,(marr))
    2295            0 :     ABI_MALLOC(dprarr,(marr))
    2296              :  end if
    2297           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'spin_projection_qpoint',tread,'DPR')
    2298           79 :  if(tread==1) multibinit_dtset%spin_projection_qpoint(1:3)= dprarr(1:3)
    2299              : 
    2300          292 :  multibinit_dtset%spin_init_qpoint= zero
    2301           73 :  if(3>marr)then
    2302            0 :     marr=3
    2303            0 :     ABI_FREE(intarr)
    2304            0 :     ABI_FREE(dprarr)
    2305            0 :     ABI_MALLOC(intarr,(marr))
    2306            0 :     ABI_MALLOC(dprarr,(marr))
    2307              :  end if
    2308           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'spin_init_qpoint',tread,'DPR')
    2309           79 :  if(tread==1) multibinit_dtset%spin_init_qpoint(1:3)= dprarr(1:3)
    2310              : 
    2311          292 :  multibinit_dtset%spin_init_rotate_axis= [1.0, 0.0, 0.0]
    2312           73 :  if(3>marr)then
    2313            0 :     marr=3
    2314            0 :     ABI_FREE(intarr)
    2315            0 :     ABI_FREE(dprarr)
    2316            0 :     ABI_MALLOC(intarr,(marr))
    2317            0 :     ABI_MALLOC(dprarr,(marr))
    2318              :  end if
    2319           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'spin_init_rotate_axis',tread,'DPR')
    2320           79 :  if(tread==1) multibinit_dtset%spin_init_rotate_axis(1:3)= dprarr(1:3)
    2321              : 
    2322           73 :  multibinit_dtset%spin_sia_add=0
    2323           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_sia_add',tread,'INT')
    2324           73 :  if(tread==1) multibinit_dtset%spin_sia_add=intarr(1)
    2325           73 :  if(multibinit_dtset%spin_sia_add <0 .or. multibinit_dtset%spin_sia_add>2 )then
    2326              :     write(message, '(a,i0,a,a,a)' )&
    2327            0 :          &   'spin_sia_add is',multibinit_dtset%spin_sia_add,', which is not 0, 1, or 2.',ch10,&
    2328            0 :          &   'Action: correct spin_sia_add in your input file.'
    2329            0 :     ABI_ERROR(message)
    2330              :  end if
    2331              : 
    2332           73 :  multibinit_dtset%spin_sia_k1amp=0.0
    2333           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_sia_k1amp',tread,'ENE')
    2334           73 :  if(tread==1) multibinit_dtset%spin_sia_k1amp=dprarr(1)
    2335              : 
    2336          292 :  multibinit_dtset%spin_sia_k1dir(:)= [0.0,0.0,1.0]
    2337           73 :  if(3>marr)then
    2338            0 :     marr=3
    2339            0 :     ABI_FREE(intarr)
    2340            0 :     ABI_FREE(dprarr)
    2341            0 :     ABI_MALLOC(intarr,(marr))
    2342            0 :     ABI_MALLOC(dprarr,(marr))
    2343              :  end if
    2344           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'spin_sia_k1dir',tread,'DPR')
    2345           73 :  if(tread==1) then
    2346            0 :     dprarr(1:3)=dprarr(1:3)/sqrt(sum(dprarr(1:3)**2))
    2347            0 :     multibinit_dtset%spin_sia_k1dir(1:3)= dprarr(1:3)
    2348              :  endif
    2349              : 
    2350           73 :  multibinit_dtset%spin_temperature=325
    2351           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_temperature',tread,'DPR')
    2352           73 :  if(tread==1) multibinit_dtset%spin_temperature=dprarr(1)
    2353           73 :  if(multibinit_dtset%spin_temperature<0)then
    2354              :    write(message, '(a,f10.1,a,a,a,a,a)' )&
    2355            0 : &   'spin_temperature is ',multibinit_dtset%spin_temperature,'. The only allowed values',ch10,&
    2356            0 : &   'are non-negative values.',ch10,&
    2357            0 : &   'Action: correct spin_temperature in your input file.'
    2358            0 :    ABI_ERROR(message)
    2359              :  end if
    2360              : 
    2361           73 :  multibinit_dtset%spin_temperature_start=0.0
    2362           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_temperature_start',tread,'DPR')
    2363           73 :  if(tread==1) multibinit_dtset%spin_temperature_start=dprarr(1)
    2364           73 :  if(multibinit_dtset%spin_temperature_start<0.0)then
    2365              :     write(message, '(a,f10.1,a,a,a,a,a)' )&
    2366            0 :          &   'spin_temperature_start is ',multibinit_dtset%spin_temperature_start,'. The only allowed values',ch10,&
    2367            0 :          &   'are positives values.',ch10,&
    2368            0 :          &   'Action: correct spin_semperature_start in your input file.'
    2369            0 :     ABI_ERROR(message)
    2370              :  end if
    2371              : 
    2372           73 :  multibinit_dtset%spin_temperature_end=0.0
    2373           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_temperature_end',tread,'DPR')
    2374           73 :  if(tread==1) multibinit_dtset%spin_temperature_end=dprarr(1)
    2375           73 :  if(multibinit_dtset%spin_temperature_end<0)then
    2376              :     write(message, '(a,f10.1,a,a,a,a,a)' )&
    2377            0 :          &   'spin_temperature_end is ',multibinit_dtset%spin_temperature_end,'. The only allowed values',ch10,&
    2378            0 :          &   'are positives values.',ch10,&
    2379            0 :          &   'Action: correct spin_semperature_end in your input file.'
    2380            0 :     ABI_ERROR(message)
    2381              :  end if
    2382              : 
    2383           73 :  multibinit_dtset%spin_temperature_nstep=1
    2384           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_temperature_nstep',tread,'INT')
    2385           73 :  if(tread==1) multibinit_dtset%spin_temperature_nstep=intarr(1)
    2386           73 :  if(multibinit_dtset%spin_temperature_nstep<=0)then
    2387              :     write(message, '(a,i0,a,a,a,a)' )&
    2388            0 :          &   'spin_temperature_nstep is',multibinit_dtset%spin_temperature_nstep,', while it should be larger than 0',ch10,&
    2389            0 :          &   'Action: correct spin_temperature_nstep in your input file.'
    2390            0 :     ABI_ERROR(message)
    2391              :  end if
    2392              : 
    2393              : 
    2394              : 
    2395              : ! multibinit_dtset%spin_tolavg=1d-02
    2396              : ! call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_tolavg',tread,'DPR')
    2397              : ! if(tread==1) multibinit_dtset%spin_tolavg=dprarr(1)
    2398              : ! if(multibinit_dtset%spin_tolavg<=0)then
    2399              : !    write(message, '(a,f10.1,a,a,a,a,a)' )&
    2400              : !         &   'spin_tolavg is ',multibinit_dtset%spin_tolavg,'. The only allowed values',ch10,&
    2401              : !         &   'are positives values.',ch10,&
    2402              : !         &   'Action: correct spin_tolavg in your input file.'
    2403              : !    ABI_ERROR(message)
    2404              : ! end if
    2405              : !
    2406              : ! multibinit_dtset%spin_tolvar=1d-02
    2407              : ! call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_tolvar',tread,'DPR')
    2408              : ! if(tread==1) multibinit_dtset%spin_tolvar=dprarr(1)
    2409              : ! if(multibinit_dtset%spin_tolvar<=0)then
    2410              : !    write(message, '(a,f10.1,a,a,a,a,a)' )&
    2411              : !         &   'spin_tolvar is ',multibinit_dtset%spin_tolvar,'. The only allowed values',ch10,&
    2412              : !         &   'are positives values.',ch10,&
    2413              : !         &   'Action: correct spin_tolvar in your input file.'
    2414              : !    ABI_ERROR(message)
    2415              : ! end if
    2416              : 
    2417           73 :  multibinit_dtset%spin_var_temperature=0
    2418           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_var_temperature',tread,'INT')
    2419           73 :  if(tread==1) multibinit_dtset%spin_var_temperature=intarr(1)
    2420           73 :  if(multibinit_dtset%spin_var_temperature/=0.and.multibinit_dtset%spin_var_temperature/=1)then
    2421              :     write(message, '(a,i0,a,a,a,a,a)' )&
    2422            0 :          &   'spin_var_temperature is',multibinit_dtset%spin_var_temperature,'. The only allowed values',ch10,&
    2423            0 :          &   'are 0, or 1.',ch10,&
    2424            0 :          &   'Action: correct spin_var_temperature in your input file.'
    2425            0 :     ABI_ERROR(message)
    2426              :  end if
    2427              : 
    2428           73 :  multibinit_dtset%spin_write_traj=0
    2429           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'spin_write_traj',tread,'INT')
    2430           73 :  if(tread==1) multibinit_dtset%spin_write_traj=intarr(1)
    2431           73 :  if(multibinit_dtset%spin_write_traj/=0.and.multibinit_dtset%spin_write_traj/=1)then
    2432              :     write(message, '(a,i0,a,a,a,a,a)' )&
    2433            0 :          &   'spin_write_traj is',multibinit_dtset%spin_write_traj,'. The only allowed values',ch10,&
    2434            0 :          &   'are 0, or 1.',ch10,&
    2435            0 :          &   'Action: correct spin_write_traj in your input file.'
    2436            0 :     ABI_ERROR(message)
    2437              :  end if
    2438              : 
    2439           73 :  multibinit_dtset%slc_coupling=0
    2440           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'slc_coupling',tread,'INT')
    2441           73 :  if(tread==1) multibinit_dtset%slc_coupling=intarr(1)
    2442              :  if(multibinit_dtset%slc_coupling.ne. 1111 .and. &
    2443              :       &   multibinit_dtset%slc_coupling.ne. 1110 .and. &
    2444              :       &   multibinit_dtset%slc_coupling.ne. 1101 .and. &
    2445              :       &   multibinit_dtset%slc_coupling.ne. 1011 .and. &
    2446              :       &   multibinit_dtset%slc_coupling.ne.  111 .and. &
    2447              :       &   multibinit_dtset%slc_coupling.ne. 1100 .and. &
    2448              :       &   multibinit_dtset%slc_coupling.ne. 1010 .and. &
    2449              :       &   multibinit_dtset%slc_coupling.ne. 1001 .and. &
    2450              :       &   multibinit_dtset%slc_coupling.ne.  110 .and. &
    2451              :       &   multibinit_dtset%slc_coupling.ne.  101 .and. &
    2452              :       &   multibinit_dtset%slc_coupling.ne.   11 .and. &
    2453              :       &   multibinit_dtset%slc_coupling.ne. 1000 .and. &
    2454              :       &   multibinit_dtset%slc_coupling.ne.  100 .and. &
    2455              :       &   multibinit_dtset%slc_coupling.ne.   10 .and. &
    2456          144 :       &   multibinit_dtset%slc_coupling.ne.    1 .and. &
    2457              :       &   multibinit_dtset%slc_coupling.ne.    0) then
    2458              :     write(message, '(a,i8,a,a,a,a,a)' )&
    2459            0 :          &   'slc_coupling is',multibinit_dtset%slc_coupling,', but the only allowed values',ch10,&
    2460            0 :          &   'are 1111, 1110, 1101, 1011, 111, 1100, 1010, 1001, 110, 101, 11, 1000, 100, 10, 1, and 0.',ch10,&
    2461            0 :          &   'Action: correct slc_coupling in your input file.'
    2462            0 :     ABI_ERROR(message)
    2463              :  end if
    2464              : 
    2465              : 
    2466           73 :  multibinit_dtset%symdynmat=1
    2467           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'symdynmat',tread,'INT')
    2468           73 :  if(tread==1) multibinit_dtset%symdynmat=intarr(1)
    2469           73 :  if(multibinit_dtset%symdynmat/=0.and.multibinit_dtset%symdynmat/=1)then
    2470              :    write(message, '(a,i0,a,a,a,a,a)' )&
    2471            0 : &   'symdynmat is',multibinit_dtset%symdynmat,'. The only allowed values',ch10,&
    2472            0 : &   'are 0, or 1.',ch10,&
    2473            0 : &   'Action: correct symdynmat in your input file.'
    2474            0 :    ABI_ERROR(message)
    2475              :  end if
    2476              : 
    2477           73 :  multibinit_dtset%sys_dim=1
    2478           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'sys_dim',tread,'INT')
    2479           73 :  if(tread==1) multibinit_dtset%sys_dim=intarr(1)
    2480           73 :  if(multibinit_dtset%sys_dim<1.or.multibinit_dtset%sys_dim>9)then
    2481              :    write(message, '(a,i0,5a)' )&
    2482            0 :    'sys_dim is ',multibinit_dtset%sys_dim,', but the only allowed values',ch10,&
    2483            0 :    'are 1, 2, 3, 4, 5, 6, 7 or 8.',ch10,'Action: correct sys_dim in your input file.'
    2484            0 :    ABI_ERROR(message)
    2485              :  end if 
    2486              : 
    2487           73 :  multibinit_dtset%strfact=100.0d0
    2488           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'strfact',tread,'DPR')
    2489           73 :  if(tread==1) multibinit_dtset%strfact=dprarr(1)
    2490           73 :  if(multibinit_dtset%strfact<-tol12)then
    2491              :    write(message, '(a,f10.1,a,a,a,a,a)' )&
    2492            0 : &   'strfact is ',multibinit_dtset%strfact,'. The only allowed values',ch10,&
    2493            0 : &   'are positives values.',ch10,&
    2494            0 : &   'Action: correct strfact in your input file.'
    2495            0 :    ABI_ERROR(message)
    2496              :  end if
    2497              : 
    2498           73 :  multibinit_dtset%strprecon=1.0d0
    2499           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'strprecon',tread,'DPR')
    2500           73 :  if(tread==1) multibinit_dtset%strprecon=dprarr(1)
    2501           73 :  if(multibinit_dtset%strprecon<tol8 .or. multibinit_dtset%strprecon >1.0d0)then
    2502              :    write(message, '(a,f10.1,a,a,a,a,a)' )&
    2503            0 : &   'strprecon is ',multibinit_dtset%strprecon,'. The only allowed values',ch10,&
    2504            0 : &   'are positives values smaller or equal than 1.',ch10,&
    2505            0 : &   'Action: correct strprecon in your input file.'
    2506            0 :    ABI_ERROR(message)
    2507              :  end if
    2508              : 
    2509              : !T
    2510              : 
    2511           73 :  multibinit_dtset%temperature=325.0d0
    2512           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'temperature',tread,'DPR')
    2513           73 :  if(tread==1) multibinit_dtset%temperature=dprarr(1)
    2514           73 :  if(multibinit_dtset%temperature<=0)then
    2515              :    write(message, '(a,f10.1,a,a,a,a,a)' )&
    2516            0 : &   'Temperature is ',multibinit_dtset%temperature,'. The only allowed values',ch10,&
    2517            0 : &   'are positives values.',ch10,&
    2518            0 : &   'Action: correct Temperature in your input file.'
    2519            0 :    ABI_ERROR(message)
    2520              :  end if
    2521              : 
    2522              : 
    2523              : 
    2524           73 :  multibinit_dtset%test_effpot=0
    2525           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'test_effpot',tread,'INT')
    2526           73 :  if(tread==1) multibinit_dtset%test_effpot=intarr(1)
    2527           73 :  if(multibinit_dtset%test_effpot<0 .or. multibinit_dtset%test_effpot>1)then
    2528              :    write(message, '(a,i0,a,a,a,a,a)' )&
    2529            0 : &   'test_effpot is ',multibinit_dtset%test_effpot,'. The only allowed values',ch10,&
    2530            0 : &   'are 0 and 1.',ch10,&
    2531            0 : &   'Action: correct test_effpot in your input file.'
    2532            0 :    ABI_ERROR(message)
    2533              :  end if
    2534              : 
    2535           73 :  multibinit_dtset%test_prt_ph=0
    2536           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'test_prt_ph',tread,'INT')
    2537           73 :  if(tread==1) multibinit_dtset%test_prt_ph=intarr(1)
    2538           73 :  if(multibinit_dtset%test_prt_ph<0 .or. multibinit_dtset%test_prt_ph>1)then
    2539              :    write(message, '(a,i0,a,a,a,a,a)' )&
    2540            0 : &   'test_prt_ph is ',multibinit_dtset%test_prt_ph,'. The only allowed values',ch10,&
    2541            0 : &   'are 0 and 1.',ch10,&
    2542            0 : &   'Action: correct test_prt_ph in your input file.'
    2543            0 :    ABI_ERROR(message)
    2544              :  end if
    2545              : 
    2546           73 :  multibinit_dtset%tolmxf=2.0d-5
    2547           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'tolmxf',tread,'DPR')
    2548           73 :  if(tread==1) multibinit_dtset%tolmxf=dprarr(1)
    2549           73 :  if(multibinit_dtset%tolmxf<0)then
    2550              :    write(message, '(a,i0,a,a,a,a,a)' )&
    2551            0 : &   'tolmxf is ',multibinit_dtset%tolmxf,'. The only allowed values',ch10,&
    2552            0 : &   'are positiv.',ch10,&
    2553            0 : &   'Action: correct tolmxf in your input file.'
    2554            0 :    ABI_ERROR(message)
    2555              :  end if
    2556              : 
    2557              : !U
    2558              : 
    2559              : !V
    2560              : 
    2561              : !W
    2562              : 
    2563              : !X
    2564              : 
    2565              : !Y
    2566              : 
    2567              : !Z
    2568              : 
    2569              : !=====================================================================
    2570              : !end non-dependent variables
    2571              : !=====================================================================
    2572              : 
    2573              : !=======================================================================
    2574              : !Read in dependent variables (dependent on dimensions above)
    2575              : !=======================================================================
    2576              : 
    2577              : !A
    2578          292 :  multibinit_dtset%acell= one
    2579           73 :  if(3>marr)then
    2580            0 :    marr=3
    2581            0 :    ABI_FREE(intarr)
    2582            0 :    ABI_FREE(dprarr)
    2583            0 :    ABI_MALLOC(intarr,(marr))
    2584            0 :    ABI_MALLOC(dprarr,(marr))
    2585              :  end if
    2586           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'acell',tread,'DPR')
    2587           73 :  if(tread==1) multibinit_dtset%acell(1:3)= dprarr(1:3)
    2588          292 :  if(any(multibinit_dtset%acell<=tol10))then
    2589              :     write(message, '(3a)' )&
    2590            0 : &       'There is negative or zero value for cell ',ch10,&
    2591            0 : &       'Action: change acell in your input file.'
    2592            0 :       ABI_ERROR(message)
    2593              :  end if
    2594              : 
    2595           73 :  if(6>marr)then
    2596            0 :    marr=6
    2597            0 :    ABI_FREE(intarr)
    2598            0 :    ABI_FREE(dprarr)
    2599            0 :    ABI_MALLOC(intarr,(marr))
    2600            0 :    ABI_MALLOC(dprarr,(marr))
    2601              :  end if
    2602          511 :  multibinit_dtset%strtarget(1:6) = zero
    2603           73 :  call intagm(dprarr,intarr,jdtset,marr,6,string(1:lenstr),'strtarget',tread,'DPR')
    2604           91 :  if(tread==1) multibinit_dtset%strtarget(1:6)=dprarr(1:6)
    2605              : 
    2606              : 
    2607          219 :  ABI_MALLOC(multibinit_dtset%atifc,(natom))
    2608          429 :  multibinit_dtset%atifc(:)=0
    2609           73 :  if(multibinit_dtset%natifc>=1)then
    2610           67 :    if(multibinit_dtset%natifc>marr)then
    2611            0 :      marr=multibinit_dtset%natifc
    2612            0 :      ABI_FREE(intarr)
    2613            0 :      ABI_FREE(dprarr)
    2614            0 :      ABI_MALLOC(intarr,(marr))
    2615            0 :      ABI_MALLOC(dprarr,(marr))
    2616              :    end if
    2617           67 :    call intagm(dprarr,intarr,jdtset,marr,multibinit_dtset%natifc,string(1:lenstr),'atifc',tread,'INT')
    2618           67 :    if(tread==1) then
    2619            0 :      multibinit_dtset%atifc(1:multibinit_dtset%natifc)= intarr(1:multibinit_dtset%natifc)
    2620              :    else ! set to the maximum
    2621          423 :      do iatifc=1,multibinit_dtset%natifc
    2622          423 :        multibinit_dtset%atifc(iatifc) =  iatifc
    2623              :      end do
    2624              :    end if
    2625          201 :    ABI_MALLOC(work,(natom))
    2626          423 :    work(:)=0
    2627              : 
    2628          423 :    do iatifc=1,multibinit_dtset%natifc
    2629          356 :      if(multibinit_dtset%atifc(iatifc)<=0.or.multibinit_dtset%atifc(iatifc)>natom)then
    2630              :        write(message, '(a,i0,a,a,a,a,a,i0,a,a,a)' )&
    2631            0 : &       'For iatifc=',iatifc,', the number of the atom ifc to be ',ch10,&
    2632            0 : &       'analysed is not valid : either negative, ',ch10,&
    2633            0 : &       'zero, or larger than natom =',natom,'.',ch10,&
    2634            0 : &       'Action: change atifc in your input file.'
    2635            0 :        ABI_ERROR(message)
    2636              :      end if
    2637          423 :      work(multibinit_dtset%atifc(iatifc))=1
    2638              :    end do
    2639          423 :    multibinit_dtset%atifc(1:natom)=int(work(:))
    2640           67 :    ABI_FREE(work)
    2641              :  end if
    2642              : 
    2643              : !B
    2644              : 
    2645              : !C
    2646          219 :  ABI_MALLOC(multibinit_dtset%coefficients,(multibinit_dtset%ncoeff))
    2647           73 :  if (multibinit_dtset%ncoeff/=0)then
    2648            8 :    if(multibinit_dtset%ncoeff>marr)then
    2649            0 :      marr=multibinit_dtset%ncoeff
    2650            0 :      ABI_FREE(intarr)
    2651            0 :      ABI_FREE(dprarr)
    2652            0 :      ABI_MALLOC(intarr,(marr))
    2653            0 :      ABI_MALLOC(dprarr,(marr))
    2654              :    end if
    2655           40 :    multibinit_dtset%coefficients(:)=zero
    2656              :    call intagm(dprarr,intarr,jdtset,marr,multibinit_dtset%ncoeff,&
    2657            8 : &              string(1:lenstr),'coefficients',tread,'DPR')
    2658            8 :    if(tread==1)then
    2659           40 :      do ii=1,multibinit_dtset%ncoeff
    2660           40 :        multibinit_dtset%coefficients(ii)=dprarr(ii)
    2661              :      end do
    2662              :    end if
    2663              :  end if
    2664              : 
    2665          219 :  ABI_MALLOC(multibinit_dtset%conf_cutoff_disp,(multibinit_dtset%natom))
    2666           73 :  if (multibinit_dtset%natom/=0)then
    2667           67 :    if(multibinit_dtset%natom>marr)then
    2668            0 :      marr=multibinit_dtset%natom
    2669            0 :      ABI_FREE(intarr)
    2670            0 :      ABI_FREE(dprarr)
    2671            0 :      ABI_MALLOC(intarr,(marr))
    2672            0 :      ABI_MALLOC(dprarr,(marr))
    2673              :    end if
    2674          423 :    multibinit_dtset%conf_cutoff_disp(:)=zero
    2675              :    call intagm(dprarr,intarr,jdtset,marr,multibinit_dtset%natom,&
    2676           67 : &              string(1:lenstr),'conf_cutoff_disp',tread,'DPR')
    2677           67 :    if(tread==1)then
    2678            0 :      do ii=1,multibinit_dtset%natom
    2679            0 :        multibinit_dtset%conf_cutoff_disp(ii)=dprarr(ii)
    2680              :      end do
    2681              :    end if
    2682          423 :    if(any(multibinit_dtset%conf_cutoff_disp<zero))then
    2683              :      write(message, '(3a)' )&
    2684            0 : &       'There is negative value for conf_cutoff_disp ',ch10,&
    2685            0 : &       'Action: change acell in your input file.'
    2686            0 :      ABI_ERROR(message)
    2687              :    end if
    2688              :  end if
    2689              : 
    2690           73 :  if(6>marr)then
    2691            0 :    marr=6
    2692            0 :    ABI_FREE(intarr)
    2693            0 :    ABI_FREE(dprarr)
    2694            0 :    ABI_MALLOC(intarr,(marr))
    2695            0 :    ABI_MALLOC(dprarr,(marr))
    2696              :  end if
    2697          511 :  multibinit_dtset%conf_cutoff_strain(1:6) = zero
    2698           73 :  call intagm(dprarr,intarr,jdtset,marr,6,string(1:lenstr),'conf_cutoff_strain',tread,'DPR')
    2699           73 :  if(tread==1) multibinit_dtset%conf_cutoff_strain(1:6)=dprarr(1:6)
    2700          429 :  if(any(multibinit_dtset%conf_cutoff_disp<zero))then
    2701              :    write(message, '(3a)' )&
    2702            0 : &     'There is negative value for conf_cutoff_strain ',ch10,&
    2703            0 : &     'Action: change acell in your input file.'
    2704            0 :    ABI_ERROR(message)
    2705              :  end if
    2706              : 
    2707              : !D
    2708          292 :  multibinit_dtset%dipdip_range(:)= (/-375,-375,-375/)
    2709           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'dipdip_range',tread,'INT')
    2710           73 :  if(tread==1) multibinit_dtset%dipdip_range(1:3)=intarr(1:3)
    2711              : ! do ii=1,3
    2712              : !   if(multibinit_dtset%dipdip_range(ii)<0.or.multibinit_dtset%dipdip_range(ii)>50)then
    2713              : !     write(message, '(a,i0,a,i0,4a,i0,a)' )&
    2714              : !&     'dipdip_range(',ii,') is ',multibinit_dtset%dipdip_range(ii),', which is lower',&
    2715              : !&     ' than 0 of superior than 50.',&
    2716              : !&     ch10,'Action: correct dipdip_range(',ii,') in your input file.'
    2717              : !     ABI_ERROR(message)
    2718              : !   end if
    2719              : ! end do
    2720              : 
    2721          292 : if(any(multibinit_dtset%dipdip_range /=-375)) then
    2722            0 :   ABI_ERROR("The use of the keyword dipdip_range has been deprecated. Please remove it from the input file!")
    2723              : end if
    2724          292 : multibinit_dtset%dipdip_range(:)=[0,0,0]
    2725              : 
    2726              : 
    2727              : 
    2728              : 
    2729              : !E
    2730           73 :  multibinit_dtset%eivec=0
    2731           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'eivec',tread,'INT')
    2732           73 :  if(tread==1) multibinit_dtset%eivec=intarr(1)
    2733           73 :  if(multibinit_dtset%eivec<0.or.multibinit_dtset%eivec>4)then
    2734              :    write(message, '(a,i0,a,a,a,a,a)' )&
    2735            0 : &   'eivec is',multibinit_dtset%eivec,', but the only allowed values',ch10,&
    2736            0 : &   'are 0, 1, 2, 3 or 4.',ch10,&
    2737            0 : &   'Action: correct eivec in your input file.'
    2738            0 :    ABI_ERROR(message)
    2739              :  end if
    2740              : 
    2741              : 
    2742              : 
    2743              : !F
    2744           73 :   multibinit_dtset%fit_anhaStrain=0
    2745           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_anhaStrain',tread,'INT')
    2746           73 :  if(tread==1) multibinit_dtset%fit_anhaStrain=intarr(1)
    2747              :  if(multibinit_dtset%fit_anhaStrain<0.and.multibinit_dtset%fit_anhaStrain>1)then
    2748              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2749              : &   'fit_anhaStrain is',multibinit_dtset%fit_anhaStrain,', but the only allowed values',ch10,&
    2750              : &   'are 0 or 1 for multibinit.',ch10,&
    2751              : &   'Action: correct fit_anhaStrain in your input file.'
    2752              :    ABI_ERROR(message)
    2753              :  end if
    2754              : 
    2755           73 :  multibinit_dtset%bound_model=0
    2756           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bound_model',tread,'INT')
    2757           73 :  if(tread==1) multibinit_dtset%bound_model=intarr(1)
    2758              :  if(multibinit_dtset%bound_model<0.and.multibinit_dtset%bound_model>3)then
    2759              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2760              : &   'bound_model is',multibinit_dtset%bound_model,', but the only allowed values',ch10,&
    2761              : &   'are between 0 and 3 for multibinit.',ch10,&
    2762              : &   'Action: correct bound_model in your input file.'
    2763              :    ABI_ERROR(message)
    2764              :  end if
    2765              : 
    2766           73 :  multibinit_dtset%bound_penalty=1.001d+0
    2767           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bound_penalty',tread,'DPR')
    2768           73 :  if(tread==1) multibinit_dtset%bound_penalty=dprarr(1)
    2769           73 :  if(multibinit_dtset%bound_penalty<1)then
    2770              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2771            0 : &   'bound_penalty is',multibinit_dtset%bound_penalty,', but the only allowed values',ch10,&
    2772            0 : &   'are between larger than 1.',ch10,&
    2773            0 : &   'Action: correct bound_penalty in your input file.'
    2774            0 :    ABI_ERROR(message)
    2775              :  end if
    2776           73 :  multibinit_dtset%bound_anhaStrain=0
    2777           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_anhaStrain',tread,'INT')
    2778           73 :  if(tread==1) multibinit_dtset%bound_anhaStrain=intarr(1)
    2779              :  if(multibinit_dtset%bound_anhaStrain<0.and.multibinit_dtset%bound_anhaStrain>1)then
    2780              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2781              : &   'fit_anhaStrain is',multibinit_dtset%bound_anhaStrain,', but the only allowed values',ch10,&
    2782              : &   'are 0 or 1 for multibinit.',ch10,&
    2783              : &   'Action: correct fit_anhaStrain in your input file.'
    2784              :    ABI_ERROR(message)
    2785              :  end if
    2786              : 
    2787           73 :  multibinit_dtset%bound_SPCoupling=1
    2788           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bound_SPCoupling',tread,'INT')
    2789           73 :  if(tread==1) multibinit_dtset%bound_SPCoupling=intarr(1)
    2790              :  if(multibinit_dtset%bound_SPCoupling<0.and.multibinit_dtset%bound_SPCoupling>1)then
    2791              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2792              :      &   'bound_SPCoupling is',multibinit_dtset%bound_SPCoupling,&
    2793              :      &   ', but the only allowed values',ch10,&
    2794              : &   'are 0 or 1 for multibinit.',ch10,&
    2795              : &   'Action: correct bound_SPCoupling in your input file.'
    2796              :    ABI_ERROR(message)
    2797              :  end if
    2798              : 
    2799           73 :  multibinit_dtset%fit_dispterms=1
    2800           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_dispterms',tread,'INT')
    2801           73 :  if(tread==1) multibinit_dtset%fit_dispterms=intarr(1)
    2802              :  if(multibinit_dtset%fit_dispterms<0.and.multibinit_dtset%fit_dispterms>1)then
    2803              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2804              :      &   'fit_dispterms is',multibinit_dtset%fit_dispterms,&
    2805              :      &   ', but the only allowed values',ch10,&
    2806              : &   'are 0 or 1 for multibinit.',ch10,&
    2807              : &   'Action: correct fit_dispterms in your input file.'
    2808              :    ABI_ERROR(message)
    2809              :  end if
    2810              : 
    2811           73 :  multibinit_dtset%fit_SPCoupling=1
    2812           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_SPCoupling',tread,'INT')
    2813           73 :  if(tread==1) multibinit_dtset%fit_SPCoupling=intarr(1)
    2814              :  if(multibinit_dtset%fit_SPCoupling<0.and.multibinit_dtset%fit_SPCoupling>1)then
    2815              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2816              :      &   'fit_SPCoupling is',multibinit_dtset%fit_SPCoupling,&
    2817              :      &   ', but the only allowed values',ch10,&
    2818              : &   'are 0 or 1 for multibinit.',ch10,&
    2819              : &   'Action: correct fit_SPCoupling in your input file.'
    2820              :    ABI_ERROR(message)
    2821              :  end if
    2822              : 
    2823           73 :  multibinit_dtset%fit_SPC_maxS=1
    2824           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_SPC_maxS',tread,'INT')
    2825           73 :  if(tread==1) multibinit_dtset%fit_SPC_maxS=intarr(1)
    2826           73 :  if(multibinit_dtset%fit_SPC_maxS<1)then
    2827              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2828            0 :      &   'fit_SPC_maxS is',multibinit_dtset%fit_SPC_maxS,&
    2829            0 :      &   ', but the only allowed values',ch10,&
    2830            0 : &   'are positiv.',ch10,&
    2831            0 : &   'Action: correct fit_SPC_maxS in your input file.'
    2832            0 :    ABI_ERROR(message)
    2833              :  end if
    2834              : 
    2835           73 :  multibinit_dtset%bound_cutoff=0
    2836           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bound_cutoff',tread,'DPR')
    2837           73 :  if(tread==1) multibinit_dtset%bound_cutoff=dprarr(1)
    2838           73 :  if(multibinit_dtset%bound_cutoff<0)then
    2839              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2840            0 : &   'bound_cutoff is',multibinit_dtset%bound_cutoff,', but the only allowed values',ch10,&
    2841            0 : &   'are positives for multibinit.',ch10,&
    2842            0 : &   'Action: correct bound_cutoff in your input file.'
    2843            0 :    ABI_ERROR(message)
    2844              :  end if
    2845              : 
    2846              : 
    2847           73 :   multibinit_dtset%bound_maxCoeff=4
    2848           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bound_maxCoeff',tread,'INT')
    2849           73 :  if(tread==1) multibinit_dtset%bound_maxCoeff=intarr(1)
    2850              :  if(multibinit_dtset%bound_maxCoeff<0.and.multibinit_dtset%bound_maxCoeff>1)then
    2851              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2852              : &   'bound_maxCoeff is',multibinit_dtset%bound_maxCoeff,', but the only allowed values',ch10,&
    2853              : &   'are 0 or 1 for multibinit.',ch10,&
    2854              : &   'Action: correct bound_maxCoeff in your input file.'
    2855              :    ABI_ERROR(message)
    2856              :  end if
    2857              : 
    2858           73 :   multibinit_dtset%bound_option=1
    2859           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bound_option',tread,'INT')
    2860           73 :  if(tread==1) multibinit_dtset%bound_option=intarr(1)
    2861              :  if(multibinit_dtset%bound_option<1.and.multibinit_dtset%bound_option>3)then
    2862              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2863              : &   'bound_option is',multibinit_dtset%bound_option,', but the only allowed values',ch10,&
    2864              : &   'are 1,2,3 for multibinit.',ch10,&
    2865              : &   'Action: correct bound_option in your input file.'
    2866              :    ABI_ERROR(message)
    2867              :  end if
    2868              : 
    2869              : 
    2870              : 
    2871           73 :   multibinit_dtset%bound_temp=325
    2872           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bound_temp',tread,'DPR')
    2873           73 :  if(tread==1) multibinit_dtset%bound_temp=dprarr(1)
    2874           73 :  if(multibinit_dtset%bound_temp<=0)then
    2875              :    write(message, '(a,f10.1,a,a,a,a,a)' )&
    2876            0 : &   'Bound_Temp is ',multibinit_dtset%bound_temp,'. The only allowed values',ch10,&
    2877            0 : &   'are positives values.',ch10,&
    2878            0 : &   'Action: correct Bound_Temp in your input file.'
    2879            0 :    ABI_ERROR(message)
    2880              :  end if
    2881           73 :  multibinit_dtset%bound_step=1000
    2882           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'bound_step',tread,'INT')
    2883           73 :  if(tread==1) multibinit_dtset%bound_step=intarr(1)
    2884              :  if(multibinit_dtset%bound_step<0.and.multibinit_dtset%bound_step>1)then
    2885              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2886              : &   'bound_step is',multibinit_dtset%bound_step,', but the only allowed values',ch10,&
    2887              : &   'are 0 or 1 for multibinit.',ch10,&
    2888              : &   'Action: correct bound_step in your input file.'
    2889              :    ABI_ERROR(message)
    2890              :  end if
    2891              : 
    2892           73 :  multibinit_dtset%fit_coeff=0
    2893           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_coeff',tread,'INT')
    2894           73 :  if(tread==1) multibinit_dtset%fit_coeff=intarr(1)
    2895              :  if(multibinit_dtset%fit_coeff<0.and.multibinit_dtset%fit_coeff>1)then
    2896              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2897              : &   'fit_coeff is',multibinit_dtset%fit_coeff,', but the only allowed values',ch10,&
    2898              : &   'are 0 or 1 for multibinit.',ch10,&
    2899              : &   'Action: correct fit_coeff in your input file.'
    2900              :    ABI_ERROR(message)
    2901              :  end if
    2902              : 
    2903              : 
    2904           73 :  multibinit_dtset%fit_cutoff=0
    2905           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_cutoff',tread,'DPR')
    2906           73 :  if(tread==1) multibinit_dtset%fit_cutoff=dprarr(1)
    2907           73 :  if(multibinit_dtset%fit_cutoff<0)then
    2908              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2909            0 : &   'fit_cutoff is',multibinit_dtset%fit_cutoff,', but the only allowed values',ch10,&
    2910            0 : &   'are positives for multibinit.',ch10,&
    2911            0 : &   'Action: correct fit_cutoff in your input file.'
    2912            0 :    ABI_ERROR(message)
    2913              :  end if
    2914              : 
    2915              :  !multibinit_dtset%fit_drop_rate=0.0_dp
    2916              :  !call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_drop_rate',tread,'DPR')
    2917              :  !if(tread==1) multibinit_dtset%fit_drop_rate=dprarr(1)
    2918              :  !if(multibinit_dtset%fit_drop_rate<0.or.multibinit_dtset%fit_drop_rate>1.0)then
    2919              :  !  write(message, '(a,i0,a,a,a,a)' )&
    2920              :  !    &     'fit_drop_rate is ',multibinit_dtset%fit_drop_rate,', which is lower',&
    2921              :  !    &     ' than 0 of superior than 1.',&
    2922              :  !    &     ch10,'Action: correct fit_drop_rate in your input file.'
    2923              :  !  ABI_ERROR(message)
    2924              :  !end if
    2925              : 
    2926              : 
    2927              : 
    2928              : 
    2929          292 :  multibinit_dtset%fit_grid(:)= 1
    2930           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'fit_grid',tread,'INT')
    2931           73 :  if(tread==1) multibinit_dtset%fit_grid(1:3)=intarr(1:3)
    2932          292 :  do ii=1,3
    2933          292 :    if(multibinit_dtset%fit_grid(ii)<0.or.multibinit_dtset%fit_grid(ii)>20)then
    2934              :      write(message, '(a,i0,a,i0,a,a,a,i0,a)' )&
    2935            0 : &     'fit_grid(',ii,') is ',multibinit_dtset%fit_grid(ii),', which is lower',&
    2936            0 : &     ' than 0 of superior than 20.',&
    2937            0 : &     ch10,'Action: correct fit_grid(',ii,') in your input file.'
    2938            0 :      ABI_ERROR(message)
    2939              :    end if
    2940              :  end do
    2941              : 
    2942              : ! multibinit_dtset%fit_min_bound_coeff=0.0_dp
    2943              : ! call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_min_bound_coeff',tread,'DPR')
    2944              : ! if(tread==1) multibinit_dtset%fit_min_bound_coeff=dprarr(1)
    2945              : !
    2946              : 
    2947              : 
    2948              : 
    2949          219 :  multibinit_dtset%fit_rangePower(:)= (/3,4/)
    2950           73 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'fit_rangePower',tread,'INT')
    2951          109 :  if(tread==1) multibinit_dtset%fit_rangePower(1:2)=intarr(1:2)
    2952          219 :  do ii=1,2
    2953          219 :    if(multibinit_dtset%fit_rangePower(ii)<0.or.multibinit_dtset%fit_rangePower(ii)>20)then
    2954              :      write(message, '(a,i0,a,i0,a,a,a,i0,a)' )&
    2955            0 : &     'fit_rangePower(',ii,') is ',multibinit_dtset%fit_rangePower(ii),', which is lower',&
    2956            0 : &     ' than 0 of superior than 20.',&
    2957            0 : &     ch10,'Action: correct fit_rangePower(',ii,') in your input file.'
    2958            0 :      ABI_ERROR(message)
    2959              :    end if
    2960              :  end do
    2961              : 
    2962          219 :  multibinit_dtset%bound_rangePower(:)= (/6,6/)
    2963           73 :  call intagm(dprarr,intarr,jdtset,marr,2,string(1:lenstr),'bound_rangePower',tread,'INT')
    2964           75 :  if(tread==1) multibinit_dtset%bound_rangePower(1:2)=intarr(1:2)
    2965          219 :  do ii=1,2
    2966          219 :    if(multibinit_dtset%bound_rangePower(ii)<=0.or.multibinit_dtset%bound_rangePower(ii)>20)then
    2967              :      write(message, '(a,i0,a,i0,a,a,a,i0,a)' )&
    2968            0 : &     'bound_rangePower(',ii,') is ',multibinit_dtset%bound_rangePower(ii),', which is lower',&
    2969            0 : &     ' than 0 of superior than 20.',&
    2970            0 : &     ch10,'Action: correct bound_rangePower(',ii,') in your input file.'
    2971            0 :      ABI_ERROR(message)
    2972              :    end if
    2973              :  end do
    2974              : 
    2975          292 :   multibinit_dtset%bound_cell(:)= (/6,6,6/)
    2976           73 :  call intagm(dprarr,intarr,jdtset,marr,3,string(1:lenstr),'bound_cell',tread,'INT')
    2977           73 :  if(tread==1) multibinit_dtset%bound_cell(1:3)=intarr(1:3)
    2978          292 :  do ii=1,3
    2979          292 :    if(multibinit_dtset%bound_cell(ii)<=0.or.multibinit_dtset%bound_cell(ii)>20)then
    2980              :      write(message, '(a,i0,a,i0,4a,i0,a)' )&
    2981            0 : &     'bound_cell(',ii,') is ',multibinit_dtset%bound_cell(ii),', which is lower',&
    2982            0 : &     ' than 0 of superior than 20.',&
    2983            0 : &     ch10,'Action: correct bound_cell(',ii,') in your input file.'
    2984            0 :      ABI_ERROR(message)
    2985              :    end if
    2986              :  end do
    2987              : 
    2988           73 :  multibinit_dtset%fit_tolMSDE=0
    2989           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_tolMSDE',tread,'DPR')
    2990           73 :  if(tread==1) multibinit_dtset%fit_tolMSDE=dprarr(1)
    2991           73 :  if(multibinit_dtset%fit_tolMSDE<0)then
    2992              :    write(message, '(a,i8,a,a,a,a,a)' )&
    2993            0 : &   'fit_tolMSDE is',multibinit_dtset%fit_tolMSDE,', but the only allowed values',ch10,&
    2994            0 : &   'are positives for multibinit.',ch10,&
    2995            0 : &   'Action: correct fit_tolMSDE in your input file.'
    2996            0 :    ABI_ERROR(message)
    2997              :  end if
    2998              : 
    2999           73 :  multibinit_dtset%fit_tolMSDF=0
    3000           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_tolMSDF',tread,'DPR')
    3001           73 :  if(tread==1) multibinit_dtset%fit_tolMSDF=dprarr(1)
    3002           73 :  if(multibinit_dtset%fit_tolMSDF<0)then
    3003              :    write(message, '(a,i8,a,a,a,a,a)' )&
    3004            0 : &   'fit_tolMSDF is',multibinit_dtset%fit_tolMSDF,', but the only allowed values',ch10,&
    3005            0 : &   'are positives for multibinit.',ch10,&
    3006            0 : &   'Action: correct fit_tolMSDF in your input file.'
    3007            0 :    ABI_ERROR(message)
    3008              :  end if
    3009              : 
    3010           73 :  multibinit_dtset%fit_tolMSDS=0
    3011           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_tolMSDS',tread,'DPR')
    3012           73 :  if(tread==1) multibinit_dtset%fit_tolMSDS=dprarr(1)
    3013           73 :  if(multibinit_dtset%fit_tolMSDS<0)then
    3014              :    write(message, '(a,i8,a,a,a,a,a)' )&
    3015            0 : &   'fit_tolMSDS is',multibinit_dtset%fit_tolMSDS,', but the only allowed values',ch10,&
    3016            0 : &   'are positives for multibinit.',ch10,&
    3017            0 : &   'Action: correct fit_tolMSDS in your input file.'
    3018            0 :    ABI_ERROR(message)
    3019              :  end if
    3020              : 
    3021           73 :  multibinit_dtset%fit_tolMSDFS=0
    3022           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_tolMSDFS',tread,'DPR')
    3023           73 :  if(tread==1) multibinit_dtset%fit_tolMSDFS=dprarr(1)
    3024           73 :  if(multibinit_dtset%fit_tolMSDFS<0)then
    3025              :    write(message, '(a,i8,a,a,a,a,a)' )&
    3026            0 : &   'fit_tolMSDFS is',multibinit_dtset%fit_tolMSDFS,', but the only allowed values',ch10,&
    3027            0 : &   'are positives for multibinit.',ch10,&
    3028            0 : &   'Action: correct fit_tolMSDFS in your input file.'
    3029            0 :    ABI_ERROR(message)
    3030              :  end if
    3031              : 
    3032           73 :  multibinit_dtset%fit_tolGF=0
    3033           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_tolGF',tread,'DPR')
    3034           73 :  if(tread==1) multibinit_dtset%fit_tolGF=dprarr(1)
    3035           73 :  if(multibinit_dtset%fit_tolGF<0)then
    3036              :    write(message, '(a,i8,a,a,a,a,a)' )&
    3037            0 : &   'fit_tolGF is',multibinit_dtset%fit_tolGF,', but the only allowed values',ch10,&
    3038            0 : &   'are positives for multibinit.',ch10,&
    3039            0 : &   'Action: correct fit_tolGF in your input file.'
    3040            0 :    ABI_ERROR(message)
    3041              :  end if
    3042              : 
    3043           73 :  multibinit_dtset%fit_weight_T=-0.1_dp
    3044           73 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'fit_weight_T',tread,'DPR')
    3045           73 :  if(tread==1) multibinit_dtset%fit_weight_T=dprarr(1)
    3046              : 
    3047              : 
    3048              : !G
    3049              : 
    3050              : !H
    3051              : 
    3052              : !I
    3053              : 
    3054              : 
    3055              : !J
    3056              : 
    3057              : !K
    3058              : 
    3059              : !L
    3060              : ! multibinit_dtset%latt_mask(:)=0
    3061              : ! call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'latt_mask',tread,'INT')
    3062              : ! if(tread==1) then
    3063              : !    do ii=1, 3
    3064              : !       multibinit_dtset%latt_mask(ii)=intarr(ii)
    3065              : !       if(multibinit_dtset%latt_mask(ii) <0 .or. multibinit_dtset%latt_mask(ii) >1)then
    3066              : !          write(message, '(a)' )&
    3067              : !               &   ' latt_mask element should be 0 or 1.'
    3068              : !          ABI_ERROR(message)
    3069              : !       end if
    3070              : !    end do
    3071              : ! end if
    3072              : 
    3073              : 
    3074              : !M
    3075              : !N
    3076              : 
    3077          219 :  ABI_MALLOC(multibinit_dtset%fit_bancoeff,(multibinit_dtset%fit_nbancoeff))
    3078           73 :  if (multibinit_dtset%fit_nbancoeff >0)then
    3079            0 :    if(multibinit_dtset%fit_nbancoeff>marr)then
    3080            0 :      marr=multibinit_dtset%fit_nbancoeff
    3081            0 :      ABI_FREE(intarr)
    3082            0 :      ABI_MALLOC(intarr,(marr))
    3083              :    end if
    3084            0 :    multibinit_dtset%fit_bancoeff(:)=0
    3085              :    call intagm(dprarr,intarr,jdtset,marr,multibinit_dtset%fit_nbancoeff,&
    3086            0 : &              string(1:lenstr),'fit_bancoeff',tread,'INT')
    3087            0 :    if(tread==1)then
    3088            0 :      do ii=1,multibinit_dtset%fit_nbancoeff
    3089            0 :        multibinit_dtset%fit_bancoeff(ii)=intarr(ii)
    3090              :      end do
    3091              :    end if
    3092              :  end if
    3093              : 
    3094          219 :  ABI_MALLOC(multibinit_dtset%fit_fixcoeff,(multibinit_dtset%fit_nfixcoeff))
    3095           73 :  if (multibinit_dtset%fit_nfixcoeff >0)then
    3096            7 :    if(multibinit_dtset%fit_nfixcoeff>marr)then
    3097            0 :      marr=multibinit_dtset%fit_nfixcoeff
    3098            0 :      ABI_FREE(intarr)
    3099            0 :      ABI_MALLOC(intarr,(marr))
    3100              :    end if
    3101           21 :    multibinit_dtset%fit_fixcoeff(:)=0
    3102              :    call intagm(dprarr,intarr,jdtset,marr,multibinit_dtset%fit_nfixcoeff,&
    3103            7 : &              string(1:lenstr),'fit_fixcoeff',tread,'INT')
    3104            7 :    if(tread==1)then
    3105           21 :      do ii=1,multibinit_dtset%fit_nfixcoeff
    3106           21 :        multibinit_dtset%fit_fixcoeff(ii)=intarr(ii)
    3107              :      end do
    3108              :    end if
    3109              :  end if
    3110              : 
    3111          219 :  ABI_MALLOC(multibinit_dtset%fit_imposecoeff,(multibinit_dtset%fit_nimposecoeff))
    3112           73 :  if (multibinit_dtset%fit_nimposecoeff >0)then
    3113            0 :    if(multibinit_dtset%fit_nimposecoeff>marr)then
    3114            0 :      marr=multibinit_dtset%fit_nimposecoeff
    3115            0 :      ABI_FREE(intarr)
    3116            0 :      ABI_MALLOC(intarr,(marr))
    3117              :    end if
    3118            0 :    multibinit_dtset%fit_imposecoeff(:)=0
    3119              :    call intagm(dprarr,intarr,jdtset,marr,multibinit_dtset%fit_nimposecoeff,&
    3120            0 : &              string(1:lenstr),'fit_imposecoeff',tread,'INT')
    3121            0 :    if(tread==1)then
    3122            0 :      do ii=1,multibinit_dtset%fit_nimposecoeff
    3123            0 :        multibinit_dtset%fit_imposecoeff(ii)=intarr(ii)
    3124              :      end do
    3125              :    end if
    3126              :  end if
    3127              : 
    3128              : !O
    3129              :  block
    3130              :    integer :: minv, maxv, n
    3131           73 :    minv =multibinit_dtset%fit_rangepower(1)
    3132           73 :    maxv =multibinit_dtset%fit_rangepower(2)
    3133           73 :    n=maxv-minv+1
    3134              :  call read_int_array_var(int_array_var=multibinit_dtset%fit_max_nbody_inrange, &
    3135              :    & size=n, &
    3136           73 :    & var_name='fit_max_nbody', type='INT', default=999)
    3137          219 :  ABI_MALLOC(multibinit_dtset%fit_max_nbody, (maxv))
    3138          348 :  multibinit_dtset%fit_max_nbody(:)=999
    3139          202 :  multibinit_dtset%fit_max_nbody(minv:maxv) = multibinit_dtset%fit_max_nbody_inrange
    3140              : 
    3141              : 
    3142              : end block
    3143              : 
    3144              : 
    3145          219 :  ABI_MALLOC(multibinit_dtset%opt_coeff,(multibinit_dtset%opt_ncoeff))
    3146           73 :  if (multibinit_dtset%opt_ncoeff >0)then
    3147            1 :    if(multibinit_dtset%opt_ncoeff>marr)then
    3148            0 :      marr=multibinit_dtset%opt_ncoeff
    3149            0 :      ABI_FREE(intarr)
    3150            0 :      ABI_MALLOC(intarr,(marr))
    3151              :    end if
    3152            3 :    multibinit_dtset%opt_coeff(:)=0
    3153              :    call intagm(dprarr,intarr,jdtset,marr,multibinit_dtset%opt_ncoeff,&
    3154            1 : &              string(1:lenstr),'opt_coeff',tread,'INT')
    3155            1 :    if(tread==1)then
    3156            3 :      do ii=1,multibinit_dtset%opt_ncoeff
    3157            3 :        multibinit_dtset%opt_coeff(ii)=intarr(ii)
    3158              :      end do
    3159              :    end if
    3160              :  end if
    3161              : 
    3162              : !P
    3163              : 
    3164              : !Q
    3165          219 :  ABI_MALLOC(multibinit_dtset%qmass,(multibinit_dtset%nnos))
    3166           73 :  multibinit_dtset%qmass(:)= zero
    3167           73 :  if(multibinit_dtset%nnos>=1)then
    3168            0 :    if(multibinit_dtset%nnos>marr)then
    3169            0 :      marr=multibinit_dtset%nnos
    3170            0 :      ABI_FREE(intarr)
    3171            0 :      ABI_FREE(dprarr)
    3172            0 :      ABI_MALLOC(intarr,(marr))
    3173            0 :      ABI_MALLOC(dprarr,(marr))
    3174              :    end if
    3175            0 :    call intagm(dprarr,intarr,jdtset,marr,multibinit_dtset%nnos,string(1:lenstr),'qmass',tread,'DPR')
    3176            0 :    if(tread==1) multibinit_dtset%qmass(:)=dprarr(1:multibinit_dtset%nnos)
    3177              :  end if
    3178              : 
    3179           73 :  if (multibinit_dtset%nqshft/=0)then
    3180           73 :    if(3*multibinit_dtset%nqshft>marr)then
    3181            0 :      marr=3*multibinit_dtset%nqshft
    3182            0 :      ABI_FREE(intarr)
    3183            0 :      ABI_FREE(dprarr)
    3184            0 :      ABI_MALLOC(intarr,(marr))
    3185            0 :      ABI_MALLOC(dprarr,(marr))
    3186              :    end if
    3187          219 :    ABI_MALLOC(multibinit_dtset%q1shft,(3,multibinit_dtset%nqshft))
    3188          365 :    multibinit_dtset%q1shft(:,:)=zero
    3189           73 :    call intagm(dprarr,intarr,jdtset,marr,3*multibinit_dtset%nqshft, string(1:lenstr),'q1shft',tread,'DPR')
    3190           73 :    if(tread==1) multibinit_dtset%q1shft(1:3,1:multibinit_dtset%nqshft)=&
    3191            0 : &   reshape(dprarr(1:3*multibinit_dtset%nqshft),(/3,multibinit_dtset%nqshft/))
    3192              :  end if
    3193              : 
    3194          219 :  ABI_MALLOC(multibinit_dtset%qph1l,(3,multibinit_dtset%nph1l))
    3195          219 :  ABI_MALLOC(multibinit_dtset%qnrml1,(multibinit_dtset%nph1l))
    3196           73 :  if (multibinit_dtset%nph1l/=0)then
    3197           73 :    if(4*multibinit_dtset%nph1l>marr)then
    3198            8 :      marr=4*multibinit_dtset%nph1l
    3199            8 :      ABI_FREE(intarr)
    3200            8 :      ABI_FREE(dprarr)
    3201           24 :      ABI_MALLOC(intarr,(marr))
    3202           24 :      ABI_MALLOC(dprarr,(marr))
    3203              :    end if
    3204          589 :    multibinit_dtset%qph1l(:,:)=zero
    3205          202 :    multibinit_dtset%qnrml1(:)=zero
    3206           73 :    call intagm(dprarr,intarr,jdtset,marr,4*multibinit_dtset%nph1l,string(1:lenstr),'qph1l',tread,'DPR')
    3207           73 :    if(tread==1)then
    3208           72 :      do iph1=1,multibinit_dtset%nph1l
    3209          256 :        do ii=1,3
    3210          256 :          multibinit_dtset%qph1l(ii,iph1)=dprarr(ii+(iph1-1)*4)
    3211              :        end do
    3212           64 :        multibinit_dtset%qnrml1(iph1)=dprarr(4+(iph1-1)*4)
    3213           72 :        if(abs(multibinit_dtset%qnrml1(iph1))<DDB_QTOL)then
    3214              :          write(message, '(a,a,a,a,a)' )&
    3215            0 : &         'The first list of wavevectors ','should not have non-analytical data.',ch10,&
    3216            0 : &         'Action: correct the first list',' of wavevectors in the input file.'
    3217            0 :          ABI_ERROR(message)
    3218              :        end if
    3219              :      end do
    3220              :    end if
    3221              :  end if
    3222              : 
    3223          219 :  ABI_MALLOC(multibinit_dtset%qph2l,(3,multibinit_dtset%nph2l))
    3224          219 :  ABI_MALLOC(multibinit_dtset%qnrml2,(multibinit_dtset%nph2l))
    3225           73 :  if (multibinit_dtset%nph2l/=0)then
    3226            0 :    if(4*multibinit_dtset%nph2l>marr)then
    3227            0 :      marr=4*multibinit_dtset%nph2l
    3228            0 :      ABI_FREE(intarr)
    3229            0 :      ABI_FREE(dprarr)
    3230            0 :      ABI_MALLOC(intarr,(marr))
    3231            0 :      ABI_MALLOC(dprarr,(marr))
    3232              :    end if
    3233            0 :    multibinit_dtset%qph2l(:,:)=zero
    3234            0 :    multibinit_dtset%qnrml2(:)=zero
    3235            0 :    call intagm(dprarr,intarr,jdtset,marr,4*multibinit_dtset%nph2l,string(1:lenstr),'qph2l',tread,'DPR')
    3236            0 :    if(tread==1)then
    3237            0 :      do iph2=1,multibinit_dtset%nph2l
    3238            0 :        do ii=1,3
    3239            0 :          multibinit_dtset%qph2l(ii,iph2)=dprarr(ii+(iph2-1)*4)
    3240              :        end do
    3241            0 :        multibinit_dtset%qnrml2(iph2)=dprarr(4+(iph2-1)*4)
    3242            0 :        if(abs(multibinit_dtset%qnrml2(iph2))>DDB_QTOL)then
    3243              :          write(message, '(a,a,a,a,a)' )&
    3244            0 : &         'The second list of wavevectors',' should have only non-analytical data.',ch10,&
    3245            0 : &         'Action: correct the second list','of wavevectors in the input file.'
    3246            0 :          ABI_ERROR(message)
    3247              :        end if
    3248              :      end do
    3249              :    end if
    3250              :  end if
    3251              : 
    3252              : !R
    3253           73 :  if(9>marr)then
    3254            0 :    marr=9
    3255            0 :    ABI_FREE(intarr)
    3256            0 :    ABI_FREE(dprarr)
    3257            0 :    ABI_MALLOC(intarr,(marr))
    3258            0 :    ABI_MALLOC(dprarr,(marr))
    3259              :  end if
    3260          949 :  multibinit_dtset%rprim(:,:)= zero
    3261           73 :  call intagm(dprarr,intarr,jdtset,marr,9,string(1:lenstr),'rprim',tread,'DPR')
    3262           73 :  if(tread==1) then
    3263            0 :    multibinit_dtset%rprim(1:3,1:3)= reshape(dprarr(1:9),(/3,3/))
    3264              : ! check new rprimd
    3265              :    if(all(abs(multibinit_dtset%rprim(1,:))<tol16).or.&
    3266            0 : &    all(abs(multibinit_dtset%rprim(2,:))<tol16).or.all(abs(multibinit_dtset%rprim(3,:))<tol16)) then
    3267              :      write(message, '(3a)' )&
    3268            0 : &  ' There is a problem with rprim',ch10,&
    3269            0 : &   'Action: correct rprim'
    3270            0 :      ABI_BUG(message)
    3271              :    end if
    3272              :  end if
    3273              : !S
    3274              : 
    3275           73 :  if(6>marr)then
    3276            0 :    marr=6
    3277            0 :    ABI_FREE(intarr)
    3278            0 :    ABI_FREE(dprarr)
    3279            0 :    ABI_MALLOC(intarr,(marr))
    3280            0 :    ABI_MALLOC(dprarr,(marr))
    3281              :  end if
    3282          511 :  multibinit_dtset%strten_reference(:)= zero
    3283           73 :  call intagm(dprarr,intarr,jdtset,marr,6,string(1:lenstr),'strten_reference',tread,'DPR')
    3284           73 :  if(tread==1) multibinit_dtset%strten_reference(1:6)= dprarr(1:6)
    3285              : 
    3286              : !T
    3287              : 
    3288              : !U
    3289              : 
    3290              : !V
    3291              : 
    3292              : !W
    3293              : 
    3294              : !X
    3295              : 
    3296              : !Y
    3297              : 
    3298              : !Z
    3299              : 
    3300              : !=======================================================================
    3301              : ! Read Geometric constraint variables for relaxation
    3302              : !=======================================================================
    3303              : 
    3304           73 :  natom_sc = natom*multibinit_dtset%ncell(1)*multibinit_dtset%ncell(2)*multibinit_dtset%ncell(3)
    3305          219 :  ABI_MALLOC(multibinit_dtset%iatfix,(3,natom_sc))
    3306        20865 :  multibinit_dtset%iatfix(:,:)=0
    3307              : 
    3308          365 :  do idir=0,3
    3309              : 
    3310          292 :    if(idir==0)then
    3311           73 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'natfix',tread,'INT')
    3312          219 :    else if(idir==1)then
    3313           73 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'natfixx',tread,'INT')
    3314          146 :    else if(idir==2)then
    3315           73 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'natfixy',tread,'INT')
    3316           73 :    else if(idir==3)then
    3317           73 :      call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'natfixz',tread,'INT')
    3318              :    end if
    3319              : 
    3320              : !  Use natfix also for natfixx,natfixy,natfixz
    3321          292 :    natfix=0
    3322          292 :    if(tread==1)then
    3323            4 :       natfix=intarr(1)
    3324            4 :       ABI_FREE(intarr)
    3325            4 :       ABI_FREE(dprarr)
    3326           12 :       ABI_MALLOC(intarr,(natfix))
    3327           12 :       ABI_MALLOC(dprarr,(natfix))
    3328            4 :       marr = natfix
    3329              :    endif
    3330              : 
    3331              : !  Checks the validity of natfix
    3332          292 :    if (natfix<0 .or. natfix>natom_sc) then
    3333              :      write(message, '(a,a,a,i0,a,i4,a,a,a)' )&
    3334            0 : &     'The input variables natfix, natfixx, natfixy and natfixz must be',ch10,&
    3335            0 : &     'between 0 and natom of the supercell (= ',natom_sc,'), while one of them is ',natfix,'.',ch10,&
    3336            0 : &     'Action: correct that occurence in your input file.'
    3337            0 :      ABI_ERROR(message)
    3338              :    end if
    3339              : 
    3340              : !  Read iatfix
    3341          292 :    if(idir==0)then
    3342           73 :      call intagm(dprarr,intarr,jdtset,marr,natfix,string(1:lenstr),'iatfix',tread,'INT')
    3343          219 :    else if(idir==1)then
    3344           73 :      call intagm(dprarr,intarr,jdtset,marr,natfix,string(1:lenstr),'iatfixx',tread,'INT')
    3345          146 :    else if(idir==2)then
    3346           73 :      call intagm(dprarr,intarr,jdtset,marr,natfix,string(1:lenstr),'iatfixy',tread,'INT')
    3347           73 :    else if(idir==3)then
    3348           73 :      call intagm(dprarr,intarr,jdtset,marr,natfix,string(1:lenstr),'iatfixz',tread,'INT')
    3349              :    end if
    3350              : 
    3351              : !  If some iatfix was read, natfix must vanish
    3352          292 :    if (natfix==0 .and. tread==1)then
    3353              :      write(message, '(a,i1,5a)' )&
    3354            0 : &     'For direction ',idir,' the corresponding natfix is zero,',ch10,&
    3355            0 : &     'while iatfix specifies some atoms to be fixed.',ch10,&
    3356            0 : &     'Action: either specify a non-zero natfix(x,y,z) or suppress iatfix(x,y,z).'
    3357            0 :      ABI_ERROR(message)
    3358              :    end if
    3359              : 
    3360              : !  If natfix is non-zero, iatfix must be defined
    3361          292 :    if (natfix>0 .and. tread==0)then
    3362              :      write(message, '(a,i1,3a,i0,3a)' )&
    3363            0 : &     'For direction ',idir,' no iatfix has been specified,',ch10,&
    3364            0 : &     'while natfix specifies that some atoms to be fixed, natfix= ',natfix,'.',ch10,&
    3365            0 : &     'Action: either set natfix(x,y,z) to zero or define iatfix(x,y,z).'
    3366            0 :      ABI_ERROR(message)
    3367              :    end if
    3368              : 
    3369          365 :    if(tread==1)then
    3370           11 :      do ii=1,natfix
    3371              : !      Checks the validity of the input iatfix
    3372            7 :        if (intarr(ii)<1 .or. intarr(ii)>natom_sc) then
    3373              :          write(message, '(a,a,a,i0,a,a,a)' )&
    3374            0 : &         'The input variables iatfix, iatfixx, iatfixy and iatfixz must be',ch10,&
    3375            0 : &         'between 1 and natom of the supercell, while one of them is ',intarr(ii),'.',ch10,&
    3376            0 : &         'Action: correct that occurence in your input file.'
    3377            0 :          ABI_ERROR(message)
    3378              :        end if
    3379              : !      Finally set the value of the internal iatfix array
    3380          151 :        do iatom=1,natom_sc
    3381          147 :          if(intarr(ii)==iatom)then
    3382           10 :            if(idir==0)multibinit_dtset%iatfix(1:3,iatom)=1
    3383            7 :            if(idir/=0)multibinit_dtset%iatfix(idir,iatom)=1
    3384              :          end if
    3385              :        end do
    3386              :      end do
    3387              :    end if
    3388              :  end do
    3389              : 
    3390              : !=======================================================================
    3391              : ! Read SCALE UP variables
    3392              : !=======================================================================
    3393              : 
    3394           73 : call invars10scup(multibinit_dtset%scup_dtset,lenstr,string)
    3395              : 
    3396              : !=======================================================================
    3397              : !Finished reading in variables - deallocate
    3398              : !=======================================================================
    3399              : 
    3400           73 :  ABI_FREE(dprarr)
    3401           73 :  ABI_FREE(intarr)
    3402              : 
    3403              : !=======================================================================
    3404              : !Check consistency of input variables:
    3405              : !=======================================================================
    3406              : 
    3407           73 :  if(multibinit_dtset%prtsrlr/=0 .and. multibinit_dtset%ifcflag/=1) then
    3408              :    write(message, '(3a)' )&
    3409            0 : &   'ifcflag must be 1 for the SR/LR decomposition of the phonon frequencies',ch10,&
    3410            0 : &   'Action: correct ifcflag in your input file.'
    3411            0 :    ABI_ERROR(message)
    3412              :  end if
    3413              : 
    3414              : !FIXME: add check that if freeze_displ /= 0 then you need to be doing ifc and phonon interpolation
    3415              : 
    3416          730 :  if (multibinit_dtset%ifcflag > 0 .and. sum(abs(multibinit_dtset%ngqpt)) == 0) then
    3417              :    write(message, '(3a)' )&
    3418            0 : &   'if you want interatomic force constant output, multibinit needs ngqpt input variable ',ch10,&
    3419            0 : &   'Action: set ngqpt in your input file.'
    3420            0 :    ABI_ERROR(message)
    3421              :  end if
    3422              : 
    3423              : !check that q-grid refinement is a divisor of ngqpt in each direction
    3424          584 :  if(any(multibinit_dtset%qrefine(:) > 1) .and. &
    3425              : &    any(abs(dmod(dble(multibinit_dtset%ngqpt(1:3))/dble(multibinit_dtset%qrefine(:)),one)) > tol10)) then
    3426              :    write(message, '(a,3i0,a,a,a,3i8,a,a)' )&
    3427            0 : &   'qrefine is',multibinit_dtset%qrefine,' The only allowed values',ch10,&
    3428            0 : &   'are integers which are divisors of the ngqpt grid', multibinit_dtset%ngqpt,ch10,&
    3429            0 : &   'Action: correct qrefine in your input file.'
    3430            0 :    ABI_ERROR(message)
    3431              :  end if
    3432              : 
    3433              : ! check new rprimd
    3434         1022 :  if(all(multibinit_dtset%acell(:) > one).and.all(abs(multibinit_dtset%rprim(:,:))<tol16))then
    3435              :    write(message, '(3a)' )&
    3436            0 : &         ' acell is defined but there is no rprim',ch10,&
    3437            0 : &         'Action: add rprim input'
    3438            0 :    ABI_BUG(message)
    3439              :  end if
    3440              : 
    3441              : 
    3442              : !check the fit_bancoeff and fit_fixcoeff and opt_coeff, fit_imposecoeff
    3443           73 :  do ii=1,multibinit_dtset%fit_nbancoeff
    3444           73 :    do jj=ii+1,multibinit_dtset%fit_nbancoeff
    3445            0 :      if (multibinit_dtset%fit_bancoeff(ii) == multibinit_dtset%fit_bancoeff(jj))then
    3446              :        write(message, '(a,I0,a,I0,2a)' )&
    3447            0 : &           ' There is two similar numbers for fit_bancoeff: ',multibinit_dtset%fit_bancoeff(ii),&
    3448            0 : &           ' and ', multibinit_dtset%fit_bancoeff(jj),ch10,&
    3449            0 : &            'Action: change fit_bancoeff'
    3450            0 :        ABI_BUG(message)
    3451              :      end if
    3452              :    end do
    3453              :  end do
    3454              : 
    3455           87 :  do ii=1,multibinit_dtset%fit_nfixcoeff
    3456           94 :    do jj=ii+1,multibinit_dtset%fit_nfixcoeff
    3457           21 :      if (multibinit_dtset%fit_fixcoeff(ii) == multibinit_dtset%fit_fixcoeff(jj))then
    3458              :        write(message, '(a,I0,a,I0,2a)' )&
    3459            0 : &           ' There is two similar numbers for fit_fixcoeff: ',multibinit_dtset%fit_fixcoeff(ii),&
    3460            0 : &           ' and ', multibinit_dtset%fit_fixcoeff(jj),ch10,&
    3461            0 : &            'Action: change fit_fixcoeff'
    3462            0 :        ABI_BUG(message)
    3463              :      end if
    3464              :    end do
    3465              :  end do
    3466              : 
    3467              : 
    3468           75 :  do ii=1,multibinit_dtset%opt_ncoeff
    3469           76 :    do jj=ii+1,multibinit_dtset%opt_ncoeff
    3470            3 :      if (multibinit_dtset%opt_coeff(ii) == multibinit_dtset%opt_coeff(jj))then
    3471              :        write(message, '(a,I0,a,I0,2a)' )&
    3472            0 : &           ' There is two similar numbers for opt_coeff: ',multibinit_dtset%opt_coeff(ii),&
    3473            0 : &           ' and ', multibinit_dtset%opt_coeff(jj),ch10,&
    3474            0 : &            'Action: change opt_coeff'
    3475            0 :        ABI_BUG(message)
    3476              :      end if
    3477              :    end do
    3478              :  end do
    3479              : 
    3480           73 :  do ii=1,multibinit_dtset%fit_nimposecoeff
    3481           73 :    do jj=ii+1,multibinit_dtset%fit_nimposecoeff
    3482            0 :      if (multibinit_dtset%fit_imposecoeff(ii) == multibinit_dtset%fit_imposecoeff(jj))then
    3483              :        write(message, '(a,I0,a,I0,2a)' )&
    3484            0 : &           ' There is two similar numbers for fit_imposecoeff: ',multibinit_dtset%fit_imposecoeff(ii),&
    3485            0 : &           ' and ', multibinit_dtset%fit_imposecoeff(jj),ch10,&
    3486            0 : &            'Action: change fit_imposecoeff'
    3487            0 :        ABI_BUG(message)
    3488              :      end if
    3489              :    end do
    3490              :  end do
    3491              : 
    3492          292 :  multibinit_dtset%dipdip_range=0
    3493          292 :  do ii=1,3
    3494          292 :    if(multibinit_dtset%dipdip_range(ii) < multibinit_dtset%ncell(ii)) then
    3495          219 :      write(message,'(4a,3I3,3a,3I3,6a)') ch10,&
    3496          219 : &                 ' --- !WARNING',ch10,&
    3497          219 : &                 '     The range of dipdip_range (',multibinit_dtset%dipdip_range(:),')',ch10,&
    3498          219 : &                 '     But the range of the cell for the simulation is',&
    3499          219 : &                       multibinit_dtset%ncell(:),')',ch10,&
    3500          219 : &                 '     dipdip_range is set to ncell.',ch10,&
    3501          438 : &                 ' ---',ch10
    3502          219 :     multibinit_dtset%dipdip_range(ii) =  multibinit_dtset%ncell(ii)
    3503          219 :      call wrtout(std_out,message,'COLL')
    3504              :    end if
    3505              : !   if(multibinit_dtset%dipdip_range(ii) < multibinit_dtset%bound_cell(ii)) then
    3506              : !     write(message,'(4a,3I3,3a,3I3,6a)') ch10,&
    3507              : !&                 ' --- !WARNING',ch10,&
    3508              : !&                 '     The range of dipdip_range (',multibinit_dtset%dipdip_range(:),')',ch10,&
    3509              : !&                 '     But the range of the cell for the simulation is',&
    3510              : !&                       multibinit_dtset%ncell(:),')',ch10,&
    3511              : !&                 '     dipdip_range is set to bound_cell.',ch10,&
    3512              : !&                 ' ---',ch10
    3513              : !     multibinit_dtset%dipdip_range(:) =  multibinit_dtset%ncell(:)
    3514              : !     call wrtout(std_out,message,'COLL')
    3515              : !     exit
    3516              : !   end if
    3517              :  end do
    3518              : 
    3519              : !Check if only one tolerance is specify
    3520           73 :  if(abs(multibinit_dtset%fit_tolMSDF) >zero .and. abs(multibinit_dtset%fit_tolMSDS) >zero) then
    3521              :    write(message, '(3a)' ) &
    3522            0 : &           ' There is two tolerance flags for the fit: fit_tolMSDF and fit_tolMSDS',ch10,&
    3523            0 : &            'Action: Put only one tolerance flag'
    3524            0 :    ABI_BUG(message)
    3525              :  end if
    3526           73 :  if(abs(multibinit_dtset%fit_tolMSDF) >zero .and. abs(multibinit_dtset%fit_tolMSDE) >zero)then
    3527              :    write(message, '(3a)' ) &
    3528            0 : &           ' There is two tolerance flags for the fit: fit_tolMSDF and fit_tolMSDE',ch10,&
    3529            0 : &            'Action: Put only one tolerance flag'
    3530            0 :    ABI_BUG(message)
    3531              :  end if
    3532           73 :  if(abs(multibinit_dtset%fit_tolMSDF) >zero .and. abs(multibinit_dtset%fit_tolMSDFS) >zero)then
    3533              :    write(message, '(3a)' ) &
    3534            0 : &           ' There is two tolerance flags for the fit: fit_tolMSDF and fit_tolMSDFS',ch10,&
    3535            0 : &            'Action: Put only one tolerance flag'
    3536            0 :    ABI_BUG(message)
    3537              :  end if
    3538           73 :  if(abs(multibinit_dtset%fit_tolMSDS) >zero .and. abs(multibinit_dtset%fit_tolMSDE) >zero)then
    3539              :    write(message, '(3a)' ) &
    3540            0 : &           ' There is two tolerance flags for the fit: fit_tolMSDS and fit_tolMSDE',ch10,&
    3541            0 : &            'Action: Put only one tolerance flag'
    3542            0 :    ABI_BUG(message)
    3543              :  end if
    3544           73 :  if(abs(multibinit_dtset%fit_tolMSDS) >zero .and. abs(multibinit_dtset%fit_tolMSDFS) >zero)then
    3545              :    write(message, '(3a)' ) &
    3546            0 : &           ' There is two tolerance flags for the fit: fit_tolMSDS and fit_tolMSDFS',ch10,&
    3547            0 : &            'Action: Put only one tolerance flag'
    3548            0 :    ABI_BUG(message)
    3549              :  end if
    3550           73 :  if(abs(multibinit_dtset%fit_tolMSDE) >zero .and. abs(multibinit_dtset%fit_tolMSDFS) >zero)then
    3551              :    write(message, '(3a)' ) &
    3552            0 : &           ' There is two tolerance flags for the fit: fit_tolMSDE and fit_tolMSDFS',ch10,&
    3553            0 : &            'Action: Put only one tolerance flag'
    3554            0 :    ABI_BUG(message)
    3555              :  end if
    3556              : 
    3557              : contains
    3558            1 :   subroutine read_int_var(int_var, var_name)
    3559              :   ! Read an integer variable from the input
    3560              :     integer, intent(inout) :: int_var
    3561              :     character(*), intent(in) :: var_name
    3562            1 :     call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),var_name,tread,'INT')
    3563            1 :     if(tread==1) int_var=intarr(1)
    3564            1 :   end subroutine read_int_var
    3565              : 
    3566           73 :   subroutine read_int_array_var(int_array_var, size, var_name, type, default)
    3567              :   ! Read an integer array variable from the input
    3568              :     integer, allocatable, intent(inout) :: int_array_var(:)
    3569              :     integer, intent(in) :: size, default
    3570              :     character(*), intent(in) :: var_name, type
    3571          219 :     ABI_MALLOC(int_array_var,(size))
    3572           73 :     if (size >0)then
    3573           73 :       if(size>marr)then
    3574            0 :         marr=size
    3575            0 :         ABI_FREE(intarr)
    3576            0 :         ABI_MALLOC(intarr,(marr))
    3577              :       end if
    3578          202 :       int_array_var(:)=default
    3579              :       call intagm(dprarr,intarr,jdtset,marr,size,&
    3580           73 :         &              string(1:lenstr),var_name,tread, type)
    3581           73 :       if(tread==1)then
    3582            2 :         do ii=1,size
    3583            2 :           int_array_var(ii)=intarr(ii)
    3584              :         end do
    3585              :       end if
    3586              :     end if
    3587           73 :   end subroutine read_int_array_var
    3588              : 
    3589          219 :   subroutine read_dpr_array_var(dpr_array_var, size, var_name, type, default)
    3590              :   ! Read a double precision real array variable from the input
    3591              :     real(dp), allocatable, intent(inout) :: dpr_array_var(:)
    3592              :     integer, intent(in) :: size
    3593              :     real(dp), intent(in) :: default
    3594              :     character(*), intent(in) :: var_name, type
    3595          657 :     ABI_MALLOC(dpr_array_var,(size))
    3596          219 :     if (size >0)then
    3597           18 :       if(size>marr)then
    3598            0 :         marr=size
    3599            0 :         ABI_FREE(intarr)
    3600            0 :         ABI_FREE(dprarr)
    3601            0 :         ABI_MALLOC(intarr,(marr))
    3602            0 :         ABI_MALLOC(dprarr,(marr))
    3603              :       end if
    3604           67 :       dpr_array_var(:)=default
    3605              :       call intagm(dprarr,intarr,jdtset,marr,size,&
    3606           18 : &              string(1:lenstr),var_name,tread, type)
    3607           18 :       if(tread==1)then
    3608           51 :         do ii=1,size
    3609           51 :           dpr_array_var(ii)=dprarr(ii)
    3610              :         end do
    3611              :       end if
    3612              :     end if
    3613          219 :   end subroutine read_dpr_array_var
    3614              : 
    3615              : end subroutine invars10
    3616              : !!***
    3617              : 
    3618              : 
    3619              : 
    3620              : !----------------------------------------------------------------------
    3621              : 
    3622              : !!****f* m_multibinit_dataset/outvars_multibinit
    3623              : !!
    3624              : !! NAME
    3625              : !! outvars_multibinit
    3626              : !!
    3627              : !! FUNCTION
    3628              : !! Takes as an input the input dtset for multibinit and echoes it to
    3629              : !! the output
    3630              : !!
    3631              : !! INPUTS
    3632              : !! multibinit_dtset <type(multibinit_dtset_type)> datatype with all the input variables
    3633              : !! nunit=unit number for input or output
    3634              : !!
    3635              : !! OUTPUT
    3636              : !!  (only writing)
    3637              : !!
    3638              : !! NOTES
    3639              : !! Should be executed by one processor only.
    3640              : !!
    3641              : !! SOURCE
    3642              : 
    3643           98 : subroutine outvars_multibinit (multibinit_dtset,nunit)
    3644              : 
    3645              : !Arguments -------------------------------
    3646              : !scalars
    3647              :  integer,intent(in) :: nunit
    3648              :  type(multibinit_dtset_type),intent(in) :: multibinit_dtset
    3649              : 
    3650              : !Local variables -------------------------
    3651              : !Set routine version number here:
    3652              : !scalars
    3653              :  integer :: ii,iph1,iph2,iqshft,natfix
    3654              :  integer :: n
    3655              : 
    3656              : !*********************************************************************
    3657              : 
    3658              : !Write the heading
    3659         7938 :  write(nunit,'(a,80a,a)') ch10,('=',ii=1,80),ch10
    3660              :  write(nunit, '(a,a)' )&
    3661           98 : & ' -outvars_multibinit: echo values of input variables ----------------------',ch10
    3662              : 
    3663              : !The flags
    3664           98 :  if(multibinit_dtset%ifcflag/=0)then
    3665           98 :    write(nunit,'(a)')' Flags : '
    3666           98 :    if(multibinit_dtset%ifcflag/=0)write(nunit,'(3x,a9,3i10)')'  ifcflag',multibinit_dtset%ifcflag
    3667           98 :    if(multibinit_dtset%prt_model/=0)write(nunit,'(3x,a9,3i10)')'prt_model',multibinit_dtset%prt_model
    3668           98 :    if(multibinit_dtset%prt_phfrq/=0)write(nunit,'(3x,a9,3i10)')'prt_phfrq',multibinit_dtset%prt_phfrq
    3669           98 :    if(multibinit_dtset%strcpling/=0)write(nunit,'(3x,a9,3i10)')'  strcpling',multibinit_dtset%strcpling
    3670           98 :    if(multibinit_dtset%strcpling==2)write(nunit,'(3x,a9,3es8.2)')'delta_df',multibinit_dtset%delta_df
    3671              :  end if
    3672              : 
    3673           98 :  if(multibinit_dtset%dynamics/=0)then
    3674           66 :    write(nunit,'(a)')' Molecular Dynamics :'
    3675           66 :    write(nunit,'(3x,a9,3I10.1)')' dynamics',multibinit_dtset%dynamics
    3676           66 :    write(nunit,'(3x,a9,3I10.1)')' dyn_chksym',multibinit_dtset%dyn_chksym
    3677           66 :    write(nunit,'(3x,a9,3F10.1)')'     temp',multibinit_dtset%temperature
    3678           66 :    write(nunit,'(3x,a9,3I10.1)')'    ntime',multibinit_dtset%ntime
    3679           66 :    if (multibinit_dtset%nctime /=1)then
    3680           10 :      write(nunit,'(3x,a9,3I10.1)')'   nctime',multibinit_dtset%nctime
    3681              :    end if
    3682           66 :    write(nunit,'(3x,a9,3i10)')  '    ncell',multibinit_dtset%ncell
    3683           66 :    write(nunit,'(3x,a9,3i10)')  '    dtion',multibinit_dtset%dtion
    3684           66 :    if (multibinit_dtset%restartxf/=0) then
    3685           18 :      write(nunit,'(3x,a9,3i10)')  'restartxf',multibinit_dtset%restartxf
    3686              :    end if
    3687           66 :    if(multibinit_dtset%dynamics==13)then
    3688           32 :      write(nunit,'(3x,a9,3i10)')'  optcell',multibinit_dtset%optcell
    3689           32 :      write(nunit,'(3x,a9,3F12.1)')'    bmass',multibinit_dtset%bmass
    3690           32 :      write(nunit,'(3x,a9,3I10)')'     nnos',multibinit_dtset%nnos
    3691           32 :      write(nunit,'(3x,a12)',advance='no')'    qmass  '
    3692           32 :      write(nunit,'(3x,15F12.10)') (multibinit_dtset%qmass(ii),ii=1,multibinit_dtset%nnos)
    3693              :    end if
    3694              : 
    3695              : ! TODO: print the value of the efield here if it is present.
    3696              : 
    3697        30994 :    if(any(multibinit_dtset%iatfix /= 0))then
    3698            2 :       natfix = 0
    3699           42 :       do ii=1,size(multibinit_dtset%iatfix,2)
    3700          134 :           if(any(multibinit_dtset%iatfix(:,ii) /= 0))then
    3701           14 :              natfix = natfix + 1
    3702              :           endif
    3703              :       enddo
    3704            2 :       write(nunit,'(3x,a9,3I10)')'   natfix', natfix
    3705              :    endif
    3706              : 
    3707              :    if(multibinit_dtset%dynamics==101)then
    3708              :    end if
    3709              : 
    3710           66 :    if(multibinit_dtset%dynamics==102)then
    3711            2 :       write(nunit,'(a15,ES15.5)')'latt_friction',multibinit_dtset%latt_friction
    3712              :    end if
    3713              : 
    3714           66 :    if(multibinit_dtset%dynamics==103)then
    3715            2 :       write(nunit,'(a15,ES15.5)')'     latt_taut',multibinit_dtset%latt_taut
    3716              :    end if
    3717              : 
    3718           66 :    if(multibinit_dtset%dynamics==104)then
    3719            0 :       write(nunit,'(a15,ES15.5)')'     latt_taut',multibinit_dtset%latt_taut
    3720              : !      write(nunit,'(a15,ES15.5)')'     latt_taup',multibinit_dtset%latt_taup
    3721              : !      write(nunit,'(a15,ES15.5)')'compressibility',multibinit_dtset%latt_compressibility
    3722              :    end if
    3723              : 
    3724           66 :    if(multibinit_dtset%dynamics==105)then
    3725            0 :       write(nunit,'(a15,ES15.5)')'     latt_taut',multibinit_dtset%latt_taut
    3726              : !      write(nunit,'(a15,ES15.5)')'     latt_taup',multibinit_dtset%latt_taup
    3727              : !      write(nunit,'(a15,ES15.5)')'compressibility',multibinit_dtset%latt_compressibility
    3728              : !      write(nunit,'(a15,ES15.5)')'     latt_mask',(multibinit_dtset%latt_mask(ii), ii=1, 3)
    3729              :    end if
    3730              :  end if
    3731              : 
    3732           98 :  if(multibinit_dtset%lwf_dynamics/=0) then
    3733            2 :     write(nunit,'(a)')' LWF Dynamics :'
    3734            2 :     write(nunit,'(12x,a16,I12.1)')'lwf_dynamics',multibinit_dtset%lwf_dynamics
    3735            2 :     write(nunit, '(13x, a15, I12.1)') 'lwf_init_state', multibinit_dtset%lwf_init_state
    3736            2 :     write(nunit,'(10x, a18, 5x, F10.5)')'lwf_temperature',multibinit_dtset%lwf_temperature
    3737            2 :     write(nunit,'(13x,a15,ES15.5, a8)')  'lwf_dt',multibinit_dtset%lwf_dt*Time_Sec , ' second' !TODO: use a.u.
    3738            2 :     write(nunit,'(13x,a15,I10.1)')'lwf_ntime',multibinit_dtset%lwf_ntime
    3739            2 :     write(nunit,'(13x,a15,I10.1)')'lwf_nctime',multibinit_dtset%lwf_nctime
    3740              :     !write(nunit,'(8x,a20,I10.1)')'lwf_self_bound_order',multibinit_dtset%lwf_self_bound_order
    3741              :     !write(nunit,'(8x,a20,F10.5)')'lwf_self_bound_coeff',multibinit_dtset%lwf_self_bound_coeff
    3742            2 :     write(nunit, '(6x, a22, I12.1)') 'lwf_var_temperature', multibinit_dtset%lwf_var_temperature
    3743            2 :     write(nunit, '(6x, a22, 5x, F10.5)') 'lwf_temperature_start', multibinit_dtset%lwf_temperature_start
    3744            2 :     write(nunit, '(6x, a22, 5x, F10.5)') 'lwf_temperature_end', multibinit_dtset%lwf_temperature_end
    3745            2 :     write(nunit, '(5x, a23, I12.1)') 'lwf_temperature_nstep', multibinit_dtset%lwf_temperature_nstep
    3746              : 
    3747            2 :     if(multibinit_dtset%lwf_dynamics==1) then
    3748            0 :     write(nunit,'(20x,a8,ES15.5, a8)')  'lwf_taut',multibinit_dtset%lwf_dt*Time_Sec , ' second' !TODO: use a.u.
    3749            2 :     else if(multibinit_dtset%lwf_dynamics==3) then
    3750            2 :        write(nunit,'(10x, a18, 5x, F10.5)')'lwf_mc_avg_amp',multibinit_dtset%lwf_mc_avg_amp
    3751              :     end if
    3752              :  end if
    3753              : 
    3754           98 :  if(multibinit_dtset%spin_dynamics/=0) then
    3755            4 :     write(nunit,'(a)')' Spin Dynamics :'
    3756              : 
    3757              :     !write(nunit,'(3x,a25,I12.1)')'spin_calc_correlation_obs',multibinit_dtset%spin_calc_correlation_obs
    3758            4 :     write(nunit,'(3x,a25,I12.1)')'spin_calc_thermo_obs',multibinit_dtset%spin_calc_thermo_obs
    3759              :     !write(nunit,'(3x,a25,I12.1)')'spin_calc_traj_obs',multibinit_dtset%spin_calc_traj_obs
    3760            4 :     write(nunit,'(12x,a16,I12.1)')'spin_dynamics',multibinit_dtset%spin_dynamics
    3761            4 :     write(nunit,'(10x, a18, 5x, F10.5)')'spin_temperature',multibinit_dtset%spin_temperature
    3762            4 :     write(nunit,'(10x, a18, 5x, F10.5)')'spin_damping',multibinit_dtset%spin_damping
    3763            4 :     write(nunit,'(9x,a19,I10.1)')'spin_ntime_pre',multibinit_dtset%spin_ntime_pre
    3764            4 :     write(nunit,'(13x,a15,I10.1)')'spin_ntime',multibinit_dtset%spin_ntime
    3765            4 :     write(nunit,'(13x,a15,3I10)')  'ncell',multibinit_dtset%ncell !TODO hexu: duplicate but dynamics can be 0.
    3766            4 :     write(nunit,'(13x,a15,ES15.5, a8)')  'spin_dt',multibinit_dtset%spin_dt*Time_Sec , ' second' !TODO: use a.u.
    3767              :     !write(nunit,'(3x,a14,3es10.5)')  '   spin_tolavg',multibinit_dtset%spin_tolavg
    3768              :     !write(nunit,'(3x,a14,3es10.5)')  '   spin_tolvar',multibinit_dtset%spin_tolvar
    3769           16 :     write(nunit,'(13x,a15,3ES15.5,a8)')   'spin_mag_field', (multibinit_dtset%spin_mag_field(ii)/Bfield_Tesla,ii=1,3), '   Tesla'
    3770            4 :     write(nunit, '(13x, a15, I12.1)') 'spin_sia_add', multibinit_dtset%spin_sia_add
    3771            4 :     write(nunit, '(13x, a15, ES15.5)') 'spin_sia_k1amp', multibinit_dtset%spin_sia_k1amp
    3772           16 :     write(nunit, '(13x, a15, 3ES15.5)') 'spin_sia_k1dir', (multibinit_dtset%spin_sia_k1dir(ii), ii=1,3)
    3773           16 :     write(nunit,'(5x,a23, 3es15.5)')   'spin_projection_qpoint', (multibinit_dtset%spin_projection_qpoint(ii),ii=1,3)
    3774            4 :     write(nunit, '(13x, a15, I12.1)') 'spin_init_state', multibinit_dtset%spin_init_state
    3775            4 :     if(multibinit_dtset%spin_init_state==3) then
    3776            0 :       write(nunit,'(6x,a22, 3es15.5)')   'spin_init_orientation', (multibinit_dtset%spin_init_orientation(ii),ii=1,3)
    3777            0 :       write(nunit,'(11x,a17, 3es15.5)')   'spin_init_qpoint', (multibinit_dtset%spin_init_qpoint(ii),ii=1,3)
    3778            0 :       write(nunit,'(6x,a22,3es15.5)')   'spin_init_rotate_axis', (multibinit_dtset%spin_init_rotate_axis(ii),ii=1,3)
    3779              :     endif
    3780            4 :     write(nunit, '(6x, a22, I12.1)') 'spin_var_temperature', multibinit_dtset%spin_var_temperature
    3781            4 :     write(nunit, '(6x, a22, 5x, F10.5)') 'spin_temperature_start', multibinit_dtset%spin_temperature_start
    3782            4 :     write(nunit, '(6x, a22, 5x, F10.5)') 'spin_temperature_end', multibinit_dtset%spin_temperature_end
    3783            4 :     write(nunit, '(5x, a23, I12.1)') 'spin_temperature_nstep', multibinit_dtset%spin_temperature_nstep
    3784            4 :     write(nunit, '(13x, a15, I12.1)') 'spin_write_traj', multibinit_dtset%spin_write_traj
    3785              :  end if
    3786              : 
    3787           98 :  if(multibinit_dtset%slc_coupling/=0) then
    3788            4 :    write(nunit,'(6x, a22, I12.4)') 'spin-lattice coupling', multibinit_dtset%slc_coupling
    3789              :  endif
    3790              : 
    3791           98 :  if(multibinit_dtset%confinement==1)then
    3792            0 :    write(nunit,'(a)')' Confinement information :'
    3793            0 :    write(nunit,'(1x,a22,I5.1)')'       conf_power_disp',multibinit_dtset%conf_power_disp
    3794            0 :    write(nunit,'(1x,a22,I5.1)')'     conf_power_strain',multibinit_dtset%conf_power_strain
    3795            0 :    write(nunit,'(1x,a22,3es16.8)')'  conf_power_fact_disp',multibinit_dtset%conf_power_fact_disp
    3796            0 :    write(nunit,'(1x,a22,3es16.8)')'conf_power_fact_strain',multibinit_dtset%conf_power_fact_strain
    3797            0 :    write(nunit,'(1x,a22)')'     conf_cutoff_disp'
    3798            0 :    write(nunit,'(19x,3es16.8)') (multibinit_dtset%conf_cutoff_disp(ii),ii=1,multibinit_dtset%natom)
    3799            0 :    write(nunit,'(1x,a22)')'    conf_cutoff_strain'
    3800            0 :    write(nunit,'(19x,3es16.8)') (multibinit_dtset%conf_cutoff_strain(ii),ii=1,6)
    3801              :  end if
    3802              : 
    3803           98 :  if(multibinit_dtset%fit_coeff/=0)then
    3804           20 :    write(nunit,'(a)')' Fit the coefficients :'
    3805           20 :    write(nunit,'(1x,a17,I3.1)')'       fit_coeff',multibinit_dtset%fit_coeff
    3806           20 :    write(nunit,'(1x,a17,I3.1)')'fit_generateCoeff',multibinit_dtset%fit_generateCoeff
    3807           20 :    if(multibinit_dtset%fit_initializeData==0)then
    3808           20 :      write(nunit,'(1x,a17,I3.1)')'fit_initializeData',multibinit_dtset%fit_initializeData
    3809              :    end if
    3810           20 :    if(multibinit_dtset%fit_tolMSDE > 0)then
    3811            0 :      write(nunit,'(1x,a17,es16.8)')'    fit_tolMSDE',multibinit_dtset%fit_tolMSDE
    3812              :    end if
    3813           20 :    if(multibinit_dtset%fit_tolMSDF > 0)then
    3814            0 :      write(nunit,'(1x,a17,es16.8)')'    fit_tolMSDF',multibinit_dtset%fit_tolMSDF
    3815              :    end if
    3816           20 :    if(multibinit_dtset%fit_tolMSDS > 0)then
    3817            0 :      write(nunit,'(1x,a17,es16.8)')'    fit_tolMSDS',multibinit_dtset%fit_tolMSDS
    3818              :    end if
    3819           20 :    if(multibinit_dtset%fit_tolMSDFS > 0)then
    3820            0 :      write(nunit,'(1x,a17,es16.8)')'   fit_tolMSDFS',multibinit_dtset%fit_tolMSDFS
    3821              :    end if
    3822           20 :    if(multibinit_dtset%fit_weight_T > 0.0_dp)then
    3823            2 :      write(nunit,'(1x,a17,es16.8)')'   fit_weight_T',multibinit_dtset%fit_weight_T
    3824              :    end if
    3825              : 
    3826           20 :    write(nunit,'(1x,a17,es16.8)')'      fit_cutoff',multibinit_dtset%fit_cutoff
    3827           20 :    write(nunit,'(1x,a17,es16.8)')'      fit_droprate',multibinit_dtset%fit_drop_rate
    3828              :    !write(nunit,'(1x,a17,es16.8)')'      fit_min_bound_coeff',multibinit_dtset%fit_min_bound_coeff
    3829           20 :    write(nunit,'(1x,a17,I3.1)')'      fit_option',multibinit_dtset%fit_option
    3830           20 :    write(nunit,'(1x,a17,2x,I0)')'      fit_iatom',multibinit_dtset%fit_iatom
    3831           20 :    write(nunit,'(1x,a17,2x,I0)')'      fit_ncoeff',multibinit_dtset%fit_ncoeff
    3832           20 :    write(nunit,'(1x,a17,3i3)') '        fit_grid',multibinit_dtset%fit_grid
    3833           20 :    write(nunit,'(1x,a17,I3.1)')'   ts_option',multibinit_dtset%ts_option
    3834           20 :    write(nunit,'(1x,a17,2i3)') '  fit_rangePower',multibinit_dtset%fit_rangePower
    3835           20 :    write(nunit,'(1x,a17,I3)')  '  fit_dispterms',multibinit_dtset%fit_dispterms
    3836           20 :    write(nunit,'(1x,a17,I3)')  '  fit_anhaStrain',multibinit_dtset%fit_anhaStrain
    3837           20 :    write(nunit,'(1x,a17,I3)')  '  fit_SPCoupling',multibinit_dtset%fit_SPCoupling
    3838           20 :    write(nunit,'(1x,a17,I3)')  '  fit_SPC_maxS',multibinit_dtset%fit_SPC_maxS
    3839              : 
    3840              : 
    3841           20 :    n=multibinit_dtset%fit_rangePower(2)-multibinit_dtset%fit_rangePower(1)+1
    3842           20 :    if(n > 0) then
    3843           20 :      write(nunit,'(1x,a17)',advance='no') '   fit_max_nbody'
    3844           42 :      write(nunit,'(4x,9i7)') (multibinit_dtset%fit_max_nbody_inrange(ii),ii=1,n)
    3845              :    end if
    3846              : 
    3847              : 
    3848           20 :    if(multibinit_dtset%fit_nbancoeff /= 0) then
    3849            0 :      write(nunit,'(1x,a17,I3)')  '   fit_nbancoeff',multibinit_dtset%fit_nbancoeff
    3850            0 :      write(nunit,'(1x,a17)',advance='no')'   fit_bancoeff'
    3851            0 :      write(nunit,'(4x,9i7)') (multibinit_dtset%fit_bancoeff(ii),ii=1,multibinit_dtset%fit_nbancoeff)
    3852              :    end if
    3853           20 :    if(multibinit_dtset%fit_nfixcoeff /= 0) then
    3854            6 :      write(nunit,'(1x,a17,I3)')  '   fit_nfixcoeff',multibinit_dtset%fit_nfixcoeff
    3855            6 :      write(nunit,'(1x,a17)',advance='no')'   fit_fixcoeff'
    3856           18 :      write(nunit,'(4x,9i7)') (multibinit_dtset%fit_fixcoeff(ii),ii=1,multibinit_dtset%fit_nfixcoeff)
    3857              :    end if
    3858           20 :    if(multibinit_dtset%fit_nimposecoeff /= 0) then
    3859            0 :      write(nunit,'(1x,a17,I3)')  '   fit_nimposecoeff',multibinit_dtset%fit_nimposecoeff
    3860            0 :      write(nunit,'(1x,a17)',advance='no')'   fit_imposecoeff'
    3861            0 :      write(nunit,'(4x,9i7)') (multibinit_dtset%fit_imposecoeff(ii),ii=1,multibinit_dtset%fit_nimposecoeff)
    3862              :    end if
    3863              :  end if
    3864              : 
    3865           98 :  if(multibinit_dtset%opt_effpot/=0)then
    3866            2 :    write(nunit,'(a)')'Optimize Effective Potential :'
    3867            2 :    if(multibinit_dtset%opt_ncoeff /= 0) then
    3868            2 :      write(nunit,'(1x,a17,I3)')  '   opt_ncoeff',multibinit_dtset%opt_ncoeff
    3869            2 :      write(nunit,'(1x,a17)',advance='no')'   opt_coeff'
    3870            6 :      write(nunit,'(4x,9i7)') (multibinit_dtset%opt_coeff(ii),ii=1,multibinit_dtset%opt_ncoeff)
    3871              :    end if
    3872              :  end if
    3873              : 
    3874           98 :  if(multibinit_dtset%bound_model /=0)then
    3875            2 :    write(nunit,'(a)')' Bound the coefficients :'
    3876            2 :    write(nunit,'(1x,a16,I3.1)') '     bound_model',multibinit_dtset%bound_model
    3877            2 :    write(nunit,'(1x,a16,es12.4)') '   bound_penalty',multibinit_dtset%bound_penalty
    3878            2 :    write(nunit,'(1x,a16,I3)')    'bound_anhaStrain',multibinit_dtset%bound_anhaStrain
    3879            2 :    write(nunit,'(1x,a16,I3)')    'bound_SPCoupling',multibinit_dtset%bound_SPCoupling
    3880            2 :    write(nunit,'(1x,a16,es16.8)')'    bound_cutoff',multibinit_dtset%bound_cutoff
    3881            2 :    write(nunit,'(1x,a16,1x,3I3)')   '      bound_cell',multibinit_dtset%bound_cell
    3882            2 :    write(nunit,'(1x,a16,1x,I3)')    '  bound_maxCoeff',multibinit_dtset%bound_maxCoeff
    3883            2 :    write(nunit,'(1x,a16,1x,I3)')    '  bound_option',multibinit_dtset%bound_option
    3884            2 :    write(nunit,'(1x,a16,es16.8)') '      bound_temp',multibinit_dtset%bound_temp
    3885            2 :    write(nunit,'(1x,a16,I7)')   '      bound_step',multibinit_dtset%bound_step
    3886            2 :    write(nunit,'(1x,a16,2I3.1)')'bound_rangePower',multibinit_dtset%bound_rangePower
    3887              :  end if
    3888              : 
    3889              : 
    3890              : !MS Variables for SCALE-UP
    3891              : !Replace by function from m_scup_dataset.F90
    3892           98 :  if(multibinit_dtset%scup_dtset%scup_elec_model)then
    3893            0 :    call outvars_scup(multibinit_dtset%scup_dtset,nunit)
    3894              :  end if
    3895              : 
    3896              : !Write the general information
    3897              :  if( multibinit_dtset%rfmeth/=1 .or. &
    3898              : & multibinit_dtset%enunit/=0 .or. &
    3899              : & multibinit_dtset%eivec/=0 .or. &
    3900           98 : & multibinit_dtset%asr/=0 .or. &
    3901              : & multibinit_dtset%chneut/=0)then
    3902           98 :    write(nunit,'(a)')' Miscellaneous information :'
    3903           98 :    if(multibinit_dtset%rfmeth/=1)write(nunit,'(3x,a9,3i10)')'   rfmeth',multibinit_dtset%rfmeth
    3904           98 :    if(multibinit_dtset%enunit/=0)write(nunit,'(3x,a9,3i10)')'   enunit',multibinit_dtset%enunit
    3905           98 :    if(multibinit_dtset%eivec/=0) write(nunit,'(3x,a9,3i10)')'    eivec',multibinit_dtset%eivec
    3906           98 :    if(multibinit_dtset%asr/=0)   write(nunit,'(3x,a9,3i10)')'      asr',multibinit_dtset%asr
    3907           98 :    if(multibinit_dtset%chneut/=0)write(nunit,'(3x,a9,3i10)')'   chneut',multibinit_dtset%chneut
    3908              :  end if
    3909              : 
    3910              : 
    3911              : !For interatomic force constant information
    3912           98 :  if(multibinit_dtset%ifcflag/=0)then
    3913           98 :    write(nunit,'(a)')' Interatomic Force Constants Inputs :'
    3914           98 :    write(nunit,'(3x,a9,3i10)')'   dipdip',multibinit_dtset%dipdip
    3915           98 :    if(multibinit_dtset%dipdip /= 0)then
    3916           66 :      write(nunit,'(a12,3i10)') 'dipdip_range',multibinit_dtset%dipdip_range
    3917              :    end if
    3918           98 :    if(multibinit_dtset%dipdip_prt/=0)then
    3919           42 :      write(nunit,'(a12,3i10)') 'dipdip_prt',multibinit_dtset%dipdip_prt
    3920              :    end if
    3921           98 :    if(multibinit_dtset%nsphere/=0)write(nunit,'(3x,a9,3i10)')'  nsphere',multibinit_dtset%nsphere
    3922           98 :    if(abs(multibinit_dtset%rifcsph)>tol10)write(nunit,'(3x,a9,E16.6)')'  nsphere',multibinit_dtset%rifcsph
    3923           98 :    write(nunit,'(3x,a9,3i10)')'   ifcana',multibinit_dtset%ifcana
    3924           98 :    write(nunit,'(3x,a9,3i10)')'   ifcout',multibinit_dtset%ifcout
    3925           98 :    if(multibinit_dtset%natifc>=1)then
    3926           86 :      write(nunit,'(3x,a9,3i10)')'   natifc',multibinit_dtset%natifc
    3927           86 :      write(nunit,'(3x,a12)',advance='no')'    atifc   '
    3928          582 :      write(nunit,'(3x,15i4)') (multibinit_dtset%atifc(ii)*ii,ii=1,multibinit_dtset%natifc)
    3929              : 
    3930              :    end if
    3931           98 :    write(nunit,'(a)')' Description of grid 1 :'
    3932           98 :    write(nunit,'(3x,a9,3i10)')'     brav',multibinit_dtset%brav
    3933           98 :    write(nunit,'(3x,a9,3i10)')'    ngqpt',multibinit_dtset%ngqpt(1:3)
    3934           98 :    write(nunit,'(3x,a9,3i10)')'   nqshft',multibinit_dtset%nqshft
    3935           98 :    if (multibinit_dtset%nqshft/=0)then
    3936           98 :      write(nunit,'(3x,a9)')'   q1shft'
    3937          196 :      do iqshft=1,multibinit_dtset%nqshft
    3938          490 :        write(nunit,'(19x,4es16.8)') (multibinit_dtset%q1shft(ii,iqshft),ii=1,3)
    3939              :      end do
    3940              :    end if
    3941          392 :    if (any(multibinit_dtset%qrefine(:) > 1)) then
    3942            0 :      write(nunit,'(3x,a9,3i10)')'  qrefine', multibinit_dtset%qrefine
    3943              :    end if
    3944              :  end if
    3945              : 
    3946              : 
    3947              : !List of vector 1  (reduced coordinates)
    3948           98 :  if(multibinit_dtset%nph1l/=0)then
    3949           98 :    write(nunit,'(a)')' First list of wavevector (reduced coord.) :'
    3950           98 :    write(nunit,'(3x,a9,3i10)')'    nph1l',multibinit_dtset%nph1l
    3951           98 :    write(nunit,'(3x,a9)')'    qph1l'
    3952          252 :    do iph1=1,multibinit_dtset%nph1l
    3953              :      write(nunit,'(19x,3es16.8,2x,es11.3)') &
    3954          714 : &     (multibinit_dtset%qph1l(ii,iph1),ii=1,3),multibinit_dtset%qnrml1(iph1)
    3955              :    end do
    3956              :  end if
    3957              : 
    3958              : !List of vector 2  (cartesian coordinates)
    3959           98 :  if(multibinit_dtset%nph2l/=0)then
    3960            0 :    write(nunit,'(a)')' Second list of wavevector (cart. coord.) :'
    3961            0 :    write(nunit,'(3x,a9,3i10)')'    nph2l',multibinit_dtset%nph2l
    3962            0 :    write(nunit,'(3x,a9)')'    qph2l'
    3963            0 :    do iph2=1,multibinit_dtset%nph2l
    3964              :      write(nunit,'(19x,3es16.8,2x,es11.3)') &
    3965            0 : &     (multibinit_dtset%qph2l(ii,iph2),ii=1,3),multibinit_dtset%qnrml2(iph2)
    3966              :    end do
    3967              :  end if
    3968              : 
    3969         7938 :  write(nunit,'(a,80a,a)') ch10,('=',ii=1,80),ch10
    3970              : 
    3971           98 : end subroutine outvars_multibinit
    3972              : !!***
    3973              : 
    3974              : 
    3975              : 
    3976            0 : end module m_multibinit_dataset
    3977              : !!***
        

Generated by: LCOV version 2.3-1