write_FVCOM_bedflag.html 8.63 KB
Newer Older
Pierre Cazenave's avatar
Pierre Cazenave committed
1 2 3 4 5 6
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of write_FVCOM_bedflag</title>
  <meta name="keywords" content="write_FVCOM_bedflag">
7
  <meta name="description" content="Write spatially-variable flag (bedflag) to FVCOM forcing file">
Pierre Cazenave's avatar
Pierre Cazenave committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">fvcom_prepro</a> &gt; write_FVCOM_bedflag.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for fvcom_prepro&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>write_FVCOM_bedflag
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
24
<div class="box"><strong>Write spatially-variable flag (bedflag) to FVCOM forcing file</strong></div>
Pierre Cazenave's avatar
Pierre Cazenave committed
25 26 27 28 29

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function write_FVCOM_bedflag(bedflag,filename,mytitle) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
30
<div class="fragment"><pre class="comment"> Write spatially-variable flag (bedflag) to FVCOM forcing file
Pierre Cazenave's avatar
Pierre Cazenave committed
31 32 33 34

 function write_FVCOM_bedflag(bedflag,filename,mytitle)

 DESCRIPTION:
35
    Generate a netCDF file containing spatially variable bedflag for FVCOM
Pierre Cazenave's avatar
Pierre Cazenave committed
36

37 38
 INPUT
   bedflag   = user defined bed flag (=0, no erosion/bedosition, =1, erosion/bedosition)
Pierre Cazenave's avatar
Pierre Cazenave committed
39 40
               on the nodes
   filename  = filename to dump to
41
   mytitle   = title of the case (set as global attribute)
Pierre Cazenave's avatar
Pierre Cazenave committed
42 43

 OUTPUT:
44
    netCDF file: filename
Pierre Cazenave's avatar
Pierre Cazenave committed
45 46 47 48

 EXAMPLE USAGE
    write_FVCOM_bedflag(bedflag, 'tst_bedflag.nc', 'no bedosition/erosion in Skagit river')

49
 Author(s):
Pierre Cazenave's avatar
Pierre Cazenave committed
50
    Geoff Cowles (University of Massachusetts Dartmouth)
51
    Pierre Cazenave (Plymouth Marine Laboratory)
Pierre Cazenave's avatar
Pierre Cazenave committed
52 53

 Revision history
54
    2016-02-18 Updated the code to use the MATLAB netCDF routines.
55 56 57 58
    2017-03-23 Add the supplied title to the generated netCDF file.
    2017-03-29 Write the flag as a float as FVCOM expects.

==========================================================================</pre></div>
Pierre Cazenave's avatar
Pierre Cazenave committed
59 60 61 62 63 64 65 66

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
Pierre Cazenave's avatar
Pierre Cazenave committed
67
</ul>
Pierre Cazenave's avatar
Pierre Cazenave committed
68 69 70 71 72
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function write_FVCOM_bedflag(bedflag,filename,mytitle)</a>
0002 <span class="comment">% Write spatially-variable flag (bedflag) to FVCOM forcing file</span>
0003 <span class="comment">%</span>
0004 <span class="comment">% function write_FVCOM_bedflag(bedflag,filename,mytitle)</span>
0005 <span class="comment">%</span>
0006 <span class="comment">% DESCRIPTION:</span>
0007 <span class="comment">%    Generate a netCDF file containing spatially variable bedflag for FVCOM</span>
0008 <span class="comment">%</span>
0009 <span class="comment">% INPUT</span>
0010 <span class="comment">%   bedflag   = user defined bed flag (=0, no erosion/bedosition, =1, erosion/bedosition)</span>
0011 <span class="comment">%               on the nodes</span>
0012 <span class="comment">%   filename  = filename to dump to</span>
0013 <span class="comment">%   mytitle   = title of the case (set as global attribute)</span>
0014 <span class="comment">%</span>
0015 <span class="comment">% OUTPUT:</span>
0016 <span class="comment">%    netCDF file: filename</span>
0017 <span class="comment">%</span>
0018 <span class="comment">% EXAMPLE USAGE</span>
0019 <span class="comment">%    write_FVCOM_bedflag(bedflag, 'tst_bedflag.nc', 'no bedosition/erosion in Skagit river')</span>
0020 <span class="comment">%</span>
0021 <span class="comment">% Author(s):</span>
0022 <span class="comment">%    Geoff Cowles (University of Massachusetts Dartmouth)</span>
0023 <span class="comment">%    Pierre Cazenave (Plymouth Marine Laboratory)</span>
0024 <span class="comment">%</span>
0025 <span class="comment">% Revision history</span>
0026 <span class="comment">%    2016-02-18 Updated the code to use the MATLAB netCDF routines.</span>
0027 <span class="comment">%    2017-03-23 Add the supplied title to the generated netCDF file.</span>
0028 <span class="comment">%    2017-03-29 Write the flag as a float as FVCOM expects.</span>
0029 <span class="comment">%</span>
0030 <span class="comment">%==========================================================================</span>
0031 
0032 <span class="keyword">global</span> ftbverbose
0033 [~, subname] = fileparts(mfilename(<span class="string">'fullpath'</span>));
0034 <span class="keyword">if</span> ftbverbose
0035     fprintf(<span class="string">'\nbegin : %s\n'</span>, subname)
0036 <span class="keyword">end</span>
0037 
0038 <span class="comment">%--------------------------------------------------------------------------</span>
0039 <span class="comment">% Parse input arguments</span>
0040 <span class="comment">%--------------------------------------------------------------------------</span>
0041 <span class="keyword">if</span> ~exist(<span class="string">'bedflag'</span>, <span class="string">'var'</span>)
0042     error(<span class="string">'incorrect usage of gen_bedflag_file, must provide bedflag field'</span>)
0043 <span class="keyword">end</span>
0044 <span class="keyword">if</span> ~exist(<span class="string">'filename'</span>, <span class="string">'var'</span>)
0045     error(<span class="string">'incorrect usage of gen_bedflag_file, must provide filename'</span>)
0046 <span class="keyword">end</span>
0047 <span class="keyword">if</span> ~exist(<span class="string">'mytitle'</span>, <span class="string">'var'</span>)
0048     error(<span class="string">'incorrect usage of gen_bedflag_file, must provide title field'</span>)
0049 <span class="keyword">end</span>
0050 
0051 <span class="comment">% check dimensions</span>
0052 nVerts = numel(bedflag);
0053 <span class="keyword">if</span>(nVerts == 0)
0054     error(<span class="string">'dimension of bedflag is 0, something is wrong '</span>)
0055 <span class="keyword">end</span>;
0056 
0057 <span class="comment">%--------------------------------------------------------------------------</span>
0058 <span class="comment">% Dump to bedflag netCDF file</span>
0059 <span class="comment">%--------------------------------------------------------------------------</span>
0060 <span class="keyword">if</span> ftbverbose
0061     fprintf(<span class="string">'Dumping to bedflag netCDF file: %s\n'</span>, filename);
0062     fprintf(<span class="string">'Size of bedflag array: %d\n'</span>, nVerts);
0063 <span class="keyword">end</span>
0064 
0065 nc = netcdf.create(filename, <span class="string">'clobber'</span>);
0066 
0067 netcdf.putAtt(nc,netcdf.getConstant(<span class="string">'NC_GLOBAL'</span>), <span class="string">'title'</span>, mytitle)
140
0068 
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
0069 
0070 <span class="comment">% define dimensions</span>
0071 node_dimid=netcdf.defDim(nc, <span class="string">'node'</span>, numel(bedflag));
0072 
0073 <span class="comment">% define variables and attributes</span>
0074 node_varid=netcdf.defVar(nc, <span class="string">'bedflag'</span>, <span class="string">'NC_FLOAT'</span>, node_dimid);
0075 netcdf.putAtt(nc,node_varid, <span class="string">'long_name'</span>, <span class="string">'bed deposition flag'</span>);
0076 netcdf.putAtt(nc,node_varid, <span class="string">'units'</span>, <span class="string">'-'</span>);
0077 
0078 <span class="comment">% end definitions</span>
0079 netcdf.endDef(nc);
0080 
0081 <span class="comment">% dump data</span>
0082 netcdf.putVar(nc, node_varid, bedflag);
0083 
0084 <span class="comment">% close netCDF</span>
0085 netcdf.close(nc)
0086 
0087 <span class="keyword">if</span> ftbverbose
0088     fprintf(<span class="string">'end   : %s\n'</span>, subname)
0089 <span class="keyword">end</span></pre></div>
Pierre Cazenave's avatar
Pierre Cazenave committed
162
<hr><address>Generated on Wed 20-Feb-2019 16:06:01 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
Pierre Cazenave's avatar
Pierre Cazenave committed
163 164
</body>
</html>