TABLE OF CONTENTS


ABINIT/m_outvars [ Modules ]

[ Top ] [ Modules ]

NAME

  m_outvars

FUNCTION

COPYRIGHT

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

PARENTS

CHILDREN

SOURCE

21 #if defined HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24 
25 #include "abi_common.h"
26 
27 module m_outvars
28 
29  use defs_basis
30  use defs_abitypes
31  use m_results_out
32  use m_abicore
33  use m_errors
34  use m_xomp
35  use m_xmpi
36 #if defined HAVE_NETCDF
37  use netcdf
38 #endif
39  use m_outvar_a_h
40  use m_outvar_i_n
41  use m_outvar_o_z
42 
43  use m_nctk,      only : create_nc_file
44 
45  implicit none
46 
47  private

ABINIT/outvars [ Functions ]

[ Top ] [ Functions ]

NAME

 outvars

FUNCTION

 Echo variables for the ABINIT code.

INPUTS

  choice= 1 if echo of preprocessed variables, 2 if echo after call driver
  dmatpuflag=flag controlling the use of an initial density matrix in PAW+U (max. value over datasets)
  dtsets(0:ndtset_alloc)=<type datafiles_type>contains all input variables
  iout=unit number for echoed output
  mxvals=maximum size of some arrays along all datasets, including:
         ga_n_rules =maximal value of input ga_n_rules for all the datasets
         gw_nqlwl   =maximal value of input gw_nqlwl for all the datasets
         lpawu      =maximal value of input lpawu for all the datasets
         mband      =maximum number of bands
         natom      =maximal value of input natom for all the datasets
         natpawu    =maximal value of number of atoms on which +U is applied for all the datasets
         natsph     =maximal value of input natsph for all the datasets
         natvshift  =maximal value of input natvshift for all the datasets
         nconeq     =maximal value of input nconeq for all the datasets
         nimage     =maximal value of input nimage for all the datasets
         nimfrqs    =maximal value of input cd_customnimfrqs for all the datasets
         nkpt       =maximal value of input nkpt for all the datasets
         nkptgw     =maximal value of input nkptgw for all the datasets
         nkpthf     =maximal value of input nkpthf for all the datasets
         nnos       =maximal value of input nnos for all the datasets
         nqptdm     =maximal value of input nqptdm for all the datasets
         nspinor    =maximal value of input nspinor for all the datasets
         nsppol     =maximal value of input nsppol for all the datasets
         nsym       =maximum number of symmetries
         ntypat     =maximum number of type of atoms
         nzchempot  =maximal value of input nzchempot for all the datasets
  ndtset=number of datasets
  ndtset_alloc=number of datasets, corrected for allocation of at least
   one data set. Use for most dimensioned arrays.
  npsp=number of pseudopotentials
  results_out(0:ndtset_alloc)=<type results_out_type>contains the results
   needed for outvars, including evolving variables
  timopt=input variable to modulate the timing

OUTPUT

  Only writing

NOTES

 Note that this routine is called only by the processor me==0 .
 In consequence, no use of message and wrtout routine.
 The lines of code needed to output the defaults are preserved
 (see last section of the routine, but are presently disabled)

PARENTS

      abinit

CHILDREN

      create_nc_file,outvar_a_h,outvar_i_n,outvar_o_z,wrtout

SOURCE

115 subroutine outvars(choice,dmatpuflag,dtsets,filnam4,iout,&
116 &  mxvals,ndtset,ndtset_alloc,npsp,results_out,timopt)
117 
118 
119 !This section has been created automatically by the script Abilint (TD).
120 !Do not modify the following lines by hand.
121 #undef ABI_FUNC
122 #define ABI_FUNC 'outvars'
123 !End of the abilint section
124 
125  implicit none
126 
127 !Arguments ------------------------------------
128 !scalars
129  integer,intent(in) :: choice,dmatpuflag,iout
130  integer,intent(in) :: ndtset,ndtset_alloc,npsp,timopt
131  type(ab_dimensions),intent(in) :: mxvals
132  character(len=*),intent(in) :: filnam4
133 !arrays
134  type(dataset_type),intent(in) :: dtsets(0:ndtset_alloc)
135  type(results_out_type),intent(in) :: results_out(0:ndtset_alloc)
136 
137 !Local variables-------------------------------
138 !scalars
139  integer,parameter :: nkpt_max=50
140  integer :: first,idtset,iimage,kptopt
141  integer :: marr,mu,ncerr
142  integer :: nshiftk
143  integer :: prtvol_glob,max_nthreads
144  integer :: rfddk,rfelfd,rfphon,rfstrs,rfuser,rfmagn,rf2_dkdk,rf2_dkde
145  integer :: ncid=0 ! Variables for NetCDF output
146  character(len=500) :: message
147  character(len=4) :: stringimage
148  type(ab_dimensions) :: multivals
149 !arrays
150  integer,allocatable :: jdtset_(:),response_(:)
151  character(len=8),allocatable :: strimg(:)
152 
153 ! *************************************************************************
154 
155 !Set up a 'global' prtvol value
156  prtvol_glob=1
157  if(sum((dtsets(:)%prtvol)**2)==0)prtvol_glob=0
158 
159 !###########################################################
160 !### 00. Echo of selected default values
161 
162  if(choice==1)then
163 
164    max_nthreads = xomp_get_max_threads()
165 #ifndef HAVE_OPENMP
166    max_nthreads = 0 ! this value signals that OMP is not enabled in ABINIT.
167 #endif
168 
169    write(iout, '(10a)' )&
170 &   '--------------------------------------------------------------------------------',ch10,&
171 &   '------------- Echo of variables that govern the present computation ------------',ch10,&
172 &   '--------------------------------------------------------------------------------',ch10,&
173 &   '-',ch10,&
174 &   '- outvars: echo of selected default values                                      '
175    write(iout, '(3(a,i3),2a)' )&
176 &   '-   iomode0 =',dtsets(0)%iomode,' , fftalg0 =',dtsets(0)%ngfft(7),' , wfoptalg0 =',dtsets(0)%wfoptalg,ch10,&
177 &   '-'
178    write(iout, '(3a,(a,i5),2a)' )&
179 &   '- outvars: echo of global parameters not present in the input file              ',ch10,&
180 &   '- ',' max_nthreads =',max_nthreads,ch10,&
181 &   '-'
182  end if
183 
184 !write(std_out,*) 'outvar 01'
185 !###########################################################
186 !### 01. First line indicating outvars
187 
188  if(choice==1)then
189    write(iout, '(a)' )&
190 &   ' -outvars: echo values of preprocessed input variables --------'
191  else
192    write(iout, '(a)' )&
193 &   ' -outvars: echo values of variables after computation  --------'
194  end if
195 
196 !###########################################################
197 !### 02. Open NetCDF file for export variables
198 
199 #ifdef HAVE_NETCDF
200  ! Enable netcdf output only if the number of datasets is small.
201  ! otherwise v6[34] crashes with errmess:
202  !    nf90_def_dim - NetCDF library returned:   NetCDF: NC_MAX_DIMS exceeded
203  ! because we keep on creating dimensions in write_var_netcdf.
204  ! one should use groups for this kind of operations!!
205 
206  ncid = 0
207  if (ndtset_alloc  < 10) then
208    if (iout==std_out)then
209      write(iout,*) ch10,' These variables are accessible in NetCDF format (',trim(filnam4)//'_OUT.nc',')',ch10
210    end if
211    call create_nc_file(trim(filnam4)//"_OUT.nc",ncid)
212 
213    if (dtsets(1)%prtvol==-2) then
214      if (ncid>0)then
215        ncid=-ncid
216      else
217        ncid=-1
218      end if
219    end if
220  else
221    MSG_WARNING("output of OUT.nc has been disabled. Too many datasets")
222  end if
223 #endif
224  !ncid = 0
225 
226 !###########################################################
227 !##1 03. Set up dimensions : determine whether these are different for different datasets.
228 
229  multivals%ga_n_rules=0
230  multivals%gw_nqlwl=0
231  multivals%mband=0
232  multivals%natom=0
233  multivals%natpawu=0
234  multivals%natsph=0
235  multivals%natvshift=0
236  multivals%nberry=0
237  multivals%nbandhf=0
238  multivals%nconeq=0
239  multivals%nfreqsp=0
240  multivals%nimage=0
241  multivals%nimfrqs=0
242  multivals%nkpt=0
243  multivals%nkptgw=0
244  multivals%nkpthf=0
245  multivals%nnos=0
246  multivals%nqptdm=0
247  multivals%nshiftk=0
248  multivals%nsp=0
249  multivals%nspinor=0
250  multivals%nsppol=0
251  multivals%nsym=0
252  multivals%ntypat=0
253  multivals%ntypalch=0
254  multivals%nzchempot=0
255 
256  if(ndtset_alloc>1)then
257    do idtset=1,ndtset_alloc
258      if(dtsets(1)%ga_n_rules/=dtsets(idtset)%ga_n_rules) multivals%ga_n_rules =1
259      if(dtsets(1)%gw_nqlwl /=dtsets(idtset)%gw_nqlwl ) multivals%gw_nqlwl =1
260      if(dtsets(1)%mband    /=dtsets(idtset)%mband    ) multivals%mband    =1
261      if(dtsets(1)%natom    /=dtsets(idtset)%natom    ) multivals%natom    =1
262      if(dtsets(1)%natpawu  /=dtsets(idtset)%natpawu  ) multivals%natpawu  =1
263      if(dtsets(1)%natsph   /=dtsets(idtset)%natsph   ) multivals%natsph   =1
264      if(dtsets(1)%natvshift/=dtsets(idtset)%natvshift) multivals%natvshift=1
265      if(dtsets(1)%nberry   /=dtsets(idtset)%nberry   ) multivals%nberry   =1
266      if(dtsets(1)%nbandhf  /=dtsets(idtset)%nbandhf  ) multivals%nbandhf  =1
267      if(dtsets(1)%nconeq   /=dtsets(idtset)%nconeq   ) multivals%nconeq   =1
268      if(dtsets(1)%nfreqsp  /=dtsets(idtset)%nfreqsp  ) multivals%nfreqsp  =1
269      if(dtsets(1)%nimage   /=dtsets(idtset)%nimage   ) multivals%nimage   =1
270      if(dtsets(1)%cd_customnimfrqs  /=dtsets(idtset)%cd_customnimfrqs  ) multivals%nimfrqs  =1
271      if(dtsets(1)%nkpt     /=dtsets(idtset)%nkpt     ) multivals%nkpt     =1
272      if(dtsets(1)%nkptgw   /=dtsets(idtset)%nkptgw   ) multivals%nkptgw   =1
273      if(dtsets(1)%nkpthf*dtsets(1)%usefock /=dtsets(idtset)%nkpthf*dtsets(idtset)%usefock) multivals%nkpthf=1
274      if(dtsets(1)%nnos     /=dtsets(idtset)%nnos     ) multivals%nnos     =1
275      if(dtsets(1)%nqptdm   /=dtsets(idtset)%nqptdm   ) multivals%nqptdm   =1
276      if(dtsets(1)%nsppol*dtsets(1)%nspinor/=dtsets(idtset)%nsppol*dtsets(idtset)%nspinor) multivals%nsp=1
277      if(dtsets(1)%nsppol   /=dtsets(idtset)%nsppol   ) multivals%nsppol   =1
278      if(dtsets(1)%nspinor  /=dtsets(idtset)%nspinor  ) multivals%nspinor  =1
279      if(dtsets(1)%nsym     /=dtsets(idtset)%nsym     ) multivals%nsym     =1
280      if(dtsets(1)%ntypat   /=dtsets(idtset)%ntypat   ) multivals%ntypat   =1
281      if(dtsets(1)%ntypalch /=dtsets(idtset)%ntypalch ) multivals%ntypalch =1
282      if(dtsets(1)%nzchempot/=dtsets(idtset)%nzchempot) multivals%nzchempot=1
283    end do
284  end if
285 
286 !DEBUG
287 ! write(std_out,*)' outvars : multivals%nkpthf =',multivals%nkpthf
288 ! write(std_out,*)' outvars : dtsets(1:ndtset_alloc)%nkpthf =',dtsets(1:ndtset_alloc)%nkpthf
289 !ENDDEBUG
290 
291  nshiftk=1
292  if(sum((dtsets(1:ndtset_alloc)%kptopt)**2)/=0)then
293    first=0
294    do idtset=1,ndtset_alloc
295      kptopt=dtsets(idtset)%kptopt
296      if(kptopt>=1)then
297        if(first==0)then
298          first=1
299          nshiftk=dtsets(idtset)%nshiftk
300        else
301          if(nshiftk/=dtsets(idtset)%nshiftk)multivals%nshiftk=1
302        end if
303      end if
304    end do
305  end if
306 
307 !###########################################################
308 !### 04. Determine whether each dataset is (or not) a response calculation
309 !## (should use optdriver, isn't it ?)
310 
311  ABI_ALLOCATE(response_,(ndtset_alloc))
312  response_(:)=0
313  do idtset=1,ndtset_alloc
314    rfddk=dtsets(idtset)%rfddk
315    rfelfd=dtsets(idtset)%rfelfd
316    rfphon=dtsets(idtset)%rfphon
317    rfstrs=dtsets(idtset)%rfstrs
318    rfuser=dtsets(idtset)%rfuser
319    rfmagn=dtsets(idtset)%rfmagn
320    rf2_dkdk=dtsets(idtset)%rf2_dkdk
321    rf2_dkde=dtsets(idtset)%rf2_dkde
322    if(rfddk/=0 .or. rfelfd/=0 .or. rfphon/=0 .or. rfstrs/=0 .or. &
323 &   rfuser/=0 .or. rf2_dkdk/=0 .or. rf2_dkde/=0 .or. rfmagn/=0)then
324      response_(idtset)=1
325    end if
326  end do
327 
328 !###########################################################
329 !### 05. Determine size of work arrays
330 
331  marr=max(3*mxvals%natom,&
332 & mxvals%natsph,&
333 & mxvals%natvshift*mxvals%nsppol*mxvals%natom,&
334 & 3*mxvals%nberry,&
335 & mxvals%nimage,&
336 & 3*mxvals%nkptgw,&
337 & 3*mxvals%nkpthf,&
338 & mxvals%nkpt*mxvals%nsppol*mxvals%mband,&
339 & 3*mxvals%nkpt,npsp,&
340 & 3*mxvals%nqptdm,&
341 & mxvals%ntypat,&
342 & 9*mxvals%nsym,3*8,&
343 & 3*mxvals%natom*mxvals%nconeq,&
344 & mxvals%nnos,&
345 & 3*mxvals%nqptdm,&
346 & 3*mxvals%nzchempot*mxvals%ntypat,&
347 & 3*mxvals%gw_nqlwl,&
348 & (2*mxvals%lpawu+1)**2*max(mxvals%nsppol,mxvals%nspinor)*mxvals%natpawu*dmatpuflag,&
349 & 30 ) ! used by ga_rules TODO : replace with mxvals% ga_n_rules
350 
351 !###########################################################
352 !### 06. Initialize strimg
353 
354  ABI_ALLOCATE(strimg,(mxvals%nimage))
355  do iimage=1,mxvals%nimage
356    if(iimage<10)then
357      write(stringimage,'(i1)')iimage
358    else if(iimage<100)then
359      write(stringimage,'(i2)')iimage
360    else if(iimage<1000)then
361      write(stringimage,'(i3)')iimage
362    else if(iimage<10000)then
363      write(stringimage,'(i4)')iimage
364    end if
365    strimg(iimage)='_'//trim(stringimage)//'img'
366  end do
367  strimg(1)=''
368 
369 !###########################################################
370 !### 07. Initialize jdtset_
371 
372  ABI_ALLOCATE(jdtset_,(0:ndtset_alloc))
373  jdtset_(0:ndtset_alloc)=dtsets(0:ndtset_alloc)%jdtset
374 
375 
376 !###########################################################
377 !### 08. Print variables, for different ranges of names
378 
379  call outvar_a_h(choice,dmatpuflag,dtsets,iout,jdtset_,marr,multivals,mxvals,&
380 & ncid,ndtset,ndtset_alloc,results_out,strimg)
381 
382  call outvar_i_n(dtsets,iout,jdtset_,marr,multivals,mxvals,&
383 & ncid,ndtset,ndtset_alloc,npsp,prtvol_glob,response_,results_out,strimg)
384 
385  call outvar_o_z(choice,dtsets,iout,&
386 & jdtset_,marr,multivals,mxvals,ncid,ndtset,ndtset_alloc,npsp,prtvol_glob,&
387 & results_out,strimg,timopt)
388 
389 
390 !###########################################################
391 !## Deallocations and cleaning
392 
393  ABI_DEALLOCATE(jdtset_)
394  ABI_DEALLOCATE(response_)
395  ABI_DEALLOCATE(strimg)
396 
397  write(message,'(a,80a)')ch10,('=',mu=1,80)
398  call wrtout(iout,message,'COLL')
399 
400 #ifdef HAVE_NETCDF
401  if (ncid /= 0) then
402    ncerr=nf90_close(abs(ncid))
403    if (ncerr/=nf90_NoErr) then
404      message='Netcdf Error while closing the OUT.nc file: '//trim(nf90_strerror(ncerr))
405      MSG_ERROR(message)
406    end if
407  end if
408 #endif
409  if (.false.) write(std_out,*) ncerr
410 
411 !**************************************************************************
412 
413 end subroutine outvars