Manual Reference Pages  - adjustr (3fortran)

NAME

ADJUSTR(3) - [CHARACTER:WHITESPACE] Right-justify a string

SYNOPSIS

result = adjustr(string)

       elemental character(len=len(string),kind=KIND) function adjustr(string)

character(len=*,kind=KIND),intent(in) :: string

CHARACTERISTICS

o STRING is a character variable
o The return value is a character variable of the same kind and length as STRING

DESCRIPTION

ADJUSTR(3) right-justifies a string by removing trailing spaces. Spaces are inserted at the start of the string as needed to retain the original length.

OPTIONS

o STRING : the string to right-justify

RESULT

Trailing spaces are removed and the same number of spaces are inserted at the start of STRING.

EXAMPLES

Sample program:

    program demo_adjustr
    implicit none
    character(len=20) :: str
       ! print a short number line
       write(*,’(a)’)repeat(’1234567890’,2)

! basic usage str = ’ sample string ’ write(*,’(a)’) str str = adjustr(str) write(*,’(a)’) str

! ! elemental ! write(*,’(a)’)repeat(’1234567890’,5) write(*,’(a)’)adjustr([character(len=50) :: & ’ first ’, & ’ second ’, & ’ third ’ ]) write(*,’(a)’)repeat(’1234567890’,5)

end program demo_adjustr

Results:

       > 12345678901234567890
       >   sample string
       >        sample string
       > 12345678901234567890123456789012345678901234567890
       >                                              first
       >                                             second
       >                                              third
       > 12345678901234567890123456789012345678901234567890

STANDARD

Fortran 95

SEE ALSO

ADJUSTL(3), TRIM(3)

Fortran intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 adjustr (3fortran) November 02, 2024
Generated by manServer 1.08 from 6c98294b-5c0c-4265-95d0-efcb99c50fbd using man macros.