Index: branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/TOP_SRC/MEDUSA/trcini_medusa.F90
===================================================================
--- branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/TOP_SRC/MEDUSA/trcini_medusa.F90	(revision 9114)
+++ branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/TOP_SRC/MEDUSA/trcini_medusa.F90	(revision 9385)
@@ -324,4 +324,14 @@
       IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
       IF(lwp) CALL flush(numout)
+      !!
+      !!----------------------------------------------------------------------
+      !! JPALM (23-01-2017): new way to initialize CO2-atm for cmip6 
+      !!                     initially done in trcsms_medusa
+      !!----------------------------------------------------------------------
+      !! 
+      IF( ( .NOT.lk_oasis ) .AND. ( .NOT.lk_pi_co2 ) ) THEN
+         IF(lwp) WRITE(numout,*) ' trc_ini_medusa: initialisating atm CO2 record'
+         CALL trc_ini_medusa_co2atm
+      ENDIF
 
    END SUBROUTINE trc_ini_medusa
@@ -480,4 +490,88 @@
    END SUBROUTINE trc_ini_medusa_river
    
+   SUBROUTINE trc_ini_medusa_co2atm
+      !!----------------------------------------------------------------------
+      !!                     ***  trc_ini_medusa_co2atm  ***  
+      !!
+      !! ** Purpose :   initialization atmospheric co2 record
+      !!
+      !! ** Method  : - Read the xco2 file
+      !!----------------------------------------------------------------------
+      INTEGER                       ::  jn, jm, io, ierr, inum, iostatus
+      INTEGER, PARAMETER            ::  iskip = 4   ! number of 1st descriptor lines
+      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:)   ::   zyy !: xCO2 record years
+      CHARACTER (len=10), PARAMETER ::  clname = 'xco2.atm'  !! atm CO2 record file
+      !!----------------------------------------------------------------------
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' trc_ini_medusa_co2atm: initialisation of atm CO2 historical record'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~'
+
+
+      IF(lwp) WRITE(numout,*) 'read of formatted file xco2.atm'
+
+      CALL ctl_opn( inum, clname, 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
+      !!!
+      ! -Compute the number of year in the file
+      ! -File starts in co2_yinit, jn represents the record number in the file.
+      ! -Remove the file head (iskip lines) to jn
+      ! -The year is jn + yinit - 1 
+      !! Determine the number of lines in xCO2 input file
+      iostatus = 0
+      jn = 1
+      DO WHILE ( iostatus == 0 )
+        READ(inum,'(1x)', IOSTAT=iostatus, END=100)
+        jn = jn + 1
+      ENDDO
+      IF( iostatus .NE. 0 ) THEN
+        !! Error while reading xCO2 input file 
+        CALL ctl_stop('trc_ini_medusa_co2atm: &
+                      & Error on the 1st reading of xco2.atm')
+        RETURN
+      ENDIF
+ 100  co2_rec = jn - 1 - iskip
+      IF ( lwp) WRITE(numout,*) '    ', co2_rec ,' years read in the file'
+      !                                ! Allocate CO2 hist arrays
+      ierr = 0 
+      ALLOCATE( hist_pco2(co2_rec),zyy(co2_rec), STAT=ierr )
+      IF( ierr > 0 ) THEN
+         CALL ctl_stop( 'trc_ini_medusa_co2atm: unable to allocate  array' )  
+         RETURN
+      ENDIF
+
+      REWIND(inum)
+
+      DO jm = 1, iskip        ! Skip over 1st six descriptor lines
+         READ(inum,'(1x)')
+      END DO
+      ! file starts in 1931 do jn represent the year in the century.jhh
+      ! Read file till the end
+      ! allocate start and end year of the file
+      DO jn = 1, co2_rec
+        READ(inum,'(F6.1,F12.7)', IOSTAT=io) zyy(jn), hist_pco2(jn)
+        IF( io .NE. 0 ) THEN
+          !! Error while reading xCO2 input file 
+          CALL ctl_stop('trc_ini_medusa_co2atm: &
+                        & Error on the 2nd reading of xco2.atm')
+          RETURN
+        ENDIF
+
+        IF(jn==1) co2_yinit = zyy(jn)
+      END DO
+      co2_yend = co2_yinit + real(co2_rec) - 1.
+
+      IF(lwp) THEN        ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'CO2 hist start year: ', co2_yinit
+         WRITE(numout,*) 'CO2 hist end   year: ', co2_yend
+         WRITE(numout,*) ' Year   xCO2 atm '
+         DO jn = 1, co2_rec
+            WRITE(numout, '(F6.1,F12.7)') zyy(jn), hist_pco2(jn)
+         END DO
+      ENDIF
+
+   END SUBROUTINE trc_ini_medusa_co2atm
+
+
 #else
    !!----------------------------------------------------------------------
