gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
dc_url.f90
Go to the documentation of this file.
1!-----------------------------------------------------------------------
2! Copyright (c) 2000-2026 Gtool Development Group. All rights reserved.
3!-----------------------------------------------------------------------
4!>
5!> @author Youhei SASAKI, Yasuhiro MORIKAWA, Eizi TOYODA
6!> @copyright Copyright (C) GFD Dennou Club, 2000-2026. All rights reserved. <br/>
7!> License is BSD-2-Clause. see [COPYRIGHT](@ref COPYRIGHT) in detail
8!> @en
9!> @brief Variable URL string parser
10!> @details
11!> This module provides procedures for parsing gtool4 variable URL strings.
12!>
13!> See "5. Various String Formats" of gtool4 netCDF convention
14!> for variable URL format.
15!>
16!> @section url_procedures Procedures Summary
17!>
18!> | Procedure | Description |
19!> |--------------------|----------------------------------------------------------------|
20!> | UrlSplit | Split variable URL to filename, variable name, attribute name and I/O range |
21!> | UrlMerge | Merge filename, variable name, attribute name and I/O range to variable URL |
22!> | UrlResolve | Complement variable URL |
23!> | Url_Chop_IOrange | Remove iorange from variable URL |
24!> | UrlSearchIORange | Get I/O range value for a dimension from variable URL |
25!> | operator(.OnTheSameFile.) | Check if two variable URLs point to the same file |
26!>
27!> This module provides mnemonics for special characters in gtool4 variables.
28!> When parsing gtool4 variables, use the variables provided here (GT_ATMARK, etc.)
29!> instead of using characters directly.
30!>
31!> @enden
32!>
33!> @ja
34!> @brief 変数 URL の文字列解析
35!> @details
36!> このモジュールは gtool4 変数 URL の文字列解析
37!> を行うための手続きを提供します。
38!>
39!> gtool4 変数の書式に関しては,
40!> gtool4 netCDF 規約の「5. 各種の文字列書式」を参照ください。
41!>
42!> @section url_procedures_ja 手続き群の要約
43!>
44!> | 手続名 | 説明 |
45!> |--------------------|----------------------------------------------------------------|
46!> | UrlSplit | 変数 URL を分解しファイル名、変数名、属性名および入出力範囲指定を取り出す |
47!> | UrlMerge | ファイル名、変数名、属性名および入出力範囲指定を連結して変数 URL を作成 |
48!> | UrlResolve | 変数 URL の補完 |
49!> | Url_Chop_IOrange | 変数 URL から iorange を除去 |
50!> | UrlSearchIORange | 変数 URL 内の iorange うち, ある次元に関する入出力範囲指定の値を取得 |
51!> | operator(.OnTheSameFile.) | 2 つの変数 URL が同じファイルを指すかどうか判定 |
52!>
53!> このモジュールは gtool4 変数において特別な役割を果たす
54!> 文字のニーモニックを提供します。gtool4 変数解析の際には、
55!> 直接文字を用いるのではなく、ここで提供する変数群
56!> (GT_ATMARK 等) を利用してください。
57!>
58!> @endja
59!>
60
61module dc_url
62 implicit none
63 private
64
65 public:: url_chop_iorange
66 public:: operator(.onthesamefile.)
67
68 public:: urlmerge
69 interface urlmerge
70! module procedure url_merge_v_vvv
71 module procedure url_merge_cc
72 module procedure url_merge_cccc
73 module procedure url_merge_cccca
74 end interface
75
76 public:: urlsplit
77 interface urlsplit
78! module procedure url_split_v
79 module procedure url_split_c
80 end interface
81
82 public:: urlresolve
83 interface urlresolve
84 module procedure url_resolve_c
85 end interface
86
87 public:: urlsearchiorange
89 module procedure url_search_iorange
90 end interface
91
92 interface operator(.onthesamefile.)
93 module procedure urlonthesamefile
94 end interface
95
96 character, public, parameter:: gt_atmark = "@"
97 ! ファイル名と変数名の区切りに用いられます。
98 character, public, parameter:: gt_question = "?"
99 ! ファイル名と変数名の区切りに用いられます。
100 character, public, parameter:: gt_colon = ":"
101 ! 変数の属性を示す時に用いられます。
102 character, public, parameter:: gt_comma = ","
103 ! 入出力範囲の限定に用いられます。
104 character, public, parameter:: gt_equal = "="
105 ! 入出力範囲の限定に用いられます。
106 character, public, parameter:: gt_circumflex = "^"
107 ! 座標の位置を値ではなく、
108 ! 格子点番号で指定する時に用いられます。
109 character, public, parameter:: gt_plus = "+"
110 ! 属性の行頭にこの文字がつく場合、大域属性を示します。
111
112contains
113
114 ! ANUrlMerge - 変数 URL の合成
115 ! 空文字列の成分はないとみなされる。
116
117! type(VSTRING) function &
118! & url_merge_v_vvv(file, var, attr, iorange) result(result) !:nodoc:
119! use dcstring_base, only: VSTRING, operator(.cat.), operator(/=), &
120! & extract, operator(==) !:nodoc:
121! implicit none
122! type(VSTRING), intent(in):: file
123! type(VSTRING), intent(in), optional:: var
124! type(VSTRING), intent(in), optional:: attr
125! type(VSTRING), intent(in), optional:: iorange
126! result = file .cat. GT_ATMARK
127! if (present(var)) result = result .cat. var
128! if (present(attr)) then
129! if (attr /= "") result = result .cat. GT_COLON .cat. attr
130! endif
131! if (present(iorange)) then
132! if (extract(iorange, 1, 1) == GT_COMMA) then
133! result = result .cat. iorange
134! else if (iorange /= "") then
135! result = result .cat. GT_COMMA .cat. iorange
136! endif
137! endif
138! end function
139
140 !> @en
141 !> @brief Merge filename and variable name to URL
142 !> @details
143 !> Concatenates filename `file` and variable name `var` and returns
144 !> as `result`.
145 !>
146 !> @param[in] file Filename
147 !> @param[in] var Variable name
148 !> @return Merged variable URL
149 !> @enden
150 !>
151 !> @ja
152 !> @brief ファイル名と変数名を URL に結合
153 !> @details
154 !> ファイル名 `file`、変数名 `var` を結合して `result` として返します。
155 !>
156 !> @param[in] file ファイル名
157 !> @param[in] var 変数名
158 !> @return 結合された変数 URL
159 !> @endja
160 function url_merge_cc(file, var) result(result)
161 use dc_types, only: string
162 character(len = STRING):: result
163 character(len = *), intent(in):: file
164 character(len = *), intent(in):: var
165 continue
166 result = url_merge_cccc(file, var, "", "")
167 end function url_merge_cc
168
169 !> @en
170 !> @brief Merge filename, variable name, attribute and I/O range array to URL
171 !> @details
172 !> Concatenates filename `file`, variable name `var`, attribute `attr`,
173 !> and I/O range `iorange` and returns as `result`.
174 !> `iorange` is given as a character array. Each element of the array
175 !> is concatenated with GT_COMMA before merging.
176 !>
177 !> @param[in] file Filename
178 !> @param[in] var Variable name
179 !> @param[in] attr Attribute name
180 !> @param[in] iorange I/O range specification (character array)
181 !> @return Merged variable URL
182 !> @enden
183 !>
184 !> @ja
185 !> @brief ファイル名、変数名、属性、入出力範囲配列を URL に結合
186 !> @details
187 !> ファイル名 `file`、変数名 `var`、属性 `attr`、
188 !> 入出力範囲 `iorange` を結合して `result` として返します。
189 !> `iorange` には文字型配列を与えます。文字型配列のそれぞれの要素は
190 !> GT_COMMA で連結されてから結合されます。
191 !>
192 !> @param[in] file ファイル名
193 !> @param[in] var 変数名
194 !> @param[in] attr 属性名
195 !> @param[in] iorange 入出力範囲指定 (文字型配列)
196 !> @return 結合された変数 URL
197 !> @endja
198 function url_merge_cccca(file, var, attr, iorange) result(result)
199 use dc_types, only: string
200 character(len = STRING):: result
201 character(len = *), intent(in):: file
202 character(len = *), intent(in):: var
203 character(len = *), intent(in):: attr
204 character(len = *), intent(in):: iorange(:)
205 integer:: i
206 continue
207 if (file /= "") then
208 result = trim(file) // gt_atmark
209 else
210 result = gt_atmark
211 endif
212 if (var /= "") result = trim(result) // var
213 if (attr /= "") then
214 result = trim(result) // gt_colon // attr
215 endif
216 do i = 1, size(iorange)
217 if (iorange(i) /= "") then
218 if (iorange(i)(1:1) == gt_comma) then
219 result = trim(result) // trim(iorange(i))
220 else
221 result = trim(result) // gt_comma // trim(iorange(i))
222 endif
223 endif
224 end do
225 end function url_merge_cccca
226
227 !> @en
228 !> @brief Merge filename, variable name, attribute and I/O range to URL
229 !> @details
230 !> Concatenates filename `file`, variable name `var`, attribute `attr`,
231 !> and I/O range `iorange` and returns as `result`.
232 !>
233 !> @param[in] file Filename
234 !> @param[in] var Variable name
235 !> @param[in] attr Attribute name
236 !> @param[in] iorange I/O range specification
237 !> @return Merged variable URL
238 !> @enden
239 !>
240 !> @ja
241 !> @brief ファイル名、変数名、属性、入出力範囲を URL に結合
242 !> @details
243 !> ファイル名 `file`、変数名 `var`、属性 `attr`、
244 !> 入出力範囲 `iorange` を結合して `result` として返します。
245 !>
246 !> @param[in] file ファイル名
247 !> @param[in] var 変数名
248 !> @param[in] attr 属性名
249 !> @param[in] iorange 入出力範囲指定
250 !> @return 結合された変数 URL
251 !> @endja
252 function url_merge_cccc(file, var, attr, iorange) result(result)
253 use dc_types, only: string
254 character(len = STRING):: result
255 character(len = *), intent(in):: file
256 character(len = *), intent(in):: var
257 character(len = *), intent(in):: attr
258 character(len = *), intent(in):: iorange
259 continue
260 if (trim(file) /= "") then
261 result = trim(file) // gt_atmark
262 else
263 result = gt_atmark
264 endif
265 if (trim(var) /= "") result = trim(result) // var
266 if (trim(attr) /= "") then
267 result = trim(result) // gt_colon // attr
268 endif
269 if (trim(iorange) /= "") then
270 if (iorange(1:1) == gt_comma) then
271 result = trim(result) // iorange
272 else
273 result = trim(result) // gt_comma // iorange
274 endif
275 endif
276 end function url_merge_cccc
277
278 !> @en
279 !> @brief Remove I/O range from variable URL
280 !> @details
281 !> Separates the I/O range specification part and the remaining part
282 !> from the variable URL given in `fullname`, and returns them in
283 !> `iorange` and `remainder` respectively.
284 !>
285 !> @param[in] fullname Variable URL
286 !> @param[out] iorange I/O range specification part
287 !> @param[out] remainder Remaining part
288 !> @enden
289 !>
290 !> @ja
291 !> @brief 変数 URL から入出力範囲を除去
292 !> @details
293 !> `fullname` で与えられる変数 URL の入出力範囲指定部分と
294 !> 残りの部分とを分離し、それぞれ `iorange` と `remainder` に返します。
295 !>
296 !> @param[in] fullname 変数 URL
297 !> @param[out] iorange 入出力範囲指定部分
298 !> @param[out] remainder 残りの部分
299 !> @endja
300 subroutine url_chop_iorange(fullname, iorange, remainder)
301 use dc_types, only: string
302 character(len = *), intent(in):: fullname
303 character(len = *), intent(out):: iorange ! 入出力範囲指定部分
304 character(len = *), intent(out):: remainder ! 残りの部分
305 character(STRING):: file, var, attr
306 call urlsplit(fullname, file=file, var=var, attr=attr, iorange=iorange)
307 remainder = url_merge_cccc(file=file, var=var, attr=attr, iorange="")
308 end subroutine url_chop_iorange
309
310 !> @en
311 !> @brief Get I/O range value for a dimension from variable URL
312 !> @details
313 !> Gets the I/O range specification value for dimension `dimvar`
314 !> from the variable URL `fullname`.
315 !>
316 !> `fullname` is given either as a complete gtool4 variable URL or
317 !> as just the I/O range specification part.
318 !> `dimvar` is given as the dimension variable name contained in
319 !> the I/O range specification part.
320 !> If a dimension variable corresponding to `dimvar` exists,
321 !> its value is returned.
322 !> If a dimension variable corresponding to `dimvar` does not exist,
323 !> an empty string is returned.
324 !>
325 !> @param[in] fullname Variable URL or I/O range specification
326 !> @param[in] dimvar Dimension variable name to search
327 !> @return I/O range value for the dimension (empty if not found)
328 !> @enden
329 !>
330 !> @ja
331 !> @brief 変数 URL 内の次元に関する入出力範囲指定の値を取得
332 !> @details
333 !> 変数 URL `fullname` 内の, 次元 `dimvar` に関する
334 !> 入出力範囲指定の値を取得します。
335 !>
336 !> `fullname` には gtool4 変数全体または入出力範囲指定部分の値を与えます。
337 !> `dimvar` には入出力範囲指定部分に含まれる次元変数名を与えます。
338 !> `dimvar` に対応する次元変数が存在する場合、その値を返します。
339 !> `dimvar` に対応する次元変数が存在しない場合、空文字を返します。
340 !>
341 !> @param[in] fullname 変数 URL または入出力範囲指定
342 !> @param[in] dimvar 検索する次元変数名
343 !> @return 次元の入出力範囲値 (見つからない場合は空文字)
344 !> @endja
345 function url_search_iorange(fullname, dimvar) result(result)
346 use dc_types, only: string
347 use dc_string, only: split
348 character(len = *), intent(in):: fullname
349 character(len = *), intent(in):: dimvar
350 character(len = STRING):: result
351 character(STRING):: file, var, attr, iorange
352 character(STRING), pointer :: ioranges_slice(:) => null()
353 integer :: i, eqpos, atmark
354 continue
355 result = ""
356 ! @ または ? が含まれているなら urlsplit で分離
357 atmark = index(fullname, gt_question)
358 if (atmark == 0) atmark = index(fullname, gt_atmark)
359 if (atmark /= 0) then
360 call urlsplit(fullname, file=file, var=var, attr=attr, iorange=iorange)
361 else
362 iorange = fullname
363 end if
364 call split(iorange, ioranges_slice, gt_comma)
365 do i = 1, size(ioranges_slice)
366 eqpos = index(ioranges_slice(i), gt_equal)
367 if (ioranges_slice(i)(1:eqpos-1) == trim(dimvar)) then
368 result = trim(ioranges_slice(i)(eqpos+1:))
369 exit
370 end if
371 end do
372 deallocate(ioranges_slice)
373 end function url_search_iorange
374
375 !> @en
376 !> @brief Split variable URL to components
377 !> @details
378 !> Splits the variable URL given in `fullname` into filename `file`,
379 !> variable name `var`, attribute name `attr`, and I/O range
380 !> specification `iorange` and returns them.
381 !> Components that are not found are assigned empty strings.
382 !>
383 !> @param[in] fullname Variable URL
384 !> @param[out] file Filename (optional)
385 !> @param[out] var Variable name (optional)
386 !> @param[out] attr Attribute name (optional)
387 !> @param[out] iorange I/O range specification (optional)
388 !> @enden
389 !>
390 !> @ja
391 !> @brief 変数 URL を各成分に分解
392 !> @details
393 !> `fullname` で与えられる変数 URL を、ファイル名 `file`、変数名 `var`、
394 !> 属性名 `attr`、入出力範囲指定 `iorange` に分解して返します。
395 !> 見つからない成分には空文字列が代入されます。
396 !>
397 !> @param[in] fullname 変数 URL
398 !> @param[out] file ファイル名 (省略可能)
399 !> @param[out] var 変数名 (省略可能)
400 !> @param[out] attr 属性名 (省略可能)
401 !> @param[out] iorange 入出力範囲指定 (省略可能)
402 !> @endja
403 subroutine url_split_c(fullname, file, var, attr, iorange)
404 use dc_types, only: string
405 character(len = *), intent(in):: fullname
406 character(len = *), intent(out), optional:: file, var, attr, iorange
407 character(len = STRING):: varpart
408 integer:: atmark, colon, comma
409 character(len = *), parameter:: VARNAME_SET &
410 = "0123456789eEdD+-=^,.:_" &
411 // "ABCDEFGHIJKLMNOPQRSTUVWXYZ" &
412 // "abcdefghijklmnopqrstuvwxyz"
413 continue
414 ! まず URL と変数属性指定 (? または @ 以降) を分離する。
415 ! URL は @ を含みうるため、最後の @ 以降に対して変数属性
416 ! として許されない文字(典型的には '/')が含まれていたら
417 ! 当該 @ は URL の一部とみなす。
418 atmark = index(fullname, gt_question)
419 if (atmark == 0) then
420 atmark = index(fullname, gt_atmark, back=.true.)
421 if (atmark /= 0) then
422 if (verify(trim(fullname(atmark+1: )), varname_set) /= 0) then
423 atmark = 0
424 endif
425 endif
426 endif
427 if (atmark == 0) then
428 ! 変数属性指定はなかった。
429 if (present(file)) file = fullname
430 if (present(var)) var = ''
431 if (present(attr)) attr = ''
432 if (present(iorange)) iorange = ''
433 return
434 endif
435 varpart = fullname(atmark+1: )
436 ! 変数属性指定があった。
437 if (present(file)) file = fullname(1: atmark - 1)
438 ! 範囲指定を探索する。
439 comma = index(varpart, gt_comma)
440 if (comma /= 0) then
441 ! 範囲指定がみつかった。
442 if (present(var)) var = varpart(1: comma - 1)
443 if (present(attr)) attr = ''
444 if (present(iorange)) iorange = varpart(comma + 1: )
445 return
446 endif
447 if (present(iorange)) iorange = ''
448 ! 範囲指定がなかったので、属性名の検索をする。
449 colon = index(varpart, gt_colon)
450 if (colon == 0) then
451 if (present(var)) var = varpart
452 if (present(attr)) attr = ''
453 varpart = ''
454 return
455 endif
456 if (present(var)) var = varpart(1: colon - 1)
457 if (present(attr)) attr = varpart(colon + 1: )
458 varpart = ''
459 end subroutine url_split_c
460
461! subroutine url_split_v(fullname, file, var, attr, iorange) !:nodoc:
462! use dcstring_base, only: VSTRING, operator(.cat.), operator(/=), &
463! & extract, operator(==) !:nodoc:
464! use dc_string
465! implicit none
466! type(VSTRING), intent(in):: fullname
467! type(VSTRING), intent(out), optional:: file, var, attr, iorange
468! type(VSTRING):: varpart
469! integer:: atmark, colon, comma
470! character(len = *), parameter:: VARNAME_SET &
471! = "0123456789eEdD+-=^,.:_" &
472! // "ABCDEFGHIJKLMNOPQRSTUVWXYZ" &
473! // "abcdefghijklmnopqrstuvwxyz"
474! continue
475! ! まず URL と変数属性指定 (? または @ 以降) を分離する。
476! ! URL は @ を含みうるため、最後の @ 以降に対して変数属性
477! ! として許されない文字(典型的には '/')が含まれていたら
478! ! 当該 @ は URL の一部とみなす。
479! atmark = vindex(fullname, GT_QUESTION)
480! if (atmark == 0) then
481! atmark = vindex(fullname, GT_ATMARK, .TRUE.)
482! if (atmark /= 0) then
483! varpart = extract(fullname, atmark + 1)
484! if (vverify(varpart, VARNAME_SET) /= 0) then
485! atmark = 0
486! endif
487! endif
488! endif
489! if (atmark == 0) then
490! ! 変数属性指定はなかった。
491! if (present(file)) file = fullname
492! if (present(var)) var = ''
493! if (present(attr)) attr = ''
494! if (present(iorange)) iorange = ''
495! return
496! endif
497! varpart = extract(fullname, atmark + 1)
498! ! 変数属性指定があった。
499! if (present(file)) file = extract(fullname, 1, atmark - 1)
500! ! 範囲指定を探索する。
501! comma = vindex(varpart, GT_COMMA)
502! if (comma /= 0) then
503! ! 範囲指定がみつかった。
504! if (present(var)) var = extract(varpart, 1, comma - 1)
505! if (present(attr)) attr = ''
506! if (present(iorange)) iorange = extract(varpart, comma + 1)
507! return
508! endif
509! if (present(iorange)) iorange = ''
510! ! 範囲指定がなかったので、属性名の検索をする。
511! colon = vindex(varpart, GT_COLON)
512! if (colon == 0) then
513! if (present(var)) var = varpart
514! if (present(attr)) attr = ''
515! varpart = ''
516! return
517! endif
518! if (present(var)) var = extract(varpart, 1, colon - 1)
519! if (present(attr)) attr = extract(varpart, colon + 1)
520! varpart = ''
521! end subroutine url_split_v
522
523 !> @en
524 !> @brief Check if two variable URLs point to the same file
525 !> @details
526 !> Determines whether the variable URL given as the first argument
527 !> and the variable URL given as the second argument point to
528 !> the same file.
529 !> Returns `.true.` if they point to the same file,
530 !> `.false.` if they point to different files.
531 !>
532 !> @param[in] url_a First variable URL
533 !> @param[in] url_b Second variable URL
534 !> @return .true. if same file, .false. otherwise
535 !> @enden
536 !>
537 !> @ja
538 !> @brief 2つの変数 URL が同じファイルを指すか判定
539 !> @details
540 !> 1 つ目の引数に与えられる変数 URL と 2 つ目の引数に与えられる
541 !> 変数 URL とが同じファイルを指しているかどうか判定します。
542 !> もしも同じファイルであれば `.true.` を、
543 !> 異なるファイルであれば `.false.` を返します。
544 !>
545 !> @param[in] url_a 1つ目の変数 URL
546 !> @param[in] url_b 2つ目の変数 URL
547 !> @return 同じファイルなら .true., そうでなければ .false.
548 !> @endja
549 logical function urlonthesamefile(url_a, url_b) result(result)
550 use dc_string
551 use dc_types, only: string
552 character(len = *), intent(in) :: url_a
553 character(len = *), intent(in) :: url_b
554 character(len = STRING) :: filepart_a
555 character(len = STRING) :: filepart_b
556 call urlsplit(url_a, file=filepart_a)
557 call urlsplit(url_b, file=filepart_b)
558 result = (filepart_a == filepart_b)
559 end function urlonthesamefile
560
561 !> @en
562 !> @brief Complement variable URL
563 !> @details
564 !> If the variable URL given in `relative` is incomplete (missing
565 !> filename, variable name, attribute name, or I/O range specification),
566 !> it is complemented from `base`.
567 !>
568 !> @param[in] relative Relative variable URL to complement
569 !> @param[in] base Base variable URL for complementing
570 !> @return Complemented variable URL
571 !> @enden
572 !>
573 !> @ja
574 !> @brief 変数 URL の補完
575 !> @details
576 !> `relative` で与えられる変数 URL が完全でない (ファイル名、変数名、
577 !> 属性名、入出力範囲指定のどれかが無い) 場合に、`base`
578 !> から補完します。
579 !>
580 !> @param[in] relative 補完する相対変数 URL
581 !> @param[in] base 補完に使用する基準変数 URL
582 !> @return 補完された変数 URL
583 !> @endja
584 function url_resolve_c(relative, base) result(result)
585 use dc_string, only: strhead
586 use dc_types, only: string
588 implicit none
589 character(len = *), intent(in):: relative
590 character(len = *), intent(in):: base
591 character(len = STRING):: result
592 integer, parameter:: file = 1, var = 2, attr = 3, ior = 4
593 character(len = STRING):: rel(file:ior), bas(file:ior)
594 character(3), parameter:: pathdelim = "/:" // achar(94)
595 integer:: idir_r, idir_b
596 continue
597 call beginsub('urlresolve', 'rel=<%c> base=<%c>', c1=relative, c2=base)
598 call urlsplit(trim(relative), file=rel(file), var=rel(var), &
599 & attr=rel(attr), iorange=rel(ior))
600 call dbgmessage('rel -> file=<%c> var=<%c> attr=<%c>', &
601 & c1=trim(rel(file)), c2=trim(rel(var)), &
602 & c3=(trim(rel(attr)) // '> ior=<' // trim(rel(ior))))
603 call urlsplit(base, file=bas(file), var=bas(var), &
604 & attr=bas(attr), iorange=bas(ior))
605 call dbgmessage('base -> file=<%s> var=<%s> attr=<%s> ior=<%s>', &
606 & c1=trim(bas(file)), c2=trim(bas(var)), &
607 & c3=(trim(bas(attr)) // '> ior=<' // trim(bas(ior))))
608 ! --- ファイル名を欠くばあいは単に補う ---
609 if (rel(file) == "") then
610 rel(file) = bas(file)
611 if (rel(var) == "") &
612 & rel(var) = bas(var)
613 result = urlmerge(file=rel(file), var=rel(var), &
614 & attr=rel(attr), iorange=rel(ior))
615 call endsub('urlresolve', '1 result=%c', c1=trim(result))
616 return
617 endif
618 ! --- 絶対パス (と見られる) ファイル名はそのまま使用 ---
619 if (strhead(rel(file), "file:") &
620 & .OR. strhead(rel(file), "http:") &
621 & .OR. strhead(rel(file), "ftp:") &
622 & .OR. strhead(rel(file), "news:") &
623 & .OR. strhead(rel(file), "www") &
624 & .OR. strhead(rel(file), "/") &
625 & .OR. strhead(rel(file), achar(94)) &
626 & .OR. rel(file)(2:2) == ":" &
627 ) then
628 result = relative
629 call endsub('urlresolve', '2 result=%c', c1=trim(result))
630 return
631 endif
632 ! ディレクトリ名の取り出し
633 idir_b = scan(bas(file), pathdelim, back=.true.)
634 if (idir_b == 0) then
635 ! が、できなければ、(エラーとすべきかもしれぬが)
636 ! 相対パスをそのまま使用
637 result = relative
638 call endsub('urlresolve', '3 result=%c', c1=trim(result))
639 return
640 endif
641 ! 相対パスのほうのディレクトリ名の取り出し
642 idir_r = scan(rel(file), pathdelim, back=.true.)
643 if (idir_r == 0) then
644 ! ができなければ全体を使用
645 idir_r = 1
646 endif
647 result = base(1: idir_b) // relative(idir_r: )
648 call endsub('urlresolve', '4 result=%c', c1=trim(result))
649 end function url_resolve_c
650
651 !> @namespace dc_url
652end module dc_url
Handling character types.
Definition dc_string.f90:83
Debug tracing module.
Definition dc_trace.f90:150
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:661
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:457
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:580
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public string
Character length for string
Definition dc_types.f90:137
Variable URL string parser.
Definition dc_url.f90:61
character, parameter, public gt_atmark
Definition dc_url.f90:96
character, parameter, public gt_plus
Definition dc_url.f90:109
character, parameter, public gt_comma
Definition dc_url.f90:102
subroutine, public url_chop_iorange(fullname, iorange, remainder)
Definition dc_url.f90:301
character, parameter, public gt_equal
Definition dc_url.f90:104
character, parameter, public gt_colon
Definition dc_url.f90:100
character, parameter, public gt_circumflex
Definition dc_url.f90:106
character, parameter, public gt_question
Definition dc_url.f90:98