r.viewshed fails on large raster: mktemp provides only 26 unique file names
|Reported by:||wenzeslaus||Owned by:|
|Keywords:||r.viewshed, mktemp, g.tempfile||Cc:|
Citing original report from mailing list r.viewshed fails on large raster: temp file already exists (nabble):
I was running r.viewshed in GRASS 7.0 under Win7 on a large raster with 11000 rows by 11000 columns. The algorithm ran in external memory mode with temporary files being written to a local directory (on C:). On starting sweeping, two temporary files were created, “STREAM_a06524” and “STREAM_b06524”, of which the first never increased in size beyond 0 KB, and the second grew to about 11 GB during sweeping. When sorting events, additional temp files were created, each of about 255 MB size, which were all named in the same logic, i.e. “STREAM_c06524”, “STREAM_d06524” etc, with only the letter after the underscore in the file name changing to the next letter in the alphabet. This continued until the file “STREAM_z06524” had been created, then the algorithm crashed with “File exists” (see sh output below). Obviously it had tried to create a file that already existed, probably named “STREAM_a06524”. It seems that either the programmer never counted on more files being necessary than the alphabet has letters, or maybe something gets mixed up in the loop and the code assumes that “STREAM_a06524” does not exist because it never wrote any data to it.
... ami_single_temp_name: mktemp failed: : File exists Assertion failed: 0, file ami_stream.cpp, line 97
_mktemp can create a maximum of 26 unique file names for any given combination of base and template values. Therefore, FNZ12345 is the last unique file name _mktemp can create for the base and template values used in this example.
Because it works on Linux, the problem is probably connected only to MS Windows'
- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47439 (similar report for gfortran)
- http://gcc.gnu.org/ml/fortran/2011-03/msg00102/mktemp.diff (otential patch to be re-used)
- http://msdn.microsoft.com/en-us/library/34wc6k1f%28v=VS.80%29.aspx (_mktemp at MSDN)
- http://msdn.microsoft.com/en-us/library/t8ex5e91%28v=vs.80%29.aspx (
- http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf (C++ standard defines
- http://www.gnu.org/software/libc/manual/html_node/Temporary-Files.html (GNU documentation)