source: trunk/etc/src/yf2m.c @ 503

Last change on this file since 503 was 503, checked in by lnalod, 13 years ago

CeCILL license.

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