@@ -277,8 +277,7 @@ def relax(self, restart_from_ens = False, get_stress = False,
277277 with some ase calculator)
278278 ensemble_loc : string
279279 Where the ensemble of each population is saved on the disk. If none, it will
280- use the content of self.data_dir. If also self.data_dir is None,
281- the ensemble will not not be saved (useful to avoid disk I/O for force fields)
280+ use the content of self.data_dir. It is just a way to override the variable self.data_dir
282281 start_pop : int, optional
283282 The starting index for the population, used only for saving the ensemble and the dynamical
284283 matrix. If None, the content of self.start_pop will be used.
@@ -292,6 +291,27 @@ def relax(self, restart_from_ens = False, get_stress = False,
292291
293292 if ensemble_loc is None :
294293 ensemble_loc = self .data_dir
294+
295+ if (not ensemble_loc ) and self .save_ensemble :
296+ ERR_MSG = """
297+ Error, you must specify where to save the ensembles.
298+ this can be done either passing ensemble_loc = "path/to/dir"
299+ for the ensemble, or by setting the data_dir attribute of this object.
300+ """
301+ raise IOError (ERR_MSG )
302+
303+ if self .save_ensemble :
304+ if not os .path .exists (ensemble_loc ):
305+ os .makedirs (ensemble_loc )
306+ else :
307+ if not os .isdir (ensemble_loc ):
308+ ERR_MSG = """
309+ Error, the specified location to save the ensemble:
310+ '{}'
311+ already exists and it is not a directory.
312+ """ .format (ensemble_loc )
313+ raise IOError (ERR_MSG )
314+
295315
296316 if start_pop is None :
297317 start_pop = self .start_pop
0 commit comments