module sph_api use sph_precision, only: rk, SPH_VERSION_MAJOR, SPH_VERSION_MINOR, & SPH_VERSION_PATCH use sph_error, only: SPH_SUCCESS, SPH_ERROR_STATE, sph_error_clear, & sph_error_set, sph_error_get use sph_log, only: sph_log_close use sph_control, only: sph_control_reset, sph_control_get_time use sph_database, only: sph_db_free, sph_db_get_particle_count, & sph_db_get_particle_state_capacity, sph_db_get_particle_state use sph_input_reader, only: sph_input_read, sph_input_build_model, & sph_input_get_warning_count use sph_solver_explicit, only: sph_solver_estimate_stable_dt, & sph_solver_advance_explicit, sph_solver_run_explicit use sph_output_csv, only: sph_output_write_csv, sph_output_write_step, & sph_output_set_directory, sph_output_set_interval use sph_restart, only: sph_restart_write, sph_restart_read use sph_coupling_interface, only: sph_coupling_reset use sph_particle, only: sph_particle_initialize, sph_particle_reset use sph_neighbor, only: sph_neighbor_rebuild, sph_neighbor_get_stats use sph_material, only: sph_material_initialize, sph_material_reset use sph_water, only: sph_water_initialize, sph_water_reset, & sph_water_get_summary, sph_water_estimate_dt_limits use sph_gas, only: sph_gas_initialize, sph_gas_reset, & sph_gas_get_summary, sph_gas_get_extended_summary, & sph_gas_get_source_summary, sph_gas_get_bubble_metrics, & sph_gas_estimate_dt_limits use sph_explosive, only: sph_explosive_initialize, sph_explosive_reset, & sph_explosive_get_summary, sph_explosive_set_default_ignition_point use sph_solid, only: sph_solid_initialize, sph_solid_reset use sph_shell, only: sph_shell_initialize, sph_shell_reset use sph_api_state, only: sph_api_initialized, sph_api_model_built, & sph_api_state_set_initialized, sph_api_state_set_model_built implicit none contains subroutine sph_initialize(ierr) integer, intent(out) :: ierr call sph_error_clear() call sph_control_reset() call sph_db_free() call sph_coupling_reset() call sph_particle_initialize() call sph_material_initialize() call sph_water_initialize() call sph_gas_initialize() call sph_explosive_initialize() call sph_solid_initialize() call sph_shell_initialize() call sph_api_state_set_initialized(.true.) call sph_api_state_set_model_built(.false.) ierr = SPH_SUCCESS end subroutine sph_initialize subroutine sph_finalize(ierr) integer, intent(out) :: ierr integer :: local_ierr call sph_db_free() call sph_coupling_reset() call sph_particle_reset() call sph_material_reset() call sph_water_reset() call sph_gas_reset() call sph_explosive_reset() call sph_solid_reset() call sph_shell_reset() call sph_log_close(local_ierr) call sph_api_state_set_initialized(.false.) call sph_error_clear() ierr = SPH_SUCCESS end subroutine sph_finalize subroutine sph_get_version(major, minor, patch, ierr) integer, intent(out) :: major integer, intent(out) :: minor integer, intent(out) :: patch integer, intent(out) :: ierr major = SPH_VERSION_MAJOR minor = SPH_VERSION_MINOR patch = SPH_VERSION_PATCH ierr = SPH_SUCCESS end subroutine sph_get_version subroutine sph_get_last_error(code, message, ierr) integer, intent(out) :: code character(len=*), intent(out) :: message integer, intent(out) :: ierr call sph_error_get(code, message) ierr = SPH_SUCCESS end subroutine sph_get_last_error subroutine sph_read_inp(filename, ierr) character(len=*), intent(in) :: filename integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_api_state_set_model_built(.false.) call sph_input_read(filename, ierr) end subroutine sph_read_inp subroutine sph_build_model(ierr) integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_input_build_model(ierr) if (ierr == SPH_SUCCESS) call sph_api_state_set_model_built(.true.) end subroutine sph_build_model subroutine sph_estimate_stable_dt(dtcrit, ierr) real(rk), intent(out) :: dtcrit integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) then dtcrit = 0.0_rk return end if call sph_api_require_model_built(ierr) if (ierr /= SPH_SUCCESS) then dtcrit = 0.0_rk return end if call sph_solver_estimate_stable_dt(dtcrit, ierr) end subroutine sph_estimate_stable_dt subroutine sph_advance_explicit(dt, ierr) real(rk), intent(in) :: dt integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_api_require_model_built(ierr) if (ierr /= SPH_SUCCESS) return call sph_solver_advance_explicit(dt, ierr) end subroutine sph_advance_explicit subroutine sph_run_explicit(ierr) integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_api_require_model_built(ierr) if (ierr /= SPH_SUCCESS) return call sph_solver_run_explicit(ierr) end subroutine sph_run_explicit subroutine sph_get_current_time(time, step, ierr) real(rk), intent(out) :: time integer, intent(out) :: step integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) then time = 0.0_rk step = 0 return end if call sph_control_get_time(time, step) ierr = SPH_SUCCESS end subroutine sph_get_current_time subroutine sph_get_particle_count(count, ierr) integer, intent(out) :: count integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) then count = 0 return end if call sph_db_get_particle_count(count, ierr) end subroutine sph_get_particle_count subroutine sph_get_particle_state_capacity(count, ndim, ierr) integer, intent(out) :: count integer, intent(out) :: ndim integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) then count = 0 ndim = 0 return end if call sph_db_get_particle_state_capacity(count, ndim, ierr) end subroutine sph_get_particle_state_capacity subroutine sph_get_particle_state(max_particles, particle_id_ext, phase, & status, material_id, section_id, x, v, a, rho, pressure, & internal_energy, temperature, h, count, ierr) integer, intent(in) :: max_particles integer, intent(out) :: particle_id_ext(max_particles) integer, intent(out) :: phase(max_particles) integer, intent(out) :: status(max_particles) integer, intent(out) :: material_id(max_particles) integer, intent(out) :: section_id(max_particles) real(rk), intent(out) :: x(3,max_particles) real(rk), intent(out) :: v(3,max_particles) real(rk), intent(out) :: a(3,max_particles) real(rk), intent(out) :: rho(max_particles) real(rk), intent(out) :: pressure(max_particles) real(rk), intent(out) :: internal_energy(max_particles) real(rk), intent(out) :: temperature(max_particles) real(rk), intent(out) :: h(max_particles) integer, intent(out) :: count integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) then count = 0 return end if call sph_db_get_particle_state(max_particles, particle_id_ext, phase, & status, material_id, section_id, x, v, a, rho, pressure, & internal_energy, temperature, h, count, ierr) end subroutine sph_get_particle_state subroutine sph_write_csv(filename, ierr) character(len=*), intent(in) :: filename integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_output_write_csv(filename, ierr) end subroutine sph_write_csv subroutine sph_write_output(step, time, ierr) integer, intent(in) :: step real(rk), intent(in) :: time integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_output_write_step(step, time, ierr) end subroutine sph_write_output subroutine sph_set_output_directory(directory, ierr) character(len=*), intent(in) :: directory integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_output_set_directory(directory, ierr) end subroutine sph_set_output_directory subroutine sph_set_output_interval(interval, ierr) integer, intent(in) :: interval integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_output_set_interval(interval, ierr) end subroutine sph_set_output_interval subroutine sph_write_restart(filename, ierr) character(len=*), intent(in) :: filename integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_restart_write(filename, ierr) end subroutine sph_write_restart subroutine sph_read_restart(filename, ierr) character(len=*), intent(in) :: filename integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_restart_read(filename, ierr) if (ierr == SPH_SUCCESS) call sph_api_state_set_model_built(.true.) end subroutine sph_read_restart subroutine sph_get_input_warning_count(count, ierr) integer, intent(out) :: count integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) then count = 0 return end if call sph_input_get_warning_count(count) ierr = SPH_SUCCESS end subroutine sph_get_input_warning_count subroutine sph_rebuild_neighbors(ierr) integer, intent(out) :: ierr call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_api_require_model_built(ierr) if (ierr /= SPH_SUCCESS) return call sph_neighbor_rebuild(ierr) end subroutine sph_rebuild_neighbors subroutine sph_get_neighbor_stats(max_neighbors, average_neighbors, ierr) integer, intent(out) :: max_neighbors real(rk), intent(out) :: average_neighbors integer, intent(out) :: ierr max_neighbors = 0 average_neighbors = 0.0_rk call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_api_require_model_built(ierr) if (ierr /= SPH_SUCCESS) return call sph_neighbor_get_stats(max_neighbors, average_neighbors, ierr) end subroutine sph_get_neighbor_stats subroutine sph_get_water_summary(mass, momentum, max_pressure, min_density, & max_density, ierr) real(rk), intent(out) :: mass real(rk), intent(out) :: momentum(3) real(rk), intent(out) :: max_pressure real(rk), intent(out) :: min_density real(rk), intent(out) :: max_density integer, intent(out) :: ierr mass = 0.0_rk momentum = 0.0_rk max_pressure = 0.0_rk min_density = 0.0_rk max_density = 0.0_rk call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_api_require_model_built(ierr) if (ierr /= SPH_SUCCESS) return call sph_water_get_summary(mass, momentum, max_pressure, min_density, & max_density, ierr) end subroutine sph_get_water_summary subroutine sph_get_water_dt_limits(dt_cfl, dt_accel, dt_viscous, ierr) real(rk), intent(out) :: dt_cfl real(rk), intent(out) :: dt_accel real(rk), intent(out) :: dt_viscous integer, intent(out) :: ierr dt_cfl = 0.0_rk dt_accel = 0.0_rk dt_viscous = 0.0_rk call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_api_require_model_built(ierr) if (ierr /= SPH_SUCCESS) return call sph_water_estimate_dt_limits(dt_cfl, dt_accel, dt_viscous, ierr) end subroutine sph_get_water_dt_limits subroutine sph_get_gas_summary(volume, center, mean_pressure, max_pressure, ierr) real(rk), intent(out) :: volume real(rk), intent(out) :: center(3) real(rk), intent(out) :: mean_pressure real(rk), intent(out) :: max_pressure integer, intent(out) :: ierr volume = 0.0_rk center = 0.0_rk mean_pressure = 0.0_rk max_pressure = 0.0_rk call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_api_require_model_built(ierr) if (ierr /= SPH_SUCCESS) return call sph_gas_get_summary(volume, center, mean_pressure, max_pressure, ierr) end subroutine sph_get_gas_summary subroutine sph_get_gas_bubble_metrics(equivalent_radius, radius_rate, center, ierr) real(rk), intent(out) :: equivalent_radius real(rk), intent(out) :: radius_rate real(rk), intent(out) :: center(3) integer, intent(out) :: ierr equivalent_radius = 0.0_rk radius_rate = 0.0_rk center = 0.0_rk call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_api_require_model_built(ierr) if (ierr /= SPH_SUCCESS) return call sph_gas_get_bubble_metrics(equivalent_radius, radius_rate, center, ierr) end subroutine sph_get_gas_bubble_metrics subroutine sph_get_gas_dt_limits(dt_cfl, dt_accel, dtcrit, ierr) real(rk), intent(out) :: dt_cfl real(rk), intent(out) :: dt_accel real(rk), intent(out) :: dtcrit integer, intent(out) :: ierr dt_cfl = 0.0_rk dt_accel = 0.0_rk dtcrit = 0.0_rk call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_api_require_model_built(ierr) if (ierr /= SPH_SUCCESS) return call sph_gas_estimate_dt_limits(dt_cfl, dt_accel, dtcrit, ierr) end subroutine sph_get_gas_dt_limits subroutine sph_get_gas_extended_summary(mass, momentum, density_range, & dt_limits, ierr) real(rk), intent(out) :: mass real(rk), intent(out) :: momentum(3) real(rk), intent(out) :: density_range(2) real(rk), intent(out) :: dt_limits(3) integer, intent(out) :: ierr mass = 0.0_rk momentum = 0.0_rk density_range = 0.0_rk dt_limits = 0.0_rk call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_api_require_model_built(ierr) if (ierr /= SPH_SUCCESS) return call sph_gas_get_extended_summary(mass, momentum, density_range, & dt_limits, ierr) end subroutine sph_get_gas_extended_summary subroutine sph_get_gas_source_summary(mass_source, momentum_source, & energy_source, ierr) real(rk), intent(out) :: mass_source real(rk), intent(out) :: momentum_source(3) real(rk), intent(out) :: energy_source integer, intent(out) :: ierr mass_source = 0.0_rk momentum_source = 0.0_rk energy_source = 0.0_rk call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_api_require_model_built(ierr) if (ierr /= SPH_SUCCESS) return call sph_gas_get_source_summary(mass_source, momentum_source, & energy_source, ierr) end subroutine sph_get_gas_source_summary subroutine sph_set_ignition_point(x_value, y_value, z_value, time_value, ierr) real(rk), intent(in) :: x_value real(rk), intent(in) :: y_value real(rk), intent(in) :: z_value real(rk), intent(in) :: time_value integer, intent(out) :: ierr real(rk) :: ignition_x(3) call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return ignition_x = (/x_value, y_value, z_value/) call sph_explosive_set_default_ignition_point(ignition_x, time_value, ierr) end subroutine sph_set_ignition_point subroutine sph_get_explosive_summary(particle_count, reacted_count, & lambda_range, released_totals, detonation_time_range, ierr) integer, intent(out) :: particle_count integer, intent(out) :: reacted_count real(rk), intent(out) :: lambda_range(3) real(rk), intent(out) :: released_totals(5) real(rk), intent(out) :: detonation_time_range(2) integer, intent(out) :: ierr particle_count = 0 reacted_count = 0 lambda_range = 0.0_rk released_totals = 0.0_rk detonation_time_range = 0.0_rk call sph_api_require_initialized(ierr) if (ierr /= SPH_SUCCESS) return call sph_api_require_model_built(ierr) if (ierr /= SPH_SUCCESS) return call sph_explosive_get_summary(particle_count, reacted_count, & lambda_range, released_totals, detonation_time_range, ierr) end subroutine sph_get_explosive_summary subroutine sph_api_require_initialized(ierr) integer, intent(out) :: ierr ierr = SPH_SUCCESS if (.not. sph_api_initialized) then call sph_error_set(SPH_ERROR_STATE, 'SPHLite API is not initialized') ierr = SPH_ERROR_STATE end if end subroutine sph_api_require_initialized subroutine sph_api_require_model_built(ierr) integer, intent(out) :: ierr ierr = SPH_SUCCESS if (.not. sph_api_model_built) then call sph_error_set(SPH_ERROR_STATE, 'SPHLite model is not built') ierr = SPH_ERROR_STATE end if end subroutine sph_api_require_model_built end module sph_api subroutine sphft_initialize(ierr) use sph_api, only: sph_initialize implicit none integer, intent(out) :: ierr call sph_initialize(ierr) end subroutine sphft_initialize subroutine sphft_finalize(ierr) use sph_api, only: sph_finalize implicit none integer, intent(out) :: ierr call sph_finalize(ierr) end subroutine sphft_finalize subroutine sphft_get_version(major, minor, patch, ierr) use sph_api, only: sph_get_version implicit none integer, intent(out) :: major integer, intent(out) :: minor integer, intent(out) :: patch integer, intent(out) :: ierr call sph_get_version(major, minor, patch, ierr) end subroutine sphft_get_version subroutine sphft_get_last_error_chars(code, chars, capacity, actual, ierr) use sph_api, only: sph_get_last_error use sph_error, only: SPH_SUCCESS implicit none integer, intent(out) :: code integer, intent(out) :: chars(*) integer, intent(in) :: capacity integer, intent(out) :: actual integer, intent(out) :: ierr character(len=256) :: message integer :: i integer :: n call sph_get_last_error(code, message, ierr) if (capacity <= 0) return n = len_trim(message) if (n > capacity - 1) n = capacity - 1 actual = n do i = 1, n chars(i) = ichar(message(i:i)) end do if (capacity > n) chars(n+1) = 0 ierr = SPH_SUCCESS end subroutine sphft_get_last_error_chars subroutine sphft_read_inp_chars(chars, count, ierr) use sph_api, only: sph_read_inp implicit none integer, intent(in) :: chars(*) integer, intent(in) :: count integer, intent(out) :: ierr character(len=1024) :: filename integer :: i integer :: n filename = ' ' n = count if (n > len(filename)) n = len(filename) do i = 1, n filename(i:i) = char(chars(i)) end do call sph_read_inp(filename(1:n), ierr) end subroutine sphft_read_inp_chars subroutine sphft_build_model(ierr) use sph_api, only: sph_build_model implicit none integer, intent(out) :: ierr call sph_build_model(ierr) end subroutine sphft_build_model subroutine sphft_estimate_stable_dt(dtcrit, ierr) use sph_api, only: sph_estimate_stable_dt use sph_precision, only: rk implicit none real(rk), intent(out) :: dtcrit integer, intent(out) :: ierr call sph_estimate_stable_dt(dtcrit, ierr) end subroutine sphft_estimate_stable_dt subroutine sphft_advance_explicit(dt, ierr) use sph_api, only: sph_advance_explicit use sph_precision, only: rk implicit none real(rk), intent(in) :: dt integer, intent(out) :: ierr call sph_advance_explicit(dt, ierr) end subroutine sphft_advance_explicit subroutine sphft_run_explicit(ierr) use sph_api, only: sph_run_explicit implicit none integer, intent(out) :: ierr call sph_run_explicit(ierr) end subroutine sphft_run_explicit subroutine sphft_get_current_time(time, step, ierr) use sph_api, only: sph_get_current_time use sph_precision, only: rk implicit none real(rk), intent(out) :: time integer, intent(out) :: step integer, intent(out) :: ierr call sph_get_current_time(time, step, ierr) end subroutine sphft_get_current_time subroutine sphft_get_particle_count(count, ierr) use sph_api, only: sph_get_particle_count implicit none integer, intent(out) :: count integer, intent(out) :: ierr call sph_get_particle_count(count, ierr) end subroutine sphft_get_particle_count subroutine sphft_get_particle_state_capacity(count, ndim, ierr) use sph_api, only: sph_get_particle_state_capacity implicit none integer, intent(out) :: count integer, intent(out) :: ndim integer, intent(out) :: ierr call sph_get_particle_state_capacity(count, ndim, ierr) end subroutine sphft_get_particle_state_capacity subroutine sphft_get_particle_state(max_particles, particle_id_ext, phase, & status, material_id, section_id, x, v, a, rho, pressure, & internal_energy, temperature, h, count, ierr) use sph_api, only: sph_get_particle_state use sph_precision, only: rk implicit none integer, intent(in) :: max_particles integer, intent(out) :: particle_id_ext(max_particles) integer, intent(out) :: phase(max_particles) integer, intent(out) :: status(max_particles) integer, intent(out) :: material_id(max_particles) integer, intent(out) :: section_id(max_particles) real(rk), intent(out) :: x(3,max_particles) real(rk), intent(out) :: v(3,max_particles) real(rk), intent(out) :: a(3,max_particles) real(rk), intent(out) :: rho(max_particles) real(rk), intent(out) :: pressure(max_particles) real(rk), intent(out) :: internal_energy(max_particles) real(rk), intent(out) :: temperature(max_particles) real(rk), intent(out) :: h(max_particles) integer, intent(out) :: count integer, intent(out) :: ierr call sph_get_particle_state(max_particles, particle_id_ext, phase, & status, material_id, section_id, x, v, a, rho, pressure, & internal_energy, temperature, h, count, ierr) end subroutine sphft_get_particle_state subroutine sphft_get_water_summary(mass, momentum, max_pressure, & min_density, max_density, ierr) use sph_api, only: sph_get_water_summary use sph_precision, only: rk implicit none real(rk), intent(out) :: mass real(rk), intent(out) :: momentum(3) real(rk), intent(out) :: max_pressure real(rk), intent(out) :: min_density real(rk), intent(out) :: max_density integer, intent(out) :: ierr call sph_get_water_summary(mass, momentum, max_pressure, min_density, & max_density, ierr) end subroutine sphft_get_water_summary subroutine sphft_get_water_dt_limits(dt_cfl, dt_accel, dt_viscous, ierr) use sph_api, only: sph_get_water_dt_limits use sph_precision, only: rk implicit none real(rk), intent(out) :: dt_cfl real(rk), intent(out) :: dt_accel real(rk), intent(out) :: dt_viscous integer, intent(out) :: ierr call sph_get_water_dt_limits(dt_cfl, dt_accel, dt_viscous, ierr) end subroutine sphft_get_water_dt_limits subroutine sphft_get_gas_summary(volume, center, mean_pressure, max_pressure, ierr) use sph_api, only: sph_get_gas_summary use sph_precision, only: rk implicit none real(rk), intent(out) :: volume real(rk), intent(out) :: center(3) real(rk), intent(out) :: mean_pressure real(rk), intent(out) :: max_pressure integer, intent(out) :: ierr call sph_get_gas_summary(volume, center, mean_pressure, max_pressure, ierr) end subroutine sphft_get_gas_summary subroutine sphft_get_gas_bubble_metrics(equivalent_radius, radius_rate, center, ierr) use sph_api, only: sph_get_gas_bubble_metrics use sph_precision, only: rk implicit none real(rk), intent(out) :: equivalent_radius real(rk), intent(out) :: radius_rate real(rk), intent(out) :: center(3) integer, intent(out) :: ierr call sph_get_gas_bubble_metrics(equivalent_radius, radius_rate, center, ierr) end subroutine sphft_get_gas_bubble_metrics subroutine sphft_get_gas_dt_limits(dt_cfl, dt_accel, dtcrit, ierr) use sph_api, only: sph_get_gas_dt_limits use sph_precision, only: rk implicit none real(rk), intent(out) :: dt_cfl real(rk), intent(out) :: dt_accel real(rk), intent(out) :: dtcrit integer, intent(out) :: ierr call sph_get_gas_dt_limits(dt_cfl, dt_accel, dtcrit, ierr) end subroutine sphft_get_gas_dt_limits subroutine sphft_get_gas_extended_summary(mass, momentum, density_range, & dt_limits, ierr) use sph_api, only: sph_get_gas_extended_summary use sph_precision, only: rk implicit none real(rk), intent(out) :: mass real(rk), intent(out) :: momentum(3) real(rk), intent(out) :: density_range(2) real(rk), intent(out) :: dt_limits(3) integer, intent(out) :: ierr call sph_get_gas_extended_summary(mass, momentum, density_range, & dt_limits, ierr) end subroutine sphft_get_gas_extended_summary subroutine sphft_get_gas_source_summary(mass_source, momentum_source, & energy_source, ierr) use sph_api, only: sph_get_gas_source_summary use sph_precision, only: rk implicit none real(rk), intent(out) :: mass_source real(rk), intent(out) :: momentum_source(3) real(rk), intent(out) :: energy_source integer, intent(out) :: ierr call sph_get_gas_source_summary(mass_source, momentum_source, & energy_source, ierr) end subroutine sphft_get_gas_source_summary subroutine sphft_set_ignition_point(x_value, y_value, z_value, time_value, ierr) use sph_api, only: sph_set_ignition_point use sph_precision, only: rk implicit none real(rk), intent(in) :: x_value real(rk), intent(in) :: y_value real(rk), intent(in) :: z_value real(rk), intent(in) :: time_value integer, intent(out) :: ierr call sph_set_ignition_point(x_value, y_value, z_value, time_value, ierr) end subroutine sphft_set_ignition_point subroutine sphft_get_explosive_summary(particle_count, reacted_count, & lambda_range, released_totals, detonation_time_range, ierr) use sph_api, only: sph_get_explosive_summary use sph_precision, only: rk implicit none integer, intent(out) :: particle_count integer, intent(out) :: reacted_count real(rk), intent(out) :: lambda_range(3) real(rk), intent(out) :: released_totals(5) real(rk), intent(out) :: detonation_time_range(2) integer, intent(out) :: ierr call sph_get_explosive_summary(particle_count, reacted_count, & lambda_range, released_totals, detonation_time_range, ierr) end subroutine sphft_get_explosive_summary subroutine sphft_set_output_directory_chars(chars, count, ierr) use sph_api, only: sph_set_output_directory implicit none integer, intent(in) :: chars(*) integer, intent(in) :: count integer, intent(out) :: ierr character(len=1024) :: directory integer :: i integer :: n directory = ' ' n = count if (n > len(directory)) n = len(directory) do i = 1, n directory(i:i) = char(chars(i)) end do call sph_set_output_directory(directory(1:n), ierr) end subroutine sphft_set_output_directory_chars subroutine sphft_set_output_interval(interval, ierr) use sph_api, only: sph_set_output_interval implicit none integer, intent(in) :: interval integer, intent(out) :: ierr call sph_set_output_interval(interval, ierr) end subroutine sphft_set_output_interval subroutine sphft_write_output(step, time, ierr) use sph_api, only: sph_write_output use sph_precision, only: rk implicit none integer, intent(in) :: step real(rk), intent(in) :: time integer, intent(out) :: ierr call sph_write_output(step, time, ierr) end subroutine sphft_write_output subroutine sphft_get_input_warning_count(count, ierr) use sph_api, only: sph_get_input_warning_count implicit none integer, intent(out) :: count integer, intent(out) :: ierr call sph_get_input_warning_count(count, ierr) end subroutine sphft_get_input_warning_count subroutine sphft_write_csv_chars(chars, count, ierr) use sph_api, only: sph_write_csv implicit none integer, intent(in) :: chars(*) integer, intent(in) :: count integer, intent(out) :: ierr character(len=1024) :: filename integer :: i integer :: n filename = ' ' n = count if (n > len(filename)) n = len(filename) do i = 1, n filename(i:i) = char(chars(i)) end do call sph_write_csv(filename(1:n), ierr) end subroutine sphft_write_csv_chars subroutine sphft_write_restart_chars(chars, count, ierr) use sph_api, only: sph_write_restart implicit none integer, intent(in) :: chars(*) integer, intent(in) :: count integer, intent(out) :: ierr character(len=1024) :: filename integer :: i integer :: n filename = ' ' n = count if (n > len(filename)) n = len(filename) do i = 1, n filename(i:i) = char(chars(i)) end do call sph_write_restart(filename(1:n), ierr) end subroutine sphft_write_restart_chars subroutine sphft_read_restart_chars(chars, count, ierr) use sph_api, only: sph_read_restart implicit none integer, intent(in) :: chars(*) integer, intent(in) :: count integer, intent(out) :: ierr character(len=1024) :: filename integer :: i integer :: n filename = ' ' n = count if (n > len(filename)) n = len(filename) do i = 1, n filename(i:i) = char(chars(i)) end do call sph_read_restart(filename(1:n), ierr) end subroutine sphft_read_restart_chars