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_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC – NEMO

source: branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcdcy.F90 @ 2198

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

merge dev_r2174_DCY into DEV_r2106_LOCEAN2010

File size: 9.7 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 in_out_manager   ! I/O manager
19
20   IMPLICIT NONE
21   PRIVATE
22   INTEGER                      ::   nday_qsr                    ! day when parameters were computed
23   REAL(wp), DIMENSION(jpi,jpj) ::   raa , rbb  , rcc  , rab     ! parameters used to compute the diurnal cycle
24   REAL(wp), DIMENSION(jpi,jpj) ::   rtmd, rdawn, rdusk, rscal   !     -       -         -           -      -
25   REAL(wp), DIMENSION(jpi,jpj) ::   qsr_daily                   ! to hold daily mean QSR
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      SUBROUTINE sbc_dcy( kt, pqsr )
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,1), INTENT(inout) ::   pqsr   ! QSR flux with diurnal cycle
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
57      REAL(wp) ::   ztmp, ztmp1, ztmp2, ztest
58      !---------------------------statement functions------------------------
59      REAL(wp) ::   fintegral, pt1, pt2, paaa, pbbb, pccc       ! dummy statement function arguments
60      fintegral( pt1, pt2, paaa, pbbb, pccc ) =                         &
61         &   paaa * pt2 + zinvtwopi * pbbb * SIN(pccc + ztwopi * pt2)   &
62         & - paaa * pt1 - zinvtwopi * pbbb * SIN(pccc + ztwopi * pt1)
63      !!---------------------------------------------------------------------
64
65      ! Initialization
66      ! --------------
67      ztwopi    = 2. * rpi
68      zinvtwopi = 1. / ztwopi
69      zconvrad  = ztwopi / 360.
70
71      ! When are we during the day (from 0 to 1)
72      zlo = MOD( rdt / rday * REAL( kt-nit000, wp ), 1.)
73      zup = zlo + rdt / rday
74
75      !                                         
76      IF( kt == nit000 ) THEN       ! first time step only               
77         IF(lwp) THEN
78            WRITE(numout,*)
79            WRITE(numout,*) 'sbc_dcy : introduce diurnal cycle from daily mean qsr'
80            WRITE(numout,*) '~~~~~~~'
81            WRITE(numout,*)
82         ENDIF
83         nday_qsr = 0
84         ! Compute rcc needed to compute the time integral of the diurnal cycle
85         rcc(:,:) = zconvrad * glamt(:,:) - rpi
86         ! time of midday
87         rtmd(:,:) = 0.5 - glamt(:,:) / 360.
88         rtmd(:,:) = MOD( (rtmd(:,:) + 1.), 1. )
89      ENDIF
90
91      ! If this is a new day, we have to update the dawn, dusk and scaling function 
92      !----------------------
93   
94      !     2.1 dawn and dusk 
95
96      ! nday is the number of days since the beginning of the current month
97      IF( nday_qsr /= nday ) THEN 
98         ! save the day of the year and the daily mean of qsr
99         nday_qsr = nday 
100         ! number of days since the previous winter solstice (supposed to be always 21 December)         
101         zdsws = 11 + nday_year
102         ! declination of the earths orbit
103         zdecrad = (-23.5 * zconvrad) * COS( zdsws * ztwopi / REAL(nyear_len(1),wp) )
104         ! save the daily QSR for nest hours of the day
105         qsr_daily(:,:) = pqsr(:,:,1)
106         ! Compute A and B needed to compute the time integral of the diurnal cycle
107       
108         DO jj = 1, jpj
109            DO ji = 1, jpi
110               ztmp = zconvrad * gphit(ji,jj)
111               raa(ji,jj) = SIN( ztmp ) * SIN( zdecrad )
112               rbb(ji,jj) = COS( ztmp ) * COS( zdecrad )
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 / rdt
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                  pqsr(ji,jj,1) = qsr_daily(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                  pqsr(ji,jj,1) = qsr_daily(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                  pqsr(ji,jj,1) = qsr_daily(ji,jj) * ztmp * rscal(ji,jj)
203                  !
204               ELSE                                         ! No day
205                  pqsr(ji,jj,1) = 0.e0
206               ENDIF
207            ENDIF
208         END DO 
209      END DO 
210      !
211   END SUBROUTINE sbc_dcy
212
213   !!======================================================================
214END MODULE sbcdcy
Note: See TracBrowser for help on using the repository browser.