ADJUSTL(3f) - [M_unicode:WHITESPACE] Left-justified a string (LICENSE:MIT)
Synopsis
Characteristics
Description
Options
Result
Examples
See Also
Author
License
result = adjustl(string,glyphs)
function adjustl(string,glyphs) result(out)type(unicode_type),intent(in) :: string integer,intent(in),optional :: glyphs type(unicode_type) :: out
o STRING is a string variable of type(unicode_type) o GLYPHS is a default integer o The return value is a string variable of type(unicode_type)
adjustl(3) will left-justify a string by removing leading spaces. Spaces are inserted at the end of the string as needed to keep the number of glyphs on output the same as the number on input unless overridden by the GLYPHS parameter.
o STRING : the string to left-justify o GLYPHS : the length of the output in glyphs
A copy of STRING where leading spaces are removed and the same number of spaces are inserted on the end of STRING unless GLYPHS is specified. Note using GLYPHS can cause in string truncation.
Sample program:
program demo_adjustl use M_unicode, only : ut=>unicode_type use M_unicode, only : ch=>character use M_unicode, only : adjustl, trim, len_trim, verify use M_unicode, only : write(formatted) use M_unicode, only : assignment(=) implicit none type(ut) :: usample, uout integer :: istart, iend character(len=*),parameter :: adt = (a,"[",DT,"]") ! ! basic use usample= sample string write(*,adt) original: ,usample ! ! note a string stays the same length ! and is not trimmed by just an adjustl(3) call. write(*,adt) adjusted: ,adjustl(usample) ! ! a fixed‐length string can be trimmed using trim(3) uout=trim(adjustl(usample)) write(*,adt) trimmed: ,uout ! ! or alternatively you can select a substring without adjusting istart= max(1,verify(usample, )) ! first non‐blank character iend = len_trim(usample) write(*,adt) substring:,usample%sub(istart,iend) ! write(*,adt) substring:,adjustl(usample,30) write(*,adt) substring:,adjustl(usample,20) write(*,adt) substring:,adjustl(usample,10) write(*,adt) substring:,adjustl(usample,0) end program demo_adjustlResults:
> original: [ sample string ] > adjusted: [sample string ] > trimmed: [sample string] > substring:[sample string]
ADJUSTR(3), TRIM(3)
John S. Urban
