The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: parfor: keep outputs with same output filename
Replies: 12   Last Post: Aug 1, 2013 2:35 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 338
Registered: 4/17/07
Re: parfor: keep outputs with same output filename
Posted: Aug 1, 2013 2:35 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


I encounter this problem again and review your suggestion. Allow me to reiterate the problem.
What I want to do is to run a fortran .exe file by using matlab-created input parameter file. And I'd like to run it thousand times and be fast.
Since that fortran .exe read and write both fixed filenames:'inputpar.dat' and 'fort.30' (this fortran program causes me headache so I don't want to compile/link it again), I can't create various input filenames and also expect have various output filenames. Hence, I decide to do it by creating various directory, and creating input file and output file in that directory. At last, collect all output files (fort.30). Although it works, it tends to be lengthy. I am wondering if this can be improve or better thought?

Here is:
% run FORTRAN program 'Console2.exe' with input parameter file 'inputpar.dat'
% created by matlab. And run many times parallel. Console2.exe will always read
% 'inputpar.dat' and write 'fort.30'
matlabpool open local 3
t = cputime;
parfor i=1:nimg
% make several dir
dirname=['a' num2str(i)];
% cd every dir and create input parameter file
% input parameter file to be run by 'Console2.exe'
[fid1,msg]=fopen('inputpar.dat','w'); % be read by Console2.exe
% cd dir and run fortran .exe file and save in a matrix
% run FORTRAN program 'Console2.exe' with the above file
% import output file 'fort.30' of 'Console2.exe'
% remove dir
dos(['rmdir/s/q ' dirname]);
matlabpool close
e = cputime-t;
fprintf('cputime: %f \n',e);

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.