Skip to content

Commit

Permalink
Merge pull request #116 from ACCESS-NRI/nc_chunk_compress
Browse files Browse the repository at this point in the history
fix history chunking and comments / formatting
  • Loading branch information
apcraig authored Feb 1, 2024
2 parents aac3a5e + d199695 commit a1710e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1174,8 +1174,8 @@ end subroutine ice_write_hist
!=======================================================================

! Defines a (time-dependent) history var in the history file
! coordinates have short_name, long_name and units, coordsiantes and cell_measures attributes,
! and are compressed and chunked for 'hd5'
! variables have short_name, long_name and units, coordiantes and cell_measures attributes,
! and are compressed and chunked for 'hdf5'

subroutine ice_hist_field_def(ncid, hfield, lprecision, dimids, ns)

Expand Down Expand Up @@ -1209,7 +1209,7 @@ subroutine ice_hist_field_def(ncid, hfield, lprecision, dimids, ns)
endif

if (history_format=='hdf5' .and. history_deflate/=0) then
status=nf90_def_var_deflate(ncid, varid, shuffle=0, deflate=1, deflate_level=history_deflate)
status = nf90_def_var_deflate(ncid, varid, shuffle=0, deflate=1, deflate_level=history_deflate)
call ice_check_nc(status, subname//' ERROR deflating var '//trim(hfield%vname), file=__FILE__, line=__LINE__)
endif

Expand Down Expand Up @@ -1325,7 +1325,7 @@ end subroutine ice_write_hist_fill

! Defines a coordinate var in the history file
! coordinates have short_name, long_name and units attributes,
! and are compressed for 'hd5' when more than one dimensional
! and are compressed for 'hdf5' when more than one dimensional

subroutine ice_hist_coord_def(ncid, coord, lprecision, dimids, varid)

Expand Down
15 changes: 10 additions & 5 deletions cicecore/cicedyn/infrastructure/io/io_pio2/ice_history_write.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,9 @@ end subroutine ice_write_hist
!=======================================================================

! Defines a coordinate var in the history file
! coordinates have short_name, long_name and units attributes,
! and are compressed for 'hdf5' when more than one dimensional

subroutine ice_hist_coord_def(File, coord,lprecision, dimids,varid)

use pio, only: file_desc_t, var_desc_t, pio_def_var, pio_put_att
Expand Down Expand Up @@ -1297,7 +1300,7 @@ subroutine ice_hist_coord_def(File, coord,lprecision, dimids,varid)
endif

if (history_format=='hdf5' .and. size(dimids)>1) then
if (dimids(1)==imtid .and. dimids(2)==jmtid) then
if (dimids(1)==imtid .and. dimids(2)==jmtid) then
chunks(1)=history_chunksize(1)
chunks(2)=history_chunksize(2)
do i = 3, size(dimids)
Expand All @@ -1319,6 +1322,9 @@ end subroutine ice_hist_coord_def
!=======================================================================

! Defines a (time-dependent) history var in the history file
! variables have short_name, long_name and units, coordiantes and cell_measures attributes,
! and are compressed and chunked for 'hdf5'

subroutine ice_hist_field_def(File, hfield,lprecision, dimids, ns)

use pio, only: file_desc_t , var_desc_t, pio_def_var, pio_put_att
Expand All @@ -1328,7 +1334,7 @@ subroutine ice_hist_field_def(File, hfield,lprecision, dimids, ns)
use netcdf, only: NF90_CHUNKED
use ice_history_shared, only: history_deflate, history_chunksize, history_format
#endif
use ice_history_shared, only: ice_hist_field, history_precision, hist_avg
use ice_history_shared, only: ice_hist_field, history_precision, hist_avg
use ice_calendar, only: histfreq, histfreq_n, write_ic

type(file_desc_t), intent(inout) :: File
Expand Down Expand Up @@ -1356,12 +1362,11 @@ subroutine ice_hist_field_def(File, hfield,lprecision, dimids, ns)
if (dimids(1)==imtid .and. dimids(2)==jmtid) then
chunks(1)=history_chunksize(1)
chunks(2)=history_chunksize(2)
do i = 1, size(dimids)
do i = 3, size(dimids)
chunks(i) = 0
enddo
status = pio_def_var_chunking(File, varid, NF90_CHUNKED, chunks)
call ice_pio_check(status, &
subname//' ERROR: chunking var '//hfield%vname,file=__FILE__,line=__LINE__)
call ice_pio_check(status, subname//' ERROR: chunking var '//hfield%vname,file=__FILE__,line=__LINE__)
endif
endif
#endif
Expand Down

0 comments on commit a1710e6

Please sign in to comment.