Fortran dll run on different computers problem

Fortran dll run on different computers problem

Hello,

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.

Thanks,

Alla

8 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.
Portrait de Steve Lionel (Intel)

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

Hi Steve,
Thank you for your response !

The fortran code is quite old and poorly written

This is the subrutine call and variables declarations :


 SUBROUTINE F1(PARAM_1,PARAM_2,PARAM_3,PARAM_4,PARAM_5

     & ,IN_ARRAY_1,IN_ARRAY_2

     & ,IN_ARRAY_3,IN_ARRAY_4,IN_ARRAY_5

     & ,OUT_ARRAY_1,OUT_ARRAY_1_SIZES

     & ,OUT_ARRAY_2,OUT_ARRAY_3,

     & ,OUT_ARRAY_4,OUT_ARRAY_5,OUT_ARRAY_5_SIZES

     & ,OUT_ARRAY_6,OUT_ARRAY_7 )

      !DEC$ ATTRIBUTES DLLEXPORT          ::F1                          
      COMMON    GRAPH ,TIME ,TEMPS(1000), GRAPH2

      COMMON/LCO/CO(20,15)

      COMMON/LCW/CW(20,30)

      COMMON/CEP/XX(100),YY(100),NRUN

      COMMON/LX1/X1(20,100)

      COMMON/LY1/Y1(20,100)

      COMMON/X/X_ARRAY_1,X_ARRAY_3,X_ARRAY_2

      COMMON/Y/Y_ARRAY_1,Y_ARRAY_3,Y_ARRAY_2

      COMMON /ARGMNT/  FMETER , FMR , BASE      
      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                                            
      INTEGER*4 PARAM_1  [VALUE]

      REAL*8    PARAM_2  [VALUE]

      INTEGER*4 PARAM_3  [VALUE]

      INTEGER*4 PARAM_4  [VALUE]

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

      INTEGER*4 ARRAY_1_SIZES	(5)

      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)

      INTEGER*4 OUT_ARRAY_1_SIZES	(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 X_ARRAY_3(5)

      DIMENSION Y_ARRAY_1(5,2,10000)

      DIMENSION Y_ARRAY_2(5,2,2)

      DIMENSION Y_ARRAY_3(5)

Alla

Portrait de Steve Lionel (Intel)

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

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

Portrait de Steve Lionel (Intel)

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

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

Connectez-vous pour laisser un commentaire.