Call System() compilation error

Call System() compilation error

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

8 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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.

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.

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

USE IFPORT
...
res = SYSTEM(command)

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.

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 [S]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.\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

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.

Quoting tim18The 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

Hi, Shailesh,

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

 

Thanks,

Wei

Leave a Comment

Please sign in to add a comment. Not a member? Join today