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.
sbcdcy.F90 in branches/dev_r2174_DCY/NEMO/OPA_SRC/SBC – NEMO

source: branches/dev_r2174_DCY/NEMO/OPA_SRC/SBC/sbcdcy.F90 @ 2210

Last change on this file since 2210 was 2210, checked in by smasson, 14 years ago

bugfix on diurnal cycle in dev_r2174_DCY, see ticket:730

File size: 9.8 KB
Line 
1MODULE sbcdcy
2   !!======================================================================
3   !!                    ***  MODULE  sbcdcy  ***
4   !! Ocean forcing:  compute the diurnal cycle
5   !!======================================================================
6   !! History : OPA  !  2005-02  (D. Bernie)  Original code
7   !!   NEMO    2.0  !  2006-02  (S. Masson, G. Madec)  adaptation to NEMO
8   !!           3.1  !  2009-07  (J.M. Molines)  adaptation to v3.1
9   !!----------------------------------------------------------------------
10
11   !!----------------------------------------------------------------------
12   !!  sbc_dcy : compute solar flux at kt from daily mean, taking
13   !!            diurnal cycle into account
14   !!----------------------------------------------------------------------
15   USE oce              ! ocean dynamics and tracers
16   USE phycst           ! ocean physics
17   USE dom_oce          ! ocean space and time domain
18   USE sbc_oce          ! Surface boundary condition: ocean fields
19   USE in_out_manager   ! I/O manager
20
21   IMPLICIT NONE
22   PRIVATE
23   INTEGER                      ::   nday_qsr                    ! day when parameters were computed
24   REAL(wp), DIMENSION(jpi,jpj) ::   raa , rbb  , rcc  , rab     ! parameters used to compute the diurnal cycle
25   REAL(wp), DIMENSION(jpi,jpj) ::   rtmd, rdawn, rdusk, rscal   !     -       -         -           -      -
26 
27   PUBLIC   sbc_dcy     ! routine called by sbc
28
29   !!----------------------------------------------------------------------
30   !! NEMO/OPA 3.3 , NEMO-consortium (2010)
31   !! $Id$
32   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
33   !!----------------------------------------------------------------------
34CONTAINS
35
36      FUNCTION sbc_dcy( kt, pqsrin ) RESULT( zqsrout )
37      !!----------------------------------------------------------------------
38      !!                  ***  ROUTINE sbc_dcy  ***
39      !!
40      !! ** Purpose : introduce a diurnal cycle of qsr from daily values
41      !!
42      !! ** Method  : see Appendix A of Bernie et al. 2007.
43      !!
44      !! ** Action  : redistribute daily QSR on each time step following the diurnal cycle
45      !!
46      !! reference  : Bernie, DJ, E Guilyardi, G Madec, JM Slingo, and SJ Woolnough, 2007
47      !!              Impact of resolving the diurnal cycle in an ocean--atmosphere GCM.
48      !!              Part 1: a diurnally forced OGCM. Climate Dynamics 29:6, 575-590.
49      !!----------------------------------------------------------------------
50      INTEGER,                      INTENT(in   ) ::   kt        ! ocean time-step index
51      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pqsrin    ! input daily QSR flux
52      !!
53      INTEGER  ::   ji, jj                                       ! dummy loop indices
54      REAL(wp) ::   ztwopi, zinvtwopi, zconvrad 
55      REAL(wp) ::   zlo, zup, zlousd, zupusd
56      REAL(wp) ::   zdsws, zdecrad, ztx, zsin, zcos
57      REAL(wp) ::   ztmp, ztmp1, ztmp2, ztest
58      REAL(wp), DIMENSION(jpi,jpj) ::   zqsrout                  ! output QSR flux with diurnal cycle
59      !---------------------------statement functions------------------------
60      REAL(wp) ::   fintegral, pt1, pt2, paaa, pbbb, pccc        ! dummy statement function arguments
61      fintegral( pt1, pt2, paaa, pbbb, pccc ) =                         &
62         &   paaa * pt2 + zinvtwopi * pbbb * SIN(pccc + ztwopi * pt2)   &
63         & - paaa * pt1 - zinvtwopi * pbbb * SIN(pccc + ztwopi * pt1)
64      !!---------------------------------------------------------------------
65
66      ! Initialization
67      ! --------------
68      ztwopi    = 2. * rpi
69      zinvtwopi = 1. / ztwopi
70      zconvrad  = ztwopi / 360.
71
72      ! When are we during the day (from 0 to 1)
73      zlo = ( REAL(nsec_day, wp) - 0.5   * rdttra(1) ) / rday
74      zup = zlo + ( REAL(nn_fsbc, wp) * rdttra(1) ) / rday
75
76      !                                         
77      IF( kt == nit000 ) THEN       ! first time step only               
78         IF(lwp) THEN
79            WRITE(numout,*)
80            WRITE(numout,*) 'sbc_dcy : introduce diurnal cycle from daily mean qsr'
81            WRITE(numout,*) '~~~~~~~'
82            WRITE(numout,*)
83         ENDIF
84         nday_qsr = 0
85         ! Compute rcc needed to compute the time integral of the diurnal cycle
86         rcc(:,:) = zconvrad * glamt(:,:) - rpi
87         ! time of midday
88         rtmd(:,:) = 0.5 - glamt(:,:) / 360.
89         rtmd(:,:) = MOD( (rtmd(:,:) + 1.), 1. )
90      ENDIF
91
92      ! If this is a new day, we have to update the dawn, dusk and scaling function 
93      !----------------------
94   
95      !     2.1 dawn and dusk 
96
97      ! nday is the number of days since the beginning of the current month
98      IF( nday_qsr /= nday ) THEN 
99         ! save the day of the year and the daily mean of qsr
100         nday_qsr = nday 
101         ! number of days since the previous winter solstice (supposed to be always 21 December)         
102         zdsws = REAL(11 + nday_year, wp)
103         ! declination of the earths orbit
104         zdecrad = (-23.5 * zconvrad) * COS( zdsws * ztwopi / REAL(nyear_len(1),wp) )
105         ! Compute A and B needed to compute the time integral of the diurnal cycle
106       
107         zsin = SIN( zdecrad )   ;   zcos = COS( zdecrad )
108         DO jj = 1, jpj
109            DO ji = 1, jpi
110               ztmp = zconvrad * gphit(ji,jj)
111               raa(ji,jj) = SIN( ztmp ) * zsin
112               rbb(ji,jj) = COS( ztmp ) * zcos
113            END DO 
114         END DO 
115
116         ! Compute the time of dawn and dusk
117
118         ! rab to test if the day time is equal to 0, less than 24h of full day       
119         rab(:,:) = -raa(:,:) / rbb(:,:)
120         DO jj = 1, jpj
121            DO ji = 1, jpi
122               IF ( ABS(rab(ji,jj)) < 1 ) THEN         ! day duration is less than 24h
123         ! When is it night?
124                  ztx = zinvtwopi * (ACOS(rab(ji,jj)) - rcc(ji,jj))
125                  ztest = -rbb(ji,jj) * SIN( rcc(ji,jj) + ztwopi * ztx )
126         ! is it dawn or dusk?
127                  IF ( ztest > 0 ) THEN
128                     rdawn(ji,jj) = ztx
129                     rdusk(ji,jj) = rtmd(ji,jj) + ( rtmd(ji,jj) - rdawn(ji,jj) )
130                  ELSE
131                     rdusk(ji,jj) = ztx
132                     rdawn(ji,jj) = rtmd(ji,jj) - ( rdusk(ji,jj) - rtmd(ji,jj) )
133                  ENDIF
134               ELSE
135                  rdawn(ji,jj) = rtmd(ji,jj) + 0.5
136                  rdusk(ji,jj) = rdawn(ji,jj)
137               ENDIF
138             END DO 
139         END DO 
140         rdawn(:,:) = MOD((rdawn(:,:) + 1.), 1.)
141         rdusk(:,:) = MOD((rdusk(:,:) + 1.), 1.)
142
143
144         !     2.2 Compute the scalling function:
145         !         S* = the inverse of the time integral of the diurnal cycle from dawm to dusk
146         DO jj = 1, jpj
147            DO ji = 1, jpi
148               IF ( ABS(rab(ji,jj)) < 1 ) THEN         ! day duration is less than 24h
149                  IF ( rdawn(ji,jj) < rdusk(ji,jj) ) THEN      ! day time in one part
150                     rscal(ji,jj) = fintegral(rdawn(ji,jj), rdusk(ji,jj), raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
151                     rscal(ji,jj) = 1. / rscal(ji,jj)
152                  ELSE                                         ! day time in two parts
153                     rscal(ji,jj) = fintegral(0., rdusk(ji,jj), raa(ji,jj), rbb(ji,jj), rcc(ji,jj))   &
154                        &         + fintegral(rdawn(ji,jj), 1., raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
155                     rscal(ji,jj) = 1. / rscal(ji,jj)
156                  ENDIF
157               ELSE
158                  IF ( raa(ji,jj) > rbb(ji,jj) ) THEN         ! 24h day
159                     rscal(ji,jj) = fintegral(0., 1., raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
160                     rscal(ji,jj) = 1. / rscal(ji,jj)
161                  ELSE                                          ! No day
162                     rscal(ji,jj) = 0.e0
163                  ENDIF
164               ENDIF
165            END DO 
166         END DO 
167         !
168         ztmp = rday / ( rdttra(1) * REAL(nn_fsbc, wp) )
169         rscal(:,:) = rscal(:,:) * ztmp
170
171      ENDIF 
172
173         !     3. update qsr with the diurnal cycle
174         !     ------------------------------------
175
176      DO jj = 1, jpj
177         DO ji = 1, jpi
178            IF( ABS(rab(ji,jj)) < 1 ) THEN         ! day duration is less than 24h
179               !
180               IF( rdawn(ji,jj) < rdusk(ji,jj) ) THEN       ! day time in one part
181                  zlousd = MAX(zlo, rdawn(ji,jj))
182                  zlousd = MIN(zlousd, zup)
183                  zupusd = MIN(zup, rdusk(ji,jj))
184                  zupusd = MAX(zupusd, zlo)
185                  ztmp = fintegral(zlousd, zupusd, raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
186                  zqsrout(ji,jj) = pqsrin(ji,jj) * ztmp * rscal(ji,jj)
187                  !
188               ELSE                                         ! day time in two parts
189                  zlousd = MIN(zlo, rdusk(ji,jj))
190                  zupusd = MIN(zup, rdusk(ji,jj))
191                  ztmp1 = fintegral(zlousd, zupusd, raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
192                  zlousd = MAX(zlo, rdawn(ji,jj))
193                  zupusd = MAX(zup, rdawn(ji,jj))
194                  ztmp2 = fintegral(zlousd, zupusd, raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
195                  ztmp = ztmp1 + ztmp2
196                  zqsrout(ji,jj) = pqsrin(ji,jj) * ztmp * rscal(ji,jj)
197               ENDIF
198            ELSE                                   ! 24h light or 24h night
199               !
200               IF( raa(ji,jj) > rbb(ji,jj) ) THEN           ! 24h day
201                  ztmp = fintegral(zlo, zup, raa(ji,jj), rbb(ji,jj), rcc(ji,jj)) 
202                  zqsrout(ji,jj) = pqsrin(ji,jj) * ztmp * rscal(ji,jj)
203                  !
204               ELSE                                         ! No day
205                  zqsrout(ji,jj) = 0.e0
206               ENDIF
207            ENDIF
208         END DO 
209      END DO 
210      !
211   END FUNCTION sbc_dcy
212
213   !!======================================================================
214END MODULE sbcdcy
Note: See TracBrowser for help on using the repository browser.