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

Fortran Console application using fortran Static Library

Bhpendra_P_
Beginner
1,131 Views

I am getting Runtime error (Severe<157> : Program Exception – access violation) in Fortran Console application using FORTRAN static library. I have tired commenting out Write statements but it gives error to next Write statement .

I have Parallel Studio XE2013 and Visual Studio 2010 installed on my laptop.

 

When I had all source files ( from which static library .lib file was created ) compiled within same project it runs fine without any issues.

 

Is there anything special I need to define/declare in console application file (console.f90)?

Anything special need to do in console file using static library?

 

Thank You

0 Kudos
1 Solution
Steven_L_Intel1
Employee
1,131 Views

mecej4 has provided a very good clue as to the problem. It also explains why building from all source together works.

Your cim.lib is built with the STDCALL calling convention - the @n suffixes on the routine names tells me this. This was used by Compaq Visual Fortran. But Intel Visual Fortran defaults to the C convention. If you call a STDCALL routine but the caller thinks it is calling a C convention routine, the stack will be corrupted and lead to errors later in the code. My guess is that if you change the project property Fortran > External Procedures > Calling Convention to "CVF" and rebuild (also making the CIM_INIT change mentioned above), it will work.

View solution in original post

0 Kudos
14 Replies
Steven_L_Intel1
Employee
1,131 Views

No, there isn't. I suspect something else was involved which you are not aware of. There may be some project settings different between your two projects. It isn't related to static libraries.

0 Kudos
Bhpendra_P_
Beginner
1,131 Views

I am in loop for few weeks about this. I tried reading file instead of getting inputs from console but same result.

Any suggestion?

0 Kudos
Steven_L_Intel1
Employee
1,131 Views

Attach a ZIP of a project that shows the problem. (Do a Build > Clean on it first). We have no idea what your program looks like.

0 Kudos
Bhpendra_P_
Beginner
1,131 Views

Also please run in Debug Mode

 

0 Kudos
Steven_L_Intel1
Employee
1,131 Views

You don't provide the source of CIM.lib so it can't be debugged.

0 Kudos
Bhpendra_P_
Beginner
1,131 Views

ok. I need to get it from someone.  Because I did not create .lib file

 

I need to find it and send you.

 

Can you Please delete .zip file I sent to you earlier?

0 Kudos
Bhpendra_P_
Beginner
1,131 Views

Thank You.

 

 

0 Kudos
Bhpendra_P_
Beginner
1,131 Views

Just want to make sure that in order to give me feed back:

You need:

1. Project containing .lib file including source

2. Current project with source

0 Kudos
mecej4
Honored Contributor III
1,131 Views

The call to CIM_INIT in your main program contains eight arguments. However, the library contains symbols _CIM_INIT and _CIM_INIT@24, which suggests that CIM_INIT expects to be called with six arguments. Can you explain this inconsistency?

How was the library compiled?

0 Kudos
Bhpendra_P_
Beginner
1,131 Views

Yup. Good catch. I had different routine having 8 arguments. But correcting that (by having same number of arguments ) also results in same error.

 

Thank You

0 Kudos
Bhpendra_P_
Beginner
1,131 Views

I did not create library some one else have created I am simply using it.  By the way, I had tried creating library myself from same source files and I had same errors.

 

Thank You

0 Kudos
Steven_L_Intel1
Employee
1,132 Views

mecej4 has provided a very good clue as to the problem. It also explains why building from all source together works.

Your cim.lib is built with the STDCALL calling convention - the @n suffixes on the routine names tells me this. This was used by Compaq Visual Fortran. But Intel Visual Fortran defaults to the C convention. If you call a STDCALL routine but the caller thinks it is calling a C convention routine, the stack will be corrupted and lead to errors later in the code. My guess is that if you change the project property Fortran > External Procedures > Calling Convention to "CVF" and rebuild (also making the CIM_INIT change mentioned above), it will work.

0 Kudos
mecej4
Honored Contributor III
1,131 Views

If the library was created using a different version of IFort or perhaps a non-Intel Fortran compiler, or if it was not compiled from Fortran code, there may be compatibility issues. I compiled your main program using the library that you provided, using IFort 15.0.2, and again using IFort 15.0.4, using the IFort 32-bit command window. With both, the resulting EXE ran to completion with the data that you gave and using the default compiler options. With /Zi, instead, both versions gave me an EXE that crashed with 

forrtl: severe (8): internal consistency check failure, file for_desc_item.c, line 631
Image              PC        Routine            Line        Source
libifcoremd.dll    5F9FE955  Unknown               Unknown  Unknown
libifcoremd.dll    5FA68063  Unknown               Unknown  Unknown
libifcoremd.dll    5FA670CB  Unknown               Unknown  Unknown
Console_CIMTEST.e  01191A97  _MAIN__                   557  Console_CIMTEST.f90

It will be necessary to have the source code for the library in order to proceed further.

0 Kudos
Bhpendra_P_
Beginner
1,131 Views

 

           I tried your suggestion and it seem to work.  This was simple test and I have commented out many things.  I need to test more complicated tests now.

Thank You so much for your help.

 

 

0 Kudos
Reply