source: trunk/LMDZ.COMMON/libf/evolution/frost.F90 @ 4074

Last change on this file since 4074 was 4074, checked in by jbclement, 10 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: 5.1 KB
Line 
1MODULE frost
2!-----------------------------------------------------------------------
3! NAME
4!     frost
5!
6! DESCRIPTION
7!     Module for managing frost variables.
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! VARIABLES
25! ---------
26! Different types of frost retained by the PEM to give back to the PCM at the end
27real(dp), dimension(:,:), allocatable :: h2o_frost4PCM
28real(dp), dimension(:,:), allocatable :: co2_frost4PCM
29
30! PARAMETERS
31! ----------
32! Different types of frost in the PCM at the beginning [Pa]
33real(dp), dimension(:,:), allocatable, protected :: h2ofrost_PCM
34real(dp), dimension(:,:), allocatable, protected :: co2frost_PCM
35
36contains
37!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
38
39!=======================================================================
40SUBROUTINE ini_frost()
41!-----------------------------------------------------------------------
42! NAME
43!     ini_frost
44!
45! DESCRIPTION
46!     Initialize the parameters of module 'frost'.
47!
48! AUTHORS & DATE
49!     JB Clement, 12/2025
50!
51! NOTES
52!
53!-----------------------------------------------------------------------
54
55! DEPENDENCIES
56! ------------
57use geometry, only: ngrid, nslope
58
59! DECLARATION
60! -----------
61implicit none
62
63! CODE
64! ----
65if (.not. allocated(h2ofrost_PCM)) allocate(h2ofrost_PCM(ngrid,nslope))
66if (.not. allocated(co2frost_PCM)) allocate(co2frost_PCM(ngrid,nslope))
67if (.not. allocated(h2o_frost4PCM)) allocate(h2o_frost4PCM(ngrid,nslope))
68if (.not. allocated(co2_frost4PCM)) allocate(co2_frost4PCM(ngrid,nslope))
69h2ofrost_PCM(:,:) = 0._dp
70co2frost_PCM(:,:) = 0._dp
71h2o_frost4PCM(:,:) = 0._dp
72co2_frost4PCM(:,:) = 0._dp
73
74END SUBROUTINE ini_frost
75!=======================================================================
76
77!=======================================================================
78SUBROUTINE end_frost()
79!-----------------------------------------------------------------------
80! NAME
81!     end_frost
82!
83! DESCRIPTION
84!     Deallocate frost arrays.
85!
86! AUTHORS & DATE
87!     JB Clement, 12/2025
88!
89! NOTES
90!
91!-----------------------------------------------------------------------
92
93! DECLARATION
94! -----------
95implicit none
96
97! CODE
98! ----
99if (allocated(h2ofrost_PCM)) deallocate(h2ofrost_PCM)
100if (allocated(co2frost_PCM)) deallocate(co2frost_PCM)
101if (allocated(h2o_frost4PCM)) deallocate(h2o_frost4PCM)
102if (allocated(co2_frost4PCM)) deallocate(co2_frost4PCM)
103
104END SUBROUTINE end_frost
105!=======================================================================
106
107!=======================================================================
108SUBROUTINE set_h2ofrost_PCM(h2ofrost_PCM_in)
109!-----------------------------------------------------------------------
110! NAME
111!     set_h2ofrost_PCM
112!
113! DESCRIPTION
114!     Setter for 'h2ofrost_PCM'.
115!
116! AUTHORS & DATE
117!     JB Clement, 12/2025
118!
119! NOTES
120!
121!-----------------------------------------------------------------------
122
123! DECLARATION
124! -----------
125implicit none
126
127! ARGUMENTS
128! ---------
129real(dp), dimension(:,:), intent(in) :: h2ofrost_PCM_in
130
131! CODE
132! ----
133h2ofrost_PCM(:,:) = h2ofrost_PCM_in(:,:)
134
135END SUBROUTINE set_h2ofrost_PCM
136!=======================================================================
137
138!=======================================================================
139SUBROUTINE set_co2frost_PCM(co2frost_PCM_in)
140!-----------------------------------------------------------------------
141! NAME
142!     set_co2frost_PCM
143!
144! DESCRIPTION
145!     Setter for 'co2frost_PCM'.
146!
147! AUTHORS & DATE
148!     JB Clement, 12/2025
149!
150! NOTES
151!
152!-----------------------------------------------------------------------
153
154! DECLARATION
155! -----------
156implicit none
157
158! ARGUMENTS
159! ---------
160real(dp), dimension(:,:), intent(in) :: co2frost_PCM_in
161
162! CODE
163! ----
164co2frost_PCM(:,:) = co2frost_PCM_in(:,:)
165
166END SUBROUTINE set_co2frost_PCM
167!=======================================================================
168
169!=======================================================================
170SUBROUTINE compute_frost4PCM(minPCM_h2ofrost,minPCM_co2frost)
171!-----------------------------------------------------------------------
172! NAME
173!     compute_frost4PCM
174!
175! DESCRIPTION
176!     Compute the frost to give back to the PCM (metamorphism).
177!
178! AUTHORS & DATE
179!     JB Clement, 12/2025
180!
181! NOTES
182!     Frost for the PEM is the extra part of the PCM frost above the
183!     yearly minimum.
184!-----------------------------------------------------------------------
185
186! DEPENDENCIES
187! ------------
188use display, only: print_msg
189
190! DECLARATION
191! -----------
192implicit none
193
194! ARGUMENTS
195! ---------
196real(dp), dimension(:,:), intent(in) :: minPCM_h2ofrost, minPCM_co2frost
197
198! CODE
199! ----
200call print_msg('> Computing frost to give back to the PCM (metamorphism)')
201
202h2o_frost4PCM(:,:) = 0._dp
203co2_frost4PCM(:,:) = 0._dp
204where (h2ofrost_PCM(:,:) > 0._dp) h2o_frost4PCM(:,:) = h2ofrost_PCM(:,:) - minPCM_h2ofrost(:,:)
205where (co2frost_PCM(:,:) > 0._dp) co2_frost4PCM(:,:) = co2frost_PCM(:,:) - minPCM_co2frost(:,:)
206
207END SUBROUTINE compute_frost4PCM
208!=======================================================================
209
210END MODULE frost
Note: See TracBrowser for help on using the repository browser.