Skip to content

Commit

Permalink
Merge branch '33-compression-level-namelist-parameter'
Browse files Browse the repository at this point in the history
  • Loading branch information
nichannah committed Aug 2, 2019
2 parents 47650cc + ccee631 commit 5526bdb
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 17 deletions.
60 changes: 45 additions & 15 deletions io_netcdf/ice_history_write.F90
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ subroutine ice_write_hist (ns)
character (char_len) :: title
character (char_len_long) :: ncfile(max_nstrm)

integer (kind=int_kind) :: shuffle, deflate, deflate_level

integer (kind=int_kind) :: ind,boundid

character (char_len) :: start_time,current_date,current_time
Expand Down Expand Up @@ -113,6 +115,19 @@ subroutine ice_write_hist (ns)
TYPE(coord_attributes), dimension(nvarz) :: var_nz
CHARACTER (char_len), dimension(ncoord) :: coord_bounds

! We leave shuffle at 0, this is only useful for integer data.
shuffle = 0

! If history_deflate_level < 0 then don't do deflation,
! otherwise it sets the deflate level
if (history_deflate_level < 0) then
deflate = 0
deflate_level = 0
else
deflate = 1
deflate_level = history_deflate_level
endif

if (my_task == master_task) then

ltime=time/int(secday)
Expand Down Expand Up @@ -181,7 +196,8 @@ subroutine ice_write_hist (ns)
status = nf90_def_var(ncid,'time',nf90_float,timid,varid)
if (status /= nf90_noerr) call abort_ice( &
'ice: Error defining var time')
status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'ice: Error deflating var time')

Expand Down Expand Up @@ -229,7 +245,8 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice( &
'ice: Error defining var time_bounds')

status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'ice: Error deflating var time_bounds')

Expand Down Expand Up @@ -334,7 +351,8 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice( &
'Error defining short_name for '//coord_var(i)%short_name)

status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'Error deflate short_name for '//coord_var(i)%short_name)

Expand Down Expand Up @@ -376,7 +394,8 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice( &
'Error defining short_name for '//var_nz(i)%short_name)

status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'Error defining short_name for '//var_nz(i)%short_name)

Expand All @@ -395,7 +414,8 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice( &
'ice: Error defining var tmask')

status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'ice: Error deflating var tmask')

Expand All @@ -416,7 +436,8 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice( &
'ice: Error defining var blkmask')

status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'ice: Error deflating var blkmask')

Expand All @@ -439,7 +460,8 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice( &
'Error defining variable '//var(i)%req%short_name)

status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'Error deflating variable '//var(i)%req%short_name)

Expand Down Expand Up @@ -472,7 +494,8 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice( &
'Error defining variable '//var_nverts(i)%short_name)

status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'Error deflating variable '//var_nverts(i)%short_name)

Expand All @@ -498,7 +521,8 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice( &
'Error defining variable '//avail_hist_fields(n)%vname)

status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'Error deflating variable '//avail_hist_fields(n)%vname)

Expand Down Expand Up @@ -562,7 +586,8 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice( &
'Error defining variable '//avail_hist_fields(n)%vname)

status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'Error deflating variable '//avail_hist_fields(n)%vname)

Expand Down Expand Up @@ -618,7 +643,8 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice( &
'Error defining variable '//avail_hist_fields(n)%vname)

status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'Error deflating variable '//avail_hist_fields(n)%vname)

Expand Down Expand Up @@ -660,7 +686,8 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice( &
'Error defining variable '//avail_hist_fields(n)%vname)

status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'Error deflating variable '//avail_hist_fields(n)%vname)

Expand Down Expand Up @@ -704,7 +731,8 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice( &
'Error defining variable '//avail_hist_fields(n)%vname)

status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'Error deflating variable '//avail_hist_fields(n)%vname)

Expand Down Expand Up @@ -762,7 +790,8 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice( &
'Error defining variable '//avail_hist_fields(n)%vname)

status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'Error deflating variable '//avail_hist_fields(n)%vname)

Expand Down Expand Up @@ -820,7 +849,8 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice( &
'Error defining variable '//avail_hist_fields(n)%vname)

status = nf90_def_var_deflate(ncid, varid, 1, 1, 1)
status = nf90_def_var_deflate(ncid, varid, shuffle, deflate, &
deflate_level)
if (status /= nf90_noerr) call abort_ice( &
'Error deflating variable '//avail_hist_fields(n)%vname)

Expand Down
4 changes: 4 additions & 0 deletions source/ice_history_shared.F90
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ module ice_history_shared
history_dir , & ! directory name for history file
incond_dir ! directory for snapshot initial conditions

integer, public :: &
history_deflate_level ! Deflation/compression level to use for
! netCDF4 output

character (len=char_len_long), public :: &
pointer_file ! input pointer file for restarts

Expand Down
10 changes: 8 additions & 2 deletions source/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ subroutine input_data(forcing_start_date, seconds_since_start_year, &
restart, restart_ext, input_dir, input_dir, restart_dir, restart_file, &
pointer_file, runid, runtype, use_restart_time, restart_format
use ice_history_shared, only: hist_avg, history_dir, history_file, &
incond_dir, incond_file
history_deflate_level, incond_dir, incond_file
use ice_exit, only: abort_ice
use ice_itd, only: kitd, kcatbound
use ice_ocean, only: oceanmixed_ice, tfrz_option
Expand Down Expand Up @@ -138,7 +138,7 @@ subroutine input_data(forcing_start_date, seconds_since_start_year, &
diagfreq, diag_type, diag_file, &
print_global, print_points, latpnt, lonpnt, &
dbug, histfreq, histfreq_n, hist_avg, &
history_dir, history_file, &
history_dir, history_file, history_deflate_level, &
write_ic, incond_dir, incond_file

namelist /grid_nml/ &
Expand Down Expand Up @@ -228,6 +228,9 @@ subroutine input_data(forcing_start_date, seconds_since_start_year, &
hist_avg = .true. ! if true, write time-averages (not snapshots)
history_dir = './' ! write to executable dir for default
history_file = 'iceh' ! history file name prefix
history_deflate_level = -1 ! Deflate/compression level to use when
! writing netCDF4 history files, -1
! means no deflation
write_ic = .false. ! write out initial condition
incond_dir = history_dir ! write to history dir for default
incond_file = 'iceh_ic'! file prefix
Expand Down Expand Up @@ -743,6 +746,7 @@ subroutine input_data(forcing_start_date, seconds_since_start_year, &
call broadcast_scalar(hist_avg, master_task)
call broadcast_scalar(history_dir, master_task)
call broadcast_scalar(history_file, master_task)
call broadcast_scalar(history_deflate_level, master_task)
call broadcast_scalar(write_ic, master_task)
call broadcast_scalar(incond_dir, master_task)
call broadcast_scalar(incond_file, master_task)
Expand Down Expand Up @@ -910,6 +914,8 @@ subroutine input_data(forcing_start_date, seconds_since_start_year, &
trim(history_dir)
write(nu_diag,*) ' history_file = ', &
trim(history_file)
write(nu_diag,*) ' history_deflate_level = ', &
history_deflate_level
if (write_ic) then
write (nu_diag,*) 'Initial condition will be written in ', &
trim(incond_dir)
Expand Down

0 comments on commit 5526bdb

Please sign in to comment.