ETSF_IO library - documentation pages

### TABLE OF CONTENTS

- etsf_io_data_write

## etsf_io_data_write

[ Top ] [ etsf_io_data_group ] [ Methods ]

NAME

etsf_io_data_write

FUNCTION

High-level routine to write a lot of ETSF variable at once.

INPUTS

- filename = the path to the file to be accessed.
- group_folder <type(etsf_groups)> = a container for different groups. All groups specified in the @groups argument must be associated.

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_data_write(filename, group_folder, lstat, error_data)

      !Arguments ------------------------------------
      character(len=*), intent(in) :: filename
      type(etsf_groups), intent(in) :: group_folder
      logical, intent(out) :: lstat
      type(etsf_io_low_error), intent(out) :: error_data
      !Local variables-------------------------------
      character(len=*),parameter :: my_name = 'etsf_io_data_write'
      integer :: ncid, i

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

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

      ! Open file for writing
      call etsf_io_low_open_modify(ncid, trim(filename), lstat, error_data = error_data)
      if (.not. lstat) then
        call etsf_io_low_error_update(error_data, my_name)
        return
      end if

      ! We switch to write mode.
      call etsf_io_low_set_write_mode(ncid, lstat, error_data = error_data)
      if (.not. lstat) then
        call etsf_io_low_error_update(error_data, my_name)
        return
      end if

      ! Put Data
      if (associated(group_folder%geometry)) then
        call etsf_io_geometry_put(ncid, group_folder%geometry, lstat, error_data)
        if (.not. lstat) then
          call etsf_io_low_error_update(error_data, my_name)
          return
        end if
      end if
      if (associated(group_folder%electrons)) then
        call etsf_io_electrons_put(ncid, group_folder%electrons, lstat, error_data)
        if (.not. lstat) then
          call etsf_io_low_error_update(error_data, my_name)
          return
        end if
      end if
      if (associated(group_folder%kpoints)) then
        call etsf_io_kpoints_put(ncid, group_folder%kpoints, lstat, error_data)
        if (.not. lstat) then
          call etsf_io_low_error_update(error_data, my_name)
          return
        end if
      end if
      if (associated(group_folder%basisdata)) then
        call etsf_io_basisdata_put(ncid, group_folder%basisdata, lstat, error_data)
        if (.not. lstat) then
          call etsf_io_low_error_update(error_data, my_name)
          return
        end if
      end if
      if (associated(group_folder%gwdata)) then
        call etsf_io_gwdata_put(ncid, group_folder%gwdata, lstat, error_data)
        if (.not. lstat) then
          call etsf_io_low_error_update(error_data, my_name)
          return
        end if
      end if
      if (associated(group_folder%dielectric)) then
        call etsf_io_dielectric_put(ncid, group_folder%dielectric, lstat, error_data)
        if (.not. lstat) then
          call etsf_io_low_error_update(error_data, my_name)
          return
        end if
      end if
      if (associated(group_folder%main)) then
        call etsf_io_main_put(ncid, group_folder%main, lstat, error_data)
        if (.not. lstat) then
          call etsf_io_low_error_update(error_data, my_name)
          return
        end if
      end if

      ! Close file
      call etsf_io_low_close(ncid, lstat, error_data = error_data)
      if (.not. lstat) call etsf_io_low_error_update(error_data, my_name)

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

    end subroutine etsf_io_data_write