Changeset 915
- Timestamp:
- 06/17/19 18:52:40 (5 years ago)
- Location:
- codes/icosagcm/devel/src
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
codes/icosagcm/devel/src/diagnostics/compute_temperature.F90
r914 r915 1 1 MODULE compute_temperature_mod 2 USE icosa 2 USE earth_const, ONLY : cpp, cppv, kappa, Rd, Rv, preff, Treff, & 3 caldyn_thermo, physics_thermo, & 4 thermo_theta, thermo_entropy, thermo_moist, thermo_fake_moist 5 USE grid_param 3 6 IMPLICIT NONE 4 7 PRIVATE … … 7 10 PUBLIC :: temperature, compute_temperature 8 11 12 #include "../unstructured/unstructured.h90" 13 9 14 CONTAINS 10 15 11 16 SUBROUTINE temperature(f_pmid,f_q,f_temp) 17 USE icosa 12 18 TYPE(t_field), POINTER :: f_pmid(:) ! IN 13 19 TYPE(t_field), POINTER :: f_q(:) ! IN … … 30 36 END SUBROUTINE temperature 31 37 32 SUBROUTINE compute_temperature(pmid,q,temp) 38 ! Macros loop_compute_temperature_fake_moist() and loop_compute_temperature() 39 ! are here to inline the thermodynamical formula inside the innermost loop. 40 ! Tests are made outside the outer loop. 41 42 #ifdef BEGIN_DYSL 43 44 {%- macro loop_compute_temperature() %} 45 {%- set comp_temp=caller() %} 46 FORALL_CELLS() 47 ON_PRIMAL 48 p_ik = pmid(CELL) 49 theta_ik = temp(CELL) 50 qv = q(CELL,1) ! water vapor mixing ratio = mv/md 51 {{ comp_temp }} 52 temp(CELL) = temp_ik 53 END_BLOCK 54 END_BLOCK 55 {%- endmacro %} 56 57 {%- macro loop_compute_temperature_fake_moist() %} 58 {%- set comp_temp=caller() %} 59 IF(physics_thermo==thermo_fake_moist) THEN 60 {% call loop_compute_temperature() %} 61 {{ comp_temp }} 62 temp_ik = temp_ik/(1+0.608*qv) 63 {% endcall %} 64 ELSE 65 {% call loop_compute_temperature() %} 66 {{ comp_temp }} 67 {% endcall %} 68 END IF 69 {%- endmacro %} 70 71 KERNEL(compute_temperature) 72 SELECT CASE(caldyn_thermo) 73 CASE(thermo_theta) 74 {% call loop_compute_temperature_fake_moist() %} 75 temp_ik = theta_ik*((p_ik/preff)**kappa) 76 {% endcall %} 77 CASE(thermo_entropy) 78 {% call loop_compute_temperature_fake_moist() %} 79 temp_ik = Treff*exp((theta_ik + Rd*log(p_ik/preff))/cpp) 80 {% endcall %} 81 CASE(thermo_moist) 82 {% call loop_compute_temperature() %} 83 Rmix = Rd+qv*Rv 84 chi = ( theta_ik + Rmix*log(p_ik/preff) ) / (cpp + qv*cppv) ! log(T/Treff) 85 temp_ik = Treff*exp(chi) 86 {% endcall %} 87 END SELECT 88 END_BLOCK 89 90 #endif END_DYSL 91 92 SUBROUTINE compute_temperature_unst(pmid, q, temp) 93 USE prec 94 REAL(rstd),INTENT(IN) :: pmid(llm, primal_num) 95 REAL(rstd),INTENT(IN) :: q(llm, primal_num, nqtot) 96 REAL(rstd),INTENT(INOUT) :: temp(llm, primal_num) 97 REAL(rstd) :: p_ik, theta_ik, temp_ik, qv, chi, Rmix 98 DECLARE_INDICES 99 #include "../kernels_unst/compute_temperature.k90" 100 END SUBROUTINE compute_temperature_unst 101 102 SUBROUTINE compute_temperature_hex(pmid,q,temp) 103 USE icosa 33 104 USE omp_para 34 105 REAL(rstd),INTENT(IN) :: pmid(iim*jjm,llm) … … 36 107 REAL(rstd),INTENT(INOUT) :: temp(iim*jjm,llm) 37 108 38 REAL(rstd) :: Rd, p_ik, theta_ik, temp_ik, qv, chi, Rmix 109 REAL(rstd) :: p_ik, theta_ik, temp_ik, qv, chi, Rmix 110 INTEGER :: ij,l 111 #include "../kernels_hex/compute_temperature.k90" 112 END SUBROUTINE compute_temperature_hex 113 114 SUBROUTINE compute_temperature(pmid,q,temp) 115 USE icosa 116 USE omp_para 117 REAL(rstd),INTENT(IN) :: pmid(iim*jjm,llm) 118 REAL(rstd),INTENT(IN) :: q(iim*jjm,llm,nqtot) 119 REAL(rstd),INTENT(INOUT) :: temp(iim*jjm,llm) 120 121 REAL(rstd) :: p_ik, theta_ik, temp_ik, qv, chi, Rmix 39 122 INTEGER :: ij,l 40 123 … … 62 145 63 146 SUBROUTINE Tv2T(f_Tv, f_q, f_T) 147 USE icosa 64 148 TYPE(t_field), POINTER :: f_TV(:) 65 149 TYPE(t_field), POINTER :: f_q(:)
Note: See TracChangeset
for help on using the changeset viewer.