Commit adf97929 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cdilib update

parent 98f38600
......@@ -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
......@@ -236,6 +236,7 @@ void *Info(void *argument)
int vlistID;
int nmiss;
int number;
int datatype;
int ivals = 0, nvals = 0;
int imiss = 0;
char varname[128];
......@@ -305,8 +306,13 @@ void *Info(void *argument)
gridID = vlistInqVarGrid(vlistID, varID);
zaxisID = vlistInqVarZaxis(vlistID, varID);
missval = vlistInqVarMissval(vlistID, varID);
number = vlistInqVarNumber(vlistID, varID);
gridsize = gridInqSize(gridID);
datatype = vlistInqVarDatatype(vlistID, varID);
if ( datatype == DATATYPE_CPX32 || datatype == DATATYPE_CPX64 )
number = CDI_COMP;
else
number = CDI_REAL;
if ( param == CDI_UNDEFPARAM ) param = cdiEncodeParam(code, tabnum, 255);
param2str(param, paramstr, sizeof(paramstr));
......
......@@ -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
......@@ -57,7 +57,7 @@ void *Sinfo(void *argument)
char *modelptr, *instptr;
int streamID = 0;
int vlistID;
int prec, number;
int datatype;
char pstr[4];
cdoInitialize(argument);
......@@ -133,28 +133,21 @@ void *Sinfo(void *argument)
else
fprintf(stdout, "var ");
prec = vlistInqVarDatatype(vlistID, varID);
number = vlistInqVarNumber(vlistID, varID);
if ( number == CDI_REAL )
{
if ( prec == DATATYPE_PACK ) strcpy(pstr, "P0");
else if ( prec > 0 && prec <= 32 ) sprintf(pstr, "P%d", prec);
else if ( prec == DATATYPE_FLT32 ) strcpy(pstr, "F32");
else if ( prec == DATATYPE_FLT64 ) strcpy(pstr, "F64");
else if ( prec == DATATYPE_INT8 ) strcpy(pstr, "I8");
else if ( prec == DATATYPE_INT16 ) strcpy(pstr, "I16");
else if ( prec == DATATYPE_INT32 ) strcpy(pstr, "I32");
else if ( prec == DATATYPE_UINT8 ) strcpy(pstr, "U8");
else if ( prec == DATATYPE_UINT16 ) strcpy(pstr, "U16");
else if ( prec == DATATYPE_UINT32 ) strcpy(pstr, "U32");
else strcpy(pstr, "-1");
}
else
{
if ( prec == DATATYPE_FLT32 ) strcpy(pstr, "C32");
else if ( prec == DATATYPE_FLT64 ) strcpy(pstr, "C64");
else strcpy(pstr, "-2");
}
datatype = vlistInqVarDatatype(vlistID, varID);
if ( datatype == DATATYPE_PACK ) strcpy(pstr, "P0");
else if ( datatype > 0 && datatype <= 32 ) sprintf(pstr, "P%d", datatype);
else if ( datatype == DATATYPE_CPX32 ) strcpy(pstr, "C32");
else if ( datatype == DATATYPE_CPX64 ) strcpy(pstr, "C64");
else if ( datatype == DATATYPE_FLT32 ) strcpy(pstr, "F32");
else if ( datatype == DATATYPE_FLT64 ) strcpy(pstr, "F64");
else if ( datatype == DATATYPE_INT8 ) strcpy(pstr, "I8");
else if ( datatype == DATATYPE_INT16 ) strcpy(pstr, "I16");
else if ( datatype == DATATYPE_INT32 ) strcpy(pstr, "I32");
else if ( datatype == DATATYPE_UINT8 ) strcpy(pstr, "U8");
else if ( datatype == DATATYPE_UINT16 ) strcpy(pstr, "U16");
else if ( datatype == DATATYPE_UINT32 ) strcpy(pstr, "U32");
else strcpy(pstr, "-1");
fprintf(stdout, " %-3s", pstr);
......
......@@ -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
......@@ -33,6 +33,7 @@ void *Tocomplex(void *argument)
int vlistID1, vlistID2;
int taxisID1, taxisID2;
int i, gridsize;
int datatype;
int nmiss, nvars;
double *array1 = NULL, *array2 = NULL;
......@@ -51,7 +52,15 @@ void *Tocomplex(void *argument)
nvars = vlistNvars(vlistID2);
for ( varID = 0; varID < nvars; ++varID )
vlistDefVarNumber(vlistID2, varID, CDI_COMP);
{
datatype = vlistInqVarDatatype(vlistID2, varID);
if ( datatype == DATATYPE_FLT64 )
datatype = DATATYPE_CPX64;
else
datatype = DATATYPE_CPX32;
vlistDefVarDatatype(vlistID2, varID, datatype);
}
taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = taxisDuplicate(taxisID1);
......
......@@ -85,6 +85,8 @@ extern "C" {
#define DATATYPE_PACK30 30
#define DATATYPE_PACK31 31
#define DATATYPE_PACK32 32
#define DATATYPE_CPX32 64
#define DATATYPE_CPX64 128
#define DATATYPE_FLT32 132
#define DATATYPE_FLT64 164
#define DATATYPE_INT8 208
......@@ -99,6 +101,7 @@ extern "C" {
#define DATATYPE_INT 251
#define DATATYPE_FLT 252
#define DATATYPE_TXT 253
#define DATATYPE_CPX 254
/* GRID types */
......@@ -376,12 +379,6 @@ void vlistDefVarDatatype(int vlistID, int varID, int datatype);
/* vlistInqVarDatatype: Get the data type of a Variable */
int vlistInqVarDatatype(int vlistID, int varID);
/* vlistDefVarNumber: Define the number type of a Variable */
void vlistDefVarNumber(int vlistID, int varID, int number);
/* vlistInqVarNumber: Get the number type of a Variable */
int vlistInqVarNumber(int vlistID, int varID);
void vlistDefVarInstitut(int vlistID, int varID, int instID);
int vlistInqVarInstitut(int vlistID, int varID);
void vlistDefVarModel(int vlistID, int varID, int modelID);
......
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