LCOV - code coverage report
Current view: top level - wannier - wann_write_amn.F (source / functions) Hit Total Coverage
Test: combined.info Lines: 0 35 0.0 %
Date: 2019-09-08 04:53:50 Functions: 0 1 0.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_wann_write_amn
       8             :       contains
       9           0 :       subroutine wann_write_amn(
      10             :      >               mpi_comm,l_p0,filename,title,
      11             :      >               nbnd,fullnkpts,nwfs,
      12             :      >               irank,isize,l_freeformat,
      13           0 :      <               amn,l_unformatted)
      14             : c**********************************************************
      15             : c     This subroutine is used to write several matrices to 
      16             : c     files: WF1.mmn, WF1.amn, etc. The corresponding 
      17             : c     filename has to be provided as input. To be concrete
      18             : c     all explanations given in the following refer to
      19             : c     WF1.amn/WF2.amn.
      20             : c
      21             : c     MPI-Version: Collect the contributions to the matrix
      22             : c     A^{k}_{mn} from the various processors.
      23             : c
      24             : c     Write the matrix A^{k}_{mn} to file WF1.amn/WF2.amn
      25             : c
      26             : c     Frank Freimuth
      27             : c**********************************************************
      28             :       implicit none
      29             :       integer, intent(in)    :: mpi_comm
      30             :       logical, intent(in)    :: l_p0,l_unformatted
      31             :       character, intent(in)  :: filename*(*)
      32             :       character, intent(in)  :: title*(*)
      33             : 
      34             :       integer, intent(in)    :: nbnd
      35             :       integer, intent(in)    :: fullnkpts
      36             :       integer, intent(in)    :: nwfs
      37             : 
      38             :       integer, intent(in)    :: irank,isize
      39             :       logical, intent(in)    :: l_freeformat
      40             : 
      41             :       complex, intent(inout) :: amn(:,:,:)
      42             : 
      43             :       integer :: ikpt,nwf,i
      44             :       integer :: cpu_index
      45             : #ifdef CPP_MPI
      46             :       include 'mpif.h'
      47             :       integer :: ierr(3)
      48             :       integer :: stt(MPI_STATUS_SIZE)
      49             : #include "cpp_double.h"
      50             : #endif
      51             : 
      52             : #ifdef CPP_MPI
      53             : c******************************************************
      54             : c     Collect contributions to the amn matrix from the
      55             : c     various processors.
      56             : c******************************************************
      57           0 :       if(isize.ne.1)then
      58           0 :        do ikpt=1,fullnkpts
      59           0 :         if(l_p0)then
      60           0 :          do cpu_index=1,isize-1
      61           0 :           if(mod(ikpt-1,isize).eq.cpu_index)then
      62             :            call MPI_RECV(
      63             :      &             amn(1:nbnd,1:nwfs,ikpt),nbnd*nwfs,
      64             :      &             CPP_MPI_COMPLEX,cpu_index,
      65           0 :      &             ikpt,mpi_comm,stt,ierr)
      66             :           endif !processors
      67             :          enddo !cpu_index
      68             :         else
      69           0 :          if(mod(ikpt-1,isize).eq.irank)then
      70             :            call MPI_SEND(
      71             :      &             amn(1:nbnd,1:nwfs,ikpt),nbnd*nwfs,
      72             :      &             CPP_MPI_COMPLEX,0,
      73           0 :      &             ikpt,mpi_comm,ierr)
      74             :          endif !processors
      75             :         endif ! l_p0
      76           0 :         call MPI_BARRIER(mpi_comm,ierr)
      77             :        enddo !ikpt 
      78             :       endif !isize
      79             : #endif
      80             : 
      81           0 :       if(l_p0)then
      82           0 :        if(l_unformatted)then
      83           0 :           open (305,file=filename,form='unformatted')
      84           0 :        elseif(l_freeformat)then
      85           0 :           open(305,file=filename,recl=1000)
      86             :        else
      87           0 :           open (305,file=filename)
      88             :        endif
      89             :        
      90           0 :        if(l_unformatted)then
      91           0 :         write(305)nbnd,fullnkpts,nwfs
      92           0 :         write(305)amn
      93             :        else
      94           0 :         write (305,*)title
      95           0 :         write (305,'(i5,i7,i5)') nbnd,fullnkpts,nwfs
      96           0 :         if(l_freeformat)then
      97           0 :          do ikpt = 1,fullnkpts
      98           0 :           do nwf = 1,nwfs
      99           0 :            do i = 1,nbnd
     100           0 :             write (305,*) i,nwf,ikpt,
     101           0 :      &              real(amn(i,nwf,ikpt)),aimag(amn(i,nwf,ikpt))
     102             :            enddo !i
     103             :           enddo !nwf
     104             :          enddo !ikpt
     105             :         else
     106           0 :          do ikpt = 1,fullnkpts
     107           0 :           do nwf = 1,nwfs
     108           0 :            do i = 1,nbnd
     109           0 :             write (305,'(i5,i5,i7,3x,2f18.12)') i,nwf,ikpt,
     110           0 :      &              real(amn(i,nwf,ikpt)),aimag(amn(i,nwf,ikpt))
     111             :            enddo !i
     112             :           enddo !nwf
     113             :          enddo !ikpt
     114             :         endif 
     115             :        endif
     116           0 :        close(305)
     117             :       endif
     118             : 
     119           0 :       end subroutine wann_write_amn
     120             :       end module m_wann_write_amn

Generated by: LCOV version 1.13