00001 /* ***************************************************** */ 00002 /* read_mask Read a mask file. */ 00003 /* read_mask.c */ 00004 /* ***************************************************** */ 00005 /* Author: Christian Page, CERFACS, Toulouse, France. */ 00006 /* ***************************************************** */ 00007 /* Date of creation: feb 2009 */ 00008 /* Last date of modification: feb 2009 */ 00009 /* ***************************************************** */ 00010 /* Original version: 1.0 */ 00011 /* Current revision: */ 00012 /* ***************************************************** */ 00013 /* Revisions */ 00014 /* ***************************************************** */ 00019 /* LICENSE BEGIN 00020 00021 Copyright Cerfacs (Christian Page) (2015) 00022 00023 christian.page@cerfacs.fr 00024 00025 This software is a computer program whose purpose is to downscale climate 00026 scenarios using a statistical methodology based on weather regimes. 00027 00028 This software is governed by the CeCILL license under French law and 00029 abiding by the rules of distribution of free software. You can use, 00030 modify and/ or redistribute the software under the terms of the CeCILL 00031 license as circulated by CEA, CNRS and INRIA at the following URL 00032 "http://www.cecill.info". 00033 00034 As a counterpart to the access to the source code and rights to copy, 00035 modify and redistribute granted by the license, users are provided only 00036 with a limited warranty and the software's author, the holder of the 00037 economic rights, and the successive licensors have only limited 00038 liability. 00039 00040 In this respect, the user's attention is drawn to the risks associated 00041 with loading, using, modifying and/or developing or reproducing the 00042 software by the user in light of its specific status of free software, 00043 that may mean that it is complicated to manipulate, and that also 00044 therefore means that it is reserved for developers and experienced 00045 professionals having in-depth computer knowledge. Users are therefore 00046 encouraged to load and test the software's suitability as regards their 00047 requirements in conditions enabling the security of their systems and/or 00048 data to be ensured and, more generally, to use and operate it in the 00049 same conditions as regards security. 00050 00051 The fact that you are presently reading this means that you have had 00052 knowledge of the CeCILL license and that you accept its terms. 00053 00054 LICENSE END */ 00055 00056 00057 00058 00059 00060 00061 00062 #include <dsclim.h> 00063 #include <shapefil.h> 00064 00066 int 00067 read_mask(mask_struct *mask) { 00074 int istat; 00075 00076 if ( !strcmp(get_filename_ext(mask->filename), "nc")) { 00077 00078 /* Read latitudes and longitudes */ 00079 istat = read_netcdf_latlon(&(mask->lon), &(mask->lat), &(mask->nlon), &(mask->nlat), mask->dimcoords, mask->coords, mask->proj, 00080 mask->lonname, mask->latname, mask->dimxname, mask->dimyname, mask->filename); 00081 if (istat < 0) { 00082 (void) fprintf(stdout, "%s: ERROR reading mask file.\n", __FILE__); 00083 return istat; 00084 } 00085 00086 /* Read mask */ 00087 istat = read_netcdf_var_2d(&(mask->field), (info_field_struct *) NULL, (proj_struct *) NULL, mask->filename, mask->maskname, 00088 mask->dimxname, mask->dimyname, &(mask->nlon), &(mask->nlat), FALSE); 00089 if (istat < 0) { 00090 (void) fprintf(stdout, "%s: ERROR reading mask file.\n", __FILE__); 00091 return istat; 00092 } 00093 00094 } 00095 else if ( !strcmp(get_filename_ext(mask->filename), ".shp")) { 00096 00097 00098 00099 } 00100 00101 (void) fprintf(stdout, "%s: mask file read successfully.\n", __FILE__); 00102 00103 /* Return status */ 00104 return 0; 00105 }