Octopus
command_line.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
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
21! ---------------------------------------------------------
22!
25!
26! ---------------------------------------------------------
28
29 use string_oct_m
30 use iso_c_binding
31
32 implicit none
33
34 private
35 public :: &
37 getopt_end, &
48
49
50 ! ---------------------------------------------------------
51 ! First, the public interfaces.
52
53
59 interface
60 subroutine getopt_casida_spectrum
61 implicit none
62 end subroutine getopt_casida_spectrum
63
64 subroutine getopt_center_geom
65 implicit none
66 end subroutine getopt_center_geom
67
69 implicit none
70 end subroutine getopt_dielectric_function
71
72 subroutine getopt_vibrational(mode)
73 implicit none
74 integer, intent(inout) :: mode
75 end subroutine getopt_vibrational
76
77 subroutine getopt_xyz_anim
78 implicit none
79 end subroutine getopt_xyz_anim
80
81 subroutine getopt_oscillator_strength(mode, omega, searchinterval, &
82 order, nresonances, nfrequencies, time, &
83 l, m, damping, file)
84 use iso_c_binding
85 implicit none
86 integer, intent(inout) :: mode
87 real(c_double), intent(inout) :: omega
88 real(c_double), intent(inout) :: searchinterval
89 integer, intent(inout) :: order, nresonances, nfrequencies
90 real(c_double), intent(inout) :: time
91 integer, intent(inout) :: l, m
92 real(c_double), intent(inout) :: damping
93 character(kind=c_char), intent(inout) :: file(*)
94 end subroutine getopt_oscillator_strength
95
96 subroutine getopt_harmonic_spectrum(w0, m, ar, x, y, z, pol) bind(c)
97 use iso_c_binding
98 implicit none
99 real(c_double) , intent(inout) :: w0
100 integer , intent(inout) :: m
101 integer , intent(inout) :: ar
102 character(kind=c_char) , intent(inout) :: pol(*)
103 real(c_double) , intent(inout) :: x
104 real(c_double) , intent(inout) :: y
105 real(c_double) , intent(inout) :: z
106 end subroutine getopt_harmonic_spectrum
107
108 subroutine getopt_help(mode, name)
109 use iso_c_binding
110 implicit none
111 character(kind=c_char), intent(inout) :: mode(*)
112 character(kind=c_char), intent(inout) :: name(*)
113 end subroutine getopt_help
114
115 subroutine getopt_photoelectron_spectrum(estep, espan, &
116 thstep, thspan, phstep, phspan, pol, center, pvec, integrate)
117 use iso_c_binding
118 implicit none
119 real(c_double), intent(inout) :: estep
120 real(c_double), intent(inout) :: espan(2)
121 real(c_double), intent(inout) :: thstep
122 real(c_double), intent(inout) :: thspan(2)
123 real(c_double), intent(inout) :: phstep
124 real(c_double), intent(inout) :: phspan(2)
125 real(c_double), intent(inout) :: pol(3)
126 real(c_double), intent(inout) :: center(3)
127 real(c_double), intent(inout) :: pvec(3)
128 integer, intent(inout) :: integrate
129 end subroutine getopt_photoelectron_spectrum
130
131 end interface
133 ! ---------------------------------------------------------
137 interface
138 subroutine set_number_clarg(argc)
139 implicit none
140 integer, intent(in) :: argc
141 end subroutine set_number_clarg
142
143 subroutine set_clarg(i, argstring) bind(c)
144 use iso_c_binding
145 implicit none
146 integer, intent(in) :: i
147 character(kind=c_char), intent(in) :: argstring(*)
148 end subroutine set_clarg
150 subroutine clean_clarg()
151 implicit none
152 end subroutine clean_clarg
154 integer(c_int) function clarg_is_set() bind(c)
155 use iso_c_binding
156 implicit none
157 end function clarg_is_set
158 end interface
159
160
161contains
162
163 subroutine getopt_octopus(config_str)
164 character(len=*), intent(in) :: config_str
165 interface
166 subroutine getopt_octopus_low(config_str) bind(c, name='getopt_octopus')
167 use iso_c_binding
168 implicit none
169 character(kind=c_char), intent(in) :: config_str(*)
170 end subroutine getopt_octopus_low
171 end interface
172
173 call getopt_octopus_low(string_f_to_c(config_str))
174 end subroutine getopt_octopus
175
176 ! ---------------------------------------------------------
179 subroutine getopt_init(ierr)
180 integer, intent(out) :: ierr
181
182 integer :: argc, i
183 character(len=100), allocatable :: argstring(:)
184
185 ! Arguments may already have been set from outside, e.g. by the Python interface
186 if (clarg_is_set() /= 0) then
187 ierr = 0
188 return
189 end if
190
191 argc = command_argument_count()
192 allocate(argstring(0:argc))
193 call set_number_clarg(argc)
194 do i = 0, argc
195 call get_command_argument(i, argstring(i))
196 call set_clarg(i, string_f_to_c(argstring(i)))
197 end do
198 deallocate(argstring)
199 ierr = 0
200 end subroutine getopt_init
201
202
203 subroutine getopt_end
204 call clean_clarg()
205 end subroutine getopt_end
206
207end module command_line_oct_m
208
209
211!! Local Variables:
212!! mode: f90
213!! coding: utf-8
214!! End:
Each program/utility that needs to use the getopt features should have an interface here – the defini...
The following interfaces are private to this module, and should not be called from outside.
This module provides an interface to the getopt C library, so that the command line arguments can be ...
subroutine, public getopt_octopus(config_str)
subroutine, public getopt_init(ierr)
Initializes the getopt machinery. Must be called before attempting to parse the options....
subroutine, public getopt_end
character(kind=c_char, len=1) function, dimension(:), allocatable, public string_f_to_c(f_string)
convert a Fortran string to a C string
Definition: string.F90:234