Changeset 802


Ignore:
Timestamp:
01/21/19 11:34:04 (5 years ago)
Author:
dubos
Message:

devel/unstructured : reduced, configurable log output

Location:
codes/icosagcm/devel
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/devel/Python/dynamico/getargs.py

    r795 r802  
    2222    return f 
    2323 
    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() 
     24def 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 
    3442 
    35 def config_log(*args, **kwargs): 
    36     logging.basicConfig(level='INFO', *args, **kwargs) 
     43def not_master(): 
     44    for logger in masters.values(): 
     45        logger.setLevel(logging.CRITICAL) 
     46 
     47masters = {} 
     48logging.basicConfig() 
  • codes/icosagcm/devel/Python/dynamico/meshes.py

    r801 r802  
    1212from util import list_stencil, Base_class, inverse_list 
    1313from precision import zeros 
     14 
     15import getargs 
     16log_master, log_world = getargs.getLogger(__name__) 
     17INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 
     18INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug 
    1419 
    1520radian=180/math.pi 
     
    5762    # mass_db = db 
    5863    n, llm, ptop = ap_il.shape[0], ap_il.shape[1]-1, ap_il[0,-1] 
    59     print 'hybrid ptop : ', ptop  
     64    DEBUG('hybrid ptop : %f' % ptop)  
    6065    mass_al = (ap_il+ptop*bp_il)/g 
    6166    mass_dak, mass_dbk = np.zeros((n,llm)), np.zeros((n,llm)) 
     
    6368        mass_dak[:,k] = mass_al[:,k]-mass_al[:,k+1] 
    6469        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,:]) 
    6873    return [ np.asarray(x) for x in bp_il, mass_dak, mass_dbk ] 
    6974 
     
    196201            f = cdf.Dataset(name, 'w', format='NETCDF4') 
    197202        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") 
    199204            raise 
    200205 
     
    292297    def get_pvars(self,pdim,*names): return [self.get_pvar(pdim,name) for name in names] 
    293298    def getvars(self,*names):  
    294             for name in names : print "getvar %s ..."%name 
     299            for name in names : DEBUG("getvar %s ..."%name) 
    295300            time1=time.time() 
    296301            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)) 
    298303            return ret 
    299304     
     
    306311        if self.meshtype == 'curvilinear': 
    307312            self.nx, self.ny = nc.nx, nc.ny 
    308         print('#NC4: Opening file:',gridfilename) 
    309313    def get_pdim(self,comm,name): return parallel.PDim(self.nc.dimensions[name], comm) 
    310314    def getvar(self,name): return self.nc.variables[name][:] 
     
    338342            self.nc = cdf.Dataset(gridfilename, "r") 
    339343        except RuntimeError: 
    340             print """ 
     344            ERROR(""" 
    341345Unable to open grid file %s, maybe you forgot to download it ? 
    342346To do so, go to the 'Python/' dir and execute './get_MPAS_grids.sh'. 
    343             """ % gridfile 
     347            """ % gridfile) 
    344348            raise 
    345349    def get_pdim(self,comm,name):  
     
    379383            r=Riv2[ivertex,:] 
    380384            r=sum(r) 
    381             if abs(r-1.)>1e-6 : print 'error with Riv2 at vertex ', ivertex 
     385            if abs(r-1.)>1e-6 : WARNING('error with Riv2 at vertex %d'%ivertex) 
    382386        # scale lengths and areas 
    383387        # this is now done by apply_map 
     
    508512                         'le', 'de', 'lon_e', 'lat_e', 'angle_e') 
    509513    def partition_metis(self): 
    510         print 'Partitioning with ParMetis...' 
     514        INFO('Partitioning with ParMetis...') 
    511515        edge_owner = unst.partition_mesh(self.trisk_deg, self.trisk, self.comm.Get_size()) 
    512516        self.edge_owner = parallel.LocPArray1D(self.dim_edge, edge_owner) 
     
    521525            return parallel.LocPArray1D(dim, owner_i + ni*owner_j) 
    522526        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)) 
    524528        n = self.comm.Get_size() 
    525529        assert n == ni*nj, 'Mismatch between ni x nj = %d and MPI_SIZE = %d.'%(ni*nj, n) 
     
    527531        self.primal_owner = owner(self.dim_primal, self.primal_i, self.primal_j) 
    528532        self.dual_owner = self.primal_owner 
    529         print 'partition_curvilinear %d :'%(self.comm.Get_rank()), self.primal_owner.data 
     533        DEBUG('partition_curvilinear %d : %s'%(self.comm.Get_rank(), self.primal_owner.data) ) 
    530534 
    531535    def get(self, getter, *names): return [ getter(self.__dict__[x]) for x in names ] 
     
    557561        comm, dim_primal, primal_owner, dim_edge, edge_owner, dim_dual, dual_owner = pmesh.members( 
    558562            'comm', 'dim_primal', 'primal_owner', 'dim_edge', 'edge_owner', 'dim_dual', 'dual_owner' ) 
    559         print 'Constructing halos ...' 
     563        INFO('Constructing halos ...') 
    560564        edges_E0 = find_my_cells(edge_owner) 
    561565        cells_C0, edges_E1, vertices_V1, edges_E2, cells_C1 = chain( 
     
    563567        edges_E0, edges_E1, edges_E2 = progressive_list(edges_E0, edges_E1, edges_E2) 
    564568        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)) ) 
    566570        get_own_cells, get_all_cells = dim_primal.getter(cells_C0), dim_primal.getter(cells_C1) 
    567571        get_all_duals, get_all_edges = dim_dual.getter(vertices_V1), dim_edge.getter(edges_E2) 
     
    583587        trisk         = pmesh.edge2edge(   edges_E2,    dict_E2) 
    584588        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()) ) 
    591595        primal_deg, primal_edge, primal_ne = primal_edge.degree,   primal_edge.neigh_loc, primal_edge.weight 
    592596        dual_deg,   dual_edge, dual_ne  = dual_edge.degree, dual_edge.neigh_loc, dual_edge.weight 
     
    608612        primal_own_all = comm.allgather(primal_own_num) 
    609613        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, displ 
     614#        print 'local primal mesh :', primal_vertex.min(), primal_vertex.max(), primal_own_all, displ 
    611615 
    612616        # construct own dual mesh for XIOS output 
  • codes/icosagcm/devel/Python/dynamico/parallel.py

    r691 r802  
    1111 
    1212from unstructured import ker 
     13 
     14import getargs 
     15log_master, log_world = getargs.getLogger(__name__) 
     16INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 
     17INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug 
    1318 
    1419#----------------------- Parallel access to distributed array ------------------------------# 
     
    142147        send_len = [len(lst) for lst in send] 
    143148        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_rank 
     149        DEBUG('send_rank %d %s'%(mpi_rank, send_rank)) 
    145150        # asssociate local index to global index 
    146151        own_dict = { glob:loc for glob,loc in zip(own_global, own_local) } 
  • codes/icosagcm/devel/Python/dynamico/time_step.py

    r778 r802  
    22from scipy import sparse as sparse 
    33import math as math 
     4 
     5import getargs 
     6log_master, log_world = getargs.getLogger(__name__) 
     7INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 
     8INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug 
    49 
    510class Struct: pass 
     
    8792    def __init__(self,precision,bwd_fast_slow, dt,nstage, bsjl,bfjl): 
    8893        if bwd_fast_slow is None: 
    89             print 'SIRK with Fortran-side time stepping' 
     94            DEBUG('SIRK with Fortran-side time stepping') 
    9095            precision=np.float64 
    9196        else: 
    92             print 'SIRK with Python-side time stepping at precision ', precision 
     97            DEBUG('SIRK with Python-side time stepping at precision %s' % precision) 
    9398 
    9499        self.bwd_fast_slow = bwd_fast_slow 
     
    98103        self.csjl, self.cfjl = [x.astype(precision) for x in csjl, cfjl] 
    99104        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.dtype 
     105        DEBUG('Types of csjl, cfjl, tauj : %s %s %s' % (self.csjl.dtype, self.cfjl.dtype, self.tauj.dtype) ) 
    101106    def next(self,zj): 
    102107        csjl, cfjl, tauj = self.csjl, self.cfjl, self.tauj 
  • codes/icosagcm/devel/Python/dynamico/wrap.py

    r790 r802  
    11#------------------- wrap C/Fortran routines -------------------#                                                                                            
    22import getargs 
     3log_master, log_world = getargs.getLogger(__name__) 
     4INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 
     5INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug 
     6 
     7 
    38import numpy as np  
    49from ctypes import * 
     
    5560                name = prefix+name 
    5661                soname = self.prefix_so+name 
    57                 if verbose : print 'wrap.Sharedlib : importing', soname 
     62                DEBUG('wrap.Sharedlib : importing %s' % soname) 
    5863                self.vardict[self.prefix_py+name] = Wrap(self.lib[soname], self.check_args, proto) 
    5964    def addvars(self,*types_and_names): 
     
    7277        for name,val in zip(names,vals): 
    7378            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  
    88import getargs 
    99args=getargs.parse() 
    10 verbose = 'xios' in args.debug 
     10log_master, log_world = getargs.getLogger(__name__) 
     11INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 
     12INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug 
    1113 
    1214#----------------------------------------------------------------------------- 
     
    1820        return self 
    1921    def __exit__(self, type, value, traceback): 
    20         print('xios_finalize()') 
     22        INFO('xios_finalize()') 
     23        DEBUG_ALL('xios_finalize') 
    2124        cxios.finalize() 
    2225    def min(self,data): return self.comm.allreduce(data, op=MPI.MIN) 
     
    2528class Context: 
    2629    def __enter__(self): 
    27         print('cxios.context_close_definition()') 
     30        INFO('cxios.context_close_definition()') 
    2831        cxios.context_close_definition() 
    2932        return self 
    3033    def __exit__(self, type, value, traceback): 
    31         print('xios_context_finalize()') 
     34        INFO('xios_context_finalize()') 
    3235        cxios.context_finalize() 
    3336    def init_llm(self, mesh, nqtot): 
     
    6871    mesh = cxios.Handle(cat,id) 
    6972    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()) ) 
    7174    i_index, j_index, lon, lat = [ x[own] for x in i_index, j_index, lon, lat ] 
    7275    log('i_index',i_index) 
  • codes/icosagcm/devel/Python/src/cxios.pyx

    r760 r802  
    66c_void_pp=POINTER(c_void_p) # used in prototype 
    77c_void_p_byref=type(byref(c_void_p())) # used in py2c because byref creates an object of this type, not c_void_pp 
     8 
     9import getargs 
     10log_master, log_world = getargs.getLogger(__name__) 
     11INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 
     12INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug 
    813 
    914# ------------- Direct cython interfaces ----------------- # 
     
    4449    _fields_ = [(name, c_int) for name in ('year', 'month', 'day', 'hour', 'minute', 'second') ] 
    4550 
    46 print Duration.from_param 
    47  
    4851for x in c_void_p_byref, Duration, Date : wrap.py2c[x]=wrap.noop # accept arguments of type (void*)&, Duration, ... 
    4952 
     
    7881            else: 
    7982                raise(TypeError) 
    80             print self.id+'.'+prefix+key, type(value), extra 
     83            DEBUG('%s.%s %s %s' % (self.id, prefix+key, type(value), extra) ) 
    8184    def update_timestep(self): 
    8285        lib.update_calendar_timestep(self.handle) 
  • codes/icosagcm/devel/Python/src/unstructured.pyx

    r792 r802  
    99cimport numpy as np 
    1010import numpy as np 
     11 
     12import getargs 
     13log_master, log_world = getargs.getLogger(__name__) 
     14INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 
     15INFO_ALL, DEBUG_ALL = log_world.info, log_world.debug 
    1116 
    1217#--------------   choose precision of kernel computations  ------------# 
     
    5863 
    5964try:     
    60     kernels = wrap.SharedLib(vars(ker), libicosa, check_args=check_args)  
    61     setvar, setvars, getvar, getvars = kernels.setvar, kernels.setvars, kernels.getvar, kernels.getvars 
     65   kernels = wrap.SharedLib(vars(ker), libicosa, check_args=check_args)  
     66   setvar, setvars, getvar, getvars = kernels.setvar, kernels.setvars, kernels.getvar, kernels.getvars 
    6267except 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 
    6770 
    6871# providing a full prototype enables type-checking when calling 
     
    9093 
    9194kernels.addvars( 
    92     c_bool,'hydrostatic','debug_hevi_solver', 
     95    c_bool,'hydrostatic','debug_hevi_solver', 'is_mpi_master', 
    9396    c_int,'llm','nqdyn','primal_num','max_primal_deg', 
    9497    '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', 
    9699    c_double,'elapsed', 
    97100    c_num, 'g', 'ptop', 'cpp', 'cppv', 
     
    119122    return data 
    120123 
    121 cdef check_ptr(name, num_ptr p, ndarray data): 
    122     if p != ptr(data) : print name, 'p <> ptr(data) !!' 
    123          
    124124cdef class Caldyn_step: 
    125125    # number of time steps to do at each invocation of advance() 
     
    300300              Ai, Av, fv, le_de, Riv2, wee): 
    301301 
    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),) ) 
    303304    for var,varname in zip((Ai,Av,fv,le_de,Riv2,wee), ('Ai','Av','fv','le_de','Riv2','wee')): 
    304305        assert var.dtype == np.float64, '%s must be double precision'%varname 
     
    308309             (llm, nqdyn, edge_num, primal_num, dual_num,  
    309310              max_trisk_deg, max_primal_deg, max_dual_deg) )         
    310     print('init_mesh ...') 
     311    INFO('init_mesh ...') 
    311312    ker.dynamico_init_mesh(primal_nb,primal_edge,primal_ne, 
    312313              dual_nb,dual_edge,dual_ne,dual_vertex, 
    313314              left,right,down,up,trisk_deg,trisk) 
    314     print ('...done') 
    315     print('init_metric ...') 
     315    INFO('...done') 
     316    INFO('init_metric ...') 
    316317    ker.dynamico_init_metric(Ai,Av,fv,le_de,Riv2,wee) 
    317     print ('...done') 
     318    INFO('...done') 
    318319 
    319320#------------------------ Mesh partitioning ------------------------ 
  • codes/icosagcm/devel/Python/test/py/Baroclinic_3D_ullrich.py

    r800 r802  
    2222getargs.defaults(dt=360., llm=50) 
    2323 
    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() 
    2525#    getargs.config_log(filename='out.log',filemode='w', 
    2626#                    format='%(processName)s:%(name)s:%(filename)s:%(module)s:%(funcName)s:%(lineno)d:%(levelname)s:%(message)s' ) 
    2727 
    28 logging = getargs.Logger('main') 
    2928args = getargs.parse() 
     29log_master, log_world = getargs.getLogger() 
     30INFO, DEBUG, DEBUG_ALL, ERROR = log_master.info, log_master.debug, log_world.debug, log_world.error 
    3031 
    3132from dynamico import unstructured as unst 
     
    5051def create_pmesh(nx,ny): 
    5152    filename = 'cart_%03d_%03d.nc'%(nx,ny) 
    52     logging.info('Reading Cartesian mesh ...') 
     53    INFO('Reading Cartesian mesh ...') 
    5354    meshfile = meshes.DYNAMICO_Format(filename) 
    5455    pmesh = meshes.Unstructured_PMesh(comm,meshfile) 
     
    105106    y_ek, alpha_ek = np.meshgrid(mesh.lat_e, alpha_k, indexing='ij') 
    106107 
    107     print(np.shape(alpha_k),np.shape(alpha_l)) 
     108#    print(np.shape(alpha_k),np.shape(alpha_l)) 
    108109    thermo = dyn.Ideal_perfect(Cpd, Rd, p0, T0) 
    109110 
     
    127128    u_ek = mesh.ucov3D(ulon(x_ek, y_ek, eta_ek), 0.*eta_ek) 
    128129 
    129     print('ztop (m) = ', Phi_il[0,-1]/g, ztop) 
     130    INFO('ztop (m) = %f %f' % (Phi_il[0,-1]/g, ztop) ) 
    130131    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))) )  
    133134 
    134135    params=dyn.Struct() 
     
    140141    # define parameters for lower BC 
    141142    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)) ) 
    143144    gas_bot = thermo.set_pT(pbot, tmean(pbot/p0)) 
    144145    params.pbot = gas_bot.p 
     
    167168class myDavies(Davies): 
    168169    def mask(self,x,y): 
    169         logging.debug('davies dy = %f'% dx) 
     170        DEBUG('davies dy = %f'% dx) 
    170171        return self.mask0(y,Ly,dx)*self.mask0(-y,0.,dx) 
    171172         
     
    174175    mpi_rank, mpi_size = comm.Get_rank(), comm.Get_size() 
    175176 
    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             
    178182    g, Lx, Ly = 9.80616, 4e7, 6e6 
    179183    nx, ny, llm = args.nx, args.ny, args.llm 
     
    181185     
    182186    unst.setvar('g',g) 
    183      
     187    unst.setvar('debug_hevi_solver', False) 
     188 
    184189    pmesh = create_pmesh(nx,ny) 
    185190    thermo, mesh, params, flow0, gas0 = baroclinic_3D(pmesh, dx,Lx,Ly,llm, args.ztop) 
     
    193198    nt = int(math.ceil(T/dt)) 
    194199    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)) 
    196201 
    197202     
     
    215220                          mesh.lon_i, mesh.lat_i, mesh.lon_e,mesh.lat_e) 
    216221#        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()) 
    220225 
    221226        def next_flow(m,S,u,Phi,W): 
     
    285290            context.send_field_dual('curl_abs', zeta_abs_vk) 
    286291 
    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')) ) 
    288293 
    289294            time1, elapsed1 =time.time(), unst.getvar('elapsed') 
     
    291296            time2, elapsed2 =time.time(), unst.getvar('elapsed') 
    292297            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)) ) 
    294299            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 
     303INFO('************DONE************') 
  • codes/icosagcm/devel/Python/test/py/RSW2_MPAS_W02.py

    r801 r802  
    1 print 'Starting' 
     1from dynamico import getargs 
     2log_master, log_world = getargs.getLogger() 
     3INFO, DEBUG, ERROR = log_master.info, log_master.debug, log_world.error 
     4 
     5INFO('Starting') 
    26 
    37from mpi4py import MPI 
    48comm = MPI.COMM_WORLD 
    59mpi_rank, mpi_size = comm.Get_rank(), comm.Get_size() 
    6 print '%d/%d starting'%(mpi_rank,mpi_size) 
     10INFO('%d/%d starting'%(mpi_rank,mpi_size)) 
    711prefix='fig_RSW2_MPAS_W02/%02d'%mpi_rank 
    812 
    9 print 'Loading DYNAMICO modules ...' 
     13INFO('Loading DYNAMICO modules ...') 
    1014from dynamico import unstructured as unst 
    1115from dynamico.meshes import MPAS_Format, Unstructured_PMesh as PMesh, Local_Mesh as Mesh 
  • codes/icosagcm/devel/src/unstructured/data_unstructured.F90

    r796 r802  
    1212  INDEX,  BIND(C) :: caldyn_thermo=thermo_theta, caldyn_eta=eta_lag, & 
    1313       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. 
    1515  LOGICAL(C_BOOL), BIND(C, NAME='debug_hevi_solver') :: debug_hevi_solver_=.TRUE. 
    1616 
     
    4242  NUM2(:,:), ALLOCATABLE          :: centroid, xyz_v, Riv2, wee, ap,bp, mass_bl, mass_dak, mass_dbk 
    4343 
    44   INTEGER(C_INT), BIND(C) :: comm_icosa, dynamico_mpi_rank=0 
     44  INTEGER(C_INT), BIND(C) :: comm_icosa 
    4545 
    4646  INTEGER, PARAMETER :: id_dev1=1, id_dev2=2, & 
     
    8282    TIME :: total_spent 
    8383    total_spent=SUM(time_spent) 
    84     IF(dynamico_mpi_rank==0) THEN 
     84    IF(is_mpi_master) THEN 
    8585       PRINT *, '========================= Performance metrics =========================' 
    8686       PRINT *, 'Total time spent in instrumented code (seconds) :', total_spent 
     
    139139    INDEX, DIMENSION(edge_num) :: left_, right_, down_, up_ 
    140140 
    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 
    146148    ALLOC1(primal_deg, primal_num) 
    147149    ALLOC2(primal_edge, max_primal_deg,primal_num) 
     
    153155    ALLOC1(trisk_deg, edge_num) 
    154156    ALLOC2(trisk, max_trisk_deg, edge_num) 
    155     PRINT *, SHAPE(trisk), edge_num 
    156157    ALLOC1(left, edge_num) 
    157158    ALLOC1(right, edge_num) 
     
    177178    trisk_deg(:)=trisk_deg_(:) 
    178179    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 
    187190  END SUBROUTINE init_mesh 
    188191 
     
    194197    DBL :: Ai_(primal_num), Av_(dual_num), fv_(dual_num), le_de_(edge_num), & 
    195198         Riv2_(max_dual_deg,dual_num), wee_(max_trisk_deg,edge_num) 
    196     PRINT *, 'init_metric ...' 
     199    IF(is_mpi_master) PRINT *, 'init_metric ...' 
    197200    ALLOC1(Ai,primal_num) 
    198201    ALLOC1(Av,dual_num) 
     
    207210    Riv2(:,:)=Riv2_(:,:) 
    208211    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 
    220225  END SUBROUTINE init_metric 
    221226  ! 
     
    225230  ! 
    226231  SUBROUTINE init_params() BINDC(init_params) 
    227     PRINT *, 'Setting physical parameters ...' 
    228     IF(hydrostatic) THEN 
    229        PRINT *, 'Hydrostatic dynamics (HPE)' 
    230     ELSE 
    231        PRINT *, 'Non-hydrostatic dynamics (Euler)' 
    232     END IF 
    233232    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 
    241248    CALL init_trace 
    242249  END SUBROUTINE init_params 
     
    245252    DBL :: bl(llm+1, primal_num), & 
    246253         dak(llm, primal_num), dbk(llm, primal_num) 
    247     PRINT *, 'Setting hybrid coefficients ...' 
     254    IF(is_mpi_master) PRINT *, 'Setting hybrid coefficients ...' 
    248255    ALLOC2(mass_bl, llm+1, primal_num) 
    249256    ALLOC2(mass_dak, llm, primal_num) 
     
    252259    mass_dak(:,:) = dak(:,:) 
    253260    mass_dbk(:,:) = dbk(:,:) 
    254     PRINT *, '... Done, llm = ', llm 
     261    IF(is_mpi_master) PRINT *, '... Done, llm = ', llm 
    255262  END SUBROUTINE Init_hybrid 
    256263 
  • codes/icosagcm/devel/src/unstructured/timestep_unstructured.F90

    r792 r802  
    305305    ! This is the case when calling from Python after importing mpi4py 
    306306    INTEGER :: ierr, mpi_threading_mode 
    307      
    308307    PRINT *, 'Initialize XIOS and obtain our communicator' 
    309308    CALL xios_initialize("icosagcm",return_comm=comm_icosa) 
    310      
    311     PRINT *, 'Initialize our XIOS context' 
    312      
    313309    CALL xios_context_initialize("icosagcm",comm_icosa) 
    314310    CALL xios_get_handle("icosagcm",ctx_hdl) 
  • codes/icosagcm/devel/src/unstructured/transfer_unstructured.F90

    r700 r802  
    3737    INTEGER(C_INT) :: send_rank(send_num), send_len(send_num), send_list(send_size), & 
    3838         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, & 
    4040       send_num, send_size, '/', send_rank, '/', send_len, '/', & 
    4141       recv_num, recv_size, '/', recv_rank, '/', recv_len, '/'  
Note: See TracChangeset for help on using the changeset viewer.