Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
libcdi
Commits
c8f2a7e7
Commit
c8f2a7e7
authored
7 years ago
by
Thomas Jahns
Browse files
Options
Downloads
Patches
Plain Diff
fixup: Extend CDI-PIO writing of data to float.
parent
11bfc103
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/deco2d_model.c
+37
-10
37 additions, 10 deletions
tests/deco2d_model.c
with
37 additions
and
10 deletions
tests/deco2d_model.c
+
37
−
10
View file @
c8f2a7e7
...
...
@@ -4,6 +4,7 @@
#include
<inttypes.h>
#include
<math.h>
#include
<stdbool.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<time.h>
...
...
@@ -78,11 +79,13 @@ modelRun(struct model_config setup, MPI_Comm comm)
Xt_idxlist
partDesc
;
Xt_redist
redist4gather
;
#endif
bool
useFloat
;
}
*
varDesc
;
int
gridID
,
taxisID
,
vlistID
,
tsID
,
tfID
=
0
;
enum
{
nmiss
=
0
};
double
*
levs
;
double
*
var
=
NULL
,
*
varslice
=
NULL
;
float
*
varsliceF
=
NULL
;
double
mscale
,
mrscale
;
time_t
current_time
;
int
vdate
=
19850101
,
vtime
=
120000
;
...
...
@@ -90,7 +93,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
char
*
filename
=
NULL
;
int
nlon
=
setup
.
nlon
,
nlat
=
setup
.
nlat
;
size_t
nVars
=
setup
.
nvars
>
0
?
(
size_t
)
setup
.
nvars
:
0
;
size_t
varslice_size
=
0
;
size_t
varslice_size
=
0
,
varsliceF_size
=
0
;
;
#if USE_MPI
int
comm_size
=
1
;
int
npart
[
2
],
rank_coord
[
2
];
...
...
@@ -261,6 +264,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
varDesc
[
varIdx
].
code
=
GRIB_USERDEF
+
(
int
)
varIdx
;
vlistDefVarCode
(
vlistID
,
varDesc
[
varIdx
].
id
,
varDesc
[
varIdx
].
code
);
vlistDefVarDatatype
(
vlistID
,
varDesc
[
varIdx
].
id
,
setup
.
datatype
);
varDesc
[
varIdx
].
useFloat
=
(
bool
)(
random
()
&
1
);
}
taxisID
=
taxisCreate
(
setup
.
taxistype
);
...
...
@@ -317,6 +321,20 @@ modelRun(struct model_config setup, MPI_Comm comm)
}
modelRegionCompute
(
varslice
,
(
int
)
varLevs
,
nlat
,
nlon
,
start
,
chunk
,
tsID
,
mscale
,
mrscale
);
bool
useFloat
=
varDesc
[
varIdx
].
useFloat
;
if
(
useFloat
)
{
if
(
varsliceF_size
<
chunkSize
)
{
varsliceF
=
(
float
*
)
Realloc
(
varsliceF
,
chunkSize
*
sizeof
(
varsliceF
[
0
]));
varsliceF_size
=
chunkSize
;
}
for
(
size_t
i
=
0
;
i
<
chunkSize
;
++
i
)
varslice
[
i
]
=
varsliceF
[
i
]
=
(
float
)
varslice
[
i
];
}
if
(
setup
.
flags
&
PIO_WRITE_CONFIG_CHECKSUM_FLAG
)
{
#if USE_MPI
...
...
@@ -356,12 +374,21 @@ modelRun(struct model_config setup, MPI_Comm comm)
blk_displ
[
k
]
=
(
int
)(
k
*
(
nblk
+
1
)
*
nproma
);
blk_lens
[
k
]
=
(
int
)
layerSize
;
}
streamWriteScatteredVarPart
(
streamID
,
varDesc
[
varIdx
].
id
,
varslice
,
(
int
)
varLevs
,
blk_lens
,
blk_displ
,
nmiss
,
varDesc
[
varIdx
].
partDesc
);
if
(
useFloat
)
streamWriteScatteredVarPartF
(
streamID
,
varDesc
[
varIdx
].
id
,
varsliceF
,
(
int
)
varLevs
,
blk_lens
,
blk_displ
,
nmiss
,
varDesc
[
varIdx
].
partDesc
);
else
streamWriteScatteredVarPart
(
streamID
,
varDesc
[
varIdx
].
id
,
varslice
,
(
int
)
varLevs
,
blk_lens
,
blk_displ
,
nmiss
,
varDesc
[
varIdx
].
partDesc
);
#else
streamWriteVar
(
streamID
,
varDesc
[
varIdx
].
id
,
var
,
nmiss
);
if
(
useFloat
)
streamWriteVarF
(
streamID
,
varDesc
[
varIdx
].
id
,
varsliceF
,
nmiss
);
else
streamWriteVar
(
streamID
,
varDesc
[
varIdx
].
id
,
varslice
,
nmiss
);
#endif
}
current_time
+=
86400
;
...
...
@@ -379,16 +406,16 @@ modelRun(struct model_config setup, MPI_Comm comm)
perror
(
"failed to open table file"
);
exit
(
EXIT_FAILURE
);
}
for
(
size_t
i
=
0
;
i
<
nVars
;
++
i
)
for
(
size_t
varIdx
=
0
;
varIdx
<
nVars
;
++
varIdx
)
{
uint32_t
cksum
;
int
code
;
cksum
=
memcrc_finish
(
&
varDesc
[
i
].
checksum_state
,
(
off_t
)((
varDesc
[
i
].
size
cksum
=
memcrc_finish
(
&
varDesc
[
varIdx
].
checksum_state
,
(
off_t
)((
varDesc
[
varIdx
].
size
*
sizeof
(
var
[
0
])
+
sizeof
(
int
)
*
2
)
*
(
size_t
)
setup
.
nts
));
code
=
vlistInqVarCode
(
vlistID
,
varDesc
[
i
].
id
);
code
=
vlistInqVarCode
(
vlistID
,
varDesc
[
varIdx
].
id
);
if
(
fprintf
(
tablefp
,
"%08lx %d
\n
"
,
(
unsigned
long
)
cksum
,
code
)
<
0
)
{
...
...
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