Changeset 795
- Timestamp:
- 01/09/19 16:26:50 (5 years ago)
- Location:
- codes/icosagcm/devel/Python
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
codes/icosagcm/devel/Python/dynamico/getargs.py
r790 r795 10 10 add("--mpi_ni", type=int, default=1, help="number of x processors") 11 11 add("--mpi_nj", type=int, default=1, help="number of y processors") 12 add("--log",type=str,default='DEBUG',choices=('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'),13 help="Set verbosity level of logging")14 12 add("--hydrostatic", action='store_true') 15 13 add("--llm", type=int) … … 20 18 def noop(*args, **kwargs): pass 21 19 20 def ignore_first(fun): 21 def f(self, *args, **kwargs) : fun(*args, **kwargs) 22 return f 23 22 24 class Logger: 23 debug, info, error = logging.debug, logging.info, logging.error 25 debug, info, error = [ ignore_first(fun) for fun in 26 logging.info, logging.warning, logging.error ] 24 27 def __init__(self, modulename): 25 28 arglist = parser.parse_args() … … 28 31 else: 29 32 print('Debug ON for module %s'%modulename) 33 config_log() 30 34 31 def config_log(**kwargs): 32 arglist = parser.parse_args() 33 loglevel = getattr(logging, arglist.log.upper()) 34 logging.basicConfig(level=loglevel, **kwargs) 35 def config_log(*args, **kwargs): 36 logging.basicConfig(level='INFO', *args, **kwargs) -
codes/icosagcm/devel/Python/test/py/Baroclinic_3D_ullrich.py
r794 r795 1 1 from __future__ import print_function 2 from __future__ import division 3 2 4 from dynamico import getargs 3 5 … … 13 15 getargs.add("--ny", type=int, default=30) 14 16 getargs.add("--betaplane", action='store_true') 17 18 getargs.add("--kappa_divgrad", type=float, default=3.0e15) 19 getargs.add("--kappa_curlcurl", type=float, default=3.0e15) 20 15 21 getargs.defaults(dt=360., llm=50) 22 23 getargs.config_log(filename='out.log',filemode='w') # must be done before calling Logger() 24 # getargs.config_log(filename='out.log',filemode='w', 25 # format='%(processName)s:%(name)s:%(filename)s:%(module)s:%(funcName)s:%(lineno)d:%(levelname)s:%(message)s' ) 16 26 17 27 logging = getargs.Logger('main') … … 136 146 return thermo, mesh, params, prec.asnum([mass_ik,Sik,u_ek,Phi_il,Wil]), gas 137 147 138 def diagnose(Phi,S,m,W ):148 def diagnose(Phi,S,m,W,u): 139 149 s=S/m 150 curl_vk = curl(mesh, u) 151 abs_vort_vk = mesh.field_z() # absolute vorticity 152 un = mesh.field_u() 153 v = mesh.field_mass() # specific volume 154 w = mesh.field_mass() 155 z = mesh.field_mass() 140 156 for l in range(llm): 141 157 v[:,l]=(Phi[:,l+1]-Phi[:,l])/(g*m[:,l]) 142 158 w[:,l]=.5*params.g*(W[:,l+1]+W[:,l])/m[:,l] 143 159 z[:,l]=.5*(Phi[:,l+1]+Phi[:,l])/params.g 160 un[:,l]=u[:,l]/mesh.de 161 abs_vort_vk[:,l]=curl_vk[:,l] + mesh.fv 144 162 gas = thermo.set_vs(v,s) 145 return gas, w, z 163 ps = gas.p[:,0]+ .5*g*m[:,0] 164 return gas, w, z, ps, un, curl_vk, abs_vort_vk 146 165 147 166 class myDavies(Davies): … … 153 172 comm = client.comm 154 173 mpi_rank, mpi_size = comm.Get_rank(), comm.Get_size() 155 # getargs.config_log(filename='out.log',filemode='w',156 # format='%(processName)s:%(name)s:%(filename)s:%(module)s:%(funcName)s:%(lineno)d:%(levelname)s:%(message)s' )157 174 158 175 logging.info('%d/%d starting'%(mpi_rank,mpi_size)) 159 176 160 g, Lx, Ly = 9.8 1, 4e7, 6e6177 g, Lx, Ly = 9.80616, 4e7, 6e6 161 178 nx, ny, llm = args.nx, args.ny, args.llm 162 179 dx = Lx/nx … … 170 187 # print('WARNING: Davies_N1 not equal to Davies_N2; average value will be used') 171 188 172 173 189 unst.setvar('g',g) 174 190 … … 198 214 scheme = time_step.ARK2(None, dt) 199 215 if args.hydrostatic: 200 caldyn_step = unst.caldyn_step_HPE(mesh,scheme,1, caldyn_thermo,caldyn_eta,thermo,params,params.g) 216 caldyn_step = unst.caldyn_step_HPE(mesh,scheme,1, caldyn_thermo,caldyn_eta, 217 thermo,params,params.g) 201 218 else: 202 caldyn_step = unst.caldyn_step_NH(mesh,scheme,1, caldyn_thermo,caldyn_eta,thermo,params,params.g) 203 davies = myDavies(args.Davies_N1, args.Davies_N2, mesh.lon_i, mesh.lat_i, mesh.lon_e,mesh.lat_e) 219 caldyn_step = unst.caldyn_step_NH(mesh,scheme,1, caldyn_thermo,caldyn_eta, 220 thermo,params,params.g) 221 davies = myDavies(args.Davies_N1, args.Davies_N2, 222 mesh.lon_i, mesh.lat_i, mesh.lon_e,mesh.lat_e) 204 223 # print('mask min/max :', davies.beta_i.min(), davies.beta_i.max() ) 205 224 logging.debug('mask min/max :') 206 225 logging.debug('%f'% davies.beta_i.min()) 207 226 logging.debug('%f'% davies.beta_i.max()) 227 208 228 def next_flow(m,S,u,Phi,W): 209 229 # junk,fast,slow = caldyn.bwd_fast_slow(flow, 0.) 210 230 caldyn_step.mass[:,:], caldyn_step.theta_rhodz[:,:], caldyn_step.u[:,:] = m,S,u 211 231 caldyn_step.geopot[:,:], caldyn_step.W[:,:] = Phi,W 212 #Relaxation zone inside the domain213 kappa = 3.26e+15 #nonhyd=>#Y3.3#Y3.27#Y3.26#Y3.255#dblchkd;N3.25#N3.2#N3.0#Y3.4#dx**4/432000.214 #Relaxation zone outside the domain215 #kappa = 3.6e+15 #nonhyd=>#Y3.3#Y3.27#Y3.26#Y3.255#dblchkd;N3.25#N3.2#N3.0#Y3.4#dx**4/432000.216 #print('Kappa=',kappa)217 232 for i in range(nt): 218 233 caldyn_step.next() … … 226 241 unst.ker.dynamico_curl_laplacian(u,lapu) 227 242 unst.ker.dynamico_curl_laplacian(lapu,bilapu) 228 caldyn_step.theta_rhodz[:] = S - dt* kappa*bilaps*m # Euler step229 caldyn_step.u[:] = u - dt* kappa*bilapu # Euler step243 caldyn_step.theta_rhodz[:] = S - dt*args.kappa_divgrad*bilaps*m # Euler step 244 caldyn_step.u[:] = u - dt*args.kappa_curlcurl*bilapu # Euler step 230 245 231 246 return (caldyn_step.mass.copy(), caldyn_step.theta_rhodz.copy(), caldyn_step.u.copy(), … … 241 256 title_format = 'Specific entropy at t=%g s (J/K/kg)' 242 257 243 w=mesh.field_mass()244 z=mesh.field_mass()245 246 258 #T, nslice, dt = 3600., 1, 3600. 247 259 Nslice = args.N 248 260 261 temp_v = mesh.field_z(), 262 249 263 with xios.Context_Curvilinear(mesh,1, 24*3600) as context: 250 264 # now XIOS knows about the mesh and we can write to disk 251 v = mesh.field_mass() # specific volume (diagnosed)252 253 265 for i in range(Nslice+1): 254 266 context.update_calendar(i+1) 255 267 256 268 # Diagnose quantities of interest from prognostic variables m,S,u,Phi,W 257 gas, w, z = diagnose(Phi,S,m,W) 258 ps = caldyn_step.ps 259 curl_vk = curl(mesh, u) 269 gas, w, z, ps, un, zeta_vk, zeta_abs_vk = diagnose(Phi,S,m,W,u) 260 270 KE_ik = KE(mesh,u) 261 271 du_fast, du_slow = caldyn_step.du_fast[0,:,:], caldyn_step.du_slow[0,:,:] … … 277 287 278 288 context.send_field_primal('div_slow', div_slow) 279 # context.send_field_primal('div_slow', div(mesh,hflux) ) 280 281 context.send_field_dual('curl ', curl_vk)289 290 context.send_field_dual('curl', zeta_vk) 291 context.send_field_dual('curl_abs', zeta_abs_vk) 282 292 283 293 print( 'ptop, model top (m) :', unst.getvar('ptop'), Phi.max()/unst.getvar('g')) -
codes/icosagcm/devel/Python/test/python.sh
r790 r795 21 21 shift 22 22 rm -f xios_client*.* 23 mpirun -np $NB_MPI python -u $* | tee dynamico.log23 mpirun -np $NB_MPI python -u $* 2>&1 | tee dynamico.log 24 24 } 25 25 -
codes/icosagcm/devel/Python/test/xml/field_def_simple.xml
r787 r795 13 13 <field_group axis_ref="lev"> 14 14 <field id="curl" /> 15 <field id="curl_abs" /> 15 16 </field_group> 16 17 </field_group> -
codes/icosagcm/devel/Python/test/xml/filedef_simple.xml
r787 r795 21 21 <field field_ref="theta" /> 22 22 <field field_ref="curl" /> 23 <field field_ref="curl_abs" /> 23 24 <field field_ref="div_fast" /> 24 25 <field field_ref="div_slow" />
Note: See TracChangeset
for help on using the changeset viewer.