Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

File/Directory managment question

TommyCee
Beginner
4,101 Views

1) I'm well aware of the intrinsic inquire function which applies to a statement like:

inquire (file = "FileName.inp", exist=result)

But suppose I want to inquire about the existence of a Directory.  Is there a counterpart statement for this?  In some checking I've done, I haven't been able to find such.

2) Suppose we can find a way to determine the existence of some Directory.  If for a statement like the above result = .true., then suppose we want to purge (delete) it from an earlier run (so it can be created anew).  Is there a simple command to Remove this Directory?

In preliminary checking, I'm not sure I have seen a reliable command for this, especially one that isn't very dependent on the library one is using.  FWIW, in my case, I'm using DFlib (not iFort).

In DOS, I could always do this very easily.

0 Kudos
1 Solution
andrew_4619
Honored Contributor III
4,103 Views

I have to say (echoing FortranFan) that in my commercial applications which are windows based I would use windows sdk routines and standard Fortran only. Pumping out external commands such as I exampled I tend to use in 'for my own benefit only' quick bits of code as you can do a lot with very little code if you don't have all the potential pitfalls to secure against.  Sticking a command that can kill entire directory trees without warning is a bit of a worrying one if you have not been ultra careful in its use.

Anyway, TommyCee, I'm glad you found a result suitable for your needs and learned a couple of things which it the main objective and benefit of participating in forums such as this. I learn useful things here all the time....

 

View solution in original post

0 Kudos
27 Replies
TommyCee
Beginner
807 Views

Duly noted.  I appreciate your perspective.

0 Kudos
andrew_4619
Honored Contributor III
4,104 Views

I have to say (echoing FortranFan) that in my commercial applications which are windows based I would use windows sdk routines and standard Fortran only. Pumping out external commands such as I exampled I tend to use in 'for my own benefit only' quick bits of code as you can do a lot with very little code if you don't have all the potential pitfalls to secure against.  Sticking a command that can kill entire directory trees without warning is a bit of a worrying one if you have not been ultra careful in its use.

Anyway, TommyCee, I'm glad you found a result suitable for your needs and learned a couple of things which it the main objective and benefit of participating in forums such as this. I learn useful things here all the time....

 

0 Kudos
FortranFan
Honored Contributor III
807 Views

Just noticed Fortran 2008 introduces an intrinsic procedure named “execute_command_line” that may work similarly as SYSTEM function, if and when it is implemented in Intel Fortran.

In ISO/IEC JTC1/SC22/WG5 N1891 document by John Reid titled, “The New Features of Fortran 2008”, this procedure is described as follows:

 

[plain]

9.9 Execute command line

 

call execute_command_line(command[,wait,exitstat,cmdstat,cmdmsg])

 

starts execution of another program if the processor supports command line execution.

 

command has intent in and is a scalar default character holding

the command line to be executed.

 

wait has intent in and is a scalar default logical. If present with

the value false, and the processor supports asynchronous execution of

the command, the command is executed asynchronously; otherwise it is

executed synchronously.

 

exitstat has intent inout and is a scalar default integer. If the

command is executed synchronously, it is assigned the value of the

processor-dependent exit status. Otherwise, the value is unchanged.

 

cmdstat has intent out and is a scalar default integer. It is assigned

the value -1 if the processor does not support command line execution,

a processor-dependent positive value if an error condition occurs, or

the value -2 if no error condition occurs but wait is present with the

value false and the processor does not support asynchronous execution.

Otherwise it is assigned the value 0.

 

cmdmsg has intent inout and is a scalar default character. If an error

condition occurs, it is assigned a processor-dependent explanatory

message. Otherwise, it is unchanged.

 

When the command is executed synchronously, the subroutine returns

after the command line has completed execution. Otherwise, it returns

without waiting. If an error condition occurs and cmdstat is not

present, error termination of execution is initiated.

 

[/plain]

0 Kudos
Steven_L_Intel1
Employee
807 Views

Yes, that intrinsic would be similar to SYSTEM, though with more flexibility. 

0 Kudos
andrew_4619
Honored Contributor III
807 Views
 

This is existing feature request ID DPD200169310. I'm sure we'll get to it eventually.

 

Will this be some time soon now?

 

0 Kudos
Steven_L_Intel1
Employee
807 Views

"Answer unclear. Ask again later." 

0 Kudos
andrew_4619
Honored Contributor III
807 Views

Is it later yet dad? :-)

 

0 Kudos
Reply