write_diagnostics_row Subroutine

public subroutine write_diagnostics_row(params, flow, step, time, stats)

Appends a new row of diagnostic data to the CSV file.

Arguments

Type IntentOptional Attributes Name
type(case_params_t), intent(in) :: params
type(flow_mpi_t), intent(in) :: flow
integer, intent(in) :: step
real(kind=rk), intent(in) :: time
type(solver_stats_t), intent(in) :: stats

Source Code

   subroutine write_diagnostics_row(params, flow, step, time, stats)
      type(case_params_t), intent(in) :: params
      type(flow_mpi_t), intent(in) :: flow
      integer, intent(in) :: step
      real(rk), intent(in) :: time
      type(solver_stats_t), intent(in) :: stats

      integer :: unit_id
      character(len=path_len + 32) :: filename

      if (flow%rank /= 0 .or. .not. params%write_diagnostics) return

      filename = trim(params%output_dir)//'/diagnostics/diagnostics.csv'
      open(newunit=unit_id, file=trim(filename), status='old', position='append', action='write')

      write(unit_id,'(i0,a,ES26.16E4,a,ES26.16E4,a,ES26.16E4,a,ES26.16E4,a,ES26.16E4,a,ES26.16E4,a,'// &
                    'i0,a,i0,a,i0,a,ES26.16E4,a,i0,a,ES26.16E4,a,ES26.16E4,a,ES26.16E4,a,'// &
                    'ES26.16E4,a,ES26.16E4,a,ES26.16E4,a,ES26.16E4)') &
            step, ',', time, ',', params%dt, ',', stats%max_divergence, ',', &
            stats%rms_divergence, ',', stats%net_boundary_flux, ',', &
            stats%kinetic_energy, ',', stats%pressure_iterations, ',', &
            stats%pressure_iterations_total, ',', stats%pressure_iterations_max, ',', &
            stats%pressure_iterations_avg, ',', stats%pressure_solve_count, ',', &
            stats%pressure_residual, ',', stats%pressure_residual_abs, ',', stats%cfl, ',', stats%wall_time, ',', &
            stats%max_velocity, ',', stats%total_mass, ',', stats%min_species_y

      close(unit_id)
   end subroutine write_diagnostics_row