forked from bishtgautam/matlab-script-for-clm-sparse-grid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCLM45SparseGridDriver_modified.m
48 lines (42 loc) · 1.93 KB
/
CLM45SparseGridDriver_modified.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% - Creates a CLM45 surface dataset and domain netcdf files in an
% unstrustured grid format for a list sites given by latitude/longitude.
%
% - The script uses already existing CLM45 surface datasets and create
% new dataset by finding nearest neighbor for each site.
%
% INPUT:
% fname = Configuration file name.
%
% EXAMPLE:
% # Download data
% mkdir clm-netcdf
% svn export https://svn-ccsm-inputdata.cgd.ucar.edu/trunk/inputdata/lnd/clm2/surfdata_map/surfdata_1.9x2.5_simyr2000_c141219.nc clm-netcdf/surfdata_1.9x2.5_simyr2000_c141219.nc
% svn export https://svn-ccsm-inputdata.cgd.ucar.edu/trunk/inputdata/share/domains/domain.clm/domain.lnd.fv1.9x2.5_USGS.110713.nc clm-netcdf/domain.lnd.fv1.9x2.5_USGS.110713.nc
%
% # Run matlab script
% CLM45SparseGridDriver('82x1_sparse_grid/82x1_sparse_grid.cfg')
%
% Gautam Bisht ([email protected])
% 05-28-2015
%
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function [fsurdat, fdomain] = CLM45SparseGridDriver(cfg_filename)
clc;
disp('1) Reading configuration file')
cfg = ReadConfigurationFile(cfg_filename);
disp('2) Reading latitude/longitude @ cell centroid')
[lat,lon] = ReadLatLon(cfg.site_latlon_filename);
disp('3) Computing latitude/longitude @ cell vertex')
[latv,lonv] = ComputeLatLonAtVertex(lat,lon, cfg.dlat, cfg.dlon);
disp('4) Creating CLM surface dataset')
fsurdat = CreateCLMUgridSurfdatForCLM45(lat, lon, ...
cfg.clm_gridded_surfdata_filename, ...
cfg.out_netcdf_dir, ...
cfg.clm_usrdat_name);
disp('5) Creating CLM domain')
fdomain = CreateCLMUgridDomainForCLM45(lat, lon, ...
latv, lonv, ...
cfg.clm_gridded_domain_filename, ...
cfg.out_netcdf_dir, ...
cfg.clm_usrdat_name);