io.h

Go to the documentation of this file.
00001 
00005 /* LICENSE BEGIN
00006 
00007 Copyright Cerfacs (Christian Page) (2015)
00008 
00009 christian.page@cerfacs.fr
00010 
00011 This software is a computer program whose purpose is to downscale climate
00012 scenarios using a statistical methodology based on weather regimes.
00013 
00014 This software is governed by the CeCILL license under French law and
00015 abiding by the rules of distribution of free software. You can use, 
00016 modify and/ or redistribute the software under the terms of the CeCILL
00017 license as circulated by CEA, CNRS and INRIA at the following URL
00018 "http://www.cecill.info". 
00019 
00020 As a counterpart to the access to the source code and rights to copy,
00021 modify and redistribute granted by the license, users are provided only
00022 with a limited warranty and the software's author, the holder of the
00023 economic rights, and the successive licensors have only limited
00024 liability. 
00025 
00026 In this respect, the user's attention is drawn to the risks associated
00027 with loading, using, modifying and/or developing or reproducing the
00028 software by the user in light of its specific status of free software,
00029 that may mean that it is complicated to manipulate, and that also
00030 therefore means that it is reserved for developers and experienced
00031 professionals having in-depth computer knowledge. Users are therefore
00032 encouraged to load and test the software's suitability as regards their
00033 requirements in conditions enabling the security of their systems and/or 
00034 data to be ensured and, more generally, to use and operate it in the 
00035 same conditions as regards security. 
00036 
00037 The fact that you are presently reading this means that you have had
00038 knowledge of the CeCILL license and that you accept its terms.
00039 
00040 LICENSE END */
00041 
00042 
00043 
00044 
00045 
00046 
00047 #ifndef IO_H
00048 #define IO_H
00049 
00050 #ifdef HAVE_CONFIG_H
00051 #include <config.h>
00052 #endif
00053 
00055 #define _GNU_SOURCE
00056 
00057 #ifdef HAVE_STDLIB_H
00058 #include <stdlib.h>
00059 #endif
00060 #ifdef HAVE_SYS_TYPES_H
00061 #include <sys/types.h>
00062 #endif
00063 #ifdef HAVE_SYS_STAT_H
00064 #include <sys/stat.h>
00065 #endif
00066 #ifdef HAVE_FCNTL_H
00067 #include <fcntl.h>
00068 #endif
00069 #ifdef HAVE_SIGNAL_H
00070 #include <signal.h>
00071 #endif
00072 #ifdef HAVE_TIME_H
00073 #include <time.h>
00074 #endif
00075 #ifdef HAVE_UNISTD_H
00076 #include <unistd.h>
00077 #endif
00078 #ifdef HAVE_STRING_H
00079 #include <string.h>
00080 #endif
00081 #ifdef HAVE_STDIO_H
00082 #include <stdio.h>
00083 #endif
00084 #ifdef HAVE_SYS_MMAN_H
00085 #include <sys/mman.h>
00086 #endif
00087 #ifdef HAVE_LIBGEN_H
00088 #include <libgen.h>
00089 #endif
00090 
00092 #define TRUE 1
00093 
00094 #define FALSE 0
00095 
00097 #define MAXPATH 5000
00098 
00100 typedef struct {
00101   char *title; 
00102   char *title_french; 
00103   char *summary; 
00104   char *summary_french; 
00105   char *keywords; 
00106   char *processor; 
00107   char *software; 
00108   char *description; 
00109   char *institution; 
00110   char *creator_email; 
00111   char *creator_url; 
00112   char *creator_name; 
00113   char *version; 
00114   char *scenario; 
00115   char *scenario_co2; 
00116   char *model; 
00117   char *institution_model; 
00118   char *country; 
00119   char *member; 
00120   char *downscaling_forcing; 
00121   char *timestep; 
00122   char *contact_email; 
00123   char *contact_name; 
00124   char *other_contact_email; 
00125   char *other_contact_name; 
00126 } info_struct;
00127 
00129 typedef struct {
00130   double fillvalue; 
00131   char *coordinates; 
00132   char *grid_mapping; 
00133   char *units; 
00134   char *height; 
00135   char *long_name; 
00136 } info_field_struct;
00137 
00139 typedef struct {
00140   char *coords; 
00141   char *eof_coords; 
00142   char *name; 
00143   char *grid_mapping_name; 
00144   double latin1; 
00145   double latin2; 
00146   double lonc; 
00147   double lat0; 
00148   double false_easting; 
00149   double false_northing; 
00150   double latpole; 
00151   double lonpole; 
00152 } proj_struct;
00153 
00155 typedef struct {
00156   int *year; 
00157   int *month; 
00158   int *day; 
00159   int *hour; 
00160   int *minutes; 
00161   double *seconds; 
00162 } time_vect_struct;
00163 
00164 /* NetCDF-related includes */
00165 #include <zlib.h>
00166 #include <hdf5.h>
00167 #include <netcdf.h>
00168 
00169 #ifdef HAVE_UDUNITS2
00170 #include <udunits.h>
00171 #endif
00172 
00173 /* Dependent local includes. */
00174 #include <misc.h>
00175 #include <utils.h>
00176 
00177 /* Prototypes */
00178 int read_netcdf_dims_3d(double **lon, double **lat, double **timeval, char **cal_type, char **time_units,
00179                         int *nlon, int *nlat, int *ntime, info_struct *info, char *coords, char *gridname,
00180                         char *lonname, char *latname, char *dimxname, char *dimyname, char *timename, char *filename);
00181 int read_netcdf_latlon(double **lon, double **lat, int *nlon, int *nlat, char *dimcoords, char *coords, char *gridname,
00182                        char *lonname, char *latname, char *dimxname, char *dimyname, char *filename);
00183 int read_netcdf_xy(double **y, double **x, int *nx, int *ny, char *xname, char *yname, char *dimxname, char *dimyname, char *filename);
00184 int read_netcdf_dims_eof(double **lon, double **lat, int *nlon, int *nlat, int *neof, char *coords,
00185                          char *lonname, char *latname, char *dimxname, char *dimyname, char *eofname, char *filename);
00186 int read_netcdf_var_3d(double **buf, info_field_struct *info_field, proj_struct *proj, char *filename, char *varname,
00187                        char *dimxname, char *dimyname, char *timename, int *nlon, int *nlat, int *ntime, int outinfo);
00188 int read_netcdf_var_3d_2d(double **buf, info_field_struct *info_field, proj_struct *proj, char *filename, char *varname,
00189                           char *dimxname, char *dimyname, char *timename, int t, int *nlon, int *nlat, int *ntime, int outinfo);
00190 int read_netcdf_var_2d(double **buf, info_field_struct *info_field, proj_struct *proj, char *filename, char *varname,
00191                        char *dimxname, char *dimyname, int *nlon, int *nlat, int outinfo);
00192 int read_netcdf_var_1d(double **buf, info_field_struct *info_field, char *filename, char *varname,
00193                        char *dimname, int *ndim, int outinfo);
00194 int read_netcdf_var_generic_val(double *buf, info_field_struct *info_field, char *filename, char *varname, int index);
00195 int write_netcdf_var_3d(double *buf, double fillvalue, char *filename,
00196                         char *varname, char *gridname, char *lonname, char *latname, char *timename,
00197                         int format, int compression_level, int nlon, int nlat, int ntime, int outinfo);
00198 int write_netcdf_var_3d_2d(double *buf, double *timein, double fillvalue, char *filename,
00199                            char *varname, char *longname, char *units, char *height,
00200                            char *gridname, char *lonname, char *latname, char *timename,
00201                            int t, int newfile, int format, int compression_level, int nlon, int nlat, int ntime, int outinfo);
00202 int write_netcdf_dims_3d(double *lon, double *lat, double *x, double *y, double *alt, double *timein, char *cal_type, char *time_units,
00203                          int nlon, int nlat, int ntime, char *timestep, char *gridname, char *coords,
00204                          char *grid_mapping_name, double latin1, double latin2,
00205                          double lonc, double lat0, double false_easting, double false_northing,
00206                          double lonpole, double latpole,
00207                          char *lonname, char *latname, char *timename,
00208                          char *filename, int outinfo);
00209 int create_netcdf(char *title, char *title_french, char *summary, char *summary_french,
00210                   char *keywords, char *processor, char *software, char *description, char *institution,
00211                   char *creator_email, char *creator_url, char *creator_name,
00212                   char *version, char *scenario, char *scenario_co2, char *model,
00213                   char *institution_model, char *country, char *member, char *downscaling_forcing,
00214                   char *contact_email, char *contact_name, char *other_contact_email, char *other_contact_name,
00215                   char *filename, int outinfo, int format, int compression);
00216 int get_time_attributes(char **time_units, char **cal_type, char *filename, char *varname);
00217 int get_attribute_str(char **var, int ncinid, int varid, char *attrname);
00218 int get_time_info(time_vect_struct *time_s, double **timeval, char **time_units, char **cal_type, int *ntime, char *filename,
00219                   char *varname, int outinfo);
00220 int compute_time_info(time_vect_struct *time_s, double *timeval, char *time_units, char *cal_type, int ntime);
00221 void handle_netcdf_error(int status, char *srcfilename, int lineno);
00222 
00223 #endif

Generated on 12 May 2016 for DSCLIM by  doxygen 1.6.1