UFO
ufo_utils.interface.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
2 ! (C) Crown Copyright 2021 Met Office
3 !
4 ! This software is licensed under the terms of the Apache Licence Version 2.0
5 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 !-------------------------------------------------------------------------------
7 
9 
10 use iso_c_binding
11 use kinds
13 
14 implicit none
15 
16 private
17 
18 contains
19 
20 !-------------------------------------------------------------------------------
21 ! Met Office Qsplit routine
22 ! output_type = 1: Partition total humidity into water vapour, liquid water and ice
23 ! output_type != 1: Compute derivatives dq/dqtotal, dql/dqtotal, dqi/dqtotal
24 subroutine ufo_ops_satrad_qsplit_c(output_type, nvals, p_in, t_in, qtotal_in, &
25  q_out, ql_out, qi_out, use_qt_split_rain) &
26  bind(c, name='ufo_ops_satrad_qsplit_f90')
27 
28 implicit none
29 integer(c_int), intent(in) :: output_type
30 integer(c_int), intent(in) :: nvals
31 real(c_float), intent(in) :: p_in(nvals)
32 real(c_float), intent(in) :: t_in(nvals)
33 real(c_float), intent(in) :: qtotal_in(nvals)
34 real(c_float), intent(out) :: q_out(nvals)
35 real(c_float), intent(out) :: ql_out(nvals)
36 real(c_float), intent(out) :: qi_out(nvals)
37 logical(c_bool), intent(in) :: use_qt_split_rain
38 
39 real(kind_real) :: q_out_kind_real(nvals)
40 real(kind_real) :: ql_out_kind_real(nvals)
41 real(kind_real) :: qi_out_kind_real(nvals)
42 
43 call ops_satrad_qsplit(output_type, dble(p_in), dble(t_in), dble(qtotal_in), &
44  q_out_kind_real, ql_out_kind_real, qi_out_kind_real, &
45  logical(use_qt_split_rain))
46 
47 q_out = real(q_out_kind_real)
48 ql_out = real(ql_out_kind_real)
49 qi_out = real(qi_out_kind_real)
50 
51 end subroutine ufo_ops_satrad_qsplit_c
52 
53 !-------------------------------------------------------------------------------
54 ! Met Office Ops_QsatWat routine
55 ! Returns a saturation mixing ratio (kg/kg) given a temperature and pressure
56 ! using saturation vapour pressure calculated using Goff-Gratch formulae
57 subroutine ufo_ops_satrad_qsatwat(qs_out, t_in, p_in, nvals) &
58  bind(c, name='ufo_ops_satrad_qsatwat_f90')
59 
60 implicit none
61 real(c_float), intent(out) :: qs_out(nvals) ! saturation mixing ratio (kg/kg)
62 real(c_float), intent(in) :: t_in(nvals) ! temperature (K)
63 real(c_float), intent(in) :: p_in(nvals) ! pressure (Pa)
64 integer(c_int), intent(in) :: nvals
65 
66 real(kind_real) :: qs_out_kind_real(nvals)
67 
68 call ops_qsatwat(qs_out_kind_real, dble(t_in), dble(p_in), nvals)
69 
70 qs_out = real(qs_out_kind_real)
71 
72 end subroutine ufo_ops_satrad_qsatwat
73 
74 !-------------------------------------------------------------------------------
subroutine ufo_ops_satrad_qsatwat(qs_out, t_in, p_in, nvals)
subroutine ufo_ops_satrad_qsplit_c(output_type, nvals, p_in, t_in, qtotal_in, q_out, ql_out, qi_out, use_qt_split_rain)
Fortran module with various useful routines.
subroutine, public ops_satrad_qsplit(output_type, p, t, qtotal, q, ql, qi, UseQtSplitRain)
Split the humidity into water vapour, liquid water and ice.
subroutine, public ops_qsatwat(QS, T, P, npnts)
Saturation Specific Humidity Scheme: Vapour to Liquid.