Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 10004)
@@ -253,8 +253,10 @@
       CALL iom_put( "avt" , avt                        )    ! T vert. eddy diff. coef.
       CALL iom_put( "avm" , avmu                       )    ! T vert. eddy visc. coef.
+#if defined key_zdftke
       IF( lk_zdftke ) THEN   
          CALL iom_put( "tke"      , en                               )    ! TKE budget: Turbulent Kinetic Energy   
          CALL iom_put( "tke_niw"  , e_niw                            )    ! TKE budget: Near-inertial waves   
       ENDIF 
+#endif
       CALL iom_put( "avs" , fsavs(:,:,:)               )    ! S vert. eddy diff. coef. (useful only with key_zdfddm)
                                                             ! Log of eddy diff coef
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd.F90	(revision 10004)
@@ -33,4 +33,5 @@
    USE wrk_nemo       ! Memory Allocation
    USE timing         ! Timing
+   USE phycst         ! Physical constants
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
    USE iom
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/OPA_SRC/TRD/trdken.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/OPA_SRC/TRD/trdken.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/OPA_SRC/TRD/trdken.F90	(revision 10004)
@@ -195,4 +195,5 @@
                     CALL ken_p2k( kt , zke )
                       CALL iom_put( "ketrd_convP2K", zke )     ! conversion -rau*g*w
+# if defined key_ldfslp || key_esopa
         CASE( jpdyn_eivke )
             ! CMIP6 diagnostic tknebto = tendency of KE from
@@ -216,4 +217,5 @@
             CALL iom_put("ketrd_eiv", zke2d)
             CALL wrk_dealloc( jpi, jpj, zke2d )
+#endif
          !
       END SELECT
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/air_sea.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/air_sea.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/air_sea.F90	(revision 10004)
@@ -62,8 +62,6 @@
 # endif
                                    zchd, zchn, zdin, zsil
-      USE dom_oce,           ONLY: e3t_0, e3t_n, gphit, tmask, mig, mjg
-# if defined key_iomput
+      USE dom_oce,           ONLY: e3t_0, gphit, tmask, mig, mjg
       USE iom,               ONLY: lk_iomput
-# endif
       USE in_out_manager,    ONLY: lwp, numout
       USE par_kind,          ONLY: wp
@@ -185,10 +183,10 @@
                call trc_rst_dia_stat(zpho(:,:), 'zpho')
 #   endif
+#  if defined key_axy_carbchem
+#   if defined key_mocsy
       DO jj = 2,jpjm1
          DO ji = 2,jpim1
             if (tmask(ji,jj,1) == 1) then
                !!
-#  if defined key_axy_carbchem
-#   if defined key_mocsy
                !! Jpalm -- 12-09-2017 -- add extra check after reccurent
                !!          carbonate failure in the coupled run.
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_med_diag_iomput.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_med_diag_iomput.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_med_diag_iomput.F90	(revision 10004)
@@ -31,5 +31,5 @@
       !!-------------------------------------------------------------------
       USE bio_medusa_mod
-      USE dom_oce,           ONLY: e3t_0, e3t_n, mbathy, tmask
+      USE dom_oce,           ONLY: e3t_0, mbathy, tmask
       USE in_out_manager,    ONLY: lwp, numout
       USE par_oce,           ONLY: jpim1, jpjm1
@@ -718,4 +718,5 @@
 CONTAINS
    SUBROUTINE bio_med_diag_iomput( )                    ! Empty routine
+      IMPLICIT NONE
       WRITE(*,*) 'bio_med_diag_iomput: You should not have seen this print! error?'
    END SUBROUTINE bio_med_diag_iomput
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_diag.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_diag.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_diag.F90	(revision 10004)
@@ -32,10 +32,7 @@
       USE bio_med_diag_iomput_mod,  ONLY: bio_med_diag_iomput
       USE bio_medusa_mod
-      USE dom_oce,                  ONLY: e3t_0, e3t_n,                  &
-                                          gdepw_0, gdepw_n, tmask
+      USE dom_oce,                  ONLY: e3t_0, gdepw_0, tmask
       USE in_out_manager,           ONLY: lwp, numout
-# if defined key_iomput
       USE iom,                      ONLY: lk_iomput
-# endif
       USE par_oce,                  ONLY: jpim1, jpjm1
       USE sms_medusa,               ONLY: xrfn, xthetapd, xthetapn,      &
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_diag_slice.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_diag_slice.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_diag_slice.F90	(revision 10004)
@@ -35,7 +35,5 @@
       USE dom_oce,           ONLY: tmask
       USE in_out_manager,    ONLY: lwp, numout
-# if defined key_iomput
       USE iom,               ONLY: iom_put
-# endif
       USE lbclnk,            ONLY: lbc_lnk
       USE oce,               ONLY: CO2Flux_out_cpl, DMS_out_cpl
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_fin.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_fin.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_fin.F90	(revision 10004)
@@ -33,9 +33,7 @@
       !!----------------------------------------------------------------------
       USE bio_medusa_mod
-      USE dom_oce,           ONLY: atfp, atfp1, neuler, rdt, e3t_n, tmask
+      USE dom_oce,           ONLY: atfp, atfp1, neuler, rdt, tmask
       USE in_out_manager,    ONLY: lwp, numout
-# if defined key_iomput
-      USE iom,               ONLY: iom_put, lk_iomput
-# endif
+      USE iom,               ONLY: iom_put
       USE lbclnk,            ONLY: lbc_lnk
       USE oce,               ONLY: chloro_out_cpl 
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_init.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_init.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_init.F90	(revision 10004)
@@ -37,10 +37,8 @@
       USE sms_medusa,        ONLY: jdms
       USE trc,               ONLY: ln_diatrc, med_diag, nittrc000 
-      USE in_out_manager,    ONLY: lwp
-
-# if defined key_iomput
-      USE iom,               ONLY: lk_iomput, numout
+      USE in_out_manager,    ONLY: lwp, numout
+
+      USE iom,               ONLY: lk_iomput
       USE trcnam_medusa,     ONLY: trc_nam_iom_medusa
-# endif
 
       !! time (integer timestep)
@@ -178,5 +176,10 @@
       zdic(:,:)  = 0.0
       zsil(:,:)  = 0.0
+# if defined key_mocsy
+      ! zpho is only defined if key_mocsy
+      ! is active, so we must protect this
+      ! initialisation accordingly. 
       zpho(:,:)  = 0.0
+# endif
       f_co2flux(:,:)  = 0.0 
       f_pco2atm(:,:)  = 0.0
@@ -864,4 +867,5 @@
 CONTAINS
    SUBROUTINE bio_medusa_init( )                   ! Empty routine
+      IMPLICIT NONE
       WRITE(*,*) 'bio_medusa_init: You should not have seen this print! error?'
    END SUBROUTINE bio_medusa_init
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_update.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_update.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/bio_medusa_update.F90	(revision 10004)
@@ -71,5 +71,5 @@
 # endif
                                    zpds, zphd, zphn
-      USE dom_oce,           ONLY: e3t_0, e3t_n, gphit, mbathy, tmask
+      USE dom_oce,           ONLY: e3t_0, gphit, mbathy, tmask
       USE in_out_manager,    ONLY: lwp, numout
       USE lib_mpp,           ONLY: ctl_stop
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/carb_chem.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/carb_chem.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/carb_chem.F90	(revision 10004)
@@ -40,6 +40,5 @@
 # endif
                                    zalk, zdic, zsal, zsil, ztmp 
-      USE dom_oce,           ONLY: gdept_0, gdept_n, gdepw_0, gdepw_n,    &
-                                   gphit, mbathy, tmask
+      USE dom_oce,           ONLY: gdept_0, gdepw_0, gphit, mbathy, tmask
       USE in_out_manager,    ONLY: lwp, numout
       USE oce,               ONLY: PCO2a_in_cpl, tsb, tsn
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/detritus.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/detritus.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/detritus.F90	(revision 10004)
@@ -45,5 +45,5 @@
                                         fun_T, fun_Q10, zdet, zdtc
       USE detritus_fast_sink_mod, ONLY: detritus_fast_sink
-      USE dom_oce,                ONLY: mbathy, e3t_0, e3t_n, gphit, tmask
+      USE dom_oce,                ONLY: mbathy, e3t_0, gphit, tmask
       USE in_out_manager,         ONLY: lwp, numout
       USE par_oce,                ONLY: jpim1, jpjm1
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/detritus_fast_sink.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/detritus_fast_sink.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/detritus_fast_sink.F90	(revision 10004)
@@ -66,6 +66,5 @@
                                    idf, idfval,                            &
                                    zdet, zdtc
-      USE dom_oce,           ONLY: e3t_0, e3t_n, gdepw_0, gdepw_n,         &
-                                   gphit, mbathy, tmask
+      USE dom_oce,           ONLY: e3t_0, gdepw_0, gphit, mbathy, tmask
       USE in_out_manager,    ONLY: lwp, numout
       USE oce,               ONLY: tsn
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/iron_chem_scav.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/iron_chem_scav.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/iron_chem_scav.F90	(revision 10004)
@@ -35,6 +35,5 @@
                                    zdet, zfer, zphd, zphn, zzme, zzmi,    &
                                    idf, idfval                          
-      USE dom_oce,           ONLY: e3t_0, e3t_n, gdepw_0, gdepw_n,        &
-                                   mbathy, tmask
+      USE dom_oce,           ONLY: e3t_0, gdepw_0, mbathy, tmask
       USE par_kind,          ONLY: wp
       USE in_out_manager,    ONLY: lwp, numout
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/phytoplankton.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/phytoplankton.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/phytoplankton.F90	(revision 10004)
@@ -44,5 +44,5 @@
                                    zfer, zpds, zphd, zphn, zsil,         &
                                    zzme, zzmi, fchl_ml
-      USE dom_oce,           ONLY: e3t_0, e3t_n, gdepw_0, gdepw_n, tmask
+      USE dom_oce,           ONLY: e3t_0, gdepw_0, tmask
       USE in_out_manager,    ONLY: lwp, numout
       USE oce,               ONLY: tsn
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/trcbio_medusa.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/trcbio_medusa.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/trcbio_medusa.F90	(revision 10004)
@@ -78,7 +78,7 @@
                                             zfer, zpds, zphd, zphn, zsil,   &
                                             zzme, zzmi
-      USE dom_oce,                    ONLY: e3t_0, e3t_n,                   &
-                                            gdept_0, gdept_n,               &
-                                            gdepw_0, gdepw_n,               &
+      USE dom_oce,                    ONLY: e3t_0,                          &
+                                            gdept_0,                        &
+                                            gdepw_0,                        &
                                             nday_year, nsec_day,            &
                                             nyear, nyear_len, ndastp,       &
@@ -87,7 +87,5 @@
                                             njmpp 
       USE in_out_manager,             ONLY: lwp, numout, nn_date0
-# if defined key_iomput
       USE iom,                        ONLY: lk_iomput
-# endif
       USE lbclnk,                     ONLY: lbc_lnk
       USE lib_mpp,                    ONLY: mpp_max, mpp_maxloc,            & 
@@ -1002,4 +1000,5 @@
 CONTAINS
    SUBROUTINE trc_bio_medusa( kt )                   ! Empty routine
+      IMPLICIT NONE
       INTEGER, INTENT( in ) ::   kt
       WRITE(*,*) 'trc_bio_medusa: You should not have seen this print! error?', kt
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/zooplankton.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/zooplankton.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/MEDUSA/zooplankton.F90	(revision 10004)
@@ -41,5 +41,5 @@
                                    idf, idfval,                          &
                                    zdet, zdtc, zphd, zphn, zzme, zzmi
-      USE dom_oce,           ONLY: e3t_0, e3t_n, tmask
+      USE dom_oce,           ONLY: e3t_0, tmask
       USE par_kind,          ONLY: wp
       USE in_out_manager,    ONLY: lwp, numout
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/trc.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/trc.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/trc.F90	(revision 10004)
@@ -110,5 +110,5 @@
    END TYPE DIAG
 
-#if defined key_medusa && defined key_iomput
+#if defined key_medusa
    TYPE, PUBLIC :: BDIAG
       LOGICAL              :: dgsave
Index: /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/trcstat.F90
===================================================================
--- /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/trcstat.F90	(revision 10003)
+++ /branches/UKMO/dev_r5518_GO6_fix_cpp_keys/NEMOGCM/NEMO/TOP_SRC/trcstat.F90	(revision 10004)
@@ -28,6 +28,5 @@
    USE par_oce,           ONLY: jpi, jpj
    USE par_trc,           ONLY: jptra
-   USE dom_oce,           ONLY: e3t_0, e3t_a, e3t_n, gdepw_0, gdepw_n,     &
-                          tmask, e1e2t
+   USE dom_oce,           ONLY: e3t_0, gdepw_0, tmask, e1e2t
    !* MPP library                         
    USE lib_mpp
