tpism_type_conversion.hh - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
HTML git clone git://src.adamsgaard.dk/pism
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
tpism_type_conversion.hh (1749B)
---
1 // Copyright (C) 2012, 2014, 2015, 2016 PISM Authors
2 //
3 // This file is part of PISM.
4 //
5 // PISM is free software; you can redistribute it and/or modify it under the
6 // terms of the GNU General Public License as published by the Free Software
7 // Foundation; either version 3 of the License, or (at your option) any later
8 // version.
9 //
10 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with PISM; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19
20 //! Convert PISM's IO types into NetCDF types and back. Note that NC_* may be
21 //! macros, so you need to include the appropriate NetCDF header first.
22 namespace pism {
23
24 static nc_type pism_type_to_nc_type(pism::IO_Type input) {
25 switch (input) {
26 case PISM_BYTE:
27 return NC_BYTE;
28 case PISM_CHAR:
29 return NC_CHAR;
30 case PISM_SHORT:
31 return NC_SHORT;
32 case PISM_INT:
33 return NC_INT;
34 case PISM_FLOAT:
35 return NC_FLOAT;
36 case PISM_DOUBLE:
37 return NC_DOUBLE;
38 default:
39 return NC_NAT;
40 }
41 }
42
43 static pism::IO_Type nc_type_to_pism_type(int input) {
44 switch (input) {
45 case NC_BYTE:
46 return PISM_BYTE;
47 case NC_CHAR:
48 case NC_STRING: // treat NC_CHAR and NC_STRING as equivalent
49 return PISM_CHAR;
50 case NC_SHORT:
51 return PISM_SHORT;
52 case NC_INT:
53 return PISM_INT;
54 case NC_FLOAT:
55 return PISM_FLOAT;
56 case NC_DOUBLE:
57 return PISM_DOUBLE;
58 default:
59 return PISM_NAT;
60 }
61 }
62
63 } // end of namespace pism