Error in Execution of Program: Find_Neighbor

  • Thread starter Thread starter Physicslad78
  • Start date Start date
  • Tags Tags
    Error
Click For Summary
SUMMARY

The forum discussion centers on an execution error encountered while running the Fortran program "find_neighbor." The error message indicates an issue with reading from the input file "ngh.in," specifically that the program attempts to read more data than is available in the file. The user is advised to verify the number of items in "ngh.in" against the number of items the program expects to read, which includes variables such as "ishell," "rc," "alat," and the atom coordinates.

PREREQUISITES
  • Understanding of Fortran programming, particularly file I/O operations.
  • Familiarity with data structures used in scientific computing, such as arrays.
  • Knowledge of error handling in programming to debug runtime issues.
  • Experience with input file formatting and data validation techniques.
NEXT STEPS
  • Review Fortran file I/O operations, focusing on the OPEN and READ statements.
  • Learn about debugging techniques in Fortran to identify runtime errors.
  • Explore data validation methods to ensure input files meet program requirements.
  • Investigate the structure and content of the input file "ngh.in" to ensure compatibility with the program's expectations.
USEFUL FOR

This discussion is beneficial for Fortran developers, computational scientists, and anyone involved in scientific programming who needs to troubleshoot file I/O errors in their applications.

Physicslad78
Messages
46
Reaction score
0
Hello All

I am trying to compile a program and I guess it compiles fine but there is a problem in execution. I get the following error:

End of file
apparent state: unit 5 (ngh.in)
last format: list io
lately reading direct formatted external IO
Aborted


I am not sure what the error is actually (I am sure it is in open related to file ngh.in). I will post the program here and I appreciate it if someone can give me tips. Thanks

program find_neighbor
c
implicit double precision (a-h,o-z)
parameter(natm=12,nlmx=1000)
dimension aa(3,3),xa(3,natm)
c
open(5,file='ngh.in')
open(6,file='ngh.list')
c
read (5,*) ishell
write (6,'(/a,i1)') ' ishell = ',ishell
read (5,*) rc,alat
write (6,'(/a,2(3f8.3,2x))') ' rc and alat = ',rc,alat
rc=rc/alat
c
write (6,'(/a)') ' real space lattice vectors:'
do i=1,3
read (5,*) (aa(j,i),j=1,3)
write (6,'(3f8.3)') (aa(j,i),j=1,3)
end do
c
read (5,*) nat
write (6,'(/a,i2)') ' nat =',nat
c
write (6,'(/a)') ' atom coordinates:'
do iat=1,nat
read (5,*) (xa(j,iat),j=1,3)
write (6,'(i2,3f10.5)') iat,(xa(j,iat),j=1,3)
end do
c
call neigh(ishell,nat,aa,xa,alat,rc)
call sort(n,ra,rb,iatm,lv,wksp,iwksp)
call indexx(n,arrin,indx)
call shell(nn,ns,arn,axn,it)
c
end
 
Technology news on Phys.org
It looks like your program tried to read more things than were in the input file. To confirm this, count the number of items in the file, and count the number of items your program is trying to read.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 14 ·
Replies
14
Views
3K
Replies
14
Views
4K
  • · Replies 70 ·
3
Replies
70
Views
5K
Replies
6
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
6
Views
3K
  • · Replies 75 ·
3
Replies
75
Views
7K