Changeset 802
- Timestamp:
- 01/21/19 11:34:04 (5 years ago)
- Location:
- codes/icosagcm/devel
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
codes/icosagcm/devel/Python/dynamico/getargs.py
r795 r802 22 22 return f 23 23 24 class Logger: 25 debug, info, error = [ ignore_first(fun) for fun in 26 logging.info, logging.warning, logging.error ] 27 def __init__(self, modulename): 28 arglist = parser.parse_args() 29 if modulename not in arglist.debug : 30 self.debug = noop 31 else: 32 print('Debug ON for module %s'%modulename) 33 config_log() 24 def getLogger(modulename='dynamico.main'): 25 # two logger are created 26 # the 'master' logger will be muted if current MPI process is not master 27 # log your messages through master two avoid massive logs with 1000+ MPI processes 28 master, world = logging.getLogger(modulename), logging.getLogger('%s.world'%modulename) 29 arglist = parser.parse_args() 30 debug=False 31 if modulename in ['dynamico.%s'%name for name in arglist.debug] : debug=True 32 if 'all' in arglist.debug : debug=True 33 if debug: 34 # print('Debug ON for module %s'%modulename) 35 master.setLevel(logging.DEBUG) 36 world.setLevel(logging.DEBUG) 37 else: 38 master.setLevel(logging.INFO) 39 world.setLevel(logging.INFO) 40 masters[modulename]=master 41 return master, world 34 42 35 def config_log(*args, **kwargs): 36 logging.basicConfig(level='INFO', *args, **kwargs) 43 def not_master(): 44 for logger in masters.values(): 45 logger.setLevel(logging.CRITICAL) 46 47 masters = {} 48 logging.basicConfig() -
codes/icosagcm/devel/Python/dynamico/meshes.py
r801 r802 12 12 from util import list_stencil, Base_class, inverse_list 13 13 from precision import zeros 14 15 import getargs 16 log_master, log_world = getargs.getLogger(__name__) 17 INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 18 INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug 14 19 15 20 radian=180/math.pi … … 57 62 # mass_db = db 58 63 n, llm, ptop = ap_il.shape[0], ap_il.shape[1]-1, ap_il[0,-1] 59 print 'hybrid ptop : ', ptop64 DEBUG('hybrid ptop : %f' % ptop) 60 65 mass_al = (ap_il+ptop*bp_il)/g 61 66 mass_dak, mass_dbk = np.zeros((n,llm)), np.zeros((n,llm)) … … 63 68 mass_dak[:,k] = mass_al[:,k]-mass_al[:,k+1] 64 69 mass_dbk[:,k] = bp_il[:,k]-bp_il[:,k+1] 65 print mass_al[0,:]66 print mass_dak[0,:]67 print mass_dbk[0,:]70 DEBUG('%s'%mass_al[0,:]) 71 DEBUG('%s'%mass_dak[0,:]) 72 DEBUG('%s'%mass_dbk[0,:]) 68 73 return [ np.asarray(x) for x in bp_il, mass_dak, mass_dbk ] 69 74 … … 196 201 f = cdf.Dataset(name, 'w', format='NETCDF4') 197 202 except: 198 print("Cartesian_mesh.ncwrite : Error occurred while opening new netCDF mesh file")203 ERROR("Cartesian_mesh.ncwrite : Error occurred while opening new netCDF mesh file") 199 204 raise 200 205 … … 292 297 def get_pvars(self,pdim,*names): return [self.get_pvar(pdim,name) for name in names] 293 298 def getvars(self,*names): 294 for name in names : print "getvar %s ..."%name299 for name in names : DEBUG("getvar %s ..."%name) 295 300 time1=time.time() 296 301 ret=[self.getvar(name) for name in names] 297 print "... Done in %f seconds"%(time.time()-time1)302 DEBUG("... Done in %f seconds"%(time.time()-time1)) 298 303 return ret 299 304 … … 306 311 if self.meshtype == 'curvilinear': 307 312 self.nx, self.ny = nc.nx, nc.ny 308 print('#NC4: Opening file:',gridfilename)309 313 def get_pdim(self,comm,name): return parallel.PDim(self.nc.dimensions[name], comm) 310 314 def getvar(self,name): return self.nc.variables[name][:] … … 338 342 self.nc = cdf.Dataset(gridfilename, "r") 339 343 except RuntimeError: 340 print"""344 ERROR(""" 341 345 Unable to open grid file %s, maybe you forgot to download it ? 342 346 To do so, go to the 'Python/' dir and execute './get_MPAS_grids.sh'. 343 """ % gridfile 347 """ % gridfile) 344 348 raise 345 349 def get_pdim(self,comm,name): … … 379 383 r=Riv2[ivertex,:] 380 384 r=sum(r) 381 if abs(r-1.)>1e-6 : print 'error with Riv2 at vertex ', ivertex385 if abs(r-1.)>1e-6 : WARNING('error with Riv2 at vertex %d'%ivertex) 382 386 # scale lengths and areas 383 387 # this is now done by apply_map … … 508 512 'le', 'de', 'lon_e', 'lat_e', 'angle_e') 509 513 def partition_metis(self): 510 print 'Partitioning with ParMetis...'514 INFO('Partitioning with ParMetis...') 511 515 edge_owner = unst.partition_mesh(self.trisk_deg, self.trisk, self.comm.Get_size()) 512 516 self.edge_owner = parallel.LocPArray1D(self.dim_edge, edge_owner) … … 521 525 return parallel.LocPArray1D(dim, owner_i + ni*owner_j) 522 526 nx, ny = self.gridfile.nx, self.gridfile.ny 523 print 'Partitioning %d x %d cells in %d x %d blocks ...'%(nx,ny,ni,nj)527 INFO('Partitioning %d x %d cells in %d x %d blocks ...'%(nx,ny,ni,nj)) 524 528 n = self.comm.Get_size() 525 529 assert n == ni*nj, 'Mismatch between ni x nj = %d and MPI_SIZE = %d.'%(ni*nj, n) … … 527 531 self.primal_owner = owner(self.dim_primal, self.primal_i, self.primal_j) 528 532 self.dual_owner = self.primal_owner 529 print 'partition_curvilinear %d :'%(self.comm.Get_rank()), self.primal_owner.data533 DEBUG('partition_curvilinear %d : %s'%(self.comm.Get_rank(), self.primal_owner.data) ) 530 534 531 535 def get(self, getter, *names): return [ getter(self.__dict__[x]) for x in names ] … … 557 561 comm, dim_primal, primal_owner, dim_edge, edge_owner, dim_dual, dual_owner = pmesh.members( 558 562 'comm', 'dim_primal', 'primal_owner', 'dim_edge', 'edge_owner', 'dim_dual', 'dual_owner' ) 559 print 'Constructing halos ...'563 INFO('Constructing halos ...') 560 564 edges_E0 = find_my_cells(edge_owner) 561 565 cells_C0, edges_E1, vertices_V1, edges_E2, cells_C1 = chain( … … 563 567 edges_E0, edges_E1, edges_E2 = progressive_list(edges_E0, edges_E1, edges_E2) 564 568 cells_C0, cells_C1 = progressive_list(cells_C0, cells_C1) 565 print 'E2,E1,E0 ; C1,C0 : ', map(len, (edges_E2, edges_E1, edges_E0, cells_C1, cells_C0))569 DEBUG('E2,E1,E0 ; C1,C0 : %s' % map(len, (edges_E2, edges_E1, edges_E0, cells_C1, cells_C0)) ) 566 570 get_own_cells, get_all_cells = dim_primal.getter(cells_C0), dim_primal.getter(cells_C1) 567 571 get_all_duals, get_all_edges = dim_dual.getter(vertices_V1), dim_edge.getter(edges_E2) … … 583 587 trisk = pmesh.edge2edge( edges_E2, dict_E2) 584 588 Riv2 = pmesh.vertex2cell( vertices_V1, dict_C1) 585 print 'Edge-vertex degree min/max %d %d'%(down_up.degree.min(), down_up.degree.max() )586 print 'Edge-cell degree min/max %d %d'%(left_right.degree.min(), left_right.degree.max() )587 print 'Primal degree min/max : %d %d'%(primal_edge.degree.min(), primal_edge.degree.max() )588 print 'Dual degree min/max : %d %d'%(dual_edge.degree.min(), dual_edge.degree.max() )589 print 'TRiSK degree min/max : %d %d'%(trisk.degree.min(), trisk.degree.max() )590 print 'Riv2 degree min/max : %d %d'%(Riv2.degree.min(), Riv2.degree.max() )589 DEBUG('Edge-vertex degree min/max %d %d'%(down_up.degree.min(), down_up.degree.max()) ) 590 DEBUG('Edge-cell degree min/max %d %d'%(left_right.degree.min(), left_right.degree.max()) ) 591 DEBUG('Primal degree min/max : %d %d'%(primal_edge.degree.min(), primal_edge.degree.max()) ) 592 DEBUG('Dual degree min/max : %d %d'%(dual_edge.degree.min(), dual_edge.degree.max()) ) 593 DEBUG('TRiSK degree min/max : %d %d'%(trisk.degree.min(), trisk.degree.max()) ) 594 DEBUG('Riv2 degree min/max : %d %d'%(Riv2.degree.min(), Riv2.degree.max()) ) 591 595 primal_deg, primal_edge, primal_ne = primal_edge.degree, primal_edge.neigh_loc, primal_edge.weight 592 596 dual_deg, dual_edge, dual_ne = dual_edge.degree, dual_edge.neigh_loc, dual_edge.weight … … 608 612 primal_own_all = comm.allgather(primal_own_num) 609 613 displ = sum(primal_own_all[0:comm.Get_rank()]) # required by XIOS 610 print 'local primal mesh :', primal_vertex.min(), primal_vertex.max(), primal_own_all, displ614 # print 'local primal mesh :', primal_vertex.min(), primal_vertex.max(), primal_own_all, displ 611 615 612 616 # construct own dual mesh for XIOS output -
codes/icosagcm/devel/Python/dynamico/parallel.py
r691 r802 11 11 12 12 from unstructured import ker 13 14 import getargs 15 log_master, log_world = getargs.getLogger(__name__) 16 INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 17 INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug 13 18 14 19 #----------------------- Parallel access to distributed array ------------------------------# … … 142 147 send_len = [len(lst) for lst in send] 143 148 send_rank = [rank for rank in range(mpi_size) if (send_len[rank]>0)] # CPUs asking for data 144 print 'send_rank %d'%mpi_rank, send_rank149 DEBUG('send_rank %d %s'%(mpi_rank, send_rank)) 145 150 # asssociate local index to global index 146 151 own_dict = { glob:loc for glob,loc in zip(own_global, own_local) } -
codes/icosagcm/devel/Python/dynamico/time_step.py
r778 r802 2 2 from scipy import sparse as sparse 3 3 import math as math 4 5 import getargs 6 log_master, log_world = getargs.getLogger(__name__) 7 INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 8 INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug 4 9 5 10 class Struct: pass … … 87 92 def __init__(self,precision,bwd_fast_slow, dt,nstage, bsjl,bfjl): 88 93 if bwd_fast_slow is None: 89 print 'SIRK with Fortran-side time stepping'94 DEBUG('SIRK with Fortran-side time stepping') 90 95 precision=np.float64 91 96 else: 92 print 'SIRK with Python-side time stepping at precision ', precision97 DEBUG('SIRK with Python-side time stepping at precision %s' % precision) 93 98 94 99 self.bwd_fast_slow = bwd_fast_slow … … 98 103 self.csjl, self.cfjl = [x.astype(precision) for x in csjl, cfjl] 99 104 self.tauj = np.array([dt*bfjl[j,j] for j in range(self.nstage)], dtype=precision) 100 print 'Types of csjl, cfjl, tauj :', self.csjl.dtype, self.cfjl.dtype, self.tauj.dtype105 DEBUG('Types of csjl, cfjl, tauj : %s %s %s' % (self.csjl.dtype, self.cfjl.dtype, self.tauj.dtype) ) 101 106 def next(self,zj): 102 107 csjl, cfjl, tauj = self.csjl, self.cfjl, self.tauj -
codes/icosagcm/devel/Python/dynamico/wrap.py
r790 r802 1 1 #------------------- wrap C/Fortran routines -------------------# 2 2 import getargs 3 log_master, log_world = getargs.getLogger(__name__) 4 INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 5 INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug 6 7 3 8 import numpy as np 4 9 from ctypes import * … … 55 60 name = prefix+name 56 61 soname = self.prefix_so+name 57 if verbose : print 'wrap.Sharedlib : importing', soname62 DEBUG('wrap.Sharedlib : importing %s' % soname) 58 63 self.vardict[self.prefix_py+name] = Wrap(self.lib[soname], self.check_args, proto) 59 64 def addvars(self,*types_and_names): … … 72 77 for name,val in zip(names,vals): 73 78 self.vars[name].value=val 74 75 args = getargs.parse()76 verbose = 'wrap' in args.debug -
codes/icosagcm/devel/Python/dynamico/xios.py
r790 r802 8 8 import getargs 9 9 args=getargs.parse() 10 verbose = 'xios' in args.debug 10 log_master, log_world = getargs.getLogger(__name__) 11 INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 12 INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug 11 13 12 14 #----------------------------------------------------------------------------- … … 18 20 return self 19 21 def __exit__(self, type, value, traceback): 20 print('xios_finalize()') 22 INFO('xios_finalize()') 23 DEBUG_ALL('xios_finalize') 21 24 cxios.finalize() 22 25 def min(self,data): return self.comm.allreduce(data, op=MPI.MIN) … … 25 28 class Context: 26 29 def __enter__(self): 27 print('cxios.context_close_definition()')30 INFO('cxios.context_close_definition()') 28 31 cxios.context_close_definition() 29 32 return self 30 33 def __exit__(self, type, value, traceback): 31 print('xios_context_finalize()')34 INFO('xios_context_finalize()') 32 35 cxios.context_finalize() 33 36 def init_llm(self, mesh, nqtot): … … 68 71 mesh = cxios.Handle(cat,id) 69 72 def log(name,data) : 70 if verbose : print('setup_curvilinear : %s shape min max'%name, data.shape, data.min(), data.max() )73 DEBUG('setup_curvilinear : %s shape min max %s %s %s'%(name, data.shape, data.min(), data.max()) ) 71 74 i_index, j_index, lon, lat = [ x[own] for x in i_index, j_index, lon, lat ] 72 75 log('i_index',i_index) -
codes/icosagcm/devel/Python/src/cxios.pyx
r760 r802 6 6 c_void_pp=POINTER(c_void_p) # used in prototype 7 7 c_void_p_byref=type(byref(c_void_p())) # used in py2c because byref creates an object of this type, not c_void_pp 8 9 import getargs 10 log_master, log_world = getargs.getLogger(__name__) 11 INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 12 INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug 8 13 9 14 # ------------- Direct cython interfaces ----------------- # … … 44 49 _fields_ = [(name, c_int) for name in ('year', 'month', 'day', 'hour', 'minute', 'second') ] 45 50 46 print Duration.from_param47 48 51 for x in c_void_p_byref, Duration, Date : wrap.py2c[x]=wrap.noop # accept arguments of type (void*)&, Duration, ... 49 52 … … 78 81 else: 79 82 raise(TypeError) 80 print self.id+'.'+prefix+key, type(value), extra83 DEBUG('%s.%s %s %s' % (self.id, prefix+key, type(value), extra) ) 81 84 def update_timestep(self): 82 85 lib.update_calendar_timestep(self.handle) -
codes/icosagcm/devel/Python/src/unstructured.pyx
r792 r802 9 9 cimport numpy as np 10 10 import numpy as np 11 12 import getargs 13 log_master, log_world = getargs.getLogger(__name__) 14 INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 15 INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug 11 16 12 17 #-------------- choose precision of kernel computations ------------# … … 58 63 59 64 try: 60 61 65 kernels = wrap.SharedLib(vars(ker), libicosa, check_args=check_args) 66 setvar, setvars, getvar, getvars = kernels.setvar, kernels.setvars, kernels.getvar, kernels.getvars 62 67 except OSError: 63 print """ 64 Unable to load shared library 'libicosa.so' ! 65 """ 66 raise 68 ERROR("Unable to load shared library 'libicosa.so' !") 69 raise 67 70 68 71 # providing a full prototype enables type-checking when calling … … 90 93 91 94 kernels.addvars( 92 c_bool,'hydrostatic','debug_hevi_solver', 95 c_bool,'hydrostatic','debug_hevi_solver', 'is_mpi_master', 93 96 c_int,'llm','nqdyn','primal_num','max_primal_deg', 94 97 'dual_num','max_dual_deg','edge_num','max_trisk_deg', 95 'caldyn_thermo','caldyn_eta','nb_threads', 'dynamico_mpi_rank',98 'caldyn_thermo','caldyn_eta','nb_threads', 96 99 c_double,'elapsed', 97 100 c_num, 'g', 'ptop', 'cpp', 'cppv', … … 119 122 return data 120 123 121 cdef check_ptr(name, num_ptr p, ndarray data):122 if p != ptr(data) : print name, 'p <> ptr(data) !!'123 124 124 cdef class Caldyn_step: 125 125 # number of time steps to do at each invocation of advance() … … 300 300 Ai, Av, fv, le_de, Riv2, wee): 301 301 302 print 'Types of Ai, Av, fv, le_de, Riv2, wee : ', Ai.dtype,Av.dtype,fv.dtype,le_de.dtype,Riv2.dtype,wee.dtype 302 DEBUG('Types of Ai, Av, fv, le_de, Riv2, wee : %s' % 303 ((Ai.dtype,Av.dtype,fv.dtype,le_de.dtype,Riv2.dtype,wee.dtype),) ) 303 304 for var,varname in zip((Ai,Av,fv,le_de,Riv2,wee), ('Ai','Av','fv','le_de','Riv2','wee')): 304 305 assert var.dtype == np.float64, '%s must be double precision'%varname … … 308 309 (llm, nqdyn, edge_num, primal_num, dual_num, 309 310 max_trisk_deg, max_primal_deg, max_dual_deg) ) 310 print('init_mesh ...')311 INFO('init_mesh ...') 311 312 ker.dynamico_init_mesh(primal_nb,primal_edge,primal_ne, 312 313 dual_nb,dual_edge,dual_ne,dual_vertex, 313 314 left,right,down,up,trisk_deg,trisk) 314 print('...done')315 print('init_metric ...')315 INFO('...done') 316 INFO('init_metric ...') 316 317 ker.dynamico_init_metric(Ai,Av,fv,le_de,Riv2,wee) 317 print('...done')318 INFO('...done') 318 319 319 320 #------------------------ Mesh partitioning ------------------------ -
codes/icosagcm/devel/Python/test/py/Baroclinic_3D_ullrich.py
r800 r802 22 22 getargs.defaults(dt=360., llm=50) 23 23 24 getargs.config_log(filename='out.log',filemode='w') # must be done before calling Logger()24 #getargs.config_log(filename='out.log',filemode='w') # must be done before calling Logger() 25 25 # getargs.config_log(filename='out.log',filemode='w', 26 26 # format='%(processName)s:%(name)s:%(filename)s:%(module)s:%(funcName)s:%(lineno)d:%(levelname)s:%(message)s' ) 27 27 28 logging = getargs.Logger('main')29 28 args = getargs.parse() 29 log_master, log_world = getargs.getLogger() 30 INFO, DEBUG, DEBUG_ALL, ERROR = log_master.info, log_master.debug, log_world.debug, log_world.error 30 31 31 32 from dynamico import unstructured as unst … … 50 51 def create_pmesh(nx,ny): 51 52 filename = 'cart_%03d_%03d.nc'%(nx,ny) 52 logging.info('Reading Cartesian mesh ...')53 INFO('Reading Cartesian mesh ...') 53 54 meshfile = meshes.DYNAMICO_Format(filename) 54 55 pmesh = meshes.Unstructured_PMesh(comm,meshfile) … … 105 106 y_ek, alpha_ek = np.meshgrid(mesh.lat_e, alpha_k, indexing='ij') 106 107 107 print(np.shape(alpha_k),np.shape(alpha_l))108 # print(np.shape(alpha_k),np.shape(alpha_l)) 108 109 thermo = dyn.Ideal_perfect(Cpd, Rd, p0, T0) 109 110 … … 127 128 u_ek = mesh.ucov3D(ulon(x_ek, y_ek, eta_ek), 0.*eta_ek) 128 129 129 print('ztop (m) = ', Phi_il[0,-1]/g, ztop)130 INFO('ztop (m) = %f %f' % (Phi_il[0,-1]/g, ztop) ) 130 131 ptop = p(eta(1.)) 131 print( 'ptop (Pa) = ', gas.p[0,-1], ptop)132 print('ztop(ptop) according to Eq. 7:', T0/lap*(1.-(ptop/p0)**(Rd*lap/g)))132 INFO( 'ptop (Pa) = %f %f' % (gas.p[0,-1], ptop) ) 133 INFO('ztop(ptop) according to Eq. 7: %f' % (T0/lap*(1.-(ptop/p0)**(Rd*lap/g))) ) 133 134 134 135 params=dyn.Struct() … … 140 141 # define parameters for lower BC 141 142 pbot = p(eta_il[:,0]) 142 print( 'min p, T :', pbot.min(), tmean(pbot/p0))143 INFO( 'min p, T : %f %s' % (pbot.min(), tmean(pbot/p0)) ) 143 144 gas_bot = thermo.set_pT(pbot, tmean(pbot/p0)) 144 145 params.pbot = gas_bot.p … … 167 168 class myDavies(Davies): 168 169 def mask(self,x,y): 169 logging.debug('davies dy = %f'% dx)170 DEBUG('davies dy = %f'% dx) 170 171 return self.mask0(y,Ly,dx)*self.mask0(-y,0.,dx) 171 172 … … 174 175 mpi_rank, mpi_size = comm.Get_rank(), comm.Get_size() 175 176 176 logging.info('%d/%d starting'%(mpi_rank,mpi_size)) 177 177 INFO('%d/%d starting'%(mpi_rank,mpi_size)) 178 if mpi_rank>0 : 179 getargs.not_master() 180 unst.setvar('is_mpi_master', False) 181 178 182 g, Lx, Ly = 9.80616, 4e7, 6e6 179 183 nx, ny, llm = args.nx, args.ny, args.llm … … 181 185 182 186 unst.setvar('g',g) 183 187 unst.setvar('debug_hevi_solver', False) 188 184 189 pmesh = create_pmesh(nx,ny) 185 190 thermo, mesh, params, flow0, gas0 = baroclinic_3D(pmesh, dx,Lx,Ly,llm, args.ztop) … … 193 198 nt = int(math.ceil(T/dt)) 194 199 dt = T/nt 195 logging.info( 'Time step : %d x %g = %g s' % (nt,dt,nt*dt))200 INFO( 'Time step : %d x %g = %g s' % (nt,dt,nt*dt)) 196 201 197 202 … … 215 220 mesh.lon_i, mesh.lat_i, mesh.lon_e,mesh.lat_e) 216 221 # print('mask min/max :', davies.beta_i.min(), davies.beta_i.max() ) 217 logging.debug('mask min/max :')218 logging.debug('%f'% davies.beta_i.min())219 logging.debug('%f'% davies.beta_i.max())222 DEBUG('mask min/max :') 223 DEBUG('%f'% davies.beta_i.min()) 224 DEBUG('%f'% davies.beta_i.max()) 220 225 221 226 def next_flow(m,S,u,Phi,W): … … 285 290 context.send_field_dual('curl_abs', zeta_abs_vk) 286 291 287 print( 'ptop, model top (m) :', unst.getvar('ptop'), Phi.max()/unst.getvar('g'))292 INFO( 'ptop, model top (m) : %f %f' % (unst.getvar('ptop'), Phi.max()/unst.getvar('g')) ) 288 293 289 294 time1, elapsed1 =time.time(), unst.getvar('elapsed') … … 291 296 time2, elapsed2 =time.time(), unst.getvar('elapsed') 292 297 factor = 1000./nt 293 print( 'ms per full time step : ', factor*(time2-time1), factor*(elapsed2-elapsed1))298 INFO( 'ms per full time step : %f %f' %(factor*(time2-time1), factor*(elapsed2-elapsed1)) ) 294 299 factor = 1e9/(4*nt*nx*ny*llm) 295 print( 'nanosec per gridpoint per full time step : ', factor*(time2-time1), factor*(elapsed2-elapsed1)) 296 297 logging.info('************DONE************') 300 INFO( 'nanosec per gridpoint per full time step : %f %f' % 301 (factor*(time2-time1), factor*(elapsed2-elapsed1)) ) 302 303 INFO('************DONE************') -
codes/icosagcm/devel/Python/test/py/RSW2_MPAS_W02.py
r801 r802 1 print 'Starting' 1 from dynamico import getargs 2 log_master, log_world = getargs.getLogger() 3 INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 4 5 INFO('Starting') 2 6 3 7 from mpi4py import MPI 4 8 comm = MPI.COMM_WORLD 5 9 mpi_rank, mpi_size = comm.Get_rank(), comm.Get_size() 6 print '%d/%d starting'%(mpi_rank,mpi_size)10 INFO('%d/%d starting'%(mpi_rank,mpi_size)) 7 11 prefix='fig_RSW2_MPAS_W02/%02d'%mpi_rank 8 12 9 print 'Loading DYNAMICO modules ...' 13 INFO('Loading DYNAMICO modules ...') 10 14 from dynamico import unstructured as unst 11 15 from dynamico.meshes import MPAS_Format, Unstructured_PMesh as PMesh, Local_Mesh as Mesh -
codes/icosagcm/devel/src/unstructured/data_unstructured.F90
r796 r802 12 12 INDEX, BIND(C) :: caldyn_thermo=thermo_theta, caldyn_eta=eta_lag, & 13 13 caldyn_vert_variant=caldyn_vert_cons, nb_threads=0, nb_stage=0 14 LOGICAL(C_BOOL), BIND(C) :: hydrostatic=.TRUE. 14 LOGICAL(C_BOOL), BIND(C) :: hydrostatic=.TRUE., is_mpi_master=.TRUE., debug_on=.FALSE. 15 15 LOGICAL(C_BOOL), BIND(C, NAME='debug_hevi_solver') :: debug_hevi_solver_=.TRUE. 16 16 … … 42 42 NUM2(:,:), ALLOCATABLE :: centroid, xyz_v, Riv2, wee, ap,bp, mass_bl, mass_dak, mass_dbk 43 43 44 INTEGER(C_INT), BIND(C) :: comm_icosa , dynamico_mpi_rank=044 INTEGER(C_INT), BIND(C) :: comm_icosa 45 45 46 46 INTEGER, PARAMETER :: id_dev1=1, id_dev2=2, & … … 82 82 TIME :: total_spent 83 83 total_spent=SUM(time_spent) 84 IF( dynamico_mpi_rank==0) THEN84 IF(is_mpi_master) THEN 85 85 PRINT *, '========================= Performance metrics =========================' 86 86 PRINT *, 'Total time spent in instrumented code (seconds) :', total_spent … … 139 139 INDEX, DIMENSION(edge_num) :: left_, right_, down_, up_ 140 140 141 PRINT *, 'init_mesh ...' 142 PRINT *, 'Primal mesh : ', primal_num, max_primal_deg 143 PRINT *, 'Dual mesh : ', dual_num, max_dual_deg 144 PRINT *, 'Edge mesh : ', edge_num, max_trisk_deg 145 PRINT *, 'Vertical levels :', llm 141 IF(is_mpi_master) THEN 142 PRINT *, 'init_mesh ...' 143 PRINT *, 'Primal mesh : ', primal_num, max_primal_deg 144 PRINT *, 'Dual mesh : ', dual_num, max_dual_deg 145 PRINT *, ' Edge mesh : ', edge_num, max_trisk_deg 146 PRINT *, 'Vertical levels :', llm 147 END IF 146 148 ALLOC1(primal_deg, primal_num) 147 149 ALLOC2(primal_edge, max_primal_deg,primal_num) … … 153 155 ALLOC1(trisk_deg, edge_num) 154 156 ALLOC2(trisk, max_trisk_deg, edge_num) 155 PRINT *, SHAPE(trisk), edge_num156 157 ALLOC1(left, edge_num) 157 158 ALLOC1(right, edge_num) … … 177 178 trisk_deg(:)=trisk_deg_(:) 178 179 trisk(:,:)=trisk_(:,:) 179 PRINT *, MAXVAL(primal_edge), edge_num 180 PRINT *, MAXVAL(dual_edge), edge_num 181 PRINT *, MAXVAL(dual_vertex), dual_num 182 PRINT *, MAXVAL(trisk), edge_num 183 PRINT *, MAX(MAXVAL(left),MAXVAL(right)), primal_num 184 PRINT *, MAX(MAXVAL(up),MAXVAL(down)), dual_num 185 PRINT *, SHAPE(trisk), edge_num 186 PRINT *,' ... Done.' 180 IF(is_mpi_master) THEN 181 PRINT *, MAXVAL(primal_edge), edge_num 182 PRINT *, MAXVAL(dual_edge), edge_num 183 PRINT *, MAXVAL(dual_vertex), dual_num 184 PRINT *, MAXVAL(trisk), edge_num 185 PRINT *, MAX(MAXVAL(left),MAXVAL(right)), primal_num 186 PRINT *, MAX(MAXVAL(up),MAXVAL(down)), dual_num 187 PRINT *, SHAPE(trisk), edge_num 188 PRINT *,' ... Done.' 189 END IF 187 190 END SUBROUTINE init_mesh 188 191 … … 194 197 DBL :: Ai_(primal_num), Av_(dual_num), fv_(dual_num), le_de_(edge_num), & 195 198 Riv2_(max_dual_deg,dual_num), wee_(max_trisk_deg,edge_num) 196 PRINT *, 'init_metric ...'199 IF(is_mpi_master) PRINT *, 'init_metric ...' 197 200 ALLOC1(Ai,primal_num) 198 201 ALLOC1(Av,dual_num) … … 207 210 Riv2(:,:)=Riv2_(:,:) 208 211 wee(:,:) = wee_(:,:) 209 PRINT *, 'Max Ai : ', MAXVAL(ABS(Ai)) 210 PRINT *, 'Max Av : ', MAXVAL(ABS(Av)) 211 PRINT *, 'Max fv : ', MAXVAL(ABS(fv)) 212 PRINT *, 'Max le_de : ', MAXVAL(ABS(le_de)) 213 PRINT *, 'Max Riv2 : ', MAXVAL(ABS(Riv2)) 214 PRINT *, 'Max wee : ', MAXVAL(ABS(wee)) 215 PRINT *, MINVAL(right), MAXVAL(right) 216 PRINT *, MINVAL(right), MAXVAL(left) 217 PRINT *,' ... Done.' 218 IF(nb_threads==0) nb_threads=OMP_GET_MAX_THREADS() 219 PRINT *,'OpenMP : max_threads, num_procs, nb_threads', OMP_GET_MAX_THREADS(), OMP_GET_NUM_PROCS(), nb_threads 212 IF(is_mpi_master) THEN 213 PRINT *, 'Max Ai : ', MAXVAL(ABS(Ai)) 214 PRINT *, 'Max Av : ', MAXVAL(ABS(Av)) 215 PRINT *, 'Max fv : ', MAXVAL(ABS(fv)) 216 PRINT *, 'Max le_de : ', MAXVAL(ABS(le_de)) 217 PRINT *, 'Max Riv2 : ', MAXVAL(ABS(Riv2)) 218 PRINT *, 'Max wee : ', MAXVAL(ABS(wee)) 219 PRINT *, MINVAL(right), MAXVAL(right) 220 PRINT *, MINVAL(right), MAXVAL(left) 221 PRINT *,' ... Done.' 222 IF(nb_threads==0) nb_threads=OMP_GET_MAX_THREADS() 223 PRINT *,'OpenMP : max_threads, num_procs, nb_threads', OMP_GET_MAX_THREADS(), OMP_GET_NUM_PROCS(), nb_threads 224 END IF 220 225 END SUBROUTINE init_metric 221 226 ! … … 225 230 ! 226 231 SUBROUTINE init_params() BINDC(init_params) 227 PRINT *, 'Setting physical parameters ...'228 IF(hydrostatic) THEN229 PRINT *, 'Hydrostatic dynamics (HPE)'230 ELSE231 PRINT *, 'Non-hydrostatic dynamics (Euler)'232 END IF233 232 kappa = Rd/cpp 234 PRINT *, 'g = ',g 235 PRINT *, 'preff = ',preff 236 PRINT *, 'Treff = ',Treff 237 PRINT *, 'Rd = ',Rd 238 PRINT *, 'cpp = ',cpp 239 PRINT *, 'kappa = ',kappa 240 PRINT *, '... Done' 233 IF(is_mpi_master) THEN 234 PRINT *, 'Setting physical parameters ...' 235 IF(hydrostatic) THEN 236 PRINT *, 'Hydrostatic dynamics (HPE)' 237 ELSE 238 PRINT *, 'Non-hydrostatic dynamics (Euler)' 239 END IF 240 PRINT *, 'g = ',g 241 PRINT *, 'preff = ',preff 242 PRINT *, 'Treff = ',Treff 243 PRINT *, 'Rd = ',Rd 244 PRINT *, 'cpp = ',cpp 245 PRINT *, 'kappa = ',kappa 246 PRINT *, '... Done' 247 END IF 241 248 CALL init_trace 242 249 END SUBROUTINE init_params … … 245 252 DBL :: bl(llm+1, primal_num), & 246 253 dak(llm, primal_num), dbk(llm, primal_num) 247 PRINT *, 'Setting hybrid coefficients ...'254 IF(is_mpi_master) PRINT *, 'Setting hybrid coefficients ...' 248 255 ALLOC2(mass_bl, llm+1, primal_num) 249 256 ALLOC2(mass_dak, llm, primal_num) … … 252 259 mass_dak(:,:) = dak(:,:) 253 260 mass_dbk(:,:) = dbk(:,:) 254 PRINT *, '... Done, llm = ', llm261 IF(is_mpi_master) PRINT *, '... Done, llm = ', llm 255 262 END SUBROUTINE Init_hybrid 256 263 -
codes/icosagcm/devel/src/unstructured/timestep_unstructured.F90
r792 r802 305 305 ! This is the case when calling from Python after importing mpi4py 306 306 INTEGER :: ierr, mpi_threading_mode 307 308 307 PRINT *, 'Initialize XIOS and obtain our communicator' 309 308 CALL xios_initialize("icosagcm",return_comm=comm_icosa) 310 311 PRINT *, 'Initialize our XIOS context'312 313 309 CALL xios_context_initialize("icosagcm",comm_icosa) 314 310 CALL xios_get_handle("icosagcm",ctx_hdl) -
codes/icosagcm/devel/src/unstructured/transfer_unstructured.F90
r700 r802 37 37 INTEGER(C_INT) :: send_rank(send_num), send_len(send_num), send_list(send_size), & 38 38 recv_rank(recv_num), recv_len(recv_num), recv_list(recv_size) 39 PRINT *, 'init_transfer', index, &39 IF(debug_on) PRINT *, 'init_transfer', index, & 40 40 send_num, send_size, '/', send_rank, '/', send_len, '/', & 41 41 recv_num, recv_size, '/', recv_rank, '/', recv_len, '/'
Note: See TracChangeset
for help on using the changeset viewer.