Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Call System() compilation error

shailesh_kumar
Beginner
2,216 Views

Hi

I am porting a Fortran codeset whichused to be built/run on Linux/Unix environment. Now, I have to build the same codeset; using Fortran 10.1 in Windows 32 and 64 bit environment. This code uses CALL SYSTEM(COMMAND) tosend a command to the system. It appears that windows library does not know about any SYSTEM function being called. So, I am getting compilation error while linking to the exe.

I was wondering; If you are aware of any library which I need to include to get this functionality/compilation working in Windows as well as in Linux environments.

Thanks and Regards
Sk

0 Kudos
7 Replies
mecej4
Honored Contributor III
2,216 Views
call systemqq() should do it on W32.

Some comments which, if taken into consideration, would make diagnosing problems easier:

"windows library does not know about any SYSTEM function": it would help to know which windows library one should be concerned with -- my system has 1565 DLLs in the windows\system32 directory.

"I am getting compilation error while linking to the exe": please do not confuse compilation time errors and linker reported errors.

Thanks.
0 Kudos
TimP
Honored Contributor III
2,216 Views
As CALL SYSTEM () is not a usage supported by Intel Fortran nor by Fortran standard, it's not too surprising it doesn't link to a provided library function. As the other poster said, there is the systemqq idiom inherited from DEC, as well as the legacy system() integer function call supported by ifort as well as certain other Fortrans. When you use vendor-dependent extensions, it's important to consult the relevant documentation and include the vendor's header or USE files (e.g. USE IFPORT) so as to get earlier warnings about incompatibilities.
0 Kudos
John4
Valued Contributor I
2,216 Views

Try using it as a function, instead of a subroutine, e.g.:

[fortran]USE IFPORT
...
res = SYSTEM(command)[/fortran]
The function is included in the IFPORT module (so the "USE IFPORT" line is necessary). The same module also includes SYSTEMQQ, which does exactly the same, but has a different scheme for the errors returned (e.g., ERR$2BIG instead of E2BIG).

GCC/Gfortran, Sun Fortran and PGI Fortran also support the function version of SYSTEM, so making the change probably won't break compatibility with the Linux/Unix environment in which your codeset used to be built.

Keep in mind that ifort's SYSTEM function executes the command in a new environment. If you need to execute within the same environment, use RUNQQ instead ---see ifort's documentation for details.

0 Kudos
shailesh_kumar
Beginner
2,216 Views
Thanks for yourresponse - John,Tim and mecei.

So, I added 'ifport.f90' as a new module with the following -

SUBROUTINE SYSTEM()

INCLUDE 'hdb.inc'

INCLUDE 'db_appmon.inc'

END SUBROUTINE SYSTEM.

Now, I am getting the following errors; when I try to compile thecode containing CALL SYSTEM(COMMAND).I am sorry, Iam unable to figure it out.

.\ifport.f90(2) : Error: Illegal character in statement label field

.\ifport.f90(2) : Error: Illegal character in statement label field

.\ifport.f90(2) : Error: Illegal character in statement label field

.\ifport.f90(2) : Error: Illegal character in statement label field

.\ifport.f90(2) : Error: Illegal character in statement label field

.\ifport.f90(2) : Error: First statement in file must not be continued

.\ifport.f90(3) : Error: Illegal character in statement label field

.\ifport.f90(3) : Error: Illegal character in statement label field

.\ifport.f90(3) : Error: Illegal character in statement label field

.\ifport.f90(3) : Error: Illegal character in statement label field

.\ifport.f90(3) : Error: Illegal character in statement label field

.\ifport.f90(4) : Error: Illegal character in statement label field

.\ifport.f90(4) : Error: Illegal character in statement label field

.\ifport.f90(4) : Error: Illegal character in statement label field

.\ifport.f90(4) : Error: Illegal character in statement label field

.\ifport.f90(4) : Error: Illegal character in statement label field

.\ifport.f90(4) : Error: Invalid character_kind_parameter. No underscore

.\ifport.f90(5) : Error: Illegal character in statement label field

.\ifport.f90(5) : Error: Illegal character in statement label field

.\ifport.f90(5) : Error: Illegal character in statement label field

.\ifport.f90(5) : Error: Illegal character in statement label field

.\ifport.f90(5) : Error: Invalid character_kind_parameter. No underscore

.\ifport.f90(3) : Error: Syntax error, found IDENTIFIER 'E' when expecting one of: =

Error: The attributes of this name conflict with those made accessible by a USE statement. [STAT]

Error: The CALL statement is invoking a function subprogram as a subroutine. [SYSTEM]

Error: The attributes of this name conflict with those made accessible by a USE statement. [STAT]

Error: The attributes of this name conflict with those made accessible by a USE statement. [STAT]

compilation aborted for D:\AREV\habsrc9B\habuser\special\appmon\appmon_monitor.for (code 1)

Please help.... Thanks


0 Kudos
TimP
Honored Contributor III
2,216 Views
The ifport.f90 or its presumably pre-compiled code ifport.mod will be incorporated automatically by the compiler when it sees
USE ifport
in your source code.
Your addition of a conflicting version of ifport.f90 causes some of the errors. Other errors appear to be caused by attempting to compile free form source code as fixed form, as would happen by default if you name a free source file with .f .F .for or the like, or if you specified a fixed source format option.
You are entitled to put in your own subroutine named SYSTEM but that will block use of the one from the provided library, in that part of your own code, even though your usage doesn't match the one supported by the library SYSTEM function.
You were already shown an example of how the library SYSTEM function works.
0 Kudos
shailesh_kumar
Beginner
2,216 Views
Quoting tim18
The ifport.f90 or its presumably pre-compiled code ifport.mod will be incorporated automatically by the compiler when it sees
USE ifport
in your source code.
Your addition of a conflicting version of ifport.f90 causes some of the errors. Other errors appear to be caused by attempting to compile free form source code as fixed form, as would happen by default if you name a free source file with .f .F .for or the like, or if you specified a fixed source format option.
You are entitled to put in your own subroutine named SYSTEM but that will block use of the one from the provided library, in that part of your own code, even though your usage doesn't match the one supported by the library SYSTEM function.
You were already shown an example of how the library SYSTEM function works.

Thanks a lot for your input Tim; it builds and links fine now.

Regards

Shailesh
0 Kudos
wei_z_2
Beginner
2,216 Views

Hi, Shailesh,

I met the same problem as you met before. Could you please let me know how to solve problem?

 

Thanks,

Wei

0 Kudos
Reply