- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
in my Fortran program, I want to start an external process and directly return to my program, not waiting for its completion.
Thus, as I understand it, the compiler routines RUNQQ, SYSTEM or SYSTEMQQ are not suitable for this problem.
I have read about the possibility to use the Windows-Routine CreateProcess instead and implemented the following function:
subroutine start_help()
c-----------------------------------------------------------------------
c
c.... Purpose: start an external process
c-----------------------------------------------------------------------
use Kernel32
implicit none
INTEGER(BOOL) :: res, bIH
INTEGER(DWORD) :: dCF
INTEGER(LPVOID) :: lpE
CHARACTER(len=500) :: fcis, fcis1
TYPE( T_SECURITY_ATTRIBUTES ) tPA, tTA
TYPE( T_PROCESS_INFORMATION ) tPI
TYPE( T_STARTUPINFO ) tSI
bIH = FALSE ! inherit handles [bool] dCF = NULL ! creation flags [dword]
lpE = NULL ! environment [lpStr]
fcis = "C:\\Program Files (x86)\\Adobe\\Reader 10.0\\Reader\\
+AcroRd32.exe"C
fcis1 = "/s /o C:\\path\\to\\my.pdf"C
res = CreateProcess(fcis,fcis1,tPA,tTA,bIH,dCF,lPE,NULL,tSI,tPI) if (res .eq. 0) then
write(16,*) "Error! Could not create process.",GetLastError()
end if
return
end
This routine works fine when calling it in a blank test program, which does nothing but call this routine.
However, as soon as I implement it to my larger program, it somehow refuses to work at all.
I tried adding a break point to the subroutine, but somehow the debugger just skips the whole routine, even when setting the break point to its call-statement and proceding with single steps.
The routine is called though, as test and error output is written just fine.
CreateProcess seems to fail too, as there is no process opened, even with other executables. The GetLastError error code is 0.
I am using Visual Studio 2010 with Intel(R) Visual Fortran Compiler XE 13.0.0.089 [Intel(R) 64]. I have used the same compiler for both programs.
No external libraries are used, OpenMP is activated but the routine and its calls are outside of parallel regions.
Thanks for your help!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
![](/skins/images/B7BA37F9CE4B52FF7CAE1FB0388839C8/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page