TABLE OF CONTENTS


ABINIT/m_abi_etsf [ Modules ]

[ Top ] [ Modules ]

NAME

 m_abi_etsf

FUNCTION

COPYRIGHT

 Copyright (C) 2006-2018 ABINIT group (DCA,YP,MJV,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 .

SOURCE

16 #if defined HAVE_CONFIG_H
17 #include "config.h"
18 #endif
19 
20 #include "abi_common.h"
21 
22 module m_abi_etsf
23 
24  use defs_basis
25  use defs_datatypes
26  use defs_abitypes
27  use defs_wvltypes
28  use m_abicore
29  use m_xmpi
30  use m_errors
31  use m_atomdata
32  use m_nctk
33  use iso_c_binding
34 #ifdef HAVE_ETSF_IO
35  use etsf_io
36 #endif
37 
38  use m_fstrings,   only : endswith
39 
40  implicit none
41 
42  private
43 
44 #ifdef HAVE_ETSF_IO
45  public :: abi_etsf_dims_init
46 #endif
47  public :: abi_etsf_init
48 
49 CONTAINS  !===========================================================

m_abi_etsf/abi_etsf_dims_init [ Functions ]

[ Top ] [ m_abi_etsf ] [ Functions ]

NAME

 abi_etsf_dims_init

FUNCTION

  Initialize the structure defining ETSF dimensions.
  starting from values stored in the dataset_type, the pseudopotential_type.
  and the wave function handler for the BIGDFT part.

INPUTS

  dtset<type(dataset_type)>=all input variables for this dataset
  psps<type(pseudopotential_type)>=variables related to pseudopotentials
  wfs<wvl_wf_type>=Object to handle wave functions for the BIGDFT part
    Presently not used, likely will be needed when ETSF-IO will be generalized to deal with PAW.
  itype = an integer to define what to put in the output file. This can
          be one of the following values (maybe a sum latter):
          1 for a density file,
          2 for a wavefunction file,
          4 for a KSS file,
          8 for the exchange potential,
         16 for the correlation potential.

OUTPUT

  dims=structure with ETSF dimensions.

PARENTS

      m_abi_etsf

CHILDREN

SOURCE

173 #ifdef HAVE_ETSF_IO
174 
175 subroutine abi_etsf_dims_init(dims, dtset, itype, psps, wfs)
176 
177 
178 !This section has been created automatically by the script Abilint (TD).
179 !Do not modify the following lines by hand.
180 #undef ABI_FUNC
181 #define ABI_FUNC 'abi_etsf_dims_init'
182 !End of the abilint section
183 
184  implicit none
185 
186 !Arguments ------------------------------------
187 !scalars
188  integer,intent(in) :: itype
189  type(dataset_type),intent(in) :: dtset
190  type(pseudopotential_type),intent(in) :: psps
191  type(wvl_wf_type),intent(in) :: wfs
192  type(etsf_dims),intent(inout) :: dims
193 
194 ! *************************************************************************
195 
196 !Set-up the dimensions
197 !=====================
198  dims%max_number_of_angular_momenta = psps%mpsang
199  dims%max_number_of_projectors      = 1
200 
201  dims%max_number_of_states   = dtset%mband
202  dims%number_of_atoms        = dtset%natom
203  dims%number_of_atom_species = dtset%ntypat
204  dims%number_of_components   = dtset%nspden
205 
206  dims%number_of_kpoints              = dtset%nkpt
207  dims%number_of_spinor_components    = dtset%nspinor
208  dims%number_of_spins                = dtset%nsppol
209  dims%number_of_symmetry_operations  = dtset%nsym
210 
211 !In the case of BigDFT, the number of coefficients are the number of wavelets.
212  if (dtset%usewvl==0) then
213    dims%max_number_of_coefficients      = dtset%mpw
214    dims%max_number_of_basis_grid_points = etsf_no_dimension
215  else
216 #ifdef HAVE_BIGDFT
217    dims%max_number_of_coefficients      = wfs%ks%lzd%Glr%wfd%nvctr_c + 7 * wfs%ks%lzd%Glr%wfd%nvctr_f
218    dims%max_number_of_basis_grid_points = wfs%ks%lzd%Glr%wfd%nvctr_c
219 #else
220    BIGDFT_NOTENABLED_ERROR()
221    if (.false.) write(std_out,*) wfs%ks
222 #endif
223  end if
224 
225  if (dtset%usepaw==1) then
226    dims%number_of_grid_points_vector1  = dtset%ngfftdg(1)
227    dims%number_of_grid_points_vector2  = dtset%ngfftdg(2)
228    dims%number_of_grid_points_vector3  = dtset%ngfftdg(3)
229  else if (dtset%usewvl==1) then
230 #ifdef HAVE_BIGDFT
231 !In the case of BigDFT, the grid size is not defined by ngfft.
232    dims%number_of_grid_points_vector1  = wfs%ks%lzd%Glr%d%n1 * 2
233    dims%number_of_grid_points_vector2  = wfs%ks%lzd%Glr%d%n2 * 2
234    dims%number_of_grid_points_vector3  = wfs%ks%lzd%Glr%d%n3 * 2
235 #endif
236  else
237    dims%number_of_grid_points_vector1  = dtset%ngfft(1)
238    dims%number_of_grid_points_vector2  = dtset%ngfft(2)
239    dims%number_of_grid_points_vector3  = dtset%ngfft(3)
240  end if
241 
242 !The density real_or_complex.
243  dims%real_or_complex_density = etsf_no_dimension
244  if (iand(itype, 1) /= 0 .or. dtset%usepaw==1) dims%real_or_complex_density = 1
245 
246 !The coefficient of wavefunctions real_or_complex.
247  dims%real_or_complex_coefficients   = etsf_no_dimension
248  if (iand(itype, 2) /= 0 .or. iand(itype, 4) /= 0) then
249    if (dtset%usewvl == 0) then
250      dims%real_or_complex_coefficients = 2 ! used in plane waves
251    else
252      dims%real_or_complex_coefficients = 1 ! used in wavelets
253    end if
254  end if
255 
256 !The gw corrections real_or_complex.
257 !Todo: Currently not exported.
258 !if (.false. .and. iand(itype, 4) /= 0) then
259  dims%real_or_complex_gw_corrections = etsf_no_dimension
260  if (iand(itype, 4) /= 0) then
261    dims%real_or_complex_gw_corrections = 2 ! used in plane waves
262  ! dims%real_or_complex_gw_corrections = 1 ! used in plane waves
263  end if
264 
265 !The potential real_or_complex.
266  dims%real_or_complex_potential = etsf_no_dimension
267  if (iand(itype, 8) /= 0 .or. iand(itype, 16) /= 0) dims%real_or_complex_potential = 1
268 
269  dims%real_or_complex_wavefunctions = etsf_no_dimension
270 
271 end subroutine abi_etsf_dims_init

m_abi_etsf/abi_etsf_init [ Functions ]

[ Top ] [ m_abi_etsf ] [ Functions ]

NAME

 abi_etsf_init

FUNCTION

  Create a NetCDF file following the ETSF file format specifications.
  It declares the dimensions and set-up the different variables, according
  to the itype argument.

INPUTS

  dtset <type(dataset_type)>=all input variables for this dataset
  filapp = character string giving the root to form the name of the GEO file
  itype = an integer to define what to put in the output file. This can
          be one of the following values (maybe a sum latter):
          1 for a density file,
          2 for a wavefunction file,
          4 for a KSS file,
          8 for the exchange potential,
         16 for the correlation potential.
  kdep= .true. if the data for the array sizes are dependant on k points.
  lmn_size=Number of (l,m,n) elements for the PAW basis set.
  psps <type(pseudopotential_type)>=variables related to pseudopotentials
  wfs <type(wvl_projector_type)>=wavefunctions informations for wavelets.

OUTPUT

  Data written in file whose name is filapp//'-etsf.nc'

PARENTS

      m_iowf

CHILDREN

SOURCE

311 subroutine abi_etsf_init(dtset,filapp,itype,kdep,lmn_size,psps,wfs)
312 
313 
314 !This section has been created automatically by the script Abilint (TD).
315 !Do not modify the following lines by hand.
316 #undef ABI_FUNC
317 #define ABI_FUNC 'abi_etsf_init'
318 !End of the abilint section
319 
320  implicit none
321 
322 !Arguments ------------------------------------
323 !scalars
324  integer,intent(in) :: itype
325  logical,intent(in) :: kdep
326  character(len=fnlen),intent(in) :: filapp
327  type(dataset_type),intent(in) :: dtset
328  type(pseudopotential_type),intent(in) :: psps
329  type(wvl_wf_type),optional,intent(in) :: wfs
330 !arrays
331  integer,intent(in) :: lmn_size(psps%npsp)
332 
333 !Local variables-------------------------------
334 #ifdef HAVE_ETSF_IO
335 !scalars
336  integer :: ncid,var_main,usewvl
337  logical :: ok
338  character(len=80) :: file_title
339  character(len=fnlen) :: filetsf
340  type(etsf_dims) :: dims
341  type(etsf_groups_flags) :: flags
342  type(etsf_io_low_error) :: error
343 #endif
344 
345 ! *************************************************************************
346 
347 #ifdef HAVE_ETSF_IO
348 !Initialize the filename
349  filetsf = nctk_ncify(filapp)
350  call wrtout(std_out,ABI_FUNC//': about to create file '//TRIM(filetsf),'COLL')
351 
352  usewvl = dtset%usewvl
353 
354 !Set-up the dimensions
355 !=====================
356  call abi_etsf_dims_init(dims,dtset,itype,psps,wfs)
357 
358 !Set-up the variables
359 !====================
360 !These mandatory values are always written by the hdr_io_etsf() routine.
361  flags%geometry  = etsf_geometry_all
362  flags%kpoints   = etsf_kpoints_red_coord_kpt + etsf_kpoints_kpoint_weights
363  flags%electrons = etsf_electrons_all - etsf_electrons_x_functional - etsf_electrons_c_functional
364  flags%basisdata = etsf_basisdata_basis_set
365 
366  if (usewvl==0) then
367    flags%basisdata = flags%basisdata + etsf_basisdata_kin_cutoff + etsf_basisdata_n_coeff
368  end if
369 
370 !These variables may be written depending on prt<something> input variables.
371  if (itype==1) then
372    flags%main = etsf_main_density
373    file_title = "Density file"
374  else if (itype == 2) then
375    if (usewvl==0) then
376      flags%basisdata = flags%basisdata + etsf_basisdata_red_coord_pw
377    else
378      flags%basisdata = flags%basisdata + etsf_basisdata_coord_grid + etsf_basisdata_n_coeff_grid
379    end if
380    flags%main = etsf_main_wfs_coeff
381    file_title = "Wavefunctions file"
382  else if (itype==4) then
383    if (usewvl==0) then
384      flags%basisdata = flags%basisdata + etsf_basisdata_red_coord_pw
385    else
386      flags%basisdata = flags%basisdata + etsf_basisdata_coord_grid + etsf_basisdata_n_coeff_grid
387    end if
388    flags%main   = etsf_main_wfs_coeff
389    flags%gwdata = etsf_gwdata_all
390    file_title = "KSS file"
391  else if (itype==8) then
392    flags%main = etsf_main_pot_x_only
393    file_title = "Exchange potential file"
394  else if (itype==16) then
395    flags%main = etsf_main_pot_c_only
396    file_title = "Correlation potential file"
397  else if (itype==24) then
398    flags%main = etsf_main_pot_xc
399    file_title = "Exchange-correlation potential file"
400  end if
401 
402 !Actually create the file
403 !========================
404 !If the group contains main, we remove it for a while to be sure to
405 !add it at the end, after ABINIT private variables.
406  var_main   = flags%main
407  flags%main = etsf_main_none
408 
409  call etsf_io_data_init(filetsf, flags, dims, file_title, &
410 & 'File generated by ABINIT with ETSF_IO', ok, error, overwrite = .true., k_dependent = kdep)
411  ETSF_CHECK_ERROR(ok, error)
412 
413 !Add the private ABINIT information when required.
414  NCF_CHECK(nctk_open_modify(ncid, filetsf, xmpi_comm_self))
415 
416 !Add the private data
417  call ini_wf_etsf(ncid,usewvl,lmn_size,psps%npsp,psps%ntypat)
418 
419 ! Add the main part as last variables in the ETSF file.
420  call etsf_io_main_def(ncid, ok, error, flags = var_main)
421  ETSF_CHECK_ERROR(ok, error)
422 
423 ! Close the file.
424  NCF_CHECK(nf90_close(ncid))
425 #else
426  ABI_UNUSED(dtset%ntypat)
427  ABI_UNUSED(filapp)
428  ABI_UNUSED(itype)
429  ABI_UNUSED(kdep)
430  ABI_UNUSED(lmn_size)
431  if(.false. .and. present(wfs))write(std_out,*)' OK'
432 #endif
433 
434 end subroutine abi_etsf_init

m_abi_etsf/etsf_dims_nullify [ Functions ]

[ Top ] [ m_abi_etsf ] [ Functions ]

NAME

 etsf_dims_nullify

FUNCTION

  Initialize the structure defining ETSF dimensions.

INPUTS

OUTPUT

  dims=structure with ETSF dimensions.

PARENTS

CHILDREN

SOURCE

 70 #ifdef HAVE_ETSF_IO
 71 
 72 subroutine etsf_dims_nullify(Dims,dimlen)
 73 
 74 
 75 !This section has been created automatically by the script Abilint (TD).
 76 !Do not modify the following lines by hand.
 77 #undef ABI_FUNC
 78 #define ABI_FUNC 'etsf_dims_nullify'
 79 !End of the abilint section
 80 
 81  implicit none
 82 
 83 !Arguments ------------------------------------
 84 !scalars
 85  integer,optional,intent(in) :: dimlen
 86  type(etsf_dims),intent(inout) :: Dims
 87 
 88 !Local variables-------------------------------
 89  integer :: my_dimlen
 90 
 91 ! *************************************************************************
 92 
 93   my_dimlen = 3; if (PRESENT(dimlen)) my_dimlen = dimlen
 94 
 95   Dims%max_number_of_angular_momenta                 = etsf_no_dimension
 96   Dims%max_number_of_basis_grid_points               = etsf_no_dimension
 97   Dims%max_number_of_coefficients                    = etsf_no_dimension
 98   Dims%max_number_of_projectors                      = etsf_no_dimension
 99   Dims%max_number_of_states                          = etsf_no_dimension
100   Dims%number_of_atoms                               = etsf_no_dimension
101   Dims%number_of_atom_species                        = etsf_no_dimension
102   Dims%number_of_cartesian_directions                = my_dimlen
103   Dims%number_of_coefficients_dielectric_function    = etsf_no_dimension
104   Dims%number_of_components                          = etsf_no_dimension
105   Dims%number_of_frequencies_dielectric_function     = etsf_no_dimension
106   Dims%number_of_grid_points_vector1                 = etsf_no_dimension
107   Dims%number_of_grid_points_vector2                 = etsf_no_dimension
108   Dims%number_of_grid_points_vector3                 = etsf_no_dimension
109   Dims%number_of_kpoints                             = etsf_no_dimension
110   Dims%number_of_localization_regions                = etsf_no_dimension
111   Dims%number_of_qpoints_dielectric_function         = etsf_no_dimension
112   Dims%number_of_qpoints_gamma_limit                 = etsf_no_dimension
113   Dims%number_of_reduced_dimensions                  = my_dimlen
114   Dims%number_of_spinor_components                   = etsf_no_dimension
115   Dims%number_of_spins                               = etsf_no_dimension
116   Dims%number_of_symmetry_operations                 = etsf_no_dimension
117   Dims%number_of_vectors                             = my_dimlen
118   Dims%real_or_complex_coefficients                  = etsf_no_dimension
119   Dims%real_or_complex_density                       = etsf_no_dimension
120   Dims%real_or_complex_gw_corrections                = etsf_no_dimension
121   Dims%real_or_complex_potential                     = etsf_no_dimension
122   Dims%real_or_complex_wavefunctions                 = etsf_no_dimension
123   Dims%symbol_length                                 = etsf_chemlen
124 
125   !Dimensions for variables that can be splitted.
126   Dims%my_max_number_of_coefficients  = etsf_no_dimension
127   Dims%my_max_number_of_states        = etsf_no_dimension
128   Dims%my_number_of_components        = etsf_no_dimension
129   Dims%my_number_of_grid_points_vect1 = etsf_no_dimension
130   Dims%my_number_of_grid_points_vect2 = etsf_no_dimension
131   Dims%my_number_of_grid_points_vect3 = etsf_no_dimension
132   Dims%my_number_of_kpoints           = etsf_no_dimension
133   Dims%my_number_of_spins             = etsf_no_dimension
134 
135 end subroutine etsf_dims_nullify

m_abi_etsf/ini_wf_etsf [ Functions ]

[ Top ] [ m_abi_etsf ] [ Functions ]

NAME

 ini_wf_etsf

FUNCTION

 Do initialization of additional dimensions and variables in wavefunction files in ETSF format.

INPUTS

  usewvl=1 if wavelets are used, 0 otherwise
  lmn_size=Number of (l,m,n) elements for the PAW basis set.
  npsp=number of pseudopotentials.
  ntypat=number of types of atoms in cell.
  ncid=the unit of the open NetCDF file.

SIDE EFFECTS

  New dimensions and variables are added to the initial NetCDF file.

PARENTS

      m_abi_etsf

CHILDREN

SOURCE

463 subroutine ini_wf_etsf(ncid,usewvl,lmn_size,npsp,ntypat)
464 
465 
466 !This section has been created automatically by the script Abilint (TD).
467 !Do not modify the following lines by hand.
468 #undef ABI_FUNC
469 #define ABI_FUNC 'ini_wf_etsf'
470 !End of the abilint section
471 
472  implicit none
473 
474 !Arguments ------------------------------------
475 !scalars
476  integer,intent(in) :: ncid,usewvl,npsp,ntypat
477 !arrays
478  integer,intent(in) :: lmn_size(npsp)
479 
480 !Local variables-------------------------------
481 #ifdef HAVE_ETSF_IO
482  integer :: ncerr
483 #endif
484 
485 ! *************************************************************************
486 
487 #ifdef HAVE_ETSF_IO
488 !Define dimensions.
489  ncerr = nctk_def_dims(ncid, [nctkdim_t("npsp", npsp), nctkdim_t("codvsnlen", 6),nctkdim_t("psptitlen", 132)])
490  NCF_CHECK(ncerr)
491 
492  if (usewvl==1) then ! Add the BigDFT private dimensions.
493    ncerr = nctk_def_dims(ncid, nctkdim_t("number_of_wavelet_resolutions", 2))
494    NCF_CHECK(ncerr)
495  end if
496 
497 !Define scalars.
498 !If variables already exist, it will check that definitions are coherent.
499  ncerr = nctk_def_iscalars(ncid, [character(len=nctk_slen) :: &
500 &   "date", "ixc", "intxc", "occopt", "pertcase", "headform", "fform", "usepaw", "usewvl"])
501  NCF_CHECK(ncerr)
502 
503  ncerr = nctk_def_dpscalars(ncid, [character(len=nctk_slen) :: &
504 &  "ecut_eff", "ecutdg", "ecutsm", "etot", "residm", "stmbias", "tphysel", "tsmear"])
505  NCF_CHECK(ncerr)
506 
507 !Multi-dimensional variables.
508  ncerr = nctk_def_arrays(ncid, [&
509    nctkarr_t("istwfk",  "i", "number_of_kpoints"),&
510    nctkarr_t("codvsn", "c", "codvsnlen"),&
511    nctkarr_t("pspcod",  "i", "npsp"),&
512    nctkarr_t("pspdat",  "i", "npsp"),&
513    nctkarr_t("pspso",  "i", "npsp"),&
514    nctkarr_t("pspxc",  "i", "npsp"),&
515    nctkarr_t("qptn",  "dp", "number_of_reduced_dimensions"),&
516    nctkarr_t("so_psp",  "i", "npsp"),&
517    nctkarr_t("symafm",  "i", "number_of_symmetry_operations"),&
518    nctkarr_t("title", "c", "psptitlen, npsp"),&
519    nctkarr_t("zionpsp",  "dp", "npsp"),&
520    nctkarr_t("znuclpsp",  "dp", "npsp"),&
521    nctkarr_t("lmn_size",  "i", "npsp")])
522  NCF_CHECK(ncerr)
523 
524 !Add the BigDFT private variables.
525  if (usewvl == 1) then
526    ncerr = nctk_def_arrays(ncid, nctkarr_t("number_of_wavelets", "i", "number_of_wavelet_resolutions"))
527    NCF_CHECK(ncerr)
528  end if
529 #else
530 
531 !if ETSF_IO is undefined, do nothing
532  ABI_UNUSED(ncid)
533  ABI_UNUSED(ntypat)
534  ABI_UNUSED(lmn_size)
535  ABI_UNUSED(usewvl)
536 #endif
537 
538 end subroutine ini_wf_etsf