Пример #1
0
        public ParallelFileLogger(Mpi mpi, string fileName, bool rewrite, bool permit = false)

        {
            _mpi = mpi;
            if (mpi == null)
            {
                throw new ArgumentNullException(nameof(mpi));
            }

            _name = mpi.GetProcessorName();
            _rank = mpi.Rank;

            if (_mpi.IsMaster)
            {
                _permitToWrite = true;
                if (rewrite)
                {
                    if (File.Exists(fileName))
                    {
                        File.Delete(fileName);
                    }
                }

                _streamWriter = new StreamWriter(fileName);
                _streamWriter.WriteLine($"File logger started at {CreationTime}");
                _streamWriter.Flush();
            }
            else
            {
                _permitToWrite = permit;
            }
        }
Пример #2
0
        public ParallelConsoleLogger(Mpi mpi, bool permit = false)
        {
            _mpi = mpi;
            if (mpi == null)
            {
                throw new ArgumentNullException(nameof(mpi));
            }

            _name = mpi.GetProcessorName();
            _rank = mpi.Rank;

            if (_mpi.IsMaster)
            {
                Console.WriteLine($"Parallel logger started on [master {_name}] at {CreationTime}");
                _permitToWrite = true;
            }
            else
            {
                _permitToWrite = permit;
            }
        }