[GRASS-dev] Proposed new GRASS add-ons

Markus Neteler neteler at osgeo.org
Wed Jan 4 02:08:10 PST 2017


Dear Thomas,

On Tue, Jan 3, 2017 at 10:17 PM, Thomas Huld <thomas.huld at gmail.com> wrote:
> Dear All,
>
> I would like to propose three new GRASS add-on raster modules, all based on
> the r.sun module:
>
> r.pv: calculate photovoltaic module power output
> r.suntrack: calculate solar radiation on sun-tracking surfaces
> r.sunyear: calculate optimum inclination for maximum insolation over the
> year
>
> These modules are part of the PVMAPS software and data set:
>
> http://re.jrc.ec.europa.eu/pvmaps
>
> which contains these modules together with scripts, a manual and a large
> amount of data to run these modules. The data are also useful for running
> r.sun.

Excellent, thank you for this contribution.

> The methods underlying the modules have been described in a paper accepted
> for publication in Solar Energy:
>
> http://www.sciencedirect.com/science/article/pii/S0038092X16306089

Congrats!

> Since I am not terribly familiar with contributing to GRASS I have attached
> the source code. I have tried to follow the recommendations for source code
> and HTML pages, but I have probably forgotten something.
>
> Is there anything serious I have forgotten before committing the new modules
> to the repository?

I have compiled them on my Linux box and got a few issues:

Compilation issue:

rsunlib.c:645:47: warning: unused parameter ‘sunSlopeGeom’ [-Wunused-parameter]
                   struct SunGeometryVarSlope *sunSlopeGeom,
                                               ^~~~~~~~~~~~
: && gcc -L/home/neteler/software/grass72/dist.x86_64-pc-linux-gnu/lib
-L/home/neteler/software/grass72/dist.x86_64-pc-linux-gnu/lib
-Wl,--no-undefined -Wl,-z,now -Wl,--export-dynamic
-Wl,-rpath-link,/home/neteler/software/grass72/dist.x86_64-pc-linux-gnu/lib
-o /home/neteler/software/grass72/dist.x86_64-pc-linux-gnu/bin/r.suntrack
OBJ.x86_64-pc-linux-gnu/main.o OBJ.x86_64-pc-linux-gnu/rsunlib.o
-lgrass_gproj.7.2.1svn -lgrass_raster.7.2.1svn -lgrass_gis.7.2.1svn
-lm  -lproj    -lm
OBJ.x86_64-pc-linux-gnu/rsunlib.o:(.bss+0x18): multiple definition of
`timeOffset'
OBJ.x86_64-pc-linux-gnu/main.o:(.bss+0x7a8): first defined here
collect2: error: ld returned 1 exit status
/home/neteler/software/grass72/include/Make/Module.make:18: recipe for
target '/home/neteler/software/grass72/dist.x86_64-pc-linux-gnu/bin/r.suntrack'
failed
make: *** [/home/neteler/software/grass72/dist.x86_64-pc-linux-gnu/bin/r.suntrack]
Error 1

The same also for the others which have rsunlib.c copies. I think this
must be declared as "extern".

Code management:

To avoid duplicated code, perhaps adopt the style of r.sim for
rsunlib.c? See simlib/ and respective modules in
https://trac.osgeo.org/grass/browser/grass/trunk/raster/r.sim/

Or better: merge it with raster/r.sun/rsunlib.c and then we move this
to library level since only a single instance of the library is the
best to maintain.
Like lib/lidar/ for example (random choice here).


Minor: Please remove the unused variables (-Wunused-parameter). I
configure GRASS with

MYCFLAGS="-g -Wall -Wshadow -Wlogical-op
-Werror-implicit-function-declaration -fPIC -fno-common -fexceptions
-Wextra -Wunused -Wreturn-type -Wfatal-errors"
MYCXXFLAGS="-g -Wall"
MYLDFLAGS="-Wl,--no-undefined -Wl,-z,now"
LDFLAGS="$MYLDFLAGS" CFLAGS="$MYCFLAGS" CXXFLAGS="$MYCXXFLAGS" ./configure ...

Then these issues show up.

Best,
Markus


More information about the grass-dev mailing list