1 | MODULE observable_mod |
---|
2 | USE icosa |
---|
3 | USE caldyn_vars_mod |
---|
4 | USE diagflux_mod |
---|
5 | USE output_field_mod |
---|
6 | IMPLICIT NONE |
---|
7 | PRIVATE |
---|
8 | |
---|
9 | TYPE(t_field),POINTER, SAVE :: f_buf_i(:), & |
---|
10 | f_buf_Fel(:), f_buf_uh(:), & ! horizontal velocity, different from prognostic velocity if NH |
---|
11 | f_buf_ulon(:), f_buf_ulat(:) |
---|
12 | TYPE(t_field),POINTER, SAVE :: f_buf_v(:), f_buf_s(:), f_buf_p(:) |
---|
13 | TYPE(t_field),POINTER, SAVE :: f_pmid(:) |
---|
14 | |
---|
15 | ! temporary shared variable for caldyn |
---|
16 | TYPE(t_field),POINTER, SAVE :: f_theta(:) |
---|
17 | |
---|
18 | PUBLIC init_observable, write_output_fields_basic, & |
---|
19 | f_theta, f_buf_i, f_buf_ulon, f_buf_ulat |
---|
20 | |
---|
21 | CONTAINS |
---|
22 | |
---|
23 | SUBROUTINE init_observable |
---|
24 | CALL allocate_field(f_buf_i, field_t,type_real,llm,name="buffer_i") |
---|
25 | CALL allocate_field(f_buf_p, field_t,type_real,llm+1) |
---|
26 | CALL allocate_field(f_buf_ulon,field_t,type_real,llm, name="buf_ulon") |
---|
27 | CALL allocate_field(f_buf_ulat,field_t,type_real,llm, name="buf_ulat") |
---|
28 | CALL allocate_field(f_buf_uh, field_u,type_real,llm, name="buf_uh") |
---|
29 | CALL allocate_field(f_buf_Fel, field_u,type_real,llm+1, name="buf_F_el") |
---|
30 | CALL allocate_field(f_buf_v, field_z,type_real,llm, name="buf_v") |
---|
31 | CALL allocate_field(f_buf_s, field_t,type_real, name="buf_s") |
---|
32 | |
---|
33 | CALL allocate_field(f_theta, field_t,type_real,llm,nqdyn, name='theta') ! potential temperature |
---|
34 | CALL allocate_field(f_pmid, field_t,type_real,llm, name='pmid') ! mid layer pressure |
---|
35 | END SUBROUTINE init_observable |
---|
36 | |
---|
37 | SUBROUTINE write_output_fields_basic(init, f_phis, f_ps, f_mass, f_geopot, f_theta_rhodz, f_u, f_W, f_q) |
---|
38 | USE xios_mod |
---|
39 | USE disvert_mod |
---|
40 | USE wind_mod |
---|
41 | USE omp_para |
---|
42 | USE time_mod |
---|
43 | USE xios_mod |
---|
44 | USE earth_const |
---|
45 | USE compute_pression_mod, ONLY : pression_mid |
---|
46 | USE compute_temperature_mod |
---|
47 | USE compute_velocity_mod |
---|
48 | USE vertical_interp_mod |
---|
49 | USE theta2theta_rhodz_mod |
---|
50 | USE compute_omega_mod, ONLY : w_omega |
---|
51 | USE kinetic_mod |
---|
52 | USE grid_param |
---|
53 | LOGICAL, INTENT(IN) :: init |
---|
54 | INTEGER :: l |
---|
55 | REAL :: scalar(1) |
---|
56 | REAL :: mid_ap(llm) |
---|
57 | REAL :: mid_bp(llm) |
---|
58 | |
---|
59 | TYPE(t_field),POINTER :: f_phis(:), f_ps(:), f_mass(:), f_geopot(:), f_theta_rhodz(:), f_u(:), f_W(:), f_q(:) |
---|
60 | ! IF (is_master) PRINT *,'CALL write_output_fields_basic' |
---|
61 | |
---|
62 | CALL transfert_request(f_ps,req_i1) |
---|
63 | |
---|
64 | IF(init) THEN |
---|
65 | IF(is_master) PRINT *, 'Creating output files ...' |
---|
66 | scalar(1)=dt |
---|
67 | IF (is_omp_master) CALL xios_send_field("timestep", scalar) |
---|
68 | scalar(1)=preff |
---|
69 | IF (is_omp_master) CALL xios_send_field("preff", scalar) |
---|
70 | IF (is_omp_master) CALL xios_send_field("ap",ap) |
---|
71 | IF (is_omp_master) CALL xios_send_field("bp",bp) |
---|
72 | DO l=1,llm |
---|
73 | mid_ap(l)=(ap(l)+ap(l+1))/2 |
---|
74 | mid_bp(l)=(bp(l)+bp(l+1))/2 |
---|
75 | ENDDO |
---|
76 | IF (is_omp_master) CALL xios_send_field("mid_ap",mid_ap) |
---|
77 | IF (is_omp_master) CALL xios_send_field("mid_bp",mid_bp) |
---|
78 | |
---|
79 | CALL output_field("phis",f_phis) |
---|
80 | CALL output_field("Ai",geom%Ai) |
---|
81 | IF(is_master) PRINT *, '... done creating output files. Writing initial condition ...' |
---|
82 | END IF |
---|
83 | |
---|
84 | IF(nqdyn>1) THEN |
---|
85 | CALL divide_by_mass(2, f_mass, f_theta_rhodz, f_buf_i) |
---|
86 | IF(init) THEN |
---|
87 | CALL output_field("dyn_q_init",f_buf_i) |
---|
88 | ELSE |
---|
89 | CALL output_field("dyn_q",f_buf_i) |
---|
90 | END IF |
---|
91 | END IF |
---|
92 | |
---|
93 | CALL divide_by_mass(1, f_mass, f_theta_rhodz, f_buf_i) |
---|
94 | IF(init) THEN |
---|
95 | CALL output_field("theta_init",f_buf_i) |
---|
96 | ELSE |
---|
97 | CALL output_field("theta",f_buf_i) |
---|
98 | END IF |
---|
99 | |
---|
100 | CALL pression_mid(f_ps, f_pmid) |
---|
101 | CALL temperature(f_pmid, f_q, f_buf_i) ! f_buf_i : IN = theta, out = T |
---|
102 | |
---|
103 | IF(init) THEN |
---|
104 | CALL output_field("p_init",f_pmid) |
---|
105 | CALL output_field("ps_init",f_ps) |
---|
106 | CALL output_field("mass_init",f_mass) |
---|
107 | CALL output_field("geopot_init",f_geopot) |
---|
108 | CALL output_field("q_init",f_q) |
---|
109 | |
---|
110 | CALL output_field("temp_init",f_buf_i) |
---|
111 | ELSE |
---|
112 | CALL output_field("p",f_pmid) |
---|
113 | CALL output_field("ps",f_ps) |
---|
114 | CALL output_field("mass",f_mass) |
---|
115 | CALL output_field("geopot",f_geopot) |
---|
116 | CALL output_field("q",f_q) |
---|
117 | |
---|
118 | CALL output_field("temp",f_buf_i) |
---|
119 | CALL vertical_interp(f_pmid,f_buf_i,f_buf_s,85000.) |
---|
120 | CALL output_field("t850",f_buf_s) |
---|
121 | CALL vertical_interp(f_pmid,f_buf_i,f_buf_s,50000.) |
---|
122 | CALL output_field("t500",f_buf_s) |
---|
123 | CALL vertical_interp(f_pmid,f_buf_i,f_buf_s,preff) |
---|
124 | CALL output_field("SST",f_buf_s) |
---|
125 | END IF |
---|
126 | |
---|
127 | IF(grid_type == grid_unst) RETURN |
---|
128 | |
---|
129 | CALL velocity(f_geopot, f_ps, f_mass, f_u, f_W, f_buf_Fel, f_buf_uh, f_buf_i) |
---|
130 | CALL transfert_request(f_buf_uh,req_e1_vect) |
---|
131 | CALL un2ulonlat(f_buf_uh, f_buf_ulon, f_buf_ulat) |
---|
132 | IF(init) THEN |
---|
133 | CALL output_field("uz_init",f_buf_i) |
---|
134 | CALL output_field("ulon_init",f_buf_ulon) |
---|
135 | CALL output_field("ulat_init",f_buf_ulat) |
---|
136 | IF(is_master) PRINT *, 'Done writing initial condition ...' |
---|
137 | ELSE |
---|
138 | CALL output_field("uz",f_buf_i) |
---|
139 | CALL output_field("ulon",f_buf_ulon) |
---|
140 | CALL output_field("ulat",f_buf_ulat) |
---|
141 | |
---|
142 | ! CALL output_field("exner",f_pk) |
---|
143 | ! CALL output_field("pv",f_qv) |
---|
144 | |
---|
145 | CALL vertical_interp(f_pmid,f_buf_ulon,f_buf_s,85000.) |
---|
146 | CALL output_field("u850",f_buf_s) |
---|
147 | CALL vertical_interp(f_pmid,f_buf_ulon,f_buf_s,50000.) |
---|
148 | CALL output_field("u500",f_buf_s) |
---|
149 | |
---|
150 | CALL vertical_interp(f_pmid,f_buf_ulat,f_buf_s,85000.) |
---|
151 | CALL output_field("v850",f_buf_s) |
---|
152 | CALL vertical_interp(f_pmid,f_buf_ulat,f_buf_s,50000.) |
---|
153 | CALL output_field("v500",f_buf_s) |
---|
154 | |
---|
155 | CALL vertical_interp(f_pmid,f_buf_i,f_buf_s,85000.) |
---|
156 | CALL output_field("w850",f_buf_s) |
---|
157 | CALL vertical_interp(f_pmid,f_buf_i,f_buf_s,50000.) |
---|
158 | CALL output_field("w500",f_buf_s) |
---|
159 | |
---|
160 | CALL w_omega(f_ps, f_u, f_buf_i) |
---|
161 | CALL output_field("omega",f_buf_i) |
---|
162 | CALL vertical_interp(f_pmid,f_buf_i,f_buf_s,85000.) |
---|
163 | CALL output_field("omega850",f_buf_s) |
---|
164 | CALL vertical_interp(f_pmid,f_buf_i,f_buf_s,50000.) |
---|
165 | CALL output_field("omega500",f_buf_s) |
---|
166 | END IF |
---|
167 | |
---|
168 | CALL kinetic(f_u, f_buf_i) |
---|
169 | IF(init) THEN |
---|
170 | CALL output_field("kinetic_trisk_init",f_buf_i) |
---|
171 | ELSE |
---|
172 | CALL output_field("kinetic_trisk",f_buf_i) |
---|
173 | END IF |
---|
174 | |
---|
175 | CALL kinetic_new(f_u, f_buf_v, f_buf_i) |
---|
176 | IF(init) THEN |
---|
177 | CALL output_field("kinetic_init",f_buf_i) |
---|
178 | ELSE |
---|
179 | CALL output_field("kinetic",f_buf_i) |
---|
180 | END IF |
---|
181 | |
---|
182 | IF(.NOT. init) THEN |
---|
183 | IF(diagflux_on) THEN |
---|
184 | CALL flux_centered_lonlat(1./(itau_out*dt) , f_massfluxt, f_buf_ulon, f_buf_ulat) |
---|
185 | CALL output_field("mass_t", f_masst) |
---|
186 | CALL output_field("massflux_lon",f_buf_ulon) |
---|
187 | CALL output_field("massflux_lat",f_buf_ulat) |
---|
188 | |
---|
189 | CALL output_energyflux(f_ulont, f_ulonfluxt, "ulon_t", "ulonflux_lon", "ulonflux_lat") |
---|
190 | CALL output_energyflux(f_thetat, f_thetafluxt, "theta_t", "thetaflux_lon", "thetaflux_lat") |
---|
191 | CALL output_energyflux(f_epot, f_epotfluxt, "epot_t", "epotflux_lon", "epotflux_lat") |
---|
192 | CALL output_energyflux(f_ekin, f_ekinfluxt, "ekin_t", "ekinflux_lon", "ekinflux_lat") |
---|
193 | CALL output_energyflux(f_enthalpy, f_enthalpyfluxt, "enthalpy_t", "enthalpyflux_lon", "enthalpyflux_lat") |
---|
194 | |
---|
195 | CALL qflux_centered_lonlat(1./(itau_out*dt) , f_qfluxt, f_qfluxt_lon, f_qfluxt_lat) |
---|
196 | CALL output_field("qmass_t", f_qmasst) |
---|
197 | CALL output_field("qflux_lon",f_qfluxt_lon) |
---|
198 | CALL output_field("qflux_lat",f_qfluxt_lat) |
---|
199 | CALL zero_qfluxt ! restart accumulating fluxes |
---|
200 | END IF |
---|
201 | END IF |
---|
202 | END SUBROUTINE write_output_fields_basic |
---|
203 | |
---|
204 | SUBROUTINE output_energyflux(f_energy, f_flux, name_energy, name_fluxlon, name_fluxlat) |
---|
205 | TYPE(t_field), POINTER :: f_energy(:), f_flux(:) |
---|
206 | CHARACTER(*), INTENT(IN) :: name_energy, name_fluxlon, name_fluxlat |
---|
207 | CALL transfert_request(f_flux,req_e1_vect) |
---|
208 | CALL flux_centered_lonlat(1./(itau_out*dt) , f_flux, f_buf_ulon, f_buf_ulat) |
---|
209 | CALL output_field(name_energy, f_energy) |
---|
210 | CALL output_field(name_fluxlon, f_buf_ulon) |
---|
211 | CALL output_field(name_fluxlat, f_buf_ulat) |
---|
212 | END SUBROUTINE output_energyflux |
---|
213 | |
---|
214 | SUBROUTINE divide_by_mass(iq, f_mass, f_theta_rhodz, f_theta) |
---|
215 | INTEGER, INTENT(IN) :: iq |
---|
216 | TYPE(t_field), POINTER :: f_mass(:), f_theta_rhodz(:), f_theta(:) |
---|
217 | REAL(rstd), POINTER :: mass(:,:), theta_rhodz(:,:,:), theta(:,:) |
---|
218 | INTEGER :: ind |
---|
219 | DO ind=1,ndomain |
---|
220 | IF (.NOT. assigned_domain(ind)) CYCLE |
---|
221 | CALL swap_dimensions(ind) |
---|
222 | CALL swap_geometry(ind) |
---|
223 | mass=f_mass(ind) |
---|
224 | theta_rhodz=f_theta_rhodz(ind) |
---|
225 | theta=f_theta(ind) |
---|
226 | theta(:,:) = theta_rhodz(:,:,iq) / mass(:,:) |
---|
227 | END DO |
---|
228 | END SUBROUTINE divide_by_mass |
---|
229 | |
---|
230 | END MODULE observable_mod |
---|