Last change
on this file since 615 was
615,
checked in by dubos, 6 years ago
|
devel/unstructured : import Python layer from HEAT
|
File size:
832 bytes
|
Line | |
---|
1 | #------------- import and wrap Kessler routines and variables -------------# |
---|
2 | |
---|
3 | from ctypes import * |
---|
4 | lib = cdll.LoadLibrary("Kessler/libkessler.so") |
---|
5 | |
---|
6 | libvars={} |
---|
7 | def addvars(ctype,names): |
---|
8 | for name in names: |
---|
9 | libvars[name]=ctype.in_dll(lib, name) |
---|
10 | def getvar(name): |
---|
11 | return libvars[name].value |
---|
12 | def setvar(name,val): |
---|
13 | libvars[name].value=val |
---|
14 | def setvars(names,vals): |
---|
15 | for name,val in zip(names,vals): |
---|
16 | libvars[name].value=val |
---|
17 | |
---|
18 | addvars(c_int,('nx','nz','nz1')) |
---|
19 | addvars(c_double,('g', 'p0', 'dt', 'cp', 'r', 'dt', 'time', 'tsfc', 'qc')) |
---|
20 | |
---|
21 | ptr_arg = POINTER(c_int) |
---|
22 | def loc(array): return array.ctypes.data_as(ptr_arg) |
---|
23 | def locs(arrays): return [loc(v) for v in arrays] |
---|
24 | def wrap(routine): return lambda *args : routine(*locs(args)) |
---|
25 | |
---|
26 | create_moist_sounding = wrap(lib.create_moist_sounding) |
---|
27 | kessler = wrap(lib.kessler) |
---|
Note: See
TracBrowser
for help on using the repository browser.