diff --git a/test_fms/mpp/test_read_input_nml.F90 b/test_fms/mpp/test_read_input_nml.F90 index 15e6e4697b..69809c4d28 100644 --- a/test_fms/mpp/test_read_input_nml.F90 +++ b/test_fms/mpp/test_read_input_nml.F90 @@ -36,14 +36,15 @@ program test_read_input_nml integer :: n, m !< Loop counting variable integer :: current_pelist_name_len_plus1 !< Current pelist name length plus 1 integer :: ierr !< used by MPI_FINALIZE +integer :: nml_unit_var !< stores nml file unit number for reads character(len=:), allocatable :: toobig !< String passed as argument into read_input_nml that is !!larger than pelis_name and should raise an error namelist /test_read_input_nml_nml/ test_numb -open(10, file="test_numb.nml", form="formatted", status="old") -read(10, nml = test_read_input_nml_nml) -close(10) +open(newunit=nml_unit_var, file="test_numb.nml", form="formatted", status="old") +read(unit=nml_unit_var, nml = test_read_input_nml_nml) +close(nml_unit_var) call mpp_init(test_level=mpp_init_test_peset_allocated) @@ -64,11 +65,11 @@ program test_read_input_nml filename = "input_alternative.nml" call read_input_nml("alternative") end if - open(1, file=filename, iostat=stat) ! Open input nml or alternative + open(newunit=nml_unit_var, file=filename, iostat=stat) ! Open input nml or alternative n = 1 do - read(1, '(A)', iostat=stat) line - if (stat.eq.-1) then + read(unit=nml_unit_var, '(A)', iostat=stat) line + if (stat < 0) then exit end if if (input_nml_file(n).ne.line) then @@ -77,7 +78,7 @@ program test_read_input_nml end if n = n + 1 end do - close(1) + close(nml_unit_var) else if (test_numb.eq.3) then ! Test 3: Tests with an invalid pelist_name_in pass as an argument. An invalid diff --git a/test_fms/mpp/test_read_input_nml2.sh b/test_fms/mpp/test_read_input_nml2.sh index 5750f641b9..5eb411429b 100755 --- a/test_fms/mpp/test_read_input_nml2.sh +++ b/test_fms/mpp/test_read_input_nml2.sh @@ -31,11 +31,11 @@ # create and enter directory for in/output output_dir -touch input.nml touch test_numb_base.nml echo "&test_read_input_nml_nml" > test_numb_base.nml echo "test_numb = 0" >> test_numb_base.nml echo "/" >> test_numb_base.nml +cp test_numb_base.nml input.nml # Test 1 sed "s/test_numb = [0-9]/test_numb = 1/" test_numb_base.nml > test_numb.nml @@ -45,7 +45,7 @@ test_expect_success "read input nml" ' # Test 2 sed "s/test_numb = [0-9]/test_numb = 2/" test_numb_base.nml > test_numb.nml -sed "s/1/2/" $top_srcdir/test_fms/mpp/input_base.nml > input_alternative.nml +cp input.nml input_alternative.nml test_expect_success "read input nml with file name" ' mpirun -n 1 ../test_read_input_nml '