Re: Newbie question
beliavsky_at_aol.com
Date: 02/26/05
- Next message: Gib Bogle: "Re: Call exported subroutine within DLL"
- Previous message: OIx: "Newbie question"
- In reply to: OIx: "Newbie question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Feb 2005 14:44:16 -0800
OIx wrote:
> Hi! I have a fortran program, that creates mesh for two-dim. area. I
> have to load nodes into Ansys, therefore i have to write node
> coordinates into specifically formatted file. The bad thing is i do
not
> know how to do it, so please help!
>
> I have the following piece of code:
>
> OPEN(UNIT, FILE='Grid', FORM = 'FORMATTED', STATUS= 'REPLACE',
> IOSTAT=error)
> WRITE(UNIT, FMT='(F8.5)') ((X(i,j), Y(i,j), j=1, N2_G), i=1, N1_G)
> CLOSE(UNIT)
>
> I writes coordinates line by line:
> x11
> y11
> x12
> y12
> etc.
>
> Instead of this, i'd like it to write as
> NODE_NUMBER X Y Z
> i.e.
> (i*N2_G +j) Xij Yij 0
>
> I'm absolutely new to fortran, and it's doesnot look like C or smth.
at
> all :))
Why should Fortran look like C? We got there first :).
You need to change the FMT='(F8.5)' part of the write statement. For
example, FMT='(1x,i6,1000F8.5)' will print an integer followed by up to
1000 reals on one line.
I think one of the tutorials at
http://www.dmoz.org/Computers/Programming/Languages/Fortran/Tutorials/Fortran_77/
, perhaps the book by Clive Page, discusses the syntax of format
strings. They are not that different from formats of the C printf
statement, although C does not have the handy repeat edit descriptor,
does have the handy newline character, and by default does not start
the output of each printf on a new line.
- Next message: Gib Bogle: "Re: Call exported subroutine within DLL"
- Previous message: OIx: "Newbie question"
- In reply to: OIx: "Newbie question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|