Octopus
help.F90
Go to the documentation of this file.
1!! Copyright (C) 2007 Xavier Andrade
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
21module help_main_oct_m
23 use global_oct_m
24 use iso_c_binding
25 use string_oct_m
27 use iso_fortran_env, only: output_unit, error_unit
28
29 implicit none
30
31 private
32 public :: help_main
33
34contains
35
36 subroutine help_main() bind(c)
37 integer :: ierr
38 character(len=32) :: mode
39 character(len=100) :: varname
40 character(kind=c_char) :: cmode(33), cvarname(101)
41
42 integer, parameter :: help_stdout = output_unit, help_stderr = error_unit
43
45
46 call getopt_init(ierr)
47 if (ierr /= 0) then
48 write(stderr, '(a)') "Your Fortran compiler doesn't support command-line arguments;"
49 write(stderr, '(a)') "the oct-help command is not available."
50 stop 1
51 end if
52
53 cmode = c_null_char
54 cvarname = c_null_char
55 call getopt_help(cmode, cvarname)
56 call string_c_to_f(cmode, mode)
57 call string_c_to_f(cvarname, varname)
58 call getopt_end()
59
60 select case (mode)
61 case ("print")
62 call varinfo_print(help_stdout, trim(varname), ierr)
63 if (ierr /= 0) then
64 write(help_stderr, '(a)') "Error: Variable "//trim(varname)//" not found."
65 end if
66
67 case ("search")
68 call varinfo_search(help_stdout, trim(varname), ierr)
69
70 case ("list")
71 call varinfo_search(help_stdout, "", ierr)
72
73 case default
74 write(help_stderr, '(a)') "Error: Unknown mode '"//trim(mode)//"'."
75 stop 1
76 end select
77
78 call global_end()
79 end subroutine help_main
80end module help_main_oct_m
81
82!! Local Variables:
83!! mode: f90
84!! coding: utf-8
85!! End:
This module provides an interface to the getopt C library, so that the command line arguments can be ...
subroutine, public getopt_init(ierr)
Initializes the getopt machinery. Must be called before attempting to parse the options....
subroutine, public getopt_end
subroutine, public global_end()
Finalise parser varinfo file, and MPI.
Definition: global.F90:500
type(mpi_comm), parameter, public serial_dummy_comm
Alias MPI_COMM_UNDEFINED for the specific use case of initialising Octopus utilities with no MPI supp...
Definition: global.F90:268
subroutine, public init_octopus_globals(comm)
Initialise Octopus-specific global constants and files. This routine performs no initialisation calls...
Definition: global.F90:438
subroutine, public help_main()
Definition: help.F90:109
subroutine, public string_c_to_f(c_string, f_string)
convert a C string to a Fortran string
Definition: string.F90:253
subroutine, public varinfo_print(iunit, var, ierr)
Definition: varinfo.F90:184
subroutine, public varinfo_search(iunit, var, ierr)
Definition: varinfo.F90:348