[Dart-dev] [7100] DART/trunk/utilities: fix 'findex' to be 'lineindex' which is more descriptive.

nancy at ucar.edu nancy at ucar.edu
Mon Aug 4 11:17:48 MDT 2014


Revision: 7100
Author:   nancy
Date:     2014-08-04 11:17:48 -0600 (Mon, 04 Aug 2014)
Log Message:
-----------
fix 'findex' to be 'lineindex' which is more descriptive.
fix the other 'findex' to be 'fileindex' which is also more
descriptive.  fix the comments and one error message to be
more helpful (hopefully).  fix the documentation to match 
the change in the function argument names.

Modified Paths:
--------------
    DART/trunk/utilities/utilities_mod.f90
    DART/trunk/utilities/utilities_mod.html

-------------- next part --------------
Modified: DART/trunk/utilities/utilities_mod.f90
===================================================================
--- DART/trunk/utilities/utilities_mod.f90	2014-08-04 17:05:50 UTC (rev 7099)
+++ DART/trunk/utilities/utilities_mod.f90	2014-08-04 17:17:48 UTC (rev 7100)
@@ -1623,13 +1623,13 @@
 !#######################################################################
 
 
-function get_next_filename( listname, findex )
+function get_next_filename( listname, lineindex )
 
 ! Arguments are the name of a file which contains a list of filenames.
 ! This routine opens the listfile, and returns the index-th one.
 !
 character(len=*),  intent(in) :: listname
-integer,           intent(in) :: findex
+integer,           intent(in) :: lineindex
 character(len=256)            :: get_next_filename
 
 integer :: i, ios, funit
@@ -1638,7 +1638,7 @@
 
 funit   = open_file(listname, form="FORMATTED", action="READ")
 
-PARSELOOP : do i=1, findex
+PARSELOOP : do i=1, lineindex
 
    read(funit, '(A)', iostat=ios) string
 
@@ -1682,7 +1682,7 @@
 character(len=*), intent(in)    :: caller_name
 integer                         :: set_filename_list
 
-integer :: findex, max_num_input_files
+integer :: fileindex, max_num_input_files
 logical :: from_file
 character(len=32) :: fsource
 
@@ -1717,31 +1717,41 @@
    from_file = .false.
 endif
 
-! the max number of names in a namelist file is the size of the array
-! that will be returned.
+! the max number of names allowed in a list file is the 
+! size of the name_array passed in by the user.
 max_num_input_files = size(name_array)
-do findex = 1, max_num_input_files
+
+! loop over the inputs.  if the names were already specified in the
+! name_array, just look for the '' to indicate the end of the list.
+! if the names were specified in the listname file, read them in and
+! fill in the name_array and then look for ''.
+do fileindex = 1, max_num_input_files
    if (from_file) &
-      name_array(findex) = get_next_filename(listname, findex)
+      name_array(fileindex) = get_next_filename(listname, fileindex)
 
-   if (name_array(findex) == '') then
-      if (findex == 1) then
+   if (name_array(fileindex) == '') then
+      if (fileindex == 1) then
          call error_handler(E_ERR, caller_name, &
              'found no '//trim(fsource), source,revision,revdate)
       endif
 
-      ! return how many files we found, either in the namelist
-      ! or in the list of files
-      set_filename_list = findex - 1
+      ! at the end of the list. return how many filenames were found, 
+      ! whether the source was the name_array or the listname.
+      set_filename_list = fileindex - 1
       return
    endif
 enddo
 
-! if you're reading from a file, make sure you don't have more
-! names in the file than can fit in the array.
+! if you get here, you read in all max_num_input_files without
+! seeing an empty string.  if the input names were already in the
+! array, you're done - set the count and return.   but if you're
+! reading names from a file it is possible to specify more names
+! than fit in the list.  test for that and give an error if you
+! aren't at the end of the list.
+
 if (from_file) then
    if (get_next_filename(listname, max_num_input_files+1) /= '') then
-      write(msgstring, *) 'cannot specify more than ',max_num_input_files,' files'
+      write(msgstring, *) 'cannot specify more than ',max_num_input_files,' filenames in the list file'
       call error_handler(E_ERR, caller_name, msgstring, source,revision,revdate)
    endif
 endif

Modified: DART/trunk/utilities/utilities_mod.html
===================================================================
--- DART/trunk/utilities/utilities_mod.html	2014-08-04 17:05:50 UTC (rev 7099)
+++ DART/trunk/utilities/utilities_mod.html	2014-08-04 17:17:48 UTC (rev 7100)
@@ -663,11 +663,11 @@
 <A NAME="get_next_filename"></A>
 <br>
 <div class=routine>
-<em class=call> var = get_next_filename( listname, index ) </em>
+<em class=call> var = get_next_filename( listname, lineindex ) </em>
 
 <pre>
 character(len=*),  intent(in) :: <em class=code>listname</em>
-integer,           intent(in) :: <em class=code>index</em>
+integer,           intent(in) :: <em class=code>lineindex</em>
 character(len=128)            :: <em class=code>get_next_filename</em>
 </pre>
 </div>
@@ -691,10 +691,10 @@
 <TABLE width=100% border=0 summary="" cellpadding=3>
 <TR><TD valign=top><em class=code>var </em></TD>
     <TD>An ascii string, up to 128 characters long, containing the
-        contents of line <em class=code>index</em> of the input file.</TD></TR>
+        contents of line <em class=code>lineindex</em> of the input file.</TD></TR>
 <TR><TD valign=top><em class=code>listname </em></TD>
     <TD>The filename to open and read lines from.</TD></TR>
-<TR><TD valign=top><em class=code>index </em></TD>
+<TR><TD valign=top><em class=code>lineindex </em></TD>
     <TD>Integer line number, starting at 1.  If larger than the
         number of lines in the file, the empty string '' will be returned.</TD></TR>
 </TABLE>


More information about the Dart-dev mailing list