Scientific.MPI.IO.LogFile

Package Scientific :: Package MPI :: Module IO :: Class LogFile |
[frames] | no frames]

# Class LogFile

File for logging events from all processes

The purpose of LogFile objects is to collect short text output from all processors into a single file. All processes can write whatever they want at any time; the date is simply stored locally. After the file has been closed by all processes, the data is sent to process 0, which then writes everything to one text file, neatly separated by process rank number.

Note that due to the intermediate storage of the data, LogFile objects should not be used for large amounts of data. Also note that all data is lost if a process crashes before closing the file.

Instance Methods
__init__(self, filename, communicator=None) |
close(self) Close the file, causing the real text file to be written |
flush(self) Write buffered data to the text file |
write(self, string) Write a string to the file |

Method Details

### __init__(self, filename, communicator=None) (Constructor) |
Parameters: `filename` (`str`) - the name of the log file `communicator` (Scientific.MPI.MPICommunicator) - the communicator in which the file is accessible. The default value of `None` means to use the global world communicator, i.e. all possible processes.

### write(self, string) |
Write a string to the file Parameters: `string` (`str`) - the string data