Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
created April 23, 2010 · complexity basic · author Alain b · version 7.0
This tip shows how to launch batch jobs and view the results in a manner that is close to interactive. Where I work, supercomputers users and Linux cluster users launch, from their PC, execution prepared files (jobs) by commands such as
llsubmit. They then have to wait for a listing file to come back with results. Every listing file is generally named
NNNN is a unique number). This process is referred to as batch mode and was common many years before PCs were developed.
You may want to have those two operations, job launching and listing viewing, as simple and close as possible, to perform what I name "close to interactively".
Here is the method I propose for Linux users. Open two Vim or gvim windows, the left one for job launching and the right one for listing editing. Extensions to vimrc are given afterwards.
Prepare a self-launching script, with such a canvas:
JOB=some_filename cat > $JOB <<EOF ... job part as complex as needed ... EOF qsub $JOB rm $JOB
When ready to launch, press the F7 key. Occasionally you may see the NNNN unique number displayed and remember it.
When you know the listing file has been returned, press F12 to edit the most recent file of a good pattern. You may choose explicitly a pattern or keep the precedent one (* by default, use *.o* if you want to restrict only to listing type files). If no more recent file is at disposal, F12 will simply keep the current file active. You may notice that the listings unique numbers are never explicitly used here.
The F7 and F12 keys may be used with success very quickly one after the other, depending on the normal delay of listing returns. You may cycle in this process doing changes in the job preparation as necessary. Obviously the method is more suitable for small tests than for big jobs execution.
Since job preparation file and listing files look often very similar, I propose to make listings read-only files, by default.
To remember keys to be used. I have chosen F12 key because it's the last one (more recent), and I propose F7 because this key is a bit dangerous and so is hidden among the other keys. Ctrl-E: E like execute. Ctrl-^ can be used to switch to the previous (alternate) file.
Additions to vimrcEdit
" Prevents, by default, modification of listing files. autocmd BufReadPre *.o[0-9]* set ro " F7: Execute current file after saving and doing chmod +x " Ctrl-E: same thing with output displayed in an xterm (scrollable) window map <F7> :w<Bar>:!(chmod +x %; %)<CR> map <C-E> :w<Bar>:!chmod +x %; xterm -title "out %" -fg orange -bg darkblue -geometry 80x43 -fn 9x15bold -hold -e %<CR> " F12: Edit most recent file of a given pattern map <F12> :exec EditMostRecentFile()<CR> if !exists("recent") let recent = " " | " By default, space equals * endif function! EditMostRecentFile() let g:pattern = input("EditMostRecentFile. Pattern of files ? (".g:recent." )") if g:pattern != "" let g:recent = g:pattern endif let shell_cmd = "ls -t ".g:recent."| head -1" exec "e ".system(shell_cmd) endfunction
Launching and editing parts may be used independently for whatever you want.
While using gvim for job launching, by construction, gvim will let you see only the last part of output produced at execution. So use Ctrl-E key instead of F7 one to have scroll enabled on displayed output; kill the xterm window when you want.
Windows users may have to change the shell_cmd definition in order to have complete use of the method.