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

Problems with execute_command_line

Chris_G_2
Beginner
786 Views

I am having some problems with execute_command_line

My program launches in a folder in  which I don't specify. I need to move around this root folder creating new sub-folders and moving between them and the root folder.

The variable 'root_folder' has the full path name for the root folder.If I am in a sub-folder of the root folder and use the Fortran code: 

 integer status
 status = changedirqq(trim(root_folder))

It works and I move back to the root folder. However, if I use

  command = 'chdir ..'
  call execute_command_line(trim(command), exitstat=estat, cmdstat=cstat)

then estat and cmdstat are returned as zero but I do not move back to the root folder.

If I use the Command Prompt window, I can move around the the folders with standard Windows commands without any problems.

I am using the latest beta compiler.

0 Kudos
6 Replies
Steve_Lionel
Honored Contributor III
786 Views

The command line executed happens in a different process and doesn’t affect your current directory. Use changedirqq for this, or explicitly specify the path when creating the folder.

0 Kudos
Chris_G_2
Beginner
786 Views

Thanks Steve.

My problem is that changedirqq seems to need the full path; I can't specify, for example,

status = changedirqq('..')

The full path may contain non-ASCII characters, so  I can't use that either. (This is related to my earlier posting about UNICODE in Fortran).

 

0 Kudos
jimdempseyatthecove
Honored Contributor III
786 Views

Can you write a C/C++ routine that you call from Fortran to perform the UNICODE change directory?

Jim Dempsey

0 Kudos
Chris_G_2
Beginner
786 Views

I guess that's what I'll have to do.

 

0 Kudos
jimdempseyatthecove
Honored Contributor III
786 Views

An additional technique you can use is to call MS CRTL function SetCurrentDirectoryW with the address of an INTEGER(2) array containing the desired path in UNICODE. If the kernal32.mod does not contain the interface, you may need to define your own interface using one of the other interfaces as a guideline.

You can use a UNICODE text editor to prepare a text file to be read by the Fortran program for use as file path\name

Jim Dempsey

0 Kudos
Chris_G_2
Beginner
786 Views

Can I double-check something please: changedirqq(path) needs the full path name?

 

0 Kudos
Reply