dc_string::split Interface Reference

Private Member Functions

subroutine split_cc (str, carray, sep, limit)
 

Detailed Description

Definition at line 118 of file dc_string.f90.

Member Function/Subroutine Documentation

◆ split_cc()

subroutine dc_string::split::split_cc ( character(*), intent(in)  str,
character(*), dimension(:), pointer  carray,
character(*), intent(in)  sep,
integer, intent(in), optional  limit 
)
private

Definition at line 1143 of file dc_string.f90.

1143  !
1144  ! *str* で与えられた文字列を 文字列 *sep* で分解し,
1145  ! ポインタ配列 *carray* に返します.
1146  ! *carray* は必ず空状態にして与えてください. 割り付け状態の
1147  ! 場合にはエラーを返します.
1148  !
1149  ! *limit* に正の数を与えた場合, 最大 *limit* 個のフィールドに分割
1150  ! します. 負の数や 0 の場合は省略した場合と同じになります. *str*
1151  ! の末尾の空白は除去されます. *sep* に空文字を代入する場合, 空白
1152  ! 文字で分割されます.
1153  !
1154  use dc_types, only: string
1155  implicit none
1156  character(*), intent(in):: str
1157  character(*), pointer:: carray(:) !(out)
1158  character(*), intent(in):: sep
1159  integer, intent(in), optional:: limit
1160  integer :: num, cur, i, limitnum
1161  character(STRING) :: substr
1162  logical :: end_flag
1163  continue
1164  if (present(limit)) then
1165  if (limit > 0) then
1166  limitnum = limit
1167  else
1168  limitnum = 0
1169  end if
1170  else
1171  limitnum = 0
1172  end if
1173 
1174  if (len(trim(sep)) == 0) then
1175  num = 1
1176  substr = str
1177  ! 重複して無駄だが carray を allocate するため, 何分割するか
1178  ! 調べ, num に格納する.
1179  do
1180  cur = index(trim(substr), ' ')
1181  if (cur == 0) exit
1182  num = num + 1
1183  substr = adjustl(substr(cur + len(sep) :len(substr)))
1184  end do
1185 
1186  if (limitnum /= 0 .and. num > limitnum) num = limitnum
1187  allocate(carray(num))
1188 
1189  substr = str
1190  end_flag = .false.
1191  do i = 1, num
1192  cur = index(trim(substr), ' ')
1193  if (cur == 0 .or. i == num) end_flag = .true.
1194  if (end_flag) then
1195  carray(i) = substr
1196  exit
1197  else
1198  carray(i) = substr(1:cur - 1)
1199  end if
1200  substr = adjustl(substr(cur + len(sep) :len(substr)))
1201  end do
1202 
1203  else
1204  num = 1
1205  substr = str
1206  ! 重複して無駄だが carray を allocate するため, 何分割するか
1207  ! 調べ, num に格納する.
1208  do
1209  cur = index(substr, trim(sep))
1210  if (cur == 0) exit
1211  num = num + 1
1212  substr = substr(cur + len(sep) :len(substr))
1213  end do
1214 
1215  if (limitnum /= 0 .and. num > limitnum) num = limitnum
1216  allocate(carray(num))
1217 
1218  substr = str
1219  end_flag = .false.
1220  do i = 1, num
1221  cur = index(substr, trim(sep))
1222  if (cur == 0 .or. i == num) end_flag = .true.
1223  if (end_flag) then
1224  carray(i) = substr
1225  exit
1226  else
1227  carray(i) = substr(1:cur - 1)
1228  end if
1229  substr = substr(cur + len(sep) :len(substr))
1230  end do
1231  end if
1232 
1233  return
1234 
種別型パラメタを提供します。
Definition: dc_types.f90:49
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition: dc_types.f90:118

The documentation for this interface was generated from the following file: