[GRASS-dev] superfluous G_legal_filename etc calls

Glynn Clements glynn at gclements.plus.com
Tue Jan 27 20:47:08 EST 2009


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.

> 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(pat_dtm_5m)
> D0/0: G_legal_filename(pat_dtm_5m)
> D0/0: G_legal_filename(pat_dtm_5m)
> D0/0: G_legal_filename(pat_dtm_5m)
> D0/0: G_legal_filename(pat_dtm_5m)
> D0/0: G_legal_filename(pat_dtm_5m)
> D0/0: G_legal_filename(pat_dtm_5m)
> 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(linke_turbidity10)
> D0/0: G_legal_filename(linke_turbidity10)
> D0/0: G_legal_filename(linke_turbidity10)
> D0/0: G_legal_filename(linke_turbidity10)
> D0/0: G_legal_filename(linke_turbidity10)
> D0/0: G_legal_filename(linke_turbidity10)
> D0/0: G_legal_filename(linke_turbidity10)
> D0/0: G_legal_filename(MASK)
> Illegal filename.  Cannot be '.' or 'NULL'    <- !!
> D0/0: G_legal_filename(pat5m_horangle_00)
> D0/0: G_legal_filename(pat5m_horangle_00)
> D0/0: G_legal_filename(pat5m_horangle_00)
> D0/0: G_legal_filename(pat5m_horangle_00)
> D0/0: G_legal_filename(pat5m_horangle_00)
> D0/0: G_legal_filename(pat5m_horangle_00)
> D0/0: G_legal_filename(pat5m_horangle_00)
> D0/0: G_legal_filename(pat5m_horangle_00)
> 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. :(
> 
> I suspect that r.sun (and maybe other modules) could be faster
> if these superfluous calls aren't done.
> 
> Any ideas where they come from?

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().

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list