Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
cdo
Commits
4f338454
Commit
4f338454
authored
10 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
Mastrfu: Merge declaration and definition
parent
f9fb70eb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Mastrfu.c
+25
-36
25 additions, 36 deletions
src/Mastrfu.c
with
25 additions
and
36 deletions
src/Mastrfu.c
+
25
−
36
View file @
4f338454
...
...
@@ -32,22 +32,18 @@
static
void
mastrfu
(
int
gridID
,
int
zaxisID
,
double
*
array1
,
double
*
array2
,
int
nmiss
,
double
missval
)
{
int
nlev
;
int
nlat
;
int
ilev
,
ilat
,
n
;
double
*
plevel
,
*
phi
,
*
cosphi
,
*
dummy
;
double
fact
=
4
*
atan
(
1
.
0
)
*
6371000
/
9
.
81
;
double
**
field1
,
**
field2
;
char
units
[
CDI_MAX_NAME
];
nlat
=
gridInqSize
(
gridID
);
nlev
=
zaxisInqSize
(
zaxisID
);
phi
=
(
double
*
)
malloc
(
nlat
*
sizeof
(
double
));
dummy
=
(
double
*
)
malloc
(
nlat
*
sizeof
(
double
));
cosphi
=
(
double
*
)
malloc
(
nlat
*
sizeof
(
double
));
plevel
=
(
double
*
)
malloc
(
nlev
*
sizeof
(
double
));
field1
=
(
double
**
)
malloc
(
nlev
*
sizeof
(
double
*
));
field2
=
(
double
**
)
malloc
(
nlev
*
sizeof
(
double
*
));
int
nlat
=
gridInqSize
(
gridID
);
int
nlev
=
zaxisInqSize
(
zaxisID
);
double
*
phi
=
(
double
*
)
malloc
(
nlat
*
sizeof
(
double
));
double
*
dummy
=
(
double
*
)
malloc
(
nlat
*
sizeof
(
double
));
double
*
cosphi
=
(
double
*
)
malloc
(
nlat
*
sizeof
(
double
));
double
*
plevel
=
(
double
*
)
malloc
(
nlev
*
sizeof
(
double
));
double
**
field1
=
(
double
**
)
malloc
(
nlev
*
sizeof
(
double
*
));
double
**
field2
=
(
double
**
)
malloc
(
nlev
*
sizeof
(
double
*
));
zaxisInqLevels
(
zaxisID
,
plevel
);
...
...
@@ -110,33 +106,26 @@ void mastrfu(int gridID, int zaxisID, double *array1, double *array2, int nmiss,
void
*
Mastrfu
(
void
*
argument
)
{
int
streamID1
,
streamID2
;
int
nrecs
;
int
tsID
,
recID
,
varID
,
levelID
;
int
gridsize
;
int
nvars
,
code
,
gridID
,
zaxisID
,
nlev
;
int
vlistID1
,
vlistID2
;
int
recID
,
varID
,
levelID
;
int
offset
;
int
nmiss
,
nmiss1
;
double
missval
;
double
*
array1
,
*
array2
;
int
taxisID1
,
taxisID2
;
cdoInitialize
(
argument
);
streamID1
=
streamOpenRead
(
cdoStreamName
(
0
));
int
streamID1
=
streamOpenRead
(
cdoStreamName
(
0
));
vlistID1
=
streamInqVlist
(
streamID1
);
int
vlistID1
=
streamInqVlist
(
streamID1
);
nvars
=
vlistNvars
(
vlistID1
);
int
nvars
=
vlistNvars
(
vlistID1
);
if
(
nvars
!=
1
)
cdoAbort
(
"This operator works only with one variable!"
);
code
=
vlistInqVarCode
(
vlistID1
,
0
);
int
code
=
vlistInqVarCode
(
vlistID1
,
0
);
if
(
code
>
0
&&
code
!=
132
)
cdoWarning
(
"Unexpected code %d!"
,
code
);
missval
=
vlistInqVarMissval
(
vlistID1
,
0
);
double
missval
=
vlistInqVarMissval
(
vlistID1
,
0
);
zaxisID
=
vlistInqVarZaxis
(
vlistID1
,
0
);
int
zaxisID
=
vlistInqVarZaxis
(
vlistID1
,
0
);
if
(
zaxisInqType
(
zaxisID
)
!=
ZAXIS_PRESSURE
&&
zaxisInqType
(
zaxisID
)
!=
ZAXIS_GENERIC
)
{
...
...
@@ -145,16 +134,16 @@ void *Mastrfu(void *argument)
cdoWarning
(
"Unexpected vertical grid %s!"
,
longname
);
}
gridID
=
vlistInqVarGrid
(
vlistID1
,
0
);
int
gridID
=
vlistInqVarGrid
(
vlistID1
,
0
);
if
(
gridInqXsize
(
gridID
)
>
1
)
cdoAbort
(
"Grid must be a zonal mean!"
);
gridsize
=
gridInqSize
(
gridID
);
nlev
=
zaxisInqSize
(
zaxisID
);
int
gridsize
=
gridInqSize
(
gridID
);
int
nlev
=
zaxisInqSize
(
zaxisID
);
vlistID2
=
vlistDuplicate
(
vlistID1
);
int
vlistID2
=
vlistDuplicate
(
vlistID1
);
taxisID1
=
vlistInqTaxis
(
vlistID1
);
taxisID2
=
taxisDuplicate
(
taxisID1
);
int
taxisID1
=
vlistInqTaxis
(
vlistID1
);
int
taxisID2
=
taxisDuplicate
(
taxisID1
);
vlistDefTaxis
(
vlistID2
,
taxisID2
);
vlistDefVarCode
(
vlistID2
,
0
,
272
);
...
...
@@ -163,14 +152,14 @@ void *Mastrfu(void *argument)
vlistDefVarUnits
(
vlistID2
,
0
,
"kg/s"
);
vlistDefVarDatatype
(
vlistID2
,
0
,
DATATYPE_FLT32
);
streamID2
=
streamOpenWrite
(
cdoStreamName
(
1
),
cdoFiletype
());
int
streamID2
=
streamOpenWrite
(
cdoStreamName
(
1
),
cdoFiletype
());
streamDefVlist
(
streamID2
,
vlistID2
);
array1
=
(
double
*
)
malloc
(
gridsize
*
nlev
*
sizeof
(
double
));
array2
=
(
double
*
)
malloc
(
gridsize
*
nlev
*
sizeof
(
double
));
double
*
array1
=
(
double
*
)
malloc
(
gridsize
*
nlev
*
sizeof
(
double
));
double
*
array2
=
(
double
*
)
malloc
(
gridsize
*
nlev
*
sizeof
(
double
));
tsID
=
0
;
int
tsID
=
0
;
while
(
(
nrecs
=
streamInqTimestep
(
streamID1
,
tsID
))
)
{
taxisCopyTimestep
(
taxisID2
,
taxisID1
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment