Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Fortran Programming Language

Output problem


Hi All,

I have the problem which contains the following three lines:
    write(6,'f25.28') output_1(1)
    write(6,'f35.28') output_1(1)
    write(6,*) output_1(1)

These lines produce the following output (also three lines):
*************************
***********************************
    3071248.096113024

Does anybody know why it happens?

Thanks.

In f25.28

the 25 is the full width of the field, including digits to the right
and to the left of the decimal point, the point itself, and possibly a
minus sign.

the 28 is supposed to be the number of decimal places you want to see.

So, the number of places on the left of the decimal point is 25 - 28 -
1.  Which in your case is a negative number...you have an error there.

For f35.28

you only have 6 columns on the left of the decimal point (35 - 28 - 1)
but the value that you are trying to print has 7...so fortran is not
going to display anything because it does not fit...so it fills it
with asterisks.

gsal

On Apr 11, 12:08 pm, "Kurda Yon" <kurda@yahoo.com> wrote:

>     write(6,'f35.28') output_1(1)
>     write(6,*) output_1(1)
...
> ***********************************
>     3071248.096113024

The f35.28 format spec wants to put 28 digits after
the decimal point.  Counting the decimal point itself,
that leaves only 6 more characters in the output field
in which to place the digits before the decimal point.
Your number has seven such digits: no room for all of
them.  The Fortran rule is to put asterisks in the
whole field it there's no room.

--
J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies."   --  C. A. R. Hoare

On Apr 11, 1:08 pm, "Kurda Yon" <kurda@yahoo.com> wrote:

> Hi All,

> I have the problem which contains the following three lines:
>     write(6,'f25.28') output_1(1)
>     write(6,'f35.28') output_1(1)
>     write(6,*) output_1(1)

> These lines produce the following output (also three lines):
> *************************
> ***********************************
>     3071248.096113024

> Does anybody know why it happens?

> Thanks.

Try this (the first value is the total field width, the second value
is number of places after the decimal, you'll probably want a larger
value, but this matches the current value):

real(8) :: output = 3071248.096113024_8
write(6,'(f17.9)') output

end

On Apr 11, 1:08 pm, "Kurda Yon" <kurda@yahoo.com> wrote:

> Hi All,

> I have the problem which contains the following three lines:
>     write(6,'f25.28') output_1(1)
>     write(6,'f35.28') output_1(1)
>     write(6,*) output_1(1)

> These lines produce the following output (also three lines):
> *************************
> ***********************************
>     3071248.096113024

> Does anybody know why it happens?

> Thanks.

Oops, I hard coded a kind value for my own use, ignore that part.
On Apr 11, 2:08 pm, "Kurda Yon" <kurda@yahoo.com> wrote:

> Hi All,

> I have the problem which contains the following three lines:
>     write(6,'f25.28') output_1(1)
>     write(6,'f35.28') output_1(1)
>     write(6,*) output_1(1)

> These lines produce the following output (also three lines):
> *************************
> ***********************************
>     3071248.096113024

> Does anybody know why it happens?

> Thanks.

You have overflowed your output field widths. Fx.y is x characters
wide with y digits after the decimal point. What is left must contain
a decimal point, any digits to the left of the decimal point, and a
negative sign if it is present. In the first format you have -4 digits
left. In the second case you have 6 left but need to print 7.

Either try a more reasonable F format, or use E or G or as you do in
the last example "list directed" format.

-- elliot

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc