From 1e5ef39e8759180f31eb9d1d0b40ddb43c43fc8e Mon Sep 17 00:00:00 2001 From: Marshall Ward Date: Sun, 2 Jan 2022 18:04:44 -0500 Subject: [PATCH] Finish I/O conversion Tests now use the create/delete_file() functions for scratch files. There are still a few wayward operations happening both within and outside of the tests which need to be handled. --- .../drivers/new_unit/MOM_new_unit_tests.F90 | 6 - .../unit_tests/MOM_file_parser_tests.F90 | 380 ++++++++---------- 2 files changed, 171 insertions(+), 215 deletions(-) diff --git a/config_src/drivers/new_unit/MOM_new_unit_tests.F90 b/config_src/drivers/new_unit/MOM_new_unit_tests.F90 index 343781e5a2..7f8e83295b 100644 --- a/config_src/drivers/new_unit/MOM_new_unit_tests.F90 +++ b/config_src/drivers/new_unit/MOM_new_unit_tests.F90 @@ -314,9 +314,6 @@ program MOM_unit_tests call run_unit_test(test_read_param_real_type_err, fatal=.true.) print '(/a)', "=== call test_read_param_real_array" -open(newunit=param_unit, file=param_filename) -write(param_unit, '(a)') sample_param_name // ' = 1., 2., 3.' -close(param_unit) call run_unit_test(test_read_param_real_array) print '(/a)', "=== call test_read_param_real_array_missing" @@ -329,9 +326,6 @@ program MOM_unit_tests call run_unit_test(test_read_param_real_array_type_err, fatal=.true.) print '(/a)', "=== call test_read_param_real_logical" -open(newunit=param_unit, file=param_filename) -write(param_unit, '(a)') sample_param_name // ' = True' -close(param_unit) call run_unit_test(test_read_param_logical) print '(/a)', "=== call test_read_param_logical_missing" diff --git a/src/framework/unit_tests/MOM_file_parser_tests.F90 b/src/framework/unit_tests/MOM_file_parser_tests.F90 index a5d83d8ee5..2c50194ea5 100644 --- a/src/framework/unit_tests/MOM_file_parser_tests.F90 +++ b/src/framework/unit_tests/MOM_file_parser_tests.F90 @@ -390,10 +390,16 @@ end subroutine test_read_param_real_type_err subroutine test_read_param_real_array type(param_file_type) :: param real :: sample(3) + type(string) :: lines(1) + + lines = string(sample_param_name // ' = 1., 2., 3.') + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) call close_param_file(param) + + call delete_file(param_filename) end subroutine test_read_param_real_array @@ -440,6 +446,10 @@ end subroutine test_read_param_real_array_type_err subroutine test_read_param_logical type(param_file_type) :: param logical :: sample + type(string) :: lines(1) + + lines = string(sample_param_name // ' = True') + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) @@ -705,13 +715,12 @@ end subroutine test_read_param_unused_fatal subroutine test_read_param_replace_tabs type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(1) ! NOTE: tabs precede and follow = character - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') sample_param_name // ' = 1' - close(param_unit) + lines = string(sample_param_name // ' = 1') + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) @@ -722,12 +731,11 @@ end subroutine test_read_param_replace_tabs subroutine test_read_param_pad_equals type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(1) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') sample_param_name // '=1' - close(param_unit) + lines = string(sample_param_name // '=1') + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) @@ -739,13 +747,14 @@ end subroutine test_read_param_pad_equals subroutine test_read_param_multiline_param type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(2) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') sample_param_name // ' = \' - write(param_unit, '(a)') ' 1' - close(param_unit) + lines = [ & + string(sample_param_name // ' = \'), & + string(' 1') & + ] + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) @@ -757,12 +766,11 @@ end subroutine test_read_param_multiline_param subroutine test_read_param_multiline_param_unclosed type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(1) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') sample_param_name // ' = \' - close(param_unit) + lines = string(sample_param_name // ' = \') + call create_file(param_filename, lines) call open_param_file(param_filename, param) ! FATAL; return to program @@ -771,17 +779,19 @@ end subroutine test_read_param_multiline_param_unclosed subroutine test_read_param_multiline_comment type(param_file_type) :: param - integer :: param_unit integer :: sample - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') '/* First C comment line' - write(param_unit, '(a)') ' Second C comment line */' - write(param_unit, '(a)') '// First C++ comment line' - write(param_unit, '(a)') '// Second C++ comment line' - write(param_unit, '(a)') '! First Fortran comment line' - write(param_unit, '(a)') '! Second Fortran comment line' - close(param_unit) + type(string) :: lines(6) + + lines = [ & + string('/* First C comment line'), & + string(' Second C comment line */'), & + string('// First C++ comment line'), & + string('// Second C++ comment line'), & + string('! First Fortran comment line'), & + string('! Second Fortran comment line') & + ] + call create_file(param_filename, lines) call open_param_file(param_filename, param) ! TODO: can I remove read_param? @@ -794,12 +804,11 @@ end subroutine test_read_param_multiline_comment subroutine test_read_param_multiline_comment_unclosed type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(1) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') '/* Unclosed C comment' - close(param_unit) + lines = string('/* Unclosed C comment') + call create_file(param_filename, lines) call open_param_file(param_filename, param) ! FATAL; return to program @@ -808,12 +817,11 @@ end subroutine test_read_param_multiline_comment_unclosed subroutine test_read_param_misplaced_quote type(param_file_type) :: param - integer :: param_unit character(len=20) :: sample + type(string) :: lines(1) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') sample_param_name // ' = "abc' - close(param_unit) + lines = string(sample_param_name // ' = "abc') + call create_file(param_filename, lines) call open_param_file(param_filename, param) ! FATAL; return to program @@ -822,12 +830,11 @@ end subroutine test_read_param_misplaced_quote subroutine test_read_param_define type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(1) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') '#define ' // sample_param_name // ' 2' - close(param_unit) + lines = string('#define ' // sample_param_name // ' 2') + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) @@ -839,12 +846,11 @@ end subroutine test_read_param_define subroutine test_read_param_define_as_flag type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(1) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') '#define ' // sample_param_name - close(param_unit) + lines = string('#define ' // sample_param_name) + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) @@ -856,13 +862,14 @@ end subroutine test_read_param_define_as_flag subroutine test_read_param_override type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(2) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') sample_param_name // ' = 1' - write(param_unit, '(a)') '#override ' // sample_param_name // ' = 2' - close(param_unit) + lines = [ & + string(sample_param_name // ' = 1'), & + string('#override ' // sample_param_name // ' = 2') & + ] + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) @@ -874,12 +881,11 @@ end subroutine test_read_param_override subroutine test_read_param_override_misplaced type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(1) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') '#define #override ' // sample_param_name // ' = 1' - close(param_unit) + lines(1) = string('#define #override ' // sample_param_name // ' = 1') + call create_file(param_filename, lines) call open_param_file(param_filename, param) ! FATAL; return to program @@ -888,14 +894,15 @@ end subroutine test_read_param_override_misplaced subroutine test_read_param_override_twice type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(3) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') sample_param_name // ' = 1' - write(param_unit, '(a)') '#override ' // sample_param_name // ' = 2' - write(param_unit, '(a)') '#override ' // sample_param_name // ' = 3' - close(param_unit) + lines = [ & + string(sample_param_name // ' = 1'), & + string('#override ' // sample_param_name // ' = 2'), & + string('#override ' // sample_param_name // ' = 3') & + ] + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) @@ -905,14 +912,15 @@ end subroutine test_read_param_override_twice subroutine test_read_param_override_repeat type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(3) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') sample_param_name // ' = 1' - write(param_unit, '(a)') '#override ' // sample_param_name // ' = 2' - write(param_unit, '(a)') '#override ' // sample_param_name // ' = 2' - close(param_unit) + lines = [ & + string(sample_param_name // ' = 1'), & + string('#override ' // sample_param_name // ' = 2'), & + string('#override ' // sample_param_name // ' = 2') & + ] + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) @@ -922,16 +930,17 @@ end subroutine test_read_param_override_repeat subroutine test_read_param_override_warn_chain type(param_file_type) :: param - integer :: param_unit integer :: sample character(len=*), parameter :: other_param_name = 'OTHER_PARAMETER' + type(string) :: lines(4) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') other_param_name // ' = 1' - write(param_unit, '(a)') sample_param_name // ' = 2' - write(param_unit, '(a)') '#override ' // other_param_name // ' = 3' - write(param_unit, '(a)') '#override ' // sample_param_name // ' = 4' - close(param_unit) + lines = [ & + string(other_param_name // ' = 1'), & + string(sample_param_name // ' = 2'), & + string('#override ' // other_param_name // ' = 3'), & + string('#override ' // sample_param_name // ' = 4') & + ] + call create_file(param_filename, lines) call open_param_file(param_filename, param) ! First invoke the "other" override, adding it to the chain @@ -948,13 +957,14 @@ end subroutine test_read_param_override_warn_chain subroutine test_read_param_assign_after_override type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(2) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') '#override ' // sample_param_name // ' = 2' - write(param_unit, '(a)') sample_param_name // ' = 3' - close(param_unit) + lines = [ & + string('#override ' // sample_param_name // ' = 2'), & + string(sample_param_name // ' = 3') & + ] + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) @@ -966,13 +976,14 @@ end subroutine test_read_param_assign_after_override subroutine test_read_param_assign_twice type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(2) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') sample_param_name // ' = 1' - write(param_unit, '(a)') sample_param_name // ' = 2' - close(param_unit) + lines = [ & + string(sample_param_name // ' = 1'), & + string(sample_param_name // ' = 2') & + ] + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) @@ -982,13 +993,14 @@ end subroutine test_read_param_assign_twice subroutine test_read_param_assign_repeat type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(2) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') sample_param_name // ' = 1' - write(param_unit, '(a)') sample_param_name // ' = 1' - close(param_unit) + lines = [ & + string(sample_param_name // ' = 1'), & + string(sample_param_name // ' = 1') & + ] + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) @@ -1000,12 +1012,11 @@ end subroutine test_read_param_assign_repeat subroutine test_read_param_null_stmt type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(1) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') sample_param_name - close(param_unit) + lines(1) = string(sample_param_name) + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) @@ -1015,12 +1026,11 @@ end subroutine test_read_param_null_stmt subroutine test_read_param_assign_in_define type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(1) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') '#define ' // sample_param_name // ' = 1' - close(param_unit) + lines = string('#define ' // sample_param_name // ' = 1') + call create_file(param_filename, lines) call open_param_file(param_filename, param) call read_param(param, sample_param_name, sample) @@ -1031,14 +1041,15 @@ end subroutine test_read_param_assign_in_define subroutine test_read_param_block type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(3) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') 'ABC%' - write(param_unit, '(a)') 'ABC%' // sample_param_name // ' = 123' - write(param_unit, '(a)') '%ABC' - close(param_unit) + lines = [ & + string('ABC%'), & + string('ABC%' // sample_param_name // ' = 123'), & + string('%ABC') & + ] + call create_file(param_filename, lines) call open_param_file(param_filename, param) call openParameterBlock(param, 'ABC') @@ -1054,16 +1065,17 @@ end subroutine test_read_param_block ! TODO: This test fails due to an implementation issue. subroutine test_read_param_block_stack type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(5) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') 'ABC%' - write(param_unit, '(a)') 'DEF%' - write(param_unit, '(a)') sample_param_name // ' = 123' - write(param_unit, '(a)') 'DEF%' - write(param_unit, '(a)') '%ABC' - close(param_unit) + lines = [ & + string('ABC%'), & + string('DEF%'), & + string(sample_param_name // ' = 123'), & + string('DEF%'), & + string('%ABC') & + ] + call create_file(param_filename, lines) call open_param_file(param_filename, param) call openParameterBlock(param, 'ABC') @@ -1080,14 +1092,15 @@ end subroutine test_read_param_block_stack ! TODO: This is a simpler version of the block_stack test which works subroutine test_read_param_block_inline_stack type(param_file_type) :: param - integer :: param_unit integer :: sample + type(string) :: lines(3) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') 'ABC%' - write(param_unit, '(a)') 'DEF%' // sample_param_name // ' = 123' - write(param_unit, '(a)') '%ABC' - close(param_unit) + lines = [ & + string('ABC%'), & + string('DEF%' // sample_param_name // ' = 123'), & + string('%ABC') & + ] + call create_file(param_filename, lines) call open_param_file(param_filename, param) call openParameterBlock(param, 'ABC') @@ -1103,10 +1116,8 @@ end subroutine test_read_param_block_inline_stack subroutine test_read_param_block_empty_pop type(param_file_type) :: param - integer :: param_unit - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call openParameterBlock(param, '%') @@ -1119,12 +1130,13 @@ end subroutine test_read_param_block_empty_pop subroutine test_read_param_block_close_unnamed type(param_file_type) :: param - integer :: param_unit + type(string) :: lines(2) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') 'ABC%' - write(param_unit, '(a)') '%ABC' - close(param_unit) + lines = [ & + string('ABC%'), & + string('%ABC') & + ] + call create_file(param_filename, lines) call open_param_file(param_filename, param) call openParameterBlock(param, 'ABC') @@ -1136,11 +1148,10 @@ end subroutine test_read_param_block_close_unnamed subroutine test_read_param_block_close_unopened type(param_file_type) :: param - integer :: param_unit + type(string) :: lines(1) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') '%CBA' - close(param_unit) + lines = string('%CBA') + call create_file(param_filename, lines) call open_param_file(param_filename, param) ! FATAL; return to program @@ -1149,12 +1160,13 @@ end subroutine test_read_param_block_close_unopened subroutine test_read_param_block_unmatched type(param_file_type) :: param - integer :: param_unit + type(string) :: lines(2) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') 'ABC%' - write(param_unit, '(a)') '%CBA' - close(param_unit) + lines = [ & + string('ABC%'), & + string('%CBA') & + ] + call create_file(param_filename, lines) call open_param_file(param_filename, param) ! FATAL; return to program @@ -1189,10 +1201,8 @@ end subroutine test_clear_unallocated_block subroutine test_log_version_cs type(param_file_type) :: param - integer :: param_unit - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call log_version(param, module_name, module_version, desc=module_desc) @@ -1209,12 +1219,10 @@ end subroutine test_log_version_plain subroutine test_log_param_int type(param_file_type) :: param - integer :: param_unit integer, parameter :: sample = 1 character(len=21), parameter :: desc = "Parameter description" - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call log_param(param, module_name, sample_param_name, sample, desc=desc) @@ -1226,12 +1234,10 @@ end subroutine test_log_param_int subroutine test_log_param_int_array type(param_file_type) :: param - integer :: param_unit integer, parameter :: sample(3) = [1, 2, 3] character(len=21), parameter :: desc = "Parameter description" - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call log_param(param, module_name, sample_param_name, sample, desc=desc) @@ -1243,12 +1249,10 @@ end subroutine test_log_param_int_array subroutine test_log_param_real type(param_file_type) :: param - integer :: param_unit real, parameter :: sample = 1. character(len=21), parameter :: desc = "Parameter description" - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call log_param(param, module_name, sample_param_name, sample, desc=desc) @@ -1260,12 +1264,10 @@ end subroutine test_log_param_real subroutine test_log_param_real_array type(param_file_type) :: param - integer :: param_unit real, parameter :: sample(3) = [1., 2., 3.] character(len=21), parameter :: desc = "Parameter description" - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call log_param(param, module_name, sample_param_name, sample, desc=desc) @@ -1277,13 +1279,13 @@ end subroutine test_log_param_real_array subroutine test_log_param_time type(param_file_type) :: param - integer :: param_unit type(time_type) :: sample character(len=21), parameter :: desc = "Parameter description" + type(string) :: lines(1) - open(newunit=param_unit, file=param_filename, status='replace') - write(param_unit, '(a)') sample_param_name // ' = 1980,1,1,0,0,0' - close(param_unit) + lines = string(sample_param_name // ' = 1980,1,1,0,0,0') + + call create_file(param_filename) call set_calendar_type(NOLEAP) call open_param_file(param_filename, param) @@ -1297,12 +1299,10 @@ end subroutine test_log_param_time subroutine test_log_param_time_as_date type(param_file_type) :: param - integer :: param_unit type(time_type) :: sample character(len=21), parameter :: desc = "Parameter description" - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) sample = set_date(1980, 1, 1, 0, 0, 0) @@ -1316,13 +1316,11 @@ end subroutine test_log_param_time_as_date subroutine test_log_param_time_as_date_default type(param_file_type) :: param - integer :: param_unit type(time_type) :: sample type(time_type) :: default_date character(len=21), parameter :: desc = "Parameter description" - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) @@ -1344,12 +1342,10 @@ end subroutine test_log_param_time_as_date_default subroutine test_log_param_time_as_date_tick type(param_file_type) :: param - integer :: param_unit type(time_type) :: sample character(len=21), parameter :: desc = "Parameter description" - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call log_param(param, module_name, sample_param_name, sample, desc=desc, & @@ -1362,14 +1358,12 @@ end subroutine test_log_param_time_as_date_tick subroutine test_log_param_time_with_unit type(param_file_type) :: param - integer :: param_unit type(time_type) :: sample type(time_type) :: default_date character(len=21), parameter :: desc = "Parameter description" character(len=19), parameter :: sample_units = "days since whatever" - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call set_ticks_per_second(60) sample = set_date(1980, 1, 1, 0, 0, 0, 30) @@ -1387,14 +1381,12 @@ end subroutine test_log_param_time_with_unit subroutine test_log_param_time_with_timeunit type(param_file_type) :: param - integer :: param_unit type(time_type) :: sample integer :: i character(len=21), parameter :: desc = "Parameter description" real, parameter :: timeunits(5) = [1., 3600., 86400., 3.1e7, 1e8] - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) do i = 1,5 @@ -1410,11 +1402,9 @@ end subroutine test_log_param_time_with_timeunit subroutine test_get_param_int type(param_file_type) :: param - integer :: param_unit integer :: sample - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample) @@ -1426,11 +1416,9 @@ end subroutine test_get_param_int subroutine test_get_param_int_no_read_no_log type(param_file_type) :: param - integer :: param_unit integer :: sample - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample, & @@ -1443,11 +1431,9 @@ end subroutine test_get_param_int_no_read_no_log subroutine test_get_param_int_array type(param_file_type) :: param - integer :: param_unit integer :: sample(3) - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample) @@ -1459,11 +1445,9 @@ end subroutine test_get_param_int_array subroutine test_get_param_int_array_no_read_no_log type(param_file_type) :: param - integer :: param_unit integer :: sample(3) - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample, & @@ -1476,11 +1460,9 @@ end subroutine test_get_param_int_array_no_read_no_log subroutine test_get_param_real type(param_file_type) :: param - integer :: param_unit real :: sample - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample) @@ -1492,11 +1474,9 @@ end subroutine test_get_param_real subroutine test_get_param_real_no_read_no_log type(param_file_type) :: param - integer :: param_unit real :: sample - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample, & @@ -1509,11 +1489,9 @@ end subroutine test_get_param_real_no_read_no_log subroutine test_get_param_real_array type(param_file_type) :: param - integer :: param_unit real :: sample(3) - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample) @@ -1525,11 +1503,9 @@ end subroutine test_get_param_real_array subroutine test_get_param_real_array_no_read_no_log type(param_file_type) :: param - integer :: param_unit real :: sample(3) - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample, & @@ -1542,11 +1518,9 @@ end subroutine test_get_param_real_array_no_read_no_log subroutine test_get_param_char type(param_file_type) :: param - integer :: param_unit character(len=8) :: sample - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample) @@ -1558,11 +1532,9 @@ end subroutine test_get_param_char subroutine test_get_param_char_no_read_no_log type(param_file_type) :: param - integer :: param_unit character(len=8) :: sample - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample, & @@ -1575,11 +1547,9 @@ end subroutine test_get_param_char_no_read_no_log subroutine test_get_param_char_array type(param_file_type) :: param - integer :: param_unit character(len=8) :: sample(3) - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample) @@ -1591,11 +1561,9 @@ end subroutine test_get_param_char_array subroutine test_get_param_logical type(param_file_type) :: param - integer :: param_unit logical :: sample - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample) @@ -1607,11 +1575,9 @@ end subroutine test_get_param_logical subroutine test_get_param_logical_no_read_no_log type(param_file_type) :: param - integer :: param_unit logical :: sample - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample, & @@ -1624,11 +1590,9 @@ end subroutine test_get_param_logical_no_read_no_log subroutine test_get_param_time type(param_file_type) :: param - integer :: param_unit type(time_type) :: sample - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample) @@ -1640,11 +1604,9 @@ end subroutine test_get_param_time subroutine test_get_param_time_no_read_no_log type(param_file_type) :: param - integer :: param_unit type(time_type) :: sample - open(newunit=param_unit, file=param_filename, status='replace') - close(param_unit) + call create_file(param_filename) call open_param_file(param_filename, param) call get_param(param, module_name, sample_param_name, sample, &