For Programmers: Free Programming Magazines  


Home > Archive > Fortran > August 2007 > directory listing









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author directory listing
gokhalen@gmail.com

2007-08-28, 7:12 pm

Hello:

Is there a way to obtain a list of files having a specified extension
using Fortran /Intel Fortran 9.1?


Thanks,

-Nachiket

Steve Lionel

2007-08-28, 7:12 pm

On Aug 28, 4:23 pm, gokha...@gmail.com wrote:

> Is there a way to obtain a list of files having a specified extension
> using Fortran /Intel Fortran 9.1?


Look in the on-disk documentation for the library routine
GETFILEINFOQQ.

If you have further questions about Intel Fortran, please visit our
user forum at http://softwarecommunity.intel.com/.../ShowForum.aspx
or contact Intel Premier Support.


Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH

User communities for Intel Software Development Products
http://softwareforums.intel.com/
Intel Fortran Support
http://support.intel.com/support/pe...cetools/fortran
My Fortran blog
http://www.intel.com/software/drfortran

fj

2007-08-28, 7:12 pm

On 28 ao=FBt, 22:23, gokha...@gmail.com wrote:
> Hello:
>
> Is there a way to obtain a list of files having a specified extension
> using Fortran /Intel Fortran 9.1?
>
> Thanks,
>
> -Nachiket

Using the specific Intel library is OK but a "more portable" way
consists in calling the routine SYSTEM available with most compilers.
But it remains necessary to test the operating system :

CHARACTER(10) :: extension=3D"f90"
CHARACTER(255) :: cfile

IF(os =3D=3D "unix") THEN
CALL system('ls -1 -p *.'//TRIM(extension)//'> list')
ELSE
CALL system('dir /b/ad/on *.'//TRIM(extension)//'> list')
ENDIF

Notice the options used respectively for the os dependent commands
"ls" and "dir" : they provide a very similar result ! After that, you
just have to open the file "list" and read each line using the format
"(A)" :

OPEN(15,file=3D"list") ! of course you can use another unit or even
select a free unit
! or even select a free unit (not used) but this
is another story
n=3D0
DO
READ(15,"(A)",END=3D10) cfile
write(*,*) TRIM(cfile)
ENDDO
10 CONTINUE


Arjen Markus

2007-08-29, 4:28 am

On 29 aug, 00:08, fj <francois.j...@irsn.fr> wrote:
> On 28 ao=FBt, 22:23, gokha...@gmail.com wrote:> Hello:
>
>
>
>
> Using the specific Intel library is OK but a "more portable" way
> consists in calling the routine SYSTEM available with most compilers.
> But it remains necessary to test the operating system :
>
> CHARACTER(10) :: extension=3D"f90"
> CHARACTER(255) :: cfile
>
> IF(os =3D=3D "unix") THEN
> CALL system('ls -1 -p *.'//TRIM(extension)//'> list')
> ELSE
> CALL system('dir /b/ad/on *.'//TRIM(extension)//'> list')
> ENDIF
>
> Notice the options used respectively for the os dependent commands
> "ls" and "dir" : they provide a very similar result ! After that, you
> just have to open the file "list" and read each line using the format
> "(A)" :
>
> OPEN(15,file=3D"list") ! of course you can use another unit or even
> select a free unit
> ! or even select a free unit (not used) but this
> is another story
> n=3D0
> DO
> READ(15,"(A)",END=3D10) cfile
> write(*,*) TRIM(cfile)
> ENDDO
> 10 CONTINUE


Small note: the option /ad means select only directories

Interesting idea though.

Regards,

Arjen

Les

2007-08-29, 4:28 am


>"fj" <francois.jacq@irsn.fr> wrote in message
>news:1188338937.234057.70310@y42g2000hsy.googlegroups.com...

On 28 août, 22:23, gokha...@gmail.com wrote:
>Using the specific Intel library is OK but a "more portable" way
>consists in calling the routine SYSTEM available with most compilers.
>But it remains necessary to test the operating system :
>
>CHARACTER(10) :: extension="f90"
>CHARACTER(255) :: cfile
>
>IF(os == "unix") THEN
> CALL system('ls -1 -p *.'//TRIM(extension)//'> list')
>ELSE
> CALL system('dir /b/ad/on *.'//TRIM(extension)//'> list')
>ENDIF


Or for those compilers where SYSTEM is a function not a subroutine

ivalue = system( ... )


Les


fj

2007-08-29, 8:07 am

On 29 ao=FBt, 09:16, Arjen Markus <arjen.mar...@wldelft.nl> wrote:
> On 29 aug, 00:08, fj <francois.j...@irsn.fr> wrote:
>
>
>
>
>
>
>
>
>
>
>
>
> Small note: the option /ad means select only directories
>
> Interesting idea though.
>
> Regards,
>
> Arjen


Right ... a bug again ! I copied an example dedicated to get sub-
directories only. Sorry

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com