print, ‘index=’, i write(6,) ‘str_piece(wc)=’, trim(str_piece(wc))
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=length_mx), | intent(in) | :: | string_in | |||
integer, | intent(in) | :: | length_mx | |||
integer, | intent(in) | :: | mxseg | |||
integer, | intent(out) | :: | nseg | |||
character(len=length_mx), | intent(out) | :: | str_piece(mxseg) | |||
integer, | intent(out) | :: | jstatus |
subroutine split_string_by_space (string_in, length_mx, & mxseg, nseg, str_piece, jstatus) integer, intent (in) :: length_mx character (len=length_mx), intent (in) :: string_in integer, intent (in) :: mxseg integer, intent (out):: nseg character (len=length_mx), intent (out):: str_piece(mxseg) integer, intent (out):: jstatus character (len=length_mx) :: string character (len=1) :: mark integer :: ios integer :: wc ! ! "xxxx yy zz uu vv" ! ! split by space '' mark=' ' wc=0 ios=0 string = trim( adjustl(string_in) ) do while (ios==0) i = index (string, mark) !!print*, 'index=', i if (i > 1) then wc = wc + 1 str_piece(wc)=trim(adjustl(string(1:i))) !!write(6,*) 'str_piece(wc)=', trim(str_piece(wc)) string = trim(adjustl(string(i:))) else ios=1 end if if (LEN_TRIM(adjustl(string)) == 0) ios=1 end do nseg=wc return end subroutine split_string_by_space