555 lines
21 KiB
Fortran
555 lines
21 KiB
Fortran
program test_particle_config_suite
|
|
use fem_precision
|
|
use fem_error
|
|
use fem_particle_config_suite
|
|
use fem_particle_config_suite_audit
|
|
use fem_particle_config_run
|
|
use fem_particle_config_check
|
|
implicit none
|
|
|
|
call check_report_parse_keyword()
|
|
call check_report_parse_data()
|
|
call check_manual_suite_run()
|
|
call check_file_suite_run()
|
|
call check_audit()
|
|
call check_audit_errors()
|
|
call check_default_check()
|
|
call check_failing_check()
|
|
call check_output_controls()
|
|
call check_error_paths()
|
|
|
|
contains
|
|
|
|
subroutine check_report_parse_keyword()
|
|
type(particle_suite_report) :: report
|
|
logical :: write_history
|
|
logical :: write_check
|
|
character(len=256) :: history_file
|
|
character(len=256) :: check_file
|
|
integer :: ierr
|
|
|
|
call psuite_report_reset(report)
|
|
call psuite_parse_report('*PARTICLE REPORT, ' // &
|
|
'HISTORY=particle_suite_hist.tmp, ' // &
|
|
'CHECK=particle_suite_check.tmp', &
|
|
report, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(10)
|
|
call psuite_report_values(report, write_history, history_file, &
|
|
write_check, check_file, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(11)
|
|
if (.not. write_history .or. .not. write_check) call fail(12)
|
|
if (trim(history_file) .ne. 'particle_suite_hist.tmp') call fail(13)
|
|
if (trim(check_file) .ne. 'particle_suite_check.tmp') call fail(14)
|
|
|
|
call psuite_parse_report('*PARTICLE REPORT, WRITE_HISTORY=NO, ' // &
|
|
'WRITE_CHECK=YES, CHECK=check_only.tmp', &
|
|
report, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(15)
|
|
call psuite_report_values(report, write_history, history_file, &
|
|
write_check, check_file, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(16)
|
|
if (write_history) call fail(17)
|
|
if (.not. write_check) call fail(18)
|
|
if (trim(check_file) .ne. 'check_only.tmp') call fail(19)
|
|
end subroutine check_report_parse_keyword
|
|
|
|
subroutine check_report_parse_data()
|
|
type(particle_suite_report) :: report
|
|
logical :: write_history
|
|
logical :: write_check
|
|
character(len=256) :: history_file
|
|
character(len=256) :: check_file
|
|
integer :: ierr
|
|
|
|
call psuite_report_reset(report)
|
|
call psuite_parse_report('REPORT, data_hist.tmp, data_check.tmp, 1, 0', &
|
|
report, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(40)
|
|
call psuite_report_values(report, write_history, history_file, &
|
|
write_check, check_file, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(41)
|
|
if (.not. write_history) call fail(42)
|
|
if (write_check) call fail(43)
|
|
if (trim(history_file) .ne. 'data_hist.tmp') call fail(44)
|
|
if (trim(check_file) .ne. 'data_check.tmp') call fail(45)
|
|
|
|
call psuite_set_history_file(report, 'manual_hist.tmp', ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(46)
|
|
call psuite_set_check_file(report, 'manual_check.tmp', ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(47)
|
|
call psuite_report_values(report, write_history, history_file, &
|
|
write_check, check_file, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(48)
|
|
if (.not. write_history .or. .not. write_check) call fail(49)
|
|
if (trim(history_file) .ne. 'manual_hist.tmp') call fail(50)
|
|
if (trim(check_file) .ne. 'manual_check.tmp') call fail(51)
|
|
end subroutine check_report_parse_data
|
|
|
|
subroutine check_manual_suite_run()
|
|
type(particle_suite_state) :: state
|
|
logical :: has_config
|
|
logical :: has_run
|
|
logical :: has_check
|
|
logical :: has_report
|
|
logical :: executed
|
|
logical :: checked
|
|
logical :: outputs_written
|
|
logical :: passed
|
|
integer :: ierr
|
|
integer :: final_step
|
|
integer :: records
|
|
integer :: failures
|
|
character(len=320) :: line
|
|
|
|
call psuite_reset(state)
|
|
call add_suite_lines(state, .true., .true., ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(80)
|
|
call psuite_flags(state, has_config, has_run, has_check, has_report, &
|
|
executed, checked, outputs_written, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(81)
|
|
if (.not. has_config .or. .not. has_run) call fail(82)
|
|
if (.not. has_check .or. .not. has_report) call fail(83)
|
|
if (executed .or. checked .or. outputs_written) call fail(84)
|
|
|
|
call psuite_execute(state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(85)
|
|
call psuite_summary(state, passed, final_step, records, failures, &
|
|
outputs_written, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(86)
|
|
if (.not. passed) call fail(87)
|
|
if (final_step .ne. 3 .or. records .ne. 3) call fail(88)
|
|
if (failures .ne. 0) call fail(89)
|
|
if (outputs_written) call fail(90)
|
|
call psuite_result_line(state, line, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(91)
|
|
if (index(line, 'final_step=3') .ne. 1) call fail(92)
|
|
if (index(line, 'passed=T') .le. 0) call fail(93)
|
|
end subroutine check_manual_suite_run
|
|
|
|
subroutine check_file_suite_run()
|
|
type(particle_suite_state) :: state
|
|
logical :: passed
|
|
logical :: outputs_written
|
|
integer :: ierr
|
|
integer :: final_step
|
|
integer :: records
|
|
integer :: failures
|
|
|
|
call write_suite_file(.true., .true., .true., ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(120)
|
|
call psuite_run_file('particle_suite_case.tmp', state, ierr)
|
|
call delete_suite_file()
|
|
if (ierr .ne. FEM_SUCCESS) call fail(121)
|
|
call psuite_summary(state, passed, final_step, records, failures, &
|
|
outputs_written, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(122)
|
|
if (.not. passed .or. failures .ne. 0) call fail(123)
|
|
if (final_step .ne. 3 .or. records .ne. 3) call fail(124)
|
|
if (.not. outputs_written) call fail(125)
|
|
call require_file_lines('particle_suite_hist.tmp', 5, 126)
|
|
call require_file_lines('particle_suite_check.tmp', 2, 127)
|
|
call delete_output_files()
|
|
end subroutine check_file_suite_run
|
|
|
|
subroutine check_audit()
|
|
type(particle_suite_state) :: state
|
|
type(particle_suite_audit) :: audit
|
|
character(len=192) :: line
|
|
real(rk) :: score
|
|
logical :: passed
|
|
logical :: requested
|
|
logical :: written
|
|
logical :: hist_req
|
|
logical :: check_req
|
|
logical :: publishable
|
|
integer :: ierr
|
|
integer :: final_step
|
|
integer :: records
|
|
integer :: failures
|
|
integer :: grade
|
|
|
|
call psuite_reset(state)
|
|
call add_suite_lines(state, .true., .true., ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(135)
|
|
call psaudit_collect(state, audit, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(136)
|
|
if (.not. audit%has_config .or. .not. audit%has_run) call fail(137)
|
|
if (.not. audit%outputs_requested) call fail(138)
|
|
if (audit%executed .or. audit%checked) call fail(139)
|
|
call psaudit_require_passed(audit, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(140)
|
|
call psaudit_require_ready(audit, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(160)
|
|
|
|
call psuite_execute(state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(141)
|
|
call psaudit_collect(state, audit, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(142)
|
|
if (.not. audit%passed) call fail(143)
|
|
if (audit%outputs_written) call fail(144)
|
|
call psaudit_require_passed(audit, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(145)
|
|
call psaudit_require_ready(audit, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(161)
|
|
call psaudit_require_outputs(audit, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(146)
|
|
call psaudit_score(audit, score, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(147)
|
|
if (score .lt. 5.0_rk) call fail(148)
|
|
call psaudit_grade(audit, grade, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(170)
|
|
if (grade .ne. PSAUDIT_PASSED) call fail(171)
|
|
call psaudit_grade_name(grade, line, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(172)
|
|
if (trim(line) .ne. 'passed') call fail(173)
|
|
call psaudit_is_publishable(audit, publishable, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(180)
|
|
if (publishable) call fail(181)
|
|
call psaudit_summary(audit, passed, final_step, records, failures, &
|
|
score, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(162)
|
|
if (.not. passed .or. final_step .ne. 3) call fail(163)
|
|
if (records .ne. 3 .or. failures .ne. 0) call fail(164)
|
|
call psaudit_output_status(audit, requested, written, hist_req, &
|
|
check_req, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(165)
|
|
if (.not. requested .or. written) call fail(166)
|
|
if (.not. hist_req .or. .not. check_req) call fail(167)
|
|
|
|
call psuite_write_outputs(state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(149)
|
|
call psaudit_collect(state, audit, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(150)
|
|
if (.not. audit%outputs_written) call fail(151)
|
|
call psaudit_grade(audit, grade, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(174)
|
|
if (grade .ne. PSAUDIT_PUBLISHED) call fail(175)
|
|
call psaudit_is_publishable(audit, publishable, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(182)
|
|
if (.not. publishable) call fail(183)
|
|
call psaudit_counts(audit, final_step, records, failures, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(176)
|
|
if (final_step .ne. 3 .or. records .ne. 3) call fail(177)
|
|
if (failures .ne. 0) call fail(178)
|
|
call psaudit_require_outputs(audit, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(152)
|
|
call psaudit_header(line, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(153)
|
|
if (index(line, 'passed,final_step') .ne. 1) call fail(154)
|
|
call psaudit_csv_line(audit, line, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(155)
|
|
if (index(line, '1,3,3') .ne. 1) call fail(156)
|
|
call psaudit_line(audit, line, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(157)
|
|
if (index(line, 'passed=T') .ne. 1) call fail(158)
|
|
call psaudit_line(audit, line(1:8), ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(159)
|
|
call psaudit_write_file('particle_suite_audit.tmp', audit, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(168)
|
|
call require_file_lines('particle_suite_audit.tmp', 2, 169)
|
|
call psaudit_grade_name(-1, line, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(179)
|
|
call delete_output_files()
|
|
call delete_audit_file()
|
|
end subroutine check_audit
|
|
|
|
subroutine check_audit_errors()
|
|
type(particle_suite_audit) :: audit
|
|
character(len=32) :: name
|
|
logical :: publishable
|
|
integer :: ierr
|
|
|
|
call psaudit_reset(audit)
|
|
call psaudit_require_ready(audit, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(190)
|
|
call psaudit_require_outputs(audit, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(191)
|
|
call psaudit_is_publishable(audit, publishable, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(192)
|
|
if (publishable) call fail(193)
|
|
call psaudit_grade_name(99, name, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(194)
|
|
end subroutine check_audit_errors
|
|
|
|
subroutine check_default_check()
|
|
type(particle_suite_state) :: state
|
|
logical :: passed
|
|
logical :: outputs_written
|
|
integer :: ierr
|
|
integer :: final_step
|
|
integer :: records
|
|
integer :: failures
|
|
|
|
call psuite_reset(state)
|
|
call add_suite_lines(state, .false., .false., ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(150)
|
|
call psuite_execute(state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(151)
|
|
call psuite_summary(state, passed, final_step, records, failures, &
|
|
outputs_written, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(152)
|
|
if (.not. passed .or. failures .ne. 0) call fail(153)
|
|
if (final_step .ne. 3 .or. records .ne. 3) call fail(154)
|
|
if (outputs_written) call fail(155)
|
|
end subroutine check_default_check
|
|
|
|
subroutine check_failing_check()
|
|
type(particle_suite_state) :: state
|
|
logical :: passed
|
|
logical :: outputs_written
|
|
integer :: ierr
|
|
integer :: final_step
|
|
integer :: records
|
|
integer :: failures
|
|
character(len=320) :: line
|
|
|
|
call psuite_reset(state)
|
|
call add_config_and_run(state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(180)
|
|
call psuite_parse_line('*PARTICLE CHECK, MAX_OVERLAP=0.01', state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(181)
|
|
call psuite_execute(state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(182)
|
|
call psuite_summary(state, passed, final_step, records, failures, &
|
|
outputs_written, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(183)
|
|
if (passed) call fail(184)
|
|
if (failures .le. 0) call fail(185)
|
|
call psuite_result_line(state, line, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(186)
|
|
if (index(line, 'first_code=overlap') .le. 0) call fail(187)
|
|
end subroutine check_failing_check
|
|
|
|
subroutine check_output_controls()
|
|
type(particle_suite_state) :: state
|
|
integer :: ierr
|
|
|
|
call psuite_reset(state)
|
|
call add_suite_lines(state, .true., .false., ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(210)
|
|
call psuite_parse_line('*PARTICLE REPORT, ' // &
|
|
'HISTORY=particle_suite_hist.tmp, ' // &
|
|
'WRITE_CHECK=NO', state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(216)
|
|
call psuite_write_outputs(state, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(211)
|
|
call psuite_execute(state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(212)
|
|
call psuite_write_outputs(state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(213)
|
|
call require_file_lines('particle_suite_hist.tmp', 5, 214)
|
|
call expect_missing('particle_suite_check.tmp', 215)
|
|
call delete_output_files()
|
|
end subroutine check_output_controls
|
|
|
|
subroutine check_error_paths()
|
|
type(particle_suite_state) :: state
|
|
type(particle_suite_report) :: report
|
|
logical :: passed
|
|
logical :: outputs_written
|
|
integer :: ierr
|
|
integer :: final_step
|
|
integer :: records
|
|
integer :: failures
|
|
character(len=8) :: short_text
|
|
|
|
call psuite_reset(state)
|
|
call psuite_execute(state, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(240)
|
|
call psuite_parse_line('*PARTICLE UNKNOWN, A=1', state, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(241)
|
|
call psuite_load_file('missing_particle_suite.tmp', state, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(242)
|
|
call psuite_summary(state, passed, final_step, records, failures, &
|
|
outputs_written, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(243)
|
|
call psuite_result_line(state, short_text, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(244)
|
|
|
|
call psuite_report_reset(report)
|
|
call psuite_parse_report('REPORT, only_one_file.tmp', report, ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(245)
|
|
call psuite_set_history_file(report, '', ierr)
|
|
if (ierr .eq. FEM_SUCCESS) call fail(246)
|
|
call psuite_validate_report(report, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(247)
|
|
end subroutine check_error_paths
|
|
|
|
subroutine add_suite_lines(state, with_check, with_report, ierr)
|
|
type(particle_suite_state), intent(inout) :: state
|
|
logical, intent(in) :: with_check
|
|
logical, intent(in) :: with_report
|
|
integer, intent(out) :: ierr
|
|
|
|
call add_config_and_run(state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
if (with_check) then
|
|
call psuite_parse_line('*PARTICLE CHECK, MIN_RECORDS=3, ' // &
|
|
'MAX_RECORDS=3, MIN_FINAL_STEP=3, ' // &
|
|
'MAX_FINAL_STEP=3, STOP=NONE, ' // &
|
|
'MIN_ACTIVE=8, MIN_GENERATED=8, ' // &
|
|
'MIN_CONTACTS=4, MIN_PEAK_CONTACTS=4, ' // &
|
|
'MAX_OVERLAP=1, MAX_ENERGY=1000', &
|
|
state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
end if
|
|
if (with_report) then
|
|
call psuite_parse_line('*PARTICLE REPORT, ' // &
|
|
'HISTORY=particle_suite_hist.tmp, ' // &
|
|
'CHECK=particle_suite_check.tmp', state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
end if
|
|
call error_clear(ierr)
|
|
end subroutine add_suite_lines
|
|
|
|
subroutine add_config_and_run(state, ierr)
|
|
type(particle_suite_state), intent(inout) :: state
|
|
integer, intent(out) :: ierr
|
|
|
|
call psuite_parse_line('*PARTICLE RUN, STEPS=3, OUTPUT=1, RESET=YES', &
|
|
state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call psuite_parse_line('*PARTICLE CLOUD, ID=1, XMIN=0, YMIN=0, ' // &
|
|
'ZMIN=0, XMAX=2, YMAX=2, ZMAX=2, ' // &
|
|
'RADIUS=0.5, DENSITY=1, SPACING=1, ' // &
|
|
'STAGGER=NO', state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call psuite_parse_line('*PARTICLE CONTACT, KN=1000, CN=0, KT=0, ' // &
|
|
'MU=0, KWALL=1000, CWALL=0', state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call psuite_parse_line('*PARTICLE STEP, DT=0.001, DAMPING=0, ' // &
|
|
'SEARCH=0, GX=0, GY=0, GZ=0, CELL=1', &
|
|
state, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
call psuite_parse_line('*PARTICLE WALL, PX=0, PY=0, PZ=0.2, ' // &
|
|
'NX=0, NY=0, NZ=1', state, ierr)
|
|
end subroutine add_config_and_run
|
|
|
|
subroutine write_suite_file(with_check, with_report, outputs, ierr)
|
|
logical, intent(in) :: with_check
|
|
logical, intent(in) :: with_report
|
|
logical, intent(in) :: outputs
|
|
integer, intent(out) :: ierr
|
|
|
|
integer :: unit
|
|
integer :: ios
|
|
|
|
unit = 70
|
|
open(unit=unit, file='particle_suite_case.tmp', status='unknown', &
|
|
action='write', iostat=ios)
|
|
if (ios .ne. 0) then
|
|
call error_set(FEM_ERR_OUTPUT, 'failed to write particle suite case', &
|
|
ierr)
|
|
return
|
|
end if
|
|
write(unit, '(A)') '# temporary particle suite case'
|
|
write(unit, '(A)') '*PARTICLE RUN, STEPS=3, OUTPUT=1, RESET=YES'
|
|
write(unit, '(A)') '*PARTICLE CLOUD, ID=1, XMIN=0, YMIN=0, ' // &
|
|
'ZMIN=0, XMAX=2, YMAX=2, ZMAX=2, ' // &
|
|
'RADIUS=0.5, DENSITY=1, SPACING=1, STAGGER=NO'
|
|
write(unit, '(A)') '*PARTICLE CONTACT, KN=1000, CN=0, KT=0, ' // &
|
|
'MU=0, KWALL=1000, CWALL=0'
|
|
write(unit, '(A)') '*PARTICLE STEP, DT=0.001, DAMPING=0, ' // &
|
|
'SEARCH=0, GX=0, GY=0, GZ=0, CELL=1'
|
|
write(unit, '(A)') '*PARTICLE WALL, PX=0, PY=0, PZ=0.2, ' // &
|
|
'NX=0, NY=0, NZ=1'
|
|
if (with_check) then
|
|
write(unit, '(A)') '*PARTICLE CHECK, MIN_RECORDS=3, MAX_RECORDS=3, ' // &
|
|
'STOP=NONE, MIN_ACTIVE=8, MIN_CONTACTS=4, ' // &
|
|
'MIN_PEAK_CONTACTS=4, MAX_OVERLAP=1, ' // &
|
|
'MAX_ENERGY=1000'
|
|
end if
|
|
if (with_report) then
|
|
if (outputs) then
|
|
write(unit, '(A)') '*PARTICLE REPORT, ' // &
|
|
'HISTORY=particle_suite_hist.tmp, ' // &
|
|
'CHECK=particle_suite_check.tmp'
|
|
else
|
|
write(unit, '(A)') '*PARTICLE REPORT, WRITE_HISTORY=NO, ' // &
|
|
'WRITE_CHECK=NO'
|
|
end if
|
|
end if
|
|
close(unit)
|
|
call error_clear(ierr)
|
|
end subroutine write_suite_file
|
|
|
|
subroutine require_file_lines(filename, expected, code)
|
|
character(len=*), intent(in) :: filename
|
|
integer, intent(in) :: expected
|
|
integer, intent(in) :: code
|
|
|
|
character(len=256) :: line
|
|
integer :: unit
|
|
integer :: ios
|
|
integer :: count
|
|
|
|
unit = 69
|
|
open(unit=unit, file=filename, status='old', action='read', iostat=ios)
|
|
if (ios .ne. 0) call fail(code)
|
|
count = 0
|
|
do
|
|
read(unit, '(A)', iostat=ios) line
|
|
if (ios .lt. 0) exit
|
|
if (ios .gt. 0) call fail(code + 1000)
|
|
count = count + 1
|
|
end do
|
|
close(unit)
|
|
if (count .ne. expected) call fail(code + 2000)
|
|
end subroutine require_file_lines
|
|
|
|
subroutine expect_missing(filename, code)
|
|
character(len=*), intent(in) :: filename
|
|
integer, intent(in) :: code
|
|
|
|
integer :: unit
|
|
integer :: ios
|
|
|
|
unit = 69
|
|
open(unit=unit, file=filename, status='old', action='read', iostat=ios)
|
|
if (ios .eq. 0) then
|
|
close(unit)
|
|
call fail(code)
|
|
end if
|
|
end subroutine expect_missing
|
|
|
|
subroutine delete_suite_file()
|
|
integer :: unit
|
|
integer :: ios
|
|
|
|
unit = 70
|
|
open(unit=unit, file='particle_suite_case.tmp', status='old', iostat=ios)
|
|
if (ios .eq. 0) close(unit, status='delete')
|
|
end subroutine delete_suite_file
|
|
|
|
subroutine delete_output_files()
|
|
integer :: unit
|
|
integer :: ios
|
|
|
|
unit = 69
|
|
open(unit=unit, file='particle_suite_hist.tmp', status='old', iostat=ios)
|
|
if (ios .eq. 0) close(unit, status='delete')
|
|
open(unit=unit, file='particle_suite_check.tmp', status='old', iostat=ios)
|
|
if (ios .eq. 0) close(unit, status='delete')
|
|
end subroutine delete_output_files
|
|
|
|
subroutine delete_audit_file()
|
|
integer :: unit
|
|
integer :: ios
|
|
|
|
unit = 68
|
|
open(unit=unit, file='particle_suite_audit.tmp', status='old', iostat=ios)
|
|
if (ios .eq. 0) close(unit, status='delete')
|
|
end subroutine delete_audit_file
|
|
|
|
subroutine fail(code)
|
|
integer, intent(in) :: code
|
|
|
|
call delete_suite_file()
|
|
call delete_output_files()
|
|
call delete_audit_file()
|
|
write(*,*) 'test_particle_config_suite failed:', code
|
|
stop 1
|
|
end subroutine fail
|
|
|
|
end program test_particle_config_suite
|