- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
program FNAME
implicit none
integer,parameter :: k15 = selected_int_kind(15)
CHARACTER(10) str
INTEGER(kind=k15) n1, n2, n3
CHARACTER(14) fname
INTEGER(kind=k15) i
str = " 1 2 3"
! List-directed READ sets n1 = 1, n2 = 2, n3 = 3.
READ(str, *) n1, n2, n3
i = 4
! Formatted WRITE sets fname = 'FM004.DAT'.
WRITE (fname, 200) i
200 FORMAT ('FM', I3.3, '.DAT')
write(*,*)fname
END
A little bit closer to what the people like at the moment.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, @JohnNichols! I filed a feature request to update the Internal Files example.
Karen again sends her thanks for caring about the documentation.
I tweaked your code a bit. It wouldn't compile. Compiler didn't like the PROGRAM name matching a variable name.
PROGRAM INTERNALFILES
implicit none
integer,parameter :: k15 = selected_int_kind(15)
CHARACTER(10) str, fname
INTEGER(kind=k15) i, n1, n2, n3
str = " 1 2 3"
! List-directed READ sets n1 = 1, n2 = 2, n3 = 3.
READ(str, *) n1, n2, n3
i = 4
! Formatted WRITE sets fname = 'FM004.DAT'.
WRITE (fname, 200) i
200 FORMAT ('FM', I3.3, '.DAT')
write(*,*)fname
END PROGRAM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Interesting, I copied the code from my VS sample code SLN file, it compiled there. Must be my mistake.
I spent a week in London and the UK without access to this board, it is amazing how much you miss these people.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@JohnNichols, this example update is published to in the Fortran Developer Guide 2023.1.
Take a look!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Barbara_P_Intel , following song is playing in the background as I read the guide

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page