Commit 14e19072 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

afterburnerlib update

parent 3f73ffa7
#ifndef _AFTER_H
#define _AFTER_H
#ifndef _AFTERBURNER_H
#define _AFTERBURNER_H
/* =============================================== */
/* These include files should be standard on all */
......@@ -28,10 +28,6 @@
# include "dmemory.h"
#endif
#define FT_GRIB 1
#define FT_SERV 2
#define FT_CDF 3
#ifndef TRUE
#define TRUE 1
#endif
......@@ -39,13 +35,6 @@
#define FALSE 0
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MaxLevel 1024
#define MaxCodes 277
......@@ -85,6 +74,8 @@ struct Control
int ivlistID;
int ovlistID;
int ovlistID2;
int taxisID;
int taxisID2;
struct Date NextDate;
struct Date NewDate;
......@@ -173,7 +164,6 @@ struct Variable
};
/* FFT */
void fft_set(double *trigs, long *ifax, long n);
void fc2gp(double *trig, long *ifax, double *fc, double *gp, long nlat, long nlon, long nlev, long nfc);
void gp2fc(double *trig, long *ifax, double *gp, double *fc, long nlat, long nlon, long nlev, long nfc);
......@@ -184,21 +174,13 @@ void sp2fc(const double *sa, double *fa, const double *poli, long nlev, long nla
void fc2sp(double *fa, double *sa, double *poli, int klev, int nlat, int nfc, int nt);
/* Physc */
void dv2ps(const double * restrict div, double * restrict pot, long nlev, long ntr);
void dv2uv(double *d, double *o, double *u, double *v, double *f, double *g,
int nt, int nsp, int nlev);
void dv2uv(double *d, double *o, double *u, double *v, double *f, double *g, int nt, int nsp, int nlev);
void scaluv(double *fu, double rclat[], int nlat, int lot);
void uv2dv(double *fu, double *fv, double *sd, double *sv,
double *pol2, double *pol3, int klev, int nlat, int nt);
void geninx(long ntr, double *f, double *g);
void MakeGeopotHeight(double *geop, double* gt, double *gq, double *ph, int nhor, int nlev);
void LayerWater (double *ww, double *ll, double pmax, double pmin,
int DimGP, int HalfLevels, double *vct);
void LayerCloud (double *cc, double *ll, double pmax, double pmin,
int DimGP, int HalfLevels, double *vct);
#define LOW_CLOUD 34
#define MID_CLOUD 35
#define HIH_CLOUD 36
......@@ -252,12 +234,6 @@ void LayerCloud (double *cc, double *ll, double pmax, double pmin,
#define THETAH 279
#define THETAF 280
void *FreeMemory(void *ptr);
double *alloc_dp(int words, char *array_name);
void after_copy_array(void *destination, void *source, int words);
void after_zero_array(double *field, int words);
void after_read_vct(const char *vctfile, double **vct, int *nvct);
void after_gp2sp(struct Control *globs, struct Variable *vars, int ccode);
......@@ -277,5 +253,6 @@ void after_EchamAddRecord(struct Control *globs, struct Variable *vars, int code
void after_AnalysisDependencies(struct Variable *vars, int ncodes);
void after_EchamDependencies(struct Variable *vars, int ncodes, int type, int source);
void after_legini_setup(struct Control *globs, struct Variable *vars);
#endif /* afterburner.h */
......@@ -12,6 +12,10 @@
int afterDebug = 0;
int labort_after = TRUE;
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
static
char *FieldName(int code, const char *text)
{
......@@ -23,6 +27,7 @@ char *FieldName(int code, const char *text)
}
/* Free array space */
static
void *FreeMemory(void *ptr)
{
free(ptr);
......@@ -81,6 +86,7 @@ void FreeSamp(struct Variable *vars)
}
/* alloc_dp - Allocate space for double array */
static
double *alloc_dp(int words, char *array_name)
{
double *result = NULL;
......@@ -95,14 +101,15 @@ double *alloc_dp(int words, char *array_name)
return(result);
}
/* after_copy_array - Copy array of type double */
static
void after_copy_array(void *destination, void *source, int words)
{
memcpy(destination, source, words*sizeof(double));
}
/* after_zero_array - Set array of type double to zero */
static
void after_zero_array(double *field, int words)
{
memset((char *)field, 0, words*sizeof(double));
......@@ -2829,3 +2836,53 @@ void after_EchamDependencies(struct Variable *vars, int ncodes, int type, int so
CheckDependencies(vars, 0);
}
void after_legini_full(int ntr, int nlat, double *restrict poli, double *restrict pold, double *restrict pdev,
double *restrict pol2, double *restrict pol3, double *restrict coslat);
void after_legini(int ntr, int nlat, double *restrict poli, double *restrict pold, double *restrict coslat);
void after_legini_setup(struct Control *globs, struct Variable *vars)
{
int ntr = globs->Truncation;
int nlat = globs->Latitudes;
int dimsp = (ntr + 1) * (ntr + 2);
int pdim = dimsp / 2 * nlat;
globs->poli = (double *) malloc(pdim*sizeof(double));
if ( ! globs->AnalysisData )
{
if ( globs->Type >= 20 ) globs->pold = (double *) malloc(pdim*sizeof(double));
if ( vars[DPSDY].needed ) globs->pdev = (double *) malloc(pdim*sizeof(double));
}
if ( (vars[DIVERGENCE].needed || vars[VORTICITY].needed ||
vars[VELOPOT].needed || vars[STREAM].needed ) && globs->Type > 20 )
{
globs->pol2 = (double *) malloc(pdim*sizeof(double));
globs->pol3 = (double *) malloc(pdim*sizeof(double));
}
if ( globs->AnalysisData && (globs->Type == 70) && globs->Gaussian && !globs->Spectral )
{
if ( globs->poli ) { free(globs->poli); globs->poli = NULL;}
if ( globs->pol2 ) { free(globs->pol2); globs->pol2 = NULL;}
if ( globs->pol3 ) { free(globs->pol3); globs->pol3 = NULL;}
return;
}
int flag = 1;
//if ( globs->poli && globs->pold && globs->pdev == NULL && globs->pol2 == NULL && globs->pol3 == NULL ) flag = 0;
if ( flag )
after_legini_full(ntr, nlat, globs->poli, globs->pold, globs->pdev,
globs->pol2, globs->pol3, globs->coslat);
else
after_legini(ntr, nlat, globs->poli, globs->pold, globs->coslat);
for ( int jgl = 0; jgl < nlat; ++jgl )
globs->rcoslat[jgl] = 1.0 / globs->coslat[jgl];
for ( int jgl = 0; jgl < nlat; ++jgl )
globs->DerivationFactor[jgl] = globs->rcoslat[jgl] / PlanetRadius;
}
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