Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Parallel computing toolbox: help with parfor!
Date: Tue, 5 May 2009 22:35:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 40
Message-ID: <gtqeum$6uo$1@fred.mathworks.com>
References: <gtnsts$no9$1@fred.mathworks.com> <gtnve9$6sl$1@fred.mathworks.com> <gto0r9$7er$1@fred.mathworks.com> <ytwprenpthg.fsf@uk-eellis-deb4-64.mathworks.co.uk>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1241562902 7128 172.30.248.35 (5 May 2009 22:35:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 5 May 2009 22:35:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1828235
Xref: news.mathworks.com comp.soft-sys.matlab:537728


Edric,
Thank you so much for your suggestion! I had thought of doing that but didn't quite know how to translate into matlab! I was already on my way to talk to the sys admin to change the fortran code when I saw your reply :) The code is now working and the results are as they should be (that is, the output files are not being overwritten).

Cheers,
Elizabeth



Edric M Ellis <eellis@mathworks.com> wrote in message <ytwprenpthg.fsf@uk-eellis-deb4-64.mathworks.co.uk>...
> "Elizabeth Kusel" <elizabeth.kusel@oregonstate.com> writes:
> 
> > [...]
> > I'm trying not to change the fortran routine if I can, since I don't have
> > admin privileges to recompile the code myself. Also the code is part of a
> > bigger fortran toolbox and compiling is not an easy process...  May be I could
> > try splitting the matlab calculations into 4 different temporary directories?
> >
> > Back to thinking of what and how to do it!
> 
> One thing you need to be aware of is that MATLABPOOL attempts to synchronise the
> path and current directory between client and workers - usually this is very
> convenient, but it will get in the way for you. Therefore, to make this work,
> you need to be somewhat careful. Something like this should work:
> 
> parfor ii=1:N
>   % Concoct a temp dir for this worker that remains constant
>   mytmpdir = fullfile( tempdir, sprintf( 'mytmp.%d', system_dependent( 'getpid' ) ) );
>   if ~exist( mytmpdir, 'dir' )
>       mkdir( mytmpdir );
>   end
>   previousDir = cd( mytmpdir );
> 
>   % Call your code here...
> 
>   cd( previousDir );
> end
> 
> Cheers,
> 
> Edric.