Ignore:
Timestamp:
12/03/18 17:58:11 (6 years ago)
Author:
dubos
Message:

devel/Python : centralize logging and command-line argument parsing + update some test cases accordingly

Location:
codes/icosagcm/devel/Python/dynamico
Files:
1 added
2 edited

Legend:

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

    r747 r790  
    11#------------------- wrap C/Fortran routines -------------------#                                                                                            
    2  
     2import getargs 
    33import numpy as np  
    44from ctypes import * 
     
    5555                name = prefix+name 
    5656                soname = self.prefix_so+name 
    57                 print 'wrap.Sharedlib : importing', soname 
     57                if verbose : print 'wrap.Sharedlib : importing', soname 
    5858                self.vardict[self.prefix_py+name] = Wrap(self.lib[soname], self.check_args, proto) 
    5959    def addvars(self,*types_and_names): 
     
    7272        for name,val in zip(names,vals): 
    7373            self.vars[name].value=val 
     74 
     75args = getargs.parse() 
     76verbose = 'wrap' in args.debug 
  • codes/icosagcm/devel/Python/dynamico/xios.py

    r787 r790  
     1from __future__ import print_function 
    12import numpy as np 
    23import cxios 
     
    45from dynamico.meshes import radian 
    56from mpi4py import MPI 
     7 
     8import getargs 
     9args=getargs.parse() 
     10verbose = 'xios' in args.debug 
    611 
    712#----------------------------------------------------------------------------- 
     
    1318        return self 
    1419    def __exit__(self, type, value, traceback): 
    15         print 'xios_finalize()' 
     20        print('xios_finalize()') 
    1621        cxios.finalize() 
    1722    def min(self,data): return self.comm.allreduce(data, op=MPI.MIN) 
     
    2025class Context: 
    2126    def __enter__(self): 
    22         print 'cxios.context_close_definition()' 
     27        print('cxios.context_close_definition()') 
    2328        cxios.context_close_definition() 
    2429        return self 
    2530    def __exit__(self, type, value, traceback): 
    26         print 'xios_context_finalize()' 
     31        print('xios_context_finalize()') 
    2732        cxios.context_finalize() 
    2833    def init_llm(self, mesh, nqtot): 
     
    6267def setup_curvilinear(cat,id,nx,ny,own,i_index,j_index,lon,lat): 
    6368    mesh = cxios.Handle(cat,id) 
    64     def log(name,data) : print 'setup_curvilinear : %s shape min max'%name, data.shape, data.min(), data.max() 
     69    def log(name,data) :  
     70        if verbose : print('setup_curvilinear : %s shape min max'%name, data.shape, data.min(), data.max() ) 
    6571    i_index, j_index, lon, lat = [ x[own] for x in i_index, j_index, lon, lat ] 
    6672    log('i_index',i_index) 
Note: See TracChangeset for help on using the changeset viewer.