Commit c8f77bc3 authored by Gregor Michalicek's avatar Gregor Michalicek

First steps towards introducing the potential I/O wrappers

parent b431148a
......@@ -15,6 +15,7 @@ io/nocoInputCheck.F90
io/inpnoco.F90
io/loddop.f90
io/cdn_io.f90
io/pot_io.f90
io/rw_inp.f90
io/rw_noco.f90
io/r_inpXML.F90
......
......@@ -62,9 +62,9 @@ MODULE m_cdn_io
REAL, INTENT (OUT) :: fr(atoms%jmtd,0:sphhar%nlhd,atoms%ntype,input%jspins), fz(vacuum%nmzd,2,input%jspins)
! local variables
INTEGER :: mode, datend, k, i, iVac, j, iUnit
LOGICAL :: l_exist, l_rhomatFile
CHARACTER(len=30) :: filename
INTEGER :: mode, datend, k, i, iVac, j, iUnit
LOGICAL :: l_exist, l_rhomatFile
CHARACTER(LEN=30) :: filename
CALL getMode(mode)
......@@ -112,7 +112,7 @@ MODULE m_cdn_io
INQUIRE(file=TRIM(ADJUSTL(filename)),EXIST=l_exist)
IF(.NOT.l_exist) THEN
CALL juDFT_error("charge density file missing",calledby ="readDensity")
CALL juDFT_error("charge density file "//TRIM(ADJUSTL(filename))//" missing",calledby ="readDensity")
END IF
iUnit = 93
......
!--------------------------------------------------------------------------------
! 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.
!--------------------------------------------------------------------------------
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!
!!! This module is a wrapper for the potential I/O
!!!
!!! GM'17
!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
MODULE m_pot_io
USE m_types
USE m_juDFT
USE m_loddop
USE m_wrtdop
IMPLICIT NONE
PRIVATE
PUBLIC readPotential, writePotential
PUBLIC POT_ARCHIVE_TYPE_TOT_const, POT_ARCHIVE_TYPE_COUL_const
PUBLIC POT_ARCHIVE_TYPE_X_const
INTEGER, PARAMETER :: POT_ARCHIVE_TYPE_TOT_const = 1
INTEGER, PARAMETER :: POT_ARCHIVE_TYPE_COUL_const = 2
INTEGER, PARAMETER :: POT_ARCHIVE_TYPE_X_const = 3
INTEGER, PARAMETER :: POT_DIRECT_MODE = 1
INTEGER, PARAMETER :: POT_STREAM_MODE = 2
INTEGER, PARAMETER :: POT_HDF5_MODE = 3
CONTAINS
SUBROUTINE readPotential(stars,vacuum,atoms,sphhar,input,sym,archiveType,&
iter,fr,fpw,fz,fzxy)
TYPE(t_stars),INTENT(IN) :: stars
TYPE(t_vacuum),INTENT(IN) :: vacuum
TYPE(t_atoms),INTENT(IN) :: atoms
TYPE(t_sphhar),INTENT(IN) :: sphhar
TYPE(t_input),INTENT(IN) :: input
TYPE(t_sym),INTENT(IN) :: sym
INTEGER, INTENT (OUT) :: iter
INTEGER, INTENT (IN) :: archiveType
! ..
! .. Array Arguments ..
COMPLEX, INTENT (OUT) :: fpw(stars%n3d,input%jspins), fzxy(vacuum%nmzxyd,stars%n2d-1,2,input%jspins)
REAL, INTENT (OUT) :: fr(atoms%jmtd,0:sphhar%nlhd,atoms%ntype,input%jspins), fz(vacuum%nmzd,2,input%jspins)
! local variables
INTEGER :: mode, iUnit
LOGICAL :: l_exist
CHARACTER(len=30) :: filename
CALL getMode(mode)
IF(mode.EQ.POT_HDF5_MODE) THEN
INQUIRE(FILE='pot.hdf',EXIST=l_exist)
IF (l_exist) THEN
!load density from pot.hdf and exit subroutine
RETURN
ELSE
WRITE(*,*) 'pot.hdf file not found.'
WRITE(*,*) 'Falling back to stream access file pot.str.'
mode = POT_STREAM_MODE
END IF
END IF
IF(mode.EQ.POT_STREAM_MODE) THEN
INQUIRE(FILE='pot.str',EXIST=l_exist)
IF (l_exist) THEN
!load density from cdn.str and exit subroutine
RETURN
ELSE
WRITE(*,*) 'pot.str file not found.'
WRITE(*,*) 'Falling back to direct access file.'
mode = POT_DIRECT_MODE
END IF
END IF
IF (mode.EQ.POT_DIRECT_MODE) THEN
filename = 'illegalPotentialArchive'
IF (archiveType.EQ.POT_ARCHIVE_TYPE_TOT_const) THEN
filename = 'pottot'
END IF
IF (archiveType.EQ.POT_ARCHIVE_TYPE_COUL_const) THEN
filename = 'potcoul'
END IF
IF (archiveType.EQ.POT_ARCHIVE_TYPE_X_const) THEN
filename = 'potx'
END IF
INQUIRE(file=TRIM(ADJUSTL(filename)),EXIST=l_exist)
IF(.NOT.l_exist) THEN
CALL juDFT_error("potential file "//TRIM(ADJUSTL(filename))//" missing",calledby ="readPotential")
END IF
iUnit = 11
OPEN (iUnit,file=TRIM(ADJUSTL(filename)),form='unformatted',status='unknown')
CALL loddop(stars,vacuum,atoms,sphhar,input,sym,&
iUnit,iter,fr,fpw,fz,fzxy)
CLOSE(iUnit)
END IF
END SUBROUTINE readPotential
SUBROUTINE writePotential(stars,vacuum,atoms,sphhar,input,sym,archiveType,&
iter,fr,fpw,fz,fzxy)
TYPE(t_stars),INTENT(IN) :: stars
TYPE(t_vacuum),INTENT(IN) :: vacuum
TYPE(t_atoms),INTENT(IN) :: atoms
TYPE(t_sphhar),INTENT(IN) :: sphhar
TYPE(t_input),INTENT(IN) :: input
TYPE(t_sym),INTENT(IN) :: sym
INTEGER, INTENT (IN) :: iter
INTEGER, INTENT (IN) :: archiveType
! ..
! .. Array Arguments ..
COMPLEX, INTENT (IN) :: fpw(stars%n3d,input%jspins), fzxy(vacuum%nmzxyd,stars%n2d-1,2,input%jspins)
REAL, INTENT (IN) :: fr(atoms%jmtd,0:sphhar%nlhd,atoms%ntype,input%jspins), fz(vacuum%nmzd,2,input%jspins)
! local variables
INTEGER :: mode, iUnit
LOGICAL :: l_exist
CHARACTER(len=30) :: filename
CALL getMode(mode)
IF(mode.EQ.POT_HDF5_MODE) THEN
! Write potential to pot.hdf file
STOP 'POT_HDF5_MODE not yet implemented!'
ELSE IF(mode.EQ.POT_STREAM_MODE) THEN
! Write potential to pot.str file
STOP 'POT_STREAM_MODE not yet implemented!'
ELSE
! Direct mode
filename = 'illegalPotentialArchive'
IF (archiveType.EQ.POT_ARCHIVE_TYPE_TOT_const) THEN
filename = 'pottot'
END IF
IF (archiveType.EQ.POT_ARCHIVE_TYPE_COUL_const) THEN
filename = 'potcoul'
END IF
IF (archiveType.EQ.POT_ARCHIVE_TYPE_X_const) THEN
filename = 'potx'
END IF
iUnit = 11
OPEN (iUnit,file=TRIM(ADJUSTL(filename)),form='unformatted',status='unknown')
CALL wrtdop(stars,vacuum,atoms,sphhar,input,sym,&
iUnit,iter,fr,fpw,fz,fzxy)
CLOSE(iUnit)
END IF
END SUBROUTINE writePotential
SUBROUTINE getMode(mode)
INTEGER, INTENT(OUT) :: mode
mode = POT_DIRECT_MODE
IF (juDFT_was_argument("-stream_pot")) mode=POT_STREAM_MODE
IF (juDFT_was_argument("-hdf_pot")) mode=POT_HDF5_MODE
END SUBROUTINE getMode
END MODULE m_pot_io
......@@ -45,7 +45,7 @@ CONTAINS
USE m_force_a4
USE m_force_a3
USE m_forcew
USE m_loddop
USE m_pot_io
USE m_cdn_io
USE m_icorrkeys
USE m_types
......@@ -150,11 +150,8 @@ CONTAINS
!+for
! ---> reload the COULOMB potential
!
OPEN (11,file='potcoul',form='unformatted',status='old')
REWIND 11
CALL loddop(stars,vacuum,atoms,sphhar, input,sym,&
11, iter,vr,vpw,vz,vxy)
CLOSE (11)
CALL readPotential(stars,vacuum,atoms,sphhar,input,sym,POT_ARCHIVE_TYPE_COUL_const,&
iter,vr,vpw,vz,vxy)
!
! CLASSICAL HELLMAN-FEYNMAN FORCE
!
......@@ -163,12 +160,9 @@ CONTAINS
IF (input%l_f) THEN
!
! core contribution to force: needs TOTAL POTENTIAL and core charge
OPEN (8,file='pottot',form='unformatted',status='old')
REWIND 8
CALL loddop(stars,vacuum,atoms,sphhar, input,sym,&
8, iter,vr,vpw,vz,vxy)
CLOSE (8)
!
CALL readPotential(stars,vacuum,atoms,sphhar,input,sym,POT_ARCHIVE_TYPE_TOT_const,&
iter,vr,vpw,vz,vxy)
CALL force_a4(atoms,sphhar,input, vr, results%force)
!
ENDIF
......
......@@ -34,6 +34,7 @@ CONTAINS
USE m_checkdop
USE m_wrtdop
USE m_cdn_io
USE m_pot_io
USE m_qfix
USE m_types
USE m_od_vvac
......@@ -410,20 +411,18 @@ CONTAINS
END IF
END IF
IF (input%total) THEN
OPEN (11,file='potcoul',form='unformatted',status='unknown')
DO js = 1,input%jspins
! to enable a GW calculation,
vpw_w(1:stars%ng3,js)=vpw_w(1:stars%ng3,js)/stars%nstr(1:stars%ng3) ! the PW-coulomb part is not
! used otherwise anyway.
ENDDO
CALL wrtdop(stars,vacuum,atoms,sphhar, input,sym,&
11, iter,vr,vpw_w,vz,vxy)
CALL writePotential(stars,vacuum,atoms,sphhar,input,sym,POT_ARCHIVE_TYPE_COUL_const,&
iter,vr,vpw_w,vz,vxy)
DO js = 1,input%jspins
DO i = 1,stars%ng3
vpw_w(i,js)=vpw_w(i,js)*stars%nstr(i)
ENDDO
ENDDO
CLOSE(11)
END IF
IF (sliceplot%plpot) THEN
OPEN (11,file='potcoul_pl',form='unformatted',status='unknown')
......@@ -836,30 +835,13 @@ CONTAINS
! **************** reanalyze vpw *************************
! call cpu_time(cp0)
IF (input%total) THEN
! ----->write potential to file 8
! -> the following procedure is required in order to run
! correctly on the helga parallel cluster in Hamburg end 2005
! Paolo & YM
l_pottot = .FALSE.
INQUIRE (file='pottot',exist=l_pottot)
IF (l_pottot) THEN
OPEN (8,file='pottot',form='unformatted',status='unknown')
CLOSE (8,status='delete')
WRITE(6,*) 'vgen: pottot deleted'
ENDIF
OPEN (8,file='pottot',form='unformatted',status='unknown')
REWIND 8
DO js=1,input%jspins
DO i=1,stars%ng3
vpw_w(i,js)=vpw_w(i,js)/stars%nstr(i)
ENDDO
ENDDO
CALL wrtdop(stars,vacuum,atoms,sphhar, input,sym,&
8, iter,vr,vpw_w,vz,vxy) ! vpw_w
CLOSE(8)
OPEN (8,file='potx',form='unformatted',status='unknown')
REWIND 8
CALL writePotential(stars,vacuum,atoms,sphhar,input,sym,POT_ARCHIVE_TYPE_TOT_const,&
iter,vr,vpw_w,vz,vxy)
DO js=1,input%jspins
DO i=1,stars%ng3
......@@ -867,11 +849,8 @@ CONTAINS
ENDDO
ENDDO
CALL wrtdop(stars,vacuum,atoms,sphhar, input,sym,&
8, iter,vxr,vxpw_w,vz,vxy)
CLOSE(8)
CALL writePotential(stars,vacuum,atoms,sphhar,input,sym,POT_ARCHIVE_TYPE_X_const,&
iter,vxr,vxpw_w,vz,vxy)
END IF
ENDIF ! mpi%irank == 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment