source: trunk/LMDZ.COMMON/libf/evolution/slopes.F90

Last change on this file was 4074, checked in by jbclement, 11 days ago

PEM:

  • Correct management of H2O ice tendency in 1D when there is not enough ice anymore.
  • Clean initialization of allocatable module arrays (especially needed when no slope)
  • One more renaming for consistency + few small updates thoughout the code.

JBC

File size: 4.5 KB
RevLine 
[4065]1MODULE slopes
2!-----------------------------------------------------------------------
3! NAME
4!     slopes
5!
6! DESCRIPTION
7!     Contains global parameters used for the slopes.
8!
9! AUTHORS & DATE
10!     JB Clement, 12/2025
11!
12! NOTES
13!
14!-----------------------------------------------------------------------
15
16! DEPENDENCIES
17! ------------
18use numerics, only: dp, di
19
20! DECLARATION
21! -----------
22implicit none
23
24! PARAMETERS
25! ----------
26real(dp), dimension(:),   allocatable, protected :: def_slope_mean ! Mean slople of each bin [degree]
27real(dp), dimension(:,:), allocatable, protected :: subslope_dist  ! Distribution of the slopes
28integer(di),                           protected :: iflat          ! Index of the flat slope
29
30contains
31!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32
33!=======================================================================
34SUBROUTINE ini_slopes()
35!-----------------------------------------------------------------------
36! NAME
37!     ini_slopes
38!
39! DESCRIPTION
40!     Initialize the parameters of module 'slopes'.
41!
42! AUTHORS & DATE
43!     JB Clement, 12/2025
44!
45! NOTES
46!
47!-----------------------------------------------------------------------
48
49! DEPENDENCIES
50! ------------
51use geometry, only: nslope, ngrid
52
53! DECLARATION
54! -----------
55implicit none
56
57! CODE
58! ----
59if (.not. allocated(def_slope_mean)) allocate(def_slope_mean(nslope))
60if (.not. allocated(subslope_dist)) allocate(subslope_dist(ngrid,nslope))
[4074]61def_slope_mean(:) = 0._dp
62subslope_dist(:,:) = 1._dp
[4065]63
64END SUBROUTINE ini_slopes
65!=======================================================================
66
67!=======================================================================
68SUBROUTINE end_slopes()
69!-----------------------------------------------------------------------
70! NAME
71!     end_slopes
72!
73! DESCRIPTION
74!     Deallocate slopes arrays.
75!
76! AUTHORS & DATE
77!     JB Clement, 12/2025
78!
79! NOTES
80!
81!-----------------------------------------------------------------------
82
83! DECLARATION
84! -----------
85implicit none
86
87! CODE
88! ----
89if (allocated(def_slope_mean)) deallocate(def_slope_mean)
90if (allocated(subslope_dist)) deallocate(subslope_dist)
91
92END SUBROUTINE end_slopes
93!=======================================================================
94
95!=======================================================================
96SUBROUTINE set_def_slope_mean(def_slope_mean_in)
97!-----------------------------------------------------------------------
98! NAME
99!     set_def_slope_mean
100!
101! DESCRIPTION
102!     Setter for 'def_slope_mean'.
103!
104! AUTHORS & DATE
105!     JB Clement, 12/2025
106!
107! NOTES
108!
109!-----------------------------------------------------------------------
110
111! DECLARATION
112! -----------
113implicit none
114
115! ARGUMENTS
116! ---------
117real(dp), dimension(:), intent(in) :: def_slope_mean_in
118
119! CODE
120! ----
121def_slope_mean(:) = def_slope_mean_in(:)
122
123END SUBROUTINE set_def_slope_mean
124!=======================================================================
125
126!=======================================================================
127SUBROUTINE set_subslope_dist(subslope_dist_in)
128!-----------------------------------------------------------------------
129! NAME
130!     set_subslope_dist
131!
132! DESCRIPTION
133!     Setter for 'subslope_dist'.
134!
135! AUTHORS & DATE
136!     JB Clement, 12/2025
137!
138! NOTES
139!
140!-----------------------------------------------------------------------
141
142! DECLARATION
143! -----------
144implicit none
145
146! ARGUMENTS
147! ---------
148real(dp), dimension(:,:), intent(in) :: subslope_dist_in
149
150! CODE
151! ----
152subslope_dist(:,:) = subslope_dist_in(:,:)
153
154END SUBROUTINE set_subslope_dist
155!=======================================================================
156
157!=======================================================================
158SUBROUTINE set_iflat()
159!-----------------------------------------------------------------------
160! NAME
161!     set_iflat
162!
163! DESCRIPTION
164!     Setter for 'iflat'.
165!
166! AUTHORS & DATE
167!     JB Clement, 12/2025
168!
169! NOTES
170!
171!-----------------------------------------------------------------------
172
173! DEPENDENCIES
174! ------------
175use geometry, only: nslope
176use display,  only: print_msg
177use utility,  only: int2str, real2str
178
179! DECLARATION
180! -----------
181implicit none
182
183! LOCAL VARIABLES
184! ---------------
185integer(di) :: islope
186
187! CODE
188! ----
189iflat = 1
190do islope = 2,nslope
191    if (abs(def_slope_mean(islope)) < abs(def_slope_mean(iflat))) iflat = islope
192end do
193call print_msg('Flat slope for islope = '//int2str(iflat))
194call print_msg('Corresponding criterium = '//real2str(def_slope_mean(iflat)))
195
196END SUBROUTINE set_iflat
197!=======================================================================
198
199END MODULE slopes
Note: See TracBrowser for help on using the repository browser.