Output data to file in Fortran 6F10.3 format

  • Thread starter Thread starter wsalden
  • Start date Start date
W

wsalden

I'm a new to writing Excel macros and have hit a bit of a wall.

I'm using Excel to pre-process data for an old Fortran Application. I
requires a .dat file containing a preamble and then data in a 6F10.
format.

The Excel data I want to write to the file is formatted as Number wit
3 decimals (+ or -). I have a macro that creates the file and preamble
I can read all the data, but I'm having trouble getting the 6 column
of F10.3 to format properly. The blank spaces are 'space' (Chr32). Th
negative sign is left of the most significant figure, not to the lef
of the field.

An example of the desired record, partial first two rows is:

12.345 -123.456 0.023 (3 more)...
100.000 -0.123 -12.120 (3 more)...

(it looks better with non-proportional type)

I've been try to manually format as text strings, but I think ther
must be a better way.

I'd appreciate any help or comments.
Thanks
Walte
 
It absolutely can be done: it depends on the format in which the data
appears. For instance, if the data is 6 figures on one row that need
to be spaced in a particular way, your approach will be different than
if the data exists as six individual figures that are concatenated
into a row. How do you get the data?
 
Thanks for your reply.

The data I have are hourly measurements originally in an excel column
There are about 750 rows per month. I do all pre-processing an
bad-data checking in excel. When I'm happy with the data I start th
macro.

My macro excutes a do-loop which starts at the first record and goe
down the column until the last record is found. This part works OK. S
essentially after reading every 6th record I want to output a line t
the .dat file. This is were I get messed up with loss of trailing 0'
and added width due to the negative signs. I thinks what's happening i
that I'm being careless with conversions between strings and numerics.

I don't need the macro to do any serious error checking as that'
already been done.

Thanks again.

Walte
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top