Prev: Random and ordered packing of uniform circles in a circle, with different areal densities
Next: Econometrics toolbox ML 2010a Seasonal ARIMA
From: dpb on 29 Apr 2010 09:14 almmond wrote: ....[top posting repaired -- please don't do that]... > dpb <none(a)non.net> wrote in message .... >> If the program uses std i/o, then a redirected file containing the CR >> on the command line _might_ work if the other input is from a file and >> doesn't use default std i/o. But, if it does, as say above, it'll >> find the CR and go on. >> >> That is, try >> >> yourprogram <FileContainingCR.Dat >> >> from the command line and see if it terminates w/o an additional CR >> from the keyboard. If so, that prevents the hangup but you have no >> way to know which case occurred programmatically unless there's a >> return exit code that distinguishes (and I forget whether you can get >> a return code back from an app w/ the ML system call or not or whether >> it's the return code of the shell rather than the app or all those >> caveats otomh)... >> >> I don't think of any way w/o having control over the Fortran source >> itself to get all of which you asked for as James says. .... > Hi, thank you very much! dpb > > Suppose I use the following line to call the fortran executable > program: > system(['H:\Mat_cod\Program\ssvv.exe', ' ', '-f', ' ', > 'H:\Mat_cod\folder_1\input.txt']); > and suppose the program will be performed successfully. Can you give > me an example to write a command equivalent to press <CR> to let > matlab carry out the following commands? I said I don't think there _is_ a command equivalent to pressing <CR> outside using OS system calls to spoof the keyboard input. I suggested creating a file that simply contains the <CR> and using it in input redirection in addition to the input file and see if the app "eats" the <CR> at the end to satisfy the internal Fortran PAUSE statement. If it won't work that way from the command line, it won't from the ML system call, either. AFAIK there isn't any way to get Matlab to spoof keystrokes into another session keyboard buffer w/o, as said above, some very OS-specific hacks (and not sure even then w/ the newer security in them; I've heard that some things that used to work don't any longer in that regard and not sure whether there are workarounds or not). --
From: almmond on 30 Apr 2010 12:49 Thank you again, dpb! I wrote the following setence in dos command window: H:\Mat_cod\Program\ssvv.exe –f H:\Mat_cod\folder_1\input.txt < H:\Mat_cod\folder_1\CR.txt Here the file "CR.txt" is the file simply includes <CR>. And the program can run successfully, but at the end there will be continuous prompt says " Fortran Pause - Enter command<CR> or <CR> to continue". In matlab, I wrote the line as follows: system(['H:\Mat_cod\Program\ssvv.exe', ' ', '-f', ' ', 'H:\Mat_cod\folder_1\input.txt', ' ', '<', ' ', ' H:\Mat_cod\folder_1\CR.txt ']); and it didn't run successfully. Please tell me if I understood wrong. I'm a beginner in using parallel computing toolbox. The reason why I would like to know if there is a command that is equivalent to entering the <CR> is because when I use matlabpool for parallel computing using 4 workers, I use parfor loop to call my fortran executable program but it can't stop even if I pressed the <CR> button. The lines I wrote for that are as follows: matlabpool(‘open’, ‘jobmanagerconfig2’, 4); parfor (i=1:4) system(['H:\Mat_cod\Program\ssvv.exe', ' ', '-f', ' ', strcat('H:\Mat_cod\folder_', num2str(i), '\input.txt')]); % Parallel run 4 SHETRAN applications end My problem here is that I can run 4 workers at the same time, but after it finished matlab was stay busy and couldn't complete the loop and perform the following line. By the way, I saw there is parameter for control run time in the simulink toolbox, so I think maybe I can also use simulink toolbox for my program running. My fortran program running is very time-consuming, I need at least half an hour to complete one run time and I need thousands of running to get my results. So I should consider doing them synchronously. However, this is totally new for me! Can you help me? Thank you very much!!!! dpb <none(a)non.net> wrote in message <hrc0rm$pjr$1(a)news.eternal-september.org>.. > > I said I don't think there _is_ a command equivalent to pressing <CR> > outside using OS system calls to spoof the keyboard input. > > I suggested creating a file that simply contains the <CR> and using it > in input redirection in addition to the input file and see if the app > "eats" the <CR> at the end to satisfy the internal Fortran PAUSE > statement. If it won't work that way from the command line, it won't > from the ML system call, either. > > AFAIK there isn't any way to get Matlab to spoof keystrokes into another > session keyboard buffer w/o, as said above, some very OS-specific hacks > (and not sure even then w/ the newer security in them; I've heard that > some things that used to work don't any longer in that regard and not > sure whether there are workarounds or not). > > --
From: dpb on 30 Apr 2010 14:18
almmond wrote: > Thank you again, dpb! > I wrote the following setence in dos command window: > H:\Mat_cod\Program\ssvv.exe –f H:\Mat_cod\folder_1\input.txt < > H:\Mat_cod\folder_1\CR.txt > Here the file "CR.txt" is the file simply includes <CR>. And the program > can run successfully, but at the end there will be continuous prompt > says " Fortran Pause - Enter command<CR> or <CR> to continue". OK, that's bad sign...how did you create the file ie, are you sure it does have the CR (ASCII x0D or 13 decimal) character and not a "<CR>" literal string or something? If that is so then the idea doesn't work and your only hope will be to try the aforementioned route of trying to write an OS-specific mex-file or use some other utility that can spoof keystrokes to the keyboard buffer. As noted earlier, w/ later versions of Windows this has become more difficult owing to more security and I've not fooled around trying to do so since NT4 at the latest. Whatever is possible now is probably most easily found on the MSDN site or on other Windows programming fora--I've no additional useful input. .... > I'm a beginner in using parallel computing toolbox. The reason why I > would like to know if there is a command that is equivalent to entering > the <CR> is because when I use matlabpool for parallel computing using 4 > workers, I use parfor loop to call my fortran executable program but it > can't stop even if I pressed the <CR> button. .... I have no experience w/ the parallel computing toolbox. Practically, I think unless you can get access to the Fortran code and modify its behavior you're likely trying the proverbial crude act up a rope unless the point first raised turns out to have merit... -- |