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!
34!
35! ---------------------------------------------------------
37
38
60
61#ifdef FC_COMMAND_LINE_MODULE
62 use fc_command_line_module
63#endif
64
65 implicit none
66
67#ifdef FC_COMMAND_LINE_INCLUDE
68 include fc_command_line_include
69#endif
70
71 private
72 public :: &
74 getopt_end, &
86#if FC_COMMAND_LINE_ARGUMENTS != 2003
87 public :: &
88 command_argument_count, &
89 get_command_argument
90#endif
91
92
93 ! ---------------------------------------------------------
94 ! First, the public interfaces.
95
96
102 interface
103 subroutine getopt_octopus(config_str)
104 implicit none
105 character(len=*), intent(in) :: config_str
106 end subroutine getopt_octopus
107
108 subroutine getopt_casida_spectrum
109 implicit none
110 end subroutine getopt_casida_spectrum
111
112 subroutine getopt_center_geom
113 implicit none
114 end subroutine getopt_center_geom
115
117 implicit none
118 end subroutine getopt_dielectric_function
119
120 subroutine getopt_propagation_spectrum(fname)
121 implicit none
122 character(len=*), intent(inout) :: fname
123 end subroutine getopt_propagation_spectrum
124
125 subroutine getopt_vibrational(mode)
126 implicit none
127 integer, intent(inout) :: mode
128 end subroutine getopt_vibrational
130 subroutine getopt_xyz_anim
131 implicit none
132 end subroutine getopt_xyz_anim
133
134 subroutine getopt_oscillator_strength(mode, omega, searchinterval, &
135 order, nresonances, nfrequencies, time, &
136 l, m, damping, file)
137 use iso_c_binding
138 implicit none
139 integer, intent(inout) :: mode
140 real(c_double), intent(inout) :: omega
141 real(c_double), intent(inout) :: searchinterval
142 integer, intent(inout) :: order, nresonances, nfrequencies
143 real(c_double), intent(inout) :: time
144 integer, intent(inout) :: l, m
145 real(c_double), intent(inout) :: damping
146 character(len=*), intent(inout) :: file
147 end subroutine getopt_oscillator_strength
148
149 subroutine getopt_harmonic_spectrum(w0, m, ar, x, y, z, pol)
150 use iso_c_binding
151 implicit none
152 real(c_double) , intent(inout) :: w0
153 integer , intent(inout) :: m
154 integer , intent(inout) :: ar
155 character(len=*) , intent(inout) :: pol
156 real(c_double) , intent(inout) :: x
157 real(c_double) , intent(inout) :: y
158 real(c_double) , intent(inout) :: z
159 end subroutine getopt_harmonic_spectrum
160
161 subroutine getopt_help(mode, name)
162 implicit none
163 character(len=*), intent(inout) :: mode
164 character(len=*), intent(inout) :: name
165 end subroutine getopt_help
166
167 subroutine getopt_photoelectron_spectrum(estep, espan, &
168 thstep, thspan, phstep, phspan, pol, center, pvec, integrate)
169 use iso_c_binding
170 implicit none
171 real(c_double), intent(inout) :: estep
172 real(c_double), intent(inout) :: espan(2)
173 real(c_double), intent(inout) :: thstep
174 real(c_double), intent(inout) :: thspan(2)
175 real(c_double), intent(inout) :: phstep
176 real(c_double), intent(inout) :: phspan(2)
177 real(c_double), intent(inout) :: pol(3)
178 real(c_double), intent(inout) :: center(3)
179 real(c_double), intent(inout) :: pvec(3)
180 integer, intent(inout) :: integrate
181 end subroutine getopt_photoelectron_spectrum
182
183 end interface
184
190#if FC_COMMAND_LINE_ARGUMENTS == 77 && ! defined(FC_COMMAND_LINE_INTRINSIC)
191
192 interface command_argument_count
193#ifdef FC_COMMAND_LINE_IMPLICIT
194 integer function iargc()
195 implicit none
196 end function iargc
197#else
198 module procedure iargc
199#endif
200 end interface
202 interface get_command_argument
203#ifdef FC_COMMAND_LINE_IMPLICIT
204 subroutine getarg(c, a)
205 implicit none
206 integer, intent(in) :: c
207 character(len=*), intent(out) :: a
208 end subroutine getarg
209#else
210 module procedure getarg
211#endif
212 end interface
214#endif /* FC_COMMAND_LINE_ARGUMENTS == 77 */
215
216
217 ! ---------------------------------------------------------
220
221 interface
222 subroutine set_number_clarg(argc)
223 implicit none
224 integer, intent(in) :: argc
225 end subroutine set_number_clarg
226
227 subroutine set_clarg(i, argstring)
228 implicit none
229 integer, intent(in) :: i
230 character(len=*), intent(in) :: argstring
231 end subroutine set_clarg
232
233 subroutine clean_clarg()
234 implicit none
235 end subroutine clean_clarg
236 end interface
237
238
239contains
240
241
242 ! ---------------------------------------------------------
246 subroutine getopt_init(ierr)
247 integer, intent(out) :: ierr
248
249 integer :: argc, i
250 character(len=100), allocatable :: argstring(:)
251
252#ifdef FC_COMMAND_LINE_ARGUMENTS
253 argc = command_argument_count()
254 allocate(argstring(0:argc))
255 call set_number_clarg(argc)
256 do i = 0, argc
257 call get_command_argument(i, argstring(i))
258 call set_clarg(i, argstring(i))
259 end do
260 deallocate(argstring)
261 ierr = 0
262#else
263 ierr = -1
264#endif
265 end subroutine getopt_init
266
267
268 subroutine getopt_end
269#ifdef FC_COMMAND_LINE_ARGUMENTS
270 call clean_clarg()
271#endif
272 end subroutine getopt_end
273
274!if there is no way to access command line, define some dummy
275!functions to avoid problems when linking
276
277#if defined(FC_COMMAND_LINE_INTRINSIC) || ! defined(FC_COMMAND_LINE_ARGUMENTS)
278
279 integer function command_argument_count()
280#if defined(FC_COMMAND_LINE_INTRINSIC)
281 command_argument_count = iargc()
282#else
283 command_argument_count = 0
284#endif
285 end function command_argument_count
286
287 subroutine get_command_argument(c, a)
288 integer, intent(in) :: c
289 character(len=*), intent(out) :: a
290
291#if defined(FC_COMMAND_LINE_INTRINSIC)
292 call getarg(c, a)
293#endif
295 end subroutine get_command_argument
296
297#endif
298
299
301
302
303
304!! Local Variables:
305!! mode: f90
306!! coding: utf-8
307!! End:
Each program/utility that needs to use the getopt features should have an interface here – the defini...
If Fortran 2003 interface to command line arguments is not available, define it using an interface ov...
subroutine, public getopt_init(ierr)
Initializes the getopt machinery. Must be called before attempting to parse the options....
subroutine, public getopt_end