/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! !! GNU General Public License !! !! !! !! This file is part of the Flexible Modeling System (FMS). !! !! !! !! FMS is free software; you can redistribute it and/or modify !! !! it and are expected to follow the terms of the GNU General Public !! !! License as published by the Free Software Foundation. !! !! !! !! FMS is distributed in the hope that it will be useful, !! !! but WITHOUT ANY WARRANTY; without even the implied warranty of !! !! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !! !! GNU General Public License for more details. !! !! !! !! You should have received a copy of the GNU General Public License !! !! along with FMS; if not, write to: !! !! Free Software Foundation, Inc. !! !! 59 Temple Place, Suite 330 !! !! Boston, MA 02111-1307 USA !! !! or see: !! !! http://www.gnu.org/licenses/gpl.txt !! !! !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ #include #include #include "constant.h" #include "mosaic_util.h" #include "gradient_c2l.h" #include 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); /*------------------------------------------------------------------------------ Routine to compute gradient terms for SCRIP: SJL: Oct 5, 2007 NOTe: pin has halo size = 1. the size of pin will be (nx+2,ny+2), T-cell center, with halo = 1 the size of dx will be (nx, ny+1), N-cell center the size of dy will be (nx+1, ny), E-cell center the size of area will be (nx, ny), T-cell center. The size of edge_w will be (ny+1), C-cell center The size of edge_e will be (ny+1), C-cell center The size of edge_s will be (nx+1), C-cell center The size of edge_n will be (nx+1), C-cell center The size of en_n will be (nx, ny+1,3),N-cell center The size of en_e will be (nx+1,ny,3), E-cell center The size of vlon will be (nx, ny, 3) T-cell center The size of vlat will be (nx, ny, 3), T-cell center ----------------------------------------------------------------------------*/ 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) { 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, on_west_edge, on_east_edge, on_south_edge, 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) { double *pb, *pdx, *pdy, *grad3; int nx, ny, nxp, nyp, i, j, m0, m1, m2, n; nx = *nlon; ny = *nlat; nxp = nx+1; nyp = ny+1; pb = (double *)malloc(nxp*nyp*sizeof(double)); pdx = (double *)malloc(3*nx*(ny+1)*sizeof(double)); pdy = (double *)malloc(3*(nx+1)*ny*sizeof(double)); grad3 = (double *)malloc(3*nx*ny*sizeof(double)); 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); for(j=0; j