from dynamico import unstructured as unst from dynamico import xios from dynamico.meshes import radian, MPAS_Format, Unstructured_PMesh as PMesh, Local_Mesh as Mesh import numpy as np with xios.Client() as client: comm = client.comm mpi_rank, mpi_size = comm.Get_rank(), comm.Get_size() print '%d/%d starting'%(mpi_rank,mpi_size) #----------------------------- read MPAS mesh -------------------------------- grid, llm, nqdyn, nqtot = 2562, 4,1,1 # 2562, 10242, 40962 Omega, radius, g, gh0 = 2.*np.pi/86400., 6.4e6, 1., 2.94e4 N, T, courant = 40, 10800., 1.2 # simulation length = N*T print 'Omega, planetary PV', Omega, 2*Omega/gh0 def f(lon,lat): return 2*Omega*np.sin(lat) # Coriolis parameter print 'Reading MPAS mesh ...' meshfile = MPAS_Format('grids/x1.%d.grid.nc'%grid) pmesh = PMesh(comm,meshfile) pmesh.partition_metis() mesh = Mesh(pmesh, llm, nqdyn, radius, f) print '...Done' #--------------------------------- write some data ---------------------------------------- with xios.Context_Unstructured(pmesh,mesh,nqtot, 3600) as context: lat_i = radian*mesh.lat_i lat_ik, junk = np.meshgrid(lat_i, np.arange(llm), indexing='ij') for i in range(100): context.update_calendar(i) print 'send_field', i, lat_ik.shape context.send_field_primal('ps', lat_i) context.send_field_primal('theta', lat_ik)