Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Problems using pipes between C# and IFORT 11.1 (rev 65)

François-Xavier
Beginner
1,157 Views

Hello Intel Fortran users,

I come today with a really strange issue with IFORT 11.1.065.

I am used to work with Visual Studio 2008 (C# language)and Intel Fortran 10using pipes. I always found it is a very simple way (and quite robust) to make them communicate without coding wrappers from managed to unmanaged code.


Principle is as following (working this Ifort 10):

1: C# open pipes using "NamedPipeServerStream" type.

public NamedPipes(string pipeName, PipeDirection dir)

{

this.pipeStream = new NamedPipeServerStream(pipeName, dir, 254,

PipeTransmissionMode.Byte, PipeOptions.None,1000000000,1000000000);

this.pipeName = pipeName;

}


2: C# launch Fortran executable and gives arguments to open C# pipe

3: Fortran Executable open pipe (I must connect pipe both way before i can write in it)

C OPEN INPUT MASTER PIPE

OPEN(XPIP1,FILE=ARGV(2),STATUS='UNKNOWN',

* FORM='FORMATTED',ACTION='READ', ERR=998)

4: Fortran Executable proceed a blocking read, waiting C# writing in pipe

READ(XPIP1,'(A100)') YORDER

5: I proceed with a write in C# and the blocking read in Fortran react once pipe contains something

public void FillPipe(string aMessage)

{

StreamWriter sw = new StreamWriter(this.pipeStream);

sw.AutoFlush = true;

sw.WriteLine(aMessage);

}


... and so on.

Problem description

I compiled Fortran 10code with the IFORT 11.1.065 and step 4 in above procedure don't work anymore. When i fill pipe using a C# streamWriter, fortran READ doesn't react.

I tried the same principle using a C++ "writefile". In that case, there is no problem.

Could you help me understand this behaviour?

Thank you for your precious help.

Franois-Xavier Bouchez

0 Kudos
11 Replies
TimP
Honored Contributor III
1,157 Views
Never having seen usage of named pipes in Windows Fortran, I'd guess you would have to access the pipe through WinAPI function such as CallNamedPipe().
0 Kudos
François-Xavier
Beginner
1,157 Views
I manage pipes in Fortran just as files.

There is just a trick with the EOF detection.

Sincerely yours,

F-Xavier
0 Kudos
François-Xavier
Beginner
1,157 Views
Dear Intel Forum, i feel that this problem does not seem to inspire you.

I will report a bug to the support and I will post the solution.

Sincerely yours,

F-Xavier
0 Kudos
Arjen_Markus
Honored Contributor I
1,157 Views
If your solution works with C++ but not with C#, could it be that there is something on the C#-side
that is working differently than you expect?

I have little experience with C#, but I would suspect something is going wrong with flushing. What
happens if you explicitly flsuh the pipe, instead of relying on "auto-flush"?

(I recently had a very similar problem, but that was with a Fortran program, compiled with gfortran sending
data over TCP/IP - by sending CRLF things were send to the other side. I still have to figure out what behaviour is to be expected)

Regards,

Arjen
0 Kudos
Wendy_Doerner__Intel
Valued Contributor I
1,157 Views
F-Xavier,

No need to report a seperate bug report to premier.intel.com. I can this this thread private and you can add the test case along with details how to build it here. Its fine if you have already reported it to premier.intel.com.

------

Wendy

Attaching or including files in a post

0 Kudos
abhimodak
New Contributor I
1,157 Views
Hi Wendy and Xavier

Instead of limited the solution to be "private", I would like to request you to consider posting a part of the solution that can be shared with others as well. A "general procedure" may be useful for everyone.

Abhi
0 Kudos
Wendy_Doerner__Intel
Valued Contributor I
1,157 Views
Once we get this isolated to a small test case, I would be happy to post it along with the root cause. So far, still waiting for a test case though.

------

Wendy

Attaching or including files in a post

0 Kudos
François-Xavier
Beginner
1,157 Views

Dear Intel Fortran forum,

Sorry for reopening this topic but we have kept the 10.1 compiler for this executable for 3 years due to priorities. Now that we have time, we would like to upgrade to Intel XE 2011 compiler. Problem with Intel XE2011 is the same as with 11.1. As a reminder, my code works with Intel 10.

THis time, I have made a lots of experiments and found that, if I add caracters in the pipe (> 1000), the READ statement (100 caracters) unblocks. I remind that the pipe is written by C# executable with a streamwriter and that there is an autoflush.

So, clearly, there is a Intel Fortran compiler behaviour which is different since Intel 11.1.

If my feeling is good, maybe the problem C# - Fortran could also be with Fortran - Fortran, but have not tried.

Are these information sufficient, or do I need to reproduce on a dummy case?

Sincerely yours and thank you so much.

0 Kudos
Steven_L_Intel1
Employee
1,157 Views
We will need a test case - thanks.
0 Kudos
jimdempseyatthecove
Honored Contributor III
1,157 Views

What happens when you try to read the C# data through the pipe....
using a C# program?

What happens if (or should I ask are) you supply what would ordinarily be a record terminator for FORTRAN console input (i.e. the RETURN character)?

Jim Dempsey

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,157 Views

What happens when you try to read the C# data through the pipe....
using a C# program?

What happens if (or should I ask are) you supply what would ordinarily be a record terminator for FORTRAN console input (i.e. the RETURN character)?

Jim Dempsey

0 Kudos
Reply