[GRASS-dev] superfluous G_legal_filename etc calls

Markus Neteler neteler at osgeo.org
Wed Jan 28 09:50:52 EST 2009


On Wed, Jan 28, 2009 at 2:47 AM, Glynn Clements
<glynn at gclements.plus.com> wrote:
>
> Markus Neteler wrote:
>
>> I am running r.sun (6.4) on a massive grid and have some troubles with
>> the libgis libraries:
>> I backported the differences locally from 7 (use G_find_cell2()
>> instead of G_find_cell() but
>> the problems remain the same:
>
>> A) Observation one:
>>  G_legal_filename (and underlying functions) are called
>>  a zillion times. IMHO one time per map would be sufficient:
>
> It's getting called once per element (cellhd, cell, fcell, cats, ...).
>
> Either G_find_file* call G_legal_filename() (in which case, you'll get
> one call for each element, multiple calls per map), or they don't (in
> which case, you get zero calls per map).
>
> AFAICT, there is no reason for G_find_file* to call
> G_legal_filename(), as they are only used for existing files. If the
> name isn't legal, it won't exist.
>
> OTOH, the time taken by G_legal_filename() is likely to be trivial
> compared to the system calls performed by G_find_file* and any
> subsequent open() call.

OK, so we ignore it.

>> B) Observation two:
>>  When running the same job (the r.sun call plus a few more lines
>>  are indeed in a shell script) in Grid Engine on a cluster, this
>>  happens:
>>
>> ...
>> Mode 2: integrated daily irradiation
>>    0%D0/0: G_legal_filename(pat_dtm_5m)
...
>> D0/0: G_legal_filename(MASK)
>> Illegal filename.  Cannot be '.' or 'NULL'      <- !!
>> D0/0: G_legal_filename(linke_turbidity10)
>> D0/0: G_legal_filename(linke_turbidity10)
...
>> D0/0: G_legal_filename(pat5m_horangle_00)
>> D0/0: G_legal_filename(MASK)
>> Illegal filename.  Cannot be '.' or 'NULL'
>> D0/0: G_legal_filename(pat5m_horangle_01)
>> D0/0: G_legal_filename(pat5m_horangle_01)
>> ...
>>
>> Interestingly "Illegal filename" appears (perhaps taking '.' -
>> current directory - into account?) I wasted quite some time
>> until I realized that the message apparently doesn't harm. :(
>>
...
> Nope.
>
> Try adding a G_debug() statement to G_legal_filename(), so that you
> catch all of the G_legal_filename() calls rather than just those
> originating from G_find_file().

Good suggestion: My bad.

The launch script contained:

# use day + jobid as MAPSET to avoid GRASS lock
MYMAPSET=$day.$JOB_ID

but day wasn't set. So GRASS created .mapset names which isn't
allowed.

Markus


More information about the grass-dev mailing list