Skip to content

Commit

Permalink
add spec file reading for tchem. pass value of config to tchem
Browse files Browse the repository at this point in the history
  • Loading branch information
jcurtis2 committed May 9, 2024
1 parent 5d04412 commit c25674a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ add_library(partmclib src/aero_state.F90 src/integer_varray.F90
src/camp_interface.F90 src/photolysis.F90 src/sys.F90
src/tchem_interface.F90
src/aero_component.F90
src/test.cpp
${SUNDIALS_SRC} ${GSL_SRC} ${TCHEM_SRC}
${C_SORT_SRC})

Expand Down
21 changes: 17 additions & 4 deletions src/partmc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ subroutine partmc_part(file)
real(kind=dp) :: dummy_time, dummy_del_t, n_part
character(len=PMC_MAX_FILENAME_LEN) :: sub_filename
type(spec_file_t) :: sub_file
character(len=PMC_MAX_FILENAME_LEN) :: camp_config_filename
character(len=PMC_MAX_FILENAME_LEN) :: camp_config_filename, &
tchem_config_filename

!> \page input_format_particle Input File Format: Particle-Resolved Simulation
!!
Expand Down Expand Up @@ -502,6 +503,14 @@ subroutine partmc_part(file)
#endif
end if

call spec_file_read_logical(file, 'do_tchem', run_part_opt%do_tchem)
if (run_part_opt%do_tchem) then
#ifdef PMC_USE_TCHEM
call spec_file_read_string(file, 'tchem_config', &
tchem_config_filename)
#endif
end if

if (do_restart) then
call input_state(restart_filename, dummy_index, dummy_time, &
dummy_del_t, dummy_i_repeat, run_part_opt%uuid, aero_data, &
Expand Down Expand Up @@ -730,6 +739,10 @@ subroutine partmc_part(file)
#endif
end if

if (run_part_opt%do_tchem) then
call tchem_initialize(tchem_config_filename, gas_data, gas_state, aero_data)
end if

! re-initialize RNG with the given seed
call pmc_rand_finalize()
call pmc_srand(rand_init, pmc_mpi_rank())
Expand Down Expand Up @@ -774,8 +787,6 @@ subroutine partmc_part(file)
end if
#endif

call tchem_init(gas_data, gas_state, aero_data)

if (run_part_opt%do_camp_chem) then
#ifdef PMC_USE_CAMP
call run_part(scenario, env_state, aero_data, aero_state, gas_data, &
Expand All @@ -789,7 +800,9 @@ subroutine partmc_part(file)

end do

call tchem_cleanup()
if (run_part_opt%do_tchem) then
call tchem_cleanup()
end if

call pmc_rand_finalize()

Expand Down
9 changes: 7 additions & 2 deletions src/run_part.F90
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ module pmc_run_part
logical :: env_average
!> Parallel coagulation method type.
integer :: parallel_coag_type
!> Whether to run CAMP
!> Whether to run CAMP.
logical :: do_camp_chem
!> Whether to run TChem.
logical :: do_tchem
!> UUID for this simulation.
character(len=PMC_UUID_LEN) :: uuid
end type run_part_opt_t
Expand Down Expand Up @@ -333,6 +335,7 @@ integer function pmc_mpi_pack_size_run_part_opt(val)
+ pmc_mpi_pack_size_logical(val%env_average) &
+ pmc_mpi_pack_size_integer(val%parallel_coag_type) &
+ pmc_mpi_pack_size_logical(val%do_camp_chem) &
+ pmc_mpi_pack_size_logical(val%do_tchem) &
+ pmc_mpi_pack_size_string(val%uuid)

end function pmc_mpi_pack_size_run_part_opt
Expand Down Expand Up @@ -383,6 +386,7 @@ subroutine pmc_mpi_pack_run_part_opt(buffer, position, val)
call pmc_mpi_pack_logical(buffer, position, val%env_average)
call pmc_mpi_pack_integer(buffer, position, val%parallel_coag_type)
call pmc_mpi_pack_logical(buffer, position, val%do_camp_chem)
call pmc_mpi_pack_logical(buffer, position, val%do_tchem)
call pmc_mpi_pack_string(buffer, position, val%uuid)
call assert(946070052, &
position - prev_position <= pmc_mpi_pack_size_run_part_opt(val))
Expand Down Expand Up @@ -436,6 +440,7 @@ subroutine pmc_mpi_unpack_run_part_opt(buffer, position, val)
call pmc_mpi_unpack_logical(buffer, position, val%env_average)
call pmc_mpi_unpack_integer(buffer, position, val%parallel_coag_type)
call pmc_mpi_unpack_logical(buffer, position, val%do_camp_chem)
call pmc_mpi_unpack_logical(buffer, position, val%do_tchem)
call pmc_mpi_unpack_string(buffer, position, val%uuid)
call assert(480118362, &
position - prev_position <= pmc_mpi_pack_size_run_part_opt(val))
Expand Down Expand Up @@ -621,7 +626,7 @@ subroutine run_part_timestep(scenario, env_state, aero_data, aero_state, &
#endif
end if

if (.true.) then
if (run_part_opt%do_tchem) then
#ifdef PMC_USE_TCHEM
call pmc_tchem_interface_solve()
#endif
Expand Down
29 changes: 11 additions & 18 deletions src/tchem_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,10 @@ module pmc_tchem_interface
#endif
use pmc_util, only : die_msg, warn_assert_msg, assert_msg

#ifdef PMC_USE_TCHEM
!#ifdef PMC_USE_TCHEM
! interface
! subroutine initialize_kokkos(nSpec) bind(c)
! use iso_c_binding
! integer(kind=c_int) :: nSpec
! end subroutine initialize_kokkos
! subroutine cfun(a) bind(C)
! use iso_c_binding
! integer(c_int) :: a
! end subroutine
! subroutine cfun1(a) bind(C)
! use iso_c_binding
! integer(c_int) :: a
! end subroutine
! end interface
#endif
!#endif
contains

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand All @@ -49,15 +37,20 @@ end subroutine pmc_tchem_interface_solve

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

subroutine tchem_init(gas_data, gas_state, aero_data)

use iso_c_binding
subroutine tchem_initialize(config_filename, gas_data, gas_state, aero_data)

character(len=*), intent(in) :: config_filename
type(gas_data_t), intent(inout) :: gas_data
type(gas_state_t), intent(inout) :: gas_state
type(aero_data_t), intent(inout) :: aero_data

call initialize_kokkos()
integer :: nSpec

nSpec = 0

call initialize(trim(config_filename))

print*, 'in partmc', nSpec, trim(config_filename)

end subroutine

Expand Down

0 comments on commit c25674a

Please sign in to comment.