EngineType consistency

Created by: germasch

In PR #1264, I've added a couple of tests to test CXX11/C/Fortran binding behavior when it comes to creating (IO::Open) an engine. All these test pass, ie., they document current behavior.

C++

The code definitely looks nicest in C++:

TEST_F(ADIOS2_CXX11_API_IO, Engine)
{
    io.SetEngine("bpfile");
    EXPECT_EQ(io.EngineType(), "bpfile");

    adios2::Engine engine = io.Open("types.bp", adios2::Mode::Write);
    EXPECT_EQ(engine.Name(), "types.bp");
    EXPECT_EQ(engine.Type(), "BP3");

    EXPECT_EQ(io.EngineType(), "bp"); // FIXME? Is it expected that adios2_open
                                      // changes the engine_type string?
}

This works mostly as expected, though I think it's iffy to have the engine show up as three different strings ("bpfile", "BP3", "bp"). Having the result of of io.EngineType() change as a consequence of calling Open is also not something I'd expect.

C

In the C API, things happen about the same way, so that's good:

TEST_F(ADIOS2_C_API_IO, Engine)
{
    int ierr;

    ierr = adios2_set_engine(ioH, "bpfile");
    EXPECT_EQ(ierr, 0);

    std::string engine_type = testing::adios2_engine_type_as_string(ioH);
    EXPECT_EQ(engine_type, "bpfile");

    adios2_engine *engineH = adios2_open(ioH, "ctypes.bp", adios2_mode_write);

    // FIXME, I'd like to check that the engine type itself is correct, but
    // there's no API to get it
    std::string engine_name = testing::adios2_engine_name_as_string(engineH);
    EXPECT_EQ(engine_name, "ctypes.bp");

    engine_type = testing::adios2_engine_type_as_string(ioH);
    EXPECT_EQ(engine_type, "bp"); // FIXME? Is it expected that adios2_open
                                  // changes the engine_type string?
}

(Note that the actual C API for getting strings looks much worse -- I hid it in helper functions that return std::string for making testing simpler.) The C API is missing a function that allows one to find the type of a given adios2_engine, but if it existed, it'd return "BP3" like cxx11.

Fortran

Fortran also doesn't have an API function to get the type for a given engine (because that'd need a corresponding C API function). It does, however, have engine%type, though I'm not sure that's supposed to be part of the official API.

  call adios2_set_engine(io, "bpfile", ierr)

  call adios2_io_engine_type(engine_type, io, ierr)
  if (engine_type /= "bpfile") stop "FAIL adios2_io_engine_type: "//engine_type
  deallocate(engine_type)

  call adios2_open(engine, io, "ftypes.bp", adios2_mode_write, ierr)

  if (engine%type /= "bpfile") stop "FAIL engine%type: "//engine%type
  ! // FIXME, I'd like to check that the engine type itself is correct, but
  ! // there's no (function-style) API to get it
  ! // FIXME, I'd like to check the engine's name, but there's no API to get it

  call adios2_io_engine_type(engine_type, io, ierr)
  if (engine_type /= "bp") stop "FAIL adios2_io_engine_type: "//engine_type
  deallocate(engine_type)

The adios2_set_engine and adios2_io_engine_type functions behave the same as their C/CXX11 counterparts. The engine%type, however, is different, returning "bpfile" instead of "BP3".

So I can see that there may be the argument "bp", "bpfile", "BP3" all mean the same thing, so why should we even care about some sort of consistency. I don't disagree that it's okay to accept various aliases for a given engine. I do, however, think, it'd be good if ADIOS2 were consistent in always returning the official name ("BP3" in this case). I also really think that the various APIs should mirror each other as much as possible, ie., having functions missing from the C/Fortran API isn't really good, and having them behave subtly differently is worse, as that'll make long term maintenance unnecessarily hard.

I have a proposed solution for this, but that's only worthwhile if there's agreement that this should be improved.