TABLE OF CONTENTS


etsf_io_gwdata_def

[ Top ] [ etsf_gwdata ] [ Methods ]

NAME

etsf_io_gwdata_def

FUNCTION

The given ETSF file must be opened and in define state (see etsf_io_low_set_define_mode() to change it). Then, all variable of the group are defined. All required dimensions must have already defined (see etsf_io_dims_def(). If some dimensions are missing, then the variable is not defined and no error are generated.

One can specify which variable may be splitted using the optional argument @split. For each associated array in this structure, variable with appropriated dimensions will use my_<something> instead of <something>.

INPUTS

OUTPUT

NOTES

This file has been automatically generated by the autogen_subroutines.py script. Any change you would bring to it will systematically be overwritten.

SOURCE

subroutine etsf_io_gwdata_def(ncid, lstat, error_data, k_dependent, flags, &
  & split)

  !Arguments ------------------------------------
  integer, intent(in) :: ncid
  logical, intent(out) :: lstat
  type(etsf_io_low_error), intent(out) :: error_data
  logical, optional, intent(in) :: k_dependent
  integer, optional, intent(in) :: flags
  type(etsf_split), optional, intent(in) :: split

  !Local variables-------------------------------
  character(len = *), parameter :: my_name = 'etsf_io_gwdata_def'
  logical :: my_k_dependent
  integer :: my_flags
  type(etsf_split) :: my_split
  integer :: ivar
  type(split_dim_names) :: split_dims


  ! *************************************************************************

!DEBUG
!write (*,*) 'etsf_io_gwdata_def : enter'
!ENDDEBUG

  ! Get values for optional arguments, set default.
  if (present(k_dependent)) then
    my_k_dependent = k_dependent
  else
    my_k_dependent = .true.
  end if
  if (present(flags)) then
    my_flags = flags
  else
    my_flags = etsf_gwdata_all
  end if
  ! Consistency checks.
  if (my_flags < etsf_gwdata_none .or. my_flags > etsf_gwdata_all) then
    call etsf_io_low_error_set(error_data, ERROR_MODE_DEF, ERROR_TYPE_ARG, my_name, &
                             & tgtname = "flags", errmess = "value out of bounds")
    lstat = .false.
    return
  end if
  
  ! Set the name for dimensions that could be splitted.
  if (present(split)) then
    if (associated(split%my_kpoints)) then
      write(split_dims%number_of_kpoints, "(A)") &
        & "my_number_of_kpoints"
    end if
    if (associated(split%my_spins)) then
      write(split_dims%number_of_spins, "(A)") &
        & "my_number_of_spins"
    end if
    if (associated(split%my_coefficients)) then
      write(split_dims%max_number_of_coefficients, "(A)") &
        & "my_max_number_of_coefficients"
    end if
    if (associated(split%my_states)) then
      write(split_dims%max_number_of_states, "(A)") &
        & "my_max_number_of_states"
    end if
  end if
  
  if (iand(my_flags, etsf_gwdata_gw_corrections) /= 0) then
    call etsf_io_low_def_var(ncid, "gw_corrections", &
      & etsf_io_low_double, &
      & (/ pad("real_or_complex_gw_corrections"), &
      &    split_dims%max_number_of_states, &
      &    split_dims%number_of_kpoints, &
      &    split_dims%number_of_spins /), &
      & lstat, ncvarid = ivar, error_data = error_data)
    ! We raise don't raise an error if a dimension is missing.
    if (.not. lstat .and. (error_data%access_mode_id /= ERROR_MODE_INQ .or. &
      & error_data%target_type_id /= ERROR_TYPE_DID)) then
      call etsf_io_low_error_update(error_data, my_name)
      return
    end if
  end if
  
  if (iand(my_flags, etsf_gwdata_kb_coeff_sig) /= 0) then
    call etsf_io_low_def_var(ncid, "kb_formfactor_sign", &
      & etsf_io_low_integer, &
      & (/ pad("max_number_of_projectors"), &
      &    pad("max_number_of_angular_momenta"), &
      &    pad("number_of_atom_species") /), &
      & lstat, ncvarid = ivar, error_data = error_data)
    ! We raise don't raise an error if a dimension is missing.
    if (.not. lstat .and. (error_data%access_mode_id /= ERROR_MODE_INQ .or. &
      & error_data%target_type_id /= ERROR_TYPE_DID)) then
      call etsf_io_low_error_update(error_data, my_name)
      return
    end if
  end if
  
  if (iand(my_flags, etsf_gwdata_kb_coeff) /= 0) then
    call etsf_io_low_def_var(ncid, "kb_formfactors", &
      & etsf_io_low_double, &
      & (/ split_dims%max_number_of_coefficients, &
      &    split_dims%number_of_kpoints, &
      &    pad("max_number_of_projectors"), &
      &    pad("max_number_of_angular_momenta"), &
      &    pad("number_of_atom_species") /), &
      & lstat, ncvarid = ivar, error_data = error_data)
    ! We raise don't raise an error if a dimension is missing.
    if (.not. lstat .and. (error_data%access_mode_id /= ERROR_MODE_INQ .or. &
      & error_data%target_type_id /= ERROR_TYPE_DID)) then
      call etsf_io_low_error_update(error_data, my_name)
      return
    end if
  end if
  
  if (iand(my_flags, etsf_gwdata_kb_coeff_der) /= 0) then
    call etsf_io_low_def_var(ncid, "kb_formfactor_derivative", &
      & etsf_io_low_double, &
      & (/ split_dims%max_number_of_coefficients, &
      &    split_dims%number_of_kpoints, &
      &    pad("max_number_of_projectors"), &
      &    pad("max_number_of_angular_momenta"), &
      &    pad("number_of_atom_species") /), &
      & lstat, ncvarid = ivar, error_data = error_data)
    ! We raise don't raise an error if a dimension is missing.
    if (.not. lstat .and. (error_data%access_mode_id /= ERROR_MODE_INQ .or. &
      & error_data%target_type_id /= ERROR_TYPE_DID)) then
      call etsf_io_low_error_update(error_data, my_name)
      return
    end if
  end if
  ! If we reach the end, then it should be OK.
  lstat = .true.


!DEBUG
!write (*,*) 'etsf_io_gwdata_def : exit'
!ENDDEBUG

end subroutine etsf_io_gwdata_def