Skip to content

Commit

Permalink
fixes #3201
Browse files Browse the repository at this point in the history
  • Loading branch information
bena-nasa committed Dec 2, 2024
1 parent 306ca39 commit 5cb22db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Fixed bug where c null character is not removed from end of string when reading netcdf attribute in NetCDF4\_FileFormatter.F90

### Removed

### Deprecated
Expand Down
3 changes: 3 additions & 0 deletions pfio/NetCDF4_FileFormatter.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module pFIO_NetCDF4_FileFormatterMod
use pfio_NetCDF_Supplement
use netcdf
use mpi
use, intrinsic :: iso_c_binding, only: C_NULL_CHAR
implicit none
private

Expand Down Expand Up @@ -992,6 +993,7 @@ subroutine inq_attributes(this, cf, varid, unusable, rc)
status = nf90_get_att(this%ncid, varid, trim(attr_name), str)
!$omp end critical
_VERIFY(status)
if (str(len:len) == C_NULL_CHAR) str = str(1:len-1)
call cf%add_attribute(trim(attr_name), str)
deallocate(str)
case (NF90_STRING)
Expand Down Expand Up @@ -1088,6 +1090,7 @@ subroutine inq_var_attributes(this, var, varid, unusable, rc)
status = nf90_get_att(this%ncid, varid, trim(attr_name), str)
!$omp end critical
_VERIFY(status)
if (str(len:len) == C_NULL_CHAR) str = str(1:len-1)
call var%add_attribute(trim(attr_name), str)
deallocate(str)
case (NF90_STRING)
Expand Down

0 comments on commit 5cb22db

Please sign in to comment.