Changeset 760 for codes/icosagcm/devel/Python/test
- Timestamp:
- 10/15/18 01:04:44 (6 years ago)
- Location:
- codes/icosagcm/devel/Python/test
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
codes/icosagcm/devel/Python/test/py/DCMIP2008c5_MPI.py
r701 r760 58 58 # mesh = meshes.Unstructured_Mesh(meshfile, llm, nqdyn, radius, f) 59 59 pmesh = meshes.Unstructured_PMesh(comm,meshfile) 60 pmesh.partition_metis() 60 61 mesh = meshes.Local_Mesh(pmesh, llm, nqdyn, radius, f) 61 62 mesh.pmesh=pmesh -
codes/icosagcm/devel/Python/test/py/RSW2_MPAS_W02.py
r749 r760 29 29 meshfile = MPAS_Format('grids/x1.%d.grid.nc'%grid) 30 30 pmesh = PMesh(comm,meshfile) 31 pmesh.partition_metis() 31 32 mesh = Mesh(pmesh, llm, nqdyn, radius, f) 32 33 print '...Done' -
codes/icosagcm/devel/Python/test/py/partition.py
r692 r760 80 80 meshfile = meshes.MPAS_Format('grids/%s.grid.nc'%grid) 81 81 pmesh = meshes.Unstructured_PMesh(comm, meshfile) 82 pmesh.partition_metis() 82 83 83 84 def coriolis(lon,lat): return 0.*lat -
codes/icosagcm/devel/Python/test/py/test_xios.py
r759 r760 1 import dynamico.unstructured as unst2 import dynamico.xios asxios1 from dynamico import unstructured as unst 2 from dynamico import xios 3 3 from dynamico.meshes import radian, MPAS_Format, Unstructured_PMesh as PMesh, Local_Mesh as Mesh 4 import numpy as np 4 5 5 from mpi4py import MPI 6 comm = MPI.COMM_WORLD 7 mpi_rank, mpi_size = comm.Get_rank(), comm.Get_size() 8 print '%d/%d starting'%(mpi_rank,mpi_size) 9 10 import numpy as np 11 import cProfile 12 import re 6 with xios.Client() as client: 7 comm = client.comm 8 mpi_rank, mpi_size = comm.Get_rank(), comm.Get_size() 9 print '%d/%d starting'%(mpi_rank,mpi_size) 13 10 14 11 #----------------------------- read MPAS mesh -------------------------------- 15 12 16 grid, llm, nqdyn, nqtot = 2562, 4,1,1 # 2562, 10242, 4096217 Omega, radius, g, gh0 = 2.*np.pi/86400., 6.4e6, 1., 2.94e418 N, T, courant = 40, 10800., 1.2 # simulation length = N*T19 print 'Omega, planetary PV', Omega, 2*Omega/gh013 grid, llm, nqdyn, nqtot = 2562, 4,1,1 # 2562, 10242, 40962 14 Omega, radius, g, gh0 = 2.*np.pi/86400., 6.4e6, 1., 2.94e4 15 N, T, courant = 40, 10800., 1.2 # simulation length = N*T 16 print 'Omega, planetary PV', Omega, 2*Omega/gh0 20 17 21 def f(lon,lat): return 2*Omega*np.sin(lat) # Coriolis parameter 22 print 'Reading MPAS mesh ...' 23 meshfile = MPAS_Format('grids/x1.%d.grid.nc'%grid) 24 pmesh = PMesh(comm,meshfile) 25 mesh = Mesh(pmesh, llm, nqdyn, radius, f) 26 print '...Done' 18 def f(lon,lat): return 2*Omega*np.sin(lat) # Coriolis parameter 19 print 'Reading MPAS mesh ...' 20 meshfile = MPAS_Format('grids/x1.%d.grid.nc'%grid) 21 pmesh = PMesh(comm,meshfile) 22 pmesh.partition_metis() 23 mesh = Mesh(pmesh, llm, nqdyn, radius, f) 24 print '...Done' 27 25 28 26 #--------------------------------- write some data ---------------------------------------- 29 27 30 context=xios.XIOS_Context_Unstructured(pmesh,mesh,nqtot, 3600) 28 with xios.Context_Unstructured(pmesh,mesh,nqtot, 3600) as context: 29 lat_i = radian*mesh.lat_i 30 lat_ik, junk = np.meshgrid(lat_i, np.arange(llm), indexing='ij') 31 31 32 lat_i = radian*mesh.lat_i 33 lat_ik, junk = np.meshgrid(lat_i, np.arange(llm), indexing='ij') 34 35 no_error=True 36 try: 37 for i in range(100): 38 context.update_calendar(i) 39 print 'send_field', i, lat_ik.shape 40 context.send_field_primal('ps', lat_i) 41 context.send_field_primal('theta', lat_ik) 42 except: 43 print 'An error has occured, trying to close XIOS properly' 44 no_error=False 45 46 print 'xios.context_finalize()' 47 context.finalize() 48 print 'xios.finalize()' 49 xios.finalize() 50 print 'Done' 51 52 if not no_error : raise 32 for i in range(100): 33 context.update_calendar(i) 34 print 'send_field', i, lat_ik.shape 35 context.send_field_primal('ps', lat_i) 36 context.send_field_primal('theta', lat_ik) -
codes/icosagcm/devel/Python/test/py/test_xios_cartesian.py
r759 r760 3 3 from dynamico import unstructured as unst 4 4 from dynamico import meshes 5 ker=unst.ker6 7 from mpi4py import MPI8 comm = MPI.COMM_WORLD9 mpi_rank, mpi_size = comm.Get_rank(), comm.Get_size()10 print '%d/%d starting'%(mpi_rank,mpi_size)11 12 5 import numpy as np 13 6 14 nqdyn,nqtot,llm = 1,1,4 7 # client.__exit__() and context.__exit__() are called at the end of the 'with' blocks 8 # even if an exception is raised in the body of the block 15 9 16 if False: 17 nx,ny,llm = 64,64 18 Lx,Ly,f = 1.,1.,1. 19 mesh = meshes.Cartesian_Mesh(nx,ny,llm,nqdyn,Lx,Ly,f) 20 else: 21 filename, g, f, radius = 'cart_128_128.nc', 1., 1., None 22 filename = 'cart_004_004.nc' 23 unst.setvar('g',g) 24 print 'Reading Cartesian mesh ...' 25 def coriolis(lon,lat): 26 return f+0.*lon 27 meshfile = meshes.DYNAMICO_Format(filename) 28 nx,ny=meshfile.nx,meshfile.ny 10 with xios.Client() as client: 11 comm = client.comm 12 mpi_rank, mpi_size = comm.Get_rank(), comm.Get_size() 13 print '%d/%d starting'%(mpi_rank,mpi_size) 29 14 30 pmesh = meshes.Unstructured_PMesh(comm,meshfile) 31 mesh = meshes.Local_Mesh(pmesh, llm, nqdyn, radius, coriolis) 15 nqdyn,nqtot,llm = 1,1,4 16 17 if False: 18 nx,ny,llm = 64,64 19 Lx,Ly,f = 1.,1.,1. 20 mesh = meshes.Cartesian_Mesh(nx,ny,llm,nqdyn,Lx,Ly,f) 21 else: 22 filename, g, f, radius = 'cart_128_128.nc', 1., 1., None 23 # filename = 'cart_008_008.nc' 24 unst.setvar('g',g) 25 print 'Reading Cartesian mesh ...' 26 def coriolis(lon,lat): 27 return f+0.*lon 28 meshfile = meshes.DYNAMICO_Format(filename) 29 nx,ny=meshfile.nx,meshfile.ny 30 31 pmesh = meshes.Unstructured_PMesh(comm,meshfile) 32 # pmesh.partition_metis() 33 pmesh.partition_curvilinear(2,2) 34 mesh = meshes.Local_Mesh(pmesh, llm, nqdyn, radius, coriolis) 32 35 33 36 #--------------------------------- write some data ---------------------------------------- 34 37 35 context=xios.XIOS_Context_Curvilinear(mesh,nqtot, 3600) 36 #lon_i,lat_i = mesh.xx[:,:,0].flatten(), mesh.yy[:,:,0].flatten() 37 lon_i,lat_i = mesh.lon_i, mesh.lat_i 38 lat_ik, junk = np.meshgrid(lat_i, np.arange(llm), indexing='ij')38 with xios.Context_Curvilinear(mesh,nqtot, 3600) as context: 39 lon_i,lat_i = mesh.lon_i, mesh.lat_i 40 lat_ik, junk = np.meshgrid(lat_i, np.arange(llm), indexing='ij') 41 lon_ik, junk = np.meshgrid(lon_i, np.arange(llm), indexing='ij') 39 42 40 no_error=True 41 try: 42 for i in range(3): 43 context.update_calendar(i) 44 print 'send_field', i, lat_ik.shape 45 context.send_field_primal('ps', lat_i) 46 context.send_field_primal('theta', lat_ik) 47 except: 48 print 'An error has occured, trying to close XIOS properly' 49 no_error=False 50 51 print 'xios.context_finalize()' 52 context.finalize() 53 print 'xios.finalize()' 54 xios.finalize() 55 print 'Done' 56 57 if not no_error : raise 43 for i in range(48): 44 context.update_calendar(i) 45 # print 'send_field', i, lat_ik.shape 46 context.send_field_primal('ps', lat_i+lon_i) 47 context.send_field_primal('theta', lat_ik+lon_ik) -
codes/icosagcm/devel/Python/test/xml/iodef.xml
r755 r760 3 3 <context id="xios"> 4 4 <variable_definition> 5 <variable id="print_file" type="bool"> false </variable>5 <variable id="print_file" type="bool"> true </variable> 6 6 <variable_group id="buffer"> 7 7 </variable_group>
Note: See TracChangeset
for help on using the changeset viewer.