Fortran dll run on different computers problem

Fortran dll run on different computers problem


Im calling a fortran dll from my csharp application. This works fine on most computers, however on several computers appears the following problem:

When one of the fortran subrutines get called the application is stuck, it enters the subrutine and doesnt come back. you can see the application running in the task manager with 50% CPU use...

The tricky part is that the problem is not the called subrutine but another one that is not got called (when the problem happens). If I remove the code of the other subrutine the application runs fine.

I also found out that array declarations in the other subrutine are cousing that problem.I have several big arrays declared inside that subrutine and also passed inside as parameters.

 When I removed all the code that's using those arrays it also solved the problem.

I've tried setting calling conventions on both sides to stdcall or Cdecl, but it had no influence.

I'he also tried to set the /heap-arrays  option, no success.

Do you have any other suggestions ?

P.S. All the computers configuration are the same : Windows7 SP1 , 32bit.

My application is compiled for 32bit , using Visual2008.



publicaciones de 8 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

There are so many variables here it's hard to know where to begin. Focusing on the arrays might be useful - please show the declaration of the arrays and their size.

Steve - Intel Developer Support

Hi Steve,
Thank you for your response !

The fortran code is quite old and poorly written

This is the subrutine call and variables declarations :


     & ,IN_ARRAY_1,IN_ARRAY_2



     & ,OUT_ARRAY_2,OUT_ARRAY_3,


     & ,OUT_ARRAY_6,OUT_ARRAY_7 )

      !DEC$ ATTRIBUTES DLLEXPORT          ::F1                          








      DIMENSION   GRAPH(60000,50)   , TIME(60000)

      DIMENSION   GRAPH2(5,9)

      DIMENSION   VLABLE(2,15)    , IPL(100)        , DER(101)

      DIMENSION   VAR(101)        , EL(100)         , EU(100)           
      DOUBLE PRECISION DSEED                                            

      REAL*8    PARAM_2  [VALUE]



      INTEGER*4 PARAM_5  [VALUE]                          
      REAL*8 	IN_ARRAY_1		(15,20)


      REAL*8 	IN_ARRAY_2		(30,20)

      REAL*8 	IN_ARRAY_3		(200)

      REAL*8 	IN_ARRAY_4		(5)

      INTEGER*4 IN_ARRAY_5		(20)                                                                                          
      REAL*8    OUT_ARRAY_1			(3,10000,5)


      REAL*8 	OUT_ARRAY_2			(100,20)

      REAL*8 	OUT_ARRAY_3			(100,20)

      REAL*8    OUT_ARRAY_4			(9,5)

      REAL*8    OUT_ARRAY_5			(10000,2,5)

      REAL*8 	OUT_ARRAY_6			(2,6,5)

      REAL*8 	OUT_ARRAY_7			(2,2,5)                                    
      DIMENSION X_ARRAY_1(5,2,10000)

      DIMENSION X_ARRAY_2(5,2,6)


      DIMENSION Y_ARRAY_1(5,2,10000)

      DIMENSION Y_ARRAY_2(5,2,2)



Nothing jumps out at me here. The arrays are large but not too large. Can you figure out how far it gets into the routine before the problem occurs? Perhaps put in some print statements at various points? Can you run this under the debugger and see the problem?

Steve - Intel Developer Support

You should notice that the problem is not at run time of this routine.
It's when I load the dll for the first time (by calling other routine in the same dll file)
So printouts and debug do not really help me here...
Also, the problem occurs only on some computers, on my computer it works fine.

When I replaced all array definitions in the following matter:

REAL*8    IN_ARRAY_1      (15)                           ->  REAL*8    IN_ARRAY_1      (1)

REAL*8    IN_ARRAY_2      (30,20)                      ->  REAL*8    IN_ARRAY_2      (1,1)

REAL*8    IN_ARRAY_3      (30,20,10)                 ->  REAL*8    IN_ARRAY_3      (1,1,1)

it also helped to load the dll successfully

But I'm not sure this is the way to go...

That's strange, because these are all dummy arguments and don't actually take any space here. I wonder if you're compiling with bounds checking and getting a bounds error signaled.

Steve - Intel Developer Support

First, I would put all your COMMON variables into MODULE and USE the MODULE where it is needed. That way you will know that the dimensions of all the arrays that are presently defined in COMMON (especially X_array_1, Y_ARRAY_1 etc.) are defined to be the same everywhere in your code.

Second, how can you be sure that the dimensions of IN_ARRAY_1 etc. and OUT_ARRAY_1 etc in the code that calls subroutine F1 match those you define in the body of the subroutine? Should you not check this first?

Steve, I think you are right about the bound checking. It doesn't solve the whole problem, but it does have an influence.
We will try to use the MODULE also...

Thank you both

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya