Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Parallel computing toolbox: help with parfor!
Date: Mon, 4 May 2009 23:58:01 +0000 (UTC)
Organization: The MathWorks Inc
Lines: 40
Message-ID: <gtnve9$6sl$1@fred.mathworks.com>
References: <gtnsts$no9$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1241481481 7061 172.30.248.37 (4 May 2009 23:58:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 4 May 2009 23:58:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869871
Xref: news.mathworks.com comp.soft-sys.matlab:537407


"Elizabeth Kusel" <elizabeth.kusel@oregonstate.com> wrote in message <gtnsts$no9$1@fred.mathworks.com>...
> Hi everyone,
> I have recently started using the parallel computing toolbox to take full advantage of my machine's 4 processors in my computations.
> 
> My problem involves running simulations for different frequencies (25 in total). The iterations are independent from each other but I need to call a fortran executable to calculate what I need. I use parfor to loop over the different frequencies passing them to a matlab function which:
> 1) writes the input file for the fortran routine containing the specific frequency
> 2) calls the fortran executable
> 3) uses the movefile command to change the name of the fortran output file, which is what I'm ultimately interested in.
> 
> Here is the code that I wrote for that:
> matlabpool local 4
> parfor j=1:25
>      callbellhop(freq(j),zmax,zmax1,ndz,ndr,rmax,rotl);
>  end
> matlabpool close
> 
> function callbellhop(freq,zmax,zmax1,ndz,ndr,rmax,rotl)
> write_envfl2(freq,zmax,zmax1,ndz,ndr,rmax,rotl); % writes the file AUTEC.env
> ! bellhop.exe < AUTEC.env 
> movefile('SHDFIL',(['SHDFIL' num2str(freq)]))
> 
> When I first attempted to run it, it seemed everything was working fine. All the processors were being used, and the output files were being created for each frequency. However, when the iteration reached j" I got an error:
> 
> ??? Error using ==> parallel_function at 594
> Error in ==> callbellhop at 4
> mv: cannot stat `/home/.../Trans1/SHDFIL': No such file or directory
> 
> 
> Error in ==> bw_248bdive2_input at 99
>     parfor j=1:25
> 
> I repeated it more than once and I get the same problem. Does anyone have any clues why it would stop before it finished? Am I overseeing any issues regarding calling the fortran executable and renaming it's output inside a parfor loop?
> Thank you in advance for any input you could give me!
> 
> Cheers,
> Elizabeth

Elizabeth,

I think the problem is that your fortran routine in each iteration is writing out to the same file "SHDFIL". Since PARFOR loops are running in parallel, there are a lot of overwriting of the same file and different loops grabbing results from other loops. You should find a way to have your fortran routine write out to a different file name, or make sure that other iterations cannot touch the file from the current iteration.