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_reanalysis4/NEMOGCM/NEMO/OPA_SRC/DIA – NEMO

source: branches/UKMO/AMM15_v3_6_STABLE_package_reanalysis4/NEMOGCM/NEMO/OPA_SRC/DIA/diatmb.F90 @ 11639

Last change on this file since 11639 was 11639, checked in by rrenshaw, 4 years ago

regional mean and transport diagnostics added for reanalysis

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