[381] | 1 | !================================================================================================ |
---|
| 2 | ! This is the "toy" chemistry module. |
---|
| 3 | !================================================================================================ |
---|
| 4 | |
---|
| 5 | MODULE Terminator |
---|
| 6 | |
---|
| 7 | implicit none |
---|
| 8 | private |
---|
| 9 | save |
---|
| 10 | |
---|
| 11 | public :: initial_value_Terminator ! initialize cl and cl2 |
---|
| 12 | public :: tendency_Terminator ! interface to tendency computation |
---|
| 13 | |
---|
| 14 | !integer, parameter :: 8 = selected_real_kind (12) |
---|
| 15 | |
---|
| 16 | real(8), parameter :: cly_constant = 4.e-6_8 |
---|
| 17 | real(8), parameter :: pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164_8 |
---|
| 18 | real(8), parameter :: half_pi = pi*0.5_8 |
---|
| 19 | real(8), parameter :: degrees_to_radians = pi/180.0_8 |
---|
| 20 | real(8), parameter :: k1_lat_center = 20.d0*degrees_to_radians |
---|
| 21 | real(8), parameter :: k1_lon_center = 300.d0*degrees_to_radians |
---|
| 22 | |
---|
| 23 | contains |
---|
| 24 | |
---|
| 25 | !=============================================================================== |
---|
| 26 | ! Solar photolysis rate and recombination rate |
---|
| 27 | !=============================================================================== |
---|
| 28 | |
---|
| 29 | subroutine k_vals( lat, lon, k1, k2 ) |
---|
| 30 | |
---|
| 31 | !----------------------------------------------------------------------- |
---|
| 32 | ! Arguments: |
---|
| 33 | !----------------------------------------------------------------------- |
---|
| 34 | real(8), intent(in) :: lat, lon ! latitude and longitude, radians |
---|
| 35 | real(8), intent(out) :: k1, k2 ! reaction rates |
---|
| 36 | |
---|
| 37 | k1 = 1.0_8*max(0.d0,sin(lat)*sin(k1_lat_center) + cos(lat)*cos(k1_lat_center)*cos(lon-k1_lon_center)) |
---|
| 38 | k2 = 1._8 |
---|
| 39 | |
---|
| 40 | return |
---|
| 41 | |
---|
| 42 | end subroutine k_vals |
---|
| 43 | |
---|
| 44 | !=============================================================================== |
---|
| 45 | ! Tendencies of cl and cl2 |
---|
| 46 | !=============================================================================== |
---|
| 47 | |
---|
| 48 | subroutine tendency_Terminator( lat, lon, cl, cl2, dt, cl_f, cl2_f ) |
---|
| 49 | |
---|
| 50 | !----------------------------------------------------------------------- |
---|
| 51 | ! Arguments: |
---|
| 52 | !----------------------------------------------------------------------- |
---|
| 53 | |
---|
| 54 | real(8), intent(in) :: lat, lon ! latitude and longitude, degrees |
---|
| 55 | real(8), intent(in) :: cl, cl2 ! molar mixing ratio of cl and cl2 |
---|
| 56 | real(8), intent(in) :: dt ! size of physics time step |
---|
| 57 | |
---|
| 58 | real(8), intent(out) :: cl_f, cl2_f ! time rate of change of cl and cl2 |
---|
| 59 | |
---|
| 60 | !----------------------------------------------------------------------- |
---|
| 61 | ! Local variables |
---|
| 62 | !----------------------------------------------------------------------- |
---|
| 63 | |
---|
| 64 | real(8) :: r, det, expdt, el ! useful algebaic quantities used in the computation |
---|
| 65 | real(8) :: k1, k2 ! reaction rates |
---|
| 66 | real(8) :: cly ! quantity that should be conseved |
---|
| 67 | |
---|
| 68 | call k_vals( lat, lon, k1, k2 ) |
---|
| 69 | |
---|
| 70 | r = k1 / (4._8*k2) |
---|
| 71 | cly = cl + 2._8* cl2 |
---|
| 72 | |
---|
| 73 | det = sqrt( r*r + 2._8*r*cly ) |
---|
| 74 | expdt = exp( -4._8*k2*det*dt ) |
---|
| 75 | |
---|
| 76 | if ( abs(det * k2 * dt) .gt. 1e-16 ) then |
---|
| 77 | el = (1._8 - expdt) /det /dt |
---|
| 78 | else |
---|
| 79 | el = 4._8*k2 |
---|
| 80 | endif |
---|
| 81 | |
---|
| 82 | cl_f = -el * (cl - det + r)*(cl + det + r) / (1._8 + expdt + dt*el*(cl + r)) |
---|
| 83 | cl2_f = -cl_f / 2._8 |
---|
| 84 | |
---|
| 85 | return |
---|
| 86 | |
---|
| 87 | end subroutine tendency_Terminator |
---|
| 88 | |
---|
| 89 | !=============================================================================== |
---|
| 90 | ! Compute initial values |
---|
| 91 | !=============================================================================== |
---|
| 92 | |
---|
| 93 | subroutine initial_value_Terminator( lat, lon, cl, cl2 ) |
---|
| 94 | |
---|
| 95 | !----------------------------------------------------------------------- |
---|
| 96 | ! Arguments: |
---|
| 97 | !----------------------------------------------------------------------- |
---|
| 98 | |
---|
| 99 | real(8), intent(in) :: lat, lon ! latitude and longitude, degrees |
---|
| 100 | real(8), intent(out) :: cl, cl2 ! molar mixing ratio of cl and cl2 |
---|
| 101 | |
---|
| 102 | !----------------------------------------------------------------------- |
---|
| 103 | ! Local variables |
---|
| 104 | !----------------------------------------------------------------------- |
---|
| 105 | |
---|
| 106 | real(8) :: r, det ! useful algebraic forms |
---|
| 107 | real(8) :: k1, k2 ! reaction rates |
---|
| 108 | |
---|
| 109 | call k_vals( lat, lon, k1, k2 ) |
---|
| 110 | |
---|
| 111 | r = k1 / (4._8*k2) |
---|
| 112 | det = sqrt(r*r + 2._8*cly_constant*r) |
---|
| 113 | |
---|
| 114 | cl = (det-r) |
---|
| 115 | cl2 = cly_constant/2._8 - (det-r)/2._8 |
---|
| 116 | |
---|
| 117 | return |
---|
| 118 | |
---|
| 119 | end subroutine initial_value_Terminator |
---|
| 120 | |
---|
| 121 | end module Terminator |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | |
---|