geodynamics / aspect

A parallel, extensible finite element code to simulate convection in both 2D and 3D models.
https://aspect.geodynamics.org/
Other
218 stars 233 forks source link

New warnings #679

Closed jperryhouts closed 8 years ago

jperryhouts commented 8 years ago

I'm getting a couple of -Wmaybe-uninitialized warnings when compiling ASPECT. Specifically:

In file included from /home/jmp/Documents/workspace/aspect/source/initial_conditions/S40RTS_perturbation.cc:28:0:
/home/jmp/packages/dealii/include/deal.II/bundled/boost/math/special_functions/spherical_harmonic.hpp: In member function ‘double aspect::InitialConditions::S40RTSPerturbation<dim>::initial_temperature(const dealii::Point<dim>&) const [with int dim = 2]’:
/home/jmp/packages/dealii/include/deal.II/bundled/boost/math/special_functions/spherical_harmonic.hpp:173:64: warning: ‘*((void*)& scoord +16)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    return policies::checked_narrowing_cast<result_type, Policy>(detail::spherical_harmonic_r(n, m, static_cast<value_type>(theta), static_cast<value_type>(phi), pol), "bost::math::spherical_harmonic_r<%1%>(unsigned, int, %1%, %1%)");
                                                                ^
/home/jmp/Documents/workspace/aspect/source/initial_conditions/S40RTS_perturbation.cc:202:36: note: ‘*((void*)& scoord +16)’ was declared here
       std_cxx11::array<double,dim> scoord = aspect::Utilities::spherical_coordinates(position);

And a similar warning from SAVANI_perturbation.cc:204:36

I assume these are trivial to fix if I knew how to do it, which is why I'm leaving this up to someone who's more familiar with C++ than I.

bangerth commented 8 years ago

This warning results from the fact that we compile the S40RTS plugin also in 2d. @jaustermann -- what would happen if one tried to select this plugin in 2d? Is it written in a way so that that would even make sense?

If the answer is "no", then I can write a small patch that ensures that the code in question is really only compiled in 3d, and that would avoid the warning message.

jaustermann commented 8 years ago

@bangerth In the current form it is not written in a way that it makes sense in 2d. It reads in spherical harmonics and evaluates them for each point, so that could be handled in 2d. However, the plugin needs x,y,z for the position on the sphere, which does not make sense in 2d. One could add something like it's done in the gplates plugin (with two points that determine the plane through the 3d sphere) but that takes a little more work. For now I would just add the patch as you suggested. Would that include an AssertThrow statement in S40RTS_perturbation and Savani_perturbation if dim is 1 or 2? If so one could add in the error message that it can be extended to 2d following the approach used in the gplates plugin.

bangerth commented 8 years ago

@jaustermann -- thanks for the feedback. I'll take care of the patch (it requires more than an assertion).

bangerth commented 8 years ago

@jperryhouts -- can you check whether the patch in #682 fixes your problem for the S40RTS case? If so, then I will write a similar patch for the Savani case.

bangerth commented 8 years ago

Fixed by #682.