Skip to content

Commit

Permalink
- Added description to matlab reader
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9101 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed May 25, 2011
1 parent e443e0c commit b649ab7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
26 changes: 24 additions & 2 deletions c_runtime/read_matlab4.c
Expand Up @@ -137,8 +137,30 @@ const char* omc_new_matlab4_reader(const char *filename, ModelicaMatReader *read
}
break;
}
case 2: {
if (-1==fseek(reader->file,matrix_length,SEEK_CUR)) return "Corrupt header: description matrix";
case 2: { /* description */
if (binTrans==1) {
for (i=0; i<hdr.ncols; i++) {
reader->allInfo[i].name = (char*) malloc(hdr.mrows+1);
if (fread(reader->allInfo[i].name,hdr.mrows,1,reader->file) != 1) return "Corrupt header: names matrix";
reader->allInfo[i].descr[hdr.mrows] = '\0';
}
} else if (binTrans==0) {
int j;
char* tmp = (char*) malloc(hdr.ncols*hdr.mrows+1);
if (fread(tmp,hdr.ncols*hdr.mrows,1,reader->file) != 1) {
free(tmp);
return "Corrupt header: names matrix";
}
for (i=0; i<hdr.mrows; i++) {
reader->allInfo[i].descr = (char*) malloc(hdr.ncols+1);
for(j=0; j<hdr.ncols; j++) {
reader->allInfo[i].descr[j] = tmp[j*hdr.mrows+i];
}
reader->allInfo[i].descr[hdr.ncols] = '\0';
/* fprintf(stderr, " Adding variable %s\n", reader->allInfo[i].name); */
}
free(tmp);
}
break;
}
case 3: { /* "dataInfo" */
Expand Down
2 changes: 1 addition & 1 deletion c_runtime/read_matlab4.h
Expand Up @@ -15,7 +15,7 @@ typedef struct {
} MHeader_t;

typedef struct {
char *name;
char *name,*descr;
int isParam;
/* Parameters are stored in data_1, variables in data_2; parameters are defined at any time, variables only within the simulation start/stop interval */
int index;
Expand Down

0 comments on commit b649ab7

Please sign in to comment.