Octopus
harmonic_spectrum.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
23 use fft_oct_m
24 use global_oct_m
25 use io_oct_m
26 use iso_c_binding
29 use parser_oct_m
33
34 implicit none
35
36 private
38
39contains
40
41 subroutine harmonic_spectrum_main() bind(c)
42
43 integer :: mode, ierr, ar
44 real(real64) :: w0, vec(1:3)
45 type(spectrum_t) :: spectrum
46 character :: pol
47 character(kind=c_char) :: cpol(2)
48 logical :: get_maxima
49
50 integer, parameter :: &
51 HS_FROM_MULT = 1, &
52 hs_from_acc = 2, &
53 hs_from_curr = 3
54
55 call getopt_init(ierr)
56 if (ierr /= 0) then
57 call messages_write("Your Fortran compiler doesn't support command-line arguments;")
59 call messages_write("the oct-harmonic-spectrum command is not available.")
60 call messages_fatal()
61 end if
62 ! These are the default values.
63 get_maxima = .true.
64 w0 = m_zero
65 mode = 1
66 ar = 0
67 vec = (/m_one, m_zero, m_one /)
68 cpol = 'x'
69 call getopt_harmonic_spectrum(w0, mode, ar, vec(1),vec(2),vec(3),cpol)
70 pol = cpol(1)
71 if (w0 <= m_zero) get_maxima = .false.
72 call getopt_end()
73
74
75 ! Initialize stuff
77
78 call parser_init()
79
80 call messages_init()
81
82 call io_init()
86
87 call spectrum_init(spectrum, global_namespace)
88
89 call messages_obsolete_variable(global_namespace, 'HarmonicSpectrumPolarization')
90 call messages_obsolete_variable(global_namespace, 'HarmonicSpectrumMode')
91
92 if ((pol /= 'x') .and. &
93 (pol /= 'y') .and. &
94 (pol /= 'z') .and. &
95 (pol /= '+') .and. &
96 (pol /= '-') .and. &
97 (pol /= 'v')) then
98 message(1) = 'The polarization direction given in the command line is not valid.'
99 call messages_fatal(1)
100 end if
101
102 select case (mode)
103 case (hs_from_mult)
104 if (get_maxima) then
105 call spectrum_hs_from_mult(spectrum, global_namespace, 'hs-mult-maxima', pol, vec, w0)
106 else
107 if (ar == 1) then
108 message(1)= "Calculating angle-resolved hs from multipoles."
109 call messages_info(1)
110 call spectrum_hs_ar_from_mult(spectrum, global_namespace, 'hs-mult', vec)
111 else
112 call spectrum_hs_from_mult(spectrum, global_namespace, 'hs-mult', pol, vec)
113 end if
114 end if
115 case (hs_from_acc)
116 if (get_maxima) then
117 call spectrum_hs_from_acc(spectrum, global_namespace, 'hs-acc-maxima', pol, vec, w0)
118 else
119 if (ar == 1) then
120 message(1)= "Calculating angle-resolved hs from acceleration."
121 call messages_info(1)
122 call spectrum_hs_ar_from_acc(spectrum, global_namespace, 'hs-acc', vec)
123 else
124 call spectrum_hs_from_acc(spectrum, global_namespace, 'hs-acc', pol, vec)
125 end if
126 end if
127 case (hs_from_curr)
128 if (get_maxima) then
129 call spectrum_hs_from_mult(spectrum, global_namespace, 'hs-curr-maxima', pol, vec, w0)
130 else
131 call spectrum_hs_from_current(spectrum, global_namespace, 'hs-curr', pol, vec)
132 end if
133 case default
134 message(1) = 'The harmonic-spectrum mode given in the command line is not valid.'
135 call messages_fatal(1)
136 end select
137
138 call fft_all_end()
140 call io_end()
141 call messages_end()
142
143 call parser_end()
144
145 call global_end()
146 end subroutine harmonic_spectrum_main
148
149!! Local Variables:
150!! mode: f90
151!! coding: utf-8
152!! 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
Fast Fourier Transform module. This module provides a single interface that works with different FFT ...
Definition: fft.F90:97
subroutine, public fft_all_init(namespace)
initialize the table
Definition: fft.F90:280
subroutine, public fft_all_end()
delete all plans
Definition: fft.F90:406
subroutine, public global_end()
Finalise parser varinfo file, and MPI.
Definition: global.F90:500
real(real64), parameter, public m_zero
Definition: global.F90:173
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
real(real64), parameter, public m_one
Definition: global.F90:174
subroutine, public harmonic_spectrum_main()
Definition: io.F90:93
subroutine, public io_init(defaults)
If the argument defaults is present and set to true, then the routine will not try to read anything f...
Definition: io.F90:142
subroutine, public io_end()
Definition: io.F90:248
subroutine, public messages_end()
Definition: messages.F90:249
subroutine, public messages_init(output_dir)
Definition: messages.F90:196
subroutine, public messages_obsolete_variable(namespace, name, rep)
Definition: messages.F90:980
subroutine, public messages_new_line()
Definition: messages.F90:1069
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:138
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:386
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:570
type(namespace_t), public global_namespace
Definition: namespace.F90:112
subroutine, public parser_init()
Initialise the Octopus parser.
Definition: parser.F90:387
subroutine, public parser_end()
End the Octopus parser.
Definition: parser.F90:419
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
Definition: profiling.F90:122
subroutine, public profiling_end(namespace)
Definition: profiling.F90:455
subroutine, public profiling_init(namespace)
Create profiling subdirectory.
Definition: profiling.F90:264
subroutine, public spectrum_hs_ar_from_acc(spectrum, namespace, out_file, vec, w0)
Definition: spectrum.F90:1720
subroutine, public spectrum_init(spectrum, namespace, default_energy_step, default_max_energy)
Definition: spectrum.F90:197
subroutine, public spectrum_hs_from_acc(spectrum, namespace, out_file, pol, vec, w0)
Definition: spectrum.F90:2043
subroutine, public spectrum_hs_from_current(spectrum, namespace, out_file, pol, vec, w0)
Definition: spectrum.F90:2144
subroutine, public spectrum_hs_from_mult(spectrum, namespace, out_file, pol, vec, w0)
Definition: spectrum.F90:1921
subroutine, public spectrum_hs_ar_from_mult(spectrum, namespace, out_file, vec, w0)
Definition: spectrum.F90:1824
This module defines the unit system, used for input and output.
subroutine, public unit_system_init(namespace)
int true(void)