Skip to content

Commit 7244430

Browse files
committed
dev
1 parent 3758f5f commit 7244430

1 file changed

Lines changed: 12 additions & 17 deletions

File tree

cf/regrid/regrid.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,12 +2577,16 @@ def create_esmpy_weights(
25772577
from resource import RUSAGE_SELF, getrusage
25782578

25792579
start_time0 = time()
2580+
maxrss = getrusage(RUSAGE_SELF).ru_maxrss
25802581
logger.debug(
25812582
"Calculating weights ...\n\n"
2582-
"Free memory before calculation of weights: "
2583-
f"{free_memory() / 2**30} GiB\n\n"
25842583
"Number of destination grid partitions: "
25852584
f"{dst_grid_partitions}\n"
2585+
"Free memory before calculation of weights: "
2586+
f"{free_memory() / 2**30} GiB\n"
2587+
"Maximum RSS before weights creation: "
2588+
f"{maxrss * 1000/ 2**30} GiB\n"
2589+
25862590
) # pragma: no cover
25872591

25882592
# Create the weights using ESMF
@@ -2633,8 +2637,7 @@ def create_esmpy_weights(
26332637
w = []
26342638

26352639
if debug:
2636-
start_time = time() # pragma: no cover
2637-
maxrss1 = None
2640+
start_time = time()
26382641

26392642
# Loop round destination grid partitions
26402643
for i, dst_esmpy_grid in enumerate(dst_esmpy_grids):
@@ -2646,7 +2649,7 @@ def create_esmpy_weights(
26462649
f"Partition {i}: Destination ESMF {dst_esmpy_grid}"
26472650
) # pragma: no cover
26482651
start_time = time() # pragma: no cover
2649-
2652+
26502653
# Create destination esmpy field
26512654
dst_esmpy_field = esmpy.Field(
26522655
dst_esmpy_grid, name="dst", meshloc=dst_meshloc
@@ -2658,9 +2661,6 @@ def create_esmpy_weights(
26582661
mask_values = np.array([0], dtype="int32")
26592662

26602663
# Create the esmpy.Regrid operator
2661-
if debug:
2662-
maxrss0 = getrusage(RUSAGE_SELF).ru_maxrss
2663-
26642664
r = esmpy.Regrid(
26652665
src_esmpy_field,
26662666
dst_esmpy_field,
@@ -2690,19 +2690,14 @@ def create_esmpy_weights(
26902690
r.destroy()
26912691

26922692
if debug:
2693+
maxrss = getrusage(RUSAGE_SELF).ru_maxrss
26932694
logger.debug(
26942695
f"Partition {i}: Time taken by ESMF to create weights: "
2695-
f"{time() - start_time} s"
2696+
f"{time() - start_time} s\n"
2697+
f"Partition {i}: Maximum RSS after ESMF weights creation: "
2698+
f"creation: {maxrss * 1000/ 2**30} GiB"
26962699
) # pragma: no cover
26972700
start_time = time() # pragma: no cover
2698-
if maxrss1 is None:
2699-
maxrss1 = getrusage(RUSAGE_SELF).ru_maxrss
2700-
logger.debug(
2701-
f"Partition {i}: Memory used by ESMF to create "
2702-
f"weights: {(maxrss1 - maxrss0) * 1000 / 2**30} GiB"
2703-
) # pragma: no cover
2704-
2705-
start_time = time() # pragma: no cover
27062701

27072702
if quarter:
27082703
# The weights were created with a dummy size 2

0 commit comments

Comments
 (0)