HDFGroup / HDFGroup/hdf5

Allocatable components of Fortran derived types change when reading static components

Open
#4,577 10 comments 0 reactions 1 assignee Claimed by @brtnfld View on GitHub
Component - Wrappers
Dominant language
C
Stars
988
Forks
355
Avg merge
4d 2h
Merged PRs (30d)
12

Description

**Describe the bug**
A HDF5 compound type is constructed from a Fortran derived type, which contains static as well as allocatable components. Only the static components are included in the compound. When writing and reading the compound type, the allocation status of the dynamic components in the read-in data depends on the written data. In particular, the dynamic components may change their status from deallocated to allocated. This seems to happen, when they were allocated in the written data.

**Expected behavior**
The status and contents of allocatable components in the read data should stay untouched.

**Platform (please complete the following information)**
- HDF5 1.14.4.2 (MacPorts)
- MAC OS Sonoma 14.5 (23F79)
- GNU Fortran (MacPorts gcc12 12.3.0_4+stdlib_flag) 12.3.0
- cmake version 3.29.3
- serial HDF5

**Additional context**
The attached file contains the Fortran source and the control output for a derived-type array of length 2. The latter shows that the dynamic component of the first element is deallocated. In the second element it is allocated, although the file should contain no information about the dynamic component.

[hdf5_test.zip](https://github.com/user-attachments/files/15887570/hdf5_test.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.