Skip to content

Commit

Permalink
Clean up marbl_io_write_history interface
Browse files Browse the repository at this point in the history
Get num_active_levels from marbl_instances%domain%kmt (and revert back to
write_diag() call that does not highlight marbl-ecosys#176)

Note that this is a good step towards different columns with different KMTs
being treated correctly, though I still need to move the read_domain call into
the num_inst loop.
  • Loading branch information
mnlevy1981 committed Feb 8, 2019
1 parent 4477940 commit e5851db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/driver_src/marbl_compute_cols_drv.F90
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ subroutine test(marbl_instances, num_PAR_subcols, driver_status_log)
end if

! 8. Output netCDF
call marbl_io_write_history(outfile, num_active_levels, marbl_instances, driver_status_log)
call marbl_io_write_history(outfile, marbl_instances, driver_status_log)
if (driver_status_log%labort_marbl) then
call driver_status_log%log_error_trace('marbl_io_write_history', subname)
return
Expand Down
16 changes: 8 additions & 8 deletions tests/driver_src/marbl_io_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -488,18 +488,15 @@ end subroutine marbl_io_define_history

!*****************************************************************************

subroutine marbl_io_write_history(outfile, num_active_levels, marbl_instances, driver_status_log)
subroutine marbl_io_write_history(outfile, marbl_instances, driver_status_log)

character(len=*), intent(in) :: outfile
integer, intent(in) :: num_active_levels
type(marbl_interface_class), dimension(:), intent(in) :: marbl_instances
type(marbl_log_type), intent(inout) :: driver_status_log

character(len=*), parameter :: subname = 'marbl_io_mod:marbl_io_write_history'
character(len=char_len) :: log_message
integer :: n, diag_size
integer :: file_id
integer :: num_inst
integer :: n, diag_size, file_id, num_inst, num_active_levels

! Get file_id given file_name
file_id = get_nc_file_id(outfile, driver_status_log)
Expand All @@ -516,6 +513,7 @@ subroutine marbl_io_write_history(outfile, num_active_levels, marbl_instances, d
! 2) Surface diagnostics
diag_size = size(marbl_instances(1)%surface_flux_diags%diags)
do num_inst=1, size(marbl_instances)
num_active_levels = marbl_instances(num_inst)%domain%kmt
do n=1, diag_size
call write_diag(file_id, marbl_instances(num_inst)%surface_flux_diags, n, num_inst, num_active_levels, &
surface_diag_ids(n), driver_status_log)
Expand All @@ -530,10 +528,11 @@ subroutine marbl_io_write_history(outfile, num_active_levels, marbl_instances, d
! 3) Interior diagnostics
diag_size = size(marbl_instances(1)%interior_tendency_diags%diags)
do num_inst=1, size(marbl_instances)
! FIXME #176: changing num_active_levels to num_levels (km instead of kmt) will populate levels below
! num_active_levels with nonsensical values
num_active_levels = marbl_instances(num_inst)%domain%kmt
do n=1, diag_size
! FIXME #176: changing num_active_levels to num_levels (60) will populate levels below
! num_active_levels with nonsensical values
call write_diag(file_id, marbl_instances(num_inst)%interior_tendency_diags, n, num_inst, num_active_levels+5, &
call write_diag(file_id, marbl_instances(num_inst)%interior_tendency_diags, n, num_inst, num_active_levels, &
interior_diag_ids(n), driver_status_log)
if (driver_status_log%labort_marbl) then
write(log_message, "(3A)") 'write_diag(', trim(marbl_instances(1)%interior_tendency_diags%diags(n)%short_name), ')'
Expand All @@ -545,6 +544,7 @@ subroutine marbl_io_write_history(outfile, num_active_levels, marbl_instances, d

! 4) Surface fluxes and Tracer tendencies
do num_inst=1, size(marbl_instances)
num_active_levels = marbl_instances(num_inst)%domain%kmt
do n=1, size(marbl_instances(num_inst)%tracer_metadata)
call netcdf_check(nf90_put_var(file_id, prog_ids_out%sflux_ids(n), marbl_instances(num_inst)%surface_fluxes(1,n), &
(/1, num_inst/)), driver_status_log)
Expand Down

0 comments on commit e5851db

Please sign in to comment.