/[lmdze]/trunk/dyn3d/limit.f
ViewVC logotype

Diff of /trunk/dyn3d/limit.f

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/libf/dyn3d/limit.f90 revision 34 by guez, Wed Jun 2 11:01:12 2010 UTC trunk/dyn3d/limit.f revision 276 by guez, Thu Jul 12 14:49:20 2018 UTC
# Line 4  module limit_mod Line 4  module limit_mod
4    
5  contains  contains
6    
7    SUBROUTINE limit    SUBROUTINE limit(pctsrf)
8    
9      ! Authors: L. Fairhead, Z. X. Li, P. Le Van      ! Authors: L. Fairhead, Z. X. Li, P. Le Van
10    
11      ! This subroutine creates files containing boundary conditions.      ! This subroutine creates files containing boundary conditions.
12      ! It uses files with climatological data.      ! It uses files with climatological data.  Both grids must be
13      ! Both grids must be regular.      ! regular.
14    
     use dimens_m, only: iim, jjm  
     use indicesol, only: epsfra, nbsrf, is_ter, is_oce, is_lic, is_sic  
     use dimphy, only: klon, zmasq  
     use comgeom, only: rlonu, rlatv  
     use etat0_mod, only: pctsrf  
     use start_init_orog_m, only: mask  
15      use conf_dat2d_m, only: conf_dat2d      use conf_dat2d_m, only: conf_dat2d
16      use inter_barxy_m, only: inter_barxy      use dimensions, only: iim, jjm
17      use numer_rec, only: spline, splint      use dimphy, only: klon
18        use dynetat0_m, only: rlonu, rlatv
19      use grid_change, only: dyn_phy      use grid_change, only: dyn_phy
20        use indicesol, only: epsfra, is_ter, is_oce, is_lic, is_sic
21      use netcdf95, only: handle_err, nf95_gw_var, NF95_CLOSE, NF95_DEF_DIM, &      use inter_barxy_m, only: inter_barxy
22           nf95_enddef, NF95_CREATE, nf95_inq_dimid, nf95_inquire_dimension, &      use netcdf95, only: NF95_CLOSE, NF95_CREATE, NF95_DEF_DIM, nf95_def_var, &
23           nf95_inq_varid, NF95_OPEN           nf95_enddef, nf95_get_var, nf95_gw_var, nf95_inq_dimid, &
24      use netcdf, only: NF90_CLOBBER, nf90_def_var, NF90_FLOAT, NF90_GET_VAR, &           nf95_inq_varid, nf95_inquire_dimension, NF95_OPEN, NF95_PUT_ATT, &
25           NF90_GLOBAL, NF90_NOWRITE, NF90_PUT_ATT, NF90_PUT_VAR, &           NF95_PUT_VAR
26        use netcdf, only: NF90_CLOBBER, NF90_FLOAT, NF90_GLOBAL, NF90_NOWRITE, &
27           NF90_UNLIMITED           NF90_UNLIMITED
28        use nr_util, only: assert
29        use numer_rec_95, only: spline, splint
30        use phyetat0_m, only: zmasq
31        use start_init_orog_m, only: mask
32        use unit_nml_m, only: unit_nml
33    
34        REAL, intent(inout):: pctsrf(:, :) ! (klon, nbsrf)
35        ! "pctsrf(i, :)" is the composition of the surface at horizontal
36        ! position "i".
37    
38      ! Variables local to the procedure:      ! Local:
39    
40      LOGICAL:: extrap = .FALSE.      LOGICAL:: extrap = .FALSE.
41      ! (extrapolation de données, comme pour les SST lorsque le fichier      ! (extrapolation de donn\'ees, comme pour les SST lorsque le fichier
42      ! ne contient pas uniquement des points océaniques)      ! ne contient pas uniquement des points oc\'eaniques)
43    
     REAL phy_alb(klon, 360)  
     REAL phy_sst(klon, 360)  
44      REAL phy_bil(klon, 360)      REAL phy_bil(klon, 360)
     REAL phy_rug(klon, 360)  
45      REAL phy_ice(klon)      REAL phy_ice(klon)
46    
47      real pctsrf_t(klon, nbsrf, 360) ! composition of the surface      ! Pour le champ de d\'epart:
   
     ! Pour le champ de départ:  
48      INTEGER imdep, jmdep, lmdep      INTEGER imdep, jmdep, lmdep
49    
50      REAL, ALLOCATABLE:: dlon(:), dlat(:)      REAL, ALLOCATABLE:: dlon(:), dlat(:)
51      REAL, pointer:: dlon_ini(:), dlat_ini(:), timeyear(:)      REAL, ALLOCATABLE:: dlon_ini(:), dlat_ini(:), timeyear(:)
52      REAL, ALLOCATABLE:: champ(:, :)      REAL, ALLOCATABLE:: champ(:, :)
53      REAL, ALLOCATABLE:: work(:, :)      REAL, ALLOCATABLE:: work(:, :)
54    
55      ! Pour le champ interpolé 3D :      ! Pour le champ interpol\'e 3D :
56      REAL, allocatable:: champtime(:, :, :)      REAL, allocatable:: champtime(:, :, :)
57      REAL champan(iim + 1, jjm + 1, 360)      REAL champan(iim + 1, jjm + 1, 360)
58    
59      ! Pour l'inteprolation verticale :      ! Pour l'inteprolation verticale :
60      REAL, allocatable:: yder(:)      REAL, allocatable:: yder(:)
61    
62      INTEGER ierr      INTEGER ndim, ntim
63        INTEGER varid_time
     INTEGER nid, ndim, ntim  
     INTEGER dims(2), debut(2)  
     INTEGER id_tim  
64      INTEGER id_SST, id_BILS, id_RUG, id_ALB      INTEGER id_SST, id_BILS, id_RUG, id_ALB
65      INTEGER id_FOCE, id_FSIC, id_FTER, id_FLIC      INTEGER id_FOCE, id_FSIC, id_FTER, id_FLIC
66    
67      INTEGER i, j, k, l      INTEGER i, j, k, l
68      INTEGER ncid, varid, dimid      INTEGER ncid, ncid_limit, varid, dimid
69    
70      REAL, parameter:: tmidmonth(12) = (/(15. + 30. * i, i = 0, 11)/)      REAL, parameter:: tmidmonth(12) = [(15. + 30. * i, i = 0, 11)]
71    
72      namelist /limit_nml/extrap      namelist /limit_nml/extrap
73    
# Line 79  contains Line 76  contains
76      print *, "Call sequence information: limit"      print *, "Call sequence information: limit"
77    
78      print *, "Enter namelist 'limit_nml'."      print *, "Enter namelist 'limit_nml'."
79      read (unit=*, nml=limit_nml)      read(unit=*, nml=limit_nml)
80      write(unit=*, nml=limit_nml)      write(unit_nml, nml=limit_nml)
81    
82        call NF95_CREATE("limit.nc", NF90_CLOBBER, ncid_limit)
83    
84        call NF95_PUT_ATT(ncid_limit, NF90_GLOBAL, "title", &
85             "Fichier conditions aux limites")
86        call NF95_DEF_DIM(ncid_limit, "points_physiques", klon, ndim)
87        call NF95_DEF_DIM(ncid_limit, "time", NF90_UNLIMITED, ntim)
88    
89      ! Process rugosity:      call NF95_DEF_VAR(ncid_limit, "TEMPS", NF90_FLOAT, ntim, varid_time)
90        call NF95_PUT_ATT(ncid_limit, varid_time, "title", "Jour dans l annee")
91    
92        call NF95_DEF_VAR(ncid_limit, "FOCE", NF90_FLOAT, dimids=[ndim, ntim], &
93             varid=id_foce)
94        call NF95_PUT_ATT(ncid_limit, id_FOCE, "title", "Fraction ocean")
95    
96        call NF95_DEF_VAR(ncid_limit, "FSIC", NF90_FLOAT, dimids=[ndim, ntim], &
97             varid=id_FSIC)
98        call NF95_PUT_ATT(ncid_limit, id_FSIC, "title", "Fraction glace de mer")
99    
100        call NF95_DEF_VAR(ncid_limit, "FTER", NF90_FLOAT, dimids=[ndim, ntim], &
101             varid=id_FTER)
102        call NF95_PUT_ATT(ncid_limit, id_FTER, "title", "Fraction terre")
103    
104        call NF95_DEF_VAR(ncid_limit, "FLIC", NF90_FLOAT, dimids=[ndim, ntim], &
105             varid=id_FLIC)
106        call NF95_PUT_ATT(ncid_limit, id_FLIC, "title", "Fraction land ice")
107    
108        call NF95_DEF_VAR(ncid_limit, "SST", NF90_FLOAT, dimids=[ndim, ntim], &
109             varid=id_SST)
110        call NF95_PUT_ATT(ncid_limit, id_SST, "title",  &
111             "Temperature superficielle de la mer")
112    
113        call NF95_DEF_VAR(ncid_limit, "BILS", NF90_FLOAT, dimids=[ndim, ntim], &
114             varid=id_BILS)
115        call NF95_PUT_ATT(ncid_limit, id_BILS, "title", &
116             "Reference flux de chaleur au sol")
117    
118        call NF95_DEF_VAR(ncid_limit, "ALB", NF90_FLOAT, dimids=[ndim, ntim], &
119             varid=id_ALB)
120        call NF95_PUT_ATT(ncid_limit, id_ALB, "title", "Albedo a la surface")
121    
122        call NF95_DEF_VAR(ncid_limit, "RUG", NF90_FLOAT, dimids=[ndim, ntim], &
123             varid=id_RUG)
124        call NF95_PUT_ATT(ncid_limit, id_RUG, "title", "Rugosite")
125    
126        call NF95_ENDDEF(ncid_limit)
127    
128        call NF95_PUT_VAR(ncid_limit, varid_time, [(k, k = 1, 360)])
129        
130      PRINT *, 'Processing rugosity...'      PRINT *, 'Processing rugosity...'
131    
132      call NF95_OPEN('Rugos.nc', NF90_NOWRITE, ncid)      call NF95_OPEN('Rugos.nc', NF90_NOWRITE, ncid)
133    
134      ! Read coordinate variables:      ! Read coordinate variables:
# Line 108  contains Line 152  contains
152      ! Read the primary variable day by day and regrid horizontally,      ! Read the primary variable day by day and regrid horizontally,
153      ! result in "champtime":      ! result in "champtime":
154      DO  l = 1, lmdep      DO  l = 1, lmdep
155         ierr = NF90_GET_VAR(ncid, varid, champ, start=(/1, 1, l/))         call NF95_GET_VAR(ncid, varid, champ, start=[1, 1, l])
        call handle_err("NF90_GET_VAR", ierr)  
   
156         CALL conf_dat2d(dlon_ini, dlat_ini, dlon, dlat, champ)         CALL conf_dat2d(dlon_ini, dlat_ini, dlon, dlat, champ)
157         CALL inter_barxy(dlon, dlat(:jmdep -1), LOG(champ), rlonu(:iim), &         CALL inter_barxy(dlon, dlat(:jmdep -1), LOG(champ), rlonu(:iim), &
158              rlatv, champtime(:, :, l))              rlatv, champtime(:, :, l))
# Line 120  contains Line 162  contains
162    
163      call NF95_CLOSE(ncid)      call NF95_CLOSE(ncid)
164    
165      DEALLOCATE(dlon, dlat, champ, dlon_ini, dlat_ini)      DEALLOCATE(dlon, dlat, champ)
166      allocate(yder(lmdep))      allocate(yder(lmdep))
167    
168      ! Interpolate monthly values to daily values, at each horizontal position:      ! Interpolate monthly values to daily values, at each horizontal position:
169      DO j = 1, jjm + 1      DO j = 1, jjm + 1
170         DO i = 1, iim         DO i = 1, iim
171            yder(:) = SPLINE(timeyear, champtime(i, j, :))            yder = SPLINE(timeyear, champtime(i, j, :))
172            DO k = 1, 360            DO k = 1, 360
173               champan(i, j, k) = SPLINT(timeyear, champtime(i, j, :), yder, &               champan(i, j, k) = SPLINT(timeyear, champtime(i, j, :), yder, &
174                    real(k-1))                    real(k-1))
# Line 134  contains Line 176  contains
176         ENDDO         ENDDO
177      ENDDO      ENDDO
178    
179      deallocate(timeyear, champtime, yder)      deallocate(champtime, yder)
180      champan(iim + 1, :, :) = champan(1, :, :)      champan(iim + 1, :, :) = champan(1, :, :)
     forall (k = 1:360) phy_rug(:, k) = pack(champan(:, :, k), dyn_phy)  
181    
182      ! Process sea ice:      DO k = 1, 360
183           call NF95_PUT_VAR(ncid_limit, id_RUG, pack(champan(:, :, k), dyn_phy), &
184                start=[1, k])
185        ENDDO
186    
187      PRINT *, 'Processing sea ice...'      PRINT *, 'Processing sea ice...'
188      call NF95_OPEN('amipbc_sic_1x1.nc', NF90_NOWRITE, ncid)      call NF95_OPEN('amipbc_sic_1x1.nc', NF90_NOWRITE, ncid)
# Line 154  contains Line 198  contains
198      call nf95_inq_dimid(ncid, "time", dimid)      call nf95_inq_dimid(ncid, "time", dimid)
199      call NF95_INQuire_DIMension(ncid, dimid, nclen=lmdep)      call NF95_INQuire_DIMension(ncid, dimid, nclen=lmdep)
200      print *, 'lmdep = ', lmdep      print *, 'lmdep = ', lmdep
201      ! PM 28/02/2002 : nouvelle coordonnée temporelle, fichiers AMIP      ! Coordonn\'ee temporelle fichiers AMIP pas en jours. Ici on suppose
202      ! pas en jours      ! qu'on a 12 mois (de 30 jours).
203      ! Ici on suppose qu'on a 12 mois (de 30 jours).      IF (lmdep /= 12) then
204      IF (lmdep /= 12) STOP 'Unknown AMIP file: not 12 months?'         print *, 'Unknown AMIP file: not 12 months?'
205           STOP 1
206        end IF
207    
208      ALLOCATE(champ(imdep, jmdep), champtime(iim, jjm + 1, lmdep))      ALLOCATE(champ(imdep, jmdep), champtime(iim, jjm + 1, lmdep))
209      ALLOCATE (dlon(imdep), dlat(jmdep))      ALLOCATE(dlon(imdep), dlat(jmdep))
210      call NF95_INQ_VARID(ncid, 'sicbcs', varid)      call NF95_INQ_VARID(ncid, 'sicbcs', varid)
211      DO l = 1, lmdep      DO l = 1, lmdep
212         ierr = NF90_GET_VAR(ncid, varid, champ, start=(/1, 1, l/))         call NF95_GET_VAR(ncid, varid, champ, start=[1, 1, l])
        call handle_err("NF90_GET_VAR", ierr)  
   
213         CALL conf_dat2d(dlon_ini, dlat_ini, dlon, dlat, champ)         CALL conf_dat2d(dlon_ini, dlat_ini, dlon, dlat, champ)
214         CALL inter_barxy (dlon, dlat(:jmdep -1), champ, rlonu(:iim), rlatv, &         CALL inter_barxy(dlon, dlat(:jmdep -1), champ, rlonu(:iim), rlatv, &
215              champtime(:, :, l))              champtime(:, :, l))
216      ENDDO      ENDDO
217    
218      call NF95_CLOSE(ncid)      call NF95_CLOSE(ncid)
219    
220      DEALLOCATE(dlon, dlat, champ, dlon_ini, dlat_ini)      DEALLOCATE(dlon, dlat, champ)
221      PRINT *, 'Interpolation temporelle'      PRINT *, 'Interpolation temporelle'
222      allocate(yder(lmdep))      allocate(yder(lmdep))
223    
224      DO j = 1, jjm + 1      DO j = 1, jjm + 1
225         DO i = 1, iim         DO i = 1, iim
226            yder(:) = SPLINE(tmidmonth, champtime(i, j, :))            yder = SPLINE(tmidmonth, champtime(i, j, :))
227            DO k = 1, 360            DO k = 1, 360
228               champan(i, j, k) = SPLINT(tmidmonth, champtime(i, j, :), yder, &               champan(i, j, k) = SPLINT(tmidmonth, champtime(i, j, :), yder, &
229                    real(k-1))                    real(k-1))
# Line 195  contains Line 239  contains
239      champan(iim + 1, :, :) = champan(1, :, :)      champan(iim + 1, :, :) = champan(1, :, :)
240    
241      DO k = 1, 360      DO k = 1, 360
242         phy_ice(:) = pack(champan(:, :, k), dyn_phy)         phy_ice = pack(champan(:, :, k), dyn_phy)
243    
244         ! (utilisation de la sous-maille fractionnelle tandis que l'ancien         ! (utilisation de la sous-maille fractionnelle tandis que l'ancien
245         ! codage utilisait l'indicateur du sol (0, 1, 2, 3))         ! codage utilisait l'indicateur du sol (0, 1, 2, 3))
246         ! PB en attendant de mettre fraction de terre         ! PB en attendant de mettre fraction de terre
247         WHERE(phy_ice(:) < EPSFRA) phy_ice(:) = 0.         WHERE (phy_ice < EPSFRA) phy_ice = 0.
248    
249         pctsrf_t(:, is_ter, k) = pctsrf(:, is_ter)         pctsrf(:, is_sic) = max(phy_ice - pctsrf(:, is_lic), 0.)
250         pctsrf_t(:, is_lic, k) = pctsrf(:, is_lic)         ! Il y a des cas o\`u il y a de la glace dans landiceref et
        pctsrf_t(:, is_sic, k) = max(phy_ice(:) - pctsrf_t(:, is_lic, k), 0.)  
        ! Il y a des cas où il y a de la glace dans landiceref et  
251         ! pas dans AMIP         ! pas dans AMIP
252         WHERE( 1. - zmasq(:) < EPSFRA)         WHERE (1. - zmasq < EPSFRA)
253            pctsrf_t(:, is_sic, k) = 0.            pctsrf(:, is_sic) = 0.
254            pctsrf_t(:, is_oce, k) = 0.            pctsrf(:, is_oce) = 0.
255         elsewhere         elsewhere
256            where (pctsrf_t(:, is_sic, k) >= 1 - zmasq(:))            where (pctsrf(:, is_sic) >= 1 - zmasq)
257               pctsrf_t(:, is_sic, k) = 1. - zmasq(:)               pctsrf(:, is_sic) = 1. - zmasq
258               pctsrf_t(:, is_oce, k) = 0.               pctsrf(:, is_oce) = 0.
259            ELSEwhere            ELSEwhere
260               pctsrf_t(:, is_oce, k) = 1. - zmasq(:) - pctsrf_t(:, is_sic, k)               pctsrf(:, is_oce) = 1. - zmasq - pctsrf(:, is_sic)
261               where (pctsrf_t(:, is_oce, k) < EPSFRA)               where (pctsrf(:, is_oce) < EPSFRA)
262                  pctsrf_t(:, is_oce, k) = 0.                  pctsrf(:, is_oce) = 0.
263                  pctsrf_t(:, is_sic, k) = 1 - zmasq(:)                  pctsrf(:, is_sic) = 1 - zmasq
264               end where               end where
265            end where            end where
266         end where         end where
267    
268         DO i = 1, klon         DO i = 1, klon
269            if (pctsrf_t(i, is_oce, k) < 0.) then            if (pctsrf(i, is_oce) < 0.) then
270               print *, 'Problème sous maille : pctsrf_t(', i, &               print *, "k = ", k
271                    ', is_oce, ', k, ') = ', pctsrf_t(i, is_oce, k)               print *, 'Bad surface fraction: pctsrf(', i, ', is_oce) = ', &
272                      pctsrf(i, is_oce)
273            ENDIF            ENDIF
274            IF (abs(pctsrf_t(i, is_ter, k) + pctsrf_t(i, is_lic, k) &            IF (abs(sum(pctsrf(i, :)) - 1.) > EPSFRA) THEN
275                 + pctsrf_t(i, is_oce, k) + pctsrf_t(i, is_sic, k) - 1.) &               print *, "k = ", k
276                 > EPSFRA) THEN               print *, 'Bad surface fraction:'
277               print *, 'Problème sous surface :'               print *, "pctsrf(", i, ", :) = ", pctsrf(i, :)
              print *, "pctsrf_t(", i, ", :, ", k, ") = ", &  
                   pctsrf_t(i, :, k)  
278               print *, "phy_ice(", i, ") = ", phy_ice(i)               print *, "phy_ice(", i, ") = ", phy_ice(i)
279            ENDIF            ENDIF
280         END DO         END DO
     ENDDO  
281    
282           call NF95_PUT_VAR(ncid_limit, id_FOCE, pctsrf(:, is_oce), start=[1, k])
283           call NF95_PUT_VAR(ncid_limit, id_FSIC, pctsrf(:, is_sic), start=[1, k])
284           call NF95_PUT_VAR(ncid_limit, id_FTER, pctsrf(:, is_ter), start=[1, k])
285           call NF95_PUT_VAR(ncid_limit, id_FLIC, pctsrf(:, is_lic), start=[1, k])
286        end DO
287        
288      PRINT *, 'Traitement de la sst'      PRINT *, 'Traitement de la sst'
289      call NF95_OPEN('amipbc_sst_1x1.nc', NF90_NOWRITE, ncid)      call NF95_OPEN('amipbc_sst_1x1.nc', NF90_NOWRITE, ncid)
290    
# Line 253  contains Line 299  contains
299      call nf95_inq_dimid(ncid, "time", dimid)      call nf95_inq_dimid(ncid, "time", dimid)
300      call NF95_INQuire_DIMension(ncid, dimid, nclen=lmdep)      call NF95_INQuire_DIMension(ncid, dimid, nclen=lmdep)
301      print *, 'lmdep = ', lmdep      print *, 'lmdep = ', lmdep
302      !PM28/02/2002 : nouvelle coord temporelle fichiers AMIP pas en jours      ! Ici on suppose qu'on a 12 mois (de 30 jours).
303      !        Ici on suppose qu'on a 12 mois (de 30 jours).      call assert(lmdep == 12, 'limit: AMIP file does not contain 12 months')
304      IF (lmdep /= 12) stop 'Unknown AMIP file: not 12 months?'  
305        ALLOCATE(champ(imdep, jmdep), champtime(iim, jjm + 1, lmdep))
306      ALLOCATE( champ(imdep, jmdep), champtime(iim, jjm + 1, lmdep))      IF (extrap) ALLOCATE(work(imdep, jmdep))
307      IF( extrap )  THEN      ALLOCATE(dlon(imdep), dlat(jmdep))
        ALLOCATE ( work(imdep, jmdep) )  
     ENDIF  
     ALLOCATE(   dlon(imdep), dlat(jmdep) )  
308      call NF95_INQ_VARID(ncid, 'tosbcs', varid)      call NF95_INQ_VARID(ncid, 'tosbcs', varid)
309    
310      DO l = 1, lmdep      DO l = 1, lmdep
311         ierr = NF90_GET_VAR(ncid, varid, champ, start=(/1, 1, l/))         call NF95_GET_VAR(ncid, varid, champ, start=[1, 1, l])
        call handle_err("NF90_GET_VAR", ierr)  
   
312         CALL conf_dat2d(dlon_ini, dlat_ini, dlon, dlat, champ)         CALL conf_dat2d(dlon_ini, dlat_ini, dlon, dlat, champ)
313         IF ( extrap ) THEN         IF (extrap) &
314            CALL extrapol(champ, imdep, jmdep, 999999., .TRUE., .TRUE., 2, work)              CALL extrapol(champ, imdep, jmdep, 999999., .TRUE., .TRUE., 2, work)
315         ENDIF         CALL inter_barxy(dlon, dlat(:jmdep -1), champ, rlonu(:iim), rlatv, &
316                champtime(:, :, l))
        CALL inter_barxy (dlon, dlat(:jmdep -1), champ, rlonu(:iim), rlatv, &  
             champtime(:, :, l) )  
317      ENDDO      ENDDO
318    
319      call NF95_CLOSE(ncid)      call NF95_CLOSE(ncid)
320        DEALLOCATE(dlon, dlat, champ)
     DEALLOCATE(dlon, dlat, champ, dlon_ini, dlat_ini)  
321      allocate(yder(lmdep))      allocate(yder(lmdep))
322    
323      ! interpolation temporelle      ! interpolation temporelle
324      DO j = 1, jjm + 1      DO j = 1, jjm + 1
325         DO i = 1, iim         DO i = 1, iim
326            yder(:) = SPLINE(tmidmonth, champtime(i, j, :))            yder = SPLINE(tmidmonth, champtime(i, j, :))
327            DO k = 1, 360            DO k = 1, 360
328               champan(i, j, k) = SPLINT(tmidmonth, champtime(i, j, :), yder, &               champan(i, j, k) = SPLINT(tmidmonth, champtime(i, j, :), yder, &
329                    real(k-1))                    real(k-1))
# Line 297  contains Line 335  contains
335      champan(iim + 1, :, :) = champan(1, :, :)      champan(iim + 1, :, :) = champan(1, :, :)
336    
337      !IM14/03/2002 : SST amipbc greater then 271.38      !IM14/03/2002 : SST amipbc greater then 271.38
338      PRINT *, 'SUB. limit_netcdf.F IM : SST Amipbc >= 271.38 '      PRINT *, 'limit: SST Amipbc >= 271.38 '
339    
340      DO k = 1, 360      DO k = 1, 360
341         DO j = 1, jjm + 1         DO j = 1, jjm + 1
342            DO i = 1, iim            DO i = 1, iim
343               champan(i, j, k) = amax1(champan(i, j, k), 271.38)               champan(i, j, k) = max(champan(i, j, k), 271.38)
344            ENDDO            ENDDO
345              
346            champan(iim + 1, j, k) = champan(1, j, k)            champan(iim + 1, j, k) = champan(1, j, k)
347         ENDDO         ENDDO
348      ENDDO      ENDDO
349      forall (k = 1:360) phy_sst(:, k) = pack(champan(:, :, k), dyn_phy)      
350        DO k = 1, 360
351      ! Traitement de l'albedo         call NF95_PUT_VAR(ncid_limit, id_SST, pack(champan(:, :, k), dyn_phy), &
352                start=[1, k])
353        end DO
354    
355      PRINT *, 'Traitement de l albedo'      PRINT *, "Traitement de l'albedo..."
356      call NF95_OPEN('Albedo.nc', NF90_NOWRITE, ncid)      call NF95_OPEN('Albedo.nc', NF90_NOWRITE, ncid)
357    
358      call nf95_inq_varid(ncid, "longitude", varid)      call nf95_inq_varid(ncid, "longitude", varid)
# Line 325  contains Line 367  contains
367      call nf95_gw_var(ncid, varid, timeyear)      call nf95_gw_var(ncid, varid, timeyear)
368      lmdep = size(timeyear)      lmdep = size(timeyear)
369    
370      ALLOCATE ( champ(imdep, jmdep), champtime(iim, jjm + 1, lmdep))      ALLOCATE(champ(imdep, jmdep), champtime(iim, jjm + 1, lmdep))
371      ALLOCATE (   dlon(imdep), dlat(jmdep) )      ALLOCATE(dlon(imdep), dlat(jmdep))
372      call NF95_INQ_VARID(ncid, 'ALBEDO', varid)      call NF95_INQ_VARID(ncid, 'ALBEDO', varid)
373    
374      DO l = 1, lmdep      DO l = 1, lmdep
375         PRINT *, 'Lecture temporelle et int. horizontale ', l, timeyear(l)         PRINT *, "timeyear(", l, ") =", timeyear(l)
376         ierr = NF90_GET_VAR(ncid, varid, champ, start=(/1, 1, l/))         call NF95_GET_VAR(ncid, varid, champ, start=[1, 1, l])
        call handle_err("NF90_GET_VAR", ierr)  
   
377         CALL conf_dat2d(dlon_ini, dlat_ini, dlon, dlat, champ)         CALL conf_dat2d(dlon_ini, dlat_ini, dlon, dlat, champ)
378         CALL inter_barxy(dlon, dlat(:jmdep-1), champ, rlonu(:iim), rlatv, &         CALL inter_barxy(dlon, dlat(:jmdep-1), champ, rlonu(:iim), rlatv, &
379              champtime(:, :, l) )              champtime(:, :, l))
380      ENDDO      ENDDO
381    
382      call NF95_CLOSE(ncid)      call NF95_CLOSE(ncid)
383    
     deallocate(dlon_ini, dlat_ini)  
384      allocate(yder(lmdep))      allocate(yder(lmdep))
385    
386      ! interpolation temporelle      ! interpolation temporelle
387      DO j = 1, jjm + 1      DO j = 1, jjm + 1
388         DO i = 1, iim         DO i = 1, iim
389            yder(:) = SPLINE(timeyear, champtime(i, j, :))            yder = SPLINE(timeyear, champtime(i, j, :))
390            DO k = 1, 360            DO k = 1, 360
391               champan(i, j, k) = SPLINT(timeyear, champtime(i, j, :), yder, &               champan(i, j, k) = SPLINT(timeyear, champtime(i, j, :), yder, &
392                    real(k-1))                    real(k-1))
393            ENDDO            ENDDO
394         ENDDO         ENDDO
395      ENDDO      ENDDO
     deallocate(timeyear)  
396    
397      champan(iim + 1, :, :) = champan(1, :, :)      champan(iim + 1, :, :) = champan(1, :, :)
     forall (k = 1:360) phy_alb(:, k) = pack(champan(:, :, k), dyn_phy)  
398    
399      DO k = 1, 360      DO k = 1, 360
400         DO i = 1, klon         call NF95_PUT_VAR(ncid_limit, id_ALB, pack(champan(:, :, k), dyn_phy), &
401            phy_bil(i, k) = 0.0              start=[1, k])
402         ENDDO      end DO
     ENDDO  
403    
404      PRINT *, 'Ecriture du fichier limit'      phy_bil = 0.
405        call NF95_PUT_VAR(ncid_limit, id_BILS, phy_bil)
     call NF95_CREATE("limit.nc", NF90_CLOBBER, nid)  
   
     ierr = NF90_PUT_ATT(nid, NF90_GLOBAL, "title", &  
          "Fichier conditions aux limites")  
     call NF95_DEF_DIM (nid, "points_physiques", klon, ndim)  
     call NF95_DEF_DIM (nid, "time", NF90_UNLIMITED, ntim)  
   
     dims(1) = ndim  
     dims(2) = ntim  
   
     ierr = NF90_DEF_VAR (nid, "TEMPS", NF90_FLOAT, ntim, id_tim)  
     ierr = NF90_PUT_ATT (nid, id_tim, "title",  &  
          "Jour dans l annee")  
     ierr = NF90_DEF_VAR (nid, "FOCE", NF90_FLOAT, dims, id_FOCE)  
     ierr = NF90_PUT_ATT (nid, id_FOCE, "title", &  
          "Fraction ocean")  
   
     ierr = NF90_DEF_VAR (nid, "FSIC", NF90_FLOAT, dims, id_FSIC)  
     ierr = NF90_PUT_ATT (nid, id_FSIC, "title", &  
          "Fraction glace de mer")  
   
     ierr = NF90_DEF_VAR (nid, "FTER", NF90_FLOAT, dims, id_FTER)  
     ierr = NF90_PUT_ATT (nid, id_FTER, "title", &  
          "Fraction terre")  
   
     ierr = NF90_DEF_VAR (nid, "FLIC", NF90_FLOAT, dims, id_FLIC)  
     ierr = NF90_PUT_ATT (nid, id_FLIC, "title", &  
          "Fraction land ice")  
   
     ierr = NF90_DEF_VAR (nid, "SST", NF90_FLOAT, dims, id_SST)  
     ierr = NF90_PUT_ATT (nid, id_SST, "title",  &  
          "Temperature superficielle de la mer")  
     ierr = NF90_DEF_VAR (nid, "BILS", NF90_FLOAT, dims, id_BILS)  
     ierr = NF90_PUT_ATT (nid, id_BILS, "title", &  
          "Reference flux de chaleur au sol")  
     ierr = NF90_DEF_VAR (nid, "ALB", NF90_FLOAT, dims, id_ALB)  
     ierr = NF90_PUT_ATT (nid, id_ALB, "title", &  
          "Albedo a la surface")  
     ierr = NF90_DEF_VAR (nid, "RUG", NF90_FLOAT, dims, id_RUG)  
     ierr = NF90_PUT_ATT (nid, id_RUG, "title", &  
          "Rugosite")  
   
     call NF95_ENDDEF(nid)  
   
     DO k = 1, 360  
        debut(1) = 1  
        debut(2) = k  
   
        ierr = NF90_PUT_VAR(nid, id_tim, FLOAT(k), (/k/))  
        ierr = NF90_PUT_VAR(nid, id_FOCE, pctsrf_t(:, is_oce, k), debut)  
        ierr = NF90_PUT_VAR (nid, id_FSIC, pctsrf_t(:, is_sic, k), debut)  
        ierr = NF90_PUT_VAR (nid, id_FTER, pctsrf_t(:, is_ter, k), debut)  
        ierr = NF90_PUT_VAR (nid, id_FLIC, pctsrf_t(:, is_lic, k), debut)  
        ierr = NF90_PUT_VAR (nid, id_SST, phy_sst(:, k), debut)  
        ierr = NF90_PUT_VAR (nid, id_BILS, phy_bil(:, k), debut)  
        ierr = NF90_PUT_VAR (nid, id_ALB, phy_alb(:, k), debut)  
        ierr = NF90_PUT_VAR (nid, id_RUG, phy_rug(:, k), debut)  
     ENDDO  
406    
407      call NF95_CLOSE(nid)      call NF95_CLOSE(ncid_limit)
408    
409    END SUBROUTINE limit    END SUBROUTINE limit
410    

Legend:
Removed from v.34  
changed lines
  Added in v.276

  ViewVC Help
Powered by ViewVC 1.1.21