source: LMDZ5/trunk/libf/phylmd/limit_slab.F90 @ 2451

Last change on this file since 2451 was 2344, checked in by Ehouarn Millour, 9 years ago

Physics/dynamics separation: get rid of all the 'include "temps.h"' in the physics; variables in module time_phylmdz_mod must be used instead. Also added JD_cur, JH_cur and JD_ref in module phys_cal_mod, in preparation for having physics handle its calendar internally.
EM

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1! $Header$
2
3SUBROUTINE limit_slab(itime, dtime, jour, lmt_bils, diff_sst, diff_siv)
4
5  USE dimphy
6  USE mod_grid_phy_lmdz, ONLY: klon_glo
7  USE mod_phys_lmdz_para
8  USE netcdf
9  USE indice_sol_mod
10
11  IMPLICIT NONE
12
13  INCLUDE "clesphys.h"
14
15! In- and ouput arguments
16!****************************************************************************************
17  INTEGER, INTENT(IN) :: itime   ! numero du pas de temps courant
18  INTEGER, INTENT(IN) :: jour    ! jour a lire dans l'annee
19  REAL   , INTENT(IN) :: dtime   ! pas de temps de la physique (en s)
20  REAL, DIMENSION(klon), INTENT(OUT) :: lmt_bils, diff_sst, diff_siv
21
22! Locals variables with attribute SAVE
23!****************************************************************************************
24  REAL, DIMENSION(:), ALLOCATABLE, SAVE :: bils_save, diff_sst_save
25  REAL, DIMENSION(:), ALLOCATABLE, SAVE :: diff_siv_save
26!$OMP THREADPRIVATE(bils_save, diff_sst_save, diff_siv_save)
27
28! Locals variables
29!****************************************************************************************
30  INTEGER                  :: lmt_pas   
31  INTEGER                  :: nvarid, nid, ierr, i
32  INTEGER, DIMENSION(2)    :: start, epais
33  REAL, DIMENSION(klon_glo):: bils_glo, sst_l_glo, sst_lp1_glo, diff_sst_glo
34  REAL, DIMENSION(klon_glo):: siv_l_glo, siv_lp1_glo, diff_siv_glo
35  CHARACTER (len = 20)     :: modname = 'limit_slab'
36  LOGICAL                  :: read_bils,read_sst,read_siv
37
38! End declaration
39!****************************************************************************************
40
41  ! calculate number of time steps for one day
42  lmt_pas = NINT(86400./dtime)
43 
44  ! F. Codron 5/14: add defaults for bils, diff_sst (0)
45  IF (MOD(itime-1, lmt_pas) == 0) THEN   ! time to read
46     !$OMP MASTER  ! Only master thread
47     IF (is_mpi_root) THEN ! Only master processus
48        print*,'in limit_slab time to read, itime=',itime
49        read_bils=.TRUE.
50        read_sst=.TRUE.
51        read_siv=.TRUE.
52       
53        ierr = NF90_OPEN ('limit_slab.nc', NF90_NOWRITE, nid)
54        IF (ierr /= NF90_NOERR) THEN
55            read_bils=.FALSE.
56            read_sst=.FALSE.
57            read_siv=.FALSE.
58        ELSE ! read file
59       
60        ! La tranche de donnees a lire:
61        start(1) = 1
62        start(2) = jour
63        epais(1) = klon_glo
64        epais(2) = 1
65
66!****************************************************************************************
67! 2) Read bils and SST/ ice volume tendency
68!
69!****************************************************************************************
70!
71! Read bils_glo
72        ierr = NF90_INQ_VARID(nid, 'BILS_OCE', nvarid)
73        IF (ierr /= NF90_NOERR) THEN
74            read_bils=.FALSE.
75        ELSE
76            ierr = NF90_GET_VAR(nid,nvarid,bils_glo,start,epais)
77            IF (ierr /= NF90_NOERR) read_bils=.FALSE.
78        END IF
79! Read sst_glo for this day
80        ierr = NF90_INQ_VARID(nid, 'SST', nvarid)
81        IF (ierr /= NF90_NOERR)  THEN
82            read_sst=.FALSE.
83        ELSE
84            ierr = NF90_GET_VAR(nid,nvarid,sst_l_glo,start,epais)
85            IF (ierr /= NF90_NOERR) read_sst=.FALSE.
86! Read sst_glo for one day ahead
87            start(2) = jour + 1
88            IF (start(2) > 360) start(2)=1
89            ierr = NF90_GET_VAR(nid,nvarid,sst_lp1_glo,start,epais)
90            IF (ierr /= NF90_NOERR) read_sst=.FALSE.
91        END IF
92
93! Read siv_glo for this day
94        ierr = NF90_INQ_VARID(nid, 'SICV', nvarid)
95        IF (ierr /= NF90_NOERR)  THEN
96            read_siv=.FALSE.
97        ELSE
98            start(2) = jour
99            ierr = NF90_GET_VAR(nid,nvarid,siv_l_glo,start,epais)
100            IF (ierr /= NF90_NOERR) read_siv=.FALSE.
101! Read siv_glo for one day ahead
102            start(2) = jour + 1
103            IF (start(2) > 360) start(2)=1
104            ierr = NF90_GET_VAR(nid,nvarid,siv_lp1_glo,start,epais)
105            IF (ierr /= NF90_NOERR) read_siv=.FALSE.
106        END IF
107
108!****************************************************************************************
109! 5) Close file and distribute variables to all processus
110!
111!****************************************************************************************
112        ierr = NF90_CLOSE(nid)
113        IF (ierr /= NF90_NOERR) CALL abort_physic(modname,'Pb when closing file', 1)
114        END IF ! Read File
115        IF (read_sst) THEN
116! Calculate difference in temperature between this day and one ahead
117            DO i=1, klon_glo
118               diff_sst_glo(i) = sst_lp1_glo(i) - sst_l_glo(i)
119            END DO
120        END IF !read_sst
121        IF (read_siv) THEN
122! Calculate difference in temperature between this day and one ahead
123            DO i=1, klon_glo
124               diff_siv_glo(i) = siv_lp1_glo(i) - siv_l_glo(i)
125            END DO
126        END IF !read_siv
127     ENDIF ! is_mpi_root
128
129!$OMP END MASTER
130       
131     IF (.NOT. ALLOCATED(bils_save)) THEN
132        ALLOCATE(bils_save(klon), diff_sst_save(klon), diff_siv_save(klon), stat=ierr)
133        IF (ierr /= 0) CALL abort_physic('limit_slab', 'pb in allocation',1)
134     END IF
135
136! Give default values if needed
137     IF (read_bils) THEN
138         CALL Scatter(bils_glo, bils_save)
139     ELSE
140         bils_save(:)=0.
141     END IF
142     IF (read_sst) THEN
143         CALL Scatter(diff_sst_glo, diff_sst_save)
144     ELSE
145         diff_sst_save(:)=0.
146     END IF
147     IF (read_siv) THEN
148         CALL Scatter(diff_siv_glo, diff_siv_save)
149     ELSE
150         diff_siv_save(:)=0.
151     END IF
152     
153  ENDIF ! time to read
154
155  lmt_bils(:) = bils_save(:)
156  diff_sst(:) = diff_sst_save(:)
157  diff_siv(:) = diff_siv_save(:)
158
159 
160END SUBROUTINE limit_slab
Note: See TracBrowser for help on using the repository browser.