scorpio icon indicating copy to clipboard operation
scorpio copied to clipboard

Two confirmed issues with pio_set_buffer_size_limit interface

Open dqwu opened this issue 4 months ago • 0 comments

Issue 1: Build error in flib_legacy

@bartgol reported a build error on his laptop when using the legacy Fortran library of SCORPIO to build SCREAM (e.g., HAVE_IS_CONTIGUOUS fails with GCC 8.5). The error occurs in csm_share during the compilation of SCREAM:

/home/lbertag/workdir/scream/scream-src/master/share/util/shr_pio_mod.F90:185:72:

        call pio_set_buffer_size_limit(pio_buffer_size_limit, prev_limit=cur_buffer_size_limit)
                                                                        1
Error: Keyword argument 'prev_limit' at (1) is not in the procedure; did you mean 'limit'?

This issue arises because the new Fortran library of SCORPIO has updated the pio_set_buffer_size_limit interface to include a second optional argument (see https://github.com/E3SM-Project/scorpio/pull/513/commits/956af1e3b804d7ee26d7b5ab791ceaa6bf6fb7e2). The updated interface is now being used in SCREAM and E3SM, but the legacy Fortran library lacks this optional argument, leading to the compiler error.

Proposed fix: The legacy Fortran library should be updated to include this optional argument for compatibility with newer client code. Adding the optional argument will not break backward compatibility.

Issue 2: Handling of zero value in pio_buffer_size_limit

Separately, @dqwu identified another issue with the handling of pio_buffer_size_limit through further investigation.

In SCORPIO's unit tests and in the E3SM/SCREAM code, 0 is assumed to be a valid value for pio_buffer_size_limit. For example: In a SCORPIO unit test: call pio_set_buffer_size_limit(PIO_BUFFER_SZ_ZERO)

In shr_pio_mod.F90, there's a comment: ! 0 is a valid value of pio_buffer_size_limit

However, it is confirmed that 0 is never actually applied to pio_buffer_size_limit due to the following logic:

/* If the user passed a valid size, use it. */
if (limit > 0)
    pio_buffer_size_limit = limit;

Proposed fix: This logic should be adjusted to allow pio_buffer_size_limit to be set to 0 when explicitly requested.

Additional concern to be aware of:

When pio_buffer_size_limit is set to 0, the following PnetCDF call in SCORPIO will fail (try to attach a NULL buffer): ierr = ncmpi_buffer_attach(file->fh, pio_buffer_size_limit);

This should also be handled carefully to avoid unintended failures.

dqwu avatar Oct 02 '24 23:10 dqwu