Commit d45fabe8 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

renamed deg2rad to DEG2RAD

parent 0afa4de0
......@@ -25,6 +25,7 @@
#include <cdi.h>
#include "cdo.h"
#include "cdo_int.h"
#include "grid.h"
#include "pstream.h"
......
......@@ -25,6 +25,7 @@
#include <cdi.h>
#include "cdo.h"
#include "cdo_int.h"
#include "grid.h"
#include "pstream.h"
......
......@@ -232,7 +232,7 @@ int gengrid(int gridID1, int lhalo, int rhalo)
gridDefYlongname(gridID2, ylongname);
gridDefYunits(gridID2, yunits);
if ( memcmp(xunits, "degree", 6) == 0 ) cpi2 *= rad2deg;
if ( memcmp(xunits, "degree", 6) == 0 ) cpi2 *= RAD2DEG;
if ( gridInqXvals(gridID1, NULL) && gridInqYvals(gridID1, NULL) )
{
......
......@@ -20,6 +20,7 @@
#include "cdo_int.h"
#include "pstream.h"
#include "interpol.h"
#include "grid.h"
#include "remap.h"
#if defined (HAVE_LIBYAC)
......
......@@ -85,22 +85,14 @@ char *strdup(const char *s);
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif
#ifndef M_LN10
#define M_LN10 2.30258509299404568402 /* log_e 10 */
#endif
#ifndef RAD2DEG
#define RAD2DEG (180./M_PI) /* conversion for rad to deg */
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif
#ifndef DEG2RAD
#define DEG2RAD (M_PI/180.) /* conversion for deg to rad */
#endif
#define IX2D(y,x,nx) ((y)*(nx)+(x))
......
......@@ -38,7 +38,7 @@ void gridToDegree(const char *units, const char *string, int gridsize, double *a
if ( memcmp(units, "radian", 6) == 0 )
{
for ( i = 0; i < gridsize; i++ ) array[i] *= rad2deg;
for ( i = 0; i < gridsize; i++ ) array[i] *= RAD2DEG;
}
else if ( memcmp(units, "degree", 6) == 0 )
{
......@@ -379,8 +379,8 @@ void sinusoidal_to_geo(int gridsize, double *xvals, double *yvals)
data.u = xvals[i];
data.v = yvals[i];
res = pj_inv(data, libProj);
xvals[i] = res.u*rad2deg;
yvals[i] = res.v*rad2deg;
xvals[i] = res.u*RAD2DEG;
yvals[i] = res.v*RAD2DEG;
}
#else
cdoAbort("proj4 support not compiled in!");
......@@ -423,8 +423,8 @@ void laea_to_geo(int gridID, int gridsize, double *xvals, double *yvals)
data.u = xvals[i];
data.v = yvals[i];
res = pj_inv(data, libProj);
xvals[i] = res.u*rad2deg;
yvals[i] = res.v*rad2deg;
xvals[i] = res.u*RAD2DEG;
yvals[i] = res.v*RAD2DEG;
}
#else
cdoAbort("proj4 support not compiled in!");
......@@ -469,8 +469,8 @@ void lcc2_to_geo(int gridID, int gridsize, double *xvals, double *yvals)
data.u = xvals[i];
data.v = yvals[i];
res = pj_inv(data, libProj);
xvals[i] = res.u*rad2deg;
yvals[i] = res.v*rad2deg;
xvals[i] = res.u*RAD2DEG;
yvals[i] = res.v*RAD2DEG;
}
#else
cdoAbort("proj4 support not compiled in!");
......@@ -1471,13 +1471,13 @@ int gridGenArea(int gridID, double *area)
{
for ( i = 0; i < gridsize; ++i )
{
grid_center_lon[i] *= deg2rad;
grid_center_lat[i] *= deg2rad;
grid_center_lon[i] *= DEG2RAD;
grid_center_lat[i] *= DEG2RAD;
}
for ( i = 0; i < gridsize*nv; ++i )
{
grid_corner_lon[i] *= deg2rad;
grid_corner_lat[i] *= deg2rad;
grid_corner_lon[i] *= DEG2RAD;
grid_corner_lat[i] *= DEG2RAD;
}
}
else
......@@ -1613,8 +1613,8 @@ int gridWeightsOld(int gridID, double *weights)
sumw = 0;
for ( j = 0; j < nlat; j++ )
{
phi1 = (lats[j-1]+lats[j])/2*deg2rad;
phi2 = (lats[j+1]+lats[j])/2*deg2rad;
phi1 = (lats[j-1]+lats[j])/2*DEG2RAD;
phi2 = (lats[j+1]+lats[j])/2*DEG2RAD;
if ( phi1 < (-1*M_PI/2) ) phi1 = -1*M_PI/2;
if ( phi1 > ( M_PI/2) ) phi1 = M_PI/2;
if ( phi2 > ( M_PI/2) ) phi2 = M_PI/2;
......@@ -1626,8 +1626,8 @@ int gridWeightsOld(int gridID, double *weights)
weights[datapoint] = 0;
else
{
theta1 = (lons[i-1]+lons[i])/2*deg2rad;
theta2 = (lons[i+1]+lons[i])/2*deg2rad;
theta1 = (lons[i-1]+lons[i])/2*DEG2RAD;
theta2 = (lons[i+1]+lons[i])/2*DEG2RAD;
weights[datapoint] = fabs((theta2-theta1)*sindphi);
sumw += weights[datapoint];
}
......
#ifndef _GRID_H
#define _GRID_H
#define deg2rad (M_PI/180.) /* conversion for deg to rad */
#define rad2deg (180./M_PI) /* conversion for rad to deg */
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif
#ifndef RAD2DEG
#define RAD2DEG (180./M_PI) /* conversion for rad to deg */
#endif
#ifndef DEG2RAD
#define DEG2RAD (M_PI/180.) /* conversion for deg to rad */
#endif
int referenceToGrid(int gridID);
......@@ -37,8 +47,6 @@ void gme_grid(int lbounds, int gridsize, double *rlon, double *rlat,
/* Rotated grid */
double lamrot_to_lam(double phis, double rlas, double polphi, double pollam, double polgam);
double phirot_to_phi(double phis, double rlas, double polphi, double polgam);
double rl_to_rls(double phi, double rla, double polphi, double pollam);
double ph_to_phs(double phi, double rla, double polphi, double pollam);
void usvs_to_uv(double us, double vs, double phi, double rla,
double polphi, double pollam, double *u, double *v);
......
#include <stdio.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif
#ifndef rad2deg
#define rad2deg (180./M_PI) /* conversion for rad to deg */
#endif
#ifndef deg2rad
#define deg2rad (M_PI/180.) /* conversion for deg to rad */
#endif
#include "grid.h"
double lamrot_to_lam(double phirot, double lamrot, double polphi, double pollam, double polgam)
......@@ -35,17 +25,17 @@ double lamrot_to_lam(double phirot, double lamrot, double polphi, double pollam,
double zphirot, zlamrot, zarg1, zarg2;
double zgam;
zsinpol = sin(deg2rad*polphi);
zcospol = cos(deg2rad*polphi);
zsinpol = sin(DEG2RAD*polphi);
zcospol = cos(DEG2RAD*polphi);
zlampol = deg2rad*pollam;
zphirot = deg2rad*phirot;
zlampol = DEG2RAD*pollam;
zphirot = DEG2RAD*phirot;
if ( lamrot > 180.0 ) lamrot -= 360.0;
zlamrot = deg2rad*lamrot;
zlamrot = DEG2RAD*lamrot;
if ( polgam > 0 )
{
zgam = deg2rad*polgam;
zgam = DEG2RAD*polgam;
zarg1 = sin(zlampol) *
(- zsinpol*cos(zphirot) * (cos(zlamrot)*cos(zgam) - sin(zlamrot)*sin(zgam))
+ zcospol*sin(zphirot))
......@@ -68,7 +58,7 @@ double lamrot_to_lam(double phirot, double lamrot, double polphi, double pollam,
if ( fabs(zarg2) < 1.0e-20 ) zarg2 = 1.0e-20;
return (rad2deg*atan2(zarg1, zarg2));
return (RAD2DEG*atan2(zarg1, zarg2));
}
......@@ -93,23 +83,23 @@ double phirot_to_phi(double phirot, double lamrot, double polphi, double polgam)
double zphirot, zlamrot, zarg;
double zgam;
zsinpol = sin(deg2rad*polphi);
zcospol = cos(deg2rad*polphi);
zsinpol = sin(DEG2RAD*polphi);
zcospol = cos(DEG2RAD*polphi);
zphirot = deg2rad*phirot;
zphirot = DEG2RAD*phirot;
if ( lamrot > 180.0 ) lamrot -= 360.0;
zlamrot = deg2rad*lamrot;
zlamrot = DEG2RAD*lamrot;
if ( polgam > 0 )
{
zgam = deg2rad*polgam;
zgam = DEG2RAD*polgam;
zarg = zsinpol*sin(zphirot) +
zcospol*cos(zphirot)*(cos(zlamrot)*cos(zgam) - sin(zgam)*sin(zlamrot));
}
else
zarg = zcospol*cos(zphirot)*cos(zlamrot) + zsinpol*sin(zphirot);
return (rad2deg*asin(zarg));
return (RAD2DEG*asin(zarg));
}
static
......@@ -128,21 +118,21 @@ double rl_to_rls(double phi, double rla, double polphi, double pollam)
double zsinpol, zcospol, zlampol;
double zphi, zrla, zarg1, zarg2;
zsinpol = sin(deg2rad*polphi);
zcospol = cos(deg2rad*polphi);
zlampol = deg2rad*pollam;
zsinpol = sin(DEG2RAD*polphi);
zcospol = cos(DEG2RAD*polphi);
zlampol = DEG2RAD*pollam;
if ( rla > 180.0 ) rla -= 360.0;
zrla = deg2rad*rla;
zphi = deg2rad*phi;
zrla = DEG2RAD*rla;
zphi = DEG2RAD*phi;
zarg1 = - sin(zrla-zlampol)*cos(zphi);
zarg2 = - zsinpol*cos(zphi)*cos(zrla-zlampol)+zcospol*sin(zphi);
if ( fabs(zarg2) < 1.0e-20 ) zarg2 = 1.0e-20;
return (rad2deg*atan2(zarg1,zarg2));
return (RAD2DEG*atan2(zarg1,zarg2));
}
static
......@@ -161,17 +151,17 @@ double ph_to_phs(double phi, double rla, double polphi, double pollam)
double zsinpol, zcospol, zlampol;
double zphi, zrla, zarg;
zsinpol = sin(deg2rad*polphi);
zcospol = cos(deg2rad*polphi);
zlampol = deg2rad*pollam;
zsinpol = sin(DEG2RAD*polphi);
zcospol = cos(DEG2RAD*polphi);
zlampol = DEG2RAD*pollam;
zphi = deg2rad*phi;
zphi = DEG2RAD*phi;
if ( rla > 180.0 ) rla -= 360.0;
zrla = deg2rad*rla;
zrla = DEG2RAD*rla;
zarg = zcospol*cos(zphi)*cos(zrla-zlampol) + zsinpol*sin(zphi);
return (rad2deg*asin(zarg));
return (RAD2DEG*asin(zarg));
}
......@@ -195,15 +185,15 @@ void usvs_to_uv(double us, double vs, double phi, double rla,
double zpolphi, zpollam, zrla, zphi, pollamd, zrlas, zarg, zbeta;
/* umrechnung von grad in bogenmass */
zpolphi = polphi*deg2rad;
zpollam = pollam*deg2rad;
zrla = rla *deg2rad;
zphi = phi *deg2rad;
zpolphi = polphi*DEG2RAD;
zpollam = pollam*DEG2RAD;
zrla = rla *DEG2RAD;
zphi = phi *DEG2RAD;
pollamd = pollam;
if ( pollamd < 0.0 ) pollamd += 360.0;
/* laenge im rotierten system berechnen */
zrlas = rl_to_rls(phi, rla, polphi, pollam)*deg2rad;
zrlas = rl_to_rls(phi, rla, polphi, pollam)*DEG2RAD;
/* winkel zbeta berechen (schnittwinkel der breitenkreise) */
zarg = - sin(zpolphi)*sin(zrla-zpollam)*sin(zrlas) - cos(zrla-zpollam)*cos(zrlas);
......
......@@ -38,9 +38,6 @@
#include "griddes.h"
#include "error.h"
#define deg2rad (M_PI/180.) /* conversion for deg to rad */
#define rad2deg (180./M_PI) /* conversion for rad to deg */
#define cmpstr(s1, s2, len) (memcmp(s1, s2, len = strlen(s2)))
/*
......@@ -1358,7 +1355,7 @@ int gridFromPingo(FILE *gfp, const char *dname)
gaussaw(yvals, yw, grid.ysize);
free(yw);
for ( i = 0; i < (int) grid.ysize; i++ )
yvals[i] = asin(yvals[i])*rad2deg;
yvals[i] = asin(yvals[i])*RAD2DEG;
for ( i = 0; i < (int) grid.ysize; i++ )
if ( fabs(yvals[i] - grid.yvals[i]) > ((yvals[0] - yvals[1])/500) ) break;
......
......@@ -22,7 +22,7 @@
* @param x the element to find a position for
*/
static
long find_element(double x, long nelem, const double *array)
long find_element(double x, long nelem, const double *restrict array)
{
long ii;
long mid = 0;
......@@ -151,6 +151,8 @@ void intlinarr2(double missval,
progressInit();
for ( ii = 0; ii < nxm; ++ii ) printf("x: %d %g\n", ii+1, xm[ii]);
#if defined (_OPENMP)
#pragma omp parallel for default(none) \
shared(ompNumThreads, field, fieldm, x, y, xm, ym, nxm, nym, gridsize2, missval, findex) \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment