Skip to content

Commit

Permalink
r3.out.netcdf: Use current major version in history attribute (#2342)
Browse files Browse the repository at this point in the history
r3.out.netcdf creates a netCDF file with attribute history which contains software. This removes the hard-coded software version information and uses the current major version instead for the history text. It uses fairly general macros to encapsulate stringification to avoid complex code needed to use snprintf.

The documentation contains the output, so the version should be there, but I removed it from the examples to avoid the need for updates (making the documentation little less precise).
  • Loading branch information
wenzeslaus committed Feb 15, 2023
1 parent adf4d3e commit 4f5477c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions raster3d/r3.out.netcdf/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
#include <grass/glocale.h>
#include <grass/gprojects.h>

// Constant to string conversion
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)

#define NDIMS 3
#define LONG_NAME "long_name"
#define STANDARD_NAME "standard_name"
Expand All @@ -51,8 +55,9 @@
#define UNITS "units"
#define DEGREES_EAST "degrees_east"
#define DEGREES_NORTH "degrees_north"
#define HISTORY_TEXT "GRASS GIS 8 netCDF export of r3.out.netcdf"
#define CF_SUPPORT "CF-1.5"
#define HISTORY_TEXT \
"GRASS GIS " STR(GRASS_VERSION_MAJOR) " netCDF export of r3.out.netcdf"
#define CF_SUPPORT "CF-1.5"

#define ERR(e) \
{ \
Expand Down
6 changes: 3 additions & 3 deletions raster3d/r3.out.netcdf/r3.out.netcdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ <h2>EXAMPLES</h2>

// global attributes:
:Conventions = "CF-1.5" ;
:history = "GRASS GIS 7 netCDF export of r3.out.netcdf" ;
:history = "GRASS GIS netCDF export of r3.out.netcdf" ;
data:

longitude = -175, -165, -155, -145, -135, -125, -115, -105, -95, -85, -75,
Expand Down Expand Up @@ -179,7 +179,7 @@ <h2>EXAMPLES</h2>

// global attributes:
:Conventions = "CF-1.5" ;
:history = "GRASS GIS 7 netCDF export of r3.out.netcdf" ;
:history = "GRASS GIS netCDF export of r3.out.netcdf" ;
data:

longitude = -175, -165, -155, -145, -135, -125, -115, -105, -95, -85, -75,
Expand Down Expand Up @@ -236,7 +236,7 @@ <h2>EXAMPLES</h2>

// global attributes:
:Conventions = "CF-1.5" ;
:history = "GRASS GIS 7 netCDF export of r3.out.netcdf" ;
:history = "GRASS GIS netCDF export of r3.out.netcdf" ;
data:

longitude = -175, -165, -155, -145, -135, -125, -115, -105, -95, -85, -75,
Expand Down

0 comments on commit 4f5477c

Please sign in to comment.