MeteoSwiss-APN / serialbox

Data serialization library and tools for C/C++ and Fortran
BSD 2-Clause "Simplified" License
2 stars 6 forks source link

Problem with dimension of size 1 #67

Open clementval opened 8 years ago

clementval commented 8 years ago

There is a weird read behavior when you have a multi-dimensional field with some dimensions of size 1. In the example below, we just serialize a 2d field with the first dimension of size 1. The serialized data seems to be right but when they are read again they are wrong. I suspect a problem in the Fortran interface.

PROGRAM main_producer
  IMPLICIT NONE
  REAL(KIND=8), DIMENSION(1,256) :: a
  INTEGER :: i

  DO i = 1, 256
    a(1,i) = i
  END DO

  PRINT *, 'CALL serialize with sum(a)=', sum(a)

  !$ser init directory='.' prefix='SerialboxTest'
  !$ser savepoint sp1
  !$ser mode write
  !$ser data ser_a=a

END PROGRAM main_producer
PROGRAM main_consumer
  IMPLICIT NONE
  REAL(KIND=8), DIMENSION(1,256) :: a

  a(1,:) = 0.0

  PRINT*,'Before read from serializer: sum(a)=', sum(a)

  !$ser init directory='.' prefix='SerialboxTest-output' prefix_ref='SerialboxTest'
  !$ser savepoint sp1
  !$ser mode read
  !$ser data ser_a=a
  !$ser mode write
  !$ser data ser_a=a

  PRINT*,'After read from serializer: sum(a)=', sum(a)
END PROGRAM main_consumer
havogt commented 7 years ago

@clementval Can you close once you verified that it is indeed fixed?