Too many raster files open
Justin Hickey
jhickey
Fri Jun 13 05:05:32 EDT 1997
Bill and Michael,
On Jun 12, 2:50pm, William L. Baker wrote:
> No one had a remedy, but someone did point out where the
> message comes from, but now when I look I see that I've lost that
> information.
I have a copy of the reply to Bill's posting from Dec 19, 1996 I include the
entire message below.
Hope this helps.
On Dec 20, 12:18pm, Martin Ameskamp wrote:
> Subject: Re: too many open raster files
> > Any grass programmers still left out there?
>
> Sure.
>
> > I get "WARNING: too many open raster files" after about
> > 20 iterations of a dynamic simulation model that uses
> > r.mapcalc and other GRASS programs, as well as some
> > contributed code. If I omit the following subroutine in
> > our contributed code, then the program does not produce this
> > error, so this is the offending code, although other things
> > going on elsewhere could be contributing other open
> > raster files (?):
>
> There are two aspects to this problem (I think). The first is
> the origin of the warning. This warning is produced in
> file src/libes/gis/opencell.c if you try to open more than
> MAXFILES files. MAXFILES is a constant that is #defined to be
> 30 in src/libes/gis/G.h
>
> I don't know why it's 30, probably the programmers thought that
> nobody in their right mind would need more than 30 open files
> anyawy (sounds vaguely familiar...).
> So I guess you could change this constant and recompile GRASS
> (you'd probably need to recompile or at least relink just about
> all of GRASS since this is a fairly central point).
>
> The second aspect is that your use of more than 30 open files
> _may_ point to a resource leakage. On the other hand, a complex
> mapcalc calculation could easily lead to a large number
> of temporary files (I don't know what mapcalc does in main-memory
> and where it uses temp files; a look at the code might help there).
>
> If your program is a complex one that opens and closes raster files
> all over the place, a debugger might help. Set breakpoints in
> the relevant routines (G_open_cell etc., recompile them with
> debugging information if necessary) and check if close
> is called often enough etc.
>
> Finally, I only use G_gisinit at the beginning of my GRASS programs
> (mostly in main()). Calling it in a subroutine makes sense if that
> routine is the only one that uses GRASS code, but calling it
> more than once might have funny effects on some bookkeeping
> details, maybe including file descriptors.
>
> Good luck, Martin
> >
> > void probascii();
> >
> > {
> >
> > int fd;
> > char *mapset;
> > static char prog_name[] = "probascii";
> > static char filename[] = "DISTPROB";
> >
> > G_gisinit(prog_name);
> >
> > if((mapset = G_find_cell(filename,"")) == NULL) {
> > printf("Unable to find file %s.\n",filename);
> > exit(1);
> > }
> >
> > if((fd = G_open_cell_old(filename, mapset)) < 0) {
> > printf("Unable to open file %s.\n",filename);
> > exit(-1);
> > }
> >
> > ...CODE OMITTED
> >
> > G_close_cell(fd);
> >
> > }
> >
> > I didn't write this code, but I'm trying to debug it.
> > Anyone see why this fails to close the raster files?
> > Or, any other clues as to what else could be
> > producing this WARNING?
> >
> > Bill Baker
> > BAKERWL at UWYO.EDU
> >
> >
> >
> >
>
>
> --
> Martin Ameskamp, Inst. f. Informatik I (Computing Dept.)
> Kiel University, Olshausenstr. 40, 24118 Kiel, Germany
> Fax: ++49 431 8804054, Voice: ++49 431 8804474,
> ma at informatik.uni-kiel.de, URL http://www.informatik.uni-kiel.de/~ma/
>-- End of excerpt from Martin Ameskamp
--
Sincerely,
Jazzman (a.k.a. Justin Hickey) e-mail: jhickey at hpcc.nectec.or.th
High Performance Computing Center
National Electronics and Computer Technology Center (NECTEC)
Bangkok, Thailand
==================================================================
People who think they know everything are very irritating to those
of us who do. ---Anonymous
Jazz and Trek Rule!!!
==================================================================
More information about the grass-user
mailing list