Changeset 836 for codes/icosagcm/devel


Ignore:
Timestamp:
05/03/19 13:25:21 (5 years ago)
Author:
dubos
Message:

devel : Cp(T) thermodynamics (TBC)

Location:
codes/icosagcm/devel
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/devel/Python/src/kernels_caldyn_hydro.jin

    r685 r836  
    6565      gv = (g*Rd)*temp_ik/p_ik   ! specific volume v = Rd*T/p 
    6666    END_GEOPOT 
     67  CASE(thermo_variable_Cp) 
     68    ! thermodynamics with variable Cp 
     69    !      Cp.dT = dh = Tds + vdp 
     70    !              pv = RT 
     71    ! =>           ds = (dh+v.dp)/T = Cp.dT/T - R dp/p 
     72    !           Cp(T) = Cp0 * (T/T0)^nu 
     73    ! =>       s(p,T) = Cp(T)/nu - R log(p/preff)  
     74    !               h = Cp(T).T/(nu+1) 
     75    BALANCE( rhodz(THECELL) ) 
     76    GEOPOT('temp_ik') 
     77      Cp_ik = nu*( theta(CELL,1) + Rd*log(p_ik/preff) ) 
     78      temp_ik = Treff* (Cp_ik/cpp)**(1./nu) 
     79      gv = (g*Rd)*temp_ik/p_ik   ! specific volume v = Rd*T/p 
     80    END_GEOPOT 
    6781  CASE(thermo_moist) 
    6882    BALANCE( rhodz(THECELL)*(1.+theta(THECELL,2)) ) 
  • codes/icosagcm/devel/src/base/earth_const.f90

    r834 r836  
    77! hence the variables set here are not THREADPRIVATE 
    88 
    9   REAL(rstd) :: g=9.80616 
    10   REAL(rstd) :: radius=6.37122E6 
     9! Some variable are BIND(C) to be accessible from Python 
     10 
     11  REAL(rstd), BIND(C) :: g=9.80616    ! acceleration of gravity assumed constant 
     12  REAL(rstd):: radius=6.37122E6 
    1113  REAL(rstd) :: omega=7.292E-5 
    1214  REAL(rstd) :: scale_factor=1. 
    1315  REAL(rstd),PARAMETER :: daysec=86400 
    1416 
    15   REAL(rstd) :: kappa=0.2857143 
    16   REAL(rstd) :: cpp=1004.70885 
    17   REAL(rstd) :: nu=0.35 ! exponent in variable-Cp law Cp=cpp*(T/Treff)^nu 
    18   REAL(rstd) :: cppv=1860. 
    19   REAL(rstd) :: Rv=461.5 
    20   REAL(rstd) :: Treff=273. 
    21   REAL(rstd) :: preff=101325. 
    22   REAL(rstd) :: pa=50000. ! default value set to preff/2 by disvert_std 
     17  REAL(rstd), BIND(C) ::   Treff=273.,     &   ! reference temperature, used in definition of entropy 
     18                           preff=101325.,  &   ! reference pressure, used in definition of entropy and theta 
     19                           cpp=1004.70885, &   ! specific heat at constant pressure at t=Treff for dry air 
     20                           cppv=1860.,     &   ! specific heat at constant pressure at t=Treff for water vapor 
     21                           Rd,             &   ! specific perfect gas constant for dry air 
     22                           Rv=461.5            ! specific perfect gas constant for water vapor 
     23 
     24  REAL(rstd) :: nu=0.35     ! exponent in variable-Cp law Cp=cpp*(T/Treff)^nu 
     25  REAL(rstd) :: pa=50000.   ! default value set to preff/2 by disvert_std 
    2326  REAL(rstd) :: scale_height=8000. ! atmospheric scale height (m) 
    2427  REAL(rstd) :: gas_constant = 8.3144621  
    25   REAL(rstd) :: Rd, mu             ! specific perfect gas constant and molar mass (?) 
     28  REAL(rstd) :: mu             ! molar mass (?) 
    2629 
    27   INTEGER, PUBLIC, PARAMETER :: thermo_none=-99, thermo_theta=1, thermo_entropy=2, thermo_variable_Cp=3, & 
     30  REAL(rstd) :: kappa=0.2857143 
     31 
     32  INTEGER, PARAMETER :: thermo_none=-99, thermo_theta=1, thermo_entropy=2, thermo_variable_Cp=3, & 
    2833       thermo_moist=4, thermo_boussinesq=5, thermo_dry=10, thermo_fake_moist=11, thermo_moist_debug=100 
    29   LOGICAL, PUBLIC :: boussinesq 
    30   INTEGER, PUBLIC :: caldyn_thermo, physics_thermo 
     34  LOGICAL :: boussinesq 
     35  INTEGER, BIND(C) :: caldyn_thermo, physics_thermo 
    3136 
    3237CONTAINS 
  • codes/icosagcm/devel/src/dynamics/caldyn_kernels_base.F90

    r731 r836  
    2424 
    2525    INTEGER :: i,j,ij,l 
    26     REAL(rstd) :: Rd, p_ik, exner_ik, temp_ik, qv, chi, Rmix, gv 
     26    REAL(rstd) :: p_ik, exner_ik, Cp_ik, temp_ik, qv, chi, Rmix, gv 
    2727    INTEGER    :: ij_omp_begin_ext, ij_omp_end_ext 
    2828 
     
    3232 
    3333    CALL distrib_level(ij_begin_ext,ij_end_ext, ij_omp_begin_ext,ij_omp_end_ext) 
    34  
    35     Rd = kappa*cpp 
    3634 
    3735    IF(dysl_geopot) THEN 
  • codes/icosagcm/devel/src/kernels_hex/compute_geopot.k90

    r724 r836  
    8282         END DO 
    8383      END DO 
     84   CASE(thermo_variable_Cp) 
     85      ! thermodynamics with variable Cp 
     86      ! Cp.dT = dh = Tds + vdp 
     87      ! pv = RT 
     88      ! => ds = (dh+v.dp)/T = Cp.dT/T - R dp/p 
     89      ! Cp(T) = Cp0 * (T/T0)^nu 
     90      ! => s(p,T) = Cp(T)/nu - R log(p/preff) 
     91      ! h = Cp(T).T/(nu+1) 
     92      !DIR$ SIMD 
     93      DO ij=ij_omp_begin_ext,ij_omp_end_ext 
     94         pk(ij,llm) = ptop + .5*g* rhodz(ij,llm) 
     95      END DO 
     96      DO l = llm-1,1,-1 
     97         !DIR$ SIMD 
     98         DO ij=ij_omp_begin_ext,ij_omp_end_ext 
     99            pk(ij,l) = pk(ij,l+1) + (.5*g)*( rhodz(ij,l) + rhodz(ij,l+1) ) 
     100         END DO 
     101      END DO 
     102      IF(caldyn_eta == eta_lag) THEN 
     103         !DIR$ SIMD 
     104         DO ij=ij_omp_begin_ext,ij_omp_end_ext 
     105            ps(ij) = pk(ij,1) + .5*g* rhodz(ij,1) 
     106         END DO 
     107      END IF 
     108      DO l = 1,llm 
     109         !DIR$ SIMD 
     110         DO ij=ij_omp_begin_ext,ij_omp_end_ext 
     111            p_ik = pk(ij,l) 
     112            Cp_ik = nu*( theta(ij,l,1) + Rd*log(p_ik/preff) ) 
     113            temp_ik = Treff* (Cp_ik/cpp)**(1./nu) 
     114            gv = (g*Rd)*temp_ik/p_ik ! specific volume v = Rd*T/p 
     115            pk(ij,l) = temp_ik 
     116            geopot(ij,l+1) = geopot(ij,l) + gv*rhodz(ij,l) 
     117         END DO 
     118      END DO 
    84119   CASE(thermo_moist) 
    85120      !DIR$ SIMD 
  • codes/icosagcm/devel/src/kernels_unst/compute_geopot.k90

    r686 r836  
    7070      END DO 
    7171      !$OMP END DO 
     72   CASE(thermo_variable_Cp) 
     73      ! thermodynamics with variable Cp 
     74      ! Cp.dT = dh = Tds + vdp 
     75      ! pv = RT 
     76      ! => ds = (dh+v.dp)/T = Cp.dT/T - R dp/p 
     77      ! Cp(T) = Cp0 * (T/T0)^nu 
     78      ! => s(p,T) = Cp(T)/nu - R log(p/preff) 
     79      ! h = Cp(T).T/(nu+1) 
     80      !$OMP DO SCHEDULE(STATIC) 
     81      DO ij=1,primal_num 
     82         pk(llm,ij) = ptop + .5*g* rhodz(llm,ij) 
     83         DO l = llm-1,1,-1 
     84            pk(l,ij) = pk(l+1,ij) + (.5*g)*( rhodz(l,ij) + rhodz(l+1,ij) ) 
     85         END DO 
     86         IF(caldyn_eta == eta_lag) THEN 
     87            ps(ij) = pk(1,ij) + .5*g* rhodz(1,ij) 
     88         END IF 
     89      END DO 
     90      !$OMP END DO 
     91      !$OMP DO SCHEDULE(STATIC) 
     92      DO ij=1,primal_num 
     93         DO l = 1,llm 
     94            p_ik = pk(l,ij) 
     95            Cp_ik = nu*( theta(l,ij,1) + Rd*log(p_ik/preff) ) 
     96            temp_ik = Treff* (Cp_ik/cpp)**(1./nu) 
     97            gv = (g*Rd)*temp_ik/p_ik ! specific volume v = Rd*T/p 
     98            pk(l,ij) = temp_ik 
     99            geopot(l+1,ij) = geopot(l,ij) + gv*rhodz(l,ij) 
     100         END DO 
     101      END DO 
     102      !$OMP END DO 
    72103   CASE(thermo_moist) 
    73104      !$OMP DO SCHEDULE(STATIC) 
  • codes/icosagcm/devel/src/unstructured/caldyn_unstructured.F90

    r833 r836  
    22  USE ISO_C_BINDING 
    33  USE OMP_LIB 
     4  USE earth_const 
    45  USE data_unstructured_mod 
    56  IMPLICIT NONE 
     
    119120  FIELD_PS     :: ps        ! OUT 
    120121  DECLARE_INDICES 
    121   NUM :: gdz, ke, uu, chi, gv, exner_ik, temp_ik, p_ik, qv, Rmix 
     122  NUM :: gdz, ke, uu, chi, gv, exner_ik, temp_ik, p_ik, qv, Rmix, Cp_ik 
    122123  START_TRACE(id_geopot, 3,0,3) 
    123124#include "../kernels_unst/compute_geopot.k90" 
  • codes/icosagcm/devel/src/unstructured/data_unstructured.F90

    r832 r836  
    11MODULE data_unstructured_mod 
    22  USE ISO_C_BINDING 
     3  USE earth_const, ONLY : thermo_theta 
    34  USE mpipara, ONLY : is_mpi_master 
    45  USE grid_param, ONLY : llm, nqdyn 
     
    1314 
    1415  INTEGER, PARAMETER :: eta_mass=1, eta_lag=2, & 
    15        thermo_theta=1, thermo_entropy=2, thermo_moist=3, thermo_boussinesq=4, & 
     16!       thermo_theta=1, thermo_entropy=2, thermo_moist=3, thermo_boussinesq=4, & 
    1617       caldyn_vert_cons=1, max_nb_stage=5 
    17   INDEX,  BIND(C) :: caldyn_thermo=thermo_theta, caldyn_eta=eta_lag, & 
     18  INDEX,  BIND(C) :: caldyn_eta=eta_lag, & 
    1819       caldyn_vert_variant=caldyn_vert_cons, nb_threads=0, nb_stage=0 
     20!  INDEX,  BIND(C) :: caldyn_thermo=thermo_theta, caldyn_eta=eta_lag, & 
     21!       caldyn_vert_variant=caldyn_vert_cons, nb_threads=0, nb_stage=0 
    1922  LOGICAL(C_BOOL), BIND(C) :: hydrostatic=.TRUE., debug_on=.FALSE. 
    2023  LOGICAL(C_BOOL), BIND(C, NAME='debug_hevi_solver') :: debug_hevi_solver_=.TRUE. 
     
    4043  TIME, PARAMETER :: print_trace_interval = 1. 
    4144  TIME, BIND(C) :: elapsed 
    42   NUM, BIND(C) :: g, ptop, cpp, cppv, Rd, Rv, preff, Treff, pbot, Phi_bot, rho_bot 
    43   NUM :: kappa 
     45  NUM, BIND(C) :: ptop, pbot, Phi_bot, rho_bot 
     46!  NUM, BIND(C) :: g, ptop, cpp, cppv, Rd, Rv, preff, Treff, pbot, Phi_bot, rho_bot 
     47!  NUM :: kappa 
    4448  NUM1(max_nb_stage), BIND(C)              :: tauj       ! diagonal of fast Butcher tableau 
    4549  NUM2(max_nb_stage,max_nb_stage), BIND(C) :: cslj, cflj ! slow and fast modified Butcher tableaus 
     
    252256  ! 
    253257  SUBROUTINE init_params() BINDC(init_params) 
     258    USE earth_const 
    254259    kappa = Rd/cpp 
    255260    IF(is_mpi_master) THEN 
Note: See TracChangeset for help on using the changeset viewer.