158 | | REAL(dp) :: averaging_angle = 0.0_dp !< latitudal and longitudal width of averaging regions [rad] |
159 | | REAL(dp) :: averaging_width_ns = 0.0_dp !< longitudal width of averaging regions [m] |
160 | | REAL(dp) :: averaging_width_ew = 0.0_dp !< latitudal width of averaging regions [m] |
161 | | REAL(dp) :: phi_equat = 0.0_dp !< latitude of rotated equator of COSMO-DE grid [rad] |
162 | | REAL(dp) :: phi_n = 0.0_dp !< latitude of rotated pole of COSMO-DE grid [rad] |
163 | | REAL(dp) :: lambda_n = 0.0_dp !< longitude of rotaded pole of COSMO-DE grid [rad] |
164 | | REAL(dp) :: phi_c = 0.0_dp !< rotated-grid latitude of the center of the PALM domain [rad] |
165 | | REAL(dp) :: lambda_c = 0.0_dp !< rotated-grid longitude of the centre of the PALM domain [rad] |
166 | | REAL(dp) :: phi_cn = 0.0_dp !< latitude of the rotated pole relative to the COSMO-DE grid [rad] |
167 | | REAL(dp) :: lambda_cn = 0.0_dp !< longitude of the rotated pole relative to the COSMO-DE grid [rad] |
168 | | REAL(dp) :: lam_centre = 0.0_dp !< longitude of the PLAM domain centre in the source (COSMO rotated-pole) system [rad] |
169 | | REAL(dp) :: phi_centre = 0.0_dp !< latitude of the PLAM domain centre in the source (COSMO rotated-pole) system [rad] |
170 | | REAL(dp) :: lam_east = 0.0_dp !< longitude of the east central-averaging-domain boundary in the source (COSMO rotated-pole) system [rad] |
171 | | REAL(dp) :: lam_west = 0.0_dp !< longitude of the west central-averaging-domain boundary in the source (COSMO rotated-pole) system [rad] |
172 | | REAL(dp) :: phi_north = 0.0_dp !< latitude of the north central-averaging-domain boundary in the source (COSMO rotated-pole) system [rad] |
173 | | REAL(dp) :: phi_south = 0.0_dp !< latitude of the south central-averaging-domain boundary in the source (COSMO rotated-pole) system [rad] |
174 | | REAL(dp) :: gam = 0.0_dp !< angle for working around phirot2phi/rlarot2rla bug |
175 | | REAL(dp) :: dx = 0.0_dp !< PALM-4U grid spacing in x direction [m] |
176 | | REAL(dp) :: dy = 0.0_dp !< PALM-4U grid spacing in y direction [m] |
177 | | REAL(dp) :: dz(10) = -1.0_dp !< PALM-4U grid spacing in z direction [m] |
178 | | REAL(dp) :: dz_max = 1000.0_dp !< maximum vertical grid spacing [m] |
179 | | REAL(dp) :: dz_stretch_factor = 1.08_dp !< factor for vertical grid stretching [m] |
180 | | REAL(dp) :: dz_stretch_level = -9999999.9_dp!< height above which the vertical grid will be stretched [m] |
181 | | REAL(dp) :: dz_stretch_level_start(9) = -9999999.9_dp !< namelist parameter |
182 | | REAL(dp) :: dz_stretch_level_end(9) = 9999999.9_dp !< namelist parameter |
183 | | REAL(dp) :: dz_stretch_factor_array(9) = 1.08_dp !< namelist parameter |
184 | | REAL(dp) :: dxi = 0.0_dp !< inverse PALM-4U grid spacing in x direction [m^-1] |
185 | | REAL(dp) :: dyi = 0.0_dp !< inverse PALM-4U grid spacing in y direction [m^-1] |
186 | | REAL(dp) :: dzi = 0.0_dp !< inverse PALM-4U grid spacing in z direction [m^-1] |
187 | | REAL(dp) :: f3 = 0.0_dp !< Coriolis parameter |
188 | | REAL(dp) :: lx = 0.0_dp !< PALM-4U domain size in x direction [m] |
189 | | REAL(dp) :: ly = 0.0_dp !< PALM-4U domain size in y direction [m] |
190 | | REAL(dp) :: p0 = 0.0_dp !< PALM-4U surface pressure, at z0 [Pa] |
191 | | REAL(dp) :: x0 = 0.0_dp !< x coordinate of PALM-4U Earth tangent [m] |
192 | | REAL(dp) :: y0 = 0.0_dp !< y coordinate of PALM-4U Earth tangent [m] |
193 | | REAL(dp) :: z0 = 0.0_dp !< Elevation of the PALM-4U domain above sea level [m] |
194 | | REAL(dp) :: z_top = 0.0_dp !< height of the scalar top boundary [m] |
195 | | REAL(dp) :: zw_top = 0.0_dp !< height of the vertical velocity top boundary [m] |
196 | | REAL(dp) :: lonmin_cosmo = 0.0_dp !< Minimunm longitude of COSMO-DE's rotated-pole grid [COSMO rotated-pole rad] |
197 | | REAL(dp) :: lonmax_cosmo = 0.0_dp !< Maximum longitude of COSMO-DE's rotated-pole grid [COSMO rotated-pole rad] |
198 | | REAL(dp) :: latmin_cosmo = 0.0_dp !< Minimunm latitude of COSMO-DE's rotated-pole grid [COSMO rotated-pole rad] |
199 | | REAL(dp) :: latmax_cosmo = 0.0_dp !< Maximum latitude of COSMO-DE's rotated-pole grid [COSMO rotated-pole rad] |
200 | | REAL(dp) :: lonmin_palm = 0.0_dp !< Minimunm longitude of PALM grid [COSMO rotated-pole rad] |
201 | | REAL(dp) :: lonmax_palm = 0.0_dp !< Maximum longitude of PALM grid [COSMO rotated-pole rad] |
202 | | REAL(dp) :: latmin_palm = 0.0_dp !< Minimunm latitude of PALM grid [COSMO rotated-pole rad] |
203 | | REAL(dp) :: latmax_palm = 0.0_dp !< Maximum latitude of PALM grid [COSMO rotated-pole rad] |
204 | | REAL(dp) :: lonmin_tot = 0.0_dp !< Minimunm longitude of required COSMO data [COSMO rotated-pole rad] |
205 | | REAL(dp) :: lonmax_tot = 0.0_dp !< Maximum longitude of required COSMO data [COSMO rotated-pole rad] |
206 | | REAL(dp) :: latmin_tot = 0.0_dp !< Minimunm latitude of required COSMO data [COSMO rotated-pole rad] |
207 | | REAL(dp) :: latmax_tot = 0.0_dp !< Maximum latitude of required COSMO data [COSMO rotated-pole rad] |
208 | | REAL(dp) :: latitude = 0.0_dp !< geographical latitude of the PALM-4U origin, from inipar namelist [deg] |
209 | | REAL(dp) :: longitude = 0.0_dp !< geographical longitude of the PALM-4U origin, from inipar namelist [deg] |
210 | | REAL(dp) :: origin_lat = 0.0_dp !< geographical latitude of the PALM-4U origin, from static driver netCDF file [deg] |
211 | | REAL(dp) :: origin_lon = 0.0_dp !< geographical longitude of the PALM-4U origin, from static driver netCDF file [deg] |
212 | | REAL(dp) :: rotation_angle = 0.0_dp !< clockwise angle the PALM-4U north is rotated away from geographical north [deg] |
213 | | REAL(dp) :: end_time = 0.0_dp !< PALM-4U simulation time [s] |
214 | | |
215 | | REAL(dp), DIMENSION(:,:,:), ALLOCATABLE, TARGET :: hhl !< heights of half layers (cell faces) above sea level in COSMO-DE, read in from external file |
216 | | REAL(dp), DIMENSION(:,:,:), ALLOCATABLE, TARGET :: hfl !< heights of full layers (cell centres) above sea level in COSMO-DE, computed as arithmetic average of hhl |
217 | | REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET :: depths !< COSMO-DE's TERRA-ML soil layer depths |
218 | | REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET :: d_depth !< COSMO-DE's TERRA-ML soil layer thicknesses |
219 | | REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET :: d_depth_rho_inv !< inverted soil water mass |
220 | | REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET :: rlon !< longitudes of COSMO-DE's rotated-pole grid |
221 | | REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET :: rlat !< latitudes of COSMO-DE's rotated-pole grid |
222 | | REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET :: time !< output times |
223 | | REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET :: x !< base palm grid x coordinate vector pointed to by grid_definitions |
224 | | REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET :: xu !< base palm grid xu coordinate vector pointed to by grid_definitions |
225 | | REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET :: y !< base palm grid y coordinate vector pointed to by grid_definitions |
226 | | REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET :: yv !< base palm grid yv coordinate vector pointed to by grid_definitions |
227 | | REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET :: z_column !< base palm grid z coordinate vector including the top boundary coordinate (entire column) |
228 | | REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET :: zw_column !< base palm grid zw coordinate vector including the top boundary coordinate (entire column) |
229 | | REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET :: z !< base palm grid z coordinate vector pointed to by grid_definitions |
230 | | REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET :: zw !< base palm grid zw coordinate vector pointed to by grid_definitions |
231 | | |
232 | | INTEGER(hp), DIMENSION(:,:,:), ALLOCATABLE, TARGET :: soiltyp !< COSMO-DE soil type map |
| 164 | REAL(wp) :: averaging_angle = 0.0_wp !< latitudal and longitudal width of averaging regions [rad] |
| 165 | REAL(wp) :: averaging_width_ns = 0.0_wp !< longitudal width of averaging regions [m] |
| 166 | REAL(wp) :: averaging_width_ew = 0.0_wp !< latitudal width of averaging regions [m] |
| 167 | REAL(wp) :: phi_equat = 0.0_wp !< latitude of rotated equator of COSMO-DE grid [rad] |
| 168 | REAL(wp) :: phi_n = 0.0_wp !< latitude of rotated pole of COSMO-DE grid [rad] |
| 169 | REAL(wp) :: lambda_n = 0.0_wp !< longitude of rotaded pole of COSMO-DE grid [rad] |
| 170 | REAL(wp) :: phi_c = 0.0_wp !< rotated-grid latitude of the center of the PALM domain [rad] |
| 171 | REAL(wp) :: lambda_c = 0.0_wp !< rotated-grid longitude of the centre of the PALM domain [rad] |
| 172 | REAL(wp) :: phi_cn = 0.0_wp !< latitude of the rotated pole relative to the COSMO-DE grid [rad] |
| 173 | REAL(wp) :: lambda_cn = 0.0_wp !< longitude of the rotated pole relative to the COSMO-DE grid [rad] |
| 174 | REAL(wp) :: lam_centre = 0.0_wp !< longitude of the PLAM domain centre in the source (COSMO rotated-pole) system [rad] |
| 175 | REAL(wp) :: phi_centre = 0.0_wp !< latitude of the PLAM domain centre in the source (COSMO rotated-pole) system [rad] |
| 176 | REAL(wp) :: lam_east = 0.0_wp !< longitude of the east central-averaging-domain boundary in the source (COSMO rotated-pole) system [rad] |
| 177 | REAL(wp) :: lam_west = 0.0_wp !< longitude of the west central-averaging-domain boundary in the source (COSMO rotated-pole) system [rad] |
| 178 | REAL(wp) :: phi_north = 0.0_wp !< latitude of the north central-averaging-domain boundary in the source (COSMO rotated-pole) system [rad] |
| 179 | REAL(wp) :: phi_south = 0.0_wp !< latitude of the south central-averaging-domain boundary in the source (COSMO rotated-pole) system [rad] |
| 180 | REAL(wp) :: gam = 0.0_wp !< angle for working around phirot2phi/rlarot2rla bug |
| 181 | REAL(wp) :: dx = 0.0_wp !< PALM-4U grid spacing in x direction [m] |
| 182 | REAL(wp) :: dy = 0.0_wp !< PALM-4U grid spacing in y direction [m] |
| 183 | REAL(wp) :: dz(10) = -1.0_wp !< PALM-4U grid spacing in z direction [m] |
| 184 | REAL(wp) :: dz_max = 1000.0_wp !< maximum vertical grid spacing [m] |
| 185 | REAL(wp) :: dz_stretch_factor = 1.08_wp !< factor for vertical grid stretching [m] |
| 186 | REAL(wp) :: dz_stretch_level = -9999999.9_wp!< height above which the vertical grid will be stretched [m] |
| 187 | REAL(wp) :: dz_stretch_level_start(9) = -9999999.9_wp !< namelist parameter |
| 188 | REAL(wp) :: dz_stretch_level_end(9) = 9999999.9_wp !< namelist parameter |
| 189 | REAL(wp) :: dz_stretch_factor_array(9) = 1.08_wp !< namelist parameter |
| 190 | REAL(wp) :: dxi = 0.0_wp !< inverse PALM-4U grid spacing in x direction [m^-1] |
| 191 | REAL(wp) :: dyi = 0.0_wp !< inverse PALM-4U grid spacing in y direction [m^-1] |
| 192 | REAL(wp) :: dzi = 0.0_wp !< inverse PALM-4U grid spacing in z direction [m^-1] |
| 193 | REAL(wp) :: f3 = 0.0_wp !< Coriolis parameter |
| 194 | REAL(wp) :: lx = 0.0_wp !< PALM-4U domain size in x direction [m] |
| 195 | REAL(wp) :: ly = 0.0_wp !< PALM-4U domain size in y direction [m] |
| 196 | REAL(wp) :: p0 = 0.0_wp !< PALM-4U surface pressure, at z0 [Pa] |
| 197 | REAL(wp) :: x0 = 0.0_wp !< x coordinate of PALM-4U Earth tangent [m] |
| 198 | REAL(wp) :: y0 = 0.0_wp !< y coordinate of PALM-4U Earth tangent [m] |
| 199 | REAL(wp) :: z0 = 0.0_wp !< Elevation of the PALM-4U domain above sea level [m] |
| 200 | REAL(wp) :: z_top = 0.0_wp !< height of the scalar top boundary [m] |
| 201 | REAL(wp) :: zw_top = 0.0_wp !< height of the vertical velocity top boundary [m] |
| 202 | REAL(wp) :: lonmin_cosmo = 0.0_wp !< Minimunm longitude of COSMO-DE's rotated-pole grid [COSMO rotated-pole rad] |
| 203 | REAL(wp) :: lonmax_cosmo = 0.0_wp !< Maximum longitude of COSMO-DE's rotated-pole grid [COSMO rotated-pole rad] |
| 204 | REAL(wp) :: latmin_cosmo = 0.0_wp !< Minimunm latitude of COSMO-DE's rotated-pole grid [COSMO rotated-pole rad] |
| 205 | REAL(wp) :: latmax_cosmo = 0.0_wp !< Maximum latitude of COSMO-DE's rotated-pole grid [COSMO rotated-pole rad] |
| 206 | REAL(wp) :: lonmin_palm = 0.0_wp !< Minimunm longitude of PALM grid [COSMO rotated-pole rad] |
| 207 | REAL(wp) :: lonmax_palm = 0.0_wp !< Maximum longitude of PALM grid [COSMO rotated-pole rad] |
| 208 | REAL(wp) :: latmin_palm = 0.0_wp !< Minimunm latitude of PALM grid [COSMO rotated-pole rad] |
| 209 | REAL(wp) :: latmax_palm = 0.0_wp !< Maximum latitude of PALM grid [COSMO rotated-pole rad] |
| 210 | REAL(wp) :: lonmin_tot = 0.0_wp !< Minimunm longitude of required COSMO data [COSMO rotated-pole rad] |
| 211 | REAL(wp) :: lonmax_tot = 0.0_wp !< Maximum longitude of required COSMO data [COSMO rotated-pole rad] |
| 212 | REAL(wp) :: latmin_tot = 0.0_wp !< Minimunm latitude of required COSMO data [COSMO rotated-pole rad] |
| 213 | REAL(wp) :: latmax_tot = 0.0_wp !< Maximum latitude of required COSMO data [COSMO rotated-pole rad] |
| 214 | REAL(wp) :: latitude = 0.0_wp !< geographical latitude of the PALM-4U origin, from inipar namelist [deg] |
| 215 | REAL(wp) :: longitude = 0.0_wp !< geographical longitude of the PALM-4U origin, from inipar namelist [deg] |
| 216 | REAL(wp) :: origin_lat = 0.0_wp !< geographical latitude of the PALM-4U origin, from static driver netCDF file [deg] |
| 217 | REAL(wp) :: origin_lon = 0.0_wp !< geographical longitude of the PALM-4U origin, from static driver netCDF file [deg] |
| 218 | REAL(wp) :: rotation_angle = 0.0_wp !< clockwise angle the PALM-4U north is rotated away from geographical north [deg] |
| 219 | REAL(wp) :: end_time = 0.0_wp !< PALM-4U simulation time [s] |
| 220 | |
| 221 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET :: hhl !< heights of half layers (cell faces) above sea level in COSMO-DE, read in from external file |
| 222 | REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET :: hfl !< heights of full layers (cell centres) above sea level in COSMO-DE, computed as arithmetic average of hhl |
| 223 | REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET :: depths !< COSMO-DE's TERRA-ML soil layer depths |
| 224 | REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET :: d_depth !< COSMO-DE's TERRA-ML soil layer thicknesses |
| 225 | REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET :: d_depth_rho_inv !< inverted soil water mass |
| 226 | REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET :: rlon !< longitudes of COSMO-DE's rotated-pole grid |
| 227 | REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET :: rlat !< latitudes of COSMO-DE's rotated-pole grid |
| 228 | REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET :: time !< output times |
| 229 | REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET :: x !< base palm grid x coordinate vector pointed to by grid_definitions |
| 230 | REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET :: xu !< base palm grid xu coordinate vector pointed to by grid_definitions |
| 231 | REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET :: y !< base palm grid y coordinate vector pointed to by grid_definitions |
| 232 | REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET :: yv !< base palm grid yv coordinate vector pointed to by grid_definitions |
| 233 | REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET :: z_column !< base palm grid z coordinate vector including the top boundary coordinate (entire column) |
| 234 | REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET :: zw_column !< base palm grid zw coordinate vector including the top boundary coordinate (entire column) |
| 235 | REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET :: z !< base palm grid z coordinate vector pointed to by grid_definitions |
| 236 | REAL(wp), DIMENSION(:), ALLOCATABLE, TARGET :: zw !< base palm grid zw coordinate vector pointed to by grid_definitions |
| 237 | |
| 238 | INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE, TARGET :: soiltyp !< COSMO-DE soil type map |
409 | | !-- Set default paths and modes |
410 | | cfg % input_path = './' |
411 | | cfg % hhl_file = '' |
412 | | cfg % soiltyp_file = '' |
413 | | cfg % namelist_file = './namelist' |
414 | | cfg % static_driver_file = '' |
415 | | cfg % output_file = './palm-4u-input.nc' |
416 | | cfg % ic_mode = 'volume' |
417 | | cfg % bc_mode = 'real' |
418 | | cfg % averaging_mode = 'level' |
419 | | |
420 | | ! |
421 | | !-- Overwrite defaults with user configuration |
422 | | CALL parse_command_line_arguments( cfg ) |
423 | | CALL report('main_loop', 'Running INIFOR version ' // VERSION) |
424 | | |
425 | | flow_prefix = TRIM(cfg % input_prefix) |
426 | | radiation_prefix = TRIM(cfg % input_prefix) |
427 | | soil_prefix = TRIM(cfg % input_prefix) |
428 | | soilmoisture_prefix = TRIM(cfg % input_prefix) |
429 | | IF (cfg % flow_prefix_is_set) flow_prefix = TRIM(cfg % flow_prefix) |
430 | | IF (cfg % radiation_prefix_is_set) radiation_prefix = TRIM(cfg % radiation_prefix) |
431 | | IF (cfg % soil_prefix_is_set) soil_prefix = TRIM(cfg % soil_prefix) |
432 | | IF (cfg % soilmoisture_prefix_is_set) soilmoisture_prefix = TRIM(cfg % soilmoisture_prefix) |
433 | | |
434 | | output_file % name = cfg % output_file |
435 | | z0 = cfg % z0 |
436 | | p0 = cfg % p0 |
437 | | |
438 | | init_variables_required = .TRUE. |
439 | | boundary_variables_required = TRIM( cfg % bc_mode ) == 'real' |
440 | | ls_forcing_variables_required = TRIM( cfg % bc_mode ) == 'ideal' |
441 | | surface_forcing_required = .FALSE. |
442 | | |
443 | | IF ( ls_forcing_variables_required ) THEN |
444 | | message = "Averaging of large-scale forcing profiles " // & |
445 | | "has not been implemented, yet." |
446 | | CALL inifor_abort('setup_parameters', message) |
447 | | ENDIF |
448 | | |
449 | | ! |
450 | | !-- Set default file paths, if not specified by user. |
451 | | CALL normalize_path(cfg % input_path) |
452 | | IF (TRIM(cfg % hhl_file) == '') cfg % hhl_file = TRIM(cfg % input_path) // 'hhl.nc' |
453 | | IF (TRIM(cfg % soiltyp_file) == '') cfg % soiltyp_file = TRIM(cfg % input_path) // 'soil.nc' |
454 | | |
455 | | CALL validate_config( cfg ) |
456 | | |
457 | | CALL report('setup_parameters', "initialization mode: " // TRIM(cfg % ic_mode)) |
458 | | CALL report('setup_parameters', " forcing mode: " // TRIM(cfg % bc_mode)) |
459 | | CALL report('setup_parameters', " averaging mode: " // TRIM(cfg % averaging_mode)) |
460 | | CALL report('setup_parameters', " averaging angle: " // real_to_str(cfg % averaging_angle)) |
461 | | CALL report('setup_parameters', " data path: " // TRIM(cfg % input_path)) |
462 | | CALL report('setup_parameters', " hhl file: " // TRIM(cfg % hhl_file)) |
463 | | CALL report('setup_parameters', " soiltyp file: " // TRIM(cfg % soiltyp_file)) |
464 | | CALL report('setup_parameters', " namelist file: " // TRIM(cfg % namelist_file)) |
465 | | CALL report('setup_parameters', " output data file: " // TRIM(output_file % name)) |
466 | | IF (cfg % debug ) CALL report('setup_parameters', " debugging mode: enabled") |
467 | | |
468 | | CALL run_control('time', 'init') |
469 | | ! |
470 | | !-- Read in namelist parameters |
471 | | OPEN(10, FILE=cfg % namelist_file) |
472 | | READ(10, NML=inipar) ! nx, ny, nz, dx, dy, dz |
473 | | READ(10, NML=d3par) ! end_time |
| 416 | !-- Set default paths and modes |
| 417 | cfg%input_path = './' |
| 418 | cfg%hhl_file = '' |
| 419 | cfg%soiltyp_file = '' |
| 420 | cfg%namelist_file = './namelist' |
| 421 | cfg%static_driver_file = '' |
| 422 | cfg%output_file = './palm-4u-input.nc' |
| 423 | cfg%ic_mode = 'volume' |
| 424 | cfg%bc_mode = 'real' |
| 425 | cfg%averaging_mode = 'level' |
| 426 | |
| 427 | ! |
| 428 | !-- Overwrite defaults with user configuration |
| 429 | CALL parse_command_line_arguments( cfg ) |
| 430 | CALL report('main_loop', 'Running INIFOR version ' // VERSION) |
| 431 | |
| 432 | flow_prefix = TRIM(cfg%input_prefix) |
| 433 | radiation_prefix = TRIM(cfg%input_prefix) |
| 434 | soil_prefix = TRIM(cfg%input_prefix) |
| 435 | soilmoisture_prefix = TRIM(cfg%input_prefix) |
| 436 | IF (cfg%flow_prefix_is_set) flow_prefix = TRIM(cfg%flow_prefix) |
| 437 | IF (cfg%radiation_prefix_is_set) radiation_prefix = TRIM(cfg%radiation_prefix) |
| 438 | IF (cfg%soil_prefix_is_set) soil_prefix = TRIM(cfg%soil_prefix) |
| 439 | IF (cfg%soilmoisture_prefix_is_set) soilmoisture_prefix = TRIM(cfg%soilmoisture_prefix) |
| 440 | |
| 441 | output_file%name = cfg%output_file |
| 442 | z0 = cfg%z0 |
| 443 | p0 = cfg%p0 |
| 444 | |
| 445 | init_variables_required = .TRUE. |
| 446 | boundary_variables_required = TRIM( cfg%bc_mode ) == 'real' |
| 447 | ls_forcing_variables_required = TRIM( cfg%bc_mode ) == 'ideal' |
| 448 | surface_forcing_required = .FALSE. |
| 449 | |
| 450 | IF ( ls_forcing_variables_required ) THEN |
| 451 | message = "Averaging of large-scale forcing profiles " // & |
| 452 | "has not been implemented, yet." |
| 453 | CALL inifor_abort('setup_parameters', message) |
| 454 | ENDIF |
| 455 | |
| 456 | ! |
| 457 | !-- Set default file paths, if not specified by user. |
| 458 | CALL normalize_path(cfg%input_path) |
| 459 | IF (TRIM(cfg%hhl_file) == '') cfg%hhl_file = TRIM(cfg%input_path) // 'hhl.nc' |
| 460 | IF (TRIM(cfg%soiltyp_file) == '') cfg%soiltyp_file = TRIM(cfg%input_path) // 'soil.nc' |
| 461 | |
| 462 | CALL validate_config( cfg ) |
| 463 | |
| 464 | CALL report('setup_parameters', "initialization mode: " // TRIM(cfg%ic_mode)) |
| 465 | CALL report('setup_parameters', " forcing mode: " // TRIM(cfg%bc_mode)) |
| 466 | CALL report('setup_parameters', " averaging mode: " // TRIM(cfg%averaging_mode)) |
| 467 | CALL report('setup_parameters', " averaging angle: " // real_to_str(cfg%averaging_angle)) |
| 468 | CALL report('setup_parameters', " data path: " // TRIM(cfg%input_path)) |
| 469 | CALL report('setup_parameters', " hhl file: " // TRIM(cfg%hhl_file)) |
| 470 | CALL report('setup_parameters', " soiltyp file: " // TRIM(cfg%soiltyp_file)) |
| 471 | CALL report('setup_parameters', " namelist file: " // TRIM(cfg%namelist_file)) |
| 472 | CALL report('setup_parameters', " output data file: " // TRIM(output_file%name)) |
| 473 | IF (cfg%debug ) CALL report('setup_parameters', " debugging mode: enabled") |
| 474 | |
| 475 | CALL log_runtime('time', 'init') |
| 476 | ! |
| 477 | !-- Read in namelist parameters |
| 478 | OPEN(10, FILE=cfg%namelist_file, STATUS='old') |
| 479 | READ(10, NML=inipar, IOSTAT=iostat) ! nx, ny, nz, dx, dy, dz |
| 480 | IF ( iostat > 0 ) THEN |
| 481 | message = "Failed to read namelist 'inipar' from file '" // & |
| 482 | TRIM( cfg%namelist_file ) // "'. " |
| 483 | CALL inifor_abort( 'setup_parameters', message ) |
552 | | !-- PALM-4U domain extents |
553 | | lx = (nx+1) * dx |
554 | | ly = (ny+1) * dy |
555 | | |
556 | | ! |
557 | | !-- PALM-4U point of Earth tangency |
558 | | x0 = 0.0_dp |
559 | | y0 = 0.0_dp |
560 | | |
561 | | ! |
562 | | !-- time vector |
563 | | nt = CEILING(end_time / (step_hour * 3600.0_dp)) + 1 |
564 | | ALLOCATE( time(nt) ) |
565 | | CALL linspace(0.0_dp, 3600.0_dp * (nt-1), time) |
566 | | output_file % time => time |
567 | | CALL run_control('time', 'init') |
568 | | |
569 | | ! |
570 | | !-- Convert the PALM-4U origin coordinates to COSMO's rotated-pole grid |
571 | | phi_c = TO_RADIANS * & |
572 | | phi2phirot( origin_lat * TO_DEGREES, origin_lon * TO_DEGREES,& |
573 | | phi_n * TO_DEGREES, lambda_n * TO_DEGREES ) |
574 | | lambda_c = TO_RADIANS * & |
575 | | rla2rlarot( origin_lat * TO_DEGREES, origin_lon * TO_DEGREES,& |
576 | | phi_n * TO_DEGREES, lambda_n * TO_DEGREES, & |
577 | | 0.0_dp ) |
578 | | |
579 | | ! |
580 | | !-- Set gamma according to whether PALM domain is in the northern or southern |
581 | | !-- hemisphere of the COSMO rotated-pole system. Gamma assumes either the |
582 | | !-- value 0 or PI and is needed to work around around a bug in the |
583 | | !-- rotated-pole coordinate transformations. |
584 | | gam = gamma_from_hemisphere(origin_lat, phi_equat) |
585 | | |
586 | | ! |
587 | | !-- Compute the north pole of the rotated-pole grid centred at the PALM-4U |
588 | | !-- domain centre. The resulting (phi_cn, lambda_cn) are coordinates in |
589 | | !-- COSMO-DE's rotated-pole grid. |
590 | | phi_cn = phic_to_phin(phi_c) |
591 | | lambda_cn = lamc_to_lamn(phi_c, lambda_c) |
592 | | |
593 | | message = "PALM-4U origin:" // NEW_LINE('') // & |
594 | | " lon (lambda) = " // & |
595 | | TRIM(real_to_str_f(origin_lon * TO_DEGREES)) // " deg"// NEW_LINE(' ') //& |
596 | | " lat (phi ) = " // & |
597 | | TRIM(real_to_str_f(origin_lat * TO_DEGREES)) // " deg (geographical)" // NEW_LINE(' ') //& |
598 | | " lon (lambda) = " // & |
599 | | TRIM(real_to_str_f(lambda_c * TO_DEGREES)) // " deg" // NEW_LINE(' ') // & |
600 | | " lat (phi ) = " // & |
601 | | TRIM(real_to_str_f(phi_c * TO_DEGREES)) // " deg (COSMO-DE rotated-pole)" |
602 | | CALL report ('setup_parameters', message) |
603 | | |
604 | | message = "North pole of the rotated COSMO-DE system:" // NEW_LINE(' ') // & |
605 | | " lon (lambda) = " // & |
606 | | TRIM(real_to_str_f(lambda_n * TO_DEGREES)) // " deg" // NEW_LINE(' ') //& |
607 | | " lat (phi ) = " // & |
608 | | TRIM(real_to_str_f(phi_n * TO_DEGREES)) // " deg (geographical)" |
609 | | CALL report ('setup_parameters', message) |
610 | | |
611 | | message = "North pole of the rotated palm system:" // NEW_LINE(' ') // & |
612 | | " lon (lambda) = " // & |
613 | | TRIM(real_to_str_f(lambda_cn * TO_DEGREES)) // " deg" // NEW_LINE(' ') // & |
614 | | " lat (phi ) = " // & |
615 | | TRIM(real_to_str_f(phi_cn * TO_DEGREES)) // " deg (COSMO-DE rotated-pole)" |
616 | | CALL report ('setup_parameters', message) |
617 | | |
618 | | CALL run_control('time', 'comp') |
| 573 | !-- PALM-4U domain extents |
| 574 | lx = (nx+1) * dx |
| 575 | ly = (ny+1) * dy |
| 576 | |
| 577 | ! |
| 578 | !-- PALM-4U point of Earth tangency |
| 579 | x0 = 0.0_wp |
| 580 | y0 = 0.0_wp |
| 581 | |
| 582 | ! |
| 583 | !-- time vector |
| 584 | nt = CEILING(end_time / (step_hour * 3600.0_wp)) + 1 |
| 585 | ALLOCATE( time(nt) ) |
| 586 | CALL linspace(0.0_wp, 3600.0_wp * (nt-1), time) |
| 587 | output_file%time => time |
| 588 | CALL log_runtime('time', 'init') |
| 589 | |
| 590 | ! |
| 591 | !-- Convert the PALM-4U origin coordinates to COSMO's rotated-pole grid |
| 592 | phi_c = TO_RADIANS * & |
| 593 | phi2phirot( origin_lat * TO_DEGREES, origin_lon * TO_DEGREES,& |
| 594 | phi_n * TO_DEGREES, lambda_n * TO_DEGREES ) |
| 595 | lambda_c = TO_RADIANS * & |
| 596 | rla2rlarot( origin_lat * TO_DEGREES, origin_lon * TO_DEGREES,& |
| 597 | phi_n * TO_DEGREES, lambda_n * TO_DEGREES, & |
| 598 | 0.0_wp ) |
| 599 | |
| 600 | ! |
| 601 | !-- Set gamma according to whether PALM domain is in the northern or southern |
| 602 | !-- hemisphere of the COSMO rotated-pole system. Gamma assumes either the |
| 603 | !-- value 0 or PI and is needed to work around around a bug in the |
| 604 | !-- rotated-pole coordinate transformations. |
| 605 | gam = gamma_from_hemisphere(origin_lat, phi_equat) |
| 606 | |
| 607 | ! |
| 608 | !-- Compute the north pole of the rotated-pole grid centred at the PALM-4U |
| 609 | !-- domain centre. The resulting (phi_cn, lambda_cn) are coordinates in |
| 610 | !-- COSMO-DE's rotated-pole grid. |
| 611 | phi_cn = phic_to_phin(phi_c) |
| 612 | lambda_cn = lamc_to_lamn(phi_c, lambda_c) |
| 613 | |
| 614 | message = "PALM-4U origin:" // NEW_LINE('') // & |
| 615 | " lon (lambda) = " // & |
| 616 | TRIM(real_to_str_f(origin_lon * TO_DEGREES)) // " deg"// NEW_LINE(' ') //& |
| 617 | " lat (phi ) = " // & |
| 618 | TRIM(real_to_str_f(origin_lat * TO_DEGREES)) // " deg (geographical)" // NEW_LINE(' ') //& |
| 619 | " lon (lambda) = " // & |
| 620 | TRIM(real_to_str_f(lambda_c * TO_DEGREES)) // " deg" // NEW_LINE(' ') // & |
| 621 | " lat (phi ) = " // & |
| 622 | TRIM(real_to_str_f(phi_c * TO_DEGREES)) // " deg (COSMO-DE rotated-pole)" |
| 623 | CALL report ('setup_parameters', message) |
| 624 | |
| 625 | message = "North pole of the rotated COSMO-DE system:" // NEW_LINE(' ') // & |
| 626 | " lon (lambda) = " // & |
| 627 | TRIM(real_to_str_f(lambda_n * TO_DEGREES)) // " deg" // NEW_LINE(' ') //& |
| 628 | " lat (phi ) = " // & |
| 629 | TRIM(real_to_str_f(phi_n * TO_DEGREES)) // " deg (geographical)" |
| 630 | CALL report ('setup_parameters', message) |
| 631 | |
| 632 | message = "North pole of the rotated palm system:" // NEW_LINE(' ') // & |
| 633 | " lon (lambda) = " // & |
| 634 | TRIM(real_to_str_f(lambda_cn * TO_DEGREES)) // " deg" // NEW_LINE(' ') // & |
| 635 | " lat (phi ) = " // & |
| 636 | TRIM(real_to_str_f(phi_cn * TO_DEGREES)) // " deg (COSMO-DE rotated-pole)" |
| 637 | CALL report ('setup_parameters', message) |
| 638 | |
| 639 | CALL log_runtime('time', 'comp') |
727 | | CALL init_grid_definition('palm', grid=palm_grid, & |
728 | | xmin=0.0_dp, xmax=lx, & |
729 | | ymin=0.0_dp, ymax=ly, & |
730 | | x0=x0, y0=y0, z0=z0, & |
731 | | nx=nx, ny=ny, nz=nz, z=z, zw=zw, ic_mode=cfg % ic_mode) |
732 | | |
733 | | ! |
734 | | !-- Subtracting 1 because arrays will be allocated with nlon + 1 elements. |
735 | | CALL init_grid_definition('cosmo-de', grid=cosmo_grid, & |
736 | | xmin=lonmin_cosmo, xmax=lonmax_cosmo, & |
737 | | ymin=latmin_cosmo, ymax=latmax_cosmo, & |
738 | | x0=x0, y0=y0, z0=0.0_dp, & |
739 | | nx=nlon-1, ny=nlat-1, nz=nlev-1) |
740 | | |
741 | | ! |
742 | | !-- Define intermediate grid. This is the same as palm_grid except with a |
743 | | !-- much coarser vertical grid. The vertical levels are interpolated in each |
744 | | !-- PALM column from COSMO's secondary levels. The main levels are then |
745 | | !-- computed as the averages of the bounding secondary levels. |
746 | | CALL init_grid_definition('palm intermediate', grid=palm_intermediate, & |
747 | | xmin=0.0_dp, xmax=lx, & |
748 | | ymin=0.0_dp, ymax=ly, & |
749 | | x0=x0, y0=y0, z0=z0, & |
750 | | nx=nx, ny=ny, nz=nlev-2) |
751 | | |
752 | | CALL init_grid_definition('boundary', grid=u_initial_grid, & |
| 748 | CALL init_grid_definition('palm', grid=palm_grid, & |
| 749 | xmin=0.0_wp, xmax=lx, & |
| 750 | ymin=0.0_wp, ymax=ly, & |
| 751 | x0=x0, y0=y0, z0=z0, & |
| 752 | nx=nx, ny=ny, nz=nz, z=z, zw=zw, ic_mode=cfg%ic_mode) |
| 753 | |
| 754 | ! |
| 755 | !-- Subtracting 1 because arrays will be allocated with nlon + 1 elements. |
| 756 | CALL init_grid_definition('cosmo-de', grid=cosmo_grid, & |
| 757 | xmin=lonmin_cosmo, xmax=lonmax_cosmo, & |
| 758 | ymin=latmin_cosmo, ymax=latmax_cosmo, & |
| 759 | x0=x0, y0=y0, z0=0.0_wp, & |
| 760 | nx=nlon-1, ny=nlat-1, nz=nlev-1) |
| 761 | |
| 762 | ! |
| 763 | !-- Define intermediate grid. This is the same as palm_grid except with a |
| 764 | !-- much coarser vertical grid. The vertical levels are interpolated in each |
| 765 | !-- PALM column from COSMO's secondary levels. The main levels are then |
| 766 | !-- computed as the averages of the bounding secondary levels. |
| 767 | CALL init_grid_definition('palm intermediate', grid=palm_intermediate, & |
| 768 | xmin=0.0_wp, xmax=lx, & |
| 769 | ymin=0.0_wp, ymax=ly, & |
| 770 | x0=x0, y0=y0, z0=z0, & |
| 771 | nx=nx, ny=ny, nz=nlev-2) |
| 772 | |
| 773 | CALL init_grid_definition('boundary', grid=u_initial_grid, & |
| 774 | xmin = dx, xmax = lx - dx, & |
| 775 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 776 | x0=x0, y0=y0, z0 = z0, & |
| 777 | nx = nx-1, ny = ny, nz = nz, & |
| 778 | z=z, ic_mode=cfg%ic_mode) |
| 779 | |
| 780 | CALL init_grid_definition('boundary', grid=v_initial_grid, & |
| 781 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 782 | ymin = dy, ymax = ly - dy, & |
| 783 | x0=x0, y0=y0, z0 = z0, & |
| 784 | nx = nx, ny = ny-1, nz = nz, & |
| 785 | z=z, ic_mode=cfg%ic_mode) |
| 786 | |
| 787 | CALL init_grid_definition('boundary', grid=w_initial_grid, & |
| 788 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 789 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 790 | x0=x0, y0=y0, z0 = z0, & |
| 791 | nx = nx, ny = ny, nz = nz-1, & |
| 792 | z=zw, ic_mode=cfg%ic_mode) |
| 793 | |
| 794 | CALL init_grid_definition('boundary intermediate', grid=u_initial_intermediate, & |
| 795 | xmin = dx, xmax = lx - dx, & |
| 796 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 797 | x0=x0, y0=y0, z0 = z0, & |
| 798 | nx = nx-1, ny = ny, nz = nlev - 2) |
| 799 | |
| 800 | CALL init_grid_definition('boundary intermediate', grid=v_initial_intermediate, & |
| 801 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 802 | ymin = dy, ymax = ly - dy, & |
| 803 | x0=x0, y0=y0, z0 = z0, & |
| 804 | nx = nx, ny = ny-1, nz = nlev - 2) |
| 805 | |
| 806 | CALL init_grid_definition('boundary intermediate', grid=w_initial_intermediate, & |
| 807 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 808 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 809 | x0=x0, y0=y0, z0 = z0, & |
| 810 | nx = nx, ny = ny, nz = nlev - 1) |
| 811 | |
| 812 | IF (boundary_variables_required) THEN |
| 813 | ! |
| 814 | !------------------------------------------------------------------------------ |
| 815 | ! Section 2: Define PALM-4U boundary grids |
| 816 | !------------------------------------------------------------------------------ |
| 817 | CALL init_grid_definition('boundary', grid=scalars_east_grid, & |
| 818 | xmin = lx + 0.5_wp * dx, xmax = lx + 0.5_wp * dx, & |
| 819 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 820 | x0=x0, y0=y0, z0 = z0, & |
| 821 | nx = 0, ny = ny, nz = nz, z=z) |
| 822 | |
| 823 | CALL init_grid_definition('boundary', grid=scalars_west_grid, & |
| 824 | xmin = -0.5_wp * dx, xmax = -0.5_wp * dx, & |
| 825 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 826 | x0=x0, y0=y0, z0 = z0, & |
| 827 | nx = 0, ny = ny, nz = nz, z=z) |
| 828 | |
| 829 | CALL init_grid_definition('boundary', grid=scalars_north_grid, & |
| 830 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 831 | ymin = ly + 0.5_wp * dy, ymax = ly + 0.5_wp * dy, & |
| 832 | x0=x0, y0=y0, z0 = z0, & |
| 833 | nx = nx, ny = 0, nz = nz, z=z) |
| 834 | |
| 835 | CALL init_grid_definition('boundary', grid=scalars_south_grid, & |
| 836 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 837 | ymin = -0.5_wp * dy, ymax = -0.5_wp * dy, & |
| 838 | x0=x0, y0=y0, z0 = z0, & |
| 839 | nx = nx, ny = 0, nz = nz, z=z) |
| 840 | |
| 841 | CALL init_grid_definition('boundary', grid=scalars_top_grid, & |
| 842 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 843 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 844 | x0=x0, y0=y0, z0 = z0, & |
| 845 | nx = nx, ny = ny, nz = 1, z=(/z_top/)) |
| 846 | |
| 847 | CALL init_grid_definition('boundary', grid=u_east_grid, & |
| 848 | xmin = lx, xmax = lx, & |
| 849 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 850 | x0=x0, y0=y0, z0 = z0, & |
| 851 | nx = 0, ny = ny, nz = nz, z=z) |
| 852 | |
| 853 | CALL init_grid_definition('boundary', grid=u_west_grid, & |
| 854 | xmin = 0.0_wp, xmax = 0.0_wp, & |
| 855 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 856 | x0=x0, y0=y0, z0 = z0, & |
| 857 | nx = 0, ny = ny, nz = nz, z=z) |
| 858 | |
| 859 | CALL init_grid_definition('boundary', grid=u_north_grid, & |
770 | | nx = nx, ny = ny, nz = nz-1, & |
771 | | z=zw, ic_mode=cfg % ic_mode) |
772 | | |
773 | | CALL init_grid_definition('boundary intermediate', grid=u_initial_intermediate, & |
| 887 | nx = 0, ny = ny-1, nz = nz, z=z) |
| 888 | |
| 889 | CALL init_grid_definition('boundary', grid=v_north_grid, & |
| 890 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 891 | ymin = ly, ymax = ly, & |
| 892 | x0=x0, y0=y0, z0 = z0, & |
| 893 | nx = nx, ny = 0, nz = nz, z=z) |
| 894 | |
| 895 | CALL init_grid_definition('boundary', grid=v_south_grid, & |
| 896 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 897 | ymin = 0.0_wp, ymax = 0.0_wp, & |
| 898 | x0=x0, y0=y0, z0 = z0, & |
| 899 | nx = nx, ny = 0, nz = nz, z=z) |
| 900 | |
| 901 | CALL init_grid_definition('boundary', grid=v_top_grid, & |
| 902 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 903 | ymin = dy, ymax = ly - dy, & |
| 904 | x0=x0, y0=y0, z0 = z0, & |
| 905 | nx = nx, ny = ny-1, nz = 1, z=(/z_top/)) |
| 906 | |
| 907 | CALL init_grid_definition('boundary', grid=w_east_grid, & |
| 908 | xmin = lx + 0.5_wp * dx, xmax = lx + 0.5_wp * dx, & |
| 909 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 910 | x0=x0, y0=y0, z0 = z0, & |
| 911 | nx = 0, ny = ny, nz = nz - 1, z=zw) |
| 912 | |
| 913 | CALL init_grid_definition('boundary', grid=w_west_grid, & |
| 914 | xmin = -0.5_wp * dx, xmax = -0.5_wp * dx, & |
| 915 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 916 | x0=x0, y0=y0, z0 = z0, & |
| 917 | nx = 0, ny = ny, nz = nz - 1, z=zw) |
| 918 | |
| 919 | CALL init_grid_definition('boundary', grid=w_north_grid, & |
| 920 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 921 | ymin = ly + 0.5_wp * dy, ymax = ly + 0.5_wp * dy, & |
| 922 | x0=x0, y0=y0, z0 = z0, & |
| 923 | nx = nx, ny = 0, nz = nz - 1, z=zw) |
| 924 | |
| 925 | CALL init_grid_definition('boundary', grid=w_south_grid, & |
| 926 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 927 | ymin = -0.5_wp * dy, ymax = -0.5_wp * dy, & |
| 928 | x0=x0, y0=y0, z0 = z0, & |
| 929 | nx = nx, ny = 0, nz = nz - 1, z=zw) |
| 930 | |
| 931 | CALL init_grid_definition('boundary', grid=w_top_grid, & |
| 932 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 933 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 934 | x0=x0, y0=y0, z0 = z0, & |
| 935 | nx = nx, ny = ny, nz = 1, z=(/zw_top/)) |
| 936 | |
| 937 | CALL init_grid_definition('boundary intermediate', grid=scalars_east_intermediate, & |
| 938 | xmin = lx + 0.5_wp * dx, xmax = lx + 0.5_wp * dx, & |
| 939 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 940 | x0=x0, y0=y0, z0 = z0, & |
| 941 | nx = 0, ny = ny, nz = nlev - 2) |
| 942 | |
| 943 | CALL init_grid_definition('boundary intermediate', grid=scalars_west_intermediate, & |
| 944 | xmin = -0.5_wp * dx, xmax = -0.5_wp * dx, & |
| 945 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 946 | x0=x0, y0=y0, z0 = z0, & |
| 947 | nx = 0, ny = ny, nz = nlev - 2) |
| 948 | |
| 949 | CALL init_grid_definition('boundary intermediate', grid=scalars_north_intermediate, & |
| 950 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 951 | ymin = ly + 0.5_wp * dy, ymax = ly + 0.5_wp * dy, & |
| 952 | x0=x0, y0=y0, z0 = z0, & |
| 953 | nx = nx, ny = 0, nz = nlev - 2) |
| 954 | |
| 955 | CALL init_grid_definition('boundary intermediate', grid=scalars_south_intermediate, & |
| 956 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 957 | ymin = -0.5_wp * dy, ymax = -0.5_wp * dy, & |
| 958 | x0=x0, y0=y0, z0 = z0, & |
| 959 | nx = nx, ny = 0, nz = nlev - 2) |
| 960 | |
| 961 | CALL init_grid_definition('boundary intermediate', grid=scalars_top_intermediate, & |
| 962 | xmin = 0.5_wp * dx, xmax = lx - 0.5_wp * dx, & |
| 963 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 964 | x0=x0, y0=y0, z0 = z0, & |
| 965 | nx = nx, ny = ny, nz = nlev - 2) |
| 966 | |
| 967 | CALL init_grid_definition('boundary intermediate', grid=u_east_intermediate, & |
| 968 | xmin = lx, xmax = lx, & |
| 969 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 970 | x0=x0, y0=y0, z0 = z0, & |
| 971 | nx = 0, ny = ny, nz = nlev - 2) |
| 972 | |
| 973 | CALL init_grid_definition('boundary intermediate', grid=u_west_intermediate, & |
| 974 | xmin = 0.0_wp, xmax = 0.0_wp, & |
| 975 | ymin = 0.5_wp * dy, ymax = ly - 0.5_wp * dy, & |
| 976 | x0=x0, y0=y0, z0 = z0, & |
| 977 | nx = 0, ny = ny, nz = nlev - 2) |
| 978 | |
| 979 | CALL init_grid_definition('boundary intermediate', grid=u_north_intermediate, & |
790 | | |
791 | | IF (boundary_variables_required) THEN |
792 | | ! |
793 | | !------------------------------------------------------------------------------ |
794 | | ! Section 2: Define PALM-4U boundary grids |
795 | | !------------------------------------------------------------------------------ |
796 | | CALL init_grid_definition('boundary', grid=scalars_east_grid, & |
797 | | xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx, & |
798 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
799 | | x0=x0, y0=y0, z0 = z0, & |
800 | | nx = 0, ny = ny, nz = nz, z=z) |
801 | | |
802 | | CALL init_grid_definition('boundary', grid=scalars_west_grid, & |
803 | | xmin = -0.5_dp * dx, xmax = -0.5_dp * dx, & |
804 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
805 | | x0=x0, y0=y0, z0 = z0, & |
806 | | nx = 0, ny = ny, nz = nz, z=z) |
807 | | |
808 | | CALL init_grid_definition('boundary', grid=scalars_north_grid, & |
809 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
810 | | ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy, & |
811 | | x0=x0, y0=y0, z0 = z0, & |
812 | | nx = nx, ny = 0, nz = nz, z=z) |
813 | | |
814 | | CALL init_grid_definition('boundary', grid=scalars_south_grid, & |
815 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
816 | | ymin = -0.5_dp * dy, ymax = -0.5_dp * dy, & |
817 | | x0=x0, y0=y0, z0 = z0, & |
818 | | nx = nx, ny = 0, nz = nz, z=z) |
819 | | |
820 | | CALL init_grid_definition('boundary', grid=scalars_top_grid, & |
821 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
822 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
823 | | x0=x0, y0=y0, z0 = z0, & |
824 | | nx = nx, ny = ny, nz = 1, z=(/z_top/)) |
825 | | |
826 | | CALL init_grid_definition('boundary', grid=u_east_grid, & |
827 | | xmin = lx, xmax = lx, & |
828 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
829 | | x0=x0, y0=y0, z0 = z0, & |
830 | | nx = 0, ny = ny, nz = nz, z=z) |
831 | | |
832 | | CALL init_grid_definition('boundary', grid=u_west_grid, & |
833 | | xmin = 0.0_dp, xmax = 0.0_dp, & |
834 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
835 | | x0=x0, y0=y0, z0 = z0, & |
836 | | nx = 0, ny = ny, nz = nz, z=z) |
837 | | |
838 | | CALL init_grid_definition('boundary', grid=u_north_grid, & |
839 | | xmin = dx, xmax = lx - dx, & |
840 | | ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy, & |
841 | | x0=x0, y0=y0, z0 = z0, & |
842 | | nx = nx-1, ny = 0, nz = nz, z=z) |
843 | | |
844 | | CALL init_grid_definition('boundary', grid=u_south_grid, & |
845 | | xmin = dx, xmax = lx - dx, & |
846 | | ymin = -0.5_dp * dy, ymax = -0.5_dp * dy, & |
847 | | x0=x0, y0=y0, z0 = z0, & |
848 | | nx = nx-1, ny = 0, nz = nz, z=z) |
849 | | |
850 | | CALL init_grid_definition('boundary', grid=u_top_grid, & |
851 | | xmin = dx, xmax = lx - dx, & |
852 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
853 | | x0=x0, y0=y0, z0 = z0, & |
854 | | nx = nx-1, ny = ny, nz = 1, z=(/z_top/)) |
855 | | |
856 | | CALL init_grid_definition('boundary', grid=v_east_grid, & |
857 | | xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx, & |
858 | | ymin = dy, ymax = ly - dy, & |
859 | | x0=x0, y0=y0, z0 = z0, & |
860 | | nx = 0, ny = ny-1, nz = nz, z=z) |
861 | | |
862 | | CALL init_grid_definition('boundary', grid=v_west_grid, & |
863 | | xmin = -0.5_dp * dx, xmax = -0.5_dp * dx, & |
864 | | ymin = dy, ymax = ly - dy, & |
865 | | x0=x0, y0=y0, z0 = z0, & |
866 | | nx = 0, ny = ny-1, nz = nz, z=z) |
867 | | |
868 | | CALL init_grid_definition('boundary', grid=v_north_grid, & |
869 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
870 | | ymin = ly, ymax = ly, & |
871 | | x0=x0, y0=y0, z0 = z0, & |
872 | | nx = nx, ny = 0, nz = nz, z=z) |
873 | | |
874 | | CALL init_grid_definition('boundary', grid=v_south_grid, & |
875 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
876 | | ymin = 0.0_dp, ymax = 0.0_dp, & |
877 | | x0=x0, y0=y0, z0 = z0, & |
878 | | nx = nx, ny = 0, nz = nz, z=z) |
879 | | |
880 | | CALL init_grid_definition('boundary', grid=v_top_grid, & |
881 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
882 | | ymin = dy, ymax = ly - dy, & |
883 | | x0=x0, y0=y0, z0 = z0, & |
884 | | nx = nx, ny = ny-1, nz = 1, z=(/z_top/)) |
885 | | |
886 | | CALL init_grid_definition('boundary', grid=w_east_grid, & |
887 | | xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx, & |
888 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
889 | | x0=x0, y0=y0, z0 = z0, & |
890 | | nx = 0, ny = ny, nz = nz - 1, z=zw) |
891 | | |
892 | | CALL init_grid_definition('boundary', grid=w_west_grid, & |
893 | | xmin = -0.5_dp * dx, xmax = -0.5_dp * dx, & |
894 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
895 | | x0=x0, y0=y0, z0 = z0, & |
896 | | nx = 0, ny = ny, nz = nz - 1, z=zw) |
897 | | |
898 | | CALL init_grid_definition('boundary', grid=w_north_grid, & |
899 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
900 | | ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy, & |
901 | | x0=x0, y0=y0, z0 = z0, & |
902 | | nx = nx, ny = 0, nz = nz - 1, z=zw) |
903 | | |
904 | | CALL init_grid_definition('boundary', grid=w_south_grid, & |
905 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
906 | | ymin = -0.5_dp * dy, ymax = -0.5_dp * dy, & |
907 | | x0=x0, y0=y0, z0 = z0, & |
908 | | nx = nx, ny = 0, nz = nz - 1, z=zw) |
909 | | |
910 | | CALL init_grid_definition('boundary', grid=w_top_grid, & |
911 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
912 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
913 | | x0=x0, y0=y0, z0 = z0, & |
914 | | nx = nx, ny = ny, nz = 1, z=(/zw_top/)) |
915 | | |
916 | | CALL init_grid_definition('boundary intermediate', grid=scalars_east_intermediate, & |
917 | | xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx, & |
918 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
919 | | x0=x0, y0=y0, z0 = z0, & |
920 | | nx = 0, ny = ny, nz = nlev - 2) |
921 | | |
922 | | CALL init_grid_definition('boundary intermediate', grid=scalars_west_intermediate, & |
923 | | xmin = -0.5_dp * dx, xmax = -0.5_dp * dx, & |
924 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
925 | | x0=x0, y0=y0, z0 = z0, & |
926 | | nx = 0, ny = ny, nz = nlev - 2) |
927 | | |
928 | | CALL init_grid_definition('boundary intermediate', grid=scalars_north_intermediate, & |
929 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
930 | | ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy, & |
931 | | x0=x0, y0=y0, z0 = z0, & |
932 | | nx = nx, ny = 0, nz = nlev - 2) |
933 | | |
934 | | CALL init_grid_definition('boundary intermediate', grid=scalars_south_intermediate, & |
935 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
936 | | ymin = -0.5_dp * dy, ymax = -0.5_dp * dy, & |
937 | | x0=x0, y0=y0, z0 = z0, & |
938 | | nx = nx, ny = 0, nz = nlev - 2) |
939 | | |
940 | | CALL init_grid_definition('boundary intermediate', grid=scalars_top_intermediate, & |
941 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
942 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
943 | | x0=x0, y0=y0, z0 = z0, & |
944 | | nx = nx, ny = ny, nz = nlev - 2) |
945 | | |
946 | | CALL init_grid_definition('boundary intermediate', grid=u_east_intermediate, & |
947 | | xmin = lx, xmax = lx, & |
948 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
949 | | x0=x0, y0=y0, z0 = z0, & |
950 | | nx = 0, ny = ny, nz = nlev - 2) |
951 | | |
952 | | CALL init_grid_definition('boundary intermediate', grid=u_west_intermediate, & |
953 | | xmin = 0.0_dp, xmax = 0.0_dp, & |
954 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
955 | | x0=x0, y0=y0, z0 = z0, & |
956 | | nx = 0, ny = ny, nz = nlev - 2) |
957 | | |
958 | | CALL init_grid_definition('boundary intermediate', grid=u_north_intermediate, & |
959 | | xmin = dx, xmax = lx - dx, & |
960 | | ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy, & |
961 | | x0=x0, y0=y0, z0 = z0, & |
962 | | nx = nx-1, ny = 0, nz = nlev - 2) |
963 | | |
964 | | CALL init_grid_definition('boundary intermediate', grid=u_south_intermediate, & |
965 | | xmin = dx, xmax = lx - dx, & |
966 | | ymin = -0.5_dp * dy, ymax = -0.5_dp * dy, & |
967 | | x0=x0, y0=y0, z0 = z0, & |
968 | | nx = nx-1, ny = 0, nz = nlev - 2) |
969 | | |
970 | | CALL init_grid_definition('boundary intermediate', grid=u_top_intermediate, & |
971 | | xmin = dx, xmax = lx - dx, & |
972 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
973 | | x0=x0, y0=y0, z0 = z0, & |
974 | | nx = nx-1, ny = ny, nz = nlev - 2) |
975 | | |
976 | | CALL init_grid_definition('boundary intermediate', grid=v_east_intermediate, & |
977 | | xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx, & |
978 | | ymin = dy, ymax = ly - dy, & |
979 | | x0=x0, y0=y0, z0 = z0, & |
980 | | nx = 0, ny = ny-1, nz = nlev - 2) |
981 | | |
982 | | CALL init_grid_definition('boundary intermediate', grid=v_west_intermediate, & |
983 | | xmin = -0.5_dp * dx, xmax = -0.5_dp * dx, & |
984 | | ymin = dy, ymax = ly - dy, & |
985 | | x0=x0, y0=y0, z0 = z0, & |
986 | | nx = 0, ny = ny-1, nz = nlev - 2) |
987 | | |
988 | | CALL init_grid_definition('boundary intermediate', grid=v_north_intermediate, & |
989 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
990 | | ymin = ly, ymax = ly, & |
991 | | x0=x0, y0=y0, z0 = z0, & |
992 | | nx = nx, ny = 0, nz = nlev - 2) |
993 | | |
994 | | CALL init_grid_definition('boundary intermediate', grid=v_south_intermediate, & |
995 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
996 | | ymin = 0.0_dp, ymax = 0.0_dp, & |
997 | | x0=x0, y0=y0, z0 = z0, & |
998 | | nx = nx, ny = 0, nz = nlev - 2) |
999 | | |
1000 | | CALL init_grid_definition('boundary intermediate', grid=v_top_intermediate, & |
1001 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
1002 | | ymin = dy, ymax = ly - dy, & |
1003 | | x0=x0, y0=y0, z0 = z0, & |
1004 | | nx = nx, ny = ny-1, nz = nlev - 2) |
1005 | | |
1006 | | CALL init_grid_definition('boundary intermediate', grid=w_east_intermediate, & |
1007 | | xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx, & |
1008 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
1009 | | x0=x0, y0=y0, z0 = z0, & |
1010 | | nx = 0, ny = ny, nz = nlev - 1) |
1011 | | |
1012 | | CALL init_grid_definition('boundary intermediate', grid=w_west_intermediate, & |
1013 | | xmin = -0.5_dp * dx, xmax = -0.5_dp * dx, & |
1014 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
1015 | | x0=x0, y0=y0, z0 = z0, & |
1016 | | nx = 0, ny = ny, nz = nlev - 1) |
1017 | | |
1018 | | CALL init_grid_definition('boundary intermediate', grid=w_north_intermediate, & |
1019 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
1020 | | ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy, & |
1021 | | x0=x0, y0=y0, z0 = z0, & |
1022 | | nx = nx, ny = 0, nz = nlev - 1) |
1023 | | |
1024 | | CALL init_grid_definition('boundary intermediate', grid=w_south_intermediate, & |
1025 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
1026 | | ymin = -0.5_dp * dy, ymax = -0.5_dp * dy, & |
1027 | | x0=x0, y0=y0, z0 = z0, & |
1028 | | nx = nx, ny = 0, nz = nlev - 1) |
1029 | | |
1030 | | CALL init_grid_definition('boundary intermediate', grid=w_top_intermediate, & |
1031 | | xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx, & |
1032 | | ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy, & |
1033 | | x0=x0, y0=y0, z0 = z0, & |
1034 | | nx = nx, ny = ny, nz = nlev - 1) |
1035 | | ENDIF |
| 1056 | ENDIF |
1042 | | lonmin_palm = MINVAL(palm_intermediate % clon) |
1043 | | lonmax_palm = MAXVAL(palm_intermediate % clon) |
1044 | | latmin_palm = MINVAL(palm_intermediate % clat) |
1045 | | latmax_palm = MAXVAL(palm_intermediate % clat) |
1046 | | |
1047 | | CALL init_averaging_grid(averaged_initial_scalar_profile, cosmo_grid, & |
1048 | | x = 0.5_dp * lx, y = 0.5_dp * ly, z = z, z0 = z0, & |
1049 | | lonmin = lonmin_palm, lonmax = lonmax_palm, & |
1050 | | latmin = latmin_palm, latmax = latmax_palm, & |
1051 | | kind='scalar', name='averaged initial scalar') |
1052 | | |
1053 | | CALL init_averaging_grid(averaged_initial_w_profile, cosmo_grid, & |
1054 | | x = 0.5_dp * lx, y = 0.5_dp * ly, z = zw, z0 = z0, & |
1055 | | lonmin = lonmin_palm, lonmax = lonmax_palm, & |
1056 | | latmin = latmin_palm, latmax = latmax_palm, & |
1057 | | kind='w', name='averaged initial w') |
1058 | | |
1059 | | CALL init_averaging_grid(averaged_scalar_profile, cosmo_grid, & |
1060 | | x = 0.5_dp * lx, y = 0.5_dp * ly, z = z, z0 = z0, & |
1061 | | lonmin = lam_west, lonmax = lam_east, & |
1062 | | latmin = phi_south, latmax = phi_north, & |
1063 | | kind='scalar', name='centre geostrophic scalar') |
1064 | | |
1065 | | CALL init_averaging_grid(averaged_w_profile, cosmo_grid, & |
1066 | | x = 0.5_dp * lx, y = 0.5_dp * ly, z = zw, z0 = z0, & |
1067 | | lonmin = lam_west, lonmax = lam_east, & |
1068 | | latmin = phi_south, latmax = phi_north, & |
1069 | | kind='w', name='centre geostrophic w') |
1070 | | |
1071 | | CALL init_averaging_grid(south_averaged_scalar_profile, cosmo_grid, & |
1072 | | x = 0.5_dp * lx, y = 0.5_dp * ly, z = z, z0 = z0, & |
1073 | | lonmin = lam_west, lonmax = lam_east, & |
1074 | | latmin = phi_centre - averaging_angle, & |
1075 | | latmax = phi_centre, & |
1076 | | kind='scalar', name='south geostrophic scalar') |
1077 | | |
1078 | | CALL init_averaging_grid(north_averaged_scalar_profile, cosmo_grid, & |
1079 | | x = 0.5_dp * lx, y = 0.5_dp * ly, z = z, z0 = z0, & |
1080 | | lonmin = lam_west, lonmax = lam_east, & |
1081 | | latmin = phi_centre, & |
1082 | | latmax = phi_centre + averaging_angle, & |
1083 | | kind='scalar', name='north geostrophic scalar') |
1084 | | |
1085 | | CALL init_averaging_grid(west_averaged_scalar_profile, cosmo_grid, & |
1086 | | x = 0.5_dp * lx, y = 0.5_dp * ly, z = z, z0 = z0, & |
1087 | | lonmin = lam_centre - averaging_angle, & |
1088 | | lonmax = lam_centre, & |
1089 | | latmin = phi_south, latmax = phi_north, & |
1090 | | kind='scalar', name='west geostrophic scalar') |
1091 | | |
1092 | | CALL init_averaging_grid(east_averaged_scalar_profile, cosmo_grid, & |
1093 | | x = 0.5_dp * lx, y = 0.5_dp * ly, z = z, z0 = z0, & |
1094 | | lonmin = lam_centre, & |
1095 | | lonmax = lam_centre + averaging_angle, & |
1096 | | latmin = phi_south, latmax = phi_north, & |
1097 | | kind='scalar', name='east geostrophic scalar') |
| 1063 | lonmin_palm = MINVAL(palm_intermediate%clon) |
| 1064 | lonmax_palm = MAXVAL(palm_intermediate%clon) |
| 1065 | latmin_palm = MINVAL(palm_intermediate%clat) |
| 1066 | latmax_palm = MAXVAL(palm_intermediate%clat) |
| 1067 | |
| 1068 | CALL init_averaging_grid(averaged_initial_scalar_profile, cosmo_grid, & |
| 1069 | x = 0.5_wp * lx, y = 0.5_wp * ly, z = z, z0 = z0, & |
| 1070 | lonmin = lonmin_palm, lonmax = lonmax_palm, & |
| 1071 | latmin = latmin_palm, latmax = latmax_palm, & |
| 1072 | kind='scalar', name='averaged initial scalar') |
| 1073 | |
| 1074 | CALL init_averaging_grid(averaged_initial_w_profile, cosmo_grid, & |
| 1075 | x = 0.5_wp * lx, y = 0.5_wp * ly, z = zw, z0 = z0, & |
| 1076 | lonmin = lonmin_palm, lonmax = lonmax_palm, & |
| 1077 | latmin = latmin_palm, latmax = latmax_palm, & |
| 1078 | kind='w', name='averaged initial w') |
| 1079 | |
| 1080 | CALL init_averaging_grid(averaged_scalar_profile, cosmo_grid, & |
| 1081 | x = 0.5_wp * lx, y = 0.5_wp * ly, z = z, z0 = z0, & |
| 1082 | lonmin = lam_west, lonmax = lam_east, & |
| 1083 | latmin = phi_south, latmax = phi_north, & |
| 1084 | kind='scalar', name='centre geostrophic scalar') |
| 1085 | |
| 1086 | CALL init_averaging_grid(averaged_w_profile, cosmo_grid, & |
| 1087 | x = 0.5_wp * lx, y = 0.5_wp * ly, z = zw, z0 = z0, & |
| 1088 | lonmin = lam_west, lonmax = lam_east, & |
| 1089 | latmin = phi_south, latmax = phi_north, & |
| 1090 | kind='w', name='centre geostrophic w') |
| 1091 | |
| 1092 | CALL init_averaging_grid(south_averaged_scalar_profile, cosmo_grid, & |
| 1093 | x = 0.5_wp * lx, y = 0.5_wp * ly, z = z, z0 = z0, & |
| 1094 | lonmin = lam_west, lonmax = lam_east, & |
| 1095 | latmin = phi_centre - averaging_angle, & |
| 1096 | latmax = phi_centre, & |
| 1097 | kind='scalar', name='south geostrophic scalar') |
| 1098 | |
| 1099 | CALL init_averaging_grid(north_averaged_scalar_profile, cosmo_grid, & |
| 1100 | x = 0.5_wp * lx, y = 0.5_wp * ly, z = z, z0 = z0, & |
| 1101 | lonmin = lam_west, lonmax = lam_east, & |
| 1102 | latmin = phi_centre, & |
| 1103 | latmax = phi_centre + averaging_angle, & |
| 1104 | kind='scalar', name='north geostrophic scalar') |
| 1105 | |
| 1106 | CALL init_averaging_grid(west_averaged_scalar_profile, cosmo_grid, & |
| 1107 | x = 0.5_wp * lx, y = 0.5_wp * ly, z = z, z0 = z0, & |
| 1108 | lonmin = lam_centre - averaging_angle, & |
| 1109 | lonmax = lam_centre, & |
| 1110 | latmin = phi_south, latmax = phi_north, & |
| 1111 | kind='scalar', name='west geostrophic scalar') |
| 1112 | |
| 1113 | CALL init_averaging_grid(east_averaged_scalar_profile, cosmo_grid, & |
| 1114 | x = 0.5_wp * lx, y = 0.5_wp * ly, z = z, z0 = z0, & |
| 1115 | lonmin = lam_centre, & |
| 1116 | lonmax = lam_centre + averaging_angle, & |
| 1117 | latmin = phi_south, latmax = phi_north, & |
| 1118 | kind='scalar', name='east geostrophic scalar') |
1104 | | interp_mode = 's' |
1105 | | CALL setup_interpolation(cosmo_grid, palm_grid, palm_intermediate, interp_mode, ic_mode=cfg % ic_mode) |
1106 | | IF (boundary_variables_required) THEN |
1107 | | CALL setup_interpolation(cosmo_grid, scalars_east_grid, scalars_east_intermediate, interp_mode) |
1108 | | CALL setup_interpolation(cosmo_grid, scalars_west_grid, scalars_west_intermediate, interp_mode) |
1109 | | CALL setup_interpolation(cosmo_grid, scalars_north_grid, scalars_north_intermediate, interp_mode) |
1110 | | CALL setup_interpolation(cosmo_grid, scalars_south_grid, scalars_south_intermediate, interp_mode) |
1111 | | CALL setup_interpolation(cosmo_grid, scalars_top_grid, scalars_top_intermediate, interp_mode) |
1112 | | ENDIF |
1113 | | |
1114 | | interp_mode = 'u' |
1115 | | CALL setup_interpolation(cosmo_grid, u_initial_grid, u_initial_intermediate, interp_mode, ic_mode=cfg % ic_mode) |
1116 | | IF (boundary_variables_required) THEN |
1117 | | CALL setup_interpolation(cosmo_grid, u_east_grid, u_east_intermediate, interp_mode) |
1118 | | CALL setup_interpolation(cosmo_grid, u_west_grid, u_west_intermediate, interp_mode) |
1119 | | CALL setup_interpolation(cosmo_grid, u_north_grid, u_north_intermediate, interp_mode) |
1120 | | CALL setup_interpolation(cosmo_grid, u_south_grid, u_south_intermediate, interp_mode) |
1121 | | CALL setup_interpolation(cosmo_grid, u_top_grid, u_top_intermediate, interp_mode) |
1122 | | ENDIF |
1123 | | |
1124 | | interp_mode = 'v' |
1125 | | CALL setup_interpolation(cosmo_grid, v_initial_grid, v_initial_intermediate, interp_mode, ic_mode=cfg % ic_mode) |
1126 | | IF (boundary_variables_required) THEN |
1127 | | CALL setup_interpolation(cosmo_grid, v_east_grid, v_east_intermediate, interp_mode) |
1128 | | CALL setup_interpolation(cosmo_grid, v_west_grid, v_west_intermediate, interp_mode) |
1129 | | CALL setup_interpolation(cosmo_grid, v_north_grid, v_north_intermediate, interp_mode) |
1130 | | CALL setup_interpolation(cosmo_grid, v_south_grid, v_south_intermediate, interp_mode) |
1131 | | CALL setup_interpolation(cosmo_grid, v_top_grid, v_top_intermediate, interp_mode) |
1132 | | ENDIF |
1133 | | |
1134 | | interp_mode = 'w' |
1135 | | CALL setup_interpolation(cosmo_grid, w_initial_grid, w_initial_intermediate, interp_mode, ic_mode=cfg % ic_mode) |
1136 | | IF (boundary_variables_required) THEN |
1137 | | CALL setup_interpolation(cosmo_grid, w_east_grid, w_east_intermediate, interp_mode) |
1138 | | CALL setup_interpolation(cosmo_grid, w_west_grid, w_west_intermediate, interp_mode) |
1139 | | CALL setup_interpolation(cosmo_grid, w_north_grid, w_north_intermediate, interp_mode) |
1140 | | CALL setup_interpolation(cosmo_grid, w_south_grid, w_south_intermediate, interp_mode) |
1141 | | CALL setup_interpolation(cosmo_grid, w_top_grid, w_top_intermediate, interp_mode) |
1142 | | ENDIF |
1143 | | |
1144 | | IF (TRIM(cfg % ic_mode) == 'profile') THEN |
1145 | | !TODO: remove this conditional if not needed. |
1146 | | ENDIF |
1147 | | |
1148 | | |
1149 | | END SUBROUTINE setup_grids |
| 1125 | interp_mode = 's' |
| 1126 | CALL setup_interpolation(cosmo_grid, palm_grid, palm_intermediate, interp_mode, ic_mode=cfg%ic_mode) |
| 1127 | IF (boundary_variables_required) THEN |
| 1128 | CALL setup_interpolation(cosmo_grid, scalars_east_grid, scalars_east_intermediate, interp_mode) |
| 1129 | CALL setup_interpolation(cosmo_grid, scalars_west_grid, scalars_west_intermediate, interp_mode) |
| 1130 | CALL setup_interpolation(cosmo_grid, scalars_north_grid, scalars_north_intermediate, interp_mode) |
| 1131 | CALL setup_interpolation(cosmo_grid, scalars_south_grid, scalars_south_intermediate, interp_mode) |
| 1132 | CALL setup_interpolation(cosmo_grid, scalars_top_grid, scalars_top_intermediate, interp_mode) |
| 1133 | ENDIF |
| 1134 | |
| 1135 | interp_mode = 'u' |
| 1136 | CALL setup_interpolation(cosmo_grid, u_initial_grid, u_initial_intermediate, interp_mode, ic_mode=cfg%ic_mode) |
| 1137 | IF (boundary_variables_required) THEN |
| 1138 | CALL setup_interpolation(cosmo_grid, u_east_grid, u_east_intermediate, interp_mode) |
| 1139 | CALL setup_interpolation(cosmo_grid, u_west_grid, u_west_intermediate, interp_mode) |
| 1140 | CALL setup_interpolation(cosmo_grid, u_north_grid, u_north_intermediate, interp_mode) |
| 1141 | CALL setup_interpolation(cosmo_grid, u_south_grid, u_south_intermediate, interp_mode) |
| 1142 | CALL setup_interpolation(cosmo_grid, u_top_grid, u_top_intermediate, interp_mode) |
| 1143 | ENDIF |
| 1144 | |
| 1145 | interp_mode = 'v' |
| 1146 | CALL setup_interpolation(cosmo_grid, v_initial_grid, v_initial_intermediate, interp_mode, ic_mode=cfg%ic_mode) |
| 1147 | IF (boundary_variables_required) THEN |
| 1148 | CALL setup_interpolation(cosmo_grid, v_east_grid, v_east_intermediate, interp_mode) |
| 1149 | CALL setup_interpolation(cosmo_grid, v_west_grid, v_west_intermediate, interp_mode) |
| 1150 | CALL setup_interpolation(cosmo_grid, v_north_grid, v_north_intermediate, interp_mode) |
| 1151 | CALL setup_interpolation(cosmo_grid, v_south_grid, v_south_intermediate, interp_mode) |
| 1152 | CALL setup_interpolation(cosmo_grid, v_top_grid, v_top_intermediate, interp_mode) |
| 1153 | ENDIF |
| 1154 | |
| 1155 | interp_mode = 'w' |
| 1156 | CALL setup_interpolation(cosmo_grid, w_initial_grid, w_initial_intermediate, interp_mode, ic_mode=cfg%ic_mode) |
| 1157 | IF (boundary_variables_required) THEN |
| 1158 | CALL setup_interpolation(cosmo_grid, w_east_grid, w_east_intermediate, interp_mode) |
| 1159 | CALL setup_interpolation(cosmo_grid, w_west_grid, w_west_intermediate, interp_mode) |
| 1160 | CALL setup_interpolation(cosmo_grid, w_north_grid, w_north_intermediate, interp_mode) |
| 1161 | CALL setup_interpolation(cosmo_grid, w_south_grid, w_south_intermediate, interp_mode) |
| 1162 | CALL setup_interpolation(cosmo_grid, w_top_grid, w_top_intermediate, interp_mode) |
| 1163 | ENDIF |
| 1164 | |
| 1165 | IF (TRIM(cfg%ic_mode) == 'profile') THEN |
| 1166 | !TODO: remove this conditional if not needed. |
| 1167 | ENDIF |
| 1168 | |
| 1169 | END SUBROUTINE setup_grids |
1283 | | SUBROUTINE init_grid_definition(kind, xmin, xmax, ymin, ymax, & |
1284 | | x0, y0, z0, nx, ny, nz, z, zw, grid, ic_mode) |
1285 | | CHARACTER(LEN=*), INTENT(IN) :: kind |
1286 | | CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: ic_mode |
1287 | | INTEGER, INTENT(IN) :: nx, ny, nz |
1288 | | REAL(dp), INTENT(IN) :: xmin, xmax, ymin, ymax |
1289 | | REAL(dp), INTENT(IN) :: x0, y0, z0 |
1290 | | REAL(dp), INTENT(IN), TARGET, OPTIONAL :: z(:) |
1291 | | REAL(dp), INTENT(IN), TARGET, OPTIONAL :: zw(:) |
1292 | | TYPE(grid_definition), INTENT(INOUT) :: grid |
1293 | | |
1294 | | grid % nx = nx |
1295 | | grid % ny = ny |
1296 | | grid % nz = nz |
1297 | | |
1298 | | grid % lx = xmax - xmin |
1299 | | grid % ly = ymax - ymin |
1300 | | |
1301 | | grid % x0 = x0 |
1302 | | grid % y0 = y0 |
1303 | | grid % z0 = z0 |
1304 | | |
1305 | | SELECT CASE( TRIM(kind) ) |
1306 | | |
1307 | | CASE('boundary') |
1308 | | |
1309 | | IF (.NOT.PRESENT(z)) THEN |
1310 | | message = "z has not been passed but is required for 'boundary' grids" |
1311 | | CALL inifor_abort('init_grid_definition', message) |
1312 | | ENDIF |
1313 | | |
1314 | | ALLOCATE( grid % x(0:nx) ) |
1315 | | CALL linspace(xmin, xmax, grid % x) |
1316 | | |
1317 | | ALLOCATE( grid % y(0:ny) ) |
1318 | | CALL linspace(ymin, ymax, grid % y) |
1319 | | |
1320 | | grid % z => z |
1321 | | |
1322 | | ! |
1323 | | !-- Allocate neighbour indices and weights |
1324 | | IF (TRIM(ic_mode) .NE. 'profile') THEN |
1325 | | ALLOCATE( grid % kk(0:nx, 0:ny, 1:nz, 2) ) |
1326 | | grid % kk(:,:,:,:) = -1 |
1327 | | |
1328 | | ALLOCATE( grid % w_verti(0:nx, 0:ny, 1:nz, 2) ) |
1329 | | grid % w_verti(:,:,:,:) = 0.0_dp |
1330 | | ENDIF |
1331 | | |
1332 | | CASE('boundary intermediate') |
1333 | | |
1334 | | ALLOCATE( grid % x(0:nx) ) |
1335 | | CALL linspace(xmin, xmax, grid % x) |
1336 | | |
1337 | | ALLOCATE( grid % y(0:ny) ) |
1338 | | CALL linspace(ymin, ymax, grid % y) |
1339 | | |
1340 | | ALLOCATE( grid % clon(0:nx, 0:ny), grid % clat(0:nx, 0:ny) ) |
1341 | | |
1342 | | CALL rotate_to_cosmo( & |
1343 | | phir = project( grid % y, y0, EARTH_RADIUS ) , & ! = plate-carree latitude |
1344 | | lamr = project( grid % x, x0, EARTH_RADIUS ) , & ! = plate-carree longitude |
1345 | | phip = phi_cn, lamp = lambda_cn, & |
1346 | | phi = grid % clat, & |
1347 | | lam = grid % clon, & |
1348 | | gam = gam & |
1349 | | ) |
1350 | | |
1351 | | ! |
1352 | | !-- Allocate neighbour indices and weights |
1353 | | ALLOCATE( grid % ii(0:nx, 0:ny, 4), & |
1354 | | grid % jj(0:nx, 0:ny, 4) ) |
1355 | | grid % ii(:,:,:) = -1 |
1356 | | grid % jj(:,:,:) = -1 |
1357 | | |
1358 | | ALLOCATE( grid % w_horiz(0:nx, 0:ny, 4) ) |
1359 | | grid % w_horiz(:,:,:) = 0.0_dp |
1360 | | |
1361 | | ! |
1362 | | !-- This mode initializes a Cartesian PALM-4U grid and adds the |
1363 | | !-- corresponding latitudes and longitudes of the rotated pole grid. |
1364 | | CASE('palm') |
1365 | | |
1366 | | IF (.NOT.PRESENT(z)) THEN |
1367 | | message = "z has not been passed but is required for 'palm' grids" |
1368 | | CALL inifor_abort('init_grid_definition', message) |
1369 | | ENDIF |
1370 | | |
1371 | | IF (.NOT.PRESENT(zw)) THEN |
1372 | | message = "zw has not been passed but is required for 'palm' grids" |
1373 | | CALL inifor_abort('init_grid_definition', message) |
1374 | | ENDIF |
1375 | | |
1376 | | grid % name(1) = 'x and lon' |
1377 | | grid % name(2) = 'y and lat' |
1378 | | grid % name(3) = 'z' |
1379 | | |
1380 | | ! |
1381 | | !-- TODO: Remove use of global dx, dy, dz variables. Consider |
1382 | | !-- TODO: associating global x,y, and z arrays. |
1383 | | ALLOCATE( grid % x(0:nx), grid % y(0:ny) ) |
1384 | | ALLOCATE( grid % xu(1:nx), grid % yv(1:ny) ) |
1385 | | CALL linspace(xmin + 0.5_dp* dx, xmax - 0.5_dp* dx, grid % x) |
1386 | | CALL linspace(ymin + 0.5_dp* dy, ymax - 0.5_dp* dy, grid % y) |
1387 | | grid % z => z |
1388 | | CALL linspace(xmin + dx, xmax - dx, grid % xu) |
1389 | | CALL linspace(ymin + dy, ymax - dy, grid % yv) |
1390 | | grid % zw => zw |
1391 | | |
1392 | | grid % depths => depths |
1393 | | |
1394 | | ! |
1395 | | !-- Allocate neighbour indices and weights |
1396 | | IF (TRIM(ic_mode) .NE. 'profile') THEN |
1397 | | ALLOCATE( grid % kk(0:nx, 0:ny, 1:nz, 2) ) |
1398 | | grid % kk(:,:,:,:) = -1 |
1399 | | |
1400 | | ALLOCATE( grid % w_verti(0:nx, 0:ny, 1:nz, 2) ) |
1401 | | grid % w_verti(:,:,:,:) = 0.0_dp |
1402 | | ENDIF |
1403 | | |
1404 | | CASE('palm intermediate') |
1405 | | |
1406 | | grid % name(1) = 'x and lon' |
1407 | | grid % name(2) = 'y and lat' |
1408 | | grid % name(3) = 'interpolated hhl or hfl' |
1409 | | |
1410 | | ! |
1411 | | !-- TODO: Remove use of global dx, dy, dz variables. Consider |
1412 | | !-- TODO: associating global x,y, and z arrays. |
1413 | | ALLOCATE( grid % x(0:nx), grid % y(0:ny) ) |
1414 | | ALLOCATE( grid % xu(1:nx), grid % yv(1:ny) ) |
1415 | | CALL linspace(xmin + 0.5_dp*dx, xmax - 0.5_dp*dx, grid % x) |
1416 | | CALL linspace(ymin + 0.5_dp*dy, ymax - 0.5_dp*dy, grid % y) |
1417 | | CALL linspace(xmin + dx, xmax - dx, grid % xu) |
1418 | | CALL linspace(ymin + dy, ymax - dy, grid % yv) |
1419 | | |
1420 | | grid % depths => depths |
1421 | | |
1422 | | ! |
1423 | | !-- Allocate rotated-pole coordinates, clon is for (c)osmo-de (lon)gitude |
1424 | | ALLOCATE( grid % clon(0:nx, 0:ny), grid % clat(0:nx, 0:ny) ) |
1425 | | ALLOCATE( grid % clonu(1:nx, 0:ny), grid % clatu(1:nx, 0:ny) ) |
1426 | | ALLOCATE( grid % clonv(0:nx, 1:ny), grid % clatv(0:nx, 1:ny) ) |
1427 | | |
1428 | | ! |
1429 | | !-- Compute rotated-pole coordinates of... |
1430 | | !-- ... PALM-4U centres |
1431 | | CALL rotate_to_cosmo( & |
1432 | | phir = project( grid % y, y0, EARTH_RADIUS ) , & ! = plate-carree latitude |
1433 | | lamr = project( grid % x, x0, EARTH_RADIUS ) , & ! = plate-carree longitude |
1434 | | phip = phi_cn, lamp = lambda_cn, & |
1435 | | phi = grid % clat, & |
1436 | | lam = grid % clon, & |
1437 | | gam = gam & |
1438 | | ) |
1439 | | |
1440 | | ! |
1441 | | !-- ... PALM-4U u winds |
1442 | | CALL rotate_to_cosmo( & |
1443 | | phir = project( grid % y, y0, EARTH_RADIUS ), & ! = plate-carree latitude |
1444 | | lamr = project( grid % xu, x0, EARTH_RADIUS ), & ! = plate-carree longitude |
1445 | | phip = phi_cn, lamp = lambda_cn, & |
1446 | | phi = grid % clatu, & |
1447 | | lam = grid % clonu, & |
1448 | | gam = gam & |
1449 | | ) |
1450 | | |
1451 | | ! |
1452 | | !-- ... PALM-4U v winds |
1453 | | CALL rotate_to_cosmo( & |
1454 | | phir = project( grid % yv, y0, EARTH_RADIUS ), & ! = plate-carree latitude |
1455 | | lamr = project( grid % x, x0, EARTH_RADIUS ), & ! = plate-carree longitude |
1456 | | phip = phi_cn, lamp = lambda_cn, & |
1457 | | phi = grid % clatv, & |
1458 | | lam = grid % clonv, & |
1459 | | gam = gam & |
1460 | | ) |
1461 | | |
1462 | | ! |
1463 | | !-- Allocate neighbour indices and weights |
1464 | | ALLOCATE( grid % ii(0:nx, 0:ny, 4), & |
1465 | | grid % jj(0:nx, 0:ny, 4) ) |
1466 | | grid % ii(:,:,:) = -1 |
1467 | | grid % jj(:,:,:) = -1 |
1468 | | |
1469 | | ALLOCATE( grid % w_horiz(0:nx, 0:ny, 4) ) |
1470 | | grid % w_horiz(:,:,:) = 0.0_dp |
1471 | | |
1472 | | CASE('cosmo-de') |
1473 | | grid % name(1) = 'rlon' ! of COMSO-DE cell centres (scalars) |
1474 | | grid % name(2) = 'rlat' ! of COMSO-DE cell centres (scalars) |
1475 | | grid % name(3) = 'height' |
1476 | | |
1477 | | ALLOCATE( grid % lon(0:nx), grid % lat(0:ny) ) |
1478 | | ALLOCATE( grid % lonu(0:nx), grid % latv(0:ny) ) |
1479 | | |
1480 | | CALL linspace(xmin, xmax, grid % lon) |
1481 | | CALL linspace(ymin, ymax, grid % lat) |
1482 | | grid % lonu(:) = grid % lon + 0.5_dp * (grid % lx / grid % nx) |
1483 | | grid % latv(:) = grid % lat + 0.5_dp * (grid % ly / grid % ny) |
1484 | | |
1485 | | ! |
1486 | | !-- Point to heights of half levels (hhl) and compute heights of full |
1487 | | !-- levels (hfl) as arithmetic averages |
1488 | | grid % hhl => hhl |
1489 | | grid % hfl => hfl |
1490 | | grid % depths => depths |
1491 | | |
1492 | | CASE DEFAULT |
1493 | | message = "Grid kind '" // TRIM(kind) // "' is not recognized." |
1494 | | CALL inifor_abort('init_grid_definition', message) |
1495 | | |
1496 | | END SELECT |
1497 | | |
1498 | | END SUBROUTINE init_grid_definition |
| 1303 | SUBROUTINE init_grid_definition(kind, xmin, xmax, ymin, ymax, & |
| 1304 | x0, y0, z0, nx, ny, nz, z, zw, grid, ic_mode) |
| 1305 | CHARACTER(LEN=*), INTENT(IN) :: kind |
| 1306 | CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: ic_mode |
| 1307 | INTEGER, INTENT(IN) :: nx, ny, nz |
| 1308 | REAL(wp), INTENT(IN) :: xmin, xmax, ymin, ymax |
| 1309 | REAL(wp), INTENT(IN) :: x0, y0, z0 |
| 1310 | REAL(wp), INTENT(IN), TARGET, OPTIONAL :: z(:) |
| 1311 | REAL(wp), INTENT(IN), TARGET, OPTIONAL :: zw(:) |
| 1312 | TYPE(grid_definition), INTENT(INOUT) :: grid |
| 1313 | |
| 1314 | grid%nx = nx |
| 1315 | grid%ny = ny |
| 1316 | grid%nz = nz |
| 1317 | |
| 1318 | grid%lx = xmax - xmin |
| 1319 | grid%ly = ymax - ymin |
| 1320 | |
| 1321 | grid%x0 = x0 |
| 1322 | grid%y0 = y0 |
| 1323 | grid%z0 = z0 |
| 1324 | |
| 1325 | SELECT CASE( TRIM(kind) ) |
| 1326 | |
| 1327 | CASE('boundary') |
| 1328 | |
| 1329 | IF (.NOT.PRESENT(z)) THEN |
| 1330 | message = "z has not been passed but is required for 'boundary' grids" |
| 1331 | CALL inifor_abort('init_grid_definition', message) |
| 1332 | ENDIF |
| 1333 | |
| 1334 | ALLOCATE( grid%x(0:nx) ) |
| 1335 | CALL linspace(xmin, xmax, grid%x) |
| 1336 | |
| 1337 | ALLOCATE( grid%y(0:ny) ) |
| 1338 | CALL linspace(ymin, ymax, grid%y) |
| 1339 | |
| 1340 | grid%z => z |
| 1341 | |
| 1342 | ! |
| 1343 | !-- Allocate neighbour indices and weights |
| 1344 | IF (TRIM(ic_mode) .NE. 'profile') THEN |
| 1345 | ALLOCATE( grid%kk(0:nx, 0:ny, 1:nz, 2) ) |
| 1346 | grid%kk(:,:,:,:) = -1 |
| 1347 | |
| 1348 | ALLOCATE( grid%w_verti(0:nx, 0:ny, 1:nz, 2) ) |
| 1349 | grid%w_verti(:,:,:,:) = 0.0_wp |
| 1350 | ENDIF |
| 1351 | |
| 1352 | CASE('boundary intermediate') |
| 1353 | |
| 1354 | ALLOCATE( grid%x(0:nx) ) |
| 1355 | CALL linspace(xmin, xmax, grid%x) |
| 1356 | |
| 1357 | ALLOCATE( grid%y(0:ny) ) |
| 1358 | CALL linspace(ymin, ymax, grid%y) |
| 1359 | |
| 1360 | ALLOCATE( grid%clon(0:nx, 0:ny), grid%clat(0:nx, 0:ny) ) |
| 1361 | |
| 1362 | CALL rotate_to_cosmo( & |
| 1363 | phir = project( grid%y, y0, EARTH_RADIUS ) , & ! = plate-carree latitude |
| 1364 | lamr = project( grid%x, x0, EARTH_RADIUS ) , & ! = plate-carree longitude |
| 1365 | phip = phi_cn, lamp = lambda_cn, & |
| 1366 | phi = grid%clat, & |
| 1367 | lam = grid%clon, & |
| 1368 | gam = gam & |
| 1369 | ) |
| 1370 | |
| 1371 | ! |
| 1372 | !-- Allocate neighbour indices and weights |
| 1373 | ALLOCATE( grid%ii(0:nx, 0:ny, 4), & |
| 1374 | grid%jj(0:nx, 0:ny, 4) ) |
| 1375 | grid%ii(:,:,:) = -1 |
| 1376 | grid%jj(:,:,:) = -1 |
| 1377 | |
| 1378 | ALLOCATE( grid%w_horiz(0:nx, 0:ny, 4) ) |
| 1379 | grid%w_horiz(:,:,:) = 0.0_wp |
| 1380 | |
| 1381 | ! |
| 1382 | !-- This mode initializes a Cartesian PALM-4U grid and adds the |
| 1383 | !-- corresponding latitudes and longitudes of the rotated pole grid. |
| 1384 | CASE('palm') |
| 1385 | |
| 1386 | IF (.NOT.PRESENT(z)) THEN |
| 1387 | message = "z has not been passed but is required for 'palm' grids" |
| 1388 | CALL inifor_abort('init_grid_definition', message) |
| 1389 | ENDIF |
| 1390 | |
| 1391 | IF (.NOT.PRESENT(zw)) THEN |
| 1392 | message = "zw has not been passed but is required for 'palm' grids" |
| 1393 | CALL inifor_abort('init_grid_definition', message) |
| 1394 | ENDIF |
| 1395 | |
| 1396 | grid%name(1) = 'x and lon' |
| 1397 | grid%name(2) = 'y and lat' |
| 1398 | grid%name(3) = 'z' |
| 1399 | |
| 1400 | ! |
| 1401 | !-- TODO: Remove use of global dx, dy, dz variables. Consider |
| 1402 | !-- TODO: associating global x,y, and z arrays. |
| 1403 | ALLOCATE( grid%x(0:nx), grid%y(0:ny) ) |
| 1404 | ALLOCATE( grid%xu(1:nx), grid%yv(1:ny) ) |
| 1405 | CALL linspace(xmin + 0.5_wp* dx, xmax - 0.5_wp* dx, grid%x) |
| 1406 | CALL linspace(ymin + 0.5_wp* dy, ymax - 0.5_wp* dy, grid%y) |
| 1407 | grid%z => z |
| 1408 | CALL linspace(xmin + dx, xmax - dx, grid%xu) |
| 1409 | CALL linspace(ymin + dy, ymax - dy, grid%yv) |
| 1410 | grid%zw => zw |
| 1411 | |
| 1412 | grid%depths => depths |
| 1413 | |
| 1414 | ! |
| 1415 | !-- Allocate neighbour indices and weights |
| 1416 | IF (TRIM(ic_mode) .NE. 'profile') THEN |
| 1417 | ALLOCATE( grid%kk(0:nx, 0:ny, 1:nz, 2) ) |
| 1418 | grid%kk(:,:,:,:) = -1 |
| 1419 | |
| 1420 | ALLOCATE( grid%w_verti(0:nx, 0:ny, 1:nz, 2) ) |
| 1421 | grid%w_verti(:,:,:,:) = 0.0_wp |
| 1422 | ENDIF |
| 1423 | |
| 1424 | CASE('palm intermediate') |
| 1425 | |
| 1426 | grid%name(1) = 'x and lon' |
| 1427 | grid%name(2) = 'y and lat' |
| 1428 | grid%name(3) = 'interpolated hhl or hfl' |
| 1429 | |
| 1430 | ! |
| 1431 | !-- TODO: Remove use of global dx, dy, dz variables. Consider |
| 1432 | !-- TODO: associating global x,y, and z arrays. |
| 1433 | ALLOCATE( grid%x(0:nx), grid%y(0:ny) ) |
| 1434 | ALLOCATE( grid%xu(1:nx), grid%yv(1:ny) ) |
| 1435 | CALL linspace(xmin + 0.5_wp*dx, xmax - 0.5_wp*dx, grid%x) |
| 1436 | CALL linspace(ymin + 0.5_wp*dy, ymax - 0.5_wp*dy, grid%y) |
| 1437 | CALL linspace(xmin + dx, xmax - dx, grid%xu) |
| 1438 | CALL linspace(ymin + dy, ymax - dy, grid%yv) |
| 1439 | |
| 1440 | grid%depths => depths |
| 1441 | |
| 1442 | ! |
| 1443 | !-- Allocate rotated-pole coordinates, clon is for (c)osmo-de (lon)gitude |
| 1444 | ALLOCATE( grid%clon(0:nx, 0:ny), grid%clat(0:nx, 0:ny) ) |
| 1445 | ALLOCATE( grid%clonu(1:nx, 0:ny), grid%clatu(1:nx, 0:ny) ) |
| 1446 | ALLOCATE( grid%clonv(0:nx, 1:ny), grid%clatv(0:nx, 1:ny) ) |
| 1447 | |
| 1448 | ! |
| 1449 | !-- Compute rotated-pole coordinates of... |
| 1450 | !-- ... PALM-4U centres |
| 1451 | CALL rotate_to_cosmo( & |
| 1452 | phir = project( grid%y, y0, EARTH_RADIUS ) , & ! = plate-carree latitude |
| 1453 | lamr = project( grid%x, x0, EARTH_RADIUS ) , & ! = plate-carree longitude |
| 1454 | phip = phi_cn, lamp = lambda_cn, & |
| 1455 | phi = grid%clat, & |
| 1456 | lam = grid%clon, & |
| 1457 | gam = gam & |
| 1458 | ) |
| 1459 | |
| 1460 | ! |
| 1461 | !-- ... PALM-4U u winds |
| 1462 | CALL rotate_to_cosmo( & |
| 1463 | phir = project( grid%y, y0, EARTH_RADIUS ), & ! = plate-carree latitude |
| 1464 | lamr = project( grid%xu, x0, EARTH_RADIUS ), & ! = plate-carree longitude |
| 1465 | phip = phi_cn, lamp = lambda_cn, & |
| 1466 | phi = grid%clatu, & |
| 1467 | lam = grid%clonu, & |
| 1468 | gam = gam & |
| 1469 | ) |
| 1470 | |
| 1471 | ! |
| 1472 | !-- ... PALM-4U v winds |
| 1473 | CALL rotate_to_cosmo( & |
| 1474 | phir = project( grid%yv, y0, EARTH_RADIUS ), & ! = plate-carree latitude |
| 1475 | lamr = project( grid%x, x0, EARTH_RADIUS ), & ! = plate-carree longitude |
| 1476 | phip = phi_cn, lamp = lambda_cn, & |
| 1477 | phi = grid%clatv, & |
| 1478 | lam = grid%clonv, & |
| 1479 | gam = gam & |
| 1480 | ) |
| 1481 | |
| 1482 | ! |
| 1483 | !-- Allocate neighbour indices and weights |
| 1484 | ALLOCATE( grid%ii(0:nx, 0:ny, 4), & |
| 1485 | grid%jj(0:nx, 0:ny, 4) ) |
| 1486 | grid%ii(:,:,:) = -1 |
| 1487 | grid%jj(:,:,:) = -1 |
| 1488 | |
| 1489 | ALLOCATE( grid%w_horiz(0:nx, 0:ny, 4) ) |
| 1490 | grid%w_horiz(:,:,:) = 0.0_wp |
| 1491 | |
| 1492 | CASE('cosmo-de') |
| 1493 | grid%name(1) = 'rlon' ! of COMSO-DE cell centres (scalars) |
| 1494 | grid%name(2) = 'rlat' ! of COMSO-DE cell centres (scalars) |
| 1495 | grid%name(3) = 'height' |
| 1496 | |
| 1497 | ALLOCATE( grid%lon(0:nx), grid%lat(0:ny) ) |
| 1498 | ALLOCATE( grid%lonu(0:nx), grid%latv(0:ny) ) |
| 1499 | |
| 1500 | CALL linspace(xmin, xmax, grid%lon) |
| 1501 | CALL linspace(ymin, ymax, grid%lat) |
| 1502 | grid%lonu(:) = grid%lon + 0.5_wp * (grid%lx / grid%nx) |
| 1503 | grid%latv(:) = grid%lat + 0.5_wp * (grid%ly / grid%ny) |
| 1504 | |
| 1505 | ! |
| 1506 | !-- Point to heights of half levels (hhl) and compute heights of full |
| 1507 | !-- levels (hfl) as arithmetic averages |
| 1508 | grid%hhl => hhl |
| 1509 | grid%hfl => hfl |
| 1510 | grid%depths => depths |
| 1511 | |
| 1512 | CASE DEFAULT |
| 1513 | message = "Grid kind '" // TRIM(kind) // "' is not recognized." |
| 1514 | CALL inifor_abort('init_grid_definition', message) |
| 1515 | |
| 1516 | END SELECT |
| 1517 | |
| 1518 | END SUBROUTINE init_grid_definition |
1529 | | SUBROUTINE init_averaging_grid(avg_grid, cosmo_grid, x, y, z, z0, & |
1530 | | lonmin, lonmax, latmin, latmax, kind, name) |
1531 | | |
1532 | | TYPE(grid_definition), INTENT(INOUT) :: avg_grid |
1533 | | TYPE(grid_definition), INTENT(IN) :: cosmo_grid |
1534 | | REAL(dp), INTENT(IN) :: x, y, z0 |
1535 | | REAL(dp), INTENT(IN), TARGET :: z(:) |
1536 | | REAL(dp), INTENT(IN) :: lonmin !< lower longitude bound of the averaging grid region [COSMO rotated-pole rad] |
1537 | | REAL(dp), INTENT(IN) :: lonmax !< upper longitude bound of the averaging grid region [COSMO rotated-pole rad] |
1538 | | REAL(dp), INTENT(IN) :: latmin !< lower latitude bound of the averaging grid region [COSMO rotated-pole rad] |
1539 | | REAL(dp), INTENT(IN) :: latmax !< lower latitude bound of the averaging grid region [COSMO rotated-pole rad] |
1540 | | |
1541 | | CHARACTER(LEN=*), INTENT(IN) :: kind |
1542 | | CHARACTER(LEN=*), INTENT(IN) :: name |
1543 | | |
1544 | | LOGICAL :: level_based_averaging |
1545 | | |
1546 | | ALLOCATE( avg_grid % x(1) ) |
1547 | | ALLOCATE( avg_grid % y(1) ) |
1548 | | avg_grid % x(1) = x |
1549 | | avg_grid % y(1) = y |
1550 | | avg_grid % z => z |
1551 | | avg_grid % z0 = z0 |
1552 | | |
1553 | | avg_grid % nz = SIZE(z, 1) |
1554 | | |
1555 | | ALLOCATE( avg_grid % lon(2) ) |
1556 | | ALLOCATE( avg_grid % lat(2) ) |
1557 | | avg_grid % lon(1:2) = (/lonmin, lonmax/) |
1558 | | avg_grid % lat(1:2) = (/latmin, latmax/) |
1559 | | |
1560 | | avg_grid % kind = TRIM(kind) |
1561 | | avg_grid % name(1) = TRIM(name) |
1562 | | |
1563 | | ! |
1564 | | !-- Find and store COSMO columns that fall into the coordinate range |
1565 | | !-- given by avg_grid % clon, % clat |
1566 | | CALL get_cosmo_averaging_region(avg_grid, cosmo_grid) |
1567 | | |
1568 | | ALLOCATE (avg_grid % kkk(avg_grid % n_columns, avg_grid % nz, 2) ) |
1569 | | ALLOCATE (avg_grid % w(avg_grid % n_columns, avg_grid % nz, 2) ) |
1570 | | ! |
1571 | | !-- Compute average COSMO levels in the averaging region |
1572 | | SELECT CASE(avg_grid % kind) |
| 1549 | SUBROUTINE init_averaging_grid(avg_grid, cosmo_grid, x, y, z, z0, & |
| 1550 | lonmin, lonmax, latmin, latmax, kind, name) |
| 1551 | |
| 1552 | TYPE(grid_definition), INTENT(INOUT) :: avg_grid |
| 1553 | TYPE(grid_definition), INTENT(IN) :: cosmo_grid |
| 1554 | REAL(wp), INTENT(IN) :: x, y, z0 |
| 1555 | REAL(wp), INTENT(IN), TARGET :: z(:) |
| 1556 | REAL(wp), INTENT(IN) :: lonmin !< lower longitude bound of the averaging grid region [COSMO rotated-pole rad] |
| 1557 | REAL(wp), INTENT(IN) :: lonmax !< upper longitude bound of the averaging grid region [COSMO rotated-pole rad] |
| 1558 | REAL(wp), INTENT(IN) :: latmin !< lower latitude bound of the averaging grid region [COSMO rotated-pole rad] |
| 1559 | REAL(wp), INTENT(IN) :: latmax !< lower latitude bound of the averaging grid region [COSMO rotated-pole rad] |
| 1560 | |
| 1561 | CHARACTER(LEN=*), INTENT(IN) :: kind |
| 1562 | CHARACTER(LEN=*), INTENT(IN) :: name |
| 1563 | |
| 1564 | LOGICAL :: level_based_averaging |
| 1565 | |
| 1566 | ALLOCATE( avg_grid%x(1) ) |
| 1567 | ALLOCATE( avg_grid%y(1) ) |
| 1568 | avg_grid%x(1) = x |
| 1569 | avg_grid%y(1) = y |
| 1570 | avg_grid%z => z |
| 1571 | avg_grid%z0 = z0 |
| 1572 | |
| 1573 | avg_grid%nz = SIZE(z, 1) |
| 1574 | |
| 1575 | ALLOCATE( avg_grid%lon(2) ) |
| 1576 | ALLOCATE( avg_grid%lat(2) ) |
| 1577 | avg_grid%lon(1:2) = (/lonmin, lonmax/) |
| 1578 | avg_grid%lat(1:2) = (/latmin, latmax/) |
| 1579 | |
| 1580 | avg_grid%kind = TRIM(kind) |
| 1581 | avg_grid%name(1) = TRIM(name) |
| 1582 | |
| 1583 | ! |
| 1584 | !-- Find and store COSMO columns that fall into the coordinate range |
| 1585 | !-- given by avg_grid%clon, %clat |
| 1586 | CALL get_cosmo_averaging_region(avg_grid, cosmo_grid) |
| 1587 | |
| 1588 | ALLOCATE (avg_grid%kkk(avg_grid%n_columns, avg_grid%nz, 2) ) |
| 1589 | ALLOCATE (avg_grid%w(avg_grid%n_columns, avg_grid%nz, 2) ) |
| 1590 | ! |
| 1591 | !-- Compute average COSMO levels in the averaging region |
| 1592 | SELECT CASE(avg_grid%kind) |
1789 | | !-- Allocation of arrays for stretching |
1790 | | ALLOCATE( min_dz_stretch_level_end(number_stretch_level_start) ) |
1791 | | |
1792 | | ! |
1793 | | !-- The stretching region has to be large enough to allow for a smooth |
1794 | | !-- transition between two different grid spacings |
1795 | | DO n = 1, number_stretch_level_start |
1796 | | min_dz_stretch_level_end(n) = dz_stretch_level_start(n) + & |
1797 | | 4 * MAX( dz(n),dz(n+1) ) |
1798 | | ENDDO |
1799 | | |
1800 | | IF ( ANY( min_dz_stretch_level_end(1:number_stretch_level_start) > & |
1801 | | dz_stretch_level_end(1:number_stretch_level_start) ) ) THEN |
1802 | | !IF ( ANY( min_dz_stretch_level_end > & |
1803 | | ! dz_stretch_level_end ) ) THEN |
1804 | | message = 'Each dz_stretch_level_end has to be larger ' // & |
1805 | | 'than its corresponding value for ' // & |
1806 | | 'dz_stretch_level_start + 4*MAX(dz(n),dz(n+1)) '//& |
1807 | | 'to allow for smooth grid stretching' |
1808 | | CALL inifor_abort('stretched_z', message) |
1809 | | ENDIF |
1810 | | |
1811 | | ! |
1812 | | !-- Stretching must not be applied within the prandtl_layer |
1813 | | !-- (first two grid points). For the default case dz_stretch_level_start |
1814 | | !-- is negative. Therefore the absolut value is checked here. |
1815 | | IF ( ANY( ABS( dz_stretch_level_start ) < dz(1) * 1.5_dp ) ) THEN |
1816 | | WRITE( message, * ) 'Eeach dz_stretch_level_start has to be ',& |
1817 | | 'larger than ', dz(1) * 1.5 |
1818 | | CALL inifor_abort( 'stretched_z', message) |
1819 | | ENDIF |
1820 | | |
1821 | | ! |
1822 | | !-- The stretching has to start and end on a grid level. Therefore |
1823 | | !-- user-specified values have to ''interpolate'' to the next lowest level |
1824 | | IF ( number_stretch_level_start /= 0 ) THEN |
1825 | | dz_stretch_level_start(1) = INT( (dz_stretch_level_start(1) - & |
1826 | | dz(1)/2.0) / dz(1) ) & |
1827 | | * dz(1) + dz(1)/2.0 |
1828 | | ENDIF |
1829 | | |
1830 | | IF ( number_stretch_level_start > 1 ) THEN |
1831 | | DO n = 2, number_stretch_level_start |
1832 | | dz_stretch_level_start(n) = INT( dz_stretch_level_start(n) / & |
1833 | | dz(n) ) * dz(n) |
1834 | | ENDDO |
1835 | | ENDIF |
1836 | | |
1837 | | IF ( number_stretch_level_end /= 0 ) THEN |
1838 | | DO n = 1, number_stretch_level_end |
1839 | | dz_stretch_level_end(n) = INT( dz_stretch_level_end(n) / & |
1840 | | dz(n+1) ) * dz(n+1) |
1841 | | ENDDO |
1842 | | ENDIF |
1843 | | |
1844 | | ! |
1845 | | !-- Determine stretching factor if necessary |
1846 | | IF ( number_stretch_level_end >= 1 ) THEN |
1847 | | CALL calculate_stretching_factor( number_stretch_level_end, dz, & |
1848 | | dz_stretch_factor_array, & |
1849 | | dz_stretch_level_end, & |
1850 | | dz_stretch_level_start ) |
1851 | | ENDIF |
1852 | | |
1853 | | z(1) = dz(1) * 0.5_dp |
1854 | | ! |
1855 | | dz_stretch_level_index = n |
1856 | | dz_stretched = dz(1) |
1857 | | DO k = 2, n |
1858 | | |
1859 | | IF ( dz_stretch_level <= z(k-1) .AND. dz_stretched < dz_max ) THEN |
1860 | | |
1861 | | dz_stretched = dz_stretched * dz_stretch_factor |
1862 | | dz_stretched = MIN( dz_stretched, dz_max ) |
1863 | | |
1864 | | IF ( dz_stretch_level_index == n ) dz_stretch_level_index = k-1 |
1865 | | |
1866 | | ENDIF |
1867 | | |
1868 | | z(k) = z(k-1) + dz_stretched |
1869 | | |
1870 | | ENDDO |
1871 | | !-- Determine u and v height levels considering the possibility of grid |
1872 | | !-- stretching in several heights. |
1873 | | n = 1 |
1874 | | dz_stretch_level_start_index(:) = UBOUND(z, 1) |
1875 | | dz_stretch_level_end_index(:) = UBOUND(z, 1) |
1876 | | dz_stretched = dz(1) |
1877 | | |
1878 | | !-- The default value of dz_stretch_level_start is negative, thus the first |
1879 | | !-- condition is always true. Hence, the second condition is necessary. |
1880 | | DO k = 2, UBOUND(z, 1) |
1881 | | IF ( dz_stretch_level_start(n) <= z(k-1) .AND. & |
1882 | | dz_stretch_level_start(n) /= -9999999.9_dp ) THEN |
1883 | | dz_stretched = dz_stretched * dz_stretch_factor_array(n) |
1884 | | |
1885 | | IF ( dz(n) > dz(n+1) ) THEN |
1886 | | dz_stretched = MAX( dz_stretched, dz(n+1) ) !Restrict dz_stretched to the user-specified (higher) dz |
1887 | | ELSE |
1888 | | dz_stretched = MIN( dz_stretched, dz(n+1) ) !Restrict dz_stretched to the user-specified (lower) dz |
1889 | | ENDIF |
1890 | | |
1891 | | IF ( dz_stretch_level_start_index(n) == UBOUND(z, 1) ) & |
1892 | | dz_stretch_level_start_index(n) = k-1 |
1893 | | |
| 1887 | z(k) = z(k-1) + dz_stretched |
| 1888 | |
| 1889 | ENDDO |
| 1890 | !-- Determine u and v height levels considering the possibility of grid |
| 1891 | !-- stretching in several heights. |
| 1892 | n = 1 |
| 1893 | dz_stretch_level_start_index(:) = UBOUND(z, 1) |
| 1894 | dz_stretch_level_end_index(:) = UBOUND(z, 1) |
| 1895 | dz_stretched = dz(1) |
| 1896 | |
| 1897 | !-- The default value of dz_stretch_level_start is negative, thus the first |
| 1898 | !-- condition is always true. Hence, the second condition is necessary. |
| 1899 | DO k = 2, UBOUND(z, 1) |
| 1900 | IF ( dz_stretch_level_start(n) <= z(k-1) .AND. & |
| 1901 | dz_stretch_level_start(n) /= -9999999.9_wp ) THEN |
| 1902 | dz_stretched = dz_stretched * dz_stretch_factor_array(n) |
| 1903 | |
| 1904 | IF ( dz(n) > dz(n+1) ) THEN |
| 1905 | dz_stretched = MAX( dz_stretched, dz(n+1) ) !Restrict dz_stretched to the user-specified (higher) dz |
| 1906 | ELSE |
| 1907 | dz_stretched = MIN( dz_stretched, dz(n+1) ) !Restrict dz_stretched to the user-specified (lower) dz |
2087 | | SUBROUTINE setup_io_groups() |
2088 | | |
2089 | | INTEGER :: ngroups |
2090 | | |
2091 | | ngroups = 16 |
2092 | | ALLOCATE( io_group_list(ngroups) ) |
2093 | | |
2094 | | ! |
2095 | | !-- soil temp |
2096 | | io_group_list(1) = init_io_group( & |
2097 | | in_files = soil_files, & |
2098 | | out_vars = output_var_table(1:1), & |
2099 | | in_var_list = input_var_table(1:1), & |
2100 | | kind = 'soil-temperature' & |
2101 | | ) |
2102 | | |
2103 | | ! |
2104 | | !-- soil water |
2105 | | io_group_list(2) = init_io_group( & |
2106 | | in_files = soil_files, & |
2107 | | out_vars = output_var_table(2:2), & |
2108 | | in_var_list = input_var_table(2:2), & |
2109 | | kind = 'soil-water' & |
2110 | | ) |
2111 | | |
2112 | | ! |
2113 | | !-- potential temperature, surface pressure, specific humidity including |
2114 | | !-- nudging and subsidence, and geostrophic winds ug, vg |
2115 | | io_group_list(3) = init_io_group( & |
2116 | | in_files = flow_files, & |
2117 | | out_vars = [output_var_table(56:64), & ! internal averaged density and pressure profiles |
2118 | | output_var_table(3:8), output_var_table(9:14), & |
2119 | | output_var_table(42:42), output_var_table(43:44), & |
2120 | | output_var_table(49:51), output_var_table(52:54)], & |
2121 | | in_var_list = (/input_var_table(3), input_var_table(17), & ! T, P, QV |
2122 | | input_var_table(4) /), & |
2123 | | kind = 'thermodynamics', & |
2124 | | n_output_quantities = 4 & ! P, Theta, Rho, qv |
2125 | | ) |
2126 | | |
2127 | | ! |
2128 | | !-- Moved to therodynamic io_group |
2129 | | !io_group_list(4) = init_io_group( & |
2130 | | ! in_files = flow_files, & |
2131 | | ! out_vars = [output_var_table(9:14), output_var_table(52:54)], & |
2132 | | ! in_var_list = input_var_table(4:4), & |
2133 | | ! kind = 'scalar' & |
2134 | | !) |
2135 | | |
2136 | | ! |
2137 | | !-- u and v velocity |
2138 | | io_group_list(5) = init_io_group( & |
2139 | | in_files = flow_files, & |
2140 | | out_vars = [output_var_table(15:26), output_var_table(45:46)], & |
2141 | | !out_vars = output_var_table(15:20), & |
2142 | | in_var_list = input_var_table(5:6), & |
2143 | | !in_var_list = input_var_table(5:5), & |
2144 | | kind = 'velocities' & |
2145 | | ) |
| 2106 | SUBROUTINE setup_io_groups() |
| 2107 | |
| 2108 | INTEGER :: ngroups |
| 2109 | |
| 2110 | ngroups = 16 |
| 2111 | ALLOCATE( io_group_list(ngroups) ) |
| 2112 | |
| 2113 | ! |
| 2114 | !-- soil temp |
| 2115 | io_group_list(1) = init_io_group( & |
| 2116 | in_files = soil_files, & |
| 2117 | out_vars = output_var_table(1:1), & |
| 2118 | in_var_list = input_var_table(1:1), & |
| 2119 | kind = 'soil-temperature' & |
| 2120 | ) |
| 2121 | |
| 2122 | ! |
| 2123 | !-- soil water |
| 2124 | io_group_list(2) = init_io_group( & |
| 2125 | in_files = soil_files, & |
| 2126 | out_vars = output_var_table(2:2), & |
| 2127 | in_var_list = input_var_table(2:2), & |
| 2128 | kind = 'soil-water' & |
| 2129 | ) |
| 2130 | |
| 2131 | ! |
| 2132 | !-- potential temperature, surface pressure, specific humidity including |
| 2133 | !-- nudging and subsidence, and geostrophic winds ug, vg |
| 2134 | io_group_list(3) = init_io_group( & |
| 2135 | in_files = flow_files, & |
| 2136 | out_vars = [output_var_table(56:64), & ! internal averaged density and pressure profiles |
| 2137 | output_var_table(3:8), output_var_table(9:14), & |
| 2138 | output_var_table(42:42), output_var_table(43:44), & |
| 2139 | output_var_table(49:51), output_var_table(52:54)], & |
| 2140 | in_var_list = (/input_var_table(3), input_var_table(17), & ! T, P, QV |
| 2141 | input_var_table(4) /), & |
| 2142 | kind = 'thermodynamics', & |
| 2143 | n_output_quantities = 4 & ! P, Theta, Rho, qv |
| 2144 | ) |
| 2145 | |
| 2146 | ! |
| 2147 | !-- Moved to therodynamic io_group |
| 2148 | !io_group_list(4) = init_io_group( & |
| 2149 | ! in_files = flow_files, & |
| 2150 | ! out_vars = [output_var_table(9:14), output_var_table(52:54)], & |
| 2151 | ! in_var_list = input_var_table(4:4), & |
| 2152 | ! kind = 'scalar' & |
| 2153 | !) |
| 2154 | |
| 2155 | ! |
| 2156 | !-- u and v velocity |
| 2157 | io_group_list(5) = init_io_group( & |
| 2158 | in_files = flow_files, & |
| 2159 | out_vars = [output_var_table(15:26), output_var_table(45:46)], & |
| 2160 | !out_vars = output_var_table(15:20), & |
| 2161 | in_var_list = input_var_table(5:6), & |
| 2162 | !in_var_list = input_var_table(5:5), & |
| 2163 | kind = 'velocities' & |
| 2164 | ) |
2158 | | !-- w velocity and subsidence and w nudging |
2159 | | io_group_list(7) = init_io_group( & |
2160 | | in_files = flow_files, & |
2161 | | out_vars = [output_var_table(27:32), output_var_table(47:48)], & |
2162 | | in_var_list = input_var_table(7:7), & |
2163 | | kind = 'scalar' & |
2164 | | ) |
2165 | | ! |
2166 | | !-- rain |
2167 | | io_group_list(8) = init_io_group( & |
2168 | | in_files = soil_moisture_files, & |
2169 | | out_vars = output_var_table(33:33), & |
2170 | | in_var_list = input_var_table(8:8), & |
2171 | | kind = 'accumulated' & |
2172 | | ) |
2173 | | io_group_list(8) % to_be_processed = .FALSE. |
2174 | | ! |
2175 | | !-- snow |
2176 | | io_group_list(9) = init_io_group( & |
2177 | | in_files = soil_moisture_files, & |
2178 | | out_vars = output_var_table(34:34), & |
2179 | | in_var_list = input_var_table(9:9), & |
2180 | | kind = 'accumulated' & |
2181 | | ) |
2182 | | io_group_list(9) % to_be_processed = .FALSE. |
2183 | | ! |
2184 | | !-- graupel |
2185 | | io_group_list(10) = init_io_group( & |
2186 | | in_files = soil_moisture_files, & |
2187 | | out_vars = output_var_table(35:35), & |
2188 | | in_var_list = input_var_table(10:10), & |
2189 | | kind = 'accumulated' & |
2190 | | ) |
2191 | | io_group_list(10) % to_be_processed = .FALSE. |
2192 | | ! |
2193 | | !-- evapotranspiration |
2194 | | io_group_list(11) = init_io_group( & |
2195 | | in_files = soil_moisture_files, & |
2196 | | out_vars = output_var_table(37:37), & |
2197 | | in_var_list = input_var_table(11:11), & |
2198 | | kind = 'accumulated' & |
2199 | | ) |
2200 | | io_group_list(11) % to_be_processed = .FALSE. |
2201 | | ! |
2202 | | !-- 2m air temperature |
2203 | | io_group_list(12) = init_io_group( & |
2204 | | in_files = soil_moisture_files, & |
2205 | | out_vars = output_var_table(36:36), & |
2206 | | in_var_list = input_var_table(12:12), & |
2207 | | kind = 'surface' & |
2208 | | ) |
2209 | | io_group_list(12) % to_be_processed = .FALSE. |
2210 | | ! |
2211 | | !-- incoming diffusive sw flux |
2212 | | io_group_list(13) = init_io_group( & |
2213 | | in_files = radiation_files, & |
2214 | | out_vars = output_var_table(38:38), & |
2215 | | in_var_list = input_var_table(13:13), & |
2216 | | kind = 'running average' & |
2217 | | ) |
2218 | | io_group_list(13) % to_be_processed = .FALSE. |
2219 | | ! |
2220 | | !-- incoming direct sw flux |
2221 | | io_group_list(14) = init_io_group( & |
2222 | | in_files = radiation_files, & |
2223 | | out_vars = output_var_table(39:39), & |
2224 | | in_var_list = input_var_table(14:14), & |
2225 | | kind = 'running average' & |
2226 | | ) |
2227 | | io_group_list(14) % to_be_processed = .FALSE. |
2228 | | ! |
2229 | | !-- sw radiation balance |
2230 | | io_group_list(15) = init_io_group( & |
2231 | | in_files = radiation_files, & |
2232 | | out_vars = output_var_table(40:40), & |
2233 | | in_var_list = input_var_table(15:15), & |
2234 | | kind = 'running average' & |
2235 | | ) |
2236 | | io_group_list(15) % to_be_processed = .FALSE. |
2237 | | ! |
2238 | | !-- lw radiation balance |
2239 | | io_group_list(16) = init_io_group( & |
2240 | | in_files = radiation_files, & |
2241 | | out_vars = output_var_table(41:41), & |
2242 | | in_var_list = input_var_table(16:16), & |
2243 | | kind = 'running average' & |
2244 | | ) |
2245 | | io_group_list(16) % to_be_processed = .FALSE. |
2246 | | |
2247 | | END SUBROUTINE setup_io_groups |
| 2177 | !-- w velocity and subsidence and w nudging |
| 2178 | io_group_list(7) = init_io_group( & |
| 2179 | in_files = flow_files, & |
| 2180 | out_vars = [output_var_table(27:32), output_var_table(47:48)], & |
| 2181 | in_var_list = input_var_table(7:7), & |
| 2182 | kind = 'scalar' & |
| 2183 | ) |
| 2184 | ! |
| 2185 | !-- rain |
| 2186 | io_group_list(8) = init_io_group( & |
| 2187 | in_files = soil_moisture_files, & |
| 2188 | out_vars = output_var_table(33:33), & |
| 2189 | in_var_list = input_var_table(8:8), & |
| 2190 | kind = 'accumulated' & |
| 2191 | ) |
| 2192 | io_group_list(8)%to_be_processed = .FALSE. |
| 2193 | ! |
| 2194 | !-- snow |
| 2195 | io_group_list(9) = init_io_group( & |
| 2196 | in_files = soil_moisture_files, & |
| 2197 | out_vars = output_var_table(34:34), & |
| 2198 | in_var_list = input_var_table(9:9), & |
| 2199 | kind = 'accumulated' & |
| 2200 | ) |
| 2201 | io_group_list(9)%to_be_processed = .FALSE. |
| 2202 | ! |
| 2203 | !-- graupel |
| 2204 | io_group_list(10) = init_io_group( & |
| 2205 | in_files = soil_moisture_files, & |
| 2206 | out_vars = output_var_table(35:35), & |
| 2207 | in_var_list = input_var_table(10:10), & |
| 2208 | kind = 'accumulated' & |
| 2209 | ) |
| 2210 | io_group_list(10)%to_be_processed = .FALSE. |
| 2211 | ! |
| 2212 | !-- evapotranspiration |
| 2213 | io_group_list(11) = init_io_group( & |
| 2214 | in_files = soil_moisture_files, & |
| 2215 | out_vars = output_var_table(37:37), & |
| 2216 | in_var_list = input_var_table(11:11), & |
| 2217 | kind = 'accumulated' & |
| 2218 | ) |
| 2219 | io_group_list(11)%to_be_processed = .FALSE. |
| 2220 | ! |
| 2221 | !-- 2m air temperature |
| 2222 | io_group_list(12) = init_io_group( & |
| 2223 | in_files = soil_moisture_files, & |
| 2224 | out_vars = output_var_table(36:36), & |
| 2225 | in_var_list = input_var_table(12:12), & |
| 2226 | kind = 'surface' & |
| 2227 | ) |
| 2228 | io_group_list(12)%to_be_processed = .FALSE. |
| 2229 | ! |
| 2230 | !-- incoming diffusive sw flux |
| 2231 | io_group_list(13) = init_io_group( & |
| 2232 | in_files = radiation_files, & |
| 2233 | out_vars = output_var_table(38:38), & |
| 2234 | in_var_list = input_var_table(13:13), & |
| 2235 | kind = 'running average' & |
| 2236 | ) |
| 2237 | io_group_list(13)%to_be_processed = .FALSE. |
| 2238 | ! |
| 2239 | !-- incoming direct sw flux |
| 2240 | io_group_list(14) = init_io_group( & |
| 2241 | in_files = radiation_files, & |
| 2242 | out_vars = output_var_table(39:39), & |
| 2243 | in_var_list = input_var_table(14:14), & |
| 2244 | kind = 'running average' & |
| 2245 | ) |
| 2246 | io_group_list(14)%to_be_processed = .FALSE. |
| 2247 | ! |
| 2248 | !-- sw radiation balance |
| 2249 | io_group_list(15) = init_io_group( & |
| 2250 | in_files = radiation_files, & |
| 2251 | out_vars = output_var_table(40:40), & |
| 2252 | in_var_list = input_var_table(15:15), & |
| 2253 | kind = 'running average' & |
| 2254 | ) |
| 2255 | io_group_list(15)%to_be_processed = .FALSE. |
| 2256 | ! |
| 2257 | !-- lw radiation balance |
| 2258 | io_group_list(16) = init_io_group( & |
| 2259 | in_files = radiation_files, & |
| 2260 | out_vars = output_var_table(41:41), & |
| 2261 | in_var_list = input_var_table(16:16), & |
| 2262 | kind = 'running average' & |
| 2263 | ) |
| 2264 | io_group_list(16)%to_be_processed = .FALSE. |
| 2265 | |
| 2266 | END SUBROUTINE setup_io_groups |