mirror of
https://github.com/triqs/dft_tools
synced 2024-09-12 05:38:31 +02:00
[vasp_converter] close input files explicitly
This commit is contained in:
parent
d55d8f3911
commit
1c9190496d
@ -135,7 +135,7 @@ class VaspConverter(ConverterTools):
|
|||||||
|
|
||||||
f_gen = self.read_data(fh)
|
f_gen = self.read_data(fh)
|
||||||
|
|
||||||
return header, f_gen
|
return header, f_gen, fh
|
||||||
|
|
||||||
def convert_dft_input(self):
|
def convert_dft_input(self):
|
||||||
"""
|
"""
|
||||||
@ -152,7 +152,7 @@ class VaspConverter(ConverterTools):
|
|||||||
mpi.report("Reading input from %s..."%self.ctrl_file)
|
mpi.report("Reading input from %s..."%self.ctrl_file)
|
||||||
|
|
||||||
# R is a generator : each R.Next() will return the next number in the file
|
# R is a generator : each R.Next() will return the next number in the file
|
||||||
jheader, rf = self.read_header_and_data(self.ctrl_file)
|
jheader, rf, fh = self.read_header_and_data(self.ctrl_file)
|
||||||
print(jheader)
|
print(jheader)
|
||||||
ctrl_head = json.loads(jheader)
|
ctrl_head = json.loads(jheader)
|
||||||
|
|
||||||
@ -185,6 +185,8 @@ class VaspConverter(ConverterTools):
|
|||||||
except StopIteration:
|
except StopIteration:
|
||||||
raise "VaspConverter: error reading %s"%self.ctrl_file
|
raise "VaspConverter: error reading %s"%self.ctrl_file
|
||||||
|
|
||||||
|
fh.close()
|
||||||
|
|
||||||
# if nc_flag:
|
# if nc_flag:
|
||||||
# VASP.6.
|
# VASP.6.
|
||||||
if SO == 1:
|
if SO == 1:
|
||||||
@ -199,7 +201,7 @@ class VaspConverter(ConverterTools):
|
|||||||
try:
|
try:
|
||||||
for ig in range(ng):
|
for ig in range(ng):
|
||||||
gr_file = self.basename + '.pg%i'%(ig + 1)
|
gr_file = self.basename + '.pg%i'%(ig + 1)
|
||||||
jheader, rf = self.read_header_and_data(gr_file)
|
jheader, rf, fh = self.read_header_and_data(gr_file)
|
||||||
gr_head = json.loads(jheader)
|
gr_head = json.loads(jheader)
|
||||||
|
|
||||||
|
|
||||||
@ -230,15 +232,14 @@ class VaspConverter(ConverterTools):
|
|||||||
pars['l'] = sh['lorb']
|
pars['l'] = sh['lorb']
|
||||||
#pars['corr'] = sh['corr']
|
#pars['corr'] = sh['corr']
|
||||||
pars['dim'] = sh['ndim']
|
pars['dim'] = sh['ndim']
|
||||||
#pars['ion_list'] = sh['ion_list']
|
|
||||||
pars['SO'] = SO
|
pars['SO'] = SO
|
||||||
# TODO: check what 'irep' entry does (it seems to be very specific to dmftproj)
|
# TODO: check what 'irep' entry does (it seems to be very specific to dmftproj)
|
||||||
pars['irep'] = 0
|
pars['irep'] = 0
|
||||||
shells.append(pars)
|
shells.append(pars)
|
||||||
shion_to_shell[ish].append(i)
|
shion_to_shell[ish].append(i)
|
||||||
shorbs_to_globalorbs[ish].append([last_dimension,
|
shorbs_to_globalorbs[ish].append([last_dimension,
|
||||||
last_dimension+sh['ndim']])
|
last_dimension + sh['ndim']])
|
||||||
last_dimension = last_dimension+sh['ndim']
|
last_dimension = last_dimension + sh['ndim']
|
||||||
if sh['corr']:
|
if sh['corr']:
|
||||||
corr_shells.append(pars)
|
corr_shells.append(pars)
|
||||||
|
|
||||||
@ -381,7 +382,7 @@ class VaspConverter(ConverterTools):
|
|||||||
except StopIteration:
|
except StopIteration:
|
||||||
raise "VaspConverter: error reading %s"%self.gr_file
|
raise "VaspConverter: error reading %s"%self.gr_file
|
||||||
|
|
||||||
rf.close()
|
fh.close()
|
||||||
|
|
||||||
|
|
||||||
proj_or_hk = self.proj_or_hk
|
proj_or_hk = self.proj_or_hk
|
||||||
|
Loading…
Reference in New Issue
Block a user