-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f8fce1
commit 3335eba
Showing
23 changed files
with
866 additions
and
446 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import os | ||
os.environ['OMP_NUM_THREADS'] = '1' | ||
|
||
from ._clima import WaterAdiabatClimate | ||
|
||
from ._clima import WaterAdiabatClimate, ClimaException | ||
from ._clima import rebin # rebin routine from futils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
cimport ClimaRadtranWrk_pxd as rwrk_pxd | ||
|
||
cdef class ClimaRadtranWrk: | ||
cdef void *_ptr | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def __dealloc__(self): | ||
pass | ||
|
||
property fup_a: | ||
def __get__(self): | ||
cdef int dim1, dim2 | ||
rwrk_pxd.climaradtranwrk_fup_a_get_size(&self._ptr, &dim1, &dim2) | ||
cdef ndarray arr = np.empty((dim1, dim2), np.double, order="F") | ||
rwrk_pxd.climaradtranwrk_fup_a_get(&self._ptr, &dim1, &dim2, <double *>arr.data) | ||
return arr | ||
|
||
property fdn_a: | ||
def __get__(self): | ||
cdef int dim1, dim2 | ||
rwrk_pxd.climaradtranwrk_fdn_a_get_size(&self._ptr, &dim1, &dim2) | ||
cdef ndarray arr = np.empty((dim1, dim2), np.double, order="F") | ||
rwrk_pxd.climaradtranwrk_fdn_a_get(&self._ptr, &dim1, &dim2, <double *>arr.data) | ||
return arr | ||
|
||
property fup_n: | ||
def __get__(self): | ||
cdef int dim1 | ||
rwrk_pxd.climaradtranwrk_fup_n_get_size(&self._ptr, &dim1) | ||
cdef ndarray arr = np.empty(dim1, np.double) | ||
rwrk_pxd.climaradtranwrk_fup_n_get(&self._ptr, &dim1, <double *>arr.data) | ||
return arr | ||
|
||
property fdn_n: | ||
def __get__(self): | ||
cdef int dim1 | ||
rwrk_pxd.climaradtranwrk_fdn_n_get_size(&self._ptr, &dim1) | ||
cdef ndarray arr = np.empty(dim1, np.double) | ||
rwrk_pxd.climaradtranwrk_fdn_n_get(&self._ptr, &dim1, <double *>arr.data) | ||
return arr | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
# getters and setters | ||
|
||
cdef extern void climaradtranwrk_fup_a_get_size(void *ptr, int *dim1, int *dim2) | ||
cdef extern void climaradtranwrk_fup_a_get(void *ptr, int *dim1, int *dim2, double *arr) | ||
|
||
cdef extern void climaradtranwrk_fdn_a_get_size(void *ptr, int *dim1, int *dim2) | ||
cdef extern void climaradtranwrk_fdn_a_get(void *ptr, int *dim1, int *dim2, double *arr) | ||
|
||
cdef extern void climaradtranwrk_fup_n_get_size(void *ptr, int *dim1) | ||
cdef extern void climaradtranwrk_fup_n_get(void *ptr, int *dim1, double *arr) | ||
|
||
cdef extern void climaradtranwrk_fdn_n_get_size(void *ptr, int *dim1) | ||
cdef extern void climaradtranwrk_fdn_n_get(void *ptr, int *dim1, double *arr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
cimport OpticalProperties_pxd as op_pxd | ||
|
||
cdef class OpticalProperties: | ||
cdef void *_ptr | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def __dealloc__(self): | ||
pass | ||
|
||
property wavl: | ||
def __get__(self): | ||
cdef int dim1 | ||
op_pxd.opticalproperties_wavl_get_size(&self._ptr, &dim1) | ||
cdef ndarray arr = np.empty(dim1, np.double) | ||
op_pxd.opticalproperties_wavl_get(&self._ptr, &dim1, <double *>arr.data) | ||
return arr | ||
|
||
property freq: | ||
def __get__(self): | ||
cdef int dim1 | ||
op_pxd.opticalproperties_freq_get_size(&self._ptr, &dim1) | ||
cdef ndarray arr = np.empty(dim1, np.double) | ||
op_pxd.opticalproperties_freq_get(&self._ptr, &dim1, <double *>arr.data) | ||
return arr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
# getters and setters | ||
|
||
cdef extern void opticalproperties_wavl_get_size(void *ptr, int *dim1) | ||
cdef extern void opticalproperties_wavl_get(void *ptr, int *dim1, double *arr) | ||
|
||
cdef extern void opticalproperties_freq_get_size(void *ptr, int *dim1) | ||
cdef extern void opticalproperties_freq_get(void *ptr, int *dim1, double *arr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
cimport Radtran_pxd as rad_pxd | ||
|
||
cdef class Radtran: | ||
cdef void *_ptr | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def __dealloc__(self): | ||
pass | ||
|
||
property ir: | ||
def __get__(self): | ||
cdef void *ptr1; | ||
rad_pxd.radtran_ir_get(&self._ptr, &ptr1) | ||
var = OpticalProperties() | ||
var._ptr = ptr1 | ||
return var | ||
|
||
property sol: | ||
def __get__(self): | ||
cdef void *ptr1; | ||
rad_pxd.radtran_sol_get(&self._ptr, &ptr1) | ||
var = OpticalProperties() | ||
var._ptr = ptr1 | ||
return var | ||
|
||
property wrk_ir: | ||
def __get__(self): | ||
cdef void *ptr1; | ||
rad_pxd.radtran_wrk_ir_get(&self._ptr, &ptr1) | ||
var = ClimaRadtranWrk() | ||
var._ptr = ptr1 | ||
return var | ||
|
||
property wrk_sol: | ||
def __get__(self): | ||
cdef void *ptr1; | ||
rad_pxd.radtran_wrk_sol_get(&self._ptr, &ptr1) | ||
var = ClimaRadtranWrk() | ||
var._ptr = ptr1 | ||
return var | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
# getters and setters | ||
cdef extern void radtran_ir_get(void *ptr, void *ptr1); | ||
|
||
cdef extern void radtran_sol_get(void *ptr, void *ptr1); | ||
|
||
cdef extern void radtran_wrk_ir_get(void *ptr, void *ptr1); | ||
|
||
cdef extern void radtran_wrk_sol_get(void *ptr, void *ptr1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
cimport futils_pxd as f_pxd | ||
|
||
cpdef rebin(ndarray[double, ndim=1] old_bins, ndarray[double, ndim=1] old_vals, ndarray[double, ndim=1] new_bins): | ||
cdef int n_old = old_bins.shape[0] - 1 | ||
cdef int n_new = new_bins.shape[0] - 1 | ||
cdef ndarray new_vals = np.empty(n_new, np.double) | ||
cdef int ierr | ||
|
||
if old_vals.shape[0] != n_old: | ||
raise ValueError('"old_bins" and "old_vals" arguments to "rebin" have incompatible shapes') | ||
|
||
f_pxd.futils_rebin_wrapper(&n_old, <double *> old_bins.data, <double *> old_vals.data, | ||
&n_new, <double *> new_bins.data, <double *> new_vals.data, &ierr) | ||
if ierr < 0: | ||
raise Exception("rebin returned error code: "+str(ierr)) | ||
|
||
return new_vals | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
cdef extern void futils_rebin_wrapper(int *n_old, double *old_bins, double *old_vals, | ||
int *n_new, double *new_bins, double *new_vals, int *ierr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
|
||
add_library(clima_wrapper | ||
wrapper_utils.f90 | ||
WaterAdiabatClimate_wrapper.f90 | ||
add_library(clima_c_api | ||
clima_c_api.f90 | ||
) | ||
target_link_libraries(clima_wrapper clima) | ||
set(clima_c_api_deps | ||
futils.f90 | ||
OpticalProperties.f90 | ||
ClimaRadtranWrk.f90 | ||
Radtran.f90 | ||
WaterAdiabatClimate.f90 | ||
) | ||
foreach(PDEP ${_clima_deps}) | ||
set_source_files_properties(clima_c_api.f90 PROPERTIES OBJECT_DEPENDS ${PDEP}) | ||
endforeach() | ||
target_link_libraries(clima_c_api clima) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
! ClimaRadtranWrk | ||
|
||
!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!!! getters and setters !!! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
subroutine climaradtranwrk_fup_a_get_size(ptr, dim1, dim2) bind(c) | ||
use clima_radtran, only: ClimaRadtranWrk | ||
type(c_ptr), intent(in) :: ptr | ||
integer(c_int), intent(out) :: dim1, dim2 | ||
type(ClimaRadtranWrk), pointer :: w | ||
call c_f_pointer(ptr, w) | ||
dim1 = size(w%fup_a,1) | ||
dim2 = size(w%fup_a,2) | ||
end subroutine | ||
|
||
subroutine climaradtranwrk_fup_a_get(ptr, dim1, dim2, arr) bind(c) | ||
use clima_radtran, only: ClimaRadtranWrk | ||
type(c_ptr), intent(in) :: ptr | ||
integer(c_int), intent(in) :: dim1, dim2 | ||
real(c_double), intent(out) :: arr(dim1,dim2) | ||
type(ClimaRadtranWrk), pointer :: w | ||
call c_f_pointer(ptr, w) | ||
arr = w%fup_a | ||
end subroutine | ||
|
||
subroutine climaradtranwrk_fdn_a_get_size(ptr, dim1, dim2) bind(c) | ||
use clima_radtran, only: ClimaRadtranWrk | ||
type(c_ptr), intent(in) :: ptr | ||
integer(c_int), intent(out) :: dim1, dim2 | ||
type(ClimaRadtranWrk), pointer :: w | ||
call c_f_pointer(ptr, w) | ||
dim1 = size(w%fdn_a,1) | ||
dim2 = size(w%fdn_a,2) | ||
end subroutine | ||
|
||
subroutine climaradtranwrk_fdn_a_get(ptr, dim1, dim2, arr) bind(c) | ||
use clima_radtran, only: ClimaRadtranWrk | ||
type(c_ptr), intent(in) :: ptr | ||
integer(c_int), intent(in) :: dim1, dim2 | ||
real(c_double), intent(out) :: arr(dim1,dim2) | ||
type(ClimaRadtranWrk), pointer :: w | ||
call c_f_pointer(ptr, w) | ||
arr = w%fdn_a | ||
end subroutine | ||
|
||
subroutine climaradtranwrk_fup_n_get_size(ptr, dim1) bind(c) | ||
use clima_radtran, only: ClimaRadtranWrk | ||
type(c_ptr), intent(in) :: ptr | ||
integer(c_int), intent(out) :: dim1 | ||
type(ClimaRadtranWrk), pointer :: w | ||
call c_f_pointer(ptr, w) | ||
dim1 = size(w%fup_n,1) | ||
end subroutine | ||
|
||
subroutine climaradtranwrk_fup_n_get(ptr, dim1, arr) bind(c) | ||
use clima_radtran, only: ClimaRadtranWrk | ||
type(c_ptr), intent(in) :: ptr | ||
integer(c_int), intent(in) :: dim1 | ||
real(c_double), intent(out) :: arr(dim1) | ||
type(ClimaRadtranWrk), pointer :: w | ||
call c_f_pointer(ptr, w) | ||
arr = w%fup_n | ||
end subroutine | ||
|
||
subroutine climaradtranwrk_fdn_n_get_size(ptr, dim1) bind(c) | ||
use clima_radtran, only: ClimaRadtranWrk | ||
type(c_ptr), intent(in) :: ptr | ||
integer(c_int), intent(out) :: dim1 | ||
type(ClimaRadtranWrk), pointer :: w | ||
call c_f_pointer(ptr, w) | ||
dim1 = size(w%fdn_n,1) | ||
end subroutine | ||
|
||
subroutine climaradtranwrk_fdn_n_get(ptr, dim1, arr) bind(c) | ||
use clima_radtran, only: ClimaRadtranWrk | ||
type(c_ptr), intent(in) :: ptr | ||
integer(c_int), intent(in) :: dim1 | ||
real(c_double), intent(out) :: arr(dim1) | ||
type(ClimaRadtranWrk), pointer :: w | ||
call c_f_pointer(ptr, w) | ||
arr = w%fdn_n | ||
end subroutine | ||
|
Oops, something went wrong.