thank you for your info. To be more clear, I simply my question with follows: 1) I create a fortran file with following:
program main integer:: i open(10,file='inputpar.dat',status='old') read(10,*) i write(30,*) i write(*,*) 'fortran main :', i end
I compile it within the project and have Console2.exe in 'D:\temp\Console2\Console2\Debug'.
2) in matlab, I have following: fid2=fopen('test.dat','a'); % this file should be run parallel' matlabpool open local 3 parfor i=1:100 fid1=fopen('inputpar.dat','w'); % be read by Console2.exe fprintf(fid1,'%2d\n',i); fclose(fid1); dos('Console2.exe<inputpar.dat'); out=importdata('fort.30') fprintf(fid2,'%2d\n',out); end matlabpool close s=load('test.dat')
Then I run this cell (step 2), I have the results: Starting matlabpool using the 'local' configuration ... connected to 3 labs. fortran main : 64 fortran main : 64 fortran main : 64 ??? Error using ==> parallel_function at 598 Error in ==> parallel_function>make_general_channel/channel_general at 894 Invalid file identifier. Use fopen to generate a valid file identifier.
I've checked the content in inputpar.dat is 64. I've also checked the content in fort.30 is also 64. I also check >> out=importdata('fort.30')
I don't understand the error message shown above. May you explain for me?
Thank you in advance.
Mike On Sunday, July 22, 2012 2:20:58 AM UTC+8, dpb wrote: > On 7/20/2012 10:56 PM, Mike wrote: > > Hi, > > > > If I run an exection file which output the same filename for many > > times using parfor, the output files will be overwritten. At last, I > > have only one output file. How to keep the output file in every run? > ... > > I presume you're looking for the 'append' option for fopen??? > > doc fopen > > --