I updated my post after I resolved the previous errors, but additional errors were produced.
I want to create a controlling shell script that contains water.mapcalc within it. The problem is, I do not know how to save a code in a file called water.mapcalc. I'm trying out the hydrologic simulation.
It is stated in page 12: "For those wishing to repeat the experiment with GRASS enter the model code in a file called water.mapcalc then create a controlling shell script."
I understood the instruction as I should save the following in a raster map called water.mapcalc:
r.mapcalc water.mapcalc = "water = water + eval(x=elev + water,
if(x>(y=elev[-1,0]+water[-1,0]),
-.15*if(elev>y, water, x-y),
.15*if(elev[-1,0]>x, water[-1,0], y-x))+
if(x>(y=elev[1,0]+water[1,0]),
-.15*if(elev>y, water, x-y),
.15*if(elev[1,0]>x, water[1,0], y-x))+
if(x>(y=elev[0,-1]+water[0,-1]),
-.15*if(elev>y, water, x-y),
.15*if(elev[0,-1]>x, water[0,-1], y-x))+
if(x>(y=elev[0,1]+water[0,1]),
-.15*if(elev>y, water, x-y),
.15*if(elev[0,1]>x, water[0,1], y-x))+
if(x>(y=elev[-1,1]+water[-1,1]),
-.10*if(elev>y, water, x-y),
.10*if(elev[-1,1]>x, water[-1,1], y-x))+
if(x>(y=elev[1,1]+water[1,1]),
-.10*if(elev>y, water, x-y),
.10*if(elev[1,1]>x, water[1,1], y-x))+
if(x>(y=elev[1,-1]+water[1,-1]),
-.10*if(elev>y, water, x-y),
.10*if(elev[1,-1]>x, water[1,-1], y-x))+
if(x>(y=elev[-1,-1]+water[-1,-1]),
-.10*if(elev>y, water, x-y),
.10*if(elev[-1,-1]>x, water[-1,-1], y-x)))"
Should I save the model code in a water.mapcalc raster map as what I did above? or should I save a water.mapcalc file in the /bin folder? I tried both but it still produced errors.
I already did the said map (water.mapcalc). and I created the following shell controlling script that needs the file (water.mapcalc). This is the shell script (myscript5.sh) and I saved it in the \bin folder of GRASS:
#!/bin/sh
export GRASS_PNGFILE=/tmp/grass6output.png
r.mapcalc water = 120
d.rast water
r.mapcalc < water.mapcalc
d.rast water
r.mapcalc < water.mapcalc
d.rast water
g.copy rast=water,water.1
r.mapcalc < water.mapcalc
d.rast water
r.mapcalc < water.mapcalc
d.rast water
g.copy rast=water,water.2
Then, I run the sh myscript5.sh
in the CMD of GRASS and it produced this message:
PNG: GRASS_TRUECOLOR status: TRUE
PNG: collecting to file: C:/Users/Rhen/AppData/Local/Temp/grass6output.png,
GRASS_WIDTH=768, GRASS_HEIGHT=508
/c/Program Files/GRASS-64/bin/myscript5.sh: line 7:
water.mapcalc: No such file or directory
PNG: GRASS_TRUECOLOR status: TRUE
PNG: collecting to file: C:/Users/Rhen/AppData/Local/Temp/grass6output.png,
GRASS_WIDTH=768, GRASS_HEIGHT=508
/c/Program Files/GRASS-64/bin/myscript5.sh: line 10:
water.mapcalc: No such file or directory
PNG: GRASS_TRUECOLOR status: TRUE
PNG: collecting to file: C:/Users/Rhen/AppData/Local/Temp/grass6output.png,
GRASS_WIDTH=768, GRASS_HEIGHT=508
Copy raster <water@PERMANENT> to current mapset as <water.1>
/c/Program Files/GRASS-64/bin/myscript5.sh: line 15:
water.mapcalc: No such file or directory
PNG: GRASS_TRUECOLOR status: TRUE
PNG: collecting to file: C:/Users/Rhen/AppData/Local/Temp/grass6output.png,
GRASS_WIDTH=768, GRASS_HEIGHT=508
/c/Program Files/GRASS-64/bin/myscript5.sh: line 18:
water.mapcalc: No such file or directory
PNG: GRASS_TRUECOLOR status: TRUE
PNG: collecting to file: C:/Users/Rhen/AppData/Local/Temp/grass6output.png,
GRASS_WIDTH=768, GRASS_HEIGHT=508
Copy raster <water@PERMANENT> to current mapset as <water.2>
the error is: water.mapcalc: No such file or directory. I think there is a problem on how I saved the water.mapcalc file. I do not know what format (raster/.txt/.sh file) and where will I save it (should I also save it in the /bin folder together with my script). I tried all of those and it still did not work. I cannot figure out where the problem is.
expr $n + 1
), also while[!=100] isn't correct (white space) etc. Again, pastebin or whatever would be handy so that corrections can be made (maybe post the final version eventually here).