source: issm/oecreview/Archive/14312-15392/ISSM-14550-14551.diff@ 15393

Last change on this file since 15393 was 15393, checked in by Mathieu Morlighem, 12 years ago

NEW: adding Archive/14312-15392 for oecreview

File size: 3.2 KB
  • ../trunk-jpl/src/c/shared/Exp/exp.h

     
    9090        /*Do a first pass through the domainname file, to figure out how many profiles we need to read: */
    9191        nprof=1;
    9292        for(;;){
    93                 fscanf(fid,"%255s %255s\n",chardummy,chardummy);
    94                 fscanf(fid,"%255s %255s\n",chardummy,chardummy);
    95                 fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy);
    96                 fscanf(fid,"%20u %255s\n",&n,chardummy);
    97                 fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy);
    98                 for (i=0;i<n;i++) fscanf(fid,"%20lf %20lf\n",&ddummy,&ddummy);
     93                //## Name:filename
     94                if(fscanf(fid,"%255s %255s\n",chardummy,chardummy)!=2) _error_("Could not read " << domainname);
     95                //## Icon:0
     96                if(fscanf(fid,"%255s %255s\n",chardummy,chardummy)!=2) _error_("Could not read " << domainname);
     97                //# Points Count Value
     98                if(fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy)!=4) _error_("Could not read " << domainname);
     99                if(fscanf(fid,"%20u %255s\n",&n,chardummy)!=2) _error_("Could not read number of points in "<<domainname);
     100                //# X pos Y pos
     101                if(fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy)!=5) _error_("Could not read " << domainname);
     102                for (i=0;i<n;i++){
     103                        if(fscanf(fid,"%20lf %20lf\n",&ddummy,&ddummy)!=2){
     104                                _error_("Could not read coordinate of vertex "<< i <<" of "<<domainname);
     105                        }
     106                }
    99107                /*check whether we are at the end of the file, otherwise, keep reading next profile:*/
    100                 if (feof(fid)) break;
     108                if(feof(fid)) break;
    101109                nprof++;
    102110        }
    103111
     
    118126        for(counter=0;counter<nprof;counter++){
    119127
    120128                /*Skip header: */
    121                 fscanf(fid,"%255s %255s\n",chardummy,chardummy);
    122                 fscanf(fid,"%255s %255s\n",chardummy,chardummy);
    123                 fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy);
     129                //## Name:filename
     130                if(fscanf(fid,"%255s %255s\n",chardummy,chardummy)!=2) _error_("Could not read " << domainname);
     131                //## Icon:0
     132                if(fscanf(fid,"%255s %255s\n",chardummy,chardummy)!=2) _error_("Could not read " << domainname);
     133                //# Points Count Value
     134                if(fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy)!=4) _error_("Could not read " << domainname);
    124135
    125136                /*Get number of profile vertices: */
    126                 fscanf(fid,"%20u %255s\n",&n,chardummy);
     137                if(fscanf(fid,"%20u %255s\n",&n,chardummy)!=2) _error_("Could not read number of points in "<<domainname);
    127138
    128139                /*Skip next line: */
    129                 fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy);
     140                //# X pos Y pos
     141                if(fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy)!=5) _error_("Could not read " << domainname);
    130142
    131143                /*Allocate vertices: */
    132144                x=xNew<doubletype>(n);
     
    134146
    135147                /*Read vertices: */
    136148                for (i=0;i<n;i++){
    137                         fscanf(fid,"%20lf %20lf\n",&x[i],&y[i]);
     149                        if(fscanf(fid,"%20lf %20lf\n",&x[i],&y[i])!=2){
     150                                _error_("Could not read coordinate of vertex "<<i<<" of "<<domainname);
     151                        }
    138152                }
    139153
    140154                /*Now check that we are dealing with open contours: */
Note: See TracBrowser for help on using the repository browser.