util file name resolve: filename too small


Click here for full thread
  • Guest -
Hi again...

I added some debugging code to util_file_name_resolve so that it now looks like this:
subroutine util_file_name_resolve(filename, oscratch)
      implicit none
#include "errquit.fh"
#include "inp.fh"
#include "util.fh"
#include "global.fh"
      character*(*) filename    ! [input/output] 
      logical oscratch          ! [input] 
c
c     If the given filename is not a full path (begins with /)
c     or explicitly relative to the current directory (./ or ../)
c     then resolve it to the scratch/permanent directory for the
c     current process according to oscratch.
c
c     Note that this resolution cannot happen at input time since only
c     process 0 reads the input and the directories are process specific.
cc
      character*(nw_max_path_len) dir
      integer flen, dlen
c
      if ((filename(1:1).ne.'/')  .and. (filename(1:2).ne.'./')
     $     .and. (filename(1:3).ne.'../')) then
         call util_directory_name(dir, oscratch, ga_nodeid())
         dlen = inp_strlen(dir)
         if (dlen .gt. 0) then
            flen = inp_strlen(filename)
            write(*,*) "filename: ", filename(1:flen)
            write(*,*) "dir: ", filename(1:dlen)
            write(*,*) "flen: ", flen
            write(*,*) "dlen: ", dlen
            write(*,*) "len(filename): ", len(filename)
            write(*,*) "nw_max_path_len: ", nw_max_path_len
            if ((flen+dlen+1).gt.len(filename)) call errquit
     $           ('util_file_name_resolve: filename too small',
     $           flen+dlen+1, INPUT_ERR)
            dir(dlen+1:dlen+1) = '/'
            dir(dlen+2:) = filename
c     
*            write(6,*) ' RESOLVED ', filename(1:flen), ' TO ', 
*     $           dir(1:inp_strlen(dir))
c     
            filename = dir
         endif
      endif
c
      end

The six lines that all start with "write(*,*)" are my debugging output. The output I get from NWChem immediately before the crash now looks like:
neb: Calculating Initial Path Energy 
 filename: <gibberish>
 dir: <gibberish>
 flen:          255
 dlen:            6
 len(filename):          255
 nw_max_path_len:          511

So the value of nw_max_path_len appears not to affect the size of filename at all, and it looks like this function is being called with filename uninitialized. Note that the output didn't actually say "<gibberish>" it gave a bunch of unformatted garbage that I couldn't successfully paste into a Wiki post.

The offending call to util_file_name_resolve() is in run_bead_list, on line 355 of src/optim/neb/bead_list.F, where it's being passed a character string (of hard-coded length 255) called perm_name that is returned by rtdb_cget:
      value = value.and.
     >        rtdb_cget(bead_rtdb,rtdb_name,1,perm_name)
      call util_file_name_resolve(perm_name, .false.)

As far as I can tell, rtdb_cget pulls character variables from the run-time database. I really don't know the structure of the code well enough to know at what point the relevant variable is being put into the run-time database, or whether it's being pulled out correctly. I should point out that if I change the last line of the input script from
task qmmm dft neb

to
task qmmm dft energy

then the single-point energy calculation works fine and my debugging code reports a single (apparently successful) call to util_file_name_resolve. If anyone is familiar with this part of the program, I would really appreciate any ideas you have, because I'm really stuck at this point, and all I'm trying to do is run the example provided in the NWChem documentation!

Thanks,

-craig