在g ++中,我使用了getopt_long
來處理命令行選項。 是否有 存在相同的東西?Fortran命令行參數
我希望能夠通過一些Fortran單元測試。
目前我有以下。正如人們可以注意到我正在照顧 獲得關鍵和價值我自己。當使用C++ getopt_long 正在爲我做這個。
i = 1
Do
Call Get_command_argument (i, arg)
If (Len_trim (arg) == 0) Exit
pos = Index (arg, "=")
!!$ Long option argument.
If (arg(1:2) == "--") Then
If (pos == 0) Then
c = arg
val = ""
Else
c = arg(:pos-1)
val = arg(pos+1:)
End If
!!$ Short option argument.
Elseif (arg(1:1) == "-") Then
c = arg
val = arg(pos+1:)
!!$ Non option argument.
Else
c = arg
val = arg
End If
!!$------------------------------------------------------------
Select Case (c)
Case ("-b","--brief")
arg_brief = .True.
Case ("-h","--help")
arg_help = .True.
Case ("-v","-V","--version")
arg_version = .True.
! Output model geographical definition
Case ("-cunit")
arg_cunit = val
Case default
arg_nonopt = Trim (Adjustl (arg))
Write (*,*) "Warning: Non option argument"
End Select
i = i + 1
End Do
!!$-------------------------------------------------------------
!!$ [TODO] Get numbers from arg_cunit
If (arg_cunit .contains. "-") Then
If (arg_cunit .contains. ",") Then
!!$ "-" and "," are present.
Else
!!$ "-" only are present.
End If
Else If (arg_cunit .contains. ",") Then
!!$ "," only are present
End If
從您的評論下面,我可以建議你使_parsing_方面更加明確嗎? – francescalus 2014-12-04 15:07:15