(j3.2006) So that I don't need to do stuff already done....

Bill Long longb
Wed Oct 19 08:41:32 EDT 2016


On Oct 19, 2016, at 7:24 AM, Dan Nagle <danlnagle at me.com> wrote:

> Hi,
> 
>> On Oct 18, 2016, at 23:59 , Van Snyder <Van.Snyder at JPL.NASA.GOV> wrote:
>> 
>> I think it's more likely the system will have POSIX functions for
>> reading directory contents than that it will have the "ls" command.
> 
> Changing 'ls' to (say) 'dir' may be done at runtime.

Right.  The argument to execute_command_line can be a variable that is defined based on some detection of the system environment.   The point of my example was to be simple - a production code would likely include more error checking. 

> Trying to run with a missing library external might be difficult.
> 

Indeed.  Based on the predictions I?ve seen, Linux (and Unix-like systems like Mac OS-X) probably extends farther into the future than POSIX I/O. 

Cheers,
Bill

>> 
>> On Wed, 2016-10-19 at 02:28 +0000, Bill Long wrote:
>>> Seems like a hard way get a list of the files in a directory.  And depends on the file system being POSIX.   Why not do something easy, like
>>> 
>>> program readdir
>>> implicit none
>>> character(1000) :: filename
>>> integer :: u,ios
>>> 
>>> call execute_command_line ("ls -1 > names.txt")
>>> open (newunit=u, file="names.txt")
>>> do 
>>>    read (u,"(a)", iostat=ios) filename
>>>    if (ios /= 0) exit
>>>    write (*,*) trim(filename)
>>> end do
>>> 
>>> end program readdir
>>> 
>>> 
>>> Cheers,
>>> Bill
>>> 
>>> 
>>> On Oct 18, 2016, at 9:13 PM, Van Snyder <Van.Snyder at jpl.nasa.gov> wrote:
>>> 
>>>> So that I don't need to do stuff that somebody else has almost certainly
>>>> already done...
>>>> 
>>>> Has anybody written interfaces to POSIX routines opendir, readdir and
>>>> closedir, and used them to read the file names in a directory?
>>>> 
>>>> NAG provides wrappers for these routines in f90_unix_dirent (and perhaps
>>>> others do something similar), but since I'm required to use several
>>>> processors I'd prefer something open-source and based on Clause 18.
>>>> 
>>>> 
>>>> _______________________________________________
>>>> J3 mailing list
>>>> J3 at mailman.j3-fortran.org
>>>> http://mailman.j3-fortran.org/mailman/listinfo/j3
>>> 
>>> Bill Long                                                                       longb at cray.com
>>> Fortran Technical Support  &                                  voice:  651-605-9024
>>> Bioinformatics Software Development                     fax:  651-605-9142
>>> Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101
>>> 
>>> 
>> 
>> 
>> _______________________________________________
>> J3 mailing list
>> J3 at mailman.j3-fortran.org
>> http://mailman.j3-fortran.org/mailman/listinfo/j3
> 
> 
> --
> 
> Cheers!
> Dan Nagle
> 
> 
> 
> 
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Bill Long                                                                       longb at cray.com
Fortran Technical Support  &                                  voice:  651-605-9024
Bioinformatics Software Development                     fax:  651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101





More information about the J3 mailing list