Skip to content

Fortran adios2_open BP4 file with adios2_append_mode data error #2940

@pbartholomew08

Description

@pbartholomew08

We ask the community to always report bugs. Please open a new issue if some other comes up in the conversation. It will help us stay on topic and manage tasks more efficiently.

Describe the bug
Opening a BP4 file with adios2_append_mode seems to result in corrupted data for runs > 1 MPI ranks when reorganised to single blocks or when opened with Paraview.

To Reproduce
Below is a small program to generate a BP file containing 3 steps based on the global fixed writer example, compile with mpif90 and using the output from adios2-config program.

To reproduce the problem:

  1. Run program on n>1 processes to obtain foo.bp
  2. Check contents look reasonable: bpls -D -lav foo.bp
  3. Reorganise file: adios2_reorganize foo.bp reorg.bp BPFile "" BPFile "" 1 1
  4. Contents of new file contain erroneous values: bpls -D -lav reorg.bp
program cart

  use mpi
  use adios2

  implicit none

  integer :: cart_comm
  integer :: nproc, nrank
  integer :: ierr
  integer, dimension(2) :: dims
  logical, dimension(2) :: periods

  type(adios2_adios) :: adios

  call MPI_Init(ierr)
  call MPI_Comm_size(MPI_COMM_WORLD, nproc, ierr)
  call MPI_Comm_rank(MPI_COMM_WORLD, nrank, ierr)

  call MPI_Dims_create(nproc, 2, dims, ierr)
  periods = .false.
  call MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periods, .false., cart_comm, ierr)

  call adios2_init(adios, cart_comm, ierr)

  call writer

  call adios2_finalize(adios, ierr)
  call MPI_Finalize(ierr)

contains

  subroutine writer()

    integer, dimension(2) :: coords, dims
    logical, dimension(2) :: periods
    integer, dimension(2) :: gdims, gcoords

    integer, parameter :: nx = 10, ny = 20
    integer :: i, j, s
    real(kind=kind(1.0d0)) :: x

    real(kind=kind(1.0d0)), dimension(2*nx, 3*ny) :: a

    type(adios2_io) :: io
    type(adios2_engine) :: engine
    type(adios2_variable) :: varh

    call MPI_Cart_get(cart_comm, 2, dims, periods, coords, ierr)
    call MPI_Comm_rank(cart_comm, nrank, ierr)

    gdims(1) = nx * dims(1)
    gdims(2) = ny * dims(2)

    gcoords(1) = nx * coords(1)
    gcoords(2) = ny * coords(2)

    call adios2_declare_io(io, adios, "output", ierr)
    call adios2_define_variable(varh, io, "foo", &
         adios2_type_dp, 2, &
         int(gdims, kind=8), int(gcoords, kind=8), int((/ nx, ny /), kind=8), &
         adios2_constant_dims, ierr)

    do s = 1, 3

       do j = 1, size(a,2)
          do i = 1, size(a,1)
             x = i + gcoords(1)
             a(i, j) = s * x
          end do
       end do

       if (s == 1) then
          call adios2_open(engine, io, "foo.bp", adios2_mode_write, ierr)
       else
          call adios2_open(engine, io, "foo.bp", adios2_mode_append, ierr)
       end if
       call adios2_begin_step(engine, adios2_step_mode_append, ierr)

       call adios2_put(engine, varh, a, ierr)
       call adios2_end_step(engine, ierr)
       call adios2_close(engine, ierr)

    end do

  end subroutine writer

end program cart

Expected behavior
Expectation is that file should contain same values on a different number of blocks (and likewise when opened in Paraview).

Desktop (please complete the following information):

  • OS/Platform: MacOS 11.5 & Ubuntu 20.04
  • Build ADIOS tag v2.7.1, gnu 10.2.0 (Mac OS) 9.3.0 (Ubuntu), cmake 3.21.1 (MacOS) 3.16.3 (Ubuntu). CMake build type Release and Debug tested, other options left to AUTO.

Additional context
Possibly related to #2482

Following up
I see that in the Full APIs/C bindings documentation it says that adios2_mode_append is not yet supported, Fortran bindings don't have a similar note, however if it should not be supported in Fortran either please close.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions