| 1 | MODULE 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 | ! ------------ |
|---|
| 18 | use numerics, only: dp, di |
|---|
| 19 | |
|---|
| 20 | ! DECLARATION |
|---|
| 21 | ! ----------- |
|---|
| 22 | implicit none |
|---|
| 23 | |
|---|
| 24 | ! VARIABLES |
|---|
| 25 | ! --------- |
|---|
| 26 | ! Different types of frost retained by the PEM to give back to the PCM at the end |
|---|
| 27 | real(dp), dimension(:,:), allocatable :: h2o_frost4PCM |
|---|
| 28 | real(dp), dimension(:,:), allocatable :: co2_frost4PCM |
|---|
| 29 | |
|---|
| 30 | ! PARAMETERS |
|---|
| 31 | ! ---------- |
|---|
| 32 | ! Different types of frost in the PCM at the beginning [Pa] |
|---|
| 33 | real(dp), dimension(:,:), allocatable, protected :: h2ofrost_PCM |
|---|
| 34 | real(dp), dimension(:,:), allocatable, protected :: co2frost_PCM |
|---|
| 35 | |
|---|
| 36 | contains |
|---|
| 37 | !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|---|
| 38 | |
|---|
| 39 | !======================================================================= |
|---|
| 40 | SUBROUTINE 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 | ! ------------ |
|---|
| 57 | use geometry, only: ngrid, nslope |
|---|
| 58 | |
|---|
| 59 | ! DECLARATION |
|---|
| 60 | ! ----------- |
|---|
| 61 | implicit none |
|---|
| 62 | |
|---|
| 63 | ! CODE |
|---|
| 64 | ! ---- |
|---|
| 65 | if (.not. allocated(h2ofrost_PCM)) allocate(h2ofrost_PCM(ngrid,nslope)) |
|---|
| 66 | if (.not. allocated(co2frost_PCM)) allocate(co2frost_PCM(ngrid,nslope)) |
|---|
| 67 | if (.not. allocated(h2o_frost4PCM)) allocate(h2o_frost4PCM(ngrid,nslope)) |
|---|
| 68 | if (.not. allocated(co2_frost4PCM)) allocate(co2_frost4PCM(ngrid,nslope)) |
|---|
| 69 | h2ofrost_PCM(:,:) = 0._dp |
|---|
| 70 | co2frost_PCM(:,:) = 0._dp |
|---|
| 71 | h2o_frost4PCM(:,:) = 0._dp |
|---|
| 72 | co2_frost4PCM(:,:) = 0._dp |
|---|
| 73 | |
|---|
| 74 | END SUBROUTINE ini_frost |
|---|
| 75 | !======================================================================= |
|---|
| 76 | |
|---|
| 77 | !======================================================================= |
|---|
| 78 | SUBROUTINE 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 | ! ----------- |
|---|
| 95 | implicit none |
|---|
| 96 | |
|---|
| 97 | ! CODE |
|---|
| 98 | ! ---- |
|---|
| 99 | if (allocated(h2ofrost_PCM)) deallocate(h2ofrost_PCM) |
|---|
| 100 | if (allocated(co2frost_PCM)) deallocate(co2frost_PCM) |
|---|
| 101 | if (allocated(h2o_frost4PCM)) deallocate(h2o_frost4PCM) |
|---|
| 102 | if (allocated(co2_frost4PCM)) deallocate(co2_frost4PCM) |
|---|
| 103 | |
|---|
| 104 | END SUBROUTINE end_frost |
|---|
| 105 | !======================================================================= |
|---|
| 106 | |
|---|
| 107 | !======================================================================= |
|---|
| 108 | SUBROUTINE 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 | ! ----------- |
|---|
| 125 | implicit none |
|---|
| 126 | |
|---|
| 127 | ! ARGUMENTS |
|---|
| 128 | ! --------- |
|---|
| 129 | real(dp), dimension(:,:), intent(in) :: h2ofrost_PCM_in |
|---|
| 130 | |
|---|
| 131 | ! CODE |
|---|
| 132 | ! ---- |
|---|
| 133 | h2ofrost_PCM(:,:) = h2ofrost_PCM_in(:,:) |
|---|
| 134 | |
|---|
| 135 | END SUBROUTINE set_h2ofrost_PCM |
|---|
| 136 | !======================================================================= |
|---|
| 137 | |
|---|
| 138 | !======================================================================= |
|---|
| 139 | SUBROUTINE 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 | ! ----------- |
|---|
| 156 | implicit none |
|---|
| 157 | |
|---|
| 158 | ! ARGUMENTS |
|---|
| 159 | ! --------- |
|---|
| 160 | real(dp), dimension(:,:), intent(in) :: co2frost_PCM_in |
|---|
| 161 | |
|---|
| 162 | ! CODE |
|---|
| 163 | ! ---- |
|---|
| 164 | co2frost_PCM(:,:) = co2frost_PCM_in(:,:) |
|---|
| 165 | |
|---|
| 166 | END SUBROUTINE set_co2frost_PCM |
|---|
| 167 | !======================================================================= |
|---|
| 168 | |
|---|
| 169 | !======================================================================= |
|---|
| 170 | SUBROUTINE 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 | ! ------------ |
|---|
| 188 | use display, only: print_msg |
|---|
| 189 | |
|---|
| 190 | ! DECLARATION |
|---|
| 191 | ! ----------- |
|---|
| 192 | implicit none |
|---|
| 193 | |
|---|
| 194 | ! ARGUMENTS |
|---|
| 195 | ! --------- |
|---|
| 196 | real(dp), dimension(:,:), intent(in) :: minPCM_h2ofrost, minPCM_co2frost |
|---|
| 197 | |
|---|
| 198 | ! CODE |
|---|
| 199 | ! ---- |
|---|
| 200 | call print_msg('> Computing frost to give back to the PCM (metamorphism)') |
|---|
| 201 | |
|---|
| 202 | h2o_frost4PCM(:,:) = 0._dp |
|---|
| 203 | co2_frost4PCM(:,:) = 0._dp |
|---|
| 204 | where (h2ofrost_PCM(:,:) > 0._dp) h2o_frost4PCM(:,:) = h2ofrost_PCM(:,:) - minPCM_h2ofrost(:,:) |
|---|
| 205 | where (co2frost_PCM(:,:) > 0._dp) co2_frost4PCM(:,:) = co2frost_PCM(:,:) - minPCM_co2frost(:,:) |
|---|
| 206 | |
|---|
| 207 | END SUBROUTINE compute_frost4PCM |
|---|
| 208 | !======================================================================= |
|---|
| 209 | |
|---|
| 210 | END MODULE frost |
|---|