43 void grad_c2l_(
const int *
nlon,
const int *
nlat,
const double *pin,
const double *dx,
const double *dy,
const double *
area,
44 const double *edge_w,
const double *edge_e,
const double *edge_s,
const double *edge_n,
45 const double *en_n,
const double *en_e,
const double *vlon,
const double *vlat,
46 double *grad_x,
double *grad_y,
const int *on_west_edge,
const int *on_east_edge,
47 const int *on_south_edge,
const int *on_north_edge)
49 grad_c2l(
nlon,
nlat, pin, dx, dy,
area, edge_w, edge_e, edge_s, edge_n, en_n, en_e, vlon, vlat, grad_x, grad_y,
50 on_west_edge, on_east_edge, on_south_edge, on_north_edge);
53 void grad_c2l(
const int *
nlon,
const int *
nlat,
const double *pin,
const double *dx,
const double *dy,
const double *
area,
54 const double *edge_w,
const double *edge_e,
const double *edge_s,
const double *edge_n,
55 const double *en_n,
const double *en_e,
const double *vlon,
const double *vlat,
56 double *grad_x,
double *grad_y,
const int *on_west_edge,
const int *on_east_edge,
57 const int *on_south_edge,
const int *on_north_edge)
60 double *pb, *pdx, *pdy, *grad3;
61 int nx,
ny, nxp, nyp,
i,
j, m0, m1,
n;
67 pb = (
double *)malloc(nxp*nyp*
sizeof(
double));
68 pdx = (
double *)malloc(3*
nx*(
ny+1)*
sizeof(
double));
69 pdy = (
double *)malloc(3*(
nx+1)*
ny*
sizeof(
double));
70 grad3 = (
double *)malloc(3*
nx*
ny*
sizeof(
double));
71 a2b_ord2(
nx,
ny, pin, edge_w, edge_e, edge_s, edge_n, pb, *on_west_edge, *on_east_edge,*on_south_edge, *on_north_edge);
73 for(
j=0;
j<nyp;
j++)
for(
i=0;
i<
nx;
i++) {
77 pdx[3*m0+
n] = 0.5*(pb[m1]+pb[m1+1])*dx[m0]*en_n[3*m0+
n];
81 for(
j=0;
j<
ny;
j++)
for(
i=0;
i<nxp;
i++) {
84 pdy[3*m0+
n] = 0.5*(pb[m0]+pb[m0+nxp])*dy[m0]*en_e[3*m0+
n];
92 grad3[m0+
n] = pdx[3*((
j+1)*
nx+
i)+
n]-pdx[m0+
n]-pdy[3*(
j*nxp+
i)+
n]+pdy[3*(
j*nxp+
i+1)+
n];
101 grad_x[m0] = (vlon[m1]*grad3[m1] + vlon[m1+1]*grad3[m1+1] + vlon[m1+2]*grad3[m1+2])/
area[m0];
104 grad_y[m0] = (vlat[m1]*grad3[m1] + vlat[m1+1]*grad3[m1+1] + vlat[m1+2]*grad3[m1+2] )/
area[m0];
119 void a2b_ord2(
int nx,
int ny,
const double *qin,
const double *edge_w,
const double *edge_e,
120 const double *edge_s,
const double *edge_n,
double *qout,
121 int on_west_edge,
int on_east_edge,
int on_south_edge,
int on_north_edge)
124 int istart, iend, jstart,
jend;
126 const double r3 = 1./3.;
130 q1 = (
double *)malloc((
nx+2)*
sizeof(
double));
131 q2 = (
double *)malloc((
ny+2)*
sizeof(
double));
152 for(
j=jstart;
j<
jend;
j++)
for(
i=istart;
i<iend;
i++) {
153 qout[
j*nxp+
i] = 0.25*(qin[
j*(
nx+2)+
i] + qin[
j*(
nx+2)+
i+1] +
154 qin[(
j+1)*(
nx+2)+
i] + qin[(
j+1)*(
nx+2)+
i+1] );
158 if(on_west_edge && on_south_edge)qout[ 0] =
r3*(qin[1* (
nx+2)+1 ]+qin[1* (
nx+2) ]+qin[ 1]);
159 if(on_east_edge && on_south_edge)qout[
nx] =
r3*(qin[1* (
nx+2)+
nx]+qin[
nx ]+qin[1* (
nx+2)+nxp]);
160 if(on_east_edge && on_north_edge)qout[
ny*nxp+
nx] =
r3*(qin[
ny*(
nx+2)+
nx]+qin[
ny*(
nx+2)+nxp]+qin[nyp*(
nx+2)+
nx ]);
161 if(on_west_edge && on_north_edge)qout[
ny*nxp ] =
r3*(qin[
ny*(
nx+2)+1 ]+qin[
ny*(
nx+2) ]+qin[nyp*(
nx+2)+1 ]);
166 q2[
j] = 0.5*(qin[
j*(
nx+2)] + qin[
j*(
nx+2)+1]);
169 qout[
j*nxp] = edge_w[
j]*q2[
j] + (1-edge_w[
j])*q2[
j+1];
176 q2[
j] = 0.5*(qin[
j*(
nx+2)+
nx] + qin[
j*(
nx+2)+nxp]);
179 qout[
j*nxp+
nx] = edge_e[
j]*q2[
j] + (1-edge_e[
j])*q2[
j+1];
185 for(
i=istart;
i<=iend;
i++){
186 q1[
i] = 0.5*(qin[
i] + qin[(
nx+2)+
i]);
188 for(
i=istart;
i<iend;
i++){
189 qout[
i] = edge_s[
i]*q1[
i] + (1 - edge_s[
i])*q1[
i+1];
195 for(
i=istart;
i<=iend;
i++){
196 q1[
i] = 0.5*(qin[
ny*(
nx+2)+
i] + qin[nyp*(
nx+2)+
i]);
198 for(
i=istart;
i<iend;
i++){
199 qout[
ny*nxp+
i] = edge_n[
i]*q1[
i] + (1 - edge_n[
i])*q1[
i+1];
210 const double *lonc,
const double *latc,
double *edge_w,
double *edge_e,
double *edge_s,
double *edge_n,
211 int on_west_edge,
int on_east_edge,
int on_south_edge,
int on_north_edge)
214 int istart, iend, jstart,
jend;
222 for(
i=0;
i<nxp;
i++) {
226 for(
j=0;
j<nyp;
j++) {
231 px = (
double *)malloc(2*(
nx+2)*
sizeof(
double));
232 py = (
double *)malloc(2*(
ny+2)*
sizeof(
double));
262 p1[0] = lonc[
j*nxp+
i];
263 p1[1] = latc[
j*nxp+
i];
280 p1[0] = lonc[
j*nxp+
i];
281 p1[1] = latc[
j*nxp+
i];
291 for(
i=istart;
i<=iend;
i++) {
293 p2[0] = lont[(
j+1)*(
nx+2)+
i];
p2[1] = latt[(
j+1)*(
nx+2)+
i];
296 for(
i=istart;
i<iend;
i++) {
297 p1[0] = lonc[
j*nxp+
i];
298 p1[1] = latc[
j*nxp+
i];
307 for(
i=istart;
i<=iend;
i++) {
309 p2[0] = lont[(
j+1)*(
nx+2)+
i];
p2[1] = latt[(
j+1)*(
nx+2)+
i];
312 for(
i=istart;
i<iend;
i++) {
313 p1[0] = lonc[
j*nxp+
i];
314 p1[1] = latc[
j*nxp+
i];
328 double e1[3],
e2[3],
e3[3];
341 e[0] =
p1[0] +
p2[0];
342 e[1] =
p1[1] +
p2[1];
343 e[2] =
p1[2] +
p2[2];
344 dd = sqrt(
e[0]*
e[0] +
e[1]*
e[1] +
e[2]*
e[2] );
369 void calc_c2l_grid_info_(
int *nx_pt,
int *ny_pt,
const double *xt,
const double *yt,
const double *xc,
const double *yc,
370 double *dx,
double *dy,
double *
area,
double *edge_w,
double *edge_e,
double *edge_s,
371 double *edge_n,
double *en_n,
double *en_e,
double *vlon,
double *vlat,
372 int *on_west_edge,
int *on_east_edge,
int *on_south_edge,
int *on_north_edge)
374 calc_c2l_grid_info(nx_pt, ny_pt, xt, yt, xc, yc, dx, dy,
area, edge_w, edge_e, edge_s, edge_n,
375 en_n, en_e, vlon, vlat, on_west_edge, on_east_edge, on_south_edge, on_north_edge);
379 void calc_c2l_grid_info(
int *nx_pt,
int *ny_pt,
const double *xt,
const double *yt,
const double *xc,
const double *yc,
380 double *dx,
double *dy,
double *
area,
double *edge_w,
double *edge_e,
double *edge_s,
381 double *edge_n,
double *en_n,
double *en_e,
double *vlon,
double *vlat,
382 int *on_west_edge,
int *on_east_edge,
int *on_south_edge,
int *on_north_edge)
384 double *x, *y, *z, *xt_tmp, *yt_tmp;
385 int nx,
ny, nxp, nyp,
i,
j;
386 double p1[3],
p2[3], p3[3], p4[3];
394 for(
j=0;
j<nyp;
j++)
for(
i=0;
i<
nx;
i++) {
397 p2[0] = xc[
j*nxp+
i+1];
398 p2[1] = yc[
j*nxp+
i+1];
402 for(
j=0;
j<
ny;
j++)
for(
i=0;
i<nxp;
i++) {
405 p2[0] = xc[(
j+1)*nxp+
i];
406 p2[1] = yc[(
j+1)*nxp+
i];
413 p2[0] = xc[(
j+1)*nxp+
i];
414 p2[1] = yc[(
j+1)*nxp+
i];
415 p3[0] = xc[
j*nxp+
i+1];
416 p3[1] = yc[
j*nxp+
i+1];
417 p4[0] = xc[(
j+1)*nxp+
i+1];
418 p4[1] = yc[(
j+1)*nxp+
i+1];
422 x = (
double *)malloc(nxp*nyp*
sizeof(
double));
423 y = (
double *)malloc(nxp*nyp*
sizeof(
double));
424 z = (
double *)malloc(nxp*nyp*
sizeof(
double));
427 for(
j=0;
j<nyp;
j++)
for(
i=0;
i<
nx;
i++) {
431 p2[0] = x[
j*nxp+
i+1];
432 p2[1] = y[
j*nxp+
i+1];
433 p2[2] = z[
j*nxp+
i+1];
438 for(
j=0;
j<
ny;
j++)
for(
i=0;
i<nxp;
i++) {
442 p1[0] = x[(
j+1)*nxp+
i];
443 p1[1] = y[(
j+1)*nxp+
i];
444 p1[2] = z[(
j+1)*nxp+
i];
449 xt_tmp = (
double *)malloc(
nx*
ny*
sizeof(
double));
450 yt_tmp = (
double *)malloc(
nx*
ny*
sizeof(
double));
452 xt_tmp[
j*
nx+
i] = xt[(
j+1)*(
nx+2)+
i+1];
453 yt_tmp[
j*
nx+
i] = yt[(
j+1)*(
nx+2)+
i+1];
456 get_edge(
nx,
ny, xt, yt, xc, yc, edge_w, edge_e, edge_s, edge_n, *on_west_edge, *on_east_edge,
457 *on_south_edge, *on_north_edge);
l_size ! loop over number of fields ke do je do i
void mid_pt3_cart(const double *p1, const double *p2, double *e)
void mid_pt_sphere(const double *p1, const double *p2, double *pm)
void vect_cross(const double *p1, const double *p2, double *e)
integer, parameter, public double
void xyz2latlon(int np, const double *x, const double *y, const double *z, double *lon, double *lat)
l_size ! loop over number of fields ke do j
void a2b_ord2(int nx, int ny, const double *qin, const double *edge_w, const double *edge_e, const double *edge_s, const double *edge_n, double *qout, int on_west_edge, int on_east_edge, int on_south_edge, int on_north_edge)
void grad_c2l_(const int *nlon, const int *nlat, const double *pin, const double *dx, const double *dy, const double *area, const double *edge_w, const double *edge_e, const double *edge_s, const double *edge_n, const double *en_n, const double *en_e, const double *vlon, const double *vlat, double *grad_x, double *grad_y, const int *on_west_edge, const int *on_east_edge, const int *on_south_edge, const int *on_north_edge)
integer nlon
No description.
pure elemental type(point) function latlon2xyz(lat, lon)
double spherical_excess_area(const double *p_ll, const double *p_ul, const double *p_lr, const double *p_ur, double radius)
real(fp), parameter, public e
real, dimension(:,:), allocatable area
double great_circle_distance(double *p1, double *p2)
void get_edge(int nx, int ny, const double *lont, const double *latt, const double *lonc, const double *latc, double *edge_w, double *edge_e, double *edge_s, double *edge_n, int on_west_edge, int on_east_edge, int on_south_edge, int on_north_edge)
void calc_c2l_grid_info_(int *nx_pt, int *ny_pt, const double *xt, const double *yt, const double *xc, const double *yc, double *dx, double *dy, double *area, double *edge_w, double *edge_e, double *edge_s, double *edge_n, double *en_n, double *en_e, double *vlon, double *vlat, int *on_west_edge, int *on_east_edge, int *on_south_edge, int *on_north_edge)
void normalize_vect(double *e)
void grad_c2l(const int *nlon, const int *nlat, const double *pin, const double *dx, const double *dy, const double *area, const double *edge_w, const double *edge_e, const double *edge_s, const double *edge_n, const double *en_n, const double *en_e, const double *vlon, const double *vlat, double *grad_x, double *grad_y, const int *on_west_edge, const int *on_east_edge, const int *on_south_edge, const int *on_north_edge)
integer nlat
No description.
void calc_c2l_grid_info(int *nx_pt, int *ny_pt, const double *xt, const double *yt, const double *xc, const double *yc, double *dx, double *dy, double *area, double *edge_w, double *edge_e, double *edge_s, double *edge_n, double *en_n, double *en_e, double *vlon, double *vlat, int *on_west_edge, int *on_east_edge, int *on_south_edge, int *on_north_edge)
void unit_vect_latlon(int size, const double *lon, const double *lat, double *vlon, double *vlat)