We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug
specfem_setup.hpp defines sizes of some numbers:
specfem_setup.hpp
using type_real = float; const static int ndim{ 2 }; const static int fint{ 4 }, fdouble{ 8 }, fbool{ 4 }, fchar{ 512 };
and fortran_read_value(type_real *value, ....) is defined as follows.
fortran_read_value(type_real *value, ....)
void specfem::IO::fortran_read_value(type_real *value, std::ifstream &stream, int &buffer_length) { buffer_length -= fdouble; // <------------------------- char *ivalue = new char[fdouble]; // <------------------------- if (buffer_length < 0) { throw std::runtime_error("Error reading fortran file in type_real"); } stream.read(ivalue, freal); *value = *reinterpret_cast<type_real *>(ivalue); delete[] ivalue; return; }
This worked for meshfem2d (fortran) because the "in-repo"'s mesher has CUSTOM_REAL set to SIZE_DOUBLE aka 8.
meshfem2d
fortran
CUSTOM_REAL
SIZE_DOUBLE
8
** Solution **
Here, we really want to define the the parameters using enable_double_precision in the cmake file.
Fix the 2d meshing and reading thereof by assuming a double?
using type_real = float; const static int ndim{ 2 }; const static int fint{ 4 }, ffloat{ 4 }, fdouble{ 8 }, fbool{ 4 }, fchar{ 512 }; constexpr static int freal = sizeof(type_real);
And as a consequence:
... void fortran_read_value(type_real *value, std::ifstream &stream, int &buffer_length); #if freal != ffloat void fortran_read_value(float *value, std::ifstream &stream, int &buffer_length); #else void fortran_read_value(double *value, std::ifstream &stream, int &buffer_length); #endif void fortran_read_value(int *value, std::ifstream &stream, int &buffer_length); ...
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Describe the bug
specfem_setup.hpp
defines sizes of some numbers:and
fortran_read_value(type_real *value, ....)
is defined as follows.This worked for
meshfem2d
(fortran
) because the "in-repo"'s mesher hasCUSTOM_REAL
set toSIZE_DOUBLE
aka8
.** Solution **
Here, we really want to define the the parameters using enable_double_precision in the cmake file.
Fix the 2d meshing and reading thereof by assuming a double?
And as a consequence:
The text was updated successfully, but these errors were encountered: