Re: conversion from type character to type real
- From: Richard E Maine <nospam@xxxxxxxxxxxxx>
- Date: Fri, 29 Apr 2005 08:30:56 -0700
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
.
- References:
- conversion from type character to type real
- From: Crissy
- conversion from type character to type real
- Prev by Date: Re: compilation problem with module function interface definition
- Next by Date: Re: Set union
- Previous by thread: conversion from type character to type real
- Index(es):
Relevant Pages
|