-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d7368d
commit 8526bed
Showing
12 changed files
with
148 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
from typing import Optional, Union | ||
|
||
from mpi4py import MPI | ||
from petsc4py import PETSc | ||
|
||
|
||
def print_with_rank(*args, comm: PETSc.Comm | MPI.Comm | None = None) -> None: | ||
def print_with_rank(*args, comm: Optional[Union[PETSc.Comm, MPI.Comm]] = None) -> None: | ||
comm = comm or PETSc.Sys.getDefaultComm() | ||
print(f"[rank {comm.rank}] : ", *args, sep="", flush=True) | ||
|
||
|
||
def print_if_rank(rank: int, *args, comm: PETSc.Comm | MPI.Comm | None = None) -> None: | ||
def print_if_rank( | ||
rank: int, *args, comm: Optional[Union[PETSc.Comm, MPI.Comm]] = None | ||
) -> None: | ||
comm = comm or PETSc.Sys.getDefaultComm() | ||
if rank == comm.rank: | ||
print(*args, flush=True) |
Oops, something went wrong.