WSF
WsfEM_ALARM_Fortran.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI//REL TO USA ONLY
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12// ****************************************************************************
13// This module was designed by Science Applications International
14// Corporation (SAIC) for the US Air Force, for use in the
15// Advanced Low Altitude Radar Model (ALARM), owned by Wright
16// Labs, Analysis and Evaluation Branch (WL/AAWA-1).
17//
18// This module is derived from algorithms and code developed for
19// the Air Force by the Massachusetts Institute of Technology's
20// (MIT) Lincoln Laboratory. Under the terms of the license
21// granted by MIT, the following restriction applies:
22//
23// COPYRIGHT (C) 1985,1988 MIT LINCOLN LABORATORY ALL RIGHTS RESERVED
24// ****************************************************************************
25
26#ifndef WSFEM_ALARM_FORTRAN_HPP
27#define WSFEM_ALARM_FORTRAN_HPP
28
29#include <cmath>
30#include <complex>
31
32#include "UtMath.hpp"
33// =================================================================================================
34// Following are a collection of definitions that makes it easier to port FORTRAN to C++
35// =================================================================================================
36
37inline double dmod(double aValue1, double aValue2)
38{
39 return aValue1 - (static_cast<int>(aValue1 / aValue2) * aValue2);
40}
41
42inline double dsign(double aValue, double aReference)
43{
44 return UtMath::Sign(aValue, aReference);
45}
46
47inline int nint(double aValue)
48{
49 return (aValue >= 0.0) ? static_cast<int>(aValue + 0.5) : static_cast<int>(aValue - 0.5);
50}
51
52inline double dble(int aValue)
53{
54 return static_cast<double>(aValue);
55}
56
57inline float real(double aValue)
58{
59 return static_cast<float>(aValue);
60}
61
62inline float real(int aValue)
63{
64 return static_cast<float>(aValue);
65}
66
67inline std::complex<float> cmplx(float aRealPart, float aImagPart)
68{
69 return std::complex<float>(aRealPart, aImagPart);
70}
71
72inline std::complex<float> cmplx(float aRealPart)
73{
74 return std::complex<float>(aRealPart, 0.0);
75}
76
77inline std::complex<float> cmplx(double aRealPart, double aImagPart)
78{
79 return std::complex<float>(static_cast<float>(aRealPart), static_cast<float>(aImagPart));
80}
81
82inline std::complex<float> cmplx(double aRealPart)
83{
84 return std::complex<float>(static_cast<float>(aRealPart), 0.0);
85}
86
87inline std::complex<float> cmplx(double aRealPart, float aImagPart)
88{
89 return std::complex<float>(static_cast<float>(aRealPart), aImagPart);
90}
91
92inline float aimag(const std::complex<float>& aValue)
93{
94 return imag(aValue);
95}
96
97inline float cabs(const std::complex<float>& aValue)
98{
99 return std::abs(aValue);
100}
101
102inline std::complex<float> cexp(const std::complex<float>& aValue)
103{
104 return exp(aValue);
105}
106
107inline std::complex<float> csqrt(const std::complex<float>& aValue)
108{
109 return sqrt(aValue);
110}
111
112// ==============================================================================================
113// The following is from ALARM 'physical_constants.f90.
114// ==============================================================================================
115
116//--------------------------------------------------------------------
117// From CRC Standard Mathematical Tables and Formula, 30th edition,
118// Copyright 1996.
119//--------------------------------------------------------------------
120const double pi = 3.141592653589793; // pi
121
122//--------------------------------------------------------------------
123// NATIONAL IMAGERY AND MAPPING AGENCY TECHNICAL REPORT 8350.2 Third
124// Edition
125//--------------------------------------------------------------------
126const double rezero = 6371008.7714; // m : mean radius of semi-axis of earth
127
128//--------------------------------------------------------------------
129// From CRC Standard Mathematical Tables and Formula, 30th edition,
130// Copyright 1996.
131//--------------------------------------------------------------------
132const double vlight = 299792458.0; // m/s : speed of light
133
134// from 19th CRC Standard Mathematical Tables
135const double sqrt2 = 1.41421356237309500; // square root of 2
136
137//--------------------------------------------------------------------
138// Derived constants
139//--------------------------------------------------------------------
140const double twopi = 2.0 * pi;
141const double fourpi = 4.0 * pi;
142const double fpicub = 64.0 * pi * pi * pi;
143const double halfpi = 0.5 * pi;
144const double forthpi = 0.25 * pi;
145const double onethr = 1.0 / 3.0;
146
147//--------------------------------------------------------------------
148// Misc unit conversions.
149//--------------------------------------------------------------------
150const double deg2rad = pi / 180.0; // degrees to radians
151const double rad2deg = 180.0 / pi; // radians to degrees
152
153// ==============================================================================================
154// The following is from ALARM 'propagation_constants.f90'
155// ==============================================================================================
156
157//-------------------------------------------------------------------
158// Parameters used by the various propagation routines.
159//-------------------------------------------------------------------
160const double dsqrt3 = 1.7320508075688772; // sqrt(3.0)
161const double sqr3o2 = 0.5 * dsqrt3;
162const double forthr = 4.0 / 3.0;
163const double twothr = 2.0 / 3.0;
164const double sr2po4 = 0.25 * 2.5066282746310002; // sqrt(twopi)
165const double dsqrpi = 0.5 / 1.7724538509055159; // sqrt(pi)
166const double tsqrpi = 2.0 * 1.7724538509055159; // sqrt(pi)
167
168// ==============================================================================================
169// The following is from ALARM 'types_polarization.f90'
170// ==============================================================================================
171
172const int pol_default = -1;
173const int pol_vertical = 0;
174const int pol_horizontal = 1;
175const int pol_slant_45 = 2;
176const int pol_slant_135 = 3;
177const int pol_rh_circular = 4;
178const int pol_lh_circular = 5;
179
180#endif
const double rezero
Definition WsfEM_ALARM_Fortran.hpp:126
double dsign(double aValue, double aReference)
Definition WsfEM_ALARM_Fortran.hpp:42
const double onethr
Definition WsfEM_ALARM_Fortran.hpp:145
std::complex< float > csqrt(const std::complex< float > &aValue)
Definition WsfEM_ALARM_Fortran.hpp:107
const double deg2rad
Definition WsfEM_ALARM_Fortran.hpp:150
const double dsqrt3
Definition WsfEM_ALARM_Fortran.hpp:160
const int pol_slant_135
Definition WsfEM_ALARM_Fortran.hpp:176
const double sqrt2
Definition WsfEM_ALARM_Fortran.hpp:135
const double pi
Definition WsfEM_ALARM_Fortran.hpp:120
int nint(double aValue)
Definition WsfEM_ALARM_Fortran.hpp:47
const double sqr3o2
Definition WsfEM_ALARM_Fortran.hpp:161
const int pol_lh_circular
Definition WsfEM_ALARM_Fortran.hpp:178
const double tsqrpi
Definition WsfEM_ALARM_Fortran.hpp:166
const double vlight
Definition WsfEM_ALARM_Fortran.hpp:132
std::complex< float > cexp(const std::complex< float > &aValue)
Definition WsfEM_ALARM_Fortran.hpp:102
const double twothr
Definition WsfEM_ALARM_Fortran.hpp:163
const int pol_default
Definition WsfEM_ALARM_Fortran.hpp:172
double dmod(double aValue1, double aValue2)
Definition WsfEM_ALARM_Fortran.hpp:37
const double halfpi
Definition WsfEM_ALARM_Fortran.hpp:143
float aimag(const std::complex< float > &aValue)
Definition WsfEM_ALARM_Fortran.hpp:92
const int pol_slant_45
Definition WsfEM_ALARM_Fortran.hpp:175
float real(double aValue)
Definition WsfEM_ALARM_Fortran.hpp:57
const double forthpi
Definition WsfEM_ALARM_Fortran.hpp:144
const int pol_rh_circular
Definition WsfEM_ALARM_Fortran.hpp:177
std::complex< float > cmplx(float aRealPart, float aImagPart)
Definition WsfEM_ALARM_Fortran.hpp:67
const int pol_horizontal
Definition WsfEM_ALARM_Fortran.hpp:174
double dble(int aValue)
Definition WsfEM_ALARM_Fortran.hpp:52
const double forthr
Definition WsfEM_ALARM_Fortran.hpp:162
const double fourpi
Definition WsfEM_ALARM_Fortran.hpp:141
const int pol_vertical
Definition WsfEM_ALARM_Fortran.hpp:173
const double twopi
Definition WsfEM_ALARM_Fortran.hpp:140
const double rad2deg
Definition WsfEM_ALARM_Fortran.hpp:151
float cabs(const std::complex< float > &aValue)
Definition WsfEM_ALARM_Fortran.hpp:97
const double fpicub
Definition WsfEM_ALARM_Fortran.hpp:142
const double dsqrpi
Definition WsfEM_ALARM_Fortran.hpp:165
const double sr2po4
Definition WsfEM_ALARM_Fortran.hpp:164
Copyrights Multiple, All Rights Reserved