Changeset 4065 for trunk/LMDZ.COMMON/libf/evolution/surf_temp.F90
- Timestamp:
- Feb 12, 2026, 9:09:12 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/LMDZ.COMMON/libf/evolution/surf_temp.F90 (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/evolution/surf_temp.F90
r3991 r4065 14 14 !----------------------------------------------------------------------- 15 15 16 ! DECLARATION 17 ! ----------- 18 implicit none 16 ! DEPENDENCIES 17 ! ------------ 18 use numerics, only: dp, di, k4, minieps 19 20 ! DECLARATION 21 ! ----------- 22 implicit none 23 24 ! PARAMATERS 25 ! ---------- 26 real(dp), dimension(:,:), allocatable, protected :: tsurf_PCM ! Surface temperature in the PCM at the beginning [K] 19 27 20 28 contains 21 !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 22 23 !======================================================================= 24 SUBROUTINE update_tsurf_nearest_baresoil(ngrid,nslope,nlon,nlat,latitude,tsurf_avg,co2_ice,is_co2ice_ini,co2ice_disappeared) 25 !----------------------------------------------------------------------- 26 ! NAME 27 ! update_tsurf_nearest_baresoil 29 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 30 31 !======================================================================= 32 SUBROUTINE ini_surf_temp() 33 !----------------------------------------------------------------------- 34 ! NAME 35 ! ini_surf_temp 36 ! 37 ! DESCRIPTION 38 ! Initialize the parameters of module 'surf_temp'. 39 ! 40 ! AUTHORS & DATE 41 ! JB Clement, 12/2025 42 ! 43 ! NOTES 44 ! 45 !----------------------------------------------------------------------- 46 47 ! DEPENDENCIES 48 ! ------------ 49 use geometry, only: ngrid, nslope 50 51 ! DECLARATION 52 ! ----------- 53 implicit none 54 55 ! CODE 56 ! ---- 57 if (.not. allocated(tsurf_PCM)) allocate(tsurf_PCM(ngrid,nslope)) 58 59 END SUBROUTINE ini_surf_temp 60 !======================================================================= 61 62 !======================================================================= 63 SUBROUTINE end_surf_temp() 64 !----------------------------------------------------------------------- 65 ! NAME 66 ! end_surf_temp 67 ! 68 ! DESCRIPTION 69 ! Deallocate surf_temp arrays. 70 ! 71 ! AUTHORS & DATE 72 ! JB Clement, 12/2025 73 ! 74 ! NOTES 75 ! 76 !----------------------------------------------------------------------- 77 78 ! DECLARATION 79 ! ----------- 80 implicit none 81 82 ! CODE 83 ! ---- 84 if (allocated(tsurf_PCM)) deallocate(tsurf_PCM) 85 86 END SUBROUTINE end_surf_temp 87 !======================================================================= 88 89 !======================================================================= 90 SUBROUTINE set_tsurf_PCM(tsurf_PCM_in) 91 !----------------------------------------------------------------------- 92 ! NAME 93 ! set_tsurf_PCM 94 ! 95 ! DESCRIPTION 96 ! Setter for 'tsurf_PCM'. 97 ! 98 ! AUTHORS & DATE 99 ! JB Clement, 12/2025 100 ! 101 ! NOTES 102 ! 103 !----------------------------------------------------------------------- 104 105 ! DECLARATION 106 ! ----------- 107 implicit none 108 109 ! ARGUMENTS 110 ! --------- 111 real(dp), dimension(:,:), intent(in) :: tsurf_PCM_in 112 113 ! CODE 114 ! ---- 115 tsurf_PCM(:,:) = tsurf_PCM_in(:,:) 116 117 END SUBROUTINE set_tsurf_PCM 118 !======================================================================= 119 120 !======================================================================= 121 SUBROUTINE adapt_tsurf2disappearedice(surfice,is_ice_ini,ice_disappeared,tsurf_avg) 122 !----------------------------------------------------------------------- 123 ! NAME 124 ! adapt_tsurf2disappearedice 28 125 ! 29 126 ! DESCRIPTION … … 40 137 ! DEPENDENCIES 41 138 ! ------------ 42 use grid_conversion, only: vect2lonlat, lonlat2vect 139 use geometry, only: ngrid, nslope, nlon, nlat, latitudes, vect2lonlat, lonlat2vect 140 use display, only: print_msg 141 use utility, only: int2str 43 142 44 143 ! DECLARATION … … 48 147 ! ARGUMENTS 49 148 ! --------- 50 integer, intent(in) :: nlon, nlat, nslope, ngrid ! Grid dimensions 51 real, dimension(ngrid,nslope), intent(in) :: co2_ice ! CO2 ice density 52 real, dimension(ngrid), intent(in) :: latitude ! Latitude 53 logical, dimension(ngrid,nslope), intent(in) :: is_co2ice_ini ! Initial CO2 ice flag 54 real, dimension(ngrid,nslope), intent(inout) :: tsurf_avg ! Average surface temperature 55 logical, dimension(ngrid,nslope), intent(inout) :: co2ice_disappeared ! Ice disappeared flag 149 real(dp), dimension(:,:), intent(in) :: surfice 150 logical(k4), dimension(:,:), intent(in) :: is_ice_ini 151 real(dp), dimension(:,:), intent(inout) :: tsurf_avg 152 logical(k4), dimension(:,:), intent(inout) :: ice_disappeared 56 153 57 154 ! LOCAL VARIABLES 58 155 ! --------------- 59 real, parameter :: eps = 1.e-10 60 integer :: islope, i, j, k, radius, rmax, di, dj, ii, jj 61 logical :: found 62 real, dimension(nlon,nlat,nslope) :: tsurf_ll, co2ice_ll, mask_co2ice_ini, co2ice_disappeared_ll 63 real, dimension(nlon,nlat) :: latitude_ll 64 real, dimension(ngrid) :: tmp 65 integer, dimension(nslope - 1) :: priority 156 integer(di) :: islope, i, j, k, radius, rmax, d_i, d_j, ii, jj 157 logical(k4) :: found 158 real(dp), dimension(nlon,nlat,nslope) :: tsurf_ll, co2ice_ll, mask_co2ice_ini, mask_co2ice_disappeared 159 real(dp), dimension(nlon,nlat) :: latitude_ll 160 real(dp), dimension(ngrid) :: tmp 161 integer(di), dimension(nslope - 1) :: priority 66 162 67 163 ! CODE … … 70 166 if (ngrid == 1) return 71 167 72 write(*,*) "> Updating surface temperature where ice disappeared" 168 call print_msg("> Adapting surface temperature where ice disappeared") 73 169 ! Convert from reduced grid to lon-lat grid 74 call vect2lonlat(nlon,nlat,ngrid,latitude ,latitude_ll)170 call vect2lonlat(nlon,nlat,ngrid,latitudes,latitude_ll) 75 171 do islope = 1,nslope 76 172 call vect2lonlat(nlon,nlat,ngrid,tsurf_avg(:,islope),tsurf_ll(:,:,islope)) 77 call vect2lonlat(nlon,nlat,ngrid, co2_ice(:,islope),co2ice_ll(:,:,islope))78 call vect2lonlat(nlon,nlat,ngrid,merge(1. ,0.,is_co2ice_ini(:,islope)),mask_co2ice_ini(:,:,islope))79 call vect2lonlat(nlon,nlat,ngrid,merge(1. ,0.,co2ice_disappeared(:,islope)),co2ice_disappeared_ll(:,:,islope))80 end do173 call vect2lonlat(nlon,nlat,ngrid,surfice(:,islope),co2ice_ll(:,:,islope)) 174 call vect2lonlat(nlon,nlat,ngrid,merge(1._dp,0._dp,is_ice_ini(:,islope)),mask_co2ice_ini(:,:,islope)) 175 call vect2lonlat(nlon,nlat,ngrid,merge(1._dp,0._dp,ice_disappeared(:,islope)),mask_co2ice_disappeared(:,:,islope)) 176 end do 81 177 82 178 ! For each point where ice disappeared … … 85 181 do i = 1,nlon 86 182 do islope = 1,nslope 87 if (mask_co2ice_ini(i,j,islope) > 0.5 .and. co2ice_ll(i,j,islope) < eps .and. co2ice_disappeared_ll(i,j,islope) < 0.5) then183 if (mask_co2ice_ini(i,j,islope) > 0.5_dp .and. co2ice_ll(i,j,islope) < minieps .and. mask_co2ice_disappeared(i,j,islope) < 0.5_dp) then 88 184 found = .false. 89 co2ice_disappeared_ll(i,j,islope) = 1.90 call get_slope_priority(latitude_ll(i,j), nslope,islope,priority)185 mask_co2ice_disappeared(i,j,islope) = 1._dp 186 call get_slope_priority(latitude_ll(i,j),islope,priority) 91 187 do k = 1,nslope - 1 92 if (mask_co2ice_ini(i,j,priority(k)) < 0.5 ) then188 if (mask_co2ice_ini(i,j,priority(k)) < 0.5_dp) then 93 189 tsurf_ll(i,j,islope) = tsurf_ll(i,j,priority(k)) 94 190 found = .true. 95 191 exit 96 end if97 end do192 end if 193 end do 98 194 99 195 radius = 1 100 196 do while (.not. found .and. radius <= rmax) ! Only if no adjacent slopes holds bare soil 101 do d j = -radius,radius102 do d i = -radius,radius103 if (abs(d i) + abs(dj) == radius) then104 ii = i + d i105 jj = j + d j197 do d_j = -radius,radius 198 do d_i = -radius,radius 199 if (abs(d_i) + abs(d_j) == radius) then 200 ii = i + d_i 201 jj = j + d_j 106 202 ! Longitudinal periodicity 107 203 if (ii < 1) then … … 109 205 else if (ii > nlon) then 110 206 ii = ii - nlon 111 end if207 end if 112 208 ! Latitude boundaries 113 209 if (jj >= 1 .and. jj <= nlat) then 114 call get_slope_priority(latitude_ll(ii,jj), nslope,islope,priority)210 call get_slope_priority(latitude_ll(ii,jj),islope,priority) 115 211 do k = 1,nslope - 1 116 if (mask_co2ice_ini(ii,jj,priority(k)) < 0.5 ) then212 if (mask_co2ice_ini(ii,jj,priority(k)) < 0.5_dp) then 117 213 tsurf_ll(i,j,islope) = tsurf_ll(ii,jj,priority(k)) 118 214 found = .true. 119 215 exit 120 end if121 end do122 end if123 end if216 end if 217 end do 218 end if 219 end if 124 220 if (found) exit 125 end do221 end do 126 222 if (found) exit 127 end do223 end do 128 224 radius = radius + 1 129 end do130 if (.not. found) write(*,*) "WARNING: no bare soil found for ice disappeared on point:",i,j,islope131 end if132 end do133 end do134 end do225 end do 226 if (.not. found) call print_msg("Warning: no bare soil found for ice disappeared at point ("//int2str(i)//','//int2str(j)//','//int2str(islope)//'!') 227 end if 228 end do 229 end do 230 end do 135 231 136 232 ! Convert back from lon-lat grid to reduced grid 137 233 do islope = 1,nslope 138 234 call lonlat2vect(nlon,nlat,ngrid,tsurf_ll(:,:,islope),tsurf_avg(:,islope)) 139 call lonlat2vect(nlon,nlat,ngrid, co2ice_disappeared_ll(:,:,islope),tmp)140 where (tmp > 0.5 ) co2ice_disappeared(:,islope) = .true.141 end do142 143 END SUBROUTINE update_tsurf_nearest_baresoil144 !======================================================================= 145 146 !======================================================================= 147 SUBROUTINE get_slope_priority(lat, nslope,islope,priority)235 call lonlat2vect(nlon,nlat,ngrid,mask_co2ice_disappeared(:,:,islope),tmp) 236 where (tmp > 0.5_dp) ice_disappeared(:,islope) = .true. 237 end do 238 239 END SUBROUTINE adapt_tsurf2disappearedice 240 !======================================================================= 241 242 !======================================================================= 243 SUBROUTINE get_slope_priority(lat,islope,priority) 148 244 !----------------------------------------------------------------------- 149 245 ! NAME … … 151 247 ! 152 248 ! DESCRIPTION 153 ! Determine slope priority based on latitude (equator-ward favored).249 ! Determine slope priority based on latitudes (equator-ward favored). 154 250 ! 155 251 ! AUTHORS & DATE … … 159 255 ! Equator-ward slopes are most likely to hold no ice. 160 256 !----------------------------------------------------------------------- 257 258 ! DEPENDENCIES 259 ! ------------ 260 use geometry, only: nslope 161 261 162 262 ! DECLARATION … … 166 266 ! ARGUMENTS 167 267 ! --------- 168 real ,intent(in) :: lat ! Latitude [degrees]169 integer , intent(in) :: nslope,islope170 integer , dimension(nslope - 1), intent(out) :: priority ! Priority ordering of slopes268 real(dp), intent(in) :: lat ! Latitude [degrees] 269 integer(di), intent(in) :: islope 270 integer(di), dimension(:), intent(out) :: priority ! Priority ordering of slopes 171 271 172 272 ! LOCAL VARIABLES 173 273 ! --------------- 174 integer :: i, k274 integer(di) :: i, k 175 275 176 276 ! CODE … … 184 284 priority(k) = i 185 285 k = k + 1 186 end do286 end do 187 287 ! Pole-ward slopes 188 288 do i = islope + 1,nslope 189 289 priority(k) = i 190 290 k = k + 1 191 end do291 end do 192 292 else ! Southern hemisphere 193 293 ! Equator-ward slopes … … 195 295 priority(k) = i 196 296 k = k + 1 197 end do297 end do 198 298 ! Pole-ward slopes 199 299 do i = islope - 1,1,-1 200 300 priority(k) = i 201 301 k = k + 1 202 end do203 end if302 end do 303 end if 204 304 205 305 END SUBROUTINE get_slope_priority 206 306 !======================================================================= 207 307 308 !======================================================================= 309 SUBROUTINE build4PCM_tsurf(tsurf_avg,tsurf_dev,tsurf4PCM) 310 !----------------------------------------------------------------------- 311 ! NAME 312 ! build4PCM_tsurf 313 ! 314 ! DESCRIPTION 315 ! Reconstructs surface temperature for the PCM. 316 ! 317 ! AUTHORS & DATE 318 ! JB Clement, 12/2025 319 ! 320 ! NOTES 321 ! 322 !----------------------------------------------------------------------- 323 324 ! DEPENDENCIES 325 ! ------------ 326 use display, only: print_msg 327 328 ! DECLARATION 329 ! ----------- 330 implicit none 331 332 ! ARGUMENTS 333 ! --------- 334 real(dp), dimension(:,:), intent(in) :: tsurf_avg, tsurf_dev 335 real(dp), dimension(:,:), intent(out) :: tsurf4PCM 336 337 ! CODE 338 ! ---- 339 call print_msg('> Building surface temperature for the PCM') 340 tsurf4PCM(:,:) = tsurf_avg(:,:) + tsurf_dev(:,:) 341 342 END SUBROUTINE build4PCM_tsurf 343 !======================================================================= 344 208 345 END MODULE surf_temp
Note: See TracChangeset
for help on using the changeset viewer.
