[759] | 1 | from dynamico import cxios |
---|
| 2 | from dynamico import xios |
---|
| 3 | from dynamico import unstructured as unst |
---|
| 4 | from dynamico import meshes |
---|
| 5 | ker=unst.ker |
---|
| 6 | |
---|
| 7 | from mpi4py import MPI |
---|
| 8 | comm = MPI.COMM_WORLD |
---|
| 9 | mpi_rank, mpi_size = comm.Get_rank(), comm.Get_size() |
---|
| 10 | print '%d/%d starting'%(mpi_rank,mpi_size) |
---|
| 11 | |
---|
| 12 | import numpy as np |
---|
| 13 | |
---|
| 14 | nqdyn,nqtot,llm = 1,1,4 |
---|
| 15 | |
---|
| 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 |
---|
| 29 | |
---|
| 30 | pmesh = meshes.Unstructured_PMesh(comm,meshfile) |
---|
| 31 | mesh = meshes.Local_Mesh(pmesh, llm, nqdyn, radius, coriolis) |
---|
| 32 | |
---|
| 33 | #--------------------------------- write some data ---------------------------------------- |
---|
| 34 | |
---|
| 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') |
---|
| 39 | |
---|
| 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 |
---|