Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Ankündigungen
Important Update: Community Platform Migration​. Learn more​>

Fortran Console application using fortran Static Library

Bhpendra_P_
Einsteiger
3.930Aufrufe

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 Lösung
Steven_L_Intel1
Mitarbeiter
3.930Aufrufe

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.

Lösung in ursprünglichem Beitrag anzeigen

14 Antworten
Steven_L_Intel1
Mitarbeiter
3.930Aufrufe

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.

Bhpendra_P_
Einsteiger
3.930Aufrufe

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

Any suggestion?

Steven_L_Intel1
Mitarbeiter
3.930Aufrufe

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.

Bhpendra_P_
Einsteiger
3.930Aufrufe

Also please run in Debug Mode

 

Steven_L_Intel1
Mitarbeiter
3.930Aufrufe

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

Bhpendra_P_
Einsteiger
3.930Aufrufe

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?

Bhpendra_P_
Einsteiger
3.930Aufrufe

Thank You.

 

 

Bhpendra_P_
Einsteiger
3.930Aufrufe

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

mecej4
Geehrter Beitragender III
3.930Aufrufe

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?

Bhpendra_P_
Einsteiger
3.930Aufrufe

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

Bhpendra_P_
Einsteiger
3.930Aufrufe

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

Steven_L_Intel1
Mitarbeiter
3.931Aufrufe

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.

mecej4
Geehrter Beitragender III
3.930Aufrufe

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.

Bhpendra_P_
Einsteiger
3.930Aufrufe

 

           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.

 

 

Antworten