Je fais actuellement un stage où j'essai d'interfacer du fotran et du python.
Je souhaite récupéré un tableau passé en paramètre entre autres et lorsque j'augmente les dimension de ce tableau, j'obtiens une erreur de segmentation.
Voici le code :
C -*- f90 -*-
!=====================================================================
! ECRIPROJ.F version 1.0 du 07/2010
!
!Ecriture des projections calculé algébriquement
!dans un fichier binaire
!
!========-=========-=========-=========-=========-=========-=========-=
!========-=========-=========-=========-=========-=========-=========-=
SUBROUTINE EXECUTABLE(ia,b,c,d,e,f,g,h,i,j,k,
&l,m,n,o,p,q,r)
! a= TAB
! b=date et heure
! c=nPixCol
! d=rayGir
! e=nAng
! f=larCha
! g=rayCach
! h=prof1
! i=prof2
! j=prof3
! k=larg1
! l=larg2
! m=larg3
! n=angInc
! o=startAng
! p=profC
! q=nbLig
! r=nbCol
INTEGER, INTENT(IN) :: c,e,f,h,i,j,k,l
! REAL, INTENT(IN) :: d,g
CHARACTER (LEN=40) :: b
INTEGER :: m,n,o,p
INTEGER :: q,r
DIMENSION ia(q,r)
CALL ECRIPROJ(ia,b,c,d,e,f,g,h,i,j,k,
&l,m,n,o,p,q,r)
RETURN
END SUBROUTINE EXECUTABLE
! !========================================================================
SUBROUTINE ECRIPROJ(ITAB,date,nPixCol,rayGir,nAng,larCha,
&rayCach,prof1,prof2,prof3,larg1,larg2,larg3,angInc,
&startAng,profC,nbLig,nbCol)
!========================================================================
! Fichier contenant l'ensemble des parametres principaux ================
INCLUDE "param2D.f"
! Déclaration des variables
! INTEGER, INTENT(IN) :: larCha,nAng
INTEGER, INTENT(IN) :: nbCol,nbLig
! INTEGER, INTENT(IN) :: nPixCol,prof1
! INTEGER, INTENT(IN):: prof2,prof3,larg1,larg2,larg3
! INTEGER, INTENT(IN) :: angInc, startAng,profC
TYPE (paramfichier) :: ParamFic
TYPE (collimateur) :: ParamCol
TYPE (geomacquis) :: ParamAcq
TYPE (deconvolution) :: ParamDec
CHARACTER*150 FICPRJ
REAL, INTENT(IN) :: rayGir,rayCach
INTEGER :: NENRG
INTEGER*4 :: TailleEnreg
CHARACTER (LEN=40), INTENT(IN) :: date
INTEGER :: I,J,m,n,s,t
DIMENSION ITAB(nbLig,nbCol)
DIMENSION IRECU(256,256)
!================== initialisation des données ===============================
Call InitEntetePy(ParamFic,ParamCol,ParamAcq,ParamDec,date)
print* , date
print* ,'nb lignes : ',nbLig
print* ,'nb colonnes : ',nbCol
TailleEnreg = 4*256
! angInc=90
! startAng=0
! profC=12
! nPixCol = 5
! rayGir=15.0
! prof1=8
! prof2=0
! nAng=4
! larCha=130
! rayCach=3.8
! prof3=0
! larg1=15
! larg2=0
! larg3=0
occ=0
I=0
J=0
m=0
n=0
s=0
t=0
FICPRJ= 'image.proj'
NENRG=0
! print* ,'rayon giration = ', rayGir
! print* ,'rayon de cache = ',rayCach
! print* ,'Pixel du collimateur = ', nPixCol
! print* ,'profondeur = ', prof
! print* ,'nb angle = ',nAng
! ==============================================================================
! Initialisation de l'entete collimateur ------------------------------------------------
ParamCol%NB_TYPE_TROU = nPixCol
ParamCol%LAR1 = larg1
ParamCol%LAR2 = larg2
ParamCol%LAR3 = larg3
ParamCol%PROF1 = prof1
ParamCol%PROF2 = prof2
ParamCol%PROF3 = prof3
! Initialisation de l'entete Geometrie acquisition--------------------------------------
ParamAcq%NB_ANG = nAng
ParamAcq%INC_ANG = angInc
ParamAcq%NSTART = startAng
ParamAcq%IRAYORBI = rayGir
ParamAcq%IRayon = rayCach
ParamAcq%LARCHA = larCha
ParamAcq%IPRCHA = profC
!==============================================================================
ParamFic%Dimension = 3
ParamFic%IncPas(1) = 1
ParamFic%IncPas(2) = 1
ParamFic%IncPas(3) = nAng
ParamFic%DebPas(1) = 1
ParamFic%DebPas(2) = 1
ParamFic%DebPas(3) = ParamAcq%NSTART
ParamFic%Var(1) = 'X'
ParamFic%Var(2) = 'Y'
ParamFic%Var(3) = 'A'
ParamFic%NbrPas(1) = larCha
ParamFic%NbrPas(2) = ParamCol%LAR1+ParamCol%LAR2+ParamCol%LAR3
ParamFic%NbrPas(3) = nAng
ParamFic%NbrEnrEnt = 4
ParamFic%TailleEnreg = TailleEnreg
! ================== Construction du nom de fichier ============================
! ================== Ouverture du fichier de sortie proja =======================
! ~~~~~~~~~~~~~ Preparation de l'entete General ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ParamFic%FormatEnreg = "R4"! Format des donnees(I4,I8,R4,R8,C8,C16,..).
ParamFic%DrapeauEnt = "ENT2010"! nom de la version de l entete
ParamFic%Drapeau = "cacao-proj"! Mot Magique (cacao-proj,cacao-psd,...)
ParamFic%Date= date
ParamFic%NbrEnrTot = ParamFic%NbrEnrEnt
& +nbLig*nbCol ! Nombre Total d'enregistrements.
ParamFic%FicBin=FICPRJ
ParamAcq%SUJET = ParamFic%FicBin
OPEN(UNIT=10,FILE=FICPRJ,FORM='UNFORMATTED',RECL=TailleEnreg,
& STATUS='NEW',ACCESS='DIRECT')
! ~~~~~~~~~~~ Ecriture de l'entete dans le fichier de sortie proj ~~~~~~~~~~~~~~
WRITE (1,REC = 1) ParamFic
WRITE (1,REC = 2) ParamCol
WRITE (1,REC = 3) ParamAcq
WRITE (1,REC = 4) ParamDec
NENRG = 4
DO m = 1,nbLig
DO n = 1,nbCol
IRECU(m,n)=0
END DO
END DO
! ~~~~~~~~~~ Récupération des projections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DO s =1, nbLig
DO t = 1, nbCol
IRECU(s,t)=ITAB(s,t)
print *,'ligne ',s
print *,'colonne ',t
END DO
END DO
! ~~~~~~~~ Ecriture des projections dans le fichier de sortie proj ~~~~~~~~~~~~~
print* ,'Lancement de lécriture dans le fichier ',FICPRJ
print* ,'Nb enregristrement total', ParamFic%NbrEnrTot
DO J = 1 , nbLig
DO I = 1 , nbCol
NENRG = NENRG + 1
!on écrit les résultats des projections dans le fichier de sortie
WRITE (10, REC=NENRG) IRECU(J,I)
END DO
END DO
! print* ,'ParamFic%TailleEnreg : ',ParamFic%TailleEnreg
! ================== Fermeture du fichier de sortie proja ======================
CLOSE(10)
print* ,'Le fichier a bien été créé'
RETURN
END SUBROUTINE ECRIPROJ
L'erreur se trouve au niveau d'ici :
DO s =1, nbLig
DO t = 1, nbCol
IRECU(s,t)=ITAB(s,t)
print *,'ligne ',s
print *,'colonne ',t
END DO
END DO
Savez-vous d'où peut venir l'erreur?
Je fais appele à executable depuis mon programme à l'aide de la ligne :