Changeset 9111


Ignore:
Timestamp:
07/25/11 13:20:15 (14 years ago)
Author:
Eric.Larour
Message:

Fixed problem with 0 sizes requested outputs + model consistency checks.

Location:
issm/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/Params/IntVecParam.cpp

    r8224 r9111  
    3232        M=in_M;
    3333
    34         values=(int*)xmalloc(M*sizeof(int));
    35         memcpy(values,in_values,M*sizeof(int));
     34        if(M){
     35                values=(int*)xmalloc(M*sizeof(int));
     36                memcpy(values,in_values,M*sizeof(int));
     37        }
     38        else values=NULL;
    3639}
    3740/*}}}*/
     
    4245        M=in_M;
    4346
    44         values=(int*)xmalloc(M*sizeof(int));
    45         for(int i=0;i<in_M;i++) values[i]=(int)in_values[i];
     47        if(M){
     48                values=(int*)xmalloc(M*sizeof(int));
     49                for(int i=0;i<in_M;i++) values[i]=(int)in_values[i];
     50        }
     51        else values=NULL;
    4652}
    4753/*}}}*/
     
    103109        memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
    104110        memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M);
    105         memcpy(marshalled_dataset,values,M*sizeof(int));marshalled_dataset+=M*sizeof(int);
     111        if(M)memcpy(marshalled_dataset,values,M*sizeof(int));marshalled_dataset+=M*sizeof(int);
    106112
    107113        *pmarshalled_dataset=marshalled_dataset;
     
    132138        /*data: */
    133139        memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M);
    134         values=(int*)xmalloc(M*sizeof(int));
    135         memcpy(values,marshalled_dataset,M*sizeof(int));marshalled_dataset+=M*sizeof(int);
     140        if(M) {
     141                values=(int*)xmalloc(M*sizeof(int));
     142                memcpy(values,marshalled_dataset,M*sizeof(int));marshalled_dataset+=M*sizeof(int);
     143        }
    136144
    137145        /*return: */
     
    160168        int* output=NULL;
    161169
    162         output=(int*)xmalloc(M*sizeof(int));
    163         memcpy(output,values,M*sizeof(int));
     170        if(M){
     171                output=(int*)xmalloc(M*sizeof(int));
     172                memcpy(output,values,M*sizeof(int));
     173        }
    164174
    165175        /*Assign output pointers:*/
     
    186196
    187197        /*cast intvec into doublevec for Matlab*/
    188         doublevec=(double*)xmalloc(M*sizeof(double));
    189         for(int i=0;i<M;i++)doublevec[i]=(double)intvec[i];
     198        if(M){
     199                doublevec=(double*)xmalloc(M*sizeof(double));
     200                for(int i=0;i<M;i++)doublevec[i]=(double)intvec[i];
     201        }
     202        else doublevec=NULL;
    190203        xfree((void**)&intvec);
    191204                               
     
    205218        xfree((void**)&this->values);
    206219
    207         this->values=(int*)xmalloc(in_M*sizeof(int));
    208         memcpy(this->values,intarray,in_M*sizeof(int));
     220        if(in_M){
     221                this->values=(int*)xmalloc(in_M*sizeof(int));
     222                memcpy(this->values,intarray,in_M*sizeof(int));
     223        }
     224        else this->values=NULL;
    209225
    210226        this->M=in_M;
  • issm/trunk/src/m/model/ismodelselfconsistent.m

    r9110 r9111  
    101101fields={'diagnostic_ref'};
    102102checksize(md,fields,[md.numberofnodes 6]);
    103 if(size(md.requested_outputs,2)~=1),
    104         message(['model ' md.name ' requested outputs should be a column vector']);
     103if ~isempty(md.requested_outputs),
     104        if(size(md.requested_outputs,2)~=1),
     105                message(['model ' md.name ' requested outputs should be a column vector']);
     106        end
    105107end
    106108%}}}
Note: See TracChangeset for help on using the changeset viewer.