Skip to content

Commit

Permalink
wrapper for diurnal fact
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholaswogan committed Nov 26, 2024
1 parent b7becb7 commit 3b24a96
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions photochem/cython/PhotochemVars.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ cdef class PhotochemVars:
raise PhotoException("Input array is the wrong size.")
var_pxd.photochemvars_particle_radius_set(self._ptr, &dim1, &dim2, <double *>arr_.data)

property diurnal_fac:
"double. Default is 0.5, to account for half planet facing the sun."
def __get__(self):
cdef double val
var_pxd.photochemvars_diurnal_fac_get(self._ptr, &val)
return val
def __set__(self, double val):
var_pxd.photochemvars_diurnal_fac_set(self._ptr, &val)

property trop_alt:
"double. Tropopause altitude."
def __get__(self):
Expand Down
3 changes: 3 additions & 0 deletions photochem/cython/PhotochemVars_pxd.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ cdef extern void photochemvars_particle_radius_get_size(PhotochemVars *ptr, int
cdef extern void photochemvars_particle_radius_get(PhotochemVars *ptr, int *dim1, int *dim2, double *arr)
cdef extern void photochemvars_particle_radius_set(PhotochemVars *ptr, int *dim1, int *dim2, double *arr)

cdef extern void photochemvars_diurnal_fac_get(PhotochemVars *ptr, double *val)
cdef extern void photochemvars_diurnal_fac_set(PhotochemVars *ptr, double *val)

cdef extern void photochemvars_trop_alt_get(PhotochemVars *ptr, double *val)

cdef extern void photochemvars_trop_ind_get(PhotochemVars *ptr, int *val)
Expand Down
16 changes: 16 additions & 0 deletions photochem/fortran/PhotochemVars_wrapper.f90
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ subroutine photochemvars_particle_radius_set(ptr, dim1, dim2, arr) bind(c)
var%particle_radius = arr
end subroutine

subroutine photochemvars_diurnal_fac_get(ptr, val) bind(c)
type(c_ptr), value, intent(in) :: ptr
real(c_double), intent(out) :: val
type(PhotochemVars), pointer :: var
call c_f_pointer(ptr, var)
val = var%diurnal_fac
end subroutine

subroutine photochemvars_diurnal_fac_set(ptr, val) bind(c)
type(c_ptr), value, intent(in) :: ptr
real(c_double), intent(in) :: val
type(PhotochemVars), pointer :: var
call c_f_pointer(ptr, var)
var%diurnal_fac = val
end subroutine

subroutine photochemvars_trop_alt_get(ptr, val) bind(c)
type(c_ptr), value, intent(in) :: ptr
real(c_double), intent(out) :: val
Expand Down

0 comments on commit 3b24a96

Please sign in to comment.