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

Last change on this file since 4071 was 4071, checked in by jbclement, 12 days ago

PEM:

  • Making the computation of ice tendencies more reliable by doing it after 'read_startpem' to know exactly where perennial ice is (no matter if there is a "startpem.nc" or not). Moreover, when there is no "startpem.nc", location of perennial ice depends now on 'watercaptag' and on huge amount of frost. This prevents negative ice tendency while there is no ice which can happen with weird PCM inputs (i.e. 'watercaptag' = F & 'watercap' /= 0 & no "stratpem.nc").
  • Few small safeguards throughout the code.

JBC

File size: 5.0 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))
69
70END SUBROUTINE ini_frost
71!=======================================================================
72
73!=======================================================================
74SUBROUTINE end_frost()
75!-----------------------------------------------------------------------
76! NAME
77!     end_frost
78!
79! DESCRIPTION
80!     Deallocate frost arrays.
81!
82! AUTHORS & DATE
83!     JB Clement, 12/2025
84!
85! NOTES
86!
87!-----------------------------------------------------------------------
88
89! DECLARATION
90! -----------
91implicit none
92
93! CODE
94! ----
95if (allocated(h2ofrost_PCM)) deallocate(h2ofrost_PCM)
96if (allocated(co2frost_PCM)) deallocate(co2frost_PCM)
97if (allocated(h2o_frost4PCM)) deallocate(h2o_frost4PCM)
98if (allocated(co2_frost4PCM)) deallocate(co2_frost4PCM)
99
100END SUBROUTINE end_frost
101!=======================================================================
102
103!=======================================================================
104SUBROUTINE set_h2ofrost_PCM(h2ofrost_PCM_in)
105!-----------------------------------------------------------------------
106! NAME
107!     set_h2ofrost_PCM
108!
109! DESCRIPTION
110!     Setter for 'h2ofrost_PCM'.
111!
112! AUTHORS & DATE
113!     JB Clement, 12/2025
114!
115! NOTES
116!
117!-----------------------------------------------------------------------
118
119! DECLARATION
120! -----------
121implicit none
122
123! ARGUMENTS
124! ---------
125real(dp), dimension(:,:), intent(in) :: h2ofrost_PCM_in
126
127! CODE
128! ----
129h2ofrost_PCM(:,:) = h2ofrost_PCM_in(:,:)
130
131END SUBROUTINE set_h2ofrost_PCM
132!=======================================================================
133
134!=======================================================================
135SUBROUTINE set_co2frost_PCM(co2frost_PCM_in)
136!-----------------------------------------------------------------------
137! NAME
138!     set_co2frost_PCM
139!
140! DESCRIPTION
141!     Setter for 'co2frost_PCM'.
142!
143! AUTHORS & DATE
144!     JB Clement, 12/2025
145!
146! NOTES
147!
148!-----------------------------------------------------------------------
149
150! DECLARATION
151! -----------
152implicit none
153
154! ARGUMENTS
155! ---------
156real(dp), dimension(:,:), intent(in) :: co2frost_PCM_in
157
158! CODE
159! ----
160co2frost_PCM(:,:) = co2frost_PCM_in(:,:)
161
162END SUBROUTINE set_co2frost_PCM
163!=======================================================================
164
165!=======================================================================
166SUBROUTINE compute_frost4PCM(minPCM_h2ofrost,minPCM_co2frost)
167!-----------------------------------------------------------------------
168! NAME
169!     compute_frost4PCM
170!
171! DESCRIPTION
172!     Compute the frost to give back to the PCM (metamorphism).
173!
174! AUTHORS & DATE
175!     JB Clement, 12/2025
176!
177! NOTES
178!     Frost for the PEM is the extra part of the PCM frost above the
179!     yearly minimum.
180!-----------------------------------------------------------------------
181
182! DEPENDENCIES
183! ------------
184use display, only: print_msg
185
186! DECLARATION
187! -----------
188implicit none
189
190! ARGUMENTS
191! ---------
192real(dp), dimension(:,:), intent(in) :: minPCM_h2ofrost, minPCM_co2frost
193
194! CODE
195! ----
196call print_msg('> Computing frost to give back to the PCM (metamorphism)')
197
198h2o_frost4PCM(:,:) = 0._dp
199co2_frost4PCM(:,:) = 0._dp
200where (h2ofrost_PCM(:,:) > 0._dp) h2o_frost4PCM(:,:) = h2ofrost_PCM(:,:) - minPCM_h2ofrost(:,:)
201where (co2frost_PCM(:,:) > 0._dp) co2_frost4PCM(:,:) = co2frost_PCM(:,:) - minPCM_co2frost(:,:)
202
203END SUBROUTINE compute_frost4PCM
204!=======================================================================
205
206END MODULE frost
Note: See TracBrowser for help on using the repository browser.