Runtime error with adios2_define_variable for reading
Created by: kshitij-v-mehta
I have a test case where the root process in the application tries to read a scalar variable from a file that was written using adios2. Test is performed on a local linux vm using mpich-3.2 built with gcc 6.3.0.
The call to adios2_define_variable
results in
ADIOS2 define_variable var_2: ERROR: variable var_2 exists in IO object read_single, in call to DefineVariable
.
Here is the test code:
program main
use mpi
use adios2
implicit none
integer*8 :: adios2_handle, adios2_io_handle, engine, var1
integer :: mpi_rank, val1, ierr
character(len=64) :: filename
call mpi_init(ierr)
call mpi_comm_rank(mpi_comm_world, mpi_rank, ierr)
call adios2_init(adios2_handle, mpi_comm_world, adios2_debug_mode_on, ierr)
call error_check(ierr, "adios2_init")
if(mpi_rank .eq. 0) then
call adios2_declare_io(adios2_io_handle, adios2_handle, "read_single", ierr)
call error_check(ierr, "adios2_declare_io")
filename = "./file1"//char(0)
call adios2_open(engine, adios2_io_handle, filename, adios2_mode_read, mpi_comm_self, ierr)
call error_check(ierr, "adios2_open")
call adios2_define_variable(var1, adios2_io_handle, "var_2", val1, ierr)
call error_check(ierr, "adios2_define_variable")
call adios2_get_sync(engine, var1, val1, ierr)
call error_check(ierr, "adios2_get_sync")
call adios2_close(engine, ierr)
print *, "Read val1: ", val1
endif
call adios2_finalize(adios2_handle, ierr)
contains
subroutine error_check(ierr, func_name)
implicit none
integer, intent(in) :: ierr
character(len=*), intent(in) :: func_name
if (ierr .ne. 0) then
print *, "ERROR: ", func_name, " failed"
call exit(-1)
endif
end subroutine
end program main
Running bpls on the existing file gives
bpls -lvd file1.bp
File info:
of groups: 1
of variables: 3
of attributes: 0
of meshes: 0
time steps: 0 - 0
file size: 372 bytes
bp version: 3
endianness: Little Endian
statistics: Min / Max / Avg / Std_dev
integer var_1 scalar = 10
integer var_2 scalar = 50
integer var_3 {5} = 10 / 50 / null / null
(0) 10 20 30 40 50