gvegayon / parallel

PARALLEL: Stata module for parallel computing
https://rawgit.com/gvegayon/parallel/master/ado/parallel.html
MIT License
118 stars 26 forks source link

parallel. prog() syntax does not recognize spaces in path #49

Closed alnahedh closed 7 years ago

alnahedh commented 7 years ago

I have a predefined program that loops over text files, coded as nmfp (x) to parse them and save them into string variables. At the end of my program, each file will be a distinct observation. I have a lot of files so I'd like to parallelize the process.. The program runs fine when calling it (to run sequentially).. but when I use the parallel syntax, I get the following error which seems to indicate that spaces in Stata installation path is causing the error:

. parallel, prog(parfor): parfor 1 1
invalid 'Customer' 
                 stata():  3598  Stata returned error
parallel_export_programs():     -  function returned error
     parallel_write_do():     -  function returned error
                 <istmt>:     -  function returned error
r(3598);

end of do-file

r(3598);

Customer above refers to the path where Stata is installed, which in my case is "C:\Users\Valued Customer\Dropbox\Software\Stata 13\Installed/StataMP-64.exe"

Here is my code, the predefined program along with how I am calling the parallel process:

prog def parfor
    args linenum filenum
        forvalues n=1/`=_N' {
            capture file open myfile using "nmfp (`n').txt", read text
            capture file read myfile line
            while r(eof)==0 {
                capture replace line_`linenum' = "`line'" if _n==`filenum'
                capture file read myfile line
                capture local linenum = `linenum' + 1
                }
            capture local linenum = 1
            capture local filenum = `filenum' + 1
            capture file close myfile
            }
        end

When I call it sequentiall, say parfor 1 1 then it runs fine.. but when I do the following:

parallel, prog(parfor): parfor 1 1

then it gives the above error

Any clues?

bquistorff commented 7 years ago

I would try to install newest version of parallel (use the directions on the readme). Looks like you have the version on the release page, but we're not very good at updating that, so use the master branch (it's "stable"). Your setup appears common (on Windows the program path usually has a space, and we often use prog()) on which parallel normally runs fine.

alnahedh commented 7 years ago

Great.. I updated with the newest version and now it works.. Thanks!!