Fortran Fortran help: deleting items from a list

  • Thread starter brad sue
  • Start date
Hi , I need help to write a code for this function(fortran 77):

integer function delete(id, list, n) where
• delete returns 0 if the deletion was successful, -1 if the list is empty, and -2 if the user is not currently in the list.
•id is the integer identification number of the user.
•list is the integer array from which the id is to be removed.
•n is the current length of the list.

I tried this:
    integer function delete(id,list,n)
     integer i,indexe,j
     do 20 i=1,n
     if(list(i) then

20    continue
         do 30 j= indexe,n
          list(i) = list(i+1)
30        continue
      n = n-1
     return 0
I have not finfished because I am stuck . I dont know where to introduce the else statement that would indicat the id is not in the list.
My second problem is that How to check if that array is empty?

please can someone help me?
Thank you for the time.


The first thing to do is to check if the list is empty, i.e., n.eq.0.

To check if id is not in the list, set indexe to 0 before the first loop and check if it is still 0 after the loop.

Want to reply to this thread?

"Fortran help: deleting items from a list" You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving