!*********************************************************************
! A funcion of Main, return a sequence number of a given atom name.  *
! The sequence number can not exceed the parameter "Matom"           *
!*********************************************************************
    Function AAA(ATNAME) 
    
    Character*4 ATNAME
    Integer     AAA
        
    AAA=0  ! If the atom name is not list here, then AAA=0.
    
    !=========================[Amino Acids Atom]
    If(ATNAME==' N  ')   AAA = 1  ! Backbone Atoms                     
    If(ATNAME==' CA ')   AAA = 2  ! Backbone Atoms                     
    If(ATNAME==' C  ')   AAA = 3  ! Backbone Atoms                     
    If(ATNAME==' O  ')   AAA = 4  ! Backbone Atoms                     
    If(ATNAME==' CB ')   AAA = 5                       
    If(ATNAME==' CD ')   AAA = 6                       
    If(ATNAME==' CD1')   AAA = 7                       
    If(ATNAME==' CD2')   AAA = 8                       
    If(ATNAME==' CE ')   AAA = 9                       
    If(ATNAME==' CE1')   AAA = 10                      
    If(ATNAME==' CE2')   AAA = 11                      
    If(ATNAME==' CE3')   AAA = 12                      
    If(ATNAME==' CG ')   AAA = 13                      
    If(ATNAME==' CG1')   AAA = 14                      
    If(ATNAME==' CG2')   AAA = 15                      
    If(ATNAME==' CH2')   AAA = 16                      
    If(ATNAME==' CZ ')   AAA = 17                      
    If(ATNAME==' CZ2')   AAA = 18                      
    If(ATNAME==' CZ3')   AAA = 19                      
    If(ATNAME==' ND1')   AAA = 20                      
    If(ATNAME==' ND2')   AAA = 21                      
    If(ATNAME==' NE ')   AAA = 22                      
    If(ATNAME==' NE1')   AAA = 23                      
    If(ATNAME==' NE2')   AAA = 24                      
    If(ATNAME==' NH1')   AAA = 25                      
    If(ATNAME==' NH2')   AAA = 26                      
  	If(ATNAME==' NZ ')   AAA = 27                        
    If(ATNAME==' OD1')   AAA = 28                    
    If(ATNAME==' OD2')   AAA = 29                    
    If(ATNAME==' OE1')   AAA = 30                    
    If(ATNAME==' OE2')   AAA = 31                    
    If(ATNAME==' OG ')   AAA = 32                    
    If(ATNAME==' OG1')   AAA = 33                    
    If(ATNAME==' OH ')   AAA = 34                    
    If(ATNAME==' OXT')   AAA = 35                    
    If(ATNAME==' SD ')   AAA = 36                    
    If(ATNAME==' SG ')   AAA = 37    
     
    !=========================[Nucleic Acids Atom]
    If(ATNAME==' P  ')   AAA = 40                    
    If(ATNAME==' C1*')   AAA = 41                    
    If(ATNAME==' C2 ')   AAA = 42                    
    If(ATNAME==' C2*')   AAA = 43                    
    If(ATNAME==' C3*')   AAA = 44                    
    If(ATNAME==' C4 ')   AAA = 45                    
    If(ATNAME==' C4*')   AAA = 46                    
    If(ATNAME==' C5 ')   AAA = 47                    
    If(ATNAME==' C5*')   AAA = 48                    
    If(ATNAME==' C5M')   AAA = 49                    
    If(ATNAME==' C6 ')   AAA = 50                    
    If(ATNAME==' C8 ')   AAA = 51                    
    If(ATNAME==' N1 ')   AAA = 52                    
    If(ATNAME==' N2 ')   AAA = 53                    
    If(ATNAME==' N3 ')   AAA = 54                    
    If(ATNAME==' N4 ')   AAA = 55                    
    If(ATNAME==' N6 ')   AAA = 56                    
    If(ATNAME==' N7 ')   AAA = 57                    
    If(ATNAME==' N9 ')   AAA = 58                    
    If(ATNAME==' O1P')   AAA = 59                    
    If(ATNAME==' O2 ')   AAA = 60                    
    If(ATNAME==' O2*')   AAA = 61                    
    If(ATNAME==' O2P')   AAA = 62                    
    If(ATNAME==' O3*')   AAA = 63                    
    If(ATNAME==' O3P')   AAA = 64                    
  	If(ATNAME==' O4 ')   AAA = 65                      
    If(ATNAME==' O4*')   AAA = 66                    
    If(ATNAME==' O5*')   AAA = 67                  
    If(ATNAME==' O6 ')   AAA = 68                  
    If(ATNAME=='1H2 ')   AAA = 69                  
    If(ATNAME=='1H2*')   AAA = 70                  
    If(ATNAME=='1H4 ')   AAA = 71                  
    If(ATNAME=='1H5*')   AAA = 72                  
    If(ATNAME=='1H5M')   AAA = 73                  
    If(ATNAME=='1H6 ')   AAA = 74                  
    If(ATNAME=='2H2 ')   AAA = 75                  
    If(ATNAME=='2H2*')   AAA = 76  
    If(ATNAME=='2H4 ')   AAA = 77    
    If(ATNAME=='2H5*')   AAA = 78    
    If(ATNAME=='2H5M')   AAA = 79    
    If(ATNAME=='2H6 ')   AAA = 70   
    If(ATNAME=='2HO*')   AAA = 81   
    If(ATNAME=='3H5M')   AAA = 82   
    If(ATNAME==' H1 ')   AAA = 83   
    If(ATNAME==' H1*')   AAA = 84   
    If(ATNAME==' H2 ')   AAA = 85   
    If(ATNAME==' H2*')   AAA = 86   
    If(ATNAME==' H3 ')   AAA = 87   
    If(ATNAME==' H3*')   AAA = 88   
    If(ATNAME==' H4*')   AAA = 89    
    If(ATNAME==' H5 ')   AAA = 80    
    If(ATNAME==' H5T')   AAA = 91    
    If(ATNAME==' H6 ')   AAA = 92    
    If(ATNAME==' H8 ')   AAA = 93 
    
    If(ATNAME(1:1)=='H') AAA = 94      
      
                           
                            
    If( AAA==0 ) AAA=99      
!    If( (AAA==0).AND.(ATNAME(2:2)=='H') ) AAA=99      
    
    Return
    End
