初始化和解析命令行参数
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line), | intent(out) | :: | self |
subroutine parse(self)
class(command_line), intent(out) :: self
type(argparser) :: args
character(*), parameter :: version_text = &
&"Version : 0.6.202310, alpha (Built on "//__DATE__//")\n&
&Program : SPX\n&
&Description: Smoothed Particle Hydrodynamics transient solver\n&
&Home Page : https://gitee.com/ship-motions/SmoothedParticleXimulation\n&
&Author : ZUO Zhihua (E-mail: zuo.zhihua@qq.com)\n&
&License : BSD-3-Clause"
args = argparser("Smoothed Particle Hydrodynamics transient solver.")
call args%set_program_name("spx")
call args%add_help_option()
call args%add_sc_option('-v', '--version', 'show version info', show_version_info)
call args%add_option_logical("-d", "--debug", "debug mode")
call args%add_option_string("-C", "--directory", "working directory", ".")
call args%add_option_integer("-t", "--num-threads", "number of OpenMP threads (deprecated)", 4)
call args%add_option_string("-f", "--file", "input file", "spx.nml")
call args%parse()
self%working_directory = unix_path(args%get_option_string("--directory"))
self%num_threads = args%get_option_integer("--num-threads")
self%debug_mode = args%get_option_logical("--debug")
self%file = trim(args%get_option_string("--file"))
contains
!> 显示版本信息
subroutine show_version_info()
print '(a)', esc(version_text)
end subroutine show_version_info
end subroutine parse