Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing fortran type to file then reading it

Status
Not open for further replies.

ArmenD

Programmer
Feb 3, 2005
101
US
ok so would some one plz explain what is gained by writing a fortran type (40F1.0) to file then reading it in?
FMAT is fortran type
CHARACTER FMAT1(127)


OPEN (10,FILE='NEWT',STATUS='NEW')
WRITE (10,'(A)') FMAT
CLOSE (10)
OPEN (10,FILE='NEWT')
READ (10,5)(FMAT1(I), I = 1,127)
5 FORMAT (127A1)
CLOSE (10)
 
What sort of Fortran type is FMAT? There are simple and difficult ways of doing things. If, for instance FMAT is CHARACTER*127 then they could code it as
Code:
      do i = 1, 127, 1
         FMAT1(i) = FMAT(i:i)
      enddo
 
yes,FMAT is CHARACTER*127
what does FMAT(i:i) mean?
 
It is the ith character. Say
Code:
!       12345678
FMAT = 'For Matt'
FMAT(2:2) is 'o' the 2nd character
FMAT(5:5) is 'M' the 5th character
 
so suppose we have something like...
READ(10,'(A)')FMAT3

what does '(A)' mean?
what does '(A\)' mean?
 
'(A)' is a text string
There is no '(A\)' - you probably meant '(A/)'. This means skip a line after reading the text string.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top