gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
dc_present.f90
Go to the documentation of this file.
1! -*- mode: f90; coding: utf-8 -*-
2!-----------------------------------------------------------------------
3! Copyright (c) 2000-2026 Gtool Development Group. All rights reserved.
4!-----------------------------------------------------------------------
5!>
6!> @author Youhei SASAKI, Yasuhiro MORIKAWA, Eizi TOYODA, Takeshi HORINOUCHI
7!> @copyright Copyright (C) GFD Dennou Club, 2000-2026. All rights reserved. <br/>
8!> License is BSD-2-Clause. see [COPYRIGHT](@ref COPYRIGHT) in detail
9!>
10!> **Important**
11!>
12!> This file is generated from ../../../../src/dc_utils/dc_present.erb by ERB included Ruby 3.3.8.
13!> Please do not edit this file directly.
14!>
15!> @en
16!> @brief Judge optional control parameters
17!> @details
18!> This module provides utility functions for checking optional arguments.
19!> These functions check whether an optional argument is present and
20!> whether it satisfies certain conditions (true, false, zero, equal to a value, etc.).
21!>
22!> @section present_procedures Procedures List
23!>
24!> | Procedure | Description |
25!> |----------------------|----------------------------------------------------------|
26!> | present_and_true | Returns .true. if arg is present and .true. |
27!> | present_and_false | Returns .true. if arg is present and .false. |
28!> | present_and_zero | Returns .true. if arg is present and equals zero |
29!> | present_and_nonzero | Returns .true. if arg is present and not zero |
30!> | present_and_eq | Returns .true. if arg is present and equals val |
31!> | present_and_ne | Returns .true. if arg is present and not equals val |
32!> | present_and_not_empty| Returns .true. if arg is present and not empty string |
33!> | present_select | Returns the first valid optional argument or default |
34!>
35!> @enden
36!>
37!> @ja
38!> @brief 省略可能な制御パラメータの判定
39!> @details
40!> 省略可能な引数のチェックに使用するユーティリティ関数を提供するモジュールです。
41!> これらの関数は、省略可能な引数が与えられているかどうか、
42!> また特定の条件(真、偽、ゼロ、指定値と等しいか、など)を満たすかどうかを判定します。
43!>
44!> @section present_procedures_ja 手続一覧
45!>
46!> | 手続名 | 説明 |
47!> |----------------------|----------------------------------------------------------|
48!> | present_and_true | arg が省略されておらず .true. の場合に .true. を返す |
49!> | present_and_false | arg が省略されておらず .false. の場合に .true. を返す |
50!> | present_and_zero | arg が省略されておらず 0 の場合に .true. を返す |
51!> | present_and_nonzero | arg が省略されておらず 0 でない場合に .true. を返す |
52!> | present_and_eq | arg が省略されておらず val と等しい場合に .true. を返す |
53!> | present_and_ne | arg が省略されておらず val と等しくない場合に .true. を返す |
54!> | present_and_not_empty| arg が省略されておらず空文字でない場合に .true. を返す |
55!> | present_select | 最初の有効な省略可能引数またはデフォルト値を返す |
56!>
57!> @endja
58!>
60 use dc_types, only: sp, sp_eps, dp, dp_eps, token, string
61 private
62 public :: present_and_true
63 public :: present_and_false
64 public :: present_and_zero
65 public :: present_and_nonzero
66 public :: present_and_eq
67 public :: present_and_ne
68 public :: present_and_not_empty
69 public :: present_select
71 module procedure present_and_eq_integer
72 module procedure present_and_eq_real
73 module procedure present_and_eq_double
74 end interface
76 module procedure present_and_ne_integer
77 module procedure present_and_ne_real
78 module procedure present_and_ne_double
79 end interface present_and_ne
81 module procedure present_select_char
82 module procedure present_select_char_auto
83 module procedure present_select_int
84 module procedure present_select_int_auto
85 module procedure present_select_real
86 module procedure present_select_real_auto
87 module procedure present_select_double
88 module procedure present_select_double_auto
89 end interface present_select
90contains
91 !> @en
92 !> @brief Check if arg is present and true
93 !> @param[in] arg Optional logical argument
94 !> @return .true. if arg is present and .true., .false. otherwise
95 !> @enden
96 !>
97 !> @ja
98 !> @brief arg が省略されておらず真かどうかを判定
99 !> @param[in] arg 省略可能な論理型引数
100 !> @return arg が省略されておらず .true. の場合は .true.、それ以外は .false.
101 !> @endja
102 function present_and_true(arg) result(result)
103 logical :: result
104 logical, intent(in), optional :: arg
105 continue
106 if(present(arg)) then
107 if(arg) then
108 result=.true.
109 else
110 result=.false.
111 endif
112 else
113 result=.false.
114 endif
115 end function present_and_true
116 !> @en
117 !> @brief Check if arg is present and false
118 !> @param[in] arg Optional logical argument
119 !> @return .true. if arg is present and .false., .false. otherwise
120 !> @enden
121 !>
122 !> @ja
123 !> @brief arg が省略されておらず偽かどうかを判定
124 !> @param[in] arg 省略可能な論理型引数
125 !> @return arg が省略されておらず .false. の場合は .true.、それ以外は .false.
126 !> @endja
127 function present_and_false(arg) result(result)
128 logical :: result
129 logical, intent(in), optional :: arg
130 continue
131 if(present(arg)) then
132 if(arg) then
133 result=.false.
134 else
135 result=.true.
136 endif
137 else
138 result=.false.
139 endif
140 end function present_and_false
141 !> @en
142 !> @brief Check if arg is present and zero
143 !> @param[in] arg Optional integer argument
144 !> @return .true. if arg is present and equals zero, .false. otherwise
145 !> @enden
146 !>
147 !> @ja
148 !> @brief arg が省略されておらず 0 かどうかを判定
149 !> @param[in] arg 省略可能な整数型引数
150 !> @return arg が省略されておらず 0 の場合は .true.、それ以外は .false.
151 !> @endja
152 function present_and_zero(arg) result(result)
153 logical :: result
154 integer, intent(in), optional :: arg
155 continue
156 if(present(arg)) then
157 if(arg==0) then
158 result=.true.
159 else
160 result=.false.
161 endif
162 else
163 result=.false.
164 endif
165 end function present_and_zero
166 !> @en
167 !> @brief Check if arg is present and non-zero
168 !> @param[in] arg Optional integer argument
169 !> @return .true. if arg is present and not equals zero, .false. otherwise
170 !> @enden
171 !>
172 !> @ja
173 !> @brief arg が省略されておらず 0 でないかどうかを判定
174 !> @param[in] arg 省略可能な整数型引数
175 !> @return arg が省略されておらず 0 でない場合は .true.、それ以外は .false.
176 !> @endja
177 function present_and_nonzero(arg) result(result)
178 logical :: result
179 integer, intent(in), optional :: arg
180 continue
181 if(present(arg)) then
182 if(arg==0) then
183 result=.false.
184 else
185 result=.true.
186 endif
187 else
188 result=.false.
189 endif
190 end function present_and_nonzero
191 !> @en
192 !> @brief Check if arg is present and equals val (integer version)
193 !> @param[in] arg Optional integer argument
194 !> @param[in] val Value to compare
195 !> @return .true. if arg is present and equals val, .false. otherwise
196 !> @enden
197 !>
198 !> @ja
199 !> @brief arg が省略されておらず val と等しいかどうかを判定(整数版)
200 !> @param[in] arg 省略可能な整数型引数
201 !> @param[in] val 比較する値
202 !> @return arg が省略されておらず val と等しい場合は .true.、それ以外は .false.
203 !> @endja
204 function present_and_eq_integer(arg,val) result(result)
205 logical :: result
206 integer, intent(in), optional :: arg
207 integer, intent(in) :: val
208 continue
209 result = .false.
210 if(present(arg)) then
211 if(arg==val) then
212 result=.true.
213 else
214 result=.false.
215 endif
216 else
217 result=.false.
218 endif
219 end function present_and_eq_integer
220 !> @en
221 !> @brief Check if arg is present and equals val (single precision version)
222 !> @param[in] arg Optional single precision real argument
223 !> @param[in] val Value to compare
224 !> @return .true. if arg is present and equals val within SP_EPS, .false. otherwise
225 !> @enden
226 !>
227 !> @ja
228 !> @brief arg が省略されておらず val と等しいかどうかを判定(単精度版)
229 !> @param[in] arg 省略可能な単精度実数型引数
230 !> @param[in] val 比較する値
231 !> @return arg が省略されておらず SP_EPS 以内で val と等しい場合は .true.、それ以外は .false.
232 !> @endja
233 function present_and_eq_real(arg,val) result(result)
234 logical :: result
235 real(sp), intent(in), optional :: arg
236 real(sp), intent(in) :: val
237 continue
238 result = .false.
239 if(present(arg)) then
240 if( abs(arg - val) .le. sp_eps ) then
241 result=.true.
242 else
243 result=.false.
244 endif
245 else
246 result=.false.
247 endif
248 end function present_and_eq_real
249 !> @en
250 !> @brief Check if arg is present and equals val (double precision version)
251 !> @param[in] arg Optional double precision real argument
252 !> @param[in] val Value to compare
253 !> @return .true. if arg is present and equals val within DP_EPS, .false. otherwise
254 !> @enden
255 !>
256 !> @ja
257 !> @brief arg が省略されておらず val と等しいかどうかを判定(倍精度版)
258 !> @param[in] arg 省略可能な倍精度実数型引数
259 !> @param[in] val 比較する値
260 !> @return arg が省略されておらず DP_EPS 以内で val と等しい場合は .true.、それ以外は .false.
261 !> @endja
262 function present_and_eq_double(arg,val) result(result)
263 logical :: result
264 real(dp), intent(in), optional :: arg
265 real(dp), intent(in) :: val
266 continue
267 if(present(arg)) then
268 if ( abs(arg - val) .le. dp_eps ) then
269 result=.true.
270 else
271 result=.false.
272 endif
273 else
274 result=.false.
275 end if
276 end function present_and_eq_double
277 !> @en
278 !> @brief Check if arg is present and not equals val (integer version)
279 !> @param[in] arg Optional integer argument
280 !> @param[in] val Value to compare
281 !> @return .true. if arg is present and not equals val, .false. otherwise
282 !> @enden
283 !>
284 !> @ja
285 !> @brief arg が省略されておらず val と等しくないかどうかを判定(整数版)
286 !> @param[in] arg 省略可能な整数型引数
287 !> @param[in] val 比較する値
288 !> @return arg が省略されておらず val と等しくない場合は .true.、それ以外は .false.
289 !> @endja
290 function present_and_ne_integer(arg,val) result(result)
291 logical :: result
292 integer, intent(in), optional :: arg
293 integer, intent(in) :: val
294 continue
295 result = .false.
296 if(present(arg)) then
297 if(arg/=val) then
298 result=.true.
299 else
300 result=.false.
301 endif
302 else
303 result=.false.
304 endif
305 end function present_and_ne_integer
306 !> @en
307 !> @brief Check if arg is present and not equals val (single precision version)
308 !> @param[in] arg Optional single precision real argument
309 !> @param[in] val Value to compare
310 !> @return .true. if arg is present and not equals val beyond SP_EPS, .false. otherwise
311 !> @enden
312 !>
313 !> @ja
314 !> @brief arg が省略されておらず val と等しくないかどうかを判定(単精度版)
315 !> @param[in] arg 省略可能な単精度実数型引数
316 !> @param[in] val 比較する値
317 !> @return arg が省略されておらず SP_EPS を超えて val と異なる場合は .true.、それ以外は .false.
318 !> @endja
319 function present_and_ne_real(arg,val) result(result)
320 logical :: result
321 real(sp), intent(in), optional :: arg
322 real(sp), intent(in) :: val
323 continue
324 result = .false.
325 if(present(arg)) then
326 if( abs(arg - val) .gt. sp_eps ) then
327 result=.true.
328 else
329 result=.false.
330 endif
331 else
332 result=.false.
333 endif
334 end function present_and_ne_real
335 !> @en
336 !> @brief Check if arg is present and not equals val (double precision version)
337 !> @param[in] arg Optional double precision real argument
338 !> @param[in] val Value to compare
339 !> @return .true. if arg is present and not equals val beyond DP_EPS, .false. otherwise
340 !> @enden
341 !>
342 !> @ja
343 !> @brief arg が省略されておらず val と等しくないかどうかを判定(倍精度版)
344 !> @param[in] arg 省略可能な倍精度実数型引数
345 !> @param[in] val 比較する値
346 !> @return arg が省略されておらず DP_EPS を超えて val と異なる場合は .true.、それ以外は .false.
347 !> @endja
348 function present_and_ne_double(arg,val) result(result)
349 logical :: result
350 real(dp), intent(in), optional :: arg
351 real(dp), intent(in) :: val
352 continue
353 result = .false.
354 if(present(arg)) then
355 if(abs(arg - val) .gt. dp_eps) then
356 result=.true.
357 else
358 result=.false.
359 endif
360 else
361 result=.false.
362 endif
363 end function present_and_ne_double
364 !> @en
365 !> @brief Check if arg is present and not empty string
366 !> @param[in] arg Optional character argument
367 !> @return .true. if arg is present and not an empty string, .false. otherwise
368 !> @enden
369 !>
370 !> @ja
371 !> @brief arg が省略されておらず空文字でないかどうかを判定
372 !> @param[in] arg 省略可能な文字型引数
373 !> @return arg が省略されておらず空文字でない場合は .true.、それ以外は .false.
374 !> @endja
375 function present_and_not_empty(arg) result(result)
376 logical :: result
377 character(len=*), intent(in), optional :: arg
378 continue
379 result = .false.
380 if( present(arg) .AND. (arg .ne. '')) result = .true.
381 end function present_and_not_empty
382 !> @en
383 !> @brief Select the first valid optional argument (Char version)
384 !> @details
385 !> Returns the first optional argument (c0-c9, i0-i9, r0-r9, or d0-d9) that is
386 !> present and not equal to invalid. c0/i0/r0/d0 has the highest priority,
387 !> c9/i9/r9/d9 has the lowest. If all optional arguments are absent or
388 !> equal to invalid, default is returned.
389 !> @param[in] invalid Value that marks an argument as invalid
390 !> @param[in] default Default value to return if no valid argument found
391 !> @return The first valid optional argument or default
392 !> @enden
393 !>
394 !> @ja
395 !> @brief 最初の有効な省略可能引数を選択(Char 版)
396 !> @details
397 !> 省略可能な引数 c0〜c9、i0〜i9、r0〜r9、d0〜d9 のうち、
398 !> 省略されておらず、且つ invalid と等しくないものを1つ返します。
399 !> c0/i0/r0/d0 の優先順位が最も高く、c9/i9/r9/d9 が最も低いです。
400 !> 全ての引数が省略されているか invalid と等しい場合は default が返ります。
401 !> @param[in] invalid 引数を無効とみなす値
402 !> @param[in] default 有効な引数がない場合に返すデフォルト値
403 !> @return 最初の有効な省略可能引数またはデフォルト値
404 !> @endja
405 function present_select_char( &
406 & invalid, default, &
407 & c0,c1,c2,c3,c4,c5,c6,c7,c8,c9 &
408 & ) result(result)
409 implicit none
410 character(*) ,intent(in) :: invalid
411 character(*) ,intent(in) :: default
412 character(*) ,intent(in),optional :: c0,c1,c2,c3,c4,c5,c6,c7,c8,c9
413 character(STRING) :: result
414 !=== Variables for internal work
415 logical :: specified
416 continue
417 specified = .false.
418 if ( present(c0) ) then
419 if ( len(trim(c0)) > len(trim(invalid)) ) then
420 result = c0
421 specified = .true.
422 else
423 if ( trim(c0) /= invalid(:len(trim(c0))) ) then
424 result = c0
425 specified = .true.
426 endif
427 end if
428 end if
429 if ( present(c1) ) then
430 if ( len(trim(c1)) > len(trim(invalid)) ) then
431 result = c1
432 specified = .true.
433 else
434 if ( trim(c1) /= invalid(:len(trim(c1))) ) then
435 result = c1
436 specified = .true.
437 endif
438 end if
439 end if
440 if ( present(c2) ) then
441 if ( len(trim(c2)) > len(trim(invalid)) ) then
442 result = c2
443 specified = .true.
444 else
445 if ( trim(c2) /= invalid(:len(trim(c2))) ) then
446 result = c2
447 specified = .true.
448 endif
449 end if
450 end if
451 if ( present(c3) ) then
452 if ( len(trim(c3)) > len(trim(invalid)) ) then
453 result = c3
454 specified = .true.
455 else
456 if ( trim(c3) /= invalid(:len(trim(c3))) ) then
457 result = c3
458 specified = .true.
459 endif
460 end if
461 end if
462 if ( present(c4) ) then
463 if ( len(trim(c4)) > len(trim(invalid)) ) then
464 result = c4
465 specified = .true.
466 else
467 if ( trim(c4) /= invalid(:len(trim(c4))) ) then
468 result = c4
469 specified = .true.
470 endif
471 end if
472 end if
473 if ( present(c5) ) then
474 if ( len(trim(c5)) > len(trim(invalid)) ) then
475 result = c5
476 specified = .true.
477 else
478 if ( trim(c5) /= invalid(:len(trim(c5))) ) then
479 result = c5
480 specified = .true.
481 endif
482 end if
483 end if
484 if ( present(c6) ) then
485 if ( len(trim(c6)) > len(trim(invalid)) ) then
486 result = c6
487 specified = .true.
488 else
489 if ( trim(c6) /= invalid(:len(trim(c6))) ) then
490 result = c6
491 specified = .true.
492 endif
493 end if
494 end if
495 if ( present(c7) ) then
496 if ( len(trim(c7)) > len(trim(invalid)) ) then
497 result = c7
498 specified = .true.
499 else
500 if ( trim(c7) /= invalid(:len(trim(c7))) ) then
501 result = c7
502 specified = .true.
503 endif
504 end if
505 end if
506 if ( present(c8) ) then
507 if ( len(trim(c8)) > len(trim(invalid)) ) then
508 result = c8
509 specified = .true.
510 else
511 if ( trim(c8) /= invalid(:len(trim(c8))) ) then
512 result = c8
513 specified = .true.
514 endif
515 end if
516 end if
517 if ( present(c9) ) then
518 if ( len(trim(c9)) > len(trim(invalid)) ) then
519 result = c9
520 specified = .true.
521 else
522 if ( trim(c9) /= invalid(:len(trim(c9))) ) then
523 result = c9
524 specified = .true.
525 endif
526 end if
527 end if
528 if (.not. specified) then
529 result = default
530 end if
531 end function present_select_char
532 !> @en
533 !> @brief Select the first valid optional argument (Char_auto version)
534 !> @details
535 !> Returns the first optional argument (c0-c9, i0-i9, r0-r9, or d0-d9) that is
536 !> present and not equal to invalid. c0/i0/r0/d0 has the highest priority,
537 !> c9/i9/r9/d9 has the lowest. If all optional arguments are absent or
538 !> equal to invalid, default is returned.
539 !> @param[in] invalid Value that marks an argument as invalid
540 !> @param[in] default Default value to return if no valid argument found
541 !> @return The first valid optional argument or default
542 !> @enden
543 !>
544 !> @ja
545 !> @brief 最初の有効な省略可能引数を選択(Char_auto 版)
546 !> @details
547 !> 省略可能な引数 c0〜c9、i0〜i9、r0〜r9、d0〜d9 のうち、
548 !> 省略されておらず、且つ invalid と等しくないものを1つ返します。
549 !> c0/i0/r0/d0 の優先順位が最も高く、c9/i9/r9/d9 が最も低いです。
550 !> 全ての引数が省略されているか invalid と等しい場合は default が返ります。
551 !> @param[in] invalid 引数を無効とみなす値
552 !> @param[in] default 有効な引数がない場合に返すデフォルト値
553 !> @return 最初の有効な省略可能引数またはデフォルト値
554 !> @endja
555 function present_select_char_auto( &
556 & invalid, default, &
557 & c0,c1,c2,c3,c4,c5,c6,c7,c8,c9 &
558 & ) result(result)
559 implicit none
560 logical ,intent(in) :: invalid
561 character(*) ,intent(in) :: default
562 character(*) ,intent(in),optional :: c0,c1,c2,c3,c4,c5,c6,c7,c8,c9
563 character(STRING) :: result
564 !=== Variables for internal work
565 logical :: specified
566 continue
567 specified = .false.
568 if ( invalid ) then
569 ! no-op: keep argument referenced for -Wunused-dummy-argument
570 end if
571 if ( present(c0) ) then
572 if ( trim(c0) /= '' ) then
573 result = c0
574 specified = .true.
575 endif
576 end if
577 if ( invalid ) then
578 ! no-op: keep argument referenced for -Wunused-dummy-argument
579 end if
580 if ( present(c1) ) then
581 if ( trim(c1) /= '' ) then
582 result = c1
583 specified = .true.
584 endif
585 end if
586 if ( invalid ) then
587 ! no-op: keep argument referenced for -Wunused-dummy-argument
588 end if
589 if ( present(c2) ) then
590 if ( trim(c2) /= '' ) then
591 result = c2
592 specified = .true.
593 endif
594 end if
595 if ( invalid ) then
596 ! no-op: keep argument referenced for -Wunused-dummy-argument
597 end if
598 if ( present(c3) ) then
599 if ( trim(c3) /= '' ) then
600 result = c3
601 specified = .true.
602 endif
603 end if
604 if ( invalid ) then
605 ! no-op: keep argument referenced for -Wunused-dummy-argument
606 end if
607 if ( present(c4) ) then
608 if ( trim(c4) /= '' ) then
609 result = c4
610 specified = .true.
611 endif
612 end if
613 if ( invalid ) then
614 ! no-op: keep argument referenced for -Wunused-dummy-argument
615 end if
616 if ( present(c5) ) then
617 if ( trim(c5) /= '' ) then
618 result = c5
619 specified = .true.
620 endif
621 end if
622 if ( invalid ) then
623 ! no-op: keep argument referenced for -Wunused-dummy-argument
624 end if
625 if ( present(c6) ) then
626 if ( trim(c6) /= '' ) then
627 result = c6
628 specified = .true.
629 endif
630 end if
631 if ( invalid ) then
632 ! no-op: keep argument referenced for -Wunused-dummy-argument
633 end if
634 if ( present(c7) ) then
635 if ( trim(c7) /= '' ) then
636 result = c7
637 specified = .true.
638 endif
639 end if
640 if ( invalid ) then
641 ! no-op: keep argument referenced for -Wunused-dummy-argument
642 end if
643 if ( present(c8) ) then
644 if ( trim(c8) /= '' ) then
645 result = c8
646 specified = .true.
647 endif
648 end if
649 if ( invalid ) then
650 ! no-op: keep argument referenced for -Wunused-dummy-argument
651 end if
652 if ( present(c9) ) then
653 if ( trim(c9) /= '' ) then
654 result = c9
655 specified = .true.
656 endif
657 end if
658 if (.not. specified) then
659 result = default
660 end if
661 end function present_select_char_auto
662 !> @en
663 !> @brief Select the first valid optional argument (Int version)
664 !> @details
665 !> Returns the first optional argument (c0-c9, i0-i9, r0-r9, or d0-d9) that is
666 !> present and not equal to invalid. c0/i0/r0/d0 has the highest priority,
667 !> c9/i9/r9/d9 has the lowest. If all optional arguments are absent or
668 !> equal to invalid, default is returned.
669 !> @param[in] invalid Value that marks an argument as invalid
670 !> @param[in] default Default value to return if no valid argument found
671 !> @return The first valid optional argument or default
672 !> @enden
673 !>
674 !> @ja
675 !> @brief 最初の有効な省略可能引数を選択(Int 版)
676 !> @details
677 !> 省略可能な引数 c0〜c9、i0〜i9、r0〜r9、d0〜d9 のうち、
678 !> 省略されておらず、且つ invalid と等しくないものを1つ返します。
679 !> c0/i0/r0/d0 の優先順位が最も高く、c9/i9/r9/d9 が最も低いです。
680 !> 全ての引数が省略されているか invalid と等しい場合は default が返ります。
681 !> @param[in] invalid 引数を無効とみなす値
682 !> @param[in] default 有効な引数がない場合に返すデフォルト値
683 !> @return 最初の有効な省略可能引数またはデフォルト値
684 !> @endja
685 function present_select_int( &
686 & invalid, default, &
687 & i0,i1,i2,i3,i4,i5,i6,i7,i8,i9 &
688 & ) result(result)
689 implicit none
690 integer ,intent(in) :: invalid
691 integer ,intent(in) :: default
692 integer ,intent(in),optional :: i0,i1,i2,i3,i4,i5,i6,i7,i8,i9
693 integer :: result
694 !=== Variables for internal work
695 logical :: specified
696 continue
697 specified = .false.
698 if ( present(i0) ) then
699 if ( i0 /= invalid ) then
700 result = i0
701 specified = .true.
702 endif
703 end if
704 if ( present(i1) ) then
705 if ( i1 /= invalid ) then
706 result = i1
707 specified = .true.
708 endif
709 end if
710 if ( present(i2) ) then
711 if ( i2 /= invalid ) then
712 result = i2
713 specified = .true.
714 endif
715 end if
716 if ( present(i3) ) then
717 if ( i3 /= invalid ) then
718 result = i3
719 specified = .true.
720 endif
721 end if
722 if ( present(i4) ) then
723 if ( i4 /= invalid ) then
724 result = i4
725 specified = .true.
726 endif
727 end if
728 if ( present(i5) ) then
729 if ( i5 /= invalid ) then
730 result = i5
731 specified = .true.
732 endif
733 end if
734 if ( present(i6) ) then
735 if ( i6 /= invalid ) then
736 result = i6
737 specified = .true.
738 endif
739 end if
740 if ( present(i7) ) then
741 if ( i7 /= invalid ) then
742 result = i7
743 specified = .true.
744 endif
745 end if
746 if ( present(i8) ) then
747 if ( i8 /= invalid ) then
748 result = i8
749 specified = .true.
750 endif
751 end if
752 if ( present(i9) ) then
753 if ( i9 /= invalid ) then
754 result = i9
755 specified = .true.
756 endif
757 end if
758 if (.not. specified) then
759 result = default
760 end if
761 end function present_select_int
762 !> @en
763 !> @brief Select the first valid optional argument (Int_auto version)
764 !> @details
765 !> Returns the first optional argument (c0-c9, i0-i9, r0-r9, or d0-d9) that is
766 !> present and not equal to invalid. c0/i0/r0/d0 has the highest priority,
767 !> c9/i9/r9/d9 has the lowest. If all optional arguments are absent or
768 !> equal to invalid, default is returned.
769 !> @param[in] invalid Value that marks an argument as invalid
770 !> @param[in] default Default value to return if no valid argument found
771 !> @return The first valid optional argument or default
772 !> @enden
773 !>
774 !> @ja
775 !> @brief 最初の有効な省略可能引数を選択(Int_auto 版)
776 !> @details
777 !> 省略可能な引数 c0〜c9、i0〜i9、r0〜r9、d0〜d9 のうち、
778 !> 省略されておらず、且つ invalid と等しくないものを1つ返します。
779 !> c0/i0/r0/d0 の優先順位が最も高く、c9/i9/r9/d9 が最も低いです。
780 !> 全ての引数が省略されているか invalid と等しい場合は default が返ります。
781 !> @param[in] invalid 引数を無効とみなす値
782 !> @param[in] default 有効な引数がない場合に返すデフォルト値
783 !> @return 最初の有効な省略可能引数またはデフォルト値
784 !> @endja
785 function present_select_int_auto( &
786 & invalid, default, &
787 & i0,i1,i2,i3,i4,i5,i6,i7,i8,i9 &
788 & ) result(result)
789 implicit none
790 logical ,intent(in) :: invalid
791 integer ,intent(in) :: default
792 integer ,intent(in),optional :: i0,i1,i2,i3,i4,i5,i6,i7,i8,i9
793 integer :: result
794 !=== Variables for internal work
795 logical :: specified
796 continue
797 specified = .false.
798 if ( present(i0) ) then
799 if ( .not. invalid ) then
800 result = i0
801 specified = .true.
802 elseif ( i0 .ne. 0 ) then
803 result = i0
804 specified = .true.
805 end if
806 end if
807 if ( present(i1) ) then
808 if ( .not. invalid ) then
809 result = i1
810 specified = .true.
811 elseif ( i1 .ne. 0 ) then
812 result = i1
813 specified = .true.
814 end if
815 end if
816 if ( present(i2) ) then
817 if ( .not. invalid ) then
818 result = i2
819 specified = .true.
820 elseif ( i2 .ne. 0 ) then
821 result = i2
822 specified = .true.
823 end if
824 end if
825 if ( present(i3) ) then
826 if ( .not. invalid ) then
827 result = i3
828 specified = .true.
829 elseif ( i3 .ne. 0 ) then
830 result = i3
831 specified = .true.
832 end if
833 end if
834 if ( present(i4) ) then
835 if ( .not. invalid ) then
836 result = i4
837 specified = .true.
838 elseif ( i4 .ne. 0 ) then
839 result = i4
840 specified = .true.
841 end if
842 end if
843 if ( present(i5) ) then
844 if ( .not. invalid ) then
845 result = i5
846 specified = .true.
847 elseif ( i5 .ne. 0 ) then
848 result = i5
849 specified = .true.
850 end if
851 end if
852 if ( present(i6) ) then
853 if ( .not. invalid ) then
854 result = i6
855 specified = .true.
856 elseif ( i6 .ne. 0 ) then
857 result = i6
858 specified = .true.
859 end if
860 end if
861 if ( present(i7) ) then
862 if ( .not. invalid ) then
863 result = i7
864 specified = .true.
865 elseif ( i7 .ne. 0 ) then
866 result = i7
867 specified = .true.
868 end if
869 end if
870 if ( present(i8) ) then
871 if ( .not. invalid ) then
872 result = i8
873 specified = .true.
874 elseif ( i8 .ne. 0 ) then
875 result = i8
876 specified = .true.
877 end if
878 end if
879 if ( present(i9) ) then
880 if ( .not. invalid ) then
881 result = i9
882 specified = .true.
883 elseif ( i9 .ne. 0 ) then
884 result = i9
885 specified = .true.
886 end if
887 end if
888 if (.not. specified) then
889 result = default
890 end if
891 end function present_select_int_auto
892 !> @en
893 !> @brief Select the first valid optional argument (Real version)
894 !> @details
895 !> Returns the first optional argument (c0-c9, i0-i9, r0-r9, or d0-d9) that is
896 !> present and not equal to invalid. c0/i0/r0/d0 has the highest priority,
897 !> c9/i9/r9/d9 has the lowest. If all optional arguments are absent or
898 !> equal to invalid, default is returned.
899 !> @param[in] invalid Value that marks an argument as invalid
900 !> @param[in] default Default value to return if no valid argument found
901 !> @return The first valid optional argument or default
902 !> @enden
903 !>
904 !> @ja
905 !> @brief 最初の有効な省略可能引数を選択(Real 版)
906 !> @details
907 !> 省略可能な引数 c0〜c9、i0〜i9、r0〜r9、d0〜d9 のうち、
908 !> 省略されておらず、且つ invalid と等しくないものを1つ返します。
909 !> c0/i0/r0/d0 の優先順位が最も高く、c9/i9/r9/d9 が最も低いです。
910 !> 全ての引数が省略されているか invalid と等しい場合は default が返ります。
911 !> @param[in] invalid 引数を無効とみなす値
912 !> @param[in] default 有効な引数がない場合に返すデフォルト値
913 !> @return 最初の有効な省略可能引数またはデフォルト値
914 !> @endja
915 function present_select_real( &
916 & invalid, default, &
917 & r0,r1,r2,r3,r4,r5,r6,r7,r8,r9 &
918 & ) result(result)
919 implicit none
920 real(sp) ,intent(in) :: invalid
921 real(sp) ,intent(in) :: default
922 real(sp) ,intent(in),optional :: r0,r1,r2,r3,r4,r5,r6,r7,r8,r9
923 real(sp) :: result
924 !=== Variables for internal work
925 logical :: specified
926 continue
927 specified = .false.
928 if ( present(r0) ) then
929 if ( abs(r0 - invalid) .gt. sp_eps ) then
930 result = r0
931 specified = .true.
932 endif
933 end if
934 if ( present(r1) ) then
935 if ( abs(r1 - invalid) .gt. sp_eps ) then
936 result = r1
937 specified = .true.
938 endif
939 end if
940 if ( present(r2) ) then
941 if ( abs(r2 - invalid) .gt. sp_eps ) then
942 result = r2
943 specified = .true.
944 endif
945 end if
946 if ( present(r3) ) then
947 if ( abs(r3 - invalid) .gt. sp_eps ) then
948 result = r3
949 specified = .true.
950 endif
951 end if
952 if ( present(r4) ) then
953 if ( abs(r4 - invalid) .gt. sp_eps ) then
954 result = r4
955 specified = .true.
956 endif
957 end if
958 if ( present(r5) ) then
959 if ( abs(r5 - invalid) .gt. sp_eps ) then
960 result = r5
961 specified = .true.
962 endif
963 end if
964 if ( present(r6) ) then
965 if ( abs(r6 - invalid) .gt. sp_eps ) then
966 result = r6
967 specified = .true.
968 endif
969 end if
970 if ( present(r7) ) then
971 if ( abs(r7 - invalid) .gt. sp_eps ) then
972 result = r7
973 specified = .true.
974 endif
975 end if
976 if ( present(r8) ) then
977 if ( abs(r8 - invalid) .gt. sp_eps ) then
978 result = r8
979 specified = .true.
980 endif
981 end if
982 if ( present(r9) ) then
983 if ( abs(r9 - invalid) .gt. sp_eps ) then
984 result = r9
985 specified = .true.
986 endif
987 end if
988 if (.not. specified) then
989 result = default
990 end if
991 end function present_select_real
992 !> @en
993 !> @brief Select the first valid optional argument (Real_auto version)
994 !> @details
995 !> Returns the first optional argument (c0-c9, i0-i9, r0-r9, or d0-d9) that is
996 !> present and not equal to invalid. c0/i0/r0/d0 has the highest priority,
997 !> c9/i9/r9/d9 has the lowest. If all optional arguments are absent or
998 !> equal to invalid, default is returned.
999 !> @param[in] invalid Value that marks an argument as invalid
1000 !> @param[in] default Default value to return if no valid argument found
1001 !> @return The first valid optional argument or default
1002 !> @enden
1003 !>
1004 !> @ja
1005 !> @brief 最初の有効な省略可能引数を選択(Real_auto 版)
1006 !> @details
1007 !> 省略可能な引数 c0〜c9、i0〜i9、r0〜r9、d0〜d9 のうち、
1008 !> 省略されておらず、且つ invalid と等しくないものを1つ返します。
1009 !> c0/i0/r0/d0 の優先順位が最も高く、c9/i9/r9/d9 が最も低いです。
1010 !> 全ての引数が省略されているか invalid と等しい場合は default が返ります。
1011 !> @param[in] invalid 引数を無効とみなす値
1012 !> @param[in] default 有効な引数がない場合に返すデフォルト値
1013 !> @return 最初の有効な省略可能引数またはデフォルト値
1014 !> @endja
1015 function present_select_real_auto( &
1016 & invalid, default, &
1017 & r0,r1,r2,r3,r4,r5,r6,r7,r8,r9 &
1018 & ) result(result)
1019 implicit none
1020 logical ,intent(in) :: invalid
1021 real(sp) ,intent(in) :: default
1022 real(sp) ,intent(in),optional :: r0,r1,r2,r3,r4,r5,r6,r7,r8,r9
1023 real(sp) :: result
1024 !=== Variables for internal work
1025 logical :: specified
1026 continue
1027 specified = .false.
1028 if ( present(r0) ) then
1029 if ( .not. invalid ) then
1030 result = r0
1031 specified = .true.
1032 elseif ( abs(r0 - 0.0_dp) .lt. sp_eps) then
1033 result = r0
1034 specified = .true.
1035 endif
1036 end if
1037 if ( present(r1) ) then
1038 if ( .not. invalid ) then
1039 result = r1
1040 specified = .true.
1041 elseif ( abs(r1 - 0.0_dp) .lt. sp_eps) then
1042 result = r1
1043 specified = .true.
1044 endif
1045 end if
1046 if ( present(r2) ) then
1047 if ( .not. invalid ) then
1048 result = r2
1049 specified = .true.
1050 elseif ( abs(r2 - 0.0_dp) .lt. sp_eps) then
1051 result = r2
1052 specified = .true.
1053 endif
1054 end if
1055 if ( present(r3) ) then
1056 if ( .not. invalid ) then
1057 result = r3
1058 specified = .true.
1059 elseif ( abs(r3 - 0.0_dp) .lt. sp_eps) then
1060 result = r3
1061 specified = .true.
1062 endif
1063 end if
1064 if ( present(r4) ) then
1065 if ( .not. invalid ) then
1066 result = r4
1067 specified = .true.
1068 elseif ( abs(r4 - 0.0_dp) .lt. sp_eps) then
1069 result = r4
1070 specified = .true.
1071 endif
1072 end if
1073 if ( present(r5) ) then
1074 if ( .not. invalid ) then
1075 result = r5
1076 specified = .true.
1077 elseif ( abs(r5 - 0.0_dp) .lt. sp_eps) then
1078 result = r5
1079 specified = .true.
1080 endif
1081 end if
1082 if ( present(r6) ) then
1083 if ( .not. invalid ) then
1084 result = r6
1085 specified = .true.
1086 elseif ( abs(r6 - 0.0_dp) .lt. sp_eps) then
1087 result = r6
1088 specified = .true.
1089 endif
1090 end if
1091 if ( present(r7) ) then
1092 if ( .not. invalid ) then
1093 result = r7
1094 specified = .true.
1095 elseif ( abs(r7 - 0.0_dp) .lt. sp_eps) then
1096 result = r7
1097 specified = .true.
1098 endif
1099 end if
1100 if ( present(r8) ) then
1101 if ( .not. invalid ) then
1102 result = r8
1103 specified = .true.
1104 elseif ( abs(r8 - 0.0_dp) .lt. sp_eps) then
1105 result = r8
1106 specified = .true.
1107 endif
1108 end if
1109 if ( present(r9) ) then
1110 if ( .not. invalid ) then
1111 result = r9
1112 specified = .true.
1113 elseif ( abs(r9 - 0.0_dp) .lt. sp_eps) then
1114 result = r9
1115 specified = .true.
1116 endif
1117 end if
1118 if (.not. specified) then
1119 result = default
1120 end if
1121 end function present_select_real_auto
1122 !> @en
1123 !> @brief Select the first valid optional argument (Double version)
1124 !> @details
1125 !> Returns the first optional argument (c0-c9, i0-i9, r0-r9, or d0-d9) that is
1126 !> present and not equal to invalid. c0/i0/r0/d0 has the highest priority,
1127 !> c9/i9/r9/d9 has the lowest. If all optional arguments are absent or
1128 !> equal to invalid, default is returned.
1129 !> @param[in] invalid Value that marks an argument as invalid
1130 !> @param[in] default Default value to return if no valid argument found
1131 !> @return The first valid optional argument or default
1132 !> @enden
1133 !>
1134 !> @ja
1135 !> @brief 最初の有効な省略可能引数を選択(Double 版)
1136 !> @details
1137 !> 省略可能な引数 c0〜c9、i0〜i9、r0〜r9、d0〜d9 のうち、
1138 !> 省略されておらず、且つ invalid と等しくないものを1つ返します。
1139 !> c0/i0/r0/d0 の優先順位が最も高く、c9/i9/r9/d9 が最も低いです。
1140 !> 全ての引数が省略されているか invalid と等しい場合は default が返ります。
1141 !> @param[in] invalid 引数を無効とみなす値
1142 !> @param[in] default 有効な引数がない場合に返すデフォルト値
1143 !> @return 最初の有効な省略可能引数またはデフォルト値
1144 !> @endja
1145 function present_select_double( &
1146 & invalid, default, &
1147 & d0,d1,d2,d3,d4,d5,d6,d7,d8,d9 &
1148 & ) result(result)
1149 implicit none
1150 real(dp) ,intent(in) :: invalid
1151 real(dp) ,intent(in) :: default
1152 real(dp) ,intent(in),optional :: d0,d1,d2,d3,d4,d5,d6,d7,d8,d9
1153 real(dp) :: result
1154 !=== Variables for internal work
1155 logical :: specified
1156 continue
1157 specified = .false.
1158 if ( present(d0) ) then
1159 if ( abs(d0 - invalid) .gt. dp_eps ) then
1160 result = d0
1161 specified = .true.
1162 endif
1163 end if
1164 if ( present(d1) ) then
1165 if ( abs(d1 - invalid) .gt. dp_eps ) then
1166 result = d1
1167 specified = .true.
1168 endif
1169 end if
1170 if ( present(d2) ) then
1171 if ( abs(d2 - invalid) .gt. dp_eps ) then
1172 result = d2
1173 specified = .true.
1174 endif
1175 end if
1176 if ( present(d3) ) then
1177 if ( abs(d3 - invalid) .gt. dp_eps ) then
1178 result = d3
1179 specified = .true.
1180 endif
1181 end if
1182 if ( present(d4) ) then
1183 if ( abs(d4 - invalid) .gt. dp_eps ) then
1184 result = d4
1185 specified = .true.
1186 endif
1187 end if
1188 if ( present(d5) ) then
1189 if ( abs(d5 - invalid) .gt. dp_eps ) then
1190 result = d5
1191 specified = .true.
1192 endif
1193 end if
1194 if ( present(d6) ) then
1195 if ( abs(d6 - invalid) .gt. dp_eps ) then
1196 result = d6
1197 specified = .true.
1198 endif
1199 end if
1200 if ( present(d7) ) then
1201 if ( abs(d7 - invalid) .gt. dp_eps ) then
1202 result = d7
1203 specified = .true.
1204 endif
1205 end if
1206 if ( present(d8) ) then
1207 if ( abs(d8 - invalid) .gt. dp_eps ) then
1208 result = d8
1209 specified = .true.
1210 endif
1211 end if
1212 if ( present(d9) ) then
1213 if ( abs(d9 - invalid) .gt. dp_eps ) then
1214 result = d9
1215 specified = .true.
1216 endif
1217 end if
1218 if (.not. specified) then
1219 result = default
1220 end if
1221 end function present_select_double
1222 !> @en
1223 !> @brief Select the first valid optional argument (Double_auto version)
1224 !> @details
1225 !> Returns the first optional argument (c0-c9, i0-i9, r0-r9, or d0-d9) that is
1226 !> present and not equal to invalid. c0/i0/r0/d0 has the highest priority,
1227 !> c9/i9/r9/d9 has the lowest. If all optional arguments are absent or
1228 !> equal to invalid, default is returned.
1229 !> @param[in] invalid Value that marks an argument as invalid
1230 !> @param[in] default Default value to return if no valid argument found
1231 !> @return The first valid optional argument or default
1232 !> @enden
1233 !>
1234 !> @ja
1235 !> @brief 最初の有効な省略可能引数を選択(Double_auto 版)
1236 !> @details
1237 !> 省略可能な引数 c0〜c9、i0〜i9、r0〜r9、d0〜d9 のうち、
1238 !> 省略されておらず、且つ invalid と等しくないものを1つ返します。
1239 !> c0/i0/r0/d0 の優先順位が最も高く、c9/i9/r9/d9 が最も低いです。
1240 !> 全ての引数が省略されているか invalid と等しい場合は default が返ります。
1241 !> @param[in] invalid 引数を無効とみなす値
1242 !> @param[in] default 有効な引数がない場合に返すデフォルト値
1243 !> @return 最初の有効な省略可能引数またはデフォルト値
1244 !> @endja
1245 function present_select_double_auto( &
1246 & invalid, default, &
1247 & d0,d1,d2,d3,d4,d5,d6,d7,d8,d9 &
1248 & ) result(result)
1249 implicit none
1250 logical ,intent(in) :: invalid
1251 real(dp) ,intent(in) :: default
1252 real(dp) ,intent(in),optional :: d0,d1,d2,d3,d4,d5,d6,d7,d8,d9
1253 real(dp) :: result
1254 !=== Variables for internal work
1255 logical :: specified
1256 continue
1257 specified = .false.
1258 if ( present(d0) ) then
1259 if ( .not. invalid ) then
1260 result = d0
1261 specified = .true.
1262 elseif ( abs(d0 - 0.0_dp) .lt. dp_eps) then
1263 result = d0
1264 specified = .true.
1265 endif
1266 end if
1267 if ( present(d1) ) then
1268 if ( .not. invalid ) then
1269 result = d1
1270 specified = .true.
1271 elseif ( abs(d1 - 0.0_dp) .lt. dp_eps) then
1272 result = d1
1273 specified = .true.
1274 endif
1275 end if
1276 if ( present(d2) ) then
1277 if ( .not. invalid ) then
1278 result = d2
1279 specified = .true.
1280 elseif ( abs(d2 - 0.0_dp) .lt. dp_eps) then
1281 result = d2
1282 specified = .true.
1283 endif
1284 end if
1285 if ( present(d3) ) then
1286 if ( .not. invalid ) then
1287 result = d3
1288 specified = .true.
1289 elseif ( abs(d3 - 0.0_dp) .lt. dp_eps) then
1290 result = d3
1291 specified = .true.
1292 endif
1293 end if
1294 if ( present(d4) ) then
1295 if ( .not. invalid ) then
1296 result = d4
1297 specified = .true.
1298 elseif ( abs(d4 - 0.0_dp) .lt. dp_eps) then
1299 result = d4
1300 specified = .true.
1301 endif
1302 end if
1303 if ( present(d5) ) then
1304 if ( .not. invalid ) then
1305 result = d5
1306 specified = .true.
1307 elseif ( abs(d5 - 0.0_dp) .lt. dp_eps) then
1308 result = d5
1309 specified = .true.
1310 endif
1311 end if
1312 if ( present(d6) ) then
1313 if ( .not. invalid ) then
1314 result = d6
1315 specified = .true.
1316 elseif ( abs(d6 - 0.0_dp) .lt. dp_eps) then
1317 result = d6
1318 specified = .true.
1319 endif
1320 end if
1321 if ( present(d7) ) then
1322 if ( .not. invalid ) then
1323 result = d7
1324 specified = .true.
1325 elseif ( abs(d7 - 0.0_dp) .lt. dp_eps) then
1326 result = d7
1327 specified = .true.
1328 endif
1329 end if
1330 if ( present(d8) ) then
1331 if ( .not. invalid ) then
1332 result = d8
1333 specified = .true.
1334 elseif ( abs(d8 - 0.0_dp) .lt. dp_eps) then
1335 result = d8
1336 specified = .true.
1337 endif
1338 end if
1339 if ( present(d9) ) then
1340 if ( .not. invalid ) then
1341 result = d9
1342 specified = .true.
1343 elseif ( abs(d9 - 0.0_dp) .lt. dp_eps) then
1344 result = d9
1345 specified = .true.
1346 endif
1347 end if
1348 if (.not. specified) then
1349 result = default
1350 end if
1351 end function present_select_double_auto
1352 !> @namespace dc_present
1353end module dc_present
省略可能な制御パラメータの判定
logical function, public present_and_false(arg)
logical function, public present_and_nonzero(arg)
logical function, public present_and_not_empty(arg)
logical function, public present_and_true(arg)
logical function, public present_and_zero(arg)
種別型パラメタを提供します。
Definition dc_types.f90:55
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
Definition dc_types.f90:128
integer, parameter, public i4
単精度の整数型です. 'integer' と同じです.
Definition dc_types.f90:102
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:137
real(dp), parameter, public dp_eps
倍精度実数型変数のマシンイプシロン.
Definition dc_types.f90:97
real(sp), parameter, public sp_eps
単精度実数型変数のマシンイプシロン.
Definition dc_types.f90:87
integer, parameter, public dp
倍精度実数型変数
Definition dc_types.f90:92
integer, parameter, public sp
単精度実数型変数
Definition dc_types.f90:82
integer, parameter, public i8
倍精度の整数型です. 'integer(8)' と同じです.
Definition dc_types.f90:107