how to define function as an array

sarahf60
07-04-2013, 06:13 AM
Hi
I 'm trying to write a code to measure comoving distance in different redshifts , and for measurin the integral I'm using the subroutine based on Romberg method.
when I want to define my function "DFUNCER(I)" as an array I'm facing with segmentation error :

" SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
lum 0000000000404013 Unknown "

and when I omit I it measure it just for one value , my code is this .....
how I can fix the errors :

INTEGER OMEGAK,N,I,j,k
DOUBLE PRECISION, dimension(100000) :: DC,DA,DOMEGA,DY,ZUP,Z
DOUBLE PRECISION LV,HO,h,DH
DOUBLE PRECISION OMEGAL,OMEGAM,ZMIN,ZMAX,STEP
integer, parameter :: AO=1

OMEGAK=0
HO=70.
h=0.7
OMEGAL=0.7
OMEGAM=0.3
LV=299792.458
DH=(LV*(AO*HO))

! ================================================== =================
Function DFUNCER (Z)
! ================================================== =================

implicit none

DOUBLE PRECISION,DIMENSION (100000) :: Z
DOUBLE PRECISION, DIMENSION (100000) :: E,dDistCa,DFUNCER
! DOUBLE PRECISION :: DFUNCER

DO j=1,N
ZMIN=0.
ZMAX=2.
STEP=0.1
N=int((zmax-zmin)/step)
Z(J)=ZMIN+(J-1)*STEP
ZUP(J)=Z(J)+STEP
!IF (K.EQ.I.AND.Z(J).EQ.Z(K)) THEN
E(j)=(OMEGAM*( 1+Z(j))**3 + OMEGAL)**(-0.5)
! dDistCa = 1/(E(j))
write(*,*)j,Z(j),E(j)
DFUNCER(J)=1/dDistCa(j)

END DO

DFUNCER=DFUNC(I)

RETURN
end function DFUNCER