Bonjour, quelqu'un aurait-il une idée ?

J'explique mon souci : j'ai créé une subroutine qui lie des données binaire d'un fichier. Lorsqu'elle est placée dans le programme principal (dans le contains), tout fonctionne sans soucis.
Cependant lorsqu'on place cette subroutine dans un module externe (programmation 'modulaire'), l'executable ouvre le fichier sans soucis, mais plante au premier read. L'erreur est la suivante "forrtl: severe (39): error during read, unit 11, file xxxx/yyy/".

Techniquement, cela devrait fonctionner. Il n'y a pas d'erreurs de compilations. Les implicit none sont OK, et il n'y a pas de variables communes.

Voici le code :
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
 
PROGRAM prog
USE cv_flv3d
IMPLICIT NONE
!! ******************* DEBUT ENTETE FICHIER ********************
!!
!! _NOM         :  prog
!! _DESCRIPTION :  test des modules
!! _HISTORIQUE  :  Version 1.0
!! _DATE        :  08 - 07 -2008
!! ******************* FIN ENTETE FICHIER **********************
 
!! DECLARATIONS
CHARACTER(LEN=200)                            :: fich    ! Nom du fichier
REAL(KIND=8), DIMENSION(:,:,:,:), ALLOCATABLE :: tab     ! Table des données
INTEGER(KIND=8)                               :: nbloc  &! Nombre de blocs
                                              &, imax   &! indice i max
                                              &, jmax   &! indice j max
                                              &, kmax    ! indice k max
INTEGER :: tmp,tmp2
 
WRITE(*,'(a17)') "Nom du fichier : "
READ (*,*)       fich
 
CALL rd_dimflow(TRIM(fich),nbloc,imax,jmax,kmax)
 
WRITE(*,*) 'nbloc', nbloc
WRITE(*,*) 'imax' , imax
WRITE(*,*) 'jmax' , jmax
WRITE(*,*) 'kmax' , kmax
 
 
ALLOCATE(tab(1:imax,1:jmax,1:kmax,1:nbloc))
CALL rd_flow(TRIM(fich),tab)
 
!WRITE(*,*) tab
 
STOP
END PROGRAM prog
 
Voici le module :
MODULE cv_flv3d
IMPLICIT NONE 
!! ****************** MODULE cv_flv3d ***********************
!! _NOM         : cv_flv3d 
!! _DESCRIPTION : Convertions et lectures des fichiers 
!!                flow type v3d
!! _CONTEXTE    :
!! _REMARQUES   :
!! _VOIR        :
!! ******************* MODULE cv_flv3d **********************
 
 
CONTAINS
 
SUBROUTINE rd_dimflow(fich,nbloc,imax,jmax,kmax)
   IMPLICIT NONE
   !! DECLARATIONS
   CHARACTER(LEN=*), INTENT (IN)    :: fich    ! Nom du fichier
   INTEGER(KIND=8) , INTENT (INOUT) :: nbloc  &! Nombre de blocs
                                    &, imax   &! indice i max
                                    &, jmax   &! indice j max
                                    &, kmax    ! indice k max
   INTEGER(KIND=8)                  :: tmp    &! variable inutilisee
                                    &, tmp2    ! variable inutilisee
   CHARACTER(LEN=20)                :: chaine  ! chaine inutilisee
 
 
   !! INSTRUCTIONS
   OPEN(UNIT=14,FILE=fich,FORM='unformatted',STATUS='old')
      READ(14) 
      nbloc = 5  ! ro rou rov row roe
      READ(14) chaine
      READ(14) tmp,tmp2,imax,jmax,kmax
   CLOSE(14)
 
   RETURN
END SUBROUTINE rd_dimflow
 
 
SUBROUTINE rd_flow(fich,tab)
   IMPLICIT NONE
 
   !! DECLARATIONS
   CHARACTER(LEN=*),                 INTENT (IN)    :: fich    ! Nom du fichier
   REAL(KIND=8), DIMENSION(:,:,:,:), INTENT (INOUT) :: tab     ! Tableau des valeurs
   INTEGER(KIND=8)                                  :: nbloc  &! Nombre de blocs
                                                    &, imax   &! indice i max
                                                    &, jmax   &! indice j max
                                                    &, kmax   &! indice k max
                                                    &, i,j,k,l&! variable de bouclage
                                                    &, tmp    &! variable inutilisee
                                                    &, tmp2    ! variable inutilisee
   !! INSTRUCTIONS
   OPEN(UNIT=11,FILE=fich,FORM='unformatted',STATUS='old')
      READ(11) nbloc
      nbloc = 5
      DO l=1,nbloc
         READ(11)                           ! Le nom du bloc ex : "va ro"
         READ(11) tmp,tmp2,imax,jmax,kmax   ! nrec,ndom,imax,jmax,kmax
         READ(11) (((tab(i,j,k,l),i=1,imax),j=1,jmax),k=1,kmax)
      END DO
   CLOSE(11)
 
   RETURN
END SUBROUTINE rd_flow
 
END MODULE cv_flv3d
Merci d'avance !