Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
cdo
Commits
e7d34204
Commit
e7d34204
authored
Jan 22, 2013
by
Uwe Schulzweida
Browse files
added operator adisit
parent
fbdb8e0f
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/Makefile.am
View file @
e7d34204
...
...
@@ -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
\
...
...
src/Makefile.in
View file @
e7d34204
...
...
@@ -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
\
Import
c
ms
af
.c Import
obs.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
\
Seas
stat.c Selbox
.c Se
le
ct.c Se
loperator
.c Sel
rec
.c Sel
time
.c
\
Sel
va
r.c Se
t
.c Se
tbox.c Setgatt
.c Set
grid
.c Set
halo
.c
\
Set
miss
.c Set
partab.c Setrcaname
.c Set
time
.c Set
zaxis
.c
\
S
howinfo.c Sinfo.c Smooth9.c Sort.c Sorttimestamp
.c S
pec
info.c
\
S
pectral.c Spectrum.c Split.c Splitrec.c Splitsel
.c
\
Split
time
.c Split
year.c SSOpar.c Subtrend.c Tee.c Templates
.c
\
Test
.c Te
sts
.c T
imcount.c Timpctl.c Timselpctl.c Timselsta
t.c
\
Tim
sort
.c Tims
tat
.c Timstat
2
.c Tims
tat3
.c Ti
nfo.c Tocomplex
.c
\
T
ranspose.c Trend.c Trms.c Tstepcount.c Vardup.c Varg
en.c
\
Var
rms.c
Vertint.c Vertstat.c Vertwind.c Wct.c W
in
d
.c
\
Writegrid.c Writerandom.c YAR.c Ydayarith.c Ydaypctl
.c
\
Y
daystat
.c Yd
run
pctl.c Yd
run
stat.c Y
hourarith.c Yhourstat
.c
\
Y
monarith.c Ymonpctl.c Ymonstat.c Yseaspctl.c Yseasstat
.c
\
Z
onstat.c
cdo.h cdo_in
t.
h
cdo
_pthread.c cdo_vlist.c color.c
\
c
olor.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 exp
r.
c
e
xpr.h expr_lex.c expr_yacc
.c
\
expr
_yacc.h field.c field.h field2.c fieldc.c
field
mem
.c
\
field
mer
.c field
zon
.c f
ouriertrans.c functs.h gradsdeslib
.c
\
gradsdeslib.h grid.c grid.h grid_gme.c grid_lcc.c
grid
_rot
.c
\
grid
des.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_elemen
t.
c
n
th_element.h
\
operator_help.h par_io.c par_io.h
percentiles.c percentiles.h
\
p
ipe.c pipe.h printinfo.h process.c process.h pstream.c
\
p
stream.h pstream_int.h pthread_debug.c pthread_debug
.h
\
read
line.c realtime.c remap.h remaplib
.c remap
sort.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
\
Import
a
ms
r
.c Import
binary.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
\
Mer
gegrid.c Mergetime.c Mer
stat.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
\
R
eplacevalues.c Rhopot.c Rotuv.c R
unpctl.c Runstat.c Scatter.c
\
Seas
count
.c Se
asp
ct
l
.c Se
asstat
.c Sel
box
.c Sel
ect
.c
\
Sel
operato
r.c Se
lrec
.c Se
ltime.c Selvar
.c Set.c Set
box
.c
\
Set
gatt
.c Set
grid.c Sethalo
.c Set
miss
.c Set
partab
.c
\
S
etrcaname.c Settime.c Setzaxis.c Showinfo
.c Sinfo.c
Smooth9.c
\
S
ort.c Sorttimestamp.c Specinfo.c Spectral.c Spectrum
.c
\
Split.c Split
rec.c Splitsel.c Splittime.c Splityear.c SSOpar
.c
\
Subtrend
.c Te
e
.c T
emplates.c Test.c Tests.c Timcoun
t.c
\
Tim
pctl
.c Tims
elpctl
.c Tims
els
tat.c Tims
ort
.c Ti
mstat
.c
\
T
imstat2.c Timstat3.c Tinfo.c Tocomplex.c Transpose.c Tr
en
d
.c
\
T
rms.c
Tstepcount.c Vardup.c Vargen.c Varrms.c Vert
in
t
.c
\
Vertstat.c Vertwind.c Wct.c Wind.c Writegrid.c Writerandom
.c
\
Y
AR.c Ydayarith
.c Yd
ay
pctl.c Yd
ay
stat.c Y
drunpctl
.c
\
Y
drunstat.c Yhourarith.c Yhourstat.c Ymonarith.c Ymonpctl
.c
\
Ym
onstat.c
Yseaspctl.c Yseasstat.c Zonsta
t.
c
cdo
.h cdo_int.h
\
c
do_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 erro
r.
h
e
topo.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 field
c
.c f
ieldmem.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
kv
list.
c
\
kvlist.h legendre.c list.c list.h merge_sort2.c merge_sort2.h
\
modules.c modules.h namelist.c namelis
t.
h
n
ormal.c
\
nth_element.c nth_element.h
operator_help.h par_io.c par_io.h
\
p
ercentiles.c percentiles.h pipe.c pipe.h printinfo.h
\
p
rocess.c process.h pstream.c pstream.h pstream_int
.h
\
pth
read
_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-A
r
it
h
.
$(OBJEXT)
\
cdo-Arith
c
.
$(OBJEXT)
cdo-Arith
days
.
$(OBJEXT)
\
cdo-Arith
lat
.
$(OBJEXT)
cdo-
CDItes
t.
$(OBJEXT)
\
cdo-CDI
read
.
$(OBJEXT)
cdo-CDI
write.
$(OBJEXT)
cdo-Cat
.
$(OBJEXT)
\
cdo-C
hang
e.
$(OBJEXT)
cdo-C
hange_e5slm
.
$(OBJEXT)
\
cdo-C
loudlayer
.
$(OBJEXT)
cdo-C
ommand
.
$(OBJEXT)
\
cdo-Comp.
$(OBJEXT)
cdo-Compc.
$(OBJEXT)
\
am_cdo_OBJECTS
=
cdo-cdo.
$(OBJEXT)
cdo-A
dis
it.
$(OBJEXT)
\
cdo-Arith.
$(OBJEXT)
cdo-Arith
c
.
$(OBJEXT)
\
cdo-Arith
days
.
$(OBJEXT)
cdo-
Arithla
t.
$(OBJEXT)
\
cdo-CDI
test
.
$(OBJEXT)
cdo-CDI
read
.
$(OBJEXT)
\
cdo-C
DIwrit
e.
$(OBJEXT)
cdo-C
at.
$(OBJEXT)
cdo-Change
.
$(OBJEXT)
\
cdo-C
hange_e5slm
.
$(OBJEXT)
cdo-C
loudlayer
.
$(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
...
...
src/Rhopot.c
View file @
e7d34204
...
...
@@ -43,17 +43,10 @@
!!
*/
/* compute density from
potential
temperature
directly
*/
/* compute density from
insitu
temperature */
static
double
potrho_1
(
double
tpo
t
,
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
t
h
o
,
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 */
/* t
h
o units: Celsius */
/* to units:
Celsius */
/* sao units: psu */
long
i
,
levelID
,
offset
;
double
*
rhoptr
,
*
t
h
optr
,
*
saoptr
;
double
*
rhoptr
,
*
toptr
,
*
saoptr
;
for
(
levelID
=
0
;
levelID
<
nlevel
;
++
levelID
)
{
offset
=
gridsize
*
levelID
;
t
h
optr
=
t
h
o
.
ptr
+
offset
;
toptr
=
to
.
ptr
+
offset
;
saoptr
=
sao
.
ptr
+
offset
;
rhoptr
=
rho
.
ptr
+
offset
;
for
(
i
=
0
;
i
<
gridsize
;
++
i
)
{
if
(
DBL_IS_EQUAL
(
t
h
optr
[
i
],
t
h
o
.
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
(
t
h
optr
[
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
t
h
oID
=
-
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
t
h
o
,
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
,
t
h
oID
);
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
]);
}
t
h
o
.
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
));
t
h
o
.
nmiss
=
0
;
to
.
nmiss
=
0
;
sao
.
nmiss
=
0
;
rho
.
nmiss
=
0
;
t
h
o
.
missval
=
vlistInqVarMissval
(
vlistID1
,
t
h
oID
);
to
.
missval
=
vlistInqVarMissval
(
vlistID1
,
toID
);
sao
.
missval
=
vlistInqVarMissval
(
vlistID1
,
saoID
);
rho
.
missval
=
t
h
o
.
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
,
"rhopot
o
"
);
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
==
t
h
oID
)
streamReadRecord
(
streamID1
,
t
h
o
.
ptr
+
offset
,
&
(
t
h
o
.
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
,
t
h
o
,
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
(
t
h
o
.
ptr
);
free
(
to
.
ptr
);
free
(
sao
.
ptr
);
cdoFinish
();
...
...
src/modules.c
View file @
e7d34204
...
...
@@ -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
},
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment