ETSF_IO library - documentation pages

### TABLE OF CONTENTS

- etsf_io_kpoints_def

## etsf_io_kpoints_def

[ Top ] [ etsf_kpoints ] [ Methods ]

NAME

etsf_io_kpoints_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

- ncid = integer returned by an 'open' NetCDF call. The file can be either in define or write mode. This status can be changed by the call.
- k_dependent = (optional) use this argument to set the attribute flag 'k_dependent' to 'yes' or 'no' on variables that have it. If no variable in the group has the attribute 'k_dependent', this argument has no effect. The default value is .true. (which puts 'yes' in the file).
- flags = (optional) One can choose the variables of the group that will be defined (and disk allocated) using this flag. This is a sum of values taken from #FLAGS_VARIABLES.
- split <type(etsf_split)> = (optional) for each array associated in the type, the dimension used to declared the variables sizes will be 'my_/something/'.

OUTPUT

- lstat = return .true. if all the actions succeed, if not the status of the file is undefined.
- error_data <type(etsf_io_low_error)> = contains the details of the error is @lstat is false.

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_kpoints_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_kpoints_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_kpoints_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_kpoints_all
      end if
      ! Consistency checks.
      if (my_flags < etsf_kpoints_none .or. my_flags > etsf_kpoints_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
      end if

      if (iand(my_flags, etsf_kpoints_kpoint_grid_shift) /= 0) then
        call etsf_io_low_def_var(ncid, "kpoint_grid_shift", &
          & etsf_io_low_double, &
          & (/ pad("number_of_reduced_dimensions") /), &
          & 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_kpoints_kpoint_grid_vectors) /= 0) then
        call etsf_io_low_def_var(ncid, "kpoint_grid_vectors", &
          & etsf_io_low_double, &
          & (/ pad("number_of_reduced_dimensions"), &
          &    pad("number_of_vectors") /), &
          & 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_kpoints_mp_folding) /= 0) then
        call etsf_io_low_def_var(ncid, "monkhorst_pack_folding", &
          & etsf_io_low_integer, &
          & (/ pad("number_of_vectors") /), &
          & 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_kpoints_red_coord_kpt) /= 0) then
        call etsf_io_low_def_var(ncid, "reduced_coordinates_of_kpoints", &
          & etsf_io_low_double, &
          & (/ pad("number_of_reduced_dimensions"), &
          &    split_dims%number_of_kpoints /), &
          & 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_kpoints_kpoint_weights) /= 0) then
        call etsf_io_low_def_var(ncid, "kpoint_weights", &
          & etsf_io_low_double, &
          & (/ split_dims%number_of_kpoints /), &
          & 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_kpoints_def : exit'
    !ENDDEBUG

    end subroutine etsf_io_kpoints_def