c&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
c
c
c lecture des fractions molaires eau , gaz carbonique 
c et changement en mettant 10%  de plus
c CERFACS juillet 2002
c.......................................................................

      program perturb


      implicit none
      include 'cecile.inc'
      include 'propradia.inc'
      include 'entre.inc'
      integer i,j,icent
      real*8 coeau,codio,a,tmp,c
      real*8 coco,cofv,cotemp

      character*32 chemin

      print *, 'CHANGER LE CHEMIN DE LA SOL DE REFERENCE'
      chemin = '../raycecile/resultats/mcmh2o_05'

c ************************************************************************
c donnees sur les coeff de perturbation pour les especes et les temperatures
c ieau pour l'eau 
c*********************************
c
      write(*,*) 'entrer la valeur de coeau (max % parabole)'
      read(*,*) coeau
      !write(*,*) 'entrer la valeur de cotemp'
      !read(*,*) cotemp
      cotemp = 0.
      codio=0.
      coco=0.
      cofv=0.
      !cotemp=0.

c LECTURE FORMAT GNUPLOT <=> sur une ligne: param,..,function (un param
cvarie/bloc)
      open(20,file=chemin // '/ind.out', status
     & ='unknown')
      read(20,*) n, rsup
      read(20,*) n, rsup
      read(20,*) n, rsup
      close(20)

c.............................................................................
c lectures des variables dans l'etat de reference
C LECTURE DE LA DIFFERENCE dfv
       open(20,file=chemin // '/fv.in',status='unknown')
       do i=1,n
          read (20,*) fv(i)
       enddo
c
       close(20)
c les fractions molaires
        open(20,file=chemin // '/fmco.in',
     &     status='unknown')
       do i=1,n
          read (20,*) fm(1,i)
       enddo
c
       close(20)
        open(20,file=chemin // '/fmco2.in',
     &      status='unknown')
       do i=1,n
          read (20,*) fm(2,i)
       enddo
c
       close(20)
        open(20,file=chemin // '/fmh2o.in',
     &      status='unknown')
       do i=1,n
          read (20,*) fm(3,i)
          !print *, fm(3,i)
       enddo
c
       close(20)
C LECTURE DE LA temp
       open(20,file=chemin // '/temperat.in',
     &     status='unknown')
       do i=0,n+1
          read (20,*) temp(i)
       enddo

       close(20)
c---------------------------------------------------------------------



C transformation de la fraction molaire d'eau 
       open(10,FILE='fmh2o.in',STATUS='unknown')
       do i=1,n
c       write(30,*) fm(3,i)
          !a =      -1
          icent =  int(n/2)+1
          !print *, ' icent: ', icent
          c = 1.                !!correction max au centre
          a = -c/(n-icent)**2   !!correction nulle en 1
          tmp = a*i*i - a*2*i*icent + (a*icent*icent +c)
          fm(3,i)=fm(3,i)+coeau*tmp*fm(3,i)          
          write (10,*) fm(3,i)
       enddo 

       close(10)

       open(10,FILE='fmco2.in',STATUS='unknown')
       do i=1,n
c          write(40,*) fm(2,i)
          fm(2,i)=fm(2,i)+codio*fm(2,i)          
          write (10,*) fm(2,i)
       enddo 
       close(10)

       open(10,FILE='fmco.in',STATUS='unknown')
       do i=1,n
c          write(50,*) fm(1,i)
          fm(1,i)=fm(1,i)+coco*fm(1,i)          
          write (10,*) fm(1,i)
       enddo 
       close(10)

       open(10,FILE='fv.in',STATUS='unknown')
       do i=1,n
c          write(60,*) fv(i)
          fv(i)=fv(i)+cofv*fv(i)          
          write (10,*) fv(i)
       enddo 
       close(10)

       open(10,FILE='temperat.in',STATUS='unknown')
       do i=0,n+1
c          write(70,*) temp(i)
          temp(i)=temp(i)+cotemp*temp(i)          
          write (10,*) temp(i)
       enddo 
       close(10)

       end


