Skip to main content
FluidEarth Portal Header version 3

FluidEarth Portal

Go Search
  
FluidEarth Portal > FluidEarth Discussions > How to read data from files and write data to files  

FluidEarth Discussions

Modify settings and columns
Discussions board for FluidEarth Users
  
View: 
Post
Started: 08/12/2009 22:23
Attachment
Picture: ZZhang
ZZhang
How to read data from files and write data to files?

I want to wrap my model using OpenWEB SDK. But I am in trouble at the beginning. The model needs to read data from files and calculate, then write the result to files. I tried to modify the TemplateFtn model, but I don’t know how to do.

The attachments are code (a simplified programme) and input data.  

Can someone tell me which files or variables need to modify and how to modify?

Thanks.

Posted: 10/12/2009 12:45
Picture Placeholder: GGlasgow
GGlasgow
good to hear you're starting to wrap your own models.
 
as with anything, there are lots of different ways to go - in the OpenWEB_Workshop_09.zip i have uploaded is an example called Simple_2D; if you have a look at the Engine.f90 code, i open and read three different files during 'initialisation' and write generic output during 'compute'.
 
in your code, perhaps you might want to have the full file path as a mandatory argument in the omi file, which you would open as normal in initialise and write out in compute.
 
i will quickly rewrite your attached code and post a little later in the day.
 
good luck!
Posted: 10/12/2009 15:40
Attachment
Picture Placeholder: GGlasgow
GGlasgow
i've created the attached file (Engine.f90) from the code you posted and the fortran template from the workshop. worth noting that i've turned the hard-coded input and output file names into mandatory arguments to be read from the omi file. i would also do the same for imax and jmax, or have them read from a steering file.
 
hopefully this will get you started,
gordon
Posted: 13/04/2011 13:52
Picture Placeholder: ABarkwith
ABarkwith

Hi,

 

How would you do I/O files for c# projects in FluidEarth?

 

Andy

Posted: 14/04/2011 09:09
Attachment
Picture Placeholder: GGlasgow
GGlasgow
Hi Andy,
 
attached a renamed zip file containing a trivial c# example model that reads data from a file called fileIN.txt during initialisation and writes data to a file called fileOUT.txt during compute. i have commented the bits you need to look out for with '//GRG:', so if you search on that across the engine.cs file you will see what i am doing.
 
the model omi, xml and input text file are in /bin/data/ and should work without recompiling.

...the caveats!! 
 
1. please be aware i am not a c# programmer - this works, but may not be a terribly intelligent way of doing things.
 
2. i would suggest that there are likely to be many different ways of doing this kind of thing, and the attached is only an example to get you going; i would recommend you search msdn, codeproject or another online dev resource to find out what other (and most probably better) ways of doing this exist.
 
but other than that, i hope this gets you going.
 
good luck,
 
gordon