MetOffice / monio

Met Office NetCDF I/O (MONIO) written in C++ for file I/O in JEDI-based DA (JADA).
BSD 3-Clause "New" or "Revised" License
3 stars 2 forks source link

Minor modifications to Monio::readState for HofX #29

Closed phlndrwd closed 11 months ago

phlndrwd commented 1 year ago

In HofX tests there is a current need to pre-allocate fields that do not exist in the model, but which are populated as part of a variable transformation process. This use-case had not previously been tested in this version of MONIO and has indicated the need to check for fields that are not available in the state file. This PR introduces that check, and generates a warning message if reading is skipped.

Test outputs in MONIO, and with LFRic-Lite and LFRic-JEDI (on feature/hofx_io_compare): http://fcm1/cylc-review/taskjobs/punderwo/?suite=hofx_io_comapare_02

DJDavies2 commented 11 months ago

This isn't building on EXZ:

/home/h01/david.davies/cylc-run/monio-29/share/mo-bundle/monio/src/monio/Utils.cc: In function 'std::string monio::utils::exec(const std::string&)': /home/h01/david.davies/cylc-run/monio-29/share/mo-bundle/monio/src/monio/Utils.cc:64:25: error: aggregate 'std::array<char, 128> buffer' has incomplete type and cannot be defined 64 | std::array<char, 128> buffer; | ^~ gmake[2]: *** [monio/src/CMakeFiles/monio.dir/build.make:300: monio/src/CMakeFiles/monio.dir/monio/Utils.cc.o] Error 1

DJDavies2 commented 11 months ago

Maybe add

include \<array>

?

DJDavies2 commented 11 months ago

Maybe add

include

?

I'm completely lost; I am trying to write #include \<array>, but it won't show the \<array>

phlndrwd commented 11 months ago

This isn't building on EXZ:

/home/h01/david.davies/cylc-run/monio-29/share/mo-bundle/monio/src/monio/Utils.cc: In function 'std::string monio::utils::exec(const std::string&)': /home/h01/david.davies/cylc-run/monio-29/share/mo-bundle/monio/src/monio/Utils.cc:64:25: error: aggregate 'std::array<char, 128> buffer' has incomplete type and cannot be defined 64 | std::array<char, 128> buffer; | ^~ gmake[2]: *** [monio/src/CMakeFiles/monio.dir/build.make:300: monio/src/CMakeFiles/monio.dir/monio/Utils.cc.o] Error 1

Thanks @DJDavies2. Your suggestion is valid from a code linting perspective, but I'm very confused why this would cause a build issue! I've added the include now. I'd be interested to know if it builds now.

DJDavies2 commented 11 months ago

If you want to use std::array you need to #include \<array>. The real question is why it does compile on other platforms; probably because \<array> is included via some other header but there is a different version of libstdc++ on the EXZ. I don't think it is standard conforming to rely on including headers indirectly from other standard library headers, the only reliable thing is to include the header where it is used.