root/doc/html/iopom_8h-source.html @ 159

Revision 106, 5.1 kB (checked in by smidl, 16 years ago)

doc

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3<title>mixpp: work/mixpp/pmsm/iopom.h Source File</title>
4<link href="doxygen.css" rel="stylesheet" type="text/css">
5<link href="tabs.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.5.5 -->
8<div class="navigation" id="top">
9  <div class="tabs">
10    <ul>
11      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
12      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
13      <li><a href="annotated.html"><span>Classes</span></a></li>
14      <li class="current"><a href="files.html"><span>Files</span></a></li>
15    </ul>
16  </div>
17<h1>work/mixpp/pmsm/iopom.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//#include &lt;netcdfcpp.h&gt;</span>
18<a name="l00002"></a>00002 <span class="preprocessor">#include &lt;fstream.h&gt;</span>
19<a name="l00003"></a>00003 <span class="preprocessor">#include &lt;fcntl.h&gt;</span>
20<a name="l00004"></a>00004
21<a name="l00005"></a>00005 <span class="comment">// void write_to_nc ( NcFile &amp;nc, mat &amp;X, std::string Xn, Array&lt;std::string&gt; A ) {</span>
22<a name="l00006"></a>00006 <span class="comment">//      char tmpstr[200];</span>
23<a name="l00007"></a>00007 <span class="comment">//      int Len = X.rows();</span>
24<a name="l00008"></a>00008 <span class="comment">// </span>
25<a name="l00009"></a>00009 <span class="comment">//      sprintf ( tmpstr,"%s.length",Xn.c_str() );</span>
26<a name="l00010"></a>00010 <span class="comment">//      NcDim* lengt = nc.add_dim ( tmpstr, ( long ) Len );</span>
27<a name="l00011"></a>00011 <span class="comment">//      for ( int j=0; j&lt;X.cols(); j++ ) {</span>
28<a name="l00012"></a>00012 <span class="comment">//              if ( j&lt;A.length() )</span>
29<a name="l00013"></a>00013 <span class="comment">//                      sprintf ( tmpstr,"%s_%s",Xn.c_str(), ( A ( j ) ).c_str() );</span>
30<a name="l00014"></a>00014 <span class="comment">//              else</span>
31<a name="l00015"></a>00015 <span class="comment">//                      sprintf ( tmpstr,"%s_%d",Xn.c_str(),j );</span>
32<a name="l00016"></a>00016 <span class="comment">//              // Create variables and their attributes</span>
33<a name="l00017"></a>00017 <span class="comment">//              NcVar* P = nc.add_var ( tmpstr, ncDouble, lengt );</span>
34<a name="l00018"></a>00018 <span class="comment">//              const double* Dp = X._data();</span>
35<a name="l00019"></a>00019 <span class="comment">//              P-&gt;put ( &amp;Dp[j*Len],Len );</span>
36<a name="l00020"></a>00020 <span class="comment">//      }</span>
37<a name="l00021"></a>00021 <span class="comment">// }</span>
38<a name="l00022"></a>00022
39<a name="l00023"></a>00023
40<a name="l00024"></a>00024 <span class="keywordtype">void</span> dirfile_write (std::ofstream &amp;form, std::string Dir, mat &amp;X, std::string Xn, Array&lt;std::string&gt; A ) {
41<a name="l00025"></a>00025   <span class="keywordtype">char</span> tmpstr[200];
42<a name="l00026"></a>00026   <span class="keywordtype">char</span> file[200];
43<a name="l00027"></a>00027   <span class="keyword">const</span> <span class="keywordtype">double</span>* Dp=X._data();
44<a name="l00028"></a>00028   <span class="keywordtype">int</span> Len = X.rows();
45<a name="l00029"></a>00029   
46<a name="l00030"></a>00030         <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> j=0; j&lt;X.cols(); j++ ) {
47<a name="l00031"></a>00031                 <span class="keywordflow">if</span> ( j&lt;A.length() )
48<a name="l00032"></a>00032                         sprintf ( tmpstr,<span class="stringliteral">"%s_%s"</span>,Xn.c_str(), ( A ( j ) ).c_str() );
49<a name="l00033"></a>00033                 <span class="keywordflow">else</span>
50<a name="l00034"></a>00034                         sprintf ( tmpstr,<span class="stringliteral">"%s_%d"</span>,Xn.c_str(),j );
51<a name="l00035"></a>00035                 <span class="comment">// save files == from kst-doc-datasource</span>
52<a name="l00036"></a>00036                 sprintf(file,<span class="stringliteral">"%s/%s"</span>,Dir.c_str(),tmpstr);
53<a name="l00037"></a>00037                 
54<a name="l00038"></a>00038                 <span class="keywordtype">int</span> fp;
55<a name="l00039"></a>00039                 fp = open(file, O_CREAT | O_WRONLY | O_TRUNC, 00644);
56<a name="l00040"></a>00040                 write(fp,&amp;Dp[j*Len],Len*<span class="keyword">sizeof</span>(<span class="keywordtype">double</span>));
57<a name="l00041"></a>00041                 close(fp);
58<a name="l00042"></a>00042   
59<a name="l00043"></a>00043                 form &lt;&lt; tmpstr &lt;&lt; <span class="stringliteral">" RAW  d 1"</span> &lt;&lt; endl;
60<a name="l00044"></a>00044         }
61<a name="l00045"></a>00045 }
62</pre></div></div>
63<hr size="1"><address style="text-align: right;"><small>Generated on Fri May 9 23:06:28 2008 for mixpp by&nbsp;
64<a href="http://www.doxygen.org/index.html">
65<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address>
66</body>
67</html>
Note: See TracBrowser for help on using the browser.