Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
17 Views

Calling functions in threads using Fortran

I have a Fortran program. It has two parts. The first part is about scientific calculating, and the second part is about TCP/IP communicating . When the program is started, the TCP/IP part will run on backgrounds and receive messages from other programs. While the scientific calculating part runs at the same time. So I need multi threads to make the two parts run at the same time. I know in C# we can build a new thread to start a function as follows. But what about Fortran? Thank you!

Thread th = new Thread(new ThreadStart(Listen));

0 Kudos
3 Replies
Highlighted
New Contributor II
17 Views

Take a look at the MSDN. There you will find the function CreateThread. The activities to be done by each thread (calculating and communicating) can be put in the ThrreadProc functions. Does this help?

Robert

 

0 Kudos
Highlighted
17 Views

The modules ifmt and kernel32 both declare interfaces to CreateThread and CreateThreadX. Then use Robert's suggestion to consult MSDN for proper calling procedures.

Jim Dempsey

0 Kudos
Highlighted
Black Belt
17 Views

If the TCPIP part and the "scientific" part are completely independent, you can simply run them as two separate tasks.

If they are dependent, you have to know the synchronization requirements and implement the synchronization by making API calls or use a system based on directives such as OpenMP.

In general, there is more work involved in developing a multithreaded task than just launching a new thread.

0 Kudos