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

Calling functions in threads using Fortran

ZongyaoLi
Beginner
342 Views

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
Robert_van_Amerongen
New Contributor III
342 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
jimdempseyatthecove
Honored Contributor III
342 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
mecej4
Honored Contributor III
342 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
Reply