Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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 ]
mike23liu@gmail.com

Posts: 1
Registered: 7/23/12
Re: parfor: keep outputs with same output filename
Posted: Jul 23, 2012 11:30 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi,

Thank you all.
I've modified the section to
[fid1,msg]=fopen('inputpar.dat','wt'); % be read by Console2.exe
if fid1==-1
error(msg)
end
fprintf(fid1,'%2d\n',i);
after parfor and re-run it, then also have the same message:

Starting matlabpool using the 'local' configuration ... connected to 3 labs.
fortran main : 46
fortran main : 46
fortran main : 46
??? 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.

>> matlabpool close
Sending a stop signal to all the labs ... stopped.

I run it again

Starting matlabpool using the 'local' configuration ... connected to 3 labs.
forrtl: severe (24): end-of-file during read, unit 10, file D:\temp\Console2\Console2\Debug\inputpar.dat
Image PC Routine Line Source
Console2.exe 004A511A Unknown Unknown Unknown
Console2.exe 00414390 Unknown Unknown Unknown
Console2.exe 0041356A Unknown Unknown Unknown
Console2.exe 00406A06 Unknown Unknown Unknown
Console2.exe 004010B9 _MAIN__ 4 Source1.f90
Console2.exe 004ABAD3 Unknown Unknown Unknown
Console2.exe 0044FC67 Unknown Unknown Unknown
Console2.exe 0044FB3F Unknown Unknown Unknown
kernel32.dll 766D339A Unknown Unknown Unknown
ntdll.dll 77489EF2 Unknown Unknown Unknown
ntdll.dll 77489EC5 Unknown Unknown Unknown
??? 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.

>> matlabpool close
Sending a stop signal to all the labs ... stopped.

I run again many times. Sometimes I have

Starting matlabpool using the 'local' configuration ... connected to 3 labs.
forrtl: severe (47): write to READONLY file, unit 30, file D:\temp\Console2\Console2\Debug\fort.30
Image PC Routine Line Source
Console2.exe 004A511A Unknown Unknown Unknown
Console2.exe 00414390 Unknown Unknown Unknown
Console2.exe 0041356A Unknown Unknown Unknown
Console2.exe 0040A06A Unknown Unknown Unknown
Console2.exe 004010FE _MAIN__ 5 Source1.f90
Console2.exe 004ABAD3 Unknown Unknown Unknown
Console2.exe 0044FC67 Unknown Unknown Unknown
Console2.exe 0044FB3F Unknown Unknown Unknown
kernel32.dll 766D339A Unknown Unknown Unknown
ntdll.dll 77489EF2 Unknown Unknown Unknown
ntdll.dll 77489EC5 Unknown Unknown Unknown
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.

>> matlabpool close
Sending a stop signal to all the labs ... stopped.

There is no message from "error(msg)".

Also, I kind of choose fixed filename: "inputpar.dat", since I wouldn't like to change that filename in FORTRAN program. My whole idea is to run FORTRAN program with input parameter file created by matlab. And run many times.

Mike

On Monday, July 23, 2012 10:34:43 PM UTC+8, dpb wrote:
> On 7/23/2012 4:45 AM, Mike wrote:
>
> ...[top posting repaired--please don't do that; hard conversation follow
> makes]...
>
> > On Sunday, July 22, 2012 2:20:58 AM UTC+8, dpb wrote:
> ...
>
> >> I presume you're looking for the'append' option for fopen???
> ...
> > To be more clear, I simply my question with follows:
> ...
> > 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');
> ...
> >
> > 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')
> >
> > out =
> >
> > 64
> >
> > I don't understand the error message shown above.
> > May you explain for me?
> ...
>
> My guess is the problem is one of timing--the file is locked by another
> process when you're trying to open it in all likelihood. This is a very
> difficult thing to try to get to work as you've written it.
>
> Start by
>
> [fid1,msg]=fopen('inputpar.dat','w'); % be read by Console2.exe
> if fid1==-1
> error(msg)
> end
>
> And at least you'll know fid1 isn't valid and stop and have the system
> error message.
>
> --




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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.