Re: directory listing
- From: fj <francois.jacq@xxxxxxx>
- Date: Wed, 29 Aug 2007 03:09:14 -0700
On 29 août, 09:16, Arjen Markus <arjen.mar...@xxxxxxxxxx> wrote:
On 29 aug, 00:08, fj <francois.j...@xxxxxxx> wrote:
On 28 août, 22:23, gokha...@xxxxxxxxx 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="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
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="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=0
DO
READ(15,"(A)",END=10) cfile
write(*,*) TRIM(cfile)
ENDDO
10 CONTINUE
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
.
- References:
- directory listing
- From: gokhalen
- Re: directory listing
- From: fj
- Re: directory listing
- From: Arjen Markus
- directory listing
- Prev by Date: Re: directory listing
- Next by Date: Re: generic interface question
- Previous by thread: Re: directory listing
- Next by thread: Re: directory listing
- Index(es):
Relevant Pages
|
|