-
Notifications
You must be signed in to change notification settings - Fork 168
Description
@VictorOnink discovered an interesting bug.
On his cluster, he was running parcels and got the following error:
In file included from /tmp/parcels-20788/parcels_random_4145b686-38e2-45a1-aadd-d599bc75389a.c:1:0:
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h: In function 'temporal_interpolation_structured_grid':
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:511:7: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < tii; i++) { \
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:544:7: note: in expansion of macro 'INTERP'
INTERP(spatial_interpolation_bilinear, spatial_interpolation_trilinear_surface);
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:511:7: note: use option -std=c99 or -std=gnu99 to compile your code
for (int i = 0; i < tii; i++) { \
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:544:7: note: in expansion of macro 'INTERP'
INTERP(spatial_interpolation_bilinear, spatial_interpolation_trilinear_surface);
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:516:7: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < tii; i++) { \
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:544:7: note: in expansion of macro 'INTERP'
INTERP(spatial_interpolation_bilinear, spatial_interpolation_trilinear_surface);
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:511:7: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < tii; i++) { \
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:546:7: note: in expansion of macro 'INTERP'
INTERP(spatial_interpolation_bilinear, spatial_interpolation_trilinear);
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:516:7: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < tii; i++) { \
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:546:7: note: in expansion of macro 'INTERP'
INTERP(spatial_interpolation_bilinear, spatial_interpolation_trilinear);
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:511:7: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < tii; i++) { \
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:549:5: note: in expansion of macro 'INTERP'
INTERP(spatial_interpolation_nearest2D, spatial_interpolation_nearest3D);
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:516:7: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < tii; i++) { \
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:549:5: note: in expansion of macro 'INTERP'
INTERP(spatial_interpolation_nearest2D, spatial_interpolation_nearest3D);
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:511:7: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < tii; i++) { \
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:551:5: note: in expansion of macro 'INTERP'
INTERP(spatial_interpolation_tracer_c_grid_2D, spatial_interpolation_tracer_c_grid_3D);
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:516:7: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < tii; i++) { \
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:551:5: note: in expansion of macro 'INTERP'
INTERP(spatial_interpolation_tracer_c_grid_2D, spatial_interpolation_tracer_c_grid_3D);
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:511:7: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < tii; i++) { \
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:553:5: note: in expansion of macro 'INTERP'
INTERP(spatial_interpolation_bilinear_invdist_land, spatial_interpolation_trilinear_invdist_land);
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:516:7: error: 'for' loop initial declarations are only allowed in C99 mode
for (int i = 0; i < tii; i++) { \
^
/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include/parcels.h:553:5: note: in expansion of macro 'INTERP'
INTERP(spatial_interpolation_bilinear_invdist_land, spatial_interpolation_trilinear_invdist_land);
^
Compiling: gcc -Wall -fPIC -I/home/ubelix/climate/vo18e689/anaconda3/envs/py3_parcels_v2_2/lib/python3.6/site-packages/parcels/include -g -O3 -m64 -o /tmp/parcels-20788/parcels_random_4145b686-38e2-45a1-aadd-d599bc75389a.so /tmp/parcels-20788/parcels_random_4145b686-38e2-45a1-aadd-d599bc75389a.c -shared -m64
Now, we compared our version of gcc-ng. The outcome:
I have the package from the conda-forge channel, which gives us a gcc-version of 7.3.0. He has on the cluster a version of gcc with 9.3.0.
The issue is as follows:
gcc 9.3.0 is more strict in enforcing a certain C-standard during code-parsing. Now, having a for (...)-loop in a macro-definition is not allowed in the initial C-89 standard, which is the default standard applied by gcc without re-definition. gcc 7.3.0 doesn't check this part of the standard-compliance during the syntax check of C-parsing, but gcc 9.3.0 does check that compliance. Hence, we don't get an error with the conda-forge version of gcc-ng, but we do get that error with the anaconda version of gcc-ng.
How can we solve it ?
- add the compiler switch
-std=c99to the compiler (not linker) switches in the code generator in parcels