Re: conversion from type character to type real



In article <1ace9f06.0504290709.117ee657@xxxxxxxxxxxxxxxxxx>,
christina.goerner@xxxxxx (Crissy) wrote:

> I have to read them out of the header an convert them
> into type real. But an additional problem is (in my opinion), that
> these numbers have a "," instead of a "." as decimal separation.
> Does anyone have a good idea how to realize this problem with F90? Is
> it possible with an internal read statement? (I use the Compaq Visual
> Fortran 6 compiler.)

You've found the internal read statement. Good, that's the most
important part of the answer. For the comma "problem", there are
several approaches.

1. In F2003, you could just add decimal='comma' to the READ statement. I
don't think that CVF supports that yet (it being a feature new to
f2003), but I haven't really looked and it is at least possible.

2. I assume that you already got the data into a character variable, or
know how to do so. (If my assumption is wrong, that's the first step).
Just find the commas and replace them with periods before doing the
internal read. The INDEX() intrinsic function can be used to find the
commas. This is probably the approach I would use (until the f2003
feature becomes widely available).

Lots of other ways are possible, but most are more complicated.

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.



Relevant Pages

  • Re: Image as excel sheet
    ... I notice that there are both commas and semicolons on the lines. ... Is it correct that what you showed us is all header lines? ... string to numeric convertors. ... and str2double) applied to a char array will also work ...
    (comp.soft-sys.matlab)
  • RE: parsing a CSV file with more fields than column names
    ... If you have some commas in your data then you might have to adjust your ... I have a CSV file whose first line is a header. ... Image,Envelope Image,Page Images ...
    (perl.beginners)
  • Re: Munged Headers....
    ... |> header is a text comment field and not an address. ... | invalid escapes were between the quotes. ... The most notable thing about this is that both the quotes and the commas ... Bruno, could you attach Frank's original message, as it is in _your_ ...
    (Fedora)
  • Re: text file for mail merge stumped
    ... when I recorde the macro I go all the way thru to close and save the doc. ... Doug Robbins - Word MVP ... similar in header seperator setting. ... "entries" separated by commas, running the following code will convert ...
    (microsoft.public.word.vba.beginners)
  • Re: Tobacco, anyone???
    ... would notice (my home-grown news/mail reader does NOT display news as ... header, which *should* be all that matters anyway. ... manually take the commas out and see what happens... ...
    (rec.models.railroad)