Commit 2e6eb5ed authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Merge declaration and definition.

parent 3fa8cb9b
...@@ -35,25 +35,18 @@ ...@@ -35,25 +35,18 @@
void *Vertwind(void *argument) void *Vertwind(void *argument)
{ {
int streamID2; int gridID, zaxisID;
int vlistID2; int nrecs, nlevel, code;
int taxisID1, taxisID2;
int gridID, zaxisID, tsID;
int nlevel, nrecs, recID, code;
int varID, levelID; int varID, levelID;
int nvars, nvct = 0; int nvct = 0;
int gridsize, i; int gridsize, i;
int offset; int offset;
int nmiss, nmiss_out; int nmiss, nmiss_out;
int temp_code, sq_code, ps_code, omega_code;
int tempID = -1, sqID = -1, psID = -1, omegaID = -1; int tempID = -1, sqID = -1, psID = -1, omegaID = -1;
char varname[CDI_MAX_NAME]; char varname[CDI_MAX_NAME];
double *vct = NULL; double *vct = NULL;
double tv, rho; double tv, rho;
double *level = NULL; double *hpress = NULL, *ps_prog = NULL;
double *temp = NULL, *sq = NULL, *omega = NULL, *wms = NULL;
double *fpress = NULL, *hpress = NULL, *ps_prog = NULL;
double missval_t, missval_sq, missval_wap, missval_out;
cdoInitialize(argument); cdoInitialize(argument);
...@@ -63,12 +56,12 @@ void *Vertwind(void *argument) ...@@ -63,12 +56,12 @@ void *Vertwind(void *argument)
vlist_check_gridsize(vlistID1); vlist_check_gridsize(vlistID1);
temp_code = 130; int temp_code = 130;
sq_code = 133; int sq_code = 133;
ps_code = 134; int ps_code = 134;
omega_code = 135; int omega_code = 135;
nvars = vlistNvars(vlistID1); int nvars = vlistNvars(vlistID1);
for ( varID = 0; varID < nvars; ++varID ) for ( varID = 0; varID < nvars; ++varID )
{ {
gridID = vlistInqVarGrid(vlistID1, varID); gridID = vlistInqVarGrid(vlistID1, varID);
...@@ -84,10 +77,10 @@ void *Vertwind(void *argument) ...@@ -84,10 +77,10 @@ void *Vertwind(void *argument)
strtolower(varname); strtolower(varname);
if ( strcmp(varname, "st") == 0 ) code = 130; if ( strcmp(varname, "st") == 0 ) code = temp_code;
else if ( strcmp(varname, "sq") == 0 ) code = 133; else if ( strcmp(varname, "sq") == 0 ) code = sq_code;
else if ( strcmp(varname, "aps") == 0 ) code = 134; else if ( strcmp(varname, "aps") == 0 ) code = ps_code;
else if ( strcmp(varname, "omega") == 0 ) code = 135; else if ( strcmp(varname, "omega") == 0 ) code = omega_code;
} }
if ( code == temp_code ) tempID = varID; if ( code == temp_code ) tempID = varID;
...@@ -105,10 +98,10 @@ void *Vertwind(void *argument) ...@@ -105,10 +98,10 @@ void *Vertwind(void *argument)
} }
/* Get missing values */ /* Get missing values */
missval_t = vlistInqVarMissval(vlistID1, tempID); double missval_t = vlistInqVarMissval(vlistID1, tempID);
missval_sq = vlistInqVarMissval(vlistID1, sqID); double missval_sq = vlistInqVarMissval(vlistID1, sqID);
missval_wap = vlistInqVarMissval(vlistID1, omegaID); double missval_wap = vlistInqVarMissval(vlistID1, omegaID);
missval_out = missval_wap; double missval_out = missval_wap;
gridID = vlistInqVarGrid(vlistID1, omegaID); gridID = vlistInqVarGrid(vlistID1, omegaID);
zaxisID = vlistInqVarZaxis(vlistID1, omegaID); zaxisID = vlistInqVarZaxis(vlistID1, omegaID);
...@@ -118,14 +111,14 @@ void *Vertwind(void *argument) ...@@ -118,14 +111,14 @@ void *Vertwind(void *argument)
gridsize = gridInqSize(gridID); gridsize = gridInqSize(gridID);
nlevel = zaxisInqSize(zaxisID); nlevel = zaxisInqSize(zaxisID);
level = (double*) Malloc(nlevel*sizeof(double)); double *level = (double*) Malloc(nlevel*sizeof(double));
zaxisInqLevels(zaxisID, level); zaxisInqLevels(zaxisID, level);
temp = (double*) Malloc(gridsize*nlevel*sizeof(double)); double *temp = (double*) Malloc(gridsize*nlevel*sizeof(double));
sq = (double*) Malloc(gridsize*nlevel*sizeof(double)); double *sq = (double*) Malloc(gridsize*nlevel*sizeof(double));
omega = (double*) Malloc(gridsize*nlevel*sizeof(double)); double *omega = (double*) Malloc(gridsize*nlevel*sizeof(double));
wms = (double*) Malloc(gridsize*nlevel*sizeof(double)); double *wms = (double*) Malloc(gridsize*nlevel*sizeof(double));
fpress = (double*) Malloc(gridsize*nlevel*sizeof(double)); double *fpress = (double*) Malloc(gridsize*nlevel*sizeof(double));
if ( zaxisInqType(zaxisID) == ZAXIS_PRESSURE ) if ( zaxisInqType(zaxisID) == ZAXIS_PRESSURE )
...@@ -159,7 +152,7 @@ void *Vertwind(void *argument) ...@@ -159,7 +152,7 @@ void *Vertwind(void *argument)
for ( levelID = 0; levelID < nlevel; ++levelID ) for ( levelID = 0; levelID < nlevel; ++levelID )
vlistDefFlag(vlistID1, omegaID, levelID, TRUE); vlistDefFlag(vlistID1, omegaID, levelID, TRUE);
vlistID2 = vlistCreate(); int vlistID2 = vlistCreate();
vlistCopyFlag(vlistID2, vlistID1); vlistCopyFlag(vlistID2, vlistID1);
vlistDefVarCode(vlistID2, 0, 40); vlistDefVarCode(vlistID2, 0, 40);
vlistDefVarName(vlistID2, 0, "W"); vlistDefVarName(vlistID2, 0, "W");
...@@ -167,22 +160,22 @@ void *Vertwind(void *argument) ...@@ -167,22 +160,22 @@ void *Vertwind(void *argument)
vlistDefVarUnits(vlistID2, 0, "m/s"); vlistDefVarUnits(vlistID2, 0, "m/s");
vlistDefVarMissval(vlistID2, 0, missval_out); vlistDefVarMissval(vlistID2, 0, missval_out);
taxisID1 = vlistInqTaxis(vlistID1); int taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = taxisDuplicate(taxisID1); int taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2); vlistDefTaxis(vlistID2, taxisID2);
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype()); int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
streamDefVlist(streamID2, vlistID2); streamDefVlist(streamID2, vlistID2);
tsID = 0; int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) ) while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{ {
taxisCopyTimestep(taxisID2, taxisID1); taxisCopyTimestep(taxisID2, taxisID1);
streamDefTimestep(streamID2, tsID); streamDefTimestep(streamID2, tsID);
for ( recID = 0; recID < nrecs; recID++ ) for ( int recID = 0; recID < nrecs; recID++ )
{ {
streamInqRecord(streamID1, &varID, &levelID); streamInqRecord(streamID1, &varID, &levelID);
...@@ -215,19 +208,15 @@ void *Vertwind(void *argument) ...@@ -215,19 +208,15 @@ void *Vertwind(void *argument)
} }
else else
{ {
/* Virtuelle Temperatur bringt die Feuchteabhaengigkeit hinein */ // Virtuelle Temperatur bringt die Feuchteabhaengigkeit hinein
tv = temp[offset+i] * (1. + 0.608*sq[offset+i]); tv = temp[offset+i] * (1. + 0.608*sq[offset+i]);
/* // Die Dichte erhaelt man nun mit der Gasgleichung rho=p/(R*tv) Level in Pa!
Die Dichte erhaelt man nun mit der Gasgleichung rho=p/(R*tv)
Level in Pa!
*/
rho = fpress[offset+i] / (R*tv); rho = fpress[offset+i] / (R*tv);
/* /*
Nun daraus die Vertikalgeschwindigkeit im m/s, indem man die Nun daraus die Vertikalgeschwindigkeit im m/s, indem man die Vertikalgeschwindigkeit
Vertikalgeschwindigkeit in Pa/s durch die Erdbeschleunigung in Pa/s durch die Erdbeschleunigung und die Dichte teilt
und die Dichte teilt
*/ */
wms[offset+i] = omega[offset+i]/(G*rho); wms[offset+i] = omega[offset+i]/(G*rho);
} }
......
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