source: LMDZ5/branches/testing/libf/phylmd/limit_slab.F90 @ 4674

Last change on this file since 4674 was 2669, checked in by Laurent Fairhead, 8 years ago

Merged trunk changes r2640:2664 into testing branch

  • 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.7 KB
RevLine 
[996]1! $Header$
2
[2220]3SUBROUTINE limit_slab(itime, dtime, jour, lmt_bils, diff_sst, diff_siv)
[996]4
5  USE dimphy
[2408]6  USE mod_grid_phy_lmdz, ONLY: klon_glo
[996]7  USE mod_phys_lmdz_para
8  USE netcdf
[1795]9  USE indice_sol_mod
[996]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)
[2220]20  REAL, DIMENSION(klon), INTENT(OUT) :: lmt_bils, diff_sst, diff_siv
[996]21
22! Locals variables with attribute SAVE
23!****************************************************************************************
[2073]24  REAL, DIMENSION(:), ALLOCATABLE, SAVE :: bils_save, diff_sst_save
[2220]25  REAL, DIMENSION(:), ALLOCATABLE, SAVE :: diff_siv_save
26!$OMP THREADPRIVATE(bils_save, diff_sst_save, diff_siv_save)
[996]27
28! Locals variables
29!****************************************************************************************
30  INTEGER                  :: lmt_pas   
31  INTEGER                  :: nvarid, nid, ierr, i
32  INTEGER, DIMENSION(2)    :: start, epais
[2073]33  REAL, DIMENSION(klon_glo):: bils_glo, sst_l_glo, sst_lp1_glo, diff_sst_glo
[2220]34  REAL, DIMENSION(klon_glo):: siv_l_glo, siv_lp1_glo, diff_siv_glo
[996]35  CHARACTER (len = 20)     :: modname = 'limit_slab'
[2220]36  LOGICAL                  :: read_bils,read_sst,read_siv
[996]37
38! End declaration
39!****************************************************************************************
40
41  ! calculate number of time steps for one day
42  lmt_pas = NINT(86400./dtime)
43 
[2542]44! Initialize saved variables
45     IF (.NOT. ALLOCATED(bils_save)) THEN
46        ALLOCATE(bils_save(klon), diff_sst_save(klon), diff_siv_save(klon), stat=ierr)
47        IF (ierr /= 0) CALL abort_physic('limit_slab', 'pb in allocation',1)
48     END IF
49
[2073]50  ! F. Codron 5/14: add defaults for bils, diff_sst (0)
[996]51  IF (MOD(itime-1, lmt_pas) == 0) THEN   ! time to read
[2542]52!$OMP MASTER  ! Only master thread
[996]53     IF (is_mpi_root) THEN ! Only master processus
54        print*,'in limit_slab time to read, itime=',itime
[2073]55        read_bils=.TRUE.
56        read_sst=.TRUE.
[2220]57        read_siv=.TRUE.
[996]58       
59        ierr = NF90_OPEN ('limit_slab.nc', NF90_NOWRITE, nid)
[2073]60        IF (ierr /= NF90_NOERR) THEN
[2542]61            PRINT *,'LIMIT_SLAB file not found'
[2073]62            read_bils=.FALSE.
63            read_sst=.FALSE.
[2220]64            read_siv=.FALSE.
[2073]65        ELSE ! read file
[996]66       
67        ! La tranche de donnees a lire:
68        start(1) = 1
69        start(2) = jour
70        epais(1) = klon_glo
71        epais(2) = 1
72
73!****************************************************************************************
[2220]74! 2) Read bils and SST/ ice volume tendency
[996]75!
76!****************************************************************************************
77!
78! Read bils_glo
79        ierr = NF90_INQ_VARID(nid, 'BILS_OCE', nvarid)
[2073]80        IF (ierr /= NF90_NOERR) THEN
81            read_bils=.FALSE.
82        ELSE
83            ierr = NF90_GET_VAR(nid,nvarid,bils_glo,start,epais)
84            IF (ierr /= NF90_NOERR) read_bils=.FALSE.
85        END IF
[996]86! Read sst_glo for this day
87        ierr = NF90_INQ_VARID(nid, 'SST', nvarid)
[2073]88        IF (ierr /= NF90_NOERR)  THEN
89            read_sst=.FALSE.
90        ELSE
91            ierr = NF90_GET_VAR(nid,nvarid,sst_l_glo,start,epais)
92            IF (ierr /= NF90_NOERR) read_sst=.FALSE.
[996]93! Read sst_glo for one day ahead
[2073]94            start(2) = jour + 1
95            IF (start(2) > 360) start(2)=1
96            ierr = NF90_GET_VAR(nid,nvarid,sst_lp1_glo,start,epais)
97            IF (ierr /= NF90_NOERR) read_sst=.FALSE.
98        END IF
[996]99
[2220]100! Read siv_glo for this day
101        ierr = NF90_INQ_VARID(nid, 'SICV', nvarid)
102        IF (ierr /= NF90_NOERR)  THEN
103            read_siv=.FALSE.
104        ELSE
105            start(2) = jour
106            ierr = NF90_GET_VAR(nid,nvarid,siv_l_glo,start,epais)
107            IF (ierr /= NF90_NOERR) read_siv=.FALSE.
108! Read siv_glo for one day ahead
109            start(2) = jour + 1
110            IF (start(2) > 360) start(2)=1
111            ierr = NF90_GET_VAR(nid,nvarid,siv_lp1_glo,start,epais)
112            IF (ierr /= NF90_NOERR) read_siv=.FALSE.
113        END IF
114
[996]115!****************************************************************************************
[2073]116! 5) Close file and distribute variables to all processus
[996]117!
118!****************************************************************************************
119        ierr = NF90_CLOSE(nid)
[2408]120        IF (ierr /= NF90_NOERR) CALL abort_physic(modname,'Pb when closing file', 1)
[2542]121        END IF ! Read File
[2073]122        IF (read_sst) THEN
123! Calculate difference in temperature between this day and one ahead
124            DO i=1, klon_glo
125               diff_sst_glo(i) = sst_lp1_glo(i) - sst_l_glo(i)
126            END DO
127        END IF !read_sst
[2220]128        IF (read_siv) THEN
129! Calculate difference in temperature between this day and one ahead
130            DO i=1, klon_glo
131               diff_siv_glo(i) = siv_lp1_glo(i) - siv_l_glo(i)
132            END DO
133        END IF !read_siv
[996]134     ENDIF ! is_mpi_root
135
136!$OMP END MASTER
[2542]137!$OMP BARRIER
[996]138       
[2542]139! Send fields to all processes
[2220]140! Give default values if needed
[2542]141     CALL bcast(read_bils)
142     CALL bcast(read_sst)
143     CALL bcast(read_siv)
144     PRINT *,'limit_slab sst',read_sst,'siv',read_siv,'qflux',read_bils
[2073]145     IF (read_bils) THEN
146         CALL Scatter(bils_glo, bils_save)
147     ELSE
148         bils_save(:)=0.
149     END IF
150     IF (read_sst) THEN
151         CALL Scatter(diff_sst_glo, diff_sst_save)
152     ELSE
153         diff_sst_save(:)=0.
154     END IF
[2220]155     IF (read_siv) THEN
156         CALL Scatter(diff_siv_glo, diff_siv_save)
157     ELSE
158         diff_siv_save(:)=0.
159     END IF
[996]160     
161  ENDIF ! time to read
162
163  lmt_bils(:) = bils_save(:)
[2073]164  diff_sst(:) = diff_sst_save(:)
[2220]165  diff_siv(:) = diff_siv_save(:)
166
[996]167END SUBROUTINE limit_slab
Note: See TracBrowser for help on using the repository browser.