source: Roms_tools/Preprocessing_tools/create_forcing.m @ 1

Last change on this file since 1 was 1, checked in by cholod, 13 years ago

import Roms_Agrif

File size: 6.3 KB
Line 
1function  create_forcing(frcname,grdname,title,smst,...
2                         shft,swft,srft,sstt,ssst,smsc,...
3                         shfc,swfc,srfc,sstc,sssc)
4%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5%
6%       Create an empty netcdf forcing file
7%       frcname: name of the forcing file
8%       grdname: name of the grid file
9%       title: title in the netcdf file 
10%
11%  Further Information: 
12%  http://www.brest.ird.fr/Roms_tools/
13
14%  This file is part of ROMSTOOLS
15%
16%  ROMSTOOLS is free software; you can redistribute it and/or modify
17%  it under the terms of the GNU General Public License as published
18%  by the Free Software Foundation; either version 2 of the License,
19%  or (at your option) any later version.
20%
21%  ROMSTOOLS is distributed in the hope that it will be useful, but
22%  WITHOUT ANY WARRANTY; without even the implied warranty of
23%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24%  GNU General Public License for more details.
25%
26%  You should have received a copy of the GNU General Public License
27%  along with this program; if not, write to the Free Software
28%  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29%  MA  02111-1307  USA
30%
31%  Copyright (c) 2001-2006 by Pierrick Penven
32%  e-mail:Pierrick.Penven@ird.fr 
33%
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35nc=netcdf(grdname);
36L=length(nc('xi_psi'));
37M=length(nc('eta_psi'));
38result=close(nc);
39Lp=L+1;
40Mp=M+1;
41
42nw = netcdf(frcname, 'clobber');
43result = redef(nw);
44
45%
46%  Create dimensions
47%
48
49nw('xi_u') = L;
50nw('eta_u') = Mp;
51nw('xi_v') = Lp;
52nw('eta_v') = M;
53nw('xi_rho') = Lp;
54nw('eta_rho') = Mp;
55nw('xi_psi') = L;
56nw('eta_psi') = M;
57nw('sms_time') = length(smst);
58nw('shf_time') = length(shft);
59nw('swf_time') = length(swft);
60nw('sst_time') = length(sstt);
61nw('srf_time') = length(srft);
62nw('sss_time') = length(ssst);
63%
64%  Create variables and attributes
65%
66nw{'sms_time'} = ncdouble('sms_time');
67nw{'sms_time'}.long_name = ncchar('surface momentum stress time');
68nw{'sms_time'}.long_name = 'surface momentum stress time';
69nw{'sms_time'}.units = ncchar('days');
70nw{'sms_time'}.units = 'days';
71nw{'sms_time'}.cycle_length = smsc;
72
73nw{'shf_time'} = ncdouble('shf_time');
74nw{'shf_time'}.long_name = ncchar('surface heat flux time');
75nw{'shf_time'}.long_name = 'surface heat flux time';
76nw{'shf_time'}.units = ncchar('days');
77nw{'shf_time'}.units = 'days';
78nw{'shf_time'}.cycle_length =shfc ;
79
80nw{'swf_time'} = ncdouble('swf_time');
81nw{'swf_time'}.long_name = ncchar('surface freshwater flux time');
82nw{'swf_time'}.long_name = 'surface freshwater flux time';
83nw{'swf_time'}.units = ncchar('days');
84nw{'swf_time'}.units = 'days';
85nw{'swf_time'}.cycle_length = swfc;
86
87
88nw{'sst_time'} = ncdouble('sst_time');
89nw{'sst_time'}.long_name = ncchar('sea surface temperature time');
90nw{'sst_time'}.long_name = 'sea surface temperature time';
91nw{'sst_time'}.units = ncchar('days');
92nw{'sst_time'}.units = 'days';
93nw{'sst_time'}.cycle_length = sstc;
94
95nw{'sss_time'} = ncdouble('sss_time');
96nw{'sss_time'}.long_name = ncchar('sea surface salinity time');
97nw{'sss_time'}.long_name = 'sea surface salinity time';
98nw{'sss_time'}.units = ncchar('days');
99nw{'sss_time'}.units = 'days';
100nw{'sss_time'}.cycle_length = sssc;
101
102nw{'srf_time'} = ncdouble('srf_time');
103nw{'srf_time'}.long_name = ncchar('solar shortwave radiation time');
104nw{'srf_time'}.long_name = 'solar shortwave radiation time';
105nw{'srf_time'}.units = ncchar('days');
106nw{'srf_time'}.units = 'days';
107nw{'srf_time'}.cycle_length = srfc;
108
109nw{'sustr'} = ncdouble('sms_time', 'eta_u', 'xi_u');
110nw{'sustr'}.long_name = ncchar('surface u-momentum stress');
111nw{'sustr'}.long_name = 'surface u-momentum stress';
112nw{'sustr'}.units = ncchar('Newton meter-2');
113nw{'sustr'}.units = 'Newton meter-2';
114
115nw{'svstr'} = ncdouble('sms_time', 'eta_v', 'xi_v');
116nw{'svstr'}.long_name = ncchar('surface v-momentum stress');
117nw{'svstr'}.long_name = 'surface v-momentum stress';
118nw{'svstr'}.units = ncchar('Newton meter-2');
119nw{'svstr'}.units = 'Newton meter-2';
120
121nw{'shflux'} = ncdouble('shf_time', 'eta_rho', 'xi_rho');
122nw{'shflux'}.long_name = ncchar('surface net heat flux');
123nw{'shflux'}.long_name = 'surface net heat flux';
124nw{'shflux'}.units = ncchar('Watts meter-2');
125nw{'shflux'}.units = 'Watts meter-2';
126
127nw{'swflux'} = ncdouble('swf_time', 'eta_rho', 'xi_rho');
128nw{'swflux'}.long_name = ncchar('surface freshwater flux (E-P)');
129nw{'swflux'}.long_name = 'surface freshwater flux (E-P)';
130nw{'swflux'}.units = ncchar('centimeter day-1');
131nw{'swflux'}.units = 'centimeter day-1';
132nw{'swflux'}.positive = ncchar('net evaporation');
133nw{'swflux'}.positive = 'net evaporation';
134nw{'swflux'}.negative = ncchar('net precipitation');
135nw{'swflux'}.negative = 'net precipitation';
136
137nw{'SST'} = ncdouble('sst_time', 'eta_rho', 'xi_rho');
138nw{'SST'}.long_name = ncchar('sea surface temperature');
139nw{'SST'}.long_name = 'sea surface temperature';
140nw{'SST'}.units = ncchar('Celsius');
141nw{'SST'}.units = 'Celsius';
142
143nw{'SSS'} = ncdouble('sss_time', 'eta_rho', 'xi_rho');
144nw{'SSS'}.long_name = ncchar('sea surface salinity');
145nw{'SSS'}.long_name = 'sea surface salinity';
146nw{'SSS'}.units = ncchar('PSU');
147nw{'SSS'}.units = 'PSU';
148
149nw{'dQdSST'} = ncdouble('sst_time', 'eta_rho', 'xi_rho');
150nw{'dQdSST'}.long_name = ncchar('surface net heat flux sensitivity to SST');
151nw{'dQdSST'}.long_name = 'surface net heat flux sensitivity to SST';
152nw{'dQdSST'}.units = ncchar('Watts meter-2 Celsius-1');
153nw{'dQdSST'}.units = 'Watts meter-2 Celsius-1';
154
155nw{'swrad'} = ncdouble('srf_time', 'eta_rho', 'xi_rho');
156nw{'swrad'}.long_name = ncchar('solar shortwave radiation');
157nw{'swrad'}.long_name = 'solar shortwave radiation';
158nw{'swrad'}.units = ncchar('Watts meter-2');
159nw{'swrad'}.units = 'Watts meter-2';
160nw{'swrad'}.positive = ncchar('downward flux, heating');
161nw{'swrad'}.positive = 'downward flux, heating';
162nw{'swrad'}.negative = ncchar('upward flux, cooling');
163nw{'swrad'}.negative = 'upward flux, cooling';
164
165result = endef(nw);
166
167%
168% Create global attributes
169%
170
171nw.title = ncchar(title);
172nw.title = title;
173nw.date = ncchar(date);
174nw.date = date;
175nw.grd_file = ncchar(grdname);
176nw.grd_file = grdname;
177nw.type = ncchar('ROMS forcing file');
178nw.type = 'ROMS forcing file';
179
180%
181% Write time variables
182%
183
184nw{'sms_time'}(:) = smst;
185nw{'shf_time'}(:) = shft;
186nw{'swf_time'}(:) = swft;
187nw{'sst_time'}(:) = sstt;
188nw{'srf_time'}(:) = srft;
189nw{'sss_time'}(:) = ssst;
190
191close(nw);
Note: See TracBrowser for help on using the repository browser.