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.
diatmb.F90 in branches/UKMO/AMM15_v3_6_STABLE_package/NEMOGCM/NEMO/OPA_SRC/DIA – NEMO

source: branches/UKMO/AMM15_v3_6_STABLE_package/NEMOGCM/NEMO/OPA_SRC/DIA/diatmb.F90 @ 8561

Last change on this file since 8561 was 8561, checked in by jgraham, 7 years ago

Updates for operational diagnostics:
25h mean diagnostics - bottom temperature (and insitu temp)
Operational foam diagnostics - diaopfoam and DIU routines added.

File size: 7.0 KB
Line 
1MODULE diatmb 
2   !!======================================================================
3   !!                       ***  MODULE  diaharm  ***
4   !! Harmonic analysis of tidal constituents
5   !!======================================================================
6   !! History :  3.6  !  2014  (E O'Dea)  Original code
7   !!----------------------------------------------------------------------
8   USE oce             ! ocean dynamics and tracers variables
9   USE dom_oce         ! ocean space and time domain
10   USE in_out_manager  ! I/O units
11   USE iom             ! I/0 library
12   USE wrk_nemo        ! working arrays
13
14
15   IMPLICIT NONE
16   PRIVATE
17
18   LOGICAL , PUBLIC ::   ln_diatmb     !: Top Middle and Bottom output
19   PUBLIC   dia_tmb_init            ! routine called by nemogcm.F90
20   PUBLIC   dia_tmb                 ! routine called by diawri.F90
21   PUBLIC   dia_calctmb             ! routine called by dia25h.F90
22
23   !!----------------------------------------------------------------------
24   !! NEMO/OPA 3.6 , NEMO Consortium (2014)
25   !! $Id$
26   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
27   !!----------------------------------------------------------------------
28CONTAINS
29
30   SUBROUTINE dia_tmb_init 
31      !!---------------------------------------------------------------------------
32      !!                  ***  ROUTINE dia_tmb_init  ***
33      !!     
34      !! ** Purpose: Initialization of tmb namelist
35      !!       
36      !! ** Method : Read namelist
37      !!   History
38      !!   3.6  !  08-14  (E. O'Dea) Routine to initialize dia_tmb
39      !!---------------------------------------------------------------------------
40      !!
41      INTEGER ::   ios                 ! Local integer output status for namelist read
42      !
43      NAMELIST/nam_diatmb/ ln_diatmb
44      !!----------------------------------------------------------------------
45      !
46      REWIND ( numnam_ref )              ! Read Namelist nam_diatmb in reference namelist : TMB diagnostics
47      READ   ( numnam_ref, nam_diatmb, IOSTAT=ios, ERR= 901 )
48901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diatmb in reference namelist', lwp )
49 
50      REWIND( numnam_cfg )              ! Namelist nam_diatmb in configuration namelist  TMB diagnostics
51      READ  ( numnam_cfg, nam_diatmb, IOSTAT = ios, ERR = 902 )
52902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diatmb in configuration namelist', lwp )
53      IF(lwm) WRITE ( numond, nam_diatmb )
54
55      IF(lwp) THEN                   ! Control print
56         WRITE(numout,*)
57         WRITE(numout,*) 'dia_tmb_init : Output Top, Middle, Bottom Diagnostics'
58         WRITE(numout,*) '~~~~~~~~~~~~'
59         WRITE(numout,*) 'Namelist nam_diatmb : set tmb outputs '
60         WRITE(numout,*) 'Switch for TMB diagnostics (T) or not (F)  ln_diatmb  = ', ln_diatmb
61      ENDIF
62
63   END SUBROUTINE dia_tmb_init
64
65   SUBROUTINE dia_calctmb( pinfield,pouttmb )
66      !!---------------------------------------------------------------------
67      !!                  ***  ROUTINE dia_tmb  ***
68      !!                   
69      !! ** Purpose :    Find the Top, Mid and Bottom fields of water Column
70      !!
71      !! ** Method  :   
72      !!      use mbathy to find surface, mid and bottom of model levels
73      !!
74      !! History :
75      !!   3.6  !  08-14  (E. O'Dea) Routine based on dia_wri_foam
76      !!----------------------------------------------------------------------
77      !! * Modules used
78
79      ! Routine to map 3d field to top, middle, bottom
80      IMPLICIT NONE
81
82
83      ! Routine arguments
84      REAL(wp), DIMENSION(jpi, jpj, jpk), INTENT(IN   ) :: pinfield    ! Input 3d field and mask
85      REAL(wp), DIMENSION(jpi, jpj, 3  ), INTENT(  OUT) :: pouttmb     ! Output top, middle, bottom
86
87
88
89      ! Local variables
90      INTEGER :: ji,jj,jk  ! Dummy loop indices
91
92      ! Local Real
93      REAL(wp)                         ::   zmdi  !  set masked values
94
95      zmdi=1.e+20 !missing data indicator for masking
96
97      ! Calculate top
98      pouttmb(:,:,1) = pinfield(:,:,1)*tmask(:,:,1)  + zmdi*(1.0-tmask(:,:,1))
99
100      ! Calculate middle
101      DO jj = 1,jpj
102         DO ji = 1,jpi
103            jk              = max(1,mbathy(ji,jj)/2)
104            pouttmb(ji,jj,2) = pinfield(ji,jj,jk)*tmask(ji,jj,jk)  + zmdi*(1.0-tmask(ji,jj,jk))
105         END DO
106      END DO
107
108      ! Calculate bottom
109      DO jj = 1,jpj
110         DO ji = 1,jpi
111            jk              = max(1,mbathy(ji,jj) )
112            pouttmb(ji,jj,3) = pinfield(ji,jj,jk)*tmask(ji,jj,jk)  + zmdi*(1.0-tmask(ji,jj,jk))
113         END DO
114      END DO
115
116   END SUBROUTINE dia_calctmb
117
118
119
120   SUBROUTINE dia_tmb
121      !!----------------------------------------------------------------------
122      !!                 ***  ROUTINE dia_tmb  ***
123      !! ** Purpose :   Write diagnostics for Top, Mid and Bottom of water Column
124      !!
125      !! ** Method  :   
126      !!      use mbathy to find surface, mid and bottom of model levels
127      !!      calls calctmb to retrieve TMB values before sending to iom_put
128      !!
129      !! History :
130      !!   3.6  !  08-14  (E. O'Dea)
131      !!         
132      !!--------------------------------------------------------------------
133      REAL(wp), POINTER, DIMENSION(:,:,:) :: zwtmb    ! temporary workspace
134      REAL(wp)                         ::   zmdi      ! set masked values
135
136      zmdi=1.e+20 !missing data indicator for maskin
137
138      IF (ln_diatmb) THEN
139         CALL wrk_alloc( jpi , jpj, 3 , zwtmb )
140         CALL dia_calctmb(  tsn(:,:,:,jp_tem),zwtmb )
141         !ssh already output but here we output it masked
142         CALL iom_put( "sshnmasked" , sshn(:,:)*tmask(:,:,1) + zmdi*(1.0 - tmask(:,:,1)) )   ! tmb Temperature
143         CALL iom_put( "top_temp" , zwtmb(:,:,1) )    ! tmb Temperature
144         CALL iom_put( "mid_temp" , zwtmb(:,:,2) )    ! tmb Temperature
145         CALL iom_put( "bot_temp" , zwtmb(:,:,3) )    ! tmb Temperature
146!         CALL iom_put( "sotrefml" , hmld_tref(:,:) )    ! "T criterion Mixed Layer Depth
147
148         CALL dia_calctmb(  tsn(:,:,:,jp_sal),zwtmb )
149         CALL iom_put( "top_sal" , zwtmb(:,:,1) )    ! tmb Salinity
150         CALL iom_put( "mid_sal" , zwtmb(:,:,2) )    ! tmb Salinity
151         CALL iom_put( "bot_sal" , zwtmb(:,:,3) )    ! tmb Salinity
152
153         CALL dia_calctmb(  un(:,:,:),zwtmb )
154         CALL iom_put( "top_u" , zwtmb(:,:,1) )    ! tmb  U Velocity
155         CALL iom_put( "mid_u" , zwtmb(:,:,2) )    ! tmb  U Velocity
156         CALL iom_put( "bot_u" , zwtmb(:,:,3) )    ! tmb  U Velocity
157!Called in  dynspg_ts.F90        CALL iom_put( "baro_u" , un_b )    ! Barotropic  U Velocity
158
159         CALL dia_calctmb(  vn(:,:,:),zwtmb )
160         CALL iom_put( "top_v" , zwtmb(:,:,1) )    ! tmb  V Velocity
161         CALL iom_put( "mid_v" , zwtmb(:,:,2) )    ! tmb  V Velocity
162         CALL iom_put( "bot_v" , zwtmb(:,:,3) )    ! tmb  V Velocity
163!Called in  dynspg_ts.F90       CALL iom_put( "baro_v" , vn_b )    ! Barotropic  V Velocity
164      ELSE
165         CALL ctl_warn('dia_tmb: tmb diagnostic is set to false you should not have seen this')
166      ENDIF
167
168   END SUBROUTINE dia_tmb
169   !!======================================================================
170END MODULE diatmb
Note: See TracBrowser for help on using the repository browser.