Changeset 12049


Ignore:
Timestamp:
04/18/12 15:16:17 (13 years ago)
Author:
Mathieu Morlighem
Message:

Using FetchData to recover Options

Location:
issm/trunk-jpl/src/modules
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/modules/BamgMesher/BamgMesher.cpp

    r12045 r12049  
    3232        FetchData(&bamgmesh_in,BAMGGEOMIN);
    3333
    34         /*!Generate internal degree of freedom numbers: */
     34        /*Call x layer*/
    3535        Bamgx(bamgmesh_out,bamggeom_out,bamgmesh_in,bamggeom_in,bamgopts);
    3636
  • TabularUnified issm/trunk-jpl/src/modules/Exp2Kml/Exp2Kml.cpp

    r11933 r12049  
    2525        /*checks on arguments on the matlab side: */
    2626        if (nlhs > NLHS) {
    27                 Exp2KmlUsage();
    28                 _error_("Exp2Kml usage error");
     27                Exp2KmlUsage(); _error_("Exp2Kml usage error");
    2928        }
    3029        if (nrhs < NRHS) {
    31                 Exp2KmlUsage();
    32                 _error_("Exp2Kml usage error");
     30                Exp2KmlUsage(); _error_("Exp2Kml usage error");
    3331        }
    3432
    3533        /*Input datasets: */
    36         if (verbose) printf("Fetching inputs:\n");
    3734        FetchData(&filexp,EXP_IN);
    38         if (verbose) printf("  filexp=\"%s\"\n",filexp);
    3935        FetchData(&filkml,KML_IN);
    40         if (verbose) printf("  filkml=\"%s\"\n",filkml);
    4136        FetchData(&sgn,SGN_IN);
    42         if (verbose) printf("  sgn=%d\n",sgn);
     37        FetchData(&options,NRHS,nrhs,prhs);
    4338
    44         if (verbose) printf("Parsing options:\n");
    45         options=new Options(NRHS,nrhs,prhs);
    46         if (options->Size()) for(i=0;i<options->Size();i++) ((Option*)options->GetObjectByOffset(i))->DeepEcho();
    4739        options->Get(&choles,"holes","no");
    48         if (!strncmp(choles,"y",1) || !strncmp(choles,"on",2))
    49                 holes=true;
     40        if (!strncmp(choles,"y",1) || !strncmp(choles,"on",2)) holes=true;
     41
    5042        /*  defaults are in Xy2lldef, so don't duplicate them here, and only use user values if both have been specified  */
    5143        if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
     
    5749
    5850        /*some checks*/
    59         if (verbose) printf("Checking inputs:\n");
    60 
    61         if (sgn != +1 && sgn != -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
     51        if (sgn !=+1 && sgn !=-1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
    6252        if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
    6353        if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
    6454
    6555        /* Run core computations: */
    66         if (verbose) printf("Calling core:\n");
    6756        if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
    68                 iret=Exp2Kmlx(filexp,filkml,
    69                                           sgn,cm,sp,
    70                                           holes);
     57                iret=Exp2Kmlx(filexp,filkml,sgn,cm,sp,holes);
    7158        else
    72                 iret=Exp2Kmlx(filexp,filkml,
    73                                           sgn,
    74                                           holes);
    75         if (verbose) printf("  iret=%d\n",iret);
     59                iret=Exp2Kmlx(filexp,filkml,sgn,holes);
    7660
    7761        /*Write data: */
     
    8872}
    8973
    90 void Exp2KmlUsage(void)
    91 {
     74void Exp2KmlUsage(void){
    9275        _printf_(true,"Exp2Kml - exp to kml file conversion module:\n");
    9376        _printf_(true,"\n");
  • TabularUnified issm/trunk-jpl/src/modules/KMLFileRead/KMLFileRead.cpp

    r11933 r12049  
    1111        /*input: */
    1212        char*   name=NULL;
    13 
    1413        char*   notes=NULL;
    1514        const mxArray* notesi;
    1615        mwIndex        nindex;
    17 
    1816        int*    elem=NULL;
    1917        int     melem=0,nelem=0;
    20 
    2118        int*    nodecon=NULL;
    2219        int     mncon=0,nncon=0;
    23 
    2420        double* lat=NULL;
    2521        int     mlat=0,nlat=0,llat=0;
    26 
    2722        double* lng=NULL;
    2823        int     mlng=0,nlng=0,llng=0;
    29 
    3024        int     nparts=0;
    31 
    3225        int*    part=NULL;
    3326        int     mprt=0,nprt=0,lprt=0;
    34 
    3527        double* data=NULL;
    3628        int     mdata=0,ndata=0;
    37 
    3829        double* cmap=NULL;
    3930        int     mcmap=0,ncmap=0;
    40 
    4131        char*   filnam=NULL;
    42 
    4332        FILE*   fidi=NULL;
    4433        FILE*   fido=NULL;
    45 
    4634        Options* options=NULL;
    4735        char*    echo    =NULL;
     
    5745        /*checks on arguments on the matlab side: */
    5846        if (nlhs > NLHS) {
    59                 KMLFileReadUsage();
    60                 _error_("KMLFileRead usage error");
     47                KMLFileReadUsage(); _error_("KMLFileRead usage error");
    6148        }
    6249        if (nrhs < NRHS) {
    63                 KMLFileReadUsage();
    64                 _error_("KMLFileRead usage error");
     50                KMLFileReadUsage(); _error_("KMLFileRead usage error");
    6551        }
    6652
    6753        /*Input datasets: */
    68         if (verbose) printf("Fetching inputs:\n");
    6954        FetchData(&filnam,FILENAME);
    70         if (verbose) printf("  filnam =\"%s\"\n",filnam);
     55        FetchData(&options,NRHS,nrhs,prhs);
     56        FetchData(&options,NRHS,nrhs,prhs);
    7157
    72         if (verbose) printf("Parsing options:\n");
    73         options=new Options(NRHS,nrhs,prhs);
    74         if (options->Size()) for(i=0;i<options->Size();i++) ((Option*)options->GetObjectByOffset(i))->DeepEcho();
    7558        options->Get(&echo    ,"echo"    ,"off");
    7659        options->Get(&deepecho,"deepecho","off");
     
    7861
    7962        /*some checks*/
    80         if (verbose) printf("Checking inputs:\n");
    81 
    82         if (!strlen(filnam))
    83                 strcpy(filnam,"stdout");
     63        if (!strlen(filnam)) strcpy(filnam,"stdout");
    8464
    8565        if (verbose) printf("Opening file \"%s\".\n",filnam);
     
    9373        fclose(fidi);
    9474
    95         if (kobj) {
     75        if (kobj){
    9676                if (!strncmp(echo    ,"on",2) || !strncmp(echo    ,"y",1))
    9777                        kobj->Echo();
     
    11090                        }
    11191                }
    112 
    11392                delete kobj;
    11493        }
     
    127106}
    128107
    129 void KMLFileReadUsage(void)
    130 {
     108void KMLFileReadUsage(void){
    131109        _printf_(true,"KMLFileRead - KML file reader module:\n");
    132110        _printf_(true,"\n");
  • TabularUnified issm/trunk-jpl/src/modules/KMLMeshWrite/KMLMeshWrite.cpp

    r11933 r12049  
    1010        /*input: */
    1111        char*   name=NULL;
    12 
    1312        char*   notes=NULL;
    1413        const mxArray* notesi;
    1514        mwIndex        nindex;
    16 
    1715        int*    elem=NULL;
    1816        int     melem=0,nelem=0;
    19 
    2017        int*    nodecon=NULL;
    2118        int     mncon=0,nncon=0;
    22 
    2319        double* lat=NULL;
    2420        int     mlat=0,nlat=0,llat=0;
    25 
    2621        double* lng=NULL;
    2722        int     mlng=0,nlng=0,llng=0;
    28 
    2923        int     nparts=0;
    30 
    3124        int*    part=NULL;
    3225        int     mprt=0,nprt=0,lprt=0;
    33 
    3426        double* data=NULL;
    3527        int     mdata=0,ndata=0;
    36 
    3728        double* cmap=NULL;
    3829        int     mcmap=0,ncmap=0;
    39 
    4030        char*   filnam=NULL;
    41 
    4231        FILE*   fid=NULL;
    43 
    4432        Options* options=NULL;
    4533
     
    5240        /*checks on arguments on the matlab side: */
    5341        if (nlhs > NLHS) {
    54                 KMLMeshWriteUsage();
    55                 _error_("KMLMeshWrite usage error");
     42                KMLMeshWriteUsage(); _error_("KMLMeshWrite usage error");
    5643        }
    5744        if (nrhs < NRHS) {
    58                 KMLMeshWriteUsage();
    59                 _error_("KMLMeshWrite usage error");
     45                KMLMeshWriteUsage(); _error_("KMLMeshWrite usage error");
    6046        }
    6147
    6248        /*Input datasets: */
    63         if (verbose) printf("Fetching inputs:\n");
    6449        FetchData(&name,NAME);
    65         if (verbose) printf("  name   =\"%s\"\n",name);
    6650
    6751/*  notes is typically a cell array of character strings  */
     
    8569        else
    8670                FetchData(&notes,NOTES);
    87         if (verbose) printf("  notes  =\"%s\"\n",notes);
    88 
    8971        FetchData(&elem,&melem,&nelem,ELEMHANDLE);
    90         if (verbose) printf("  elem   =size [%d x %d]\n",melem,nelem);
    9172        FetchData(&nodecon,&mncon,&nncon,NODECONHANDLE);
    92         if (verbose) printf("  nodecon=size [%d x %d]\n",mncon,nncon);
    9373        FetchData(&lat,&mlat,&nlat,LATHANDLE);
    9474        llat=mlat*nlat;
    95         if (verbose) printf("  lat    =length [%d]\n",llat);
    9675        FetchData(&lng,&mlng,&nlng,LNGHANDLE);
    9776        llng=mlng*nlng;
    98         if (verbose) printf("  lng    =length [%d]\n",llng);
    9977        FetchData(&part,&mprt,&nprt,PARTHANDLE);
    10078        lprt=mprt*nprt;
    101         if (verbose) printf("  part   =length [%d]\n",lprt);
    10279        FetchData(&data,&mdata,&ndata,DATAHANDLE);
    103         if (verbose) printf("  data   =size [%d x %d]\n",mdata,ndata);
    10480        FetchData(&cmap,&mcmap,&ncmap,CMAPHANDLE);
    105         if (verbose) printf("  cmap   =size [%d x %d]\n",mcmap,ncmap);
    10681        FetchData(&filnam,FILENAME);
    107         if (verbose) printf("  filnam =\"%s\"\n",filnam);
    108 
    109         if (verbose) printf("Parsing options:\n");
    110         options=new Options(NRHS,nrhs,prhs);
    111 //      if (options->Size()) for(i=0;i<options->Size();i++) ((Option*)options->GetObjectByOffset(i))->DeepEcho();
     82        FetchData(&options,NRHS,nrhs,prhs);
    11283
    11384        /*some checks*/
    114         if (verbose) printf("Checking inputs:\n");
     85        for (i=0; i<melem*nelem; i++) if(elem[i]>nnodes) nnodes=elem[i];
     86        if(part) for (i=0; i<lprt; i++) if (part[i]+1 > nparts) nparts=part[i]+1;
    11587
    116         for (i=0; i<melem*nelem; i++)
    117                 if (elem[i] > nnodes)
    118                         nnodes=elem[i];
    119         if (verbose) printf("  nnodes =%d\n",nnodes);
    120         if (part)
    121                 for (i=0; i<lprt; i++)
    122                         if (part[i]+1 > nparts)
    123                                 nparts=part[i]+1;
    124         if (verbose) printf("  nparts =%d\n",nparts);
    125 
    126         if      (nodecon && (mncon != nnodes))
     88        if (nodecon && (mncon != nnodes))
    12789                _error_("Nodal connectivity table, if supplied, must be supplied for all nodes.");
    12890        else if (!nodecon)
     
    13698        if (cmap && (ncmap != 3))
    13799                _error_("Colormap matrix, if supplied, must have three columns for rgb.");
    138 
    139100        if (!strlen(filnam))
    140101                strcpy(filnam,"stdout");
    141102
    142         if (verbose) printf("Opening file \"%s\".\n",filnam);
     103        /* Run core computations: */
    143104        fid=fopen(filnam,"w");
    144 
    145         /* Run core computations: */
    146         if (verbose) printf("Calling core:\n");
    147         KMLMeshWritex(&ierror,
    148                                   name,
    149                                   notes,
    150                                   elem,melem,nelem,
    151                                   nodecon,mncon,nncon,
    152                                   lat,lng,
    153                                   part,
    154                                   data,mdata,ndata,
    155                                   cmap,mcmap,ncmap,
    156                                   fid);
    157 
    158         if (verbose) printf("Closing file \"%s\".\n",filnam);
     105        KMLMeshWritex(&ierror,name,notes,elem,melem,nelem,nodecon,mncon,nncon,lat,lng,part,data,mdata,ndata,cmap,mcmap,ncmap,fid);
    159106        fclose(fid);
    160107
     
    170117}
    171118
    172 void KMLMeshWriteUsage(void)
    173 {
     119void KMLMeshWriteUsage(void){
    174120        _printf_(true,"KMLMeshWrite - KML mesh writer module:\n");
    175121        _printf_(true,"\n");
     
    196142        _printf_(true,"\n");
    197143}
    198 
  • TabularUnified issm/trunk-jpl/src/modules/KMLOverlay/KMLOverlay.cpp

    r11933 r12049  
    3030
    3131        /*checks on arguments on the matlab side: */
    32         if (nlhs > NLHS) {
    33                 KMLOverlayUsage();
    34                 _error_("KMLOverlay usage error");
     32        if(nlhs>NLHS){
     33                KMLOverlayUsage(); _error_("KMLOverlay usage error");
    3534        }
    36         if (nrhs < NRHS) {
    37                 KMLOverlayUsage();
    38                 _error_("KMLOverlay usage error");
     35        if(nrhs<NRHS){
     36                KMLOverlayUsage(); _error_("KMLOverlay usage error");
    3937        }
    4038
    4139        /*Input datasets: */
    42         if (verbose) printf("Fetching inputs:\n");
    4340        FetchData(&filkml,FILENAME);
    44         if (verbose) printf("  filkml=\"%s\"\n",filkml);
     41        FetchData(&options,NRHS,nrhs,prhs);
    4542
    46         if (verbose) printf("Parsing options:\n");
    47         options=new Options(NRHS,nrhs,prhs);
    48 //      if (options->Size()) for(i=0;i<options->Size();i++) ((Option*)options->GetObjectByOffset(i))->DeepEcho();
    4943        options->Get(&lataxis ,&nlat ,"lataxis" );
    5044        if (verbose && lataxis) for (i=0; i<nlat; i++) printf("  lataxis [%d]=%g\n",i,lataxis[i]);
    5145        options->Get(&longaxis,&nlong,"longaxis");
    5246        if (verbose && longaxis) for (i=0; i<nlong; i++) printf("  longaxis[%d]=%g\n",i,longaxis[i]);
    53 //      ((Option*)options->GetOption("images"))->DeepEcho();
    5447        options->Get(&pimages,&nimages,"images");
    5548        if (verbose && pimages) for (i=0; i<nimages; i++) printf("  pimages[%d]=\"%s\"\n",i,pimages[i]);
     
    5851
    5952        /*some checks*/
    60         if (verbose) printf("Checking inputs:\n");
    61 
    62         if (nlat  != 2) _error_("Latitudinal axes \"lataxis\" require two double values, not %d.",nlat);
    63         if (nlong != 2) _error_("Longitudinal axes \"longaxis\" require two double values, not %d.",nlong);
     53        if (nlat !=2) _error_("Latitudinal axes \"lataxis\" require two double values, not %d.",nlat);
     54        if (nlong!=2) _error_("Longitudinal axes \"longaxis\" require two double values, not %d.",nlong);
    6455        if (!nimages) _error_("No image files provided.");
    6556
    66         if ((int)dzip) {
     57        if ((int)dzip){
    6758                filkmz=filkml;
    68                 filkml=(char *) xmalloc(8*sizeof(char));
     59                filkml=(char*)mxMalloc(8*sizeof(char));
    6960                strcpy(filkml,"doc.kml");
    7061        }
    7162
    72         if (!strlen(filkml))
    73                 strcpy(filkml,"stdout");
     63        if(!strlen(filkml)) strcpy(filkml,"stdout");
    7464
    75         if (verbose) printf("Opening kml overlay file \"%s\".\n",filkml);
     65        if(verbose) printf("Opening kml overlay file \"%s\".\n",filkml);
    7666        fid=fopen(filkml,"w");
    7767
    7868        /* Run core computations: */
    7969        if (verbose) printf("Calling core:\n");
    80         KMLOverlayx(&ierror,
    81                                 lataxis,longaxis,
    82                                 nimages,pimages,
    83                                 fid);
     70        KMLOverlayx(&ierror,lataxis,longaxis,nimages,pimages,fid);
    8471
    8572        if (verbose) printf("Closing file \"%s\".\n",filkml);
     
    8875        /* Create kmz file, if specified: */
    8976        if ((int)dzip) {
    90                 czip=(char *) xmalloc((5+strlen(filkmz)+1+strlen(filkml)+1)*sizeof(char));
     77                czip=(char*)mxMalloc((5+strlen(filkmz)+1+strlen(filkml)+1)*sizeof(char));
    9178                czip[0]='\0';
    9279                strcat(czip,"!zip ");
     
    9683                for (i=0; i<nimages; i++)
    9784                        if (strlen(pimages[i]) && strncmp(pimages[i],"http",4)) {
    98                                 czip=(char *) xrealloc(czip,(strlen(czip)+1+strlen(pimages[i])+1)*sizeof(char));
     85                                czip=(char*)mxRealloc(czip,(strlen(czip)+1+strlen(pimages[i])+1)*sizeof(char));
    9986                                strcat(czip," ");
    10087                                strcat(czip,pimages[i]);
     
    125112}
    126113
    127 void KMLOverlayUsage(void)
    128 {
     114void KMLOverlayUsage(void){
    129115        _printf_(true,"KMLOverlay - KML file overlay module:\n");
    130116        _printf_(true,"\n");
     
    147133        _printf_(true,"\n");
    148134}
    149 
  • TabularUnified issm/trunk-jpl/src/modules/Kml2Exp/Kml2Exp.cpp

    r11933 r12049  
    1111        char    *filkml=NULL,*filexp=NULL;
    1212        int     sgn;
    13 
    1413        Options* options=NULL;
    1514        double   cm=0.,sp=0.;
     
    2322        /*checks on arguments on the matlab side: */
    2423        if (nlhs > NLHS) {
    25                 Kml2ExpUsage();
    26                 _error_("Kml2Exp usage error");
     24                Kml2ExpUsage(); _error_("Kml2Exp usage error");
    2725        }
    2826        if (nrhs < NRHS) {
    29                 Kml2ExpUsage();
    30                 _error_("Kml2Exp usage error");
     27                Kml2ExpUsage(); _error_("Kml2Exp usage error");
    3128        }
    3229
    3330        /*Input datasets: */
    34         if (verbose) printf("Fetching inputs:\n");
    3531        FetchData(&filkml,KML_IN);
    36         if (verbose) printf("  filkml=\"%s\"\n",filkml);
    3732        FetchData(&filexp,EXP_IN);
    38         if (verbose) printf("  filexp=\"%s\"\n",filexp);
    3933        FetchData(&sgn,SGN_IN);
    40         if (verbose) printf("  sgn=%d\n",sgn);
     34        FetchData(&options,NRHS,nrhs,prhs);
    4135
    42         if (verbose) printf("Parsing options:\n");
    43         options=new Options(NRHS,nrhs,prhs);
    44         if (options->Size()) for(i=0;i<options->Size();i++) ((Option*)options->GetObjectByOffset(i))->DeepEcho();
    4536        /*  defaults are in Ll2xydef, so don't duplicate them here, and only use user values if both have been specified  */
    4637        if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
     
    5243
    5344        /*some checks*/
    54         if (verbose) printf("Checking inputs:\n");
    55 
    56         if (sgn != +1 && sgn != -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
     45        if (sgn !=+1 && sgn!= -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
    5746        if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
    5847        if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
    5948
    6049        /* Run core computations: */
    61         if (verbose) printf("Calling core:\n");
    6250        if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
    63                 iret=Kml2Expx(filkml,filexp,
    64                                           sgn,cm,sp);
     51                iret=Kml2Expx(filkml,filexp,sgn,cm,sp);
    6552        else
    66                 iret=Kml2Expx(filkml,filexp,
    67                                           sgn);
    68         if (verbose) printf("  iret=%d\n",iret);
     53                iret=Kml2Expx(filkml,filexp,sgn);
    6954
    7055        /*Write data: */
     
    8065}
    8166
    82 void Kml2ExpUsage(void)
    83 {
     67void Kml2ExpUsage(void){
    8468        _printf_(true,"Kml2Exp - kml to exp file conversion module:\n");
    8569        _printf_(true,"\n");
  • TabularUnified issm/trunk-jpl/src/modules/Ll2xy/Ll2xy.cpp

    r11933 r12049  
    2525        /*checks on arguments on the matlab side: */
    2626        if (nlhs > NLHS) {
    27                 Ll2xyUsage();
    28                 _error_("Ll2xy usage error");
     27                Ll2xyUsage(); _error_("Ll2xy usage error");
    2928        }
    3029        if (nrhs < NRHS) {
    31                 Ll2xyUsage();
    32                 _error_("Ll2xy usage error");
     30                Ll2xyUsage(); _error_("Ll2xy usage error");
    3331        }
    3432
    3533        /*Input datasets: */
    36         if (verbose) printf("Fetching inputs:\n");
    3734        FetchData(&lat,&nlat,LAT_IN);
    38         if (verbose)
    39                 if   (nlat == 1) printf("  lat=%g\n",lat[0]);
    40                 else             printf("  lat=[%d values]\n",nlat);
    41 //      for (i=0; i<nlat; i++) printf("  lat[%d]=%g\n",i,lat[i]);
    4235        FetchData(&lon,&nlon,LON_IN);
    43         if (verbose)
    44                 if   (nlon == 1) printf("  lon=%g\n",lon[0]);
    45                 else             printf("  lon=[%d values]\n",nlon);
    46 //      for (i=0; i<nlon; i++) printf("  lon[%d]=%g\n",i,lon[i]);
    4736        FetchData(&sgn,SGN_IN);
    48         if (verbose) printf("  sgn=%d\n",sgn);
     37        FetchData(&options,NRHS,nrhs,prhs);
    4938
    50         if (verbose) printf("Parsing options:\n");
    51         options=new Options(NRHS,nrhs,prhs);
    52         if (options->Size()) for(i=0;i<options->Size();i++) ((Option*)options->GetObjectByOffset(i))->DeepEcho();
    5339        /*  defaults are in Ll2xydef, so don't duplicate them here, and only use user values if both have been specified  */
    54         if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
     40        if(options->GetOption("central_meridian") || options->GetOption("standard_parallel")){
    5541                options->Get(&cm,"central_meridian");
    5642                if (verbose) printf("  cm=%g\n",cm);
     
    6147        /*some checks*/
    6248        if (verbose) printf("Checking inputs:\n");
    63 
    64         if   (nlat != nlon) _error_("Must have same number of lat[%d] and lon[%d] coordinates.",nlat,nlon);
     49        if (nlat != nlon) _error_("Must have same number of lat[%d] and lon[%d] coordinates.",nlat,nlon);
    6550        else                ncoord=nlat;
    6651        if (sgn != +1 && sgn != -1) _error_("Hemisphere sgn=%d must be +1 (north) or -1 (south).",sgn);
     
    6853        if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
    6954
    70         x=(double *)xmalloc(ncoord*sizeof(double));
    71         y=(double *)xmalloc(ncoord*sizeof(double));
     55        x=(double*)mxMalloc(ncoord*sizeof(double));
     56        y=(double*)mxMalloc(ncoord*sizeof(double));
    7257
    7358        /* Run core computations: */
    74         if (verbose) printf("Calling core:\n");
    7559        if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
    76                 iret=Ll2xyx(x,y,
    77                                         lat,lon,ncoord,
    78                                         sgn,cm,sp);
     60                iret=Ll2xyx(x,y,lat,lon,ncoord,sgn,cm,sp);
    7961        else
    80                 iret=Ll2xyx(x,y,
    81                                         lat,lon,ncoord,
    82                                         sgn);
    83         if (verbose) printf("  iret=%d\n",iret);
     62                iret=Ll2xyx(x,y,lat,lon,ncoord,sgn);
    8463
    8564        /*Write data: */
     
    9473}
    9574
    96 void Ll2xyUsage(void)
    97 {
     75void Ll2xyUsage(void){
    9876        _printf_(true,"Ll2xy - lat/long to x/y coordinate transformation module:\n");
    9977        _printf_(true,"\n");
     
    11997        _printf_(true,"\n");
    12098}
    121 
  • TabularUnified issm/trunk-jpl/src/modules/Shp2Kml/Shp2Kml.cpp

    r11933 r12049  
    1818        char    *filshp=NULL,*filkml=NULL;
    1919        int     sgn;
    20 
    2120        Options* options=NULL;
    2221        double   cm=0.,sp=0.;
     
    3433        /*checks on arguments on the matlab side: */
    3534        if (nlhs > NLHS) {
    36                 Shp2KmlUsage();
    37                 _error_("Shp2Kml usage error");
     35                Shp2KmlUsage(); _error_("Shp2Kml usage error");
    3836        }
    3937        if (nrhs < NRHS) {
    40                 Shp2KmlUsage();
    41                 _error_("Shp2Kml usage error");
     38                Shp2KmlUsage(); _error_("Shp2Kml usage error");
    4239        }
    4340
    4441        /*Input datasets: */
    45         if (verbose) printf("Fetching inputs:\n");
    4642        FetchData(&filshp,SHP_IN);
    47         if (verbose) printf("  filshp=\"%s\"\n",filshp);
    4843        FetchData(&filkml,KML_IN);
    49         if (verbose) printf("  filkml=\"%s\"\n",filkml);
    5044        FetchData(&sgn,SGN_IN);
    51         if (verbose) printf("  sgn=%d\n",sgn);
     45        FetchData(&options,NRHS,nrhs,prhs);
    5246
    53         if (verbose) printf("Parsing options:\n");
    54         options=new Options(NRHS,nrhs,prhs);
    55         if (options->Size()) for(i=0;i<options->Size();i++) ((Option*)options->GetObjectByOffset(i))->DeepEcho();
    5647        /*  defaults are in Xy2lldef, so don't duplicate them here, and only use user values if both have been specified  */
    5748        if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
     
    6354
    6455        /*some checks*/
    65         if (verbose) printf("Checking inputs:\n");
    66 
    6756        if (sgn < -1 || sgn > +1) _error_("Hemisphere sgn=%d must be +1 (north), -1 (south), or 0 (no translation).",sgn);
    6857        if (fabs(cm)      > 180.) _error_("Central meridian cm=%g must be between -180 (west) and +180 (east) degrees.",cm);
     
    7059
    7160        /* Run core computations: */
    72         if (verbose) printf("Calling core:\n");
    7361        if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
    74                 iret=Shp2Kmlx(filshp,filkml,
    75                                           sgn,cm,sp);
     62                iret=Shp2Kmlx(filshp,filkml,sgn,cm,sp);
    7663        else
    77                 iret=Shp2Kmlx(filshp,filkml,
    78                                           sgn);
    79         if (verbose) printf("  iret=%d\n",iret);
     64                iret=Shp2Kmlx(filshp,filkml,sgn);
    8065
    8166        /*Write data: */
     
    9176}
    9277
    93 void Shp2KmlUsage(void)
    94 {
     78void Shp2KmlUsage(void){
    9579        _printf_(true,"Shp2Kml - shp to kml file conversion module:\n");
    9680        _printf_(true,"\n");
     
    11599        _printf_(true,"\n");
    116100}
    117 
  • TabularUnified issm/trunk-jpl/src/modules/Xy2ll/Xy2ll.cpp

    r11933 r12049  
    1212        int     nx,ny,ncoord;
    1313        int     sgn;
    14 
    1514        Options* options=NULL;
    1615        double   cm=0.,sp=0.;
     
    2524        /*checks on arguments on the matlab side: */
    2625        if (nlhs > NLHS) {
    27                 Xy2llUsage();
    28                 _error_("Xy2ll usage error");
     26                Xy2llUsage(); _error_("Xy2ll usage error");
    2927        }
    3028        if (nrhs < NRHS) {
    31                 Xy2llUsage();
    32                 _error_("Xy2ll usage error");
     29                Xy2llUsage(); _error_("Xy2ll usage error");
    3330        }
    3431
    3532        /*Input datasets: */
    36         if (verbose) printf("Fetching inputs:\n");
    3733        FetchData(&x,&nx,X_IN);
    38         if (verbose)
    39                 if   (nx == 1) printf("  x=%g\n",x[0]);
    40                 else           printf("  x=[%d values]\n",nx);
    41 //      for (i=0; i<nx; i++) printf("  x[%d]=%g\n",i,x[i]);
    4234        FetchData(&y,&ny,Y_IN);
    43         if (verbose)
    44                 if   (ny == 1) printf("  y=%g\n",y[0]);
    45                 else           printf("  y=[%d values]\n",ny);
    46 //      for (i=0; i<ny; i++) printf("  y[%d]=%g\n",i,y[i]);
    4735        FetchData(&sgn,SGN_IN);
    48         if (verbose) printf("  sgn=%d\n",sgn);
     36        FetchData(&options,NRHS,nrhs,prhs);
    4937
    50         if (verbose) printf("Parsing options:\n");
    51         options=new Options(NRHS,nrhs,prhs);
    52         if (options->Size()) for(i=0;i<options->Size();i++) ((Option*)options->GetObjectByOffset(i))->DeepEcho();
    5338        /*  defaults are in Xy2lldef, so don't duplicate them here, and only use user values if both have been specified  */
    5439        if (options->GetOption("central_meridian") || options->GetOption("standard_parallel")) {
     
    6045
    6146        /*some checks*/
    62         if (verbose) printf("Checking inputs:\n");
    63 
    6447        if   (nx != ny) _error_("Must have same number of x[%d] and y[%d] coordinates.",nx,ny);
    6548        else            ncoord=nx;
     
    6851        if (sp < 0. || sp >  90.) _error_("Standard parallel sp=%g must be between 0 and 90 degrees (in specified hemisphere).",sp);
    6952
    70         lat=(double *)xmalloc(ncoord*sizeof(double));
    71         lon=(double *)xmalloc(ncoord*sizeof(double));
     53        lat=(double*)mxMalloc(ncoord*sizeof(double));
     54        lon=(double*)mxMalloc(ncoord*sizeof(double));
    7255
    7356        /* Run core computations: */
    7457        if (verbose) printf("Calling core:\n");
    7558        if (options->GetOption("central_meridian") && options->GetOption("standard_parallel"))
    76                 iret=Xy2llx(lat,lon,
    77                                         x,y,ncoord,
    78                                         sgn,cm,sp);
     59                iret=Xy2llx(lat,lon,x,y,ncoord,sgn,cm,sp);
    7960        else
    80                 iret=Xy2llx(lat,lon,
    81                                         x,y,ncoord,
    82                                         sgn);
    83         if (verbose) printf("  iret=%d\n",iret);
     61                iret=Xy2llx(lat,lon,x,y,ncoord,sgn);
    8462
    8563        /*Write data: */
     
    9472}
    9573
    96 void Xy2llUsage(void)
    97 {
     74void Xy2llUsage(void){
    9875        _printf_(true,"Xy2ll - x/y to lat/long coordinate transformation module:\n");
    9976        _printf_(true,"\n");
Note: See TracChangeset for help on using the changeset viewer.