buffer_release Subroutine

private subroutine buffer_release(buffer)

Release buffer

Arguments

TypeIntentOptionalAttributesName
type(dbcsr_buffer), intent(inout) :: buffer

Contents

Source Code


Source Code

   SUBROUTINE buffer_release(buffer)
      !! Release buffer
      TYPE(dbcsr_buffer), INTENT(INOUT)                  :: buffer

      IF (buffer%has_rma_win) THEN
         CALL mp_win_unlock_all(buffer%data_win)
         CALL mp_win_free(buffer%data_win)
         CALL mp_win_unlock_all(buffer%meta_win)
         CALL mp_win_free(buffer%meta_win)
         buffer%has_rma_win = .FALSE.
         buffer%grp = mp_comm_null
         IF (buffer%subgrp .NE. mp_comm_null .AND. buffer%num_layers_3D .GT. 1) &
            CALL mp_comm_free(buffer%subgrp)
         buffer%subgrp = mp_comm_null
         buffer%num_layers_3D = 1
      END IF
      !
      IF (buffer%is_valid) THEN
         CALL dbcsr_data_release(buffer%data)
         IF (dbcsr_data_valid(buffer%trs_stackbuf)) THEN
            CALL dbcsr_data_release(buffer%trs_stackbuf)
         END IF
         IF (dbcsr_data_valid(buffer%data_before_resize)) THEN
            CALL dbcsr_data_release(buffer%data_before_resize)
         END IF
         buffer%is_valid = .FALSE.
      END IF
      IF (ASSOCIATED(buffer%meta)) THEN
         CALL memory_deallocate(buffer%meta, memtype_mpi_buffer)
         NULLIFY (buffer%meta)
      END IF
      IF (ASSOCIATED(buffer%meta_before_resize)) THEN
         CALL memory_deallocate(buffer%meta_before_resize, memtype_mpi_buffer)
         NULLIFY (buffer%meta_before_resize)
      END IF
      IF (ASSOCIATED(buffer%meta_red3D)) THEN
         CALL memory_deallocate(buffer%meta_red3D, memtype_mpi_buffer)
         NULLIFY (buffer%meta_red3D)
      END IF
   END SUBROUTINE buffer_release