Skip to content

Commit

Permalink
specify solving one system
Browse files Browse the repository at this point in the history
  • Loading branch information
jcurtis2 committed Oct 2, 2024
1 parent d9297e1 commit 3a71a95
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
7 changes: 4 additions & 3 deletions src/run_part.F90
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ subroutine spec_file_read_run_part(file, run_part_opt, aero_data, &
type(spec_file_t) :: sub_file
character(len=PMC_MAX_FILENAME_LEN) :: camp_config_filename, &
tchem_gas_filename, tchem_aero_filename, tchem_numerics_filename
integer :: n_grid_cells

call spec_file_read_string(file, 'output_prefix', &
run_part_opt%output_prefix)
Expand Down Expand Up @@ -562,9 +563,9 @@ subroutine spec_file_read_run_part(file, run_part_opt, aero_data, &

if (run_part_opt%do_tchem) then
#ifdef PMC_USE_TCHEM
! FIXME: Switch to aerosols
call pmc_tchem_initialize(tchem_gas_filename, &
tchem_aero_filename, tchem_numerics_filename, gas_data, aero_data)
n_grid_cells = 1
call pmc_tchem_initialize(tchem_gas_filename, tchem_aero_filename, &
tchem_numerics_filename, gas_data, aero_data, n_grid_cells)
#endif
end if

Expand Down
29 changes: 17 additions & 12 deletions src/tchem_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,20 @@ function TChem_getLengthOfStateVector() bind(c, &
use iso_c_binding
integer(kind=c_int) :: TChem_getLengthOfStateVector
end function
subroutine TChem_getStateVector(array, i_batch) bind(c, name="TChem_getStateVector")
subroutine TChem_getStateVector(array, i_batch) bind(c, &
name="TChem_getStateVector")
use iso_c_binding
real(kind=c_double) :: array(*)
integer(c_int), value :: i_batch
end subroutine
subroutine TChem_setStateVector(array, i_batch) bind(c, name="TChem_setStateVector")
subroutine TChem_setStateVector(array, i_batch) bind(c, &
name="TChem_setStateVector")
use iso_c_binding
real(kind=c_double) :: array(*)
integer(c_int), value :: i_batch
end subroutine
integer(kind=c_size_t) function TChem_getSpeciesName(index, result, buffer_size) &
bind(C, name="TChem_getSpeciesName")
integer(kind=c_size_t) function TChem_getSpeciesName(index, result, &
buffer_size) bind(C, name="TChem_getSpeciesName")
use iso_c_binding
integer(kind=c_int), intent(in) :: index
character(kind=c_char), intent(out) :: result(*)
Expand Down Expand Up @@ -97,7 +99,7 @@ end subroutine pmc_tchem_interface_solve

!> Initialize TChem and PartMC gas and aerosol data.
subroutine pmc_tchem_initialize(gas_config_filename, aero_config_filename, &
solver_config_filename, gas_data, aero_data)
solver_config_filename, gas_data, aero_data, n_grid_cells)
use iso_c_binding

!> Gas configuration filename.
Expand All @@ -110,6 +112,8 @@ subroutine pmc_tchem_initialize(gas_config_filename, aero_config_filename, &
type(gas_data_t), intent(inout) :: gas_data
!> Aerosol data.
type(aero_data_t), intent(inout) :: aero_data
!> Number of cells to solve.
integer, intent(in) :: n_grid_cells

integer(kind=c_int) :: nSpec, nAeroSpec
integer :: n_species
Expand All @@ -119,7 +123,8 @@ subroutine pmc_tchem_initialize(gas_config_filename, aero_config_filename, &

! initialize the model
call TChem_initialize(trim(gas_config_filename), &
trim(aero_config_filename), trim(solver_config_filename), 1)
trim(aero_config_filename), trim(solver_config_filename), &
n_grid_cells)

! Get size that gas_data should be
nSpec = TChem_getNumberOfSpecies()
Expand All @@ -135,10 +140,11 @@ subroutine pmc_tchem_initialize(gas_config_filename, aero_config_filename, &
allocate(gas_data%mosaic_index(gas_data_n_spec(gas_data)))
gas_data%mosaic_index(:) = 0

! Aerosols
! Temporarily set so PartMC can run.
! Species names
! Species properties - density, kappa, molecular weight
! TODO: Create aero_data based on TChem input.
! From TChem we need:
! Species names
! Species properties - density, kappa, molecular weight
! Temporarily allocate aero_data structure so PartMC can run.
n_species = 10
call ensure_string_array_size(aero_data%name, n_species)
call ensure_integer_array_size(aero_data%mosaic_index, n_species)
Expand All @@ -148,7 +154,6 @@ subroutine pmc_tchem_initialize(gas_config_filename, aero_config_filename, &
call ensure_real_array_size(aero_data%molec_weight, n_species)
call ensure_real_array_size(aero_data%kappa, n_species)
do i = 1,n_species

end do

end subroutine pmc_tchem_initialize
Expand Down Expand Up @@ -283,7 +288,7 @@ subroutine TChem_initialize(chemFile, aeroFile, NumericsFile, n_batch)
integer(kind=c_int), intent(in) :: n_batch

call initialize(chemFile//c_null_char, aeroFile//c_null_char, &
numericsFile//c_null_char, 1)
numericsFile//c_null_char, n_batch)

end subroutine TChem_initialize

Expand Down

0 comments on commit 3a71a95

Please sign in to comment.