tpism_matlab.m - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
(HTM) git clone git://src.adamsgaard.dk/pism
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
tpism_matlab.m (2996B)
---
1 function pism_matlab()
2 % PISM_MATLAB Creates "from scratch" a boring dataset with the right format
3 % to use as a PISM bootstrapping file. Example use of Matlab for this purpose.
4 %
5 % Usage, including a minimal PISM call to bootstrap from this file:
6 % $ matlab
7 % >> pism_matlab % creates bar.nc
8 % >> exit
9 % $ pismr -i bar.nc -bootstrap -Mx 41 -My 41 -Mz 21 -Lz 4000 -Mbz 5 -Lbz 500 -y 1
10
11 % tested in MATLAB Version R2012b (8.0.0.783)
12
13 % set up the grid:
14 Lx = 1e6;
15 Ly = 1e6;
16 Mx = 51;
17 My = 71;
18 x = linspace(-Lx,Lx,Mx);
19 y = linspace(-Ly,Ly,My);
20
21 % create dummy fields
22 [xx,yy] = ndgrid(x,y); % meshgrid() generates wrong ordering
23 acab = zeros(Mx,My);
24 artm = zeros(Mx,My) + 273.15 + 10.0; % 10 degrees Celsius
25 topg = 1000.0 + 200.0 * (xx + yy) / max(Lx, Ly); % change "1000.0" to "0.0" to test
26 % flotation criterion, etc.
27 thk = 3000.0 * (1.0 - 3.0 * (xx.^2 + yy.^2) / Lx^2);
28 thk(thk < 0.0) = 0.0;
29
30 % create a file; NC_CLOBBER means "overwrite if exists"
31 ncid = netcdf.create('bar.nc', 'NC_CLOBBER');
32
33 % create dimensions:
34 x_id = netcdf.defDim(ncid, 'x', Mx);
35 y_id = netcdf.defDim(ncid, 'y', My);
36
37 % create coordinate variables:
38 x_var_id = netcdf.defVar(ncid, 'x', 'float', [x_id]);
39 y_var_id = netcdf.defVar(ncid, 'y', 'float', [y_id]);
40
41 % write attributes:
42 netcdf.putAtt(ncid, x_var_id, 'long_name', 'easting');
43 netcdf.putAtt(ncid, x_var_id, 'standard_name', 'projection_x_coordinate');
44 netcdf.putAtt(ncid, y_var_id, 'long_name', 'northing');
45 netcdf.putAtt(ncid, y_var_id, 'standard_name', 'projection_y_coordinate');
46
47 % create variables corresponding to spatial fields:
48 % dimension transpose is standard: "float thk(y, x)" in NetCDF file
49 topg_id = netcdf.defVar(ncid, 'topg', 'float', [x_id,y_id]);
50 thk_id = netcdf.defVar(ncid, 'thk', 'float', [x_id,y_id]);
51 acab_id = netcdf.defVar(ncid, 'climatic_mass_balance', 'float', [x_id,y_id]);
52 artm_id = netcdf.defVar(ncid, 'ice_surface_temp', 'float', [x_id,y_id]);
53
54 % write attributes:
55 netcdf.putAtt(ncid, topg_id, 'units', 'm');
56 netcdf.putAtt(ncid, topg_id, 'standard_name', 'bedrock_altitude');
57 netcdf.putAtt(ncid, thk_id, 'units', 'm');
58 netcdf.putAtt(ncid, thk_id, 'standard_name', 'land_ice_thickness');
59 netcdf.putAtt(ncid, acab_id, 'units', 'm year-1');
60 netcdf.putAtt(ncid, acab_id, 'standard_name', 'land_ice_surface_specific_mass_balance');
61 netcdf.putAtt(ncid, artm_id, 'units', 'K');
62
63 % done defining dimensions and variables:
64 netcdf.endDef(ncid);
65
66 % write coordinate variables:
67 netcdf.putVar(ncid, x_var_id, x);
68 netcdf.putVar(ncid, y_var_id, y);
69
70 % surface temperature:
71 netcdf.putVar(ncid, artm_id, artm);
72
73 % accumulation/ablation rate:
74 netcdf.putVar(ncid, acab_id, acab);
75
76 % bedrock elevation:
77 netcdf.putVar(ncid, topg_id, topg);
78
79 % ice thickness:
80 netcdf.putVar(ncid, thk_id, thk);
81
82 netcdf.close(ncid);
83
84 disp(' PISM-bootable NetCDF file "bar.nc" written')
85 disp(' for example, run:')
86 disp(' $ pismr -i bar.nc -bootstrap -Mx 41 -My 41 -Mz 21 -Lz 4000 -Mbz 5 -Lbz 500 -y 1')
87