ADJUSTR(3) - [CHARACTER:WHITESPACE] Right-justify a string
result = adjustr(string)
elemental character(len=len(string),kind=KIND) function adjustr(string)character(len=*,kind=KIND),intent(in) :: string
o STRING is a character variable o The return value is a character variable of the same kind and length as STRING
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.
o STRING : the string to right-justify
Trailing spaces are removed and the same number of spaces are inserted at the start of STRING.
Sample program:
program demo_adjustr implicit none character(len=20) :: str ! print a short number line write(*,(a))repeat(1234567890,2)Results:! 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
> 12345678901234567890 > sample string > sample string > 12345678901234567890123456789012345678901234567890 > first > second > third > 12345678901234567890123456789012345678901234567890
Fortran 95
ADJUSTL(3), TRIM(3)
Fortran intrinsic descriptions (license: MIT) @urbanjost
Nemo Release 3.1 | adjustr (3fortran) | November 02, 2024 |