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.
tradwl.F90 in NEMO/branches/UKMO/NEMO_4.0.4_CO9_shelf_climate/src/OCE/TRA – NEMO

source: NEMO/branches/UKMO/NEMO_4.0.4_CO9_shelf_climate/src/OCE/TRA/tradwl.F90 @ 15634

Last change on this file since 15634 was 15634, checked in by hadjt, 2 years ago

TRA/tradwl.F90 BUG FIX

The over-stratification problem I was having was due to a bug in the TRA/tradwl.F90 code.

Enda looked through my namelist, and made some suggestsion which could be causing the error. I ran a series of tests to see if any caused the error (none did).

By comparing output.namelist.dyn between my run and Enda's, I found some additional differences, so I ran some additional test.

I found namelist:namtrd ln_tra_trd was causing the problem. Setting it to .false. fixed it.

Somewhere, ln_tra_trd = .true. was causing the problem.

ln_tra_trd is defined in trd_oce.F90
read in from the name list in trdini.F90, and is queried in trdtra, where it is used to call trd_tra_iom.
The only other place its used in (my version of) nemo is in trdini.F90, where it sets l_trdtra = True...

l_trdtra is all over NEMO, in 20 F90 files.

However, I noted l_trdtra is also in tradwl.F90 that I implemented. Looking l_trdtra in tradwl, it looked suspicious. The call to the trends functions had been commented out by CEOD, and it used pointers (pointing to ua and va as temp space??) to store changes to T and S. So as well as not reporting the changes, they could be overwriting the ua and va fields (the "after" 3d u and v velocity).

I have commented out these sections of code. At a later date, it may be useful to add them back in, in a way that is consistent with NEMO4, but it has not been done here.

--

File size: 10.4 KB
Line 
1MODULE tradwl
2   !!======================================================================
3   !!                       ***  MODULE  tradwl  ***
4   !! Ocean physics: solar radiation penetration in the top ocean levels
5   !!======================================================================
6   !! History :  POLCOMS  !  1996-10  (J. Holt)  Original code
7   !!   NEMO     3.2  !  2010-03  (E. O'Dea)  Import to Nemo for use in Shelf Model
8   !!----------------------------------------------------------------------
9
10   !!----------------------------------------------------------------------
11   !!   tra_dwl      : trend due to the solar radiation penetration
12   !!   tra_dwl_init : solar radiation penetration initialization
13   !!----------------------------------------------------------------------
14   USE oce             ! ocean dynamics and active tracers
15   USE dom_oce         ! ocean space and time domain
16   USE sbc_oce         ! surface boundary condition: ocean
17   USE trc_oce         ! share SMS/Ocean variables
18   USE trd_oce         ! trends: ocean variables
19   USE trdtra          ! ocean active tracers trends
20   USE in_out_manager  ! I/O manager
21   USE phycst          ! physical constants
22   USE prtctl          ! Print control
23   USE iom             ! I/O manager
24   USE fldread         ! read input fields
25   !JT
26   USE domzgr
27   USE domain
28   !JT
29   IMPLICIT NONE
30   PRIVATE
31
32   PUBLIC   tra_dwl        ! routine called by step.F90 (ln_tradwl=T)
33
34   !                                           !!* Namelist namtra_qsr: penetrative solar radiation
35   LOGICAL , PUBLIC ::   ln_tradwl  = .TRUE.    ! light absorption (dwl) flag
36   LOGICAL , PUBLIC ::   ln_vary_lambda  = .TRUE.    ! vary Lambda or not flag
37   
38   !! * Substitutions
39!#  include "domzgr_substitute.h90"
40#  include "vectopt_loop_substitute.h90"
41   !!----------------------------------------------------------------------
42   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)
43   !! $Id$
44   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
45   !!----------------------------------------------------------------------
46
47CONTAINS
48
49   SUBROUTINE tra_dwl( kt )
50      !!----------------------------------------------------------------------
51      !!                  ***  ROUTINE tra_qsr  ***
52      !!
53      !! ** Purpose :   Compute the temperature trend due to the solar radiation
54      !!      penetration and add it to the general temperature trend.
55      !!
56      !! ** Method  : The profile of the solar radiation within the ocean is defined
57      !!
58      !!          Jason Holt Oct 96
59      !!
60      !!          Calculates change in temperature due to penetrating
61      !!          radiation, with cooling at the surface layer
62      !!
63      !!          rad=rad0*exp(lambda*z)
64      !!
65      !!       Heat input into box is between z=K and z=K+1 is RAD(K)-RAD(K+1)
66      !!
67      !!
68      !! ** Action  : - update ta with the penetrative solar radiation trend
69      !!              - save the trend in ttrd ('key_trdtra')
70      !!
71      !!----------------------------------------------------------------------
72
73      !JT USE oce, ONLY :   ztrdt => ua   ! use ua as 3D workspace   
74      !JT USE oce, ONLY :   ztrds => va   ! use va as 3D workspace   
75
76      !!
77      INTEGER, INTENT(in) ::   kt     ! ocean time-step
78      !!
79      INTEGER  ::   ji, jj, jk           ! dummy loop indices
80      INTEGER  ::   irgb                 ! temporary integers
81      REAL(wp) ::   zchl, zcoef, zsi0r   ! temporary scalars
82      REAL(wp) ::   zc0, zc1, zc2, zc3   !    -         -
83      !JT
84      REAL(wp), DIMENSION(jpi,jpj) ::   hbatt, qsr_tradwl
85      !JT
86      !!----------------------------------------------------------------------
87      !! HERE GO VARIABLES USED IN POLCOMS CLEAN UP LATER
88
89      integer i,j,k
90!      real*8 dtmp(n-1)
91      real*8 dtmp(jpkm1)
92      real*8 z1,z2,Rad0,Rad1,Rad2,rD,SurfOut,cp
93      logical first
94      save first
95      data first/.true./
96      !!--------------------------End of POLCOMS variables Note instead of using saves
97      !!--------------------------Could shift this into initial code
98
99      IF( kt == nit000 ) THEN
100         IF(lwp) WRITE(numout,*)
101         IF(lwp) WRITE(numout,*) 'tra_dwl : penetration of the surface solar radiation'
102         IF(lwp) WRITE(numout,*) '~~~~~~~'
103         CALL tra_dwl_init
104         IF( .NOT.ln_tradwl )   RETURN
105      ENDIF
106
107      !JT IF( l_trdtra ) THEN      ! Save ta and sa trends
108      !JT    ztrdt(:,:,:) = tsa(:,:,:,jp_tem)
109      !JT    ztrds(:,:,:) = 0.e0
110      !JT ENDIF
111!--------------------------------------------------------------------
112!  Set transmissivity
113!--------------------------------------------------------------------
114!
115!  Normal value
116!
117!---------------------------------------------------------------------------
118!
119!  Convert Heat fluxes to units used in POL subroutine dwl
120!
121!---------------------------------------------------------------------------
122    !cp=3986.0d0
123
124    DO jj = 2, jpj
125         DO ji = fs_2, fs_jpim1
126           qsr_tradwl(ji,jj)  = qsr(ji,jj)  * (r1_rau0_rcp)
127         ENDDO       !ji
128    ENDDO            !jj
129!--------------------------------------------------------------------------------
130 
131
132   if ( first ) then
133    do jj=2,jpjm1
134      do ji = fs_2, fs_jpim1 
135          IF ( tmask(ji,jj,1) .EQ. 1) THEN ! if land
136            hbatt(ji,jj) = sum( e3t_n(ji,jj,:)*tmask(ji,jj,:) )
137        else
138            hbatt(ji,jj)= 0.
139        endif
140      enddo ! ji
141    enddo ! jj
142
143   !CALL iom_put('hbatt_tradwl', hbatt(:,:) )
144
145        rlambda2(:,:) = 0.0
146        first=.false.
147        if ( ln_vary_lambda ) then
148
149        do jj=2,jpjm1
150          do ji = fs_2, fs_jpim1   ! vector opt.
151              !IF ( tmask(ji,jj,1) .EQ. 1) THEN ! if land
152
153
154              rlambda2(ji,jj)=-0.033*log(hbatt(ji,jj))+0.2583    ! JIAs formula
155              rlambda2(ji,jj)=max(0.05,rlambda2(ji,jj))     ! limit in deep water
156              rlambda2(ji,jj)=min(0.25,rlambda2(ji,jj))     ! Catch the infinities, from very shallow water/land. 10cm = 0.25
157
158            !else
159            !    rlambda2(ji,jj)= 0.25
160            !endif
161          enddo ! ji
162        enddo ! jj
163        rlambda = 0.0
164       else
165        rLambda=0.154
166       endif ! If vary lambda
167      endif ! If first
168
169      ! CALL iom_put('rlambda2_tradwl', rlambda2(:,:) )
170
171      DO jk=2,jpk
172         DO jj=2,jpjm1
173            DO ji = fs_2, fs_jpim1   ! vector opt.
174
175              IF ( tmask(ji,jj,1) .EQ. 1) THEN ! if land
176
177    !--------------------------------------------------------------------
178    ! Calculate change in temperature
179    !--------------------------------------------------------------------
180    !
181    !        rad0 = hfl_in(i,j)   ! change hfl_in to qsr I assume
182
183                    rad0 = qsr_tradwl(ji,jj)
184                    rD = rLambda2(ji,jj)  +rLambda      !  Transmissivity to be used here
185                          !       if rlambda 0 then rlambda2 not zer and vica versa
186
187                    z2=gdepw_0(ji,jj,jk-1)    ! grid box is from z=z1 to z=z2
188                    z1=gdepw_0(ji,jj,jk)
189
190                    Rad2=Rad0*(exp(-z2*rD)) ! radiation entering box
191                    Rad1=Rad0*(exp(-z1*rD)) ! radiation leaving box
192
193
194                    dtmp(jk)=1.0/(e3t_0(ji,jj,jk))*(Rad2-Rad1) !change in temperature
195                    tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) + dtmp(jk)
196                endif ! if land
197            enddo  ! ji
198         enddo  ! jj
199      enddo !jk
200
201
202      !JT IF( l_trdtra ) THEN     ! qsr tracers trends saved for diagnostics
203      !JT    ztrdt(:,:,:) = tsa(:,:,:,jp_tem) - ztrdt(:,:,:)
204      !JT    !CEODCALL trd_mod( ztrdt, ztrds, jptra_trd_qsr, 'TRA', kt )
205      !JT ENDIF
206      !                       ! print mean trends (used for debugging)
207      IF(ln_ctl)   CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' qsr  - Ta: ', mask1=tmask, clinfo3='tra-ta' )
208      !
209   END SUBROUTINE tra_dwl
210
211
212   SUBROUTINE tra_dwl_init
213      !!----------------------------------------------------------------------
214      !!                  ***  ROUTINE tra_dwl_init  ***
215      !!
216      !! ** Purpose :   Initialization for the penetrative solar radiation for Downwell routine
217      !!
218      !! ** Method  :   The profile of solar radiation within the ocean is set
219      !!      from two length scale of penetration (rn_si0,rn_si1) and a ratio
220      !!      (rn_abs). These parameters are read in the namtra_qsr namelist. The
221      !!      default values correspond to clear water (type I in Jerlov'
222      !!      (1968) classification.
223      !!         called by tra_qsr at the first timestep (nit000)
224      !!
225      !! ** Action  : - initialize rn_si0, rn_si1 and rn_abs
226      !!
227      !! Reference : Jerlov, N. G., 1968 Optical Oceanography, Elsevier, 194pp.
228      !!----------------------------------------------------------------------
229      INTEGER  ::   ji, jj, jk            ! dummy loop indices
230      INTEGER  ::   ios                   ! Local integer output status for namelist read
231      INTEGER  ::   irgb, ierror          ! temporary integer
232      INTEGER  ::   ioptio, nqsr          ! temporary integer
233      REAL(wp) ::   zc0  , zc1            ! temporary scalars
234      REAL(wp) ::   zc2  , zc3  , zchl    !    -         -
235      REAL(wp) ::   zsi0r, zsi1r, zcoef   !    -         -
236      !!
237      CHARACTER(len=100) ::   cn_dir   ! Root directory for location of ssr files
238      TYPE(FLD_N)        ::   sn_chl   ! informations about the chlorofyl field to be read
239      NAMELIST/namtra_dwl/  ln_tradwl, ln_vary_lambda
240      !!----------------------------------------------------------------------
241
242      REWIND( numnam_ref )            ! Read Namelist namtra_dwl in reference namelist :
243      READ  ( numnam_ref, namtra_dwl, IOSTAT = ios, ERR = 901)
244901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_qsr in reference namelist')
245     
246      REWIND( numnam_cfg )            ! Read Namelist namtra_dwl in configuration namelist :
247      READ  ( numnam_cfg, namtra_dwl, IOSTAT = ios, ERR = 902)
248902   IF( ios > 0 ) CALL ctl_nam ( ios , 'namtra_qsr in configuration namelist')
249      !
250      IF(lwp) THEN                ! control print
251         WRITE(numout,*)
252         WRITE(numout,*) 'tra_dwl_init : '
253         WRITE(numout,*) '~~~~~~~~~~~~'
254         WRITE(numout,*) '   Namelist namtra_dwl : set the parameter of penetration'
255         WRITE(numout,*) '      Light penetration (T) or not (F)         ln_tradwl  = ', ln_tradwl
256         WRITE(numout,*) '      Vary Lambda  (T) or not (F))             ln_vary_lambda  = ', ln_vary_lambda
257      ENDIF
258
259   END SUBROUTINE tra_dwl_init
260
261   !!======================================================================
262END MODULE tradwl
Note: See TracBrowser for help on using the repository browser.