Skip to content
Snippets Groups Projects
Commit b299412d authored by POLCHER Jan's avatar POLCHER Jan :bicyclist_tone4:
Browse files

Merge branch 'anthony' into 'master'

rank and nbpt inside rank

See merge request jan.polcher/routingpp!1
parents 8317f5fb d6cd8880
No related branches found
No related tags found
1 merge request!1rank and nbpt inside rank
......@@ -269,6 +269,9 @@ class HydroGraph :
self.num_largest = routing_interface.finalrivclass(part.landcorelist, self.route_togrid, self.route_tobasin, self.routing_fetch, \
hydrosuper.largest_rivarea)
#
nbpt = hydrosuper.basin_count.shape[0]
self.nbpt_proc = np.arange(1,nbpt+1)
self.proc = np.full(nbpt, part.rank)
return
#
def dumpnetcdf(self, filename, globalgrid, procgrid, part) :
......@@ -349,6 +352,32 @@ class HydroGraph :
else :
area = np.zeros((1,1))
area[:,:] = part.gather(areas[:,:])
#
# Environment
# nbpt_proc
subpt = procgrid.landscatter(self.nbpt_proc[:], order='F')
subpt = subpt.astype(vtyp, copy=False)
subpt[np.isnan(subpt)] = NCFillValue
if part.rank == 0 :
subptgrid = outnf.createVariable("nbpt_proc", vtyp, ('y','x'), fill_value=NCFillValue)
subptgrid.title = "gridpoint reference inside each proc"
subptgrid.units = "-"
else :
subptgrid = np.zeros((1,1,1))
subptgrid[:,:] = part.gather(subpt)
#
# rank
procnum = procgrid.landscatter(self.proc[:], order='F')
procnum = procnum.astype(vtyp, copy=False)
procnum[np.isnan(procnum)] = NCFillValue
if part.rank == 0 :
procn = outnf.createVariable("proc_num", vtyp, ('y','x'), fill_value=NCFillValue)
procn.title = "rank"
procn.units = "-"
else :
procn = np.zeros((1,1,1))
procn[:,:] = part.gather(procnum)
#
# Variables
# Once gathered on root_proc we transform them into float64. Careful, Integer variables do not have NaN !
......
......@@ -128,12 +128,14 @@ print("nbasmax : ", nbasmax)
#
# Extract hydo data from file
#
INFO("hydrodata")
hydrodata = HG.HydroData(hydrogrid.ncfile, hydrogrid.box, sub_index)
INFO("nitiatmgrid")
IF.initatmgrid(rank, nbcore, nbpt, modelgrid)
INFO("hoverlap")
hoverlap = IF.HydroOverlap(nbpt, nbvmax, sub_pts, sub_index, sub_area, sub_lon, sub_lat, modelgrid, hydrodata)
#
......@@ -146,7 +148,7 @@ del sub_lon
del sub_lat
gc.collect()
if nbcore == 1 :
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")
......@@ -154,13 +156,13 @@ hsuper = IF.HydroSuper(nbvmax, hydrodata, hoverlap)
#
# Plot the hydrological supermesh
#
if nbcore == 1 :
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)
if nbcore == 1 :
if rank ==0 :
if lonint[0] != lonint[1] and latint[0] != latint[1] :
DP.SUPERMESHPLOT("MapSuperGrid_Afterlinkup", lonint, latint, hoverlap, hsuper, modelgrid.polyll)
......
......@@ -4,8 +4,8 @@
EarthRadius = 6370000.
#
ModelGridFile = /bdd/MEDI/workspaces/polcher/NewRouting/EM_WFDEI_CRU_2000.nc
##WEST_EAST = -9.75, 5.25
##SOUTH_NORTH = 36.1, 44.2
WEST_EAST = -9.75, 5.25
SOUTH_NORTH = 36.25, 44.25
HydroFile = /bdd/MEDI/workspaces/polcher/NewRouting/routing_MED.nc
#
# FORTRAN interface parameters
......@@ -23,5 +23,5 @@ GraphFile = EM_WFDEI_test_graph.nc
# Diagnostics
# You need to provide an interval in longitude and Latitude.
#
DiagLon = 39.9, 39.9
DiagLat = 40.0, 40.0
DiagLon = -9.75, 5.25
DiagLat = 36.25, 44.25
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment