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

CDI-PIO support #485

Open
wants to merge 168 commits into
base: dev
Choose a base branch
from
Open

CDI-PIO support #485

wants to merge 168 commits into from

Conversation

ckhroulev
Copy link
Member

@ckhroulev ckhroulev commented Jun 9, 2021

This pull request contains CDI-PIO-related changes from #479, but applied to the dev branch instead of master. PICO optimizations are already in the dev branch.

The code as it stands has several issues:

  • only asynchronous writing is supported, making it harder than necessary to test the implementation (in particular: we cannot test this code in a serial run, only with mpiexec -n N pismr ... for some N > 1)

  • The async flag is useless because pismr stops with an error message when it is set to "false".

  • It is not clear if appending to an existing file (-extra_append) is possible. Need to be clarified with CDI-PIO developers if appending files is supported. Reading the CDI documentation it does not seem to be the case.

  • Reading is not implemented. Moreover, it fails silently instead of stopping with an error message.

  • The code does not follow the RAII (see Wikipedia as well) idiom: the CDI class should be responsible for both opening and closing files, ensuring that all open files get closed. For example: CDI::open_impl does not actually open a file. This is wrong.

  • The CDI class needs documenting comments. I understand what the code does, but it is not clear why it is done.

  • Configuration parameters specifying CDI file types and I/O modes should be "keywords", not integers.

  • Possible file type and I/O mode choices are undocumented.

  • The File class keeps track of whether dimensions were written and VariableMetadata keeps track of the same for variables. This is inconsistent; both tasks should probably be performed in File.

  • File::is_split() and File::set_split() do not make sense: one File instance corresponds to one file, never multiple files.

  • YAXT is written in the GNU dialect of C uses C99 features that are not a part of the C++ standard and so including yaxt.h (and cdi.h as well) pollutes PISM's code, breaking standard compliance (PISM follows the C++11 language standard). This makes it impossible to compile this using GCC 10 and possibly some other compilers. (Clang works.)

  • PISM's code should compile (with CMAKE_BUILD_TYPE=Debug) without warnings.

  • We need to free all allocated resources (see malloc() and free(), ccs_init_calendar() and ccs_free_calendar(), etc).

  • Most of PISM should not have to #include cdi.h, yaxt.h, etc. Most CDI-PIO and YAXT functions should be called from the "Initializer" class and from the CDI class, but not elsewhere.

  • All changes to IceModel related to avoiding closing and re-opening files should work with all supported I/O libraries and should not be enclosed in #if (Pism_USE_CDIPIO==1) ... #endif.

  • The code initializing and finalizing MPI, PETSc, and CDI-PIO in pismr.cc needs more testing.

  • update documentation

  • update CHANGES.rst

  • add regression tests

k202136 and others added 30 commits June 9, 2021 09:24
- pass std::string by const reference
- throw an exception if the I/O mode is invalid
- rename m_async to m_initialized (this is a closer match to its meaning)
- replace a sequence of if () ... else if () with a std::map (makes the code easier to
  read)
- replace int with unsigned int for n_writers since the number of writers cannot be
  negative
- add an include guard to the header
- replace if conditions with std::map
- throw an exception on invalid input
This was referenced Jun 17, 2021
@EnricoDeg
Copy link

EnricoDeg commented Aug 31, 2021

The issue with YAXT and GCC compiler can be temporarily solved by modifying the header files once the library is installed. For this purpose, I have written a simple script that does that.

for i in *.h; do
    sed -i -e 's/\( \)\([^[\@ ]*\)\(\[[^]]*\]\)/\1\3\2/g;s/\s\[[^]]*\]/ */g' $i
done

The code has been tested and it seems to work as expected.
I will get in contact with the YAXT developers and try to integrate this script into the installation process or, even better, write a wrapper for C++. In case this is taking long, as a workaround we can run this script during PISM installation process since YAXT installation folder is provided by the user. This might be a way to support older versions of the library.

@EnricoDeg
Copy link

EnricoDeg commented Aug 31, 2021

All the output files are now opened at the beginning and closed at the end. It seems to work as expected but more tests are needed.

@ckhroulev ckhroulev deleted the branch dev September 14, 2021 22:36
@ckhroulev ckhroulev closed this Sep 14, 2021
@ckhroulev ckhroulev reopened this Sep 14, 2021
@EnricoDeg
Copy link

The CDI-PIO mode is not needed because right now we are supporting only NetCDF files. It should be quite straightforward to add GRIB files support but I think it is better to first validate the implementation for NC files which are currently the only format used within PISM.

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.

None yet

2 participants