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
21program oct_help
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 integer :: ierr
32 character(len=32) :: mode
33 character(len=100) :: varname
34 character(kind=c_char) :: cmode(33), cvarname(101)
35
36 integer, parameter :: help_stdout = output_unit, help_stderr = error_unit
37
39
40 call getopt_init(ierr)
41 if (ierr /= 0) then
42 write(stderr, '(a)') "Your Fortran compiler doesn't support command-line arguments;"
43 write(stderr, '(a)') "the oct-help command is not available."
44 stop 1
45 end if
46
47 cmode = c_null_char
48 cvarname = c_null_char
49 call getopt_help(cmode, cvarname)
50 call string_c_to_f(cmode, mode)
51 call string_c_to_f(cvarname, varname)
52 call getopt_end()
53
54 select case (mode)
55 case ("print")
56 call varinfo_print(help_stdout, trim(varname), ierr)
57 if (ierr /= 0) then
58 write(help_stderr, '(a)') "Error: Variable "//trim(varname)//" not found."
59 end if
60
61 case ("search")
62 call varinfo_search(help_stdout, trim(varname), ierr)
63
64 case ("list")
65 call varinfo_search(help_stdout, "", ierr)
66
67 case default
68 write(help_stderr, '(a)') "Error: Unknown mode '"//trim(mode)//"'."
69 stop 1
70 end select
71
72 call global_end()
73
74end program oct_help
75
76!! Local Variables:
77!! mode: f90
78!! coding: utf-8
79!! End:
program oct_help
Definition: help.F90:116
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:494
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:294
subroutine, public init_octopus_globals(comm)
Initialise Octopus-specific global constants and files. This routine performs no initialisation calls...
Definition: global.F90:432
subroutine, public string_c_to_f(c_string, f_string)
convert a C string to a Fortran string
Definition: string.F90:276
subroutine, public varinfo_print(iunit, var, ierr)
Definition: varinfo.F90:207
subroutine, public varinfo_search(iunit, var, ierr)
Definition: varinfo.F90:371