New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
trdtrc_oce.F90 in branches/UKMO/r6232_collate_bgc_diagnostics/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/UKMO/r6232_collate_bgc_diagnostics/NEMOGCM/NEMO/TOP_SRC/TRP/trdtrc_oce.F90 @ 11134

Last change on this file since 11134 was 11134, checked in by jcastill, 5 years ago

Full set of changes as in the original branch

File size: 10.5 KB
Line 
1MODULE trdtrc_oce
2   !!======================================================================
3   !!                   ***  MODULE trdtrc_oce  ***
4   !! Ocean trends :   set tracer and momentum trend variables
5   !!======================================================================
6#if defined key_top   ||   defined key_esopa
7   !!----------------------------------------------------------------------
8   !!   'key_top'                                                TOP models
9   !!----------------------------------------------------------------------
10   USE par_oce       ! ocean parameters
11   USE par_trc       ! passive tracers parameters
12
13   IMPLICIT NONE
14   PUBLIC
15
16   !                                         !!* Namelist namtoptrd:  diagnostics on passive tracers trends
17   INTEGER  ::    nn_trd_trc                  !: time step frequency dynamics and tracers trends
18   INTEGER  ::    nn_ctls_trc                 !: control surface type for trends vertical integration
19   REAL(wp) ::    rn_ucf_trc                  !: unit conversion factor (for netCDF trends outputs)
20   LOGICAL  ::    ln_trdmxl_trc_instant       !: flag to diagnose inst./mean ML trc trends
21   LOGICAL  ::    ln_trdmxl_trc_restart       !: flag to restart mixed-layer trc diagnostics
22   CHARACTER(len=50) ::  cn_trdrst_trc_in     !: suffix of pass. tracer restart name (input)
23   CHARACTER(len=50) ::  cn_trdrst_trc_out    !: suffix of pass. tracer restart name (output)
24   ! --->>> FABM
25   ! LOGICAL, DIMENSION(jptra) ::   ln_trdtrc   !: large trends diagnostic to write or not (namelist)
26   ! FABM <<<---
27   ! +++>>> FABM
28   LOGICAL, DIMENSION(jpmaxtrc) ::   ln_trdtrc   !: large trends diagnostic to write or not (namelist)
29   ! FABM <<<+++
30
31# if defined key_trdtrc && defined key_iomput
32   LOGICAL, PARAMETER ::   lk_trdtrc = .TRUE. 
33# else
34   LOGICAL, PARAMETER ::   lk_trdtrc = .FALSE.   !: ML trend flag
35# endif
36
37# if defined key_trdmxl_trc   ||   defined key_esopa
38   !!----------------------------------------------------------------------
39   !!   'key_trdmxl_trc'                     mixed layer trends diagnostics
40   !!----------------------------------------------------------------------
41
42   LOGICAL, PARAMETER ::   lk_trdmxl_trc = .TRUE.    !: ML trend flag
43
44   INTEGER, PARAMETER ::            & !: mixed layer trends indices
45        jpmxl_trc_xad     =  1,     & !:     zonal       advection     
46        jpmxl_trc_yad     =  2,     & !:     meridonal   =========
47        jpmxl_trc_zad     =  3,     & !:     vertical    =========
48        jpmxl_trc_ldf     =  4,     & !:     lateral diffusion (geopot. or iso-neutral)
49        jpmxl_trc_zdf     =  5,     & !:     vertical diffusion (TKE)
50        jpmxl_trc_bbl     =  6,     & !:     bottom boundary layer (advective/diffusive)
51        jpmxl_trc_dmp     =  7,     & !:     internal restoring trend
52        jpmxl_trc_sbc     =  8,     & !:     forcing
53        jpmxl_trc_sms     =  9,     & !:     sources minus sinks trend
54  !     jpmxl_trc_xxx     = xx,     & !:     add here any additional trend    (** AND UPDATE JPLTRD_TRC BELOW **)
55        jpmxl_trc_radn    = 10,     & !:     corr. trn<0 in trcrad
56        jpmxl_trc_radb    = 11,     & !:     corr. trb<0 in trcrad (like atf) (** MUST BE BEFORE THE LAST ONE **)
57        jpmxl_trc_atf     = 12        !:     asselin trend                    (** MUST BE    THE      LAST ONE**)
58
59   !! Trends diagnostics parameters
60   !!---------------------------------------------------------------------
61   INTEGER, PARAMETER :: jpltrd_trc = 12    !: number of mixed-layer trends arrays
62     
63   INTEGER            :: jpktrd_trc         !: max level for mixed-layer trends diag.
64
65   !! Arrays used for diagnosing mixed-layer trends
66   !!---------------------------------------------------------------------
67   CHARACTER(LEN=80) :: clname_trc, ctrd_trc(jpltrd_trc+1,2)
68
69   INTEGER, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   &
70      nmld_trc       , &                            !: mixed layer depth indexes
71      nbol_trc                                   !: mixed-layer depth indexes when read from file
72
73   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  wkx_trc  !:
74
75   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::  rmld_trc     !: ML depth (m) corresponding to nmld_trc
76   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::  rmld_sum_trc !: needed to compute the leap-frog time mean of ML depth
77   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::  rmldbn_trc   !: idem
78
79   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  &
80      tml_trc    ,                        &      !: \ "now" mixed layer temperature/salinity
81      tmlb_trc   ,                        &      !: /  and associated "before" fields
82      tmlbb_trc  ,                        &      !: \  idem, but valid at the 1rst time step of the
83      tmlbn_trc  ,                        &      !: /  current analysis window
84      tml_sum_trc,                        &      !: mixed layer T, summed over the current analysis period
85      tml_sumb_trc,                       &      !: idem, but from the previous analysis period
86      tmltrd_atf_sumb_trc,                &      !: Asselin trends, summed over the previous analysis period
87      tmltrd_rad_sumb_trc                        !: trends due to trb correction in trcrad.F90, summed over the
88                                                 !:     previous analysis period
89                                                 
90   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  &     
91      tmlatfb_trc, tmlatfn_trc ,          &      !: "before" Asselin contrib. at beginning of the averaging
92                                                 !:     period (i.e. last contrib. from previous such period)
93                                                 !:     and "now" Asselin contrib. to the ML trc. trends
94      tmlatfm_trc,                        &      !: accumulator for Asselin trends (needed for storage only)
95      tmlradb_trc, tmlradn_trc ,          &      !: similar to Asselin above, but for the trend due to trb
96                                                 !:     correction in trcrad.F90
97      tmlradm_trc                                !: accumulator for the previous trcrad trend
98
99   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::  &
100      tmltrd_trc,                         &      !: \ physical contributions to the total trend (for T/S),
101                                                 !: / cumulated over the current analysis window
102      tmltrd_sum_trc,                     &      !: sum of these trends over the analysis period
103      tmltrd_csum_ln_trc,                 &      !: now cumulated sum of trends over the "lower triangle"
104      tmltrd_csum_ub_trc                         !: before (prev. analysis period) cumulated sum over the
105                                                 !: upper triangle
106   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  &
107      tmltrdm_trc                                !: total cumulative trends over the analysis window
108
109# else
110   LOGICAL, PARAMETER ::   lk_trdmxl_trc = .FALSE.   !: ML trend flag
111# endif
112
113# if defined key_pisces_reduced
114   CHARACTER(LEN=80) :: clname_bio, ctrd_bio(jpdiabio,2)
115   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  &
116      tmltrd_bio,                         &      !: \ biological contributions to the total trend ,
117                                                 !: / cumulated over the current analysis window
118      tmltrd_sum_bio,                     &      !: sum of these trends over the analysis period
119      tmltrd_csum_ln_bio,                 &      !: now cumulated sum of trends over the "lower triangle"
120      tmltrd_csum_ub_bio                         !: before (prev. analysis period) cumulated sum over the
121                                                 !: upper triangle
122#endif
123   !!----------------------------------------------------------------------
124   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
125   !! $Id$
126   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
127   !!----------------------------------------------------------------------
128CONTAINS
129
130   INTEGER FUNCTION trd_trc_oce_alloc()
131      !!----------------------------------------------------------------------
132      !!         *** ROUTINE trd_trc_oce_alloc ***
133      !!----------------------------------------------------------------------
134      USE lib_mpp, ONLY: ctl_warn
135      INTEGER :: ierr(2)
136      !!----------------------------------------------------------------------
137      ierr(:) = 0
138      !
139# if defined key_trdmxl_trc
140      ALLOCATE(nmld_trc(jpi,jpj),          nbol_trc(jpi,jpj),           &
141               wkx_trc(jpi,jpj,jpk),       rmld_trc(jpi,jpj),           &
142               rmld_sum_trc(jpi,jpj),      rmldbn_trc(jpi,jpj),         &
143               tml_trc(jpi,jpj,jptra),     tmlb_trc(jpi,jpj,jptra),     &
144               tmlbb_trc(jpi,jpj,jptra),   tmlbn_trc(jpi,jpj,jptra),    &
145               tml_sum_trc(jpi,jpj,jptra), tml_sumb_trc(jpi,jpj,jptra), &
146               tmltrd_atf_sumb_trc(jpi,jpj,jptra),                      &
147               tmltrd_rad_sumb_trc(jpi,jpj,jptra),                      &
148               !
149               tmlatfb_trc(jpi,jpj,jptra), tmlatfn_trc(jpi,jpj,jptra),  &
150               tmlatfm_trc(jpi,jpj,jptra), tmlradb_trc(jpi,jpj,jptra),  &
151               tmlradn_trc(jpi,jpj,jptra), tmlradm_trc(jpi,jpj,jptra),  &
152               !
153               tmltrd_trc(jpi,jpj,jpltrd_trc,jptra)         , &
154               tmltrd_sum_trc(jpi,jpj,jpltrd_trc,jptra)     , &
155               tmltrd_csum_ln_trc(jpi,jpj,jpltrd_trc,jptra) , &
156               tmltrd_csum_ub_trc(jpi,jpj,jpltrd_trc,jptra) , &
157               !
158               tmltrdm_trc(jpi,jpj,jptra)                   , STAT=ierr(1) )
159#endif
160      !
161# if defined key_pisces_reduced
162      ALLOCATE( tmltrd_bio        (jpi,jpj,jpdiabio) ,     &
163         &      tmltrd_sum_bio    (jpi,jpj,jpdiabio) ,     &
164         &      tmltrd_csum_ln_bio(jpi,jpj,jpdiabio) ,     &
165         &      tmltrd_csum_ub_bio(jpi,jpj,jpdiabio) , STAT=ierr(2) )
166# endif
167      !
168      trd_trc_oce_alloc = MAXVAL(ierr)
169      !
170      IF( trd_trc_oce_alloc /= 0 )   CALL ctl_warn('trd_trc_oce_alloc: failed to allocate arrays')
171      !
172# if defined key_trdmxl_trc
173      jpktrd_trc = jpk      ! Initialise what used to be a parameter - max level for mixed-layer trends diag.
174# endif
175      !
176   END FUNCTION trd_trc_oce_alloc
177
178#else
179   !!----------------------------------------------------------------------
180   !!  Empty module :                                     No passive tracer
181   !!----------------------------------------------------------------------
182#endif
183
184   !!======================================================================
185END MODULE trdtrc_oce
Note: See TracBrowser for help on using the repository browser.