- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I know there is available in the Intel Fortran Compiler a SYSTEM call or SYSTEMQQ logical function to be used for executing batch processes from CMD. However, the problem is that in either case Fortran does not wait until completion of the batch process.
Below is a sample case:
==============================================
PROGRAM MAIN
C
C IMPLICIT NONE
C
CHARACTER(LEN=8) :: JOBID
CHARACTER(LEN=9) :: DRIVER1
CHARACTER(LEN=3) :: DRIVER2
INTEGER :: RET
C
JOBID='''JOB100'''
DRIVER1='BATCH991('
DRIVER2=',1)'
CALL SYSTEM(DRIVER1//JOBID//DRIVER2)
C
C
PRINT*,'>>> RUNNING BATCH... >>>'
PRINT*, CHAR(7)
C
C continue FORTRAN statements...
C
C
END PROGRAM MAIN
==============================================
The BATCH991 process takes around of 40 seconds to complete, and the beep sounds instantaneously after printing the RUNNING... message, a clear indication that Fortran is not waiting until completion to continue with the statements. I both tried with CALL SYSTEM, RES=SYSTEM(..) and RES=SYSTEMQQ(), in any case Fortran does not wait until the batch termination.
I really appreciate your help on this issue.
Thanks once again.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are able to use a current Fortran, your time might be better spent with execute_command_line (and watch for bugs in Intel documentation). Then the WAIT option does what you are asking. When you say "the" Intel Fortran it is still good to say which era you are visiting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Both SYSTEM and SYSTEMQQ are documented saying "On Windows* systems, the calling process waits until the command terminates." and both appear to honor this.
I tested both SYSTEM and SYSTEMQQ under our PSXE 2015 (15.0 compiler) and 2016 (16.0 compiler) releases and find that both routines wait for completion of the command issued. My command was a simple .bat simulating a sleep for a specified time period. Perhaps you have a compiler version earlier than those that might be misbehaving or perhaps your BATCH991 is actually completing.
I would be happy to look further into this if you can provide a complete reproducer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Tim Prince,
Thanks for your prompt response. I apologize because I forgot to mention the version of the IFORT compiler that I have installed in my machine: Intel Fortran Composer XE 2011 (Intel Fortran Compiler 12.0).
My understanding is that version of IFORT does not have the instrinsic subroutine EXECUTE_COMMAND_LINE. I guess that is why I am having the following error when trying to compile:
===============================================
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.0.0.104 Build 201010
06
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
-out:test12.exe
-subsystem:console
test12.obj
test12.obj : error LNK2019: unresolved external symbol EXECUTE_COMMAND_LINE referenced in function MAIN__
test12.exe : fatal error LNK1120: 1 unresolved externals
===============================================
Is there any workaround for this? I guess it should be possible in Fortran, though I don't know any other command to do it.
I shall wait to hear back from you.
Thanks in advance.-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Kevin Davis,
Good to know your feedback. Might it be related to the version of my Intel Fortran Compiler 12.0?
I will check modifying the BATCH991 process and simplify it with a simple SLEEP as you did. I let you know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Kevin,
I simplified the batch script and it worked out perfectly with the SYSTEM function as you had mentioned. So SYSTEM and SYSTEMQQ work as expected, they wait for completion of the whole batch file before continuing with the next statements of Fortran.
Then I realized that the issue was related to a bug within the batch file. Inside the batch a Matlab routine was invoked in CMD, it did not wait until Matlab finish and continued with the following line in the batch. In order to solve it, the argument -wait was added to the matlab.exe driver in the batch file. That solved the problem.
Thanks again.
Francesco.-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad to hear that! Good luck going forward.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page