eig66_io.F90 10.3 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
MODULE m_eig66_io
#include "juDFT_env.h"
9
  USE m_types
10 11 12
  USE m_eig66_data
  IMPLICIT NONE
  PRIVATE
13

14 15 16 17
  PUBLIC open_eig,close_eig
  PUBLIC read_eig, write_eig
  PUBLIC read_dos,write_dos
CONTAINS
18

19 20 21 22
  FUNCTION open_eig(mpi_comm,nmat,neig,nkpts,jspins,lmax,nlo,ntype,nlotot,&
                    l_noco,l_create,l_real,l_soc,l_readonly,n_size,mode_in,&
                    filename,layers,nstars,ncored,nsld,nat,l_dos,l_mcd,l_orb)&
           RESULT(id)
23 24 25 26 27 28
    USE m_eig66_hdf,ONLY:open_eig_hdf=>open_eig
    USE m_eig66_DA ,ONLY:open_eig_DA=>open_eig
    USE m_eig66_mem,ONLY:open_eig_mem=>open_eig
    USE m_eig66_MPI,ONLY:open_eig_mpi=>open_eig
    IMPLICIT NONE
    INTEGER,INTENT(IN)          :: nmat,neig,nkpts,jspins,lmax,nlo,ntype,nlotot,mpi_comm
29
    LOGICAL,INTENT(IN)          :: l_noco,l_readonly,l_create,l_real,l_soc
30
    INTEGER,INTENT(IN),OPTIONAL :: n_size,mode_in
31
    LOGICAL,INTENT(IN),OPTIONAL :: l_dos,l_mcd,l_orb
32
    CHARACTER(LEN=*),INTENT(IN),OPTIONAL :: filename
33
    INTEGER,INTENT(IN),OPTIONAL :: layers,nstars,ncored,nsld,nat
34 35 36
    INTEGER:: id,mode

    INTEGER:: neig_local,isize,err
37 38 39 40 41
    if (l_soc) THEN
       neig_local=2*neig
    else
       neig_local=neig
    endif
42
    mode=-1
43
    IF (PRESENT(mode_in)) mode=mode_in
44 45 46 47 48 49 50 51 52

    IF (mode<0) THEN
       !Use default mode
#ifdef CPP_MPI
       mode=MPI_mode
#else
       mode=MEM_mode
#endif
       !check if default was given on command-line
53 54 55 56
       IF (juDFT_was_argument("-mpi")) mode=MPI_mode
       IF (juDFT_was_argument("-mem")) mode=MEM_mode
       IF (juDFT_was_argument("-da")) mode=DA_mode
       IF (juDFT_was_argument("-hdf")) mode=HDF_mode
57 58 59
    ENDIF
    !Check if mode is available
#ifndef CPP_MPI
60
    IF (mode==MPI_mode) CALL juDFT_error("MPI-mode not available. Recompile with CPP_MPI",calledby="eig66_io")
61
#else
62 63 64
    CALL MPI_COMM_SIZE(mpi_comm,isize,err)
    IF (isize>1.AND.((mode==DA_mode.OR.mode==mem_mode))) &
         CALL juDFT_error("In a parallel calculation MEM/DA-mode are not available",calledby="eig66_io")
65 66
#endif
#ifndef CPP_HDF
67
    IF (mode==HDF_mode) CALL juDFT_error("HDF-mode not available. Recompile with CPP_HDF",calledby="eig66_io")
68 69
#endif

70
    id=eig66_data_newid(mode)
71

Daniel Wortmann's avatar
Daniel Wortmann committed
72
    !PRINT *,"open_eig:",id,mode
73

74
    CALL timestart("Open file/memory for IO of eig66")
75
    SELECT CASE (eig66_data_mode(id))
76
    CASE (DA_mode)
77
       CALL open_eig_DA(id,nmat,neig_local,nkpts,jspins,lmax,nlo,ntype,nlotot,l_create,l_real,l_soc,l_dos,l_mcd,l_orb,filename,layers,nstars,ncored,nsld,nat)
78
    CASE (hdf_mode)
Daniel Wortmann's avatar
Daniel Wortmann committed
79
       CALL open_eig_HDF(id,mpi_comm,nmat,neig_local,nkpts,jspins,lmax,nlo,ntype,l_create,l_real,l_soc,nlotot,l_readonly,l_dos,l_mcd,l_orb,filename,layers,nstars,ncored,nsld,nat)
80
    CASE (mem_mode)
81
       CALL open_eig_MEM(id,nmat,neig_local,nkpts,jspins,lmax,nlo,ntype,l_create,l_real,l_soc,nlotot,l_noco,l_dos,l_mcd,l_orb,filename,layers,nstars,ncored,nsld,nat)
82
    CASE (mpi_mode)
83
       CALL open_eig_MPI(id,mpi_comm,nmat,neig_local,nkpts,jspins,lmax,nlo,ntype,l_create,l_real,l_soc,nlotot,l_noco,n_size,l_dos,l_mcd,l_orb,filename,layers,nstars,ncored,nsld,nat)
84 85
    CASE DEFAULT
       CALL juDFT_error("Invalid IO-mode in eig66_io")
86
    END SELECT
87 88
    CALL timestop("Open file/memory for IO of eig66")
  END FUNCTION open_eig
89

90
  SUBROUTINE close_eig(id,filename)
91 92 93 94 95 96 97 98 99
    USE m_eig66_hdf,ONLY:close_eig_hdf=>close_eig
    USE m_eig66_DA ,ONLY:close_eig_DA=>close_eig
    USE m_eig66_mem,ONLY:close_eig_MEM=>close_eig
    USE m_eig66_MPI,ONLY:close_eig_MPI=>close_eig
    IMPLICIT NONE
    INTEGER,INTENT(IN)                   :: id
    CHARACTER(LEN=*),INTENT(IN),OPTIONAL :: filename
    INTEGER  :: mode
    mode=eig66_data_mode(id)
Daniel Wortmann's avatar
Daniel Wortmann committed
100
    !PRINT*,"close_eig:",id,mode
101
    SELECT CASE (mode)
102 103 104 105 106 107 108 109 110 111
    CASE (DA_mode)
       CALL close_eig_DA(id,filename)
    CASE (hdf_mode)
       CALL close_eig_HDF(id,filename)
    CASE (mem_mode)
       CALL close_eig_Mem(id,filename=filename)
    CASE (MPI_mode)
       CALL close_eig_MPI(id,filename=filename)
    CASE (-1)
       CALL juDFT_error("ID not assigned in close_eig",calledby="eig66_io")
112 113
    END SELECT

114
  END SUBROUTINE close_eig
115

Daniel Wortmann's avatar
Daniel Wortmann committed
116
  SUBROUTINE read_eig(id,nk,jspin,nv,nmat,k1,k2,k3,bk,wk,neig,eig,w_iks,el,ello,evac,kveclo,n_start,n_end,zmat)
117 118 119 120 121 122 123 124
    USE m_eig66_hdf,ONLY:read_eig_hdf=>read_eig
    USE m_eig66_DA ,ONLY:read_eig_DA=>read_eig
    USE m_eig66_mem,ONLY:read_eig_mem=>read_eig
    USE m_eig66_MPI,ONLY:read_eig_MPI=>read_eig
    IMPLICIT NONE
    INTEGER, INTENT(IN)            :: id,nk,jspin
    INTEGER, INTENT(OUT),OPTIONAL  :: nv,nmat
    INTEGER, INTENT(OUT),OPTIONAL  :: neig
Daniel Wortmann's avatar
Daniel Wortmann committed
125
    REAL,    INTENT(OUT),OPTIONAL  :: eig(:),w_iks(:)
126 127 128 129
    INTEGER, INTENT(OUT),OPTIONAL  :: k1(:),k2(:),k3(:),kveclo(:)
    REAL,    INTENT(OUT),OPTIONAL  :: evac(:),ello(:,:),el(:,:)
    REAL,    INTENT(OUT),OPTIONAL  :: bk(:),wk
    INTEGER, INTENT(IN),OPTIONAL   :: n_start,n_end
130
    TYPE(t_zMAT),INTENT(INOUT),OPTIONAL  :: zmat
131 132 133
    INTEGER::n
    CALL timestart("IO (read)")
    SELECT CASE (eig66_data_mode(id))
134
    CASE (DA_mode)
Daniel Wortmann's avatar
Daniel Wortmann committed
135
       CALL read_eig_DA(id,nk,jspin,nv,nmat,k1,k2,k3,bk,wk,neig,eig,w_iks,el,ello,evac,kveclo,n_start,n_end,zmat)
136
    CASE (hdf_mode)
Daniel Wortmann's avatar
Daniel Wortmann committed
137
       CALL read_eig_hdf(id,nk,jspin,nv,nmat,k1,k2,k3,bk,wk,neig,eig,w_iks,el,ello,evac,kveclo,n_start,n_end,zmat)
138
    CASE (mem_mode)
Daniel Wortmann's avatar
Daniel Wortmann committed
139
       CALL read_eig_mem(id,nk,jspin,nv,nmat,k1,k2,k3,bk,wk,neig,eig,w_iks,el,ello,evac,kveclo,n_start,n_end,zmat)
140
    CASE (mpi_mode)
Daniel Wortmann's avatar
Daniel Wortmann committed
141
       CALL read_eig_mpi(id,nk,jspin,nv,nmat,k1,k2,k3,bk,wk,neig,eig,w_iks,el,ello,evac,kveclo,n_start,n_end,zmat)
142
    CASE (-1)
143
       CALL juDFT_error("Could not read eig-file before opening", calledby = "eig66_io")
144
    END SELECT
145 146
    CALL timestop("IO (read)")
  END SUBROUTINE read_eig
147

Daniel Wortmann's avatar
Daniel Wortmann committed
148
  SUBROUTINE write_eig(id,nk,jspin,neig,neig_total,nv,nmat,k1,k2,k3,bk,wk,eig,w_iks,el,ello,evac,nlotot,kveclo,n_start,n_end,zmat)
149 150 151 152 153 154 155 156 157
    USE m_eig66_hdf,ONLY:write_eig_hdf=>write_eig
    USE m_eig66_DA ,ONLY:write_eig_DA=>write_eig
    USE m_eig66_mem,ONLY:write_eig_MEM=>write_eig
    USE m_eig66_MPI,ONLY:write_eig_MPI=>write_eig
    IMPLICIT NONE
    INTEGER, INTENT(IN) :: id,nk,jspin
    REAL,    INTENT(IN),OPTIONAL :: wk
    INTEGER, INTENT(IN),OPTIONAL :: neig,neig_total,nv,nmat,nlotot,n_start,n_end
    INTEGER, INTENT(IN),OPTIONAL :: k1(:),k2(:),k3(:),kveclo(:)
Daniel Wortmann's avatar
Daniel Wortmann committed
158
    REAL,    INTENT(IN),OPTIONAL :: bk(3),eig(:),el(:,:),evac(2),ello(:,:),w_iks(:)
159
    TYPE(t_zMat),INTENT(IN),OPTIONAL :: zmat
160 161 162
    CALL timestart("IO (write)")
    SELECT CASE (eig66_data_mode(id))
    CASE (da_mode)
Daniel Wortmann's avatar
Daniel Wortmann committed
163
       CALL write_eig_DA(id,nk,jspin,neig,neig_total,nv,nmat,k1,k2,k3,bk,wk,eig,w_iks,el,ello,evac,nlotot,kveclo,n_start,n_end,zmat)
164
    CASE (hdf_mode)
Daniel Wortmann's avatar
Daniel Wortmann committed
165
       CALL write_eig_HDF(id,nk,jspin,neig,neig_total,nv,nmat,k1,k2,k3,bk,wk,eig,w_iks,el,ello,evac,nlotot,kveclo,n_start,n_end,zmat)
166
    CASE (mem_mode)
Daniel Wortmann's avatar
Daniel Wortmann committed
167
       CALL write_eig_Mem(id,nk,jspin,neig,neig_total,nv,nmat,k1,k2,k3,bk,wk,eig,w_iks,el,ello,evac,nlotot,kveclo,n_start,n_end,zmat)
168
    CASE (MPI_mode)
Daniel Wortmann's avatar
Daniel Wortmann committed
169
       CALL write_eig_MPI(id,nk,jspin,neig,neig_total,nv,nmat,k1,k2,k3,bk,wk,eig,w_iks,el,ello,evac,nlotot,kveclo,n_start,n_end,zmat)
170
    CASE (-1)
171
       CALL juDFT_error("Could not write eig-file before opening", calledby = "eig66_io")
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
    END SELECT
    CALL timestop("IO (write)")
  END SUBROUTINE write_eig

  SUBROUTINE write_dos(id,nk,jspin,qal,qvac,qis,qvlay,qstars,ksym,jsym,mcd,qintsl,qmtsl,qmtp,orbcomp)
    USE m_eig66_hdf,ONLY:write_dos_hdf=>write_dos
    USE m_eig66_DA ,ONLY:write_dos_DA=>write_dos
    USE m_eig66_mem,ONLY:write_dos_MEM=>write_dos
    USE m_eig66_MPI,ONLY:write_dos_MPI=>write_dos
    IMPLICIT NONE
    INTEGER, INTENT(IN)          :: id,nk,jspin
    REAL,INTENT(IN)              :: qal(:,:,:),qvac(:,:),qis(:),qvlay(:,:,:)
    COMPLEX,INTENT(IN)           :: qstars(:,:,:,:)
    INTEGER,INTENT(IN)           :: ksym(:),jsym(:)
    REAL,INTENT(IN),OPTIONAL     :: mcd(:,:,:)
    REAL,INTENT(IN),OPTIONAL     :: qintsl(:,:),qmtsl(:,:),qmtp(:,:),orbcomp(:,:,:)
    CALL timestart("IO (dos-write)")
    SELECT CASE (eig66_data_mode(id))
    CASE (da_mode)
       CALL write_dos_DA(id,nk,jspin,qal,qvac,qis,qvlay,qstars,ksym,jsym,mcd,qintsl,qmtsl,qmtp,orbcomp)
    CASE (hdf_mode)
       CALL write_dos_HDF(id,nk,jspin,qal,qvac,qis,qvlay,qstars,ksym,jsym,mcd,qintsl,qmtsl,qmtp,orbcomp)
    CASE (mem_mode)
       CALL write_dos_Mem(id,nk,jspin,qal,qvac,qis,qvlay,qstars,ksym,jsym,mcd,qintsl,qmtsl,qmtp,orbcomp)
    CASE (MPI_mode)
       CALL write_dos_MPI(id,nk,jspin,qal,qvac,qis,qvlay,qstars,ksym,jsym,mcd,qintsl,qmtsl,qmtp,orbcomp)
    CASE (-1)
199
       CALL juDFT_error("Could not write DOS to eig-file before opening", calledby = "eig66_io")
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
    END SELECT
    CALL timestop("IO (dos-write)")
  END SUBROUTINE write_dos


  SUBROUTINE read_dos(id,nk,jspin,qal,qvac,qis,qvlay,qstars,ksym,jsym,mcd,qintsl,qmtsl,qmtp,orbcomp)
    USE m_eig66_hdf,ONLY:read_dos_hdf=>read_dos
    USE m_eig66_DA ,ONLY:read_dos_DA=>read_dos
    USE m_eig66_mem,ONLY:read_dos_MEM=>read_dos
    USE m_eig66_MPI,ONLY:read_dos_MPI=>read_dos
    IMPLICIT NONE
    INTEGER, INTENT(IN)          :: id,nk,jspin
    REAL,INTENT(OUT)              :: qal(:,:,:),qvac(:,:),qis(:),qvlay(:,:,:)
    COMPLEX,INTENT(OUT)           :: qstars(:,:,:,:)
    INTEGER,INTENT(OUT)           :: ksym(:),jsym(:)
    REAL,INTENT(OUT),OPTIONAL     :: mcd(:,:,:)
    REAL,INTENT(OUT),OPTIONAL     :: qintsl(:,:),qmtsl(:,:),qmtp(:,:),orbcomp(:,:,:)
    CALL timestart("IO (dos-read)")
218
    SELECT CASE (eig66_data_mode(id))
219 220 221 222 223 224 225 226 227
    CASE (da_mode)
       CALL read_dos_DA(id,nk,jspin,qal,qvac,qis,qvlay,qstars,ksym,jsym,mcd,qintsl,qmtsl,qmtp,orbcomp)
    CASE (hdf_mode)
       CALL read_dos_HDF(id,nk,jspin,qal,qvac,qis,qvlay,qstars,ksym,jsym,mcd,qintsl,qmtsl,qmtp,orbcomp)
    CASE (mem_mode)
       CALL read_dos_Mem(id,nk,jspin,qal,qvac,qis,qvlay,qstars,ksym,jsym,mcd,qintsl,qmtsl,qmtp,orbcomp)
    CASE (MPI_mode)
       CALL read_dos_MPI(id,nk,jspin,qal,qvac,qis,qvlay,qstars,ksym,jsym,mcd,qintsl,qmtsl,qmtp,orbcomp)
    CASE (-1)
228
       CALL juDFT_error("Could not DOS from read eig-file before opening", calledby = "eig66_io")
229
    END SELECT
230 231
    CALL timestop("IO (dos-read)")
  END SUBROUTINE read_dos
232 233

END MODULE m_eig66_io