segment_trajectory_json Subroutine

public subroutine segment_trajectory_json(seg, iseg, last, buf)

The JSON object of a segment's trajectory (for export_trajectory_json_file), replacing the contents of buf.

Arguments

Type IntentOptional Attributes Name
type(segment), intent(in) :: seg
integer, intent(in) :: iseg

segment number

logical, intent(in) :: last

if this is the last segment (no comma after it)

type(text_buffer), intent(inout) :: buf

Calls

proc~~segment_trajectory_json~~CallsGraph proc~segment_trajectory_json segment_trajectory_json proc~add_int text_buffer%add_int proc~segment_trajectory_json->proc~add_int proc~add_real_array text_buffer%add_real_array proc~segment_trajectory_json->proc~add_real_array proc~add_str text_buffer%add_str proc~segment_trajectory_json->proc~add_str proc~clear text_buffer%clear proc~segment_trajectory_json->proc~clear proc~add_digits add_digits proc~add_int->proc~add_digits proc~add_real_array->proc~add_str proc~add_real_list text_buffer%add_real_list proc~add_real_array->proc~add_real_list proc~reserve text_buffer%reserve proc~add_real_array->proc~reserve proc~add_str->proc~reserve proc~add_digits->proc~add_str proc~add_real_list->proc~add_str proc~add_real_list->proc~reserve proc~add_real text_buffer%add_real proc~add_real_list->proc~add_real proc~add_real->proc~add_str proc~add_real->proc~add_digits proc~add_real->proc~reserve proc~scaled scaled proc~add_real->proc~scaled proc~two_prod two_prod proc~scaled->proc~two_prod proc~split split proc~two_prod->proc~split

Called by

proc~~segment_trajectory_json~~CalledByGraph proc~segment_trajectory_json segment_trajectory_json proc~export_trajectory_json_file mission_type%export_trajectory_json_file proc~export_trajectory_json_file->proc~segment_trajectory_json proc~halo_solver_main halo_solver_main proc~halo_solver_main->proc~export_trajectory_json_file

Source Code

    subroutine segment_trajectory_json(seg, iseg, last, buf)

    implicit none

    type(segment),intent(in) :: seg
    integer,intent(in) :: iseg  !! segment number
    logical,intent(in) :: last  !! if this is the last segment (no comma after it)
    type(text_buffer),intent(inout) :: buf

    character(len=*),parameter :: nl = new_line('a')

    call buf%clear()
    call buf%add_str('    {'//nl//'      "iseg": ')
    call buf%add_int(iseg)
    call add_array('et',          seg%traj_inertial%et)
    call add_array('x_inertial',  seg%traj_inertial%x)
    call add_array('y_inertial',  seg%traj_inertial%y)
    call add_array('z_inertial',  seg%traj_inertial%z)
    call add_array('vx_inertial', seg%traj_inertial%vx)
    call add_array('vy_inertial', seg%traj_inertial%vy)
    call add_array('vz_inertial', seg%traj_inertial%vz)
    call add_array('x_rotating',  seg%traj_rotating%x)
    call add_array('y_rotating',  seg%traj_rotating%y)
    call add_array('z_rotating',  seg%traj_rotating%z)
    call add_array('x_se_rotating', seg%traj_se_rotating%x)
    call add_array('y_se_rotating', seg%traj_se_rotating%y)
    call add_array('z_se_rotating', seg%traj_se_rotating%z)
    if (last) then
        call buf%add_str(nl//'    }'//nl)
    else
        call buf%add_str(nl//'    },'//nl)
    end if

    contains

        subroutine add_array(name, x)
        character(len=*),intent(in) :: name
        real(wp),dimension(:),intent(in) :: x
        call buf%add_str(','//nl//'      "'//name//'": ')
        call buf%add_real_array(x)
        end subroutine add_array

    end subroutine segment_trajectory_json