add_vector Subroutine

private subroutine add_vector(me, val, int_fmt, real_fmt, trim_str)

Add a vector to a CSV file. Each element is added as a cell to the current line.

Type Bound

csv_file

Arguments

Type IntentOptional Attributes Name
class(csv_file), intent(inout) :: me
class(*), intent(in), dimension(:) :: val

the values to add

character(len=*), intent(in), optional :: int_fmt

if val is an integer, use this format string.

character(len=*), intent(in), optional :: real_fmt

if val is a real, use this format string.

logical, intent(in), optional :: trim_str

if val is a string, then trim it.


Calls

proc~~add_vector~~CallsGraph proc~add_vector csv_file%add_vector none~add csv_file%add proc~add_vector->none~add none~add->proc~add_vector proc~add_cell csv_file%add_cell none~add->proc~add_cell proc~add_matrix csv_file%add_matrix none~add->proc~add_matrix proc~add_matrix->none~add proc~next_row csv_file%next_row proc~add_matrix->proc~next_row

Called by

proc~~add_vector~~CalledByGraph proc~add_vector csv_file%add_vector none~add csv_file%add proc~add_vector->none~add none~add->proc~add_vector proc~add_matrix csv_file%add_matrix none~add->proc~add_matrix proc~add_matrix->none~add

Source Code

    subroutine add_vector(me,val,int_fmt,real_fmt,trim_str)

    implicit none

    class(csv_file),intent(inout) :: me
    class(*),dimension(:),intent(in) :: val  !! the values to add
    character(len=*),intent(in),optional :: int_fmt  !! if `val` is an integer, use
                                                     !! this format string.
    character(len=*),intent(in),optional :: real_fmt !! if `val` is a real, use
                                                     !! this format string.
    logical,intent(in),optional :: trim_str !! if `val` is a string, then trim it.

    integer :: i !! counter

    do i=1,size(val)

#if ( defined __GFORTRAN__ ) && ( __GNUC__ <= 10 )
        ! This is a stupid workaround for gfortran bugs (tested with 7.2.0)
        select type (val)
        type is (character(len=*))
            call me%add(val(i),int_fmt,real_fmt,trim_str)
        class default
            call me%add(val(i),int_fmt,real_fmt,trim_str)
        end select
#else
        call me%add(val(i),int_fmt,real_fmt,trim_str)
#endif

    end do

    end subroutine add_vector