source: codes/icosagcm/devel/Python/test/py/test_xios_cartesian.py @ 759

Last change on this file since 759 was 759, checked in by dubos, 6 years ago

devel/unstructured : towards XIOS output with curvilinear mesh

File size: 1.6 KB
Line 
1from dynamico import cxios
2from dynamico import xios
3from dynamico import unstructured as unst
4from dynamico import meshes
5ker=unst.ker
6
7from mpi4py import MPI
8comm = MPI.COMM_WORLD
9mpi_rank, mpi_size = comm.Get_rank(), comm.Get_size()
10print '%d/%d starting'%(mpi_rank,mpi_size)
11
12import numpy as np
13
14nqdyn,nqtot,llm = 1,1,4
15
16if 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)
20else:
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
35context=xios.XIOS_Context_Curvilinear(mesh,nqtot, 3600)
36#lon_i,lat_i = mesh.xx[:,:,0].flatten(), mesh.yy[:,:,0].flatten()
37lon_i,lat_i = mesh.lon_i, mesh.lat_i
38lat_ik, junk  = np.meshgrid(lat_i, np.arange(llm), indexing='ij')
39
40no_error=True
41try:
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)
47except:
48    print 'An error has occured, trying to close XIOS properly'
49    no_error=False
50
51print 'xios.context_finalize()'
52context.finalize()
53print 'xios.finalize()'
54xios.finalize()
55print 'Done'
56
57if not no_error : raise
Note: See TracBrowser for help on using the repository browser.