MODULE in_unknown
!
!**********************************************************************************
!*  IN_UNKNOWN                                                                    *
!**********************************************************************************
!* This module attempts to read files in an unknown format.                       *
!* NOTE: this module will attempt to get only the "minimum vital" informations,   *
!*      i.e. the vectors of the box, and the positions and chemical species       *
!*      of atoms. No auxiliary properties will be extracted from the file.        *
!**********************************************************************************
!* (C) Sept. 2015 - Pierre Hirel                                                  *
!*     Université de Lille, Sciences et Technologies                              *
!*     UMR CNRS 8207, UMET - C6, F-59655 Villeneuve D'Ascq, France                *
!*     pierre.hirel@univ-lille.fr                                                 *
!* Last modification: P. Hirel - 08 Feb. 2016                                     *
!**********************************************************************************
!* This program is free software: you can redistribute it and/or modify           *
!* it under the terms of the GNU General Public License as published by           *
!* the Free Software Foundation, either version 3 of the License, or              *
!* (at your option) any later version.                                            *
!*                                                                                *
!* This program is distributed in the hope that it will be useful,                *
!* but WITHOUT ANY WARRANTY; without even the implied warranty of                 *
!* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                  *
!* GNU General Public License for more details.                                   *
!*                                                                                *
!* You should have received a copy of the GNU General Public License              *
!* along with this program.  If not, see <http://www.gnu.org/licenses/>.          *
!**********************************************************************************
!
!
USE atoms
USE comv
USE constants
USE messages
USE files
USE subroutines
!
!
CONTAINS
!
SUBROUTINE READ_UNKNOWN(inputfile,H,P,comment,AUXNAMES,AUX)
!
IMPLICIT NONE
CHARACTER(LEN=*),INTENT(IN):: inputfile
CHARACTER(LEN=2):: species
CHARACTER(LEN=128):: msg
CHARACTER(LEN=1024):: temp
CHARACTER(LEN=32),DIMENSION(20):: columns
CHARACTER(LEN=128),DIMENSION(:),ALLOCATABLE:: AUXNAMES !names of auxiliary properties
CHARACTER(LEN=128),DIMENSION(:),ALLOCATABLE:: comment
INTEGER:: i, icol, j
INTEGER:: Nlines  !number of lines in the file
REAL(dp):: tempreal
REAL(dp),DIMENSION(3,3):: H   !Base vectors of the supercell
REAL(dp),DIMENSION(:,:),ALLOCATABLE:: P   !atom positions
REAL(dp),DIMENSION(:,:),ALLOCATABLE:: AUX !auxiliary properties
!
!
!Initialize variables
i = 0
!
!
msg = 'entering READ_UNKNOWN'
CALL ATOMSK_MSG(999,(/TRIM(msg)/),(/0.d0/))
!
!
!
100 CONTINUE
OPEN(UNIT=30,FILE=inputfile,FORM='FORMATTED',STATUS='OLD')
REWIND(30)
!Determine number of lines
Nlines=0
DO
  READ(30,*,ERR=200,END=200) temp
  Nlines=Nlines+1
ENDDO
!
!
!
200 CONTINUE
!Extract data from file
DO
  READ(30,'(a1024)',ERR=800,END=800) temp
  temp = ADJUSTL(temp)
  !
  SELECT CASE(temp(1:1))
  CASE("#","!")
    !This line is probably a comment => ignore it
    CONTINUE
    !
  CASE DEFAULT
    !Determine number of columns of this line, store all columns in array
    icol=0
    columns(:) = ""
    DO i=1,SIZE(columns)
      icol=i
      !READ(temp,*) columns(j), j=1,i
    ENDDO
    !
    !Interpret what is in the columns
    
    !
  END SELECT
  !
  290 CONTINUE
  !Go to next
ENDDO
!
!
!
800 CONTINUE
CALL ATOMSK_MSG(802,(/''/),(/DBLE(i)/))
nerr = nerr+1
GOTO 1000
!
!
!
1000 CONTINUE
CLOSE(30)
!
END SUBROUTINE READ_UNKNOWN
!
!
END MODULE in_unknown
