/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !! !! 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 #include #include #include "mpp.h" #include "mosaic_util.h" #include "interp.h" #include "tool_util.h" #include "constant.h" #include "create_hgrid.h" #define D2R (M_PI/180.) #define R2D (180./M_PI) /********************************************************************************* some private routines used in this file *********************************************************************************/ void set_regular_lonlat_grid( int nxp, int nyp, int isc, int iec, int jsc, int jec, double *xb, double *yb, double *x, double *y, double *dx, double *dy, double *area, double *angle ); /************************************************************************************ void create_regular_lonlat_grid( int *nxbnds, int *nybnds, double *xbnds, double *ybnds, int *nlon, int *nlat, int *isc, int *iec, int *jsc, int *jec, double *x, double *y, double *dx, double *dy, double *area, double *angle_dx ) calculate grid location, length, area and rotation angle. The routine takes the following arguments INPUT: OUTPUT: ************************************************************************************/ void create_regular_lonlat_grid( int *nxbnds, int *nybnds, double *xbnds, double *ybnds, int *nlon, int *nlat, int *isc, int *iec, int *jsc, int *jec, double *x, double *y, double *dx, double *dy, double *area, double *angle_dx, const char *center ) { int nx, ny, nxp, nyp, nxb, nyb; double *xb=NULL, *yb=NULL; int refine; /* use cubic-spline interpolation algorithm to calculate nominal zonal grid location. */ nxb = *nxbnds; nyb = *nybnds; xb = compute_grid_bound(nxb, xbnds, nlon, &nx, center), nxp = nx + 1; yb = compute_grid_bound(nyb, ybnds, nlat, &ny, center), nyp = ny + 1; set_regular_lonlat_grid( nxp, nyp, *isc, *iec, *jsc, *jec, xb, yb, x, y, dx, dy, area, angle_dx); free(xb); free(yb); }; /* create_regular_lonlat_grid */ /************************************************************************************ void create_simple_cartesian_grid( double *xbnds, double *ybnds, int *nlon, int *nlat, double *simple_dx, *simple_dy, int *isc, int *iec, int *jsc, int *jec, double *x, double *y, double *dx, double *dy, double *area, double *angle_dx ) calculate grid location, length, area and rotation angle. The routine takes the following arguments INPUT: OUTPUT: ************************************************************************************/ void create_simple_cartesian_grid( double *xbnds, double *ybnds, int *nlon, int *nlat, double *simple_dx, double *simple_dy, int *isc, int *iec, int *jsc, int *jec, double *x, double *y, double *dx, double *dy, double *area, double *angle_dx ) { int nx, ny, nxp, nyp, i, j, n, nxc, nyc, nxb, nyb; double *grid1=NULL, *grid2=NULL, *xb=NULL, *yb=NULL; nxb = 2; nyb = 2; nx = *nlon; ny = *nlat; nxp = nx + 1; nyp = ny + 1; /* use cubic-spline interpolation algorithm to calculate nominal zonal grid location. */ xb = (double *)malloc(nxp*sizeof(double)); grid1 = (double *)malloc(nxb*sizeof(double)); grid1[0] = 1; grid1[1] = nxp; grid2 = (double *)malloc(nxp*sizeof(double)); for(i=0;i