Ignore:
Timestamp:
Dec 19, 2025, 11:19:30 AM (5 weeks ago)
Author:
yann meurdesoif
Message:

GPU port of surf_seaice
Merge of commit r5889
YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/phylmd/soil.f90

    r5942 r5965  
    22! $Header$
    33!
    4 SUBROUTINE soil(ptimestep, indice, knon, snow, ptsrf, qsol, &
    5      lon, lat, ptsoil, pcapcal, pfluxgrd)
    6  
    7   USE yomcst_mod_h
    8   USE dimphy
    9   USE mod_phys_lmdz_para
    10   USE indice_sol_mod
    11   USE print_control_mod, ONLY: lunout
     4MODULE soil_mod
    125  USE dimsoil_mod_h, ONLY: nsoilmx
    13   USE comsoil_mod_h
    14   IMPLICIT NONE
    15 
    16 !=======================================================================
    17 !
    18 !   Auteur:  Frederic Hourdin     30/01/92
    19 !   -------
    20 !
    21 !   Object:  Computation of : the soil temperature evolution
    22 !   -------                   the surfacic heat capacity "Capcal"
    23 !                            the surface conduction flux pcapcal
    24 !
    25 !   Update: 2021/07 : soil thermal inertia, formerly a constant value,
    26 !   ------   can also be now a function of soil moisture (F Cheruy's idea)
    27 !            depending on iflag_inertie, read from physiq.def via conf_phys_m.F90
    28 !            ("Stage L3" Eve Rebouillat, with E Vignon, A Sima, F Cheruy)
    29 !
    30 !   Method: Implicit time integration
    31 !   -------
    32 !   Consecutive ground temperatures are related by:
    33 !           T(k+1) = C(k) + D(k)*T(k)  (*)
    34 !   The coefficients C and D are computed at the t-dt time-step.
    35 !   Routine structure:
    36 !   1) C and D coefficients are computed from the old temperature
    37 !   2) new temperatures are computed using (*)
    38 !   3) C and D coefficients are computed from the new temperature
    39 !      profile for the t+dt time-step
    40 !   4) the coefficients A and B are computed where the diffusive
    41 !      fluxes at the t+dt time-step is given by
    42 !             Fdiff = A + B Ts(t+dt)
    43 !      or     Fdiff = F0 + Capcal (Ts(t+dt)-Ts(t))/dt
    44 !             with F0 = A + B (Ts(t))
    45 !                 Capcal = B*dt
    46 !
    47 !   Interface:
    48 !   ----------
    49 !
    50 !   Arguments:
    51 !   ----------
    52 !   ptimestep            physical timestep (s)
    53 !   indice               sub-surface index
    54 !   snow(klon)           snow
    55 !   ptsrf(klon)          surface temperature at time-step t (K)
    56 !   qsol(klon)           soil moisture (kg/m2 or mm)
    57 !   lon(klon)            longitude in radian
    58 !   lat(klon)            latitude in radian
    59 !   ptsoil(klon,nsoilmx) temperature inside the ground (K)
    60 !   pcapcal(klon)        surfacic specific heat (W*m-2*s*K-1)
    61 !   pfluxgrd(klon)       surface diffusive flux from ground (Wm-2)
    62 !
    63 !=======================================================================
    64 ! Arguments
    65 ! ---------
    66   REAL, INTENT(IN)                     :: ptimestep
    67   INTEGER, INTENT(IN)                  :: indice, knon !, knindex
    68   REAL, DIMENSION(knon), INTENT(IN)    :: snow
    69   REAL, DIMENSION(knon), INTENT(IN)    :: ptsrf
    70   REAL, DIMENSION(knon), INTENT(IN)    :: qsol
    71   REAL, DIMENSION(knon), INTENT(IN)    :: lon
    72   REAL, DIMENSION(knon), INTENT(IN)    :: lat
    73 
    74   REAL, DIMENSION(knon,nsoilmx), INTENT(INOUT) :: ptsoil
    75   REAL, DIMENSION(knon), INTENT(OUT)           :: pcapcal
    76   REAL, DIMENSION(knon), INTENT(OUT)           :: pfluxgrd
    77 
    78 !-----------------------------------------------------------------------
    79 ! Local variables
    80 ! ---------------
    81   INTEGER                             :: ig, jk, ierr
    82   REAL                                :: min_period,dalph_soil
    83   REAL, DIMENSION(nsoilmx)            :: zdz2
    84   REAL                                :: z1s
    85   REAL, DIMENSION(knon)               :: ztherm_i
    86   REAL, DIMENSION(knon,nsoilmx,nbsrf) :: C_coef, D_coef
    87 
    88 ! Local saved variables
    89 ! ---------------------
     6  PRIVATE
     7 
    908  REAL, SAVE                     :: lambda
    919!$OMP THREADPRIVATE(lambda)
    9210  REAL, DIMENSION(nsoilmx), SAVE :: dz1, dz2
    9311!$OMP THREADPRIVATE(dz1,dz2)
    94   LOGICAL, SAVE                  :: firstcall=.TRUE.
    95 !$OMP THREADPRIVATE(firstcall)
    96    
     12  LOGICAL, SAVE                  :: is_initialized=.FALSE.
     13!$OMP THREADPRIVATE(is_initialized)
     14
     15  PUBLIC :: soil_init, soil
     16
     17CONTAINS
     18
     19SUBROUTINE soil_init
     20USE dimsoil_mod_h, ONLY: nsoilmx
     21USE print_control_mod, ONLY: lunout
     22USE mod_phys_lmdz_para
     23IMPLICIT NONE
     24  REAL                                :: min_period,dalph_soil
     25  INTEGER                             :: ig, jk, ierr
    9726!-----------------------------------------------------------------------
    9827!   Depthts:
     
    10736!-----------------------------------------------------------------------
    10837
    109   IF (firstcall) THEN
    11038!-----------------------------------------------------------------------
    11139!   ground levels
    11240!   grnd=z/l where l is the skin depth of the diurnal cycle:
    11341!-----------------------------------------------------------------------
     42    IF (.NOT. is_initialized) THEN
    11443
    11544     min_period=1800. ! en secondes
     
    15483     ENDDO
    15584
    156      firstcall =.FALSE.
     85     is_initialized=.TRUE.
    15786  END IF
     87
     88END SUBROUTINE  soil_init
     89
     90SUBROUTINE soil(ptimestep, indice, knon, snow, ptsrf, qsol, &
     91     lon, lat, ptsoil, pcapcal, pfluxgrd)
     92!$gpum horizontal knon klon
     93  USE yomcst_mod_h
     94  USE dimphy
     95  USE mod_phys_lmdz_para
     96  USE indice_sol_mod
     97  USE print_control_mod, ONLY: lunout
     98  USE dimsoil_mod_h, ONLY: nsoilmx
     99  USE comsoil_mod_h
     100  IMPLICIT NONE
     101
     102!=======================================================================
     103!
     104!   Auteur:  Frederic Hourdin     30/01/92
     105!   -------
     106!
     107!   Object:  Computation of : the soil temperature evolution
     108!   -------                   the surfacic heat capacity "Capcal"
     109!                            the surface conduction flux pcapcal
     110!
     111!   Update: 2021/07 : soil thermal inertia, formerly a constant value,
     112!   ------   can also be now a function of soil moisture (F Cheruy's idea)
     113!            depending on iflag_inertie, read from physiq.def via conf_phys_m.F90
     114!            ("Stage L3" Eve Rebouillat, with E Vignon, A Sima, F Cheruy)
     115!
     116!   Method: Implicit time integration
     117!   -------
     118!   Consecutive ground temperatures are related by:
     119!           T(k+1) = C(k) + D(k)*T(k)  (*)
     120!   The coefficients C and D are computed at the t-dt time-step.
     121!   Routine structure:
     122!   1) C and D coefficients are computed from the old temperature
     123!   2) new temperatures are computed using (*)
     124!   3) C and D coefficients are computed from the new temperature
     125!      profile for the t+dt time-step
     126!   4) the coefficients A and B are computed where the diffusive
     127!      fluxes at the t+dt time-step is given by
     128!             Fdiff = A + B Ts(t+dt)
     129!      or     Fdiff = F0 + Capcal (Ts(t+dt)-Ts(t))/dt
     130!             with F0 = A + B (Ts(t))
     131!                 Capcal = B*dt
     132!
     133!   Interface:
     134!   ----------
     135!
     136!   Arguments:
     137!   ----------
     138!   ptimestep            physical timestep (s)
     139!   indice               sub-surface index
     140!   snow(klon)           snow
     141!   ptsrf(klon)          surface temperature at time-step t (K)
     142!   qsol(klon)           soil moisture (kg/m2 or mm)
     143!   lon(klon)            longitude in radian
     144!   lat(klon)            latitude in radian
     145!   ptsoil(klon,nsoilmx) temperature inside the ground (K)
     146!   pcapcal(klon)        surfacic specific heat (W*m-2*s*K-1)
     147!   pfluxgrd(klon)       surface diffusive flux from ground (Wm-2)
     148!
     149!=======================================================================
     150! Arguments
     151! ---------
     152  REAL, INTENT(IN)                     :: ptimestep
     153  INTEGER, INTENT(IN)                  :: indice, knon !, knindex
     154  REAL, DIMENSION(knon), INTENT(IN)    :: snow
     155  REAL, DIMENSION(knon), INTENT(IN)    :: ptsrf
     156  REAL, DIMENSION(knon), INTENT(IN)    :: qsol
     157  REAL, DIMENSION(knon), INTENT(IN)    :: lon
     158  REAL, DIMENSION(knon), INTENT(IN)    :: lat
     159
     160  REAL, DIMENSION(knon,nsoilmx), INTENT(INOUT) :: ptsoil
     161  REAL, DIMENSION(knon), INTENT(OUT)           :: pcapcal
     162  REAL, DIMENSION(knon), INTENT(OUT)           :: pfluxgrd
     163
     164!-----------------------------------------------------------------------
     165! Local variables
     166! ---------------
     167  INTEGER                             :: ig, jk, ierr
     168  REAL, DIMENSION(nsoilmx)            :: zdz2
     169  REAL                                :: z1s
     170  REAL, DIMENSION(knon)               :: ztherm_i
     171  REAL, DIMENSION(knon,nsoilmx,nbsrf) :: C_coef, D_coef
     172
    158173
    159174
     
    351366   
    352367END SUBROUTINE soil
     368
     369END MODULE soil_mod
Note: See TracChangeset for help on using the changeset viewer.