source: LMDZ5/branches/testing/libf/phylmd/rrtm/gridpoint_buffers.F90 @ 5407

Last change on this file since 5407 was 1999, checked in by Laurent Fairhead, 11 years ago

Merged trunk changes r1920:1997 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
File size: 3.2 KB
Line 
1MODULE GRIDPOINT_BUFFERS
2
3!     Purpose.
4!     --------
5!           GRIDPOINT_BUFFERS defines the type "gridpoint buffer",
6!           and the operations to create and destroy instances of
7!           the type.
8
9!     Author.
10!     -------
11!        Mike Fisher *ECMWF*
12
13!     Modifications.
14!     --------------
15!        Original : 1999-11-10
16!        M.Hamrud      01-Oct-2003 CY28 Cleaning
17
18!     ------------------------------------------------------------------
19
20USE PARKIND1  ,ONLY : JPIM     ,JPRB
21USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
22
23USE YOMCT0   , ONLY : NPRINTLEV , LALLOPR
24USE YOMGEM   , ONLY : NGPTOT
25USE YOMLUN   , ONLY : NULOUT
26
27IMPLICIT NONE
28SAVE
29
30PRIVATE
31PUBLIC gridpoint_buffer, &
32 & ALLOCATE_GRIDPOINT_BUFFER, &
33 & ALLOCATED_GRIDPOINT_BUFFER, &
34 & DEALLOCATE_GRIDPOINT_BUFFER 
35
36TYPE gridpoint_buffer
37CHARACTER(LEN=1), POINTER :: CLNAME(:)
38INTEGER(KIND=JPIM) :: IFIELDS
39INTEGER(KIND=JPIM) :: IDGEN
40INTEGER(KIND=JPIM) :: IDGENL
41INTEGER(KIND=JPIM) :: IBLEN
42INTEGER(KIND=JPIM) :: IPACK
43LOGICAL   :: LFILLED
44REAL(KIND=JPRB),    POINTER :: GPBUF(:)
45END TYPE gridpoint_buffer
46
47#include "abor1.intfb.h"
48
49!-----------------------------------------------------------------------
50
51CONTAINS
52SUBROUTINE ALLOCATE_GRIDPOINT_BUFFER (CDNAME,YDGPBUF,KFIELDS,KPACK, &
53                                &     KGPTOT)
54
55TYPE (gridpoint_buffer),INTENT(OUT)        :: YDGPBUF
56CHARACTER(LEN=*) , INTENT(IN)  :: CDNAME
57INTEGER(KIND=JPIM)        , INTENT(IN)  :: KFIELDS,KPACK
58INTEGER(KIND=JPIM)        , INTENT(IN),OPTIONAL  :: KGPTOT
59
60INTEGER(KIND=JPIM)   ::   J, IGPTOT
61REAL(KIND=JPRB)      :: ZDUM
62REAL(KIND=JPRB) :: ZHOOK_HANDLE
63
64IF (LHOOK) CALL DR_HOOK('GRIDPOINT_BUFFERS:ALLOCATE_GRIDPOINT_BUFFER',0,ZHOOK_HANDLE)
65
66IF(PRESENT(KGPTOT))THEN
67   IGPTOT=KGPTOT
68ELSE
69   IGPTOT=NGPTOT
70ENDIF
71
72ALLOCATE (YDGPBUF%CLNAME(LEN(CDNAME)))
73
74DO J=1,LEN(CDNAME)
75  YDGPBUF%CLNAME(J)  = CDNAME(J:J)
76ENDDO
77
78YDGPBUF%IFIELDS = KFIELDS
79YDGPBUF%IPACK   = KPACK
80
81IF (KPACK > 1) CALL ABOR1('ALLOCATE_GRIDPOINT_BUFFER: KPACK > 1')
82YDGPBUF%IBLEN = IGPTOT  * KFIELDS
83
84ALLOCATE (YDGPBUF%GPBUF(YDGPBUF%IBLEN))
85IF (NPRINTLEV >= 1.OR. LALLOPR) &
86 & WRITE(NULOUT,91) CDNAME,SIZE(YDGPBUF%GPBUF),SHAPE(YDGPBUF%GPBUF) 
87YDGPBUF%GPBUF(:) = HUGE(ZDUM)
88YDGPBUF%LFILLED = .FALSE.
89
90IF (LHOOK) CALL DR_HOOK('GRIDPOINT_BUFFERS:ALLOCATE_GRIDPOINT_BUFFER',1,ZHOOK_HANDLE)
9191  FORMAT(1X,'ALLOCATED GRIDPOINT BUFFER ',A,', SIZE=',I8,', SHAPE=',7I8)
92END SUBROUTINE ALLOCATE_GRIDPOINT_BUFFER
93
94SUBROUTINE DEALLOCATE_GRIDPOINT_BUFFER (YDGPBUF)
95TYPE (gridpoint_buffer),INTENT(INOUT) :: YDGPBUF
96INTEGER(KIND=JPIM) :: J
97REAL(KIND=JPRB) :: ZHOOK_HANDLE
98
99IF (LHOOK) CALL DR_HOOK('GRIDPOINT_BUFFERS:DEALLOCATE_GRIDPOINT_BUFFER',0,ZHOOK_HANDLE)
100IF (NPRINTLEV >= 1.OR. LALLOPR) &
101 & WRITE(NULOUT,92) (YDGPBUF%CLNAME(J),J=1,SIZE(YDGPBUF%CLNAME)) 
102
103DEALLOCATE (YDGPBUF%GPBUF)
104DEALLOCATE (YDGPBUF%CLNAME)
105YDGPBUF%LFILLED = .FALSE.
106
107IF (LHOOK) CALL DR_HOOK('GRIDPOINT_BUFFERS:DEALLOCATE_GRIDPOINT_BUFFER',1,ZHOOK_HANDLE)
10892  FORMAT(1X,'DEALLOCATED GRIDPOINT BUFFER:,',100A1)
109END SUBROUTINE DEALLOCATE_GRIDPOINT_BUFFER
110
111LOGICAL FUNCTION ALLOCATED_GRIDPOINT_BUFFER (YDGPBUF)
112TYPE (gridpoint_buffer),INTENT(IN) :: YDGPBUF
113ALLOCATED_GRIDPOINT_BUFFER =  ASSOCIATED (YDGPBUF%GPBUF)
114END FUNCTION ALLOCATED_GRIDPOINT_BUFFER
115
116END MODULE GRIDPOINT_BUFFERS
117
Note: See TracBrowser for help on using the repository browser.