IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Fortran Discussion :

ifort et allocation dynamique


Sujet :

Fortran

  1. #1
    Membre à l'essai
    Inscrit en
    Décembre 2008
    Messages
    22
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 22
    Points : 15
    Points
    15
    Par défaut ifort et allocation dynamique
    Bonjour a tous,
    J'ai un petit souci avec un programme et l'allocation dynamique de mes tableaux en boucle, je vous en met une version épurée:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    program cj_proxy_oerested_multisec
          implicit none
          integer i,j,ok,oki,ndata,tdata,k,job,cout,ndata2,dk,ler
          integer ii,jj,ll,lpre,nbc,nbf,tmp,it,nsec,yi,al,kp,itb,ypre
          integer*8 nombreCrenaux,nboite,ya
          integer,dimension(:),allocatable::nombrePoints,nbp
          integer,dimension(:),allocatable::ldeb,lfin
          integer,dimension(:),allocatable::ipvt
          complex*16,dimension(:),allocatable::dst_t,dst_f,dst_w
          complex*16,dimension(:),allocatable::swarm_br,tcAB,Matfin
          complex*16,dimension(:),allocatable::swarm_bt,swarm_bp
          complex*16,dimension(:,:),allocatable::dstwc,matA,cjg_dstwc
          complex*16,dimension(:),allocatable::z,wc
          complex*16 dipi,nio,niopre,dstwcpre1,dstwcpre2
          real*8,dimension(:),allocatable::t,f,w,ts,tt
          real*8,dimension(:),allocatable::wsave,wmoy
          real*8,dimension(:,:),allocatable     :: halah
          real*8 t1,t2,rr,tloc,x,samy,titi,bixi,biyi,bizi,bimi
          real*8 pi,rcond,alt,teta,phi,br,bt,bp,liss_param,hal
          real*8 passec_DST,bx,by,bz,bm,dtt,xxi,yyi,zzi,vi,ti1,ti2
          real*8 ttmp,fmoy,altTmp,tetaTmp,phiTmp,tt1,tt2,tp,tpre,mr
    ! Paramètre de lissage de la matrice transposée conjuguée tcAA      
          parameter (liss_param=0.d0)      
    ! Tableau initialisant les debuts de fenêtres de 60 jours----------------------------
          real*8,dimension(9) :: Tsec= &
          (/0.d0,125.d0,250.d0,375.d0,500.d0,625.d0,750.d0,875.d0,1000.d0/)   
    !------------------------------------------------------------------------------------
          character (LEN=2)   :: sectioni
          character (LEN=1)   :: isec
          character (LEN=51)  :: path=&
           '/work/fcivet/Oersted/BoiteOersted_tout158_2/'
          character (LEN=24)  :: respath1='Oersted_ace/'
          character (LEN=27)  :: respath2='Oersted_dst/'
     
          character (LEN=3)   :: boite
          character (LEN=4)   :: dat='.dat'
          character (LEN=3)   :: ficfreq
          character (LEN=30)  :: respath
          do it=1,8
            do nboite=1,158!--------------------------> Boucle sur les boites
     
    ...calcul de tdata et ndata
     
              allocate(dst_t(ndata),dst_f(ndata))
              allocate(wsave(4*ndata+15))
              allocate(t(ndata))
              allocate(tt(ndata))
              allocate(f(ndata))
              allocate(swarm_br(tdata))
              allocate(swarm_bp(tdata))
              allocate(swarm_bt(tdata))
              allocate(ts(tdata))
     
    ... calcul de ndata2
     
              cout = 0
              allocate(w(ndata2))
              allocate(dst_w(ndata2))
     
    ... calcul
     
              nombreCrenaux = 300
              allocate (ldeb(nombreCrenaux),lfin(nombreCrenaux))
              allocate (nombrePoints(nombrecrenaux))
              allocate(nbp(nombrecrenaux))
     
    ... calcul de nbc
     
              allocate(wmoy(nbc))
              allocate(tcAB(nbc))
              allocate(z(nbc))
              allocate(ipvt(nbc))
              allocate(Matfin(nbc))
              allocate(matA(nbc,nbc))
              allocate(dstwc(nbc,tdata))
              allocate(cjg_dstwc(nbc,tdata))
              allocate(wc(nbc))
              allocate(halah(nbc,nbc))
     
    ... calcul et impression du résultat
     
              print *,'deallocate...'
              if ((allocated(ldeb) .eqv. .true.).and.(allocated(lfin) .eqv. .true.)) then
                deallocate (ldeb,lfin)
                print *,'ldeb, lfin ok' 
              endif
              if (allocated(nombrePoints) .eqv. .true.) then
                deallocate (nombrePoints)
                print *,'nombrePoints ok'
              endif
              if (allocated(nbp) .eqv. .true.) then
                deallocate(nbp)
                print *,'nbp ok'
              endif
              if (allocated(wmoy) .eqv. .true.) then
                deallocate (wmoy)
                print *,'wmoy ok'
              endif
              if (allocated(tcAB) .eqv. .true.) then
                deallocate(tcAB)
                print *,'tcab ok'
              endif
              if (allocated(z) .eqv. .true.) then
                deallocate(z)
                print *,'z ok'
              endif
              if (allocated(ipvt) .eqv. .true.) then
                deallocate(ipvt)
                print *,'ipvt ok'
              endif
              if (allocated(Matfin) .eqv. .true.) then
                deallocate(Matfin)
                print *,'Matfin ok'
              endif
              if (allocated(matA) .eqv. .true.) then
                deallocate (matA)
                print  *,'MatAok'
              endif
              if (allocated(dstwc) .eqv. .true.) then 
                deallocate(dstwc)
                print *,'dstwc ok'
              endif
              if (allocated(cjg_dstwc) .eqv. .true.) then
                deallocate(cjg_dstwc)
                print *,'cjg_dstwc ok'
              endif
              if (allocated(wc) .eqv. .true.) then
                deallocate(wc)
                print *,'wc ok'
              endif
              if (allocated(w) .eqv. .true.) then
                deallocate(w)
                print *,'w ok'
              endif
              if (allocated(dst_w) .eqv. .true.) then
                deallocate(dst_w)
                print *,'dst_w ok'
              endif
              if (allocated(halah) .eqv. .true.) then
                deallocate(halah)
                print *,'halah ok'
              endif
              if (allocated(dst_t) .eqv. .true.)then
                deallocate(dst_t)
                print *,'dst_t ok'
              endif
              if (allocated(dst_f) .eqv. .true.) then
                deallocate(dst_f)
                print *,'dst_f ok'
              endif
              if (allocated(wsave) .eqv. .true.) then
                deallocate(wsave)
                print *,'wsave ok'
              endif
              if (allocated(t) .eqv. .true.) then
                deallocate(t)
                print *,'t ok'
              endif
              if (allocated(tt) .eqv. .true.) then
                deallocate(tt)
                print *,'tt ok'
              endif
              if (allocated(f) .eqv. .true.) then
                deallocate(f)
                print *,'f ok'
              endif
              if (allocated(ts) .eqv. .true.) then
                deallocate(ts)
                print *,'ts ok'
              endif
              if (allocated(swarm_br) .eqv. .true.) then
                deallocate(swarm_br)
                print *,'swarm_br ok'
              endif
              if (allocated(swarm_bt) .eqv. .true.) then
                deallocate(swarm_bt)
                print *,'swarm_bt ok'
              endif
              if (allocated(swarm_bp) .eqv. .true.) then
                deallocate(swarm_bp)
                print *,'swarm_bp ok'
              endif
              print *,'boite ',nboite,' ok!!'
              close(15)
              close(25)
              close(35)
              close(110)
            end do!----------------------------Fin de boulce sur les boites
            print *,'section ',it,'ok!'
            call cpu_time(tt2)
            print *,'temps calcul ',tt2-tt1
          enddo
          end
    la 1ere boucle sur nboite se déroule sans souci et a la 2eme iteration il plante , c'est a dire qu'il se fige, comme s'il rentrait dans une boucle infine.

    je l'ai donc fait tourner avec gdb en imprimant toutes les variable au moment du 'deallocate'. Je vous met le résultat:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
     deallocate...
     ldeb, lfin ok
     nombrePoints ok
     nbp ok
     wmoy ok
     tcab ok
     z ok
     ipvt ok
     Matfin ok
     MatAok
     dstwc ok
     cjg_dstwc ok
     wc ok
     w ok
     dst_w ok
     halah ok
     dst_t ok
     dst_f ok
     wsave ok
     t ok
     tt ok
     
    Program received signal SIGSEGV, Segmentation fault.
    0x00002aaaab1b68fa in _int_free () from /lib64/libc.so.6
    (gdb) bt
    #0  0x00002aaaab1b68fa in _int_free () from /lib64/libc.so.6
    #1  0x00002aaaab1b9f6c in free () from /lib64/libc.so.6
    #2  0x00000000004411fc in for_dealloc_allocatable ()
    #3  0x000000000040f550 in cj_proxy_mars_multisec () at cjl_oested_multisec.f90:567
    #4  0x00000000004034bc in main ()
    Je ne comprends absolument pas ce qui lui arrive...
    Si quelqu'un a deja rencontré ce probleme ou bien sait de quoi il s'agit, je lui serait reconnaissant de m'éclairer.
    Merci d'avance

  2. #2
    Membre à l'essai
    Inscrit en
    Décembre 2008
    Messages
    22
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 22
    Points : 15
    Points
    15
    Par défaut
    Bon,
    c'etait un bete dépassement de tableau qui venait bouffer sur l'espace memoire du tableau précédent...
    pense-bete: toujours penser a surveiller les indices...
    Merci quand meme

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. probleme d'allocation dynamique
    Par vince3320 dans le forum C
    Réponses: 10
    Dernier message: 22/04/2004, 16h27
  2. petit pbm allocation dynamique de stringGrid
    Par AnneOlga dans le forum C++Builder
    Réponses: 10
    Dernier message: 17/01/2004, 11h59
  3. Allocation dynamique de structures
    Par fr_knoxville dans le forum C
    Réponses: 8
    Dernier message: 06/05/2003, 21h59
  4. Allocation dynamique de mémoire en asm
    Par narmataru dans le forum Assembleur
    Réponses: 7
    Dernier message: 17/12/2002, 22h31
  5. Réponses: 4
    Dernier message: 03/12/2002, 16h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo