Commit 5cc61c2d authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

mulcoslat: added support for GME grids

parent e8d5ef1c
2010-11-22 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* mulcoslat: added support for GME grids [request: Jaison-Thomas Ambadan]
2010-11-19 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* select: added paramter *ltype* [request: Jaison-Thomas Ambadan]
......
......@@ -27,26 +27,24 @@
#include "cdo.h"
#include "cdo_int.h"
#include "pstream.h"
#include "grid.h"
#ifndef DEG2RAD
#define DEG2RAD (M_PI/180.) /* conversion for deg to rad */
#endif
void *Arithlat(void *argument)
{
int operatorID;
int operfunc;
int streamID1, streamID2;
int gridsize, gridtype;
int gridtype;
int gridID, gridID0 = -1;
int nlon = 0, nlat = 0, i, j;
int nrecs, recID;
int tsID;
int varID, levelID;
int vlistID1, vlistID2;
int taxisID1, taxisID2;
int nmiss;
long gridsize, i;
char units[128];
double *scale = NULL;
double *array = NULL;
......@@ -93,39 +91,69 @@ void *Arithlat(void *argument)
if ( gridID != gridID0 )
{
gridID0 = gridID;
gridtype = gridInqType(gridID);
if ( gridtype != GRID_LONLAT && gridtype != GRID_GAUSSIAN )
if ( gridtype == GRID_LONLAT ||
gridtype == GRID_GAUSSIAN ||
gridtype == GRID_LCC )
{
if ( gridInqType(gridID) == GRID_GAUSSIAN_REDUCED )
cdoAbort("Gaussian reduced grid found. Use option -R to convert it to a regular grid!");
gridID = gridToCurvilinear(gridID);
}
else if ( gridtype == GRID_CURVILINEAR ||
gridtype == GRID_CELL )
{
/* No conversion necessary */
}
else if ( gridtype == GRID_GME )
{
gridID = gridToCell(gridID);
}
else
{
if ( gridtype == GRID_GAUSSIAN_REDUCED )
cdoAbort("Unsupported grid type: %s, use CDO option -R to convert reduced to regular grid!",
gridNamePtr(gridtype));
else
cdoAbort("LONLAT or GAUSSIAN grid not found!");
cdoAbort("Unsupported grid type: %s", gridNamePtr(gridtype));
}
gridsize = gridInqSize(gridID);
nlon = gridInqXsize(gridID);
nlat = gridInqYsize(gridID);
scale = (double *) realloc(scale, nlat*sizeof(double));
scale = (double *) realloc(scale, gridsize*sizeof(double));
gridInqYvals(gridID, scale);
/* Convert lat/lon units if required */
gridInqXunits(gridID, units);
if ( memcmp(units, "degree", 6) == 0 )
{
for ( i = 0; i < gridsize; ++i ) scale[i] *= DEG2RAD;
}
else if ( memcmp(units, "radian", 6) == 0 )
{
/* No conversion necessary */
}
else
{
cdoWarning("Unknown units supplied for grid1 center lat/lon: proceeding assuming radians");
}
if ( operfunc == func_mul )
for ( j = 0; j < nlat; j++ ) scale[j] = cos(scale[j]*DEG2RAD);
for ( i = 0; i < gridsize; ++i ) scale[i] = cos(scale[i]);
else
for ( j = 0; j < nlat; j++ ) scale[j] = 1./cos(scale[j]*DEG2RAD);
for ( i = 0; i < gridsize; ++i ) scale[i] = 1./cos(scale[i]);
if ( cdoVerbose ) for ( j = 0; j < nlat; j++ ) cdoPrint("coslat %3d %g", j+1, scale[j]);
gridID0 = gridID;
if ( cdoVerbose ) for ( i = 0; i < 10; ++i ) cdoPrint("coslat %3d %g", i+1, scale[i]);
}
for ( j = 0; j < nlat; j++ )
for ( i = 0; i < nlon; i++ )
array[i+j*nlon] *= scale[j];
for ( i = 0; i < gridsize; ++i ) array[i] *= scale[i];
streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, array, nmiss);
}
tsID++;
}
......
......@@ -2,7 +2,7 @@
This file is part of CDO. CDO is a collection of Operators to
manipulate and analyse Climate model Data.
Copyright (C) 2003-2009 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-2010 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -473,6 +473,7 @@ int ltype2ztype(int ltype)
else if ( ltype == 105 ) zaxistype = ZAXIS_HEIGHT;
else if ( ltype == 107 ) zaxistype = ZAXIS_SIGMA;
else if ( ltype == 109 ) zaxistype = ZAXIS_HYBRID;
else if ( ltype == 110 ) zaxistype = ZAXIS_HYBRID_HALF;
else if ( ltype == 111 ) zaxistype = ZAXIS_DEPTH_BELOW_LAND;
else if ( ltype == 113 ) zaxistype = ZAXIS_ISENTROPIC;
else if ( ltype == 160 ) zaxistype = ZAXIS_DEPTH_BELOW_SEA;
......
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