Date: Aug 1, 2013 2:35 AM
Subject: Re: parfor: keep outputs with same output filename
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?
% 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;
% make several dir
% 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]);
e = cputime-t;
fprintf('cputime: %f \n',e);