LCOV - code coverage report
Current view: top level - io - eig66_io.F90 (source / functions) Hit Total Coverage
Test: combined.info Lines: 43 61 70.5 %
Date: 2019-09-08 04:53:50 Functions: 5 5 100.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------
       2             : ! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
       3             : ! This file is part of FLEUR and available as free software under the conditions
       4             : ! of the MIT license as expressed in the LICENSE file in more detail.
       5             : !--------------------------------------------------------------------------------
       6             : 
       7             : MODULE m_eig66_io
       8             : #include "juDFT_env.h"
       9             :   USE m_types
      10             :   USE m_eig66_data
      11             :   IMPLICIT NONE
      12             :   PRIVATE
      13             : 
      14             :   PUBLIC open_eig,close_eig,reset_eig
      15             :   PUBLIC read_eig,write_eig
      16             : CONTAINS
      17             : 
      18          66 :   FUNCTION open_eig(mpi_comm,nmat,neig,nkpts,jspins,&
      19             :                     l_noco,l_create,l_real,l_soc,l_readonly,n_size,mode_in,filename)&
      20             :            RESULT(id)
      21             :     USE m_eig66_hdf,ONLY:open_eig_hdf=>open_eig
      22             :     USE m_eig66_DA ,ONLY:open_eig_DA=>open_eig
      23             :     USE m_eig66_mem,ONLY:open_eig_mem=>open_eig
      24             :     USE m_eig66_MPI,ONLY:open_eig_mpi=>open_eig
      25             :     IMPLICIT NONE
      26             :     INTEGER,INTENT(IN)          :: nmat,neig,nkpts,jspins,mpi_comm
      27             :     LOGICAL,INTENT(IN)          :: l_noco,l_readonly,l_create,l_real,l_soc
      28             :     INTEGER,INTENT(IN),OPTIONAL :: n_size,mode_in
      29             :     CHARACTER(LEN=*),INTENT(IN),OPTIONAL :: filename
      30             :     INTEGER:: id,mode
      31             : 
      32             :     INTEGER:: neig_local,isize,err
      33          66 :     if (l_soc) THEN
      34          16 :        neig_local=2*neig
      35             :     else
      36          50 :        neig_local=neig
      37             :     endif
      38          66 :     mode=-1
      39          66 :     IF (PRESENT(mode_in)) mode=mode_in
      40             : 
      41          66 :     IF (mode<0) THEN
      42             :        !Use default mode
      43             : #ifdef CPP_MPI
      44          66 :        CALL MPI_COMM_SIZE(mpi_comm,isize,err)
      45          66 :        IF (isize>1) THEN
      46          66 :            mode=MPI_mode
      47             :         ELSE
      48           0 :            mode=MEM_mode
      49             :         ENDIF   
      50             : #else
      51             :        mode=MEM_mode
      52             : #endif
      53             :        !check if default was given on command-line
      54          66 :        IF (TRIM(juDFT_string_for_argument("-eig"))=="mpi") mode=MPI_mode
      55          66 :        IF (TRIM(juDFT_string_for_argument("-eig"))=="mem") mode=MEM_mode
      56          66 :        IF (TRIM(juDFT_string_for_argument("-eig"))=="da") mode=DA_mode
      57          66 :        IF (TRIM(juDFT_string_for_argument("-eig"))=="hdf") mode=HDF_mode
      58             :     ENDIF
      59             :     !Check if mode is available
      60             : #ifndef CPP_MPI
      61             :     IF (mode==MPI_mode) CALL juDFT_error("MPI-mode not available. Recompile with CPP_MPI",calledby="eig66_io")
      62             : #else
      63          66 :     CALL MPI_COMM_SIZE(mpi_comm,isize,err)
      64          66 :     IF (isize>1.AND.((mode==DA_mode.OR.mode==mem_mode))) &
      65           0 :          CALL juDFT_error("In a parallel calculation MEM/DA-mode are not available",calledby="eig66_io")
      66             : #endif
      67             : #ifndef CPP_HDF
      68             :     IF (mode==HDF_mode) CALL juDFT_error("HDF-mode not available. Recompile with CPP_HDF",calledby="eig66_io")
      69             : #endif
      70             : 
      71          66 :     id=eig66_data_newid(mode)
      72             : 
      73             :     !PRINT *,"open_eig:",id,mode
      74             : 
      75          66 :     CALL timestart("Open file/memory for IO of eig66")
      76           0 :     SELECT CASE (eig66_data_mode(id))
      77             :     CASE (DA_mode)
      78           0 :        CALL open_eig_DA(id,nmat,neig_local,nkpts,jspins,l_create,l_real,l_soc,filename)
      79             :     CASE (hdf_mode)
      80           0 :        CALL open_eig_HDF(id,mpi_comm,nmat,neig_local,nkpts,jspins,l_create,l_real,l_soc,l_readonly,filename)
      81             :     CASE (mem_mode)
      82           0 :        CALL open_eig_MEM(id,nmat,neig_local,nkpts,jspins,l_create,l_real,l_soc,l_noco,filename)
      83             :     CASE (mpi_mode)
      84          66 :        CALL open_eig_MPI(id,mpi_comm,nmat,neig_local,nkpts,jspins,l_create,l_real,l_soc,l_noco,n_size,filename)
      85             :     CASE DEFAULT
      86          66 :        CALL juDFT_error("Invalid IO-mode in eig66_io")
      87             :     END SELECT
      88          66 :     CALL timestop("Open file/memory for IO of eig66")
      89          66 :   END FUNCTION open_eig
      90             : 
      91          48 :   SUBROUTINE close_eig(id,filename)
      92             :     USE m_eig66_hdf,ONLY:close_eig_hdf=>close_eig
      93             :     USE m_eig66_DA ,ONLY:close_eig_DA=>close_eig
      94             :     USE m_eig66_mem,ONLY:close_eig_MEM=>close_eig
      95             :     USE m_eig66_MPI,ONLY:close_eig_MPI=>close_eig
      96             :     IMPLICIT NONE
      97             :     INTEGER,INTENT(IN)                   :: id
      98             :     CHARACTER(LEN=*),INTENT(IN),OPTIONAL :: filename
      99             :     INTEGER  :: mode
     100          48 :     mode=eig66_data_mode(id)
     101             :     !PRINT*,"close_eig:",id,mode
     102           0 :     SELECT CASE (mode)
     103             :     CASE (DA_mode)
     104           0 :        CALL close_eig_DA(id,filename)
     105             :     CASE (hdf_mode)
     106           0 :        CALL close_eig_HDF(id,filename)
     107             :     CASE (mem_mode)
     108           0 :        CALL close_eig_Mem(id,filename=filename)
     109             :     CASE (MPI_mode)
     110          48 :        CALL close_eig_MPI(id,filename=filename)
     111             :     CASE (-1)
     112          48 :        CALL juDFT_error("ID not assigned in close_eig",calledby="eig66_io")
     113             :     END SELECT
     114             : 
     115          48 :   END SUBROUTINE close_eig
     116             : 
     117        2750 :   SUBROUTINE read_eig(id,nk,jspin,neig,eig,w_iks,list,zmat)
     118             :     USE m_eig66_hdf,ONLY:read_eig_hdf=>read_eig
     119             :     USE m_eig66_DA ,ONLY:read_eig_DA=>read_eig
     120             :     USE m_eig66_mem,ONLY:read_eig_mem=>read_eig
     121             :     USE m_eig66_MPI,ONLY:read_eig_MPI=>read_eig
     122             :     IMPLICIT NONE
     123             :     INTEGER, INTENT(IN)            :: id,nk,jspin
     124             :     INTEGER, INTENT(OUT),OPTIONAL  :: neig
     125             :     REAL,    INTENT(OUT),OPTIONAL  :: eig(:),w_iks(:)
     126             :     INTEGER, INTENT(IN),OPTIONAL   :: list(:)
     127             :     TYPE(t_mat),INTENT(INOUT),OPTIONAL  :: zmat
     128             :     INTEGER::n
     129        2750 :     CALL timestart("IO (read)")
     130           0 :     SELECT CASE (eig66_data_mode(id))
     131             :     CASE (DA_mode)
     132           0 :        CALL read_eig_DA(id,nk,jspin,neig,eig,w_iks,list,zmat)
     133             :     CASE (hdf_mode)
     134           0 :        CALL read_eig_hdf(id,nk,jspin,neig,eig,w_iks,list,zmat)
     135             :     CASE (mem_mode)
     136           0 :        CALL read_eig_mem(id,nk,jspin,neig,eig,w_iks,list,zmat)
     137             :     CASE (mpi_mode)
     138        2750 :        CALL read_eig_mpi(id,nk,jspin,neig,eig,w_iks,list,zmat)
     139             :     CASE (-1)
     140        2750 :        CALL juDFT_error("Could not read eig-file before opening", calledby = "eig66_io")
     141             :     END SELECT
     142        2750 :     CALL timestop("IO (read)")
     143        2750 :   END SUBROUTINE read_eig
     144             : 
     145        2007 :   SUBROUTINE write_eig(id,nk,jspin,neig,neig_total,eig,w_iks,n_start,n_end,zmat)
     146             :     USE m_eig66_hdf,ONLY:write_eig_hdf=>write_eig
     147             :     USE m_eig66_DA ,ONLY:write_eig_DA=>write_eig
     148             :     USE m_eig66_mem,ONLY:write_eig_MEM=>write_eig
     149             :     USE m_eig66_MPI,ONLY:write_eig_MPI=>write_eig
     150             :     IMPLICIT NONE
     151             :     INTEGER, INTENT(IN) :: id,nk,jspin
     152             :     INTEGER, INTENT(IN),OPTIONAL :: neig,neig_total,n_start,n_end
     153             :     REAL,    INTENT(IN),OPTIONAL :: eig(:),w_iks(:)
     154             :     TYPE(t_Mat),INTENT(IN),OPTIONAL :: zmat
     155        2007 :     CALL timestart("IO (write)")
     156           0 :     SELECT CASE (eig66_data_mode(id))
     157             :     CASE (da_mode)
     158           0 :        CALL write_eig_DA(id,nk,jspin,neig,neig_total,eig,w_iks,n_start,n_end,zmat)
     159             :     CASE (hdf_mode)
     160           0 :        CALL write_eig_HDF(id,nk,jspin,neig,neig_total,eig,w_iks,n_start,n_end,zmat)
     161             :     CASE (mem_mode)
     162           0 :        CALL write_eig_Mem(id,nk,jspin,neig,neig_total,eig,w_iks,n_start,n_end,zmat)
     163             :     CASE (MPI_mode)
     164        2007 :        CALL write_eig_MPI(id,nk,jspin,neig,neig_total,eig,w_iks,n_start,n_end,zmat)
     165             :     CASE (-1)
     166        2007 :        CALL juDFT_error("Could not write eig-file before opening", calledby = "eig66_io")
     167             :     END SELECT
     168        2007 :     CALL timestop("IO (write)")
     169        2007 :   END SUBROUTINE write_eig
     170             : 
     171         340 :   SUBROUTINE reset_eig(id,l_soc)
     172             :      USE m_eig66_MPI,ONLY:reset_eig_MPI=>reset_eig
     173             :      INTEGER, INTENT(IN) :: id
     174             :      LOGICAL, INTENT(IN) :: l_soc
     175             : 
     176         340 :      SELECT CASE (eig66_data_mode(id))
     177             :      CASE (MPI_mode)
     178         680 :         CALL reset_eig_MPI(id,l_soc)
     179             :      END SELECT
     180             : 
     181         340 :   END SUBROUTINE reset_eig
     182             : 
     183             : END MODULE m_eig66_io

Generated by: LCOV version 1.13