eig66_data.F90 7.15 KB
Newer Older
1 2 3 4 5 6
!--------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------

7 8 9 10 11 12 13 14 15 16
module m_eig66_data
#include "juDFT_env.h"
#ifdef CPP_HDF
    use hdf5
#endif
    implicit none

    TYPE :: t_data
       INTEGER:: io_mode
       INTEGER:: jspins,nkpts,nmat,neig,lmax,nlotot,nlo,ntype
17
       LOGICAL:: l_dos,l_mcd,l_orb,l_real,l_soc
18 19 20 21 22
    END TYPE

    TYPE,EXTENDS(t_data):: t_data_DA
        REAL,   ALLOCATABLE:: el_s(:,:),ello_s(:,:),evac_s(:)
        INTEGER,ALLOCATABLE:: kvec_s(:,:),kveclo_s(:)
23
        INTEGER            :: recl_bas=0,recl_vec=0,recl_dos
24
        CHARACTER(LEN=20)  :: fname="eig"
25
        INTEGER            :: file_io_id_bas,file_io_id_vec,file_io_id_dos
26 27 28 29 30 31
    END TYPE

    TYPE,extends(t_data):: t_data_MPI
       INTEGER             :: n_size=1
       INTEGER             :: size_k,size_el,size_ello,size_eig
       INTEGER             :: int_handle,real_handle,eig_handle,zr_handle,zc_handle,neig_handle
32 33
       INTEGER             :: qal_handle,qvac_handle,qis_handle,qvlay_handle,qintsl_handle,qmtsl_handle
       INTEGER             :: qmtp_handle,orbcomp_handle,qstars_handle,mcd_handle,jsym_handle,ksym_handle
34 35 36 37 38
       INTEGER,ALLOCATABLE :: pe_basis(:,:),slot_basis(:,:)
       INTEGER,ALLOCATABLE :: pe_ev(:,:,:),slot_ev(:,:,:)
       INTEGER             :: irank
       INTEGER,POINTER     :: neig_data(:),int_data(:)
       REAL,POINTER        :: eig_data(:),zr_data(:),real_data(:)
39 40 41 42
       REAL,POINTER        :: qal_data(:),qvac_data(:),qis_data(:),qvlay_data(:)
       REAL,POINTER        :: qintsl_data(:),qmtsl_data(:),qmtp_data(:),orbcomp_data(:),mcd_data(:)
       COMPLEX,POINTER     :: qstars_data(:)
       INTEGER,POINTER     :: jsym_data(:),ksym_data(:)
43 44 45 46 47 48 49 50 51
       COMPLEX,POINTER     :: zc_data(:)
    END TYPE
    TYPE,EXTENDS(t_data):: t_data_hdf
#ifdef CPP_HDF
         INTEGER(HID_T) :: fid
         INTEGER(HID_T) :: esetid,evacsetid,ellosetid
         INTEGER(HID_T) :: bksetid,wksetid,ksetid
         INTEGER(HID_T) :: neigsetid,nvsetid,nmatsetid
         INTEGER(HID_T) :: energysetid,evsetid
52 53 54
         INTEGER(HID_T) :: qalsetid,qvacsetid,qissetid,qvlaysetid
         INTEGER(HID_T) :: qstarssetid,ksymsetid,jsymsetid,mcdsetid
         INTEGER(HID_T) :: qintslsetid,qmtslsetid,qmtpstid,orbcompsetid
55 56 57 58 59 60 61 62 63 64
         CHARACTER(LEN=20) :: fname="eig"
#endif
      END TYPE

   TYPE,EXTENDS(t_data):: t_data_mem
        INTEGER,ALLOCATABLE :: eig_int(:,:)
        REAL,ALLOCATABLE    :: eig_real(:,:)
        REAL,ALLOCATABLE    :: eig_eig(:,:)
        REAL,ALLOCATABLE    :: eig_vecr(:,:)
        COMPLEX,ALLOCATABLE :: eig_vecc(:,:)
65 66 67 68 69 70 71 72 73 74 75 76
        REAL,ALLOCATABLE    :: qal(:,:,:,:)
        REAL,ALLOCATABLE    :: qvac(:,:,:)
        REAL,ALLOCATABLE    :: qis(:,:)
        REAL,ALLOCATABLE    :: qvlay(:,:,:,:)
        COMPLEX,ALLOCATABLE :: qstars(:,:,:,:,:)
        INTEGER,ALLOCATABLE :: ksym(:,:)
        INTEGER,ALLOCATABLE :: jsym(:,:)
        REAL,ALLOCATABLE    :: mcd(:,:,:,:)
        REAL,ALLOCATABLE    :: qintsl(:,:,:)
        REAL,ALLOCATABLE    :: qmtsl(:,:,:)
        REAL,ALLOCATABLE    :: qmtp(:,:,:)
        REAL,ALLOCATABLE    :: orbcomp(:,:,:,:)
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
    END TYPE

    TYPE t_list
        INTEGER               :: id
        CLASS(t_data),POINTER :: data
        TYPE(t_list),POINTER  :: next=>null()
    END TYPE



    TYPE(t_list),POINTER :: linked_list=>null()
    private linked_list
    INTEGER, PARAMETER :: DA_mode=0,HDF_mode=1,MEM_mode=2,MPI_mode=3

    contains
    
93
    subroutine eig66_data_storedefault(d,jspins,nkpts,nmat,neig,lmax,nlotot,nlo,ntype,l_real,l_soc,l_dos,l_mcd,l_orb)
94 95
    CLASS(t_data)::d
    INTEGER,INTENT(IN)::jspins,nkpts,nmat,neig,lmax,nlotot,nlo,ntype
96
    LOGICAL,INTENT(IN):: l_real,l_soc
97
    LOGICAL,INTENT(IN),OPTIONAL::l_dos,l_mcd,l_orb
98 99 100 101 102 103 104 105
    d%jspins=jspins
    d%nkpts=nkpts
    d%nmat=nmat
    d%neig=neig
    d%lmax=lmax
    d%nlotot=nlotot
    d%nlo=nlo
    d%ntype=ntype
106 107
    d%l_real=l_real
    d%l_soc=l_soc
108 109 110 111 112 113 114 115 116
    if (present(l_dos)) THEN
       d%l_dos=l_dos
       d%l_mcd=l_mcd
       d%l_orb=l_orb
    else
       d%l_dos=.false.
       d%l_mcd=.false.
       d%l_orb=.false.
    endif
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
    END SUBROUTINE

    subroutine eig66_find_data(d,id,io_mode)
    IMPLICIT NONE
    INTEGER,INTENT(IN) ::id
    INTEGER,INTENT(IN),OPTIONAL :: io_mode
    CLASS(t_data),pointer::d

    TYPE(t_list),POINTER:: listpointer,lastinlist
    lastinlist=>null()

    listpointer=>linked_list
    DO WHILE(associated(listpointer))
       lastinlist=>listpointer
       if (listpointer%id==id) THEN
           d=>listpointer%data
           return
       endif
       listpointer=>listpointer%next
    enddo
    !no pointer found
    IF (present(io_mode)) THEN
       IF (.not.associated(lastinlist)) THEN
          allocate(linked_list)
          linked_list%id=id
          lastinlist=>linked_list
       ELSE
          allocate(lastinlist%next)
          lastinlist%next%id=id
          lastinlist=>lastinlist%next
       ENDIF
       SELECT CASE (io_mode)
         case (DA_MODE)
          allocate(t_data_DA::lastinlist%data)
         case (HDF_MODE)
#ifdef CPP_HDF
          allocate(t_data_HDF::lastinlist%data)
#else
          call juDFT_error("Cannot use hdf mode for IO, recompile with CPP_HDF",calledby="eig66_data")
#endif
         case (MEM_MODE)
          allocate(t_data_MEM::lastinlist%data)
         case (MPI_MODE)
          allocate(t_data_MPI::lastinlist%data)
         end select
         lastinlist%data%io_mode=io_mode
         d=>lastinlist%data
    ELSE
       call juDFT_error("BUG:Could not find data object in eig66_mpi")
    ENDIF
    END SUBROUTINE

    subroutine eig66_remove_data(id)
    INTEGER,INTENT(IN)::id

    TYPE(t_list),POINTER:: listpointer,lastpointer
    lastpointer=>null()
    listpointer=>linked_list
    loop:DO WHILE(associated(listpointer))
      IF (listpointer%id==id) THEN
        exit loop
      ENDIF
      lastpointer=>listpointer
      listpointer=>listpointer%next
    ENDDO loop

    if (.not.associated(listpointer)) call juDFT_error("BUG in eig66_data: ID not found in deleting")
    IF (associated(lastpointer)) THEN
        lastpointer%next=>listpointer%next
    ELSE
        linked_list=>listpointer%next
    ENDIF

    deallocate(listpointer)
    end subroutine

    INTEGER FUNCTION eig66_data_newid(mode)
    INTEGER,INTENT(IN)  :: mode
    TYPE(t_list),POINTER:: listpointer
    INTEGER             :: id
    CLASS(t_data),POINTER::d

    id=0
    listpointer=>linked_list
    DO WHILE(associated(listpointer))
      id=max(id,listpointer%id)
      listpointer=>listpointer%next
    ENDDO
    eig66_data_newid=id+1

    call eig66_find_data(d,id+1,mode)

    end function

    INTEGER function eig66_data_mode(id)RESULT(mode)
    INTEGER,INTENT(IN)  :: id
    TYPE(t_list),POINTER:: listpointer
    mode=-1
    listpointer=>linked_list
    DO WHILE(associated(listpointer))
      if (id==listpointer%id) THEN
           mode=listpointer%data%io_mode
           return
      ENDIF
      listpointer=>listpointer%next
    ENDDO
    END FUNCTION

end module m_eig66_data