WSL/SLF GitLab Repository
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
snow-models
meteoio
Commits
8cdde5b0
Commit
8cdde5b0
authored
Sep 02, 2015
by
Mathias Bavay
Browse files
For consistency, the CNRM plugin now uses METEOPATH
parent
1ecb5269
Changes
1
Hide whitespace changes
Inline
Side-by-side
meteoio/plugins/CNRMIO.cc
View file @
8cdde5b0
...
...
@@ -45,12 +45,13 @@ namespace mio {
*
* @section cnrm_keywords Keywords
* This plugin uses the following keywords:
* - COORDSYS: coordinate system (see Coords); [Input] and [Output] section
* - COORDPARAM: extra coordinates parameters (see Coords); [Input] and [Output] section
* - COORDSYS: coordinate system (see Coords); [Input] and [Output] section
s
* - COORDPARAM: extra coordinates parameters (see Coords); [Input] and [Output] section
s
* - DEMFILE: The filename of the file containing the DEM; [Input] section
* - DEMVAR: The variable name of the DEM within the DEMFILE; [Input] section
* - METEOFILE: the NetCDF file which shall be used for the meteo parameter input/output; [Input] and [Output] section
* - GRID2DFILE: the NetCDF file which shall be used for gridded input/output; [Input] and [Output] section
* - METEOPATH: where to find the meteofiles as refered to here below; [Input] and [Output] sections
* - METEOFILE: the NetCDF file which shall be used for the meteo parameter input/output; [Input] and [Output] sections
* - GRID2DFILE: the NetCDF file which shall be used for gridded input/output; [Input] and [Output] sections
* - STRICTFORMAT: Whether the NetCDF file should be strictly compliant with the CNRM standard; Parameters not present
* in the specification will be omitted; [Input] and [Output] section
*
...
...
@@ -283,13 +284,15 @@ void CNRMIO::readStationData(const Date&, std::vector<StationData>& vecStation)
return
;
}
const
string
path
=
cfg
.
get
(
"METEOPATH"
,
"Input"
);
const
string
filename
=
cfg
.
get
(
"METEOFILE"
,
"Input"
);
const
string
file_and_path
=
path
+
"/"
+
filename
;
int
ncid
;
if
(
!
IOUtils
::
fileExists
(
file
name
))
throw
FileAccessException
(
file
name
,
AT
);
//prevent invalid filenames
ncpp
::
open_file
(
file
name
,
NC_NOWRITE
,
ncid
);
if
(
!
IOUtils
::
fileExists
(
file
_and_path
))
throw
FileAccessException
(
file
_and_path
,
AT
);
//prevent invalid filenames
ncpp
::
open_file
(
file
_and_path
,
NC_NOWRITE
,
ncid
);
readMetaData
(
ncid
,
vecMetaData
);
ncpp
::
close_file
(
file
name
,
ncid
);
ncpp
::
close_file
(
file
_and_path
,
ncid
);
vecStation
=
vecMetaData
;
}
...
...
@@ -345,11 +348,13 @@ void CNRMIO::readMetaData(const int& ncid, std::vector<StationData>& vecStation)
void
CNRMIO
::
readMeteoData
(
const
Date
&
dateStart
,
const
Date
&
dateEnd
,
std
::
vector
<
std
::
vector
<
MeteoData
>
>&
vecMeteo
,
const
size_t
&
)
{
vecMeteo
.
clear
();
const
string
path
=
cfg
.
get
(
"METEOPATH"
,
"Input"
);
const
string
filename
=
cfg
.
get
(
"METEOFILE"
,
"Input"
);
const
string
file_and_path
=
path
+
"/"
+
filename
;
int
ncid
;
if
(
!
IOUtils
::
fileExists
(
file
name
))
throw
FileAccessException
(
file
name
,
AT
);
//prevent invalid filenames
ncpp
::
open_file
(
file
name
,
NC_NOWRITE
,
ncid
);
if
(
!
IOUtils
::
fileExists
(
file
_and_path
))
throw
FileAccessException
(
file
_and_path
,
AT
);
//prevent invalid filenames
ncpp
::
open_file
(
file
_and_path
,
NC_NOWRITE
,
ncid
);
if
(
vecMetaData
.
empty
())
readMetaData
(
ncid
,
vecMetaData
);
...
...
@@ -366,7 +371,7 @@ void CNRMIO::readMeteoData(const Date& dateStart, const Date& dateEnd, std::vect
}
}
ncpp
::
close_file
(
file
name
,
ncid
);
ncpp
::
close_file
(
file
_and_path
,
ncid
);
}
void
CNRMIO
::
readData
(
const
int
&
ncid
,
const
size_t
&
index_start
,
const
std
::
vector
<
Date
>&
vec_date
,
...
...
@@ -633,13 +638,15 @@ void CNRMIO::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMete
if
(
number_of_stations
==
0
)
return
;
//Nothing to write
const
size_t
number_of_records
=
vecMeteo
[
0
].
size
();
const
string
path
=
cfg
.
get
(
"METEOPATH"
,
"Output"
);
const
string
filename
=
cfg
.
get
(
"METEOFILE"
,
"Output"
);
const
string
file_and_path
=
path
+
"/"
+
filename
;
int
ncid
,
did_time
,
vid_time
,
did_points
;
bool
create_time
=
false
,
create_points
=
false
,
create_locations
=
false
,
create_variables
=
false
;
const
bool
exists
=
IOUtils
::
fileExists
(
file
name
);
if
(
exists
)
remove
(
file
name
.
c_str
());
// NOTE: file is deleted if it exists
const
bool
exists
=
IOUtils
::
fileExists
(
file
_and_path
);
if
(
exists
)
remove
(
file
_and_path
.
c_str
());
// NOTE: file is deleted if it exists
double
*
dates
;
map
<
string
,
double
*>
map_data
;
// holds a pointer for every C array to be written
...
...
@@ -654,7 +661,7 @@ void CNRMIO::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMete
get_parameters
(
vecMeteo
,
map_param_name
,
map_data
,
dates
);
ncpp
::
create_file
(
file
name
,
NC_CLASSIC_MODEL
,
ncid
);
ncpp
::
create_file
(
file
_and_path
,
NC_CLASSIC_MODEL
,
ncid
);
create_time
=
create_points
=
create_locations
=
create_variables
=
true
;
if
(
create_time
)
create_time_dimension
(
ncid
,
did_time
,
vid_time
);
...
...
@@ -662,7 +669,7 @@ void CNRMIO::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMete
if
(
create_locations
)
create_meta_data
(
ncid
,
did_points
,
map_data
,
varid
);
if
(
create_variables
)
create_parameters
(
ncid
,
did_time
,
did_points
,
number_of_records
,
number_of_stations
,
map_param_name
,
map_data
,
varid
);
ncpp
::
end_definitions
(
file
name
,
ncid
);
ncpp
::
end_definitions
(
file
_and_path
,
ncid
);
copy_data
(
number_of_stations
,
number_of_records
,
vecMeteo
,
map_param_name
,
map_data
);
...
...
@@ -673,7 +680,7 @@ void CNRMIO::writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMete
delete
[]
it
->
second
;
}
ncpp
::
close_file
(
file
name
,
ncid
);
ncpp
::
close_file
(
file
_and_path
,
ncid
);
delete
[]
dates
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment