Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg	(revision 12184)
@@ -381,5 +381,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AGRIF_DEMO/EXPREF/2_namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AGRIF_DEMO/EXPREF/2_namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AGRIF_DEMO/EXPREF/2_namelist_cfg	(revision 12184)
@@ -330,5 +330,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AGRIF_DEMO/EXPREF/3_namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AGRIF_DEMO/EXPREF/3_namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AGRIF_DEMO/EXPREF/3_namelist_cfg	(revision 12184)
@@ -312,5 +312,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AGRIF_DEMO/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AGRIF_DEMO/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AGRIF_DEMO/EXPREF/namelist_cfg	(revision 12184)
@@ -381,5 +381,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AMM12/EXPREF/context_nemo.xml
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AMM12/EXPREF/context_nemo.xml	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AMM12/EXPREF/context_nemo.xml	(revision 12184)
@@ -22,6 +22,81 @@
     <field_definition src="./field_def_nemo-oce.xml"/>   <!--  NEMO ocean dynamics                     -->
 
+<!-- Override field definitions for multiple-linear-regression analysis (diamlr) -->
+    <field_definition level="1" prec="4" operation="average" enabled=".TRUE." default_value="1.e20" >
+      <field_group id="diamlr_fields">
+        <!-- Time -->
+        <field id="diamlr_time" grid_ref="diamlr_grid_T_2D" prec="8" />
+        <!-- Regressors for tidal harmonic analysis -->
+        <field id="diamlr_r001" field_ref="diamlr_time" expr="sin( __TDE_M2_omega__ * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:M2" />
+        <field id="diamlr_r002" field_ref="diamlr_time" expr="cos( __TDE_M2_omega__ * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:M2" />
+        <field id="diamlr_r003" field_ref="diamlr_time" expr="sin( __TDE_K1_omega__ * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:K1" />
+        <field id="diamlr_r004" field_ref="diamlr_time" expr="cos( __TDE_K1_omega__ * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:K1" />
+        <field id="diamlr_r005" enabled=".FALSE." />
+        <field id="diamlr_r006" enabled=".FALSE." />
+        <field id="diamlr_r007" enabled=".FALSE." />
+        <field id="diamlr_r008" enabled=".FALSE." />
+        <field id="diamlr_r009" enabled=".FALSE." />
+        <field id="diamlr_r010" enabled=".FALSE." />
+        <field id="diamlr_r011" enabled=".FALSE." />
+        <field id="diamlr_r012" enabled=".FALSE." />
+        <field id="diamlr_r013" enabled=".FALSE." />
+        <field id="diamlr_r014" enabled=".FALSE." />
+        <field id="diamlr_r015" enabled=".FALSE." />
+        <field id="diamlr_r016" enabled=".FALSE." />
+        <field id="diamlr_r017" enabled=".FALSE." />
+        <field id="diamlr_r018" enabled=".FALSE." />
+        <field id="diamlr_r019" enabled=".FALSE." />
+        <field id="diamlr_r020" enabled=".FALSE." />
+        <field id="diamlr_r021" enabled=".FALSE." />
+        <field id="diamlr_r022" enabled=".FALSE." />
+        <field id="diamlr_r023" enabled=".FALSE." />
+        <field id="diamlr_r024" enabled=".FALSE." />
+        <field id="diamlr_r025" enabled=".FALSE." />
+        <field id="diamlr_r026" enabled=".FALSE." />
+        <field id="diamlr_r027" enabled=".FALSE." />
+        <field id="diamlr_r028" enabled=".FALSE." />
+        <field id="diamlr_r029" enabled=".FALSE." />
+        <field id="diamlr_r030" enabled=".FALSE." />
+        <field id="diamlr_r031" enabled=".FALSE." />
+        <field id="diamlr_r032" enabled=".FALSE." />
+        <field id="diamlr_r033" enabled=".FALSE." />
+        <field id="diamlr_r034" enabled=".FALSE." />
+        <field id="diamlr_r035" enabled=".FALSE." />
+        <field id="diamlr_r036" enabled=".FALSE." />
+        <field id="diamlr_r037" enabled=".FALSE." />
+        <field id="diamlr_r038" enabled=".FALSE." />
+        <field id="diamlr_r101" field_ref="diamlr_time" expr="diamlr_time^0.0"                       enabled=".TRUE."  comment="mean"            />
+        <!-- Fields selected for regression analysis -->
+        <field id="diamlr_f001" field_ref="ssh"  enabled=".TRUE." />
+        <field id="diamlr_f002" field_ref="uoce" enabled=".TRUE." />
+        <field id="diamlr_f003" field_ref="voce" enabled=".TRUE." />
+        <field id="diamlr_f004" field_ref="toce" enabled=".TRUE." />
+      </field_group>
+    </field_definition>
+
 <!-- Files definition -->
     <file_definition src="./file_def_nemo-oce.xml"/>     <!--  NEMO ocean dynamics                     -->
+
+    <file_definition type="multiple_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="10d" min_digits="4">
+
+<!-- Activation of intermediate output for multiple-linear-regression analysis (diamlr) -->
+      <file_group id="diamlr_files" output_freq="1d"  output_level="10" enabled=".TRUE."/>
+
+<!-- Activation and selection of daily detided model diagnostics (diadetide) -->
+      <file_group id="diadetide_files" output_freq="1d" output_level="10" enabled=".TRUE.">
+	<file id="file22" name_suffix="_M2detided_grid_T" description="M2-detided ocean T-grid variables">
+	  <field id="diadetide_ssh"  field_ref="diadetide_weight_grid_T_2D" operation="accumulate"> this * ssh </field>
+	</file>
+	<file id="file23" name_suffix="_M2detided_grid_U" description="M2-detided ocean U-grid variables">
+	  <field id="diadetide_uoce" field_ref="diadetide_weight_grid_U_3D" operation="accumulate"> this * uoce </field>
+	</file>
+	<file id="file24" name_suffix="_M2detided_grid_V" description="M2-detided ocean V-grid variables">
+	  <field id="diadetide_voce"  field_ref="diadetide_weight_grid_V_3D" operation="accumulate"> this * voce </field>
+	</file>
+      </field_group>
+
+    </file_definition>
+
+    <!-- 
 
 <!-- Axis definition -->
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AMM12/EXPREF/file_def_nemo-oce.xml
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AMM12/EXPREF/file_def_nemo-oce.xml	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AMM12/EXPREF/file_def_nemo-oce.xml	(revision 12184)
@@ -49,5 +49,4 @@
 
       <file_group id="25h_mean" output_freq="1d" output_level="10" enabled=".TRUE.">
-
 
      <file id="file12" name_suffix="_25hourm_grid_T" description="ocean T grid variables, 25h meaned" enabled=".TRUE." >
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AMM12/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AMM12/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/AMM12/EXPREF/namelist_cfg	(revision 12184)
@@ -154,22 +154,21 @@
 &nam_tide      !   tide parameters                                      (default: OFF)
 !-----------------------------------------------------------------------
-   ln_tide     = .true.    ! Activate tides
-      ln_tide_pot   = .true.  !  use tidal potential forcing
-
-   clname(1)     =   'Q1'   !  name of constituent
-   clname(2)     =   'O1'
-   clname(3)     =   'P1'
-   clname(4)     =   'S1'
-   clname(5)     =   'K1'
-   clname(6)     =   '2N2'
-   clname(7)     =   'MU2'
-   clname(8)     =   'N2'
-   clname(9)     =   'NU2'
-   clname(10)    =   'M2'
-   clname(11)    =   'L2'
-   clname(12)    =   'T2'
-   clname(13)    =   'S2'
-   clname(14)    =   'K2'
-   clname(15)    =   'M4'
+   ln_tide     = .true.        ! Activate tides
+      ln_tide_pot     = .true. !  use tidal potential forcing
+   sn_tide_cnames(1)  = 'Q1'   !  name of constituent
+   sn_tide_cnames(2)  = 'O1'
+   sn_tide_cnames(3)  = 'P1'
+   sn_tide_cnames(4)  = 'S1'
+   sn_tide_cnames(5)  = 'K1'
+   sn_tide_cnames(6)  = '2N2'
+   sn_tide_cnames(7)  = 'MU2'
+   sn_tide_cnames(8)  = 'N2'
+   sn_tide_cnames(9)  = 'NU2'
+   sn_tide_cnames(10) = 'M2'
+   sn_tide_cnames(11) = 'L2'
+   sn_tide_cnames(12) = 'T2'
+   sn_tide_cnames(13) = 'S2'
+   sn_tide_cnames(14) = 'K2'
+   sn_tide_cnames(15) = 'M4'
 /
 !-----------------------------------------------------------------------
@@ -351,5 +350,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/C1D_PAPA/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/C1D_PAPA/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/C1D_PAPA/EXPREF/namelist_cfg	(revision 12184)
@@ -420,5 +420,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
@@ -448,8 +447,4 @@
 /
 !-----------------------------------------------------------------------
-&nam_diaharm   !   Harmonic analysis of tidal constituents              (default: OFF)
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &nam_diadct    ! transports through some sections                       (default: OFF)
 !-----------------------------------------------------------------------
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/GYRE_BFM/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/GYRE_BFM/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/GYRE_BFM/EXPREF/namelist_cfg	(revision 12184)
@@ -228,5 +228,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/GYRE_PISCES/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/GYRE_PISCES/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/GYRE_PISCES/EXPREF/namelist_cfg	(revision 12184)
@@ -222,5 +222,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg	(revision 12184)
@@ -391,5 +391,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_cfg	(revision 12184)
@@ -377,5 +377,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
@@ -405,8 +404,4 @@
 /
 !-----------------------------------------------------------------------
-&nam_diaharm   !   Harmonic analysis of tidal constituents              (default: OFF)
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &nam_diadct    !   transports through some sections                     (default: OFF)
 !-----------------------------------------------------------------------
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/ORCA2_OFF_TRC/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/ORCA2_OFF_TRC/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/ORCA2_OFF_TRC/EXPREF/namelist_cfg	(revision 12184)
@@ -375,5 +375,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
 !!   namdct       transports through some sections                      ("key_diadct")
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
@@ -403,8 +402,4 @@
 /
 !-----------------------------------------------------------------------
-&nam_diaharm   !   Harmonic analysis of tidal constituents              ("key_diaharm")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namdct        ! transports through some sections                       ("key_diadct")
 !-----------------------------------------------------------------------
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/ORCA2_SAS_ICE/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/ORCA2_SAS_ICE/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/ORCA2_SAS_ICE/EXPREF/namelist_cfg	(revision 12184)
@@ -196,5 +196,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/SHARED/field_def_nemo-oce.xml
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/SHARED/field_def_nemo-oce.xml	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/SHARED/field_def_nemo-oce.xml	(revision 12184)
@@ -1,4 +1,76 @@
 <?xml version="1.0"?> 
     <!-- $id$ -->
+
+    <field_definition level="1" prec="4" operation="average" enabled=".TRUE." default_value="1.e20" > <!-- time step automaticaly defined -->
+
+    <!--
+       =====================================================================================================
+       =                                   Configurable diagnostics                                        =
+       =====================================================================================================
+      -->
+
+    <field_group id="diamlr_fields">
+
+    <!--
+       =====================================================================================================
+                         Configuration of multiple-linear-regression analysis (diamlr)
+       =====================================================================================================
+       
+       This field group configures diamlr for tidal harmonic analysis of field
+       ssh: in addition to a regressor for fitting the mean value (diamlr_r101),
+       it includes the regressors for the analysis of the tidal constituents
+       that are available in the tidal-forcing implementation (see
+       ./src/OCE/SBC/tide.h90).
+
+      -->
+
+      <!-- Time -->
+      <field id="diamlr_time" grid_ref="diamlr_grid_T_2D" prec="8" />
+
+      <!-- Regressors for tidal harmonic analysis -->
+      <field id="diamlr_r001"  field_ref="diamlr_time" expr="sin( __TDE_M2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:M2"   />
+      <field id="diamlr_r002"  field_ref="diamlr_time" expr="cos( __TDE_M2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:M2"   />
+      <field id="diamlr_r003"  field_ref="diamlr_time" expr="sin( __TDE_N2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:N2"   />
+      <field id="diamlr_r004"  field_ref="diamlr_time" expr="cos( __TDE_N2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:N2"   />
+      <field id="diamlr_r005"  field_ref="diamlr_time" expr="sin( __TDE_2N2_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:2N2"  />
+      <field id="diamlr_r006"  field_ref="diamlr_time" expr="cos( __TDE_2N2_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:2N2"  />
+      <field id="diamlr_r007"  field_ref="diamlr_time" expr="sin( __TDE_S2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:S2"   />
+      <field id="diamlr_r008"  field_ref="diamlr_time" expr="cos( __TDE_S2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:S2"   />
+      <field id="diamlr_r009"  field_ref="diamlr_time" expr="sin( __TDE_K2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:K2"   />
+      <field id="diamlr_r010"  field_ref="diamlr_time" expr="cos( __TDE_K2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:K2"   />
+      <field id="diamlr_r011"  field_ref="diamlr_time" expr="sin( __TDE_K1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:K1"   />
+      <field id="diamlr_r012"  field_ref="diamlr_time" expr="cos( __TDE_K1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:K1"   />
+      <field id="diamlr_r013"  field_ref="diamlr_time" expr="sin( __TDE_O1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:O1"   />
+      <field id="diamlr_r014"  field_ref="diamlr_time" expr="cos( __TDE_O1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:O1"   />
+      <field id="diamlr_r015"  field_ref="diamlr_time" expr="sin( __TDE_Q1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:Q1"   />
+      <field id="diamlr_r016"  field_ref="diamlr_time" expr="cos( __TDE_Q1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:Q1"   />
+      <field id="diamlr_r017"  field_ref="diamlr_time" expr="sin( __TDE_P1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:P1"   />
+      <field id="diamlr_r018"  field_ref="diamlr_time" expr="cos( __TDE_P1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:P1"   />
+      <field id="diamlr_r019"  field_ref="diamlr_time" expr="sin( __TDE_M4_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:M4"   />
+      <field id="diamlr_r020"  field_ref="diamlr_time" expr="cos( __TDE_M4_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:M4"   />
+      <field id="diamlr_r021"  field_ref="diamlr_time" expr="sin( __TDE_Mf_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:Mf"   />
+      <field id="diamlr_r022"  field_ref="diamlr_time" expr="cos( __TDE_Mf_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:Mf"   />
+      <field id="diamlr_r023"  field_ref="diamlr_time" expr="sin( __TDE_Mm_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:Mm"   />
+      <field id="diamlr_r024"  field_ref="diamlr_time" expr="cos( __TDE_Mm_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:Mm"   />
+      <field id="diamlr_r025"  field_ref="diamlr_time" expr="sin( __TDE_Msqm_omega__ * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:Msqm" />
+      <field id="diamlr_r026"  field_ref="diamlr_time" expr="cos( __TDE_Msqm_omega__ * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:Msqm" />
+      <field id="diamlr_r027"  field_ref="diamlr_time" expr="sin( __TDE_Mtm_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:Mtm"  />
+      <field id="diamlr_r028"  field_ref="diamlr_time" expr="cos( __TDE_Mtm_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:Mtm"  />
+      <field id="diamlr_r029"  field_ref="diamlr_time" expr="sin( __TDE_S1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:S1"   />
+      <field id="diamlr_r030"  field_ref="diamlr_time" expr="cos( __TDE_S1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:S1"   />
+      <field id="diamlr_r031"  field_ref="diamlr_time" expr="sin( __TDE_MU2_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:MU2"  />
+      <field id="diamlr_r032"  field_ref="diamlr_time" expr="cos( __TDE_MU2_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:MU2"  />
+      <field id="diamlr_r033"  field_ref="diamlr_time" expr="sin( __TDE_NU2_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:NU2"  />
+      <field id="diamlr_r034"  field_ref="diamlr_time" expr="cos( __TDE_NU2_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:NU2"  />
+      <field id="diamlr_r035"  field_ref="diamlr_time" expr="sin( __TDE_L2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:L2"   />
+      <field id="diamlr_r036"  field_ref="diamlr_time" expr="cos( __TDE_L2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:L2"   />
+      <field id="diamlr_r037"  field_ref="diamlr_time" expr="sin( __TDE_T2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:T2"   />
+      <field id="diamlr_r038"  field_ref="diamlr_time" expr="cos( __TDE_T2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:T2"   />
+      <field id="diamlr_r101"  field_ref="diamlr_time" expr="diamlr_time^0.0"                         enabled=".TRUE."  comment="mean"              />
+
+      <!-- Fields selected for regression analysis -->
+      <field id="diamlr_f001" field_ref="ssh" enabled=".TRUE." />
+
+    </field_group>
     
     <!-- 
@@ -8,5 +80,24 @@
 ============================================================================================================
     -->
-    <field_definition level="1" prec="4" operation="average" enabled=".TRUE." default_value="1.e20" > <!-- time step automaticaly defined -->
+
+    <field_group id="diadetide_fields">
+
+    <!--
+       =====================================================================================================
+                 Weight fields for the computation of daily detided model diagnostics (diadetide)
+       =====================================================================================================
+
+       -->
+
+      <field id="diadetide_weight" grid_ref="diadetide_grid_T_2D" enabled=".TRUE." />
+      <field id="diadetide_weight_grid_T_2D" field_ref="diadetide_weight" grid_ref="diadetide_grid_T_2D" enabled=".TRUE." > this </field>
+      <field id="diadetide_weight_grid_U_2D" field_ref="diadetide_weight" grid_ref="diadetide_grid_U_2D" enabled=".TRUE." > this </field>
+      <field id="diadetide_weight_grid_V_2D" field_ref="diadetide_weight" grid_ref="diadetide_grid_V_2D" enabled=".TRUE." > this </field>
+      <field id="diadetide_weight_grid_T_3D" field_ref="diadetide_weight" grid_ref="diadetide_grid_2D_to_grid_T_3D" enabled=".TRUE." > this </field>
+      <field id="diadetide_weight_grid_U_3D" field_ref="diadetide_weight" grid_ref="diadetide_grid_2D_to_grid_U_3D" enabled=".TRUE." > this </field>
+      <field id="diadetide_weight_grid_V_3D" field_ref="diadetide_weight" grid_ref="diadetide_grid_2D_to_grid_V_3D" enabled=".TRUE." > this </field>
+      <field id="diadetide_weight_grid_W_3D" field_ref="diadetide_weight" grid_ref="diadetide_grid_2D_to_grid_W_3D" enabled=".TRUE." > this </field>
+
+    </field_group>
 
     <!-- 
@@ -138,77 +229,25 @@
 
       <field_group id="Tides_T" grid_ref="grid_T_2D" operation="once" >
-        <!-- tidal composante -->
-        <field id="M2x"          long_name="M2 Elevation harmonic real part "                             unit="m"        />
-        <field id="M2y"          long_name="M2 Elevation harmonic imaginary part"                         unit="m"        />
-        <field id="S2x"          long_name="S2 Elevation harmonic real part "                             unit="m"        />
-        <field id="S2y"          long_name="S2 Elevation harmonic imaginary part"                         unit="m"        />
-        <field id="N2x"          long_name="N2 Elevation harmonic real part "                             unit="m"        />
-        <field id="N2y"          long_name="N2 Elevation harmonic imaginary part"                         unit="m"        />
-        <field id="K1x"          long_name="K1 Elevation harmonic real part "                             unit="m"        />
-        <field id="K1y"          long_name="K1 Elevation harmonic imaginary part"                         unit="m"        />
-        <field id="O1x"          long_name="O1 Elevation harmonic real part "                             unit="m"        />
-        <field id="O1y"          long_name="O1 Elevation harmonic imaginary part"                         unit="m"        />
-        <field id="Q1x"          long_name="Q1 Elevation harmonic real part "                             unit="m"        />
-        <field id="Q1y"          long_name="Q1 Elevation harmonic imaginary part"                         unit="m"        />
-        <field id="M4x"          long_name="M4 Elevation harmonic real part "                             unit="m"        />
-        <field id="M4y"          long_name="M4 Elevation harmonic imaginary part"                         unit="m"        />
-        <field id="K2x"          long_name="K2 Elevation harmonic real part "                             unit="m"        />
-        <field id="K2y"          long_name="K2 Elevation harmonic imaginary part"                         unit="m"        />
-        <field id="P1x"          long_name="P1 Elevation harmonic real part "                             unit="m"        />
-        <field id="P1y"          long_name="P1 Elevation harmonic imaginary part"                         unit="m"        />
-        <field id="Mfx"          long_name="Mf Elevation harmonic real part "                             unit="m"        />
-        <field id="Mfy"          long_name="Mf Elevation harmonic imaginary part"                         unit="m"        />
-        <field id="Mmx"          long_name="Mm Elevation harmonic real part "                             unit="m"        />
-        <field id="Mmy"          long_name="Mm Elevation harmonic imaginary part"                         unit="m"        />
-      </field_group>
-	 
-      <field_group id="Tides_U" grid_ref="grid_U_2D" operation="once" >
-        <field id="M2x_u"        long_name="M2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-        <field id="M2y_u"        long_name="M2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="S2x_u"        long_name="S2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-        <field id="S2y_u"        long_name="S2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="N2x_u"        long_name="N2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-        <field id="N2y_u"        long_name="N2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="K1x_u"        long_name="K1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-        <field id="K1y_u"        long_name="K1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="O1x_u"        long_name="O1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-        <field id="O1y_u"        long_name="O1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="Q1x_u"        long_name="Q1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-        <field id="Q1y_u"        long_name="Q1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="M4x_u"        long_name="M4 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-        <field id="M4y_u"        long_name="M4 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="K2x_u"        long_name="K2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-        <field id="K2y_u"        long_name="K2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="P1x_u"        long_name="P1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-        <field id="P1y_u"        long_name="P1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="Mfx_u"        long_name="Mf current barotrope along i-axis harmonic real part "        unit="m/s"      />
-        <field id="Mfy_u"        long_name="Mf current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="Mmx_u"        long_name="Mm current barotrope along i-axis harmonic real part "        unit="m/s"      />
-        <field id="Mmy_u"        long_name="Mm current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-      </field_group>
-	 
-      <field_group id="Tides_V" grid_ref="grid_V_2D" operation="once" >
-        <field id="M2x_v"        long_name="M2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-        <field id="M2y_v"        long_name="M2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="S2x_v"        long_name="S2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-        <field id="S2y_v"        long_name="S2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="N2x_v"        long_name="N2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-        <field id="N2y_v"        long_name="N2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="K1x_v"        long_name="K1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-        <field id="K1y_v"        long_name="K1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="O1x_v"        long_name="O1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-        <field id="O1y_v"        long_name="O1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="Q1x_v"        long_name="Q1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-        <field id="Q1y_v"        long_name="Q1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="M4x_v"        long_name="M4 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-        <field id="M4y_v"        long_name="M4 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="K2x_v"        long_name="K2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-        <field id="K2y_v"        long_name="K2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="P1x_v"        long_name="P1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-        <field id="P1y_v"        long_name="P1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="Mfx_v"        long_name="Mf current barotrope along j-axis harmonic real part "        unit="m/s"      />
-        <field id="Mfy_v"        long_name="Mf current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-        <field id="Mmx_v"        long_name="Mm current barotrope along j-axis harmonic real part "        unit="m/s"      />
-        <field id="Mmy_v"        long_name="Mm current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />	 
+        <!-- Tidal potential -->
+        <field id="tide_pot"      long_name="Total tidal potential" unit="m" />
+        <field id="tide_pot_M2"   long_name="M2 tidal potential"    unit="m" />
+        <field id="tide_pot_N2"   long_name="N2 tidal potential"    unit="m" />
+        <field id="tide_pot_2N2"  long_name="2N2 tidal potential"   unit="m" />
+        <field id="tide_pot_S2"   long_name="S2 tidal potential"    unit="m" />
+        <field id="tide_pot_K2"   long_name="K2 tidal potential"    unit="m" />
+        <field id="tide_pot_K1"   long_name="K1 tidal potential"    unit="m" />
+        <field id="tide_pot_O1"   long_name="O1 tidal potential"    unit="m" />
+        <field id="tide_pot_Q1"   long_name="Q1 tidal potential"    unit="m" />
+        <field id="tide_pot_P1"   long_name="P1 tidal potential"    unit="m" />
+        <field id="tide_pot_M4"   long_name="M4 tidal potential"    unit="m" />
+        <field id="tide_pot_Mf"   long_name="Mf tidal potential"    unit="m" />
+        <field id="tide_pot_Mm"   long_name="Mm tidal potential"    unit="m" />
+        <field id="tide_pot_Msqm" long_name="Msqm tidal potential"  unit="m" />
+        <field id="tide_pot_Mtm"  long_name="Mtm tidal potential"   unit="m" />
+        <field id="tide_pot_S1"   long_name="S1 tidal potential"    unit="m" />
+        <field id="tide_pot_MU2"  long_name="MU2 tidal potential"   unit="m" />
+        <field id="tide_pot_NU2"  long_name="NU2 tidal potential"   unit="m" />
+        <field id="tide_pot_L2"   long_name="L2 tidal potential"    unit="m" />
+        <field id="tide_pot_T2"   long_name="T2 tidal potential"    unit="m" />
       </field_group>
 
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/SHARED/grid_def_nemo.xml
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/SHARED/grid_def_nemo.xml	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/SHARED/grid_def_nemo.xml	(revision 12184)
@@ -1,2 +1,3 @@
+<?xml version="1.0"?>
 <!--
 ============================================================================================================
@@ -4,5 +5,5 @@
 ============================================================================================================
     -->
- 
+
     <grid_definition>    
 
@@ -240,5 +241,93 @@
         <scalar/>
       </grid>
- 
-    </grid_definition>   
- 
+
+      <!-- grid definitions for multiple-linear-regression analysis (diamlr) -->
+      <grid id="diamlr_grid_scalar" >
+	<scalar />
+	<scalar />
+      </grid>
+      <grid id="diamlr_grid_T_2D" >
+	<domain domain_ref="grid_T" />
+	<scalar />
+      </grid>
+      <grid id="diamlr_grid_U_2D" >
+	<domain domain_ref="grid_U" />
+	<scalar />
+      </grid>
+      <grid id="diamlr_grid_V_2D" >
+	<domain domain_ref="grid_V" />
+	<scalar />
+      </grid>
+      <grid id="diamlr_grid_W_2D" >
+	<domain domain_ref="grid_W" />
+	<scalar />
+      </grid>
+      <grid id="diamlr_grid_2D_to_grid_T_3D" >
+	<domain domain_ref="grid_T" />
+        <axis axis_ref="deptht">
+          <duplicate_scalar />
+        </axis>
+      </grid>
+      <grid id="diamlr_grid_2D_to_grid_U_3D" >
+	<domain domain_ref="grid_U" />
+        <axis axis_ref="depthu">
+          <duplicate_scalar />
+        </axis>
+      </grid>
+      <grid id="diamlr_grid_2D_to_grid_V_3D" >
+	<domain domain_ref="grid_V" />
+        <axis axis_ref="depthv">
+          <duplicate_scalar />
+        </axis>
+      </grid>
+      <grid id="diamlr_grid_2D_to_grid_W_3D" >
+	<domain domain_ref="grid_W" />
+        <axis axis_ref="depthw">
+          <duplicate_scalar />
+        </axis>
+      </grid>
+      <grid id="diamlr_grid_2D_to_scalar" >
+        <scalar>
+          <reduce_domain operation="average" />
+        </scalar>
+	<scalar />
+      </grid>
+      <!-- grid definitions for the computation of daily detided model diagnostics (diadetide) -->
+      <grid id="diadetide_grid_T_2D" >
+	<domain domain_ref="grid_T" />
+	<scalar />
+      </grid>
+      <grid id="diadetide_grid_U_2D" >
+	<domain domain_ref="grid_U" />
+	<scalar />
+      </grid>
+      <grid id="diadetide_grid_V_2D" >
+	<domain domain_ref="grid_V" />
+	<scalar />
+      </grid>
+      <grid id="diadetide_grid_2D_to_grid_T_3D" >
+	<domain domain_ref="grid_T" />
+        <axis axis_ref="deptht">
+          <duplicate_scalar />
+        </axis>
+      </grid>
+      <grid id="diadetide_grid_2D_to_grid_U_3D" >
+	<domain domain_ref="grid_U" />
+        <axis axis_ref="depthu">
+          <duplicate_scalar />
+        </axis>
+      </grid>
+      <grid id="diadetide_grid_2D_to_grid_V_3D" >
+	<domain domain_ref="grid_V" />
+        <axis axis_ref="depthv">
+          <duplicate_scalar />
+        </axis>
+      </grid>
+      <grid id="diadetide_grid_2D_to_grid_W_3D" >
+	<domain domain_ref="grid_W" />
+        <axis axis_ref="depthw">
+          <duplicate_scalar />
+        </axis>
+      </grid>
+
+    </grid_definition>
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/SHARED/namelist_ref
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/SHARED/namelist_ref	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/SHARED/namelist_ref	(revision 12184)
@@ -646,5 +646,9 @@
 !-----------------------------------------------------------------------
    ln_tide     = .false.      ! Activate tides
+      nn_tide_var   = 1          !  Variant of tidal parameter set and tide-potential computation
+      !                          !     (1: default; 0: compatibility with previous versions)
+      ln_tide_dia   = .false.    !  Enable tidal diagnostic output
       ln_tide_pot   = .false.               !  use tidal potential forcing
+         rn_tide_gamma = 0.7                   ! Tidal tilt factor
          ln_scal_load  = .false.               ! Use scalar approximation for
             rn_scal_load = 0.094               !     load potential
@@ -653,6 +657,6 @@
             !
       ln_tide_ramp  = .false.               !  Use linear ramp for tides at startup
-         rdttideramp   =    0.                 !  ramp duration in days
-      clname(1)     = 'DUMMY'               !  name of constituent - all tidal components must be set in namelist_cfg
+         rn_tide_ramp_dt = 0.               !  ramp duration in days
+      sn_tide_cnames(1) = 'DUMMY'               !  name of constituent - all tidal components must be set in namelist_cfg
 /
 !-----------------------------------------------------------------------
@@ -730,5 +734,4 @@
    filtide          = 'bdydta/amm12_bdytide_'   !  file name root of tidal forcing files
    ln_bdytide_2ddta = .false.                   !
-   ln_bdytide_conj  = .false.                   !
 /
 
@@ -1196,5 +1199,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
@@ -1249,14 +1251,4 @@
       ln_ariane   = .true.    !    Input with Ariane tool convention(T)
       ln_flo_ascii= .true.    !    Output with Ariane tool netcdf convention(F) or ascii file (T)
-/
-!-----------------------------------------------------------------------
-&nam_diaharm   !   Harmonic analysis of tidal constituents              (default: OFF)
-!-----------------------------------------------------------------------
-    ln_diaharm = .false.   ! Choose tidal harmonic output or not
-       nit000_han = 1      !    First time step used for harmonic analysis
-       nitend_han = 75     !    Last time step used for harmonic analysis
-       nstep_han  = 15     !    Time step frequency for harmonic analysis
-       tname(1)   = 'M2'   !    Name of tidal constituents
-       tname(2)   = 'K1'   !              ---
 /
 !-----------------------------------------------------------------------
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/SPITZ12/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/SPITZ12/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/cfgs/SPITZ12/EXPREF/namelist_cfg	(revision 12184)
@@ -138,14 +138,14 @@
 &nam_tide      !   tide parameters                                      (default: OFF)
 !-----------------------------------------------------------------------
-   ln_tide     = .true.      ! Activate tides
-      ln_tide_pot   = .false.                !  use tidal potential forcing
-      clname(1)     =   'M2'    !  name of constituent
-      clname(2)     =   'S2'
-      clname(3)     =   'N2'
-      clname(4)     =   'K2'
-      clname(5)     =   'K1'
-      clname(6)     =   'O1'
-      clname(7)     =   'P1'
-      clname(8)     =   'Q1'
+   ln_tide     = .true.           ! Activate tides
+      ln_tide_pot       = .false. !  use tidal potential forcing
+      sn_tide_cnames(1) =   'M2'  !  name of constituent
+      sn_tide_cnames(2) =   'S2'
+      sn_tide_cnames(3) =   'N2'
+      sn_tide_cnames(4) =   'K2'
+      sn_tide_cnames(5) =   'K1'
+      sn_tide_cnames(6) =   'O1'
+      sn_tide_cnames(7) =   'P1'
+      sn_tide_cnames(8) =   'Q1'
 /
 !-----------------------------------------------------------------------
@@ -348,5 +348,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/doc/latex/NEMO/subfiles/chap_DIA.tex
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/doc/latex/NEMO/subfiles/chap_DIA.tex	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/doc/latex/NEMO/subfiles/chap_DIA.tex	(revision 12184)
@@ -1580,50 +1580,4 @@
 
 %% =================================================================================================
-\section[Harmonic analysis of tidal constituents (\texttt{\textbf{key\_diaharm}})]{Harmonic analysis of tidal constituents (\protect\key{diaharm})}
-\label{sec:DIA_diag_harm}
-
-\begin{listing}
-  \nlst{nam_diaharm}
-  \caption{\forcode{&nam_diaharm}}
-  \label{lst:nam_diaharm}
-\end{listing}
-
-A module is available to compute the amplitude and phase of tidal waves.
-This on-line Harmonic analysis is actived with \key{diaharm}.
-
-Some parameters are available in namelist \nam{_diaharm}{\_diaharm}:
-
- - \np{nit000_han}{nit000\_han} is the first time step used for harmonic analysis
-
- - \np{nitend_han}{nitend\_han} is the  last time step used for harmonic analysis
-
- - \np{nstep_han}{nstep\_han}  is the  time step frequency for harmonic analysis
-
-% - \np{nb_ana}{nb\_ana}     is the number of harmonics to analyse
-
- - \np{tname}{tname}       is an array with names of tidal constituents to analyse
-
- \np{nit000_han}{nit000\_han} and \np{nitend_han}{nitend\_han} must be between \np{nit000}{nit000} and \np{nitend}{nitend} of the simulation.
- The restart capability is not implemented.
-
- The Harmonic analysis solve the following equation:
-
- \[
-   h_{i} - A_{0} + \sum^{nb\_ana}_{j=1}[A_{j}cos(\nu_{j}t_{j}-\phi_{j})] = e_{i}
- \]
-
-With $A_{j}$, $\nu_{j}$, $\phi_{j}$, the amplitude, frequency and phase for each wave and $e_{i}$ the error.
-$h_{i}$ is the sea level for the time $t_{i}$ and $A_{0}$ is the mean sea level. \\
-We can rewrite this equation:
-
-\[
-  h_{i} - A_{0} + \sum^{nb\_ana}_{j=1}[C_{j}cos(\nu_{j}t_{j})+S_{j}sin(\nu_{j}t_{j})] = e_{i}
-\]
-
-with $A_{j}=\sqrt{C^{2}_{j}+S^{2}_{j}}$ and $\phi_{j}=arctan(S_{j}/C_{j})$.
-
-We obtain in output $C_{j}$ and $S_{j}$ for each tidal wave.
-
-%% =================================================================================================
 \section[Transports across sections (\texttt{\textbf{key\_diadct}})]{Transports across sections (\protect\key{diadct})}
 \label{sec:DIA_diag_dct}
Index: MO/branches/2019/dev_r12072_MERGE_OPTION2_2019/doc/namelists/nam_diaharm
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/doc/namelists/nam_diaharm	(revision 12183)
+++ 	(revision )
@@ -1,10 +1,0 @@
-!-----------------------------------------------------------------------
-&nam_diaharm   !   Harmonic analysis of tidal constituents              (default: OFF)
-!-----------------------------------------------------------------------
-    ln_diaharm = .false.   ! Choose tidal harmonic output or not
-       nit000_han = 1      !    First time step used for harmonic analysis
-       nitend_han = 75     !    Last time step used for harmonic analysis
-       nstep_han  = 15     !    Time step frequency for harmonic analysis
-       tname(1)   = 'M2'   !    Name of tidal constituents
-       tname(2)   = 'K1'   !              ---
-/
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/BDY/bdydta.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/BDY/bdydta.F90	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/BDY/bdydta.F90	(revision 12184)
@@ -23,5 +23,5 @@
    USE phycst         ! physical constants
    USE sbcapr         ! atmospheric pressure forcing
-   USE sbctide        ! Tidal forcing or not
+   USE tide_mod, ONLY: ln_tide ! tidal forcing
    USE bdy_oce        ! ocean open boundary conditions  
    USE bdytides       ! tidal forcing at boundaries
@@ -75,5 +75,5 @@
 CONTAINS
 
-   SUBROUTINE bdy_dta( kt, kit, kt_offset )
+   SUBROUTINE bdy_dta( kt, kt_offset )
       !!----------------------------------------------------------------------
       !!                   ***  SUBROUTINE bdy_dta  ***
@@ -85,7 +85,5 @@
       !!----------------------------------------------------------------------
       INTEGER, INTENT(in)           ::   kt           ! ocean time-step index 
-      INTEGER, INTENT(in), OPTIONAL ::   kit          ! subcycle time-step index (for timesplitting option)
-      INTEGER, INTENT(in), OPTIONAL ::   kt_offset    ! time offset in units of timesteps. NB. if kit
-      !                                               ! is present then units = subcycle timesteps.
+      INTEGER, INTENT(in), OPTIONAL ::   kt_offset    ! time offset in units of timesteps
       !                                               ! kt_offset = 0 => get data at "now" time level
       !                                               ! kt_offset = -1 => get data at "before" time level
@@ -105,5 +103,5 @@
       ! Initialise data arrays once for all from initial conditions where required
       !---------------------------------------------------------------------------
-      IF( kt == nit000 .AND. .NOT.PRESENT(kit) ) THEN
+      IF( kt == nit000 ) THEN
 
          ! Calculate depth-mean currents
@@ -216,5 +214,5 @@
          ! read/update all bdy data
          ! ------------------------
-         CALL fld_read( kt, 1, bf_alias, kit = kit, kt_offset = kt_offset )
+         CALL fld_read( kt, 1, bf_alias, kt_offset = kt_offset )
 
          ! apply some corrections in some specific cases...
@@ -275,10 +273,4 @@
             END DO
          ENDIF   ! ltotvel
-
-         ! update tidal harmonic forcing
-         IF( PRESENT(kit) .AND. nn_dyn2d_dta(jbdy) .GE. 2 ) THEN
-            CALL bdytide_update( kt = kt, idx = idx_bdy(jbdy), dta = dta_alias, td = tides(jbdy),   & 
-               &                 kit = kit, kt_offset = kt_offset )
-         ENDIF
 
          !  atm surface pressure : add inverted barometer effect to ssh if it was read
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/BDY/bdyini.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/BDY/bdyini.F90	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/BDY/bdyini.F90	(revision 12184)
@@ -22,5 +22,5 @@
    USE bdydta         ! open boundary cond. setting   (bdy_dta_init routine)
    USE bdytides       ! open boundary cond. setting   (bdytide_init routine)
-   USE sbctide        ! Tidal forcing or not
+   USE tide_mod, ONLY: ln_tide ! tidal forcing
    USE phycst   , ONLY: rday
    !
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/BDY/bdytides.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/BDY/bdytides.F90	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/BDY/bdytides.F90	(revision 12184)
@@ -18,5 +18,5 @@
    USE phycst         ! physical constants
    USE bdy_oce        ! ocean open boundary conditions
-   USE tideini        ! 
+   USE tide_mod       ! 
    USE daymod         ! calendar
    !
@@ -30,5 +30,4 @@
 
    PUBLIC   bdytide_init     ! routine called in bdy_init
-   PUBLIC   bdytide_update   ! routine called in bdy_dta
    PUBLIC   bdy_dta_tides    ! routine called in dyn_spg_ts
 
@@ -45,4 +44,6 @@
    TYPE(OBC_DATA)  , PUBLIC, DIMENSION(jp_bdy) :: dta_bdy_s  !: bdy external data (slow component)
 
+   INTEGER ::   kt_tide
+
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -64,5 +65,4 @@
       CHARACTER(len=80)                         ::   filtide             !: Filename root for tidal input files
       LOGICAL                                   ::   ln_bdytide_2ddta    !: If true, read 2d harmonic data
-      LOGICAL                                   ::   ln_bdytide_conj     !: If true, assume complex conjugate tidal data
       !!
       INTEGER                                   ::   ib_bdy, itide, ib   !: dummy loop indices
@@ -77,5 +77,5 @@
       TYPE(TIDES_DATA),  POINTER                ::   td                  !: local short cut   
       !!
-      NAMELIST/nambdy_tide/filtide, ln_bdytide_2ddta, ln_bdytide_conj
+      NAMELIST/nambdy_tide/filtide, ln_bdytide_2ddta
       !!----------------------------------------------------------------------
       !
@@ -105,10 +105,9 @@
             IF(lwp) WRITE(numout,*) '          Namelist nambdy_tide : tidal harmonic forcing at open boundaries'
             IF(lwp) WRITE(numout,*) '             read tidal data in 2d files: ', ln_bdytide_2ddta
-            IF(lwp) WRITE(numout,*) '             assume complex conjugate   : ', ln_bdytide_conj
             IF(lwp) WRITE(numout,*) '             Number of tidal components to read: ', nb_harmo
             IF(lwp) THEN 
                     WRITE(numout,*) '             Tidal components: ' 
                DO itide = 1, nb_harmo
-                  WRITE(numout,*)  '                 ', Wave(ntide(itide))%cname_tide 
+                  WRITE(numout,*)  '                 ', tide_harmonics(itide)%cname_tide 
                END DO
             ENDIF 
@@ -151,6 +150,6 @@
                igrd = 1                       ! Everything is at T-points here
                DO itide = 1, nb_harmo
-                  CALL iom_get( inum, jpdom_autoglo, TRIM(Wave(ntide(itide))%cname_tide)//'_z1', ztr(:,:) )
-                  CALL iom_get( inum, jpdom_autoglo, TRIM(Wave(ntide(itide))%cname_tide)//'_z2', zti(:,:) ) 
+                  CALL iom_get( inum, jpdom_autoglo, TRIM(tide_harmonics(itide)%cname_tide)//'_z1', ztr(:,:) )
+                  CALL iom_get( inum, jpdom_autoglo, TRIM(tide_harmonics(itide)%cname_tide)//'_z2', zti(:,:) ) 
                   DO ib = 1, ilen0(igrd)
                      ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
@@ -168,6 +167,6 @@
                igrd = 2                       ! Everything is at U-points here
                DO itide = 1, nb_harmo
-                  CALL iom_get  ( inum, jpdom_autoglo, TRIM(Wave(ntide(itide))%cname_tide)//'_u1', ztr(:,:) )
-                  CALL iom_get  ( inum, jpdom_autoglo, TRIM(Wave(ntide(itide))%cname_tide)//'_u2', zti(:,:) )
+                  CALL iom_get  ( inum, jpdom_autoglo, TRIM(tide_harmonics(itide)%cname_tide)//'_u1', ztr(:,:) )
+                  CALL iom_get  ( inum, jpdom_autoglo, TRIM(tide_harmonics(itide)%cname_tide)//'_u2', zti(:,:) )
                   DO ib = 1, ilen0(igrd)
                      ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
@@ -185,6 +184,6 @@
                igrd = 3                       ! Everything is at V-points here
                DO itide = 1, nb_harmo
-                  CALL iom_get  ( inum, jpdom_autoglo, TRIM(Wave(ntide(itide))%cname_tide)//'_v1', ztr(:,:) )
-                  CALL iom_get  ( inum, jpdom_autoglo, TRIM(Wave(ntide(itide))%cname_tide)//'_v2', zti(:,:) )
+                  CALL iom_get  ( inum, jpdom_autoglo, TRIM(tide_harmonics(itide)%cname_tide)//'_v1', ztr(:,:) )
+                  CALL iom_get  ( inum, jpdom_autoglo, TRIM(tide_harmonics(itide)%cname_tide)//'_v2', zti(:,:) )
                   DO ib = 1, ilen0(igrd)
                      ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
@@ -210,5 +209,5 @@
                DO itide = 1, nb_harmo
                   !                                                              ! SSH fields
-                  clfile = TRIM(filtide)//TRIM(Wave(ntide(itide))%cname_tide)//'_grid_T.nc'
+                  clfile = TRIM(filtide)//TRIM(tide_harmonics(itide)%cname_tide)//'_grid_T.nc'
                   CALL iom_open( clfile, inum )
                   CALL fld_map( inum, 'z1' , dta_read(1:ilen0(1),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,1) )
@@ -218,5 +217,5 @@
                   CALL iom_close( inum )
                   !                                                              ! U fields
-                  clfile = TRIM(filtide)//TRIM(Wave(ntide(itide))%cname_tide)//'_grid_U.nc'
+                  clfile = TRIM(filtide)//TRIM(tide_harmonics(itide)%cname_tide)//'_grid_U.nc'
                   CALL iom_open( clfile, inum )
                   CALL fld_map( inum, 'u1' , dta_read(1:ilen0(2),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,2) )
@@ -226,5 +225,5 @@
                   CALL iom_close( inum )
                   !                                                              ! V fields
-                  clfile = TRIM(filtide)//TRIM(Wave(ntide(itide))%cname_tide)//'_grid_V.nc'
+                  clfile = TRIM(filtide)//TRIM(tide_harmonics(itide)%cname_tide)//'_grid_V.nc'
                   CALL iom_open( clfile, inum )
                   CALL fld_map( inum, 'v1' , dta_read(1:ilen0(3),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,3) )
@@ -240,10 +239,4 @@
             ENDIF ! ln_bdytide_2ddta=.true.
             !
-            IF( ln_bdytide_conj ) THEN    ! assume complex conjugate in data files
-               td%ssh0(:,:,2) = - td%ssh0(:,:,2)
-               td%u0  (:,:,2) = - td%u0  (:,:,2)
-               td%v0  (:,:,2) = - td%v0  (:,:,2)
-            ENDIF
-            !
             ! Allocate slow varying data in the case of time splitting:
             ! Do it anyway because at this stage knowledge of free surface scheme is unknown
@@ -260,93 +253,4 @@
       !
    END SUBROUTINE bdytide_init
-
-
-   SUBROUTINE bdytide_update( kt, idx, dta, td, kit, kt_offset )
-      !!----------------------------------------------------------------------
-      !!                 ***  SUBROUTINE bdytide_update  ***
-      !!                
-      !! ** Purpose : - Add tidal forcing to ssh, u2d and v2d OBC data arrays. 
-      !!                
-      !!----------------------------------------------------------------------
-      INTEGER          , INTENT(in   ) ::   kt          ! Main timestep counter
-      TYPE(OBC_INDEX)  , INTENT(in   ) ::   idx         ! OBC indices
-      TYPE(OBC_DATA)   , INTENT(inout) ::   dta         ! OBC external data
-      TYPE(TIDES_DATA) , INTENT(inout) ::   td          ! tidal harmonics data
-      INTEGER, OPTIONAL, INTENT(in   ) ::   kit         ! Barotropic timestep counter (for timesplitting option)
-      INTEGER, OPTIONAL, INTENT(in   ) ::   kt_offset   ! time offset in units of timesteps. NB. if kit
-      !                                                 ! is present then units = subcycle timesteps.
-      !                                                 ! kt_offset = 0  => get data at "now"    time level
-      !                                                 ! kt_offset = -1 => get data at "before" time level
-      !                                                 ! kt_offset = +1 => get data at "after"  time level
-      !                                                 ! etc.
-      !
-      INTEGER  ::   itide, igrd, ib       ! dummy loop indices
-      INTEGER  ::   time_add              ! time offset in units of timesteps
-      INTEGER, DIMENSION(3) ::   ilen0    ! length of boundary data (from OBC arrays)
-      REAL(wp) ::   z_arg, z_sarg, zflag, zramp   ! local scalars    
-      REAL(wp), DIMENSION(jpmax_harmo) :: z_sist, z_cost
-      !!----------------------------------------------------------------------
-      !
-      ilen0(1) =  SIZE(td%ssh(:,1,1))
-      ilen0(2) =  SIZE(td%u(:,1,1))
-      ilen0(3) =  SIZE(td%v(:,1,1))
-
-      zflag=1
-      IF ( PRESENT(kit) ) THEN
-        IF ( kit /= 1 ) zflag=0
-      ENDIF
-
-      IF ( (nsec_day == NINT(0.5_wp * rdt) .OR. kt==nit000) .AND. zflag==1 ) THEN
-        !
-        kt_tide = kt - (nsec_day - 0.5_wp * rdt)/rdt
-        !
-        IF(lwp) THEN
-           WRITE(numout,*)
-           WRITE(numout,*) 'bdytide_update : (re)Initialization of the tidal bdy forcing at kt=',kt
-           WRITE(numout,*) '~~~~~~~~~~~~~~ '
-        ENDIF
-        !
-        CALL tide_init_elevation ( idx, td )
-        CALL tide_init_velocities( idx, td )
-        !
-      ENDIF 
-
-      time_add = 0
-      IF( PRESENT(kt_offset) ) THEN
-         time_add = kt_offset
-      ENDIF
-         
-      IF( PRESENT(kit) ) THEN  
-         z_arg = ((kt-kt_tide) * rdt + (kit+0.5_wp*(time_add-1)) * rdt / REAL(nn_baro,wp) )
-      ELSE                              
-         z_arg = ((kt-kt_tide)+time_add) * rdt
-      ENDIF
-
-      ! Linear ramp on tidal component at open boundaries 
-      zramp = 1._wp
-      IF (ln_tide_ramp) zramp = MIN(MAX( (z_arg + (kt_tide-nit000)*rdt)/(rdttideramp*rday),0._wp),1._wp)
-
-      DO itide = 1, nb_harmo
-         z_sarg = z_arg * omega_tide(itide)
-         z_cost(itide) = COS( z_sarg )
-         z_sist(itide) = SIN( z_sarg )
-      END DO
-
-      DO itide = 1, nb_harmo
-         igrd=1                              ! SSH on tracer grid
-         DO ib = 1, ilen0(igrd)
-            dta%ssh(ib) = dta%ssh(ib) + zramp*(td%ssh(ib,itide,1)*z_cost(itide) + td%ssh(ib,itide,2)*z_sist(itide))
-         END DO
-         igrd=2                              ! U grid
-         DO ib = 1, ilen0(igrd)
-            dta%u2d(ib) = dta%u2d(ib) + zramp*(td%u  (ib,itide,1)*z_cost(itide) + td%u  (ib,itide,2)*z_sist(itide))
-         END DO
-         igrd=3                              ! V grid
-         DO ib = 1, ilen0(igrd) 
-            dta%v2d(ib) = dta%v2d(ib) + zramp*(td%v  (ib,itide,1)*z_cost(itide) + td%v  (ib,itide,2)*z_sist(itide))
-         END DO
-      END DO
-      !
-   END SUBROUTINE bdytide_update
 
 
@@ -392,5 +296,5 @@
       ! Linear ramp on tidal component at open boundaries 
       zramp = 1.
-      IF (ln_tide_ramp) zramp = MIN(MAX( (z_arg - nit000*rdt)/(rdttideramp*rday),0.),1.)
+      IF (ln_tide_ramp) zramp = MIN(MAX( (z_arg - nit000*rdt)/(rn_tide_ramp_dt*rday),0.),1.)
 
       DO ib_bdy = 1,nb_bdy
@@ -433,5 +337,5 @@
             DO itide = 1, nb_harmo
                !
-               z_sarg = (z_arg + zoff) * omega_tide(itide)
+               z_sarg = (z_arg + zoff) * tide_harmonics(itide)%omega
                z_cost = zramp * COS( z_sarg )
                z_sist = zramp * SIN( z_sarg )
@@ -491,6 +395,6 @@
          END DO
          DO ib = 1 , ilen0(igrd)
-            mod_tide(ib)=mod_tide(ib)*ftide(itide)
-            phi_tide(ib)=phi_tide(ib)+v0tide(itide)+utide(itide)
+            mod_tide(ib)=mod_tide(ib)*tide_harmonics(itide)%f
+            phi_tide(ib)=phi_tide(ib)+tide_harmonics(itide)%v0+tide_harmonics(itide)%u
          ENDDO
          DO ib = 1 , ilen0(igrd)
@@ -530,6 +434,6 @@
          END DO
          DO ib = 1, ilen0(igrd)
-            mod_tide(ib)=mod_tide(ib)*ftide(itide)
-            phi_tide(ib)=phi_tide(ib)+v0tide(itide)+utide(itide)
+            mod_tide(ib)=mod_tide(ib)*tide_harmonics(itide)%f
+            phi_tide(ib)=phi_tide(ib)+tide_harmonics(itide)%v0 + tide_harmonics(itide)%u
          ENDDO
          DO ib = 1, ilen0(igrd)
@@ -551,6 +455,6 @@
          END DO
          DO ib = 1, ilen0(igrd)
-            mod_tide(ib)=mod_tide(ib)*ftide(itide)
-            phi_tide(ib)=phi_tide(ib)+v0tide(itide)+utide(itide)
+            mod_tide(ib)=mod_tide(ib)*tide_harmonics(itide)%f
+            phi_tide(ib)=phi_tide(ib)+tide_harmonics(itide)%v0 + tide_harmonics(itide)%u
          ENDDO
          DO ib = 1, ilen0(igrd)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/DIA/diadetide.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/DIA/diadetide.F90	(revision 12184)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/DIA/diadetide.F90	(revision 12184)
@@ -0,0 +1,109 @@
+MODULE diadetide
+   !!======================================================================
+   !!                      ***  MODULE diadetide  ***
+   !! Computation of weights for daily detided model diagnostics
+   !!======================================================================
+   !! History :       !  2019  (S. Mueller)
+   !!----------------------------------------------------------------------
+   USE par_oce        , ONLY :   wp, jpi, jpj
+   USE in_out_manager , ONLY :   lwp, numout
+   USE iom            , ONLY :   iom_put
+   USE dom_oce        , ONLY :   rdt, nsec_day
+   USE phycst         , ONLY :   rpi
+   USE tide_mod
+   USE xios
+
+   IMPLICIT NONE
+   PRIVATE
+
+   LOGICAL, PUBLIC                               ::   lk_diadetide
+   INTEGER                                       ::   ndiadetide
+   REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:)     ::   tdiadetide
+
+   PUBLIC ::   dia_detide_init, dia_detide
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2019)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dia_detide_init
+      !!----------------------------------------------------------------------
+      !!               ***  ROUTINE dia_detide_init  ***
+      !!
+      !! ** Purpose : initialisation of the weight computation for daily
+      !!              detided diagnostics (currently M2-detiding only)
+      !!
+      !!----------------------------------------------------------------------
+
+      REAL(wp)                                   ::   zdt
+      INTEGER                                    ::   jn
+      CHARACTER (LEN=4), DIMENSION(jpmax_harmo)  ::   ctide_selected = ' n/a '
+      TYPE(tide_harmonic), DIMENSION(:), POINTER ::   stideconst
+
+      ! Enquire detiding activation state (test for presence of detiding-related
+      ! weights field and output file group)
+      IF ( xios_is_valid_field( "diadetide_weight" ).AND.xios_is_valid_filegroup( "diadetide_files" ).AND.ln_tide ) THEN
+         lk_diadetide = .TRUE.
+      ELSE
+         lk_diadetide = .FALSE.
+      END IF
+
+      IF (lwp) THEN
+         WRITE (numout, *)
+         WRITE (numout, *) 'dia_detide_init : weight computation for daily detided model diagnostics'
+         WRITE (numout, *) '~~~~~~~~~~~~~~~'
+         WRITE (numout, *) '                  lk_diadetide = ', lk_diadetide
+      END IF
+
+      IF (lk_diadetide) THEN
+         ! Retrieve information about M2 tidal constituent
+         ctide_selected(1) = 'M2'
+         CALL tide_init_harmonics(ctide_selected, stideconst) 
+
+         ! For M2, twice the tidal period spans slightly more than one full
+         ! day. Compute the maximum number of equal intervals that span exactly
+         ! twice the tidal period *and* whose mid-points fall within a 24-hour
+         ! period from midnight to midnight.
+         zdt = 2.0_wp * 2.0_wp * rpi / stideconst(1)%omega
+         ndiadetide = FLOOR( zdt / ( zdt - 86400.0_wp ) )
+         ! Compute mid-points of the intervals to be included in the detided
+         ! average
+         ALLOCATE ( tdiadetide(ndiadetide) )
+         DO jn = 1, ndiadetide
+            tdiadetide(jn) = ( REAL( jn, KIND=wp) - 0.5_wp ) * zdt / REAL( ndiadetide, KIND=wp ) - ( zdt - 86400.0_wp ) * 0.5_wp
+         END DO
+      END IF
+
+   END SUBROUTINE dia_detide_init
+
+   SUBROUTINE dia_detide( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_detide  ***
+      !!
+      !! ** Purpose : weight computation for daily detided model diagnostics
+      !!----------------------------------------------------------------------
+
+      INTEGER, INTENT(in)          ::   kt
+      REAL(wp), DIMENSION(jpi,jpj) ::   zwght_2D
+      REAL(wp)                     ::   zwght, ztmp
+      INTEGER                      ::   jn
+
+      ! Compute detiding weight at the current time-step; the daily total weight
+      ! is one, and the daily summation of a diagnosed field multiplied by this
+      ! weight should provide daily detided averages
+      zwght = 0.0_wp
+      DO jn = 1, ndiadetide
+         ztmp = ( tdiadetide(jn) - REAL( nsec_day, KIND=wp ) ) / rdt
+         IF ( ( ztmp < 0.5_wp ).AND.( ztmp >= -0.5_wp ) ) THEN
+            zwght = zwght + 1.0_wp / REAL( ndiadetide, KIND=wp )
+         END IF
+      END DO
+      zwght_2D(:,:) = zwght
+      CALL iom_put( "diadetide_weight", zwght_2D)
+
+   END SUBROUTINE dia_detide
+
+END MODULE diadetide
Index: MO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/DIA/diaharm.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/DIA/diaharm.F90	(revision 12183)
+++ 	(revision )
@@ -1,517 +1,0 @@
-MODULE diaharm 
-   !!======================================================================
-   !!                       ***  MODULE  diaharm  ***
-   !! Harmonic analysis of tidal constituents 
-   !!======================================================================
-   !! History :  3.1  !  2007  (O. Le Galloudec, J. Chanut)  Original code
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers variables
-   USE dom_oce         ! ocean space and time domain
-   USE phycst
-   USE daymod
-   USE tide_mod
-   USE sbctide         ! Tidal forcing or not
-   !
-   USE in_out_manager  ! I/O units
-   USE iom             ! I/0 library
-   USE ioipsl          ! NetCDF IPSL library
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE timing          ! preformance summary
-   USE lib_mpp           ! MPP library
-
-   IMPLICIT NONE
-   PRIVATE
-   
-   INTEGER, PARAMETER :: jpincomax    = 2.*jpmax_harmo
-   INTEGER, PARAMETER :: jpdimsparse  = jpincomax*300*24
-
-   !                         !!** namelist variables **
-   LOGICAL, PUBLIC ::   ln_diaharm    ! Choose tidal harmonic output or not
-   INTEGER         ::   nit000_han    ! First time step used for harmonic analysis
-   INTEGER         ::   nitend_han    ! Last time step used for harmonic analysis
-   INTEGER         ::   nstep_han     ! Time step frequency for harmonic analysis
-   INTEGER         ::   nb_ana        ! Number of harmonics to analyse
-
-   INTEGER , ALLOCATABLE, DIMENSION(:)       ::   name
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) ::   ana_temp
-   REAL(wp), ALLOCATABLE, DIMENSION(:)       ::   ana_freq, ut   , vt   , ft
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   out_eta , out_u, out_v
-
-   INTEGER ::   ninco, nsparse
-   INTEGER ,       DIMENSION(jpdimsparse)         ::   njsparse, nisparse
-   INTEGER , SAVE, DIMENSION(jpincomax)           ::   ipos1
-   REAL(wp),       DIMENSION(jpdimsparse)         ::   valuesparse
-   REAL(wp),       DIMENSION(jpincomax)           ::   ztmp4 , ztmp7
-   REAL(wp), SAVE, DIMENSION(jpincomax,jpincomax) ::   ztmp3 , zpilier
-   REAL(wp), SAVE, DIMENSION(jpincomax)           ::   zpivot
-
-   CHARACTER (LEN=4), DIMENSION(jpmax_harmo) ::   tname   ! Names of tidal constituents ('M2', 'K1',...)
-
-   PUBLIC   dia_harm        ! routine called by step.F90
-   PUBLIC   dia_harm_init   ! routine called by nemogcm.F90
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id$
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE dia_harm_init 
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE dia_harm_init  ***
-      !!         
-      !! ** Purpose :   Initialization of tidal harmonic analysis
-      !!
-      !! ** Method  :   Initialize frequency array and  nodal factor for nit000_han
-      !!
-      !!--------------------------------------------------------------------
-      INTEGER ::   jh, nhan, ji
-      INTEGER ::   ios                 ! Local integer output status for namelist read
-
-      NAMELIST/nam_diaharm/ ln_diaharm, nit000_han, nitend_han, nstep_han, tname
-      !!----------------------------------------------------------------------
-
-      IF(lwp) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) 'dia_harm_init: Tidal harmonic analysis initialization'
-         WRITE(numout,*) '~~~~~~~ '
-      ENDIF
-      !
-      REWIND( numnam_ref )              ! Namelist nam_diaharm in reference namelist : Tidal harmonic analysis
-      READ  ( numnam_ref, nam_diaharm, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_diaharm in reference namelist' )
-      REWIND( numnam_cfg )              ! Namelist nam_diaharm in configuration namelist : Tidal harmonic analysis
-      READ  ( numnam_cfg, nam_diaharm, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nam_diaharm in configuration namelist' )
-      IF(lwm) WRITE ( numond, nam_diaharm )
-      !
-      IF(lwp) THEN
-         WRITE(numout,*) 'Tidal diagnostics = ', ln_diaharm
-         WRITE(numout,*) '   First time step used for analysis:         nit000_han= ', nit000_han
-         WRITE(numout,*) '   Last  time step used for analysis:         nitend_han= ', nitend_han
-         WRITE(numout,*) '   Time step frequency for harmonic analysis: nstep_han = ', nstep_han
-      ENDIF
-
-      IF( ln_diaharm .AND. .NOT.ln_tide )   CALL ctl_stop( 'dia_harm_init : ln_tide must be true for harmonic analysis')
-
-      IF( ln_diaharm ) THEN
-
-         CALL tide_init_Wave
-         !
-         ! Basic checks on harmonic analysis time window:
-         ! ----------------------------------------------
-         IF( nit000 > nit000_han )   CALL ctl_stop( 'dia_harm_init : nit000_han must be greater than nit000',   &
-            &                                       ' restart capability not implemented' )
-         IF( nitend < nitend_han )   CALL ctl_stop( 'dia_harm_init : nitend_han must be lower than nitend',   &
-            &                                       'restart capability not implemented' )
-
-         IF( MOD( nitend_han-nit000_han+1 , nstep_han ) /= 0 )   &
-            &                        CALL ctl_stop( 'dia_harm_init : analysis time span must be a multiple of nstep_han' )
-         !
-         nb_ana = 0
-         DO jh=1,jpmax_harmo
-            DO ji=1,jpmax_harmo
-               IF(TRIM(tname(jh)) == Wave(ji)%cname_tide) THEN
-                  nb_ana=nb_ana+1
-               ENDIF
-            END DO
-         END DO
-         !
-         IF(lwp) THEN
-            WRITE(numout,*) '        Namelist nam_diaharm'
-            WRITE(numout,*) '        nb_ana    = ', nb_ana
-            CALL flush(numout)
-         ENDIF
-         !
-         IF (nb_ana > jpmax_harmo) THEN
-            WRITE(ctmp1,*) ' nb_ana must be lower than jpmax_harmo'
-            WRITE(ctmp2,*) ' jpmax_harmo= ', jpmax_harmo
-            CALL ctl_stop( 'dia_harm_init', ctmp1, ctmp2 )
-         ENDIF
-
-         ALLOCATE(name    (nb_ana))
-         DO jh=1,nb_ana
-            DO ji=1,jpmax_harmo
-               IF (TRIM(tname(jh)) ==  Wave(ji)%cname_tide) THEN
-                  name(jh) = ji
-                  EXIT
-               END IF
-            END DO
-         END DO
-
-         ! Initialize frequency array:
-         ! ---------------------------
-         ALLOCATE( ana_freq(nb_ana), ut(nb_ana), vt(nb_ana), ft(nb_ana) )
-
-         CALL tide_harmo( ana_freq, vt, ut, ft, name, nb_ana )
-
-         IF(lwp) WRITE(numout,*) 'Analysed frequency  : ',nb_ana ,'Frequency '
-
-         DO jh = 1, nb_ana
-            IF(lwp) WRITE(numout,*) '                    : ',tname(jh),' ',ana_freq(jh)
-         END DO
-
-         ! Initialize temporary arrays:
-         ! ----------------------------
-         ALLOCATE( ana_temp(jpi,jpj,2*nb_ana,3) )
-         ana_temp(:,:,:,:) = 0._wp
-
-      ENDIF
-
-   END SUBROUTINE dia_harm_init
-
-
-   SUBROUTINE dia_harm ( kt )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE dia_harm  ***
-      !!         
-      !! ** Purpose :   Tidal harmonic analysis main routine
-      !!
-      !! ** Action  :   Sums ssh/u/v over time analysis [nit000_han,nitend_han]
-      !!
-      !!--------------------------------------------------------------------
-      INTEGER, INTENT( IN ) :: kt
-      !
-      INTEGER  :: ji, jj, jh, jc, nhc
-      REAL(wp) :: ztime, ztemp
-      !!--------------------------------------------------------------------
-      IF( ln_timing )   CALL timing_start('dia_harm')
-      !
-      IF( kt >= nit000_han .AND. kt <= nitend_han .AND. MOD(kt,nstep_han) == 0 ) THEN
-         !
-         ztime = (kt-nit000+1) * rdt 
-         !
-         nhc = 0
-         DO jh = 1, nb_ana
-            DO jc = 1, 2
-               nhc = nhc+1
-               ztemp =(     MOD(jc,2) * ft(jh) *COS(ana_freq(jh)*ztime + vt(jh) + ut(jh))  &
-                  &    +(1.-MOD(jc,2))* ft(jh) *SIN(ana_freq(jh)*ztime + vt(jh) + ut(jh)))
-                  !
-               DO jj = 1,jpj
-                  DO ji = 1,jpi
-                     ! Elevation
-                     ana_temp(ji,jj,nhc,1) = ana_temp(ji,jj,nhc,1) + ztemp*sshn(ji,jj)*ssmask (ji,jj)        
-                     ana_temp(ji,jj,nhc,2) = ana_temp(ji,jj,nhc,2) + ztemp*un_b(ji,jj)*ssumask(ji,jj)
-                     ana_temp(ji,jj,nhc,3) = ana_temp(ji,jj,nhc,3) + ztemp*vn_b(ji,jj)*ssvmask(ji,jj)
-                  END DO
-               END DO
-               !
-            END DO
-         END DO
-         !       
-      END IF
-      !
-      IF( kt == nitend_han )   CALL dia_harm_end
-      !
-      IF( ln_timing )   CALL timing_stop('dia_harm')
-      !
-   END SUBROUTINE dia_harm
-
-
-   SUBROUTINE dia_harm_end
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE diaharm_end  ***
-      !!         
-      !! ** Purpose :  Compute the Real and Imaginary part of tidal constituents
-      !!
-      !! ** Action  :  Decompose the signal on the harmonic constituents 
-      !!
-      !!--------------------------------------------------------------------
-      INTEGER :: ji, jj, jh, jc, jn, nhan, jl
-      INTEGER :: ksp, kun, keq
-      REAL(wp) :: ztime, ztime_ini, ztime_end
-      REAL(wp) :: X1, X2
-      REAL(wp), DIMENSION(jpi,jpj,jpmax_harmo,2) ::   ana_amp   ! workspace
-      !!--------------------------------------------------------------------
-      !
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'anharmo_end: kt=nitend_han: Perform harmonic analysis'
-      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
-
-      ztime_ini = nit000_han*rdt                 ! Initial time in seconds at the beginning of analysis
-      ztime_end = nitend_han*rdt                 ! Final time in seconds at the end of analysis
-      nhan = (nitend_han-nit000_han+1)/nstep_han ! Number of dumps used for analysis
-
-      ninco = 2*nb_ana
-
-      ksp = 0
-      keq = 0        
-      DO jn = 1, nhan
-         ztime=( (nhan-jn)*ztime_ini + (jn-1)*ztime_end )/FLOAT(nhan-1)
-         keq = keq + 1
-         kun = 0
-         DO jh = 1, nb_ana
-            DO jc = 1, 2
-               kun = kun + 1
-               ksp = ksp + 1
-               nisparse(ksp) = keq
-               njsparse(ksp) = kun
-               valuesparse(ksp) = (   MOD(jc,2) * ft(jh) * COS(ana_freq(jh)*ztime + vt(jh) + ut(jh))   &
-                  &             + (1.-MOD(jc,2))* ft(jh) * SIN(ana_freq(jh)*ztime + vt(jh) + ut(jh)) )
-            END DO
-         END DO
-      END DO
-
-      nsparse = ksp
-
-      ! Elevation:
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            ! Fill input array
-            kun = 0
-            DO jh = 1, nb_ana
-               DO jc = 1, 2
-                  kun = kun + 1
-                  ztmp4(kun)=ana_temp(ji,jj,kun,1)
-               END DO
-            END DO
-
-            CALL SUR_DETERMINE(jj)
-
-            ! Fill output array
-            DO jh = 1, nb_ana
-               ana_amp(ji,jj,jh,1)=ztmp7((jh-1)*2+1)
-               ana_amp(ji,jj,jh,2)=ztmp7((jh-1)*2+2)
-            END DO
-         END DO
-      END DO
-
-      ALLOCATE( out_eta(jpi,jpj,2*nb_ana),   & 
-         &      out_u  (jpi,jpj,2*nb_ana),   &
-         &      out_v  (jpi,jpj,2*nb_ana)  )
-
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            DO jh = 1, nb_ana 
-               X1 = ana_amp(ji,jj,jh,1)
-               X2 =-ana_amp(ji,jj,jh,2)
-               out_eta(ji,jj,jh       ) = X1 * tmask_i(ji,jj)
-               out_eta(ji,jj,jh+nb_ana) = X2 * tmask_i(ji,jj)
-            END DO
-         END DO
-      END DO
-
-      ! ubar:
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            ! Fill input array
-            kun=0
-            DO jh = 1,nb_ana
-               DO jc = 1,2
-                  kun = kun + 1
-                  ztmp4(kun)=ana_temp(ji,jj,kun,2)
-               END DO
-            END DO
-
-            CALL SUR_DETERMINE(jj+1)
-
-            ! Fill output array
-            DO jh = 1, nb_ana
-               ana_amp(ji,jj,jh,1) = ztmp7((jh-1)*2+1)
-               ana_amp(ji,jj,jh,2) = ztmp7((jh-1)*2+2)
-            END DO
-
-         END DO
-      END DO
-
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            DO jh = 1, nb_ana 
-               X1= ana_amp(ji,jj,jh,1)
-               X2=-ana_amp(ji,jj,jh,2)
-               out_u(ji,jj,       jh) = X1 * ssumask(ji,jj)
-               out_u(ji,jj,nb_ana+jh) = X2 * ssumask(ji,jj)
-            ENDDO
-         ENDDO
-      ENDDO
-
-      ! vbar:
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            ! Fill input array
-            kun=0
-            DO jh = 1,nb_ana
-               DO jc = 1,2
-                  kun = kun + 1
-                  ztmp4(kun)=ana_temp(ji,jj,kun,3)
-               END DO
-            END DO
-
-            CALL SUR_DETERMINE(jj+1)
-
-            ! Fill output array
-            DO jh = 1, nb_ana
-               ana_amp(ji,jj,jh,1)=ztmp7((jh-1)*2+1)
-               ana_amp(ji,jj,jh,2)=ztmp7((jh-1)*2+2)
-            END DO
-
-         END DO
-      END DO
-
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            DO jh = 1, nb_ana 
-               X1=ana_amp(ji,jj,jh,1)
-               X2=-ana_amp(ji,jj,jh,2)
-               out_v(ji,jj,       jh)=X1 * ssvmask(ji,jj)
-               out_v(ji,jj,nb_ana+jh)=X2 * ssvmask(ji,jj)
-            END DO
-         END DO
-      END DO
-      !
-      CALL dia_wri_harm ! Write results in files
-      !
-   END SUBROUTINE dia_harm_end
-
-
-   SUBROUTINE dia_wri_harm
-      !!--------------------------------------------------------------------
-      !!                 ***  ROUTINE dia_wri_harm  ***
-      !!         
-      !! ** Purpose : Write tidal harmonic analysis results in a netcdf file
-      !!--------------------------------------------------------------------
-      CHARACTER(LEN=lc) :: cltext
-      CHARACTER(LEN=lc) ::   &
-         cdfile_name_T   ,   & ! name of the file created (T-points)
-         cdfile_name_U   ,   & ! name of the file created (U-points)
-         cdfile_name_V         ! name of the file created (V-points)
-      INTEGER  ::   jh
-      !!----------------------------------------------------------------------
-
-      IF(lwp) WRITE(numout,*) '  '
-      IF(lwp) WRITE(numout,*) 'dia_wri_harm : Write harmonic analysis results'
-      IF(lwp) WRITE(numout,*) '  '
-
-      ! A) Elevation
-      !/////////////
-      !
-      DO jh = 1, nb_ana
-      CALL iom_put( TRIM(tname(jh))//'x', out_eta(:,:,jh) )
-      CALL iom_put( TRIM(tname(jh))//'y', out_eta(:,:,nb_ana+jh) )
-      END DO
-
-      ! B) ubar
-      !/////////
-      !
-      DO jh = 1, nb_ana
-      CALL iom_put( TRIM(tname(jh))//'x_u', out_u(:,:,jh) )
-      CALL iom_put( TRIM(tname(jh))//'y_u', out_u(:,:,nb_ana+jh) )
-      END DO
-
-      ! C) vbar
-      !/////////
-      !
-      DO jh = 1, nb_ana
-         CALL iom_put( TRIM(tname(jh))//'x_v', out_v(:,:,jh       ) )
-         CALL iom_put( TRIM(tname(jh))//'y_v', out_v(:,:,jh+nb_ana) )
-      END DO
-      !
-   END SUBROUTINE dia_wri_harm
-
-
-   SUBROUTINE SUR_DETERMINE(init)
-      !!---------------------------------------------------------------------------------
-      !!                      *** ROUTINE SUR_DETERMINE ***
-      !!    
-      !!    
-      !!       
-      !!---------------------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   init 
-      !
-      INTEGER                         :: ji_sd, jj_sd, ji1_sd, ji2_sd, jh1_sd, jh2_sd
-      REAL(wp)                        :: zval1, zval2, zx1
-      REAL(wp), DIMENSION(jpincomax) :: ztmpx, zcol1, zcol2
-      INTEGER , DIMENSION(jpincomax) :: ipos2, ipivot
-      !---------------------------------------------------------------------------------
-      !            
-      IF( init == 1 ) THEN
-         IF( nsparse > jpdimsparse )   CALL ctl_stop( 'STOP', 'SUR_DETERMINE : nsparse .GT. jpdimsparse')
-         IF( ninco   > jpincomax   )   CALL ctl_stop( 'STOP', 'SUR_DETERMINE : ninco .GT. jpincomax')
-         !
-         ztmp3(:,:) = 0._wp
-         !
-         DO jh1_sd = 1, nsparse
-            DO jh2_sd = 1, nsparse
-               nisparse(jh2_sd) = nisparse(jh2_sd)
-               njsparse(jh2_sd) = njsparse(jh2_sd)
-               IF( nisparse(jh2_sd) == nisparse(jh1_sd) ) THEN
-                  ztmp3(njsparse(jh1_sd),njsparse(jh2_sd)) = ztmp3(njsparse(jh1_sd),njsparse(jh2_sd))  &
-                     &                                     + valuesparse(jh1_sd)*valuesparse(jh2_sd)
-               ENDIF
-            END DO
-         END DO
-         !
-         DO jj_sd = 1 ,ninco
-            ipos1(jj_sd) = jj_sd
-            ipos2(jj_sd) = jj_sd
-         END DO
-         !
-         DO ji_sd = 1 , ninco
-            !
-            !find greatest non-zero pivot:
-            zval1 = ABS(ztmp3(ji_sd,ji_sd))
-            !
-            ipivot(ji_sd) = ji_sd
-            DO jj_sd = ji_sd, ninco
-               zval2 = ABS(ztmp3(ji_sd,jj_sd))
-               IF( zval2 >= zval1 )THEN
-                  ipivot(ji_sd) = jj_sd
-                  zval1         = zval2
-               ENDIF
-            END DO
-            !
-            DO ji1_sd = 1, ninco
-               zcol1(ji1_sd)               = ztmp3(ji1_sd,ji_sd)
-               zcol2(ji1_sd)               = ztmp3(ji1_sd,ipivot(ji_sd))
-               ztmp3(ji1_sd,ji_sd)         = zcol2(ji1_sd)
-               ztmp3(ji1_sd,ipivot(ji_sd)) = zcol1(ji1_sd)
-            END DO
-            !
-            ipos2(ji_sd)         = ipos1(ipivot(ji_sd))
-            ipos2(ipivot(ji_sd)) = ipos1(ji_sd)
-            ipos1(ji_sd)         = ipos2(ji_sd)
-            ipos1(ipivot(ji_sd)) = ipos2(ipivot(ji_sd))
-            zpivot(ji_sd)        = ztmp3(ji_sd,ji_sd)
-            DO jj_sd = 1, ninco
-               ztmp3(ji_sd,jj_sd) = ztmp3(ji_sd,jj_sd) / zpivot(ji_sd)
-            END DO
-            !
-            DO ji2_sd = ji_sd+1, ninco
-               zpilier(ji2_sd,ji_sd)=ztmp3(ji2_sd,ji_sd)
-               DO jj_sd=1,ninco
-                  ztmp3(ji2_sd,jj_sd)=  ztmp3(ji2_sd,jj_sd) - ztmp3(ji_sd,jj_sd) * zpilier(ji2_sd,ji_sd)
-               END DO
-            END DO
-            !
-         END DO
-         !
-      ENDIF ! End init==1
-
-      DO ji_sd = 1, ninco
-         ztmp4(ji_sd) = ztmp4(ji_sd) / zpivot(ji_sd)
-         DO ji2_sd = ji_sd+1, ninco
-            ztmp4(ji2_sd) = ztmp4(ji2_sd) - ztmp4(ji_sd) * zpilier(ji2_sd,ji_sd)
-         END DO
-      END DO
-
-      !system solving: 
-      ztmpx(ninco) = ztmp4(ninco) / ztmp3(ninco,ninco)
-      ji_sd = ninco
-      DO ji_sd = ninco-1, 1, -1
-         zx1 = 0._wp
-         DO jj_sd = ji_sd+1, ninco
-            zx1 = zx1 + ztmpx(jj_sd) * ztmp3(ji_sd,jj_sd)
-         END DO
-         ztmpx(ji_sd) = ztmp4(ji_sd)-zx1
-      END DO
-
-      DO jj_sd =1, ninco
-         ztmp7(ipos1(jj_sd))=ztmpx(jj_sd)
-      END DO
-      !
-   END SUBROUTINE SUR_DETERMINE
-
-   !!======================================================================
-END MODULE diaharm
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/DIA/diamlr.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/DIA/diamlr.F90	(revision 12184)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/DIA/diamlr.F90	(revision 12184)
@@ -0,0 +1,415 @@
+MODULE diamlr
+   !!======================================================================
+   !!                       ***  MODULE  diamlr  ***
+   !! Management of the IOM context for multiple-linear-regression analysis
+   !!======================================================================
+   !! History :       !  2019  (S. Mueller)
+   !!----------------------------------------------------------------------
+
+   USE par_oce        , ONLY :   wp, jpi, jpj
+   USE phycst         , ONLY :   rpi
+   USE in_out_manager , ONLY :   lwp, numout, ln_timing
+   USE iom            , ONLY :   iom_put, iom_use, iom_update_file_name
+   USE dom_oce        , ONLY :   adatrj
+   USE timing         , ONLY :   timing_start, timing_stop
+   USE xios
+   USE tide_mod
+
+   IMPLICIT NONE
+   PRIVATE
+
+   LOGICAL, PUBLIC ::   lk_diamlr = .FALSE.
+
+   PUBLIC ::   dia_mlr_init, dia_mlr_iom_init, dia_mlr
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2019)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+   
+   SUBROUTINE dia_mlr_init
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE dia_mlr_init  ***
+      !!
+      !! ** Purpose : initialisation of IOM context management for 
+      !!              multiple-linear-regression analysis
+      !!
+      !!----------------------------------------------------------------------
+
+      lk_diamlr = .TRUE.
+
+      IF(lwp) THEN
+         WRITE(numout, *)
+         WRITE(numout, *) 'dia_mlr_init : initialisation of IOM context management for'
+         WRITE(numout, *) '~~~~~~~~~~~~   multiple-linear-regression analysis'
+      END IF
+
+   END SUBROUTINE dia_mlr_init
+
+   SUBROUTINE dia_mlr_iom_init
+      !!----------------------------------------------------------------------
+      !!               ***  ROUTINE dia_mlr_iom_init  ***
+      !!
+      !! ** Purpose : IOM context setup for multiple-linear-regression
+      !!              analysis
+      !!
+      !!----------------------------------------------------------------------
+
+      TYPE(xios_fieldgroup)                       ::   slxhdl_fldgrp
+      TYPE(xios_filegroup)                        ::   slxhdl_filgrp
+      TYPE(xios_field), ALLOCATABLE, DIMENSION(:) ::   slxhdl_regs,    slxhdl_flds
+      TYPE(xios_field)                            ::   slxhdl_fld
+      TYPE(xios_file)                             ::   slxhdl_fil
+      LOGICAL                                     ::   llxatt_enabled, llxatt_comment
+      CHARACTER(LEN=256)                          ::   clxatt_expr,    clxatt_comment
+      CHARACTER(LEN=32)                           ::   clxatt_name1,   clxatt_name2
+      CHARACTER(LEN=32)                           ::   clxatt_gridref, clxatt_fieldref
+      INTEGER, PARAMETER                          ::   jpscanmax = 999
+      INTEGER                                     ::   ireg, ifld
+      CHARACTER(LEN=3)                            ::   cl3i
+      CHARACTER(LEN=6)                            ::   cl6a
+      CHARACTER(LEN=7)                            ::   cl7a
+      CHARACTER(LEN=1)                            ::   clgt
+      CHARACTER(LEN=2)                            ::   clgd
+      CHARACTER(LEN=25)                           ::   clfloat
+      CHARACTER(LEN=32)                           ::   clrepl
+      INTEGER                                     ::   jl, jm, jn
+      INTEGER                                     ::   itide                       ! Number of available tidal components
+      REAL(wp)                                    ::   ztide_phase                 ! Tidal-constituent phase at adatrj=0
+      CHARACTER (LEN=4), DIMENSION(jpmax_harmo)   ::   ctide_selected = ' n/a '
+      TYPE(tide_harmonic), DIMENSION(:), POINTER  ::   stideconst
+
+      IF(lwp) THEN
+         WRITE(numout, *)
+         WRITE(numout, *) 'dia_mlr_iom_init : IOM context setup for multiple-linear-regression'
+         WRITE(numout, *) '~~~~~~~~~~~~~~~~'
+      END IF
+
+      ! Get handles to multiple-linear-regression analysis configuration (field
+      ! group 'diamrl_fields' and file group 'diamlr_files'); if no suitable
+      ! configuration is found, disable diamlr
+      IF ( lk_diamlr .AND. xios_is_valid_fieldgroup( "diamlr_fields" ) .AND. xios_is_valid_field( "diamlr_time" ) .AND.   &
+         & xios_is_valid_filegroup( "diamlr_files" ) ) THEN
+         CALL xios_get_handle("diamlr_fields", slxhdl_fldgrp)
+         CALL xios_get_handle("diamlr_files",  slxhdl_filgrp)
+      ELSE
+         IF (lwp) THEN
+            WRITE(numout, *) "diamlr: configuration not found or icomplete (field group 'diamlr_fields'"
+            WRITE(numout, *) "        and/or file group 'diamlr_files' and/or field 'diamlr_time' missing);"
+            WRITE(numout, *) "        disabling output for multiple-linear-regression analysis."
+         END IF
+         lk_diamlr = .FALSE.
+      END IF
+
+      ! Set up IOM context for multiple-linear-regression analysis
+      IF ( lk_diamlr ) THEN
+
+         ! Set up output files for grid types scalar, grid_T, grid_U, grid_V,
+         ! and grid_W
+         DO jm = 1, 5
+            SELECT CASE( jm )
+            CASE( 1 )
+               cl6a = 'scalar'
+            CASE( 2 )
+               cl6a = 'grid_T'
+            CASE( 3 )
+               cl6a = 'grid_U'
+            CASE( 4 )
+               cl6a = 'grid_V'
+            CASE( 5 )
+               cl6a = 'grid_W'
+            END SELECT
+            CALL xios_add_child      ( slxhdl_filgrp, slxhdl_fil, "diamlr_file_"//cl6a )
+            CALL xios_set_attr       ( slxhdl_fil, name_suffix="_diamlr_"//cl6a,   &
+               &                       description="Intermediate output for multiple-linear-regression analysis - "//cl6a )
+            CALL iom_update_file_name( "diamlr_file_"//cl6a )
+         END DO
+
+         ! Compile lists of active regressors and of fields selected for
+         ! analysis (fields "diamlr_r<nnn>" and "diamlr_f<nnn>", where <nnn> is
+         ! a 3-digit integer); also carry out placeholder substitution of tidal
+         ! parameters in regressor expressions
+         !
+         ALLOCATE( slxhdl_regs( jpscanmax ), slxhdl_flds( jpscanmax ) )
+         ireg = 0
+         ifld = 0
+         !
+         IF ( ln_tide ) THEN
+            ! Retrieve information (frequency, phase, nodal correction) about all
+            ! available tidal constituents for placeholder substitution below
+            ctide_selected(1:34) = (/ 'Mf', 'Mm', 'Ssa', 'Mtm', 'Msf',    &
+               &                      'Msqm', 'Sa', 'K1', 'O1', 'P1',     &
+               &                      'Q1', 'J1', 'S1', 'M2', 'S2', 'N2', &
+               &                      'K2', 'nu2', 'mu2', '2N2', 'L2',    &
+               &                      'T2', 'eps2', 'lam2', 'R2', 'M3',   &
+               &                      'MKS2', 'MN4', 'MS4', 'M4', 'N4',   &
+               &                      'S4', 'M6', 'M8' /)
+            CALL tide_init_harmonics(ctide_selected, stideconst)
+            itide = size(stideconst)
+         ELSE
+            itide = 0
+         ENDIF
+         
+         DO jm = 1, jpscanmax
+            WRITE (cl3i, '(i3.3)') jm
+
+            ! Look for regressor
+            IF ( xios_is_valid_field( "diamlr_r"//cl3i ) ) THEN
+
+               CALL xios_get_handle( "diamlr_r"//cl3i, slxhdl_regs(ireg+1) )
+               ! Retrieve pre-configured value of "enabled" attribute and
+               ! regressor expression
+               CALL xios_get_attr  ( slxhdl_regs(ireg+1), enabled=llxatt_enabled, expr=clxatt_expr )
+               ! If enabled, keep handle in list of active regressors; also
+               ! substitute placeholders for tidal frequencies, phases, and
+               ! nodal corrections in regressor expressions
+               IF ( llxatt_enabled ) THEN
+
+                  ! Substitution of placeholders for tidal-constituent
+                  ! parameters (amplitudes, angular veloccities, nodal phase
+                  ! correction) with values that have been obtained from the
+                  ! tidal-forcing implementation (if enabled)
+                  DO jn = 1, itide
+                     ! Compute phase of tidal constituent (incl. current nodal
+                     ! correction) at the start of the model run (i.e. for
+                     ! adatrj=0)
+                     ztide_phase = MOD( stideconst(jn)%u +  stideconst(jn)%v0 - adatrj * 86400.0_wp * stideconst(jn)%omega, &
+                        & 2.0_wp * rpi )
+                     clrepl = "__TDE_"//TRIM( stideconst(jn)%cname_tide )//"_omega__"
+                     DO WHILE ( INDEX( clxatt_expr, TRIM( clrepl ) ) > 0 )
+                        WRITE (clfloat, '(e25.18)') stideconst(jn)%omega
+                        jl = INDEX( clxatt_expr, TRIM( clrepl ) )
+                        clxatt_expr = clxatt_expr(1:jl - 1)//clfloat//   &
+                           &          clxatt_expr(jl + LEN( TRIM( clrepl ) ):LEN( TRIM( clxatt_expr ) ))
+                     END DO
+                     clrepl = "__TDE_"//TRIM( stideconst(jn)%cname_tide )//"_phase__"
+                     DO WHILE ( INDEX( clxatt_expr, TRIM( clrepl ) ) > 0 )
+                        WRITE (clfloat, '(e25.18)') ztide_phase
+                        jl = INDEX( clxatt_expr, TRIM( clrepl ) )
+                        clxatt_expr = clxatt_expr(1:jl - 1)//clfloat//   &
+                           &          clxatt_expr(jl + LEN( TRIM( clrepl ) ):LEN( TRIM( clxatt_expr ) ))
+                     END DO
+                     clrepl = "__TDE_"//TRIM( stideconst(jn)%cname_tide )//"_amplitude__"
+                     DO WHILE (INDEX( clxatt_expr, TRIM( clrepl ) ) > 0 )
+                        WRITE (clfloat, '(e25.18)') stideconst(jn)%f
+                        jl = INDEX( clxatt_expr, TRIM( clrepl ) )
+                        clxatt_expr = clxatt_expr(1:jl - 1)//clfloat//   &
+                           &          clxatt_expr(jl + LEN( TRIM( clrepl ) ):LEN( TRIM( clxatt_expr ) ))
+                     END DO
+                  END DO
+
+                  ! Set standard value for comment attribute, including possible
+                  ! existing comment added in parantheses
+                  CALL xios_is_defined_attr( slxhdl_regs(ireg+1), comment=llxatt_comment )
+                  IF ( llxatt_comment ) THEN
+                     CALL xios_get_attr( slxhdl_regs(ireg+1), comment=clxatt_comment )
+                     clxatt_comment = "Regressor "//cl3i//" ("//TRIM( clxatt_comment )//") "
+                  ELSE
+                     clxatt_comment = "Regressor "//cl3i
+                  END IF
+
+                  ! Set name attribute (and overwrite possible pre-configured
+                  ! name) with field id to enable id string retrieval from
+                  ! stored handle below, re-set expression with possible
+                  ! substitutions, and set or re-set comment attribute
+                  CALL xios_set_attr  ( slxhdl_regs(ireg+1), name="diamlr_r"//cl3i, expr=TRIM( clxatt_expr ),   &
+                     &                  comment=TRIM( clxatt_comment ) )
+
+                  ireg = ireg + 1   ! Accept regressor in list of active regressors
+
+               END IF
+            END IF
+
+            ! Look for field
+            IF ( xios_is_valid_field( "diamlr_f"//cl3i ) ) THEN
+
+               CALL xios_get_handle( "diamlr_f"//cl3i, slxhdl_flds(ifld+1) )
+               ! Retrieve pre-configured value of "enabled" attribute
+               CALL xios_get_attr  ( slxhdl_flds(ifld+1), enabled=llxatt_enabled )
+               ! If enabled, keep handle in list of fields selected for analysis
+               IF ( llxatt_enabled ) THEN
+                  
+                  ! Set name attribute (and overwrite possible pre-configured name)
+                  ! with field id to enable id string retrieval from stored handle
+                  ! below
+                  CALL xios_set_attr  ( slxhdl_flds(ifld+1), name="diamlr_f"//cl3i )
+
+                  ifld = ifld + 1   ! Accept field in list of fields selected for analysis
+
+               END IF
+            END IF
+
+         END DO
+
+         ! Output number of active regressors and fields selected for analysis
+         IF ( lwp ) WRITE(numout,'(a,i3,a)' ) 'diamlr: ', ireg, ' active regressors found'
+         IF ( lwp ) WRITE(numout,'(a,i3,a)' ) 'diamlr: ', ifld, ' fields selected for analysis'
+
+         ! Set up output of minimum, maximum, and average values of the time
+         ! variable available for the computation of regressors (diamlr_time)
+         CALL xios_get_handle( "diamlr_file_scalar", slxhdl_fil )
+         CALL xios_add_child ( slxhdl_fil, slxhdl_fld, "diamlr_time_average" )
+!$AGRIF_DO_NOT_TREAT
+         CALL xios_set_attr  ( slxhdl_fld, standard_name="diamlr_time",                          &
+            &                  long_name="Elapsed model time at start of regression interval",   &
+            &                  unit="s", operation="average", field_ref="diamlr_time",           &
+            &                  grid_ref="diamlr_grid_2D_to_scalar" )
+!$AGRIF_END_DO_NOT_TREAT
+         CALL xios_add_child ( slxhdl_fil, slxhdl_fld, "diamlr_time_minimum" )
+!$AGRIF_DO_NOT_TREAT
+         CALL xios_set_attr  ( slxhdl_fld, standard_name="diamlr_time",                          &
+            &                  long_name="Elapsed model time at start of regression interval",   &
+            &                  unit="s", operation="minimum", field_ref="diamlr_time",           &
+            &                  grid_ref="diamlr_grid_2D_to_scalar" )
+!$AGRIF_END_DO_NOT_TREAT
+         CALL xios_add_child ( slxhdl_fil, slxhdl_fld, "diamlr_time_maximum" )
+!$AGRIF_DO_NOT_TREAT
+         CALL xios_set_attr  ( slxhdl_fld, standard_name="diamlr_time",                          &
+            &                  long_name="Elapsed model time at start of regression interval",   &
+            &                  unit="s", operation="maximum", field_ref="diamlr_time",           &
+            &                  grid_ref="diamlr_grid_2D_to_scalar" )
+!$AGRIF_END_DO_NOT_TREAT
+
+         ! For each active regressor:
+         DO jm = 1, ireg
+
+            !   i) set up 2-dimensional and 3-dimensional versions of the
+            !      regressors; explicitely set "enabled" attribute; note, while
+            !      the scalar versions of regressors are part of the
+            !      configuration, the respective 2-dimensional versions take
+            !      over the defining expression, while the scalar and
+            !      3-dimensional versions are simply obtained via grid
+            !      transformations from the 2-dimensional version.
+            CALL xios_get_attr  ( slxhdl_regs( jm ), name=clxatt_name1, expr=clxatt_expr,              &
+               &                  enabled=llxatt_enabled, comment=clxatt_comment )
+            CALL xios_add_child ( slxhdl_fldgrp, slxhdl_fld, TRIM( clxatt_name1 )//"_grid_T_2D" )
+            CALL xios_set_attr  ( slxhdl_fld, expr=TRIM( clxatt_expr ), grid_ref="diamlr_grid_T_2D",     &
+               &                  field_ref="diamlr_time", enabled=llxatt_enabled )
+            CALL xios_add_child ( slxhdl_fldgrp, slxhdl_fld, TRIM( clxatt_name1 )//"_grid_U_2D" )
+            CALL xios_set_attr  ( slxhdl_fld, expr=TRIM( clxatt_expr ), grid_ref="diamlr_grid_U_2D",     &
+               &                  field_ref="diamlr_time", enabled=llxatt_enabled )
+            CALL xios_add_child ( slxhdl_fldgrp, slxhdl_fld, TRIM( clxatt_name1 )//"_grid_V_2D" )
+            CALL xios_set_attr  ( slxhdl_fld, expr=TRIM( clxatt_expr ), grid_ref="diamlr_grid_V_2D",     &
+               &                  field_ref="diamlr_time", enabled=llxatt_enabled )
+            CALL xios_add_child ( slxhdl_fldgrp, slxhdl_fld, TRIM( clxatt_name1 )//"_grid_W_2D" )
+            CALL xios_set_attr  ( slxhdl_fld, expr=TRIM( clxatt_expr ), grid_ref="diamlr_grid_W_2D",     &
+               &                  field_ref="diamlr_time", enabled=llxatt_enabled )
+            CALL xios_add_child ( slxhdl_fldgrp, slxhdl_fld, TRIM( clxatt_name1 )//"_grid_T_3D")
+            CALL xios_set_attr  ( slxhdl_fld, expr="this", grid_ref="diamlr_grid_2D_to_grid_T_3D",            &
+               &                  field_ref=TRIM( clxatt_name1 )//"_grid_T_2D", enabled=llxatt_enabled)
+            CALL xios_add_child ( slxhdl_fldgrp, slxhdl_fld, TRIM( clxatt_name1 )//"_grid_U_3D")
+            CALL xios_set_attr  ( slxhdl_fld, expr="this", grid_ref="diamlr_grid_2D_to_grid_U_3D",            &
+               &                  field_ref=TRIM( clxatt_name1 )//"_grid_U_2D", enabled=llxatt_enabled)
+            CALL xios_add_child ( slxhdl_fldgrp, slxhdl_fld, TRIM( clxatt_name1 )//"_grid_V_3D")
+            CALL xios_set_attr  ( slxhdl_fld, expr="this", grid_ref="diamlr_grid_2D_to_grid_V_3D",            &
+               &                  field_ref=TRIM( clxatt_name1 )//"_grid_V_2D", enabled=llxatt_enabled)
+            CALL xios_add_child ( slxhdl_fldgrp, slxhdl_fld, TRIM( clxatt_name1 )//"_grid_W_3D")
+            CALL xios_set_attr  ( slxhdl_fld, expr="this", grid_ref="diamlr_grid_2D_to_grid_W_3D",            &
+               &                  field_ref=TRIM( clxatt_name1 )//"_grid_W_2D", enabled=llxatt_enabled)
+            CALL xios_set_attr  ( slxhdl_regs(jm), expr="this", grid_ref="diamlr_grid_2D_to_scalar",   &
+               &                  field_ref=TRIM( clxatt_name1 )//"_grid_T_2D", enabled=llxatt_enabled)
+
+            !  ii) set up output of active regressors, including metadata
+            CALL xios_get_handle( "diamlr_file_scalar", slxhdl_fil )
+            ! Add regressor to output file
+            CALL xios_add_child ( slxhdl_fil, slxhdl_fld, TRIM( clxatt_name1 ) )
+            CALL xios_set_attr  ( slxhdl_fld, standard_name=TRIM( clxatt_comment ), long_name=TRIM( clxatt_expr ),   &
+               &                  operation="average" )
+               
+            ! iii) set up the output of scalar products with itself and with
+            !      other active regressors
+            CALL xios_get_attr  ( slxhdl_regs(jm), name=clxatt_name1 )
+            DO jn = 1, jm
+               ! Field for product between regressors
+               CALL xios_get_attr  ( slxhdl_regs(jn), name=clxatt_name2 )
+               CALL xios_add_child ( slxhdl_fldgrp, slxhdl_fld, TRIM( clxatt_name1 )//"."//TRIM( clxatt_name2 ) )
+               ! Set appropriate name attribute to avoid the possibility of
+               ! using an inappropriate inherited name attribute as the variable
+               ! name in the output file
+               CALL xios_set_attr  ( slxhdl_fld,                                                        &
+                  &                  name=TRIM( clxatt_name1 )//"."//TRIM( clxatt_name2 ),              &
+                  &                  grid_ref="diamlr_grid_scalar",                                     &
+                  &                  expr="this * "//TRIM( clxatt_name2 ),                              &
+                  &                  field_ref=TRIM( clxatt_name1 ),                                    &
+                  &                  enabled=llxatt_enabled,                                            &
+                  &                  long_name="Scalar product of regressor "//TRIM( clxatt_name1 )//   &
+                  &                     " and regressor "//TRIM( clxatt_name2 ),                        &
+                  &                  standard_name=TRIM( clxatt_name1 )//"."//TRIM( clxatt_name2 ),     &
+                  &                  operation="accumulate")
+               ! Add regressor-product field to output file
+               CALL xios_add_child ( slxhdl_fil, slxhdl_fld, TRIM( clxatt_name1 )//"."//TRIM( clxatt_name2 ) )
+            END DO
+
+            !  iv) set up definitions for the output of scalar products with
+            !      fields selected for analysis
+            DO jn = 1, ifld
+               CALL xios_get_attr  ( slxhdl_flds(jn), name=clxatt_name2, field_ref=clxatt_fieldref )
+               CALL xios_get_handle( TRIM( clxatt_fieldref ), slxhdl_fld )
+               CALL xios_get_attr  ( slxhdl_fld, grid_ref=clxatt_gridref )
+               clgt="T"
+               IF ( INDEX( clxatt_gridref, "_U_" ) > 0 ) clgt="U"
+               IF ( INDEX( clxatt_gridref, "_V_" ) > 0 ) clgt="V"
+               IF ( INDEX( clxatt_gridref, "_W_" ) > 0 ) clgt="W"
+               clgd="2D"
+               cl7a=""
+               IF ( INDEX( clxatt_gridref, "_3D" ) > 0 ) THEN
+                  clgd="3D"
+               ELSE
+                  cl7a="diamlr_"
+               END IF
+               CALL xios_add_child ( slxhdl_fldgrp, slxhdl_fld, TRIM( clxatt_name2 )//"."//TRIM( clxatt_name1 ) )
+               ! Set appropriate name attribute to avoid the possibility of
+               ! using an inappropriate inherited name attribute as the variable
+               ! name in the output file; use metadata (standard_name and
+               ! long_name) to refer to the id of the analysed field
+               CALL xios_set_attr  ( slxhdl_fld,                                                         &
+                  &                  name=TRIM( clxatt_name2 )//"."//TRIM( clxatt_name1 ),               &
+                  &                  expr="this * "//TRIM( clxatt_fieldref ),                            &
+                  &                  grid_ref=cl7a//"grid_"//clgt//"_"//clgd,                                      &
+                  &                  field_ref=TRIM( clxatt_name1 )//"_grid_"//clgt//"_"//clgd,          &
+                  &                  enabled=llxatt_enabled,                                             &
+                  &                  long_name="Scalar product of "//TRIM( clxatt_fieldref )//           &
+                  &                     " and regressor "//TRIM( clxatt_name1 ),                         &
+                  &                  standard_name=TRIM( clxatt_fieldref )//"."//TRIM( clxatt_name1 ),   &
+                  &                  operation="accumulate" )
+               CALL xios_get_handle( "diamlr_file_grid_"//clgt, slxhdl_fil )
+               CALL xios_add_child ( slxhdl_fil, slxhdl_fld, TRIM( clxatt_name2 )//"."//TRIM( clxatt_name1 ) )
+            END DO
+
+         END DO
+
+         ! Release list of active regressors and fields selected for analysis
+         DEALLOCATE( slxhdl_regs, slxhdl_flds )
+
+      END IF
+
+   END SUBROUTINE dia_mlr_iom_init
+
+   SUBROUTINE dia_mlr
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE dia_mlr  ***
+      !!
+      !! ** Purpose : update time used in multiple-linear-regression analysis
+      !!
+      !!----------------------------------------------------------------------
+
+      REAL(wp), DIMENSION(jpi,jpj) ::   zadatrj2d
+
+      IF( ln_timing )   CALL timing_start('dia_mlr')
+
+      ! Update time to the continuous time since the start of the model run
+      ! (value of adatrj converted to time in units of seconds)
+      !
+      ! A 2-dimensional field of constant value is sent, and subsequently used
+      ! directly or transformed to a scalar or a constant 3-dimensional field as
+      ! required.
+      zadatrj2d(:,:) = adatrj*86400.0_wp
+      IF ( iom_use('diamlr_time') ) CALL iom_put('diamlr_time', zadatrj2d)
+      
+      IF( ln_timing )   CALL timing_stop('dia_mlr')
+
+   END SUBROUTINE dia_mlr
+
+END MODULE diamlr
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/DYN/dynspg.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/DYN/dynspg.F90	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/DYN/dynspg.F90	(revision 12184)
@@ -21,6 +21,5 @@
    USE dynspg_exp     ! surface pressure gradient     (dyn_spg_exp routine)
    USE dynspg_ts      ! surface pressure gradient     (dyn_spg_ts  routine)
-   USE sbctide        ! 
-   USE updtide        ! 
+   USE tide_mod       !
    USE trd_oce        ! trends: ocean variables
    USE trddyn         ! trend manager: dynamics
@@ -43,4 +42,6 @@
    INTEGER, PARAMETER ::   np_EXP = 0   !       explicit time stepping
    INTEGER, PARAMETER ::   np_NO  =-1   ! no surface pressure gradient, no scheme
+   !
+   REAL(wp) ::   zt0step !   Time of day at the beginning of the time step
 
    !! * Substitutions
@@ -113,5 +114,7 @@
          IF( .NOT.ln_dynspg_ts .AND. ( ln_tide_pot .AND. ln_tide )  ) THEN   ! N.B. added directly at sub-time-step in ts-case
             !
-            CALL upd_tide( kt )                      ! update tide potential
+            ! Update tide potential at the beginning of current time step
+            zt0step = REAL(nsec_day, wp)-0.5_wp*rdt
+            CALL upd_tide(zt0step)
             !
             DO jj = 2, jpjm1                         ! add tide potential forcing
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/DYN/dynspg_ts.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/DYN/dynspg_ts.F90	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/DYN/dynspg_ts.F90	(revision 12184)
@@ -44,6 +44,5 @@
    USE bdytides        ! open boundary condition data
    USE bdydyn2d        ! open boundary conditions on barotropic variables
-   USE sbctide         ! tides
-   USE updtide         ! tide potential
+   USE tide_mod        !
    USE sbcwave         ! surface wave
    USE diatmb          ! Top,middle,bottom output
@@ -170,4 +169,5 @@
       REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: ztwdmask, zuwdmask, zvwdmask ! ROMS wetting and drying masks at t,u,v points
       REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: zuwdav2, zvwdav2    ! averages over the sub-steps of zuwdmask and zvwdmask
+      REAL(wp) ::   zt0substep !   Time of day at the beginning of the time substep
       !!----------------------------------------------------------------------
       !
@@ -442,5 +442,9 @@
          !
          IF( ln_bdy      .AND. ln_tide )   CALL bdy_dta_tides( kt, kit=jn, kt_offset= noffset+1 )
-         IF( ln_tide_pot .AND. ln_tide )   CALL upd_tide     ( kt, kit=jn, kt_offset= noffset   )
+         ! Update tide potential at the beginning of current time substep
+         IF( ln_tide_pot .AND. ln_tide ) THEN
+            zt0substep = REAL(nsec_day, wp) - 0.5_wp*rdt + (jn + noffset - 1) * rdt / REAL(nn_baro, wp)
+            CALL upd_tide(zt0substep)
+         END IF
          !
          !                    !==  extrapolation at mid-step  ==!   (jn+1/2)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/IOM/iom.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/IOM/iom.F90	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/IOM/iom.F90	(revision 12184)
@@ -56,7 +56,7 @@
    LOGICAL, PUBLIC, PARAMETER ::   lk_iomput = .FALSE.       !: iom_put flag
 #endif
-   PUBLIC iom_init, iom_swap, iom_open, iom_close, iom_setkt, iom_varid, iom_get, iom_get_var
+   PUBLIC iom_init, iom_init_closedef, iom_swap, iom_open, iom_close, iom_setkt, iom_varid, iom_get, iom_get_var
    PUBLIC iom_chkatt, iom_getatt, iom_putatt, iom_getszuld, iom_rstput, iom_delay_rst, iom_put
-   PUBLIC iom_use, iom_context_finalize, iom_miss_val
+   PUBLIC iom_use, iom_context_finalize, iom_update_file_name, iom_miss_val
 
    PRIVATE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d
@@ -65,5 +65,5 @@
 #if defined key_iomput
    PRIVATE iom_set_domain_attr, iom_set_axis_attr, iom_set_field_attr, iom_set_file_attr, iom_get_file_attr, iom_set_grid_attr
-   PRIVATE set_grid, set_grid_bounds, set_scalar, set_xmlatt, set_mooring, iom_update_file_name, iom_sdate
+   PRIVATE set_grid, set_grid_bounds, set_scalar, set_xmlatt, set_mooring, iom_sdate
    PRIVATE iom_set_rst_context, iom_set_rstw_active, iom_set_rstr_active
 # endif
@@ -93,5 +93,5 @@
 CONTAINS
 
-   SUBROUTINE iom_init( cdname, fname, ld_tmppatch ) 
+   SUBROUTINE iom_init( cdname, fname, ld_tmppatch, ld_closedef ) 
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE   ***
@@ -103,4 +103,5 @@
       CHARACTER(len=*), OPTIONAL, INTENT(in)  :: fname
       LOGICAL         , OPTIONAL, INTENT(in)  :: ld_tmppatch
+      LOGICAL         , OPTIONAL, INTENT(in)  :: ld_closedef
 #if defined key_iomput
       !
@@ -117,4 +118,5 @@
       INTEGER ::   nldi_save, nlei_save    !:      and close boundaries in output files
       INTEGER ::   nldj_save, nlej_save    !:
+      LOGICAL ::   ll_closedef = .TRUE.
       !!----------------------------------------------------------------------
       !
@@ -131,4 +133,5 @@
          IF( njmpp + jpj - 1 == jpjglo ) nlej = jpj
       ENDIF
+      IF ( PRESENT(ld_closedef) ) ll_closedef = ld_closedef
       !
       ALLOCATE( zt_bnds(2,jpk), zw_bnds(2,jpk) )
@@ -269,9 +272,10 @@
       ENDIF
       !
-      ! end file definition
+      ! set time step length
       dtime%second = rdt
       CALL xios_set_timestep( dtime )
-      CALL xios_close_context_definition()
-      CALL xios_update_calendar( 0 )
+      !
+      ! conditional closure of context definition
+      IF ( ll_closedef ) CALL iom_init_closedef
       !
       DEALLOCATE( zt_bnds, zw_bnds )
@@ -284,4 +288,18 @@
       !
    END SUBROUTINE iom_init
+
+   SUBROUTINE iom_init_closedef
+      !!----------------------------------------------------------------------
+      !!            ***  SUBROUTINE iom_init_closedef  ***
+      !!----------------------------------------------------------------------
+      !!
+      !! ** Purpose : Closure of context definition
+      !!
+      !!----------------------------------------------------------------------
+
+      CALL xios_close_context_definition()
+      CALL xios_update_calendar( 0 )
+
+   END SUBROUTINE iom_init_closedef
 
    SUBROUTINE iom_set_rstw_var_active(field)
Index: MO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/SBC/sbctide.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/SBC/sbctide.F90	(revision 12183)
+++ 	(revision )
@@ -1,168 +1,0 @@
-MODULE sbctide
-   !!======================================================================
-   !!                       ***  MODULE  sbctide  ***
-   !! Initialization of tidal forcing
-   !!======================================================================
-   !! History :  9.0  !  2007  (O. Le Galloudec)  Original code
-   !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and tracers variables
-   USE dom_oce        ! ocean space and time domain
-   USE phycst         ! physical constant
-   USE daymod         ! calandar
-   USE tideini        ! 
-   !
-   USE in_out_manager ! I/O units
-   USE iom            ! xIOs server
-   USE ioipsl         ! NetCDF IPSL library
-   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
-
-   IMPLICIT NONE
-   PUBLIC
-
-   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) ::   pot_astro   !
-
-   !!----------------------------------------------------------------------
-   !!   tidal potential
-   !!----------------------------------------------------------------------
-   !!   sbc_tide            : 
-   !!   tide_init_potential :
-   !!----------------------------------------------------------------------
-
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   amp_pot, phi_pot
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   amp_load, phi_load
- 
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id$
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE sbc_tide( kt )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE sbc_tide  ***
-      !!----------------------------------------------------------------------      
-      INTEGER, INTENT( in ) ::   kt     ! ocean time-step
-      INTEGER               ::   jk     ! dummy loop index
-      INTEGER               ::   nsec_day_orig     ! Temporary variable
-      !!----------------------------------------------------------------------
-      
-      IF( nsec_day == NINT(0.5_wp * rdt) .OR. kt == nit000 ) THEN      ! start a new day
-         !
-         IF( kt == nit000 )THEN
-            ALLOCATE( amp_pot(jpi,jpj,nb_harmo),                      &
-               &      phi_pot(jpi,jpj,nb_harmo), pot_astro(jpi,jpj)   )
-            IF( ln_read_load )THEN
-               ALLOCATE( amp_load(jpi,jpj,nb_harmo), phi_load(jpi,jpj,nb_harmo) )
-               CALL tide_init_load
-            ENDIF
-         ENDIF
-         !
-         IF( ln_read_load )THEN
-            amp_pot(:,:,:) = amp_load(:,:,:)
-            phi_pot(:,:,:) = phi_load(:,:,:)
-         ELSE 
-            amp_pot(:,:,:) = 0._wp
-            phi_pot(:,:,:) = 0._wp
-         ENDIF
-         pot_astro(:,:) = 0._wp
-         !
-         ! If the run does not start from midnight then need to initialise tides
-         ! at the start of the current day (only occurs when kt==nit000)
-         ! Temporarily set nsec_day to beginning of day.
-         nsec_day_orig = nsec_day
-         IF( nsec_day /= NINT(0.5_wp * rdt) ) THEN 
-            kt_tide = kt - (nsec_day - 0.5_wp * rdt)/rdt
-            nsec_day = NINT(0.5_wp * rdt)
-         ELSE
-            kt_tide = kt 
-         ENDIF
-         CALL tide_harmo( omega_tide, v0tide, utide, ftide, ntide, nb_harmo )
-         !
-         !
-         IF(lwp) THEN
-            WRITE(numout,*)
-            WRITE(numout,*) 'sbc_tide : Update of the components and (re)Init. the potential at kt=', kt
-            WRITE(numout,*) '~~~~~~~~ '
-            DO jk = 1, nb_harmo
-               WRITE(numout,*) Wave(ntide(jk))%cname_tide, utide(jk), ftide(jk), v0tide(jk), omega_tide(jk)
-            END DO
-         ENDIF
-         !
-         IF( ln_tide_pot )   CALL tide_init_potential
-         !
-         ! Reset nsec_day
-         nsec_day = nsec_day_orig 
-      ENDIF
-      !
-   END SUBROUTINE sbc_tide
-
-
-   SUBROUTINE tide_init_potential
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE tide_init_potential  ***
-      !!----------------------------------------------------------------------
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zcons, ztmp1, ztmp2, zlat, zlon, ztmp, zamp, zcs   ! local scalar
-      !!----------------------------------------------------------------------
-
-      DO jk = 1, nb_harmo
-         zcons = 0.7_wp * Wave(ntide(jk))%equitide * ftide(jk)
-         DO ji = 1, jpi
-            DO jj = 1, jpj
-               ztmp1 =  ftide(jk) * amp_pot(ji,jj,jk) * COS( phi_pot(ji,jj,jk) + v0tide(jk) + utide(jk) )
-               ztmp2 = -ftide(jk) * amp_pot(ji,jj,jk) * SIN( phi_pot(ji,jj,jk) + v0tide(jk) + utide(jk) )
-               zlat = gphit(ji,jj)*rad !! latitude en radian
-               zlon = glamt(ji,jj)*rad !! longitude en radian
-               ztmp = v0tide(jk) + utide(jk) + Wave(ntide(jk))%nutide * zlon
-               ! le potentiel est composé des effets des astres:
-               IF    ( Wave(ntide(jk))%nutide == 1 )  THEN  ;  zcs = zcons * SIN( 2._wp*zlat )
-               ELSEIF( Wave(ntide(jk))%nutide == 2 )  THEN  ;  zcs = zcons * COS( zlat )**2
-               ELSE                                         ;  zcs = 0._wp
-               ENDIF
-               ztmp1 = ztmp1 + zcs * COS( ztmp )
-               ztmp2 = ztmp2 - zcs * SIN( ztmp )
-               zamp = SQRT( ztmp1*ztmp1 + ztmp2*ztmp2 )
-               amp_pot(ji,jj,jk) = zamp
-               phi_pot(ji,jj,jk) = ATAN2( -ztmp2 / MAX( 1.e-10_wp , zamp ) ,   &
-                  &                        ztmp1 / MAX( 1.e-10_wp,  zamp )   )
-            END DO
-         END DO
-      END DO
-      !
-   END SUBROUTINE tide_init_potential
-
-   SUBROUTINE tide_init_load
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE tide_init_load  ***
-      !!----------------------------------------------------------------------
-      INTEGER :: inum                 ! Logical unit of input file
-      INTEGER :: ji, jj, itide        ! dummy loop indices
-      REAL(wp), DIMENSION(jpi,jpj) ::   ztr, zti   !: workspace to read in tidal harmonics data 
-      !!----------------------------------------------------------------------
-      IF(lwp) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) 'tide_init_load : Initialization of load potential from file'
-         WRITE(numout,*) '~~~~~~~~~~~~~~ '
-      ENDIF
-      !
-      CALL iom_open ( cn_tide_load , inum )
-      !
-      DO itide = 1, nb_harmo
-         CALL iom_get  ( inum, jpdom_data,TRIM(Wave(ntide(itide))%cname_tide)//'_z1', ztr(:,:) )
-         CALL iom_get  ( inum, jpdom_data,TRIM(Wave(ntide(itide))%cname_tide)//'_z2', zti(:,:) )
-         !
-         DO ji=1,jpi
-            DO jj=1,jpj
-               amp_load(ji,jj,itide) =  SQRT( ztr(ji,jj)**2. + zti(ji,jj)**2. )
-               phi_load(ji,jj,itide) = ATAN2(-zti(ji,jj), ztr(ji,jj) )
-            END DO
-         END DO
-         !
-      END DO
-      CALL iom_close( inum )
-      !
-   END SUBROUTINE tide_init_load
-
-  !!======================================================================
-END MODULE sbctide
Index: MO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/SBC/tide.h90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/SBC/tide.h90	(revision 12183)
+++ 	(revision )
@@ -1,29 +1,0 @@
-   !!----------------------------------------------------------------------
-   !! History :  3.2  !  2007  (O. Le Galloudec)  Original code
-   !!----------------------------------------------------------------------
-
-   !             !! name_tide , equitide , nutide , nt , ns , nh , np , np1 , shift , nksi , nnu0 , nnu1 , nnu2 , R , formula !!
-   !             !!           !          !        !    !    !    !    !     !       !      !      !      !      !   !         !!
-   Wave( 1) = tide(  'M2'     , 0.242297 ,    2   ,  2 , -2 ,  2 ,  0 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,    78   )
-   Wave( 2) = tide(  'N2'     , 0.046313 ,    2   ,  2 , -3 ,  2 ,  1 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,    78   )
-   Wave( 3) = tide( '2N2'     , 0.006184 ,    2   ,  2 , -4 ,  2 ,  2 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,    78   )
-   Wave( 4) = tide(  'S2'     , 0.113572 ,    2   ,  2 ,  0 ,  0 ,  0 ,  0  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,     0   )
-   Wave( 5) = tide(  'K2'     , 0.030875 ,    2   ,  2 ,  0 ,  2 ,  0 ,  0  ,    0  ,  0   ,  0   ,  0   , -2   , 0 ,   235   )
-   !              !           !          !        !    !    !    !    !     !       !      !      !      !      !   !         !
-   Wave( 6) = tide(  'K1'     , 0.142408 ,    1   ,  1 ,  0 ,  1 ,  0 ,  0  ,  -90  ,  0   ,  0   , -1   ,  0   , 0 ,   227   )
-   Wave( 7) = tide(  'O1'     , 0.101266 ,    1   ,  1 , -2 ,  1 ,  0 ,  0  ,  +90  ,  2   , -1   ,  0   ,  0   , 0 ,    75   )
-   Wave( 8) = tide(  'Q1'     , 0.019387 ,    1   ,  1 , -3 ,  1 ,  1 ,  0  ,  +90  ,  2   , -1   ,  0   ,  0   , 0 ,    75   )
-   Wave( 9) = tide(  'P1'     , 0.047129 ,    1   ,  1 ,  0 , -1 ,  0 ,  0  ,  +90  ,  0   ,  0   ,  0   ,  0   , 0 ,    0    )
-   !              !           !          !        !    !    !    !    !     !       !      !      !      !      !   !         !
-   Wave(10) = tide(  'M4'     , 0.000000 ,    4   ,  4 , -4 ,  4 ,  0 ,  0  ,    0  ,  4   , -4   ,  0   ,  0   , 0 ,    1    )
-   !              !           !          !        !    !    !    !    !     !       !      !      !      !      !   !         !
-   Wave(11) = tide(  'Mf'     , 0.042017 ,    0   ,  0 ,  2 ,  0 ,  0 ,  0  ,    0  , -2   ,  0   ,  0   ,  0   , 0 ,   74    )
-   Wave(12) = tide(  'Mm'     , 0.022191 ,    0   ,  0 ,  1 ,  0 , -1 ,  0  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,   73    )
-   Wave(13) = tide(  'Msqm'   , 0.000667 ,    0   ,  0 ,  4 , -2 ,  0 ,  0  ,    0  , -2   ,  0   ,  0   ,  0   , 0 ,   74    )
-   Wave(14) = tide(  'Mtm'    , 0.008049 ,    0   ,  0 ,  3 ,  0 , -1 ,  0  ,    0  , -2   ,  0   ,  0   ,  0   , 0 ,   74    )
-   !              !           !          !        !    !    !    !    !     !       !      !      !      !      !   !         !
-   Wave(15) = tide(  'S1'     , 0.000000 ,    1   ,  1 ,  0 ,  0 ,  0 ,  0  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,    0    )   
-   Wave(16) = tide(  'MU2'    , 0.005841 ,    2   ,  2 , -4 ,  4 ,  0 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,   78    )
-   Wave(17) = tide(  'NU2'    , 0.009094 ,    2   ,  2 , -3 ,  4 , -1 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,   78    ) 
-   Wave(18) = tide(  'L2'     , 0.006694 ,    2   ,  2 , -1 ,  2 , -1 ,  0  , +180  ,  2   , -2   ,  0   ,  0   , 0 ,  215    )
-   Wave(19) = tide(  'T2'     , 0.006614 ,    2   ,  2 ,  0 , -1 ,  0 ,  1  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,    0    )
Index: MO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/SBC/tide_mod.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/SBC/tide_mod.F90	(revision 12183)
+++ 	(revision )
@@ -1,411 +1,0 @@
-MODULE tide_mod
-   !!======================================================================
-   !!                       ***  MODULE  tide_mod  ***
-   !! Compute nodal modulations corrections and pulsations
-   !!======================================================================
-   !! History :  1.0  !  2007  (O. Le Galloudec)  Original code
-   !!----------------------------------------------------------------------
-   USE dom_oce        ! ocean space and time domain
-   USE phycst         ! physical constant
-   USE daymod         ! calendar
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   tide_harmo       ! called by tideini and diaharm modules
-   PUBLIC   tide_init_Wave   ! called by tideini and diaharm modules
-
-   INTEGER, PUBLIC, PARAMETER ::   jpmax_harmo = 19   !: maximum number of harmonic
-
-   TYPE, PUBLIC ::    tide
-      CHARACTER(LEN=4) ::   cname_tide
-      REAL(wp)         ::   equitide
-      INTEGER          ::   nutide
-      INTEGER          ::   nt, ns, nh, np, np1, shift
-      INTEGER          ::   nksi, nnu0, nnu1, nnu2, R
-      INTEGER          ::   nformula
-   END TYPE tide
-
-   TYPE(tide), PUBLIC, DIMENSION(jpmax_harmo) ::   Wave   !:
-
-   REAL(wp) ::   sh_T, sh_s, sh_h, sh_p, sh_p1             ! astronomic angles
-   REAL(wp) ::   sh_xi, sh_nu, sh_nuprim, sh_nusec, sh_R   !
-   REAL(wp) ::   sh_I, sh_x1ra, sh_N                       !
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id$ 
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE tide_init_Wave
-#     include "tide.h90"
-   END SUBROUTINE tide_init_Wave
-
-
-   SUBROUTINE tide_harmo( pomega, pvt, put , pcor, ktide ,kc)
-      !!----------------------------------------------------------------------
-      !!----------------------------------------------------------------------
-      INTEGER , DIMENSION(kc), INTENT(in ) ::   ktide            ! Indice of tidal constituents
-      INTEGER                , INTENT(in ) ::   kc               ! Total number of tidal constituents
-      REAL(wp), DIMENSION(kc), INTENT(out) ::   pomega           ! pulsation in radians/s
-      REAL(wp), DIMENSION(kc), INTENT(out) ::   pvt, put, pcor   !
-      !!----------------------------------------------------------------------
-      !
-      CALL astronomic_angle
-      CALL tide_pulse( pomega, ktide ,kc )
-      CALL tide_vuf  ( pvt, put, pcor, ktide ,kc )
-      !
-   END SUBROUTINE tide_harmo
-
-
-   SUBROUTINE astronomic_angle
-      !!----------------------------------------------------------------------
-      !!  tj is time elapsed since 1st January 1900, 0 hour, counted in julian
-      !!  century (e.g. time in days divide by 36525)
-      !!----------------------------------------------------------------------
-      REAL(wp) ::   cosI, p, q, t2, t4, sin2I, s2, tgI2, P1, sh_tgn2, at1, at2
-      REAL(wp) ::   zqy , zsy, zday, zdj, zhfrac
-      !!----------------------------------------------------------------------
-      !
-      zqy = AINT( (nyear-1901.)/4. )
-      zsy = nyear - 1900.
-      !
-      zdj  = dayjul( nyear, nmonth, nday )
-      zday = zdj + zqy - 1.
-      !
-      zhfrac = nsec_day / 3600.
-      !
-      !----------------------------------------------------------------------
-      !  Sh_n Longitude of ascending lunar node
-      !----------------------------------------------------------------------
-      sh_N=(259.1560564-19.328185764*zsy-.0529539336*zday-.0022064139*zhfrac)*rad
-      !----------------------------------------------------------------------
-      ! T mean solar angle (Greenwhich time)
-      !----------------------------------------------------------------------
-      sh_T=(180.+zhfrac*(360./24.))*rad
-      !----------------------------------------------------------------------
-      ! h mean solar Longitude
-      !----------------------------------------------------------------------
-      sh_h=(280.1895014-.238724988*zsy+.9856473288*zday+.0410686387*zhfrac)*rad
-      !----------------------------------------------------------------------
-      ! s mean lunar Longitude
-      !----------------------------------------------------------------------
-      sh_s=(277.0256206+129.38482032*zsy+13.176396768*zday+.549016532*zhfrac)*rad
-      !----------------------------------------------------------------------
-      ! p1 Longitude of solar perigee
-      !----------------------------------------------------------------------
-      sh_p1=(281.2208569+.01717836*zsy+.000047064*zday+.000001961*zhfrac)*rad
-      !----------------------------------------------------------------------
-      ! p Longitude of lunar perigee
-      !----------------------------------------------------------------------
-      sh_p=(334.3837214+40.66246584*zsy+.111404016*zday+.004641834*zhfrac)*rad
-
-      sh_N = MOD( sh_N ,2*rpi )
-      sh_s = MOD( sh_s ,2*rpi )
-      sh_h = MOD( sh_h, 2*rpi )
-      sh_p = MOD( sh_p, 2*rpi )
-      sh_p1= MOD( sh_p1,2*rpi )
-
-      cosI = 0.913694997 -0.035692561 *cos(sh_N)
-
-      sh_I = ACOS( cosI )
-
-      sin2I   = sin(sh_I)
-      sh_tgn2 = tan(sh_N/2.0)
-
-      at1=atan(1.01883*sh_tgn2)
-      at2=atan(0.64412*sh_tgn2)
-
-      sh_xi=-at1-at2+sh_N
-
-      IF( sh_N > rpi )   sh_xi=sh_xi-2.0*rpi
-
-      sh_nu = at1 - at2
-
-      !----------------------------------------------------------------------
-      ! For constituents l2 k1 k2
-      !----------------------------------------------------------------------
-
-      tgI2 = tan(sh_I/2.0)
-      P1   = sh_p-sh_xi
-
-      t2 = tgI2*tgI2
-      t4 = t2*t2
-      sh_x1ra = sqrt( 1.0-12.0*t2*cos(2.0*P1)+36.0*t4 )
-
-      p = sin(2.0*P1)
-      q = 1.0/(6.0*t2)-cos(2.0*P1)
-      sh_R = atan(p/q)
-
-      p = sin(2.0*sh_I)*sin(sh_nu)
-      q = sin(2.0*sh_I)*cos(sh_nu)+0.3347
-      sh_nuprim = atan(p/q)
-
-      s2 = sin(sh_I)*sin(sh_I)
-      p  = s2*sin(2.0*sh_nu)
-      q  = s2*cos(2.0*sh_nu)+0.0727
-      sh_nusec = 0.5*atan(p/q)
-      !
-   END SUBROUTINE astronomic_angle
-
-
-   SUBROUTINE tide_pulse( pomega, ktide ,kc )
-      !!----------------------------------------------------------------------
-      !!                     ***  ROUTINE tide_pulse  ***
-      !!                      
-      !! ** Purpose : Compute tidal frequencies
-      !!----------------------------------------------------------------------
-      INTEGER                , INTENT(in ) ::   kc       ! Total number of tidal constituents
-      INTEGER , DIMENSION(kc), INTENT(in ) ::   ktide    ! Indice of tidal constituents
-      REAL(wp), DIMENSION(kc), INTENT(out) ::   pomega   ! pulsation in radians/s
-      !
-      INTEGER  ::   jh
-      REAL(wp) ::   zscale
-      REAL(wp) ::   zomega_T =  13149000.0_wp
-      REAL(wp) ::   zomega_s =    481267.892_wp
-      REAL(wp) ::   zomega_h =     36000.76892_wp
-      REAL(wp) ::   zomega_p =      4069.0322056_wp
-      REAL(wp) ::   zomega_n =      1934.1423972_wp
-      REAL(wp) ::   zomega_p1=         1.719175_wp
-      !!----------------------------------------------------------------------
-      !
-      zscale =  rad / ( 36525._wp * 86400._wp ) 
-      !
-      DO jh = 1, kc
-         pomega(jh) = (  zomega_T * Wave( ktide(jh) )%nT   &
-            &          + zomega_s * Wave( ktide(jh) )%ns   &
-            &          + zomega_h * Wave( ktide(jh) )%nh   &
-            &          + zomega_p * Wave( ktide(jh) )%np   &
-            &          + zomega_p1* Wave( ktide(jh) )%np1  ) * zscale
-      END DO
-      !
-   END SUBROUTINE tide_pulse
-
-
-   SUBROUTINE tide_vuf( pvt, put, pcor, ktide ,kc )
-      !!----------------------------------------------------------------------
-      !!                     ***  ROUTINE tide_vuf  ***
-      !!                      
-      !! ** Purpose : Compute nodal modulation corrections
-      !!
-      !! ** Outputs : vt: Phase of tidal potential relative to Greenwich (radians)
-      !!              ut: Phase correction u due to nodal motion (radians)
-      !!              ft: Nodal correction factor
-      !!----------------------------------------------------------------------
-      INTEGER                , INTENT(in ) ::   kc               ! Total number of tidal constituents
-      INTEGER , DIMENSION(kc), INTENT(in ) ::   ktide            ! Indice of tidal constituents
-      REAL(wp), DIMENSION(kc), INTENT(out) ::   pvt, put, pcor   !
-      !
-      INTEGER ::   jh   ! dummy loop index
-      !!----------------------------------------------------------------------
-      !
-      DO jh = 1, kc
-         !  Phase of the tidal potential relative to the Greenwhich 
-         !  meridian (e.g. the position of the fictuous celestial body). Units are radian:
-         pvt(jh) = sh_T * Wave( ktide(jh) )%nT    &
-            &    + sh_s * Wave( ktide(jh) )%ns    &
-            &    + sh_h * Wave( ktide(jh) )%nh    &
-            &    + sh_p * Wave( ktide(jh) )%np    &
-            &    + sh_p1* Wave( ktide(jh) )%np1   &
-            &    +        Wave( ktide(jh) )%shift * rad
-         !
-         !  Phase correction u due to nodal motion. Units are radian:
-         put(jh) = sh_xi     * Wave( ktide(jh) )%nksi   &
-            &    + sh_nu     * Wave( ktide(jh) )%nnu0   &
-            &    + sh_nuprim * Wave( ktide(jh) )%nnu1   &
-            &    + sh_nusec  * Wave( ktide(jh) )%nnu2   &
-            &    + sh_R      * Wave( ktide(jh) )%R
-
-         !  Nodal correction factor:
-         pcor(jh) = nodal_factort( Wave( ktide(jh) )%nformula )
-      END DO
-      !
-   END SUBROUTINE tide_vuf
-
-
-   RECURSIVE FUNCTION nodal_factort( kformula ) RESULT( zf )
-      !!----------------------------------------------------------------------
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) :: kformula
-      !
-      REAL(wp) :: zf
-      REAL(wp) :: zs, zf1, zf2
-      !!----------------------------------------------------------------------
-      !
-      SELECT CASE( kformula )
-      !
-      CASE( 0 )                  !==  formule 0, solar waves
-         zf = 1.0
-         !
-      CASE( 1 )                  !==  formule 1, compound waves (78 x 78)
-         zf=nodal_factort(78)
-         zf = zf * zf
-         !
-      CASE ( 2 )                 !==  formule 2, compound waves (78 x 0)  ===  (78) 
-       zf1= nodal_factort(78)
-       zf = nodal_factort( 0)
-       zf = zf1 * zf
-       !
-      CASE ( 4 )                 !==  formule 4,  compound waves (78 x 235) 
-         zf1 = nodal_factort( 78)
-         zf  = nodal_factort(235)
-         zf  = zf1 * zf
-         !
-      CASE ( 5 )                 !==  formule 5,  compound waves (78 *78 x 235)
-         zf1 = nodal_factort( 78)
-         zf  = nodal_factort(235)
-         zf  = zf * zf1 * zf1
-         !
-      CASE ( 6 )                 !==  formule 6,  compound waves (78 *78 x 0)
-         zf1 = nodal_factort(78)
-         zf  = nodal_factort( 0)
-         zf  = zf * zf1 * zf1 
-         !
-      CASE( 7 )                  !==  formule 7, compound waves (75 x 75)
-         zf = nodal_factort(75)
-         zf = zf * zf
-         !
-      CASE( 8 )                  !==  formule 8,  compound waves (78 x 0 x 235)
-         zf  = nodal_factort( 78)
-         zf1 = nodal_factort(  0)
-         zf2 = nodal_factort(235)
-         zf  = zf * zf1 * zf2
-         !
-      CASE( 9 )                  !==  formule 9,  compound waves (78 x 0 x 227)
-         zf  = nodal_factort( 78)
-         zf1 = nodal_factort(  0)
-         zf2 = nodal_factort(227)
-         zf  = zf * zf1 * zf2
-         !
-      CASE( 10 )                 !==  formule 10,  compound waves (78 x 227)
-         zf  = nodal_factort( 78)
-         zf1 = nodal_factort(227)
-         zf  = zf * zf1
-         !
-      CASE( 11 )                 !==  formule 11,  compound waves (75 x 0)
-!!gm bug???? zf 2 fois !
-         zf = nodal_factort(75)
-         zf1 = nodal_factort( 0)
-         zf = zf * zf1
-         !
-      CASE( 12 )                 !==  formule 12,  compound waves (78 x 78 x 78 x 0) 
-         zf1 = nodal_factort(78)
-         zf  = nodal_factort( 0)
-         zf  = zf * zf1 * zf1 * zf1
-         !
-      CASE( 13 )                 !==  formule 13, compound waves (78 x 75)
-         zf1 = nodal_factort(78)
-         zf  = nodal_factort(75)
-         zf  = zf * zf1
-         !
-      CASE( 14 )                 !==  formule 14, compound waves (235 x 0)  ===  (235)
-         zf  = nodal_factort(235)
-         zf1 = nodal_factort(  0)
-         zf  = zf * zf1
-         !
-      CASE( 15 )                 !==  formule 15, compound waves (235 x 75) 
-         zf  = nodal_factort(235)
-         zf1 = nodal_factort( 75)
-         zf  = zf * zf1
-         !
-      CASE( 16 )                 !==  formule 16, compound waves (78 x 0 x 0)  ===  (78)
-         zf  = nodal_factort(78)
-         zf1 = nodal_factort( 0)
-         zf  = zf * zf1 * zf1
-         !
-      CASE( 17 )                 !==  formule 17,  compound waves (227 x 0) 
-         zf1 = nodal_factort(227)
-         zf  = nodal_factort(  0)
-         zf  = zf * zf1
-         !
-      CASE( 18 )                 !==  formule 18,  compound waves (78 x 78 x 78 )
-         zf1 = nodal_factort(78)
-         zf  = zf1 * zf1 * zf1
-         !
-      CASE( 19 )                 !==  formule 19, compound waves (78 x 0 x 0 x 0)  ===  (78)
-!!gm bug2 ==>>>   here identical to formule 16,  a third multiplication by zf1 is missing
-         zf  = nodal_factort(78)
-         zf1 = nodal_factort( 0)
-         zf = zf * zf1 * zf1
-         !
-      CASE( 73 )                 !==  formule 73
-         zs = sin(sh_I)
-         zf = (2./3.-zs*zs)/0.5021
-         !
-      CASE( 74 )                 !==  formule 74
-         zs = sin(sh_I)
-         zf = zs * zs / 0.1578
-         !
-      CASE( 75 )                 !==  formule 75
-         zs = cos(sh_I/2)
-         zf = sin(sh_I) * zs * zs / 0.3800
-         !
-      CASE( 76 )                 !==  formule 76
-         zf = sin(2*sh_I) / 0.7214
-         !
-      CASE( 77 )                 !==  formule 77
-         zs = sin(sh_I/2)
-         zf = sin(sh_I) * zs * zs / 0.0164
-         !
-      CASE( 78 )                 !==  formule 78
-         zs = cos(sh_I/2)
-         zf = zs * zs * zs * zs / 0.9154
-         !
-      CASE( 79 )                 !==  formule 79
-         zs = sin(sh_I)
-         zf = zs * zs / 0.1565
-         !
-      CASE( 144 )                !==  formule 144
-         zs = sin(sh_I/2)
-         zf = ( 1-10*zs*zs+15*zs*zs*zs*zs ) * cos(sh_I/2) / 0.5873
-         !
-      CASE( 149 )                !==  formule 149
-         zs = cos(sh_I/2)
-         zf = zs*zs*zs*zs*zs*zs / 0.8758
-         !
-      CASE( 215 )                !==  formule 215
-         zs = cos(sh_I/2)
-         zf = zs*zs*zs*zs / 0.9154 * sh_x1ra
-         !
-      CASE( 227 )                !==  formule 227 
-         zs = sin(2*sh_I)
-         zf = sqrt( 0.8965*zs*zs+0.6001*zs*cos (sh_nu)+0.1006 )
-         !
-      CASE ( 235 )               !==  formule 235 
-         zs = sin(sh_I)
-         zf = sqrt( 19.0444*zs*zs*zs*zs + 2.7702*zs*zs*cos(2*sh_nu) + .0981 )
-         !
-      END SELECT
-      !
-   END FUNCTION nodal_factort
-
-
-   FUNCTION dayjul( kyr, kmonth, kday )
-      !!----------------------------------------------------------------------
-      !!  *** THIS ROUTINE COMPUTES THE JULIAN DAY (AS A REAL VARIABLE)
-      !!----------------------------------------------------------------------
-      INTEGER,INTENT(in) ::   kyr, kmonth, kday
-      !
-      INTEGER,DIMENSION(12) ::  idayt, idays
-      INTEGER  ::   inc, ji
-      REAL(wp) ::   dayjul, zyq
-      !
-      DATA idayt/0.,31.,59.,90.,120.,151.,181.,212.,243.,273.,304.,334./
-      !!----------------------------------------------------------------------
-      !
-      idays(1) = 0.
-      idays(2) = 31.
-      inc = 0.
-      zyq = MOD( kyr-1900. , 4. )
-      IF( zyq == 0.)   inc = 1.
-      DO ji = 3, 12
-         idays(ji)=idayt(ji)+inc
-      END DO
-      dayjul = idays(kmonth) + kday
-      !
-   END FUNCTION dayjul
-
-   !!======================================================================
-END MODULE tide_mod
Index: MO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/SBC/tideini.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/SBC/tideini.F90	(revision 12183)
+++ 	(revision )
@@ -1,134 +1,0 @@
-MODULE tideini
-   !!======================================================================
-   !!                       ***  MODULE  tideini  ***
-   !! Initialization of tidal forcing
-   !!======================================================================
-   !! History :  1.0  !  2007  (O. Le Galloudec)  Original code
-   !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and tracers variables
-   USE dom_oce        ! ocean space and time domain
-   USE phycst         ! physical constants
-   USE daymod         ! calendar
-   USE tide_mod       ! 
-   !
-   USE in_out_manager ! I/O units
-   USE iom            ! xIOs server
-   USE ioipsl         ! NetCDF IPSL library
-   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
-
-   IMPLICIT NONE
-   PUBLIC
-
-   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:) ::   omega_tide   !:
-   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:) ::   v0tide       !:
-   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:) ::   utide        !:
-   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:) ::   ftide        !:
-
-   LOGICAL , PUBLIC ::   ln_tide         !:
-   LOGICAL , PUBLIC ::   ln_tide_pot     !:
-   LOGICAL , PUBLIC ::   ln_read_load    !:
-   LOGICAL , PUBLIC ::   ln_scal_load    !:
-   LOGICAL , PUBLIC ::   ln_tide_ramp    !:
-   INTEGER , PUBLIC ::   nb_harmo        !:
-   INTEGER , PUBLIC ::   kt_tide         !:
-   REAL(wp), PUBLIC ::   rdttideramp     !:
-   REAL(wp), PUBLIC ::   rn_scal_load    !:
-   CHARACTER(lc), PUBLIC ::   cn_tide_load   !: 
-
-   INTEGER , PUBLIC, ALLOCATABLE, DIMENSION(:) ::   ntide   !:
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id$
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-   
-   SUBROUTINE tide_init
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE tide_init  ***
-      !!----------------------------------------------------------------------      
-      INTEGER  :: ji, jk
-      CHARACTER(LEN=4), DIMENSION(jpmax_harmo) :: clname
-      INTEGER  ::   ios                 ! Local integer output status for namelist read
-      !
-      NAMELIST/nam_tide/ln_tide, ln_tide_pot, ln_scal_load, ln_read_load, cn_tide_load, &
-                  &     ln_tide_ramp, rn_scal_load, rdttideramp, clname
-      !!----------------------------------------------------------------------
-      !
-      ! Read Namelist nam_tide
-      REWIND( numnam_ref )              ! Namelist nam_tide in reference namelist : Tides
-      READ  ( numnam_ref, nam_tide, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_tide in reference namelist' )
-      !
-      REWIND( numnam_cfg )              ! Namelist nam_tide in configuration namelist : Tides
-      READ  ( numnam_cfg, nam_tide, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nam_tide in configuration namelist' )
-      IF(lwm) WRITE ( numond, nam_tide )
-      !
-      IF( ln_tide ) THEN
-         IF(lwp) THEN
-            WRITE(numout,*)
-            WRITE(numout,*) 'tide_init : Initialization of the tidal components'
-            WRITE(numout,*) '~~~~~~~~~ '
-            WRITE(numout,*) '   Namelist nam_tide'
-            WRITE(numout,*) '      Use tidal components                       ln_tide      = ', ln_tide
-            WRITE(numout,*) '         Apply astronomical potential            ln_tide_pot  = ', ln_tide_pot
-            WRITE(numout,*) '         Use scalar approx. for load potential   ln_scal_load = ', ln_scal_load
-            WRITE(numout,*) '         Read load potential from file           ln_read_load = ', ln_read_load
-            WRITE(numout,*) '         Apply ramp on tides at startup          ln_tide_ramp = ', ln_tide_ramp
-            WRITE(numout,*) '         Fraction of SSH used in scal. approx.   rn_scal_load = ', rn_scal_load
-            WRITE(numout,*) '         Duration (days) of ramp                 rdttideramp  = ', rdttideramp
-         ENDIF
-      ELSE
-         rn_scal_load = 0._wp 
-
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'tide_init : tidal components not used (ln_tide = F)'
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~ '
-         RETURN
-      ENDIF
-      !
-      CALL tide_init_Wave
-      !
-      nb_harmo=0
-      DO jk = 1, jpmax_harmo
-         DO ji = 1,jpmax_harmo
-            IF( TRIM(clname(jk)) == Wave(ji)%cname_tide )   nb_harmo = nb_harmo + 1
-         END DO
-      END DO
-      !       
-      ! Ensure that tidal components have been set in namelist_cfg
-      IF( nb_harmo == 0 )   CALL ctl_stop( 'tide_init : No tidal components set in nam_tide' )
-      !
-      IF( ln_read_load.AND.(.NOT.ln_tide_pot) ) &
-          &   CALL ctl_stop('ln_read_load requires ln_tide_pot')
-      IF( ln_scal_load.AND.(.NOT.ln_tide_pot) ) &
-          &   CALL ctl_stop('ln_scal_load requires ln_tide_pot')
-      IF( ln_scal_load.AND.ln_read_load ) &
-          &   CALL ctl_stop('Choose between ln_scal_load and ln_read_load')
-      IF( ln_tide_ramp.AND.((nitend-nit000+1)*rdt/rday < rdttideramp) )   &
-         &   CALL ctl_stop('rdttideramp must be lower than run duration')
-      IF( ln_tide_ramp.AND.(rdttideramp<0.) ) &
-         &   CALL ctl_stop('rdttideramp must be positive')
-      !
-      ALLOCATE( ntide(nb_harmo) )
-      DO jk = 1, nb_harmo
-         DO ji = 1, jpmax_harmo
-            IF( TRIM(clname(jk)) == Wave(ji)%cname_tide ) THEN
-               ntide(jk) = ji
-               EXIT
-            ENDIF
-         END DO
-      END DO
-      !
-      ALLOCATE( omega_tide(nb_harmo), v0tide    (nb_harmo),   &
-         &      utide     (nb_harmo), ftide     (nb_harmo)  )
-      kt_tide = nit000
-      !
-      IF(.NOT.ln_scal_load ) rn_scal_load = 0._wp
-      !
-   END SUBROUTINE tide_init
-     
-   !!======================================================================
-END MODULE tideini
Index: MO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/SBC/updtide.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/SBC/updtide.F90	(revision 12183)
+++ 	(revision )
@@ -1,81 +1,0 @@
-MODULE updtide
-   !!======================================================================
-   !!                       ***  MODULE  updtide  ***
-   !! Initialization of tidal forcing
-   !!======================================================================
-   !! History :  9.0  !  07  (O. Le Galloudec)  Original code
-   !!----------------------------------------------------------------------
-   !!   upd_tide       : update tidal potential
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers variables
-   USE dom_oce         ! ocean space and time domain
-   USE in_out_manager  ! I/O units
-   USE phycst          ! physical constant
-   USE sbctide         ! tide potential variable
-   USE tideini, ONLY: ln_tide_ramp, rdttideramp
-
-   IMPLICIT NONE
-   PUBLIC
-
-   PUBLIC   upd_tide   ! called in dynspg_... modules
-  
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id$
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE upd_tide( kt, kit, kt_offset )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE upd_tide  ***
-      !!
-      !! ** Purpose :   provide at each time step the astronomical potential
-      !!
-      !! ** Method  :   computed from pulsation and amplitude of all tide components
-      !!
-      !! ** Action  :   pot_astro   actronomical potential
-      !!----------------------------------------------------------------------      
-      INTEGER, INTENT(in)           ::   kt      ! ocean time-step index
-      INTEGER, INTENT(in), OPTIONAL ::   kit     ! external mode sub-time-step index (lk_dynspg_ts=T)
-      INTEGER, INTENT(in), OPTIONAL ::   kt_offset ! time offset in number 
-                                                     ! of internal steps             (lk_dynspg_ts=F)
-                                                     ! of external steps             (lk_dynspg_ts=T)
-      !
-      INTEGER  ::   ioffset      ! local integer
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zt, zramp    ! local scalar
-      REAL(wp), DIMENSION(nb_harmo) ::   zwt 
-      !!----------------------------------------------------------------------      
-      !
-      !                               ! tide pulsation at model time step (or sub-time-step)
-      zt = ( kt - kt_tide ) * rdt
-      !
-      ioffset = 0
-      IF( PRESENT( kt_offset ) )   ioffset = kt_offset
-      !
-      IF( PRESENT( kit ) )   THEN
-         zt = zt + ( kit +  ioffset - 1 ) * rdt / REAL( nn_baro, wp )
-      ELSE
-         zt = zt + ioffset * rdt
-      ENDIF
-      !
-      zwt(:) = omega_tide(:) * zt
-
-      pot_astro(:,:) = 0._wp          ! update tidal potential (sum of all harmonics)
-      DO jk = 1, nb_harmo   
-         pot_astro(:,:) = pot_astro(:,:) + amp_pot(:,:,jk) * COS( zwt(jk) + phi_pot(:,:,jk) )      
-      END DO
-      !
-      IF( ln_tide_ramp ) THEN         ! linear increase if asked
-         zt = ( kt - nit000 ) * rdt
-         IF( PRESENT( kit ) )   zt = zt + ( kit + ioffset -1) * rdt / REAL( nn_baro, wp )
-         zramp = MIN(  MAX( zt / (rdttideramp*rday) , 0._wp ) , 1._wp  )
-         pot_astro(:,:) = zramp * pot_astro(:,:)
-      ENDIF
-      !
-   END SUBROUTINE upd_tide
-
-  !!======================================================================
-
-END MODULE updtide
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/TDE/tide.h90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/TDE/tide.h90	(revision 12184)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/TDE/tide.h90	(revision 12184)
@@ -0,0 +1,166 @@
+   !!=====================================================================
+   !!                  ***  Include file tide.h90  ***
+   !!======================================================================
+   !! History :  3.2  !  2007  (O. Le Galloudec)  Original code
+   !!                 !  2019  (S. Mueller, N. Bruneau)  Alternative parameter set
+   !!----------------------------------------------------------------------
+   !!
+   !! ** Purpose : Inclusion of alternative variants of tidal-constituent
+   !!              parameter definitions during code preprocessing: the default
+   !!              variant includes the 34 constituents available in the FES2014
+   !!              version of the Finite Element Solution - Global Tide data
+   !!              product
+   !!              (https://www.aviso.altimetry.fr/en/data/products/auxiliary-products/global-tide-fes.html);
+   !!              also available is the default parameter set available in
+   !!              previous NEMO versions
+   !!
+   !! ** References :
+   !!       S58) Schureman, P. (1958): Manual of Harmonic Analysis and
+   !!            Prediction of Tides (Revised (1940) Edition (Reprinted 1958
+   !!            with corrections). Reprinted June 2001). U.S. Department of
+   !!            Commerce, Coast and Geodetic Survey Special Publication
+   !!            No. 98. Washington DC, United States Government Printing
+   !!            Office. 317 pp. DOI: 10.25607/OBP-155.
+   !!      CT71) Cartwright, D. E. and Tayler, R. J. (1971): New computations of
+   !!            the Tide-generating Potential. Geophys. J. R. astr. Soc. 23,
+   !!            pp. 45-74. DOI: 10.1111/j.1365-246X.1971.tb01803.x
+   !!      CE73) Cartwright, D. E. and Edden, A. C. (1973): Corrected Tables of
+   !!            Tidal Harmonics. Geophys. J. R. astr. Soc. 33,
+   !!            pp. 253-264. DOI: 10.1111/j.1365-246X.1973.tb03420.x
+   !!   FES2014) FES (Finite element Solution) - Global
+   !!            tide. https://www.aviso.altimetry.fr/en/data/products/auxiliary-products/global-tide-fes.html
+   !!
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2019)
+   !! $Id$
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+#ifndef TIDE_VAR_0
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   !                         | Name   | Equilibrium  | nt | ns | nh | np | np1 | Phase | nxi | nnu0 | nnu1 | nnu2 |  R | Nodal      | Equilibrium    | Parameters source     | Notes  |
+   !                         |        | tide         |    |    |    |    |     | shift |     |      |      |      |    | correction | tide           |                       |        |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    | formula    | source/comment |                       |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   !                         |                                                            Long-period tidal constituents                                                              |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components( 1) = tide( 'Mf'   ,  0.042054_wp ,  0 ,  2 ,  1 ,  0 ,   0 ,     0 ,  -2 ,    0 ,    0 ,    0 ,  0 ,  74 )      ! CE73           | S54 (Table 2, A6)     |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components( 2) = tide( 'Mm'   ,  0.022187_wp ,  0 ,  1 ,  0 , -1 ,   0 ,     0 ,   0 ,    0 ,    0 ,    0 ,  0 ,  73 )      ! CE73           | S54 (Table 2, A2)     |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components( 3) = tide( 'Ssa'  ,  0.019572_wp ,  0 ,  0 ,  2 ,  0 ,   0 ,     0 ,   0 ,    0 ,    0 ,    0 ,  0 ,   0 )      ! CE73           | S54 (Table 2, B6)     |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components( 4) = tide( 'Mtm'  ,  0.008052_wp ,  0 ,  3 ,  0 , -1 ,   0 ,     0 ,  -2 ,    0 ,    0 ,    0 ,  0 ,  74 )      ! CE73           | FES2014 (prediction   |        |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            |                | algorithm); S54       |        |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            |                | (Table 2, A7)         |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components( 5) = tide( 'Msf'  ,  0.003677_wp ,  0 ,  2 , -2 ,  0 ,   0 ,     0 ,   0 ,    0 ,    0 ,    0 ,  0 ,  73 )      ! CE73           | S54 (Table 2, A5)     |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components( 6) = tide( 'Msqm' ,  0.001287_wp ,  0 ,  4 , -2 ,  0 ,   0 ,     0 ,  -2 ,    0 ,    0 ,    0 ,  0 ,  74 )      ! CE73           | FES2014 (prediction   |        |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            |                | algorithm); S54       |        |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            |                | (Table 2, A12)        |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components( 7) = tide( 'Sa'   ,  0.000000_wp ,  0 ,  0 ,  1 ,  0 ,   0 ,     0 ,   0 ,    0 ,    0 ,    0 ,  0 ,   0 )      ! Meteorological | S54 (Table 2, B64)    |        |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            | tide only      |                       |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   !                         |                                                              Diurnal tidal constituents                                                                |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components( 8) = tide( 'K1'   , -0.142486_wp ,  1 ,  0 ,  1 ,  0 ,   0 ,    90 ,   0 ,    0 ,   -1 ,    0 ,  0 , 227 )      ! CE73           | S54 (Table 2)         | Note 1 |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components( 9) = tide( 'O1'   ,  0.101316_wp ,  1 , -2 ,  1 ,  0 ,   0 ,    90 ,   2 ,   -1 ,    0 ,    0 ,  0 ,  75 )      ! CE73           | S54 (Table 2, A14)    |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(10) = tide( 'P1'   ,  0.047152_wp ,  1 ,  0 , -1 ,  0 ,   0 ,    90 ,   0 ,    0 ,    0 ,    0 ,  0 ,   0 )      ! CE73           | S54 (Table 2, B14)    |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(11) = tide( 'Q1'   ,  0.019396_wp ,  1 , -3 ,  1 ,  1 ,   0 ,    90 ,   2 ,   -1 ,    0 ,    0 ,  0 ,  75 )      ! CE73           | S54 (Table 2, A15)    |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(12) = tide( 'J1'   , -0.007967_wp ,  1 ,  1 ,  1 , -1 ,   0 ,    90 ,   0 ,   -1 ,    0 ,    0 ,  0 ,  76 )      ! CE73           | S54 (Table 2, A24)    | Note 1 |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(13) = tide( 'S1'   ,  0.000000_wp ,  1 ,  0 ,  0 ,  0 ,   0 ,     0 ,   0 ,    0 ,    0 ,    0 ,  0 ,   0 )      ! Meteorological | S54 (Table 2, B71)    |        |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            | tide only      |                       |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   !                         |                                                            Semidiurnal tidal constituents                                                              |
+   !                         +--------+-------------+-----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(14) = tide( 'M2'   ,  0.244081_wp ,  2 , -2 ,  2 ,  0 ,   0 ,     0 ,   2 ,   -2 ,    0 ,    0 ,  0 ,  78 )      ! CE73           | S54 (Table 2, A39)    |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(15) = tide( 'S2'   ,  0.110242_wp ,  2 ,  0 ,  0 ,  0 ,   0 ,     0 ,   0 ,    0 ,    0 ,    0 ,  0 ,   0 )      ! CE73           | S54 (Table 2, B39)    |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(16) = tide( 'N2'   ,  0.046732_wp ,  2 , -3 ,  2 ,  1 ,   0 ,     0 ,   2 ,   -2 ,    0 ,    0 ,  0 ,  78 )      ! CE73           | S54 (Table 2, A40)    |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(17) = tide( 'K2'   ,  0.030905_wp ,  2 ,  0 ,  2 ,  0 ,   0 ,     0 ,   0 ,    0 ,    0 ,   -2 ,  0 , 235 )      ! CE73           | S54 (Table 2)         |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(18) = tide( 'nu2'  ,  0.008877_wp ,  2 , -3 ,  4 , -1 ,   0 ,     0 ,   2 ,   -2 ,    0 ,    0 ,  0 ,  78 )      ! CE73           | S54 (Table 2, A43)    |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(19) = tide( 'mu2'  ,  0.007463_wp ,  2 , -4 ,  4 ,  0 ,   0 ,     0 ,   2 ,   -2 ,    0 ,    0 ,  0 ,  78 )      ! CE73           | S54 (Table 2, A45)    |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(20) = tide( '2N2'  ,  0.006184_wp ,  2 , -4 ,  2 ,  2 ,   0 ,     0 ,   2 ,   -2 ,    0 ,    0 ,  0 ,  78 )      ! CE73           | S54 (Table 2, A42)    |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(21) = tide( 'L2'   , -0.006899_wp ,  2 , -1 ,  2 , -1 ,   0 ,     0 ,   2 ,   -2 ,    0 ,    0 , -1 , 215 )      ! CE73           | S54 (Table 2)         | Note 1 |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(22) = tide( 'T2'   ,  0.006655_wp ,  2 ,  0 , -1 ,  0 ,   1 ,     0 ,   0 ,    0 ,    0 ,    0 ,  0 ,   0 )      ! CE73           | S54 (Table 2, B40)    |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(23) = tide( 'eps2' ,  0.001804_wp ,  2 , -5 ,  4 ,  1 ,   0 ,     0 ,   2 ,   -2 ,    0 ,    0 ,  0 ,  78 )      ! CE73           | FES2014 (prediction   |        |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            |                | algorithm)            |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(24) = tide( 'lam2' , -0.001800_wp ,  2 , -1 ,  0 ,  1 ,   0 ,     0 ,   2 ,   -2 ,    0 ,    0 ,  0 ,  78 )      ! CE73           | S54 (Table 2, A44)    | Note 1 |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(25) = tide( 'R2'   , -0.000952_wp ,  2 ,  0 ,  1 ,  0 ,  -1 ,     0 ,   0 ,    0 ,    0 ,    0 ,  0 ,   0 )      ! CE73           | S54 (Table 2, B41)    | Note 1 |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   !                         |                                                            Terdiurnal tidal constituents                                                               |
+   !                         +--------+-------------+-----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(26) = tide( 'M3'   , -0.003192_wp ,  3 , -3 ,  3 ,  0 ,   0 ,   180 ,   3 ,   -3 ,    0 ,    0 ,  0 , 149 )      ! CT71           | S54 (Table 2, A82)    | Note 2 |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   !                         |                                                                    Compound tides                                                                      |
+   !                         +--------+-------------+-----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(27) = tide( 'MKS2' ,  0.000000_wp ,  2 , -2 ,  4 ,  0 ,   0 ,     0 ,   2 ,   -2 ,    0 ,   -2 ,  0 ,   4 )      ! Compound tide  | FES2014 (prediction   |        |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            |                | algorithm)            |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(28) = tide( 'MN4'  ,  0.000000_wp ,  4 , -5 ,  4 ,  1 ,   0 ,     0 ,   4 ,   -4 ,    0 ,    0 ,  0 ,   1 )      ! Compound tide  | S54 (Table 2a)        |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(29) = tide( 'MS4'  ,  0.000000_wp ,  4 , -2 ,  2 ,  0 ,   0 ,     0 ,   2 ,   -2 ,    0 ,    0 ,  0 ,  78 )      ! Compound tide  | FES2014 (prediction   | Note 3 |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            |                | algorithm); S54       |        |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            |                | (Table 2a)            |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   !                         |                                                                       Overtides                                                                        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(30) = tide( 'M4'   ,  0.000000_wp ,  4 , -4 ,  4 ,  0 ,   0 ,     0 ,   4 ,   -4 ,    0 ,    0 ,  0 ,   1 )      ! Overtide       | S54                   |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(31) = tide( 'N4'   ,  0.000000_wp ,  4 , -6 ,  4 ,  2 ,   0 ,     0 ,   4 ,   -4 ,    0 ,    0 ,  0 ,   1 )      ! Overtide       | FES2014 (prediction   |        |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            |                | algorithm)            |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(32) = tide( 'S4'   ,  0.000000_wp ,  4 ,  0 ,  0 ,  0 ,  0  ,     0 ,   0 ,    0 ,    0 ,    0 ,  0 ,   0 )      ! Overtide       | S54                   |        | 
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(33) = tide( 'M6'   ,  0.000000_wp ,  6 , -6 ,  6 ,  0 ,  0  ,     0 ,   6 ,   -6 ,    0 ,    0 ,  0 ,  18 )      ! Overtide       | S54                   |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   tide_components(34) = tide( 'M8'   ,  0.000000_wp ,  8 , -8 ,  8 ,  0 ,  0  ,     0 ,   8 ,   -8 ,    0 ,    0 ,  0 ,  20 )      ! Overtide       | S54                   |        |
+   !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
+   !   Note 1: the phase shift from Table 2 of S54 has been adjusted to accomodate the negative sign of the equilibrium-tide value derived from CE73.
+   !   Note 2: the phase shift from Table 2 of S54 has been adjusted to accomodate the negative sign of the equilibrium-tide value derived from CT71.
+   !   Note 3: the nodal correction factor formulas from FES2014 and S54 differ; here, the version from FES2014 has been selected.
+#else
+   !                        !! name_tide , equitide , nt , ns , nh , np , np1 , shift , nksi , nnu0 , nnu1 , nnu2 , R , formula !!
+   !                        !!           !          !    !    !    !    !     !       !      !      !      !      !   !         !!
+   tide_components( 1) = tide(  'M2'     , 0.242297 ,  2 , -2 ,  2 ,  0 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,    78   )
+   tide_components( 2) = tide(  'N2'     , 0.046313 ,  2 , -3 ,  2 ,  1 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,    78   )
+   tide_components( 3) = tide( '2N2'     , 0.006184 ,  2 , -4 ,  2 ,  2 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,    78   )
+   tide_components( 4) = tide(  'S2'     , 0.113572 ,  2 ,  0 ,  0 ,  0 ,  0  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,     0   )
+   tide_components( 5) = tide(  'K2'     , 0.030875 ,  2 ,  0 ,  2 ,  0 ,  0  ,    0  ,  0   ,  0   ,  0   , -2   , 0 ,   235   )
+   !                         !           !          !    !    !    !    !     !       !      !      !      !      !   !         !
+   tide_components( 6) = tide(  'K1'     , 0.142408 ,  1 ,  0 ,  1 ,  0 ,  0  ,  -90  ,  0   ,  0   , -1   ,  0   , 0 ,   227   )
+   tide_components( 7) = tide(  'O1'     , 0.101266 ,  1 , -2 ,  1 ,  0 ,  0  ,  +90  ,  2   , -1   ,  0   ,  0   , 0 ,    75   )
+   tide_components( 8) = tide(  'Q1'     , 0.019387 ,  1 , -3 ,  1 ,  1 ,  0  ,  +90  ,  2   , -1   ,  0   ,  0   , 0 ,    75   )
+   tide_components( 9) = tide(  'P1'     , 0.047129 ,  1 ,  0 , -1 ,  0 ,  0  ,  +90  ,  0   ,  0   ,  0   ,  0   , 0 ,    0    )
+   !                         !           !          !    !    !    !    !     !       !      !      !      !      !   !         !
+   tide_components(10) = tide(  'M4'     , 0.000000 ,  4 , -4 ,  4 ,  0 ,  0  ,    0  ,  4   , -4   ,  0   ,  0   , 0 ,    1    )
+   !                         !           !          !    !    !    !    !     !       !      !      !      !      !   !         !
+   tide_components(11) = tide(  'Mf'     , 0.042017 ,  0 ,  2 ,  0 ,  0 ,  0  ,    0  , -2   ,  0   ,  0   ,  0   , 0 ,   74    )
+   tide_components(12) = tide(  'Mm'     , 0.022191 ,  0 ,  1 ,  0 , -1 ,  0  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,   73    )
+   tide_components(13) = tide(  'Msqm'   , 0.000667 ,  0 ,  4 , -2 ,  0 ,  0  ,    0  , -2   ,  0   ,  0   ,  0   , 0 ,   74    )
+   tide_components(14) = tide(  'Mtm'    , 0.008049 ,  0 ,  3 ,  0 , -1 ,  0  ,    0  , -2   ,  0   ,  0   ,  0   , 0 ,   74    )
+   !                         !           !          !    !    !    !    !     !       !      !      !      !      !   !         !
+   tide_components(15) = tide(  'S1'     , 0.000000 ,  1 ,  0 ,  0 ,  0 ,  0  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,    0    )   
+   tide_components(16) = tide(  'MU2'    , 0.005841 ,  2 , -4 ,  4 ,  0 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,   78    )
+   tide_components(17) = tide(  'NU2'    , 0.009094 ,  2 , -3 ,  4 , -1 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,   78    ) 
+   tide_components(18) = tide(  'L2'     , 0.006694 ,  2 , -1 ,  2 , -1 ,  0  , +180  ,  2   , -2   ,  0   ,  0   , 0 ,  215    )
+   tide_components(19) = tide(  'T2'     , 0.006614 ,  2 ,  0 , -1 ,  0 ,  1  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,    0    )
+#endif
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/TDE/tide_mod.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/TDE/tide_mod.F90	(revision 12184)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/TDE/tide_mod.F90	(revision 12184)
@@ -0,0 +1,763 @@
+MODULE tide_mod
+   !!======================================================================
+   !!                       ***  MODULE  tide_mod  ***
+   !! Compute nodal modulations corrections and pulsations
+   !!======================================================================
+   !! History :  1.0  !  2007  (O. Le Galloudec)  Original code
+   !!                 !  2019  (S. Mueller)
+   !!----------------------------------------------------------------------
+   !!
+   !! ** Reference :
+   !!       S58) Schureman, P. (1958): Manual of Harmonic Analysis and
+   !!            Prediction of Tides (Revised (1940) Edition (Reprinted 1958
+   !!            with corrections). Reprinted June 2001). U.S. Department of
+   !!            Commerce, Coast and Geodetic Survey Special Publication
+   !!            No. 98. Washington DC, United States Government Printing
+   !!            Office. 317 pp. DOI: 10.25607/OBP-155.
+   !!----------------------------------------------------------------------
+
+   USE oce, ONLY : sshn       ! sea-surface height
+   USE par_oce                ! ocean parameters
+   USE phycst, ONLY : rpi     ! pi
+   USE daymod, ONLY : ndt05   ! half-length of time step
+   USE in_out_manager         ! I/O units
+   USE iom                    ! xIOs server
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tide_init
+   PUBLIC   tide_update           ! called by stp
+   PUBLIC   tide_init_harmonics   ! called internally and by module diaharm
+   PUBLIC   upd_tide              ! called in dynspg_... modules
+
+   INTEGER, PUBLIC, PARAMETER ::   jpmax_harmo = 64   !: maximum number of harmonic components
+
+   TYPE ::    tide
+      CHARACTER(LEN=4) ::   cname_tide = ''
+      REAL(wp)         ::   equitide
+      INTEGER          ::   nt, ns, nh, np, np1, shift
+      INTEGER          ::   nksi, nnu0, nnu1, nnu2, R
+      INTEGER          ::   nformula
+   END TYPE tide
+
+   TYPE(tide), DIMENSION(:), POINTER ::   tide_components   !: Array of selected tidal component parameters
+
+   TYPE, PUBLIC ::   tide_harmonic       !:   Oscillation parameters of harmonic tidal components
+      CHARACTER(LEN=4) ::   cname_tide   !    Name of component
+      REAL(wp)         ::   equitide     !    Amplitude of equilibrium tide
+      REAL(wp)         ::   f            !    Node factor
+      REAL(wp)         ::   omega        !    Angular velocity
+      REAL(wp)         ::   v0           !    Initial phase at prime meridian
+      REAL(wp)         ::   u            !    Phase correction
+   END type tide_harmonic
+
+   TYPE(tide_harmonic), PUBLIC, DIMENSION(:), POINTER ::   tide_harmonics   !: Oscillation parameters of selected tidal components
+
+   LOGICAL , PUBLIC ::   ln_tide             !:
+   LOGICAL , PUBLIC ::   ln_tide_pot         !:
+   INTEGER          ::   nn_tide_var         !  Variant of tidal parameter set and tide-potential computation
+   LOGICAL          ::   ln_tide_dia         !  Enable tidal diagnostic output
+   LOGICAL          ::   ln_read_load        !:
+   LOGICAL , PUBLIC ::   ln_scal_load        !:
+   LOGICAL , PUBLIC ::   ln_tide_ramp        !:
+   INTEGER , PUBLIC ::   nb_harmo            !: Number of active tidal components
+   REAL(wp), PUBLIC ::   rn_tide_ramp_dt     !:
+   REAL(wp), PUBLIC ::   rn_scal_load        !:
+   CHARACTER(lc), PUBLIC ::   cn_tide_load   !: 
+   REAL(wp)         ::   rn_tide_gamma       ! Tidal tilt factor
+
+   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:)   ::   pot_astro            !: tidal potential
+   REAL(wp),         ALLOCATABLE, DIMENSION(:,:)   ::   pot_astro_comp       !  tidal-potential component
+   REAL(wp),         ALLOCATABLE, DIMENSION(:,:,:) ::   amp_pot, phi_pot
+   REAL(wp),         ALLOCATABLE, DIMENSION(:,:,:) ::   amp_load, phi_load
+
+   REAL(wp) ::   rn_tide_ramp_t   !   Elapsed time in seconds
+
+   REAL(wp) ::   sh_T, sh_s, sh_h, sh_p, sh_p1             ! astronomic angles
+   REAL(wp) ::   sh_xi, sh_nu, sh_nuprim, sh_nusec, sh_R   !
+   REAL(wp) ::   sh_I, sh_x1ra, sh_N                       !
+
+   ! Longitudes on 1 Jan 1900, 00h and angular velocities (units of deg and
+   ! deg/h, respectively. The values of these module variables have been copied
+   ! from subroutine astronomic_angle of the version of this module used in
+   ! release version 4.0 of NEMO.
+   REAL(wp) ::   rlon00_N  =  259.1560564_wp               ! Longitude of ascending lunar node
+   REAL(wp) ::   romega_N  = -.0022064139_wp
+   REAL(wp) ::   rlon00_T  =  180.0_wp                     ! Mean solar angle (GMT)
+   REAL(wp) ::   romega_T  =  15.0_wp
+   REAL(wp) ::   rlon00_h  =  280.1895014_wp               ! Mean solar Longitude
+   REAL(wp) ::   romega_h  =  .0410686387_wp
+   REAL(wp) ::   rlon00_s  =  277.0256206_wp               ! Mean lunar Longitude
+   REAL(wp) ::   romega_s  =  .549016532_wp
+   REAL(wp) ::   rlon00_p1 =  281.2208569_wp               ! Longitude of solar perigee
+   REAL(wp) ::   romega_p1 =  .000001961_wp
+   REAL(wp) ::   rlon00_p  =  334.3837214_wp               ! Longitude of lunar perigee
+   REAL(wp) ::   romega_p  =  .004641834_wp
+   ! Values of cos(i)*cos(epsilon), rcice, and sin(incl)*sin(epsilon), rsise,
+   ! where i is the inclination of the orbit of the Moon w.r.t. the ecliptic and
+   ! epsilon the obliquity of the ecliptic on 1 January 1900, 00h. The values of
+   ! these module variables have been copied from subroutine astronomic_angle
+   ! (computation of the cosine of inclination of orbit of Moon to the celestial
+   ! equator) of the version of this module used in release version 4.0 of NEMO.
+   REAL(wp) ::   rcice    = 0.913694997_wp
+   REAL(wp) ::   rsise    = 0.035692561_wp
+   ! Coefficients used to compute sh_xi and sh_nu in subroutine astronomic_angle
+   ! according to two equations given in the explanation of Table 6 of S58
+   REAL(wp) ::   rxinu1, rxinu2
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id$ 
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE tide_init
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE tide_init  ***
+      !!----------------------------------------------------------------------      
+      INTEGER  :: ji, jk
+      CHARACTER(LEN=4), DIMENSION(jpmax_harmo) :: sn_tide_cnames ! Names of selected tidal components
+      INTEGER  ::   ios                 ! Local integer output status for namelist read
+      !
+      NAMELIST/nam_tide/ln_tide, nn_tide_var, ln_tide_dia, ln_tide_pot, rn_tide_gamma, &
+         &              ln_scal_load, ln_read_load, cn_tide_load,         &
+         &              ln_tide_ramp, rn_scal_load, rn_tide_ramp_dt,      &
+         &              sn_tide_cnames
+      !!----------------------------------------------------------------------
+      !
+      ! Initialise all array elements of sn_tide_cnames, as some of them
+      ! typically do not appear in namelist_ref or namelist_cfg
+      sn_tide_cnames(:) = ''
+      ! Read Namelist nam_tide
+      REWIND( numnam_ref )              ! Namelist nam_tide in reference namelist : Tides
+      READ  ( numnam_ref, nam_tide, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_tide in reference namelist' )
+      !
+      REWIND( numnam_cfg )              ! Namelist nam_tide in configuration namelist : Tides
+      READ  ( numnam_cfg, nam_tide, IOSTAT = ios, ERR = 902 )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nam_tide in configuration namelist' )
+      IF(lwm) WRITE ( numond, nam_tide )
+      !
+      IF( ln_tide ) THEN
+         IF (lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'tide_init : Initialization of the tidal components'
+            WRITE(numout,*) '~~~~~~~~~ '
+            WRITE(numout,*) '   Namelist nam_tide'
+            WRITE(numout,*) '      Use tidal components                       ln_tide         = ', ln_tide
+            WRITE(numout,*) '         Variant (1: default; 0: legacy option)  nn_tide_var     = ', nn_tide_var
+            WRITE(numout,*) '         Tidal diagnostic output                 ln_tide_dia     = ', ln_tide_dia
+            WRITE(numout,*) '         Apply astronomical potential            ln_tide_pot     = ', ln_tide_pot
+            WRITE(numout,*) '         Tidal tilt factor                       rn_tide_gamma   = ', rn_tide_gamma
+            WRITE(numout,*) '         Use scalar approx. for load potential   ln_scal_load    = ', ln_scal_load
+            WRITE(numout,*) '         Read load potential from file           ln_read_load    = ', ln_read_load
+            WRITE(numout,*) '         Apply ramp on tides at startup          ln_tide_ramp    = ', ln_tide_ramp
+            WRITE(numout,*) '         Fraction of SSH used in scal. approx.   rn_scal_load    = ', rn_scal_load
+            WRITE(numout,*) '         Duration (days) of ramp                 rn_tide_ramp_dt = ', rn_tide_ramp_dt
+         ENDIF
+      ELSE
+         rn_scal_load = 0._wp 
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tide_init : tidal components not used (ln_tide = F)'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~ '
+         RETURN
+      ENDIF
+      !
+      IF( ln_read_load.AND.(.NOT.ln_tide_pot) ) &
+          &   CALL ctl_stop('ln_read_load requires ln_tide_pot')
+      IF( ln_scal_load.AND.(.NOT.ln_tide_pot) ) &
+          &   CALL ctl_stop('ln_scal_load requires ln_tide_pot')
+      IF( ln_scal_load.AND.ln_read_load ) &
+          &   CALL ctl_stop('Choose between ln_scal_load and ln_read_load')
+      IF( ln_tide_ramp.AND.((nitend-nit000+1)*rdt/rday < rn_tide_ramp_dt) )   &
+         &   CALL ctl_stop('rn_tide_ramp_dt must be lower than run duration')
+      IF( ln_tide_ramp.AND.(rn_tide_ramp_dt<0.) ) &
+         &   CALL ctl_stop('rn_tide_ramp_dt must be positive')
+      !
+      ! Compute coefficients which are used in subroutine astronomic_angle to
+      ! compute sh_xi and sh_nu according to two equations given in the
+      ! explanation of Table 6 of S58
+      rxinu1 = COS( 0.5_wp * ( ABS( ACOS( rcice + rsise ) ) ) ) / COS( 0.5_wp * ( ACOS( rcice - rsise ) ) )
+      rxinu2 = SIN( 0.5_wp * ( ABS( ACOS( rcice + rsise ) ) ) ) / SIN( 0.5_wp * ( ACOS( rcice - rsise ) ) )
+      !
+      ! Initialise array used to store tidal oscillation parameters (frequency,
+      ! amplitude, phase); also retrieve and store array of information about
+      ! selected tidal components
+      CALL tide_init_harmonics(sn_tide_cnames, tide_harmonics, tide_components)
+      !
+      ! Number of active tidal components
+      nb_harmo = size(tide_components)
+      !       
+      ! Ensure that tidal components have been set in namelist_cfg
+      IF( nb_harmo == 0 )   CALL ctl_stop( 'tide_init : No tidal components set in nam_tide' )
+      !
+      IF (.NOT.ln_scal_load ) rn_scal_load = 0._wp
+      !
+      ALLOCATE( amp_pot(jpi,jpj,nb_harmo),                      &
+           &      phi_pot(jpi,jpj,nb_harmo), pot_astro(jpi,jpj)   )
+      IF( ln_tide_dia ) ALLOCATE( pot_astro_comp(jpi,jpj) )
+      IF( ln_read_load ) THEN
+         ALLOCATE( amp_load(jpi,jpj,nb_harmo), phi_load(jpi,jpj,nb_harmo) )
+         CALL tide_init_load
+         amp_pot(:,:,:) = amp_load(:,:,:)
+         phi_pot(:,:,:) = phi_load(:,:,:)
+      ELSE		
+         amp_pot(:,:,:) = 0._wp
+         phi_pot(:,:,:) = 0._wp	 
+      ENDIF
+      !
+   END SUBROUTINE tide_init
+
+
+   SUBROUTINE tide_init_components(pcnames, ptide_comp)
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE tide_init_components  ***
+      !!
+      !! Returns pointer to array of variables of type 'tide' that contain
+      !! information about the selected tidal components
+      !! ----------------------------------------------------------------------
+      CHARACTER(LEN=4),              DIMENSION(jpmax_harmo), INTENT(in)  ::   pcnames             ! Names of selected components
+      TYPE(tide),       POINTER,     DIMENSION(:),           INTENT(out) ::   ptide_comp          ! Selected components
+      INTEGER,          ALLOCATABLE, DIMENSION(:)                        ::   icomppos            ! Indices of selected components
+      INTEGER                                                            ::   icomp, jk, jj, ji   ! Miscellaneous integers
+      LOGICAL                                                            ::   llmatch             ! Local variables used for
+      INTEGER                                                            ::   ic1, ic2            !    string comparison
+      TYPE(tide),       POINTER,     DIMENSION(:)                        ::   tide_components     ! All available components
+      
+      ! Populate local array with information about all available tidal
+      ! components
+      !
+      ! Note, here 'tide_components' locally overrides the global module
+      ! variable of the same name to enable the use of the global name in the
+      ! include file that contains the initialisation of elements of array
+      ! 'tide_components'
+      ALLOCATE(tide_components(jpmax_harmo), icomppos(jpmax_harmo))
+      ! Initialise array of indices of the selected componenents
+      icomppos(:) = 0
+      ! Include tidal component parameters for all available components
+      IF (nn_tide_var < 1) THEN
+#define TIDE_VAR_0
+#include "tide.h90"
+#undef TIDE_VAR_0
+      ELSE
+#include "tide.h90"
+      END IF
+      ! Identify the selected components that are availble
+      icomp = 0
+      DO jk = 1, jpmax_harmo
+         IF (TRIM(pcnames(jk)) /= '') THEN
+            DO jj = 1, jpmax_harmo
+               ! Find matches between selected and available constituents
+               ! (ignore capitalisation unless legacy variant has been selected)
+               IF (nn_tide_var < 1) THEN
+                  llmatch = (TRIM(pcnames(jk)) == TRIM(tide_components(jj)%cname_tide))
+               ELSE
+                  llmatch = .TRUE.
+                  ji = MAX(LEN_TRIM(pcnames(jk)), LEN_TRIM(tide_components(jj)%cname_tide))
+                  DO WHILE (llmatch.AND.(ji > 0))
+                     ic1 = IACHAR(pcnames(jk)(ji:ji))
+                     IF ((ic1 >= 97).AND.(ic1 <= 122)) ic1 = ic1 - 32
+                     ic2 = IACHAR(tide_components(jj)%cname_tide(ji:ji))
+                     IF ((ic2 >= 97).AND.(ic2 <= 122)) ic2 = ic2 - 32
+                     llmatch = (ic1 == ic2)
+                     ji = ji - 1
+                  END DO
+               END IF
+               IF (llmatch) THEN
+                  ! Count and record the match
+                  icomp = icomp + 1
+                  icomppos(icomp) = jj
+                  ! Set the capitalisation of the tidal constituent identifier
+                  ! as specified in the namelist
+                  tide_components(jj)%cname_tide = pcnames(jk)
+                  IF (lwp) WRITE(numout, '(10X,"Tidal component #",I2.2,36X,"= ",A4)') icomp, tide_components(jj)%cname_tide
+                  EXIT
+               END IF
+            END DO
+            IF ((lwp).AND.(jj > jpmax_harmo)) WRITE(numout, '(10X,"Tidal component ",A4," is not available!")') pcnames(jk)
+         END IF
+      END DO
+      
+      ! Allocate and populate reduced list of components
+      ALLOCATE(ptide_comp(icomp))
+      DO jk = 1, icomp
+         ptide_comp(jk) = tide_components(icomppos(jk))
+      END DO
+      
+      ! Release local array of available components and list of selected
+      ! components
+      DEALLOCATE(tide_components, icomppos)
+      
+   END SUBROUTINE tide_init_components
+
+
+   SUBROUTINE tide_init_harmonics(pcnames, ptide_harmo, ptide_comp)
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE tide_init_harmonics  ***
+      !!
+      !! Returns pointer to array of variables of type 'tide_harmonics' that
+      !! contain oscillation parameters of the selected harmonic tidal
+      !! components
+      !! ----------------------------------------------------------------------
+      CHARACTER(LEN=4),             DIMENSION(jpmax_harmo), INTENT(in) ::   pcnames     ! Names of selected components
+      TYPE(tide_harmonic), POINTER, DIMENSION(:)                       ::   ptide_harmo ! Oscillation parameters of tidal components
+      TYPE(tide),          POINTER, DIMENSION(:), OPTIONAL             ::   ptide_comp  ! Selected components
+      TYPE(tide),          POINTER, DIMENSION(:)                       ::   ztcomp      ! Selected components
+
+      ! Retrieve information about selected tidal components
+      ! If requested, prepare tidal component array for returning
+      IF (PRESENT(ptide_comp)) THEN
+         CALL tide_init_components(pcnames, ptide_comp)
+         ztcomp => ptide_comp
+      ELSE
+         CALL tide_init_components(pcnames, ztcomp)
+      END IF
+
+      ! Allocate and populate array of oscillation parameters
+      ALLOCATE(ptide_harmo(size(ztcomp)))
+      ptide_harmo(:)%cname_tide = ztcomp(:)%cname_tide
+      ptide_harmo(:)%equitide = ztcomp(:)%equitide
+      CALL tide_harmo(ztcomp, ptide_harmo)
+
+   END SUBROUTINE tide_init_harmonics
+
+
+   SUBROUTINE tide_init_potential
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE tide_init_potential  ***
+      !!
+      !! ** Reference :
+      !!      CT71) Cartwright, D. E. and Tayler, R. J. (1971): New computations of
+      !!            the Tide-generating Potential. Geophys. J. R. astr. Soc. 23,
+      !!            pp. 45-74. DOI: 10.1111/j.1365-246X.1971.tb01803.x
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zcons, ztmp1, ztmp2, zlat, zlon, ztmp, zamp, zcs   ! local scalar
+      !!----------------------------------------------------------------------
+
+      IF( ln_read_load ) THEN
+	 amp_pot(:,:,:) = amp_load(:,:,:)
+	 phi_pot(:,:,:) = phi_load(:,:,:)
+      ELSE		
+         amp_pot(:,:,:) = 0._wp
+         phi_pot(:,:,:) = 0._wp	 
+      ENDIF
+      DO jk = 1, nb_harmo
+         zcons = rn_tide_gamma * tide_components(jk)%equitide * tide_harmonics(jk)%f
+         DO ji = 1, jpi
+            DO jj = 1, jpj
+               ztmp1 =  tide_harmonics(jk)%f * amp_pot(ji,jj,jk) * COS( phi_pot(ji,jj,jk) &
+                  &                                                   + tide_harmonics(jk)%v0 + tide_harmonics(jk)%u )
+               ztmp2 = -tide_harmonics(jk)%f * amp_pot(ji,jj,jk) * SIN( phi_pot(ji,jj,jk) &
+                  &                                                   + tide_harmonics(jk)%v0 + tide_harmonics(jk)%u )
+               zlat = gphit(ji,jj)*rad !! latitude en radian
+               zlon = glamt(ji,jj)*rad !! longitude en radian
+               ztmp = tide_harmonics(jk)%v0 + tide_harmonics(jk)%u + tide_components(jk)%nt * zlon
+               ! le potentiel est composé des effets des astres:
+               SELECT CASE( tide_components(jk)%nt )
+               CASE( 0 )                                                  !   long-periodic tidal constituents (included unless
+                  zcs = zcons * ( 0.5_wp - 1.5_wp * SIN( zlat )**2 )      !   compatibility with original formulation is requested)
+                  IF ( nn_tide_var < 1 ) zcs = 0.0_wp
+               CASE( 1 )                                                  !   diurnal tidal constituents
+                  zcs = zcons * SIN( 2.0_wp*zlat )
+               CASE( 2 )                                                  !   semi-diurnal tidal constituents
+                  zcs = zcons * COS( zlat )**2
+               CASE( 3 )                                                  !   Terdiurnal tidal constituents; the colatitude-dependent
+                  zcs = zcons * COS( zlat )**3                            !   factor is sin(theta)^3 (Table 2 of CT71)
+               CASE DEFAULT                                               !   constituents of higher frequency are not included
+                  zcs = 0.0_wp
+               END SELECT
+               ztmp1 = ztmp1 + zcs * COS( ztmp )
+               ztmp2 = ztmp2 - zcs * SIN( ztmp )
+               zamp = SQRT( ztmp1*ztmp1 + ztmp2*ztmp2 )
+               amp_pot(ji,jj,jk) = zamp
+               phi_pot(ji,jj,jk) = ATAN2( -ztmp2 / MAX( 1.e-10_wp , zamp ) ,   &
+                  &                        ztmp1 / MAX( 1.e-10_wp,  zamp )   )
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE tide_init_potential
+
+
+   SUBROUTINE tide_init_load
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE tide_init_load  ***
+      !!----------------------------------------------------------------------
+      INTEGER :: inum                 ! Logical unit of input file
+      INTEGER :: ji, jj, itide        ! dummy loop indices
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztr, zti   !: workspace to read in tidal harmonics data 
+      !!----------------------------------------------------------------------
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'tide_init_load : Initialization of load potential from file'
+         WRITE(numout,*) '~~~~~~~~~~~~~~ '
+      ENDIF
+      !
+      CALL iom_open ( cn_tide_load , inum )
+      !
+      DO itide = 1, nb_harmo
+         CALL iom_get  ( inum, jpdom_data,TRIM(tide_components(itide)%cname_tide)//'_z1', ztr(:,:) )
+         CALL iom_get  ( inum, jpdom_data,TRIM(tide_components(itide)%cname_tide)//'_z2', zti(:,:) )
+         !
+         DO ji=1,jpi
+            DO jj=1,jpj
+               amp_load(ji,jj,itide) =  SQRT( ztr(ji,jj)**2. + zti(ji,jj)**2. )
+               phi_load(ji,jj,itide) = ATAN2(-zti(ji,jj), ztr(ji,jj) )
+            END DO
+         END DO
+         !
+      END DO
+      CALL iom_close( inum )
+      !
+   END SUBROUTINE tide_init_load
+
+
+   SUBROUTINE tide_update( kt )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE tide_update  ***
+      !!----------------------------------------------------------------------      
+      INTEGER, INTENT( in ) ::   kt     ! ocean time-step
+      INTEGER               ::   jk     ! dummy loop index
+      !!----------------------------------------------------------------------
+      
+      IF( nsec_day == NINT(0.5_wp * rdt) .OR. kt == nit000 ) THEN      ! start a new day
+         !
+         CALL tide_harmo(tide_components, tide_harmonics, ndt05) ! Update oscillation parameters of tidal components for start of current day
+         !
+         !
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'tide_update : Update of the components and (re)Init. the potential at kt=', kt
+            WRITE(numout,*) '~~~~~~~~~~~ '
+            DO jk = 1, nb_harmo
+               WRITE(numout,*) tide_harmonics(jk)%cname_tide, tide_harmonics(jk)%u, &
+                  &            tide_harmonics(jk)%f,tide_harmonics(jk)%v0, tide_harmonics(jk)%omega
+            END DO
+         ENDIF
+         !
+         IF( ln_tide_pot )   CALL tide_init_potential
+         !
+         rn_tide_ramp_t = (kt - nit000)*rdt !   Elapsed time in seconds
+      ENDIF
+      !
+   END SUBROUTINE tide_update
+
+
+   SUBROUTINE tide_harmo( ptide_comp, ptide_harmo, psec_day )
+      !
+      TYPE(tide),          DIMENSION(:), POINTER ::   ptide_comp   ! Array of selected tidal component parameters
+      TYPE(tide_harmonic), DIMENSION(:), POINTER ::   ptide_harmo  ! Oscillation parameters of selected tidal components
+      INTEGER, OPTIONAL ::   psec_day                              ! Number of seconds since the start of the current day
+      !
+      IF (PRESENT(psec_day)) THEN 
+         CALL astronomic_angle(psec_day)
+      ELSE
+         CALL astronomic_angle(nsec_day)
+      END IF
+      CALL tide_pulse( ptide_comp, ptide_harmo )
+      CALL tide_vuf(   ptide_comp, ptide_harmo )
+      !
+   END SUBROUTINE tide_harmo
+
+
+   SUBROUTINE astronomic_angle(psec_day)
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE astronomic_angle  ***
+      !!                      
+      !! ** Purpose : Compute astronomic angles
+      !!----------------------------------------------------------------------
+      INTEGER  ::   psec_day !   Number of seconds from midnight
+      REAL(wp) ::   zp, zq, zt2, zs2, ztgI2, zP1, ztgn2, zat1, zat2
+      REAL(wp) ::   zqy , zsy, zday, zdj, zhfrac, zt
+      !!----------------------------------------------------------------------
+      !
+      ! Computation of the time from 1 Jan 1900, 00h in years
+      zqy = AINT( (nyear - 1901.0_wp) / 4.0_wp )
+      zsy = nyear - 1900.0_wp
+      !
+      zdj  = dayjul( nyear, nmonth, nday )
+      zday = zdj + zqy - 1.0_wp
+      !
+      zhfrac = psec_day / 3600.0_wp
+      !
+      zt = zsy * 365.0_wp * 24.0_wp + zday * 24.0_wp + zhfrac
+      !
+      ! Longitude of ascending lunar node
+      sh_N  = ( rlon00_N  + romega_N * zt     ) * rad
+      sh_N = MOD( sh_N,  2*rpi )
+      ! Mean solar angle (Greenwhich time)
+      sh_T  = ( rlon00_T  + romega_T * zhfrac ) * rad
+      ! Mean solar Longitude
+      sh_h  = ( rlon00_h  + romega_h * zt     ) * rad
+      sh_h = MOD( sh_h,  2*rpi )
+      ! Mean lunar Longitude
+      sh_s  = ( rlon00_s  + romega_s * zt     ) * rad
+      sh_s = MOD( sh_s,  2*rpi )
+      ! Longitude of solar perigee
+      sh_p1 = ( rlon00_p1 + romega_p1 * zt    ) * rad
+      sh_p1= MOD( sh_p1, 2*rpi )
+      ! Longitude of lunar perigee
+      sh_p  = ( rlon00_p  + romega_p  * zt    ) * rad
+      sh_p = MOD( sh_p,  2*rpi )
+      !
+      ! Inclination of the orbit of the moon w.r.t. the celestial equator, see
+      ! explanation of Table 6 of S58
+      sh_I = ACOS( rcice - rsise * COS( sh_N ) )
+      !
+      ! Computation of sh_xi and sh_nu, see explanation of Table 6 of S58
+      ztgn2 = TAN( sh_N / 2.0_wp )
+      zat1 = ATAN( rxinu1 * ztgn2 )
+      zat2 = ATAN( rxinu2 * ztgn2 )
+      sh_xi = sh_N - zat1 - zat2
+      IF( sh_N > rpi ) sh_xi = sh_xi - 2.0_wp * rpi
+      sh_nu = zat1 - zat2
+      !
+      ! Computation of sh_x1ra, sh_R, sh_nuprim, and sh_nusec used for tidal
+      ! constituents L2, K1, and K2
+      !
+      ! Computation of sh_x1ra and sh_R (Equations 204, 213, and 214 of S58)
+      ztgI2 = tan( sh_I / 2.0_wp )
+      zP1   = sh_p - sh_xi
+      zt2   = ztgI2 * ztgI2
+      sh_x1ra = SQRT( 1.0 - 12.0 * zt2 * COS( 2.0_wp * zP1 ) + 36.0_wp * zt2 * zt2 )
+      zp = SIN( 2.0_wp * zP1 )
+      zq = 1.0_wp / ( 6.0_wp * zt2 ) - COS( 2.0_wp * zP1 )
+      sh_R = ATAN( zp / zq )
+      !
+      ! Computation of sh_nuprim (Equation 224 of S58)
+      zp = SIN( 2.0_wp * sh_I ) * SIN( sh_nu )
+      zq = SIN( 2.0_wp * sh_I ) * COS( sh_nu ) + 0.3347_wp
+      sh_nuprim = ATAN( zp / zq )
+      !
+      ! Computation of sh_nusec  (Equation 232 of S58)
+      zs2 = SIN( sh_I ) * SIN( sh_I )
+      zp  = zs2 * SIN( 2.0_wp * sh_nu )
+      zq  = zs2 * COS( 2.0_wp * sh_nu ) + 0.0727_wp
+      sh_nusec = 0.5_wp * ATAN( zp / zq )
+      !
+   END SUBROUTINE astronomic_angle
+
+
+   SUBROUTINE tide_pulse( ptide_comp, ptide_harmo )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE tide_pulse  ***
+      !!                      
+      !! ** Purpose : Compute tidal frequencies
+      !!----------------------------------------------------------------------
+      TYPE(tide),          DIMENSION(:), POINTER ::   ptide_comp   ! Array of selected tidal component parameters
+      TYPE(tide_harmonic), DIMENSION(:), POINTER ::   ptide_harmo  ! Oscillation parameters of selected tidal components
+      !
+      INTEGER  ::   jh
+      REAL(wp) ::   zscale
+      !!----------------------------------------------------------------------
+      !
+      zscale =  rad / 3600.0_wp
+      !
+      DO jh = 1, size(ptide_harmo)
+         ptide_harmo(jh)%omega = (  romega_T * ptide_comp( jh )%nT   &
+            &                     + romega_s * ptide_comp( jh )%ns   &
+            &                     + romega_h * ptide_comp( jh )%nh   &
+            &                     + romega_p * ptide_comp( jh )%np   &
+            &                     + romega_p1* ptide_comp( jh )%np1  ) * zscale
+      END DO
+      !
+   END SUBROUTINE tide_pulse
+
+
+   SUBROUTINE tide_vuf( ptide_comp, ptide_harmo )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE tide_vuf  ***
+      !!                      
+      !! ** Purpose : Compute nodal modulation corrections
+      !!
+      !! ** Outputs : vt: Phase of tidal potential relative to Greenwich (radians)
+      !!              ut: Phase correction u due to nodal motion (radians)
+      !!              ft: Nodal correction factor
+      !!----------------------------------------------------------------------
+      TYPE(tide),          DIMENSION(:), POINTER ::   ptide_comp   ! Array of selected tidal component parameters
+      TYPE(tide_harmonic), DIMENSION(:), POINTER ::   ptide_harmo  ! Oscillation parameters of selected tidal components
+      !
+      INTEGER ::   jh   ! dummy loop index
+      !!----------------------------------------------------------------------
+      !
+      DO jh = 1, size(ptide_harmo)
+         !  Phase of the tidal potential relative to the Greenwhich 
+         !  meridian (e.g. the position of the fictuous celestial body). Units are radian:
+         ptide_harmo(jh)%v0 = sh_T * ptide_comp( jh )%nT    &
+            &                   + sh_s * ptide_comp( jh )%ns    &
+            &                   + sh_h * ptide_comp( jh )%nh    &
+            &                   + sh_p * ptide_comp( jh )%np    &
+            &                   + sh_p1* ptide_comp( jh )%np1   &
+            &                   +        ptide_comp( jh )%shift * rad
+         !
+         !  Phase correction u due to nodal motion. Units are radian:
+         ptide_harmo(jh)%u = sh_xi     * ptide_comp( jh )%nksi   &
+            &                  + sh_nu     * ptide_comp( jh )%nnu0   &
+            &                  + sh_nuprim * ptide_comp( jh )%nnu1   &
+            &                  + sh_nusec  * ptide_comp( jh )%nnu2   &
+            &                  + sh_R      * ptide_comp( jh )%R
+
+         !  Nodal correction factor:
+         ptide_harmo(jh)%f = nodal_factort( ptide_comp( jh )%nformula )
+      END DO
+      !
+   END SUBROUTINE tide_vuf
+
+
+   RECURSIVE FUNCTION nodal_factort( kformula ) RESULT( zf )
+      !!----------------------------------------------------------------------
+      !!                  ***  FUNCTION nodal_factort  ***
+      !!
+      !! ** Purpose : Compute amplitude correction factors due to nodal motion
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kformula
+      !
+      REAL(wp)            ::   zf
+      REAL(wp)            ::   zs, zf1, zf2
+      CHARACTER(LEN=3)    ::   clformula
+      !!----------------------------------------------------------------------
+      !
+      SELECT CASE( kformula )
+      !
+      CASE( 0 )                  ! Formula 0, solar waves
+         zf = 1.0
+         !
+      CASE( 1 )                  ! Formula 1, compound waves (78 x 78)
+         zf=nodal_factort( 78 )
+         zf = zf * zf
+         !
+      CASE ( 4 )                 ! Formula 4,  compound waves (78 x 235) 
+         zf1 = nodal_factort( 78 )
+         zf  = nodal_factort(235)
+         zf  = zf1 * zf
+         !
+      CASE( 18 )                 ! Formula 18,  compound waves (78 x 78 x 78 )
+         zf1 = nodal_factort( 78 )
+         zf  = zf1 * zf1 * zf1
+         !
+      CASE( 20 )                 ! Formula 20, compound waves ( 78 x 78 x 78 x 78 )
+         zf1 = nodal_factort( 78 )
+         zf  = zf1 * zf1 * zf1 * zf1
+         !
+      CASE( 73 )                 ! Formula 73 of S58
+         zs = SIN( sh_I )
+         zf = ( 2.0_wp / 3.0_wp - zs * zs ) / 0.5021_wp
+         !
+      CASE( 74 )                 ! Formula 74 of S58
+         zs = SIN(sh_I)
+         zf = zs * zs / 0.1578_wp
+         !
+      CASE( 75 )                 ! Formula 75 of S58
+         zs = COS( sh_I / 2.0_wp )
+         zf = SIN( sh_I ) * zs * zs / 0.3800_wp
+         !
+      CASE( 76 )                 ! Formula 76 of S58
+         zf = SIN( 2.0_wp * sh_I ) / 0.7214_wp
+         !
+      CASE( 78 )                 ! Formula 78 of S58
+         zs = COS( sh_I/2 )
+         zf = zs * zs * zs * zs / 0.9154_wp
+         !
+      CASE( 149 )                ! Formula 149 of S58
+         zs = COS( sh_I/2 )
+         zf = zs * zs * zs * zs * zs * zs / 0.8758_wp
+         !
+      CASE( 215 )                ! Formula 215 of S58 with typo correction (0.9154 instead of 0.9145)
+         zs = COS( sh_I/2 )
+         zf = zs * zs * zs * zs / 0.9154_wp * sh_x1ra
+         !
+      CASE( 227 )                ! Formula 227 of S58
+         zs = SIN( 2.0_wp * sh_I )
+         zf = SQRT( 0.8965_wp * zs * zs + 0.6001_wp * zs * COS( sh_nu ) + 0.1006_wp )
+         !
+      CASE ( 235 )               ! Formula 235 of S58
+         zs = SIN( sh_I )
+         zf = SQRT( 19.0444_wp * zs * zs * zs * zs + 2.7702_wp * zs * zs * cos( 2.0_wp * sh_nu ) + 0.0981_wp )
+         !
+      CASE DEFAULT
+         WRITE( clformula, '(I3)' ) kformula
+         CALL ctl_stop('nodal_factort: formula ' // clformula // ' is not available')
+      END SELECT
+      !
+   END FUNCTION nodal_factort
+
+
+   FUNCTION dayjul( kyr, kmonth, kday )
+      !!----------------------------------------------------------------------
+      !!                   ***  FUNCTION dayjul  ***
+      !!
+      !! Purpose :  compute the Julian day
+      !!----------------------------------------------------------------------
+      INTEGER,INTENT(in)    ::   kyr, kmonth, kday
+      !
+      INTEGER,DIMENSION(12) ::   idayt = (/ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 /)
+      INTEGER,DIMENSION(12) ::   idays
+      INTEGER               ::   inc, ji, zyq
+      REAL(wp)              ::   dayjul
+      !!----------------------------------------------------------------------
+      !
+      idays(1) = 0
+      idays(2) = 31
+      inc = 0.0_wp
+      zyq = MOD( kyr - 1900 , 4 )
+      IF( zyq == 0 ) inc = 1
+      DO ji = 3, 12
+         idays(ji) = idayt(ji) + inc
+      END DO
+      dayjul = REAL( idays(kmonth) + kday, KIND=wp )
+      !
+   END FUNCTION dayjul
+
+
+   SUBROUTINE upd_tide(pdelta)
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE upd_tide  ***
+      !!
+      !! ** Purpose :   provide at each time step the astronomical potential
+      !!
+      !! ** Method  :   computed from pulsation and amplitude of all tide components
+      !!
+      !! ** Action  :   pot_astro   actronomical potential
+      !!----------------------------------------------------------------------      
+      REAL, INTENT(in)              ::   pdelta      ! Temporal offset in seconds
+      INTEGER                       ::   jk          ! Dummy loop index
+      REAL(wp)                      ::   zt, zramp   ! Local scalars
+      REAL(wp), DIMENSION(nb_harmo) ::   zwt         ! Temporary array
+      !!----------------------------------------------------------------------      
+      !
+      zwt(:) = tide_harmonics(:)%omega * pdelta
+      !
+      IF( ln_tide_ramp ) THEN         ! linear increase if asked
+         zt = rn_tide_ramp_t + pdelta
+         zramp = MIN(  MAX( zt / (rn_tide_ramp_dt*rday) , 0._wp ) , 1._wp  )
+      ENDIF
+      !
+      pot_astro(:,:) = 0._wp          ! update tidal potential (sum of all harmonics)
+      DO jk = 1, nb_harmo
+         IF ( .NOT. ln_tide_dia ) THEN
+            pot_astro(:,:) = pot_astro(:,:) + amp_pot(:,:,jk) * COS( zwt(jk) + phi_pot(:,:,jk) )
+         ELSE
+            pot_astro_comp(:,:) = amp_pot(:,:,jk) * COS( zwt(jk) + phi_pot(:,:,jk) )
+            pot_astro(:,:) = pot_astro(:,:) + pot_astro_comp(:,:)
+            IF ( iom_use( "tide_pot_" // TRIM( tide_harmonics(jk)%cname_tide ) ) ) THEN   ! Output tidal potential (incl. load potential)
+               IF ( ln_tide_ramp ) pot_astro_comp(:,:) = zramp * pot_astro_comp(:,:)
+               CALL iom_put( "tide_pot_" // TRIM( tide_harmonics(jk)%cname_tide ), pot_astro_comp(:,:) )
+            END IF
+         END IF
+      END DO
+      !
+      IF ( ln_tide_ramp ) pot_astro(:,:) = zramp * pot_astro(:,:)
+      !
+      IF( ln_tide_dia ) THEN          ! Output total tidal potential (incl. load potential)
+         IF ( iom_use( "tide_pot" ) ) CALL iom_put( "tide_pot", pot_astro(:,:) + rn_scal_load * sshn(:,:) )
+      END IF
+      !
+   END SUBROUTINE upd_tide
+
+   !!======================================================================
+END MODULE tide_mod
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/nemogcm.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/nemogcm.F90	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/nemogcm.F90	(revision 12184)
@@ -46,5 +46,5 @@
    USE closea         ! treatment of closed seas (for ln_closea)
    USE usrdef_nam     ! user defined configuration
-   USE tideini        ! tidal components initialization   (tide_ini routine)
+   USE tide_mod, ONLY : tide_init ! tidal components initialization   (tide_init routine)
    USE bdy_oce,  ONLY : ln_bdy
    USE bdyini         ! open boundary cond. setting       (bdy_init routine)
@@ -59,5 +59,5 @@
    USE diaobs         ! Observation diagnostics       (dia_obs_init routine)
    USE diacfl         ! CFL diagnostics               (dia_cfl_init routine)
-   USE diaharm        ! tidal harmonics diagnostics  (dia_harm_init routine)
+   USE diamlr         ! IOM context management for multiple-linear-regression analysis
    USE step           ! NEMO time-stepping                 (stp     routine)
    USE isfstp         ! ice shelf                     (isf_stp_init routine)
@@ -75,4 +75,5 @@
    USE diatmb         ! Top,middle,bottom output
    USE dia25h         ! 25h mean output
+   USE diadetide      ! Weights computation for daily detiding of model diagnostics
    USE sbc_oce , ONLY : lk_oasis
    USE wet_dry        ! Wetting and drying setting   (wad_init routine)
@@ -491,6 +492,7 @@
                            CALL dia_tmb_init    ! TMB outputs
                            CALL dia_25h_init    ! 25h mean  outputs
-                           CALL dia_harm_init   ! tidal harmonics outputs
+                           CALL dia_detide_init ! Weights computation for daily detiding of model diagnostics
      IF( ln_diaobs    )    CALL dia_obs( nit000-1 )   ! Observation operator for restart
+                           CALL dia_mlr_init    ! Initialisation of IOM context management for multiple-linear-regression analysis
 
       !                                      ! Assimilation increments
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/step.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/step.F90	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/step.F90	(revision 12184)
@@ -100,5 +100,7 @@
                              
       IF( kstp == nit000 ) THEN                       ! initialize IOM context (must be done after nemo_init for AGRIF+XIOS+OASIS)
-                             CALL iom_init(      cxios_context          )  ! for model grid (including passible AGRIF zoom)
+                             CALL iom_init( cxios_context, ld_closedef=.FALSE. )   ! for model grid (including passible AGRIF zoom)
+         IF( lk_diamlr   )   CALL dia_mlr_iom_init    ! with additional setup for multiple-linear-regression analysis
+                             CALL iom_init_closedef
          IF( ln_crs      )   CALL iom_init( TRIM(cxios_context)//"_crs" )  ! for coarse grid
       ENDIF
@@ -110,5 +112,5 @@
       ! Update external forcing (tides, open boundaries, and surface boundary condition (including sea-ice)
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      IF( ln_tide    )   CALL sbc_tide( kstp )                   ! update tide potential
+      IF( ln_tide    )   CALL tide_update( kstp )                ! update tide potential
       IF( ln_apr_dyn )   CALL sbc_apr ( kstp )                   ! atmospheric pressure (NB: call before bdy_dta which needs ssh_ib) 
       IF( ln_bdy     )   CALL bdy_dta ( kstp, kt_offset = +1 )   ! update dynamic & tracer data at open boundaries
@@ -209,7 +211,8 @@
                          CALL dia_ar5 ( kstp )        ! ar5 diag
                          CALL dia_ptr ( kstp )        ! Poleward adv/ldf TRansports diagnostics
-      IF( ln_diaharm )   CALL dia_harm( kstp )        ! Tidal harmonic analysis
                          CALL dia_wri ( kstp )        ! ocean model: outputs
       !
+      IF( lk_diadetide ) CALL dia_detide( kstp )      ! Weights computation for daily detiding of model diagnostics
+      IF( lk_diamlr  )   CALL dia_mlr                 ! Update time used in multiple-linear-regression analysis
       IF( ln_crs     )   CALL crs_fld       ( kstp )  ! ocean model: online field coarsening & output
       
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/step_oce.F90
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/step_oce.F90	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/OCE/step_oce.F90	(revision 12184)
@@ -19,5 +19,5 @@
    USE sbccpl          ! surface boundary condition: coupled formulation (call send at end of step)
    USE sbcapr          ! surface boundary condition: atmospheric pressure
-   USE sbctide         ! Tide initialisation
+   USE tide_mod, ONLY : ln_tide, tide_update
    USE sbcwave         ! Wave intialisation
 
@@ -83,7 +83,8 @@
    USE diahth          ! thermocline depth                (dia_hth routine)
    USE diahsb          ! heat, salt and volume budgets    (dia_hsb routine)
-   USE diaharm
    USE diacfl
    USE diaobs          ! Observation operator
+   USE diadetide       ! Weights computation for daily detiding of model diagnostics
+   USE diamlr          ! IOM context management for multiple-linear-regression analysis
    USE flo_oce         ! floats variables
    USE floats          ! floats computation               (flo_stp routine)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/CANAL/EXPREF/field_def_nemo-oce.xml
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/CANAL/EXPREF/field_def_nemo-oce.xml	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/CANAL/EXPREF/field_def_nemo-oce.xml	(revision 12184)
@@ -110,82 +110,4 @@
          <field id="tpt_dep"      long_name="T-point depth"                  standard_name="depth_below_geoid"   unit="m"   grid_ref="grid_T_3D" />
          <field id="e3tdef"       long_name="T-cell thickness deformation"                                       unit="%"   grid_ref="grid_T_3D" />
-      </field_group>
-
-      <!-- Tides -->
-
-      <field_group id="Tides_T" grid_ref="grid_T_2D" operation="once" >
-         <!-- tidal composante -->
-         <field id="M2x"          long_name="M2 Elevation harmonic real part "                             unit="m"        />
-         <field id="M2y"          long_name="M2 Elevation harmonic imaginary part"                         unit="m"        />
-         <field id="S2x"          long_name="S2 Elevation harmonic real part "                             unit="m"        />
-         <field id="S2y"          long_name="S2 Elevation harmonic imaginary part"                         unit="m"        />
-         <field id="N2x"          long_name="N2 Elevation harmonic real part "                             unit="m"        />
-         <field id="N2y"          long_name="N2 Elevation harmonic imaginary part"                         unit="m"        />
-         <field id="K1x"          long_name="K1 Elevation harmonic real part "                             unit="m"        />
-         <field id="K1y"          long_name="K1 Elevation harmonic imaginary part"                         unit="m"        />
-         <field id="O1x"          long_name="O1 Elevation harmonic real part "                             unit="m"        />
-         <field id="O1y"          long_name="O1 Elevation harmonic imaginary part"                         unit="m"        />
-         <field id="Q1x"          long_name="Q1 Elevation harmonic real part "                             unit="m"        />
-         <field id="Q1y"          long_name="Q1 Elevation harmonic imaginary part"                         unit="m"        />
-         <field id="M4x"          long_name="M4 Elevation harmonic real part "                             unit="m"        />
-         <field id="M4y"          long_name="M4 Elevation harmonic imaginary part"                         unit="m"        />
-         <field id="K2x"          long_name="K2 Elevation harmonic real part "                             unit="m"        />
-         <field id="K2y"          long_name="K2 Elevation harmonic imaginary part"                         unit="m"        />
-         <field id="P1x"          long_name="P1 Elevation harmonic real part "                             unit="m"        />
-         <field id="P1y"          long_name="P1 Elevation harmonic imaginary part"                         unit="m"        />
-         <field id="Mfx"          long_name="Mf Elevation harmonic real part "                             unit="m"        />
-         <field id="Mfy"          long_name="Mf Elevation harmonic imaginary part"                         unit="m"        />
-         <field id="Mmx"          long_name="Mm Elevation harmonic real part "                             unit="m"        />
-         <field id="Mmy"          long_name="Mm Elevation harmonic imaginary part"                         unit="m"        />
-      </field_group>
-	 
-      <field_group id="Tides_U" grid_ref="grid_U_2D" operation="once" >
-         <field id="M2x_u"        long_name="M2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-         <field id="M2y_u"        long_name="M2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="S2x_u"        long_name="S2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-         <field id="S2y_u"        long_name="S2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="N2x_u"        long_name="N2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-         <field id="N2y_u"        long_name="N2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="K1x_u"        long_name="K1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-         <field id="K1y_u"        long_name="K1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="O1x_u"        long_name="O1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-         <field id="O1y_u"        long_name="O1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="Q1x_u"        long_name="Q1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-         <field id="Q1y_u"        long_name="Q1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="M4x_u"        long_name="M4 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-         <field id="M4y_u"        long_name="M4 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="K2x_u"        long_name="K2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-         <field id="K2y_u"        long_name="K2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="P1x_u"        long_name="P1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
-         <field id="P1y_u"        long_name="P1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="Mfx_u"        long_name="Mf current barotrope along i-axis harmonic real part "        unit="m/s"      />
-         <field id="Mfy_u"        long_name="Mf current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="Mmx_u"        long_name="Mm current barotrope along i-axis harmonic real part "        unit="m/s"      />
-         <field id="Mmy_u"        long_name="Mm current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
-      </field_group>
-	 
-      <field_group id="Tides_V" grid_ref="grid_V_2D" operation="once" >
-         <field id="M2x_v"        long_name="M2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-         <field id="M2y_v"        long_name="M2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="S2x_v"        long_name="S2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-         <field id="S2y_v"        long_name="S2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="N2x_v"        long_name="N2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-         <field id="N2y_v"        long_name="N2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="K1x_v"        long_name="K1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-         <field id="K1y_v"        long_name="K1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="O1x_v"        long_name="O1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-         <field id="O1y_v"        long_name="O1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="Q1x_v"        long_name="Q1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-         <field id="Q1y_v"        long_name="Q1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="M4x_v"        long_name="M4 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-         <field id="M4y_v"        long_name="M4 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="K2x_v"        long_name="K2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-         <field id="K2y_v"        long_name="K2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="P1x_v"        long_name="P1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
-         <field id="P1y_v"        long_name="P1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="Mfx_v"        long_name="Mf current barotrope along j-axis harmonic real part "        unit="m/s"      />
-         <field id="Mfy_v"        long_name="Mf current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
-         <field id="Mmx_v"        long_name="Mm current barotrope along j-axis harmonic real part "        unit="m/s"      />
-         <field id="Mmy_v"        long_name="Mm current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />	 
       </field_group>
 
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/CANAL/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/CANAL/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/CANAL/EXPREF/namelist_cfg	(revision 12184)
@@ -276,5 +276,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV1D/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV1D/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV1D/EXPREF/namelist_cfg	(revision 12184)
@@ -202,5 +202,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV1D/EXPREF/namelist_cfg_120pts
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV1D/EXPREF/namelist_cfg_120pts	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV1D/EXPREF/namelist_cfg_120pts	(revision 12184)
@@ -202,5 +202,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV1D/EXPREF/namelist_cfg_240pts
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV1D/EXPREF/namelist_cfg_240pts	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV1D/EXPREF/namelist_cfg_240pts	(revision 12184)
@@ -202,5 +202,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV1D/EXPREF/namelist_cfg_60pts
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV1D/EXPREF/namelist_cfg_60pts	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV1D/EXPREF/namelist_cfg_60pts	(revision 12184)
@@ -202,5 +202,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV2D/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV2D/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_ADV2D/EXPREF/namelist_cfg	(revision 12184)
@@ -202,5 +202,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_AGRIF/EXPREF/1_namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_AGRIF/EXPREF/1_namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_AGRIF/EXPREF/1_namelist_cfg	(revision 12184)
@@ -202,5 +202,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_AGRIF/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_AGRIF/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ICE_AGRIF/EXPREF/namelist_cfg	(revision 12184)
@@ -202,5 +202,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ISOMIP/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ISOMIP/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/ISOMIP/EXPREF/namelist_cfg	(revision 12184)
@@ -428,5 +428,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_flux_ubs_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_flux_ubs_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_flux_ubs_cfg	(revision 12184)
@@ -276,5 +276,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_flux_ubs_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_flux_ubs_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_flux_ubs_cfg	(revision 12184)
@@ -294,5 +294,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/VORTEX/EXPREF/1_namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/VORTEX/EXPREF/1_namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/VORTEX/EXPREF/1_namelist_cfg	(revision 12184)
@@ -273,5 +273,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/VORTEX/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/VORTEX/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/VORTEX/EXPREF/namelist_cfg	(revision 12184)
@@ -264,5 +264,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default; OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
Index: /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/WAD/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/WAD/EXPREF/namelist_cfg	(revision 12183)
+++ /NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/tests/WAD/EXPREF/namelist_cfg	(revision 12184)
@@ -422,5 +422,4 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
 !!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
