From 35b1ad0c7c94861f493580000784b5cdd6515ef1 Mon Sep 17 00:00:00 2001 From: POLCHER Jan <jan.polcher@lmd.jussieu.fr> Date: Tue, 26 May 2020 19:38:43 +0200 Subject: [PATCH] A more elegant exit when a processor does not have any land points. --- Partition.py | 33 ++++++++++++++++----------- tests/Mallorca/BuildHTUs_Mallorca.pbs | 6 ++--- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Partition.py b/Partition.py index 99e04a4..db43384 100644 --- a/Partition.py +++ b/Partition.py @@ -50,23 +50,24 @@ def halfpartition(partin, land) : def fit_partition(partin, land): partout = [] for i, dom in enumerate(partin): - l = land[dom["jstart"]:dom["jstart"]+dom["nbj"],dom["istart"]:dom["istart"]+dom["nbi"]] - l1 = np.sum(l, axis = 0) + if dom["nbland"] > 0 : + l = land[dom["jstart"]:dom["jstart"]+dom["nbj"],dom["istart"]:dom["istart"]+dom["nbi"]] + l1 = np.sum(l, axis = 0) - i0 = np.where(l1>0)[0][0] - i1 = np.where(l1>0)[0][-1] + i0 = np.where(l1>0)[0][0] + i1 = np.where(l1>0)[0][-1] - l2 = np.ma.sum(l, axis = 1) - j0 = np.where(l2>0)[0][0] - j1 = np.where(l2>0)[0][-1] + l2 = np.ma.sum(l, axis = 1) + j0 = np.where(l2>0)[0][0] + j1 = np.where(l2>0)[0][-1] - dom["jstart"] = j0 + dom["jstart"] - dom["nbj"] = j1-j0+1 - dom["istart"] = i0 + dom["istart"] - dom["nbi"] = i1-i0+1 - dom["nbland"] = int(np.nansum(land[dom["jstart"]:dom["jstart"]+dom["nbj"],dom["istart"]:dom["istart"]+dom["nbi"]])) + dom["jstart"] = j0 + dom["jstart"] + dom["nbj"] = j1-j0+1 + dom["istart"] = i0 + dom["istart"] + dom["nbi"] = i1-i0+1 + dom["nbland"] = int(np.nansum(land[dom["jstart"]:dom["jstart"]+dom["nbj"],dom["istart"]:dom["istart"]+dom["nbi"]])) - partout.append(dom) + partout.append(dom) return partout # # @@ -361,6 +362,12 @@ class partition : # self.allistart = [] self.alljstart = [] + # + if self.size != len(part) : + ERROR("There are too many processors for the size of the domain.") + ERROR(str(self.size)+" processors. But partition could only achieve "+str(len(part))+" domain with land points") + sys.exit() + # for i in range(self.size) : self.allistart.append(part[i]["istart"]) self.alljstart.append(part[i]["jstart"]) diff --git a/tests/Mallorca/BuildHTUs_Mallorca.pbs b/tests/Mallorca/BuildHTUs_Mallorca.pbs index 8342828..9cb1c5b 100644 --- a/tests/Mallorca/BuildHTUs_Mallorca.pbs +++ b/tests/Mallorca/BuildHTUs_Mallorca.pbs @@ -42,15 +42,15 @@ fi # /bin/rm -f run.def *.txt cp run_E2OFD.def run.def -mpirun -n 2 python ../../RoutingPreProc.py +mpirun -n 3 python ../../RoutingPreProc.py if [ $? -gt 0 ] ; then echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - echo "X Run E2OFD on 4 Proc failed X" + echo "X Run E2OFD on 3 Proc failed X" echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" exit else echo "==================================" - echo "= Run E2OFD on 4 Proc successful =" + echo "= Run E2OFD on 3 Proc successful =" echo "==================================" ls -lt fi -- GitLab