Line data Source code
1 : !> \file mo_edk_cli.f90 2 : !> \brief \copybrief mo_edk_cli 3 : !> \details \copydetails mo_edk_cli 4 : 5 : !> \brief Module to parse command line arguments of edk. 6 : !> \version 0.1 7 : !> \authors Sebastian Mueller 8 : !> \date Jun 2022 9 : !> \details A simple parser for command line arguments for edk. 10 : !! You can pass the path to the config namelist (main.dat by default) 11 : !! 12 : !! You can also pass the CWD as plain last argument and get a help or version text. 13 : !! 14 : !! \code{.sh} 15 : !! edk -h 16 : !! edk -v 17 : !! \endcode 18 : !> \copyright Copyright 2005-\today, the CHS Developers, Luis Samaniego, Sabine Attinger: All rights reserved. 19 : !! EDK is released under the LGPLv3+ license \license_note 20 : module mo_edk_cli 21 : implicit none 22 : 23 : private 24 : 25 : public :: parse_command_line 26 : 27 : contains 28 : 29 : !> \brief parse the given command line arguments. 30 2 : subroutine parse_command_line() 31 : use mo_cli, only: cli_parser 32 : use mo_edk_info, only: version, file_namelist 33 : use mo_os, only: change_dir 34 : 35 : implicit none 36 : 37 2 : type(cli_parser) :: parser 38 : 39 : parser = cli_parser( & 40 : description="The External Drift Kriging - EDK program", & 41 : add_version_option=.true., & 42 2 : version=version) 43 : 44 : call parser%add_option( & 45 : name="cwd", & 46 : blank=.true., & 47 2 : help="The desired working directory (optional).") 48 : 49 : call parser%add_option( & 50 : name="nml", & 51 : s_name="n", & 52 : has_value=.true., & 53 : value_name="path", & 54 : default="edk.nml", & 55 2 : help="The edk configuration namelist.") 56 : 57 : ! parse given command line arguments 58 2 : call parser%parse() 59 : 60 : ! change working directory first 61 2 : if (parser%option_was_read("cwd")) call change_dir(parser%option_value("cwd")) 62 : 63 : ! set nml file path 64 2 : file_namelist = parser%option_value("nml") 65 : 66 10 : end subroutine parse_command_line 67 : 68 : end module mo_edk_cli