Skip to content
New issue

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

Issue 463 -- Making header files configuration files #467

Merged
merged 16 commits into from
Feb 14, 2025
Merged

Conversation

lsawade
Copy link
Collaborator

@lsawade lsawade commented Feb 11, 2025

Description

This PR tracks progress towards seemless definition of floating point or double precision
computation as part of meshfem2d/-3d and specfempp.

The use can now specify

cmake ... -D ENABLE_DOUBLE_PRECISION 

during the configuration and the adjustments are propagated throughout the code.

Why?

Currently, all *.h files in meshfem2d/meshfem3d as well as the specfem_setup.hpp were hard coded. This has led to inconsistency in the binary IO (see #465).

While xmeshfem2D and xmeshfem3D are only writing double precision values to the binary files, xgenerate_databases writes base on CUSTOM_REAL that is usually defined within the configuration of SPECFEM2D/3D/3D_GLOBE.

This required quite a bit of change in the IO related functions and the cmake compilation.

What needed to change?

TODO:

  • create include/specfem_setup.hpp from setup/specfem_setup.hpp.in via CMake
  • create include/constants.hpp from setup/constants.hpp.in via CMake
  • create fortran/meshfem2d/*.h from fortran/meshfem2d/setup*.h.in via CMake
  • create fortran/meshfem3d/setup/*.h from fortran/meshfem3d/setup*.h.in via CMake
  • Update src/IO/fortranio/fortran_io.cpp to read "old" mesh files correctly.
    • fortran_read_value(type_real *value, ...) indicated that the readable input is
      always dependent on specfempp's definition of type_real, when in reality meshfem2d
      only writes double precision values, and fortran_read_value(type_real *value, ...)
      reads a double and converts it type_real. Not great.
    • Solution implemented:
      • fortran_read_value(float *value, ...)
      • fortran_read_value(double *value, ...)
      • Updated the read_2d_mesh functions to explicitly read double precision values
        and then convert them into type_real after the fact.
      • Updated tests that load the database files (specfem::testing::array2d/3d)
        that invoked type_real reads to read doubles instead.

The most difficult part of this was figuring out how to create the config.h files. Part of which I'm not 100% confident whether it is required, but it works. Please see the fortran/meshfem?d/setup/config.h.in and the corresponding fortran/meshfem?d/setup/CMakeLists.txt for generation of the necessary files.

Issue Number

Closes #463
Closes #465

Checklist

Please make sure to check developer documentation on specfem docs.

  • I ran the code through pre-commit to check style
  • My code passes all the integration tests
  • I have added sufficient unittests to test my changes
  • I have added/updated documentation for the changes I am proposing
  • I have updated CMakeLists to ensure my code builds
  • My code builds across all platforms

@lsawade lsawade closed this Feb 11, 2025
@lsawade lsawade reopened this Feb 11, 2025
@lsawade lsawade changed the base branch from main to issue-390 February 11, 2025 23:35
@lsawade lsawade requested a review from icui February 13, 2025 19:21
@lsawade lsawade merged commit 426e6f0 into issue-390 Feb 14, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fortran IO read size inconsistent
2 participants