diff --git a/.gitignore b/.gitignore index aca73777d794e08652ab8c25b007386b073e9881..5ad03b4ee6fbbdaff28acbaf66a4750564f64e2f 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ xcuserdata/ Weights/ __pycache__/ run.def +Out*.txt # # Test configurations and directories # diff --git a/Diags/plotgraphs.py b/Diags/plotgraphs.py index b705c2fae34b24d068dc25966a51c4614f138449..0875be454505df23b19e2a2af09b4c1d24aba5bc 100644 --- a/Diags/plotgraphs.py +++ b/Diags/plotgraphs.py @@ -6,9 +6,9 @@ import numpy as np from netCDF4 import Dataset import sys -NCfile="../MEDCORDEX_test_graph.nc" +NCfile="../SPortugal_test_graph_n4.nc" GraphicFile = "test.png" -title="Test" +title="From file : "+NCfile # ##################################################################### # @@ -101,8 +101,8 @@ for il in range(landindex.nbland) : j,i = landindex.land2ij(il) xt,yt=m(lon_full[j,i],lat_full[j,i]) plt.text(xt,yt,str(il)) - # - for ih in range(nhtu) : + act_nhtu=np.count_nonzero(routetohtu[:,j,i] > 0) + for ih in range(act_nhtu) : lo = cglon[ih,j,i] la = cglat[ih,j,i] xl,yl=m(lo, la) @@ -117,7 +117,7 @@ for il in range(landindex.nbland) : else : print("Unforseen coding of outlof HTU : ",int(routetohtu[ih,j,i]-1)) sys.exit() - # + if int(routetohtu[ih,j,i]-1) < nhtu : ile = int(routetogrid[ih,j,i]-1) je,ie = landindex.land2ij(ile) diff --git a/DocumentationInterface b/DocumentationInterface index 8770db92b216c74bb0f2a01e0fe358ea77be0366..d71e5bd0ef33711f1003a996c72e3d97b0e2e288 100644 --- a/DocumentationInterface +++ b/DocumentationInterface @@ -1,9 +1,11 @@ -initatmgrid(polygons_in,centre_in,area_in,contfrac_in,neighbours_in,[nbpt,nbseg]) +initatmgrid(rank_bn,nbcore,polygons_in,centre_in,area_in,contfrac_in,neighbours_in,[nbpt,nbseg]) Wrapper for ``initatmgrid``. Parameters ---------- +rank_bn : input int +nbcore : input int polygons_in : input rank-3 array('f') with bounds (nbpt,2 * nbseg + 1,2) centre_in : input rank-2 array('f') with bounds (nbpt,2) area_in : input rank-1 array('f') with bounds (nbpt) diff --git a/F90subroutines/ioipsl.f90 b/F90subroutines/ioipsl.f90 index e41dd6988fc549fd86de78f53a8582855e8170af..91402885d130ae8e05498f5b45ebbe031bddec97 100644 --- a/F90subroutines/ioipsl.f90 +++ b/F90subroutines/ioipsl.f90 @@ -4,7 +4,7 @@ MODULE ioipsl PUBLIC :: ipslerr, ipslerr_p - INTEGER, PARAMETER :: numout=6 + INTEGER, SAVE :: numout=6 INTEGER :: ipslout=6, ilv_cur=0, ilv_max=0 LOGICAL :: ioipsl_debug=.FALSE., lact_mode=.TRUE. diff --git a/F90subroutines/routing_interface.f90 b/F90subroutines/routing_interface.f90 index e6e4e202922f5cf849f87a7f1d4b016a10737ea2..591d6d2fbfd7c53384754b33e7ff62b1693e94c3 100644 --- a/F90subroutines/routing_interface.f90 +++ b/F90subroutines/routing_interface.f90 @@ -1,11 +1,14 @@ -SUBROUTINE initatmgrid(nbpt, nbseg, polygons_in, centre_in, area_in, contfrac_in, neighbours_in) +SUBROUTINE initatmgrid(rank, nbcore, nbpt, nbseg, polygons_in, centre_in, area_in, contfrac_in, neighbours_in) ! USE grid + USE ioipsl ! IMPLICIT NONE ! !! INPUT VARIABLES + INTEGER, INTENT(in) :: rank !! rank of processor + INTEGER, INTENT(in) :: nbcore INTEGER, INTENT(in) :: nbpt !! Atmospheric Domain size (unitless) INTEGER, INTENT(in) :: nbseg !! Number of segments in the polygone REAL, INTENT(in) :: polygons_in(nbpt,2*nbseg+1,2) @@ -17,6 +20,7 @@ SUBROUTINE initatmgrid(nbpt, nbseg, polygons_in, centre_in, area_in, contfrac_in !! Local INTEGER :: i INTEGER :: neighbours_loc(nbpt,nbseg*2) + CHARACTER(LEN=33) :: outfname ! DO i=1,nbpt ! Move from C to F indexing. @@ -25,8 +29,20 @@ SUBROUTINE initatmgrid(nbpt, nbseg, polygons_in, centre_in, area_in, contfrac_in ! CALL grid_init(nbpt, nbseg, polygons_in, centre_in, area_in, contfrac_in, neighbours_loc) ! + numout=100+rank + WRITE(outfname,'(A15,I4.4,A6,I4.4,A4)') "Out_RoutingReg_",rank,"_from_",nbcore,".txt" + OPEN(unit=numout, file=outfname) + ! END SUBROUTINE initatmgrid +SUBROUTINE closeinterface() + ! + USE ioipsl + ! + CLOSE(unit=numout) + ! +END SUBROUTINE closeinterface + SUBROUTINE gethydrogrid(nbpt, nbvmax_in, nbxmax_in, sub_pts, sub_index, sub_area, max_basins, min_topoind, & & lon_rel, lat_rel, trip, basins, topoindex, fac, hierarchy, nbi, nbj, area_bx, trip_bx, basin_bx, & & topoind_bx, fac_bx, hierarchy_bx, lon_bx, lat_bx, lshead_bx, nwbas) diff --git a/Interface.py b/Interface.py index ede10559d96a3166f263ba02a5847259d4e0f1ad..be95db1e9adf49db9a004eacf79b9de21cb48c92 100644 --- a/Interface.py +++ b/Interface.py @@ -52,11 +52,18 @@ if gendoc.lower() == "true" : # # initatmgrid : Initialises the grid.f90 module and passes the description of the atmospheric grid. # -def initatmgrid(nbpt, modelgrid) : +def initatmgrid(rank, nbcore, nbpt, modelgrid) : print("INITATMGRID corners", np.array(modelgrid.polyll).shape) print("INITATMGRID area", np.array(modelgrid.area).shape) print("INITATMGRID neighbours", np.array(modelgrid.neighbours).shape) - routing_interface.initatmgrid( modelgrid.polyll, modelgrid.coordll, modelgrid.area, modelgrid.contfrac, modelgrid.neighbours) + routing_interface.initatmgrid(rank, nbcore, modelgrid.polyll, modelgrid.coordll, modelgrid.area, modelgrid.contfrac, modelgrid.neighbours) + return +# +# +# +def closeinterface(comm) : + comm.Barrier() + routing_interface.closeinterface() return # # @@ -267,7 +274,19 @@ class HydroGraph : # # The field route_togrid is with indices on the local grid. That needs to be converted to the global grid. # + itarget=-1 + for il in range(procgrid.nbland) : + lo = procgrid.lon_full[procgrid.indP[il][0],procgrid.indP[il][1]] + la = procgrid.lat_full[procgrid.indP[il][0],procgrid.indP[il][1]] + d=np.sqrt((lo-3.13)**2+(la-39.70)**2) + if d < 0.05 : + itarget = il + + if itarget >+ 0 : + print part.rank, itarget, " Before route_togrid = ", self.route_togrid[itarget,:] grgrid = part.l2glandindex(self.route_togrid[:,:]) + if itarget >+ 0 : + print part.rank, itarget, " After route_togrid = ", self.route_togrid[itarget,:] rgrid = procgrid.landscatter(grgrid, order='F') rgrid = rgrid.astype(vtyp, copy=False) rgrid[rgrid >= RPP.IntFillValue] = NCFillValue diff --git a/RoutingPreProc.py b/RoutingPreProc.py index b4e5cb22dfabbc261781d5b69d01731a6d5ccc48..63aa0a0595bc7aa44c6c36782c5463725f9e848d 100644 --- a/RoutingPreProc.py +++ b/RoutingPreProc.py @@ -130,7 +130,7 @@ print("nbasmax : ", nbasmax) # hydrodata = HG.HydroData(hydrogrid.ncfile, hydrogrid.box, sub_index) -IF.initatmgrid(nbpt, modelgrid) +IF.initatmgrid(rank, nbcore, nbpt, modelgrid) @@ -177,3 +177,5 @@ hsuper.fetch() hgraph = IF.HydroGraph(nbasmax, hsuper) hgraph.dumpnetcdf(OutGraphFile, gg, modelgrid, part) + +IF.closeinterface(comm)