Welcome, Guest
Username: Password: Remember me

TOPIC: How to create a global variable and use it in a subroutine?

How to create a global variable and use it in a subroutine? 10 years 6 months ago #12946

  • qilong
  • qilong's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 340
  • Thank you received: 33
Hello,

I was trying to create a global variable and use it in a subroutine, but I didn't succeed... I really appreciate if someone could help me. Here is what I did.

The global variable I would like to create is called FLUDPT_VASE.

1. Modify subroutine "declarations_sisyphe". Added the following line:
TYPE(BIEF_OBJ), TARGET :: FLUDPT_VASE

2. Modify subroutine "interface_sisyphe_suspension". I added "FLUDPT_VASE" as an additional argument to subroutine "suspension_depot". So that part becomes
      !==============================!
      SUBROUTINE SUSPENSION_DEPOT    ! 
      ! **************************** !   
     &(TOB,HN, NPOIN, HMIN,XWC,VITCD,
     & ZERO,KARMAN,FDM,FD90,XMVE, T1,T2,ZREF,FLUDPT,FLUDPT_VASE,DEBUG,
     & SEDCO,CSTAEQ)
      USE BIEF
      IMPLICIT NONE
      TYPE (BIEF_OBJ),  INTENT(IN)    :: HN, TOB, CSTAEQ
      INTEGER,          INTENT(IN)    :: NPOIN,DEBUG
      LOGICAL,          INTENT(IN)    :: SEDCO
      DOUBLE PRECISION, INTENT(IN)    :: HMIN
      DOUBLE PRECISION, INTENT(IN)    :: FDM,FD90,XWC
      DOUBLE PRECISION, INTENT(IN)    :: VITCD
      DOUBLE PRECISION, INTENT(IN)    :: ZERO, KARMAN,XMVE
      TYPE (BIEF_OBJ),  INTENT(INOUT) :: T1,T2
      TYPE (BIEF_OBJ),  INTENT(IN)    :: ZREF
      TYPE (BIEF_OBJ),  INTENT(INOUT) :: FLUDPT,FLUDPT_VASE
      !----------------------------------------------------------------!
      END SUBROUTINE SUSPENSION_DEPOT
      !================================================================!

3. Modify subroutine "suspension_computation". The lines I modified are:
USE DECLARATIONS_SISYPHE, ONLY : FLULIM,FLUDPT_VASE
and
      CALL SUSPENSION_DEPOT(TOB,HN,NPOIN,HMIN,XWC,VITCD,ZERO,KARMAN,
     &  FDM,FD90,XMVE,T1,T2,ZREF,FLUDPT,FLUDPT_VASE,DEBUG,SEDCO,CSTAEQ)

4. Modify subroutine "suspension_depot" like I did in step 2.

I recompiled the whole program and it didn't give errors. But I can't use FLUDPT_VASE while running simulations. I got "forrtl: severe (157): Program Exception - access violation". It seems that FLUDPT_VASE doesn't exist.

I want to have a global variable like FLUER_VASE that can be used in subroutine "suspension_computation" and "suspension_depot". How can I make this work?

Kind regards,
Qilong
The administrator has disabled public write access.

How to create a global variable and use it in a subroutine? 10 years 6 months ago #12947

  • c.coulet
  • c.coulet's Avatar
  • OFFLINE
  • Moderator
  • Posts: 3722
  • Thank you received: 1031
Hi Qilong

You should also allocate it in the subroutine "points_sisyphe" otherwise it's just a pointer
Have a look into bief_allvec...

Hope this helps
Christophe
The administrator has disabled public write access.
The following user(s) said Thank You: qilong

How to create a global variable and use it in a subroutine? 10 years 6 months ago #12948

  • jmhervouet
  • jmhervouet's Avatar
Hello Qilong,

You're nearly done! Don't forget also, as you say, to recompile THE WHOLE PROGRAM, cleaning previous compiled subroutines, so that all in Sisyphe are compiled with the same declarations.

Regards,

JMH
The administrator has disabled public write access.

How to create a global variable and use it in a subroutine? 10 years 6 months ago #12954

  • qilong
  • qilong's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 340
  • Thank you received: 33
Hello Christophe and Jean-Michel,

Thank you for your help!
I modified "points_sisyphe" and recompiled the whole program. Now it works perfectly!

Kind regards,
Qilong
The administrator has disabled public write access.
Moderators: Pablo, pavans

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.