IamMcCoder
Programmer
Little help debugging please? Thanks in advance.
I receive this error message when compiling my code using FORTRAN g95:
In file short_trl.f:171
type (*,'short_trline:',nstp,x,y,z,h,hemisphere)
1
Error: Unexpected array reference at (1)
Here's my code:
SUBROUTINE short_stepcon(status)
!******************************************************************
!******************************************************************
IMPLICIT NONE
INTEGER n
PARAMETER (n=4)
REAL*8 xyz, xyztry, error, h, hmin, hmax, tol, sig
COMMON /fltcom/ xyz, xyztry, error, h, hmin, hmax, tol, sig
INTEGER i
REAL*8 errmax, hsm
REAL*8 safety, pgrow, pshrnk, errcon
PARAMETER (safety=0.9, pgrow=-.25, pshrnk=-.25, errcon=1.89
integer*2 status
real*8 err_limit
!******************************************************************
save
1 h = h*signh
CALL step_trace(status)
h = ABS(h)
errmax=0.
DO 11 i=1,3
errmax = errmax + error(i)*error(i)
11 CONTINUE
errmax=SQRT(errmax)/tol
err_limit = 1.0
IF((errmax.GT.err_limit).AND.(h.GT.hmin).and.
# (status .ne. -1))then
! PRINT *,'hfail: h=', h
hsm = safety*h*(errmax**pshrnk)
IF (hsm/h .LT. 0.1) hsm = 0.1*h
h = MIN(MAX(hsm, hmin), hmax)
GOTO 1
ELSE
DO 12 i=1,n
xyz(i) = xyztry(i)
12 CONTINUE
RETURN
ENDIF
END
!******************************************************************
SUBROUTINE short_trline(in_pos,out_pos,dir,final_r,status)
c******************************************************************
IMPLICIT NONE
real*8 in_pos(4)
real*8 out_pos(4)
real*8 final_r
integer*2 status
integer*2 dir
INTEGER n
PARAMETER (n=4)
REAL*8 xyz, xyztry, error, h, hmin, hmax, tol, sig
COMMON /fltcom/ xyz, xyztry, error, h, hmin, hmax, tol, sig
INTEGER*4 nstp
integer*4 trace_print
real*4 nmax
REAL*8 x, y, z, ls, rs, vz, hz, hs, r,vpar
REAL*8 pi(3.1415926535897932D0)
EQUIVALENCE (xyz(1),x), (xyz(2),y), (xyz(3),z), (xyz(4),vpa
PARAMETER(ls=-60.0, rs=20.0, vz=40.0)
PARAMETER(hz=(rs-ls)/2.0, hs=ABS(rs+ls)/2.0)
logical*1 done
real*8 accepted_z
parameter (accepted_z = 0.001)
real*8 R_e
parameter (R_e = 6371.2)
real*8 hemisphere
real*8 stop_r
save
status = 0
hmin = 1.e-7
hmax = 2.e-6
h = 2.e-6
tol = 0.0001
nmax = 10000.
signh = dble(dir)
stop_r = 1. + final_r/R_e
x = in_pos(1)/R_e
y = in_pos(2)/R_e
z = in_pos(3)/R_e
vpar = 5.e7
done = .false.
nstp = 1
do while(.not. done)
r = sqrt(x*x + y*y + z*z)
if(r .le. stop_r) then
done = .true.
else
IF(nstp .GT. 2) then
h=MIN(hmin,h,hmax)
endif
call short_stepcon(status)
trace_print = mod(nstp,1000)
if(trace_print .eq. 0) then
hemisphere = float(dir) * z
TYPE (*,'short_trline:',nstp,x,y,z,h,hemisphere)
endif
if(nstp .gt. nmax) then
status = 2
done = .true.
endif
nstp = nstp + 1
endif
end do
out_pos(1) = x * R_e
out_pos(2) = y * R_e
out_pos(3) = z * R_e
out_pos(4) = vpar
RETURN
END
I receive this error message when compiling my code using FORTRAN g95:
In file short_trl.f:171
type (*,'short_trline:',nstp,x,y,z,h,hemisphere)
1
Error: Unexpected array reference at (1)
Here's my code:
SUBROUTINE short_stepcon(status)
!******************************************************************
!******************************************************************
IMPLICIT NONE
INTEGER n
PARAMETER (n=4)
REAL*8 xyz, xyztry, error, h, hmin, hmax, tol, sig
COMMON /fltcom/ xyz, xyztry, error, h, hmin, hmax, tol, sig
INTEGER i
REAL*8 errmax, hsm
REAL*8 safety, pgrow, pshrnk, errcon
PARAMETER (safety=0.9, pgrow=-.25, pshrnk=-.25, errcon=1.89
integer*2 status
real*8 err_limit
!******************************************************************
save
1 h = h*signh
CALL step_trace(status)
h = ABS(h)
errmax=0.
DO 11 i=1,3
errmax = errmax + error(i)*error(i)
11 CONTINUE
errmax=SQRT(errmax)/tol
err_limit = 1.0
IF((errmax.GT.err_limit).AND.(h.GT.hmin).and.
# (status .ne. -1))then
! PRINT *,'hfail: h=', h
hsm = safety*h*(errmax**pshrnk)
IF (hsm/h .LT. 0.1) hsm = 0.1*h
h = MIN(MAX(hsm, hmin), hmax)
GOTO 1
ELSE
DO 12 i=1,n
xyz(i) = xyztry(i)
12 CONTINUE
RETURN
ENDIF
END
!******************************************************************
SUBROUTINE short_trline(in_pos,out_pos,dir,final_r,status)
c******************************************************************
IMPLICIT NONE
real*8 in_pos(4)
real*8 out_pos(4)
real*8 final_r
integer*2 status
integer*2 dir
INTEGER n
PARAMETER (n=4)
REAL*8 xyz, xyztry, error, h, hmin, hmax, tol, sig
COMMON /fltcom/ xyz, xyztry, error, h, hmin, hmax, tol, sig
INTEGER*4 nstp
integer*4 trace_print
real*4 nmax
REAL*8 x, y, z, ls, rs, vz, hz, hs, r,vpar
REAL*8 pi(3.1415926535897932D0)
EQUIVALENCE (xyz(1),x), (xyz(2),y), (xyz(3),z), (xyz(4),vpa
PARAMETER(ls=-60.0, rs=20.0, vz=40.0)
PARAMETER(hz=(rs-ls)/2.0, hs=ABS(rs+ls)/2.0)
logical*1 done
real*8 accepted_z
parameter (accepted_z = 0.001)
real*8 R_e
parameter (R_e = 6371.2)
real*8 hemisphere
real*8 stop_r
save
status = 0
hmin = 1.e-7
hmax = 2.e-6
h = 2.e-6
tol = 0.0001
nmax = 10000.
signh = dble(dir)
stop_r = 1. + final_r/R_e
x = in_pos(1)/R_e
y = in_pos(2)/R_e
z = in_pos(3)/R_e
vpar = 5.e7
done = .false.
nstp = 1
do while(.not. done)
r = sqrt(x*x + y*y + z*z)
if(r .le. stop_r) then
done = .true.
else
IF(nstp .GT. 2) then
h=MIN(hmin,h,hmax)
endif
call short_stepcon(status)
trace_print = mod(nstp,1000)
if(trace_print .eq. 0) then
hemisphere = float(dir) * z
TYPE (*,'short_trline:',nstp,x,y,z,h,hemisphere)
endif
if(nstp .gt. nmax) then
status = 2
done = .true.
endif
nstp = nstp + 1
endif
end do
out_pos(1) = x * R_e
out_pos(2) = y * R_e
out_pos(3) = z * R_e
out_pos(4) = vpar
RETURN
END