Commit 0d953cb8 authored by POLCHER Jan's avatar POLCHER Jan 🚴🏾
Browse files

Some clean-up of the code and supression of the call to the plot routines in...

Some clean-up of the code and supression of the call to the plot routines in the main. That is replced by Anthony's code.
parent a0d7b266
...@@ -10,7 +10,7 @@ import RPPtools as RPP ...@@ -10,7 +10,7 @@ import RPPtools as RPP
import configparser import configparser
config=configparser.ConfigParser() config=configparser.ConfigParser()
config.read("run.def") config.read("run.def")
EarthRadius=config.getfloat("OverAll", "EarthRadius") EarthRadius=config.getfloat("OverAll", "EarthRadius", fallback=6370000.0)
# #
import getargs import getargs
log_master, log_world = getargs.getLogger(__name__) log_master, log_world = getargs.getLogger(__name__)
...@@ -58,8 +58,6 @@ def corners(lon, lat) : ...@@ -58,8 +58,6 @@ def corners(lon, lat) :
def gather(x, index) : def gather(x, index) :
y=[] y=[]
for ia in index : for ia in index :
# print("XXXX shape of ia :", ia.shape, ia.dtype)
# print("XXXX ia :", ia)
y.append(list(x[ia[0,i],ia[1,i]] for i in range(ia.shape[1]) )) y.append(list(x[ia[0,i],ia[1,i]] for i in range(ia.shape[1]) ))
return y return y
# #
......
...@@ -26,11 +26,11 @@ MPI.COMM_WORLD.Barrier() ...@@ -26,11 +26,11 @@ MPI.COMM_WORLD.Barrier()
import routing_interface import routing_interface
# #
import configparser import configparser
config = configparser.ConfigParser({'Documentation':'false', 'nbxmax':'63', 'ROUTING_RIVERS':'50'}) config = configparser.ConfigParser()
config.read("run.def") config.read("run.def")
gendoc = config.get("OverAll", "Documentation") gendoc = config.get("OverAll", "Documentation", fallback='false')
nbxmax = config.getint("OverAll", "nbxmax") nbxmax = config.getint("OverAll", "nbxmax", fallback=63)
largest_pos = config.getint("OverAll", "ROUTING_RIVERS") largest_pos = config.getint("OverAll", "ROUTING_RIVERS", fallback=50)
# #
undef_int = 999999999.9 undef_int = 999999999.9
# Order of magnitude for the area precision in m^2. # Order of magnitude for the area precision in m^2.
......
...@@ -10,7 +10,7 @@ import RPPtools as RPP ...@@ -10,7 +10,7 @@ import RPPtools as RPP
import sys import sys
# #
import configparser import configparser
config=configparser.ConfigParser({"WEST_EAST":"-180., 180", "SOUTH_NORTH":"-90., 90."}) config=configparser.ConfigParser()
config.read("run.def") config.read("run.def")
# #
import getargs import getargs
...@@ -19,7 +19,7 @@ INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error ...@@ -19,7 +19,7 @@ INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error
INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug
# #
# #
EarthRadius=config.getfloat("OverAll", "EarthRadius") EarthRadius=config.getfloat("OverAll", "EarthRadius", fallback=6370000.0)
rose=[[-1,-1],[-1,0],[-1,+1],[0,+1],[+1,+1],[+1,0],[+1,-1],[0,-1]] rose=[[-1,-1],[-1,0],[-1,+1],[0,+1],[+1,+1],[+1,0],[+1,-1],[0,-1]]
epsilon=0.00001 epsilon=0.00001
# #
...@@ -410,8 +410,8 @@ class ModelGrid : ...@@ -410,8 +410,8 @@ class ModelGrid :
class GlobalGrid : class GlobalGrid :
def __init__(self) : def __init__(self) :
lonrange=np.array(config.get("OverAll", "WEST_EAST").split(","),dtype=float) lonrange=np.array(config.get("OverAll", "WEST_EAST", fallback="-180., 180.").split(","),dtype=float)
latrange=np.array(config.get("OverAll", "SOUTH_NORTH").split(","),dtype=float) latrange=np.array(config.get("OverAll", "SOUTH_NORTH", fallback="-90., 90.").split(","),dtype=float)
self.source=config.get("OverAll", "ModelGridFile") self.source=config.get("OverAll", "ModelGridFile")
INFO("Opening : "+self.source) INFO("Opening : "+self.source)
......
...@@ -15,10 +15,10 @@ from spherical_geometry import vector ...@@ -15,10 +15,10 @@ from spherical_geometry import vector
# Configuration # Configuration
# #
import configparser import configparser
config=configparser.ConfigParser({'SaveWeights':'true'}) config=configparser.ConfigParser()
config.read("run.def") config.read("run.def")
saveweights=config.get("OverAll", "SaveWeights") saveweights=config.get("OverAll", "SaveWeights", fallback="true")
EarthRadius=config.getfloat("OverAll", "EarthRadius") EarthRadius=config.getfloat("OverAll", "EarthRadius", fallback=6370000.0)
# #
# Logging in MPI : https://groups.google.com/forum/#!topic/mpi4py/SaNzc8bdj6U # Logging in MPI : https://groups.google.com/forum/#!topic/mpi4py/SaNzc8bdj6U
# #
......
...@@ -15,14 +15,12 @@ import time ...@@ -15,14 +15,12 @@ import time
# Gert the information from the configuration file. # Gert the information from the configuration file.
# #
import configparser import configparser
config=configparser.ConfigParser({"DiagLon":"0.0, 0.0", "DiagLat":"0.0, 0.0"}) config=configparser.ConfigParser()
config.read("run.def") config.read("run.def")
nbasmax=config.getint("OverAll", "nbasmax") nbasmax=config.getint("OverAll", "nbasmax")
numop=config.getint("OverAll", "numop", fallback=100) numop=config.getint("OverAll", "numop", fallback=100)
OutGraphFile=config.get("OverAll","GraphFile") OutGraphFile=config.get("OverAll","GraphFile")
DumpHydroSuper=config.getboolean("OverAll","DumpHydroSuper",fallback=False) DumpHydroSuper=config.getboolean("OverAll","DumpHydroSuper",fallback=False)
lonint=np.array(config.get("OverAll", "DiagLon").split(","),dtype=float)
latint=np.array(config.get("OverAll", "DiagLat").split(","),dtype=float)
wfile=config.get("OverAll","WeightFile",fallback="Weights.nc") wfile=config.get("OverAll","WeightFile",fallback="Weights.nc")
# #
import ModelGrid as MG import ModelGrid as MG
...@@ -89,23 +87,11 @@ comm.Barrier() ...@@ -89,23 +87,11 @@ comm.Barrier()
del w del w
gc.collect() gc.collect()
if rank ==0 :
if lonint[0] != lonint[1] and latint[0] != latint[1] :
DP.MAPPLOT("MapHydroGrid", lonint, latint, hoverlap, hoverlap.hierarchy_bx, modelgrid.polyll, title="Distance to ocean")
hsuper = IF.HydroSuper(nbvmax, hydrodata, hoverlap, nbasmax) hsuper = IF.HydroSuper(nbvmax, hydrodata, hoverlap, nbasmax)
# #
# Plot the hydrological supermesh INFO("=================== LINKUP ====================")
#
if rank == 0 :
if lonint[0] != lonint[1] and latint[0] != latint[1] :
DP.SUPERMESHPLOT("MapSuperGrid_Beforelinkup", lonint, latint, hoverlap, hsuper, modelgrid.polyll)
print("=================== LINKUP ====================")
hsuper.linkup(hydrodata) hsuper.linkup(hydrodata)
if rank ==0 :
if lonint[0] != lonint[1] and latint[0] != latint[1] :
DP.SUPERMESHPLOT("MapSuperGrid_Afterlinkup", lonint, latint, hoverlap, hsuper, modelgrid.polyll)
# #
# Do some memory management and synchronize procs. # Do some memory management and synchronize procs.
# #
...@@ -114,7 +100,7 @@ comm.Barrier() ...@@ -114,7 +100,7 @@ comm.Barrier()
del hoverlap del hoverlap
gc.collect() gc.collect()
print("=================== Compute fetch ====================") INFO("=================== Compute fetch ====================")
t = time.time() t = time.time()
hsuper.fetch(part) hsuper.fetch(part)
comm.Barrier() comm.Barrier()
...@@ -123,7 +109,7 @@ print("Time for fetch: {:0.2f} s.".format(t1-t)) ...@@ -123,7 +109,7 @@ print("Time for fetch: {:0.2f} s.".format(t1-t))
comm.Barrier() comm.Barrier()
if DumpHydroSuper : if DumpHydroSuper :
print("Dumping HydroSuper") INFO("Dumping HydroSuper")
hsuper.dumpnetcdf(OutGraphFile.replace(".nc","_HydroSuper.nc"), gg, modelgrid, part) hsuper.dumpnetcdf(OutGraphFile.replace(".nc","_HydroSuper.nc"), gg, modelgrid, part)
print("Rank : {0} - Basin_count Before Truncate : ".format(part.rank), hsuper.basin_count) print("Rank : {0} - Basin_count Before Truncate : ".format(part.rank), hsuper.basin_count)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment