I am attempting to port software from Digital Visual Fortran which uses the function peekcharqq() to enable safely exiting the program while still executing if the user hits a key. It simply checks the input buffer and returns as TRUE if a key has been hit. Notably it does not wait for a key to be hit if one has not been, but simply returns FALSE. This was in the Digital DFLIB library, part of which you have ported but not this routine! Is there another function supported in PGI fortran that could substitute or another workaround that would allow program abort only at “safe” places in a program?
I’ve asked around here but we were able to think of a good alternative for you. There might be a way using non-advancing i/o along with checking for end-of-record, to accomplish this or maybe call a C routine to interface with the Windows system call that does this (I’m not sure what function peekcharqq calls). However, we don’t have an example.
Hopefully another user can jump in if they’ve done something similar.
Sorry for not being of much help,
I found a different solution which uses the supported VAX-extension function SIGNAL. This allows one to disable ctrl+c interrupts during a sensitive portion of the program, such as writing multiple files that need to stay synced, and then turn it back on when it is safe. It also allows replacing the ctrl+c interrupt handler with your own fortran procedure. So now I can safely interrupt the program, which was the point of the old peekcharqq() method. Note to anyone who wishes to try this: new interrupt procedure needs to be declared external in the program that calls signal. Also, ctrl+c is signal number 2 in most systems, but apparently this is not universal.