ornladios / ADIOS

The old ADIOS 1.x code repository. Look for ADIOS2 for new repo
https://csmd.ornl.gov/adios
Other
54 stars 41 forks source link

Update mode from Fortran does not update #121

Open suchyta1 opened 7 years ago

suchyta1 commented 7 years ago

I've noticed that using mode="u" for adios_open from Fortran doesn't seem to work. The file retains whatever values were there before. For example, I modified the simple Fortran arrays examples. After running this, all the arrays have 1 as the value for each element.

I ran into this working with coupling GENE and XGC, which are both Fortran codes. I don't necessarily want to update instead of appending, but figured I should report this anyway. In the coupling work, I've seen trying to update causing a seg fault as well, but I don't seem to trigger than in a simple example.

program arrays
    use adios_write_mod
    implicit none
    include 'mpif.h'

    character(len=25)   :: filename = "arrays.bp"
    integer             :: rank, size, i, j, ierr
    integer             :: comm

    ! ADIOS variables declarations for matching gwrite_temperature.fh 
    integer                 :: adios_err
    integer*8               :: adios_groupsize, adios_totalsize
    integer*8               :: adios_handle

    ! variables to write out 
    integer, parameter      :: NX = 10, NY = 100
    real*8                  :: t(NX,NY)
    integer                 :: p(NX)
    integer                 :: k

    call MPI_Init (ierr)
    call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
    call MPI_Comm_rank (comm, rank, ierr)
    call MPI_Comm_size (comm, size, ierr)

    call adios_init ("arrays.xml", comm, adios_err);

    do k = 1, 100
        do j = 1,NY 
            do i = 1,NX
                t(i,j) = k
            enddo     
        enddo

        do i = 1,NX
            p(i) = k
        enddo

        if (k.eq.1) then
            call adios_open (adios_handle, "arrays", filename, "w", comm, adios_err)
        else
            call adios_open (adios_handle, "arrays", filename, "u", comm, adios_err)
        end if

#include "gwrite_arrays.fh"
        call adios_close (adios_handle, adios_err)
    end do

    call MPI_Barrier (comm, ierr);
    call adios_finalize (rank, adios_err);
    call MPI_Finalize (ierr);

end program