size - Over-riding FORTRAN error "array bound is not scalar integer" -
i'd know if loop can created, inside can call subroutine in there arrays defined size varies function of loop variable. tried following, got error "array bound not scalar integer". how solve issue?
. . . iloop: i=5,24,0.5 jloop: j=5,20 call check(i,j,divlen,machexit,final) if (final.eq.1) exit iloop enddo jloop enddo iloop . . end program
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine check(i,j,divlen,machexit,final) integer, parameter :: ivlpts=10 real :: i,divlen,machexit integer :: final,j integer :: exppts,intstrtpts,contourstrtpts,totalpts,p1,p2,p3,p4,p5,p6,p7 exppts=((j*ivlpts)+((j-1)*(ivlpts-1))) p2=(exppts-ivlpts) p3=(ivlpts-1) p6=(exppts-p2) call check2(ivlpts,i,j,divlen,machexit,final,exppts,p2,p3,p6) end subroutine check
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine check2(ivlpts,i,j,divlen,machexit,final,exppts,p2,p3,p6) real, parameter :: gamma=1.4d0,mini=1.02d0 integer,allocatable :: expcontourpts(:),m(:),x(:),y(:) real,allocatable :: aoverastar(:),mvariance(:) allocate(expcontourpts(exppts)) allocate(m(exppts)) allocate(x(exppts)) allocate(y(exppts)) allocate(aoverastar(p6)) allocate(mvariance(p6)) . . . end subroutine check2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
here i'm answering:
i'd know if loop can created, inside can call subroutine in there arrays defined size varies function of loop variable.
the answer "yes", allocate() isn't way it. use 1 of arguments array dimension. here example summation in inefficient way, uses method i'm describing:
program main implicit none integer :: i, j = 1,5 call sum_values(i,j) write(*,*) j end end program main subroutine sum_values(i,j) implicit none integer, intent(in) :: integer, intent(out) :: j integer, dimension(i) :: an_array an_array(1:i) = 1 j = sum(an_array(1:i)) end subroutine sum_values
critical line is:
integer, dimension(i) :: an_array
the dimension of array given in argument list when called.
i see you're using different approach. approach should still work, think way i'm describing lot less error-prone , appropriate complexity of you've asked for. make sure use "implicit none" statements, , declare in/out arguments.
Comments
Post a Comment