program test_input_explosive_errors use sph_error, only: SPH_SUCCESS use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, sph_build_model implicit none call expect_error('tests/data/explosive_bad_velocity_040.inp', 'bad velocity') call expect_error('tests/data/explosive_bad_product_040.inp', 'bad product') call expect_error('tests/data/explosive_bad_ignition_040.inp', 'bad ignition') call expect_error('tests/data/explosive_bad_ignition_time_041.inp', & 'bad ignition time') call expect_error('tests/data/explosive_missing_density_040.inp', 'missing density') call expect_error('tests/data/explosive_bad_burn_time_040.inp', 'bad burn time') call expect_error('tests/data/explosive_bad_energy_040.inp', 'bad energy') call expect_error('tests/data/explosive_product_missing_eos_040.inp', 'missing product EOS') contains subroutine expect_error(filename, label) character(len=*), intent(in) :: filename character(len=*), intent(in) :: label integer :: ierr integer :: final_ierr call sph_initialize(ierr) call assert_ok(ierr, 'initialize failed for ' // label) call sph_read_inp(filename, ierr) if (ierr == SPH_SUCCESS) then call sph_build_model(ierr) end if if (ierr == SPH_SUCCESS) call fail('input unexpectedly passed: ' // label) call sph_finalize(final_ierr) call assert_ok(final_ierr, 'finalize failed for ' // label) end subroutine expect_error subroutine assert_ok(ierr_value, message) integer, intent(in) :: ierr_value character(len=*), intent(in) :: message if (ierr_value /= SPH_SUCCESS) call fail(message) end subroutine assert_ok subroutine fail(message) character(len=*), intent(in) :: message write(*, '(A)') trim(message) stop 1 end subroutine fail end program test_input_explosive_errors