On 01/08/2014 06:49 PM, Oleg Rubel wrote:
I tried to compile the FORTRAN code you attached. It has the include statement
use util, only: line_count
use structmod, only: struct, struct_read
use const, only: BUFSZ
I was able to find 'util.f' in the w2w package, but not 'structmod'
and 'const'. Would you please send me those too.
Sorry, I forgot about that. I attach ‘util.F’ (which contains all those
modules) and a header file it needs. The ‘util.f’ from the current
wien2wannier distribution will not work with this ‘vec2ascii.f90’.
When compiling remember that for the ‘.F’ file you have tell that
compiler that it is free-form, so
$ ifort -warn all -free util.F vec2ascii.f90 -o vec2ascii
or
$ gfortran -ffree-form -Wall util.F vec2ascii.f90 -o vec2ascii
(of course you need to use the same as for lapw1 …)
Elias
!!! wien2wannier/util/util.f90
!!!
!!!Collection of routines for the programs in util/ and woptic/
!!!
!!! Copyright 2010-2012 Philipp Wissgott
!!! Copyright 2013 Elias Assmann
!--- Constants mathematical and configurational ---
module const
use iso_fortran_env, only: int32
implicit none
public
integer, parameter :: BUFSZ = 256
!! Default kinds
integer, parameter :: DP = selected_real_kind(15,300) ! inherited from W90
integer, parameter :: IP = int32
!! Kinds for WIEN-compatibility
real*4, private :: four_real
real*8, private :: eight_real
complex*16, private :: sixteen_complex
integer, parameter :: R4 = kind(four_real)
integer, parameter :: R8 = kind(eight_real)
integer, parameter :: C16= kind(sixteen_complex)
real(DP), parameter :: PI = 3.1415926535897932d0
real(DP), parameter :: ORTHO_TEST = 1.d-12
real(DP), parameter :: SQ3= sqrt(3d0)
end module const
!--- Assorted miscellanea ---
MODULE util
use const, only: DP, BUFSZ
implicit none
private
public :: string, inverse3x3, ptime, uppercase, lowercase, line_count
interface string
module procedure int2str, real2str
end interface string
contains
character(len=10) function int2str(n)
integer, intent(in) :: n
write(int2str,(I5)) n
end function int2str
character(len=15) function real2str(r)
real(DP), intent(in) :: r
write(real2str,(E16.9)) r
end function real2str
subroutine inverse3x3(a, ainv)
!inverse of th 3x3 matrix A
implicit none
real(DP), intent(in) :: a(3,3)
real(DP), intent(out) :: ainv(3,3)
real(DP) :: det
det = a(1,1)*a(2,2)*a(3,3) + a(1,2)*a(2,3)*a(3,1)
+a(1,3)*a(2,1)*a(3,2) - a(3,1)*a(2,2)*a(1,3)
-a(1,1)*a(3,2)*a(2,3) - a(2,1)*a(1,2)*a(3,3)
ainv(1,1) = ( a(2,2)*a(3,3) - a(2,3)*a(3,2) ) / det
ainv(2,1) = (- a(2,1)*a(3,3) + a(2,3)*a(3,1) ) / det
ainv(3,1) = ( a(2,1)*a(3,2) - a(2,2)*a(3,1) ) / det
ainv(1,2) = (- a(1,2)*a(3,3) + a(1,3)*a(3,2) ) / det
ainv(2,2) = ( a(1,1)*a(3,3) - a(1,3)*a(3,1) ) / det
ainv(3,2) = (- a(1,1)*a(3,2) + a(1,2)*a(3,1) ) / det
ainv(1,3) = ( a(1,2)*a(2,3) - a(1,3)*a(2,2) ) / det
ainv(2,3) = (- a(1,1)*a(2,3) + a(1,3)*a(2,1) ) / det
ainv(3,3) = ( a(1,1)*a(2,2) - a(1,2)*a(2,1) ) / det
end subroutine inverse3x3
subroutine ptime(descr, unit)
character(len=*), intent(in), optional :: descr
integer, intent(in), optional :: unit
character(len=*), parameter :: fmt = ('Times for ', A, T33, '(sec):',
F8.3, ' wall;', F9.3)!, ' cpu =', F8.3, ' user +', F8.3, ' sys')
real(DP), save :: cputime1, cputime2
integer,save :: walltime1, walltime2, count_rate
integer,save :: default_lun
integer :: lun
if (.not. present(descr)) then
call cpu_time(cputime1)
call system_clock(walltime1, count_rate)
if (present(unit)) default_lun=unit
return
end if
if (present(unit)) then
lun=unit
else
lun=default_lun
end if
call cpu_time(cputime2)
call system_clock(walltime2)
write(lun, fmt) descr, real(walltime2-walltime1)/count_rate,
(cputime2-cputime1)
walltime1 = walltime2
cputime1 = cputime2
end subroutine ptime
pure function uppercase(str)
character(*), intent(in) :: str
character(len(str)) :: uppercase
integer :: ic, i
character(26), parameter :: CAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
character(26), parameter :: low = 'abcdefghijklmnopqrstuvwxyz'
uppercase = str
do i = 1, len_trim(str)
ic = index(low, str(i:i))
if (ic 0) uppercase(i:i) = CAP(ic:ic)
end do
end function uppercase
pure function lowercase(str)
character(*), intent(in) :: str
character(len(str)) :: lowercase
integer :: ic, i
character(26), parameter :: CAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
character(26), parameter :: low = 'abcdefghijklmnopqrstuvwxyz'
lowercase = str
do i = 1, len_trim(str)
ic =