mirror of
https://gitlab.com/scemama/EZFIO.git
synced 2024-10-14 20:11:53 +02:00
commit
4fb3b5080b
54
bin/archive_ezfio.py
Executable file
54
bin/archive_ezfio.py
Executable file
@ -0,0 +1,54 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
sys.path = [ os.path.dirname(__file__)+"/../Python" ]+sys.path
|
||||||
|
import cPickle as pickle
|
||||||
|
import zlib
|
||||||
|
from ezfio import ezfio_obj, ezfio
|
||||||
|
|
||||||
|
# Hide errors
|
||||||
|
def f(where,txt):
|
||||||
|
raise IOError
|
||||||
|
ezfio.error = f
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
do_verbose = False
|
||||||
|
if "-v" in sys.argv:
|
||||||
|
do_verbose = True
|
||||||
|
sys.argv.remove("-v")
|
||||||
|
|
||||||
|
if len(sys.argv) == 1:
|
||||||
|
print "syntax: %s <EZFIO_Filename>"%(sys.argv[0])
|
||||||
|
sys.exit(1)
|
||||||
|
ezfio_filename = sys.argv[1]
|
||||||
|
while ezfio_filename[-1] == "/":
|
||||||
|
ezfio_filename = ezfio_filename[:-1]
|
||||||
|
|
||||||
|
ezfio.set_filename(ezfio_filename)
|
||||||
|
|
||||||
|
get_functions = filter(
|
||||||
|
lambda x: x.startswith("has_"),
|
||||||
|
ezfio_obj.__dict__.keys() )
|
||||||
|
|
||||||
|
d = {}
|
||||||
|
for f in get_functions:
|
||||||
|
f_name = f[4:]
|
||||||
|
try:
|
||||||
|
exec """d['%s'] = ezfio.%s"""%(f_name,f_name)
|
||||||
|
except:
|
||||||
|
if do_verbose:
|
||||||
|
print "%-40s [%5s]"%(f_name, "Empty")
|
||||||
|
else:
|
||||||
|
if do_verbose:
|
||||||
|
print "%-40s [%5s]"%(f_name, " OK ")
|
||||||
|
|
||||||
|
dump = zlib.compress(pickle.dumps(d))
|
||||||
|
file = open(ezfio_filename+".ezar","w")
|
||||||
|
file.write(dump)
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
52
bin/unarchive_ezfio.py
Executable file
52
bin/unarchive_ezfio.py
Executable file
@ -0,0 +1,52 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
sys.path = [ os.path.dirname(__file__)+"/../Python" ]+sys.path
|
||||||
|
import cPickle as pickle
|
||||||
|
import zlib
|
||||||
|
from ezfio import ezfio_obj, ezfio
|
||||||
|
|
||||||
|
# Hide errors
|
||||||
|
def f(where,txt):
|
||||||
|
raise IOError
|
||||||
|
ezfio.error = f
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) == 1:
|
||||||
|
print "syntax: %s <EZFIO_Archive.ezar>"%(sys.argv[0])
|
||||||
|
sys.exit(1)
|
||||||
|
ezfio_filename = sys.argv[1].split(".ezar")[0]
|
||||||
|
|
||||||
|
file = open(ezfio_filename+".ezar","r")
|
||||||
|
dump = file.read()
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
ezfio.set_filename(ezfio_filename)
|
||||||
|
|
||||||
|
d = pickle.loads(zlib.decompress(dump))
|
||||||
|
|
||||||
|
set_functions = d.keys()
|
||||||
|
|
||||||
|
nerrors_old = len(d)+1
|
||||||
|
nerrors = nerrors_old+1
|
||||||
|
while nerrors != nerrors_old:
|
||||||
|
nerrors_old = nerrors
|
||||||
|
nerrors = 0
|
||||||
|
failed = []
|
||||||
|
for f_name in set_functions:
|
||||||
|
try:
|
||||||
|
exec """ezfio.%s = d['%s']"""%(f_name,f_name)
|
||||||
|
except:
|
||||||
|
nerrors += 1
|
||||||
|
failed.append(f_name)
|
||||||
|
|
||||||
|
if nerrors != 0:
|
||||||
|
print "Unarchive failed:"
|
||||||
|
for i in failed:
|
||||||
|
print i
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -24,36 +24,31 @@
|
|||||||
|
|
||||||
BEGIN_PROVIDER [ integer, PID ]
|
BEGIN_PROVIDER [ integer, PID ]
|
||||||
&BEGIN_PROVIDER [ character*(8), PID_str ]
|
&BEGIN_PROVIDER [ character*(8), PID_str ]
|
||||||
implicit none
|
implicit none
|
||||||
BEGIN_DOC
|
BEGIN_DOC
|
||||||
! Current process ID
|
! Current process ID
|
||||||
END_DOC
|
END_DOC
|
||||||
integer :: getpid
|
integer :: getpid
|
||||||
PID = getpid()
|
PID = getpid()
|
||||||
write(PID_str,'(I8.8)') PID
|
write(PID_str,'(I8.8)') PID
|
||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
logical function ezfio_exists(path)
|
logical function ezfio_exists(path)
|
||||||
implicit none
|
implicit none
|
||||||
character*(*) :: path
|
character*(*) :: path
|
||||||
inquire(file=trim(path)//'/.version',exist=ezfio_exists)
|
inquire(file=trim(path)//'/.version',exist=ezfio_exists)
|
||||||
if (ezfio_exists) then
|
if (ezfio_exists) then
|
||||||
open(unit=libezfio_iunit,file=trim(path)//'/.version')
|
open(unit=libezfio_iunit,file=trim(path)//'/.version')
|
||||||
character*(32) :: V
|
character*(32) :: V
|
||||||
read(libezfio_iunit,*) V
|
read(libezfio_iunit,*) V
|
||||||
close(libezfio_iunit)
|
close(libezfio_iunit)
|
||||||
! integer :: char_to_version
|
|
||||||
! if (char_to_version(V) > char_to_version(libezfio_version)) then
|
|
||||||
! call ezfio_error(irp_here, "This file was generated with version "//trim(V)//&
|
|
||||||
! " but the current installed version is "//trim(libezfio_version)//".")
|
|
||||||
! endif
|
|
||||||
endif
|
endif
|
||||||
end function
|
end function
|
||||||
|
|
||||||
subroutine ezfio_mkdir(path)
|
subroutine ezfio_mkdir(path)
|
||||||
implicit none
|
implicit none
|
||||||
character*(*) :: path
|
character*(*) :: path
|
||||||
logical :: ezfio_exists
|
logical :: ezfio_exists
|
||||||
if (libezfio_read_only) then
|
if (libezfio_read_only) then
|
||||||
call ezfio_error(irp_here,'Read-only file.')
|
call ezfio_error(irp_here,'Read-only file.')
|
||||||
endif
|
endif
|
||||||
@ -63,15 +58,14 @@ subroutine ezfio_mkdir(path)
|
|||||||
write(libezfio_iunit,'(A)') libezfio_version
|
write(libezfio_iunit,'(A)') libezfio_version
|
||||||
close(libezfio_iunit)
|
close(libezfio_iunit)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
end subroutine
|
end subroutine
|
||||||
|
|
||||||
|
|
||||||
subroutine libezfio_openz(filename,mode,err)
|
subroutine libezfio_openz(filename,mode,err)
|
||||||
implicit none
|
implicit none
|
||||||
character*(*) :: filename, mode
|
character*(*) :: filename, mode
|
||||||
character*(1024) :: fifo
|
character*(1024) :: fifo
|
||||||
integer :: err
|
integer :: err
|
||||||
fifo = trim(filename)//'.'//PID_str
|
fifo = trim(filename)//'.'//PID_str
|
||||||
err=1
|
err=1
|
||||||
|
|
||||||
@ -89,8 +83,8 @@ end
|
|||||||
|
|
||||||
subroutine libezfio_closez(filename,mode)
|
subroutine libezfio_closez(filename,mode)
|
||||||
implicit none
|
implicit none
|
||||||
character*(*) :: filename, mode
|
character*(*) :: filename, mode
|
||||||
character*(1024) :: fifo
|
character*(1024) :: fifo
|
||||||
fifo = trim(filename)//'.'//PID_str
|
fifo = trim(filename)//'.'//PID_str
|
||||||
if (mode(1:1) == 'w') then
|
if (mode(1:1) == 'w') then
|
||||||
close(unit=libezfio_iunit)
|
close(unit=libezfio_iunit)
|
||||||
@ -108,12 +102,12 @@ from f_types import format, t_short
|
|||||||
template = """
|
template = """
|
||||||
subroutine ezfio_read_%(type_short)s(dir,fil,dat)
|
subroutine ezfio_read_%(type_short)s(dir,fil,dat)
|
||||||
implicit none
|
implicit none
|
||||||
character*(*), intent(in) :: dir, fil
|
character*(*), intent(in) :: dir, fil
|
||||||
%(type)s, intent(out) :: dat
|
%(type)s, intent(out) :: dat
|
||||||
character*(1024) :: l_filename
|
character*(1024) :: l_filename
|
||||||
l_filename=trim(dir)//'/'//fil
|
l_filename=trim(dir)//'/'//fil
|
||||||
open(unit=libezfio_iunit,file=l_filename,form='FORMATTED', &
|
open(unit=libezfio_iunit,file=l_filename,form='FORMATTED', &
|
||||||
action='READ',err=9)
|
action='READ',err=9)
|
||||||
read(libezfio_iunit,%(fmt)s,end=9,err=9) dat
|
read(libezfio_iunit,%(fmt)s,end=9,err=9) dat
|
||||||
close(libezfio_iunit)
|
close(libezfio_iunit)
|
||||||
return
|
return
|
||||||
@ -123,9 +117,9 @@ end
|
|||||||
|
|
||||||
subroutine ezfio_write_%(type_short)s(dir,fil,dat)
|
subroutine ezfio_write_%(type_short)s(dir,fil,dat)
|
||||||
implicit none
|
implicit none
|
||||||
character*(*), intent(in) :: dir, fil
|
character*(*), intent(in) :: dir, fil
|
||||||
%(type)s, intent(in) :: dat
|
%(type)s, intent(in) :: dat
|
||||||
character*(1024) :: l_filename(2)
|
character*(1024) :: l_filename(2)
|
||||||
if (libezfio_read_only) then
|
if (libezfio_read_only) then
|
||||||
call ezfio_error(irp_here,'Read-only file.')
|
call ezfio_error(irp_here,'Read-only file.')
|
||||||
endif
|
endif
|
||||||
@ -139,45 +133,45 @@ end
|
|||||||
|
|
||||||
subroutine ezfio_read_array_%(type_short)s(dir,fil,rank,dims,dim_max,dat)
|
subroutine ezfio_read_array_%(type_short)s(dir,fil,rank,dims,dim_max,dat)
|
||||||
implicit none
|
implicit none
|
||||||
character*(*), intent(in) :: dir, fil
|
character*(*), intent(in) :: dir, fil
|
||||||
integer :: rank
|
integer :: rank
|
||||||
integer :: dims(rank)
|
integer :: dims(rank)
|
||||||
integer :: dim_max
|
integer :: dim_max
|
||||||
%(type)s :: dat(dim_max)
|
%(type)s :: dat(dim_max)
|
||||||
integer :: err
|
integer :: err
|
||||||
character*(1024) :: l_filename
|
character*(1024) :: l_filename
|
||||||
l_filename=trim(dir)//'/'//fil//'.gz'
|
l_filename=trim(dir)//'/'//fil//'.gz'
|
||||||
|
|
||||||
err = 0
|
err = 0
|
||||||
call libezfio_openz(trim(l_filename),'rb',err)
|
call libezfio_openz(trim(l_filename),'rb',err)
|
||||||
if (err == 0) then
|
if (err == 0) then
|
||||||
integer :: rank_read
|
integer :: rank_read
|
||||||
integer :: dims_read(rank), i
|
integer :: dims_read(rank), i
|
||||||
|
|
||||||
read(libezfio_iunit,'(I3)') rank_read
|
read(libezfio_iunit,'(I3)') rank_read
|
||||||
if (rank_read /= rank) then
|
if (rank_read /= rank) then
|
||||||
call ezfio_error(irp_here,'Rank of data '//trim(l_filename)//&
|
call ezfio_error(irp_here,'Rank of data '//trim(l_filename)// &
|
||||||
' different from array.')
|
' different from array.')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if (err /= 0) then
|
if (err /= 0) then
|
||||||
call ezfio_error(irp_here,'Error reading data in '//trim(l_filename)//&
|
call ezfio_error(irp_here,'Error reading data in '//trim(l_filename)//&
|
||||||
'.')
|
'.')
|
||||||
endif
|
endif
|
||||||
read(libezfio_iunit,'(30(I20,X))') dims_read(1:rank)
|
read(libezfio_iunit,'(30(I20,X))') dims_read(1:rank)
|
||||||
do i=1,rank
|
do i=1,rank
|
||||||
if (dims_read(i) /= dims(i)) then
|
if (dims_read(i) /= dims(i)) then
|
||||||
call ezfio_error(irp_here,'Dimensions of data '//trim(l_filename)//&
|
call ezfio_error(irp_here,'Dimensions of data '//trim(l_filename)//&
|
||||||
' different from array.')
|
' different from array.')
|
||||||
endif
|
endif
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
do i=1,dim_max
|
do i=1,dim_max
|
||||||
if (err /= 0) then
|
if (err /= 0) then
|
||||||
call ezfio_error(irp_here,'Error reading data in '//trim(l_filename)//&
|
call ezfio_error(irp_here,'Error reading data in '//trim(l_filename)//&
|
||||||
'.')
|
'.')
|
||||||
endif
|
endif
|
||||||
read(libezfio_iunit,%(fmt)s) dat(i)
|
read(libezfio_iunit,%(fmt)s) dat(i)
|
||||||
enddo
|
enddo
|
||||||
call libezfio_closez(trim(l_filename),'r')
|
call libezfio_closez(trim(l_filename),'r')
|
||||||
return
|
return
|
||||||
@ -185,30 +179,31 @@ subroutine ezfio_read_array_%(type_short)s(dir,fil,rank,dims,dim_max,dat)
|
|||||||
call ezfio_error(irp_here,'Attribute '//trim(l_filename)//' is not set')
|
call ezfio_error(irp_here,'Attribute '//trim(l_filename)//' is not set')
|
||||||
endif
|
endif
|
||||||
end
|
end
|
||||||
|
|
||||||
subroutine ezfio_write_array_%(type_short)s(dir,fil,rank,dims,dim_max,dat)
|
subroutine ezfio_write_array_%(type_short)s(dir,fil,rank,dims,dim_max,dat)
|
||||||
implicit none
|
implicit none
|
||||||
character*(*), intent(in) :: dir, fil
|
character*(*), intent(in) :: dir, fil
|
||||||
integer, intent(in) :: rank
|
integer, intent(in) :: rank
|
||||||
integer, intent(in) :: dims(rank)
|
integer, intent(in) :: dims(rank)
|
||||||
integer, intent(in) :: dim_max
|
integer, intent(in) :: dim_max
|
||||||
%(type)s, intent(in) :: dat(dim_max)
|
%(type)s, intent(in) :: dat(dim_max)
|
||||||
integer :: err
|
integer :: err
|
||||||
character*(1024) :: l_filename(2)
|
character*(1024) :: l_filename(2)
|
||||||
if (libezfio_read_only) then
|
if (libezfio_read_only) then
|
||||||
call ezfio_error(irp_here,'Read-only file.')
|
call ezfio_error(irp_here,'Read-only file.')
|
||||||
endif
|
endif
|
||||||
l_filename(1)=trim(dir)//'/.'//fil//PID_str//'.gz'
|
l_filename(1)=trim(dir)//'/.'//fil//PID_str//'.gz'
|
||||||
l_filename(2)=trim(dir)//'/'//fil//'.gz'
|
l_filename(2)=trim(dir)//'/'//fil//'.gz'
|
||||||
|
|
||||||
err = 0
|
err = 0
|
||||||
call libezfio_openz(trim(l_filename(1)),'wb',err)
|
call libezfio_openz(trim(l_filename(1)),'wb',err)
|
||||||
if (err == 0) then
|
if (err == 0) then
|
||||||
write(libezfio_iunit,'(I3)') rank
|
write(libezfio_iunit,'(I3)') rank
|
||||||
write(libezfio_iunit,'(30(I20,X))') dims(1:rank)
|
write(libezfio_iunit,'(30(I20,X))') dims(1:rank)
|
||||||
|
|
||||||
integer :: i
|
integer :: i
|
||||||
do i=1,dim_max
|
do i=1,dim_max
|
||||||
write(libezfio_iunit,%(fmt)s) dat(i)
|
write(libezfio_iunit,%(fmt)s) dat(i)
|
||||||
enddo
|
enddo
|
||||||
call libezfio_closez(trim(l_filename(1)),'w')
|
call libezfio_closez(trim(l_filename(1)),'w')
|
||||||
endif
|
endif
|
||||||
@ -218,19 +213,19 @@ end
|
|||||||
|
|
||||||
template_no_logical = """
|
template_no_logical = """
|
||||||
integer function n_count_%(type_short)s(array,isize,val)
|
integer function n_count_%(type_short)s(array,isize,val)
|
||||||
%(type)s, intent(in) :: array(*)
|
%(type)s, intent(in) :: array(*)
|
||||||
integer, intent(in) :: isize
|
integer, intent(in) :: isize
|
||||||
%(type)s, intent(in) :: val
|
%(type)s, intent(in) :: val
|
||||||
|
|
||||||
integer :: i
|
integer :: i
|
||||||
n_count_%(type_short)s = 0
|
n_count_%(type_short)s = 0
|
||||||
do i=1,isize
|
do i=1,isize
|
||||||
if (array(i) == val) then
|
if (array(i) == val) then
|
||||||
n_count_%(type_short)s = n_count_%(type_short)s +1
|
n_count_%(type_short)s = n_count_%(type_short)s +1
|
||||||
endif
|
endif
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
! Build Python functions
|
! Build Python functions
|
||||||
"""
|
"""
|
||||||
for t in format.keys():
|
for t in format.keys():
|
||||||
@ -334,81 +329,80 @@ file_py.close()
|
|||||||
END_SHELL
|
END_SHELL
|
||||||
|
|
||||||
BEGIN_PROVIDER [ integer, libezfio_buffer_rank ]
|
BEGIN_PROVIDER [ integer, libezfio_buffer_rank ]
|
||||||
BEGIN_DOC
|
BEGIN_DOC
|
||||||
! Rank of the buffer ready for reading
|
! Rank of the buffer ready for reading
|
||||||
END_DOC
|
END_DOC
|
||||||
libezfio_buffer_rank = -1
|
libezfio_buffer_rank = -1
|
||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
subroutine ezfio_open_write_buffer(dir,fil,rank)
|
subroutine ezfio_open_write_buffer(dir,fil,rank)
|
||||||
implicit none
|
implicit none
|
||||||
character*(*),intent(in) :: dir
|
character*(*),intent(in) :: dir
|
||||||
character*(*),intent(in) :: fil
|
character*(*),intent(in) :: fil
|
||||||
integer,intent(in) :: rank
|
integer,intent(in) :: rank
|
||||||
character*(1024) :: l_filename
|
character*(1024) :: l_filename
|
||||||
if (libezfio_read_only) then
|
if (libezfio_read_only) then
|
||||||
call ezfio_error(irp_here,'Read-only file.')
|
call ezfio_error(irp_here,'Read-only file.')
|
||||||
endif
|
endif
|
||||||
l_filename=trim(dir)//'/'//fil//'.gz'
|
l_filename=trim(dir)//'/'//fil//'.gz'
|
||||||
|
|
||||||
if (libezfio_buffer_rank /= -1) then
|
if (libezfio_buffer_rank /= -1) then
|
||||||
call ezfio_error(irp_here,'Another buffered file is already open.')
|
call ezfio_error(irp_here,'Another buffered file is already open.')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
libezfio_buffer_rank = rank
|
libezfio_buffer_rank = rank
|
||||||
if (libezfio_buffer_rank <= 0) then
|
if (libezfio_buffer_rank <= 0) then
|
||||||
call ezfio_error(irp_here,'In file '//trim(l_filename)//': rank <= 0.')
|
call ezfio_error(irp_here,'In file '//trim(l_filename)//': rank <= 0.')
|
||||||
endif
|
endif
|
||||||
TOUCH libezfio_buffer_rank
|
TOUCH libezfio_buffer_rank
|
||||||
|
|
||||||
integer :: err
|
integer :: err
|
||||||
call libezfio_openz(trim(l_filename),'wb',err)
|
call libezfio_openz(trim(l_filename),'wb',err)
|
||||||
if (err /= 0) then
|
if (err /= 0) then
|
||||||
call ezfio_error(irp_here,'Unable to open buffered file '//trim(l_filename)//'.')
|
call ezfio_error(irp_here,'Unable to open buffered file '//trim(l_filename)//'.')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
write(libezfio_iunit,'(I2)') rank
|
write(libezfio_iunit,'(I2)') rank
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
subroutine ezfio_open_read_buffer(dir,fil,rank)
|
subroutine ezfio_open_read_buffer(dir,fil,rank)
|
||||||
implicit none
|
implicit none
|
||||||
character*(*),intent(in) :: dir
|
character*(*),intent(in) :: dir
|
||||||
character*(*),intent(in) :: fil
|
character*(*),intent(in) :: fil
|
||||||
integer,intent(in) :: rank
|
integer,intent(in) :: rank
|
||||||
character*(1024) :: l_filename
|
character*(1024) :: l_filename
|
||||||
l_filename=trim(dir)//'/'//fil//'.gz'
|
l_filename=trim(dir)//'/'//fil//'.gz'
|
||||||
|
|
||||||
if (libezfio_buffer_rank /= -1) then
|
if (libezfio_buffer_rank /= -1) then
|
||||||
call ezfio_error(irp_here,'Another buffered file is already open.')
|
call ezfio_error(irp_here,'Another buffered file is already open.')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
integer :: err
|
integer :: err
|
||||||
call libezfio_openz(trim(l_filename),'rb',err)
|
call libezfio_openz(trim(l_filename),'rb',err)
|
||||||
if (err /= 0) then
|
if (err /= 0) then
|
||||||
print *, err, l_filename
|
print *, err, l_filename
|
||||||
call ezfio_error(irp_here,'Unable to open buffered file '//trim(l_filename)//'.')
|
call ezfio_error(irp_here,'Unable to open buffered file '//trim(l_filename)//'.')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if (err /= 0) then
|
if (err /= 0) then
|
||||||
print *, err, l_filename
|
print *, err, l_filename
|
||||||
call ezfio_error(irp_here,'Unable to read buffered file '//trim(l_filename)//'.')
|
call ezfio_error(irp_here,'Unable to read buffered file '//trim(l_filename)//'.')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
read(libezfio_iunit,'(I2)') libezfio_buffer_rank
|
read(libezfio_iunit,'(I2)') libezfio_buffer_rank
|
||||||
if (libezfio_buffer_rank /= rank) then
|
if (libezfio_buffer_rank /= rank) then
|
||||||
call ezfio_error(irp_here,'In file '//trim(l_filename)//': Rank is not correct')
|
call ezfio_error(irp_here,'In file '//trim(l_filename)//': Rank is not correct')
|
||||||
endif
|
endif
|
||||||
TOUCH libezfio_buffer_rank
|
TOUCH libezfio_buffer_rank
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
subroutine ezfio_close_read_buffer(dir,fil,rank)
|
subroutine ezfio_close_read_buffer(dir,fil,rank)
|
||||||
implicit none
|
implicit none
|
||||||
character*(*),intent(in) :: dir
|
character*(*),intent(in) :: dir
|
||||||
character*(*),intent(in) :: fil
|
character*(*),intent(in) :: fil
|
||||||
integer,intent(in) :: rank
|
integer,intent(in) :: rank
|
||||||
character*(1024) :: l_filename
|
character*(1024) :: l_filename
|
||||||
l_filename=trim(dir)//'/'//fil//'.gz'
|
l_filename=trim(dir)//'/'//fil//'.gz'
|
||||||
ASSERT (libezfio_buffer_rank > 0)
|
ASSERT (libezfio_buffer_rank > 0)
|
||||||
call libezfio_closez(l_filename,'r')
|
call libezfio_closez(l_filename,'r')
|
||||||
@ -417,10 +411,10 @@ end
|
|||||||
|
|
||||||
subroutine ezfio_close_write_buffer(dir,fil,rank)
|
subroutine ezfio_close_write_buffer(dir,fil,rank)
|
||||||
implicit none
|
implicit none
|
||||||
character*(*),intent(in) :: dir
|
character*(*),intent(in) :: dir
|
||||||
character*(*),intent(in) :: fil
|
character*(*),intent(in) :: fil
|
||||||
integer,intent(in) :: rank
|
integer,intent(in) :: rank
|
||||||
character*(1024) :: l_filename
|
character*(1024) :: l_filename
|
||||||
l_filename=trim(dir)//'/'//fil//'.gz'
|
l_filename=trim(dir)//'/'//fil//'.gz'
|
||||||
ASSERT (libezfio_buffer_rank > 0)
|
ASSERT (libezfio_buffer_rank > 0)
|
||||||
call libezfio_closez(l_filename,'w')
|
call libezfio_closez(l_filename,'w')
|
||||||
@ -429,19 +423,19 @@ end
|
|||||||
|
|
||||||
subroutine ezfio_read_buffer(indices,values,isize)
|
subroutine ezfio_read_buffer(indices,values,isize)
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
integer, intent(inout) :: isize
|
integer, intent(inout) :: isize
|
||||||
integer, intent(out) :: indices(*)
|
integer, intent(out) :: indices(*)
|
||||||
double precision, intent(out) :: values(isize)
|
double precision, intent(out) :: values(isize)
|
||||||
|
|
||||||
integer :: i, j
|
integer :: i, j
|
||||||
|
|
||||||
if (libezfio_buffer_rank == -1) then
|
if (libezfio_buffer_rank == -1) then
|
||||||
call ezfio_error(irp_here,'No buffered file is open.')
|
call ezfio_error(irp_here,'No buffered file is open.')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
do i=1,isize
|
do i=1,isize
|
||||||
read(libezfio_iunit,err=10) (indices((i-1)*libezfio_buffer_rank+j), j=1,libezfio_buffer_rank), values(i)
|
read(libezfio_iunit,err=10) (indices((i-1)*libezfio_buffer_rank+j), j=1,libezfio_buffer_rank), values(i)
|
||||||
enddo
|
enddo
|
||||||
return
|
return
|
||||||
10 continue
|
10 continue
|
||||||
@ -450,14 +444,14 @@ end
|
|||||||
|
|
||||||
subroutine ezfio_write_buffer(indices,values,isize)
|
subroutine ezfio_write_buffer(indices,values,isize)
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
integer, intent(in) :: isize
|
integer, intent(in) :: isize
|
||||||
integer, intent(in) :: indices(*)
|
integer, intent(in) :: indices(*)
|
||||||
double precision, intent(in) :: values(isize)
|
double precision, intent(in) :: values(isize)
|
||||||
|
|
||||||
character*(80) :: cformat
|
character*(80) :: cformat
|
||||||
integer :: i, j, k, num, imax, l1, l2
|
integer :: i, j, k, num, imax, l1, l2
|
||||||
|
|
||||||
if (libezfio_read_only) then
|
if (libezfio_read_only) then
|
||||||
call ezfio_error(irp_here,'Read-only file.')
|
call ezfio_error(irp_here,'Read-only file.')
|
||||||
endif
|
endif
|
||||||
@ -466,8 +460,8 @@ subroutine ezfio_write_buffer(indices,values,isize)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
write(cformat,*) '(',num,'(',libezfio_buffer_rank,'(I4,X),E24.15,A1))'
|
write(cformat,*) '(',num,'(',libezfio_buffer_rank,'(I4,X),E24.15,A1))'
|
||||||
write(libezfio_iunit,cformat) ((indices((i-1)*libezfio_buffer_rank+j), j=1,libezfio_buffer_rank), &
|
write(libezfio_iunit,cformat) ((indices((i-1)*libezfio_buffer_rank+j), j=1,libezfio_buffer_rank),&
|
||||||
values(i), i=1,isize)
|
values(i), i=1,isize)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ groups = {}
|
|||||||
group = None
|
group = None
|
||||||
my_list = []
|
my_list = []
|
||||||
for line, filename in lines:
|
for line, filename in lines:
|
||||||
|
line = line.lower()
|
||||||
try:
|
try:
|
||||||
|
|
||||||
if len(line.strip()) == 0:
|
if len(line.strip()) == 0:
|
||||||
groups[group] = my_list
|
groups[group] = my_list
|
||||||
elif line[0] != ' ': # New group
|
elif line[0] != ' ': # New group
|
||||||
|
Loading…
Reference in New Issue
Block a user