The Queen's University of Belfast
Parallel Computer Centre

[Next] [Previous] [Top]

Interactive input and output


Interactive input and output

Topics

I/O Overview

Background

FORMAT Statement

label FORMAT( list )

where list is a list of edit descriptors drawn from:

I,F,E,ES,EN,D,G,L,A,H,T,TL,TR,X,P,

BN,BZ,SP,SS,S,/,:,'

Examples:

READ(*,100) i,j

WRITE(*,100) i,j

READ(*,FMT=200) x,y

WRITE(*,200) x,y

100 FORMAT(2I)

200 FORMAT(2F10.6)

READ(*,'(2I)') i,j

WRITE(*,'(2F12.6)') x,y

Edit Descriptors

I,F,E,ES,EN,A,X,/,:,',()

I

I I6 I10.3 5I 4I6.4

WRITE (6,`(I6.4)`) 56

would ouput two spaces followed by 0056

F

WRITE(6,`(2F12.6)`) 12.6, -131.45678

would output:

^^^12.600000 -131.456780

E, ES, EN

A, X, L

Special characters

Input/Output Lists

Implied DO Loop

(do_list, var=start,stop[,step])

INTEGER :: i, j

REAL, DIMENSION(10) :: a

REAL, DIMENSION(10,10) :: b

READ(*,*) (a(j),j=1,10)

WRITE(*,*) (a(j), j=10,1,-1)

WRITE(*,*) ((b(i,j),i=1,10), j=1,10)

The last WRITE satatement prints b(1,1), b(2,1), b(3,1), ...etc.

Namelist

NAMELIST /group_name/ variable_list

Examples

NAMELIST /week/ mon, tues

NAMELIST/week/ sat, sun, thur

mon = 2

tues = 3

sat = 1

WRITE(*,NML=week)

will produce:

&WEEK MON=2, TUES=3, SAT=1.../

&group-name var=value [,var=value]/

INTEGER, DIMENSION(10) :: items

NAMELIST /group/items

items(1) = 1

...

WRITE(*,NML=group)

would produce:

&group items(1)=1, items(2:10)=0 /

Non-Advancing I/O

READ(*,*,ADVANCE='YES') ...

WRITE(*,*, ADVANCE='NO') ...

Examples

WRITE(*,*,ADVANCE='NO') 'value? '

READ(*,*) I

This would appear as

value? 10

CHARACTER(LEN=32) :: filename

INTEGER :: length

bb: DO

WRITE(*,*, ADVANCE='NO') 'File? '

READ(*,*,ADVANCE='NO',EOR=20,&

SIZE=length) filename

OPEN(10,FILE=filename(1:LENGTH))

EXIT bb

20 WRITE(*,*)'error...'

END DO


[Next] [Previous] [Top]
All documents are the responsibility of, and copyright, © their authors and do not represent the views of The Parallel Computer Centre, nor of The Queen's University of Belfast.
Maintained by Alan Rea, email A.Rea@qub.ac.uk
Generated with CERN WebMaker