source: LMDZ6/trunk/libf/phylmd/buffer_mod.F90 @ 3634

Last change on this file since 3634 was 1907, checked in by lguez, 11 years ago

Added a copyright property to every file of the distribution, except
for the fcm files (which have their own copyright). Use svn propget on
a file to see the copyright. For instance:

$ svn propget copyright libf/phylmd/physiq.F90
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

Also added the files defining the CeCILL version 2 license, in French
and English, at the top of the LMDZ tree.

  • 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:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1MODULE buffer_mod
2
3PRIVATE
4  REAL,PARAMETER :: grow_factor=1.5
5
6  INTEGER, POINTER, SAVE :: buffer_i(:)
7  INTEGER,SAVE :: size_buffer_i = 0
8!$OMP THREADPRIVATE(buffer_i,size_buffer_i)
9
10  REAL,POINTER,SAVE      :: buffer_r(:)
11  INTEGER,SAVE :: size_buffer_r = 0
12!$OMP THREADPRIVATE(buffer_r,size_buffer_r)
13 
14  LOGICAL,POINTER,SAVE   :: buffer_l(:)
15  INTEGER,SAVE :: size_buffer_l = 0
16!$OMP THREADPRIVATE(buffer_l,size_buffer_l)
17
18  CHARACTER,POINTER,SAVE :: buffer_c(:)
19  INTEGER,SAVE :: size_buffer_c = 0
20!$OMP THREADPRIVATE(buffer_c,size_buffer_c)
21
22INTERFACE get_buffer
23  MODULE PROCEDURE get_buffer_i, get_buffer_r, get_buffer_l, get_buffer_c
24END INTERFACE
25 
26PUBLIC :: get_buffer
27
28CONTAINS
29
30  SUBROUTINE get_buffer_i(buff,buff_size)
31  IMPLICIT NONE
32    INTEGER,POINTER    :: buff(:)
33    INTEGER,INTENT(IN) :: buff_size
34
35    IF (buff_size>size_buffer_i) THEN
36      DEALLOCATE(buffer_i)
37      size_buffer_i=MAX(2,INT(size_buffer_i*grow_factor))
38      ALLOCATE(buffer_i(size_buffer_i))
39    ENDIF
40   
41    buff=>buffer_i
42  END SUBROUTINE get_buffer_i
43
44  SUBROUTINE get_buffer_r(buff,buff_size)
45  IMPLICIT NONE
46    REAL,POINTER       :: buff(:)
47    INTEGER,INTENT(IN) :: buff_size
48
49    IF (buff_size>size_buffer_r) THEN
50      DEALLOCATE(buffer_r)
51      size_buffer_r=MAX(2,INT(size_buffer_r*grow_factor))
52      ALLOCATE(buffer_r(size_buffer_r))
53    ENDIF
54   
55    buff=>buffer_r
56  END SUBROUTINE get_buffer_r
57
58  SUBROUTINE get_buffer_l(buff,buff_size)
59  IMPLICIT NONE
60    LOGICAL,POINTER    :: buff(:)
61    INTEGER,INTENT(IN) :: buff_size
62
63    IF (buff_size>size_buffer_l) THEN
64      DEALLOCATE(buffer_l)
65      size_buffer_l=MAX(2,INT(size_buffer_l*grow_factor))
66      ALLOCATE(buffer_l(size_buffer_l))
67    ENDIF
68   
69    buff=>buffer_l
70  END SUBROUTINE get_buffer_l
71 
72  SUBROUTINE get_buffer_c(buff,buff_size)
73  IMPLICIT NONE
74    CHARACTER,POINTER  :: buff(:)
75    INTEGER,INTENT(IN) :: buff_size
76
77    IF (buff_size>size_buffer_c) THEN
78      DEALLOCATE(buffer_c)
79      size_buffer_c=MAX(2,INT(size_buffer_c*grow_factor))
80      ALLOCATE(buffer_c(size_buffer_c))
81    ENDIF
82   
83    buff=>buffer_c
84  END SUBROUTINE get_buffer_c
85 
86END MODULE buffer_mod
Note: See TracBrowser for help on using the repository browser.