Advertisement
Guest User

Untitled

a guest
Jun 11th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.      function read_list(InputFile) result (List)                              
  2.                       type(Line), pointer :: List                                            
  3. ~                                   character(*), intent(in)  :: InputFile                                
  4. ~                                    integer :: in                                                          
  5. ~                                                                                                        
  6. ~                                       open (file=InputFile, encoding=E_, newunit=in)                        
  7. ~                                          List => read_line(InputFile)                                        
  8. ~                                    close(in)                                                              
  9. ~                                    end function read_list                                                  
  10. ~                                                                                                            
  11. ~                                   recursive function read_line(in) result (srcLine)                        
  12. ~                                           type(Line), pointer      :: srcLine                                  
  13. ~                                         character(*), intent(in) :: in                                      
  14. ~                                       integer, parameter       :: max_len = 1024                          
  15. ~                                         character(max_len,CH_)   :: string                                  
  16. ~                                       integer                  :: IO                                      
  17. ~                                                                                                            
  18. ~                                                                                                            
  19. ~                                         read(in,"(a)",iostat=IO) string                                      
  20. ~                                       call Handle_IO_Status(IO,"reading line from file")                  
  21. ~                                         if (IO == 0) then                                                    
  22. ~                                            allocate(srcLine)                                                
  23. ~                                            srcLine%str = Trim(string)                                        
  24. ~                                              srcLine%next   = read_line(in)                                    
  25. ~                                           else                                                                
  26. ~                                                srcLine => Null()                                              
  27. ~                                          end if                                                              
  28. end function read_line
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement