[354] | 1 | MODULE observable_mod |
---|
| 2 | USE icosa |
---|
[732] | 3 | USE caldyn_vars_mod |
---|
[603] | 4 | USE diagflux_mod |
---|
| 5 | USE output_field_mod |
---|
[354] | 6 | IMPLICIT NONE |
---|
| 7 | PRIVATE |
---|
| 8 | |
---|
[374] | 9 | TYPE(t_field),POINTER, SAVE :: f_buf_i(:), & |
---|
[579] | 10 | f_buf_Fel(:), f_buf_uh(:), & ! horizontal velocity, different from prognostic velocity if NH |
---|
[598] | 11 | f_buf_ulon(:), f_buf_ulat(:) |
---|
[354] | 12 | TYPE(t_field),POINTER, SAVE :: f_buf_v(:), f_buf_s(:), f_buf_p(:) |
---|
[397] | 13 | TYPE(t_field),POINTER, SAVE :: f_pmid(:) |
---|
[354] | 14 | |
---|
| 15 | ! temporary shared variable for caldyn |
---|
| 16 | TYPE(t_field),POINTER, SAVE :: f_theta(:) |
---|
| 17 | |
---|
[714] | 18 | PUBLIC init_observable, write_output_fields_basic, & |
---|
| 19 | f_theta, f_buf_i, f_buf_ulon, f_buf_ulat |
---|
[413] | 20 | |
---|
[354] | 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") |
---|
[374] | 28 | CALL allocate_field(f_buf_uh, field_u,type_real,llm, name="buf_uh") |
---|
[579] | 29 | CALL allocate_field(f_buf_Fel, field_u,type_real,llm+1, name="buf_F_el") |
---|
[374] | 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") |
---|
[354] | 32 | |
---|
[404] | 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 |
---|
[354] | 35 | END SUBROUTINE init_observable |
---|
[413] | 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) |
---|
[482] | 38 | USE xios_mod |
---|
[413] | 39 | USE disvert_mod |
---|
[354] | 40 | USE wind_mod |
---|
| 41 | USE omp_para |
---|
[397] | 42 | USE time_mod |
---|
[482] | 43 | USE xios_mod |
---|
[397] | 44 | USE earth_const |
---|
[955] | 45 | USE compute_pression_mod, ONLY : pression_mid, hydrostatic_pressure |
---|
[914] | 46 | USE compute_temperature_mod |
---|
| 47 | USE compute_velocity_mod |
---|
[397] | 48 | USE vertical_interp_mod |
---|
| 49 | USE theta2theta_rhodz_mod |
---|
[919] | 50 | USE compute_omega_mod, ONLY : w_omega |
---|
[728] | 51 | USE kinetic_mod |
---|
[868] | 52 | USE grid_param |
---|
[413] | 53 | LOGICAL, INTENT(IN) :: init |
---|
| 54 | INTEGER :: l |
---|
[397] | 55 | REAL :: scalar(1) |
---|
| 56 | REAL :: mid_ap(llm) |
---|
| 57 | REAL :: mid_bp(llm) |
---|
| 58 | |
---|
[413] | 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' |
---|
[403] | 61 | |
---|
[417] | 62 | CALL transfert_request(f_ps,req_i1) |
---|
| 63 | |
---|
[413] | 64 | IF(init) THEN |
---|
[579] | 65 | IF(is_master) PRINT *, 'Creating output files ...' |
---|
[413] | 66 | scalar(1)=dt |
---|
[470] | 67 | IF (is_omp_master) CALL xios_send_field("timestep", scalar) |
---|
[413] | 68 | scalar(1)=preff |
---|
[470] | 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) |
---|
[413] | 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 |
---|
[470] | 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) |
---|
[413] | 78 | |
---|
| 79 | CALL output_field("phis",f_phis) |
---|
[579] | 80 | CALL output_field("Ai",geom%Ai) |
---|
| 81 | IF(is_master) PRINT *, '... done creating output files. Writing initial condition ...' |
---|
[413] | 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 | |
---|
[529] | 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 |
---|
[434] | 99 | |
---|
[955] | 100 | CALL hydrostatic_pressure(f_mass, f_theta_rhodz, f_ps, f_pmid) |
---|
[914] | 101 | CALL temperature(f_pmid, f_q, f_buf_i) ! f_buf_i : IN = theta, out = T |
---|
[529] | 102 | |
---|
[413] | 103 | IF(init) THEN |
---|
[906] | 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 | |
---|
[413] | 110 | CALL output_field("temp_init",f_buf_i) |
---|
| 111 | ELSE |
---|
[906] | 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 | |
---|
[413] | 118 | CALL output_field("temp",f_buf_i) |
---|
[436] | 119 | CALL vertical_interp(f_pmid,f_buf_i,f_buf_s,85000.) |
---|
[413] | 120 | CALL output_field("t850",f_buf_s) |
---|
[436] | 121 | CALL vertical_interp(f_pmid,f_buf_i,f_buf_s,50000.) |
---|
[413] | 122 | CALL output_field("t500",f_buf_s) |
---|
[436] | 123 | CALL vertical_interp(f_pmid,f_buf_i,f_buf_s,preff) |
---|
[413] | 124 | CALL output_field("SST",f_buf_s) |
---|
| 125 | END IF |
---|
[397] | 126 | |
---|
[906] | 127 | IF(grid_type == grid_unst) RETURN |
---|
| 128 | |
---|
[914] | 129 | CALL velocity(f_geopot, f_ps, f_mass, f_u, f_W, f_buf_Fel, f_buf_uh, f_buf_i) |
---|
[374] | 130 | CALL transfert_request(f_buf_uh,req_e1_vect) |
---|
| 131 | CALL un2ulonlat(f_buf_uh, f_buf_ulon, f_buf_ulat) |
---|
[413] | 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) |
---|
[579] | 136 | IF(is_master) PRINT *, 'Done writing initial condition ...' |
---|
[413] | 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) |
---|
[397] | 141 | |
---|
[413] | 142 | ! CALL output_field("exner",f_pk) |
---|
| 143 | ! CALL output_field("pv",f_qv) |
---|
| 144 | |
---|
[436] | 145 | CALL vertical_interp(f_pmid,f_buf_ulon,f_buf_s,85000.) |
---|
[413] | 146 | CALL output_field("u850",f_buf_s) |
---|
[436] | 147 | CALL vertical_interp(f_pmid,f_buf_ulon,f_buf_s,50000.) |
---|
[413] | 148 | CALL output_field("u500",f_buf_s) |
---|
| 149 | |
---|
[436] | 150 | CALL vertical_interp(f_pmid,f_buf_ulat,f_buf_s,85000.) |
---|
[413] | 151 | CALL output_field("v850",f_buf_s) |
---|
[436] | 152 | CALL vertical_interp(f_pmid,f_buf_ulat,f_buf_s,50000.) |
---|
[413] | 153 | CALL output_field("v500",f_buf_s) |
---|
[397] | 154 | |
---|
[436] | 155 | CALL vertical_interp(f_pmid,f_buf_i,f_buf_s,85000.) |
---|
[413] | 156 | CALL output_field("w850",f_buf_s) |
---|
[436] | 157 | CALL vertical_interp(f_pmid,f_buf_i,f_buf_s,50000.) |
---|
[413] | 158 | CALL output_field("w500",f_buf_s) |
---|
[397] | 159 | |
---|
[413] | 160 | CALL w_omega(f_ps, f_u, f_buf_i) |
---|
| 161 | CALL output_field("omega",f_buf_i) |
---|
[436] | 162 | CALL vertical_interp(f_pmid,f_buf_i,f_buf_s,85000.) |
---|
[413] | 163 | CALL output_field("omega850",f_buf_s) |
---|
[436] | 164 | CALL vertical_interp(f_pmid,f_buf_i,f_buf_s,50000.) |
---|
[413] | 165 | CALL output_field("omega500",f_buf_s) |
---|
| 166 | END IF |
---|
[397] | 167 | |
---|
[728] | 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 | |
---|
[588] | 182 | IF(.NOT. init) THEN |
---|
| 183 | IF(diagflux_on) THEN |
---|
[594] | 184 | CALL flux_centered_lonlat(1./(itau_out*dt) , f_massfluxt, f_buf_ulon, f_buf_ulat) |
---|
[592] | 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) |
---|
[595] | 188 | |
---|
[603] | 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") |
---|
[595] | 194 | |
---|
[594] | 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) |
---|
[588] | 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 |
---|
[354] | 202 | END SUBROUTINE write_output_fields_basic |
---|
[603] | 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 |
---|
[354] | 213 | |
---|
[413] | 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 | |
---|
[354] | 230 | END MODULE observable_mod |
---|