TABLE OF CONTENTS


ABINIT/hdr_vs_dtset [ Functions ]

[ Top ] [ Functions ]

NAME

 hdr_vs_dtset

FUNCTION

  Check the compatibility of the Abinit header with respect to the
  input variables defined in the input file. 

COPYRIGHT

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

INPUTS

  Dtset<type(dataset_type)>=all input variables for this dataset
  Hdr <type(hdr_type)>=the header structured variable

OUTPUT

  Only check

PARENTS

      eph,setup_bse,setup_screening,setup_sigma,wfk_analyze

CHILDREN

      wrtout

SOURCE

 31 #if defined HAVE_CONFIG_H
 32 #include "config.h"
 33 #endif
 34 
 35 #include "abi_common.h"
 36 
 37 subroutine hdr_vs_dtset(Hdr,Dtset)
 38     
 39  use defs_basis
 40  use defs_abitypes
 41  use m_errors
 42  use m_profiling_abi
 43 
 44  use m_fstrings, only : ltoa
 45  use m_crystal,  only : print_symmetries
 46 
 47 !This section has been created automatically by the script Abilint (TD).
 48 !Do not modify the following lines by hand.
 49 #undef ABI_FUNC
 50 #define ABI_FUNC 'hdr_vs_dtset'
 51  use interfaces_14_hidewrite
 52 !End of the abilint section
 53 
 54  implicit none
 55 
 56 !Arguments ------------------------------------
 57  type(Hdr_type),intent(in) :: Hdr
 58  type(Dataset_type),intent(in) :: Dtset
 59 
 60 !Local variables-------------------------------
 61  integer :: ik,jj,ierr
 62  logical :: test
 63  logical :: tsymrel,ttnons,tsymafm
 64  character(len=500) :: msg      
 65 ! *************************************************************************
 66 
 67 !=== Check basic dimensions ===
 68  ierr=0
 69  call compare_int('natom',  Hdr%natom,  Dtset%natom,  ierr)
 70  call compare_int('nkpt',   Hdr%nkpt,   Dtset%nkpt,   ierr)
 71  call compare_int('npsp',   Hdr%npsp,   Dtset%npsp,   ierr)
 72  call compare_int('nspden', Hdr%nspden, Dtset%nspden, ierr)
 73  call compare_int('nspinor',Hdr%nspinor,Dtset%nspinor,ierr)
 74  call compare_int('nsppol', Hdr%nsppol, Dtset%nsppol, ierr)
 75  call compare_int('nsym',   Hdr%nsym,   Dtset%nsym,   ierr)
 76  call compare_int('ntypat', Hdr%ntypat, Dtset%ntypat, ierr)
 77  call compare_int('usepaw', Hdr%usepaw, Dtset%usepaw, ierr)
 78  call compare_int('usewvl', Hdr%usewvl, Dtset%usewvl, ierr)
 79  call compare_int('kptopt', Hdr%kptopt, Dtset%kptopt, ierr)
 80  call compare_int('pawcpxocc', Hdr%pawcpxocc, Dtset%pawcpxocc, ierr)
 81  call compare_int('nshiftk_orig', Hdr%nshiftk_orig, Dtset%nshiftk_orig, ierr)
 82  call compare_int('nshiftk', Hdr%nshiftk, Dtset%nshiftk, ierr)
 83 
 84 !=== The number of fatal errors must be zero ===
 85  if (ierr/=0) then 
 86    write(msg,'(3a)')&
 87 &   'Cannot continue, basic dimensions reported in the header do not agree with input file. ',ch10,&
 88 &   'Check consistency between the content of the external file and the input file. '
 89    MSG_ERROR(msg)
 90  end if
 91 
 92  test=ALL(ABS(Hdr%xred-Dtset%xred_orig(:,1:Dtset%natom,1))<tol6)
 93  ABI_CHECK(test,'Mismatch in xred')
 94 
 95  test=ALL(Hdr%typat==Dtset%typat(1:Dtset%natom)) 
 96  ABI_CHECK(test,'Mismatch in typat')
 97 !
 98 !* Check if the lattice from the input file agrees with that read from the KSS file
 99  if ( (ANY(ABS(Hdr%rprimd-Dtset%rprimd_orig(1:3,1:3,1))>tol6)) ) then
100    write(msg,'(6a)')ch10,&
101 &   ' hdr_vs_dtset : ERROR - ',ch10,&
102 &   ' real lattice vectors read from Header ',ch10,&
103 &   ' differ from the values specified in the input file'
104    call wrtout(std_out,msg,'COLL')
105    write(msg,'(3a,3(3es16.6),3a,3(3es16.6),3a)')ch10,&
106 &   ' rprimd from Hdr file   = ',ch10,(Hdr%rprimd(:,jj),jj=1,3),ch10,&
107 &   ' rprimd from input file = ',ch10,(Dtset%rprimd_orig(:,jj,1),jj=1,3),ch10,ch10,&
108 &   '  Modify the lattice vectors in the input file '
109    call wrtout(std_out,msg,'COLL') 
110    MSG_ERROR("")
111  end if 
112 
113 !=== Check symmetry operations ===
114  tsymrel=(ALL(Hdr%symrel==Dtset%symrel(:,:,1:Dtset%nsym)))
115  if (.not.tsymrel) then
116    write(msg,'(6a)')ch10,&
117 &   ' hdr_vs_dtset : ERROR - ',ch10,&
118 &   ' real space symmetries read from Header ',ch10,&
119 &   ' differ from the values inferred from the input file'
120    call wrtout(std_out,msg,'COLL')
121    tsymrel=.FALSE.
122  end if 
123 
124  ttnons=ALL(ABS(Hdr%tnons-Dtset%tnons(:,1:Dtset%nsym))<tol6)
125  if (.not.ttnons) then
126    write(msg,'(6a)')ch10,&
127 &   ' hdr_vs_dtset : ERROR - ',ch10,&
128 &   ' fractional translations read from Header ',ch10,&
129 &   ' differ from the values inferred from the input file'
130    call wrtout(std_out,msg,'COLL')
131    ttnons=.FALSE.
132  end if 
133 
134  tsymafm=ALL(Hdr%symafm==Dtset%symafm(1:Dtset%nsym))
135  if (.not.tsymafm) then
136    write(msg,'(6a)')ch10,&
137 &   ' hdr_vs_dtset : ERROR - ',ch10,&
138 &   ' AFM symmetries read from Header ',ch10,&
139 &   ' differ from the values inferred from the input file'
140    call wrtout(std_out,msg,'COLL')
141    tsymafm=.FALSE.
142  end if
143 
144  if (.not.(tsymrel.and.ttnons.and.tsymafm)) then
145    write(msg,'(a)')' Header ' 
146    call wrtout(std_out,msg,'COLL') 
147    call print_symmetries(Hdr%nsym,Hdr%symrel,Hdr%tnons,Hdr%symafm)
148    write(msg,'(a)')' Dtset  ' 
149    call wrtout(std_out,msg,'COLL') 
150    call print_symmetries(Dtset%nsym,Dtset%symrel,Dtset%tnons,Dtset%symafm)
151    MSG_ERROR('Check symmetry operations')
152  end if
153 
154  if (abs(Dtset%nelect-hdr%nelect)>tol6) then
155    write(msg,'(2(a,f8.2))')&
156 &   "File contains ", hdr%nelect," electrons but nelect initialized from input is ",Dtset%nelect
157    MSG_ERROR(msg)
158  end if
159  if (abs(Dtset%charge-hdr%charge)>tol6) then
160    write(msg,'(2(a,f8.2))')&
161 &   "File contains charge ", hdr%charge," but charge from input is ",Dtset%charge
162    MSG_ERROR(msg)
163  end if
164 
165  if (any(hdr%kptrlatt_orig /= dtset%kptrlatt_orig)) then
166    write(msg,"(5a)")&
167    "hdr%kptrlatt_orig: ",trim(ltoa(reshape(hdr%kptrlatt_orig,[9]))),ch10,&
168    "dtset%kptrlatt_orig: ",trim(ltoa(reshape(dtset%kptrlatt_orig, [9])))
169    MSG_ERROR(msg)
170  end if
171 
172  if (any(hdr%kptrlatt /= dtset%kptrlatt)) then
173    write(msg,"(5a)")&
174    "hdr%kptrlatt: ",trim(ltoa(reshape(hdr%kptrlatt, [9]))),ch10,&
175    "dtset%kptrlatt: ",trim(ltoa(reshape(dtset%kptrlatt, [9])))
176    MSG_ERROR(msg)
177  end if
178 
179  if (any(abs(hdr%shiftk_orig - dtset%shiftk_orig(:,1:dtset%nshiftk_orig)) > tol6)) then
180    write(msg,"(5a)")&
181    "hdr%shiftk_orig: ",trim(ltoa(reshape(hdr%shiftk_orig, [3*hdr%nshiftk_orig]))),ch10,&
182    "dtset%shiftk_orig: ",trim(ltoa(reshape(dtset%shiftk_orig, [3*dtset%nshiftk_orig])))
183    MSG_ERROR(msg)
184  end if
185 
186  if (any(abs(hdr%shiftk - dtset%shiftk(:,1:dtset%nshiftk)) > tol6)) then
187    write(msg,"(5a)")&
188    "hdr%shiftk: ",trim(ltoa(reshape(hdr%shiftk, [3*hdr%nshiftk]))),ch10,&
189    "dtset%shiftk: ",trim(ltoa(reshape(dtset%shiftk, [3*dtset%nshiftk])))
190    MSG_ERROR(msg)
191  end if
192 
193 !* Check if the k-points from the input file agrees with that read from the WFK file
194  if ( (ANY(ABS(Hdr%kptns(:,:)-Dtset%kpt(:,1:Dtset%nkpt))>tol6)) ) then
195    write(msg,'(9a)')ch10,&
196 &   ' hdr_vs_dtset : ERROR - ',ch10,&
197 &   '  k-points read from Header ',ch10,&
198 &   '  differ from the values specified in the input file',ch10,&
199 &   '  k-points from Hdr file                        | k-points from input file ',ch10
200    call wrtout(std_out,msg,'COLL') 
201    do ik=1,Dtset%nkpt
202      write(msg,'(3(3es16.6,3x))')Hdr%kptns(:,ik),Dtset%kpt(:,ik)
203      call wrtout(std_out,msg,'COLL') 
204    end do
205    MSG_ERROR('Modify the k-mesh in the input file')
206  end if 
207 
208  if (ANY(ABS(Hdr%wtk(:)-Dtset%wtk(1:Dtset%nkpt))>tol6)) then
209    write(msg,'(9a)')ch10,&
210 &   ' hdr_vs_dtset : ERROR - ',ch10,&
211 &   '  k-point weights read from Header ',ch10,&
212 &   '  differ from the values specified in the input file',ch10,&
213 &   '  Hdr file  |  File ',ch10
214    call wrtout(std_out,msg,'COLL') 
215    do ik=1,Dtset%nkpt
216      write(msg,'(2(f11.5,1x))')Hdr%wtk(ik),Dtset%wtk(ik)
217      call wrtout(std_out,msg,'COLL') 
218    end do
219    MSG_ERROR('Check the k-mesh and the symmetries of the system. ')
220  end if 
221 
222 !Check istwfk storage
223  if ( (ANY(Hdr%istwfk(:)/=Dtset%istwfk(1:Dtset%nkpt))) ) then
224    write(msg,'(9a)')ch10,&
225 &   ' hdr_vs_dtset : ERROR - ',ch10,&
226 &   '  istwfk read from Header ',ch10,&
227 &   '  differ from the values specified in the input file',ch10,&
228 &   '  Hdr | input ',ch10
229    call wrtout(std_out,msg,'COLL') 
230    do ik=1,Dtset%nkpt
231      write(msg,'(i5,3x,i5)')Hdr%istwfk(ik),Dtset%istwfk(ik)
232      call wrtout(std_out,msg,'COLL') 
233    end do
234    MSG_ERROR('Modify istwfk in the input file')
235  end if 
236 
237  CONTAINS  !===========================================================

hdr_vs_dtset/compare_int [ Functions ]

[ Top ] [ hdr_vs_dtset ] [ Functions ]

NAME

 compare_int

FUNCTION

  Compare two int value and may raise an exception on error.

INPUTS

  name=Name of the variable
  iexp= expected value.
  ifound=the actuval value

SIDE EFFECTS

  ierr=increased by one if values differ 

PARENTS

      hdr_vs_dtset

CHILDREN

      wrtout

SOURCE

263  subroutine compare_int(name,iexp,ifound,ierr)
264 
265 
266 !This section has been created automatically by the script Abilint (TD).
267 !Do not modify the following lines by hand.
268 #undef ABI_FUNC
269 #define ABI_FUNC 'compare_int'
270  use interfaces_14_hidewrite
271 !End of the abilint section
272 
273  implicit none
274 
275 !Arguments ------------------------------------
276  integer,intent(in) :: iexp,ifound
277  integer,intent(inout) :: ierr
278  character(len=*),intent(in) :: name
279 
280 !Local variables-------------------------------
281  logical :: leq                       
282  character(len=500) :: msg                                              
283 ! *************************************************************************
284 
285    leq=(iexp==ifound)
286 
287    if (.not.leq) then 
288      write(msg,'(4a,i6,a,i6)')ch10,&
289      ' hdr_vs_dtset : WARNING - Mismatch in '//TRIM(name),ch10,&
290      '  Expected = ',iexp,' Found = ',ifound
291      call wrtout(std_out,msg,'COLL') 
292 !      Increase ierr to signal we should stop in the caller.
293      ierr=ierr+1 
294    end if
295 
296  end subroutine compare_int