diff --git a/.gitignore b/.gitignore index 91811d37958e23f8b1973a1d7015c3567390477e..f6e84233a391d14ec54c2bc19bcb0d61f53cb791 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,11 @@ xcuserdata/ *.png *.so *.log +*.nc Weights/ __pycache__/ -DomainDecompTests/Output/ \ No newline at end of file +# +# Test configurations and directories +# +DomainDecompTests/Output/ +DomainDecompTests/run.def \ No newline at end of file diff --git a/DomainDecomp.py b/DomainDecomp.py deleted file mode 100644 index 52ca51b6880e43d2e652d565d3f29f05076200a9..0000000000000000000000000000000000000000 --- a/DomainDecomp.py +++ /dev/null @@ -1,124 +0,0 @@ -# -# -# -import numpy as np -import os, sys -from netCDF4 import Dataset -from mpi4py import MPI -comm = MPI.COMM_WORLD -# -sys.path.append('../') -# -# Get the information from the configuration file. -# -import configparser -config=configparser.ConfigParser({'SaveWeights':'true', "DiagLon":"0.0, 0.0", "DiagLat":"0.0, 0.0"}) -config.read("../run.def") -# -import getargs -log_master, log_world = getargs.getLogger(__name__) -INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error -INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug -# -import ModelGrid as MG -import Partition as PA -import RPPtools as RPP -# -import matplotlib.pylab as plt -import savefile -# -gg = MG.GlobalGrid() -# -szhalo=1 -nbc=comm.Get_size() -rank=comm.Get_rank() -# -# Open write unit -# -if not os.path.exists('Output'): - os.makedirs('Output') -wunit = open("Output/TestDomain_out_"+str(rank)+".txt", "w") -# -wunit.write("START :: i = 0 :"+str(gg.ni-1)+" >> j = 0 :"+str(gg.nj-1)+" SZ="+str(gg.ni*gg.nj)+" nbland="+str(gg.nbland)+'\n') -wunit.write("======================================"+'\n') -# -part = PA.partition(gg.ni, gg.nj, gg.land, comm, nbc, szhalo, rank, wunit=wunit) - -wunit.write("Domain on proc : "+str(part.ni)+str(part.nj)+" Offset from global domain : "+str(part.istart)+str(part.jstart)+'\n') -wunit.write("Domain with halo on proc : "+str(part.nih)+str(part.njh)+" Offset with halo : "+str(part.ihstart)+str(part.jhstart)+'\n') -wunit.write(" i inner = "+str(part.istart)+":"+str(part.istart+part.ni-1)+" i w.halo = "+str(part.ihstart)+":"+str(part.ihstart+part.nih-1)) -wunit.write(" j inner = "+str(part.jstart)+":"+str(part.jstart+part.nj-1)+" j w.halo = "+str(part.jhstart)+":"+str(part.jhstart+part.njh-1)+'\n') -wunit.write("=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+======================"+'\n') - -x=np.zeros((part.njh,part.nih)) -ihoff=part.istart-part.ihstart -jhoff=part.jstart-part.jhstart -x[jhoff:jhoff+part.nj,ihoff:ihoff+part.ni]=99 - -wunit.write("====== TEST FIELD START ======================"+'\n') -for j in range(part.njh) : - wunit.write(str(x[j,:].astype(int))+'\n') - -part.sendtohalo(x) - -wunit.write("====== TEST FIELD AFTER HALO EXCHANGE ======================"+'\n') -for j in range(part.njh) : - wunit.write(str(x[j,:].astype(int))+'\n') - -x=np.zeros((part.njh,part.nih)) -ihoff=part.istart-part.ihstart -jhoff=part.jstart-part.jhstart -x[jhoff:jhoff+part.nj,ihoff:ihoff+part.ni]=rank - -wunit.write("====== GATHER FIELD START ======================"+'\n') -for j in range(part.njh) : - wunit.write(str(x[j,:].astype(int))+'\n') - -xgather = part.gather(x) - -if rank == 0 : - print("Type of gathered variable : ", xgather.astype(int)) - -modelgrid=MG.ModelGrid(part.ihstart+gg.igstart, part.nih, part.jhstart+gg.jgstart, part.njh) -INFO("Longitude interval on proc "+str(rank)+" = "+str(modelgrid.box_land[0][0])+" : "+str(modelgrid.box_land[0][1])) -INFO("Latitude interval on proc "+str(rank)+" = "+str(modelgrid.box_land[1][0])+" : "+str(modelgrid.box_land[1][1])) - -rland=np.zeros((modelgrid.nbland)) -rland[:] = rank - -xland = part.landscatgat(modelgrid, rland) - -if rank == 0 : - xland[~np.isnan(xland)] = 1 - xland[np.isnan(xland)] = 0 - print("Difference between global and and the gathered version :",np.sum(xland-gg.land)) - -# -# Test the landsendtohalo function -# -x=np.zeros((part.njh,part.nih)) -x[:,:]=-1 -ihoff=part.istart-part.ihstart -jhoff=part.jstart-part.jhstart -x[jhoff:jhoff+part.nj,ihoff:ihoff+part.ni]=rank - -lx = modelgrid.landgather(x) -part.landsendtohalo(lx) -xland = part.landscatgat(modelgrid, lx) - -if rank == 0 : - xland[~np.isnan(xland)] = 1 - xland[np.isnan(xland)] = 0 - print("Difference between global and gathered version of land only :",np.sum(xland-gg.land)) - -print("len areas : ", len(modelgrid.area)) -areas = part.landscatgat(modelgrid, np.array(modelgrid.area)) -if rank == 0 : - print(areas/1000000000.) -wunit.close() - -y=np.zeros((nbc,modelgrid.nbland)) -print("Test : ", y.shape, modelgrid.nbland) -y[rank,:]=rank - -savefile.dumpnetcdf("TestDomainDecomp.nc", gg, modelgrid, part, rland, x, y) diff --git a/DomainDecompTests/DomainDecomp.py b/DomainDecompTests/DomainDecomp.py index c1481d07b9628d2def519195fc4c43d209f9d08e..ca0bacfc43cc81ed5a3423184f6c18bedecbeeeb 100644 --- a/DomainDecompTests/DomainDecomp.py +++ b/DomainDecompTests/DomainDecomp.py @@ -35,8 +35,10 @@ rank=comm.Get_rank() # # Open write unit # -if not os.path.exists('Output'): - os.makedirs('Output') +if rank == 0 : + if not os.path.exists('Output'): + os.makedirs('Output') +comm.Barrier() wunit = open("Output/TestDomain_out_"+str(rank)+".txt", "w") # wunit.write("START :: i = 0 :"+str(gg.ni-1)+" >> j = 0 :"+str(gg.nj-1)+" SZ="+str(gg.ni*gg.nj)+" nbland="+str(gg.nbland)+'\n') diff --git a/DomainDecompTests/TestDomaonDecomp.pbs b/DomainDecompTests/TestDomainDecomp.pbs similarity index 100% rename from DomainDecompTests/TestDomaonDecomp.pbs rename to DomainDecompTests/TestDomainDecomp.pbs