Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@697 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
henjo
committed
Jan 28, 2002
1 parent
98985f9
commit 1b30074
Showing
3 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
#include "read_write.h" | ||
|
||
void read_modelica_real(FILE* file, modelica_real* data) | ||
{ | ||
float f; | ||
fscanf(file,"%e",&f); | ||
*data = f; | ||
} | ||
|
||
void read_real_array(FILE* file, real_array_t* arr) | ||
{ | ||
int nr_elements; | ||
int i; | ||
float f; | ||
nr_elements = real_array_nr_of_elements(arr); | ||
for (i = 0; i < nr_elements; ++i) | ||
{ | ||
fscanf(file,"%e",&f); | ||
arr->data[i] = f; | ||
} | ||
} | ||
|
||
void write_modelica_real(FILE* file, modelica_real* data) | ||
{ | ||
fprintf(file,"%e\n",*data); | ||
} | ||
|
||
void write_real_array(FILE* file, real_array_t* arr) | ||
{ | ||
int nr_elements; | ||
int i; | ||
nr_elements = real_array_nr_of_elements(arr); | ||
for (i = 0; i < nr_elements; ++i) | ||
{ | ||
fprintf(file,"%e",arr->data[i]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef READ_WRITE_H_ | ||
#define READ_WIRTE_H_ | ||
|
||
#include <stdio.h> | ||
#include "modelica.h" | ||
|
||
#define PRE_VARIABLES FILE *in_file,*out_file;int close_file; | ||
#define PRE_OPEN_FILE(fv,fn,m,df) if(strcmp("-",fn)==0){fv=df;close_file=0;}else{fv=fopen(fn,m);close_file=1;if(!fv){return errno;}} | ||
|
||
#define PRE_OPEN_INFILE PRE_OPEN_FILE(in_file,in_filename,"r",stdin) | ||
#define PRE_OPEN_OUTFILE PRE_OPEN_FILE(out_file,out_filename,"w",stdout) | ||
#define PRE_READ_DONE if (close_file) fclose(in_file); | ||
#define PRE_WRITE_DONE if (close_file) fclose(out_file); | ||
|
||
void read_modelica_real(FILE*,modelica_real*); | ||
void read_real_array(FILE*,real_array_t*); | ||
void write_modelica_real(FILE*,modelica_real*); | ||
void write_real_array(FILE*,real_array_t*); | ||
|
||
#endif |