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

added operator adisit

parent fbdb8e0f
......@@ -3,7 +3,8 @@
bin_PROGRAMS = cdo
#
cdo_SOURCES = cdo.c
cdo_SOURCES += Arith.c \
cdo_SOURCES += Adisit.c \
Arith.c \
Arithc.c \
Arithdays.c \
Arithlat.c \
......
......@@ -86,57 +86,57 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
am__cdo_SOURCES_DIST = cdo.c Arith.c Arithc.c Arithdays.c Arithlat.c \
CDItest.c CDIread.c CDIwrite.c Cat.c Change.c Change_e5slm.c \
Cloudlayer.c Command.c Comp.c Compc.c Complextorect.c Cond.c \
Cond2.c Condc.c Consecstat.c Copy.c Deltime.c Derivepar.c \
Detrend.c Diff.c Duplicate.c EOFs.c Eof3d.c EcaIndices.c \
Echam5ini.c Enlarge.c Enlargegrid.c Ensstat.c Ensstat3.c \
Ensval.c Eofcoeff.c Eofcoeff3d.c Exprf.c FC.c Filedes.c \
Fillmiss.c Filter.c Fldrms.c Fldstat.c Fldstat2.c Fourier.c \
Gather.c Gengrid.c Gradsdes.c Gridboxstat.c Gridcell.c \
Harmonic.c Hi.c Histogram.c Importamsr.c Importbinary.c \
Importcmsaf.c Importobs.c Info.c Input.c Intgrid.c \
Intgridtraj.c Intlevel.c Intlevel3d.c Intntime.c Inttime.c \
Intyear.c Invert.c Invertlev.c Isosurface.c Kvl.c Log.c \
Maskbox.c Mastrfu.c Math.c Merge.c Mergegrid.c Mergetime.c \
Merstat.c Monarith.c Mrotuv.c Mrotuvb.c Ninfo.c Nmltest.c \
Output.c Outputgmt.c Pinfo.c Pressure.c Regres.c Remap.c \
Remapeta.c Replace.c Replacevalues.c Rhopot.c Rotuv.c \
Runpctl.c Runstat.c Scatter.c Seascount.c Seaspctl.c \
Seasstat.c Selbox.c Select.c Seloperator.c Selrec.c Seltime.c \
Selvar.c Set.c Setbox.c Setgatt.c Setgrid.c Sethalo.c \
Setmiss.c Setpartab.c Setrcaname.c Settime.c Setzaxis.c \
Showinfo.c Sinfo.c Smooth9.c Sort.c Sorttimestamp.c Specinfo.c \
Spectral.c Spectrum.c Split.c Splitrec.c Splitsel.c \
Splittime.c Splityear.c SSOpar.c Subtrend.c Tee.c Templates.c \
Test.c Tests.c Timcount.c Timpctl.c Timselpctl.c Timselstat.c \
Timsort.c Timstat.c Timstat2.c Timstat3.c Tinfo.c Tocomplex.c \
Transpose.c Trend.c Trms.c Tstepcount.c Vardup.c Vargen.c \
Varrms.c Vertint.c Vertstat.c Vertwind.c Wct.c Wind.c \
Writegrid.c Writerandom.c YAR.c Ydayarith.c Ydaypctl.c \
Ydaystat.c Ydrunpctl.c Ydrunstat.c Yhourarith.c Yhourstat.c \
Ymonarith.c Ymonpctl.c Ymonstat.c Yseaspctl.c Yseasstat.c \
Zonstat.c cdo.h cdo_int.h cdo_pthread.c cdo_vlist.c color.c \
color.h commandline.c const.h counter.h dmemory.h dtypes.h \
ecacore.c ecacore.h ecautil.c ecautil.h error.h etopo.h temp.h \
mask.h exception.c expr.c expr.h expr_lex.c expr_yacc.c \
expr_yacc.h field.c field.h field2.c fieldc.c fieldmem.c \
fieldmer.c fieldzon.c fouriertrans.c functs.h gradsdeslib.c \
gradsdeslib.h grid.c grid.h grid_gme.c grid_lcc.c grid_rot.c \
griddes.c griddes.h griddes_h5.c griddes_nc.c hetaeta.c \
hetaeta.h history.c institution.c interpol.c interpol.h job.c \
juldate.c kvlist.c kvlist.h legendre.c list.c list.h \
merge_sort2.c merge_sort2.h modules.c modules.h namelist.c \
namelist.h normal.c nth_element.c nth_element.h \
operator_help.h par_io.c par_io.h percentiles.c percentiles.h \
pipe.c pipe.h printinfo.h process.c process.h pstream.c \
pstream.h pstream_int.h pthread_debug.c pthread_debug.h \
readline.c realtime.c remap.h remaplib.c remapsort.c \
specspace.c specspace.h statistic.c statistic.h table.c \
timebase.h timer.c userlog.c util.c util.h vinterp.c vinterp.h \
zaxis.c Magplot.c Magvector.c Maggraph.c template_parser.h \
template_parser.c results_template_parser.h \
am__cdo_SOURCES_DIST = cdo.c Adisit.c Arith.c Arithc.c Arithdays.c \
Arithlat.c CDItest.c CDIread.c CDIwrite.c Cat.c Change.c \
Change_e5slm.c Cloudlayer.c Command.c Comp.c Compc.c \
Complextorect.c Cond.c Cond2.c Condc.c Consecstat.c Copy.c \
Deltime.c Derivepar.c Detrend.c Diff.c Duplicate.c EOFs.c \
Eof3d.c EcaIndices.c Echam5ini.c Enlarge.c Enlargegrid.c \
Ensstat.c Ensstat3.c Ensval.c Eofcoeff.c Eofcoeff3d.c Exprf.c \
FC.c Filedes.c Fillmiss.c Filter.c Fldrms.c Fldstat.c \
Fldstat2.c Fourier.c Gather.c Gengrid.c Gradsdes.c \
Gridboxstat.c Gridcell.c Harmonic.c Hi.c Histogram.c \
Importamsr.c Importbinary.c Importcmsaf.c Importobs.c Info.c \
Input.c Intgrid.c Intgridtraj.c Intlevel.c Intlevel3d.c \
Intntime.c Inttime.c Intyear.c Invert.c Invertlev.c \
Isosurface.c Kvl.c Log.c Maskbox.c Mastrfu.c Math.c Merge.c \
Mergegrid.c Mergetime.c Merstat.c Monarith.c Mrotuv.c \
Mrotuvb.c Ninfo.c Nmltest.c Output.c Outputgmt.c Pinfo.c \
Pressure.c Regres.c Remap.c Remapeta.c Replace.c \
Replacevalues.c Rhopot.c Rotuv.c Runpctl.c Runstat.c Scatter.c \
Seascount.c Seaspctl.c Seasstat.c Selbox.c Select.c \
Seloperator.c Selrec.c Seltime.c Selvar.c Set.c Setbox.c \
Setgatt.c Setgrid.c Sethalo.c Setmiss.c Setpartab.c \
Setrcaname.c Settime.c Setzaxis.c Showinfo.c Sinfo.c Smooth9.c \
Sort.c Sorttimestamp.c Specinfo.c Spectral.c Spectrum.c \
Split.c Splitrec.c Splitsel.c Splittime.c Splityear.c SSOpar.c \
Subtrend.c Tee.c Templates.c Test.c Tests.c Timcount.c \
Timpctl.c Timselpctl.c Timselstat.c Timsort.c Timstat.c \
Timstat2.c Timstat3.c Tinfo.c Tocomplex.c Transpose.c Trend.c \
Trms.c Tstepcount.c Vardup.c Vargen.c Varrms.c Vertint.c \
Vertstat.c Vertwind.c Wct.c Wind.c Writegrid.c Writerandom.c \
YAR.c Ydayarith.c Ydaypctl.c Ydaystat.c Ydrunpctl.c \
Ydrunstat.c Yhourarith.c Yhourstat.c Ymonarith.c Ymonpctl.c \
Ymonstat.c Yseaspctl.c Yseasstat.c Zonstat.c cdo.h cdo_int.h \
cdo_pthread.c cdo_vlist.c color.c color.h commandline.c \
const.h counter.h dmemory.h dtypes.h ecacore.c ecacore.h \
ecautil.c ecautil.h error.h etopo.h temp.h mask.h exception.c \
expr.c expr.h expr_lex.c expr_yacc.c expr_yacc.h field.c \
field.h field2.c fieldc.c fieldmem.c fieldmer.c fieldzon.c \
fouriertrans.c functs.h gradsdeslib.c gradsdeslib.h grid.c \
grid.h grid_gme.c grid_lcc.c grid_rot.c griddes.c griddes.h \
griddes_h5.c griddes_nc.c hetaeta.c hetaeta.h history.c \
institution.c interpol.c interpol.h job.c juldate.c kvlist.c \
kvlist.h legendre.c list.c list.h merge_sort2.c merge_sort2.h \
modules.c modules.h namelist.c namelist.h normal.c \
nth_element.c nth_element.h operator_help.h par_io.c par_io.h \
percentiles.c percentiles.h pipe.c pipe.h printinfo.h \
process.c process.h pstream.c pstream.h pstream_int.h \
pthread_debug.c pthread_debug.h readline.c realtime.c remap.h \
remaplib.c remapsort.c specspace.c specspace.h statistic.c \
statistic.h table.c timebase.h timer.c userlog.c util.c util.h \
vinterp.c vinterp.h zaxis.c Magplot.c Magvector.c Maggraph.c \
template_parser.h template_parser.c results_template_parser.h \
results_template_parser.c magics_template_parser.h \
magics_template_parser.c StringUtilities.h StringUtilities.c \
CdoMagicsMapper.h CdoMagicsMapper.c
......@@ -148,13 +148,13 @@ am__cdo_SOURCES_DIST = cdo.c Arith.c Arithc.c Arithdays.c Arithlat.c \
@ENABLE_MAGICS_TRUE@ cdo-magics_template_parser.$(OBJEXT) \
@ENABLE_MAGICS_TRUE@ cdo-StringUtilities.$(OBJEXT) \
@ENABLE_MAGICS_TRUE@ cdo-CdoMagicsMapper.$(OBJEXT)
am_cdo_OBJECTS = cdo-cdo.$(OBJEXT) cdo-Arith.$(OBJEXT) \
cdo-Arithc.$(OBJEXT) cdo-Arithdays.$(OBJEXT) \
cdo-Arithlat.$(OBJEXT) cdo-CDItest.$(OBJEXT) \
cdo-CDIread.$(OBJEXT) cdo-CDIwrite.$(OBJEXT) cdo-Cat.$(OBJEXT) \
cdo-Change.$(OBJEXT) cdo-Change_e5slm.$(OBJEXT) \
cdo-Cloudlayer.$(OBJEXT) cdo-Command.$(OBJEXT) \
cdo-Comp.$(OBJEXT) cdo-Compc.$(OBJEXT) \
am_cdo_OBJECTS = cdo-cdo.$(OBJEXT) cdo-Adisit.$(OBJEXT) \
cdo-Arith.$(OBJEXT) cdo-Arithc.$(OBJEXT) \
cdo-Arithdays.$(OBJEXT) cdo-Arithlat.$(OBJEXT) \
cdo-CDItest.$(OBJEXT) cdo-CDIread.$(OBJEXT) \
cdo-CDIwrite.$(OBJEXT) cdo-Cat.$(OBJEXT) cdo-Change.$(OBJEXT) \
cdo-Change_e5slm.$(OBJEXT) cdo-Cloudlayer.$(OBJEXT) \
cdo-Command.$(OBJEXT) cdo-Comp.$(OBJEXT) cdo-Compc.$(OBJEXT) \
cdo-Complextorect.$(OBJEXT) cdo-Cond.$(OBJEXT) \
cdo-Cond2.$(OBJEXT) cdo-Condc.$(OBJEXT) \
cdo-Consecstat.$(OBJEXT) cdo-Copy.$(OBJEXT) \
......@@ -452,8 +452,8 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
cdo_SOURCES = cdo.c Arith.c Arithc.c Arithdays.c Arithlat.c CDItest.c \
CDIread.c CDIwrite.c Cat.c Change.c Change_e5slm.c \
cdo_SOURCES = cdo.c Adisit.c Arith.c Arithc.c Arithdays.c Arithlat.c \
CDItest.c CDIread.c CDIwrite.c Cat.c Change.c Change_e5slm.c \
Cloudlayer.c Command.c Comp.c Compc.c Complextorect.c Cond.c \
Cond2.c Condc.c Consecstat.c Copy.c Deltime.c Derivepar.c \
Detrend.c Diff.c Duplicate.c EOFs.c Eof3d.c EcaIndices.c \
......@@ -631,6 +631,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Adisit.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Arith.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Arithc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdo-Arithdays.Po@am__quote@
......@@ -907,6 +908,20 @@ cdo-cdo.obj: cdo.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-cdo.obj `if test -f 'cdo.c'; then $(CYGPATH_W) 'cdo.c'; else $(CYGPATH_W) '$(srcdir)/cdo.c'; fi`
cdo-Adisit.o: Adisit.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Adisit.o -MD -MP -MF $(DEPDIR)/cdo-Adisit.Tpo -c -o cdo-Adisit.o `test -f 'Adisit.c' || echo '$(srcdir)/'`Adisit.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/cdo-Adisit.Tpo $(DEPDIR)/cdo-Adisit.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='Adisit.c' object='cdo-Adisit.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Adisit.o `test -f 'Adisit.c' || echo '$(srcdir)/'`Adisit.c
cdo-Adisit.obj: Adisit.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Adisit.obj -MD -MP -MF $(DEPDIR)/cdo-Adisit.Tpo -c -o cdo-Adisit.obj `if test -f 'Adisit.c'; then $(CYGPATH_W) 'Adisit.c'; else $(CYGPATH_W) '$(srcdir)/Adisit.c'; fi`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/cdo-Adisit.Tpo $(DEPDIR)/cdo-Adisit.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='Adisit.c' object='cdo-Adisit.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Adisit.obj `if test -f 'Adisit.c'; then $(CYGPATH_W) 'Adisit.c'; else $(CYGPATH_W) '$(srcdir)/Adisit.c'; fi`
cdo-Arith.o: Arith.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Arith.o -MD -MP -MF $(DEPDIR)/cdo-Arith.Tpo -c -o cdo-Arith.o `test -f 'Arith.c' || echo '$(srcdir)/'`Arith.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/cdo-Arith.Tpo $(DEPDIR)/cdo-Arith.Po
......
......@@ -43,17 +43,10 @@
!!
*/
/* compute density from potential temperature directly */
/* compute density from insitu temperature */
static
double potrho_1(double tpot, double sal, double p)
double potrho_1(double t, double sal, double p)
{
double a_a1 = 3.6504E-4, a_a2 = 8.3198E-5, a_a3 = 5.4065E-7,
a_a4 = 4.0274E-9,
a_b1 = 1.7439E-5, a_b2 = 2.9778E-7,
a_c1 = 8.9309E-7, a_c2 = 3.1628E-8, a_c3 = 2.1987E-10,
a_d = 4.1057E-9,
a_e1 = 1.6056E-10, a_e2 = 5.0484E-12;
double r_a0 = 999.842594, r_a1 = 6.793952e-2, r_a2 = -9.095290e-3,
r_a3 = 1.001685e-4, r_a4 = -1.120083e-6, r_a5 = 6.536332e-9,
r_b0 = 8.24493e-1, r_b1 = -4.0899e-3, r_b2 = 7.6438e-5,
......@@ -72,24 +65,10 @@ double potrho_1(double tpot, double sal, double p)
r_ak0 = 8.50935e-5, r_ak1 = -6.12293e-6, r_ak2 = 5.2787e-8,
r_am0 = -9.9348e-7, r_am1 = 2.0816e-8, r_am2 = 9.1697e-10;
double dc, dv, dvs, fne, fst, qc, qn3, qnq, qv, qvs, s, s3h, t, tpo;
double s, s3h;
double rho;
qc = p * (a_a1 + p * (a_c1 - a_e1 * p));
qv = p * (a_b1 - a_d * p);
dc = 1. + p * (-a_a2 + p * (a_c2 - a_e2 * p));
dv = a_b2 * p;
qnq = -p * (-a_a3 + p * a_c3);
qn3 = -p * a_a4;
{
tpo = tpot;
qvs = qv*(sal - 35.) + qc;
dvs = dv*(sal - 35.) + dc;
t = (tpo + qvs)/dvs;
fne = - qvs + t*(dvs + t*(qnq + t*qn3)) - tpo;
fst = dvs + t*(2.*qnq + 3.*qn3*t);
t = t - fne/fst;
s = MAX(sal, 0.0);
s3h = sqrt(s*s*s);
......@@ -147,32 +126,32 @@ int main (int argc, char *argv[])
*/
static
void calc_rhopot(long gridsize, long nlevel, double *pressure, field_t tho, field_t sao, field_t rho)
void calc_rhopot(long gridsize, long nlevel, double *pressure, field_t to, field_t sao, field_t rho)
{
/* pressure units: hPa */
/* tho units: Celsius */
/* to units: Celsius */
/* sao units: psu */
long i, levelID, offset;
double *rhoptr, *thoptr, *saoptr;
double *rhoptr, *toptr, *saoptr;
for ( levelID = 0; levelID < nlevel; ++levelID )
{
offset = gridsize*levelID;
thoptr = tho.ptr + offset;
toptr = to.ptr + offset;
saoptr = sao.ptr + offset;
rhoptr = rho.ptr + offset;
for ( i = 0; i < gridsize; ++i )
{
if ( DBL_IS_EQUAL(thoptr[i], tho.missval) ||
if ( DBL_IS_EQUAL(toptr[i], to.missval) ||
DBL_IS_EQUAL(saoptr[i], sao.missval) )
{
rhoptr[i] = rho.missval;
}
else
{
rhoptr[i] = potrho_1(thoptr[i], saoptr[i], pressure[levelID]);
rhoptr[i] = potrho_1(toptr[i], saoptr[i], pressure[levelID]);
}
}
}
......@@ -192,13 +171,13 @@ void *Rhopot(void *argument)
int ngrids, nlevel;
int i;
int nmiss;
int thoID = -1, saoID = -1;
int toID = -1, saoID = -1, thoID = -1;
char varname[CDI_MAX_NAME], stdname[CDI_MAX_NAME];
int taxisID1, taxisID2;
double pin = -1;
double *pressure;
double *single;
field_t tho, sao, rho;
field_t to, sao, rho;
cdoInitialize(argument);
......@@ -215,25 +194,37 @@ void *Rhopot(void *argument)
gridID = vlistInqVarGrid(vlistID1, varID);
code = vlistInqVarCode(vlistID1, varID);
vlistInqVarName(vlistID1, varID, varname);
vlistInqVarStdname(vlistID1,varID, stdname);
strtolower(varname);
if ( strcmp(varname, "tho") == 0 ) code = 2;
else if ( strcmp(varname, "sao") == 0 ) code = 5;
if ( code <= 0 )
{
vlistInqVarName(vlistID1, varID, varname);
vlistInqVarStdname(vlistID1,varID, stdname);
strtolower(varname);
if ( strcmp(varname, "to") == 0 ) code = 20;
else if ( strcmp(varname, "sao") == 0 ) code = 5;
else if ( strcmp(varname, "tho") == 0 ) code = 2;
else if ( strcmp(varname, "t") == 0 ) code = 2;
else if ( strcmp(varname, "s") == 0 ) code = 5;
else if ( strcmp(varname, "s") == 0 ) code = 5;
else if ( strcmp(varname, "t") == 0 ) code = 2;
else if ( strcmp(stdname, "sea_water_potential_temperature") == 0 ) code = 2;
else if ( strcmp(stdname, "sea_water_salinity") == 0 ) code = 5;
else if ( strcmp(stdname, "sea_water_salinity") == 0 ) code = 5;
else if ( strcmp(stdname, "sea_water_potential_temperature") == 0 ) code = 2;
}
if ( code == 2 ) thoID = varID;
else if ( code == 5 ) saoID = varID;
if ( code == 20 ) toID = varID;
else if ( code == 5 ) saoID = varID;
else if ( code == 2 ) thoID = varID;
}
if ( thoID == -1 ) cdoAbort("Potential temperature not found!");
if ( saoID == -1 ) cdoAbort("Sea water salinity not found!");
if ( toID == -1 && thoID != -1 )
{
cdoPrint("Use the CDO operator 'adisit' to convert potential temperature to In-situ temperature.");
cdoPrint("Here is an example:");
cdoPrint(" cdo rhopot -adisit %s %s", cdoStreamName(0), cdoStreamName(1));
}
if ( toID == -1 ) cdoAbort("In-situ temperature not found!");
ngrids = vlistNgrids(vlistID1);
gridID = vlistGrid(vlistID1, 0);
......@@ -249,7 +240,7 @@ void *Rhopot(void *argument)
zaxisID = vlistInqVarZaxis(vlistID1, saoID);
nlevel1 = zaxisInqSize(zaxisID);
zaxisID = vlistInqVarZaxis(vlistID1, thoID);
zaxisID = vlistInqVarZaxis(vlistID1, toID);
nlevel2 = zaxisInqSize(zaxisID);
if ( nlevel1 != nlevel2 ) cdoAbort("temperature and salinity have different number of levels!");
......@@ -270,23 +261,23 @@ void *Rhopot(void *argument)
cdoPrint("%5d %g", i+1, pressure[i]);
}
tho.ptr = (double *) malloc(gridsize*nlevel*sizeof(double));
to.ptr = (double *) malloc(gridsize*nlevel*sizeof(double));
sao.ptr = (double *) malloc(gridsize*nlevel*sizeof(double));
rho.ptr = (double *) malloc(gridsize*nlevel*sizeof(double));
tho.nmiss = 0;
to.nmiss = 0;
sao.nmiss = 0;
rho.nmiss = 0;
tho.missval = vlistInqVarMissval(vlistID1, thoID);
to.missval = vlistInqVarMissval(vlistID1, toID);
sao.missval = vlistInqVarMissval(vlistID1, saoID);
rho.missval = tho.missval;
rho.missval = to.missval;
vlistID2 = vlistCreate();
varID = vlistDefVar(vlistID2, gridID, zaxisID, TSTEP_INSTANT);
vlistDefVarParam(vlistID2, varID, cdiEncodeParam(18, 255, 255));
vlistDefVarName(vlistID2, varID, "rhopot");
vlistDefVarName(vlistID2, varID, "rhopoto");
vlistDefVarLongname(vlistID2, varID, "Sea water potential density");
vlistDefVarStdname(vlistID2, varID, "sea_water_potential_density");
vlistDefVarUnits(vlistID2, varID, "kg m-3");
......@@ -314,11 +305,11 @@ void *Rhopot(void *argument)
offset = gridsize*levelID;
if ( varID == thoID ) streamReadRecord(streamID1, tho.ptr+offset, &(tho.nmiss));
if ( varID == toID ) streamReadRecord(streamID1, to.ptr+offset, &(to.nmiss));
if ( varID == saoID ) streamReadRecord(streamID1, sao.ptr+offset, &(sao.nmiss));
}
calc_rhopot(gridsize, nlevel, pressure, tho, sao, rho);
calc_rhopot(gridsize, nlevel, pressure, to, sao, rho);
for ( levelID = 0; levelID < nlevel; ++levelID )
{
......@@ -343,7 +334,7 @@ void *Rhopot(void *argument)
free(pressure);
free(rho.ptr);
free(tho.ptr);
free(to.ptr);
free(sao.ptr);
cdoFinish();
......
......@@ -42,6 +42,7 @@ typedef struct {
modules_t;
void *Adisit(void *argument);
void *Arith(void *argument);
void *Arithc(void *argument);
void *Arithdays(void *argument);
......@@ -268,6 +269,7 @@ void *Maggraph(void *argument);
#endif
#define AdisitOperators {"adisit"}
#define ArithOperators {"add", "sub", "mul", "div", "min", "max", "atan2"}
#define ArithcOperators {"addc", "subc", "mulc", "divc", "mod"}
#define ArithdaysOperators {"muldpm", "divdpm", "muldpy", "divdpy", "muldoy"}
......@@ -535,6 +537,7 @@ static modules_t Modules[] =
function help function operator names number num streams
type in out
*/
{ Adisit, NULL, AdisitOperators, CDI_REAL, 1, 1 },
{ Arith, ArithHelp, ArithOperators, CDI_REAL, 2, 1 },
{ Arithc, ArithcHelp, ArithcOperators, CDI_REAL, 1, 1 },
{ Arithdays, ArithdaysHelp, ArithdaysOperators, CDI_REAL, 1, 1 },
......
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