19
19
Module to handle model input & output
20
20
"""
21
21
22
- from .backend import File , Function , HDF5File , MPI , XDMFFile , \
22
+ from .backend import File , Function , HDF5File , XDMFFile , \
23
23
configure_checkpointing
24
24
from tlm_adjoint .fenics .backend import backend_Function
25
25
26
+ import mpi4py .MPI as MPI # noqa: N817
26
27
import sys
27
28
import time
28
29
import csv
@@ -48,7 +49,7 @@ class Writer(ABC):
48
49
unnamed_re = re .compile ("f_[0-9]+" )
49
50
suffix = None # the subclass specific file extension
50
51
51
- def __init__ (self , fpath , comm = MPI .comm_world ):
52
+ def __init__ (self , fpath , comm = MPI .COMM_WORLD ):
52
53
assert comm is not None , "Need an MPI communicator"
53
54
self ._fpath = Path (fpath )
54
55
self .comm = comm
@@ -245,7 +246,7 @@ def write_dqval(dQ_ts, cntrl_names, params):
245
246
outdir_f = Path (outdir )/ phase_name / phase_suffix
246
247
# TODO add this file to diags once Dan makes his pull request
247
248
vtkfile = File (str ((diagdir_f / h5_filename ).with_suffix (".pvd" )))
248
- hdf5out = HDF5File (MPI .comm_world , str (outdir_f / h5_filename ), 'w' )
249
+ hdf5out = HDF5File (MPI .COMM_WORLD , str (outdir_f / h5_filename ), 'w' )
249
250
n = 0.0
250
251
251
252
# Loop dQ sample times ('num_sens')
@@ -304,15 +305,15 @@ def write_variable(var, params, name=None, outdir=None, phase_name='', phase_suf
304
305
xml_fname = str (outfname .with_suffix (".xml" ))
305
306
File (xml_fname ) << outvar
306
307
if 'h5' in output_var_format :
307
- hdf5out = HDF5File (MPI .comm_world , str (outfname .with_suffix (".h5" )), 'w' )
308
+ hdf5out = HDF5File (MPI .COMM_WORLD , str (outfname .with_suffix (".h5" )), 'w' )
308
309
hdf5out .write (outvar , name )
309
310
hdf5out .close ()
310
311
if 'all' in output_var_format :
311
312
vtk_fname = str (outfname .with_suffix (".pvd" ))
312
313
xml_fname = str (outfname .with_suffix (".xml" ))
313
314
File (vtk_fname ) << outvar
314
315
File (xml_fname ) << outvar
315
- hdf5out = HDF5File (MPI .comm_world , str (outfname .with_suffix (".h5" )), 'w' )
316
+ hdf5out = HDF5File (MPI .COMM_WORLD , str (outfname .with_suffix (".h5" )), 'w' )
316
317
hdf5out .write (outvar , name )
317
318
hdf5out .close ()
318
319
0 commit comments