Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/history/cam_hist_file.F90
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,9 @@ subroutine config_set_up_fields(this, possible_field_list)
field_ptr%units(), field_ptr%type(), field_ptr%decomp(), &
dimensions, this%accumulate_types(idx), field_ptr%num_levels(), &
field_shape, beg_dims=beg_dim, end_dims=end_dim, &
mixing_ratio=field_ptr%mixing_ratio())
mixing_ratio=field_ptr%mixing_ratio(), &
flag_xyfill=field_ptr%flag_xyfill(), &
sampling_seq=field_ptr%sampling_sequence())
call hist_new_buffer(field_info, field_shape, &
this%rl_kind, 1, this%accumulate_types(idx), 1, errors=errors)
if (masterproc) then
Expand Down Expand Up @@ -912,6 +914,8 @@ subroutine config_define_file(this, restart, logname, host, model_doi_url)
use cam_history_support, only: write_hist_coord_attrs
use cam_history_support, only: write_hist_coord_vars
use cam_history_support, only: max_chars
use cam_history_support, only: fillvalue
use shr_kind_mod, only: r4 => shr_kind_r4
use time_manager, only: get_ref_date, timemgr_get_calendar_cf
use time_manager, only: get_step_size
use string_utils, only: date2yyyymmdd, sec2hms, stringify
Expand Down Expand Up @@ -1285,8 +1289,20 @@ subroutine config_define_file(this, restart, logname, host, model_doi_url)
call cam_pio_handle_error(ierr, 'config_define_file: cannot define Sampling_Sequence for '//trim(fname_tmp))
end if
if (this%field_list(field_index)%flag_xyfill()) then
! peverwhee - TODO: implement fill values!
call endrun('config_define_file: fill values not yet implemented!', file=__FILE__, line=__LINE__)
! Write _FillValue and missing_value attributes so that
! netCDF-aware tools (ncview, ncdump, etc.) recognise fill
! values. The attribute type must match the variable type.
if (ncreal == pio_double) then
ierr = pio_put_att(this%hist_files(split_file_index), varid, '_FillValue', fillvalue)
call cam_pio_handle_error(ierr, subname//'cannot define _FillValue for '//trim(fname_tmp))
ierr = pio_put_att(this%hist_files(split_file_index), varid, 'missing_value', fillvalue)
call cam_pio_handle_error(ierr, subname//'cannot define missing_value for '//trim(fname_tmp))
else
ierr = pio_put_att(this%hist_files(split_file_index), varid, '_FillValue', real(fillvalue, r4))
call cam_pio_handle_error(ierr, subname//'cannot define _FillValue for '//trim(fname_tmp))
ierr = pio_put_att(this%hist_files(split_file_index), varid, 'missing_value', real(fillvalue, r4))
call cam_pio_handle_error(ierr, subname//'cannot define missing_value for '//trim(fname_tmp))
end if
end if
str = this%field_list(field_index)%units()
if (len_trim(str) > 0) then
Expand Down
5 changes: 4 additions & 1 deletion src/history/cam_history.F90
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,10 @@ subroutine history_add_field_nd(diagnostic_name, standard_name, dimnames, avgfla
cell_methods = ''
end if

! peverwhee - TODO: handle fill values
! Fill values: flag_xyfill is propagated to the hist file field_list
! and _FillValue / missing_value attributes are written in
! config_define_file (cam_hist_file.F90).
! TODO: fill-aware accumulation for averaged output.

allocate(mdim_indices(size(dimnames)), stat=ierr)
call check_allocate(ierr, subname, 'mdim_indices', file=__FILE__, line=__LINE__-1)
Expand Down
Loading