25 #ifndef MOSAIC_UTIL_H_ 26 #define MOSAIC_UTIL_H_ 28 #ifndef RANGE_CHECK_CRITERIA 29 #define RANGE_CHECK_CRITERIA 0.05 32 #define min(a,b) (a<b ? a:b) 33 #define max(a,b) (a>b ? a:b) 34 #define SMALL_VALUE ( 1.e-10 ) 52 int lon_fix(
double *
x,
double *
y,
int n_in,
double tlon);
64 double box_area(
double ll_lon,
double ll_lat,
double ur_lon,
double ur_lat);
70 int insert_vtx(
double x[],
double y[],
int n,
int n_ins,
double lon_in,
double lat_in);
78 void tokenize(
const char *
const string,
const char *tokens,
unsigned int varlen,
79 unsigned int maxvar,
char * pstring,
unsigned int *
const nstr);
84 const double* p_lr,
const double* p_ur,
double radius);
88 double spherical_angle(
const double *v1,
const double *v2,
const double *v3);
96 double *
cross(
const double *
p1,
const double *
p2);
98 double dot(
const double *
p1,
const double *
p2);
105 void mult(
long double m[],
long double v[],
long double out_v[]);
107 double metric(
const double *
p);
122 int inbound,
int is1,
int ie1,
int is2,
int ie2);
126 int samePoint(
double x1,
double y1,
double z1,
double x2,
double y2,
double z2);
143 double x2,
double y2,
double z2);
146 double x2,
double y2,
double z2);
real, parameter, public radius
Radius of the Earth [m].
int isInside(struct Node *node)
int invert_matrix_3x3(long double m[], long double m_inv[])
void addNode(struct Node *list, struct Node nodeIn)
void initNode(struct Node *node)
int delete_vtx(double x[], double y[], int n, int n_del)
int sameNode(struct Node node1, struct Node node2)
void setCoordinate(struct Node *node, double x, double y, double z)
real function intersect(x1, y1, x2, y2, x)
int inside_a_polygon(double *lon1, double *lat1, int *npts, double *lon2, double *lat2)
real(fvprc), dimension(:), allocatable lon
double metric(const double *p)
void set_reproduce_siena_true(void)
double box_area(double ll_lon, double ll_lat, double ur_lon, double ur_lat)
double poly_area(const double lon[], const double lat[], int n)
int fix_lon(double lon[], double lat[], int n, double tlon)
struct Node * getLast(struct Node *list)
void addEnd(struct Node *list, double x, double y, double z, int intersect, double u, int inbound, int inside)
double * cross(const double *p1, const double *p2)
int intersect_tri_with_line(const double *plane, const double *l1, const double *l2, double *p, double *t)
double dot(const double *p1, const double *p2)
void latlon2xyz(int size, const double *lon, const double *lat, double *x, double *y, double *z)
void mult(long double m[], long double v[], long double out_v[])
real(r8), dimension(cast_m, cast_n) p
int nearest_index(double value, const double *array, int ia)
void vect_cross(const double *p1, const double *p2, double *e)
double spherical_angle(const double *v1, const double *v2, const double *v3)
int lon_fix(double *x, double *y, int n_in, double tlon)
void tokenize(const char *const string, const char *tokens, unsigned int varlen, unsigned int maxvar, char *pstring, unsigned int *const nstr)
int getFirstInbound(struct Node *list, struct Node *nodeOut)
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
struct Node * getNextNode(struct Node *list)
void set_reproduce_siena_true_(void)
double great_circle_distance(double *p1, double *p2)
int insidePolygon(struct Node *node, struct Node *list)
real(kind=kind_real), parameter u1
int insert_vtx(double x[], double y[], int n, int n_ins, double lon_in, double lat_in)
void insertIntersect(struct Node *list, double x, double y, double z, double u1, double u2, int inbound, double x2, double y2, double z2)
double great_circle_area(int n, const double *x, const double *y, const double *z)
double poly_area_dimensionless(const double lon[], const double lat[], int n)
real(fvprc), dimension(:), allocatable lat
void insertAfter(struct Node *list, double x, double y, double z, int intersect, double u, int inbound, double x2, double y2, double z2)
int getInbound(struct Node node)
int length(struct Node *list)
double avgval_double(int size, const double *data)
int samePoint(double x1, double y1, double z1, double x2, double y2, double z2)
void normalize_vect(double *e)
integer, parameter, public npts
void setInbound(struct Node *interList, struct Node *list)
void copyNode(struct Node *node_out, struct Node node_in)
int inside_a_polygon_(double *lon1, double *lat1, int *npts, double *lon2, double *lat2)
void getCoordinates(struct Node *node, double *p)
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software 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 Lesser General Public *License along with FMS If see< http:! ***********************************************************************subroutine READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> tlevel if(PRESENT(start_in) .AND. PRESENT(axsiz_in)) then if(size(start(! the data domain and compute domain must refer to the subdomain being passed ! In this ! since that attempts to gather all data on PE size(field%axes(:)) axsiz(i)
void getCoordinate(struct Node node, double *x, double *y, double *z)
int addIntersect(struct Node *list, double x, double y, double z, int intersect, double u1, double u2, int inbound, int is1, int ie1, int is2, int ie2)
real(r8), dimension(cast_m, cast_n) t
struct Node * getNode(struct Node *list, struct Node inNode)
void printNode(struct Node *list, char *str)
void error_handler(const char *msg)
void unit_vect_latlon(int size, const double *lon, const double *lat, double *vlon, double *vlat)
double gridArea(struct Node *grid)
int isIntersect(struct Node node)
double poly_area_no_adjust(const double x[], const double y[], int n)
int intersectInList(struct Node *list, double x, double y, double z)
double minval_double(int size, const double *data)
void xyz2latlon(int size, const double *x, const double *y, const double *z, double *lon, double *lat)
real(kind=kind_real), parameter u2
double maxval_double(int size, const double *data)