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
39386d1d
Commit
39386d1d
authored
4 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
Apply patch from Julian Kunkel (support for ESDM URL).
parent
bce6b1c0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!7
Replaced gridDefDatatype()/gridInqDatatype() by cdiDefKeyInt()/cdiInqKeyInt()...
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cdf_int.c
+9
-18
9 additions, 18 deletions
src/cdf_int.c
src/stream.c
+33
-32
33 additions, 32 deletions
src/stream.c
with
42 additions
and
50 deletions
src/cdf_int.c
+
9
−
18
View file @
39386d1d
...
...
@@ -42,42 +42,33 @@ void cdf_create(const char *path, int cmode, int *ncidp)
int
cdf_open
(
const
char
*
path
,
int
omode
,
int
*
ncidp
)
{
int
status
=
0
;
bool
dapfile
=
false
;
#ifdef HAVE_LIBNC_DAP
if
(
strncmp
(
path
,
"http:"
,
5
)
==
0
||
strncmp
(
path
,
"https:"
,
6
)
==
0
)
dapfile
=
true
;
#endif
if
(
dapfile
)
if
(
strstr
(
path
,
":/"
))
// ESDM and DAP
{
status
=
nc_open
(
path
,
omode
,
ncidp
);
}
else
{
struct
stat
filestat
;
if
(
stat
(
path
,
&
filestat
)
!=
0
)
SysError
(
path
);
if
(
stat
(
path
,
&
filestat
)
!=
0
)
SysError
(
path
);
size_t
chunksizehint
=
0
;
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
chunksizehint
=
(
size_t
)
filestat
.
st_blksize
*
4
;
if
(
chunksizehint
>
(
size_t
)
filestat
.
st_size
)
chunksizehint
=
(
size_t
)
filestat
.
st_size
;
if
(
chunksizehint
>
(
size_t
)
filestat
.
st_size
)
chunksizehint
=
(
size_t
)
filestat
.
st_size
;
#endif
/*
if ( chunksizehint < ChunkSizeMin ) chunksizehint = ChunkSizeMin;
*/
if
(
cdiNcChunksizehint
!=
CDI_UNDEFID
)
chunksizehint
=
(
size_t
)
cdiNcChunksizehint
;
// if (chunksizehint < ChunkSizeMin) chunksizehint = ChunkSizeMin;
if
(
cdiNcChunksizehint
!=
CDI_UNDEFID
)
chunksizehint
=
(
size_t
)
cdiNcChunksizehint
;
/
*
FIXME: parallel part missing
*/
/
/
FIXME: parallel part missing
status
=
nc__open
(
path
,
omode
,
&
chunksizehint
,
ncidp
);
if
(
CDF_Debug
)
Message
(
"chunksizehint %zu"
,
chunksizehint
);
if
(
CDF_Debug
)
Message
(
"chunksizehint %zu"
,
chunksizehint
);
}
if
(
CDF_Debug
)
Message
(
"ncid=%d mode=%d file=%s"
,
*
ncidp
,
omode
,
path
);
if
(
CDF_Debug
)
Message
(
"ncid=%d mode=%d file=%s"
,
*
ncidp
,
omode
,
path
);
if
(
CDF_Debug
&&
status
!=
NC_NOERR
)
Message
(
"%s"
,
nc_strerror
(
status
));
if
(
CDF_Debug
&&
status
!=
NC_NOERR
)
Message
(
"%s"
,
nc_strerror
(
status
));
return
status
;
}
...
...
This diff is collapsed.
Click to expand it.
src/stream.c
+
33
−
32
View file @
39386d1d
...
...
@@ -71,6 +71,7 @@ int getByteorder(int byteswap)
default:
Error
(
"unhandled endianness"
);
}
return
byteorder
;
}
...
...
@@ -82,25 +83,25 @@ int cdiGetFiletype(const char *filename, int *byteorder)
int
version
;
long
recpos
;
int
fileID
=
fileOpen
(
filename
,
"r"
);
const
int
fileID
=
fileOpen
(
filename
,
"r"
);
if
(
fileID
==
CDI_UNDEFID
)
if
(
fileID
==
CDI_UNDEFID
)
{
if
(
str
ncmp
(
filename
,
"http:"
,
5
)
==
0
||
strncmp
(
filename
,
"https:"
,
6
)
==
0
)
return
CDI_FILETYPE_NC
;
if
(
str
str
(
filename
,
":/"
)
)
return
CDI_FILETYPE_NC
;
// support for NetCDF remote types and ESDM
else
return
CDI_ESYSTEM
;
}
else
if
(
fileID
==
-
2
)
return
CDI_ETMOF
;
else
if
(
fileID
==
-
2
)
return
CDI_ETMOF
;
char
buffer
[
8
];
if
(
fileRead
(
fileID
,
buffer
,
8
)
!=
8
)
if
(
fileRead
(
fileID
,
buffer
,
8
)
!=
8
)
{
struct
stat
buf
;
if
(
stat
(
filename
,
&
buf
)
==
0
)
if
(
stat
(
filename
,
&
buf
)
==
0
)
{
if
(
buf
.
st_size
==
0
)
return
CDI_EISEMPTY
;
if
(
buf
.
st_mode
&
S_IFDIR
)
return
CDI_EISDIR
;
if
(
buf
.
st_size
==
0
)
return
CDI_EISEMPTY
;
if
(
buf
.
st_mode
&
S_IFDIR
)
return
CDI_EISDIR
;
}
return
CDI_EUFTYPE
;
...
...
@@ -108,73 +109,73 @@ int cdiGetFiletype(const char *filename, int *byteorder)
fileRewind
(
fileID
);
if
(
memcmp
(
buffer
,
"GRIB"
,
4
)
==
0
)
if
(
memcmp
(
buffer
,
"GRIB"
,
4
)
==
0
)
{
version
=
buffer
[
7
];
if
(
version
<=
1
)
{
filetype
=
CDI_FILETYPE_GRB
;
if
(
CDI_Debug
)
Message
(
"found GRIB file = %s, version %d"
,
filename
,
version
);
if
(
CDI_Debug
)
Message
(
"found GRIB file = %s, version %d"
,
filename
,
version
);
}
else
if
(
version
==
2
)
else
if
(
version
==
2
)
{
filetype
=
CDI_FILETYPE_GRB2
;
if
(
CDI_Debug
)
Message
(
"found GRIB2 file = %s"
,
filename
);
if
(
CDI_Debug
)
Message
(
"found GRIB2 file = %s"
,
filename
);
}
}
else
if
(
memcmp
(
buffer
,
"CDF
\001
"
,
4
)
==
0
)
else
if
(
memcmp
(
buffer
,
"CDF
\001
"
,
4
)
==
0
)
{
filetype
=
CDI_FILETYPE_NC
;
if
(
CDI_Debug
)
Message
(
"found CDF1 file = %s"
,
filename
);
if
(
CDI_Debug
)
Message
(
"found CDF1 file = %s"
,
filename
);
}
else
if
(
memcmp
(
buffer
,
"CDF
\002
"
,
4
)
==
0
)
else
if
(
memcmp
(
buffer
,
"CDF
\002
"
,
4
)
==
0
)
{
filetype
=
CDI_FILETYPE_NC2
;
if
(
CDI_Debug
)
Message
(
"found CDF2 file = %s"
,
filename
);
if
(
CDI_Debug
)
Message
(
"found CDF2 file = %s"
,
filename
);
}
else
if
(
memcmp
(
buffer
,
"CDF
\005
"
,
4
)
==
0
)
else
if
(
memcmp
(
buffer
,
"CDF
\005
"
,
4
)
==
0
)
{
filetype
=
CDI_FILETYPE_NC5
;
if
(
CDI_Debug
)
Message
(
"found CDF5 file = %s"
,
filename
);
if
(
CDI_Debug
)
Message
(
"found CDF5 file = %s"
,
filename
);
}
else
if
(
memcmp
(
buffer
+
1
,
"HDF"
,
3
)
==
0
)
else
if
(
memcmp
(
buffer
+
1
,
"HDF"
,
3
)
==
0
)
{
filetype
=
CDI_FILETYPE_NC4
;
if
(
CDI_Debug
)
Message
(
"found HDF file = %s"
,
filename
);
if
(
CDI_Debug
)
Message
(
"found HDF file = %s"
,
filename
);
}
#ifdef HAVE_LIBSERVICE
else
if
(
srvCheckFiletype
(
fileID
,
&
swap
)
)
else
if
(
srvCheckFiletype
(
fileID
,
&
swap
))
{
filetype
=
CDI_FILETYPE_SRV
;
if
(
CDI_Debug
)
Message
(
"found SRV file = %s"
,
filename
);
if
(
CDI_Debug
)
Message
(
"found SRV file = %s"
,
filename
);
}
#endif
#ifdef HAVE_LIBEXTRA
else
if
(
extCheckFiletype
(
fileID
,
&
swap
)
)
else
if
(
extCheckFiletype
(
fileID
,
&
swap
))
{
filetype
=
CDI_FILETYPE_EXT
;
if
(
CDI_Debug
)
Message
(
"found EXT file = %s"
,
filename
);
if
(
CDI_Debug
)
Message
(
"found EXT file = %s"
,
filename
);
}
#endif
#ifdef HAVE_LIBIEG
else
if
(
iegCheckFiletype
(
fileID
,
&
swap
)
)
else
if
(
iegCheckFiletype
(
fileID
,
&
swap
))
{
filetype
=
CDI_FILETYPE_IEG
;
if
(
CDI_Debug
)
Message
(
"found IEG file = %s"
,
filename
);
if
(
CDI_Debug
)
Message
(
"found IEG file = %s"
,
filename
);
}
#endif
#ifdef HAVE_LIBGRIB
else
if
(
gribCheckSeek
(
fileID
,
&
recpos
,
&
version
)
==
0
)
else
if
(
gribCheckSeek
(
fileID
,
&
recpos
,
&
version
)
==
0
)
{
if
(
version
<=
1
)
if
(
version
<=
1
)
{
filetype
=
CDI_FILETYPE_GRB
;
if
(
CDI_Debug
)
Message
(
"found seeked GRIB file = %s"
,
filename
);
if
(
CDI_Debug
)
Message
(
"found seeked GRIB file = %s"
,
filename
);
}
else
if
(
version
==
2
)
else
if
(
version
==
2
)
{
filetype
=
CDI_FILETYPE_GRB2
;
if
(
CDI_Debug
)
Message
(
"found seeked GRIB2 file = %s"
,
filename
);
if
(
CDI_Debug
)
Message
(
"found seeked GRIB2 file = %s"
,
filename
);
}
}
#endif
...
...
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