[Dart-dev] [5902] DART/branches/development/utilities/utilities_mod.f90: Made the line length an optional argument to find_textfile_dims().
nancy at ucar.edu
nancy at ucar.edu
Thu Oct 18 16:24:57 MDT 2012
Revision: 5902
Author: thoar
Date: 2012-10-18 16:24:56 -0600 (Thu, 18 Oct 2012)
Log Message:
-----------
Made the line length an optional argument to find_textfile_dims().
It had been a mandatory argument.
Modified Paths:
--------------
DART/branches/development/utilities/utilities_mod.f90
-------------- next part --------------
Modified: DART/branches/development/utilities/utilities_mod.f90
===================================================================
--- DART/branches/development/utilities/utilities_mod.f90 2012-10-18 22:21:31 UTC (rev 5901)
+++ DART/branches/development/utilities/utilities_mod.f90 2012-10-18 22:24:56 UTC (rev 5902)
@@ -1476,10 +1476,11 @@
subroutine find_textfile_dims( fname, nlines, linelen )
! Determines the number of lines and maximum line length
! of the file. Sometimes you need to know this stuff.
-character(len=*), intent(IN) :: fname
-integer, intent(OUT) :: nlines, linelen
+character(len=*), intent(IN) :: fname
+integer, intent(OUT) :: nlines
+integer, optional, intent(OUT) :: linelen
-integer :: i, mylen, ios, funit
+integer :: i, maxlen, mylen, ios, funit
character(len=1024) :: oneline
character(len=129) :: error_msg
@@ -1487,13 +1488,13 @@
! if there is no file, return -1 for both counts
if (.not. file_exist(fname)) then
nlines = -1
- linelen = -1
+ if (present(linelen)) linelen = -1
return
endif
! the file exists, go count things up.
nlines = 0
-linelen = 0
+maxlen = 0
funit = open_file(fname, form="FORMATTED", action="READ")
READLOOP : do i = 1,100000
@@ -1509,12 +1510,14 @@
nlines = nlines + 1
mylen = len_trim(oneline)
- if (mylen > linelen) linelen = mylen
+ if (mylen > maxlen) maxlen = mylen
enddo READLOOP
call close_file(funit)
+if (present(linelen)) linelen = maxlen
+
end subroutine find_textfile_dims
!#######################################################################
More information about the Dart-dev
mailing list