Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

page 639

JohnNichols
Valued Contributor III
1,001 Views
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.  

4 Replies
Barbara_P_Intel
Employee
929 Views

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

 

0 Kudos
JohnNichols
Valued Contributor III
846 Views

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.  

0 Kudos
Barbara_P_Intel
Employee
741 Views

@JohnNichols, this example update is published to in the Fortran Developer Guide 2023.1.

Take a look!



0 Kudos
JohnNichols
Valued Contributor III
730 Views

@Barbara_P_Intel , following song is playing in the background as I read the guide

heroes for one day 

0 Kudos
Reply