\hypertarget{interfacedc__args_1_1option}{}\section{dc\+\_\+args\+:\+:option Interface Reference}
\label{interfacedc__args_1_1option}\index{dc\+\_\+args\+::option@{dc\+\_\+args\+::option}}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
subroutine \hyperlink{interfacedc__args_1_1option_a4aca5128ad8d2bd089ea246b9625a83c}{dcargsoption0} (arg, options, flag, value, \hyperlink{interfacedc__args_1_1help}{help})
\end{DoxyCompactItemize}


\subsection{Detailed Description}


Definition at line 278 of file dc\+\_\+args.\+f90.



\subsection{Member Function/\+Subroutine Documentation}
\mbox{\Hypertarget{interfacedc__args_1_1option_a4aca5128ad8d2bd089ea246b9625a83c}\label{interfacedc__args_1_1option_a4aca5128ad8d2bd089ea246b9625a83c}} 
\index{dc\+\_\+args\+::option@{dc\+\_\+args\+::option}!dcargsoption0@{dcargsoption0}}
\index{dcargsoption0@{dcargsoption0}!dc\+\_\+args\+::option@{dc\+\_\+args\+::option}}
\subsubsection{\texorpdfstring{dcargsoption0()}{dcargsoption0()}}
{\footnotesize\ttfamily subroutine dc\+\_\+args\+::option\+::dcargsoption0 (\begin{DoxyParamCaption}\item[{type(\hyperlink{structdc__args_1_1args}{args}), intent(inout)}]{arg,  }\item[{character(len = $\ast$), dimension(\+:), intent(in)}]{options,  }\item[{logical, intent(out)}]{flag,  }\item[{character(len = $\ast$), intent(out), optional}]{value,  }\item[{character(len = $\ast$), intent(in), optional}]{help }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 395 of file dc\+\_\+args.\+f90.


\begin{DoxyCode}
395     \textcolor{comment}{!}
396     \textcolor{comment}{! オプション情報の登録と取得を行います. }
397     \textcolor{comment}{!}
398     \textcolor{comment}{! コマンドライン引数のうち, *options* に与えるオプションに関する情}
399     \textcolor{comment}{! 報を *flag* と *value* に取得します. *options* がコマンドライン}
400     \textcolor{comment}{! 引数に与えられていれば *flag* に .true. が, そうでない場合は }
401     \textcolor{comment}{! .false. が返ります. オプションに値が指定される場合は *value* に}
402     \textcolor{comment}{! その値が返ります. オプション自体が与えられていない場合には}
403     \textcolor{comment}{! *value* には空文字が返ります.}
404     \textcolor{comment}{!}
405     \textcolor{comment}{! *help* には *options* に関するヘルプメッセージを *arg* に}
406     \textcolor{comment}{! 登録します. サブルーチン DCArgsHelp を}
407     \textcolor{comment}{! 用いた際に, このメッセージが出力されます.}
408     \textcolor{comment}{! *value* を与えているかどうかでこのメッセージは変化します.}
409     \textcolor{comment}{!}
410     \textcolor{comment}{!=== オプションの書式}
411     \textcolor{comment}{!}
412     \textcolor{comment}{! コマンドライン引数のうち, オプションと判定されるのは以下の場合です.}
413     \textcolor{comment}{!}
414     \textcolor{comment}{! * 1 文字目が '-' の場合. この場合は短いオプションとなり, '-'}
415     \textcolor{comment}{!   の次の一文字のみがオプションとして有効になります.}
416     \textcolor{comment}{!}
417     \textcolor{comment}{! * 1-2文字目が '--' (ハイフン 2 文字) の場合.}
418     \textcolor{comment}{!   この場合は長いオプションとなり,}
419     \textcolor{comment}{!   '--' 以降の文字列がオプションとして有効になります.}
420     \textcolor{comment}{!}
421     \textcolor{comment}{! オプションの値は, "=" よりも後ろの文字列になります.}
422     \textcolor{comment}{!}
423     \textcolor{comment}{! 例}
424     \textcolor{comment}{!}
425     \textcolor{comment}{! <b>コマンドライン引数</b>  :: <b>オプション名, 値      </b>}
426     \textcolor{comment}{! -h                         ::    -h,           無し}
427     \textcolor{comment}{! --help                     ::    --help,       無し}
428     \textcolor{comment}{! -D=6                       ::    -D,            6}
429     \textcolor{comment}{! -debug=                    ::    -d,           無し}
430     \textcolor{comment}{! --include=/usr             ::    --include,    /usr}
431     \textcolor{comment}{!}
432 
433     \textcolor{keywordtype}{use }\hyperlink{namespacedc__message}{dc\_message}\textcolor{keywordtype}{, only}: \hyperlink{interfacedc__message_1_1messagenotify}{messagenotify}
434     \textcolor{keywordtype}{implicit none}
435     \textcolor{keywordtype}{type}(args), \textcolor{keywordtype}{intent(inout)} :: arg
436     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)} :: options(:)
437     \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)} :: flag
438     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(out)}, \textcolor{keywordtype}{optional} :: value
439     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}, \textcolor{keywordtype}{optional} :: help
440     \textcolor{keywordtype}{integer} :: i, j, options\_size, table\_size
441     \textcolor{keywordtype}{type}(opt\_entry), \textcolor{keywordtype}{allocatable} :: local\_tables(:)
442     \textcolor{keywordtype}{character(len = STRING)} :: opt\_name, opt\_value, opt\_full
443     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{parameter}  :: subname = \textcolor{stringliteral}{'DCArgsOption'}
444   \textcolor{keywordflow}{continue}
445     flag = .false.
446     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(\textcolor{keywordtype}{value})) \textcolor{keywordtype}{value} = \textcolor{stringliteral}{''}
447     \textcolor{keywordflow}{if} (.not. arg % initialized) \textcolor{keywordflow}{then}
448       \textcolor{keyword}{call }\hyperlink{interfacedc__message_1_1messagenotify}{messagenotify}(\textcolor{stringliteral}{'W'}, subname, \textcolor{stringliteral}{'Call Open before Option in dc\_args.'})
449       \textcolor{keyword}{call }dcargsopen(arg)
450 \textcolor{keywordflow}{    end if}
451     options\_size = \textcolor{keyword}{size}(options)
452     \textcolor{keywordflow}{if} (options\_size < 1) \textcolor{keywordflow}{then}
453       \textcolor{keywordflow}{return}
454 \textcolor{keywordflow}{    end if}
455 
456     \textcolor{comment}{!-----------------------------------}
457     \textcolor{comment}{! 構造体 ARGS へのヘルプメッセージ用の情報登録}
458     \textcolor{comment}{! * まずはテーブル arg % opt\_table を一つ広げる.}
459     \textcolor{comment}{!-----------------------------------}
460     \textcolor{keywordflow}{if} ( .not. \textcolor{keyword}{associated}( arg % opt\_table ) ) \textcolor{keywordflow}{then}
461       \textcolor{comment}{! 1 つめのオプション指定}
462       \textcolor{comment}{!}
463       table\_size = 0
464       \textcolor{keyword}{allocate}(arg % opt\_table(table\_size + 1))
465     \textcolor{keywordflow}{else}
466       \textcolor{comment}{! 2 つめ以降のオプション指定}
467       \textcolor{comment}{!}
468       table\_size = \textcolor{keyword}{size}(arg % opt\_table)
469       \textcolor{keyword}{allocate}(local\_tables(table\_size))
470       local\_tables(1:table\_size) = arg % opt\_table(1:table\_size)
471       \textcolor{keyword}{deallocate}(arg % opt\_table)
472       \textcolor{keyword}{allocate}(arg % opt\_table(table\_size + 1))
473       arg % opt\_table(1:table\_size) = local\_tables(1:table\_size)
474       \textcolor{keyword}{deallocate}(local\_tables)
475 \textcolor{keywordflow}{    end if}
476 
477     \textcolor{comment}{!----- 値の代入 -----}
478     \textcolor{keyword}{allocate}(arg % opt\_table(table\_size + 1) % options(options\_size))
479     arg % opt\_table(table\_size + 1) % options = options
480     arg % opt\_table(table\_size + 1) % help\_message = \textcolor{stringliteral}{''}
481     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(help)) \textcolor{keywordflow}{then}
482       arg % opt\_table(table\_size + 1) % help\_message = help
483 \textcolor{keywordflow}{    end if}
484     arg % opt\_table(table\_size + 1) % optvalue\_flag = \textcolor{keyword}{present}(\textcolor{keywordtype}{value})
485 
486 
487     \textcolor{comment}{!----- options の正規化 -----}
488     \textcolor{keywordflow}{do} i = 1, options\_size
489       opt\_full = arg % opt\_table(table\_size + 1) % options(i)
490       \textcolor{keywordflow}{if} (dcoptionformc(opt\_full, opt\_name, opt\_value)) \textcolor{keywordflow}{then}
491         arg % opt\_table(table\_size + 1) % options(i) = opt\_name
492       \textcolor{keywordflow}{else}
493         \textcolor{keywordflow}{if} (len(trim(adjustl(opt\_full))) < 2) \textcolor{keywordflow}{then}
494           arg % opt\_table(table\_size + 1) % options(i) = &
495             & \textcolor{stringliteral}{'-'} // trim(adjustl(opt\_full))
496         \textcolor{keywordflow}{else}
497           arg % opt\_table(table\_size + 1) % options(i) = &
498             & \textcolor{stringliteral}{'--'} // trim(adjustl(opt\_full))
499 \textcolor{keywordflow}{        end if}
500 \textcolor{keywordflow}{      end if}
501 \textcolor{keywordflow}{    end do}
502 
503     \textcolor{comment}{! arg % cmd\_opts\_list 内の探査と flag, value への代入}
504     \textcolor{comment}{! 呼ばれたものに関しては arg % cmd\_opts\_list % flag\_called を}
505     \textcolor{comment}{! .true. に}
506     \textcolor{keywordflow}{do} i = 1, options\_size
507       \textcolor{keywordflow}{do} j = 1, \textcolor{keyword}{size}(arg % cmd\_opts\_list)
508         \textcolor{keywordflow}{if} (trim(arg % opt\_table(table\_size + 1) % options(i)) &
509           &             == trim(arg % cmd\_opts\_list(j) % name)) \textcolor{keywordflow}{then}
510           flag = .true.
511           \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(\textcolor{keywordtype}{value})) \textcolor{keywordflow}{then}
512             \textcolor{keywordtype}{value} = arg % cmd\_opts\_list(j) % value
513 \textcolor{keywordflow}{          end if}
514           arg % cmd\_opts\_list(j) % flag\_called = .true.
515 \textcolor{keywordflow}{        end if}
516 \textcolor{keywordflow}{      end do}
517 \textcolor{keywordflow}{    end do}
\end{DoxyCode}


The documentation for this interface was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
dc\+\_\+utils/\hyperlink{dc__args_8f90}{dc\+\_\+args.\+f90}\end{DoxyCompactItemize}
