Class option_parser
In: setup/option_parser.f90

コマンドライン引数解析処理

Command line option parser

Note that Japanese and English are described in parallel.

コマンドライン引数の解析処理を行います.

Command line options are parsed

Procedures List

OptParseInit :コマンドライン引数の解析処理
———— :————
OptParseInit :Parse of command line options

Methods

Included Modules

dc_types dc_string dc_args dc_present

Public Instance methods

Subroutine :
namelist_filename :character(*), intent(out)
: NAMELIST ファイルの名称. NAMELIST file name
exec_name :character(*), intent(in ), optional
: 実行ファイル名. Executable file name
brief :character(*), intent(in ), optional
: 実行ファイルの簡潔な説明 Brief account of executable file

option_parser モジュールの初期設定を行います.

Initialize "option_parser" module.

[Source]

  subroutine OptParseInit( namelist_filename, exec_name, brief )
    !
    ! option_parser モジュールの初期設定を行います. 
    !
    ! Initialize "option_parser" module. 
    !

    ! モジュール引用 ; USE statements
    !

    ! 文字列操作
    ! Character handling
    !
    use dc_string, only: StoA

    ! コマンドライン引数処理下請け
    ! Command line option parser subcontractor
    !
    use dc_args, only: ARGS, DCArgsOpen,  DCArgsHelpMsg, DCArgsOption, DCArgsDebug, DCArgsHelp,    DCArgsStrict, DCArgsClose

    ! 組み込み関数 PRESENT の拡張版関数
    ! Extended functions of intrinsic function "PRESENT"
    !
    use dc_present, only: present_and_not_empty

    ! 宣言文 ; Declaration statements
    !
    implicit none
    character(*), intent(out)          :: namelist_filename
                              ! NAMELIST ファイルの名称. 
                              ! NAMELIST file name
    character(*), intent(in ), optional:: exec_name
                              ! 実行ファイル名. 
                              ! Executable file name
    character(*), intent(in ), optional:: brief
                              ! 実行ファイルの簡潔な説明
                              ! Brief account of executable file

    character(STRING):: ename
                              ! 実行ファイル名. 
                              ! Executable file name
    character(STRING):: brief_msg
                              ! 実行ファイルの簡潔な説明
                              ! Brief account of executable file

    type(ARGS):: arg          ! コマンドライン引数. 
                              ! Command line options

    ! 実行文 ; Executable statement
    !

    if ( option_parser_inited ) return
    call InitCheck

    ! オプショナル引数の処理. 
    ! Handling of optional arguments 
    !
    if ( present_and_not_empty(exec_name) ) then
      ename = exec_name
    else
      ename = 'dcpam'
    end if

    if ( present_and_not_empty(brief) ) then
      brief_msg = brief
    else
      brief_msg = 'dcpam main program'
    end if

    ! コマンドライン引数の解析処理
    ! Parse command line arguments
    !
    call DCArgsOpen( arg )               ! (out)

    call DCArgsHelpMsg( arg, category = 'Title', msg = trim(ename) // ': ' // trim(brief_msg) )  ! (in)
    call DCArgsHelpMsg( arg, category = 'Usage', msg = './' // trim(ename) // ' [Options]' ) ! (in)

    call DCArgsOption( arg, options = StoA('-N', '--namelist'), flag = namelist_flag, value = namelist_filename, help = "Namelist filename")           ! (in)

    call DCArgsDebug( arg )  ! (inout)
    call DCArgsHelp( arg )   ! (inout)
    call DCArgsStrict( arg ) ! (inout)

    call DCArgsClose( arg )  ! (inout)

    option_parser_inited = .true.
  end subroutine OptParseInit
option_parser_inited
Variable :
option_parser_inited = .false. :logical, save, public
: 初期設定フラグ. Initialization flag

Private Instance methods

Subroutine :

依存モジュールの初期化チェック

Check initialization of dependency modules

[Source]

  subroutine InitCheck
    !
    ! 依存モジュールの初期化チェック
    !
    ! Check initialization of dependency modules

    ! 実行文 ; Executable statement
    !


  end subroutine InitCheck
module_name
Constant :
module_name = ‘option_parser :character(*), parameter
: モジュールの名称. Module name
namelist_flag
Variable :
namelist_flag = .false. :logical, save
: NAMELIST ファイル指定の有無を示すフラグ. Flag of NAMELIST file specification
version
Constant :
version = ’$Name: $’ // ’$Id: option_parser.f90,v 1.3 2010/08/30 01:54:45 yot Exp $’ :character(*), parameter
: モジュールのバージョン Module version