Commit f3605a23 authored by Michal Koutek's avatar Michal Koutek

Adding Hirlam_extension branch for new CDO functions for HIRLAM NWP model processing

parent 1d8164a7
*.test
*~
*.la
*.lo
*.o
*.so
*.log
*.trs
*.dSYM
*.pyd
*.pyc
*.swp
*.plo
*.prof
**/.deps
**/.libs
.dirstamp
stamp-h1
config.log
config.status
config.h
build
cdo.pdf
cdo_eca.pdf
cdo_magics.pdf
cdo_refcard.pdf
Makefile
**/Makefile
**/config.h
**/config.lt
**/config.log
**/config.status
*.dirstamp
cdo.settings
config.status
autom4te.cache
cdo.spec
src/cdotest
libtool
src/cdo
src/stamp-h1
contrib/bindings/python
# libcdi is a sub-project
libcdi/
.hgignore
.hg/
......@@ -570,8 +570,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='cdo'
PACKAGE_TARNAME='cdo'
PACKAGE_VERSION='1.7.2rc2'
PACKAGE_STRING='cdo 1.7.2rc2'
PACKAGE_VERSION='1.7.2rc2.hirlExt'
PACKAGE_STRING='cdo 1.7.2rc2.hirlExt'
PACKAGE_BUGREPORT='http://mpimet.mpg.de/cdo'
PACKAGE_URL=''
......@@ -1500,6 +1500,7 @@ Optional Features:
--enable-all-static build a completely statically linked CDO binary
[default=no]
--enable-cxx Use CXX as default compiler [default=no]
--enable-HIRLAM-extensions This will ensure that HIRLAM_EXTENSIONS is defined.
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
......@@ -19638,6 +19639,28 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_cgribex" >&5
$as_echo "$enable_cgribex" >&6; }
ENABLE_CGRIBEX=$enable_cgribex
# ----------------------------------------------------------------------
# Compile interface with HIRLAM extensions
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for HIRLAM extensions" >&5
$as_echo_n "checking for HIRLAM extensions... " >&6; }
# Check whether --enable-HIRLAM-extensions was given.
if test "${enable-HIRLAM-extensions+set}" = set; then :
enableval=$enable_HIRLAMext; if test "x$enable_HIRLAMext" != 'xno'; then :
$as_echo "#define HIRLAM_EXTENSIONS 1" >>confdefs.h
enable_HIRLAMext=yes
fi
else
$as_echo "#define HIRLAM_EXTENSIONS 1" >>confdefs.h
enable_HIRLAMext=yes
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_HIRLAMext" >&5
$as_echo "$enable_HIRLAMext" >&6; }
ENABLE_HIRLAMEXT=$enable_HIRLAMext
# ----------------------------------------------------------------------
# Compile interface with internal SERVICE library
......
......@@ -5,6 +5,8 @@ complete -W "
-- \
-- \
-- \
-- \
-- \
-L \
-M \
-O \
......
......@@ -5,6 +5,8 @@ set cdoCmpl = (\
- \
- \
- \
- \
- \
L \
M \
O \
......
......@@ -5,6 +5,8 @@ compctl -k "(
-- \
-- \
-- \
-- \
-- \
-L \
-M \
-O \
......
......@@ -162,17 +162,17 @@ static void dump_global_attributes(struct kv **ht, int streamID)
vlistInqAtt(vlistID, CDI_GLOBAL, i, name, &type, &len);
switch ( type )
{
case DATATYPE_TXT:
case CDI_DATATYPE_TXT:
value = Malloc(len + 1);
vlistInqAttTxt(vlistID, CDI_GLOBAL, name, len, value);
value[len] = '\0';
break;
case DATATYPE_INT32:
case CDI_DATATYPE_INT32:
value = Malloc(CDI_MAX_NAME);
vlistInqAttInt(vlistID, CDI_GLOBAL, name, len, (int *)buffer);
snprintf(value, CDI_MAX_NAME, "%i", *(int *)buffer);
break;
case DATATYPE_FLT64:
case CDI_DATATYPE_FLT64:
value = Malloc(CDI_MAX_NAME);
vlistInqAttFlt(vlistID, CDI_GLOBAL, name, len, (double *)buffer);
snprintf(value, CDI_MAX_NAME, "%e", *(double *)buffer);
......
......@@ -26,6 +26,9 @@
#include "cdo_int.h"
#include "par_io.h"
#include "pstream.h"
#ifdef HIRLAM_EXTENSIONS
#include "cdo_extensions.h"
#endif // HIRLAM_EXTENSIONS
void *Copy(void *argument)
......@@ -50,6 +53,13 @@ void *Copy(void *argument)
bool lcopy = false;
if ( UNCHANGED_RECORD ) lcopy = true;
#ifdef HIRLAM_EXTENSIONS
// KEEP in mind the difference between copy and selall with respect to unpacking and repacking the GRIB information!
// Especially when setting the DataScanningMode.
printf("cdo copy/selall : UNCHANGED_RECORD=%d\n",UNCHANGED_RECORD);
//if (cdoGribDataScanningMode != -1) lcopy = FALSE;
printf("cdo copy/selall : cdoGribDataScanningMode=%d; lcopy=%d\n",cdoGribDataScanningMode, lcopy);
#endif //#ifdef HIRLAM_EXTENSIONS
int operatorID = cdoOperatorID();
if ( operatorID == SZIP )
......
......@@ -69,7 +69,13 @@ void minmaxval(long nvals, double *array, int *imiss, double *minval, double *ma
void *Derivepar(void *argument)
{
int mode;
#ifndef HIRLAM_EXTENSIONS
enum {ECHAM_MODE, WMO_MODE};
gribcode_t gribcodes = {0};
#else
enum {ECHAM_MODE, WMO_MODE,HIRLAM_MODE};
gribcode_t gribcodes = {0};
#endif //HIRLAM_EXTENSIONS
int streamID2;
int vlistID2;
int recID, nrecs;
......@@ -103,7 +109,7 @@ void *Derivepar(void *argument)
double minval, maxval;
int instNum, tableNum;
int useTable;
gribcode_t gribcodes = {0};
// bring this line above in the code: gribcode_t gribcodes = {0};
cdoInitialize(argument);
......@@ -203,6 +209,8 @@ void *Derivepar(void *argument)
cdiDecodeParam(param, &pnum, &pcat, &pdis);
if ( pdis >= 0 && pdis < 255 ) code = -1;
if ( cdoVerbose && useTable ) cdoPrint("Param. code: %d; table nr.:%d!",code,tableNum);
if ( useTable )
{
if ( tableNum == 2 )
......@@ -215,6 +223,16 @@ void *Derivepar(void *argument)
mode = ECHAM_MODE;
echam_gribcodes(&gribcodes);
}
#ifdef HIRLAM_EXTENSIONS
// KNMI: HIRLAM model version 7.2 uses tableNum=1 (LAMH_D11*)
// KNMI: HARMONIE model version 36 uses tableNum=1 (grib*) (opreational NWP version)
// KNMI: HARMONIE model version 38 uses tableNum=253 (grib,grib_md) and tableNum=1 (grib_sfx) (research version)
else if ( tableNum == 1 || tableNum == 253 )
{
mode = HIRLAM_MODE;
hirlam_harmonie_gribcodes(&gribcodes);
}
#endif //HIRLAM_EXTENSIONS
else
mode = -1;
}
......
......@@ -377,8 +377,8 @@ void *EOFs(void * argument)
npack = 0;
for ( i = 0; i < gridsize; ++i )
{
if ( !DBL_IS_EQUAL(weight[i], 0.0) && !DBL_IS_EQUAL(weight[i], missval) &&
!DBL_IS_EQUAL(in[i], missval) )
if ( !DBL_IS_EQUAL(weight[i], (float)0) && !DBL_IS_EQUAL(weight[i], missval) &&
!DBL_IS_EQUAL(in[i], missval) ) // Bugfixing: DBL_IS_EQUAL(weight[i], 0) => DBL_IS_EQUAL(weight[i], (float)0)
pack[npack++] = i;
}
......@@ -392,8 +392,8 @@ void *EOFs(void * argument)
ipack = 0;
for ( i = 0; i < gridsize; ++i )
{
if ( !DBL_IS_EQUAL(weight[i], 0.0) && !DBL_IS_EQUAL(weight[i], missval) &&
!DBL_IS_EQUAL(in[i], missval) && pack[ipack++] != i )
if ( !DBL_IS_EQUAL(weight[i], (float)0) && !DBL_IS_EQUAL(weight[i], missval) &&
!DBL_IS_EQUAL(in[i], missval) && pack[ipack++] != i ) // Bugfixing: DBL_IS_EQUAL(weight[i], 0) => DBL_IS_EQUAL(weight[i], (float)0)
{
cdoAbort("Missing values unsupported!");
}
......
......@@ -365,6 +365,16 @@ void *Expr(void *argument)
varIDmap[varID] = pidx;
}
#ifdef HIRLAM_EXTENSIONS
if ( cdoVerbose )
{
for ( int varID = 0; varID < nvars1; varID++ )
if ( parse_arg.needed[varID] && cdoVerbose )
printf("needed: %d %s\n", varID, parse_arg.params[varID].name);
cdoPrint("vlistNvars(vlistID1)=%d, vlistNvars(vlistID2)=%d",vlistNvars(vlistID1),vlistNvars(vlistID2));
}
#endif //#ifdef HIRLAM_EXTENSIONS
int nvars2 = vlistNvars(vlistID2);
if ( nvars2 == 0 ) cdoAbort("No output variable found!");
......
......@@ -369,6 +369,13 @@ cdo_SOURCES += nearpt3c.h
# cellsearchorder.h
#endif
#if ENABLE_HIRLAMEXT
cdo_SOURCES += \
Selmulti.c \
SampleGrid.c \
WindTrans.c
#endif
#if ENABLE_MAGICS
cdo_SOURCES += Magplot.c \
Magvector.c \
......
......@@ -247,6 +247,7 @@ am_cdo_OBJECTS = cdo-cdo.$(OBJEXT) cdo-Adisit.$(OBJEXT) \
cdo-Yseasstat.$(OBJEXT) cdo-Zonstat.$(OBJEXT) \
cdo-Magplot.$(OBJEXT) cdo-Magvector.$(OBJEXT) \
cdo-Maggraph.$(OBJEXT) cdo-template_parser.$(OBJEXT) \
cdo-Selmulti.$(OBJEXT) cdo-SampleGrid.$(OBJEXT) cdo-WindTrans.$(OBJEXT) \
cdo-results_template_parser.$(OBJEXT) \
cdo-magics_template_parser.$(OBJEXT) \
cdo-StringUtilities.$(OBJEXT) cdo-CdoMagicsMapper.$(OBJEXT)
......@@ -581,6 +582,7 @@ cdo_SOURCES = cdo.c Adisit.c Afterburner.c Arith.c Arithc.c \
Ymonpctl.c Ymonstat.c Yseaspctl.c Yseasstat.c Zonstat.c cdo.h \
nearpt3c.h Magplot.c Magvector.c Maggraph.c template_parser.h \
template_parser.c results_template_parser.h \
Selmulti.c SampleGrid.c WindTrans.c \
results_template_parser.c magics_template_parser.h \
magics_template_parser.c StringUtilities.h StringUtilities.c \
CdoMagicsMapper.h CdoMagicsMapper.c
......@@ -968,6 +970,9 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Yseasstat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Zonstat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-cdo.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Selmulti.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-SampleGrid.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-WindTrans.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-magics_template_parser.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-results_template_parser.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-template_parser.Po@am__quote@
......@@ -4353,6 +4358,48 @@ cdo-Zonstat.obj: Zonstat.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Zonstat.obj `if test -f 'Zonstat.c'; then $(CYGPATH_W) 'Zonstat.c'; else $(CYGPATH_W) '$(srcdir)/Zonstat.c'; fi`
cdo-Selmulti.o: Selmulti.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Selmulti.o -MD -MP -MF $(DEPDIR)/cdo-Selmulti.Tpo -c -o cdo-Selmulti.o `test -f 'Selmulti.c' || echo '$(srcdir)/'`Selmulti.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cdo-Selmulti.Tpo $(DEPDIR)/cdo-Selmulti.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='Selmulti.c' object='cdo-Selmulti.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Selmulti.o `test -f 'Selmulti.c' || echo '$(srcdir)/'`Selmulti.c
cdo-Selmulti.obj: Selmulti.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Selmulti.obj -MD -MP -MF $(DEPDIR)/cdo-Selmulti.Tpo -c -o cdo-Selmulti.obj `if test -f 'Selmulti.c'; then $(CYGPATH_W) 'Selmulti.c'; else $(CYGPATH_W) '$(srcdir)/Selmulti.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cdo-Selmulti.Tpo $(DEPDIR)/cdo-Selmulti.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='Selmulti.c' object='cdo-Selmulti.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Selmulti.obj `if test -f 'Selmulti.c'; then $(CYGPATH_W) 'Selmulti.c'; else $(CYGPATH_W) '$(srcdir)/Selmulti.c'; fi`
cdo-SampleGrid.o: SampleGrid.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-SampleGrid.o -MD -MP -MF $(DEPDIR)/cdo-SampleGrid.Tpo -c -o cdo-SampleGrid.o `test -f 'SampleGrid.c' || echo '$(srcdir)/'`SampleGrid.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cdo-SampleGrid.Tpo $(DEPDIR)/cdo-SampleGrid.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='SampleGrid.c' object='cdo-SampleGrid.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-SampleGrid.o `test -f 'SampleGrid.c' || echo '$(srcdir)/'`SampleGrid.c
cdo-SampleGrid.obj: SampleGrid.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-SampleGrid.obj -MD -MP -MF $(DEPDIR)/cdo-SampleGrid.Tpo -c -o cdo-SampleGrid.obj `if test -f 'SampleGrid.c'; then $(CYGPATH_W) 'SampleGrid.c'; else $(CYGPATH_W) '$(srcdir)/SampleGrid.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cdo-SampleGrid.Tpo $(DEPDIR)/cdo-SampleGrid.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='SampleGrid.c' object='cdo-SampleGrid.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-SampleGrid.obj `if test -f 'SampleGrid.c'; then $(CYGPATH_W) 'SampleGrid.c'; else $(CYGPATH_W) '$(srcdir)/SampleGrid.c'; fi`
cdo-WindTrans.o: WindTrans.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-WindTrans.o -MD -MP -MF $(DEPDIR)/cdo-WindTrans.Tpo -c -o cdo-WindTrans.o `test -f 'WindTrans.c' || echo '$(srcdir)/'`WindTrans.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cdo-WindTrans.Tpo $(DEPDIR)/cdo-WindTrans.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='WindTrans.c' object='cdo-WindTrans.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-WindTrans.o `test -f 'WindTrans.c' || echo '$(srcdir)/'`WindTrans.c
cdo-WindTrans.obj: WindTrans.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-WindTrans.obj -MD -MP -MF $(DEPDIR)/cdo-WindTrans.Tpo -c -o cdo-WindTrans.obj `if test -f 'WindTrans.c'; then $(CYGPATH_W) 'WindTrans.c'; else $(CYGPATH_W) '$(srcdir)/WindTrans.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cdo-WindTrans.Tpo $(DEPDIR)/cdo-WindTrans.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='WindTrans.c' object='cdo-WindTrans.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-WindTrans.obj `if test -f 'WindTrans.c'; then $(CYGPATH_W) 'WindTrans.c'; else $(CYGPATH_W) '$(srcdir)/WindTrans.c'; fi`
cdo-Magplot.o: Magplot.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Magplot.o -MD -MP -MF $(DEPDIR)/cdo-Magplot.Tpo -c -o cdo-Magplot.o `test -f 'Magplot.c' || echo '$(srcdir)/'`Magplot.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cdo-Magplot.Tpo $(DEPDIR)/cdo-Magplot.Po
......
......@@ -220,6 +220,8 @@ void *Mrotuv(void *argument)
vlistID1 = streamInqVlist(streamID1);
// T.B.D. This is a very strange piece of code..
// It is an idea to use: wmo_gribcodes(&gribcodes) /or/ echam_gribcodes(&gribcodes) /or/ hirlam_harmonie_gribcodes(&gribcodes)
nvars = vlistNvars(vlistID1);
for ( varid = 0; varid < nvars; varid++ )
{
......@@ -229,6 +231,7 @@ void *Mrotuv(void *argument)
}
if ( uid == -1 || vid == -1 )
// T.B.D. This is a very strange piece of code..
{
if ( nvars == 2 )
{
......
......@@ -37,7 +37,13 @@
void *Pressure(void *argument)
{
int mode;
#ifndef HIRLAM_EXTENSIONS
enum {ECHAM_MODE, WMO_MODE};
gribcode_t gribcodes = {0};
#else
enum {ECHAM_MODE, WMO_MODE, HIRLAM_MODE};
gribcode_t gribcodes = {0};
#endif //HIRLAM_EXTENSIONS
int ps_code = 0, lsp_code = 0;
int streamID2;
int vlistID2;
......@@ -88,6 +94,10 @@ void *Pressure(void *argument)
zaxisID = vlistZaxis(vlistID1, i);
nlevel = zaxisInqSize(zaxisID);
#ifdef HIRLAM_EXTENSIONS
if ( cdoVerbose )
cdoPrint("ZAXIS_HYBRID = %d ZAXIS_HYBRID_HALF=%d nlevel=%d mono_level=%d", zaxisInqType(zaxisID) == ZAXIS_HYBRID, zaxisInqType(zaxisID) == ZAXIS_HYBRID_HALF, nlevel, mono_level);
#endif //HIRLAM_EXTENSIONS
if ( (zaxisInqType(zaxisID) == ZAXIS_HYBRID || zaxisInqType(zaxisID) == ZAXIS_HYBRID_HALF) &&
nlevel > 1 )
{
......@@ -119,6 +129,10 @@ void *Pressure(void *argument)
vct = (double*) Malloc(nvct*sizeof(double));
zaxisInqVct(zaxisID, vct);
#ifdef HIRLAM_EXTENSIONS
if ( cdoVerbose )
cdoPrint("Detected half-level model definition : nlevel == (nvct/2 - 1) (nlevel: %d, nvct: %d, nhlevf: %d, nhlevh: %d) ", nlevel, nvct,nhlevf, nhlevh);
#endif //HIRLAM_EXTENSIONS
}
}
else if ( nlevel == (nvct/2) )
......@@ -133,6 +147,10 @@ void *Pressure(void *argument)
vct = (double*) Malloc(nvct*sizeof(double));
zaxisInqVct(zaxisID, vct);
#ifdef HIRLAM_EXTENSIONS
if ( cdoVerbose )
cdoPrint("Detected full-level model definition : nlevel == (nvct/2) (nlevel: %d, nvct: %d, nhlevf: %d, nhlevh: %d) ", nlevel, nvct,nhlevf, nhlevh);
#endif //HIRLAM_EXTENSIONS
}
}
else if ( nlevel == (nvct - 4 - 1) )
......@@ -198,10 +216,25 @@ void *Pressure(void *argument)
else
cdoAbort("No 3D variable with hybrid sigma pressure coordinate found!");
#ifdef HIRLAM_EXTENSIONS
if ( operatorID == PRESSURE_FL || operatorID == DELTAP )
{
if ( cdoVerbose )
cdoPrint("Creating ZAXIS_HYBRID .. (nhlevf=%d)",nhlevf);
zaxisIDp = zaxisCreate(ZAXIS_HYBRID, nhlevf);
}
else
{
if ( cdoVerbose )
cdoPrint("Creating ZAXIS_HYBRID_HALF .. (nhlevh=%d)",nhlevh);
zaxisIDp = zaxisCreate(ZAXIS_HYBRID_HALF, nhlevh);
}
#else
if ( operatorID == PRESSURE_FL || operatorID == DELTAP )
zaxisIDp = zaxisCreate(ZAXIS_HYBRID, nhlevf);
else
zaxisIDp = zaxisCreate(ZAXIS_HYBRID_HALF, nhlevh);
#endif //HIRLAM_EXTENSIONS
{
double *level;
......@@ -246,26 +279,49 @@ void *Pressure(void *argument)
if ( tableNum == 2 )
{
mode = WMO_MODE;
ps_code = 1;
// removing this: ps_code = 1;
wmo_gribcodes(&gribcodes);
}
else if ( tableNum == 128 )
{
mode = ECHAM_MODE;
ps_code = 134;
lsp_code = 152;
// removing this: ps_code = 134;
// removing this: lsp_code = 152;
echam_gribcodes(&gribcodes);
}
#ifdef HIRLAM_EXTENSIONS
// KNMI: HIRLAM model version 7.2 uses tableNum=1 (LAMH_D11*)
// KNMI: HARMONIE model version 36 uses tableNum=1 (grib*) (opreational NWP version)
// KNMI: HARMONIE model version 38 uses tableNum=253 (grib,grib_md) and tableNum=1 (grib_sfx) (research version)
else if ( tableNum == 1 || tableNum == 253 )
{
mode = HIRLAM_MODE;
hirlam_harmonie_gribcodes(&gribcodes);
}
#endif //HIRLAM_EXTENSIONS
else
mode = -1;
}
else
{
mode = ECHAM_MODE;
ps_code = 134;
lsp_code = 152;
// removing this: ps_code = 134;
// removing this: lsp_code = 152;
echam_gribcodes(&gribcodes);
}
if ( cdoVerbose )
#ifdef HIRLAM_EXTENSIONS
{
// As there are many other NWP or climate models it might be more usefull to provide more verbose print.
// Especially when there is so much variation in the codes and names of the variables.
vlistInqVarName(vlistID1, varID, varname);
strtolower(varname);
cdoPrint("Mode = %d Center = %d TableNum =%d Code = %d Param = %s Varname = %s varID = %d", mode, instNum,tableNum, code, paramstr, varname, varID);
}
#else
cdoPrint("Mode = %d Center = %d Param = %s", mode, instNum, paramstr);
#endif //HIRLAM_EXTENSIONS
if ( code <= 0 )
{
......@@ -284,14 +340,20 @@ void *Pressure(void *argument)
if ( mode == ECHAM_MODE )
{
if ( code == ps_code && nlevel == 1 ) psID = varID;
else if ( code == lsp_code && nlevel == 1 ) lnpsID = varID;
if ( code == gribcodes.ps && nlevel == 1 ) psID = varID;
else if ( code == gribcodes.lsp && nlevel == 1 ) lnpsID = varID;
/* else if ( code == 156 ) gheightID = varID; */
}
else if ( mode == WMO_MODE )
{
if ( code == ps_code && nlevel == 1 ) psID = varID;
if ( code == gribcodes.ps && nlevel == 1 ) psID = varID;
}
#ifdef HIRLAM_EXTENSIONS
else if ( mode == HIRLAM_MODE )
{
if ( code == gribcodes.ps && nlevel == 1 ) psID = varID;
}
#endif //HIRLAM_EXTENSIONS
}
pvarID = lnpsID;
......
......@@ -340,6 +340,8 @@ void *Remapeta(void *argument)
{
zaxisID = vlistZaxis(vlistID1, i);
nlevel = zaxisInqSize(zaxisID);
if ( cdoVerbose )
cdoPrint("zaxisIDh = %d, nlevel = %d", zaxisIDh, nlevel);
if ( zaxisInqType(zaxisID) == ZAXIS_HYBRID )
{
if ( nlevel > 1 )
......@@ -401,6 +403,8 @@ void *Remapeta(void *argument)
streamDefVlist(streamID2, vlistID2);
if ( cdoVerbose )
cdoPrint(" zaxisIDh=%d\n", zaxisIDh);
if ( zaxisIDh == -1 )
cdoWarning("No 3D variable with hybrid sigma pressure coordinate found!");
......
/*
HIRLAM extensions ..
*/
/*
This module "SampleGrid" contains the following operators:
samplegrid Resample current grid with given factor, typically 2 (which will half the resolution);
tested on curvilinear and LCC grids;
subgrid Similar to selindexbox but this operator works for LCC grids (tested on HARMONIE NWP model).
*/
#include <ctype.h>
#include "cdo.h"
#include "cdi.h"
#include "cdo_int.h"
#include "grid.h"
#include "griddes.h"
#include "pstream.h"
#include "specspace.h"
#include "list.h"
#include "math.h"
#ifdef HIRLAM_EXTENSIONS
extern int cdoDebugExt; // defined in cdo.c
static
void sampleData(int nwpv, double *array1, int gridID1, double *array2, int gridID2, int resampleFactor )
{
long nlon1, nlat1;
long nlon2, nlat2;
long ilat1, ilon1;
long ilat2, ilon2;
nlon1 = gridInqXsize(gridID1);
nlat1 = gridInqYsize(gridID1);
nlon2 = gridInqXsize(gridID2);
nlat2 = gridInqYsize(gridID2);
if ( cdoDebugExt >= 100) cdoPrint("sampleData():: (nlon1: %d; nlat1: %d) => (nlon2: %d; nlat2: %d); gridID1: %d; gridID2: %d; resampleFactor: %d)",nlon1,nlat1, nlon2,nlat2, gridID1, gridID2, resampleFactor);
if ( nwpv == 1 )
{
for ( ilat1 = 0; ilat1 < nlat1; ilat1+=resampleFactor )
{
for ( ilon1 = 0; ilon1 < nlon1; ilon1+=resampleFactor )
*array2++ = array1[ilat1*nlon1 + ilon1];
}
}
else
if ( nwpv == 2 ) // complex numbers ... unsupported yet ...
{
/*
for ( ilat = lat1; ilat <= lat2; ilat++ )
{
for ( ilon = lon21; ilon <= lon22; ilon++ )
{
*array2++ = array1[ilat*nlon1*2 + ilon*2];