
! Copyright (C) 2002 - Observatoire de Paris/Meudon
!                      Universite Paris 7
!                      CNRS (France)
!                      Contact : Jacques.Lebourlot@obspm.fr
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License version 2
! as published by the Free Software Foundation.
!
! 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, write to the Free Software
! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

! JLB - 24 May 2008

!%%%%%%%%%%%%%%%%%%%%
PROGRAM CHEM_ANALYSER
!%%%%%%%%%%%%%%%%%%%

   USE PXDR_CONSTANTES
   USE PXDR_PROFIL
   USE PREP_LECTUR
   USE CHEM_ANALYS

   IMPLICIT NONE

   INTEGER :: iargc

   INTEGER :: ifin
   INTEGER :: ipoint

   CHARACTER (LEN=50) :: fichi

!--------+---------+---------+---------+---------+---------+---------+-*-------+

   PRINT *, "*************************************"
   PRINT *, "*                                   *"
   PRINT *, "*   PDR MODEL CHEMISTRY ANALYSIS    *"
   PRINT *, "*                                   *"
   PRINT *, "*************************************"
   PRINT *

   !========================================================
   ! Choose the input file (.bin file)
   !========================================================

   IF (iargc() .eq. 1) THEN
      CALL getarg(1,fichier)
   ELSE
      PRINT *
      PRINT *, 'Enter name of "bin" file'
      READ (*,'(a50)') fichi
      fichi  = TRIM(ADJUSTL(fichi))
      ipoint = INDEX(fichi,'.',back=.true.)
      IF (ipoint > 1) THEN
         modele = fichi(1:ipoint-1)
         PRINT *, modele
      ENDIF
      out_dir = TRIM(out_dir)//TRIM(modele)//"/"
      fichier = TRIM(out_dir)//TRIM(fichi)
   ENDIF

   !========================================================
   ! READ INPUT DATAFILE
   !========================================================

   CALL PLECTUR

   !========================================================
   ! ANALYSIS
   !========================================================

   ifin = 1
   DO WHILE (ifin == 1)

      CALL ANALYS
      PRINT *, 'Do you want to continue?'
      PRINT *, '1: yes,   0: no'
      READ *, ifin

   ENDDO

END PROGRAM CHEM_ANALYSER
