source: trunk/etc/src/yf2m.c

Last change on this file was 610, checked in by grlod, 12 years ago

header replacements
uml diagrams updated
should have been committed 3 months ago ...

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1/*
2Copyright or © or Copr. MMSA team, LOCEAN Paris (2011)
3
4This software is a framework for variational data assimilation in
5numerical models.
6
7This software is governed by the CeCILL license under French law and
8abiding by the rules of distribution of free software.  You can  use,
9modify and/ or redistribute the software under the terms of the CeCILL
10license as circulated by CEA, CNRS and INRIA at the following URL
11"http://www.cecill.info".
12
13As a counterpart to the access to the source code and  rights to copy,
14modify and redistribute granted by the license, users are provided only
15with a limited warranty  and the software's author,  the holder of the
16economic rights,  and the successive licensors  have only  limited
17liability.
18
19In this respect, the user's attention is drawn to the risks associated
20with loading,  using,  modifying and/or developing or reproducing the
21software by the user in light of its specific status of free software,
22that may mean  that it is complicated to manipulate,  and  that  also
23therefore means  that it is reserved for developers  and  experienced
24professionals having in-depth computer knowledge. Users are therefore
25encouraged to load and test the software's suitability as regards their
26requirements in conditions enabling the security of their systems and/or
27data to be ensured and,  more generally, to use and operate it in the
28same conditions as regards security.
29
30The fact that you are presently reading this means that you have had
31knowledge of the CeCILL license and that you accept its terms.
32
33YAO website : http://www.locean-ipsl.upmc.fr/~yao/
34Contact : yao@locean-ipsl.upmc.fr
35*/
36// Contributor : Charles Sorror
37#include <stdio.h>
38#include <stdlib.h>
39
40#define BUFSIZE 80
41
42int main (int argc, char *argv[])
43{ /* . Syntaxe : yf2m f1 mf ncol
44     . Purpose : file (f1)  to matlab matrice file (mf) ;
45                 ncol is the number of column of the matrice.
46     . Compilation : cc -Wall -o yf2m yf2m.c */
47
48        FILE    *f1, *mf;
49        char    buf[BUFSIZE+1];
50        int     ncol;
51        int     icol, nblig;
52
53        if ((f1 = fopen(argv[1], "r")) <= 0)
54        {       printf ("yao file %s not found !!!\n", argv[1]);
55                exit(0);
56        }
57        if ((mf = fopen(argv[2], "w")) <= 0)
58        {       printf ("failed while opening matlab file %s !!!\n", argv[2]);
59                exit(0);
60        }
61
62        ncol = atoi(argv[3]);
63        if (ncol<=0)
64        {       printf ("bad value for ncol \n");
65                exit(0);
66        }
67
68        icol=0; nblig=0;
69        //while (fgets (buf, BUFSIZE, f1) != NULL)
70        while (fscanf(f1, "%s", buf) > 0)
71        {
72                fprintf(mf, "%s", buf);         //printf("%s", buf);
73                icol = (icol+1)%ncol;
74                if (icol) fprintf(mf, "\t");    //printf("\t");
75                else
76                {         fprintf(mf, "\n");    //printf("\n");
77                          ++nblig;
78                }
79        }
80
81        if (icol != 0)
82           printf("\nyf2m: Warning : last line not complete : only %i elt instead of %i \n", icol, ncol);
83
84        printf ("yf2m: %i line resumed\n", nblig);
85        return(0);
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
Note: See TracBrowser for help on using the repository browser.