Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
cdo
Commits
e76453c5
Commit
e76453c5
authored
Nov 14, 2017
by
Uwe Schulzweida
Browse files
Merge declaration and initialization.
parent
abdf4da2
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/grid_rot.cc
View file @
e76453c5
...
...
@@ -7,6 +7,8 @@
double
lamrot_to_lam
(
double
phirot
,
double
lamrot
,
double
polphi
,
double
pollam
,
double
polgam
)
{
/*
Name of the original Fortran function: PHTOPHS
This function converts lambda from one rotated system to lambda in another system.
If the optional argument polgam is present, the other system can also be a rotated one,
where polgam is the angle between the two north poles.
...
...
@@ -20,8 +22,6 @@ double lamrot_to_lam(double phirot, double lamrot, double polphi, double pollam,
result : longitude in the geographical system
*/
double
zarg1
,
zarg2
;
double
zgam
;
double
result
=
0
;
double
zsinpol
=
sin
(
DEG2RAD
*
polphi
);
double
zcospol
=
cos
(
DEG2RAD
*
polphi
);
...
...
@@ -32,8 +32,10 @@ double lamrot_to_lam(double phirot, double lamrot, double polphi, double pollam,
double
zlamrot
=
DEG2RAD
*
lamrot
;
if
(
fabs
(
polgam
)
>
0
)
//X if ( polgam > 0 )
{
zgam
=
-
DEG2RAD
*
polgam
;
double
zgam
=
-
DEG2RAD
*
polgam
;
//X double zgam = DEG2RAD*polgam;
zarg1
=
sin
(
zlampol
)
*
(
-
zsinpol
*
cos
(
zphirot
)
*
(
cos
(
zlamrot
)
*
cos
(
zgam
)
-
sin
(
zlamrot
)
*
sin
(
zgam
))
+
zcospol
*
sin
(
zphirot
))
...
...
@@ -54,6 +56,7 @@ double lamrot_to_lam(double phirot, double lamrot, double polphi, double pollam,
sin
(
zlampol
)
*
sin
(
zlamrot
)
*
cos
(
zphirot
);
}
double
result
=
0
;
if
(
fabs
(
zarg2
)
>
0
)
result
=
RAD2DEG
*
atan2
(
zarg1
,
zarg2
);
if
(
fabs
(
result
)
<
9.e-14
)
result
=
0
;
...
...
@@ -64,6 +67,8 @@ double lamrot_to_lam(double phirot, double lamrot, double polphi, double pollam,
double
phirot_to_phi
(
double
phirot
,
double
lamrot
,
double
polphi
,
double
polgam
)
{
/*
Name of the original Fortran function: PHSTOPH
This function converts phi from one rotated system to phi in another
system. If the optional argument polgam is present, the other system
can also be a rotated one, where polgam is the angle between the two
...
...
@@ -79,18 +84,19 @@ double phirot_to_phi(double phirot, double lamrot, double polphi, double polgam)
result : latitude in the geographical system
*/
double
zarg
;
double
zgam
;
double
zsinpol
=
sin
(
DEG2RAD
*
polphi
);
double
zcospol
=
cos
(
DEG2RAD
*
polphi
);
double
zphirot
=
DEG2RAD
*
phirot
;
double
zphirot
=
DEG2RAD
*
phirot
;
if
(
lamrot
>
180.0
)
lamrot
-=
360.0
;
double
zlamrot
=
DEG2RAD
*
lamrot
;
double
zlamrot
=
DEG2RAD
*
lamrot
;
if
(
fabs
(
polgam
)
>
0
)
//X if ( polgam > 0 )
{
zgam
=
-
DEG2RAD
*
polgam
;
double
zgam
=
-
DEG2RAD
*
polgam
;
//X double zgam = DEG2RAD*polgam;
zarg
=
zsinpol
*
sin
(
zphirot
)
+
zcospol
*
cos
(
zphirot
)
*
(
cos
(
zlamrot
)
*
cos
(
zgam
)
-
sin
(
zgam
)
*
sin
(
zlamrot
));
}
...
...
@@ -104,6 +110,8 @@ static
double
lam_to_lamrot
(
double
phi
,
double
rla
,
double
polphi
,
double
pollam
)
{
/*
Name of the original Fortran function: RLSTORL
Umrechnung von rla (geo. System) auf rlas (rot. System)
phi : Breite im geographischen System (N>0)
...
...
@@ -130,14 +138,17 @@ double lam_to_lamrot(double phi, double rla, double polphi, double pollam)
return
RAD2DEG
*
atan2
(
zarg1
,
zarg2
);
}
#ifdef TEST_GRID_ROT
static
double
phi_to_phirot
(
double
phi
,
double
r
la
,
double
polphi
,
double
pollam
)
double
phi_to_phirot
(
double
phi
,
double
la
m
,
double
polphi
,
double
pollam
)
{
/*
Name of the original Fortran function: PHTOPHS
Umrechnung von phi (geo. System) auf phis (rot. System)
phi : Breite im geographischen System (N>0)
r
la : Laenge im geographischen System (E>0)
la
m
: Laenge im geographischen System (E>0)
polphi : Geographische Breite des Nordpols des rot. Systems
pollam : Geographische Laenge des Nordpols des rot. Systems
...
...
@@ -147,29 +158,29 @@ double phi_to_phirot(double phi, double rla, double polphi, double pollam)
double
zcospol
=
cos
(
DEG2RAD
*
polphi
);
double
zlampol
=
DEG2RAD
*
pollam
;
double
zphi
=
DEG2RAD
*
phi
;
if
(
r
la
>
180.0
)
r
la
-=
360.0
;
double
z
r
la
=
DEG2RAD
*
r
la
;
double
zphi
=
DEG2RAD
*
phi
;
if
(
la
m
>
180.0
)
la
m
-=
360.0
;
double
zla
m
=
DEG2RAD
*
la
m
;
double
zarg
=
zcospol
*
cos
(
zphi
)
*
cos
(
z
r
la
-
zlampol
)
+
zsinpol
*
sin
(
zphi
);
double
zarg
=
zcospol
*
cos
(
zphi
)
*
cos
(
zla
m
-
zlampol
)
+
zsinpol
*
sin
(
zphi
);
return
RAD2DEG
*
asin
(
zarg
);
}
#endif
void
usvs_to_uv
(
double
us
,
double
vs
,
double
phi
,
double
rla
,
double
polphi
,
double
pollam
,
double
*
u
,
double
*
v
)
{
/*
Umrechnen der windkomponente us, vs im rotierten sphaerischen
Umrechnen der windkomponente
n
us, vs im rotierten sphaerischen
system in die windkomponenten u, v, im geographischen system
us : 'zonaler wind im rotierten system
vs : 'merid. wind im rotierten system
phi :
b
reite im geographischen system (
n
>0)
rla :
l
aenge im geographischen system (
e
>0)
polphi :
g
eographische breite des
n-
pols des rot.
sys.
pollam :
g
eographische laenge des
n-
pols des rot.
sys.
phi :
B
reite im geographischen system (
N
>0)
rla :
L
aenge im geographischen system (
E
>0)
polphi :
G
eographische breite des
Nord
pols des rot.
Systems
pollam :
G
eographische laenge des
Nord
pols des rot.
Systems
u : zonaler wind im geographischen system
v : merid. wind im geographischen system
...
...
@@ -178,6 +189,7 @@ void usvs_to_uv(double us, double vs, double phi, double rla,
double
zpolphi
=
polphi
*
DEG2RAD
;
double
zpollam
=
pollam
*
DEG2RAD
;
if
(
rla
<
0.0
)
rla
+=
360.0
;
//X if ( rla < 0.0 ) rla += 360.0;
double
zrla
=
rla
*
DEG2RAD
;
double
pollamd
=
pollam
;
if
(
pollamd
<
0.0
)
pollamd
+=
360.0
;
...
...
@@ -194,7 +206,7 @@ void usvs_to_uv(double us, double vs, double phi, double rla,
zbeta = sign(zbeta, -(rla - (pollamd-180.0)));
*/
double
zbeta
=
fabs
(
acos
(
zarg
));
/
*
if ( -(rla - (pollamd-180.0)) < 0 ) zbeta = -zbeta;
*/
/
/
if ( -(rla - (pollamd-180.0)) < 0 ) zbeta = -zbeta;
if
(
(
-
(
rla
-
(
pollamd
-
180.0
))
<
0
)
&&
(
-
(
rla
-
(
pollamd
-
180.0
))
>=
-
180
)
)
zbeta
=
-
zbeta
;
/* us - wind transformieren */
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment