source: XIOS/dev/dev_cmip6_omp/extern/src_netcdf4/ncio.c @ 1606

Last change on this file since 1606 was 409, checked in by ymipsl, 11 years ago

Add improved nectdf internal library src

YM

  • Property svn:eol-style set to native
File size: 3.6 KB
Line 
1/*
2 *      Copyright 1996, University Corporation for Atmospheric Research
3 *      See netcdf/COPYRIGHT file for copying and redistribution conditions.
4 */
5
6#include <config.h>
7#include <stdlib.h>
8
9#include "netcdf.h"
10#include "ncio.h"
11#include "fbits.h"
12
13/* With the advent of diskless io, we need to provide
14   for multiple ncio packages at the same time,
15   so we have multiple versions of ncio_create.
16*/
17
18/* Define known ncio packages */
19extern int posixio_create(const char*,int,size_t,off_t,size_t,size_t*,ncio**,void** const);
20extern int posixio_open(const char*,int,off_t,size_t,size_t*,ncio**,void** const);
21
22#ifdef USE_FFIO
23extern int ffio_create(const char*,int,size_t,off_t,size_t,size_t*,ncio**,void** const);
24extern int ffio_open(const char*,int,off_t,size_t,size_t*,ncio**,void** const);
25#endif
26
27#ifdef USE_DISKLESS
28#  ifdef USE_MMAP
29     extern int mmapio_create(const char*,int,size_t,off_t,size_t,size_t*,ncio**,void** const);
30     extern int mmapio_open(const char*,int,off_t,size_t,size_t*,ncio**,void** const);
31#  endif
32     extern int memio_create(const char*,int,size_t,off_t,size_t,size_t*,ncio**,void** const);
33     extern int memio_open(const char*,int,off_t,size_t,size_t*,ncio**,void** const);
34#endif
35
36int
37ncio_create(const char *path, int ioflags, size_t initialsz,
38                       off_t igeto, size_t igetsz, size_t *sizehintp,
39                       ncio** iopp, void** const mempp)
40{
41#ifdef USE_DISKLESS
42    if(fIsSet(ioflags,NC_DISKLESS)) {
43#  ifdef USE_MMAP
44      if(fIsSet(ioflags,NC_MMAP))
45        return mmapio_create(path,ioflags,initialsz,igeto,igetsz,sizehintp,iopp,mempp);
46      else
47#  endif /*USE_MMAP*/
48        return memio_create(path,ioflags,initialsz,igeto,igetsz,sizehintp,iopp,mempp);
49    }
50#endif
51
52#ifdef USE_FFIO
53    return ffio_create(path,ioflags,initialsz,igeto,igetsz,sizehintp,iopp,mempp);
54#else
55    return posixio_create(path,ioflags,initialsz,igeto,igetsz,sizehintp,iopp,mempp);
56#endif
57}
58
59int
60ncio_open(const char *path, int ioflags,
61                     off_t igeto, size_t igetsz, size_t *sizehintp,
62                     ncio** iopp, void** const mempp)
63{
64    /* Diskless open has the following constraints:
65       1. file must be classic version 1 or 2
66     */
67#ifdef USE_DISKLESS
68    if(fIsSet(ioflags,NC_DISKLESS)) {
69#  ifdef USE_MMAP
70      if(fIsSet(ioflags,NC_MMAP))
71        return mmapio_open(path,ioflags,igeto,igetsz,sizehintp,iopp,mempp);
72      else
73#  endif /*USE_MMAP*/
74        return memio_open(path,ioflags,igeto,igetsz,sizehintp,iopp,mempp);
75    }
76#endif
77#ifdef USE_FFIO
78    return ffio_open(path,ioflags,igeto,igetsz,sizehintp,iopp,mempp);
79#else
80    return posixio_open(path,ioflags,igeto,igetsz,sizehintp,iopp,mempp);
81#endif
82}
83
84/**************************************************/
85/* wrapper functions for the ncio dispatch table */
86
87int
88ncio_rel(ncio *const nciop, off_t offset, int rflags)
89{
90    return nciop->rel(nciop,offset,rflags);
91}
92
93int
94ncio_get(ncio *const nciop, off_t offset, size_t extent,
95                        int rflags, void **const vpp)
96{
97    return nciop->get(nciop,offset,extent,rflags,vpp);
98}
99
100int
101ncio_move(ncio *const nciop, off_t to, off_t from, size_t nbytes, int rflags)
102{
103    return nciop->move(nciop,to,from,nbytes,rflags);
104}
105
106int
107ncio_sync(ncio *const nciop)
108{
109    return nciop->sync(nciop);
110}
111
112int
113ncio_filesize(ncio *nciop, off_t *filesizep)
114{
115    return nciop->filesize(nciop,filesizep);
116}
117
118int
119ncio_pad_length(ncio* nciop, off_t length)
120{
121    return nciop->pad_length(nciop,length);
122}
123
124int
125ncio_close(ncio *nciop, int doUnlink)
126{
127    /* close and release all resources associated
128       with nciop, including nciop
129    */
130    int status = nciop->close(nciop,doUnlink);
131    return status;
132}
Note: See TracBrowser for help on using the repository browser.