C----------------------------------------------------------------
      SUBROUTINE DFASE(I, OX_I, OX_FINAL) 
C----------------------------------------------------------------
c   I = mesh
c   OX_I = input O abundance (mass fraction}
c   OX_FINAL = output O abundance (mass fraction)
c
C Phase diagram Segretain & Chabrier (1993) 
C 
C
      IMPLICIT DOUBLE PRECISION ( A-H, O-Z )
      PARAMETER( NMESH= 5000)
      DIMENSION OX_I(NMESH), XXC(101), XXCF(101) 
      DATA  XXC  / 0.000D0, 0.010D0, 0.020D0, 0.030D0, 0.040D0,
     #             0.050D0, 0.060D0, 0.070D0, 0.080D0, 0.090D0,
     #             0.100D0, 0.110D0, 0.120D0, 0.130D0, 0.140D0,
     #             0.150D0, 0.160D0, 0.170D0, 0.180D0, 0.190D0,
     #             0.200D0, 0.210D0, 0.220D0, 0.230D0, 0.240D0,
     #             0.250D0, 0.260D0, 0.270D0, 0.280D0, 0.290D0,
     #             0.300D0, 0.310D0, 0.320D0, 0.330D0, 0.340D0,
     #             0.350D0, 0.360D0, 0.370D0, 0.380D0, 0.390D0,
     #             0.400D0, 0.410D0, 0.420D0, 0.430D0, 0.440D0,
     #             0.450D0, 0.460D0, 0.470D0, 0.480D0, 0.490D0,
     #             0.500D0, 0.510D0, 0.520D0, 0.530D0, 0.540D0,
     #             0.550D0, 0.560D0, 0.570D0, 0.580D0, 0.590D0,
     #             0.600D0, 0.610D0, 0.620D0, 0.630D0, 0.640D0,
     #             0.650D0, 0.660D0, 0.670D0, 0.680D0, 0.690D0,
     #             0.700D0, 0.710D0, 0.720D0, 0.730D0, 0.740D0,
     #             0.750D0, 0.760D0, 0.770D0, 0.780D0, 0.790D0,
     #             0.800D0, 0.810D0, 0.820D0, 0.830D0, 0.840D0,
     #             0.850D0, 0.860D0, 0.870D0, 0.880D0, 0.890D0,
     #             0.900D0, 0.910D0, 0.920D0, 0.930D0, 0.940D0,
     #             0.950D0, 0.960D0, 0.970D0, 0.980D0, 0.990D0,
     #             1.000D0 /
C
      DATA XXCF /  0.000, 0.006, 0.011, 0.017, 0.022, 0.028, 0.033,
     &             0.038, 0.044, 0.049, 0.054, 0.059, 0.064, 0.069, 
     &             0.074, 0.079, 0.084, 0.089, 0.094, 0.100, 0.106, 
     &             0.112, 0.118, 0.124, 0.130, 0.136, 0.141, 0.147, 
     &             0.153, 0.159, 0.165, 0.171, 0.177, 0.183, 0.189, 
     &             0.195, 0.202, 0.208, 0.215, 0.221, 0.228, 0.235, 
     &             0.242, 0.249, 0.256, 0.264, 0.272, 0.280, 0.288, 
     &             0.297, 0.306, 0.316, 0.326, 0.336, 0.347, 0.357, 
     &             0.368, 0.379, 0.390, 0.402, 0.413, 0.425, 0.437, 
     &             0.450, 0.462, 0.476, 0.489, 0.503, 0.517, 0.531, 
     &             0.545, 0.560, 0.574, 0.589, 0.603, 0.618, 0.633, 
     &             0.648, 0.664, 0.680, 0.696, 0.713, 0.730, 0.749, 
     &             0.769, 0.790, 0.812, 0.835, 0.858, 0.878, 0.896, 
     &             0.910, 0.922, 0.932, 0.940, 0.949, 0.958, 0.968, 
     &             0.978, 0.989, 1.000 /
C
      XCAR= 1.D0 - OX_I(I)
C
      write(*,*) xcar
      DO K= 1, 101
         IF(XCAR .LT. XXC(K)) GOTO 45  
      ENDDO   
C
 45   AA= (XCAR - XXC(K-1)) / (XXC(K) - XXC(K-1))
      BB= 1.D0 - AA
      OC_FINAL= AA * XXCF(K) + BB * XXCF(K-1)
      OX_FINAL= 1.D0 - OC_FINAL
C
      RETURN
      END
