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

Transplan to Linux

Zhanghong_T_
Novice
933 Views
Hi all,
I have some problems in transplant my code from windows to linux:
1. code such as
!DEC$ ATTRIBUTES DLLEXPORT::xxx
How to change it in linux system?
2. code such as
use ifwin
...
hFile = CreateFile("temp.txt"C, GENERIC_WRITE,&
FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0)
ret = SetStdHandle(STD_OUTPUT_HANDLE, hFile)
...
ret=CloseHandle (hFile)
ret=DeleteFile ("temp.txt"C)
How to change the code?
Thanks,
Zhanghong Tang
0 Kudos
4 Replies
Steven_L_Intel1
Employee
933 Views
The Linux equivalent of DLL is "shared object". They do not require special directives, just a different way of linking.

Your code uses Windows Win32 API routines, though the ones you show could easily be replaced with standard Fortran OPEN, WRITE and CLOSE statements. You will need to understand what your code is doing and determine if perhaps there are Linux system routines you can use for the same purpose.
0 Kudos
Zhanghong_T_
Novice
933 Views

Hi Steve,

Thank you very much for your reply. In my code, I use windows API function to relocate the screen output to a file. There are many write statements which output data to the screen and I don't want to change all these statements. Is there any subroutine which have the same function as these API functions in windows system?

Thanks,

Zhanghong Tang

0 Kudos
Steven_L_Intel1
Employee
933 Views
I am not familiar with Linux system calls. It will not be a direct translation. You will have to learn how such things are done on Linux.
0 Kudos
TimP
Honored Contributor III
933 Views
Replacement of standard Fortran with API calls is not so commonly done outside of Windows, so you won't find much in the way of examples to go on. You might have to examine how gfortran is implemented, if you wish to know how to do it with linux C. One of the purposes of Windows API calls is to make portability difficult.
0 Kudos
Reply