E3SM-Project / E3SM-Project/scorpio

Invalid var_desc_t type handle found in pio_buf_lim_tests

Open
#110 2 comments 0 reactions 1 assignee Claimed by @dqwu View on GitHub
bug
Dominant language
C++
Stars
22
Forks
20
Avg merge
12d 19m
Merged PRs (30d)
1

Description

When PIO_TEST_CLOSE_OPEN_FOR_SYNC is ON, we first close a file and then reopen it.

After PIO_closefile is called, all existing var_desc_t type handles (obtained from previous PIO_def_var/PIO_inq_varid calls) become invalid and we should use PIO_inq_varid to renew them after reopening the file.

In pio_buf_lim_tests.F90.in, pio_var4 handle is not renewed, but it is still used to call PIO_write_darray.

PS, only ADIOS type can show the failure (for other types, the invalid handle for var4 happens to work)
```
...
ierr = PIO_def_var(pio_file, PIO_VAR4_NAME, PIO_TF_DATA_TYPE, (/pio_dim/), pio_var4)
...
#ifdef PIO_TEST_CLOSE_OPEN_FOR_SYNC
call PIO_closefile(pio_file)
ierr = PIO_openfile(pio_tf_iosystem_, pio_file, iotypes(i), filename, PIO_write)
ierr = PIO_inq_varid(pio_file, PIO_VAR1_NAME, pio_var1)
ierr = PIO_inq_varid(pio_file, PIO_VAR2_NAME, pio_var2)
ierr = PIO_inq_varid(pio_file, PIO_VAR3_NAME, pio_var3)
#else
call PIO_syncfile(pio_file)
#endif
...
! ============ Flush every 3 vars ======================
...
! Flush for the previous 3 vars, pio_var1, pio_var2, pio_var3 should happen
! inside PIO_write_darray(pio_var4)
call PIO_write_darray(pio_file, pio_var4, iodesc, wbuf, ierr)
PIO_TF_CHECK_ERR(ierr, "Failed to write darray(var4) : " // trim(filename))
...
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.