Changeset 3979


Ignore:
Timestamp:
Nov 28, 2025, 5:34:32 PM (2 days ago)
Author:
jbclement
Message:

PEM:
Addition of the periodicity to search along the longitudes to find the nearest bare soil from the place where ice disappeared + Searching with slope priority according to equator-ward orientation to try gaining efficiency + Warning if the search is unsuccessful.
JBC

Location:
trunk/LMDZ.COMMON/libf/evolution
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/evolution/changelog.txt

    r3977 r3979  
    802802- Deletion of the reshaping tool "reshape_XIOS_output" used to convert XIOS outputs onto the PCM grid. Thus, the PEM is now able to read directly the format of XIOS outputs.
    803803- Addition of subroutines to convert data between a lon x lat array and a vector.
     804
     805== 28/11/2025 == JBC
     806Addition of the periodicity to search along the longitudes to find the nearest bare soil from the place where ice disappeared + Searching with slope priority according to equator-ward orientation to try gaining efficiency + Warning if the search is unsuccessful.
  • trunk/LMDZ.COMMON/libf/evolution/pem.F90

    r3977 r3979  
    743743!------------------------
    744744! II_d.1 Update Tsurf
    745     call update_tsurf_nearest_baresoil(ngrid,nslope,iim,jjm_value,tsurf_avg,co2_ice,is_co2ice_ini,co2ice_disappeared)
     745    call update_tsurf_nearest_baresoil(ngrid,nslope,iim,jjm - 1,latitude,tsurf_avg,co2_ice,is_co2ice_ini,co2ice_disappeared)
    746746
    747747    if (soil_pem) then
  • trunk/LMDZ.COMMON/libf/evolution/surf_temp.F90

    r3977 r3979  
    77!=======================================================================
    88
    9 SUBROUTINE update_tsurf_nearest_baresoil(ngrid,nslope,iim_input,jjm_input,tsurf_avg,co2_ice,is_co2ice_ini,co2ice_disappeared)
     9SUBROUTINE update_tsurf_nearest_baresoil(ngrid,nslope,nlon,nlat,latitude,tsurf_avg,co2_ice,is_co2ice_ini,co2ice_disappeared)
     10
     11use grid_conversion, only: vect2lonlat, lonlat2vect
    1012
    1113implicit none
    1214
    1315! Inputs:
    14 integer,                          intent(in) :: iim_input, jjm_input, nslope, ngrid
     16integer,                          intent(in) :: nlon, nlat, nslope, ngrid
    1517real,    dimension(ngrid,nslope), intent(in) :: co2_ice
     18real,    dimension(ngrid),        intent(in) :: latitude
    1619logical, dimension(ngrid,nslope), intent(in) :: is_co2ice_ini
    1720! Outputs:
     
    1922logical, dimension(ngrid,nslope), intent(inout) :: co2ice_disappeared
    2023! Local variables:
    21 real, parameter                                     :: eps = 1.e-10
    22 integer                                             :: islope, i, j, k, radius, rmax, di, dj, ii, jj
    23 logical                                             :: found
    24 real, dimension(iim_input + 1,jjm_input + 1,nslope) :: tsurf_ll, co2ice_ll, mask_co2ice_ini, co2ice_disappeared_ll
    25 real, dimension(ngrid)                              :: tmp
     24real, parameter                   :: eps = 1.e-10
     25integer                           :: islope, i, j, k, radius, rmax, di, dj, ii, jj
     26logical                           :: found
     27real, dimension(nlon,nlat,nslope) :: tsurf_ll, co2ice_ll, mask_co2ice_ini, co2ice_disappeared_ll
     28real, dimension(nlon,nlat)        :: latitude_ll
     29real, dimension(ngrid)            :: tmp
     30integer, dimension(nslope - 1)    :: priority
    2631
    27 ! Check to escape the subroutine
     32! Check to escape the subroutine (not relevant in 1D)
    2833if (ngrid == 1) return
    2934
    3035write(*,*) "> Updating surface temperature where ice disappeared"
    3136! Convert from reduced grid to lon-lat grid
    32 #ifndef CPP_1D
     37call vect2lonlat(nlon,nlat,ngrid,latitude,latitude_ll)
    3338do islope = 1,nslope
    34     call gr_fi_dyn(1,ngrid,iim_input + 1,jjm_input + 1,tsurf_avg(:,islope),tsurf_ll(:,:,islope))
    35     call gr_fi_dyn(1,ngrid,iim_input + 1,jjm_input + 1,co2_ice(:,islope),co2ice_ll(:,:,islope))
    36     call gr_fi_dyn(1,ngrid,iim_input + 1,jjm_input + 1,merge(1.,0.,is_co2ice_ini(:,islope)),mask_co2ice_ini(:,:,islope))
    37     call gr_fi_dyn(1,ngrid,iim_input + 1,jjm_input + 1,merge(1.,0.,co2ice_disappeared(:,islope)),co2ice_disappeared_ll(:,:,islope))
     39    call vect2lonlat(nlon,nlat,ngrid,tsurf_avg(:,islope),tsurf_ll(:,:,islope))
     40    call vect2lonlat(nlon,nlat,ngrid,co2_ice(:,islope),co2ice_ll(:,:,islope))
     41    call vect2lonlat(nlon,nlat,ngrid,merge(1.,0.,is_co2ice_ini(:,islope)),mask_co2ice_ini(:,:,islope))
     42    call vect2lonlat(nlon,nlat,ngrid,merge(1.,0.,co2ice_disappeared(:,islope)),co2ice_disappeared_ll(:,:,islope))
    3843enddo
    39 #endif
    4044
    4145! For each point where ice disappeared
    42 rmax = max(iim_input + 1,jjm_input + 1)
    43 do j = 1,jjm_input + 1
    44     do i = 1,iim_input + 1
     46rmax = max(nlon,nlat)
     47do j = 1,nlat
     48    do i = 1,nlon
    4549        do islope = 1,nslope
    4650            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) then
    4751                found = .false.
    4852                co2ice_disappeared_ll(i,j,islope) = 1.
    49                 do k = 1,nslope
    50                     if (k /= islope .and. mask_co2ice_ini(i,j,k) < 0.5) then
    51                         tsurf_ll(i,j,islope) = tsurf_ll(i,j,k)
     53                call get_slope_priority(latitude_ll(i,j),nslope,islope,priority)
     54                do k = 1,nslope - 1
     55                    if (mask_co2ice_ini(i,j,priority(k)) < 0.5) then
     56                        tsurf_ll(i,j,islope) = tsurf_ll(i,j,priority(k))
    5257                        found = .true.
    5358                        exit
     
    5661
    5762                radius = 1
    58                 do while (.not. found .and. radius <= rmax) ! only if no adjacent slopes holds bare soil
     63                do while (.not. found .and. radius <= rmax) ! Only if no adjacent slopes holds bare soil
    5964                    do dj = -radius,radius
    6065                        do di = -radius,radius
     
    6267                                ii = i + di
    6368                                jj = j + dj
    64                                 if (ii >= 1 .and. ii <= iim_input + 1 .and. jj >= 1 .and. jj <= jjm_input + 1) then
    65                                     do k = 1,nslope
    66                                         if (mask_co2ice_ini(ii,jj,k) < 0.5) then
    67                                             tsurf_ll(i,j,islope) = tsurf_ll(i,j,k)
     69                                ! Longitudinal periodicity
     70                                if (ii < 1) then
     71                                    ii = ii + nlon
     72                                else if (ii > nlon) then
     73                                    ii = ii - nlon
     74                                endif
     75                                ! Latitude boundaries
     76                                if (jj >= 1 .and. jj <= nlat) then
     77                                    call get_slope_priority(latitude_ll(ii,jj),nslope,islope,priority)
     78                                    do k = 1,nslope - 1
     79                                        if (mask_co2ice_ini(ii,jj,priority(k)) < 0.5) then
     80                                            tsurf_ll(i,j,islope) = tsurf_ll(ii,jj,priority(k))
    6881                                            found = .true.
    6982                                            exit
     
    7891                    radius = radius + 1
    7992                enddo
     93                if (.not. found) write(*,*) "WARNING: no bare soil found for ice disappeared on  point:",i,j,islope
    8094            endif
    81 
    8295        enddo
    8396    enddo
     
    8598
    8699! Convert back from lon-lat grid to reduced grid
    87 #ifndef CPP_1D
    88100do islope = 1,nslope
    89     call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,tsurf_ll(:,:,islope),tsurf_avg(:,islope))
    90     call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,co2ice_disappeared_ll(:,:,islope),tmp)
     101    call lonlat2vect(nlon,nlat,ngrid,tsurf_ll(:,:,islope),tsurf_avg(:,islope))
     102    call lonlat2vect(nlon,nlat,ngrid,co2ice_disappeared_ll(:,:,islope),tmp)
    91103    where (tmp > 0.5) co2ice_disappeared(:,islope) = .true.
    92104enddo
    93 #endif
    94105
    95106END SUBROUTINE update_tsurf_nearest_baresoil
    96107
     108!=======================================================================
     109SUBROUTINE get_slope_priority(lat,nslope,islope,priority)
     110! Priority given to equator-ward slope which are most likely to hold no ice
     111
     112implicit none
     113
     114! Inputs:
     115real,    intent(in) :: lat
     116integer, intent(in) :: nslope, islope
     117! Outputs:
     118integer, dimension(nslope - 1), intent(out) :: priority
     119! Locals:
     120integer :: i, k
     121
     122! Code
     123!-----
     124k = 1
     125
     126! Northern hemisphere
     127if (lat > 0.) then
     128    ! Equator-ward slopes
     129    do i = islope - 1,1,-1
     130        priority(k) = i
     131        k = k + 1
     132    enddo
     133    ! Pole-ward slopes
     134    do i = islope + 1,nslope
     135        priority(k) = i
     136        k = k + 1
     137    enddo
     138else ! Southern hemisphere
     139    ! Equator-ward slopes
     140    do i = islope + 1,nslope
     141        priority(k) = i
     142        k = k + 1
     143    enddo
     144    ! Pole-ward slopes
     145    do i = islope - 1,1,-1
     146        priority(k) = i
     147        k = k + 1
     148    enddo
     149endif
     150
     151END SUBROUTINE get_slope_priority
     152
    97153END MODULE surf_temp
Note: See TracChangeset for help on using the changeset viewer.