!===============================================================================
!
! module_dd.F90
!
!-------------------------------------------------------------------------------
!
! Copyright (C) 2009-2010 Yoshifumi Nakamura
!
! This file is part of BQCD -- Berlin Quantum ChromoDynamics program
!
! BQCD is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! BQCD is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with BQCD.  If not, see <http://www.gnu.org/licenses/>.
!
!-------------------------------------------------------------------------------
#include "defs.h"

!-------------------------------------------------------------------------------
module module_dd
  integer,save :: ddlat(4)
  logical,save :: ddable=.false.
  logical,save :: ddallactive=.true.

  type :: type_nn
     INTEGER, dimension(:, :, :, :), pointer :: nn, nn2, volh_dd, volh_eo
     INTEGER, dimension(:, :, :), pointer :: count_dd, count_eo, proj_i
     INTEGER, dimension(:, :), pointer :: proj_c
  end type type_nn

  type :: type_nndm
     INTEGER :: dm
     INTEGER :: pe
  end type type_nndm


  type :: ddlatvol
     integer :: l(4), n(4), nh(4), ip(4)
     logical :: single(4)
     integer :: volume, vol, volh, volh_tot, num_ip
     integer, dimension (-1:1, -1:1, -1:1, -1:1) :: offset
     INTEGER, dimension(:, :, :), pointer :: list
  end type ddlatvol

  type :: global_domain
     type(ddlatvol) :: lat
     type(type_nn) :: nn
  end type global_domain

  type :: local_domain
     type(ddlatvol) :: lat
  end type local_domain

  type(global_domain), save :: gd
  type(local_domain), save :: ld

  type(type_nn), dimension(:), pointer,save :: ldnn
  type(type_nndm), dimension(:,:,:,:,:), pointer,save :: ldnndm


  integer, dimension(:,:,:), pointer, save :: ddi2, ddeo2
  integer, dimension(:,:), pointer, save :: ddi, ddeo, ddip, my_dm
  integer, dimension(:), pointer, save :: eo_dm, i_dm

!!! module module_dd
!!!
!!!module module_p_dd_interface
!!!
!!!  interface
!!!     subroutine allocate_dd_nn(nn)
!!!     INTEGER, dimension(:, :, :, :), pointer :: nn
!!!     end subroutine allocate_dd_nn
!!!  end interface
!!!
!!!end module module_p_dd_interface
!!!
!!!
!!!subroutine allocate_dd_nn(nn)
!!!  use module_dd
!!!  INTEGER, dimension(:, :, :, :), pointer :: nn
!!!  allocate(nn( ld%lat%volh_tot, EVEN:ODD, DIM, FWD:BWD))
!!!
!!!end subroutine allocate_dd_nn
!!!
!!!!subroutine allocate_dd_nn(nn,nn2,count_dd, count_eo,volh_dd, volh_eo)
!!!!  INTEGER, dimension(:, :, :, :), pointer :: nn, nn2, volh_dd, volh_eo
!!!!  INTEGER, dimension(:, :, :), pointer :: count_dd, count_eo
!!!
!!!!  allocate(nn( ld%lat%volh_tot, EVEN:ODD, DIM, FWD:BWD))
!!!!  allocate(nn2(DIM, ld%lat%volh_tot, EVEN:ODD, FWD:BWD))
!!!!  allocate(count_dd(EVEN:ODD, DIM, FWD:BWD))
!!!!  allocate(count_eo(EVEN:ODD, DIM, FWD:BWD))
!!!!  allocate(volh_dd(ld%lat%volh, EVEN:ODD, DIM, FWD:BWD))
!!!!  allocate(volh_eo(ld%lat%volh, EVEN:ODD, DIM, FWD:BWD))
!!!!end subroutine allocate_dd_nn
!!!



end

!===============================================================================
