| 1 | MODULE metamorphism |
|---|
| 2 | !----------------------------------------------------------------------- |
|---|
| 3 | ! NAME |
|---|
| 4 | ! metamorphism |
|---|
| 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 | ! DECLARATION |
|---|
| 17 | ! ----------- |
|---|
| 18 | implicit none |
|---|
| 19 | |
|---|
| 20 | ! MODULE VARIABLES |
|---|
| 21 | ! ---------------- |
|---|
| 22 | ! Different types of frost retained by the PEM to give back to the PCM at the end |
|---|
| 23 | real, dimension(:,:), allocatable :: h2o_frost4PCM |
|---|
| 24 | real, dimension(:,:), allocatable :: co2_frost4PCM |
|---|
| 25 | |
|---|
| 26 | ! Indices for frost taken from the PCM |
|---|
| 27 | integer :: iPCM_h2ofrost, iPCM_co2frost |
|---|
| 28 | |
|---|
| 29 | contains |
|---|
| 30 | !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|---|
| 31 | |
|---|
| 32 | !======================================================================= |
|---|
| 33 | SUBROUTINE ini_frost_id(nqtot,noms) |
|---|
| 34 | !----------------------------------------------------------------------- |
|---|
| 35 | ! NAME |
|---|
| 36 | ! ini_frost_id |
|---|
| 37 | ! |
|---|
| 38 | ! DESCRIPTION |
|---|
| 39 | ! Initialize frost indices from PCM variable names. |
|---|
| 40 | ! |
|---|
| 41 | ! AUTHORS & DATE |
|---|
| 42 | ! JB Clement, 12/2025 |
|---|
| 43 | ! |
|---|
| 44 | ! NOTES |
|---|
| 45 | ! |
|---|
| 46 | !----------------------------------------------------------------------- |
|---|
| 47 | |
|---|
| 48 | ! DECLARATION |
|---|
| 49 | ! ----------- |
|---|
| 50 | implicit none |
|---|
| 51 | |
|---|
| 52 | ! ARGUMENTS |
|---|
| 53 | ! --------- |
|---|
| 54 | integer, intent(in) :: nqtot |
|---|
| 55 | character(*), dimension(nqtot), intent(in) :: noms |
|---|
| 56 | |
|---|
| 57 | ! LOCAL VARIABLES |
|---|
| 58 | ! --------------- |
|---|
| 59 | integer :: i |
|---|
| 60 | |
|---|
| 61 | ! CODE |
|---|
| 62 | ! ---- |
|---|
| 63 | ! Initialization |
|---|
| 64 | iPCM_h2ofrost = -1 |
|---|
| 65 | iPCM_co2frost = -1 |
|---|
| 66 | |
|---|
| 67 | ! Getting the index |
|---|
| 68 | do i = 1,nqtot |
|---|
| 69 | if (trim(noms(i)) == "h2o_ice") iPCM_h2ofrost = i |
|---|
| 70 | if (trim(noms(i)) == "co2") iPCM_co2frost = i |
|---|
| 71 | enddo |
|---|
| 72 | |
|---|
| 73 | ! Checking if everything has been found |
|---|
| 74 | if (iPCM_h2ofrost < 0) error stop 'ini_frost_id: H2O frost index not found!' |
|---|
| 75 | if (iPCM_co2frost < 0) error stop 'ini_frost_id: CO2 frost index not found!' |
|---|
| 76 | |
|---|
| 77 | END SUBROUTINE ini_frost_id |
|---|
| 78 | !======================================================================= |
|---|
| 79 | |
|---|
| 80 | !======================================================================= |
|---|
| 81 | SUBROUTINE compute_frost(ngrid,nslope,h2ofrost_PCM,min_h2ofrost,co2frost_PCM,min_co2frost) |
|---|
| 82 | !----------------------------------------------------------------------- |
|---|
| 83 | ! NAME |
|---|
| 84 | ! compute_frost |
|---|
| 85 | ! |
|---|
| 86 | ! DESCRIPTION |
|---|
| 87 | ! Compute the frost to give back to the PCM. |
|---|
| 88 | ! |
|---|
| 89 | ! AUTHORS & DATE |
|---|
| 90 | ! JB Clement, 12/2025 |
|---|
| 91 | ! |
|---|
| 92 | ! NOTES |
|---|
| 93 | ! Frost for the PEM is the extra part of the PCM frost above the |
|---|
| 94 | ! yearly minimum. |
|---|
| 95 | !----------------------------------------------------------------------- |
|---|
| 96 | |
|---|
| 97 | ! DECLARATION |
|---|
| 98 | ! ----------- |
|---|
| 99 | implicit none |
|---|
| 100 | |
|---|
| 101 | ! ARGUMENTS |
|---|
| 102 | ! --------- |
|---|
| 103 | integer, intent(in) :: ngrid, nslope |
|---|
| 104 | real, dimension(ngrid,nslope), intent(in) :: h2ofrost_PCM, min_h2ofrost, co2frost_PCM, min_co2frost |
|---|
| 105 | |
|---|
| 106 | ! CODE |
|---|
| 107 | ! ---- |
|---|
| 108 | write(*,*) '> Computing frost to give back to the PCM' |
|---|
| 109 | |
|---|
| 110 | ! Allocation |
|---|
| 111 | call ini_frost(ngrid,nslope) |
|---|
| 112 | |
|---|
| 113 | ! Initialization |
|---|
| 114 | h2o_frost4PCM(:,:) = 0. |
|---|
| 115 | co2_frost4PCM(:,:) = 0. |
|---|
| 116 | |
|---|
| 117 | ! Computation: frost for the PEM is the extra part of the PCM frost above the yearly minimum |
|---|
| 118 | where (h2ofrost_PCM(:,:) > 0.) h2o_frost4PCM(:,:) = h2ofrost_PCM(:,:) - min_h2ofrost(:,:) |
|---|
| 119 | where (co2frost_PCM(:,:) > 0.) co2_frost4PCM(:,:) = co2frost_PCM(:,:) - min_co2frost(:,:) |
|---|
| 120 | |
|---|
| 121 | END SUBROUTINE compute_frost |
|---|
| 122 | !======================================================================= |
|---|
| 123 | |
|---|
| 124 | !======================================================================= |
|---|
| 125 | SUBROUTINE set_frost4PCM(PCMfrost) |
|---|
| 126 | !----------------------------------------------------------------------- |
|---|
| 127 | ! NAME |
|---|
| 128 | ! set_frost4PCM |
|---|
| 129 | ! |
|---|
| 130 | ! DESCRIPTION |
|---|
| 131 | ! Reconstruct frost for the PCM from PEM computations. |
|---|
| 132 | ! |
|---|
| 133 | ! AUTHORS & DATE |
|---|
| 134 | ! JB Clement, 12/2025 |
|---|
| 135 | ! |
|---|
| 136 | ! NOTES |
|---|
| 137 | ! |
|---|
| 138 | !----------------------------------------------------------------------- |
|---|
| 139 | |
|---|
| 140 | ! DECLARATION |
|---|
| 141 | ! ----------- |
|---|
| 142 | implicit none |
|---|
| 143 | |
|---|
| 144 | ! ARGUMENTS |
|---|
| 145 | ! --------- |
|---|
| 146 | real, dimension(:,:,:), intent(inout) :: PCMfrost |
|---|
| 147 | |
|---|
| 148 | ! CODE |
|---|
| 149 | ! ---- |
|---|
| 150 | write(*,*) '> Reconstructing frost for the PCM' |
|---|
| 151 | PCMfrost(:,iPCM_h2ofrost,:) = h2o_frost4PCM(:,:) |
|---|
| 152 | PCMfrost(:,iPCM_co2frost,:) = co2_frost4PCM(:,:) |
|---|
| 153 | |
|---|
| 154 | ! Deallocation |
|---|
| 155 | call end_frost() |
|---|
| 156 | |
|---|
| 157 | END SUBROUTINE set_frost4PCM |
|---|
| 158 | !======================================================================= |
|---|
| 159 | |
|---|
| 160 | !======================================================================= |
|---|
| 161 | SUBROUTINE ini_frost(ngrid,nslope) |
|---|
| 162 | !----------------------------------------------------------------------- |
|---|
| 163 | ! NAME |
|---|
| 164 | ! ini_frost |
|---|
| 165 | ! |
|---|
| 166 | ! DESCRIPTION |
|---|
| 167 | ! Initialize frost arrays. |
|---|
| 168 | ! |
|---|
| 169 | ! AUTHORS & DATE |
|---|
| 170 | ! JB Clement, 12/2025 |
|---|
| 171 | ! |
|---|
| 172 | ! NOTES |
|---|
| 173 | ! |
|---|
| 174 | !----------------------------------------------------------------------- |
|---|
| 175 | |
|---|
| 176 | ! DECLARATION |
|---|
| 177 | ! ----------- |
|---|
| 178 | implicit none |
|---|
| 179 | |
|---|
| 180 | ! ARGUMENTS |
|---|
| 181 | ! --------- |
|---|
| 182 | integer, intent(in) :: ngrid, nslope |
|---|
| 183 | |
|---|
| 184 | ! CODE |
|---|
| 185 | ! ---- |
|---|
| 186 | if (.not. allocated(h2o_frost4PCM)) allocate(h2o_frost4PCM(ngrid,nslope)) |
|---|
| 187 | if (.not. allocated(co2_frost4PCM)) allocate(co2_frost4PCM(ngrid,nslope)) |
|---|
| 188 | |
|---|
| 189 | END SUBROUTINE ini_frost |
|---|
| 190 | !======================================================================= |
|---|
| 191 | |
|---|
| 192 | !======================================================================= |
|---|
| 193 | SUBROUTINE end_frost() |
|---|
| 194 | !----------------------------------------------------------------------- |
|---|
| 195 | ! NAME |
|---|
| 196 | ! end_frost |
|---|
| 197 | ! |
|---|
| 198 | ! DESCRIPTION |
|---|
| 199 | ! Deallocate frost arrays. |
|---|
| 200 | ! |
|---|
| 201 | ! AUTHORS & DATE |
|---|
| 202 | ! JB Clement, 12/2025 |
|---|
| 203 | ! |
|---|
| 204 | ! NOTES |
|---|
| 205 | ! |
|---|
| 206 | !----------------------------------------------------------------------- |
|---|
| 207 | |
|---|
| 208 | ! DECLARATION |
|---|
| 209 | ! ----------- |
|---|
| 210 | implicit none |
|---|
| 211 | |
|---|
| 212 | ! CODE |
|---|
| 213 | ! ---- |
|---|
| 214 | if (allocated(h2o_frost4PCM)) deallocate(h2o_frost4PCM) |
|---|
| 215 | if (allocated(co2_frost4PCM)) deallocate(co2_frost4PCM) |
|---|
| 216 | |
|---|
| 217 | END SUBROUTINE end_frost |
|---|
| 218 | !======================================================================= |
|---|
| 219 | |
|---|
| 220 | END MODULE metamorphism |
|---|