Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LEFEBVREJP email
radix
Commits
05630fbd
Commit
05630fbd
authored
Oct 29, 2018
by
Purves, Murray
Browse files
WIP radixsnd2arl: Writing full index header;
parent
eb0630bb
Pipeline
#16759
failed with stages
in 9 minutes and 11 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
radixio/arldatastream.cc
View file @
05630fbd
...
...
@@ -190,17 +190,45 @@ bool ARLDataStream::write_index_header(const ARLRecordHeader& rheader,
radix_line
(
" nz = "
<<
iheader
.
nz
);
radix_line
(
" Size of each record = "
<<
p
->
recordSize
);
char
indexHeader
[
108
];
sprintf
(
indexHeader
,
size_t
MAX_HEADER_LENGTH
=
10000
;
char
indexHeaderMain
[
108
],
indexHeaderVars
[
MAX_HEADER_LENGTH
];
int
pos
=
0
;
// Write the variable description part of the header
for
(
size_t
level
=
0
;
level
<
iheader
.
nz
;
++
level
)
{
pos
+=
sprintf
(
indexHeaderVars
+
pos
,
"%6.2f"
,
iheader
.
levels
[
level
]);
pos
+=
sprintf
(
indexHeaderVars
+
pos
,
"%2d"
,
iheader
.
nVarsAtLevels
[
level
]);
for
(
size_t
var
=
0
;
var
<
iheader
.
nVarsAtLevels
[
level
];
++
var
)
{
if
(
level
==
0
)
{
pos
+=
sprintf
(
indexHeaderVars
+
pos
,
"%4s"
,
iheader
.
surfaceVarNames
[
var
].
c_str
());
}
else
{
pos
+=
sprintf
(
indexHeaderVars
+
pos
,
"%4s"
,
iheader
.
varNames
[
var
].
c_str
());
}
pos
+=
sprintf
(
indexHeaderVars
+
pos
,
"%3d "
,
iheader
.
checkSums
[
var
]);
}
}
// Construct the main part of the header (inc. size calculation)
int
headerLength
=
108
+
pos
;
sprintf
(
indexHeaderMain
,
"%4s%3d%2d%7.2f%7.2f%7.2f%7.2f%7.2f%7.2f%7.2f%7.2f%7.2f%7.2f%7.2f%7."
"2f%3d%3d%3d%2d%4d"
,
iheader
.
model_id
.
c_str
(),
iheader
.
icx
,
iheader
.
mn
,
iheader
.
pole_lat
,
iheader
.
pole_lon
,
iheader
.
ref_lat
,
iheader
.
ref_lon
,
iheader
.
size
,
iheader
.
orient
,
iheader
.
tang_lat
,
iheader
.
sync_xp
,
iheader
.
sync_yp
,
iheader
.
sync_lat
,
iheader
.
sync_lon
,
iheader
.
dummy
,
iheader
.
nx
,
iheader
.
ny
,
iheader
.
nz
,
iheader
.
z_flag
,
i
header
.
len
h
);
iheader
.
ny
,
iheader
.
nz
,
iheader
.
z_flag
,
header
Lengt
h
);
p
->
stream
->
writeString
(
std
::
string
(
indexHeader
),
108
);
// Write the two elements of the header
p
->
stream
->
writeString
(
std
::
string
(
indexHeaderMain
),
108
);
p
->
stream
->
writeString
(
std
::
string
(
indexHeaderVars
),
pos
);
// Skip enough bytes to get to the next index header
int
bytesToSkip
=
roundUpInt
(
p
->
stream
->
bytesWritten
(),
p
->
recordSize
)
-
...
...
@@ -210,7 +238,7 @@ bool ARLDataStream::write_index_header(const ARLRecordHeader& rheader,
p
->
stream
->
writeString
(
""
,
bytesToSkip
);
radix_line
(
" header as string:
\n
"
<<
indexHeader
);
radix_line
(
" header as string:
\n
"
<<
indexHeader
Vars
);
result
=
true
;
return
result
;
...
...
radixio/arldatastream.hh
View file @
05630fbd
...
...
@@ -109,6 +109,12 @@ struct RADIX_PUBLIC ARLIndexHeader
int
nz
;
int
z_flag
;
int
lenh
;
std
::
vector
<
float
>
levels
;
std
::
vector
<
int
>
nVarsAtLevels
;
std
::
vector
<
std
::
string
>
surfaceVarNames
;
std
::
vector
<
std
::
string
>
varNames
;
std
::
vector
<
int
>
checkSums
;
bool
prime
;
bool
latlon
;
bool
gbldat
;
...
...
radixio/examples/radixsnd2arl.cc
View file @
05630fbd
...
...
@@ -165,8 +165,8 @@ int main(int argc, char **argv)
std
::
string
inputCsvPath
=
commandLine
.
get
<
std
::
string
>
(
"i"
);
std
::
string
outputArlPath
=
commandLine
.
get
<
std
::
string
>
(
"o"
,
inputCsvPath
+
".bin"
);
float
extent
=
commandLine
.
get
<
in
t
>
(
"e"
);
float
resolution
=
commandLine
.
get
<
in
t
>
(
"r"
);
float
extent
=
commandLine
.
get
<
floa
t
>
(
"e"
);
float
resolution
=
commandLine
.
get
<
floa
t
>
(
"r"
);
float
centreLat
=
commandLine
.
get
<
float
>
(
"clat"
);
float
centreLon
=
commandLine
.
get
<
float
>
(
"clon"
);
int
numberTimesteps
=
commandLine
.
get
<
int
>
(
"n"
,
1
);
...
...
@@ -404,27 +404,32 @@ int main(int argc, char **argv)
thisRecordHeader
.
prec
=
0.
f
;
thisRecordHeader
.
var1
=
0.
f
;
ARLIndexHeader
thisIndexHeader
;
thisIndexHeader
.
model_id
=
"NFDB"
;
thisIndexHeader
.
icx
=
0
;
thisIndexHeader
.
mn
=
0
;
thisIndexHeader
.
pole_lat
=
centreLat
;
thisIndexHeader
.
pole_lon
=
centreLon
;
thisIndexHeader
.
ref_lat
=
centreLat
;
thisIndexHeader
.
ref_lon
=
centreLon
;
thisIndexHeader
.
size
=
000.
f
;
thisIndexHeader
.
orient
=
0.
f
;
thisIndexHeader
.
tang_lat
=
centreLat
;
thisIndexHeader
.
sync_xp
=
(
numberGridCells
+
1
)
/
2
;
thisIndexHeader
.
sync_yp
=
(
numberGridCells
+
1
)
/
2
;
thisIndexHeader
.
sync_lat
=
centreLat
;
thisIndexHeader
.
sync_lon
=
centreLon
;
thisIndexHeader
.
dummy
=
0.
f
;
thisIndexHeader
.
nx
=
numberGridCells
;
thisIndexHeader
.
ny
=
numberGridCells
;
thisIndexHeader
.
nz
=
inputPressures
.
size
();
thisIndexHeader
.
z_flag
=
2
;
thisIndexHeader
.
lenh
=
inputPressures
.
size
()
*
numberGridCells
*
numberGridCells
;
thisIndexHeader
.
model_id
=
"NFDB"
;
thisIndexHeader
.
icx
=
0
;
thisIndexHeader
.
mn
=
0
;
thisIndexHeader
.
pole_lat
=
centreLat
;
thisIndexHeader
.
pole_lon
=
centreLon
;
thisIndexHeader
.
ref_lat
=
centreLat
;
thisIndexHeader
.
ref_lon
=
centreLon
;
thisIndexHeader
.
size
=
000.
f
;
thisIndexHeader
.
orient
=
0.
f
;
thisIndexHeader
.
tang_lat
=
centreLat
;
thisIndexHeader
.
sync_xp
=
(
numberGridCells
+
1
)
/
2
;
thisIndexHeader
.
sync_yp
=
(
numberGridCells
+
1
)
/
2
;
thisIndexHeader
.
sync_lat
=
centreLat
;
thisIndexHeader
.
sync_lon
=
centreLon
;
thisIndexHeader
.
dummy
=
0.
f
;
thisIndexHeader
.
nx
=
numberGridCells
;
thisIndexHeader
.
ny
=
numberGridCells
;
thisIndexHeader
.
nz
=
inputPressures
.
size
();
thisIndexHeader
.
z_flag
=
2
;
thisIndexHeader
.
lenh
=
numberGridCells
*
numberGridCells
;
thisIndexHeader
.
levels
=
inputPressures
;
thisIndexHeader
.
nVarsAtLevels
=
std
::
vector
<
int
>
(
inputPressures
.
size
(),
5
);
thisIndexHeader
.
surfaceVarNames
=
{
"PRSS"
,
"TEMP"
,
"RELH"
,
"UWND"
,
"VWND"
};
thisIndexHeader
.
varNames
=
{
"PRES"
,
"TEMP"
,
"RELH"
,
"UWND"
,
"VWND"
};
thisIndexHeader
.
checkSums
=
std
::
vector
<
int
>
(
5
,
0
);
// Write the headers
outputStream
.
write_record_header
(
thisRecordHeader
);
outputStream
.
write_index_header
(
thisRecordHeader
,
thisIndexHeader
);
...
...
@@ -438,7 +443,14 @@ int main(int argc, char **argv)
// Write pressure variables
{
thisRecordHeader
.
kvar
=
"PRSS"
;
if
(
level
==
0
)
{
thisRecordHeader
.
kvar
=
"PRSS"
;
}
else
{
thisRecordHeader
.
kvar
=
"PRES"
;
}
thisRecordHeader
.
var1
=
inputPressures
[
level
];
std
::
vector
<
std
::
vector
<
float
>>
thisData
(
numberGridCells
,
...
...
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