KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
The following code is returning a Segmentation Fault because the allocatable array I am trying to pass is not being properly recognized (size returns 1, when it should be 3). In this page (http://www.eng-tips.com/viewthread.cfm?qid=170599) a similar example seems to indicate that it should work fine in F95; my code file has a .F90 extension, but I tried changing it to F95, and I am using gfortran to compile. My guess is that the problem should be in the way I am passing the allocatable array to the subroutine; What am I doing wrong? !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%! PROGRAM test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%! IMPLICIT NONE DOUBLE PRECISION,ALLOCATABLE :: Array(:,:) INTEGER :: iii,jjj ALLOCATE(Array(3,3)) DO iii=1,3 DO jjj=1,3 Array(iii,jjj)=iii+jjj PRINT*,Array(iii,jjj) ENDDO ENDDO CALL Subtest(Array) END PROGRAM !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%! SUBROUTINE Subtest(Array) DOUBLE PRECISION,ALLOCATABLE,INTENT(IN) :: Array(:,:) INTEGER :: iii,jjj PRINT*,SIZE(Array,1),SIZE(Array,2) DO iii=1,SIZE(Array,1) DO jjj=1,SIZE(Array,2) PRINT*,Array(iii,jjj) ENDDO ENDDO END SUBROUTINE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%!
Tags (comma-separated)
Save Edits
Cancel