Yep.. I made that word up.

So I’ve been working on this project about “Entropic Turbulent Flow” and stuff. It’s way over my head the math they’re doing, but the data lends itself to some really neat pictures. It’s been alot of fun. I’ve been getting 128^3 datasets and doing some volume rendering and isosurface extraction, making some pretty movies. Then we got the big data.

The guy ran a simulation of a 512-cube, 5 data values per data point, 160 timesteps. He wrote all the output as ASCII Text. To further complicate it, it came in 1024 files. you might think, “well, he just has multiple files per timestep”. Well you’re close. He’s got 1 file per Processor the simulation ran on. Each file representing all timesteps of a different 64x64x32 block. Ewww.

He was, however, nice enough to send me a little snippet of fortran code that could take the 1024 1.7Gigabye (yes, that’s 2 Terabytes of data) files and combine them into 1 massive file, collating all the blocks. Unfortunately, he wrote it to work with the IBM XLF90 compiler, which I don’t have access to. No biggie, i’ll just modify it to work with the MipsPro F90 compiler. That’s what I thought. His code opened all 1024 files, and then read 1 timestep from each. Then the blocks were combined, and written to disk. Then the whole process was repeated for each timestep. Unfortunatley, the SGI’s here have a limitation of 1023 open files.. So close, yet so far. Not to mention, XLF90 apparently defaults all the file ID’s to files matching fort.fileid so “open” and “close” are unnecessary. So I have to add all that.

So, first thing first, programmatically constructing a filename and opening the file. I had to dig way back to my Junior year at MississippiStateUniversity and dig through alot of online help before I got this little nugget to work:

         if (iu .lt. 1000) then            write(unit=filename,fmt="(a,i3.3)") "fort.",iu         else            write(unit=filename,fmt="(a,i4.3)") "fort.",iu         end if         print*,'Opening ', filename         open(UNIT=200, FILE=filename, ACTION='READ')

So, one hurdle passed. But how to open 1024 files and read the data? Well, welcome to the world of Perl, master of ASCII text processing. Torey helped me write a small perl script to take each of the files and split them into 160 smaller ascii text files, one for each timestep. The resulting files were sorted into directories named after their timestep. Now, I could just modify the fortran code to open 1 file, read the data, then close it.

So that gave me my 160 Fortran Unformatted binary files. Then I wrote a C/C++ program that could convert these into VTK Legacy Format files (Binary, Image Data). Then I wrote a TclTk script that could control multiple instances of all these programs, so that I could process 5 files simultaneously.

So to recap, I used the following languages to solve this one problem:

  1. Fortran F90
  2. Perl
  3. C & C++
  4. Tcl

Not to mention the tcsh Shell scripts required to connect & automate it further. My old friend LouArata once said it’s important to know “the right tool for the job”, and not to be afraid to use it. I think he’ld be proud of this convoluted, but effective, solution.

Now to compute vorticity & do my renderings.. More Tcl & C for that, i’ve already done it.

No related posts.