Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
e94c87ee
Commit
e94c87ee
authored
Sep 18, 2012
by
Uwe Schulzweida
Browse files
added cdiReset()
parent
306658c4
Changes
5
Hide whitespace changes
Inline
Side-by-side
.gitattributes
View file @
e94c87ee
...
...
@@ -113,6 +113,7 @@ examples/cdi_write.c -text
examples/cdi_write_ens.c -text
examples/cdi_write_f.f -text
examples/cdi_write_f2003.f90 -text
examples/cdi_write_reset.c -text
examples/compf -text
examples/pio/Makefile.am -text
examples/pio/Makefile.in -text
...
...
examples/cdi_write_reset.c
0 → 100644
View file @
e94c87ee
#include
<stdio.h>
#include
"cdi.h"
#define nrun 30 // Number of runs
#define nlon 12 // Number of longitudes
#define nlat 6 // Number of latitudes
#define nlev 5 // Number of levels
#define nts 3 // Number of time steps
static
int
run
(
int
irun
)
{
int
gridID
,
zaxisID1
,
zaxisID2
,
taxisID
;
int
vlistID
,
varID1
,
varID2
,
streamID
,
tsID
;
int
i
,
nmiss
=
0
;
double
lons
[
nlon
]
=
{
0
,
30
,
60
,
90
,
120
,
150
,
180
,
210
,
240
,
270
,
300
,
330
};
double
lats
[
nlat
]
=
{
-
75
,
-
45
,
-
15
,
15
,
45
,
75
};
double
levs
[
nlev
]
=
{
101300
,
92500
,
85000
,
50000
,
20000
};
double
var1
[
nlon
*
nlat
];
double
var2
[
nlon
*
nlat
*
nlev
];
// Create a regular lon/lat grid
gridID
=
gridCreate
(
GRID_LONLAT
,
nlon
*
nlat
);
gridDefXsize
(
gridID
,
nlon
);
gridDefYsize
(
gridID
,
nlat
);
gridDefXvals
(
gridID
,
lons
);
gridDefYvals
(
gridID
,
lats
);
// Create a surface level Z-axis
zaxisID1
=
zaxisCreate
(
ZAXIS_SURFACE
,
1
);
// Create a pressure level Z-axis
zaxisID2
=
zaxisCreate
(
ZAXIS_PRESSURE
,
nlev
);
zaxisDefLevels
(
zaxisID2
,
levs
);
// Create a variable list
vlistID
=
vlistCreate
();
// Define the variables
varID1
=
vlistDefVar
(
vlistID
,
gridID
,
zaxisID1
,
TIME_VARIABLE
);
varID2
=
vlistDefVar
(
vlistID
,
gridID
,
zaxisID2
,
TIME_VARIABLE
);
// Define the variable names
vlistDefVarName
(
vlistID
,
varID1
,
"varname1"
);
vlistDefVarName
(
vlistID
,
varID2
,
"varname2"
);
// Create a Time axis
taxisID
=
taxisCreate
(
TAXIS_ABSOLUTE
);
// Assign the Time axis to the variable list
vlistDefTaxis
(
vlistID
,
taxisID
);
// Create a dataset in netCDF format
streamID
=
streamOpenWrite
(
"example.nc"
,
FILETYPE_NC
);
if
(
streamID
<
0
)
{
fprintf
(
stderr
,
"%s
\n
"
,
cdiStringError
(
streamID
));
return
(
1
);
}
// Assign the variable list to the dataset
streamDefVlist
(
streamID
,
vlistID
);
// Loop over the number of time steps
for
(
tsID
=
0
;
tsID
<
nts
;
tsID
++
)
{
// Set the verification date to 1985-01-01 + tsID
taxisDefVdate
(
taxisID
,
19850101
+
tsID
);
// Set the verification time to 12:00:00
taxisDefVtime
(
taxisID
,
120000
);
// Define the time step
streamDefTimestep
(
streamID
,
tsID
);
// Init var1 and var2
for
(
i
=
0
;
i
<
nlon
*
nlat
;
i
++
)
var1
[
i
]
=
1
.
1
;
for
(
i
=
0
;
i
<
nlon
*
nlat
*
nlev
;
i
++
)
var2
[
i
]
=
2
.
2
;
// Write var1 and var2
streamWriteVar
(
streamID
,
varID1
,
var1
,
nmiss
);
streamWriteVar
(
streamID
,
varID2
,
var2
,
nmiss
);
}
fprintf
(
stderr
,
"%d gridID=%d, zaxisID1=%d, vlistID=%d, streamID=%d
\n
"
,
irun
,
gridID
,
zaxisID1
,
vlistID
,
streamID
);
// Close the output stream
streamClose
(
streamID
);
// Destroy the object
/*
vlistDestroy(vlistID);
taxisDestroy(taxisID);
zaxisDestroy(zaxisID1);
zaxisDestroy(zaxisID2);
gridDestroy(gridID);
*/
return
0
;
}
int
main
(
void
)
{
int
irun
;
for
(
irun
=
0
;
irun
<
nrun
;
++
irun
)
{
run
(
irun
);
// cdiReset();
}
return
0
;
}
src/cdi.h
View file @
e94c87ee
...
...
@@ -226,6 +226,8 @@ void pioWriteTimestep ( int, int, int );
/* CDI control routines */
void
cdiReset
(
void
);
char
*
cdiStringError
(
int
cdiErrno
);
void
cdiDebug
(
int
debug
);
...
...
src/config.h.in
View file @
e94c87ee
...
...
@@ -189,11 +189,6 @@
/* Version number of package */
#undef VERSION
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
...
...
src/resource_handle.c
View file @
e94c87ee
...
...
@@ -116,7 +116,8 @@ void listInitPointer ( void )
/**************************************************************/
static
void
listDestroy
(
void
)
static
void
listDestroy
(
void
)
{
listElem_t
*
listElem
;
int
i
,
j
,
nnsp
;
...
...
@@ -187,7 +188,8 @@ void listInitialize ( void )
/**************************************************************/
static
void
listSizeExtend
()
static
void
listSizeExtend
()
{
int
newListSize
;
int
i
,
nsp
;
...
...
@@ -671,9 +673,18 @@ void reshListPrint ( char * filename )
pioNamespaceSetActive
(
temp
);
}
void
cdiReset
(
void
)
{
LIST_LOCK
();
listDestroy
();
listNew
();
listInitPointer
();
LIST_UNLOCK
();
}
/*
* Local Variables:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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