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

Add Fortran Interface for NetCDF C++ API: File Create and Close Operations #28

Open
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

amstokely
Copy link
Collaborator

@amstokely amstokely commented Dec 12, 2024

Description of Changes

Problem:
The NetCDF Fortran API lacks support for reading and writing NetCDF string variables, limiting functionality when working with modern NetCDF files. This gap necessitates an alternative approach to access the full range of NetCDF features.

Solution:
Developed an interface to call the NetCDF C++ API from Fortran. Currently, this interface supports basic operations such as opening and closing NetCDF files. This is the foundational step toward a comprehensive Fortran-to-NetCDF C++ interface that will expose all features of the NetCDF C++ API to Fortran applications, significantly enhancing functionality and flexibility.

…tests.

As of now, there are no unit tests but that will change in the future. Also updated installation section of The README to include instructions on how to install pFUnit and build obs2ioda with pFUnit support.
The command now is executed with bash -c '<prev command>' to make it possible to run from any shell, given the system has bash installed.
Removed the obs2ioda root dir argument from obs2ioda cmake args. Apparently CMake requires that the cmake root dir and cmake args in stored in seperate variables.
Removed seemingly hard requirement that build directories have to be named 'build' in the install instructions.
This dummy test serves as an example of how to write a unit test with pFUnit and how to add a pFUnit test to obs2ioda.
Example of how pfunit can catch a subtle type mismatch when using iso_c_bindings.
With a hypothetical way this bug could introduce a numerical error in obs2ioda without causing it to crash.
…_mod.f90

Moved all fortran files in obs2ioda-v2/src into obs2ioda-v2/src/fortran.

This will help with project organization if other languages are used in obs2ioda.

Updated CMakeLists to reflect the new directory structure.
This commit introduces derived types to facilitate interoperability between Fortran and C for 1D arrays of integers, doubles, and reals. Type-bound procedures were implemented to manage conversions between Fortran arrays and C-compatible arrays, including memory management in both directions. Unit tests were written for each new derived type. As memory allocation and alignment errors are easy to introduce with these new changes, valgrind based unit tests were written for each pFUnit test.
…stalled/discoverable. If it is not, cmake skips adding memcheck unit tests.
… fortran. This allows developers to use memory safe string/vector operations and does not add any sigificant code bloat.
…ng the netcdf C++ api from fortran. Added relevant tests.
…lso moved test cmake code to their own functions.
@amstokely amstokely self-assigned this Dec 12, 2024
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.

1 participant