openPMD / openPMD-api

:floppy_disk: C++ & Python API for Scientific I/O
https://openpmd-api.readthedocs.io
GNU Lesser General Public License v3.0
142 stars 51 forks source link

Unable to run example 3, write serial as is #1352

Closed s-sajid-ali closed 1 year ago

s-sajid-ali commented 1 year ago

Describe the bug Unable to run example 3 as is (apart from a change to location of file).

To Reproduce

sasyed@MAC-140753 ~/D/p/t/c/build> make -j2
Consolidate compiler generated dependencies of target example
[  0%] Built target copy-compile-commands
[ 50%] Building CXX object CMakeFiles/example.dir/example.cpp.o
/Users/sasyed/Documents/packages/temp/compass4/example.cpp:52:23: error: no matching function for call to 'determineDatatype'
  Datatype datatype = determineDatatype(global_data.data());
                      ^~~~~~~~~~~~~~~~~
/Users/sasyed/Documents/packages/spack/var/spack/environments/synergia/.spack-env/view/include/openPMD/Datatype.hpp:273:27: note: candidate template ignored: could not match 'std::shared_ptr<T>' against 'std::vector<double>::value_type *' (aka 'double *')
inline constexpr Datatype determineDatatype(std::shared_ptr<T>)
                          ^
/Users/sasyed/Documents/packages/spack/var/spack/environments/synergia/.spack-env/view/include/openPMD/Datatype.hpp:121:27: note: candidate function template not viable: requires 0 arguments, but 1 was provided
inline constexpr Datatype determineDatatype()
                          ^
1 error generated.
make[2]: *** [CMakeFiles/example.dir/example.cpp.o] Error 1
make[1]: *** [CMakeFiles/example.dir/all] Error 2
make: *** [all] Error 2

Expected behavior Example compiles and runs.

Software Environment

Additional context The example works if with the change

Datatype datatype = determineDatatype(shareRaw(global_data.data()));

i.e. adding a shareRaw call before determineDatatype.

Potential fix Perhaps the example needs to be corrected to add the shareRaw call?

s-sajid-ali commented 1 year ago

will be fixed by 0.15 release.

franzpoeschel commented 1 year ago

This looks like you accidentally tried compiling the dev version of the example against the release version of the openPMD-api. We extended the determineDatatype() function templates and updated the examples accordingly.