	PROGRAM CAFMEM
	
	  TYPE T
	    INTEGER(KIND=4) :: N
	    REAL(KIND=8),ALLOCATABLE :: D(:)
	  END TYPE T
	  
	  TYPE(T),ALLOCATABLE :: A(:)[:]
          
          REAL(KIND=8),ALLOCATABLE :: B(:)
          INTEGER(KIND=2) :: N
	  
	  INTEGER(KIND=4) :: I,J,K,L,IMG
	  REAL(KIND=8) :: TOTAL,TOTAL_I
	  INTEGER(KIND=4),PARAMETER :: M=10000,R=10
	  
	  ALLOCATE(A(M)[*])
	  
	  IMG=THIS_IMAGE()
	  DO I=1,M
	    A(I)%N=1000
	    ALLOCATE(A(I)%D(A(I)%N))
	    A(I)%D=IMG*1.0_8
	  END DO
	  
	  SYNC ALL
	  
	  DO K=1,R
	    TOTAL=0.0_8
	    DO J=1,NUM_IMAGES()
	      DO I=1,M

                N=A(I)[J]%N
                
                ALLOCATE(B(N))
                
                B=A(I)[J]%D
            
                TOTAL_I=0.0_8
                DO L=1,N
                  TOTAL_I=TOTAL_I+B(L)
                END DO
            
                DEALLOCATE(B)
	        
	        TOTAL=TOTAL+TOTAL_I
	        
	      END DO
	    END DO
	    WRITE(6,*) 'IMAGEN: ',IMG,' CICLO: ',K
	    CALL FLUSH(6)
	  END DO
	  
	END PROGRAM CAFMEM