MODULE etat0_isothermal_mod
   USE icosa, ONLY: rstd, getin, llm, nqtot, preff
   IMPLICIT NONE
   PRIVATE
   SAVE

   REAL(rstd) :: etat0_temp
!$OMP THREADPRIVATE(etat0_temp)

   PUBLIC :: getin_etat0, compute_etat0

CONTAINS

!----------------------------- Resting isothermal state --------------------------------

   SUBROUTINE getin_etat0
      ! @getin_doc etat0_temp realm=initial type=real default=300
      !  When `etat0=="isothermal"`, selects initial temperature.
      etat0_temp = 300
      CALL getin("etat0_isothermal_temp", etat0_temp)
   END SUBROUTINE getin_etat0

   SUBROUTINE compute_etat0(ngrid, phis, ps, temp, ulon, ulat, q)
      INTEGER, INTENT(IN)    :: ngrid
      REAL(rstd), INTENT(OUT) :: phis(ngrid)
      REAL(rstd), INTENT(OUT) :: ps(ngrid)
      REAL(rstd), INTENT(OUT) :: temp(ngrid, llm)
      REAL(rstd), INTENT(OUT) :: ulon(ngrid, llm)
      REAL(rstd), INTENT(OUT) :: ulat(ngrid, llm)
      REAL(rstd), INTENT(OUT) :: q(ngrid, llm, nqtot)
      phis(:) = 0
      ps(:) = preff
      temp(:, :) = etat0_temp
      ulon(:, :) = 0
      ulat(:, :) = 0
      q(:, :, :) = 0
   END SUBROUTINE compute_etat0

END MODULE etat0_isothermal_mod
