[Dart-dev] [6984] DART/trunk/utilities/utilities_mod.f90: found a few other changes to the utilities mod that
nancy at ucar.edu
nancy at ucar.edu
Tue May 6 10:31:10 MDT 2014
Revision: 6984
Author: nancy
Date: 2014-05-06 10:31:09 -0600 (Tue, 06 May 2014)
Log Message:
-----------
found a few other changes to the utilities mod that
should have been in the last commit. includes:
1) call close_file() instead of just "close"
2) add missing argument to an error_handler() call (was
missing subroutine name)
3) fix output from close_file() to be more informative
in case the status cannot be determined.
4) fix comments about rewind vs backspace in the
find_namelist_in_file() routine
Modified Paths:
--------------
DART/trunk/utilities/utilities_mod.f90
-------------- next part --------------
Modified: DART/trunk/utilities/utilities_mod.f90
===================================================================
--- DART/trunk/utilities/utilities_mod.f90 2014-05-06 16:17:51 UTC (rev 6983)
+++ DART/trunk/utilities/utilities_mod.f90 2014-05-06 16:31:09 UTC (rev 6984)
@@ -441,9 +441,9 @@
endif
endif
- close(logfileunit)
+ call close_file(logfileunit)
if ((nmlfileunit /= logfileunit) .and. (nmlfileunit /= -1)) then
- close(nmlfileunit)
+ call close_file(nmlfileunit)
endif
module_initialized = .false.
@@ -999,7 +999,7 @@
if (rc /= 0) then
write(msgstring,*)'Cannot open file "'//trim(fname)//'" for '//trim(act)
- call error_handler(E_ERR, msgstring, source, revision, revdate)
+ call error_handler(E_ERR, 'open_file: ', msgstring, source, revision, revdate)
endif
endif
@@ -1280,8 +1280,9 @@
subroutine close_file(iunit)
!-----------------------------------------------------------------------
!
-! Closes the given unit_number. If the file is already closed,
-! nothing happens. Pretty dramatic, eh?
+! Closes the given unit_number if that unit is open.
+! Not an error to call on an already closed unit.
+! Will print a message if the status of the unit cannot be determined.
!
integer, intent(in) :: iunit
@@ -1293,9 +1294,8 @@
inquire (unit=iunit, opened=open, iostat=ios)
if ( ios /= 0 ) then
- print *,'Dagnabbit. Cannot inquire about unit # ',iunit
- print *,'Error status was ',ios
- print *,'Hoping for the best and continuing.'
+ write(msgstring,*)'Unable to determine status of file unit ', iunit
+ call error_handler(E_MSG, 'close_file: ', msgstring, source, revision, revdate)
endif
if (open) close(iunit)
@@ -1313,14 +1313,14 @@
! Opens namelist_file_name if it exists on unit iunit, error if it
! doesn't exist.
! Searches file for a line containing ONLY the string
-! &nml_name, for instance &filter_nml. If found, rewinds the file and
+! &nml_name, for instance &filter_nml. If found, backs up one record and
! returns true. Otherwise, error message and terminates
!
-character(len=*), intent(in) :: namelist_file_name
-character(len=*), intent(in) :: nml_name
-integer, intent(out) :: iunit
-logical, intent(in), optional :: write_to_logfile_in
+character(len=*), intent(in) :: namelist_file_name
+character(len=*), intent(in) :: nml_name
+integer, intent(out) :: iunit
+logical, optional, intent(in) :: write_to_logfile_in
character(len=256) :: nml_string, test_string, string1
integer :: io
More information about the Dart-dev
mailing list