[GRASS-SVN] r58853 - grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Feb 3 08:37:07 PST 2014
Author: neteler
Date: 2014-02-03 08:37:07 -0800 (Mon, 03 Feb 2014)
New Revision: 58853
Modified:
grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/daemon.c
grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/daemon.h
grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/description.html
Log:
r.li.daemon: compilation fix (needed due to r56730); HTML cosmetics
Modified: grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/daemon.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/daemon.c 2014-02-03 16:26:58 UTC (rev 58852)
+++ grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/daemon.c 2014-02-03 16:37:07 UTC (rev 58853)
@@ -45,9 +45,17 @@
g_areas g;
int receiveChannel;
int res;
- wd child[WORKERS];
int i, mypid, doneDir, withoutJob, mv_fd, random_access;
+ int num_workers;
+ /* check if environment variable override was set */
+ const char *p = getenv("WORKERS");
+ num_workers = p ? atoi(p) : DEFAULT_WORKERS;
+ if ((num_workers <= 0) || (num_workers > 1e6))
+ G_fatal_error(_("Invalid number of workers: [%s]"), p);
+
+ wd child[num_workers];
+
/*int mv_rows, mv_cols; */
list l;
msg m, doneJob;
@@ -73,7 +81,7 @@
############################################### */
i = 0;
- while (i < WORKERS) {
+ while (i < num_workers) {
int childpid;
/*creating pipe */
@@ -126,7 +134,7 @@
if (parsed == MVWIN) {
/* struct Cell_head cellhd_r, cellhd_new;
char *mapset; */
- /*creating new raster file */
+ /* create new raster file */
mv_fd = G_open_raster_new(output, DCELL_TYPE);
if (mv_fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), output);
@@ -156,14 +164,14 @@
/*#######################################################
------------------analysis loop----------------------
####################################################### */
- /*first job scheduling */
- while ((i < WORKERS) && next_Area(parsed, l, g, &m) != 0) {
+ /* first job scheduling */
+ while ((i < num_workers) && next_Area(parsed, l, g, &m) != 0) {
send(child[i].channel, &m);
i++;
}
- /*body */
+ /* body */
while (next_Area(parsed, l, g, &m) != 0) {
int j = 0, donePid;
@@ -179,7 +187,7 @@
print_Output(res, doneJob);
}
else {
- /*raster output */
+ /* raster output */
raster_Output(random_access, doneJob.f.f_d.aid, g,
doneJob.f.f_d.res);
}
@@ -190,19 +198,20 @@
error_Output(res, doneJob);
}
else {
- /*printf("todo ");fflush(stdout); *//* TODO scrivere su raster NULL ??? */
+ /* printf("todo"); fflush(stdout); */
+ /* TODO write to raster NULL ??? */
}
}
j = 0;
- while (j < WORKERS && donePid != child[j].pid)
+ while (j < num_workers && donePid != child[j].pid)
j++;
send(child[j].channel, &m);
}
- /*kill childs */
+ /* kill childs */
withoutJob = i;
while (i > 0) {
int j = 0, donePid, status;
@@ -228,13 +237,14 @@
error_Output(res, doneJob);
}
else {
- /*printf("todo2 ");fflush(stdout); *//*TODO scrivere su raster */
+ /* printf("todo2 "); fflush(stdout); */
+ /* TODO write to raster */
}
}
i--;
- while (j < WORKERS && donePid != child[j].pid)
+ while (j < num_workers && donePid != child[j].pid)
j++;
m.type = TERM;
@@ -249,7 +259,7 @@
G_verbose_message(_("r.li.worker (pid %i) terminated successfully"),
donePid);
perc++;
- G_percent (perc, WORKERS, 1);
+ G_percent (perc, num_workers, 1);
}
/* remove pipe */
if (close(child[j].channel) != 0)
@@ -259,7 +269,7 @@
}
/* kill children without Job */
- for (i = withoutJob; i < WORKERS; i++) {
+ for (i = withoutJob; i < num_workers; i++) {
int status;
m.type = TERM;
Modified: grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/daemon.h
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/daemon.h 2014-02-03 16:26:58 UTC (rev 58852)
+++ grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/daemon.h 2014-02-03 16:37:07 UTC (rev 58853)
@@ -25,7 +25,7 @@
/**
* \brief number of r.li.workers to use
*/
-#define WORKERS 10
+#define DEFAULT_WORKERS 10
#define NORMAL 1
#define MVWIN 2
#define GEN 3
Modified: grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/description.html
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/description.html 2014-02-03 16:26:58 UTC (rev 58852)
+++ grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/description.html 2014-02-03 16:37:07 UTC (rev 58853)
@@ -10,6 +10,7 @@
<img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
<H2>NAME</H2>
+
<EM><B>libgrass_rli</B></EM> - r.li landscape index support library
<H2>DESCRIPTION</H2>
@@ -57,6 +58,7 @@
Compile it using a changed Makefile based on the file for <em>r.li.patchdensity</em>.
<H2>NOTES</H2>
+
Using GRASS library function to access raster rows can slow down moving windows
execution. It is recommended to use
<br><div class="code"><pre>
@@ -66,8 +68,10 @@
</pre></div><br>
to use an ad hoc build memory management developed to speed up the system.
The documentation is in doxygen files.
+<p>
+The <tt>WORKERS</tt> environment variable can be set to the number of
+concurrent processes desired. If not set, the default is 10 concurrent jobs.
-
<H2>SEE ALSO</H2>
<EM><A HREF="http://grass.osgeo.org/gdp/landscape/r_le_manual5.pdf">old r.le manual</A></EM><BR>
@@ -75,7 +79,14 @@
<EM><A HREF="r.li.patchdensity.html">r.li.patchdensity</A></EM>,
<EM><A HREF="r.li.setup.html">r.li.setup</A></EM>
+
+<h2>REFERENCES</h2>
+McGarigal, K., and B. J. Marks. 1995. FRAGSTATS: spatial pattern
+analysis program for quantifying landscape structure. USDA For. Serv.
+Gen. Tech. Rep. PNW-351. (<a href="http://treesearch.fs.fed.us/pubs/3064">PDF</a>)
+
<H2>AUTHORS</H2>
+
Claudio Porta and Lucio Davide Spano, students of Computer Science
University of Pisa (Italy).<br>
Commission from Faunalia Pontedera (PI)<br>
@@ -87,6 +98,8 @@
<i>Last changed: $Date$</i>
<HR>
-<P><a href="index.html">Main index</a> - <a href="raster.html">raster index</a> - <a href="full_index.html">Full index</a>
+<P><a href="index.html">Main index</a>
+ - <a href="raster.html">raster index</a>
+ - <a href="full_index.html">Full index</a>
</body>
</html>
More information about the grass-commit
mailing list