- #36
DrClaude
Mentor
- 8,386
- 5,474
Could it be possible to see the code where you call varelec_init?
DrClaude said:Could it be possible to see the code where you call varelec_init?
Not a reflection on you, Matterwave, but whoever wrote this code seems to have been completely unaware of one of the main principles of good programming practice - modularization, breaking a large program into smaller, more easily manageable chunks.Matterwave said:varelec_init is called in the main program, which is several thousand lines long.
Mark44 said:Not a reflection on you, Matterwave, but whoever wrote this code seems to have been completely unaware of one of the main principles of good programming practice - modularization, breaking a large program into smaller, more easily manageable chunks.
call varelec_init(varelecfrac,elecprofile,effilename,elecfracname)
Can you show the lines where varelecfrac,elecprofile,effilename,elecfracname are declared in the part of the code where this call is?Matterwave said:So the problem seems to be coming from simply calling varelec_init.
The call statement looks like this:
Fortran:call varelec_init(varelecfrac,elecprofile,effilename,elecfracname)
DrClaude said:Can you show the lines where varelecfrac,elecprofile,effilename,elecfracname are declared in the part of the code where this call is?
if(myid.eq.0) then
read(5,*) irestart,isconsist,iprofile,spinco,varelecfrac,rhofilename,effilename
read(5,*) dm21sq,dm32sq,theta12,theta13,theta23
read(5,*) rsrad,drsinit,dr0,rfinal
read(5,*) lum(1:nflavor,1:2)
read(5,*) errtol,drwrite,itwrite
read(5,*) drwvwrite,itwvwrite
read(5,*) timemax
read(5,*) ranrhoescale,ranrhodrscale
dm21sq=dm21sq*1.d-12
dm32sq=dm32sq*1.d-12
do iphi=1,nphi
do idr=1,nranrhodr
ranrhoe(idr,iphi)=1.d0+ranrhoescale*rannyu(0)
enddo
enddo
! convert maximum time to hours
timemax(:)=timemax(:)*3600.d0
endif
! read data file
iend=0
iegrid=0
do while (iend.eq.0)
iegrid=iegrid+1
read(21,*,iostat=ierr) ryegrid(iegrid), yegrid(iegrid)
if(ierr.ne.0) then
iend=1
iegrid=iegrid-1
close(21)
endif
enddo
write(6,*) ' Electron fraction grid contains ',iegrid,'values'
write(6,*) ' Beginning of Y_e grid '
do i=1,min(5,iegrid)
write(6,'(f15.7,e18.9)') ryegrid(i),yegrid(i)
enddo
write(6,*) ' End of Y_e grid '
do i=max(1,iegrid-4),iegrid
write(6,'(f15.7,e18.9)') ryegrid(i),yegrid(i)
enddo
DrClaude said:I was asking for the part of the code where the variables are declared, meaning where their type is defined.
Your bug is reminiscent of out-of-bounds array assignments. It seems that part of the memory is being modified when it shouldn't, so I would like to see what which are in the call varelec_init are actually like.
integer :: varelecfrac
integer :: elecprofile
character*80 helname,rhofilename,effilename,elecfracname
I'm not at all surprised.Matterwave said:UPDATE: Ok, something funky is happening with iegrid.
Matterwave said:I can change the output of the code by changing iegrid from 0 (regular bug) to 30 (new bug) to 292 (works like usual). It must be messing around with helec_init...and this is probably another instance where an implicit variable is screwing me. :( I think that's what's messing the code up. I'm going to go ahead and rename this variable and see what happens.
I see ryegrid and yegrid declarations at the top of the helectron module. I can't find one for myvid. The helectron module uses two other modules, params and parallel, so maybe myvid is declared in one of these.Mark44 said:2. A number of variables appear (as if by magic!) in varelec_init(). These are myvid, icomments, iend, iegrid, ryegrid, and yegrid.
fluidistic said:Just a thought, Matterwave. Maybe you could put all of your code in github so that anyone interested could look at the whole code. At least temporarily (it's pretty easy to delete the github repository). In the readme file you could put an example of the input and the expected output.
If you're interested let us know and we'll give you the commands to enter in the terminal.