Added a fallback mechanism to generate a file name when the q-point does not have a simple rational-number expression (i.e. [0 0 0.99194853094755497]). The mechanism does not really matter a lot as names are generated whil writing but read from a list when seeking the file.

git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@8716 c92efa57-630b-4861-b058-cf58834340f0
This commit is contained in:
paulatto 2012-02-23 13:26:53 +00:00
parent 058bb3f306
commit 7eab645417
2 changed files with 24 additions and 10 deletions

View File

@ -178,7 +178,7 @@ FUNCTION dfile_choose_name(xq, name, prefix, generate, equiv)
! Make up a new name
dfile_choose_name = dfile_generate_name(xq, basename)
!
! Append the new name to the file
! Append the new name to the list
iunit = open_dfile_directory(basename, prefix)
WRITE(iunit,*,iostat=ios) dfile_choose_name, xq
IF(ios/=0) CALL errore('dfile_choose_name','Cannot write dfile_directory',1)
@ -279,17 +279,18 @@ END FUNCTION dfile_generate_name
!----------------------------------------------------------------------
FUNCTION real2frac(r) RESULT (f)
!----------------------------------------------------------------------
USE kinds, ONLY : DP
USE kinds, ONLY : DP
USE wrappers, ONLY : md5_from_char
IMPLICIT NONE
REAL(DP),INTENT(in) :: r
CHARACTER(len=64) :: f
!
INTEGER :: d, n
INTEGER,PARAMETER :: max_denominator = 48000
REAL(DP),PARAMETER :: accept = 1.d-5
REAL(DP),PARAMETER :: accept = 1.d-6
CHARACTER(len=64) :: nc,dc
!
IF(max_denominator*accept*2>1._dp) &
IF(max_denominator*accept*20>1._dp) &
CALL errore('real2frac', 'incompatible parameters', 2)
! Threat zero and integers separately:
IF (ABS(r)<accept) THEN
@ -306,7 +307,25 @@ FUNCTION real2frac(r) RESULT (f)
IF( ABS(r*d-NINT(r*d)) < accept ) EXIT
ENDDO
!
IF (d > max_denominator) CALL errore('real2frac', 'not a fraction', 1)
#ifdef __ISO_C_BINDING__USE_MD5_HERE
IF (d > max_denominator) THEN
WRITE(*, '("WARNING from real2frac:",e25.15," is not a fraction, falling back to md5." )') r
! CALL md5_from_char(TRANSFER(r,f), f)
WRITE(nc,'(e64.20)') r
! WRITE(nc,'(b64)') TRANSFER(r,d)
CALL md5_from_char(nc, f)
RETURN
ENDIF
#else
! IF (d > max_denominator) CALL errore('real2frac', 'not a fraction', 1)
! this other method is less elegant, but works as well and produces shorter names
IF (d > max_denominator) THEN
WRITE(*, '("WARNING from real2frac:",e25.15," is not a fraction, falling back to hex." )') r
WRITE(f,'(Z64)') r
f='0x'//TRIM(ADJUSTL(f))
RETURN
ENDIF
#endif
!
n = NINT(r*d)
!

View File

@ -250,8 +250,6 @@ SUBROUTINE write_dfile_star(descr, source, nsym, xq, u, nq, sxq, isq, s, sr, inv
USE fft_base, ONLY : dfftp, cgather_sym
USE cell_base, ONLY : at, bg
USE ions_base, ONLY : nat, tau, amass
! USE gvect, ONLY : dfftp%nnr
! USE gvect, ONLY : nr1, nr2, nr3, dfftp%nr1x, dfftp%nr2x, dfftp%nr3x
USE symm_base, ONLY : ftau, t_rev
USE lsda_mod, ONLY : nspin
USE modes, ONLY : nirr, npert, npertx, rtau
@ -260,15 +258,12 @@ SUBROUTINE write_dfile_star(descr, source, nsym, xq, u, nq, sxq, isq, s, sr, inv
use io_files, ONLY : find_free_unit, diropn, prefix
USE constants, ONLY : tpi
USE dfile_autoname, ONLY : dfile_choose_name
! USE control_flags, ONLY : iverbosity, modenum
USE save_ph, ONLY : tmp_dir_save
USE control_ph, ONLY : search_sym
USE noncollin_module, ONLY : nspin_mag
USE mp_global, ONLY : intra_image_comm
USE mp, ONLY : mp_bcast
!USE xml_io_base, ONLY : create_directory
USE wrappers, ONLY : f_mkdir
!
IMPLICIT NONE
! input variables: