Skip to content

Commit

Permalink
remove prints, and changed how planet_radius is set
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholaswogan committed Apr 17, 2024
1 parent ef95e44 commit 559ff6b
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 66 deletions.
12 changes: 0 additions & 12 deletions photochem/cython/EvoAtmosphere.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -385,18 +385,6 @@ cdef class EvoAtmosphere:
if len(err.strip()) > 0:
raise PhotoException(err.decode("utf-8").strip())

def update_planet_mass_radius(self, double planet_mass, double planet_radius):
"""Updates planet mass and radius. The routine recomputes gravity vs. altitude.
Parameters
----------
planet_mass : float
In grams
planet_radius : float
In cm
"""
ea_pxd.evoatmosphere_update_planet_mass_radius_wrapper(&self._ptr, &planet_mass, &planet_radius)

def regrid_prep_atmosphere(self, ndarray[double, ndim=2] usol, double top_atmos):
"""This subroutine calculates re-grids the model so that the top of the model domain
is at `top_atmos` the computes reaction rates, photolysis rates, etc.
Expand Down
1 change: 0 additions & 1 deletion photochem/cython/EvoAtmosphere_pxd.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ cdef extern void evoatmosphere_set_press_temp_edd_wrapper(void *ptr, int *P_dim1
bool *hydro_pressure, bool *hydro_pressure_present, char *err)
cdef extern void evoatmosphere_update_vertical_grid_wrapper(void *ptr, double *toa_alt, bool *toa_alt_present,
double *toa_pressure, bool *toa_pressure_present, char *err)
cdef extern void evoatmosphere_update_planet_mass_radius_wrapper(void *ptr, double *planet_mass, double *planet_radius)
cdef extern void evoatmosphere_regrid_prep_atmosphere_wrapper(void *ptr, int *nq, int *nz, double *usol, double *top_atmos, char *err)

cdef extern void evoatmosphere_evolve_wrapper(void *ptr, char *filename,
Expand Down
2 changes: 2 additions & 0 deletions photochem/cython/PhotochemData.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ cdef class PhotochemData:
cdef double val
dat_pxd.photochemdata_planet_radius_get(&self._ptr, &val)
return val
def __set__(self, double val):
dat_pxd.photochemdata_planet_radius_set(&self._ptr, &val)

property species_names:
"""List, shape (nsp+2). A list of the species in the model (particles and gases).
Expand Down
1 change: 1 addition & 0 deletions photochem/cython/PhotochemData_pxd.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cdef extern void photochemdata_nw_get(void *ptr, int *nq)
cdef extern void photochemdata_planet_mass_get(void *ptr, double *val)

cdef extern void photochemdata_planet_radius_get(void *ptr, double *val)
cdef extern void photochemdata_planet_radius_set(void *ptr, double *val)

cdef extern void photochemdata_species_names_get_size(void *ptr, int *dim1)
cdef extern void photochemdata_species_names_get(void *ptr, int *dim1, char* species_names)
Expand Down
10 changes: 0 additions & 10 deletions photochem/fortran/EvoAtmosphere_wrapper.f90
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,6 @@ subroutine evoatmosphere_update_vertical_grid_wrapper(ptr, TOA_alt, TOA_alt_pres

end subroutine

subroutine evoatmosphere_update_planet_mass_radius_wrapper(ptr, planet_mass, planet_radius) bind(c)
type(c_ptr), intent(in) :: ptr
real(c_double), intent(in) :: planet_mass, planet_radius
type(EvoAtmosphere), pointer :: pc

call c_f_pointer(ptr, pc)
call pc%update_planet_mass_radius(planet_mass, planet_radius)

end subroutine

subroutine evoatmosphere_regrid_prep_atmosphere_wrapper(ptr, nq, nz, usol, top_atmos, err) bind(c)
type(c_ptr), intent(in) :: ptr
integer(c_int), intent(in) :: nq, nz
Expand Down
8 changes: 8 additions & 0 deletions photochem/fortran/PhotochemData_wrapper.f90
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ subroutine photochemdata_planet_radius_get(ptr, val) bind(c)
call c_f_pointer(ptr, dat)
val = dat%planet_radius
end subroutine

subroutine photochemdata_planet_radius_set(ptr, val) bind(c)
type(c_ptr), intent(in) :: ptr
real(c_double), intent(in) :: val
type(PhotochemData), pointer :: dat
call c_f_pointer(ptr, dat)
dat%planet_radius = val
end subroutine

subroutine photochemdata_species_names_get_size(ptr, dim1) bind(c)
type(c_ptr), intent(in) :: ptr
Expand Down
7 changes: 0 additions & 7 deletions src/evoatmosphere/photochem_evoatmosphere.f90
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ function temp_dependent_albedo_fcn(T_surf) result(albedo)
procedure :: set_temperature
procedure :: set_press_temp_edd
procedure :: update_vertical_grid
procedure :: update_planet_mass_radius
procedure :: rebin_update_vertical_grid
procedure :: regrid_prep_atmosphere

Expand Down Expand Up @@ -315,12 +314,6 @@ module subroutine update_vertical_grid(self, TOA_alt, TOA_pressure, err)
character(:), allocatable, intent(out) :: err
end subroutine

!> Updates planet mass and radius. The routine recomputes gravity vs. altitude.
module subroutine update_planet_mass_radius(self, planet_mass, planet_radius)
class(EvoAtmosphere), target, intent(inout) :: self
real(dp), intent(in) :: planet_mass, planet_radius
end subroutine

! Both below are needed only for `evolve` routine and probably should not be used most of the time.

module subroutine rebin_update_vertical_grid(self, usol_old, top_atmos, usol_new, err)
Expand Down
10 changes: 0 additions & 10 deletions src/evoatmosphere/photochem_evoatmosphere_utils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -793,16 +793,6 @@ module subroutine update_vertical_grid(self, TOA_alt, TOA_pressure, err)

end subroutine

module subroutine update_planet_mass_radius(self, planet_mass, planet_radius)
use photochem_eqns, only: gravity
class(EvoAtmosphere), target, intent(inout) :: self
real(dp), intent(in) :: planet_mass, planet_radius
self%dat%planet_mass = planet_mass
self%dat%planet_radius = planet_radius
call gravity(self%dat%planet_radius, self%dat%planet_mass, &
self%var%nz, self%var%z, self%var%grav)
end subroutine

! Below is mostly stuff needed in `evolve` routine

module subroutine rebin_update_vertical_grid(self, usol_old, top_atmos, usol_new, err)
Expand Down
8 changes: 0 additions & 8 deletions src/input/photochem_input_after_read.f90
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,6 @@ subroutine interp2atmosfile(dat, var, err)
var%particle_radius = 10.0_dp**var%particle_radius
endif

if (var%z(1) < dat%z_file(1)) then
print*,'Warning: vertical grid is being extrapolated below where there is input data.'
endif

if (var%z(var%nz) > dat%z_file(dat%nzf)) then
print*,'Warning: vertical grid is being extrapolated above where there is input data.'
endif

end subroutine

subroutine interp2atmosfile_mixconserving(dat, var, err)
Expand Down
18 changes: 0 additions & 18 deletions src/input/photochem_input_read.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2558,14 +2558,12 @@ subroutine read_atmosphere_file(atmosphere_txt, dat, var, err)
character(:), allocatable, intent(out) :: err

character(len=10000) :: line
character(len=:), allocatable :: message
character(len=s_str_len) :: arr1(1000)
character(len=s_str_len) :: arr11(1000)
character(len=s_str_len),allocatable, dimension(:) :: labels
integer :: ind(1)
real(dp), allocatable :: temp(:,:)
integer :: io, i, n, nn, ii
logical :: missing

open(4, file=trim(atmosphere_txt),status='old',iostat=io)
if (io /= 0) then
Expand Down Expand Up @@ -2632,24 +2630,14 @@ subroutine read_atmosphere_file(atmosphere_txt, dat, var, err)
close(4)

! reads in mixing ratios
missing = .false.
do i=1,dat%nq
ind = findloc(labels,dat%species_names(i))
if (ind(1) /= 0) then
dat%mix_file(i,:) = temp(ind(1),:)
else
missing = .true.
endif
enddo

if (missing) then
message = 'Warning: Did not find initial data for some species in '// &
trim(atmosphere_txt)//' . The program will assume initial mixing ratios of 1.0e-40'
print*,message
endif

if (dat%there_are_particles) then
missing = .false.
do i=1,dat%npq
ind = findloc(labels,trim(dat%species_names(i))//"_r")
if (ind(1) /= 0) then
Expand All @@ -2658,14 +2646,8 @@ subroutine read_atmosphere_file(atmosphere_txt, dat, var, err)
! did not find the data
! will set to 0.1 micron
dat%particle_radius_file(i,:) = 1.0e-5_dp
missing = .true.
endif
enddo

if (missing) then
print*,'Warning: Did not find particle radii for some species in '//&
trim(atmosphere_txt)//' . The program will assume 0.1 micron raddii.'
endif
endif

! reads in temperature
Expand Down

0 comments on commit 559ff6b

Please sign in to comment.