str_a_R4P Function

private pure function str_a_R4P(n, no_sign, separator, delimiters, compact) result(str)

Convert real array to string.

 use penf
 print "(A)", str(n=[1._R4P, -2._R4P])
 use penf
 print "(A)", str(n=[1._R4P, 2._R4P], no_sign=.true.)
 use penf
 print "(A)", str(n=[1._R4P, -2._R4P], separator='|')
 use penf
 print "(A)", str(n=[1._R4P, -2._R4P], delimiters=['(', ')'])
 use penf
 print "(A)", str(n=[1._R4P, -2._R4P], compact=.true.)

Arguments

TypeIntentOptionalAttributesName
real(kind=R4P), intent(in) :: n(:)

Real array to be converted.

logical, intent(in), optional :: no_sign

Flag for leaving out the sign.

character(len=1), intent(in), optional :: separator

Eventual separator of array values.

character, intent(in), optional :: delimiters(1:2)

Eventual delimiters of array values.

logical, intent(in), optional :: compact

Flag for compacting string encoding.

Return Value character(len=:),allocatable

Returned string containing input number.


Calls

proc~~str_a_r4p~~CallsGraph proc~str_a_r4p str_a_R4P proc~str_r4p str_R4P proc~str_a_r4p->proc~str_r4p proc~compact_real_string compact_real_string proc~str_r4p->proc~compact_real_string

Called by

proc~~str_a_r4p~~CalledByGraph proc~str_a_r4p str_a_R4P interface~str str interface~str->proc~str_a_r4p proc~printf printf proc~printf->interface~str proc~bctoi_i8p bctoi_I8P proc~bctoi_i8p->interface~str proc~printf~4 printf proc~printf~4->interface~str proc~printf~2 printf proc~printf~2->interface~str proc~bctoi_i2p bctoi_I2P proc~bctoi_i2p->interface~str program~volatile_doctest~33 volatile_doctest program~volatile_doctest~33->interface~str program~volatile_doctest~229 volatile_doctest program~volatile_doctest~229->interface~str program~volatile_doctest~369 volatile_doctest program~volatile_doctest~369->interface~str program~volatile_doctest~645 volatile_doctest program~volatile_doctest~645->interface~str proc~bctoi_i1p bctoi_I1P proc~bctoi_i1p->interface~str proc~printf~3 printf proc~printf~3->interface~str proc~bctoi_i4p bctoi_I4P proc~bctoi_i4p->interface~str program~volatile_doctest~30 volatile_doctest program~volatile_doctest~30->interface~str program~volatile_doctest~412 volatile_doctest program~volatile_doctest~412->interface~str program~volatile_doctest~512 volatile_doctest program~volatile_doctest~512->interface~str program~volatile_doctest~744 volatile_doctest program~volatile_doctest~744->interface~str interface~bcton bcton interface~bcton->proc~bctoi_i8p interface~bcton->proc~bctoi_i2p interface~bcton->proc~bctoi_i1p interface~bcton->proc~bctoi_i4p

Contents

Source Code


Source Code

   pure function str_a_R4P(n, no_sign, separator, delimiters, compact) result(str)
   !< Convert real array to string.
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=[1._R4P, -2._R4P])
   !<```
   !=> +0.100000E+01,-0.200000E+01 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=[1._R4P, 2._R4P], no_sign=.true.)
   !<```
   !=> 0.100000E+01,0.200000E+01 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=[1._R4P, -2._R4P], separator='|')
   !<```
   !=> +0.100000E+01|-0.200000E+01 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=[1._R4P, -2._R4P], delimiters=['(', ')'])
   !<```
   !=> (+0.100000E+01,-0.200000E+01) <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=[1._R4P, -2._R4P], compact=.true.)
   !<```
   !=> +0.1E+1,-0.2E+1 <<<
   real(R4P),    intent(in)           :: n(:)            !< Real array to be converted.
   logical,      intent(in), optional :: no_sign         !< Flag for leaving out the sign.
   character(1), intent(in), optional :: separator       !< Eventual separator of array values.
   character(*), intent(in), optional :: delimiters(1:2) !< Eventual delimiters of array values.
   logical,      intent(in), optional :: compact         !< Flag for *compacting* string encoding.
   character(len=:), allocatable      :: str             !< Returned string containing input number.
   character(DR4P)                    :: strn            !< String containing of element of input array number.
   character(len=1)                   :: sep             !< Array values separator
   integer                            :: i               !< Counter.

   str = ''
   sep = ','
   if(present(separator)) sep = separator
   do i=1,size(n)
     strn = str_R4P(no_sign=no_sign, compact=compact, n=n(i))
     str = str//sep//trim(strn)
   enddo
   str = trim(str(2:))
   if (present(delimiters)) str = delimiters(1)//str//delimiters(2)
   endfunction str_a_R4P