MONC
set_atm.F90
Go to the documentation of this file.
1 ! *****************************COPYRIGHT*******************************
2 ! (C) Crown copyright Met Office. All rights reserved.
3 ! For further details please refer to the file COPYRIGHT.txt
4 ! which you should have received as part of this distribution.
5 ! *****************************COPYRIGHT*******************************
6 !
7 ! Subroutine to set the grid used by the core radiation code
8 !
9 !------------------------------------------------------------------------------
10 SUBROUTINE set_atm( &
11 
12 ! Structures for the core radiation code interface
13  control, atm, dimen, spectrum, &
14 
15 ! Grid
16  n_profile, n_layer, &
17 ! monc fields
18  socrates_opt, merge_fields)
19 
20 USE rad_pcf
21 USE def_control, ONLY: strctrl
22 USE def_atm, ONLY: stratm, allocate_atm
23 USE def_spectrum, ONLY: strspecdata
24 USE def_dimen, ONLY: strdim
26 
27 USE gas_list_pcf, ONLY: ip_h2o, ip_co2, ip_o3, ip_n2o, &
28  ip_ch4, ip_o2, ip_cfc11, ip_cfc12, &
29  ip_cfc113, ip_cfc114, ip_hcfc22, &
30  ip_hfc125, ip_hfc134a
31 ! monc-socrates couple structures
34 ! From MONC model_core use science constants for consitency
37 
38 IMPLICIT NONE
39 
40 ! Control options:
41 TYPE(strctrl), INTENT(IN) :: control
42 
43 ! Atmospheric properties:
44 TYPE(stratm), INTENT(OUT) :: atm
45 
46 ! Dimensions:
47 TYPE(strdim), INTENT(IN) :: dimen
48 
49 ! Spectral data:
50 TYPE (StrSpecData), INTENT(IN) :: spectrum
51 
52 ! McClatchey profiles plus monc profiles, flipped
53 type (str_merge_atm), intent(in) :: merge_fields
54 !
55 ! MONC options read from configuration
56 type (str_socrates_options), intent(in) :: socrates_opt
57 
58 INTEGER, INTENT(IN) :: n_profile
59 ! Number of atmospheric profiles for radiation calculations
60 INTEGER, INTENT(IN) :: n_layer
61 ! Number of atmospheric layers for radiation calculations
62 
63 integer :: i, k, l ! loop counters
64 
65 call allocate_atm(atm, dimen, spectrum)
66 
67 ! Setup atmosphere for radiation (upside down!)
68 atm%n_profile = n_profile
69 atm%n_layer = n_layer
70 
71 do l=1, atm%n_profile
72 
73  atm%p_level(l,:) = merge_fields%pres_level(:) ! pref + mcclatchy going from the top 1:n_layer+1
74  atm%t_level(l,:) = merge_fields%t_level(:)! equivalent to t_bdy and tac = atm%t
75  atm%mass(l,:) = merge_fields%mass(:)
76  atm%p(l,:) = merge_fields%pres_n(:)
77  atm%t(l,:) = merge_fields%t_n(:)
78  if (spectrum%Cont%index_water > 0) THEN
79  ! The following lines come from socrates:src/modules_core/rad_ccf.
80  ! and accounts for the impact of water vapour of air density
81  DO k=1, atm%n_layer
82  atm%density(l, k)=atm%p(l, k)/(r*atm%t(l, k)*(1.0e+00_default_precision &
83  + (ratio_mol_wts-1.0_default_precision) &
84  *merge_fields%qv_n(k)))
85  enddo
86  else
87  atm%density(l, :)=atm%p(l, :)/(r*atm%t(l, :))
88  endif
89 
90 enddo
91 
92 DO i=1, spectrum%gas%n_absorb
93  DO k=1, atm%n_layer
94  DO l=1, atm%n_profile
95 
96  IF (spectrum%gas%type_absorb(i) == ip_h2o) THEN
97  atm%gas_mix_ratio(l, k, i) = merge_fields%qv_n(k)
98  ELSE IF (spectrum%gas%type_absorb(i) == ip_co2) THEN
99  atm%gas_mix_ratio(l, k, i) = socrates_opt%co2_mmr
100  ELSE IF (spectrum%gas%type_absorb(i) == ip_o3) THEN
101  atm%gas_mix_ratio(l, k, i) = merge_fields%o3_n(k)
102  ELSE IF (spectrum%gas%type_absorb(i) == ip_n2o) THEN
103  atm%gas_mix_ratio(l, k, i) = socrates_opt%n2o_mmr
104  ELSE IF (spectrum%gas%type_absorb(i) == ip_ch4) THEN
105  atm%gas_mix_ratio(l, k, i) = socrates_opt%ch4_mmr
106  ELSE IF (spectrum%gas%type_absorb(i) == ip_o2) THEN
107  atm%gas_mix_ratio(l, k, i) = socrates_opt%o2_mmr
108  ELSE IF (spectrum%gas%type_absorb(i) == ip_cfc11) THEN
109  atm%gas_mix_ratio(l, k, i) = socrates_opt%cfc11_mmr
110  ELSE IF (spectrum%gas%type_absorb(i) == ip_cfc12) THEN
111  atm%gas_mix_ratio(l, k, i) = socrates_opt%cfc12_mmr
112  ELSE IF (spectrum%gas%type_absorb(i) == ip_cfc113) THEN
113  atm%gas_mix_ratio(l, k, i) = socrates_opt%cfc113_mmr
114  ELSE IF (spectrum%gas%type_absorb(i) == ip_cfc114) THEN
115  atm%gas_mix_ratio(l, k, i) = socrates_opt%cfc114_mmr
116  ELSE IF (spectrum%gas%type_absorb(i) == ip_hcfc22) THEN
117  atm%gas_mix_ratio(l, k, i) = socrates_opt%hcfc22_mmr
118  ELSE IF (spectrum%gas%type_absorb(i) == ip_hfc125) THEN
119  atm%gas_mix_ratio(l, k, i) = socrates_opt%hfc125_mmr
120  ELSE IF (spectrum%gas%type_absorb(i) == ip_hfc134a) THEN
121  atm%gas_mix_ratio(l, k, i) = socrates_opt%hfc134a_mmr
122  ELSE
123  atm%gas_mix_ratio(l, k, i) = 0.0
124  END IF
125  END DO
126  END DO
127 END DO
128 
129 !print *, 'vapour, co2, o3, n2o, ch4'
130 
131 !DO k=1, atm%n_layer
132 ! print *, k, atm%gas_mix_ratio(1, k, 1),atm%gas_mix_ratio(1, k, 2), atm%gas_mix_ratio(1, k, 3), &
133 ! atm%gas_mix_ratio(1, k, 4), atm%gas_mix_ratio(1, k, 5)
134 !enddo
135 
136 END SUBROUTINE set_atm
def_socrates_derived_fields
Definition: def_socrates_derived_fields.F90:1
set_atm
subroutine set_atm(control, atm, dimen, spectrum, n_profile, n_layer, socrates_opt, merge_fields)
Definition: set_atm.F90:19
def_merge_atm::str_merge_atm
Definition: def_merge_atm.F90:10
science_constants_mod
Scientific constant values used throughout simulations. Each has a default value and this can be over...
Definition: scienceconstants.F90:3
science_constants_mod::r
real(kind=default_precision), public r
Definition: scienceconstants.F90:13
def_socrates_options::str_socrates_options
Definition: def_socrates_options.F90:7
science_constants_mod::ratio_mol_wts
real(kind=default_precision), public ratio_mol_wts
Definition: scienceconstants.F90:13
datadefn_mod
Contains common definitions for the data and datatypes used by MONC.
Definition: datadefn.F90:2
def_socrates_derived_fields::str_socrates_derived_fields
Definition: def_socrates_derived_fields.F90:7
def_socrates_options
Definition: def_socrates_options.F90:1
def_merge_atm
Definition: def_merge_atm.F90:1
datadefn_mod::default_precision
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
Definition: datadefn.F90:17