Changeset 4792 for palm/trunk/SOURCE/netcdf_interface_mod.f90
- Timestamp:
- Nov 23, 2020 1:02:38 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/netcdf_interface_mod.f90
r4742 r4792 1 1 !> @file netcdf_interface_mod.f90 2 !------------------------------------------------------------------------------ !2 !--------------------------------------------------------------------------------------------------! 3 3 ! This file is part of the PALM model system. 4 4 ! 5 ! PALM is free software: you can redistribute it and/or modify it under the 6 ! terms of the GNU General Public License as published by the Free Software 7 ! Foundation, either version 3 of the License, or (at your option) any later 8 ! version. 9 ! 10 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY 11 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 ! 14 ! You should have received a copy of the GNU General Public License along with 15 ! PALM. If not, see <http://www.gnu.org/licenses/>. 5 ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General 6 ! Public License as published by the Free Software Foundation, either version 3 of the License, or 7 ! (at your option) any later version. 8 ! 9 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 10 ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 ! Public License for more details. 12 ! 13 ! You should have received a copy of the GNU General Public License along with PALM. If not, see 14 ! <http://www.gnu.org/licenses/>. 16 15 ! 17 16 ! Copyright 1997-2020 Leibniz Universitaet Hannover 18 !------------------------------------------------------------------------------ !17 !--------------------------------------------------------------------------------------------------! 19 18 ! 20 19 ! Current revisions: … … 25 24 ! ----------------- 26 25 ! $Id$ 26 ! file re-formatted to follow the PALM coding standard 27 ! 28 ! 4742 2020-10-14 15:11:02Z schwenkel 27 29 ! Implement snow and graupel (bulk microphysics) 28 ! 30 ! 29 31 ! 4502 2020-04-17 16:14:16Z schwenkel 30 32 ! Implementation of ice microphysics 31 ! 33 ! 32 34 ! 4455 2020-03-11 12:20:29Z Giersch 33 35 ! Axis attribute added to netcdf output 34 ! 36 ! 35 37 ! 4400 2020-02-10 20:32:41Z suehring 36 ! Move routine to transform coordinates from netcdf_interface_mod to 38 ! Move routine to transform coordinates from netcdf_interface_mod to 37 39 ! basic_constants_and_equations_mod 38 ! 40 ! 39 41 ! 4360 2020-01-07 11:25:50Z suehring 40 42 ! Adjusted output of multi-agent system for biometeorology 41 ! 43 ! 42 44 ! 4227 2019-09-10 18:04:34Z gronemeier 43 45 ! Replace function date_time_string by call to get_date_time 44 ! 46 ! 45 47 ! 4223 2019-09-10 09:20:47Z gronemeier 46 ! replaced rotation angle from input-netCDF file 47 ! by namelist parameter 'rotation_angle' 48 ! 48 ! replaced rotation angle from input-netCDF file by namelist parameter 'rotation_angle' 49 ! 49 50 ! 4182 2019-08-22 15:20:23Z scharf 50 51 ! Corrected "Former revisions" section 51 ! 52 ! 52 53 ! 4127 2019-07-30 14:47:10Z suehring 53 ! - Introduce new vertical dimension for plant-canopy output.54 ! - Temporarlily disable masked output for soil (merge from branch resler)55 ! 54 ! - Introduce new vertical dimension for plant-canopy output. 55 ! - Temporarlily disable masked output for soil (merge from branch resler) 56 ! 56 57 ! 4069 2019-07-01 14:05:51Z Giersch 57 ! Masked output running index mid has been introduced as a local variable to 58 ! avoid runtime error(Loop variable has been modified) in time_integration59 ! 58 ! Masked output running index mid has been introduced as a local variable to avoid runtime error 59 ! (Loop variable has been modified) in time_integration 60 ! 60 61 ! 4046 2019-06-21 17:32:04Z knoop 61 62 ! removal of special treatment for usm_define_netcdf_grid call 62 ! 63 ! 63 64 ! 4039 2019-06-18 10:32:41Z suehring 64 65 ! Rename subroutines in module for diagnostic quantities … … 71 72 ! 72 73 ! 3994 2019-05-22 18:08:09Z suehring 73 ! remove origin time from time unit, compose origin_time_string within 74 ! subroutinenetcdf_create_global_atts74 ! remove origin time from time unit, compose origin_time_string within subroutine 75 ! netcdf_create_global_atts 75 76 ! 76 77 ! 3954 2019-05-06 12:49:42Z gronemeier … … 78 79 ! 79 80 ! 3953 2019-05-06 12:11:55Z gronemeier 80 ! bugfix: set origin_time and starting point of time coordinate according to 81 ! day_of_year_init andtime_utc_init81 ! bugfix: set origin_time and starting point of time coordinate according to day_of_year_init and 82 ! time_utc_init 82 83 ! 83 84 ! 3942 2019-04-30 13:08:30Z kanani … … 92 93 ! 93 94 ! 3744 2019-02-15 18:38:58Z suehring 94 ! Bugfix: - initialize return values to ensure they are set before returning 95 ! (routinedefine_geo_coordinates)95 ! Bugfix: - initialize return values to ensure they are set before returning (routine 96 ! define_geo_coordinates) 96 97 ! - change order of dimensions for some variables 97 98 ! … … 103 104 ! 104 105 ! 3655 2019-01-07 16:51:22Z knoop 105 ! Move the control parameter "salsa" from salsa_mod to control_parameters 106 ! (M. Kurppa) 106 ! Move the control parameter "salsa" from salsa_mod to control_parameters (M. Kurppa) 107 107 ! 108 108 ! Revision 1.1 2005/05/18 15:37:16 raasch … … 113 113 ! ------------ 114 114 !> In case of extend = .FALSE.: 115 !> Define all necessary dimensions, axes and variables for the different 116 !> netCDF datasets. This subroutine is called from check_open after a new117 !> dataset is created. It leaves the open netCDFfiles ready to write.115 !> Define all necessary dimensions, axes and variables for the different netCDF datasets. This 116 !> subroutine is called from check_open after a new dataset is created. It leaves the open netCDF 117 !> files ready to write. 118 118 !> 119 119 !> In case of extend = .TRUE.: 120 !> Find out if dimensions and variables of an existing file match the values 121 !> of the actual run. If so, get all necessary information (ids, etc.) from 122 !> this file. 120 !> Find out if dimensions and variables of an existing file match the values of the actual run. If 121 !> so, get all necessary information (ids, etc.) from this file. 123 122 !> 124 !> Parameter av can assume values 0 (non-averaged data) and 1 (time averaged 125 !> data) 123 !> Parameter av can assume values 0 (non-averaged data) and 1 (time averaged data) 126 124 !> 127 !> @todo calculation of output time levels for parallel NetCDF still does not 128 !> cover every exception (change of dt_do, end_time in restart) 129 !> @todo timeseries and profile output still needs to be rewritten to allow 130 !> modularization 125 !> @todo calculation of output time levels for parallel NetCDF still does not cover every exception 126 ! (change of dt_do, end_time in restart) 127 !> @todo timeseries and profile output still needs to be rewritten to allow modularization 131 128 !> @todo output 2d UTM coordinates without global arrays 132 129 !> @todo output longitude/latitude also with non-parallel output (3d and xy) 133 !------------------------------------------------------------------------------ !130 !--------------------------------------------------------------------------------------------------! 134 131 MODULE netcdf_interface 135 132 136 USE control_parameters, & 137 ONLY: biometeorology, fl_max, & 138 max_masks, multi_agent_system_end, & 139 multi_agent_system_start, & 140 rotation_angle, & 141 var_fl_max, varnamelength 133 USE control_parameters, & 134 ONLY: biometeorology, & 135 fl_max, & 136 max_masks, & 137 multi_agent_system_end, & 138 multi_agent_system_start, & 139 rotation_angle, & 140 var_fl_max, & 141 varnamelength 142 142 USE kinds 143 143 #if defined( __netcdf ) 144 144 USE NETCDF 145 145 #endif 146 USE mas_global_attributes, &146 USE mas_global_attributes, & 147 147 ONLY: dim_size_agtnum 148 148 149 USE netcdf_data_input_mod, &150 ONLY: coord_ref_sys, &151 crs_list, &149 USE netcdf_data_input_mod, & 150 ONLY: coord_ref_sys, & 151 crs_list, & 152 152 init_model 153 153 154 154 PRIVATE 155 155 156 CHARACTER (LEN=16), DIMENSION(13) :: agt_var_names = &157 (/ 'ag_id ', 'ag_x ', 'ag_y ', &158 'ag_wind ', 'ag_temp ', 'ag_group ', &159 'ag_iPT ', 'ag_PM10 ', 'ag_PM25 ', &160 'not_used ', 'not_used ', 'not_used ', &161 'not_used ' /)162 163 CHARACTER (LEN=16), DIMENSION(13) :: agt_var_units = &164 (/ 'dim_less ', 'meters ', 'meters ', &165 'm/s ', 'K ', 'dim_less ', &166 'C ', 'tbd ', 'tbd ', &167 'tbd ', 'not_used ', 'not_used ', &168 'not_used ' /)169 170 156 INTEGER(iwp), PARAMETER :: dopr_norm_num = 7, dopts_num = 29, dots_max = 100 171 172 CHARACTER (LEN=7), DIMENSION(dopr_norm_num) :: dopr_norm_names = &173 (/ 'wtheta0', 'ws2 ', 'tsw2 ', 'ws3 ', 'ws2tsw ', 'wstsw2 ', &174 'z_i ' /)175 176 CHARACTER (LEN=7), DIMENSION(dopr_norm_num) :: dopr_norm_longnames = &177 (/ 'wtheta0', 'w*2 ', 't*w2 ', 'w*3 ', 'w*2t*w ', 'w*t*w2 ', &178 'z_i ' /)179 180 CHARACTER (LEN=7), DIMENSION(dopts_num) :: dopts_label = &181 (/ 'tnpt ', 'x_ ', 'y_ ', 'z_ ', 'z_abs ', 'u ', &182 'v ', 'w ', 'u" ', 'v" ', 'w" ', 'npt_up ', &183 'w_up ', 'w_down ', 'radius ', 'r_min ', 'r_max ', 'npt_max', &184 'npt_min', 'x*2 ', 'y*2 ', 'z*2 ', 'u*2 ', 'v*2 ', &185 'w*2 ', 'u"2 ', 'v"2 ', 'w"2 ', 'npt*2 ' /)186 187 CHARACTER (LEN=7), DIMENSION(dopts_num) :: dopts_unit = &188 (/ 'number ', 'm ', 'm ', 'm ', 'm ', 'm/s ', &189 'm/s ', 'm/s ', 'm/s ', 'm/s ', 'm/s ', 'number ', &190 'm/s ', 'm/s ', 'm ', 'm ', 'm ', 'number ', &191 'number ', 'm2 ', 'm2 ', 'm2 ', 'm2/s2 ', 'm2/s2 ', &192 'm2/s2 ', 'm2/s2 ', 'm2/s2 ', 'm2/s2 ', 'number2' /)193 194 157 INTEGER(iwp) :: dots_num = 25 !< number of timeseries defined by default 195 158 INTEGER(iwp) :: dots_soil = 26 !< starting index for soil-timeseries 196 159 INTEGER(iwp) :: dots_rad = 32 !< starting index for radiation-timeseries 197 160 198 CHARACTER (LEN=13), DIMENSION(dots_max) :: dots_label = & 199 (/ 'E ', 'E* ', 'dt ', & 200 'us* ', 'th* ', 'umax ', & 201 'vmax ', 'wmax ', 'div_new ', & 202 'div_old ', 'zi_wtheta ', 'zi_theta ', & 203 'w* ', 'w"theta"0 ', 'w"theta" ', & 204 'wtheta ', 'theta(0) ', 'theta(z_mo) ', & 205 'w"u"0 ', 'w"v"0 ', 'w"q"0 ', & 206 'ol ', 'q* ', 'w"s" ', & 207 's* ', 'ghf ', 'qsws_liq ', & 208 'qsws_soil ', 'qsws_veg ', 'r_a ', & 209 'r_s ', & 210 'rad_net ', 'rad_lw_in ', 'rad_lw_out ', & 211 'rad_sw_in ', 'rad_sw_out ', 'rrtm_aldif ', & 212 'rrtm_aldir ', 'rrtm_asdif ', 'rrtm_asdir ', & 161 CHARACTER (LEN=16) :: heatflux_output_unit !< unit for heatflux output 162 CHARACTER (LEN=16) :: waterflux_output_unit !< unit for waterflux output 163 CHARACTER (LEN=16) :: momentumflux_output_unit !< unit for momentumflux output 164 CHARACTER (LEN=40) :: netcdf_data_format_string 165 166 CHARACTER (LEN=16), DIMENSION(13) :: agt_var_names = & 167 (/ 'ag_id ', 'ag_x ', 'ag_y ', & 168 'ag_wind ', 'ag_temp ', 'ag_group ', & 169 'ag_iPT ', 'ag_PM10 ', 'ag_PM25 ', & 170 'not_used ', 'not_used ', 'not_used ', & 171 'not_used ' /) 172 173 CHARACTER (LEN=16), DIMENSION(13) :: agt_var_units = & 174 (/ 'dim_less ', 'meters ', 'meters ', & 175 'm/s ', 'K ', 'dim_less ', & 176 'C ', 'tbd ', 'tbd ', & 177 'tbd ', 'not_used ', 'not_used ', & 178 'not_used ' /) 179 180 CHARACTER (LEN=20), DIMENSION(fl_max) :: dofl_dim_label_x 181 CHARACTER (LEN=20), DIMENSION(fl_max) :: dofl_dim_label_y 182 CHARACTER (LEN=20), DIMENSION(fl_max) :: dofl_dim_label_z 183 CHARACTER (LEN=20), DIMENSION(fl_max*var_fl_max) :: dofl_label 184 CHARACTER (LEN=20), DIMENSION(fl_max*var_fl_max) :: dofl_unit 185 186 CHARACTER (LEN=7), DIMENSION(dopr_norm_num) :: dopr_norm_names = & 187 (/ 'wtheta0', 'ws2 ', 'tsw2 ', 'ws3 ', 'ws2tsw ', 'wstsw2 ', 'z_i ' /) 188 189 CHARACTER (LEN=7), DIMENSION(dopr_norm_num) :: dopr_norm_longnames = & 190 (/ 'wtheta0', 'w*2 ', 't*w2 ', 'w*3 ', 'w*2t*w ', 'w*t*w2 ', 'z_i ' /) 191 192 CHARACTER (LEN=9), DIMENSION(300) :: dopr_unit = 'unknown' 193 194 CHARACTER (LEN=7), DIMENSION(dopts_num) :: dopts_label = & 195 (/ 'tnpt ', 'x_ ', 'y_ ', 'z_ ', 'z_abs ', 'u ', & 196 'v ', 'w ', 'u" ', 'v" ', 'w" ', 'npt_up ', & 197 'w_up ', 'w_down ', 'radius ', 'r_min ', 'r_max ', 'npt_max', & 198 'npt_min', 'x*2 ', 'y*2 ', 'z*2 ', 'u*2 ', 'v*2 ', & 199 'w*2 ', 'u"2 ', 'v"2 ', 'w"2 ', 'npt*2 ' /) 200 201 CHARACTER (LEN=7), DIMENSION(dopts_num) :: dopts_unit = & 202 (/ 'number ', 'm ', 'm ', 'm ', 'm ', 'm/s ', & 203 'm/s ', 'm/s ', 'm/s ', 'm/s ', 'm/s ', 'number ', & 204 'm/s ', 'm/s ', 'm ', 'm ', 'm ', 'number ', & 205 'number ', 'm2 ', 'm2 ', 'm2 ', 'm2/s2 ', 'm2/s2 ', & 206 'm2/s2 ', 'm2/s2 ', 'm2/s2 ', 'm2/s2 ', 'number2' /) 207 208 CHARACTER (LEN=13), DIMENSION(dots_max) :: dots_label = & 209 (/ 'E ', 'E* ', 'dt ', & 210 'us* ', 'th* ', 'umax ', & 211 'vmax ', 'wmax ', 'div_new ', & 212 'div_old ', 'zi_wtheta ', 'zi_theta ', & 213 'w* ', 'w"theta"0 ', 'w"theta" ', & 214 'wtheta ', 'theta(0) ', 'theta(z_mo) ', & 215 'w"u"0 ', 'w"v"0 ', 'w"q"0 ', & 216 'ol ', 'q* ', 'w"s" ', & 217 's* ', 'ghf ', 'qsws_liq ', & 218 'qsws_soil ', 'qsws_veg ', 'r_a ', & 219 'r_s ', & 220 'rad_net ', 'rad_lw_in ', 'rad_lw_out ', & 221 'rad_sw_in ', 'rad_sw_out ', 'rrtm_aldif ', & 222 'rrtm_aldir ', 'rrtm_asdif ', 'rrtm_asdir ', & 213 223 ( 'unknown ', i9 = 1, dots_max-40 ) /) 214 224 215 CHARACTER (LEN=13), DIMENSION(dots_max) :: dots_unit = &216 (/ 'm2/s2 ', 'm2/s2 ', 's ', &217 'm/s ', 'K ', 'm/s ', &218 'm/s ', 'm/s ', 's-1 ', &219 's-1 ', 'm ', 'm ', &220 'm/s ', 'K m/s ', 'K m/s ', &221 'K m/s ', 'K ', 'K ', &222 'm2/s2 ', 'm2/s2 ', 'kg m/s ', &223 'm ', 'kg/kg ', 'kg m/(kg s) ', &224 'kg/kg ', 'W/m2 ', 'W/m2 ', &225 'W/m2 ', 'W/m2 ', 's/m ', &226 's/m ', &227 'W/m2 ', 'W/m2 ', 'W/m2 ', &228 'W/m2 ', 'W/m2 ', ' ', &229 ' ', ' ', ' ', &225 CHARACTER (LEN=13), DIMENSION(dots_max) :: dots_unit = & 226 (/ 'm2/s2 ', 'm2/s2 ', 's ', & 227 'm/s ', 'K ', 'm/s ', & 228 'm/s ', 'm/s ', 's-1 ', & 229 's-1 ', 'm ', 'm ', & 230 'm/s ', 'K m/s ', 'K m/s ', & 231 'K m/s ', 'K ', 'K ', & 232 'm2/s2 ', 'm2/s2 ', 'kg m/s ', & 233 'm ', 'kg/kg ', 'kg m/(kg s) ', & 234 'kg/kg ', 'W/m2 ', 'W/m2 ', & 235 'W/m2 ', 'W/m2 ', 's/m ', & 236 's/m ', & 237 'W/m2 ', 'W/m2 ', 'W/m2 ', & 238 'W/m2 ', 'W/m2 ', ' ', & 239 ' ', ' ', ' ', & 230 240 ( 'unknown ', i9 = 1, dots_max-40 ) /) 231 241 232 CHARACTER (LEN=16) :: heatflux_output_unit !< unit for heatflux output 233 CHARACTER (LEN=16) :: waterflux_output_unit !< unit for waterflux output 234 CHARACTER (LEN=16) :: momentumflux_output_unit !< unit for momentumflux output 235 236 CHARACTER (LEN=9), DIMENSION(300) :: dopr_unit = 'unknown' 242 CHARACTER (LEN=20), DIMENSION(11) :: netcdf_precision = ' ' 237 243 238 244 CHARACTER (LEN=7), DIMENSION(0:1,500) :: do2d_unit, do3d_unit … … 260 266 ! 'not_used ' /) 261 267 262 CHARACTER(LEN=20), DIMENSION(11) :: netcdf_precision = ' ' 263 CHARACTER(LEN=40) :: netcdf_data_format_string 264 265 INTEGER(iwp) :: id_dim_agtnum, id_dim_time_agt, & 266 id_dim_time_fl, id_dim_time_pr, & 267 id_dim_time_pts, id_dim_time_sp, id_dim_time_ts, & 268 id_dim_x_sp, id_dim_y_sp, id_dim_zu_sp, id_dim_zw_sp, & 269 id_set_agt, id_set_fl, id_set_pr, id_set_prt, id_set_pts, & 270 id_set_sp, id_set_ts, id_var_agtnum, id_var_time_agt, & 271 id_var_time_fl, id_var_rnoa_agt, id_var_time_pr, & 272 id_var_time_pts, id_var_time_sp, id_var_time_ts, & 273 id_var_x_sp, id_var_y_sp, id_var_zu_sp, id_var_zw_sp, & 268 INTEGER(iwp) :: dofl_time_count 269 270 INTEGER(iwp) :: id_dim_agtnum, id_dim_time_agt, id_dim_time_fl, id_dim_time_pr, & 271 id_dim_time_pts, id_dim_time_sp, id_dim_time_ts, id_dim_x_sp, id_dim_y_sp, & 272 id_dim_zu_sp, id_dim_zw_sp, & 273 id_set_agt, id_set_fl, id_set_pr, id_set_prt, id_set_pts, id_set_sp, & 274 id_set_ts, & 275 id_var_agtnum, id_var_time_agt, id_var_time_fl, id_var_rnoa_agt, & 276 id_var_time_pr, id_var_time_pts, id_var_time_sp, id_var_time_ts, id_var_x_sp, & 277 id_var_y_sp, id_var_zu_sp, id_var_zw_sp, & 274 278 nc_stat 275 279 276 277 INTEGER(iwp), DIMENSION(0:1) :: id_dim_time_xy, id_dim_time_xz, & 278 id_dim_time_yz, id_dim_time_3d, id_dim_x_xy, id_dim_xu_xy, & 279 id_dim_x_xz, id_dim_xu_xz, id_dim_x_yz, id_dim_xu_yz, & 280 id_dim_x_3d, id_dim_xu_3d, id_dim_y_xy, id_dim_yv_xy, & 281 id_dim_y_xz, id_dim_yv_xz, id_dim_y_yz, id_dim_yv_yz, & 282 id_dim_y_3d, id_dim_yv_3d, id_dim_zs_xy, id_dim_zs_xz, & 283 id_dim_zs_yz, id_dim_zs_3d, id_dim_zpc_3d, & 284 id_dim_zu_xy, id_dim_zu1_xy, & 285 id_dim_zu_xz, id_dim_zu_yz, id_dim_zu_3d, id_dim_zw_xy, & 286 id_dim_zw_xz, id_dim_zw_yz, id_dim_zw_3d, id_set_xy, & 287 id_set_xz, id_set_yz, id_set_3d, id_var_ind_x_yz, & 288 id_var_ind_y_xz, id_var_ind_z_xy, id_var_time_xy, & 289 id_var_time_xz, id_var_time_yz, id_var_time_3d, id_var_x_xy, & 290 id_var_xu_xy, id_var_x_xz, id_var_xu_xz, id_var_x_yz, & 291 id_var_xu_yz, id_var_x_3d, id_var_xu_3d, id_var_y_xy, & 292 id_var_yv_xy, id_var_y_xz, id_var_yv_xz, id_var_y_yz, & 293 id_var_yv_yz, id_var_y_3d, id_var_yv_3d, id_var_zs_xy, & 294 id_var_zs_xz, id_var_zs_yz, id_var_zs_3d, id_var_zpc_3d, & 295 id_var_zusi_xy, id_var_zusi_3d, id_var_zu_xy, id_var_zu1_xy, id_var_zu_xz, & 296 id_var_zu_yz, id_var_zu_3d, id_var_zwwi_xy, id_var_zwwi_3d, & 297 id_var_zw_xy, id_var_zw_xz, id_var_zw_yz, id_var_zw_3d 298 299 INTEGER(iwp), DIMENSION(0:2,0:1) :: id_var_eutm_3d, id_var_nutm_3d, & 300 id_var_eutm_xy, id_var_nutm_xy, & 301 id_var_eutm_xz, id_var_nutm_xz, & 302 id_var_eutm_yz, id_var_nutm_yz 303 304 INTEGER(iwp), DIMENSION(0:2,0:1) :: id_var_lat_3d, id_var_lon_3d, & 305 id_var_lat_xy, id_var_lon_xy, & 306 id_var_lat_xz, id_var_lon_xz, & 307 id_var_lat_yz, id_var_lon_yz 308 309 INTEGER :: netcdf_data_format = 2 !< NetCDF3 64bit offset format 310 INTEGER :: netcdf_deflate = 0 !< NetCDF compression, default: no 311 !< compression 312 313 INTEGER(iwp) :: dofl_time_count 314 INTEGER(iwp), DIMENSION(10) :: id_var_dospx, id_var_dospy 315 INTEGER(iwp), DIMENSION(20) :: id_var_agt 316 ! INTEGER(iwp), DIMENSION(20) :: id_var_prt 317 INTEGER(iwp), DIMENSION(11) :: nc_precision 280 INTEGER :: netcdf_data_format = 2 !< NetCDF3 64bit offset format 281 INTEGER :: netcdf_deflate = 0 !< NetCDF compression, default: no 282 !< compression 283 284 INTEGER(iwp), DIMENSION(20) :: id_var_agt 285 INTEGER(iwp), DIMENSION(10) :: id_var_dospx, id_var_dospy 318 286 INTEGER(iwp), DIMENSION(dopr_norm_num) :: id_var_norm_dopr 319 320 INTEGER(iwp), DIMENSION(fl_max) :: id_dim_x_fl, id_dim_y_fl, id_dim_z_fl 321 INTEGER(iwp), DIMENSION(fl_max) :: id_var_x_fl, id_var_y_fl, id_var_z_fl 322 323 CHARACTER (LEN=20), DIMENSION(fl_max*var_fl_max) :: dofl_label 324 CHARACTER (LEN=20), DIMENSION(fl_max*var_fl_max) :: dofl_unit 325 CHARACTER (LEN=20), DIMENSION(fl_max) :: dofl_dim_label_x 326 CHARACTER (LEN=20), DIMENSION(fl_max) :: dofl_dim_label_y 327 CHARACTER (LEN=20), DIMENSION(fl_max) :: dofl_dim_label_z 328 287 ! INTEGER(iwp), DIMENSION(20) :: id_var_prt 288 INTEGER(iwp), DIMENSION(11) :: nc_precision 289 290 INTEGER(iwp), DIMENSION(fl_max) :: id_dim_x_fl, id_dim_y_fl, id_dim_z_fl 329 291 INTEGER(iwp), DIMENSION(fl_max*var_fl_max) :: id_var_dofl 292 INTEGER(iwp), DIMENSION(fl_max) :: id_var_x_fl, id_var_y_fl, id_var_z_fl 293 294 INTEGER(iwp), DIMENSION(0:1) :: id_dim_time_xy, id_dim_time_xz, id_dim_time_yz, & 295 id_dim_time_3d, id_dim_x_xy, id_dim_xu_xy, id_dim_x_xz, & 296 id_dim_xu_xz, id_dim_x_yz, id_dim_xu_yz, id_dim_x_3d, & 297 id_dim_xu_3d, id_dim_y_xy, id_dim_yv_xy, id_dim_y_xz, & 298 id_dim_yv_xz, id_dim_y_yz, id_dim_yv_yz, id_dim_y_3d, & 299 id_dim_yv_3d, id_dim_zs_xy, id_dim_zs_xz, id_dim_zs_yz, & 300 id_dim_zs_3d, id_dim_zpc_3d, id_dim_zu_xy, id_dim_zu1_xy, & 301 id_dim_zu_xz, id_dim_zu_yz, id_dim_zu_3d, id_dim_zw_xy, & 302 id_dim_zw_xz, id_dim_zw_yz, id_dim_zw_3d, & 303 id_set_xy, id_set_xz, id_set_yz, id_set_3d, & 304 id_var_ind_x_yz, id_var_ind_y_xz, id_var_ind_z_xy, & 305 id_var_time_xy, id_var_time_xz, id_var_time_yz, & 306 id_var_time_3d, id_var_x_xy, id_var_xu_xy, id_var_x_xz, & 307 id_var_xu_xz, id_var_x_yz, id_var_xu_yz, id_var_x_3d, & 308 id_var_xu_3d, id_var_y_xy, id_var_yv_xy, id_var_y_xz, & 309 id_var_yv_xz, id_var_y_yz, id_var_yv_yz, id_var_y_3d, & 310 id_var_yv_3d, id_var_zs_xy, id_var_zs_xz, id_var_zs_yz, & 311 id_var_zs_3d, id_var_zpc_3d, id_var_zusi_xy, id_var_zusi_3d, & 312 id_var_zu_xy, id_var_zu1_xy, id_var_zu_xz, id_var_zu_yz, & 313 id_var_zu_3d, id_var_zwwi_xy, id_var_zwwi_3d, id_var_zw_xy, & 314 id_var_zw_xz, id_var_zw_yz, id_var_zw_3d 315 316 INTEGER(iwp), DIMENSION(0:2,0:1) :: id_var_eutm_3d, id_var_eutm_xy, id_var_eutm_xz, & 317 id_var_eutm_yz, & 318 id_var_nutm_3d, id_var_nutm_xy, id_var_nutm_xz, & 319 id_var_nutm_yz 320 321 INTEGER(iwp), DIMENSION(0:2,0:1) :: id_var_lat_3d, id_var_lat_xy, id_var_lat_xz, & 322 id_var_lat_yz, & 323 id_var_lon_3d, id_var_lon_xy, id_var_lon_xz, id_var_lon_yz 324 330 325 331 326 INTEGER(iwp), DIMENSION(dopts_num,0:10) :: id_var_dopts 332 327 INTEGER(iwp), DIMENSION(0:1,500) :: id_var_do2d, id_var_do3d 333 INTEGER(iwp), DIMENSION(100,0:99) :: id_dim_z_pr, id_var_dopr, & 334 id_var_z_pr 328 INTEGER(iwp), DIMENSION(100,0:99) :: id_dim_z_pr, id_var_dopr, id_var_z_pr 335 329 INTEGER(iwp), DIMENSION(dots_max,0:99) :: id_var_dots 336 330 … … 339 333 CHARACTER (LEN=7), DIMENSION(max_masks,0:1,100) :: domask_unit 340 334 335 INTEGER(iwp), DIMENSION(1:max_masks,0:1) :: id_dim_time_mask, id_dim_x_mask, id_dim_xu_mask, & 336 id_dim_y_mask, id_dim_yv_mask, id_dim_zs_mask, & 337 id_dim_zu_mask, id_dim_zw_mask, & 338 id_set_mask, & 339 id_var_time_mask, id_var_x_mask, id_var_xu_mask, & 340 id_var_y_mask, id_var_yv_mask, id_var_zs_mask, & 341 id_var_zu_mask, id_var_zw_mask, & 342 id_var_zusi_mask, id_var_zwwi_mask 343 344 345 INTEGER(iwp), DIMENSION(1:max_masks,0:1,100) :: id_var_domask 346 INTEGER(iwp), DIMENSION(0:2,1:max_masks,0:1) :: id_var_eutm_mask, id_var_nutm_mask 347 INTEGER(iwp), DIMENSION(0:2,1:max_masks,0:1) :: id_var_lat_mask, id_var_lon_mask 348 349 341 350 LOGICAL :: output_for_t0 = .FALSE. 342 351 343 INTEGER(iwp), DIMENSION(1:max_masks,0:1) :: id_dim_time_mask, id_dim_x_mask, &344 id_dim_xu_mask, id_dim_y_mask, id_dim_yv_mask, id_dim_zs_mask, &345 id_dim_zu_mask, id_dim_zw_mask, &346 id_set_mask, &347 id_var_time_mask, id_var_x_mask, id_var_xu_mask, &348 id_var_y_mask, id_var_yv_mask, id_var_zs_mask, &349 id_var_zu_mask, id_var_zw_mask, &350 id_var_zusi_mask, id_var_zwwi_mask351 352 INTEGER(iwp), DIMENSION(0:2,1:max_masks,0:1) :: id_var_eutm_mask, &353 id_var_nutm_mask354 355 INTEGER(iwp), DIMENSION(0:2,1:max_masks,0:1) :: id_var_lat_mask, &356 id_var_lon_mask357 358 INTEGER(iwp), DIMENSION(1:max_masks,0:1,100) :: id_var_domask359 360 352 REAL(wp) :: fill_value = -9999.0_wp !< value for the _FillValue attribute 361 353 362 354 363 PUBLIC dofl_dim_label_x, dofl_dim_label_y, dofl_dim_label_z, dofl_label, & 364 dofl_time_count, dofl_unit, domask_unit, dopr_unit, dopts_num, & 365 dots_label, dots_max, dots_num, dots_rad, dots_soil, dots_unit, & 366 do2d_unit, do3d_unit, fill_value, id_set_agt, id_set_fl, & 367 id_set_mask, id_set_pr, id_set_prt, id_set_pts, id_set_sp, & 368 id_set_ts, id_set_xy, id_set_xz, id_set_yz, id_set_3d, id_var_agt, & 369 id_var_domask, id_var_dofl, id_var_dopr, id_var_dopts, & 370 id_var_dospx, id_var_dospy, id_var_dots, id_var_do2d, id_var_do3d, & 371 id_var_norm_dopr, id_var_time_agt, id_var_time_fl, & 372 id_var_time_mask, id_var_time_pr, id_var_rnoa_agt, id_var_time_pts,& 373 id_var_time_sp, id_var_time_ts, & 374 id_var_time_xy, id_var_time_xz, id_var_time_yz, id_var_time_3d, & 375 id_var_x_fl, id_var_y_fl, id_var_z_fl, nc_stat, & 376 netcdf_data_format, netcdf_data_format_string, netcdf_deflate, & 377 netcdf_precision, output_for_t0, heatflux_output_unit, & 378 waterflux_output_unit, momentumflux_output_unit 355 PUBLIC dofl_dim_label_x, dofl_dim_label_y, dofl_dim_label_z, dofl_label, dofl_time_count, & 356 dofl_unit, domask_unit, dopr_unit, dopts_num, dots_label, dots_max, dots_num, dots_rad,& 357 dots_soil, dots_unit, do2d_unit, do3d_unit, fill_value, id_set_agt, id_set_fl, & 358 id_set_mask, id_set_pr, id_set_prt, id_set_pts, id_set_sp, id_set_ts, id_set_xy, & 359 id_set_xz, id_set_yz, id_set_3d, id_var_agt, id_var_domask, id_var_dofl, id_var_dopr, & 360 id_var_dopts, id_var_dospx, id_var_dospy, id_var_dots, id_var_do2d, id_var_do3d, & 361 id_var_norm_dopr, id_var_time_agt, id_var_time_fl, id_var_time_mask, id_var_time_pr, & 362 id_var_rnoa_agt, id_var_time_pts, id_var_time_sp, id_var_time_ts, id_var_time_xy, & 363 id_var_time_xz, id_var_time_yz, id_var_time_3d, id_var_x_fl, id_var_y_fl, id_var_z_fl, & 364 nc_stat, netcdf_data_format, netcdf_data_format_string, netcdf_deflate, & 365 netcdf_precision, output_for_t0, heatflux_output_unit, waterflux_output_unit, & 366 momentumflux_output_unit 379 367 380 368 SAVE … … 412 400 END INTERFACE netcdf_open_write_file 413 401 414 PUBLIC netcdf_create_att, netcdf_create_dim, netcdf_create_file, & 415 netcdf_create_global_atts, netcdf_create_var, netcdf_define_header, & 416 netcdf_handle_error, netcdf_open_write_file 402 PUBLIC netcdf_create_att, netcdf_create_dim, netcdf_create_file, netcdf_create_global_atts, & 403 netcdf_create_var, netcdf_define_header, netcdf_handle_error, netcdf_open_write_file 417 404 418 405 CONTAINS … … 422 409 #if defined( __netcdf ) 423 410 424 USE arrays_3d, &411 USE arrays_3d, & 425 412 ONLY: zu, zw 426 413 427 USE biometeorology_mod, &414 USE biometeorology_mod, & 428 415 ONLY: bio_define_netcdf_grid 429 416 430 USE chemistry_model_mod, &417 USE chemistry_model_mod, & 431 418 ONLY: chem_define_netcdf_grid 432 419 433 USE basic_constants_and_equations_mod, &434 ONLY: convert_utm_to_geographic, &420 USE basic_constants_and_equations_mod, & 421 ONLY: convert_utm_to_geographic, & 435 422 pi 436 423 437 USE control_parameters, & 438 ONLY: agent_time_unlimited, air_chemistry, averaging_interval, & 439 averaging_interval_pr, data_output_pr, domask, dopr_n, & 440 dopr_time_count, dopts_time_count, dots_time_count, & 441 do2d, do2d_at_begin, do2d_xz_time_count, do3d, do3d_at_begin, & 442 do2d_yz_time_count, dt_data_output_av, dt_do2d_xy, dt_do2d_xz, & 443 dt_do2d_yz, dt_do3d, dt_write_agent_data, mask_size, & 444 do2d_xy_time_count, do3d_time_count, domask_time_count, & 445 end_time, indoor_model, land_surface, & 446 mask_size_l, mask_i, mask_i_global, mask_j, mask_j_global, & 447 mask_k_global, mask_surface, & 448 message_string, ntdim_2d_xy, ntdim_2d_xz, & 449 ntdim_2d_yz, ntdim_3d, nz_do3d, ocean_mode, plant_canopy, & 450 run_description_header, salsa, section, simulated_time, & 451 simulated_time_at_begin, skip_time_data_output_av, & 452 skip_time_do2d_xy, skip_time_do2d_xz, skip_time_do2d_yz, & 453 skip_time_do3d, topography, num_leg, num_var_fl, & 454 urban_surface 455 456 USE diagnostic_output_quantities_mod, & 424 USE control_parameters, & 425 ONLY: agent_time_unlimited, air_chemistry, averaging_interval, averaging_interval_pr, & 426 data_output_pr, domask, dopr_n, dopr_time_count, dopts_time_count, dots_time_count, & 427 do2d, do2d_at_begin, do2d_xz_time_count, do3d, do3d_at_begin, do2d_yz_time_count, & 428 dt_data_output_av, dt_do2d_xy, dt_do2d_xz, dt_do2d_yz, dt_do3d, dt_write_agent_data,& 429 mask_size, do2d_xy_time_count, do3d_time_count, domask_time_count, end_time, & 430 indoor_model, land_surface, mask_size_l, mask_i, mask_i_global, mask_j, & 431 mask_j_global, mask_k_global, mask_surface, message_string, ntdim_2d_xy, & 432 ntdim_2d_xz, ntdim_2d_yz, ntdim_3d, nz_do3d, ocean_mode, plant_canopy, & 433 run_description_header, salsa, section, simulated_time, simulated_time_at_begin, & 434 skip_time_data_output_av, skip_time_do2d_xy, skip_time_do2d_xz, skip_time_do2d_yz, & 435 skip_time_do3d, topography, num_leg, num_var_fl, urban_surface 436 437 USE diagnostic_output_quantities_mod, & 457 438 ONLY: doq_define_netcdf_grid 458 439 459 USE grid_variables, &440 USE grid_variables, & 460 441 ONLY: dx, dy, zu_s_inner, zw_w_inner 461 442 462 USE gust_mod, &443 USE gust_mod, & 463 444 ONLY: gust_define_netcdf_grid, gust_module_enabled 464 445 465 USE indices, &446 USE indices, & 466 447 ONLY: nx, nxl, nxr, ny, nys, nyn, nz ,nzb, nzt 467 448 468 449 USE kinds 469 450 470 USE indoor_model_mod, &451 USE indoor_model_mod, & 471 452 ONLY: im_define_netcdf_grid 472 453 473 USE land_surface_model_mod, &454 USE land_surface_model_mod, & 474 455 ONLY: lsm_define_netcdf_grid, nzb_soil, nzt_soil, nzs, zs 475 456 476 USE ocean_mod, &457 USE ocean_mod, & 477 458 ONLY: ocean_define_netcdf_grid 478 459 479 460 USE pegrid 480 461 481 USE particle_attributes, &462 USE particle_attributes, & 482 463 ONLY: number_of_particle_groups 483 464 484 USE plant_canopy_model_mod, &465 USE plant_canopy_model_mod, & 485 466 ONLY: pch_index, pcm_define_netcdf_grid 486 467 487 USE profil_parameter, &468 USE profil_parameter, & 488 469 ONLY: crmax, cross_profiles, dopr_index, profile_columns, profile_rows 489 470 490 USE radiation_model_mod, &471 USE radiation_model_mod, & 491 472 ONLY: radiation, radiation_define_netcdf_grid 492 473 493 USE salsa_mod, &474 USE salsa_mod, & 494 475 ONLY: salsa_define_netcdf_grid 495 476 496 USE spectra_mod, & 497 ONLY: averaging_interval_sp, comp_spectra_level, data_output_sp, dosp_time_count, spectra_direction 498 499 USE statistics, & 477 USE spectra_mod, & 478 ONLY: averaging_interval_sp, comp_spectra_level, data_output_sp, dosp_time_count, & 479 spectra_direction 480 481 USE statistics, & 500 482 ONLY: hom, statistic_regions 501 483 502 USE turbulence_closure_mod, &484 USE turbulence_closure_mod, & 503 485 ONLY: tcm_define_netcdf_grid 504 486 505 USE urban_surface_mod, &487 USE urban_surface_mod, & 506 488 ONLY: usm_define_netcdf_grid 507 489 508 USE user, &490 USE user, & 509 491 ONLY: user_module_enabled, user_define_netcdf_grid 510 492 … … 513 495 IMPLICIT NONE 514 496 515 CHARACTER (LEN=3) :: suffix !<516 497 CHARACTER (LEN=2), INTENT (IN) :: callmode !< 498 CHARACTER (LEN=4000) :: char_cross_profiles !< 517 499 CHARACTER (LEN=4) :: grid_x !< 518 500 CHARACTER (LEN=4) :: grid_y !< 519 501 CHARACTER (LEN=4) :: grid_z !< 520 502 CHARACTER (LEN=6) :: mode !< 503 CHARACTER (LEN=20) :: netcdf_var_name !< 521 504 CHARACTER (LEN=10) :: precision !< 505 CHARACTER (LEN=3) :: suffix !< 506 CHARACTER (LEN=80) :: time_average_text !< 507 CHARACTER (LEN=varnamelength) :: trimvar !< TRIM of output-variable string 522 508 CHARACTER (LEN=10) :: var !< 523 CHARACTER (LEN=20) :: netcdf_var_name !<524 CHARACTER (LEN=varnamelength) :: trimvar !< TRIM of output-variable string525 CHARACTER (LEN=80) :: time_average_text !<526 CHARACTER (LEN=4000) :: char_cross_profiles !<527 509 CHARACTER (LEN=4000) :: var_list !< 528 510 CHARACTER (LEN=4000) :: var_list_old !< … … 545 527 INTEGER(iwp) :: k !< 546 528 INTEGER(iwp) :: kk !< 529 INTEGER(iwp) :: l !< 547 530 INTEGER(iwp) :: mid !< masked output running index 548 531 INTEGER(iwp) :: ns !< … … 551 534 INTEGER(iwp) :: ntime_count !< number of time levels found in file 552 535 INTEGER(iwp) :: nz_old !< 553 INTEGER(iwp) :: l !<554 536 555 537 INTEGER(iwp), SAVE :: oldmode !< … … 566 548 INTEGER(iwp), DIMENSION(1:crmax) :: cross_profiles_numb !< 567 549 568 LOGICAL :: found !<569 570 550 LOGICAL, INTENT (INOUT) :: extend !< 551 LOGICAL :: found !< 571 552 572 553 LOGICAL, SAVE :: init_netcdf = .FALSE. !< … … 591 572 IF ( .NOT. init_netcdf ) THEN 592 573 ! 593 !-- Check and set accuracy for netCDF output. First set default value 574 !-- Check and set accuracy for netCDF output. First set default value. 594 575 nc_precision = NF90_REAL4 595 576 … … 598 579 j = INDEX( netcdf_precision(i), '_' ) 599 580 IF ( j == 0 ) THEN 600 WRITE ( message_string, * ) 'netcdf_precision must contain a ', &601 '"_"netcdf_precision(', i, ')="', &581 WRITE ( message_string, * ) 'netcdf_precision must contain a ', & 582 '"_"netcdf_precision(', i, ')="', & 602 583 TRIM( netcdf_precision(i) ),'"' 603 584 CALL message( 'netcdf_define_header', 'PA0241', 2, 2, 0, 6, 0 ) … … 612 593 j = NF90_REAL8 613 594 ELSE 614 WRITE ( message_string, * ) 'illegal netcdf precision: ', &615 'netcdf_precision(', i, ')="', &595 WRITE ( message_string, * ) 'illegal netcdf precision: ', & 596 'netcdf_precision(', i, ')="', & 616 597 TRIM( netcdf_precision(i) ),'"' 617 598 CALL message( 'netcdf_define_header', 'PA0242', 1, 2, 0, 6, 0 ) … … 645 626 646 627 CASE DEFAULT 647 WRITE ( message_string, * ) 'unknown variable in ' // & 648 'initialization_parameters ', & 649 'assignment: netcdf_precision(', i, ')="', & 628 WRITE ( message_string, * ) 'unknown variable in ' // 'initialization_parameters ',& 629 'assignment: netcdf_precision(', i, ')="', & 650 630 TRIM( netcdf_precision(i) ),'"' 651 631 CALL message( 'netcdf_define_header', 'PA0243', 1, 2, 0, 6, 0 ) … … 660 640 !-- Check for allowed parameter range 661 641 IF ( netcdf_deflate < 0 .OR. netcdf_deflate > 9 ) THEN 662 WRITE ( message_string, '(A,I3,A)' ) 'netcdf_deflate out of ' // & 663 'range & given value: ', netcdf_deflate, & 664 ', allowed range: 0-9' 642 WRITE ( message_string, '(A,I3,A)' ) 'netcdf_deflate out of ' // 'range & given value: ',& 643 netcdf_deflate, ', allowed range: 0-9' 665 644 CALL message( 'netcdf_define_header', 'PA0355', 2, 2, 0, 6, 0 ) 666 645 ENDIF … … 687 666 688 667 ! 689 !-- Select the mode to be processed. Possibilities are 3d, ma (mask), xy, xz, 690 !-- yz, pr (profiles), ps (particle timeseries), fl (flight data), ts 691 !-- (timeseries) or sp (spectra) 668 !-- Select the mode to be processed. Possibilities are 3d, ma (mask), xy, xz, yz, pr (profiles), ps 669 !-- (particle timeseries), fl (flight data), ts (timeseries) or sp (spectra). 692 670 SELECT CASE ( mode ) 693 671 … … 695 673 696 674 ! 697 !-- decompose actual parameter file_id (=formal parameter av) into 698 !-- mid and av 675 !-- Decompose actual parameter file_id (=formal parameter av) into mid and av 699 676 file_id = av 700 677 IF ( file_id <= 200+max_masks ) THEN … … 709 686 !-- Define some global attributes of the dataset 710 687 IF ( av == 0 ) THEN 711 CALL netcdf_create_global_atts( id_set_mask(mid,av), 'podsmasked', TRIM( run_description_header ), 464 ) 688 CALL netcdf_create_global_atts( id_set_mask(mid,av), 'podsmasked', & 689 TRIM( run_description_header ), 464 ) 712 690 time_average_text = ' ' 713 691 ELSE 714 CALL netcdf_create_global_atts( id_set_mask(mid,av), 'podsmasked', TRIM( run_description_header ), 464 ) 692 CALL netcdf_create_global_atts( id_set_mask(mid,av), 'podsmasked', & 693 TRIM( run_description_header ), 464 ) 715 694 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval 716 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), NF90_GLOBAL, 'time_avg', &695 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), NF90_GLOBAL, 'time_avg', & 717 696 TRIM( time_average_text ) ) 718 697 CALL netcdf_handle_error( 'netcdf_define_header', 466 ) … … 721 700 ! 722 701 !-- Define time coordinate for volume data (unlimited dimension) 723 CALL netcdf_create_dim( id_set_mask(mid,av), 'time', NF90_UNLIMITED, &702 CALL netcdf_create_dim( id_set_mask(mid,av), 'time', NF90_UNLIMITED, & 724 703 id_dim_time_mask(mid,av), 467 ) 725 CALL netcdf_create_var( id_set_mask(mid,av), &726 (/ id_dim_time_mask(mid,av) /), 'time', &727 NF90_DOUBLE, id_var_time_mask(mid,av), &704 CALL netcdf_create_var( id_set_mask(mid,av), & 705 (/ id_dim_time_mask(mid,av) /), 'time', & 706 NF90_DOUBLE, id_var_time_mask(mid,av), & 728 707 'seconds', 'time', 468, 469, 000 ) 729 CALL netcdf_create_att( id_set_mask(mid,av), id_var_time_mask(mid,av), 'standard_name', 'time', 000) 708 CALL netcdf_create_att( id_set_mask(mid,av), id_var_time_mask(mid,av), & 709 'standard_name', 'time', 000) 730 710 CALL netcdf_create_att( id_set_mask(mid,av), id_var_time_mask(mid,av), 'axis', 'T', 000) 731 711 … … 734 714 IF ( mask_surface(mid) ) THEN 735 715 ! 736 !-- In case of terrain-following output, the vertical dimensions are 737 !-- indices, not meters 738 CALL netcdf_create_dim( id_set_mask(mid,av), 'ku_above_surf', & 739 mask_size(mid,3), id_dim_zu_mask(mid,av), & 716 !-- In case of terrain-following output, the vertical dimensions are indices, not meters. 717 CALL netcdf_create_dim( id_set_mask(mid,av), 'ku_above_surf', & 718 mask_size(mid,3), id_dim_zu_mask(mid,av), & 740 719 470 ) 741 CALL netcdf_create_var( id_set_mask(mid,av), &742 (/ id_dim_zu_mask(mid,av) /), &743 'ku_above_surf', &744 NF90_DOUBLE, id_var_zu_mask(mid,av), &745 '1', 'grid point above terrain', &720 CALL netcdf_create_var( id_set_mask(mid,av), & 721 (/ id_dim_zu_mask(mid,av) /), & 722 'ku_above_surf', & 723 NF90_DOUBLE, id_var_zu_mask(mid,av), & 724 '1', 'grid point above terrain', & 746 725 471, 472, 000 ) 747 CALL netcdf_create_att( id_set_mask(mid,av), & 748 id_var_zu_mask(mid,av), 'axis', 'Z', 000) 749 750 CALL netcdf_create_dim( id_set_mask(mid,av), 'kw_above_surf', & 751 mask_size(mid,3), id_dim_zw_mask(mid,av), & 726 CALL netcdf_create_att( id_set_mask(mid,av), id_var_zu_mask(mid,av), 'axis', 'Z', 000) 727 728 CALL netcdf_create_dim( id_set_mask(mid,av), 'kw_above_surf', & 729 mask_size(mid,3), id_dim_zw_mask(mid,av), & 752 730 473 ) 753 CALL netcdf_create_var( id_set_mask(mid,av), &754 (/ id_dim_zw_mask(mid,av) /), &755 'kw_above_surf', &756 NF90_DOUBLE, id_var_zw_mask(mid,av), &757 '1', 'grid point above terrain', &731 CALL netcdf_create_var( id_set_mask(mid,av), & 732 (/ id_dim_zw_mask(mid,av) /), & 733 'kw_above_surf', & 734 NF90_DOUBLE, id_var_zw_mask(mid,av), & 735 '1', 'grid point above terrain', & 758 736 474, 475, 000 ) 759 CALL netcdf_create_att( id_set_mask(mid,av), & 760 id_var_zw_mask(mid,av), 'axis', 'Z', 000) 737 CALL netcdf_create_att( id_set_mask(mid,av),id_var_zw_mask(mid,av), 'axis', 'Z', 000) 761 738 ELSE 762 739 ! 763 740 !-- Define vertical coordinate grid (zu grid) 764 CALL netcdf_create_dim( id_set_mask(mid,av), 'zu_3d', &765 mask_size(mid,3), id_dim_zu_mask(mid,av), &741 CALL netcdf_create_dim( id_set_mask(mid,av), 'zu_3d', & 742 mask_size(mid,3), id_dim_zu_mask(mid,av), & 766 743 470 ) 767 CALL netcdf_create_var( id_set_mask(mid,av), &768 (/ id_dim_zu_mask(mid,av) /), 'zu_3d', &769 NF90_DOUBLE, id_var_zu_mask(mid,av), &744 CALL netcdf_create_var( id_set_mask(mid,av), & 745 (/ id_dim_zu_mask(mid,av) /), 'zu_3d', & 746 NF90_DOUBLE, id_var_zu_mask(mid,av), & 770 747 'meters', '', 471, 472, 000 ) 771 CALL netcdf_create_att( id_set_mask(mid,av), & 772 id_var_zu_mask(mid,av), 'axis', 'Z', 000) 748 CALL netcdf_create_att( id_set_mask(mid,av), id_var_zu_mask(mid,av), 'axis', 'Z', 000) 773 749 ! 774 750 !-- Define vertical coordinate grid (zw grid) 775 CALL netcdf_create_dim( id_set_mask(mid,av), 'zw_3d', &776 mask_size(mid,3), id_dim_zw_mask(mid,av), &751 CALL netcdf_create_dim( id_set_mask(mid,av), 'zw_3d', & 752 mask_size(mid,3), id_dim_zw_mask(mid,av), & 777 753 473 ) 778 CALL netcdf_create_var( id_set_mask(mid,av), &779 (/ id_dim_zw_mask(mid,av) /), 'zw_3d', &780 NF90_DOUBLE, id_var_zw_mask(mid,av), &754 CALL netcdf_create_var( id_set_mask(mid,av), & 755 (/ id_dim_zw_mask(mid,av) /), 'zw_3d', & 756 NF90_DOUBLE, id_var_zw_mask(mid,av), & 781 757 'meters', '', 474, 475, 000 ) 782 CALL netcdf_create_att( id_set_mask(mid,av), & 783 id_var_zw_mask(mid,av), 'axis', 'Z', 000) 758 CALL netcdf_create_att( id_set_mask(mid,av), id_var_zw_mask(mid,av), 'axis', 'Z', 000) 784 759 ENDIF 785 760 ! 786 761 !-- Define x-axis (for scalar position) 787 CALL netcdf_create_dim( id_set_mask(mid,av), 'x', mask_size(mid,1), &762 CALL netcdf_create_dim( id_set_mask(mid,av), 'x', mask_size(mid,1), & 788 763 id_dim_x_mask(mid,av), 476 ) 789 CALL netcdf_create_var( id_set_mask(mid,av), &790 (/ id_dim_x_mask(mid,av) /), 'x', &791 NF90_DOUBLE, id_var_x_mask(mid,av), &764 CALL netcdf_create_var( id_set_mask(mid,av), & 765 (/ id_dim_x_mask(mid,av) /), 'x', & 766 NF90_DOUBLE, id_var_x_mask(mid,av), & 792 767 'meters', '', 477, 478, 000 ) 793 CALL netcdf_create_att( id_set_mask(mid,av), id_var_x_mask(mid,av), & 794 'axis', 'X', 000) 768 CALL netcdf_create_att( id_set_mask(mid,av), id_var_x_mask(mid,av), 'axis', 'X', 000) 795 769 ! 796 770 !-- Define x-axis (for u position) 797 CALL netcdf_create_dim( id_set_mask(mid,av), 'xu', mask_size(mid,1), &771 CALL netcdf_create_dim( id_set_mask(mid,av), 'xu', mask_size(mid,1), & 798 772 id_dim_xu_mask(mid,av), 479 ) 799 CALL netcdf_create_var( id_set_mask(mid,av), &800 (/ id_dim_xu_mask(mid,av) /), 'xu', &801 NF90_DOUBLE, id_var_xu_mask(mid,av), &773 CALL netcdf_create_var( id_set_mask(mid,av), & 774 (/ id_dim_xu_mask(mid,av) /), 'xu', & 775 NF90_DOUBLE, id_var_xu_mask(mid,av), & 802 776 'meters', '', 480, 481, 000 ) 803 CALL netcdf_create_att( id_set_mask(mid,av), id_var_xu_mask(mid,av), & 804 'axis', 'X', 000) 777 CALL netcdf_create_att( id_set_mask(mid,av), id_var_xu_mask(mid,av), 'axis', 'X', 000) 805 778 ! 806 779 !-- Define y-axis (for scalar position) 807 CALL netcdf_create_dim( id_set_mask(mid,av), 'y', mask_size(mid,2), &780 CALL netcdf_create_dim( id_set_mask(mid,av), 'y', mask_size(mid,2), & 808 781 id_dim_y_mask(mid,av), 482 ) 809 CALL netcdf_create_var( id_set_mask(mid,av), &810 (/ id_dim_y_mask(mid,av) /), 'y', &811 NF90_DOUBLE, id_var_y_mask(mid,av), &782 CALL netcdf_create_var( id_set_mask(mid,av), & 783 (/ id_dim_y_mask(mid,av) /), 'y', & 784 NF90_DOUBLE, id_var_y_mask(mid,av), & 812 785 'meters', '', 483, 484, 000 ) 813 CALL netcdf_create_att( id_set_mask(mid,av), id_var_y_mask(mid,av), & 814 'axis', 'Y', 000) 786 CALL netcdf_create_att( id_set_mask(mid,av), id_var_y_mask(mid,av), 'axis', 'Y', 000) 815 787 ! 816 788 !-- Define y-axis (for v position) 817 CALL netcdf_create_dim( id_set_mask(mid,av), 'yv', mask_size(mid,2), &789 CALL netcdf_create_dim( id_set_mask(mid,av), 'yv', mask_size(mid,2), & 818 790 id_dim_yv_mask(mid,av), 485 ) 819 CALL netcdf_create_var( id_set_mask(mid,av), &820 (/ id_dim_yv_mask(mid,av) /), &821 'yv', NF90_DOUBLE, id_var_yv_mask(mid,av), &791 CALL netcdf_create_var( id_set_mask(mid,av), & 792 (/ id_dim_yv_mask(mid,av) /), & 793 'yv', NF90_DOUBLE, id_var_yv_mask(mid,av), & 822 794 'meters', '', 486, 487, 000 ) 823 CALL netcdf_create_att( id_set_mask(mid,av), id_var_yv_mask(mid,av), & 824 'axis', 'Y', 000) 795 CALL netcdf_create_att( id_set_mask(mid,av), id_var_yv_mask(mid,av), 'axis', 'Y', 000) 825 796 ! 826 797 !-- Define UTM and geographic coordinates 827 CALL define_geo_coordinates( id_set_mask(mid,av), &828 (/ id_dim_x_mask(mid,av), id_dim_xu_mask(mid,av) /),&829 (/ id_dim_y_mask(mid,av), id_dim_yv_mask(mid,av) /),&830 id_var_eutm_mask(:,mid,av), id_var_nutm_mask(:,mid,av),&831 id_var_lat_mask(:,mid,av), id_var_lon_mask(:,mid,av) )798 CALL define_geo_coordinates( id_set_mask(mid,av), & 799 (/ id_dim_x_mask(mid,av), id_dim_xu_mask(mid,av) /), & 800 (/ id_dim_y_mask(mid,av), id_dim_yv_mask(mid,av) /), & 801 id_var_eutm_mask(:,mid,av), id_var_nutm_mask(:,mid,av), & 802 id_var_lat_mask(:,mid,av), id_var_lon_mask(:,mid,av) ) 832 803 ! 833 804 !-- Define coordinate-reference system 834 805 CALL netcdf_create_crs( id_set_mask(mid,av), 000 ) 835 806 ! 836 !-- In case of non-flat topography define 2d-arrays containing the height 837 !-- information. Only for parallel netcdf output. 838 IF ( TRIM( topography ) /= 'flat' .AND. & 839 netcdf_data_format > 4 ) THEN 807 !-- In case of non-flat topography define 2d-arrays containing the height information. Only 808 !-- for parallel netcdf output. 809 IF ( TRIM( topography ) /= 'flat' .AND. netcdf_data_format > 4 ) THEN 840 810 ! 841 811 !-- Define zusi = zu(nzb_s_inner) 842 CALL netcdf_create_var( id_set_mask(mid,av), & 843 (/ id_dim_x_mask(mid,av), & 844 id_dim_y_mask(mid,av) /), 'zusi', & 845 NF90_DOUBLE, id_var_zusi_mask(mid,av), & 846 'meters', 'zu(nzb_s_inner)', 488, 489, & 847 490 ) 812 CALL netcdf_create_var( id_set_mask(mid,av), & 813 (/ id_dim_x_mask(mid,av), id_dim_y_mask(mid,av) /), 'zusi', & 814 NF90_DOUBLE, id_var_zusi_mask(mid,av), & 815 'meters', 'zu(nzb_s_inner)', 488, 489, 490 ) 848 816 ! 849 817 !-- Define zwwi = zw(nzb_w_inner) 850 CALL netcdf_create_var( id_set_mask(mid,av), & 851 (/ id_dim_x_mask(mid,av), & 852 id_dim_y_mask(mid,av) /), 'zwwi', & 853 NF90_DOUBLE, id_var_zwwi_mask(mid,av), & 854 'meters', 'zw(nzb_w_inner)', 491, 492, & 855 493 ) 818 CALL netcdf_create_var( id_set_mask(mid,av), & 819 (/ id_dim_x_mask(mid,av), id_dim_y_mask(mid,av) /), 'zwwi', & 820 NF90_DOUBLE, id_var_zwwi_mask(mid,av), & 821 'meters', 'zw(nzb_w_inner)', 491, 492, 493 ) 856 822 ENDIF 857 823 … … 859 825 ! 860 826 !-- Define vertical coordinate grid (zw grid) 861 CALL netcdf_create_dim( id_set_mask(mid,av), 'zs_3d', &862 mask_size(mid,3), id_dim_zs_mask(mid,av), &827 CALL netcdf_create_dim( id_set_mask(mid,av), 'zs_3d', & 828 mask_size(mid,3), id_dim_zs_mask(mid,av), & 863 829 536 ) 864 CALL netcdf_create_var( id_set_mask(mid,av), &865 (/ id_dim_zs_mask(mid,av) /), 'zs_3d', &866 NF90_DOUBLE, id_var_zs_mask(mid,av), &830 CALL netcdf_create_var( id_set_mask(mid,av), & 831 (/ id_dim_zs_mask(mid,av) /), 'zs_3d', & 832 NF90_DOUBLE, id_var_zs_mask(mid,av), & 867 833 'meters', '', 537, 555, 000 ) 868 CALL netcdf_create_att( id_set_mask(mid,av), & 869 id_var_zs_mask(mid,av), 'axis', 'Z', 000) 834 CALL netcdf_create_att( id_set_mask(mid,av), id_var_zs_mask(mid,av), 'axis', 'Z', 000) 870 835 ENDIF 871 836 … … 875 840 i = 1 876 841 877 DO WHILE ( domask(mid,av,i)(1:1) /= ' ' )842 DO WHILE ( domask(mid,av,i)(1:1) /= ' ' ) 878 843 879 844 trimvar = TRIM( domask(mid,av,i) ) … … 884 849 ! 885 850 !-- Most variables are defined on the scalar grid 886 CASE ( 'e', 'nc', 'nr', 'p', 'pc', 'pr', 'prr', &887 'q', 'qc', 'ql', 'ql_c', 'ql_v', 'ql_vp', 'qr', 'qv', &851 CASE ( 'e', 'nc', 'nr', 'p', 'pc', 'pr', 'prr', & 852 'q', 'qc', 'ql', 'ql_c', 'ql_v', 'ql_vp', 'qr', 'qv', & 888 853 's', 'theta', 'thetal', 'thetav', 'qi', 'ni', 'qg', 'ng', 'qs', 'ns' ) 889 854 … … 923 888 ENDIF 924 889 925 IF ( .NOT. found ) &890 IF ( .NOT. found ) & 926 891 CALL doq_define_netcdf_grid( trimvar, found, grid_x, grid_y, grid_z ) 927 892 … … 991 956 ! 992 957 !-- Define the grid 993 CALL netcdf_create_var( id_set_mask(mid,av), (/ id_x, id_y, id_z,&994 id_dim_time_mask(mid,av) /),&995 domask(mid,av,i), nc_precision(11), &996 id_var_domask(mid,av,i), &997 TRIM( domask_unit(mid,av,i) ), &958 CALL netcdf_create_var( id_set_mask(mid,av), & 959 (/ id_x, id_y, id_z, id_dim_time_mask(mid,av) /), & 960 domask(mid,av,i), nc_precision(11), & 961 id_var_domask(mid,av,i), & 962 TRIM( domask_unit(mid,av,i) ), & 998 963 domask(mid,av,i), 494, 495, 496, .TRUE. ) 999 964 … … 1009 974 1010 975 ! 1011 !-- Write the list of variables as global attribute (this is used by 1012 !-- restart runs and by combine_plot_fields) 1013 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), NF90_GLOBAL, & 1014 'VAR_LIST', var_list ) 976 !-- Write the list of variables as global attribute (this is used by restart runs and by 977 !-- combine_plot_fields). 978 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), NF90_GLOBAL, 'VAR_LIST', var_list ) 1015 979 CALL netcdf_handle_error( 'netcdf_define_header', 497 ) 1016 980 … … 1026 990 netcdf_data = ( mask_i_global(mid,:mask_size(mid,1)) + 0.5_wp ) * dx 1027 991 1028 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_x_mask(mid,av), &1029 netcdf_data, start = (/ 1 /), &992 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_x_mask(mid,av), & 993 netcdf_data, start = (/ 1 /), & 1030 994 count = (/ mask_size(mid,1) /) ) 1031 995 CALL netcdf_handle_error( 'netcdf_define_header', 499 ) … … 1033 997 netcdf_data = mask_i_global(mid,:mask_size(mid,1)) * dx 1034 998 1035 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_xu_mask(mid,av), &1036 netcdf_data, start = (/ 1 /), &999 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_xu_mask(mid,av), & 1000 netcdf_data, start = (/ 1 /), & 1037 1001 count = (/ mask_size(mid,1) /) ) 1038 1002 CALL netcdf_handle_error( 'netcdf_define_header', 500 ) … … 1046 1010 netcdf_data = ( mask_j_global(mid,:mask_size(mid,2)) + 0.5_wp ) * dy 1047 1011 1048 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_y_mask(mid,av), &1049 netcdf_data, start = (/ 1 /), &1012 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_y_mask(mid,av), & 1013 netcdf_data, start = (/ 1 /), & 1050 1014 count = (/ mask_size(mid,2) /)) 1051 1015 CALL netcdf_handle_error( 'netcdf_define_header', 501 ) … … 1053 1017 netcdf_data = mask_j_global(mid,:mask_size(mid,2)) * dy 1054 1018 1055 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_yv_mask(mid,av), &1056 netcdf_data, start = (/ 1 /), &1019 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_yv_mask(mid,av), & 1020 netcdf_data, start = (/ 1 /), & 1057 1021 count = (/ mask_size(mid,2) /)) 1058 1022 CALL netcdf_handle_error( 'netcdf_define_header', 502 ) … … 1084 1048 ENDIF 1085 1049 1086 netcdf_data = init_model%origin_x + cos_rot_angle &1087 * ( mask_i_global(mid,:mask_size(mid,1)) + shift_x ) * dx1088 1089 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), &1090 id_var_eutm_mask(k,mid,av), &1091 netcdf_data, start = (/ 1 /), &1050 netcdf_data = init_model%origin_x + cos_rot_angle & 1051 * ( mask_i_global(mid,:mask_size(mid,1)) + shift_x ) * dx 1052 1053 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), & 1054 id_var_eutm_mask(k,mid,av), & 1055 netcdf_data, start = (/ 1 /), & 1092 1056 count = (/ mask_size(mid,1) /) ) 1093 1057 CALL netcdf_handle_error( 'netcdf_define_header', 555 ) … … 1113 1077 ENDIF 1114 1078 1115 netcdf_data = init_model%origin_y + cos_rot_angle &1116 * ( mask_j_global(mid,:mask_size(mid,2)) + shift_y ) * dy1117 1118 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), &1119 id_var_nutm_mask(k,mid,av), &1120 netcdf_data, start = (/ 1 /), &1079 netcdf_data = init_model%origin_y + cos_rot_angle & 1080 * ( mask_j_global(mid,:mask_size(mid,2)) + shift_y ) * dy 1081 1082 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), & 1083 id_var_nutm_mask(k,mid,av), & 1084 netcdf_data, start = (/ 1 /), & 1121 1085 count = (/ mask_size(mid,2) /) ) 1122 1086 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) … … 1149 1113 DO j = 1, mask_size(mid,2) 1150 1114 DO i = 1, mask_size(mid,1) 1151 netcdf_data_2d(i,j) = init_model%origin_x &1152 + cos_rot_angle * ( mask_i_global(mid,i) + shift_x ) * dx&1153 + sin_rot_angle * ( mask_j_global(mid,j) + shift_y ) * dy1115 netcdf_data_2d(i,j) = init_model%origin_x & 1116 + cos_rot_angle * ( mask_i_global(mid,i) + shift_x ) * dx & 1117 + sin_rot_angle * ( mask_j_global(mid,j) + shift_y ) * dy 1154 1118 ENDDO 1155 1119 ENDDO 1156 1120 1157 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), & 1158 id_var_eutm_mask(k,mid,av), & 1159 netcdf_data_2d, start = (/ 1, 1 /), & 1160 count = (/ mask_size(mid,1), & 1161 mask_size(mid,2) /) ) 1121 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), & 1122 id_var_eutm_mask(k,mid,av), & 1123 netcdf_data_2d, start = (/ 1, 1 /), & 1124 count = (/ mask_size(mid,1), mask_size(mid,2) /) ) 1162 1125 CALL netcdf_handle_error( 'netcdf_define_header', 555 ) 1163 1126 1164 1127 DO j = 1, mask_size(mid,2) 1165 1128 DO i = 1, mask_size(mid,1) 1166 netcdf_data_2d(i,j) = init_model%origin_y &1167 - sin_rot_angle * ( mask_i_global(mid,i) + shift_x ) * dx&1168 + cos_rot_angle * ( mask_j_global(mid,j) + shift_y ) * dy1129 netcdf_data_2d(i,j) = init_model%origin_y & 1130 - sin_rot_angle * ( mask_i_global(mid,i) + shift_x ) * dx & 1131 + cos_rot_angle * ( mask_j_global(mid,j) + shift_y ) * dy 1169 1132 ENDDO 1170 1133 ENDDO 1171 1134 1172 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), & 1173 id_var_nutm_mask(k,mid,av), & 1174 netcdf_data_2d, start = (/ 1, 1 /), & 1175 count = (/ mask_size(mid,1), & 1176 mask_size(mid,2) /) ) 1135 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), & 1136 id_var_nutm_mask(k,mid,av), & 1137 netcdf_data_2d, start = (/ 1, 1 /), & 1138 count = (/ mask_size(mid,1), mask_size(mid,2) /) ) 1177 1139 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) 1178 1140 … … 1204 1166 DO j = 1, mask_size(mid,2) 1205 1167 DO i = 1, mask_size(mid,1) 1206 eutm = init_model%origin_x & 1207 + cos_rot_angle * ( mask_i_global(mid,i) + shift_x ) * dx & 1208 + sin_rot_angle * ( mask_j_global(mid,j) + shift_y ) * dy 1209 nutm = init_model%origin_y & 1210 - sin_rot_angle * ( mask_i_global(mid,i) + shift_x ) * dx & 1211 + cos_rot_angle * ( mask_j_global(mid,j) + shift_y ) * dy 1212 1213 CALL convert_utm_to_geographic( crs_list, & 1214 eutm, nutm, & 1215 lon(i,j), lat(i,j) ) 1168 eutm = init_model%origin_x & 1169 + cos_rot_angle * ( mask_i_global(mid,i) + shift_x ) * dx & 1170 + sin_rot_angle * ( mask_j_global(mid,j) + shift_y ) * dy 1171 nutm = init_model%origin_y & 1172 - sin_rot_angle * ( mask_i_global(mid,i) + shift_x ) * dx & 1173 + cos_rot_angle * ( mask_j_global(mid,j) + shift_y ) * dy 1174 1175 CALL convert_utm_to_geographic( crs_list, eutm, nutm, lon(i,j), lat(i,j) ) 1216 1176 ENDDO 1217 1177 ENDDO 1218 1178 1219 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), & 1220 id_var_lon_mask(k,mid,av), & 1221 lon, start = (/ 1, 1 /), & 1222 count = (/ mask_size(mid,1), & 1223 mask_size(mid,2) /) ) 1179 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), & 1180 id_var_lon_mask(k,mid,av), & 1181 lon, start = (/ 1, 1 /), & 1182 count = (/ mask_size(mid,1), mask_size(mid,2) /) ) 1224 1183 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) 1225 1184 1226 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), & 1227 id_var_lat_mask(k,mid,av), & 1228 lat, start = (/ 1, 1 /), & 1229 count = (/ mask_size(mid,1), & 1230 mask_size(mid,2) /) ) 1185 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), & 1186 id_var_lat_mask(k,mid,av), & 1187 lat, start = (/ 1, 1 /), & 1188 count = (/ mask_size(mid,1), mask_size(mid,2) /) ) 1231 1189 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) 1232 1190 ENDDO … … 1242 1200 netcdf_data = mask_k_global(mid,:mask_size(mid,3)) 1243 1201 1244 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_zu_mask(mid,av), &1245 netcdf_data, start = (/ 1 /), &1202 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_zu_mask(mid,av), & 1203 netcdf_data, start = (/ 1 /), & 1246 1204 count = (/ mask_size(mid,3) /) ) 1247 1205 CALL netcdf_handle_error( 'netcdf_define_header', 503 ) … … 1249 1207 netcdf_data = mask_k_global(mid,:mask_size(mid,3)) 1250 1208 1251 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_zw_mask(mid,av), &1252 netcdf_data, start = (/ 1 /), &1209 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_zw_mask(mid,av), & 1210 netcdf_data, start = (/ 1 /), & 1253 1211 count = (/ mask_size(mid,3) /) ) 1254 1212 CALL netcdf_handle_error( 'netcdf_define_header', 504 ) … … 1258 1216 netcdf_data = zu( mask_k_global(mid,:mask_size(mid,3)) ) 1259 1217 1260 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_zu_mask(mid,av), &1261 netcdf_data, start = (/ 1 /), &1218 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_zu_mask(mid,av), & 1219 netcdf_data, start = (/ 1 /), & 1262 1220 count = (/ mask_size(mid,3) /) ) 1263 1221 CALL netcdf_handle_error( 'netcdf_define_header', 503 ) … … 1265 1223 netcdf_data = zw( mask_k_global(mid,:mask_size(mid,3)) ) 1266 1224 1267 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_zw_mask(mid,av), &1268 netcdf_data, start = (/ 1 /), &1225 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_zw_mask(mid,av), & 1226 netcdf_data, start = (/ 1 /), & 1269 1227 count = (/ mask_size(mid,3) /) ) 1270 1228 CALL netcdf_handle_error( 'netcdf_define_header', 504 ) … … 1276 1234 ! 1277 1235 !-- In case of non-flat topography write height information 1278 IF ( TRIM( topography ) /= 'flat' .AND. & 1279 netcdf_data_format > 4 ) THEN 1236 IF ( TRIM( topography ) /= 'flat' .AND. netcdf_data_format > 4 ) THEN 1280 1237 1281 1238 ALLOCATE( netcdf_data_2d(mask_size_l(mid,1),mask_size_l(mid,2)) ) 1282 netcdf_data_2d = zu_s_inner( mask_i(mid,:mask_size_l(mid,1)), &1239 netcdf_data_2d = zu_s_inner( mask_i(mid,:mask_size_l(mid,1)), & 1283 1240 mask_j(mid,:mask_size_l(mid,2)) ) 1284 1241 1285 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), & 1286 id_var_zusi_mask(mid,av), & 1287 netcdf_data_2d, & 1288 start = (/ 1, 1 /), & 1289 count = (/ mask_size_l(mid,1), & 1290 mask_size_l(mid,2) /) ) 1242 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), & 1243 id_var_zusi_mask(mid,av), & 1244 netcdf_data_2d, & 1245 start = (/ 1, 1 /), & 1246 count = (/ mask_size_l(mid,1), mask_size_l(mid,2) /) ) 1291 1247 CALL netcdf_handle_error( 'netcdf_define_header', 505 ) 1292 1248 1293 netcdf_data_2d = zw_w_inner( mask_i(mid,:mask_size_l(mid,1)), &1249 netcdf_data_2d = zw_w_inner( mask_i(mid,:mask_size_l(mid,1)), & 1294 1250 mask_j(mid,:mask_size_l(mid,2)) ) 1295 1251 1296 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), & 1297 id_var_zwwi_mask(mid,av), & 1298 netcdf_data_2d, & 1299 start = (/ 1, 1 /), & 1300 count = (/ mask_size_l(mid,1), & 1301 mask_size_l(mid,2) /) ) 1252 nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), & 1253 id_var_zwwi_mask(mid,av), & 1254 netcdf_data_2d, & 1255 start = (/ 1, 1 /), & 1256 count = (/ mask_size_l(mid,1), mask_size_l(mid,2) /) ) 1302 1257 CALL netcdf_handle_error( 'netcdf_define_header', 506 ) 1303 1258 … … 1306 1261 ENDIF 1307 1262 ! 1308 !-- soil is not in masked output for now - disable temporary this block1263 !-- Soil is not in masked output for now - disable temporary this block 1309 1264 ! IF ( land_surface ) THEN 1310 1265 ! … … 1325 1280 1326 1281 ! 1327 !-- restore original parameter file_id (=formal parameter av) into av1282 !-- Restore original parameter file_id (=formal parameter av) into av 1328 1283 av = file_id 1329 1284 … … 1332 1287 1333 1288 ! 1334 !-- decompose actual parameter file_id (=formal parameter av) into 1335 !-- mid and av 1289 !-- Decompose actual parameter file_id (=formal parameter av) into mid and av 1336 1290 file_id = av 1337 1291 IF ( file_id <= 200+max_masks ) THEN … … 1345 1299 ! 1346 1300 !-- Get the list of variables and compare with the actual run. 1347 !-- First var_list_old has to be reset, since GET_ATT does not assign 1348 !-- trailing blanks. 1301 !-- First var_list_old has to be reset, since GET_ATT does not assign trailing blanks. 1349 1302 var_list_old = ' ' 1350 nc_stat = NF90_GET_ATT( id_set_mask(mid,av), NF90_GLOBAL, 'VAR_LIST',& 1351 var_list_old ) 1303 nc_stat = NF90_GET_ATT( id_set_mask(mid,av), NF90_GLOBAL, 'VAR_LIST', var_list_old ) 1352 1304 CALL netcdf_handle_error( 'netcdf_define_header', 507 ) 1353 1305 … … 1366 1318 1367 1319 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 1368 WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), &1369 ' data for mask', mid, ' from previous run found,',&1370 '&but this file cannot be extended due to variable ',&1371 'mismatch.&New file is created instead.'1320 WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), & 1321 ' data for mask', mid, ' from previous run found,', & 1322 '&but this file cannot be extended due to variable ', & 1323 'mismatch.&New file is created instead.' 1372 1324 CALL message( 'define_netcdf_header', 'PA0335', 0, 1, 0, 6, 0 ) 1373 1325 extend = .FALSE. … … 1377 1329 ! 1378 1330 !-- Get and compare the number of vertical gridpoints 1379 nc_stat = NF90_INQ_VARID( id_set_mask(mid,av), 'zu_3d', & 1380 id_var_zu_mask(mid,av) ) 1331 nc_stat = NF90_INQ_VARID( id_set_mask(mid,av), 'zu_3d', id_var_zu_mask(mid,av) ) 1381 1332 CALL netcdf_handle_error( 'netcdf_define_header', 508 ) 1382 1333 1383 nc_stat = NF90_INQUIRE_VARIABLE( id_set_mask(mid,av), &1384 id_var_zu_mask(mid,av), &1334 nc_stat = NF90_INQUIRE_VARIABLE( id_set_mask(mid,av), & 1335 id_var_zu_mask(mid,av), & 1385 1336 dimids = id_dim_zu_mask_old ) 1386 1337 CALL netcdf_handle_error( 'netcdf_define_header', 509 ) 1387 1338 id_dim_zu_mask(mid,av) = id_dim_zu_mask_old(1) 1388 1339 1389 nc_stat = NF90_INQUIRE_DIMENSION( id_set_mask(mid,av), &1390 id_dim_zu_mask(mid,av), &1391 len= nz_old )1340 nc_stat = NF90_INQUIRE_DIMENSION( id_set_mask(mid,av), & 1341 id_dim_zu_mask(mid,av), & 1342 LEN = nz_old ) 1392 1343 CALL netcdf_handle_error( 'netcdf_define_header', 510 ) 1393 1344 1394 1345 IF ( mask_size(mid,3) /= nz_old ) THEN 1395 WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), &1396 '&data for mask', mid, ' from previous run found,',&1397 ' but this file cannot be extended due to mismatch in ',&1398 ' number of vertical grid points.',&1399 '&New file is created instead.'1346 WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), & 1347 '&data for mask', mid, ' from previous run found,', & 1348 ' but this file cannot be extended due to mismatch in ', & 1349 ' number of vertical grid points.', & 1350 '&New file is created instead.' 1400 1351 CALL message( 'define_netcdf_header', 'PA0336', 0, 1, 0, 6, 0 ) 1401 1352 extend = .FALSE. … … 1404 1355 1405 1356 ! 1406 !-- Get the id of the time coordinate (unlimited coordinate) and its 1407 !-- last index on the file. The next time level is plmask..count+1. 1408 !-- The current time must be larger than the last output time 1409 !-- on the file. 1410 nc_stat = NF90_INQ_VARID( id_set_mask(mid,av), 'time', & 1411 id_var_time_mask(mid,av) ) 1357 !-- Get the id of the time coordinate (unlimited coordinate) and its last index on the file. 1358 !-- The next time level is plmask..count+1. 1359 !-- The current time must be larger than the last output time on the file. 1360 nc_stat = NF90_INQ_VARID( id_set_mask(mid,av), 'time', id_var_time_mask(mid,av) ) 1412 1361 CALL netcdf_handle_error( 'netcdf_define_header', 511 ) 1413 1362 1414 nc_stat = NF90_INQUIRE_VARIABLE( id_set_mask(mid,av), &1415 id_var_time_mask(mid,av), &1363 nc_stat = NF90_INQUIRE_VARIABLE( id_set_mask(mid,av), & 1364 id_var_time_mask(mid,av), & 1416 1365 dimids = id_dim_time_old ) 1417 1366 CALL netcdf_handle_error( 'netcdf_define_header', 512 ) 1418 1367 id_dim_time_mask(mid,av) = id_dim_time_old(1) 1419 1368 1420 nc_stat = NF90_INQUIRE_DIMENSION( id_set_mask(mid,av), &1421 id_dim_time_mask(mid,av), &1422 len= domask_time_count(mid,av) )1369 nc_stat = NF90_INQUIRE_DIMENSION( id_set_mask(mid,av), & 1370 id_dim_time_mask(mid,av), & 1371 LEN = domask_time_count(mid,av) ) 1423 1372 CALL netcdf_handle_error( 'netcdf_define_header', 513 ) 1424 1373 1425 nc_stat = NF90_GET_VAR( id_set_mask(mid,av), &1426 id_var_time_mask(mid,av), &1427 last_time_coordinate, &1428 start = (/ domask_time_count(mid,av) /), &1374 nc_stat = NF90_GET_VAR( id_set_mask(mid,av), & 1375 id_var_time_mask(mid,av), & 1376 last_time_coordinate, & 1377 start = (/ domask_time_count(mid,av) /), & 1429 1378 count = (/ 1 /) ) 1430 1379 CALL netcdf_handle_error( 'netcdf_define_header', 514 ) 1431 1380 1432 1381 IF ( last_time_coordinate(1) >= simulated_time ) THEN 1433 WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), &1434 ' data for mask', mid, ' from previous run found,',&1435 '&but this file cannot be extended because the current ',&1436 'output time is less or equal than the last output time ',&1437 'on this file.&New file is created instead.'1382 WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), & 1383 ' data for mask', mid, ' from previous run found,', & 1384 '&but this file cannot be extended because the current ', & 1385 'output time is less or equal than the last output time ',& 1386 'on this file.&New file is created instead.' 1438 1387 CALL message( 'define_netcdf_header', 'PA0337', 0, 1, 0, 6, 0 ) 1439 1388 domask_time_count(mid,av) = 0 … … 1447 1396 i = 1 1448 1397 DO WHILE ( domask(mid,av,i)(1:1) /= ' ' ) 1449 nc_stat = NF90_INQ_VARID( id_set_mask(mid,av), &1450 TRIM( domask(mid,av,i) ), &1398 nc_stat = NF90_INQ_VARID( id_set_mask(mid,av), & 1399 TRIM( domask(mid,av,i) ), & 1451 1400 id_var_domask(mid,av,i) ) 1452 1401 CALL netcdf_handle_error( 'netcdf_define_header', 515 ) … … 1455 1404 1456 1405 ! 1457 !-- Update the title attribute on file 1458 !-- In order to avoid 'data mode' errors if updated attributes are larger 1459 !-- than their original size, NF90_PUT_ATT is called in 'define mode' 1460 !-- enclosed by NF90_REDEF and NF90_ENDDEF calls. This implies a possible 1461 !-- performance loss due to data copying; an alternative strategy would be 1462 !-- to ensure equal attribute size in a job chain. Maybe revise later. 1406 !-- Update the title attribute on file. 1407 !-- In order to avoid 'data mode' errors if updated attributes are larger than their original 1408 !-- size, NF90_PUT_ATT is called in 'define mode' enclosed by NF90_REDEF and NF90_ENDDEF 1409 !-- calls. This implies a possible performance loss due to data copying; an alternative 1410 !-- strategy would be to ensure equal attribute size in a job chain. Maybe revise later. 1463 1411 IF ( av == 0 ) THEN 1464 1412 time_average_text = ' ' 1465 1413 ELSE 1466 WRITE (time_average_text, '('', '',F7.1,'' s average'')') & 1467 averaging_interval 1414 WRITE (time_average_text, '('', '',F7.1,'' s average'')') averaging_interval 1468 1415 ENDIF 1469 1416 nc_stat = NF90_REDEF( id_set_mask(mid,av) ) 1470 1417 CALL netcdf_handle_error( 'netcdf_define_header', 516 ) 1471 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), NF90_GLOBAL, 'title', & 1472 TRIM( run_description_header ) // & 1473 TRIM( time_average_text ) ) 1418 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), NF90_GLOBAL, 'title', & 1419 TRIM( run_description_header ) // TRIM( time_average_text ) ) 1474 1420 CALL netcdf_handle_error( 'netcdf_define_header', 517 ) 1475 1421 nc_stat = NF90_ENDDEF( id_set_mask(mid,av) ) 1476 1422 CALL netcdf_handle_error( 'netcdf_define_header', 518 ) 1477 WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), & 1478 ' data for mask', mid, ' from previous run found.', & 1479 ' &This file will be extended.' 1423 WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), ' data for mask', mid, & 1424 ' from previous run found.', ' &This file will be extended.' 1480 1425 CALL message( 'define_netcdf_header', 'PA0338', 0, 0, 0, 6, 0 ) 1481 1426 ! 1482 !-- restore original parameter file_id (=formal parameter av) into av1427 !-- Restore original parameter file_id (=formal parameter av) into av 1483 1428 av = file_id 1484 1429 … … 1489 1434 !-- Define some global attributes of the dataset 1490 1435 IF ( av == 0 ) THEN 1491 CALL netcdf_create_global_atts( id_set_3d(av), '3d', TRIM( run_description_header ), 62 ) 1436 CALL netcdf_create_global_atts( id_set_3d(av), '3d', & 1437 TRIM( run_description_header ), 62 ) 1492 1438 time_average_text = ' ' 1493 1439 ELSE 1494 CALL netcdf_create_global_atts( id_set_3d(av), '3d_av', TRIM( run_description_header ), 62 ) 1440 CALL netcdf_create_global_atts( id_set_3d(av), '3d_av', & 1441 TRIM( run_description_header ), 62 ) 1495 1442 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval 1496 nc_stat = NF90_PUT_ATT( id_set_3d(av), NF90_GLOBAL, 'time_avg', &1443 nc_stat = NF90_PUT_ATT( id_set_3d(av), NF90_GLOBAL, 'time_avg', & 1497 1444 TRIM( time_average_text ) ) 1498 1445 CALL netcdf_handle_error( 'netcdf_define_header', 63 ) … … 1501 1448 ! 1502 1449 !-- Define time coordinate for volume data. 1503 !-- For parallel output the time dimensions has to be limited, otherwise 1504 !-- the performance dropssignificantly.1450 !-- For parallel output the time dimensions has to be limited, otherwise the performance drops 1451 !-- significantly. 1505 1452 IF ( netcdf_data_format < 5 ) THEN 1506 CALL netcdf_create_dim( id_set_3d(av), 'time', NF90_UNLIMITED, & 1507 id_dim_time_3d(av), 64 ) 1453 CALL netcdf_create_dim( id_set_3d(av), 'time', NF90_UNLIMITED, id_dim_time_3d(av), 64 ) 1508 1454 ELSE 1509 CALL netcdf_create_dim( id_set_3d(av), 'time', ntdim_3d(av), & 1510 id_dim_time_3d(av), 523 ) 1511 ENDIF 1512 1513 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_time_3d(av) /), & 1514 'time', NF90_DOUBLE, id_var_time_3d(av), & 1515 'seconds', 'time', 65, 66, 00 ) 1455 CALL netcdf_create_dim( id_set_3d(av), 'time', ntdim_3d(av), id_dim_time_3d(av), 523 ) 1456 ENDIF 1457 1458 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_time_3d(av) /), 'time', NF90_DOUBLE, & 1459 id_var_time_3d(av), 'seconds', 'time', 65, 66, 00 ) 1516 1460 CALL netcdf_create_att( id_set_3d(av), id_var_time_3d(av), 'standard_name', 'time', 000) 1517 1461 CALL netcdf_create_att( id_set_3d(av), id_var_time_3d(av), 'axis', 'T', 000) … … 1519 1463 !-- Define spatial dimensions and coordinates: 1520 1464 !-- Define vertical coordinate grid (zu grid) 1521 CALL netcdf_create_dim( id_set_3d(av), 'zu_3d', nz_do3d-nzb+1, & 1522 id_dim_zu_3d(av), 67 ) 1523 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_zu_3d(av) /), & 1524 'zu_3d', NF90_DOUBLE, id_var_zu_3d(av), & 1525 'meters', '', 68, 69, 00 ) 1526 CALL netcdf_create_att( id_set_3d(av), id_var_zu_3d(av), 'axis', & 1527 'Z', 000) 1465 CALL netcdf_create_dim( id_set_3d(av), 'zu_3d', nz_do3d-nzb+1, id_dim_zu_3d(av), 67 ) 1466 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_zu_3d(av) /), 'zu_3d', NF90_DOUBLE, & 1467 id_var_zu_3d(av), 'meters', '', 68, 69, 00 ) 1468 CALL netcdf_create_att( id_set_3d(av), id_var_zu_3d(av), 'axis', 'Z', 000) 1528 1469 ! 1529 1470 !-- Define vertical coordinate grid (zw grid) 1530 CALL netcdf_create_dim( id_set_3d(av), 'zw_3d', nz_do3d-nzb+1, & 1531 id_dim_zw_3d(av), 70 ) 1532 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_zw_3d(av) /), & 1533 'zw_3d', NF90_DOUBLE, id_var_zw_3d(av), & 1534 'meters', '', 71, 72, 00 ) 1535 CALL netcdf_create_att( id_set_3d(av), id_var_zw_3d(av), 'axis', & 1536 'Z', 000) 1471 CALL netcdf_create_dim( id_set_3d(av), 'zw_3d', nz_do3d-nzb+1, id_dim_zw_3d(av), 70 ) 1472 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_zw_3d(av) /), 'zw_3d', NF90_DOUBLE, & 1473 id_var_zw_3d(av), 'meters', '', 71, 72, 00 ) 1474 CALL netcdf_create_att( id_set_3d(av), id_var_zw_3d(av), 'axis', 'Z', 000) 1537 1475 ! 1538 1476 !-- Define x-axis (for scalar position) 1539 CALL netcdf_create_dim( id_set_3d(av), 'x', nx+1, id_dim_x_3d(av), & 1540 73 ) 1541 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_x_3d(av) /), 'x', & 1542 NF90_DOUBLE, id_var_x_3d(av), 'meters', '', & 1543 74, 75, 00 ) 1544 CALL netcdf_create_att( id_set_3d(av), id_var_x_3d(av), 'axis', & 1545 'X', 000) 1477 CALL netcdf_create_dim( id_set_3d(av), 'x', nx+1, id_dim_x_3d(av), 73 ) 1478 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_x_3d(av) /), 'x', NF90_DOUBLE, & 1479 id_var_x_3d(av), 'meters', '', 74, 75, 00 ) 1480 CALL netcdf_create_att( id_set_3d(av), id_var_x_3d(av), 'axis', 'X', 000) 1546 1481 ! 1547 1482 !-- Define x-axis (for u position) 1548 CALL netcdf_create_dim( id_set_3d(av), 'xu', nx+1, id_dim_xu_3d(av), & 1549 358 ) 1550 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_xu_3d(av) /), 'xu', & 1551 NF90_DOUBLE, id_var_xu_3d(av), 'meters', '', & 1552 359, 360, 000 ) 1553 CALL netcdf_create_att( id_set_3d(av), id_var_xu_3d(av), 'axis', & 1554 'X', 000) 1483 CALL netcdf_create_dim( id_set_3d(av), 'xu', nx+1, id_dim_xu_3d(av), 358 ) 1484 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_xu_3d(av) /), 'xu', NF90_DOUBLE, & 1485 id_var_xu_3d(av), 'meters', '', 359, 360, 000 ) 1486 CALL netcdf_create_att( id_set_3d(av), id_var_xu_3d(av), 'axis', 'X', 000) 1555 1487 ! 1556 1488 !-- Define y-axis (for scalar position) 1557 CALL netcdf_create_dim( id_set_3d(av), 'y', ny+1, id_dim_y_3d(av), & 1558 76 ) 1559 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_y_3d(av) /), 'y', & 1560 NF90_DOUBLE, id_var_y_3d(av), 'meters', '', & 1561 77, 78, 00 ) 1562 CALL netcdf_create_att( id_set_3d(av), id_var_y_3d(av), 'axis', & 1563 'Y', 000) 1489 CALL netcdf_create_dim( id_set_3d(av), 'y', ny+1, id_dim_y_3d(av), 76 ) 1490 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_y_3d(av) /), 'y', NF90_DOUBLE, & 1491 id_var_y_3d(av), 'meters', '', 77, 78, 00 ) 1492 CALL netcdf_create_att( id_set_3d(av), id_var_y_3d(av), 'axis', 'Y', 000) 1564 1493 ! 1565 1494 !-- Define y-axis (for v position) 1566 CALL netcdf_create_dim( id_set_3d(av), 'yv', ny+1, id_dim_yv_3d(av), & 1567 361 ) 1568 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_yv_3d(av) /), 'yv', & 1569 NF90_DOUBLE, id_var_yv_3d(av), 'meters', '', & 1570 362, 363, 000 ) 1571 CALL netcdf_create_att( id_set_3d(av), id_var_yv_3d(av), 'axis', & 1572 'Y', 000) 1495 CALL netcdf_create_dim( id_set_3d(av), 'yv', ny+1, id_dim_yv_3d(av), 361 ) 1496 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_yv_3d(av) /), 'yv', NF90_DOUBLE, & 1497 id_var_yv_3d(av), 'meters', '', 362, 363, 000 ) 1498 CALL netcdf_create_att( id_set_3d(av), id_var_yv_3d(av), 'axis', 'Y', 000) 1573 1499 ! 1574 1500 !-- Define UTM and geographic coordinates 1575 CALL define_geo_coordinates( id_set_3d(av), &1576 (/ id_dim_x_3d(av), id_dim_xu_3d(av) /),&1577 (/ id_dim_y_3d(av), id_dim_yv_3d(av) /),&1578 id_var_eutm_3d(:,av), id_var_nutm_3d(:,av),&1579 id_var_lat_3d(:,av), id_var_lon_3d(:,av) )1501 CALL define_geo_coordinates( id_set_3d(av), & 1502 (/ id_dim_x_3d(av), id_dim_xu_3d(av) /), & 1503 (/ id_dim_y_3d(av), id_dim_yv_3d(av) /), & 1504 id_var_eutm_3d(:,av), id_var_nutm_3d(:,av), & 1505 id_var_lat_3d(:,av), id_var_lon_3d(:,av) ) 1580 1506 ! 1581 1507 !-- Define coordinate-reference system 1582 1508 CALL netcdf_create_crs( id_set_3d(av), 000 ) 1583 1509 ! 1584 !-- In case of non-flat topography define 2d-arrays containing the height 1585 !-- information. Only output 2d topography information in case of parallel 1586 !-- output. 1587 IF ( TRIM( topography ) /= 'flat' .AND. & 1588 netcdf_data_format > 4 ) THEN 1510 !-- In case of non-flat topography define 2d-arrays containing the height information. Only 1511 !-- output 2d topography information in case of parallel output. 1512 IF ( TRIM( topography ) /= 'flat' .AND. netcdf_data_format > 4 ) THEN 1589 1513 ! 1590 1514 !-- Define zusi = zu(nzb_s_inner) 1591 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_x_3d(av), & 1592 id_dim_y_3d(av) /), 'zusi', NF90_DOUBLE, & 1593 id_var_zusi_3d(av), 'meters', & 1594 'zu(nzb_s_inner)', 413, 414, 415 ) 1515 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_x_3d(av), id_dim_y_3d(av) /), 'zusi',& 1516 NF90_DOUBLE, id_var_zusi_3d(av), 'meters', 'zu(nzb_s_inner)', & 1517 413, 414, 415 ) 1595 1518 ! 1596 1519 !-- Define zwwi = zw(nzb_w_inner) 1597 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_x_3d(av), & 1598 id_dim_y_3d(av) /), 'zwwi', NF90_DOUBLE, & 1599 id_var_zwwi_3d(av), 'meters', & 1600 'zw(nzb_w_inner)', 416, 417, 418 ) 1520 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_x_3d(av), id_dim_y_3d(av) /), 'zwwi',& 1521 NF90_DOUBLE, id_var_zwwi_3d(av), 'meters', 'zw(nzb_w_inner)', & 1522 416, 417, 418 ) 1601 1523 1602 1524 ENDIF … … 1605 1527 ! 1606 1528 !-- Define vertical coordinate grid (zs grid) 1607 CALL netcdf_create_dim( id_set_3d(av), 'zs_3d', &1529 CALL netcdf_create_dim( id_set_3d(av), 'zs_3d', & 1608 1530 nzt_soil-nzb_soil+1, id_dim_zs_3d(av), 70 ) 1609 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_zs_3d(av) /), & 1610 'zs_3d', NF90_DOUBLE, id_var_zs_3d(av), & 1611 'meters', '', 71, 72, 00 ) 1612 CALL netcdf_create_att( id_set_3d(av), id_var_zs_3d(av), 'axis', & 1613 'Z', 000) 1531 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_zs_3d(av) /), 'zs_3d', NF90_DOUBLE, & 1532 id_var_zs_3d(av), 'meters', '', 71, 72, 00 ) 1533 CALL netcdf_create_att( id_set_3d(av), id_var_zs_3d(av), 'axis', 'Z', 000) 1614 1534 1615 1535 ENDIF … … 1618 1538 ! 1619 1539 !-- Define vertical coordinate grid (zpc grid) 1620 CALL netcdf_create_dim( id_set_3d(av), 'zpc_3d', & 1621 pch_index+1, id_dim_zpc_3d(av), 70 ) 1540 CALL netcdf_create_dim( id_set_3d(av), 'zpc_3d', pch_index+1, id_dim_zpc_3d(av), 70 ) 1622 1541 !netcdf_create_dim(ncid, dim_name, ncdim_type, ncdim_id, error_no) 1623 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_zpc_3d(av) /), & 1624 'zpc_3d', NF90_DOUBLE, id_var_zpc_3d(av), & 1625 'meters', '', 71, 72, 00 ) 1626 CALL netcdf_create_att( id_set_3d(av), id_var_zpc_3d(av), 'axis', & 1627 'Z', 000) 1542 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_zpc_3d(av) /), 'zpc_3d', NF90_DOUBLE,& 1543 id_var_zpc_3d(av), 'meters', '', 71, 72, 00 ) 1544 CALL netcdf_create_att( id_set_3d(av), id_var_zpc_3d(av), 'axis', 'Z', 000) 1628 1545 1629 1546 ENDIF … … 1636 1553 DO WHILE ( do3d(av,i)(1:1) /= ' ' ) 1637 1554 ! 1638 !-- Temporary solution to account for data output within the new urban 1639 !-- surface model(urban_surface_mod.f90), see also SELECT CASE ( trimvar )1555 !-- Temporary solution to account for data output within the new urban surface model 1556 !-- (urban_surface_mod.f90), see also SELECT CASE ( trimvar ) 1640 1557 trimvar = TRIM( do3d(av,i) ) 1641 1558 IF ( urban_surface .AND. trimvar(1:4) == 'usm_' ) THEN … … 1680 1597 !-- Block of urban surface model outputs 1681 1598 CASE ( 'usm_output' ) 1682 CALL usm_define_netcdf_grid( do3d(av,i), found, & 1683 grid_x, grid_y, grid_z ) 1599 CALL usm_define_netcdf_grid( do3d(av,i), found, grid_x, grid_y, grid_z ) 1684 1600 1685 1601 CASE DEFAULT 1686 1602 1687 CALL tcm_define_netcdf_grid( do3d(av,i), found, & 1688 grid_x, grid_y, grid_z ) 1603 CALL tcm_define_netcdf_grid( do3d(av,i), found, grid_x, grid_y, grid_z ) 1689 1604 1690 1605 ! 1691 1606 !-- Check for land surface quantities 1692 IF ( .NOT. found .AND. land_surface ) THEN 1693 CALL lsm_define_netcdf_grid( do3d(av,i), found, grid_x, & 1694 grid_y, grid_z ) 1607 IF ( .NOT. found .AND. land_surface ) THEN 1608 CALL lsm_define_netcdf_grid( do3d(av,i), found, grid_x, grid_y, grid_z ) 1695 1609 ENDIF 1696 1610 ! 1697 1611 !-- Check for ocean quantities 1698 1612 IF ( .NOT. found .AND. ocean_mode ) THEN 1699 CALL ocean_define_netcdf_grid( do3d(av,i), found, & 1700 grid_x, grid_y, grid_z ) 1613 CALL ocean_define_netcdf_grid( do3d(av,i), found, grid_x, grid_y, grid_z ) 1701 1614 ENDIF 1702 1615 … … 1704 1617 !-- Check for plant canopy quantities 1705 1618 IF ( .NOT. found .AND. plant_canopy ) THEN 1706 CALL pcm_define_netcdf_grid( do3d(av,i), found, grid_x, & 1707 grid_y, grid_z ) 1619 CALL pcm_define_netcdf_grid( do3d(av,i), found, grid_x, grid_y, grid_z ) 1708 1620 ENDIF 1709 1621 … … 1711 1623 !-- Check for radiation quantities 1712 1624 IF ( .NOT. found .AND. radiation ) THEN 1713 CALL radiation_define_netcdf_grid( do3d(av,i), found, & 1714 grid_x, grid_y, & 1715 grid_z ) 1625 CALL radiation_define_netcdf_grid( do3d(av,i), found, grid_x, grid_y, grid_z ) 1716 1626 ENDIF 1717 1627 1718 1628 !-- Check for gust module quantities 1719 1629 IF ( .NOT. found .AND. gust_module_enabled ) THEN 1720 CALL gust_define_netcdf_grid( do3d(av,i), found, grid_x, & 1721 grid_y, grid_z ) 1630 CALL gust_define_netcdf_grid( do3d(av,i), found, grid_x, grid_y, grid_z ) 1722 1631 ENDIF 1723 1632 ! 1724 1633 !-- Check for indoor model quantities 1725 IF ( .NOT. found .AND. indoor_model ) THEN 1726 CALL im_define_netcdf_grid( do3d(av,i), found, & 1727 grid_x, grid_y, grid_z ) 1634 IF ( .NOT. found .AND. indoor_model ) THEN 1635 CALL im_define_netcdf_grid( do3d(av,i), found, grid_x, grid_y, grid_z ) 1728 1636 ENDIF 1729 1637 … … 1731 1639 !-- Check for biometeorology quantities 1732 1640 IF ( .NOT. found .AND. biometeorology ) THEN 1733 CALL bio_define_netcdf_grid( do3d(av,i), found, & 1734 grid_x, grid_y, grid_z ) 1641 CALL bio_define_netcdf_grid( do3d(av,i), found, grid_x, grid_y, grid_z ) 1735 1642 ENDIF 1736 1643 … … 1738 1645 !-- Check for chemistry quantities 1739 1646 IF ( .NOT. found .AND. air_chemistry ) THEN 1740 CALL chem_define_netcdf_grid( do3d(av,i), found, & 1741 grid_x, grid_y, grid_z ) 1647 CALL chem_define_netcdf_grid( do3d(av,i), found, grid_x, grid_y, grid_z ) 1742 1648 ENDIF 1743 1649 … … 1745 1651 !-- Check for SALSA quantities 1746 1652 IF ( .NOT. found .AND. salsa ) THEN 1747 CALL salsa_define_netcdf_grid( do3d(av,i), found, grid_x,& 1748 grid_y, grid_z ) 1653 CALL salsa_define_netcdf_grid( do3d(av,i), found, grid_x, grid_y, grid_z ) 1749 1654 ENDIF 1750 1655 ! 1751 1656 !-- Check for user-defined quantities 1752 1657 IF ( .NOT. found .AND. user_module_enabled ) THEN 1753 CALL user_define_netcdf_grid( do3d(av,i), found, grid_x, & 1754 grid_y, grid_z ) 1658 CALL user_define_netcdf_grid( do3d(av,i), found, grid_x, grid_y, grid_z ) 1755 1659 ENDIF 1756 1660 1757 IF ( .NOT. found ) & 1758 CALL doq_define_netcdf_grid( do3d(av,i), found, grid_x, & 1759 grid_y, grid_z ) 1661 IF ( .NOT. found ) & 1662 CALL doq_define_netcdf_grid( do3d(av,i), found, grid_x, grid_y, grid_z ) 1760 1663 1761 1664 IF ( .NOT. found ) THEN 1762 WRITE ( message_string, * ) 'no grid defined for varia', & 1763 'ble ', TRIM( do3d(av,i) ) 1764 CALL message( 'define_netcdf_header', 'PA0244', 0, 1, 0, & 1765 6, 0 ) 1665 WRITE ( message_string, * ) 'no grid defined for variable ', & 1666 TRIM( do3d(av,i) ) 1667 CALL message( 'define_netcdf_header', 'PA0244', 0, 1, 0, 6, 0 ) 1766 1668 ENDIF 1767 1669 … … 1794 1696 ! 1795 1697 !-- Define the grid 1796 CALL netcdf_create_var( id_set_3d(av),(/ id_x, id_y, id_z, & 1797 id_dim_time_3d(av) /), do3d(av,i), & 1798 nc_precision(4), id_var_do3d(av,i), & 1799 TRIM( do3d_unit(av,i) ), do3d(av,i), 79, & 1800 80, 357, .TRUE. ) 1698 CALL netcdf_create_var( id_set_3d(av),(/ id_x, id_y, id_z, id_dim_time_3d(av) /), & 1699 do3d(av,i), nc_precision(4), id_var_do3d(av,i), & 1700 TRIM( do3d_unit(av,i) ), do3d(av,i), 79, 80, 357, .TRUE. ) 1801 1701 #if defined( __netcdf4_parallel ) 1802 1702 IF ( netcdf_data_format > 4 ) THEN 1803 1703 ! 1804 1704 !-- Set no fill for every variable to increase performance. 1805 nc_stat = NF90_DEF_VAR_FILL( id_set_3d(av), & 1806 id_var_do3d(av,i), & 1807 NF90_NOFILL, 0 ) 1705 nc_stat = NF90_DEF_VAR_FILL( id_set_3d(av), id_var_do3d(av,i), NF90_NOFILL, 0 ) 1808 1706 CALL netcdf_handle_error( 'netcdf_define_header', 532 ) 1809 1707 ! 1810 1708 !-- Set collective io operations for parallel io 1811 nc_stat = NF90_VAR_PAR_ACCESS( id_set_3d(av), & 1812 id_var_do3d(av,i), & 1813 NF90_COLLECTIVE ) 1709 nc_stat = NF90_VAR_PAR_ACCESS( id_set_3d(av), id_var_do3d(av,i), NF90_COLLECTIVE ) 1814 1710 CALL netcdf_handle_error( 'netcdf_define_header', 445 ) 1815 1711 ENDIF … … 1826 1722 1827 1723 ! 1828 !-- Write the list of variables as global attribute (this is used by 1829 !-- restart runs and by combine_plot_fields) 1830 nc_stat = NF90_PUT_ATT( id_set_3d(av), NF90_GLOBAL, 'VAR_LIST', & 1831 var_list ) 1724 !-- Write the list of variables as global attribute (this is used by restart runs and by 1725 !-- combine_plot_fields). 1726 nc_stat = NF90_PUT_ATT( id_set_3d(av), NF90_GLOBAL, 'VAR_LIST', var_list ) 1832 1727 CALL netcdf_handle_error( 'netcdf_define_header', 81 ) 1833 1728 1834 1729 ! 1835 !-- Set general no fill, otherwise the performance drops significantly for 1836 !-- parallel output. 1730 !-- Set general no fill, otherwise the performance drops significantly for parallel output. 1837 1731 nc_stat = NF90_SET_FILL( id_set_3d(av), NF90_NOFILL, oldmode ) 1838 1732 CALL netcdf_handle_error( 'netcdf_define_header', 528 ) … … 1844 1738 1845 1739 ! 1846 !-- These data are only written by PE0 for parallel output to increase 1847 !-- the performance. 1740 !-- These data are only written by PE0 for parallel output to increase the performance. 1848 1741 IF ( myid == 0 .OR. netcdf_data_format < 5 ) THEN 1849 1742 ! … … 1855 1748 ENDDO 1856 1749 1857 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_x_3d(av), &1858 netcdf_data, start = (/ 1 /), &1750 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_x_3d(av), & 1751 netcdf_data, start = (/ 1 /), & 1859 1752 count = (/ nx+1 /) ) 1860 1753 CALL netcdf_handle_error( 'netcdf_define_header', 83 ) … … 1864 1757 ENDDO 1865 1758 1866 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_xu_3d(av), &1867 netcdf_data, start = (/ 1 /), &1759 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_xu_3d(av), & 1760 netcdf_data, start = (/ 1 /), & 1868 1761 count = (/ nx+1 /) ) 1869 1762 CALL netcdf_handle_error( 'netcdf_define_header', 385 ) … … 1879 1772 ENDDO 1880 1773 1881 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_y_3d(av), &1882 netcdf_data, start = (/ 1 /), &1774 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_y_3d(av), & 1775 netcdf_data, start = (/ 1 /), & 1883 1776 count = (/ ny+1 /) ) 1884 1777 CALL netcdf_handle_error( 'netcdf_define_header', 84 ) … … 1888 1781 ENDDO 1889 1782 1890 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_yv_3d(av), &1891 netcdf_data, start = (/ 1 /), &1783 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_yv_3d(av), & 1784 netcdf_data, start = (/ 1 /), & 1892 1785 count = (/ ny+1 /)) 1893 1786 CALL netcdf_handle_error( 'netcdf_define_header', 387 ) … … 1920 1813 1921 1814 DO i = 0, nx 1922 netcdf_data(i) = init_model%origin_x & 1923 + cos_rot_angle * ( i + shift_x ) * dx 1815 netcdf_data(i) = init_model%origin_x + cos_rot_angle * ( i + shift_x ) * dx 1924 1816 ENDDO 1925 1817 1926 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_eutm_3d(k,av), &1927 netcdf_data, start = (/ 1 /), &1818 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_eutm_3d(k,av), & 1819 netcdf_data, start = (/ 1 /), & 1928 1820 count = (/ nx+1 /) ) 1929 1821 CALL netcdf_handle_error( 'netcdf_define_header', 555 ) … … 1950 1842 1951 1843 DO j = 0, ny 1952 netcdf_data(j) = init_model%origin_y & 1953 + cos_rot_angle * ( j + shift_y ) * dy 1844 netcdf_data(j) = init_model%origin_y + cos_rot_angle * ( j + shift_y ) * dy 1954 1845 ENDDO 1955 1846 1956 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_nutm_3d(k,av), &1957 netcdf_data, start = (/ 1 /), &1847 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_nutm_3d(k,av), & 1848 netcdf_data, start = (/ 1 /), & 1958 1849 count = (/ ny+1 /) ) 1959 1850 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) … … 1986 1877 DO j = 0, ny 1987 1878 DO i = 0, nx 1988 netcdf_data_2d(i,j) = init_model%origin_x &1989 + cos_rot_angle * ( i + shift_x ) * dx&1990 + sin_rot_angle * ( j + shift_y ) * dy1879 netcdf_data_2d(i,j) = init_model%origin_x & 1880 + cos_rot_angle * ( i + shift_x ) * dx & 1881 + sin_rot_angle * ( j + shift_y ) * dy 1991 1882 ENDDO 1992 1883 ENDDO 1993 1884 1994 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_eutm_3d(k,av), &1995 netcdf_data_2d, start = (/ 1, 1 /), &1885 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_eutm_3d(k,av), & 1886 netcdf_data_2d, start = (/ 1, 1 /), & 1996 1887 count = (/ nx+1, ny+1 /) ) 1997 1888 CALL netcdf_handle_error( 'netcdf_define_header', 555 ) … … 1999 1890 DO j = 0, ny 2000 1891 DO i = 0, nx 2001 netcdf_data_2d(i,j) = init_model%origin_y &2002 - sin_rot_angle * ( i + shift_x ) * dx &2003 + cos_rot_angle * ( j + shift_y ) * dy1892 netcdf_data_2d(i,j) = init_model%origin_y & 1893 - sin_rot_angle * ( i + shift_x ) * dx & 1894 + cos_rot_angle * ( j + shift_y ) * dy 2004 1895 ENDDO 2005 1896 ENDDO 2006 1897 2007 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_nutm_3d(k,av), &2008 netcdf_data_2d, start = (/ 1, 1 /), &1898 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_nutm_3d(k,av), & 1899 netcdf_data_2d, start = (/ 1, 1 /), & 2009 1900 count = (/ nx+1, ny+1 /) ) 2010 1901 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) … … 2015 1906 ! 2016 1907 !-- Write zu and zw data (vertical axes) 2017 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zu_3d(av), &2018 zu(nzb:nz_do3d), start = (/ 1 /), &1908 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zu_3d(av), & 1909 zu(nzb:nz_do3d), start = (/ 1 /), & 2019 1910 count = (/ nz_do3d-nzb+1 /) ) 2020 1911 CALL netcdf_handle_error( 'netcdf_define_header', 85 ) 2021 1912 2022 1913 2023 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zw_3d(av), &2024 zw(nzb:nz_do3d), start = (/ 1 /), &1914 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zw_3d(av), & 1915 zw(nzb:nz_do3d), start = (/ 1 /), & 2025 1916 count = (/ nz_do3d-nzb+1 /) ) 2026 1917 CALL netcdf_handle_error( 'netcdf_define_header', 86 ) … … 2029 1920 ! 2030 1921 !-- Write zs grid 2031 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zs_3d(av), &2032 - zs(nzb_soil:nzt_soil), start = (/ 1 /), &1922 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zs_3d(av), & 1923 - zs(nzb_soil:nzt_soil), start = (/ 1 /), & 2033 1924 count = (/ nzt_soil-nzb_soil+1 /) ) 2034 1925 CALL netcdf_handle_error( 'netcdf_define_header', 86 ) … … 2038 1929 ! 2039 1930 !-- Write zpc grid 2040 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zpc_3d(av), &2041 zu(nzb:nzb+pch_index), start = (/ 1 /), &1931 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zpc_3d(av), & 1932 zu(nzb:nzb+pch_index), start = (/ 1 /), & 2042 1933 count = (/ pch_index+1 /) ) 2043 1934 CALL netcdf_handle_error( 'netcdf_define_header', 86 ) … … 2071 1962 DO j = nys, nyn 2072 1963 DO i = nxl, nxr 2073 eutm = init_model%origin_x & 2074 + cos_rot_angle * ( i + shift_x ) * dx & 2075 + sin_rot_angle * ( j + shift_y ) * dy 2076 nutm = init_model%origin_y & 2077 - sin_rot_angle * ( i + shift_x ) * dx & 2078 + cos_rot_angle * ( j + shift_y ) * dy 2079 2080 CALL convert_utm_to_geographic( crs_list, & 2081 eutm, nutm, & 2082 lon(i,j), lat(i,j) ) 1964 eutm = init_model%origin_x & 1965 + cos_rot_angle * ( i + shift_x ) * dx & 1966 + sin_rot_angle * ( j + shift_y ) * dy 1967 nutm = init_model%origin_y & 1968 - sin_rot_angle * ( i + shift_x ) * dx & 1969 + cos_rot_angle * ( j + shift_y ) * dy 1970 1971 CALL convert_utm_to_geographic( crs_list, eutm, nutm, lon(i,j), lat(i,j) ) 2083 1972 ENDDO 2084 1973 ENDDO 2085 1974 2086 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_lon_3d(k,av), &2087 lon, start = (/ nxl+1, nys+1 /),&2088 count = (/ nxr-nxl+1, nyn-nys+1 /) )1975 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_lon_3d(k,av), & 1976 lon, start = (/ nxl+1, nys+1 /), & 1977 count = (/ nxr-nxl+1, nyn-nys+1 /) ) 2089 1978 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) 2090 1979 2091 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_lat_3d(k,av), &2092 lat, start = (/ nxl+1, nys+1 /),&2093 count = (/ nxr-nxl+1, nyn-nys+1 /) )1980 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_lat_3d(k,av), & 1981 lat, start = (/ nxl+1, nys+1 /), & 1982 count = (/ nxr-nxl+1, nyn-nys+1 /) ) 2094 1983 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) 2095 1984 ENDDO … … 2100 1989 ENDIF 2101 1990 ! 2102 !-- In case of non-flat topography write height information. Only for 2103 !-- parallel netcdf output. 2104 IF ( TRIM( topography ) /= 'flat' .AND. & 2105 netcdf_data_format > 4 ) THEN 1991 !-- In case of non-flat topography write height information. Only for parallel netcdf output. 1992 IF ( TRIM( topography ) /= 'flat' .AND. netcdf_data_format > 4 ) THEN 2106 1993 2107 1994 ! IF ( nxr == nx .AND. nyn /= ny ) THEN 2108 ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zusi_3d(av), &2109 ! zu_s_inner(nxl:nxr+1,nys:nyn), &2110 ! start = (/ nxl+1, nys+1 /), &1995 ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zusi_3d(av), & 1996 ! zu_s_inner(nxl:nxr+1,nys:nyn), & 1997 ! start = (/ nxl+1, nys+1 /), & 2111 1998 ! count = (/ nxr-nxl+2, nyn-nys+1 /) ) 2112 1999 ! ELSEIF ( nxr /= nx .AND. nyn == ny ) THEN 2113 ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zusi_3d(av), &2114 ! zu_s_inner(nxl:nxr,nys:nyn+1), &2115 ! start = (/ nxl+1, nys+1 /), &2000 ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zusi_3d(av), & 2001 ! zu_s_inner(nxl:nxr,nys:nyn+1), & 2002 ! start = (/ nxl+1, nys+1 /), & 2116 2003 ! count = (/ nxr-nxl+1, nyn-nys+2 /) ) 2117 2004 ! ELSEIF ( nxr == nx .AND. nyn == ny ) THEN 2118 ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zusi_3d(av), &2119 ! zu_s_inner(nxl:nxr+1,nys:nyn+1), &2120 ! start = (/ nxl+1, nys+1 /), &2005 ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zusi_3d(av), & 2006 ! zu_s_inner(nxl:nxr+1,nys:nyn+1), & 2007 ! start = (/ nxl+1, nys+1 /), & 2121 2008 ! count = (/ nxr-nxl+2, nyn-nys+2 /) ) 2122 2009 ! ELSE 2123 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zusi_3d(av), &2124 zu_s_inner(nxl:nxr,nys:nyn), &2125 start = (/ nxl+1, nys+1 /), &2010 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zusi_3d(av), & 2011 zu_s_inner(nxl:nxr,nys:nyn), & 2012 start = (/ nxl+1, nys+1 /), & 2126 2013 count = (/ nxr-nxl+1, nyn-nys+1 /) ) 2127 2014 ! ENDIF … … 2129 2016 2130 2017 ! IF ( nxr == nx .AND. nyn /= ny ) THEN 2131 ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zwwi_3d(av), &2132 ! zw_w_inner(nxl:nxr+1,nys:nyn), &2133 ! start = (/ nxl+1, nys+1 /), &2018 ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zwwi_3d(av), & 2019 ! zw_w_inner(nxl:nxr+1,nys:nyn), & 2020 ! start = (/ nxl+1, nys+1 /), & 2134 2021 ! count = (/ nxr-nxl+2, nyn-nys+1 /) ) 2135 2022 ! ELSEIF ( nxr /= nx .AND. nyn == ny ) THEN 2136 ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zwwi_3d(av), &2137 ! zw_w_inner(nxl:nxr,nys:nyn+1), &2138 ! start = (/ nxl+1, nys+1 /), &2023 ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zwwi_3d(av), & 2024 ! zw_w_inner(nxl:nxr,nys:nyn+1), & 2025 ! start = (/ nxl+1, nys+1 /), & 2139 2026 ! count = (/ nxr-nxl+1, nyn-nys+2 /) ) 2140 2027 ! ELSEIF ( nxr == nx .AND. nyn == ny ) THEN 2141 ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zwwi_3d(av), &2142 ! zw_w_inner(nxl:nxr+1,nys:nyn+1), &2143 ! start = (/ nxl+1, nys+1 /), &2028 ! nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zwwi_3d(av), & 2029 ! zw_w_inner(nxl:nxr+1,nys:nyn+1), & 2030 ! start = (/ nxl+1, nys+1 /), & 2144 2031 ! count = (/ nxr-nxl+2, nyn-nys+2 /) ) 2145 2032 ! ELSE 2146 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zwwi_3d(av), &2147 zw_w_inner(nxl:nxr,nys:nyn), &2148 start = (/ nxl+1, nys+1 /), &2033 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zwwi_3d(av), & 2034 zw_w_inner(nxl:nxr,nys:nyn), & 2035 start = (/ nxl+1, nys+1 /), & 2149 2036 count = (/ nxr-nxl+1, nyn-nys+1 /) ) 2150 2037 ! ENDIF … … 2157 2044 ! 2158 2045 !-- Get the list of variables and compare with the actual run. 2159 !-- First var_list_old has to be reset, since GET_ATT does not assign 2160 !-- trailing blanks. 2046 !-- First var_list_old has to be reset, since GET_ATT does not assign trailing blanks. 2161 2047 var_list_old = ' ' 2162 nc_stat = NF90_GET_ATT( id_set_3d(av), NF90_GLOBAL, 'VAR_LIST', & 2163 var_list_old ) 2048 nc_stat = NF90_GET_ATT( id_set_3d(av), NF90_GLOBAL, 'VAR_LIST', var_list_old ) 2164 2049 CALL netcdf_handle_error( 'netcdf_define_header', 87 ) 2165 2050 2166 2051 var_list = ';' 2167 2052 i = 1 2168 DO WHILE ( do3d(av,i)(1:1) /= ' ' )2169 var_list = TRIM( var_list) // TRIM( do3d(av,i) ) // ';'2053 DO WHILE ( do3d(av,i)(1:1) /= ' ' ) 2054 var_list = TRIM( var_list ) // TRIM( do3d(av,i) ) // ';' 2170 2055 i = i + 1 2171 2056 ENDDO … … 2178 2063 2179 2064 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 2180 message_string = 'netCDF file for volume data ' // & 2181 TRIM( var ) // ' from previous run found,' // & 2182 '&but this file cannot be extended due to' // & 2183 ' variable mismatch.' // & 2184 '&New file is created instead.' 2065 message_string = 'netCDF file for volume data ' // TRIM( var ) // & 2066 ' from previous run found,' // & 2067 '&but this file cannot be extended due to' // & 2068 ' variable mismatch.' // '&New file is created instead.' 2185 2069 CALL message( 'define_netcdf_header', 'PA0245', 0, 1, 0, 6, 0 ) 2186 2070 extend = .FALSE. … … 2193 2077 CALL netcdf_handle_error( 'netcdf_define_header', 88 ) 2194 2078 2195 nc_stat = NF90_INQUIRE_VARIABLE( id_set_3d(av), id_var_zu_3d(av), &2079 nc_stat = NF90_INQUIRE_VARIABLE( id_set_3d(av), id_var_zu_3d(av), & 2196 2080 dimids = id_dim_zu_3d_old ) 2197 2081 CALL netcdf_handle_error( 'netcdf_define_header', 89 ) 2198 2082 id_dim_zu_3d(av) = id_dim_zu_3d_old(1) 2199 2083 2200 nc_stat = NF90_INQUIRE_DIMENSION( id_set_3d(av), id_dim_zu_3d(av), & 2201 len = nz_old ) 2084 nc_stat = NF90_INQUIRE_DIMENSION( id_set_3d(av), id_dim_zu_3d(av), LEN = nz_old ) 2202 2085 CALL netcdf_handle_error( 'netcdf_define_header', 90 ) 2203 2086 2204 2087 IF ( nz_do3d-nzb+1 /= nz_old ) THEN 2205 message_string = 'netCDF file for volume data ' // & 2206 TRIM( var ) // ' from previous run found,' // & 2207 '&but this file cannot be extended due to' // & 2208 ' mismatch in number of' // & 2209 ' vertical grid points (nz_do3d).' // & 2088 message_string = 'netCDF file for volume data ' // TRIM( var ) // & 2089 ' from previous run found,' // & 2090 '&but this file cannot be extended due to' // & 2091 ' mismatch in number of' // ' vertical grid points (nz_do3d).' // & 2210 2092 '&New file is created instead.' 2211 2093 CALL message( 'define_netcdf_header', 'PA0246', 0, 1, 0, 6, 0 ) … … 2215 2097 2216 2098 ! 2217 !-- Get the id of the time coordinate (unlimited coordinate) and its 2218 !-- last index on the file. The next time level is pl3d..count+1. 2219 !-- The current time must be larger than the last output time 2220 !-- on the file. 2099 !-- Get the id of the time coordinate (unlimited coordinate) and its last index on the file. 2100 !-- The next time level is pl3d..count+1. 2101 !-- The current time must be larger than the last output time on the file. 2221 2102 nc_stat = NF90_INQ_VARID( id_set_3d(av), 'time', id_var_time_3d(av) ) 2222 2103 CALL netcdf_handle_error( 'netcdf_define_header', 91 ) 2223 2104 2224 nc_stat = NF90_INQUIRE_VARIABLE( id_set_3d(av), id_var_time_3d(av), &2105 nc_stat = NF90_INQUIRE_VARIABLE( id_set_3d(av), id_var_time_3d(av), & 2225 2106 dimids = id_dim_time_old ) 2226 2107 CALL netcdf_handle_error( 'netcdf_define_header', 92 ) … … 2228 2109 id_dim_time_3d(av) = id_dim_time_old(1) 2229 2110 2230 nc_stat = NF90_INQUIRE_DIMENSION( id_set_3d(av), id_dim_time_3d(av), & 2231 len = ntime_count ) 2111 nc_stat = NF90_INQUIRE_DIMENSION( id_set_3d(av), id_dim_time_3d(av), LEN = ntime_count ) 2232 2112 CALL netcdf_handle_error( 'netcdf_define_header', 93 ) 2233 2113 2234 2114 ! 2235 !-- For non-parallel output use the last output time level of the netcdf 2236 !-- file because the time dimension is unlimited. In case of parallel 2237 !-- output the variable ntime_count could get the value of 9*10E36 because 2238 !-- the time dimension is limited. 2115 !-- For non-parallel output use the last output time level of the netcdf file because the time 2116 !-- dimension is unlimited. In case of parallel output the variable ntime_count could get the 2117 !-- value of 9*10E36 because the time dimension is limited. 2239 2118 IF ( netcdf_data_format < 5 ) do3d_time_count(av) = ntime_count 2240 2119 2241 nc_stat = NF90_GET_VAR( id_set_3d(av), id_var_time_3d(av), &2242 last_time_coordinate, &2243 start = (/ do3d_time_count(av) /), &2120 nc_stat = NF90_GET_VAR( id_set_3d(av), id_var_time_3d(av), & 2121 last_time_coordinate, & 2122 start = (/ do3d_time_count(av) /), & 2244 2123 count = (/ 1 /) ) 2245 2124 CALL netcdf_handle_error( 'netcdf_define_header', 94 ) 2246 2125 2247 2126 IF ( last_time_coordinate(1) >= simulated_time ) THEN 2248 message_string = 'netCDF file for volume data ' // & 2249 TRIM( var ) // ' from previous run found,' // & 2250 '&but this file cannot be extended becaus' // & 2251 'e the current output time' // & 2252 '&is less or equal than the last output t' // & 2253 'ime on this file.' // & 2127 message_string = 'netCDF file for volume data ' // TRIM( var ) // & 2128 ' from previous run found,' // & 2129 '&but this file cannot be extended because' // & 2130 ' the current output time' // & 2131 '&is less or equal than the last output time' // ' on this file.' // & 2254 2132 '&New file is created instead.' 2255 2133 CALL message( 'define_netcdf_header', 'PA0247', 0, 1, 0, 6, 0 ) … … 2261 2139 IF ( netcdf_data_format > 4 ) THEN 2262 2140 ! 2263 !-- Check if the needed number of output time levels is increased 2264 !-- compared to the number oftime levels in the existing file.2141 !-- Check if the needed number of output time levels is increased compared to the number of 2142 !-- time levels in the existing file. 2265 2143 IF ( ntdim_3d(av) > ntime_count ) THEN 2266 message_string = 'netCDF file for volume data ' // & 2267 TRIM( var ) // ' from previous run found,' // & 2268 '&but this file cannot be extended becaus' // & 2269 'e the number of output time levels has b' // & 2270 'een increased compared to the previous s' // & 2271 'imulation.' // & 2144 message_string = 'netCDF file for volume data ' // TRIM( var ) // & 2145 ' from previous run found,' // & 2146 '&but this file cannot be extended becaus' // & 2147 'e the number of output time levels has b' // & 2148 'een increased compared to the previous s' // 'imulation.' // & 2272 2149 '&New file is created instead.' 2273 2150 CALL message( 'define_netcdf_header', 'PA0388', 0, 1, 0, 6, 0 ) … … 2277 2154 !-- Recalculate the needed time levels for the new file. 2278 2155 IF ( av == 0 ) THEN 2279 ntdim_3d(0) = CEILING( & 2280 ( end_time - MAX( skip_time_do3d, & 2281 simulated_time_at_begin ) & 2282 ) / dt_do3d ) 2156 ntdim_3d(0) = CEILING( ( end_time - MAX( skip_time_do3d, & 2157 simulated_time_at_begin ) & 2158 ) / dt_do3d ) 2283 2159 IF ( do3d_at_begin ) ntdim_3d(0) = ntdim_3d(0) + 1 2284 2160 ELSE 2285 ntdim_3d(1) = CEILING( & 2286 ( end_time - MAX( skip_time_data_output_av, & 2287 simulated_time_at_begin ) & 2288 ) / dt_data_output_av ) 2161 ntdim_3d(1) = CEILING( ( end_time - MAX( skip_time_data_output_av, & 2162 simulated_time_at_begin ) & 2163 ) / dt_data_output_av ) 2289 2164 ENDIF 2290 2165 RETURN … … 2296 2171 !-- Now get the variable ids. 2297 2172 i = 1 2298 DO WHILE ( do3d(av,i)(1:1) /= ' ' ) 2299 nc_stat = NF90_INQ_VARID( id_set_3d(av), TRIM( do3d(av,i) ), & 2300 id_var_do3d(av,i) ) 2173 DO WHILE ( do3d(av,i)(1:1) /= ' ' ) 2174 nc_stat = NF90_INQ_VARID( id_set_3d(av), TRIM( do3d(av,i) ), id_var_do3d(av,i) ) 2301 2175 CALL netcdf_handle_error( 'netcdf_define_header', 95 ) 2302 2176 #if defined( __netcdf4_parallel ) … … 2304 2178 !-- Set collective io operations for parallel io 2305 2179 IF ( netcdf_data_format > 4 ) THEN 2306 nc_stat = NF90_VAR_PAR_ACCESS( id_set_3d(av), & 2307 id_var_do3d(av,i), & 2308 NF90_COLLECTIVE ) 2180 nc_stat = NF90_VAR_PAR_ACCESS( id_set_3d(av), id_var_do3d(av,i), NF90_COLLECTIVE ) 2309 2181 CALL netcdf_handle_error( 'netcdf_define_header', 453 ) 2310 2182 ENDIF … … 2314 2186 2315 2187 ! 2316 !-- Update the title attribute on file 2317 !-- In order to avoid 'data mode' errors if updated attributes are larger 2318 !-- than their original size, NF90_PUT_ATT is called in 'define mode' 2319 !-- enclosed by NF90_REDEF and NF90_ENDDEF calls. This implies a possible 2320 !-- performance loss due to data copying; an alternative strategy would be 2321 !-- to ensure equal attribute size. Maybe revise later. 2188 !-- Update the title attribute on file. 2189 !-- In order to avoid 'data mode' errors if updated attributes are larger than their original 2190 !-- size, NF90_PUT_ATT is called in 'define mode' enclosed by NF90_REDEF and NF90_ENDDEF 2191 !-- calls. This implies a possible performance loss due to data copying; an alternative 2192 !-- strategy would be to ensure equal attribute size. Maybe revise later. 2322 2193 IF ( av == 0 ) THEN 2323 2194 time_average_text = ' ' 2324 2195 ELSE 2325 WRITE (time_average_text, '('', '',F7.1,'' s average'')') & 2326 averaging_interval 2196 WRITE ( time_average_text, '('', '',F7.1,'' s average'')' ) averaging_interval 2327 2197 ENDIF 2328 2198 nc_stat = NF90_REDEF( id_set_3d(av) ) 2329 2199 CALL netcdf_handle_error( 'netcdf_define_header', 429 ) 2330 nc_stat = NF90_PUT_ATT( id_set_3d(av), NF90_GLOBAL, 'title', & 2331 TRIM( run_description_header ) // & 2332 TRIM( time_average_text ) ) 2200 nc_stat = NF90_PUT_ATT( id_set_3d(av), NF90_GLOBAL, 'title', & 2201 TRIM( run_description_header ) // TRIM( time_average_text ) ) 2333 2202 CALL netcdf_handle_error( 'netcdf_define_header', 96 ) 2334 2203 nc_stat = NF90_ENDDEF( id_set_3d(av) ) 2335 2204 CALL netcdf_handle_error( 'netcdf_define_header', 430 ) 2336 message_string = 'netCDF file for volume data ' // & 2337 TRIM( var ) // ' from previous run found.' // & 2338 '&This file will be extended.' 2205 message_string = 'netCDF file for volume data ' // TRIM( var ) // & 2206 ' from previous run found.' // '&This file will be extended.' 2339 2207 CALL message( 'define_netcdf_header', 'PA0248', 0, 0, 0, 6, 0 ) 2340 2208 … … 2344 2212 ! 2345 2213 !-- Define some global attributes of the dataset 2346 nc_stat = NF90_PUT_ATT( id_set_agt, NF90_GLOBAL, 'title', & 2347 TRIM( run_description_header ) ) 2214 nc_stat = NF90_PUT_ATT( id_set_agt, NF90_GLOBAL, 'title', TRIM( run_description_header ) ) 2348 2215 CALL netcdf_handle_error( 'netcdf_define_header', 330 ) 2349 2216 ! 2350 2217 !-- Switch for unlimited time dimension 2351 2218 IF ( agent_time_unlimited ) THEN 2352 CALL netcdf_create_dim( id_set_agt, 'time', NF90_UNLIMITED, & 2219 CALL netcdf_create_dim( id_set_agt, 'time', NF90_UNLIMITED, id_dim_time_agt, 331 ) 2220 ELSE 2221 CALL netcdf_create_dim( id_set_agt, 'time', & 2222 INT( ( MIN( multi_agent_system_end, end_time ) - & 2223 multi_agent_system_start ) / & 2224 dt_write_agent_data * 1.1 ), & 2353 2225 id_dim_time_agt, 331 ) 2354 ELSE 2355 CALL netcdf_create_dim( id_set_agt, 'time', & 2356 INT( ( MIN( multi_agent_system_end, & 2357 end_time ) - & 2358 multi_agent_system_start ) / & 2359 dt_write_agent_data * 1.1 ), & 2360 id_dim_time_agt, 331 ) 2361 ENDIF 2362 2363 CALL netcdf_create_var( id_set_agt, (/ id_dim_time_agt /), 'time', & 2364 NF90_REAL4, id_var_time_agt, 'seconds', 'time', & 2365 332, 333, 000 ) 2226 ENDIF 2227 2228 CALL netcdf_create_var( id_set_agt, (/ id_dim_time_agt /), 'time', NF90_REAL4, & 2229 id_var_time_agt, 'seconds', 'time', 332, 333, 000 ) 2366 2230 CALL netcdf_create_att( id_set_agt, id_var_time_agt, 'standard_name', 'time', 000) 2367 2231 CALL netcdf_create_att( id_set_agt, id_var_time_agt, 'axis', 'T', 000) 2368 2232 2369 CALL netcdf_create_dim( id_set_agt, 'agent_number', & 2370 dim_size_agtnum, id_dim_agtnum, 334 ) 2371 2372 CALL netcdf_create_var( id_set_agt, (/ id_dim_agtnum /), & 2373 'agent_number', NF90_REAL4, & 2374 id_var_agtnum, 'agent number', '', 335, & 2375 336, 000 ) 2233 CALL netcdf_create_dim( id_set_agt, 'agent_number', dim_size_agtnum, id_dim_agtnum, 334 ) 2234 2235 CALL netcdf_create_var( id_set_agt, (/ id_dim_agtnum /), 'agent_number', NF90_REAL4, & 2236 id_var_agtnum, 'agent number', '', 335, 336, 000 ) 2376 2237 ! 2377 2238 !-- Define variable which contains the real number of agents in use 2378 CALL netcdf_create_var( id_set_agt, (/ id_dim_time_agt /), & 2379 'real_num_of_agt', NF90_REAL4, & 2380 id_var_rnoa_agt, 'agent number', '', 337, & 2381 338, 000 ) 2239 CALL netcdf_create_var( id_set_agt, (/ id_dim_time_agt /), 'real_num_of_agt', NF90_REAL4,& 2240 id_var_rnoa_agt, 'agent number', '', 337, 338, 000 ) 2382 2241 i = 1 2383 CALL netcdf_create_var( id_set_agt, (/ id_dim_agtnum, & 2384 id_dim_time_agt /), agt_var_names(i), & 2385 NF90_DOUBLE, id_var_agt(i), & 2386 TRIM( agt_var_units(i) ), & 2387 TRIM( agt_var_names(i) ), 339, 340, 341 ) 2242 CALL netcdf_create_var( id_set_agt, (/ id_dim_agtnum, id_dim_time_agt /), & 2243 agt_var_names(i), NF90_DOUBLE, id_var_agt(i), & 2244 TRIM( agt_var_units(i) ), TRIM( agt_var_names(i) ), & 2245 339, 340, 341 ) 2388 2246 ! 2389 2247 !-- Define the variables 2390 2248 DO i = 2, 6 2391 CALL netcdf_create_var( id_set_agt, (/ id_dim_agtnum, & 2392 id_dim_time_agt /), agt_var_names(i), & 2393 NF90_REAL4, id_var_agt(i), & 2394 TRIM( agt_var_units(i) ), & 2395 TRIM( agt_var_names(i) ), 339, 340, 341 ) 2249 CALL netcdf_create_var( id_set_agt, (/ id_dim_agtnum, id_dim_time_agt /), & 2250 agt_var_names(i), NF90_REAL4, id_var_agt(i), & 2251 TRIM( agt_var_units(i) ), TRIM( agt_var_names(i) ), & 2252 339, 340, 341 ) 2396 2253 2397 2254 ENDDO … … 2399 2256 !-- Define vars for biometeorology 2400 2257 IF ( biometeorology ) THEN 2401 CALL netcdf_create_var( id_set_agt, (/ id_dim_agtnum, & 2402 id_dim_time_agt /), agt_var_names(7), & 2403 nc_precision(8), id_var_agt(7), & 2404 TRIM( agt_var_units(7) ), & 2405 TRIM( agt_var_names(7) ), 339, 340, 341 ) 2258 CALL netcdf_create_var( id_set_agt, (/ id_dim_agtnum, id_dim_time_agt /), & 2259 agt_var_names(7), nc_precision(8), id_var_agt(7), & 2260 TRIM( agt_var_units(7) ), TRIM( agt_var_names(7) ), & 2261 339, 340, 341 ) 2406 2262 ENDIF 2407 2263 ! … … 2415 2271 ! 2416 2272 ! ! 2417 ! !-- Get the id of the time coordinate (unlimited coordinate) and its 2418 ! !-- last index on the file. The next time level is prt..count+1. 2419 ! !-- The current time must be larger than the last output time 2420 ! !-- on the file. 2273 ! !-- Get the id of the time coordinate (unlimited coordinate) and its last index on the file. 2274 ! !-- The next time level is prt..count+1. 2275 ! !-- The current time must be larger than the last output time on the file. 2421 2276 ! nc_stat = NF90_INQ_VARID( id_set_agt, 'time', id_var_time_agt ) 2422 2277 ! CALL netcdf_handle_error( 'netcdf_define_header', 343 ) 2423 2278 ! 2424 ! nc_stat = NF90_INQUIRE_VARIABLE( id_set_agt, id_var_time_agt, & 2425 ! dimids = id_dim_time_old ) 2279 ! nc_stat = NF90_INQUIRE_VARIABLE( id_set_agt, id_var_time_agt, dimids = id_dim_time_old ) 2426 2280 ! CALL netcdf_handle_error( 'netcdf_define_header', 344 ) 2427 2281 ! id_dim_time_agt = id_dim_time_old(1) 2428 2282 ! 2429 ! nc_stat = NF90_INQUIRE_DIMENSION( id_set_agt, id_dim_time_agt, & 2430 ! len = agt_time_count ) 2283 ! nc_stat = NF90_INQUIRE_DIMENSION( id_set_agt, id_dim_time_agt, LEN = agt_time_count ) 2431 2284 ! CALL netcdf_handle_error( 'netcdf_define_header', 345 ) 2432 2285 ! 2433 ! nc_stat = NF90_GET_VAR( id_set_agt, id_var_time_agt, &2434 ! last_time_coordinate, &2435 ! start = (/ agt_time_count /), &2286 ! nc_stat = NF90_GET_VAR( id_set_agt, id_var_time_agt, & 2287 ! last_time_coordinate, & 2288 ! start = (/ agt_time_count /), & 2436 2289 ! count = (/ 1 /) ) 2437 2290 ! CALL netcdf_handle_error( 'netcdf_define_header', 346 ) 2438 2291 ! 2439 2292 ! IF ( last_time_coordinate(1) >= simulated_time ) THEN 2440 ! message_string = 'netCDF file for agents ' // & 2441 ! 'from previous run found,' // & 2442 ! '&but this file cannot be extended becaus' // & 2443 ! 'e the current output time' // & 2444 ! '&is less or equal than the last output t' // & 2445 ! 'ime on this file.' // & 2293 ! message_string = 'netCDF file for agents ' //'from previous run found,' // & 2294 ! '&but this file cannot be extended because' // & 2295 ! ' the current output time' // & 2296 ! '&is less or equal than the last output time' // ' on this file.' //& 2446 2297 ! '&New file is created instead.' 2447 2298 ! CALL message( 'define_netcdf_header', 'PA0265', 0, 1, 0, 6, 0 ) … … 2454 2305 ! !-- Dataset seems to be extendable. 2455 2306 ! !-- Now get the variable ids. 2456 ! nc_stat = NF90_INQ_VARID( id_set_agt, 'real_num_of_agt', & 2457 ! id_var_rnoa_agt ) 2307 ! nc_stat = NF90_INQ_VARID( id_set_agt, 'real_num_of_agt', id_var_rnoa_agt ) 2458 2308 ! CALL netcdf_handle_error( 'netcdf_define_header', 347 ) 2459 2309 ! 2460 2310 ! DO i = 1, 17 2461 2311 ! 2462 ! nc_stat = NF90_INQ_VARID( id_set_agt, agt_var_names(i), & 2463 ! id_var_prt(i) ) 2312 ! nc_stat = NF90_INQ_VARID( id_set_agt, agt_var_names(i), id_var_prt(i) ) 2464 2313 ! CALL netcdf_handle_error( 'netcdf_define_header', 348 ) 2465 2314 ! 2466 2315 ! ENDDO 2467 2316 ! 2468 ! message_string = 'netCDF file for particles ' // & 2469 ! 'from previous run found.' // & 2317 ! message_string = 'netCDF file for particles ' //'from previous run found.' // & 2470 2318 ! '&This file will be extended.' 2471 2319 ! CALL message( 'define_netcdf_header', 'PA0266', 0, 0, 0, 6, 0 ) … … 2477 2325 !-- Define some global attributes of the dataset 2478 2326 IF ( av == 0 ) THEN 2479 CALL netcdf_create_global_atts( id_set_xy(av), 'xy', TRIM( run_description_header ), 97 ) 2327 CALL netcdf_create_global_atts( id_set_xy(av), 'xy', TRIM( run_description_header ), & 2328 97 ) 2480 2329 time_average_text = ' ' 2481 2330 ELSE 2482 CALL netcdf_create_global_atts( id_set_xy(av), 'xy_av', TRIM( run_description_header ), 97 ) 2331 CALL netcdf_create_global_atts( id_set_xy(av), 'xy_av', & 2332 TRIM( run_description_header ), 97 ) 2483 2333 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval 2484 nc_stat = NF90_PUT_ATT( id_set_xy(av), NF90_GLOBAL, 'time_avg', &2334 nc_stat = NF90_PUT_ATT( id_set_xy(av), NF90_GLOBAL, 'time_avg', & 2485 2335 TRIM( time_average_text ) ) 2486 2336 CALL netcdf_handle_error( 'netcdf_define_header', 98 ) … … 2489 2339 ! 2490 2340 !-- Define time coordinate for xy sections. 2491 !-- For parallel output the time dimensions has to be limited, otherwise 2492 !-- the performance dropssignificantly.2341 !-- For parallel output the time dimensions has to be limited, otherwise the performance drops 2342 !-- significantly. 2493 2343 IF ( netcdf_data_format < 5 ) THEN 2494 CALL netcdf_create_dim( id_set_xy(av), 'time', NF90_UNLIMITED, & 2495 id_dim_time_xy(av), 99 ) 2344 CALL netcdf_create_dim( id_set_xy(av), 'time', NF90_UNLIMITED, id_dim_time_xy(av), 99 ) 2496 2345 ELSE 2497 CALL netcdf_create_dim( id_set_xy(av), 'time', ntdim_2d_xy(av), & 2498 id_dim_time_xy(av), 524 ) 2499 ENDIF 2500 2501 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_time_xy(av) /), & 2502 'time', NF90_DOUBLE, id_var_time_xy(av), & 2503 'seconds', 'time', 100, 101, 000 ) 2346 CALL netcdf_create_dim( id_set_xy(av), 'time', ntdim_2d_xy(av), id_dim_time_xy(av), & 2347 524 ) 2348 ENDIF 2349 2350 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_time_xy(av) /), 'time', NF90_DOUBLE, & 2351 id_var_time_xy(av), 'seconds', 'time', 100, 101, 000 ) 2504 2352 CALL netcdf_create_att( id_set_xy(av), id_var_time_xy(av), 'standard_name', 'time', 000) 2505 2353 CALL netcdf_create_att( id_set_xy(av), id_var_time_xy(av), 'axis', 'T', 000) … … 2511 2359 ELSE 2512 2360 ns = 1 2513 DO WHILE ( section(ns,1) /= -9999 .AND. ns <= 100 )2361 DO WHILE ( section(ns,1) /= -9999 .AND. ns <= 100 ) 2514 2362 ns = ns + 1 2515 2363 ENDDO … … 2519 2367 ! 2520 2368 !-- Define vertical coordinate grid (zu grid) 2521 CALL netcdf_create_dim( id_set_xy(av), 'zu_xy', ns, & 2522 id_dim_zu_xy(av), 102 ) 2523 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zu_xy(av) /), & 2524 'zu_xy', NF90_DOUBLE, id_var_zu_xy(av), & 2525 'meters', '', 103, 104, 000 ) 2526 CALL netcdf_create_att( id_set_xy(av), id_var_zu_xy(av), 'axis', & 2527 'Z', 000) 2369 CALL netcdf_create_dim( id_set_xy(av), 'zu_xy', ns, id_dim_zu_xy(av), 102 ) 2370 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zu_xy(av) /), 'zu_xy', NF90_DOUBLE, & 2371 id_var_zu_xy(av), 'meters', '', 103, 104, 000 ) 2372 CALL netcdf_create_att( id_set_xy(av), id_var_zu_xy(av), 'axis', 'Z', 000) 2528 2373 ! 2529 2374 !-- Define vertical coordinate grid (zw grid) 2530 CALL netcdf_create_dim( id_set_xy(av), 'zw_xy', ns, & 2531 id_dim_zw_xy(av), 105 ) 2532 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zw_xy(av) /), & 2533 'zw_xy', NF90_DOUBLE, id_var_zw_xy(av), & 2534 'meters', '', 106, 107, 000 ) 2535 CALL netcdf_create_att( id_set_xy(av), id_var_zw_xy(av), 'axis', & 2536 'Z', 000) 2375 CALL netcdf_create_dim( id_set_xy(av), 'zw_xy', ns, id_dim_zw_xy(av), 105 ) 2376 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zw_xy(av) /), 'zw_xy', NF90_DOUBLE, & 2377 id_var_zw_xy(av), 'meters', '', 106, 107, 000 ) 2378 CALL netcdf_create_att( id_set_xy(av), id_var_zw_xy(av), 'axis', 'Z', 000) 2537 2379 2538 2380 IF ( land_surface ) THEN 2539 2381 2540 2382 ns_do = 1 2541 DO WHILE ( section(ns_do,1) /= -9999 .AND. ns_do < nzs )2383 DO WHILE ( section(ns_do,1) /= -9999 .AND. ns_do < nzs ) 2542 2384 ns_do = ns_do + 1 2543 2385 ENDDO 2544 2386 ! 2545 2387 !-- Define vertical coordinate grid (zs grid) 2546 CALL netcdf_create_dim( id_set_xy(av), 'zs_xy', ns_do, & 2547 id_dim_zs_xy(av), 539 ) 2548 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zs_xy(av) /), & 2549 'zs_xy', NF90_DOUBLE, id_var_zs_xy(av), & 2550 'meters', '', 540, 541, 000 ) 2551 CALL netcdf_create_att( id_set_xy(av), id_var_zs_xy(av), 'axis', & 2552 'Z', 000) 2553 2554 ENDIF 2555 2556 ! 2557 !-- Define a pseudo vertical coordinate grid for the surface variables 2558 !-- u* and t* to store their height level 2559 CALL netcdf_create_dim( id_set_xy(av), 'zu1_xy', 1, & 2560 id_dim_zu1_xy(av), 108 ) 2561 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zu1_xy(av) /), & 2562 'zu1_xy', NF90_DOUBLE, id_var_zu1_xy(av), & 2563 'meters', '', 109, 110, 000 ) 2564 CALL netcdf_create_att( id_set_xy(av), id_var_zu1_xy(av), 'axis', & 2565 'Z', 000) 2566 ! 2567 !-- Define a variable to store the layer indices of the horizontal cross 2568 !-- sections, too 2569 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zu_xy(av) /), & 2570 'ind_z_xy', NF90_DOUBLE, & 2571 id_var_ind_z_xy(av), 'gridpoints', '', 111, & 2572 112, 000 ) 2388 CALL netcdf_create_dim( id_set_xy(av), 'zs_xy', ns_do, id_dim_zs_xy(av), 539 ) 2389 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zs_xy(av) /), 'zs_xy', NF90_DOUBLE, & 2390 id_var_zs_xy(av), 'meters', '', 540, 541, 000 ) 2391 CALL netcdf_create_att( id_set_xy(av), id_var_zs_xy(av), 'axis', 'Z', 000) 2392 2393 ENDIF 2394 2395 ! 2396 !-- Define a pseudo vertical coordinate grid for the surface variables u* and t* to store 2397 !-- their height level. 2398 CALL netcdf_create_dim( id_set_xy(av), 'zu1_xy', 1, id_dim_zu1_xy(av), 108 ) 2399 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zu1_xy(av) /), 'zu1_xy', NF90_DOUBLE, & 2400 id_var_zu1_xy(av), 'meters', '', 109, 110, 000 ) 2401 CALL netcdf_create_att( id_set_xy(av), id_var_zu1_xy(av), 'axis', 'Z', 000) 2402 ! 2403 !-- Define a variable to store the layer indices of the horizontal cross sections, too. 2404 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zu_xy(av) /), 'ind_z_xy', NF90_DOUBLE, & 2405 id_var_ind_z_xy(av), 'gridpoints', '', 111, 112, 000 ) 2573 2406 ! 2574 2407 !-- Define x-axis (for scalar position) 2575 CALL netcdf_create_dim( id_set_xy(av), 'x', nx+1, id_dim_x_xy(av), & 2576 113 ) 2577 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_x_xy(av) /), 'x', & 2578 NF90_DOUBLE, id_var_x_xy(av), 'meters', '', & 2579 114, 115, 000 ) 2580 CALL netcdf_create_att( id_set_xy(av), id_var_x_xy(av), 'axis', & 2581 'X', 000) 2408 CALL netcdf_create_dim( id_set_xy(av), 'x', nx+1, id_dim_x_xy(av), 113 ) 2409 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_x_xy(av) /), 'x', NF90_DOUBLE, & 2410 id_var_x_xy(av), 'meters', '', 114, 115, 000 ) 2411 CALL netcdf_create_att( id_set_xy(av), id_var_x_xy(av), 'axis', 'X', 000) 2582 2412 ! 2583 2413 !-- Define x-axis (for u position) 2584 CALL netcdf_create_dim( id_set_xy(av), 'xu', nx+1, & 2585 id_dim_xu_xy(av), 388 ) 2586 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_xu_xy(av) /), 'xu', & 2587 NF90_DOUBLE, id_var_xu_xy(av), 'meters', '', & 2588 389, 390, 000 ) 2589 CALL netcdf_create_att( id_set_xy(av), id_var_xu_xy(av), 'axis', & 2590 'X', 000) 2414 CALL netcdf_create_dim( id_set_xy(av), 'xu', nx+1, id_dim_xu_xy(av), 388 ) 2415 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_xu_xy(av) /), 'xu', NF90_DOUBLE, & 2416 id_var_xu_xy(av), 'meters', '', 389, 390, 000 ) 2417 CALL netcdf_create_att( id_set_xy(av), id_var_xu_xy(av), 'axis', 'X', 000) 2591 2418 ! 2592 2419 !-- Define y-axis (for scalar position) 2593 CALL netcdf_create_dim( id_set_xy(av), 'y', ny+1, id_dim_y_xy(av), & 2594 116 ) 2595 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_y_xy(av) /), 'y', & 2596 NF90_DOUBLE, id_var_y_xy(av), 'meters', '', & 2597 117, 118, 000 ) 2598 CALL netcdf_create_att( id_set_xy(av), id_var_y_xy(av), 'axis', & 2599 'Y', 000) 2420 CALL netcdf_create_dim( id_set_xy(av), 'y', ny+1, id_dim_y_xy(av), 116 ) 2421 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_y_xy(av) /), 'y', NF90_DOUBLE, & 2422 id_var_y_xy(av), 'meters', '', 117, 118, 000 ) 2423 CALL netcdf_create_att( id_set_xy(av), id_var_y_xy(av), 'axis', 'Y', 000) 2600 2424 ! 2601 2425 !-- Define y-axis (for scalar position) 2602 CALL netcdf_create_dim( id_set_xy(av), 'yv', ny+1, & 2603 id_dim_yv_xy(av), 364 ) 2604 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_yv_xy(av) /), 'yv', & 2605 NF90_DOUBLE, id_var_yv_xy(av), 'meters', '', & 2606 365, 366, 000 ) 2607 CALL netcdf_create_att( id_set_xy(av), id_var_yv_xy(av), 'axis', & 2608 'Y', 000) 2426 CALL netcdf_create_dim( id_set_xy(av), 'yv', ny+1, id_dim_yv_xy(av), 364 ) 2427 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_yv_xy(av) /), 'yv', NF90_DOUBLE, & 2428 id_var_yv_xy(av), 'meters', '', 365, 366, 000 ) 2429 CALL netcdf_create_att( id_set_xy(av), id_var_yv_xy(av), 'axis', 'Y', 000) 2609 2430 ! 2610 2431 !-- Define UTM and geographic coordinates 2611 CALL define_geo_coordinates( id_set_xy(av), &2612 (/ id_dim_x_xy(av), id_dim_xu_xy(av) /),&2613 (/ id_dim_y_xy(av), id_dim_yv_xy(av) /),&2614 id_var_eutm_xy(:,av), id_var_nutm_xy(:,av),&2615 id_var_lat_xy(:,av), id_var_lon_xy(:,av) )2432 CALL define_geo_coordinates( id_set_xy(av), & 2433 (/ id_dim_x_xy(av), id_dim_xu_xy(av) /), & 2434 (/ id_dim_y_xy(av), id_dim_yv_xy(av) /), & 2435 id_var_eutm_xy(:,av), id_var_nutm_xy(:,av), & 2436 id_var_lat_xy(:,av), id_var_lon_xy(:,av) ) 2616 2437 ! 2617 2438 !-- Define coordinate-reference system 2618 2439 CALL netcdf_create_crs( id_set_xy(av), 000 ) 2619 2440 ! 2620 !-- In case of non-flat topography define 2d-arrays containing the height 2621 !-- information. Only for parallel netcdf output. 2622 IF ( TRIM( topography ) /= 'flat' .AND. & 2623 netcdf_data_format > 4 ) THEN 2441 !-- In case of non-flat topography define 2d-arrays containing the height information. Only 2442 !-- for parallel netcdf output. 2443 IF ( TRIM( topography ) /= 'flat' .AND. netcdf_data_format > 4 ) THEN 2624 2444 ! 2625 2445 !-- Define zusi = zu(nzb_s_inner) 2626 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_x_xy(av), & 2627 id_dim_y_xy(av) /), 'zusi', NF90_DOUBLE, & 2628 id_var_zusi_xy(av), 'meters', & 2629 'zu(nzb_s_inner)', 421, 422, 423 ) 2446 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_x_xy(av), id_dim_y_xy(av) /), 'zusi',& 2447 NF90_DOUBLE, id_var_zusi_xy(av), 'meters', 'zu(nzb_s_inner)', & 2448 421, 422, 423 ) 2630 2449 ! 2631 2450 !-- Define zwwi = zw(nzb_w_inner) 2632 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_x_xy(av), & 2633 id_dim_y_xy(av) /), 'zwwi', NF90_DOUBLE, & 2634 id_var_zwwi_xy(av), 'meters', & 2635 'zw(nzb_w_inner)', 424, 425, 426 ) 2451 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_x_xy(av), id_dim_y_xy(av) /), 'zwwi',& 2452 NF90_DOUBLE, id_var_zwwi_xy(av), 'meters', 'zw(nzb_w_inner)', & 2453 424, 425, 426 ) 2636 2454 2637 2455 ENDIF … … 2642 2460 i = 1 2643 2461 2644 DO WHILE ( do2d(av,i)(1:1) /= ' ' )2462 DO WHILE ( do2d(av,i)(1:1) /= ' ' ) 2645 2463 2646 2464 IF ( INDEX( do2d(av,i), 'xy' ) /= 0 ) THEN 2647 2465 ! 2648 !-- If there is a star in the variable name (u* or t*), it is a 2649 !-- surface variable. Defineit with id_dim_zu1_xy.2466 !-- If there is a star in the variable name (u* or t*), it is a surface variable. Define 2467 !-- it with id_dim_zu1_xy. 2650 2468 IF ( INDEX( do2d(av,i), '*' ) /= 0 ) THEN 2651 2469 2652 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_x_xy(av), & 2653 id_dim_y_xy(av), id_dim_zu1_xy(av), & 2654 id_dim_time_xy(av) /), do2d(av,i), & 2655 nc_precision(1), id_var_do2d(av,i), & 2656 TRIM( do2d_unit(av,i) ), & 2657 do2d(av,i), 119, 120, 354, .TRUE. ) 2470 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_x_xy(av), id_dim_y_xy(av), & 2471 id_dim_zu1_xy(av), id_dim_time_xy(av) /), do2d(av,i), & 2472 nc_precision(1), id_var_do2d(av,i), & 2473 TRIM( do2d_unit(av,i) ), do2d(av,i), 119, 120, 354, & 2474 .TRUE. ) 2658 2475 2659 2476 ELSE … … 2666 2483 !-- Most variables are defined on the zu grid 2667 2484 CASE ( 'e_xy', 'nc_xy', 'ng_xy', 'ni_xy', 'nr_xy', 'ns_xy', 'p_xy', & 2668 'pc_xy', 'pr_xy', 'prr_xy', 'q_xy', &2485 'pc_xy', 'pr_xy', 'prr_xy', 'q_xy', & 2669 2486 'qc_xy', 'qg_xy', 'qi_xy', 'ql_xy', 'ql_c_xy', 'ql_v_xy', & 2670 2487 'ql_vp_xy', 'qr_xy', 'qs_xy', 'qv_xy', & 2671 's_xy', &2488 's_xy', & 2672 2489 'theta_xy', 'thetal_xy', 'thetav_xy' ) 2673 2490 … … 2702 2519 !-- Check for land surface quantities 2703 2520 IF ( land_surface ) THEN 2704 CALL lsm_define_netcdf_grid( do2d(av,i), found, & 2705 grid_x, grid_y, grid_z ) 2521 CALL lsm_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 2706 2522 ENDIF 2707 2523 2708 2524 IF ( .NOT. found ) THEN 2709 CALL tcm_define_netcdf_grid( do2d(av,i), found, & 2710 grid_x, grid_y, & 2525 CALL tcm_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 2526 ENDIF 2527 2528 ! 2529 !-- Check for ocean quantities 2530 IF ( .NOT. found .AND. ocean_mode ) THEN 2531 CALL ocean_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, & 2532 grid_z ) 2533 ENDIF 2534 ! 2535 !-- Check for radiation quantities 2536 IF ( .NOT. found .AND. radiation ) THEN 2537 CALL radiation_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, & 2538 grid_z ) 2539 ENDIF 2540 2541 ! 2542 !-- Check for SALSA quantities 2543 IF ( .NOT. found .AND. salsa ) THEN 2544 CALL salsa_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, & 2545 grid_z ) 2546 ENDIF 2547 2548 ! 2549 !-- Check for gust module quantities 2550 IF ( .NOT. found .AND. gust_module_enabled ) THEN 2551 CALL gust_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, & 2552 grid_z ) 2553 ENDIF 2554 ! 2555 !-- Check for biometeorology quantities 2556 IF ( .NOT. found .AND. biometeorology ) THEN 2557 CALL bio_define_netcdf_grid( do2d( av, i), found, grid_x, grid_y, & 2711 2558 grid_z ) 2712 2559 ENDIF 2713 2714 ! 2715 !-- Check for ocean quantities 2716 IF ( .NOT. found .AND. ocean_mode ) THEN 2717 CALL ocean_define_netcdf_grid( do2d(av,i), found, & 2718 grid_x, grid_y, & 2719 grid_z ) 2720 ENDIF 2721 ! 2722 !-- Check for radiation quantities 2723 IF ( .NOT. found .AND. radiation ) THEN 2724 CALL radiation_define_netcdf_grid( do2d(av,i), & 2725 found, grid_x, grid_y,& 2726 grid_z ) 2727 ENDIF 2728 2729 ! 2730 !-- Check for SALSA quantities 2731 IF ( .NOT. found .AND. salsa ) THEN 2732 CALL salsa_define_netcdf_grid( do2d(av,i), found, & 2733 grid_x, grid_y, & 2734 grid_z ) 2735 ENDIF 2736 2737 ! 2738 !-- Check for gust module quantities 2739 IF ( .NOT. found .AND. gust_module_enabled ) THEN 2740 CALL gust_define_netcdf_grid( do2d(av,i), found, & 2741 grid_x, grid_y, & 2560 ! 2561 !-- Check for chemistry quantities 2562 IF ( .NOT. found .AND. air_chemistry ) THEN 2563 CALL chem_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, & 2742 2564 grid_z ) 2743 2565 ENDIF 2744 ! 2745 !-- Check for biometeorology quantities 2746 IF ( .NOT. found .AND. biometeorology ) THEN 2747 CALL bio_define_netcdf_grid( do2d( av, i), found, & 2748 grid_x, grid_y, & 2749 grid_z ) 2750 ENDIF 2751 ! 2752 !-- Check for chemistry quantities 2753 IF ( .NOT. found .AND. air_chemistry ) THEN 2754 CALL chem_define_netcdf_grid( do2d(av,i), found, & 2755 grid_x, grid_y, & 2566 2567 IF ( .NOT. found ) & 2568 CALL doq_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 2569 ! 2570 !-- Check for user-defined quantities 2571 IF ( .NOT. found .AND. user_module_enabled ) THEN 2572 CALL user_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, & 2756 2573 grid_z ) 2757 2574 ENDIF 2758 2575 2759 IF ( .NOT. found ) &2760 CALL doq_define_netcdf_grid( &2761 do2d(av,i), found, grid_x, &2762 grid_y, grid_z )2763 !2764 !-- Check for user-defined quantities2765 IF ( .NOT. found .AND. user_module_enabled ) THEN2766 CALL user_define_netcdf_grid( do2d(av,i), found, &2767 grid_x, grid_y, &2768 grid_z )2769 ENDIF2770 2771 2576 IF ( .NOT. found ) THEN 2772 WRITE ( message_string, * ) 'no grid defined for', & 2773 ' variable ', TRIM( do2d(av,i) ) 2774 CALL message( 'define_netcdf_header', 'PA0244', & 2775 0, 1, 0, 6, 0 ) 2577 WRITE ( message_string, * ) 'no grid defined for', ' variable ', & 2578 TRIM( do2d(av,i) ) 2579 CALL message( 'define_netcdf_header', 'PA0244', 0, 1, 0, 6, 0 ) 2776 2580 ENDIF 2777 2581 … … 2804 2608 ! 2805 2609 !-- Define the grid 2806 CALL netcdf_create_var( id_set_xy(av), (/ id_x, id_y, id_z, & 2807 id_dim_time_xy(av) /), do2d(av,i), & 2808 nc_precision(1), id_var_do2d(av,i), & 2809 TRIM( do2d_unit(av,i) ), & 2810 do2d(av,i), 119, 120, 354, .TRUE. ) 2610 CALL netcdf_create_var( id_set_xy(av), (/ id_x, id_y, id_z, & 2611 id_dim_time_xy(av) /), do2d(av,i), nc_precision(1), & 2612 id_var_do2d(av,i), TRIM( do2d_unit(av,i) ), do2d(av,i), & 2613 119, 120, 354, .TRUE. ) 2811 2614 2812 2615 ENDIF … … 2816 2619 ! 2817 2620 !-- Set no fill for every variable to increase performance. 2818 nc_stat = NF90_DEF_VAR_FILL( id_set_xy(av), & 2819 id_var_do2d(av,i), & 2820 NF90_NOFILL, 0 ) 2621 nc_stat = NF90_DEF_VAR_FILL( id_set_xy(av), id_var_do2d(av,i), NF90_NOFILL, 0 ) 2821 2622 CALL netcdf_handle_error( 'netcdf_define_header', 533 ) 2822 2623 ! 2823 2624 !-- Set collective io operations for parallel io 2824 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xy(av), & 2825 id_var_do2d(av,i), & 2625 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xy(av), id_var_do2d(av,i), & 2826 2626 NF90_COLLECTIVE ) 2827 2627 CALL netcdf_handle_error( 'netcdf_define_header', 448 ) … … 2841 2641 2842 2642 ! 2843 !-- Write the list of variables as global attribute (this is used by 2844 !-- restart runs and by combine_plot_fields) 2845 nc_stat = NF90_PUT_ATT( id_set_xy(av), NF90_GLOBAL, 'VAR_LIST', & 2846 var_list ) 2643 !-- Write the list of variables as global attribute (this is used by restart runs and by 2644 !-- combine_plot_fields). 2645 nc_stat = NF90_PUT_ATT( id_set_xy(av), NF90_GLOBAL, 'VAR_LIST', var_list ) 2847 2646 CALL netcdf_handle_error( 'netcdf_define_header', 121 ) 2848 2647 2849 2648 ! 2850 !-- Set general no fill, otherwise the performance drops significantly for 2851 !-- parallel output. 2649 !-- Set general no fill, otherwise the performance drops significantly for parallel output. 2852 2650 nc_stat = NF90_SET_FILL( id_set_xy(av), NF90_NOFILL, oldmode ) 2853 2651 CALL netcdf_handle_error( 'netcdf_define_header', 529 ) … … 2859 2657 2860 2658 ! 2861 !-- These data are only written by PE0 for parallel output to increase 2862 !-- the performance. 2659 !-- These data are only written by PE0 for parallel output to increase the performance. 2863 2660 IF ( myid == 0 .OR. netcdf_data_format < 5 ) THEN 2864 2661 … … 2876 2673 ENDIF 2877 2674 ENDDO 2878 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zu_xy(av), &2879 netcdf_data, start = (/ 1 /), &2675 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zu_xy(av), & 2676 netcdf_data, start = (/ 1 /), & 2880 2677 count = (/ ns /) ) 2881 2678 CALL netcdf_handle_error( 'netcdf_define_header', 123 ) … … 2890 2687 ENDIF 2891 2688 ENDDO 2892 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zw_xy(av), &2893 netcdf_data, start = (/ 1 /), &2689 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zw_xy(av), & 2690 netcdf_data, start = (/ 1 /), & 2894 2691 count = (/ ns /) ) 2895 2692 CALL netcdf_handle_error( 'netcdf_define_header', 124 ) … … 2909 2706 ENDDO 2910 2707 2911 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zs_xy(av), &2912 netcdf_data(1:ns_do), start = (/ 1 /), &2708 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zs_xy(av), & 2709 netcdf_data(1:ns_do), start = (/ 1 /), & 2913 2710 count = (/ ns_do /) ) 2914 2711 CALL netcdf_handle_error( 'netcdf_define_header', 124 ) … … 2919 2716 !-- Write gridpoint number data 2920 2717 netcdf_data(1:ns) = section(1:ns,1) 2921 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_ind_z_xy(av), &2922 netcdf_data, start = (/ 1 /), &2718 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_ind_z_xy(av), & 2719 netcdf_data, start = (/ 1 /), & 2923 2720 count = (/ ns /) ) 2924 2721 CALL netcdf_handle_error( 'netcdf_define_header', 125 ) … … 2928 2725 ! 2929 2726 !-- Write the cross section height u*, t* 2930 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zu1_xy(av), &2931 (/ zu(nzb+1) /), start = (/ 1 /), &2727 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zu1_xy(av), & 2728 (/ zu(nzb+1) /), start = (/ 1 /), & 2932 2729 count = (/ 1 /) ) 2933 2730 CALL netcdf_handle_error( 'netcdf_define_header', 126 ) … … 2941 2738 ENDDO 2942 2739 2943 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_x_xy(av), &2944 netcdf_data, start = (/ 1 /), &2740 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_x_xy(av), & 2741 netcdf_data, start = (/ 1 /), & 2945 2742 count = (/ nx+1 /) ) 2946 2743 CALL netcdf_handle_error( 'netcdf_define_header', 127 ) … … 2950 2747 ENDDO 2951 2748 2952 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_xu_xy(av), &2953 netcdf_data, start = (/ 1 /), &2749 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_xu_xy(av), & 2750 netcdf_data, start = (/ 1 /), & 2954 2751 count = (/ nx+1 /) ) 2955 2752 CALL netcdf_handle_error( 'netcdf_define_header', 367 ) … … 2965 2762 ENDDO 2966 2763 2967 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_y_xy(av), &2968 netcdf_data, start = (/ 1 /), &2764 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_y_xy(av), & 2765 netcdf_data, start = (/ 1 /), & 2969 2766 count = (/ ny+1 /)) 2970 2767 CALL netcdf_handle_error( 'netcdf_define_header', 128 ) … … 2974 2771 ENDDO 2975 2772 2976 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_yv_xy(av), &2977 netcdf_data, start = (/ 1 /), &2773 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_yv_xy(av), & 2774 netcdf_data, start = (/ 1 /), & 2978 2775 count = (/ ny+1 /)) 2979 2776 CALL netcdf_handle_error( 'netcdf_define_header', 368 ) … … 3005 2802 3006 2803 DO i = 0, nx 3007 netcdf_data(i) = init_model%origin_x & 3008 + cos_rot_angle * ( i + shift_x ) * dx 2804 netcdf_data(i) = init_model%origin_x + cos_rot_angle * ( i + shift_x ) * dx 3009 2805 ENDDO 3010 2806 3011 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_eutm_xy(k,av), &3012 netcdf_data, start = (/ 1 /), &2807 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_eutm_xy(k,av), & 2808 netcdf_data, start = (/ 1 /), & 3013 2809 count = (/ nx+1 /) ) 3014 2810 CALL netcdf_handle_error( 'netcdf_define_header', 555 ) … … 3035 2831 3036 2832 DO j = 0, ny 3037 netcdf_data(j) = init_model%origin_y & 3038 + cos_rot_angle * ( j + shift_y ) * dy 2833 netcdf_data(j) = init_model%origin_y + cos_rot_angle * ( j + shift_y ) * dy 3039 2834 ENDDO 3040 2835 3041 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_nutm_xy(k,av), &3042 netcdf_data, start = (/ 1 /), &2836 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_nutm_xy(k,av), & 2837 netcdf_data, start = (/ 1 /), & 3043 2838 count = (/ ny+1 /) ) 3044 2839 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) … … 3071 2866 DO j = 0, ny 3072 2867 DO i = 0, nx 3073 netcdf_data_2d(i,j) = init_model%origin_x &3074 + cos_rot_angle * ( i + shift_x ) * dx&3075 + sin_rot_angle * ( j + shift_y ) * dy2868 netcdf_data_2d(i,j) = init_model%origin_x & 2869 + cos_rot_angle * ( i + shift_x ) * dx & 2870 + sin_rot_angle * ( j + shift_y ) * dy 3076 2871 ENDDO 3077 2872 ENDDO 3078 2873 3079 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_eutm_xy(k,av), &3080 netcdf_data_2d, start = (/ 1, 1 /), &2874 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_eutm_xy(k,av), & 2875 netcdf_data_2d, start = (/ 1, 1 /), & 3081 2876 count = (/ nx+1, ny+1 /) ) 3082 2877 CALL netcdf_handle_error( 'netcdf_define_header', 555 ) … … 3084 2879 DO j = 0, ny 3085 2880 DO i = 0, nx 3086 netcdf_data_2d(i,j) = init_model%origin_y &3087 - sin_rot_angle * ( i + shift_x ) * dx&3088 + cos_rot_angle * ( j + shift_y ) * dy2881 netcdf_data_2d(i,j) = init_model%origin_y & 2882 - sin_rot_angle * ( i + shift_x ) * dx & 2883 + cos_rot_angle * ( j + shift_y ) * dy 3089 2884 ENDDO 3090 2885 ENDDO 3091 2886 3092 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_nutm_xy(k,av), &3093 netcdf_data_2d, start = (/ 1, 1 /), &2887 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_nutm_xy(k,av), & 2888 netcdf_data_2d, start = (/ 1, 1 /), & 3094 2889 count = (/ nx+1, ny+1 /) ) 3095 2890 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) … … 3126 2921 DO j = nys, nyn 3127 2922 DO i = nxl, nxr 3128 eutm = init_model%origin_x & 3129 + cos_rot_angle * ( i + shift_x ) * dx & 3130 + sin_rot_angle * ( j + shift_y ) * dy 3131 nutm = init_model%origin_y & 3132 - sin_rot_angle * ( i + shift_x ) * dx & 3133 + cos_rot_angle * ( j + shift_y ) * dy 3134 3135 CALL convert_utm_to_geographic( crs_list, & 3136 eutm, nutm, & 3137 lon(i,j), lat(i,j) ) 2923 eutm = init_model%origin_x & 2924 + cos_rot_angle * ( i + shift_x ) * dx & 2925 + sin_rot_angle * ( j + shift_y ) * dy 2926 nutm = init_model%origin_y & 2927 - sin_rot_angle * ( i + shift_x ) * dx & 2928 + cos_rot_angle * ( j + shift_y ) * dy 2929 2930 CALL convert_utm_to_geographic( crs_list, eutm, nutm, lon(i,j), lat(i,j) ) 3138 2931 ENDDO 3139 2932 ENDDO 3140 2933 3141 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_lon_xy(k,av), &3142 lon, start = (/ nxl+1, nys+1 /),&3143 count = (/ nxr-nxl+1, nyn-nys+1 /) )2934 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_lon_xy(k,av), & 2935 lon, start = (/ nxl+1, nys+1 /), & 2936 count = (/ nxr-nxl+1, nyn-nys+1 /) ) 3144 2937 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) 3145 2938 3146 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_lat_xy(k,av), &3147 lat, start = (/ nxl+1, nys+1 /),&3148 count = (/ nxr-nxl+1, nyn-nys+1 /) )2939 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_lat_xy(k,av), & 2940 lat, start = (/ nxl+1, nys+1 /), & 2941 count = (/ nxr-nxl+1, nyn-nys+1 /) ) 3149 2942 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) 3150 2943 ENDDO … … 3157 2950 !-- In case of non-flat topography write height information. Only for 3158 2951 !-- parallel netcdf output. 3159 IF ( TRIM( topography ) /= 'flat' .AND. & 3160 netcdf_data_format > 4 ) THEN 2952 IF ( TRIM( topography ) /= 'flat' .AND. netcdf_data_format > 4 ) THEN 3161 2953 3162 2954 ! IF ( nxr == nx .AND. nyn /= ny ) THEN 3163 ! nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zusi_xy(av), &3164 ! zu_s_inner(nxl:nxr+1,nys:nyn), &3165 ! start = (/ nxl+1, nys+1 /), &2955 ! nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zusi_xy(av), & 2956 ! zu_s_inner(nxl:nxr+1,nys:nyn), & 2957 ! start = (/ nxl+1, nys+1 /), & 3166 2958 ! count = (/ nxr-nxl+2, nyn-nys+1 /) ) 3167 2959 ! ELSEIF ( nxr /= nx .AND. nyn == ny ) THEN 3168 ! nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zusi_xy(av), &3169 ! zu_s_inner(nxl:nxr,nys:nyn+1), &3170 ! start = (/ nxl+1, nys+1 /), &2960 ! nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zusi_xy(av), & 2961 ! zu_s_inner(nxl:nxr,nys:nyn+1), & 2962 ! start = (/ nxl+1, nys+1 /), & 3171 2963 ! count = (/ nxr-nxl+1, nyn-nys+2 /) ) 3172 2964 ! ELSEIF ( nxr == nx .AND. nyn == ny ) THEN 3173 ! nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zusi_xy(av), &3174 ! zu_s_inner(nxl:nxr+1,nys:nyn+1), &3175 ! start = (/ nxl+1, nys+1 /), &2965 ! nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zusi_xy(av), & 2966 ! zu_s_inner(nxl:nxr+1,nys:nyn+1), & 2967 ! start = (/ nxl+1, nys+1 /), & 3176 2968 ! count = (/ nxr-nxl+2, nyn-nys+2 /) ) 3177 2969 ! ELSE 3178 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zusi_xy(av), &3179 zu_s_inner(nxl:nxr,nys:nyn), &3180 start = (/ nxl+1, nys+1 /), &2970 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zusi_xy(av), & 2971 zu_s_inner(nxl:nxr,nys:nyn), & 2972 start = (/ nxl+1, nys+1 /), & 3181 2973 count = (/ nxr-nxl+1, nyn-nys+1 /) ) 3182 2974 ! ENDIF … … 3184 2976 3185 2977 ! IF ( nxr == nx .AND. nyn /= ny ) THEN 3186 ! nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zwwi_xy(av), &3187 ! zw_w_inner(nxl:nxr+1,nys:nyn), &3188 ! start = (/ nxl+1, nys+1 /), &2978 ! nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zwwi_xy(av), & 2979 ! zw_w_inner(nxl:nxr+1,nys:nyn), & 2980 ! start = (/ nxl+1, nys+1 /), & 3189 2981 ! count = (/ nxr-nxl+2, nyn-nys+1 /) ) 3190 2982 ! ELSEIF ( nxr /= nx .AND. nyn == ny ) THEN 3191 ! nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zwwi_xy(av), &3192 ! zw_w_inner(nxl:nxr,nys:nyn+1), &3193 ! start = (/ nxl+1, nys+1 /), &2983 ! nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zwwi_xy(av), & 2984 ! zw_w_inner(nxl:nxr,nys:nyn+1), & 2985 ! start = (/ nxl+1, nys+1 /), & 3194 2986 ! count = (/ nxr-nxl+1, nyn-nys+2 /) ) 3195 2987 ! ELSEIF ( nxr == nx .AND. nyn == ny ) THEN 3196 ! nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zwwi_xy(av), &3197 ! zw_w_inner(nxl:nxr+1,nys:nyn+1), &3198 ! start = (/ nxl+1, nys+1 /), &2988 ! nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zwwi_xy(av), & 2989 ! zw_w_inner(nxl:nxr+1,nys:nyn+1), & 2990 ! start = (/ nxl+1, nys+1 /), & 3199 2991 ! count = (/ nxr-nxl+2, nyn-nys+2 /) ) 3200 2992 ! ELSE 3201 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zwwi_xy(av), &3202 zw_w_inner(nxl:nxr,nys:nyn), &3203 start = (/ nxl+1, nys+1 /), &2993 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zwwi_xy(av), & 2994 zw_w_inner(nxl:nxr,nys:nyn), & 2995 start = (/ nxl+1, nys+1 /), & 3204 2996 count = (/ nxr-nxl+1, nyn-nys+1 /) ) 3205 2997 ! ENDIF … … 3212 3004 ! 3213 3005 !-- Get the list of variables and compare with the actual run. 3214 !-- First var_list_old has to be reset, since GET_ATT does not assign 3215 !-- trailing blanks. 3006 !-- First var_list_old has to be reset, since GET_ATT does not assign trailing blanks. 3216 3007 var_list_old = ' ' 3217 nc_stat = NF90_GET_ATT( id_set_xy(av), NF90_GLOBAL, 'VAR_LIST', & 3218 var_list_old ) 3008 nc_stat = NF90_GET_ATT( id_set_xy(av), NF90_GLOBAL, 'VAR_LIST', var_list_old ) 3219 3009 CALL netcdf_handle_error( 'netcdf_define_header', 129 ) 3220 3010 3221 3011 var_list = ';' 3222 3012 i = 1 3223 DO WHILE ( do2d(av,i)(1:1) /= ' ' )3013 DO WHILE ( do2d(av,i)(1:1) /= ' ' ) 3224 3014 IF ( INDEX( do2d(av,i), 'xy' ) /= 0 ) THEN 3225 3015 var_list = TRIM( var_list ) // TRIM( do2d(av,i) ) // ';' … … 3235 3025 3236 3026 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 3237 message_string = 'netCDF file for cross-sections ' // & 3238 TRIM( var ) // ' from previous run found,' // & 3239 '&but this file cannot be extended due to' // & 3240 ' variable mismatch.' // & 3241 '&New file is created instead.' 3027 message_string = 'netCDF file for cross-sections ' // & 3028 TRIM( var ) // ' from previous run found,' // & 3029 '&but this file cannot be extended due to' // & 3030 ' variable mismatch.' // '&New file is created instead.' 3242 3031 CALL message( 'define_netcdf_header', 'PA0249', 0, 1, 0, 6, 0 ) 3243 3032 extend = .FALSE. … … 3248 3037 !-- Calculate the number of current sections 3249 3038 ns = 1 3250 DO WHILE ( section(ns,1) /= -9999 .AND. ns <= 100 )3039 DO WHILE ( section(ns,1) /= -9999 .AND. ns <= 100 ) 3251 3040 ns = ns + 1 3252 3041 ENDDO … … 3258 3047 CALL netcdf_handle_error( 'netcdf_define_header', 130 ) 3259 3048 3260 nc_stat = NF90_INQUIRE_VARIABLE( id_set_xy(av), id_var_zu_xy(av), &3049 nc_stat = NF90_INQUIRE_VARIABLE( id_set_xy(av), id_var_zu_xy(av), & 3261 3050 dimids = id_dim_zu_xy_old ) 3262 3051 CALL netcdf_handle_error( 'netcdf_define_header', 131 ) 3263 3052 id_dim_zu_xy(av) = id_dim_zu_xy_old(1) 3264 3053 3265 nc_stat = NF90_INQUIRE_DIMENSION( id_set_xy(av), id_dim_zu_xy(av), & 3266 len = ns_old ) 3054 nc_stat = NF90_INQUIRE_DIMENSION( id_set_xy(av), id_dim_zu_xy(av), LEN = ns_old ) 3267 3055 CALL netcdf_handle_error( 'netcdf_define_header', 132 ) 3268 3056 3269 3057 IF ( ns /= ns_old ) THEN 3270 message_string = 'netCDF file for cross-sections ' // & 3271 TRIM( var ) // ' from previous run found,' // & 3272 '&but this file cannot be extended due to' // & 3273 ' mismatch in number of' // & 3274 ' cross sections.' // & 3058 message_string = 'netCDF file for cross-sections ' // & 3059 TRIM( var ) // ' from previous run found,' // & 3060 '&but this file cannot be extended due to' // & 3061 ' mismatch in number of' // ' cross sections.' // & 3275 3062 '&New file is created instead.' 3276 3063 CALL message( 'define_netcdf_header', 'PA0250', 0, 1, 0, 6, 0 ) … … 3289 3076 IF ( section(i,1) /= -1 ) THEN 3290 3077 IF ( zu(section(i,1)) /= netcdf_data(i) ) THEN 3291 message_string = 'netCDF file for cross-sections ' // & 3292 TRIM( var ) // ' from previous run found,' // & 3293 ' but this file cannot be extended' // & 3294 ' due to mismatch in cross' // & 3295 ' section levels.' // & 3296 ' New file is created instead.' 3297 CALL message( 'define_netcdf_header', 'PA0251', & 3298 0, 1, 0, 6, 0 ) 3078 message_string = 'netCDF file for cross-sections ' // & 3079 TRIM( var ) // ' from previous run found,' // & 3080 ' but this file cannot be extended' // & 3081 ' due to mismatch in cross' // ' section levels.' // & 3082 ' New file is created instead.' 3083 CALL message( 'define_netcdf_header', 'PA0251', 0, 1, 0, 6, 0 ) 3299 3084 extend = .FALSE. 3300 3085 RETURN … … 3302 3087 ELSE 3303 3088 IF ( -1.0_wp /= netcdf_data(i) ) THEN 3304 message_string = 'netCDF file for cross-sections ' // & 3305 TRIM( var ) // ' from previous run found,' // & 3306 ' but this file cannot be extended' // & 3307 ' due to mismatch in cross' // & 3308 ' section levels.' // & 3309 ' New file is created instead.' 3310 CALL message( 'define_netcdf_header', 'PA0251', & 3311 0, 1, 0, 6, 0 ) 3089 message_string = 'netCDF file for cross-sections ' // & 3090 TRIM( var ) // ' from previous run found,' // & 3091 ' but this file cannot be extended' // & 3092 ' due to mismatch in cross' // ' section levels.' // & 3093 ' New file is created instead.' 3094 CALL message( 'define_netcdf_header', 'PA0251', 0, 1, 0, 6, 0 ) 3312 3095 extend = .FALSE. 3313 3096 RETURN … … 3319 3102 3320 3103 ! 3321 !-- Get the id of the time coordinate (unlimited coordinate) and its 3322 !-- last index on the file. The next time level is do2d..count+1. 3323 !-- The current time must be larger than the last output time 3324 !-- on the file. 3104 !-- Get the id of the time coordinate (unlimited coordinate) and its last index on the file. 3105 !-- The next time level is do2d..count+1. 3106 !-- The current time must be larger than the last output time on the file. 3325 3107 nc_stat = NF90_INQ_VARID( id_set_xy(av), 'time', id_var_time_xy(av) ) 3326 3108 CALL netcdf_handle_error( 'netcdf_define_header', 134 ) 3327 3109 3328 nc_stat = NF90_INQUIRE_VARIABLE( id_set_xy(av), id_var_time_xy(av), &3110 nc_stat = NF90_INQUIRE_VARIABLE( id_set_xy(av), id_var_time_xy(av), & 3329 3111 dimids = id_dim_time_old ) 3330 3112 CALL netcdf_handle_error( 'netcdf_define_header', 135 ) 3331 3113 id_dim_time_xy(av) = id_dim_time_old(1) 3332 3114 3333 nc_stat = NF90_INQUIRE_DIMENSION( id_set_xy(av), id_dim_time_xy(av), & 3334 len = ntime_count ) 3115 nc_stat = NF90_INQUIRE_DIMENSION( id_set_xy(av), id_dim_time_xy(av), LEN = ntime_count ) 3335 3116 CALL netcdf_handle_error( 'netcdf_define_header', 136 ) 3336 3117 3337 3118 ! 3338 !-- For non-parallel output use the last output time level of the netcdf 3339 !-- file because the time dimension is unlimited. In case of parallel 3340 !-- output the variable ntime_count could get the value of 9*10E36 because 3341 !-- the time dimension is limited. 3119 !-- For non-parallel output use the last output time level of the netcdf file because the time 3120 !-- dimension is unlimited. In case of parallel output the variable ntime_count could get the 3121 !-- value of 9*10E36 because the time dimension is limited. 3342 3122 IF ( netcdf_data_format < 5 ) do2d_xy_time_count(av) = ntime_count 3343 3123 3344 nc_stat = NF90_GET_VAR( id_set_xy(av), id_var_time_xy(av), &3345 last_time_coordinate, &3346 start = (/ do2d_xy_time_count(av) /), &3124 nc_stat = NF90_GET_VAR( id_set_xy(av), id_var_time_xy(av), & 3125 last_time_coordinate, & 3126 start = (/ do2d_xy_time_count(av) /), & 3347 3127 count = (/ 1 /) ) 3348 3128 CALL netcdf_handle_error( 'netcdf_define_header', 137 ) 3349 3129 3350 3130 IF ( last_time_coordinate(1) >= simulated_time ) THEN 3351 message_string = 'netCDF file for cross sections ' // & 3352 TRIM( var ) // ' from previous run found,' // & 3353 '&but this file cannot be extended becaus' // & 3354 'e the current output time' // & 3355 '&is less or equal than the last output t' // & 3356 'ime on this file.' // & 3131 message_string = 'netCDF file for cross sections ' // & 3132 TRIM( var ) // ' from previous run found,' // & 3133 '&but this file cannot be extended because' // & 3134 ' the current output time' // & 3135 '&is less or equal than the last output time' // ' on this file.' // & 3357 3136 '&New file is created instead.' 3358 3137 CALL message( 'define_netcdf_header', 'PA0252', 0, 1, 0, 6, 0 ) … … 3364 3143 IF ( netcdf_data_format > 4 ) THEN 3365 3144 ! 3366 !-- Check if the needed number of output time levels is increased 3367 !-- compared to the number oftime levels in the existing file.3145 !-- Check if the needed number of output time levels is increased compared to the number of 3146 !-- time levels in the existing file. 3368 3147 IF ( ntdim_2d_xy(av) > ntime_count ) THEN 3369 message_string = 'netCDF file for cross sections ' // & 3370 TRIM( var ) // ' from previous run found,' // & 3371 '&but this file cannot be extended becaus' // & 3372 'e the number of output time levels has b' // & 3373 'een increased compared to the previous s' // & 3374 'imulation.' // & 3375 '&New file is created instead.' 3148 message_string = 'netCDF file for cross sections ' // & 3149 TRIM( var ) // ' from previous run found,' // & 3150 '&but this file cannot be extended becaus' // & 3151 'e the number of output time levels has b' // & 3152 'een increased compared to the previous s' // & 3153 'imulation.' // '&New file is created instead.' 3376 3154 CALL message( 'define_netcdf_header', 'PA0389', 0, 1, 0, 6, 0 ) 3377 3155 do2d_xy_time_count(av) = 0 … … 3380 3158 !-- Recalculate the needed time levels for the new file. 3381 3159 IF ( av == 0 ) THEN 3382 ntdim_2d_xy(0) = CEILING( & 3383 ( end_time - MAX( skip_time_do2d_xy, & 3384 simulated_time_at_begin ) & 3385 ) / dt_do2d_xy ) 3160 ntdim_2d_xy(0) = CEILING( ( end_time - MAX( skip_time_do2d_xy, & 3161 simulated_time_at_begin ) & 3162 ) / dt_do2d_xy ) 3386 3163 IF ( do2d_at_begin ) ntdim_2d_xy(0) = ntdim_2d_xy(0) + 1 3387 3164 ELSE 3388 ntdim_2d_xy(1) = CEILING( & 3389 ( end_time - MAX( skip_time_data_output_av, & 3390 simulated_time_at_begin ) & 3391 ) / dt_data_output_av ) 3165 ntdim_2d_xy(1) = CEILING( ( end_time - MAX( skip_time_data_output_av, & 3166 simulated_time_at_begin ) & 3167 ) / dt_data_output_av ) 3392 3168 ENDIF 3393 3169 RETURN … … 3399 3175 !-- Now get the variable ids. 3400 3176 i = 1 3401 DO WHILE ( do2d(av,i)(1:1) /= ' ' )3177 DO WHILE ( do2d(av,i)(1:1) /= ' ' ) 3402 3178 IF ( INDEX( do2d(av,i), 'xy' ) /= 0 ) THEN 3403 nc_stat = NF90_INQ_VARID( id_set_xy(av), do2d(av,i), & 3404 id_var_do2d(av,i) ) 3179 nc_stat = NF90_INQ_VARID( id_set_xy(av), do2d(av,i), id_var_do2d(av,i) ) 3405 3180 CALL netcdf_handle_error( 'netcdf_define_header', 138 ) 3406 3181 #if defined( __netcdf4_parallel ) … … 3408 3183 !-- Set collective io operations for parallel io 3409 3184 IF ( netcdf_data_format > 4 ) THEN 3410 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xy(av), & 3411 id_var_do2d(av,i), & 3185 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xy(av), id_var_do2d(av,i), & 3412 3186 NF90_COLLECTIVE ) 3413 3187 CALL netcdf_handle_error( 'netcdf_define_header', 454 ) … … 3419 3193 3420 3194 ! 3421 !-- Update the title attribute on file 3422 !-- In order to avoid 'data mode' errors if updated attributes are larger 3423 !-- than their original size, NF90_PUT_ATT is called in 'define mode' 3424 !-- enclosed by NF90_REDEF and NF90_ENDDEF calls. This implies a possible 3425 !-- performance loss due to data copying; an alternative strategy would be 3426 !-- to ensure equal attribute size in a job chain. Maybe revise later. 3195 !-- Update the title attribute on file. 3196 !-- In order to avoid 'data mode' errors if updated attributes are larger than their original 3197 !-- size, NF90_PUT_ATT is called in 'define mode' enclosed by NF90_REDEF and NF90_ENDDEF 3198 !-- calls. This implies a possible performance loss due to data copying; an alternative 3199 !-- strategy would be to ensure equal attribute size in a job chain. Maybe revise later. 3427 3200 IF ( av == 0 ) THEN 3428 3201 time_average_text = ' ' 3429 3202 ELSE 3430 WRITE (time_average_text, '('', '',F7.1,'' s average'')') & 3431 averaging_interval 3203 WRITE ( time_average_text, '('', '',F7.1,'' s average'')' ) averaging_interval 3432 3204 ENDIF 3433 3205 nc_stat = NF90_REDEF( id_set_xy(av) ) 3434 3206 CALL netcdf_handle_error( 'netcdf_define_header', 431 ) 3435 nc_stat = NF90_PUT_ATT( id_set_xy(av), NF90_GLOBAL, 'title', & 3436 TRIM( run_description_header ) // & 3437 TRIM( time_average_text ) ) 3207 nc_stat = NF90_PUT_ATT( id_set_xy(av), NF90_GLOBAL, 'title', & 3208 TRIM( run_description_header ) // TRIM( time_average_text ) ) 3438 3209 CALL netcdf_handle_error( 'netcdf_define_header', 139 ) 3439 3210 nc_stat = NF90_ENDDEF( id_set_xy(av) ) 3440 3211 CALL netcdf_handle_error( 'netcdf_define_header', 432 ) 3441 message_string = 'netCDF file for cross-sections ' // &3442 TRIM( var ) // ' from previous run found.' // &3212 message_string = 'netCDF file for cross-sections ' // & 3213 TRIM( var ) // ' from previous run found.' // & 3443 3214 '&This file will be extended.' 3444 3215 CALL message( 'define_netcdf_header', 'PA0253', 0, 0, 0, 6, 0 ) … … 3450 3221 !-- Define some global attributes of the dataset 3451 3222 IF ( av == 0 ) THEN 3452 CALL netcdf_create_global_atts( id_set_xz(av), 'xz', TRIM( run_description_header ), 140 ) 3223 CALL netcdf_create_global_atts( id_set_xz(av), 'xz', TRIM( run_description_header ), & 3224 140 ) 3453 3225 time_average_text = ' ' 3454 3226 ELSE 3455 CALL netcdf_create_global_atts( id_set_xz(av), 'xz_av', TRIM( run_description_header ), 140 ) 3227 CALL netcdf_create_global_atts( id_set_xz(av), 'xz_av', & 3228 TRIM( run_description_header ), 140 ) 3456 3229 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval 3457 nc_stat = NF90_PUT_ATT( id_set_xz(av), NF90_GLOBAL, 'time_avg', &3230 nc_stat = NF90_PUT_ATT( id_set_xz(av), NF90_GLOBAL, 'time_avg', & 3458 3231 TRIM( time_average_text ) ) 3459 3232 CALL netcdf_handle_error( 'netcdf_define_header', 141 ) … … 3462 3235 ! 3463 3236 !-- Define time coordinate for xz sections. 3464 !-- For parallel output the time dimensions has to be limited, otherwise 3465 !-- the performance dropssignificantly.3237 !-- For parallel output the time dimensions has to be limited, otherwise the performance drops 3238 !-- significantly. 3466 3239 IF ( netcdf_data_format < 5 ) THEN 3467 CALL netcdf_create_dim( id_set_xz(av), 'time', NF90_UNLIMITED, &3468 id_dim_time_xz(av),142 )3240 CALL netcdf_create_dim( id_set_xz(av), 'time', NF90_UNLIMITED, id_dim_time_xz(av), & 3241 142 ) 3469 3242 ELSE 3470 CALL netcdf_create_dim( id_set_xz(av), 'time', ntdim_2d_xz(av), & 3471 id_dim_time_xz(av), 525 ) 3472 ENDIF 3473 3474 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_time_xz(av) /), & 3475 'time', NF90_DOUBLE, id_var_time_xz(av), & 3476 'seconds', 'time', 143, 144, 000 ) 3243 CALL netcdf_create_dim( id_set_xz(av), 'time', ntdim_2d_xz(av), id_dim_time_xz(av), & 3244 525 ) 3245 ENDIF 3246 3247 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_time_xz(av) /), 'time', NF90_DOUBLE, & 3248 id_var_time_xz(av), 'seconds', 'time', 143, 144, 000 ) 3477 3249 CALL netcdf_create_att( id_set_xz(av), id_var_time_xz(av), 'standard_name', 'time', 000) 3478 3250 CALL netcdf_create_att( id_set_xz(av), id_var_time_xz(av), 'axis', 'T', 000) … … 3492 3264 ! 3493 3265 !-- Define y-axis (for scalar position) 3494 CALL netcdf_create_dim( id_set_xz(av), 'y_xz', ns, id_dim_y_xz(av), & 3495 145 ) 3496 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_y_xz(av) /), & 3497 'y_xz', NF90_DOUBLE, id_var_y_xz(av), & 3498 'meters', '', 146, 147, 000 ) 3499 CALL netcdf_create_att( id_set_xz(av), id_var_y_xz(av), 'axis', & 3500 'Y', 000) 3266 CALL netcdf_create_dim( id_set_xz(av), 'y_xz', ns, id_dim_y_xz(av), 145 ) 3267 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_y_xz(av) /), 'y_xz', NF90_DOUBLE, & 3268 id_var_y_xz(av), 'meters', '', 146, 147, 000 ) 3269 CALL netcdf_create_att( id_set_xz(av), id_var_y_xz(av), 'axis', 'Y', 000) 3501 3270 ! 3502 3271 !-- Define y-axis (for v position) 3503 CALL netcdf_create_dim( id_set_xz(av), 'yv_xz', ns, & 3504 id_dim_yv_xz(av), 369 ) 3505 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_yv_xz(av) /), & 3506 'yv_xz', NF90_DOUBLE, id_var_yv_xz(av), & 3507 'meters', '', 370, 371, 000 ) 3508 CALL netcdf_create_att( id_set_xz(av), id_var_yv_xz(av), 'axis', & 3509 'Y', 000) 3510 ! 3511 !-- Define a variable to store the layer indices of the vertical cross 3512 !-- sections 3513 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_y_xz(av) /), & 3514 'ind_y_xz', NF90_DOUBLE, & 3515 id_var_ind_y_xz(av), 'gridpoints', '', 148, & 3516 149, 000 ) 3272 CALL netcdf_create_dim( id_set_xz(av), 'yv_xz', ns, id_dim_yv_xz(av), 369 ) 3273 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_yv_xz(av) /), 'yv_xz', NF90_DOUBLE, & 3274 id_var_yv_xz(av), 'meters', '', 370, 371, 000 ) 3275 CALL netcdf_create_att( id_set_xz(av), id_var_yv_xz(av), 'axis', 'Y', 000) 3276 ! 3277 !-- Define a variable to store the layer indices of the vertical cross sections 3278 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_y_xz(av) /), 'ind_y_xz', NF90_DOUBLE, & 3279 id_var_ind_y_xz(av), 'gridpoints', '', 148, 149, 000 ) 3517 3280 ! 3518 3281 !-- Define x-axis (for scalar position) 3519 CALL netcdf_create_dim( id_set_xz(av), 'x', nx+1, id_dim_x_xz(av), & 3520 150 ) 3521 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_x_xz(av) /), 'x', & 3522 NF90_DOUBLE, id_var_x_xz(av), 'meters', '', & 3523 151, 152, 000 ) 3524 CALL netcdf_create_att( id_set_xz(av), id_var_x_xz(av), 'axis', & 3525 'X', 000) 3282 CALL netcdf_create_dim( id_set_xz(av), 'x', nx+1, id_dim_x_xz(av), 150 ) 3283 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_x_xz(av) /), 'x', NF90_DOUBLE, & 3284 id_var_x_xz(av), 'meters', '', 151, 152, 000 ) 3285 CALL netcdf_create_att( id_set_xz(av), id_var_x_xz(av), 'axis', 'X', 000) 3526 3286 ! 3527 3287 !-- Define x-axis (for u position) 3528 CALL netcdf_create_dim( id_set_xz(av), 'xu', nx+1, id_dim_xu_xz(av), & 3529 372 ) 3530 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_xu_xz(av) /), 'xu', & 3531 NF90_DOUBLE, id_var_xu_xz(av), 'meters', '', & 3532 373, 374, 000 ) 3533 CALL netcdf_create_att( id_set_xz(av), id_var_xu_xz(av), 'axis', & 3534 'X', 000) 3535 3288 CALL netcdf_create_dim( id_set_xz(av), 'xu', nx+1, id_dim_xu_xz(av), 372 ) 3289 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_xu_xz(av) /), 'xu', NF90_DOUBLE, & 3290 id_var_xu_xz(av), 'meters', '', 373, 374, 000 ) 3291 CALL netcdf_create_att( id_set_xz(av), id_var_xu_xz(av), 'axis', 'X', 000) 3292 3536 3293 ! 3537 3294 !-- Define the three z-axes (zu, zw, and zs) 3538 CALL netcdf_create_dim( id_set_xz(av), 'zu', nz+2, id_dim_zu_xz(av), & 3539 153 ) 3540 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_zu_xz(av) /), 'zu', & 3541 NF90_DOUBLE, id_var_zu_xz(av), 'meters', '', & 3542 154, 155, 000 ) 3543 CALL netcdf_create_att( id_set_xz(av), id_var_zu_xz(av), 'axis', & 3544 'Z', 000) 3545 3546 CALL netcdf_create_dim( id_set_xz(av), 'zw', nz+2, id_dim_zw_xz(av), & 3547 156 ) 3548 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_zw_xz(av) /), 'zw', & 3549 NF90_DOUBLE, id_var_zw_xz(av), 'meters', '', & 3550 157, 158, 000 ) 3551 CALL netcdf_create_att( id_set_xz(av), id_var_zw_xz(av), 'axis', & 3552 'Z', 000) 3295 CALL netcdf_create_dim( id_set_xz(av), 'zu', nz+2, id_dim_zu_xz(av), 153 ) 3296 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_zu_xz(av) /), 'zu', NF90_DOUBLE, & 3297 id_var_zu_xz(av), 'meters', '', 154, 155, 000 ) 3298 CALL netcdf_create_att( id_set_xz(av), id_var_zu_xz(av), 'axis', 'Z', 000) 3299 3300 CALL netcdf_create_dim( id_set_xz(av), 'zw', nz+2, id_dim_zw_xz(av), 156 ) 3301 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_zw_xz(av) /), 'zw', NF90_DOUBLE, & 3302 id_var_zw_xz(av), 'meters', '', 157, 158, 000 ) 3303 CALL netcdf_create_att( id_set_xz(av), id_var_zw_xz(av), 'axis', 'Z', 000) 3553 3304 ! 3554 3305 !-- Define UTM and geographic coordinates 3555 CALL define_geo_coordinates( id_set_xz(av), &3556 (/ id_dim_x_xz(av), id_dim_xu_xz(av) /),&3557 (/ id_dim_y_xz(av), id_dim_yv_xz(av) /),&3558 id_var_eutm_xz(:,av), id_var_nutm_xz(:,av),&3559 id_var_lat_xz(:,av), id_var_lon_xz(:,av) )3306 CALL define_geo_coordinates( id_set_xz(av), & 3307 (/ id_dim_x_xz(av), id_dim_xu_xz(av) /), & 3308 (/ id_dim_y_xz(av), id_dim_yv_xz(av) /), & 3309 id_var_eutm_xz(:,av), id_var_nutm_xz(:,av), & 3310 id_var_lat_xz(:,av), id_var_lon_xz(:,av) ) 3560 3311 ! 3561 3312 !-- Define coordinate-reference system … … 3564 3315 IF ( land_surface ) THEN 3565 3316 3566 CALL netcdf_create_dim( id_set_xz(av), 'zs', nzs, & 3567 id_dim_zs_xz(av), 542 ) 3568 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_zs_xz(av) /), & 3569 'zs', NF90_DOUBLE, id_var_zs_xz(av), & 3570 'meters', '', 543, 544, 000 ) 3571 CALL netcdf_create_att( id_set_xz(av), id_var_zs_xz(av), 'axis', & 3572 'Z', 000) 3317 CALL netcdf_create_dim( id_set_xz(av), 'zs', nzs, id_dim_zs_xz(av), 542 ) 3318 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_zs_xz(av) /), 'zs', NF90_DOUBLE, & 3319 id_var_zs_xz(av), 'meters', '', 543, 544, 000 ) 3320 CALL netcdf_create_att( id_set_xz(av), id_var_zs_xz(av), 'axis', 'Z', 000) 3573 3321 3574 3322 ENDIF … … 3625 3373 !-- Check for land surface quantities 3626 3374 IF ( land_surface ) THEN 3627 CALL lsm_define_netcdf_grid( do2d(av,i), found, & 3628 grid_x, grid_y, grid_z ) 3375 CALL lsm_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 3629 3376 ENDIF 3630 3377 3631 3378 IF ( .NOT. found ) THEN 3632 CALL tcm_define_netcdf_grid( do2d(av,i), found, & 3633 grid_x, grid_y, grid_z ) 3379 CALL tcm_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 3634 3380 ENDIF 3635 3381 … … 3637 3383 !-- Check for ocean quantities 3638 3384 IF ( .NOT. found .AND. ocean_mode ) THEN 3639 CALL ocean_define_netcdf_grid( do2d(av,i), found, & 3640 grid_x, grid_y, grid_z ) 3385 CALL ocean_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 3641 3386 ENDIF 3642 3387 ! 3643 3388 !-- Check for radiation quantities 3644 3389 IF ( .NOT. found .AND. radiation ) THEN 3645 CALL radiation_define_netcdf_grid( do2d(av,i), found, & 3646 grid_x, grid_y, & 3390 CALL radiation_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, & 3647 3391 grid_z ) 3648 3392 ENDIF … … 3650 3394 !-- Check for SALSA quantities 3651 3395 IF ( .NOT. found .AND. salsa ) THEN 3652 CALL salsa_define_netcdf_grid( do2d(av,i), found, & 3653 grid_x, grid_y, grid_z ) 3396 CALL salsa_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 3654 3397 ENDIF 3655 3398 … … 3657 3400 !-- Check for gust module quantities 3658 3401 IF ( .NOT. found .AND. gust_module_enabled ) THEN 3659 CALL gust_define_netcdf_grid( do2d(av,i), found, & 3660 grid_x, grid_y, grid_z ) 3402 CALL gust_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 3661 3403 ENDIF 3662 3404 … … 3664 3406 !-- Check for chemistry quantities 3665 3407 IF ( .NOT. found .AND. air_chemistry ) THEN 3666 CALL chem_define_netcdf_grid( do2d(av,i), found, & 3667 grid_x, grid_y, & 3668 grid_z ) 3408 CALL chem_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 3669 3409 ENDIF 3670 3410 3671 IF ( .NOT. found ) & 3672 CALL doq_define_netcdf_grid( do2d(av,i), found, & 3673 grid_x, grid_y, grid_z ) 3411 IF ( .NOT. found ) & 3412 CALL doq_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 3674 3413 3675 3414 ! 3676 3415 !-- Check for user-defined quantities 3677 3416 IF ( .NOT. found .AND. user_module_enabled ) THEN 3678 CALL user_define_netcdf_grid( do2d(av,i), found, & 3679 grid_x, grid_y, grid_z ) 3417 CALL user_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 3680 3418 ENDIF 3681 3419 3682 3420 IF ( .NOT. found ) THEN 3683 WRITE ( message_string, * ) 'no grid defined for', & 3684 ' variable ', TRIM( do2d(av,i) ) 3685 CALL message( 'define_netcdf_header', 'PA0244', & 3686 0, 1, 0, 6, 0 ) 3421 WRITE ( message_string, * ) 'no grid defined for', ' variable ', & 3422 TRIM( do2d(av,i) ) 3423 CALL message( 'define_netcdf_header', 'PA0244', 0, 1, 0, 6, 0 ) 3687 3424 ENDIF 3688 3425 … … 3713 3450 ! 3714 3451 !-- Define the grid 3715 CALL netcdf_create_var( id_set_xz(av), (/ id_x, id_y, id_z, & 3716 id_dim_time_xz(av) /), do2d(av,i), & 3717 nc_precision(2), id_var_do2d(av,i), & 3718 TRIM( do2d_unit(av,i) ), do2d(av,i), & 3719 159, 160, 355, .TRUE. ) 3452 CALL netcdf_create_var( id_set_xz(av), (/ id_x, id_y, id_z, id_dim_time_xz(av) /), & 3453 do2d(av,i), nc_precision(2), id_var_do2d(av,i), & 3454 TRIM( do2d_unit(av,i) ), do2d(av,i), 159, 160, 355, .TRUE. ) 3720 3455 3721 3456 #if defined( __netcdf4_parallel ) … … 3729 3464 CALL netcdf_handle_error( 'netcdf_define_header', 534 ) 3730 3465 ! 3731 !-- Set independent io operations for parallel io. Collective io 3732 !-- is only allowed in case of a 1d-decomposition along x,3733 !-- because otherwise, not all PEs have outputdata.3466 !-- Set independent io operations for parallel io. Collective io is only allowed in 3467 !-- case of a 1d-decomposition along x, because otherwise, not all PEs have output 3468 !-- data. 3734 3469 IF ( npey == 1 ) THEN 3735 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av), &3736 id_var_do2d(av,i), &3470 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av), & 3471 id_var_do2d(av,i), & 3737 3472 NF90_COLLECTIVE ) 3738 3473 ELSE 3739 3474 ! 3740 !-- Test simulations showed that the output of cross sections 3741 !-- by all PEs in data_output_2d using NF90_COLLECTIVE is 3742 !-- faster than the output by the first row of PEs in 3743 !-- x-direction using NF90_INDEPENDENT. 3744 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av), & 3745 id_var_do2d(av,i), & 3746 NF90_COLLECTIVE ) 3747 ! nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av), & 3748 ! id_var_do2d(av,i), & 3475 !-- Test simulations showed that the output of cross sections by all PEs in 3476 !-- data_output_2d using NF90_COLLECTIVE is faster than the output by the first 3477 !-- row of PEs in x-direction using NF90_INDEPENDENT. 3478 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av), & 3479 id_var_do2d(av,i), & 3480 NF90_COLLECTIVE ) 3481 ! nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av), & 3482 ! id_var_do2d(av,i), & 3749 3483 ! NF90_INDEPENDENT ) 3750 3484 ENDIF … … 3765 3499 3766 3500 ! 3767 !-- Write the list of variables as global attribute (this is used by 3768 !-- restart runs and by combine_plot_fields) 3769 nc_stat = NF90_PUT_ATT( id_set_xz(av), NF90_GLOBAL, 'VAR_LIST', & 3770 var_list ) 3501 !-- Write the list of variables as global attribute (this is used by restart runs and by 3502 !-- combine_plot_fields) 3503 nc_stat = NF90_PUT_ATT( id_set_xz(av), NF90_GLOBAL, 'VAR_LIST', var_list ) 3771 3504 CALL netcdf_handle_error( 'netcdf_define_header', 161 ) 3772 3505 3773 3506 ! 3774 !-- Set general no fill, otherwise the performance drops significantly for 3775 !-- parallel output. 3507 !-- Set general no fill, otherwise the performance drops significantly for parallel output. 3776 3508 nc_stat = NF90_SET_FILL( id_set_xz(av), NF90_NOFILL, oldmode ) 3777 3509 CALL netcdf_handle_error( 'netcdf_define_header', 530 ) … … 3783 3515 3784 3516 ! 3785 !-- These data are only written by PE0 for parallel output to increase 3786 !-- the performance. 3517 !-- These data are only written by PE0 for parallel output to increase the performance. 3787 3518 IF ( myid == 0 .OR. netcdf_data_format < 5 ) THEN 3788 3519 … … 3800 3531 ENDIF 3801 3532 ENDDO 3802 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_y_xz(av), &3803 netcdf_data, start = (/ 1 /), &3533 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_y_xz(av), & 3534 netcdf_data, start = (/ 1 /), & 3804 3535 count = (/ ns /) ) 3805 3536 CALL netcdf_handle_error( 'netcdf_define_header', 163 ) … … 3814 3545 ENDIF 3815 3546 ENDDO 3816 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_yv_xz(av), &3817 netcdf_data, start = (/ 1 /), &3547 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_yv_xz(av), & 3548 netcdf_data, start = (/ 1 /), & 3818 3549 count = (/ ns /) ) 3819 3550 CALL netcdf_handle_error( 'netcdf_define_header', 375 ) … … 3822 3553 !-- Write gridpoint number data 3823 3554 netcdf_data(1:ns) = section(1:ns,2) 3824 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_ind_y_xz(av), &3825 netcdf_data, start = (/ 1 /), &3555 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_ind_y_xz(av), & 3556 netcdf_data, start = (/ 1 /), & 3826 3557 count = (/ ns /) ) 3827 3558 CALL netcdf_handle_error( 'netcdf_define_header', 164 ) … … 3838 3569 ENDDO 3839 3570 3840 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_x_xz(av), &3841 netcdf_data, start = (/ 1 /), &3571 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_x_xz(av), & 3572 netcdf_data, start = (/ 1 /), & 3842 3573 count = (/ nx+1 /) ) 3843 3574 CALL netcdf_handle_error( 'netcdf_define_header', 165 ) … … 3847 3578 ENDDO 3848 3579 3849 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_xu_xz(av), &3850 netcdf_data, start = (/ 1 /), &3580 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_xu_xz(av), & 3581 netcdf_data, start = (/ 1 /), & 3851 3582 count = (/ nx+1 /) ) 3852 3583 CALL netcdf_handle_error( 'netcdf_define_header', 377 ) … … 3859 3590 3860 3591 netcdf_data(0:nz+1) = zu(nzb:nzt+1) 3861 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_zu_xz(av), &3862 netcdf_data, start = (/ 1 /), &3592 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_zu_xz(av), & 3593 netcdf_data, start = (/ 1 /), & 3863 3594 count = (/ nz+2 /) ) 3864 3595 CALL netcdf_handle_error( 'netcdf_define_header', 166 ) 3865 3596 3866 3597 netcdf_data(0:nz+1) = zw(nzb:nzt+1) 3867 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_zw_xz(av), &3868 netcdf_data, start = (/ 1 /), &3598 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_zw_xz(av), & 3599 netcdf_data, start = (/ 1 /), & 3869 3600 count = (/ nz+2 /) ) 3870 3601 CALL netcdf_handle_error( 'netcdf_define_header', 167 ) … … 3874 3605 IF ( land_surface ) THEN 3875 3606 netcdf_data(0:nzs-1) = - zs(nzb_soil:nzt_soil) 3876 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_zs_xz(av), &3877 netcdf_data(0:nzs), start = (/ 1 /), &3607 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_zs_xz(av), & 3608 netcdf_data(0:nzs), start = (/ 1 /), & 3878 3609 count = (/ nzt_soil-nzb_soil+1 /) ) 3879 3610 CALL netcdf_handle_error( 'netcdf_define_header', 548 ) … … 3906 3637 3907 3638 DO i = 0, nx 3908 netcdf_data(i) = init_model%origin_x & 3909 + cos_rot_angle * ( i + shift_x ) * dx 3639 netcdf_data(i) = init_model%origin_x + cos_rot_angle * ( i + shift_x ) * dx 3910 3640 ENDDO 3911 3641 3912 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_eutm_xz(k,av), &3913 netcdf_data, start = (/ 1 /), &3642 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_eutm_xz(k,av), & 3643 netcdf_data, start = (/ 1 /), & 3914 3644 count = (/ nx+1 /) ) 3915 3645 CALL netcdf_handle_error( 'netcdf_define_header', 555 ) … … 3939 3669 netcdf_data(i) = -1.0_wp ! section averaged along y 3940 3670 ELSE 3941 netcdf_data(i) = init_model%origin_y &3942 + cos_rot_angle * ( section(i,2) + shift_y ) * dy3671 netcdf_data(i) = init_model%origin_y & 3672 + cos_rot_angle * ( section(i,2) + shift_y ) * dy 3943 3673 ENDIF 3944 3674 ENDDO 3945 3675 3946 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_nutm_xz(k,av), &3947 netcdf_data, start = (/ 1 /), &3676 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_nutm_xz(k,av), & 3677 netcdf_data, start = (/ 1 /), & 3948 3678 count = (/ ns /) ) 3949 3679 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) … … 3979 3709 ELSE 3980 3710 DO i = 0, nx 3981 netcdf_data_2d(i,j) = init_model%origin_x &3982 + cos_rot_angle * ( i + shift_x ) * dx&3983 + sin_rot_angle * ( section(j,2) + shift_y ) * dy3711 netcdf_data_2d(i,j) = init_model%origin_x & 3712 + cos_rot_angle * ( i + shift_x ) * dx & 3713 + sin_rot_angle * ( section(j,2) + shift_y ) * dy 3984 3714 ENDDO 3985 3715 ENDIF 3986 3716 ENDDO 3987 3717 3988 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_eutm_xz(k,av), &3989 netcdf_data_2d, start = (/ 1, 1 /), &3718 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_eutm_xz(k,av), & 3719 netcdf_data_2d, start = (/ 1, 1 /), & 3990 3720 count = (/ nx+1, ns /) ) 3991 3721 CALL netcdf_handle_error( 'netcdf_define_header', 555 ) … … 3996 3726 ELSE 3997 3727 DO i = 0, nx 3998 netcdf_data_2d(i,j) = init_model%origin_y &3999 - sin_rot_angle * ( i + shift_x ) * dx&4000 + cos_rot_angle * ( section(j,2) + shift_y ) * dy3728 netcdf_data_2d(i,j) = init_model%origin_y & 3729 - sin_rot_angle * ( i + shift_x ) * dx & 3730 + cos_rot_angle * ( section(j,2) + shift_y ) * dy 4001 3731 ENDDO 4002 3732 ENDIF 4003 3733 ENDDO 4004 3734 4005 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_nutm_xz(k,av), &4006 netcdf_data_2d, start = (/ 1, 1 /), &3735 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_nutm_xz(k,av), & 3736 netcdf_data_2d, start = (/ 1, 1 /), & 4007 3737 count = (/ nx+1, ns /) ) 4008 3738 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) … … 4039 3769 ELSE 4040 3770 DO i = 0, nx 4041 eutm = init_model%origin_x & 4042 + cos_rot_angle * ( i + shift_x ) * dx & 4043 + sin_rot_angle * ( section(j,2) + shift_y ) * dy 4044 nutm = init_model%origin_y & 4045 - sin_rot_angle * ( i + shift_x ) * dx & 4046 + cos_rot_angle * ( section(j,2) + shift_y ) * dy 4047 4048 CALL convert_utm_to_geographic( crs_list, & 4049 eutm, nutm, & 4050 lon(i,j), lat(i,j) ) 3771 eutm = init_model%origin_x & 3772 + cos_rot_angle * ( i + shift_x ) * dx & 3773 + sin_rot_angle * ( section(j,2) + shift_y ) * dy 3774 nutm = init_model%origin_y & 3775 - sin_rot_angle * ( i + shift_x ) * dx & 3776 + cos_rot_angle * ( section(j,2) + shift_y ) * dy 3777 3778 CALL convert_utm_to_geographic( crs_list, eutm, nutm, lon(i,j), lat(i,j) ) 4051 3779 ENDDO 4052 3780 ENDIF 4053 3781 ENDDO 4054 3782 4055 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_lon_xz(k,av), &4056 lon, start = (/ 1, 1 /),&4057 count = (/ nx+1, ns /) )3783 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_lon_xz(k,av), & 3784 lon, start = (/ 1, 1 /), & 3785 count = (/ nx+1, ns /) ) 4058 3786 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) 4059 3787 4060 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_lat_xz(k,av), &4061 lat, start = (/ 1, 1 /),&4062 count = (/ nx+1, ns /) )3788 nc_stat = NF90_PUT_VAR( id_set_xz(av), id_var_lat_xz(k,av), & 3789 lat, start = (/ 1, 1 /), & 3790 count = (/ nx+1, ns /) ) 4063 3791 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) 4064 3792 ENDDO … … 4074 3802 ! 4075 3803 !-- Get the list of variables and compare with the actual run. 4076 !-- First var_list_old has to be reset, since GET_ATT does not assign 4077 !-- trailing blanks. 3804 !-- First var_list_old has to be reset, since GET_ATT does not assign trailing blanks. 4078 3805 var_list_old = ' ' 4079 nc_stat = NF90_GET_ATT( id_set_xz(av), NF90_GLOBAL, 'VAR_LIST', & 4080 var_list_old ) 3806 nc_stat = NF90_GET_ATT( id_set_xz(av), NF90_GLOBAL, 'VAR_LIST', var_list_old ) 4081 3807 CALL netcdf_handle_error( 'netcdf_define_header', 168 ) 4082 3808 … … 4097 3823 4098 3824 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 4099 message_string = 'netCDF file for cross-sections ' // & 4100 TRIM( var ) // ' from previous run found,' // & 4101 '&but this file cannot be extended due to' // & 4102 ' variable mismatch.' // & 4103 '&New file is created instead.' 3825 message_string = 'netCDF file for cross-sections ' // TRIM( var ) // & 3826 ' from previous run found,' // & 3827 '&but this file cannot be extended due to' // & 3828 ' variable mismatch.' // '&New file is created instead.' 4104 3829 CALL message( 'define_netcdf_header', 'PA0249', 0, 1, 0, 6, 0 ) 4105 3830 extend = .FALSE. … … 4120 3845 CALL netcdf_handle_error( 'netcdf_define_header', 169 ) 4121 3846 4122 nc_stat = NF90_INQUIRE_VARIABLE( id_set_xz(av), id_var_y_xz(av), &3847 nc_stat = NF90_INQUIRE_VARIABLE( id_set_xz(av), id_var_y_xz(av), & 4123 3848 dimids = id_dim_y_xz_old ) 4124 3849 CALL netcdf_handle_error( 'netcdf_define_header', 170 ) 4125 3850 id_dim_y_xz(av) = id_dim_y_xz_old(1) 4126 3851 4127 nc_stat = NF90_INQUIRE_DIMENSION( id_set_xz(av), id_dim_y_xz(av), & 4128 len = ns_old ) 3852 nc_stat = NF90_INQUIRE_DIMENSION( id_set_xz(av), id_dim_y_xz(av), LEN = ns_old ) 4129 3853 CALL netcdf_handle_error( 'netcdf_define_header', 171 ) 4130 3854 4131 3855 IF ( ns /= ns_old ) THEN 4132 message_string = 'netCDF file for cross-sections ' // & 4133 TRIM( var ) // ' from previous run found,' // & 4134 '&but this file cannot be extended due to' // & 4135 ' mismatch in number of' // & 4136 ' cross sections.' // & 3856 message_string = 'netCDF file for cross-sections ' // TRIM( var ) // & 3857 ' from previous run found,' // & 3858 '&but this file cannot be extended due to' // & 3859 ' mismatch in number of' // ' cross sections.' // & 4137 3860 '&New file is created instead.' 4138 3861 CALL message( 'define_netcdf_header', 'PA0250', 0, 1, 0, 6, 0 ) … … 4151 3874 IF ( section(i,2) /= -1 ) THEN 4152 3875 IF ( ( ( section(i,2) + 0.5 ) * dy ) /= netcdf_data(i) ) THEN 4153 message_string = 'netCDF file for cross-sections ' // & 4154 TRIM( var ) // ' from previous run found,' // & 4155 ' but this file cannot be extended' // & 4156 ' due to mismatch in cross' // & 4157 ' section levels.' // & 4158 ' New file is created instead.' 4159 CALL message( 'define_netcdf_header', 'PA0251', & 4160 0, 1, 0, 6, 0 ) 3876 message_string = 'netCDF file for cross-sections ' // TRIM( var ) // & 3877 ' from previous run found,' // & 3878 ' but this file cannot be extended' // & 3879 ' due to mismatch in cross' // ' section levels.' // & 3880 ' New file is created instead.' 3881 CALL message( 'define_netcdf_header', 'PA0251', 0, 1, 0, 6, 0 ) 4161 3882 extend = .FALSE. 4162 3883 RETURN … … 4164 3885 ELSE 4165 3886 IF ( -1.0_wp /= netcdf_data(i) ) THEN 4166 message_string = 'netCDF file for cross-sections ' // & 4167 TRIM( var ) // ' from previous run found,' // & 4168 ' but this file cannot be extended' // & 4169 ' due to mismatch in cross' // & 4170 ' section levels.' // & 4171 ' New file is created instead.' 4172 CALL message( 'define_netcdf_header', 'PA0251', & 4173 0, 1, 0, 6, 0 ) 3887 message_string = 'netCDF file for cross-sections ' // TRIM( var ) // & 3888 ' from previous run found,' // & 3889 ' but this file cannot be extended' // & 3890 ' due to mismatch in cross' // ' section levels.' // & 3891 ' New file is created instead.' 3892 CALL message( 'define_netcdf_header', 'PA0251', 0, 1, 0, 6, 0 ) 4174 3893 extend = .FALSE. 4175 3894 RETURN … … 4181 3900 4182 3901 ! 4183 !-- Get the id of the time coordinate (unlimited coordinate) and its 4184 !-- last index on the file. The next time level is do2d..count+1. 4185 !-- The current time must be larger than the last output time 4186 !-- on the file. 3902 !-- Get the id of the time coordinate (unlimited coordinate) and its last index on the file. 3903 !-- The next time level is do2d..count+1. 3904 !-- The current time must be larger than the last output time on the file. 4187 3905 nc_stat = NF90_INQ_VARID( id_set_xz(av), 'time', id_var_time_xz(av) ) 4188 3906 CALL netcdf_handle_error( 'netcdf_define_header', 173 ) 4189 3907 4190 nc_stat = NF90_INQUIRE_VARIABLE( id_set_xz(av), id_var_time_xz(av), &3908 nc_stat = NF90_INQUIRE_VARIABLE( id_set_xz(av), id_var_time_xz(av), & 4191 3909 dimids = id_dim_time_old ) 4192 3910 CALL netcdf_handle_error( 'netcdf_define_header', 174 ) 4193 3911 id_dim_time_xz(av) = id_dim_time_old(1) 4194 3912 4195 nc_stat = NF90_INQUIRE_DIMENSION( id_set_xz(av), id_dim_time_xz(av), & 4196 len = ntime_count ) 3913 nc_stat = NF90_INQUIRE_DIMENSION( id_set_xz(av), id_dim_time_xz(av), LEN = ntime_count ) 4197 3914 CALL netcdf_handle_error( 'netcdf_define_header', 175 ) 4198 3915 4199 3916 ! 4200 !-- For non-parallel output use the last output time level of the netcdf 4201 !-- file because the time dimension is unlimited. In case of parallel 4202 !-- output the variable ntime_count could get the value of 9*10E36 because 4203 !-- the time dimension is limited. 3917 !-- For non-parallel output use the last output time level of the netcdf file because the time 3918 !-- dimension is unlimited. In case of parallel output the variable ntime_count could get the 3919 !-- value of 9*10E36 because the time dimension is limited. 4204 3920 IF ( netcdf_data_format < 5 ) do2d_xz_time_count(av) = ntime_count 4205 3921 4206 nc_stat = NF90_GET_VAR( id_set_xz(av), id_var_time_xz(av), &4207 last_time_coordinate, &4208 start = (/ do2d_xz_time_count(av) /), &3922 nc_stat = NF90_GET_VAR( id_set_xz(av), id_var_time_xz(av), & 3923 last_time_coordinate, & 3924 start = (/ do2d_xz_time_count(av) /), & 4209 3925 count = (/ 1 /) ) 4210 3926 CALL netcdf_handle_error( 'netcdf_define_header', 176 ) 4211 3927 4212 3928 IF ( last_time_coordinate(1) >= simulated_time ) THEN 4213 message_string = 'netCDF file for cross sections ' // & 4214 TRIM( var ) // ' from previous run found,' // & 4215 '&but this file cannot be extended becaus' // & 4216 'e the current output time' // & 4217 '&is less or equal than the last output t' // & 4218 'ime on this file.' // & 3929 message_string = 'netCDF file for cross sections ' // TRIM( var ) // & 3930 ' from previous run found,' // & 3931 '&but this file cannot be extended because' // & 3932 ' the current output time' // & 3933 '&is less or equal than the last output time' // ' on this file.' // & 4219 3934 '&New file is created instead.' 4220 3935 CALL message( 'define_netcdf_header', 'PA0252', 0, 1, 0, 6, 0 ) … … 4226 3941 IF ( netcdf_data_format > 4 ) THEN 4227 3942 ! 4228 !-- Check if the needed number of output time levels is increased 4229 !-- compared to the number oftime levels in the existing file.3943 !-- Check if the needed number of output time levels is increased compared to the number of 3944 !-- time levels in the existing file. 4230 3945 IF ( ntdim_2d_xz(av) > ntime_count ) THEN 4231 message_string = 'netCDF file for cross sections ' // & 4232 TRIM( var ) // ' from previous run found,' // & 4233 '&but this file cannot be extended becaus' // & 4234 'e the number of output time levels has b' // & 4235 'een increased compared to the previous s' // & 4236 'imulation.' // & 3946 message_string = 'netCDF file for cross sections ' // TRIM( var ) // & 3947 ' from previous run found,' // & 3948 '&but this file cannot be extended becaus' // & 3949 'e the number of output time levels has b' // & 3950 'een increased compared to the previous s' // 'imulation.' // & 4237 3951 '&New file is created instead.' 4238 3952 CALL message( 'define_netcdf_header', 'PA0390', 0, 1, 0, 6, 0 ) … … 4242 3956 !-- Recalculate the needed time levels for the new file. 4243 3957 IF ( av == 0 ) THEN 4244 ntdim_2d_xz(0) = CEILING( & 4245 ( end_time - MAX( skip_time_do2d_xz, & 4246 simulated_time_at_begin ) & 4247 ) / dt_do2d_xz ) 3958 ntdim_2d_xz(0) = CEILING( ( end_time - MAX( skip_time_do2d_xz, & 3959 simulated_time_at_begin ) & 3960 ) / dt_do2d_xz ) 4248 3961 IF ( do2d_at_begin ) ntdim_2d_xz(0) = ntdim_2d_xz(0) + 1 4249 3962 ELSE 4250 ntdim_2d_xz(1) = CEILING( & 4251 ( end_time - MAX( skip_time_data_output_av, & 4252 simulated_time_at_begin ) & 4253 ) / dt_data_output_av ) 3963 ntdim_2d_xz(1) = CEILING( ( end_time - MAX( skip_time_data_output_av, & 3964 simulated_time_at_begin ) & 3965 ) / dt_data_output_av ) 4254 3966 ENDIF 4255 3967 RETURN … … 4263 3975 DO WHILE ( do2d(av,i)(1:1) /= ' ' ) 4264 3976 IF ( INDEX( do2d(av,i), 'xz' ) /= 0 ) THEN 4265 nc_stat = NF90_INQ_VARID( id_set_xz(av), do2d(av,i), & 4266 id_var_do2d(av,i) ) 3977 nc_stat = NF90_INQ_VARID( id_set_xz(av), do2d(av,i), id_var_do2d(av,i) ) 4267 3978 CALL netcdf_handle_error( 'netcdf_define_header', 177 ) 4268 3979 #if defined( __netcdf4_parallel ) 4269 3980 ! 4270 !-- Set independent io operations for parallel io. Collective io 4271 !-- is only allowed in case of a 1d-decomposition along x, because 4272 !-- otherwise, not all PEs have output data. 3981 !-- Set independent io operations for parallel io. Collective io is only allowed in case 3982 !-- of a 1d-decomposition along x, because otherwise, not all PEs have output data. 4273 3983 IF ( netcdf_data_format > 4 ) THEN 4274 3984 IF ( npey == 1 ) THEN 4275 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av), &4276 id_var_do2d(av,i), &3985 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av), & 3986 id_var_do2d(av,i), & 4277 3987 NF90_COLLECTIVE ) 4278 3988 ELSE 4279 3989 ! 4280 !-- Test simulations showed that the output of cross sections 4281 !-- by all PEs in data_output_2d using NF90_COLLECTIVE is 4282 !-- faster than the output by the first row of PEs in 4283 !-- x-direction using NF90_INDEPENDENT. 4284 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av), & 4285 id_var_do2d(av,i), & 3990 !-- Test simulations showed that the output of cross sections by all PEs in 3991 !-- data_output_2d using NF90_COLLECTIVE is faster than the output by the first 3992 !-- row of PEs in x-direction using NF90_INDEPENDENT. 3993 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av), & 3994 id_var_do2d(av,i), & 4286 3995 NF90_COLLECTIVE ) 4287 ! nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av), &4288 ! id_var_do2d(av,i), &3996 ! nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av), & 3997 ! id_var_do2d(av,i), & 4289 3998 ! NF90_INDEPENDENT ) 4290 3999 ENDIF … … 4297 4006 4298 4007 ! 4299 !-- Update the title attribute on file 4300 !-- In order to avoid 'data mode' errors if updated attributes are larger 4301 !-- than their original size, NF90_PUT_ATT is called in 'define mode' 4302 !-- enclosed by NF90_REDEF and NF90_ENDDEF calls. This implies a possible 4303 !-- performance loss due to data copying; an alternative strategy would be 4304 !-- to ensure equal attribute size in a job chain. Maybe revise later. 4008 !-- Update the title attribute on file. 4009 !-- In order to avoid 'data mode' errors if updated attributes are larger than their original 4010 !-- size, NF90_PUT_ATT is called in 'define mode' enclosed by NF90_REDEF and NF90_ENDDEF 4011 !-- calls. This implies a possible performance loss due to data copying; an alternative 4012 !-- strategy would be to ensure equal attribute size in a job chain. Maybe revise later. 4305 4013 IF ( av == 0 ) THEN 4306 4014 time_average_text = ' ' 4307 4015 ELSE 4308 WRITE (time_average_text, '('', '',F7.1,'' s average'')') & 4309 averaging_interval 4016 WRITE ( time_average_text, '('', '',F7.1,'' s average'')' ) averaging_interval 4310 4017 ENDIF 4311 4018 nc_stat = NF90_REDEF( id_set_xz(av) ) 4312 4019 CALL netcdf_handle_error( 'netcdf_define_header', 433 ) 4313 nc_stat = NF90_PUT_ATT( id_set_xz(av), NF90_GLOBAL, 'title', & 4314 TRIM( run_description_header ) // & 4315 TRIM( time_average_text ) ) 4020 nc_stat = NF90_PUT_ATT( id_set_xz(av), NF90_GLOBAL, 'title', & 4021 TRIM( run_description_header ) // TRIM( time_average_text ) ) 4316 4022 CALL netcdf_handle_error( 'netcdf_define_header', 178 ) 4317 4023 nc_stat = NF90_ENDDEF( id_set_xz(av) ) 4318 4024 CALL netcdf_handle_error( 'netcdf_define_header', 434 ) 4319 message_string = 'netCDF file for cross-sections ' // & 4320 TRIM( var ) // ' from previous run found.' // & 4321 '&This file will be extended.' 4025 message_string = 'netCDF file for cross-sections ' // TRIM( var ) // & 4026 ' from previous run found.' // '&This file will be extended.' 4322 4027 CALL message( 'define_netcdf_header', 'PA0253', 0, 0, 0, 6, 0 ) 4323 4028 … … 4328 4033 !-- Define some global attributes of the dataset 4329 4034 IF ( av == 0 ) THEN 4330 CALL netcdf_create_global_atts( id_set_yz(av), 'yz', TRIM( run_description_header ), 179 ) 4035 CALL netcdf_create_global_atts( id_set_yz(av), 'yz', TRIM( run_description_header ), & 4036 179 ) 4331 4037 time_average_text = ' ' 4332 4038 ELSE 4333 CALL netcdf_create_global_atts( id_set_yz(av), 'yz_av', TRIM( run_description_header ), 179 ) 4039 CALL netcdf_create_global_atts( id_set_yz(av), 'yz_av', & 4040 TRIM( run_description_header ), 179 ) 4334 4041 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval 4335 nc_stat = NF90_PUT_ATT( id_set_yz(av), NF90_GLOBAL, 'time_avg', &4042 nc_stat = NF90_PUT_ATT( id_set_yz(av), NF90_GLOBAL, 'time_avg', & 4336 4043 TRIM( time_average_text ) ) 4337 4044 CALL netcdf_handle_error( 'netcdf_define_header', 180 ) … … 4340 4047 ! 4341 4048 !-- Define time coordinate for yz sections. 4342 !-- For parallel output the time dimensions has to be limited, otherwise 4343 !-- the performance dropssignificantly.4049 !-- For parallel output the time dimensions has to be limited, otherwise the performance drops 4050 !-- significantly. 4344 4051 IF ( netcdf_data_format < 5 ) THEN 4345 CALL netcdf_create_dim( id_set_yz(av), 'time', NF90_UNLIMITED, &4346 id_dim_time_yz(av),181 )4052 CALL netcdf_create_dim( id_set_yz(av), 'time', NF90_UNLIMITED, id_dim_time_yz(av), & 4053 181 ) 4347 4054 ELSE 4348 CALL netcdf_create_dim( id_set_yz(av), 'time', ntdim_2d_yz(av), & 4349 id_dim_time_yz(av), 526 ) 4350 ENDIF 4351 4352 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_time_yz(av) /), & 4353 'time', NF90_DOUBLE, id_var_time_yz(av), & 4354 'seconds', 'time', 182, 183, 000 ) 4055 CALL netcdf_create_dim( id_set_yz(av), 'time', ntdim_2d_yz(av), id_dim_time_yz(av), & 4056 526 ) 4057 ENDIF 4058 4059 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_time_yz(av) /), 'time', NF90_DOUBLE, & 4060 id_var_time_yz(av), 'seconds', 'time', 182, 183, 000 ) 4355 4061 CALL netcdf_create_att( id_set_yz(av), id_var_time_yz(av), 'standard_name', 'time', 000) 4356 4062 CALL netcdf_create_att( id_set_yz(av), id_var_time_yz(av), 'axis', 'T', 000) … … 4362 4068 ELSE 4363 4069 ns = 1 4364 DO WHILE ( section(ns,3) /= -9999 .AND. ns <= 100 )4070 DO WHILE ( section(ns,3) /= -9999 .AND. ns <= 100 ) 4365 4071 ns = ns + 1 4366 4072 ENDDO … … 4370 4076 ! 4371 4077 !-- Define x axis (for scalar position) 4372 CALL netcdf_create_dim( id_set_yz(av), 'x_yz', ns, id_dim_x_yz(av), & 4373 184 ) 4374 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_x_yz(av) /), & 4375 'x_yz', NF90_DOUBLE, id_var_x_yz(av), & 4376 'meters', '', 185, 186, 000 ) 4377 CALL netcdf_create_att( id_set_yz(av), id_var_x_yz(av), 'axis', & 4378 'X', 000) 4078 CALL netcdf_create_dim( id_set_yz(av), 'x_yz', ns, id_dim_x_yz(av), 184 ) 4079 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_x_yz(av) /), 'x_yz', NF90_DOUBLE, & 4080 id_var_x_yz(av), 'meters', '', 185, 186, 000 ) 4081 CALL netcdf_create_att( id_set_yz(av), id_var_x_yz(av), 'axis', 'X', 000) 4379 4082 ! 4380 4083 !-- Define x axis (for u position) 4381 CALL netcdf_create_dim( id_set_yz(av), 'xu_yz', ns, & 4382 id_dim_xu_yz(av), 377 ) 4383 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_xu_yz(av) /), & 4384 'xu_yz', NF90_DOUBLE, id_var_xu_yz(av), & 4385 'meters', '', 378, 379, 000 ) 4386 CALL netcdf_create_att( id_set_yz(av), id_var_xu_yz(av), 'axis', & 4387 'X', 000) 4388 ! 4389 !-- Define a variable to store the layer indices of the vertical cross 4390 !-- sections 4391 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_x_yz(av) /), & 4392 'ind_x_yz', NF90_DOUBLE, & 4393 id_var_ind_x_yz(av), 'gridpoints', '', 187, & 4394 188, 000 ) 4084 CALL netcdf_create_dim( id_set_yz(av), 'xu_yz', ns, id_dim_xu_yz(av), 377 ) 4085 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_xu_yz(av) /), 'xu_yz', NF90_DOUBLE, & 4086 id_var_xu_yz(av), 'meters', '', 378, 379, 000 ) 4087 CALL netcdf_create_att( id_set_yz(av), id_var_xu_yz(av), 'axis', 'X', 000) 4088 ! 4089 !-- Define a variable to store the layer indices of the vertical cross sections 4090 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_x_yz(av) /), 'ind_x_yz', NF90_DOUBLE, & 4091 id_var_ind_x_yz(av), 'gridpoints', '', 187, 188, 000 ) 4395 4092 ! 4396 4093 !-- Define y-axis (for scalar position) 4397 CALL netcdf_create_dim( id_set_yz(av), 'y', ny+1, id_dim_y_yz(av), & 4398 189 ) 4399 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_y_yz(av) /), 'y', & 4400 NF90_DOUBLE, id_var_y_yz(av), 'meters', '', & 4401 190, 191, 000 ) 4402 CALL netcdf_create_att( id_set_yz(av), id_var_y_yz(av), 'axis', & 4403 'Y', 000) 4094 CALL netcdf_create_dim( id_set_yz(av), 'y', ny+1, id_dim_y_yz(av), 189 ) 4095 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_y_yz(av) /), 'y', NF90_DOUBLE, & 4096 id_var_y_yz(av), 'meters', '', 190, 191, 000 ) 4097 CALL netcdf_create_att( id_set_yz(av), id_var_y_yz(av), 'axis', 'Y', 000) 4404 4098 ! 4405 4099 !-- Define y-axis (for v position) 4406 CALL netcdf_create_dim( id_set_yz(av), 'yv', ny+1, id_dim_yv_yz(av), & 4407 380 ) 4408 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_yv_yz(av) /), 'yv', & 4409 NF90_DOUBLE, id_var_yv_yz(av), 'meters', '', & 4410 381, 382, 000 ) 4411 CALL netcdf_create_att( id_set_yz(av), id_var_yv_yz(av), 'axis', & 4412 'Y', 000) 4100 CALL netcdf_create_dim( id_set_yz(av), 'yv', ny+1, id_dim_yv_yz(av), 380 ) 4101 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_yv_yz(av) /), 'yv', NF90_DOUBLE, & 4102 id_var_yv_yz(av), 'meters', '', 381, 382, 000 ) 4103 CALL netcdf_create_att( id_set_yz(av), id_var_yv_yz(av), 'axis', 'Y', 000) 4413 4104 ! 4414 4105 !-- Define the two z-axes (zu and zw) 4415 CALL netcdf_create_dim( id_set_yz(av), 'zu', nz+2, id_dim_zu_yz(av), & 4416 192 ) 4417 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_zu_yz(av) /), 'zu', & 4418 NF90_DOUBLE, id_var_zu_yz(av), 'meters', '', & 4419 193, 194, 000 ) 4420 CALL netcdf_create_att( id_set_yz(av), id_var_zu_yz(av), 'axis', & 4421 'Z', 000) 4422 4423 CALL netcdf_create_dim( id_set_yz(av), 'zw', nz+2, id_dim_zw_yz(av), & 4424 195 ) 4425 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_zw_yz(av) /), 'zw', & 4426 NF90_DOUBLE, id_var_zw_yz(av), 'meters', '', & 4427 196, 197, 000 ) 4428 CALL netcdf_create_att( id_set_yz(av), id_var_zw_yz(av), 'axis', & 4429 'Z', 000) 4106 CALL netcdf_create_dim( id_set_yz(av), 'zu', nz+2, id_dim_zu_yz(av), 192 ) 4107 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_zu_yz(av) /), 'zu', NF90_DOUBLE, & 4108 id_var_zu_yz(av), 'meters', '', 193, 194, 000 ) 4109 CALL netcdf_create_att( id_set_yz(av), id_var_zu_yz(av), 'axis', 'Z', 000) 4110 4111 CALL netcdf_create_dim( id_set_yz(av), 'zw', nz+2, id_dim_zw_yz(av), 195 ) 4112 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_zw_yz(av) /), 'zw', NF90_DOUBLE, & 4113 id_var_zw_yz(av), 'meters', '', 196, 197, 000 ) 4114 CALL netcdf_create_att( id_set_yz(av), id_var_zw_yz(av), 'axis', 'Z', 000) 4430 4115 ! 4431 4116 !-- Define UTM and geographic coordinates 4432 CALL define_geo_coordinates( id_set_yz(av), &4433 (/ id_dim_x_yz(av), id_dim_xu_yz(av) /),&4434 (/ id_dim_y_yz(av), id_dim_yv_yz(av) /),&4435 id_var_eutm_yz(:,av), id_var_nutm_yz(:,av),&4436 id_var_lat_yz(:,av), id_var_lon_yz(:,av) )4117 CALL define_geo_coordinates( id_set_yz(av), & 4118 (/ id_dim_x_yz(av), id_dim_xu_yz(av) /), & 4119 (/ id_dim_y_yz(av), id_dim_yv_yz(av) /), & 4120 id_var_eutm_yz(:,av), id_var_nutm_yz(:,av), & 4121 id_var_lat_yz(:,av), id_var_lon_yz(:,av) ) 4437 4122 ! 4438 4123 !-- Define coordinate-reference system … … 4441 4126 IF ( land_surface ) THEN 4442 4127 4443 CALL netcdf_create_dim( id_set_yz(av), 'zs', nzs, & 4444 id_dim_zs_yz(av), 545 ) 4445 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_zs_yz(av) /), & 4446 'zs', NF90_DOUBLE, id_var_zs_yz(av), & 4447 'meters', '', 546, 547, 000 ) 4448 CALL netcdf_create_att( id_set_yz(av), id_var_zs_yz(av), 'axis', & 4449 'Z', 000) 4128 CALL netcdf_create_dim( id_set_yz(av), 'zs', nzs, id_dim_zs_yz(av), 545 ) 4129 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_zs_yz(av) /), 'zs', NF90_DOUBLE, & 4130 id_var_zs_yz(av), 'meters', '', 546, 547, 000 ) 4131 CALL netcdf_create_att( id_set_yz(av), id_var_zs_yz(av), 'axis', 'Z', 000) 4450 4132 4451 4133 ENDIF … … 4502 4184 !-- Check for land surface quantities 4503 4185 IF ( land_surface ) THEN 4504 CALL lsm_define_netcdf_grid( do2d(av,i), found, & 4505 grid_x, grid_y, grid_z ) 4186 CALL lsm_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 4506 4187 ENDIF 4507 4188 4508 4189 IF ( .NOT. found ) THEN 4509 CALL tcm_define_netcdf_grid( do2d(av,i), found, & 4510 grid_x, grid_y, grid_z ) 4190 CALL tcm_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 4511 4191 ENDIF 4512 4192 … … 4514 4194 !-- Check for ocean quantities 4515 4195 IF ( .NOT. found .AND. ocean_mode ) THEN 4516 CALL ocean_define_netcdf_grid( do2d(av,i), found, & 4517 grid_x, grid_y, grid_z ) 4196 CALL ocean_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 4518 4197 ENDIF 4519 4198 ! 4520 4199 !-- Check for radiation quantities 4521 4200 IF ( .NOT. found .AND. radiation ) THEN 4522 CALL radiation_define_netcdf_grid( do2d(av,i), found, & 4523 grid_x, grid_y, & 4201 CALL radiation_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, & 4524 4202 grid_z ) 4525 4203 ENDIF … … 4527 4205 !-- Check for SALSA quantities 4528 4206 IF ( .NOT. found .AND. salsa ) THEN 4529 CALL salsa_define_netcdf_grid( do2d(av,i), found, & 4530 grid_x, grid_y, grid_z ) 4207 CALL salsa_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 4531 4208 ENDIF 4532 4209 ! 4533 4210 !-- Check for gust module quantities 4534 4211 IF ( .NOT. found .AND. gust_module_enabled ) THEN 4535 CALL gust_define_netcdf_grid( do2d(av,i), found, & 4536 grid_x, grid_y, grid_z ) 4212 CALL gust_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 4537 4213 ENDIF 4538 4214 … … 4540 4216 !-- Check for chemistry quantities 4541 4217 IF ( .NOT. found .AND. air_chemistry ) THEN 4542 CALL chem_define_netcdf_grid( do2d(av,i), found, & 4543 grid_x, grid_y, & 4544 grid_z ) 4218 CALL chem_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 4545 4219 ENDIF 4546 4220 4547 IF ( .NOT. found ) & 4548 CALL doq_define_netcdf_grid( & 4549 do2d(av,i), found, grid_x, & 4550 grid_y, grid_z ) 4221 IF ( .NOT. found ) & 4222 CALL doq_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 4551 4223 ! 4552 4224 !-- Check for user-defined quantities 4553 4225 IF ( .NOT. found .AND. user_module_enabled ) THEN 4554 CALL user_define_netcdf_grid( do2d(av,i), found, & 4555 grid_x, grid_y, grid_z ) 4226 CALL user_define_netcdf_grid( do2d(av,i), found, grid_x, grid_y, grid_z ) 4556 4227 ENDIF 4557 4228 4558 4229 IF ( .NOT. found ) THEN 4559 WRITE ( message_string, * ) 'no grid defined for', & 4560 ' variable ', TRIM( do2d(av,i) ) 4561 CALL message( 'define_netcdf_header', 'PA0244', & 4562 0, 1, 0, 6, 0 ) 4230 WRITE ( message_string, * ) 'no grid defined for', ' variable ', & 4231 TRIM( do2d(av,i) ) 4232 CALL message( 'define_netcdf_header', 'PA0244', 0, 1, 0, 6, 0 ) 4563 4233 ENDIF 4564 4234 … … 4589 4259 ! 4590 4260 !-- Define the grid 4591 CALL netcdf_create_var( id_set_yz(av), (/ id_x, id_y, id_z, & 4592 id_dim_time_yz(av) /), do2d(av,i), & 4593 nc_precision(3), id_var_do2d(av,i), & 4594 TRIM( do2d_unit(av,i) ), do2d(av,i), & 4595 198, 199, 356, .TRUE. ) 4261 CALL netcdf_create_var( id_set_yz(av), (/ id_x, id_y, id_z, id_dim_time_yz(av) /),& 4262 do2d(av,i), nc_precision(3), id_var_do2d(av,i), & 4263 TRIM( do2d_unit(av,i) ), do2d(av,i), 198, 199, 356, .TRUE. ) 4596 4264 4597 4265 #if defined( __netcdf4_parallel ) … … 4599 4267 ! 4600 4268 !-- Set no fill for every variable to increase performance. 4601 nc_stat = NF90_DEF_VAR_FILL( id_set_yz(av), &4602 id_var_do2d(av,i), &4269 nc_stat = NF90_DEF_VAR_FILL( id_set_yz(av), & 4270 id_var_do2d(av,i), & 4603 4271 NF90_NOFILL, 0 ) 4604 4272 CALL netcdf_handle_error( 'netcdf_define_header', 535 ) 4605 4273 ! 4606 !-- Set independent io operations for parallel io. Collective io 4607 !-- is only allowed in case of a 1d-decomposition along y,4608 !-- because otherwise, not all PEs have outputdata.4274 !-- Set independent io operations for parallel io. Collective io is only allowed in 4275 !-- case of a 1d-decomposition along y, because otherwise, not all PEs have output 4276 !-- data. 4609 4277 IF ( npex == 1 ) THEN 4610 nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av), &4611 id_var_do2d(av,i), &4278 nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av), & 4279 id_var_do2d(av,i), & 4612 4280 NF90_COLLECTIVE ) 4613 4281 ELSE 4614 4282 ! 4615 !-- Test simulations showed that the output of cross sections 4616 !-- by all PEs in data_output_2d using NF90_COLLECTIVE is 4617 !-- faster than the output by the first row of PEs in 4618 !-- y-direction using NF90_INDEPENDENT. 4619 nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av), & 4620 id_var_do2d(av,i), & 4283 !-- Test simulations showed that the output of cross sections by all PEs in 4284 !-- data_output_2d using NF90_COLLECTIVE is faster than the output by the first 4285 !-- row of PEs in y-direction using NF90_INDEPENDENT. 4286 nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av), & 4287 id_var_do2d(av,i), & 4621 4288 NF90_COLLECTIVE ) 4622 ! nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av), &4623 ! id_var_do2d(av,i), &4289 ! nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av), & 4290 ! id_var_do2d(av,i), & 4624 4291 ! NF90_INDEPENDENT ) 4625 4292 ENDIF … … 4640 4307 4641 4308 ! 4642 !-- Write the list of variables as global attribute (this is used by 4643 !-- restart runs and by combine_plot_fields) 4644 nc_stat = NF90_PUT_ATT( id_set_yz(av), NF90_GLOBAL, 'VAR_LIST', & 4645 var_list ) 4309 !-- Write the list of variables as global attribute (this is used by restart runs and by 4310 !-- combine_plot_fields) 4311 nc_stat = NF90_PUT_ATT( id_set_yz(av), NF90_GLOBAL, 'VAR_LIST', var_list ) 4646 4312 CALL netcdf_handle_error( 'netcdf_define_header', 200 ) 4647 4313 4648 4314 ! 4649 !-- Set general no fill, otherwise the performance drops significantly for 4650 !-- parallel output. 4315 !-- Set general no fill, otherwise the performance drops significantly for parallel output. 4651 4316 nc_stat = NF90_SET_FILL( id_set_yz(av), NF90_NOFILL, oldmode ) 4652 4317 CALL netcdf_handle_error( 'netcdf_define_header', 531 ) … … 4658 4323 4659 4324 ! 4660 !-- These data are only written by PE0 for parallel output to increase 4661 !-- the performance. 4325 !-- These data are only written by PE0 for parallel output to increase the performance. 4662 4326 IF ( myid == 0 .OR. netcdf_data_format < 5 ) THEN 4663 4327 … … 4675 4339 ENDIF 4676 4340 ENDDO 4677 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_x_yz(av), &4678 netcdf_data, start = (/ 1 /), &4341 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_x_yz(av), & 4342 netcdf_data, start = (/ 1 /), & 4679 4343 count = (/ ns /) ) 4680 4344 CALL netcdf_handle_error( 'netcdf_define_header', 202 ) … … 4689 4353 ENDIF 4690 4354 ENDDO 4691 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_xu_yz(av), &4692 netcdf_data, start = (/ 1 /), &4355 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_xu_yz(av), & 4356 netcdf_data, start = (/ 1 /), & 4693 4357 count = (/ ns /) ) 4694 4358 CALL netcdf_handle_error( 'netcdf_define_header', 383 ) … … 4697 4361 !-- Write gridpoint number data 4698 4362 netcdf_data(1:ns) = section(1:ns,3) 4699 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_ind_x_yz(av), &4700 netcdf_data, start = (/ 1 /), &4363 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_ind_x_yz(av), & 4364 netcdf_data, start = (/ 1 /), & 4701 4365 count = (/ ns /) ) 4702 4366 CALL netcdf_handle_error( 'netcdf_define_header', 203 ) … … 4712 4376 ENDDO 4713 4377 4714 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_y_yz(av), &4715 netcdf_data, start = (/ 1 /), &4378 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_y_yz(av), & 4379 netcdf_data, start = (/ 1 /), & 4716 4380 count = (/ ny+1 /) ) 4717 4381 CALL netcdf_handle_error( 'netcdf_define_header', 204 ) … … 4721 4385 ENDDO 4722 4386 4723 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_yv_yz(av), &4724 netcdf_data, start = (/ 1 /), &4387 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_yv_yz(av), & 4388 netcdf_data, start = (/ 1 /), & 4725 4389 count = (/ ny+1 /) ) 4726 4390 CALL netcdf_handle_error( 'netcdf_define_header', 384 ) … … 4733 4397 4734 4398 netcdf_data(0:nz+1) = zu(nzb:nzt+1) 4735 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_zu_yz(av), &4736 netcdf_data, start = (/ 1 /), &4399 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_zu_yz(av), & 4400 netcdf_data, start = (/ 1 /), & 4737 4401 count = (/ nz+2 /) ) 4738 4402 CALL netcdf_handle_error( 'netcdf_define_header', 205 ) 4739 4403 4740 4404 netcdf_data(0:nz+1) = zw(nzb:nzt+1) 4741 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_zw_yz(av), &4742 netcdf_data, start = (/ 1 /), &4405 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_zw_yz(av), & 4406 netcdf_data, start = (/ 1 /), & 4743 4407 count = (/ nz+2 /) ) 4744 4408 CALL netcdf_handle_error( 'netcdf_define_header', 206 ) … … 4773 4437 netcdf_data(i) = -1.0_wp ! section averaged along x 4774 4438 ELSE 4775 netcdf_data(i) = init_model%origin_x &4776 + cos_rot_angle * ( section(i,3) + shift_x ) * dx4439 netcdf_data(i) = init_model%origin_x & 4440 + cos_rot_angle * ( section(i,3) + shift_x ) * dx 4777 4441 ENDIF 4778 4442 ENDDO 4779 4443 4780 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_eutm_yz(k,av), &4781 netcdf_data, start = (/ 1 /), &4444 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_eutm_yz(k,av), & 4445 netcdf_data, start = (/ 1 /), & 4782 4446 count = (/ ns /) ) 4783 4447 CALL netcdf_handle_error( 'netcdf_define_header', 555 ) … … 4804 4468 4805 4469 DO i = 0, ny 4806 netcdf_data(i) = init_model%origin_y & 4807 + cos_rot_angle * ( i + shift_y ) * dy 4470 netcdf_data(i) = init_model%origin_y + cos_rot_angle * ( i + shift_y ) * dy 4808 4471 ENDDO 4809 4472 4810 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_nutm_yz(k,av), &4811 netcdf_data, start = (/ 1 /), &4473 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_nutm_yz(k,av), & 4474 netcdf_data, start = (/ 1 /), & 4812 4475 count = (/ ny+1 /) ) 4813 4476 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) … … 4843 4506 netcdf_data_2d(i,:) = -1.0_wp !section averaged along x 4844 4507 ELSE 4845 netcdf_data_2d(i,j) = init_model%origin_x &4846 + cos_rot_angle * ( section(i,3) + shift_x ) * dx &4847 + sin_rot_angle * ( j + shift_y ) * dy4508 netcdf_data_2d(i,j) = init_model%origin_x & 4509 + cos_rot_angle * ( section(i,3) + shift_x ) * dx & 4510 + sin_rot_angle * ( j + shift_y ) * dy 4848 4511 ENDIF 4849 4512 ENDDO 4850 4513 ENDDO 4851 4514 4852 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_eutm_yz(k,av), &4853 netcdf_data_2d, start = (/ 1, 1 /), &4515 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_eutm_yz(k,av), & 4516 netcdf_data_2d, start = (/ 1, 1 /), & 4854 4517 count = (/ ns, ny+1 /) ) 4855 4518 CALL netcdf_handle_error( 'netcdf_define_header', 555 ) … … 4860 4523 netcdf_data_2d(i,:) = -1.0_wp !section averaged along x 4861 4524 ELSE 4862 netcdf_data_2d(i,j) = init_model%origin_y &4863 - sin_rot_angle * ( section(i,3) + shift_x ) * dx &4864 + cos_rot_angle * ( j + shift_y ) * dy4525 netcdf_data_2d(i,j) = init_model%origin_y & 4526 - sin_rot_angle * ( section(i,3) + shift_x ) * dx & 4527 + cos_rot_angle * ( j + shift_y ) * dy 4865 4528 ENDIF 4866 4529 ENDDO 4867 4530 ENDDO 4868 4531 4869 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_nutm_yz(k,av), &4870 netcdf_data_2d, start = (/ 1, 1 /), &4532 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_nutm_yz(k,av), & 4533 netcdf_data_2d, start = (/ 1, 1 /), & 4871 4534 count = (/ ns, ny+1 /) ) 4872 4535 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) … … 4903 4566 lon(i,:) = -180.0_wp ! section averaged along x 4904 4567 ELSE 4905 eutm = init_model%origin_x & 4906 + cos_rot_angle * ( section(i,3) + shift_x ) * dx & 4907 + sin_rot_angle * ( j + shift_y ) * dy 4908 nutm = init_model%origin_y & 4909 - sin_rot_angle * ( section(i,3) + shift_x ) * dx & 4910 + cos_rot_angle * ( j + shift_y ) * dy 4911 4912 CALL convert_utm_to_geographic( crs_list, & 4913 eutm, nutm, & 4914 lon(i,j), lat(i,j) ) 4568 eutm = init_model%origin_x & 4569 + cos_rot_angle * ( section(i,3) + shift_x ) * dx & 4570 + sin_rot_angle * ( j + shift_y ) * dy 4571 nutm = init_model%origin_y & 4572 - sin_rot_angle * ( section(i,3) + shift_x ) * dx & 4573 + cos_rot_angle * ( j + shift_y ) * dy 4574 4575 CALL convert_utm_to_geographic( crs_list, eutm, nutm, lon(i,j), lat(i,j) ) 4915 4576 ENDIF 4916 4577 ENDDO 4917 4578 ENDDO 4918 4579 4919 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_lon_yz(k,av), &4920 lon, start = (/ 1, 1 /),&4921 count = (/ ns, ny+1 /) )4580 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_lon_yz(k,av), & 4581 lon, start = (/ 1, 1 /), & 4582 count = (/ ns, ny+1 /) ) 4922 4583 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) 4923 4584 4924 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_lat_yz(k,av), &4925 lat, start = (/ 1, 1 /),&4926 count = (/ ns, ny+1 /) )4585 nc_stat = NF90_PUT_VAR( id_set_yz(av), id_var_lat_yz(k,av), & 4586 lat, start = (/ 1, 1 /), & 4587 count = (/ ns, ny+1 /) ) 4927 4588 CALL netcdf_handle_error( 'netcdf_define_header', 556 ) 4928 4589 ENDDO … … 4938 4599 ! 4939 4600 !-- Get the list of variables and compare with the actual run. 4940 !-- First var_list_old has to be reset, since GET_ATT does not assign 4941 !-- trailing blanks. 4601 !-- First var_list_old has to be reset, since GET_ATT does not assign trailing blanks. 4942 4602 var_list_old = ' ' 4943 nc_stat = NF90_GET_ATT( id_set_yz(av), NF90_GLOBAL, 'VAR_LIST', & 4944 var_list_old ) 4603 nc_stat = NF90_GET_ATT( id_set_yz(av), NF90_GLOBAL, 'VAR_LIST', var_list_old ) 4945 4604 CALL netcdf_handle_error( 'netcdf_define_header', 207 ) 4946 4605 4947 4606 var_list = ';' 4948 4607 i = 1 4949 DO WHILE ( do2d(av,i)(1:1) /= ' ' )4608 DO WHILE ( do2d(av,i)(1:1) /= ' ' ) 4950 4609 IF ( INDEX( do2d(av,i), 'yz' ) /= 0 ) THEN 4951 4610 var_list = TRIM( var_list ) // TRIM( do2d(av,i) ) // ';' … … 4961 4620 4962 4621 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 4963 message_string = 'netCDF file for cross-sections ' // & 4964 TRIM( var ) // ' from previous run found,' // & 4965 '&but this file cannot be extended due to' // & 4966 ' variable mismatch.' // & 4967 '&New file is created instead.' 4622 message_string = 'netCDF file for cross-sections ' // TRIM( var ) // & 4623 ' from previous run found,' // & 4624 '&but this file cannot be extended due to' // & 4625 ' variable mismatch.' // '&New file is created instead.' 4968 4626 CALL message( 'define_netcdf_header', 'PA0249', 0, 1, 0, 6, 0 ) 4969 4627 extend = .FALSE. … … 4989 4647 id_dim_x_yz(av) = id_dim_x_yz_old(1) 4990 4648 4991 nc_stat = NF90_INQUIRE_DIMENSION( id_set_yz(av), id_dim_x_yz(av), & 4992 len = ns_old ) 4649 nc_stat = NF90_INQUIRE_DIMENSION( id_set_yz(av), id_dim_x_yz(av), LEN = ns_old ) 4993 4650 CALL netcdf_handle_error( 'netcdf_define_header', 210 ) 4994 4651 4995 4652 IF ( ns /= ns_old ) THEN 4996 message_string = 'netCDF file for cross-sections ' // & 4997 TRIM( var ) // ' from previous run found,' // & 4998 '&but this file cannot be extended due to' // & 4999 ' mismatch in number of' // & 5000 ' cross sections.' // & 4653 message_string = 'netCDF file for cross-sections ' // TRIM( var ) // & 4654 ' from previous run found,' // & 4655 '&but this file cannot be extended due to' // & 4656 ' mismatch in number of' // ' cross sections.' // & 5001 4657 '&New file is created instead.' 5002 4658 CALL message( 'define_netcdf_header', 'PA0250', 0, 1, 0, 6, 0 ) … … 5015 4671 IF ( section(i,3) /= -1 ) THEN 5016 4672 IF ( ( ( section(i,3) + 0.5 ) * dx ) /= netcdf_data(i) ) THEN 5017 message_string = 'netCDF file for cross-sections ' // & 5018 TRIM( var ) // ' from previous run found,' // & 5019 ' but this file cannot be extended' // & 5020 ' due to mismatch in cross' // & 5021 ' section levels.' // & 5022 ' New file is created instead.' 5023 CALL message( 'define_netcdf_header', 'PA0251', & 5024 0, 1, 0, 6, 0 ) 4673 message_string = 'netCDF file for cross-sections ' // TRIM( var ) // & 4674 ' from previous run found,' // & 4675 ' but this file cannot be extended' // & 4676 ' due to mismatch in cross' // ' section levels.' // & 4677 ' New file is created instead.' 4678 CALL message( 'define_netcdf_header', 'PA0251', 0, 1, 0, 6, 0 ) 5025 4679 extend = .FALSE. 5026 4680 RETURN … … 5028 4682 ELSE 5029 4683 IF ( -1.0_wp /= netcdf_data(i) ) THEN 5030 message_string = 'netCDF file for cross-sections ' // & 5031 TRIM( var ) // ' from previous run found,' // & 5032 ' but this file cannot be extended' // & 5033 ' due to mismatch in cross' // & 5034 ' section levels.' // & 5035 ' New file is created instead.' 5036 CALL message( 'define_netcdf_header', 'PA0251', & 5037 0, 1, 0, 6, 0 ) 4684 message_string = 'netCDF file for cross-sections ' // TRIM( var ) // & 4685 ' from previous run found,' // & 4686 ' but this file cannot be extended' // & 4687 ' due to mismatch in cross' // ' section levels.' // & 4688 ' New file is created instead.' 4689 CALL message( 'define_netcdf_header', 'PA0251', 0, 1, 0, 6, 0 ) 5038 4690 extend = .FALSE. 5039 4691 RETURN … … 5045 4697 5046 4698 ! 5047 !-- Get the id of the time coordinate (unlimited coordinate) and its 5048 !-- last index on the file. The next time level is pl2d..count+1. 5049 !-- The current time must be larger than the last output time 5050 !-- on the file. 4699 !-- Get the id of the time coordinate (unlimited coordinate) and its last index on the file. 4700 !-- The next time level is pl2d..count+1. 4701 !-- The current time must be larger than the last output time on the file. 5051 4702 nc_stat = NF90_INQ_VARID( id_set_yz(av), 'time', id_var_time_yz(av) ) 5052 4703 CALL netcdf_handle_error( 'netcdf_define_header', 212 ) 5053 4704 5054 nc_stat = NF90_INQUIRE_VARIABLE( id_set_yz(av), id_var_time_yz(av), &4705 nc_stat = NF90_INQUIRE_VARIABLE( id_set_yz(av), id_var_time_yz(av), & 5055 4706 dimids = id_dim_time_old ) 5056 4707 CALL netcdf_handle_error( 'netcdf_define_header', 213 ) 5057 4708 id_dim_time_yz(av) = id_dim_time_old(1) 5058 4709 5059 nc_stat = NF90_INQUIRE_DIMENSION( id_set_yz(av), id_dim_time_yz(av), & 5060 len = ntime_count ) 4710 nc_stat = NF90_INQUIRE_DIMENSION( id_set_yz(av), id_dim_time_yz(av), LEN = ntime_count ) 5061 4711 CALL netcdf_handle_error( 'netcdf_define_header', 214 ) 5062 4712 5063 4713 ! 5064 !-- For non-parallel output use the last output time level of the netcdf 5065 !-- file because the time dimension is unlimited. In case of parallel 5066 !-- output the variable ntime_count could get the value of 9*10E36 because 5067 !-- the time dimension is limited. 4714 !-- For non-parallel output use the last output time level of the netcdf file because the time 4715 !-- dimension is unlimited. In case of parallel output the variable ntime_count could get the 4716 !-- value of 9*10E36 because the time dimension is limited. 5068 4717 IF ( netcdf_data_format < 5 ) do2d_yz_time_count(av) = ntime_count 5069 4718 5070 nc_stat = NF90_GET_VAR( id_set_yz(av), id_var_time_yz(av), &5071 last_time_coordinate, &5072 start = (/ do2d_yz_time_count(av) /), &4719 nc_stat = NF90_GET_VAR( id_set_yz(av), id_var_time_yz(av), & 4720 last_time_coordinate, & 4721 start = (/ do2d_yz_time_count(av) /), & 5073 4722 count = (/ 1 /) ) 5074 4723 CALL netcdf_handle_error( 'netcdf_define_header', 215 ) 5075 4724 5076 4725 IF ( last_time_coordinate(1) >= simulated_time ) THEN 5077 message_string = 'netCDF file for cross sections ' // & 5078 TRIM( var ) // ' from previous run found,' // & 5079 '&but this file cannot be extended becaus' // & 5080 'e the current output time' // & 5081 '&is less or equal than the last output t' // & 5082 'ime on this file.' // & 4726 message_string = 'netCDF file for cross sections ' // TRIM( var ) // & 4727 ' from previous run found,' // & 4728 '&but this file cannot be extended because' // & 4729 ' the current output time' // & 4730 '&is less or equal than the last output time' // ' on this file.' // & 5083 4731 '&New file is created instead.' 5084 4732 CALL message( 'define_netcdf_header', 'PA0252', 0, 1, 0, 6, 0 ) … … 5093 4741 !-- compared to the number of time levels in the existing file. 5094 4742 IF ( ntdim_2d_yz(av) > ntime_count ) THEN 5095 message_string = 'netCDF file for cross sections ' // & 5096 TRIM( var ) // ' from previous run found,' // & 5097 '&but this file cannot be extended becaus' // & 5098 'e the number of output time levels has b' // & 5099 'een increased compared to the previous s' // & 5100 'imulation.' // & 4743 message_string = 'netCDF file for cross sections ' // TRIM( var ) // & 4744 ' from previous run found,' // & 4745 '&but this file cannot be extended because' // & 4746 ' the number of output time levels has ' // & 4747 'been increased compared to the previous ' // 'simulation.' // & 5101 4748 '&New file is created instead.' 5102 4749 CALL message( 'define_netcdf_header', 'PA0391', 0, 1, 0, 6, 0 ) … … 5106 4753 !-- Recalculate the needed time levels for the new file. 5107 4754 IF ( av == 0 ) THEN 5108 ntdim_2d_yz(0) = CEILING( & 5109 ( end_time - MAX( skip_time_do2d_yz, & 5110 simulated_time_at_begin ) & 5111 ) / dt_do2d_yz ) 4755 ntdim_2d_yz(0) = CEILING( ( end_time - MAX( skip_time_do2d_yz, & 4756 simulated_time_at_begin ) & 4757 ) / dt_do2d_yz ) 5112 4758 IF ( do2d_at_begin ) ntdim_2d_yz(0) = ntdim_2d_yz(0) + 1 5113 4759 ELSE 5114 ntdim_2d_yz(1) = CEILING( & 5115 ( end_time - MAX( skip_time_data_output_av, & 5116 simulated_time_at_begin ) & 5117 ) / dt_data_output_av ) 4760 ntdim_2d_yz(1) = CEILING( ( end_time - MAX( skip_time_data_output_av, & 4761 simulated_time_at_begin ) & 4762 ) / dt_data_output_av ) 5118 4763 ENDIF 5119 4764 RETURN … … 5127 4772 DO WHILE ( do2d(av,i)(1:1) /= ' ' ) 5128 4773 IF ( INDEX( do2d(av,i), 'yz' ) /= 0 ) THEN 5129 nc_stat = NF90_INQ_VARID( id_set_yz(av), do2d(av,i), & 5130 id_var_do2d(av,i) ) 4774 nc_stat = NF90_INQ_VARID( id_set_yz(av), do2d(av,i), id_var_do2d(av,i) ) 5131 4775 CALL netcdf_handle_error( 'netcdf_define_header', 216 ) 5132 4776 #if defined( __netcdf4_parallel ) 5133 4777 ! 5134 !-- Set independent io operations for parallel io. Collective io 5135 !-- is only allowed in case of a 1d-decomposition along y, because 5136 !-- otherwise, not all PEs have output data. 4778 !-- Set independent io operations for parallel io. Collective io is only allowed in case 4779 !-- of a 1d-decomposition along y, because otherwise, not all PEs have output data. 5137 4780 IF ( netcdf_data_format > 4 ) THEN 5138 4781 IF ( npex == 1 ) THEN 5139 nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av), &5140 id_var_do2d(av,i), &4782 nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av), & 4783 id_var_do2d(av,i), & 5141 4784 NF90_COLLECTIVE ) 5142 4785 ELSE 5143 4786 ! 5144 !-- Test simulations showed that the output of cross sections 5145 !-- by all PEs in data_output_2d using NF90_COLLECTIVE is 5146 !-- faster than the output by the first row of PEs in 5147 !-- y-direction using NF90_INDEPENDENT. 5148 nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av), & 5149 id_var_do2d(av,i), & 4787 !-- Test simulations showed that the output of cross sections by all PEs in 4788 !-- data_output_2d using NF90_COLLECTIVE is faster than the output by the first 4789 !-- row of PEs in y-direction using NF90_INDEPENDENT. 4790 nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av), & 4791 id_var_do2d(av,i), & 5150 4792 NF90_COLLECTIVE ) 5151 ! nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av), &5152 ! id_var_do2d(av,i), &4793 ! nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av), & 4794 ! id_var_do2d(av,i), & 5153 4795 ! NF90_INDEPENDENT ) 5154 4796 ENDIF … … 5161 4803 5162 4804 ! 5163 !-- Update the title attribute on file 5164 !-- In order to avoid 'data mode' errors if updated attributes are larger 5165 !-- than their original size, NF90_PUT_ATT is called in 'define mode' 5166 !-- enclosed by NF90_REDEF and NF90_ENDDEF calls. This implies a possible 5167 !-- performance loss due to data copying; an alternative strategy would be 5168 !-- to ensure equal attribute size in a job chain. Maybe revise later. 4805 !-- Update the title attribute on file. 4806 !-- In order to avoid 'data mode' errors if updated attributes are larger than their original 4807 !-- size, NF90_PUT_ATT is called in 'define mode' enclosed by NF90_REDEF and NF90_ENDDEF 4808 !-- calls. This implies a possible performance loss due to data copying; an alternative 4809 !-- strategy would be to ensure equal attribute size in a job chain. Maybe revise later. 5169 4810 IF ( av == 0 ) THEN 5170 4811 time_average_text = ' ' 5171 4812 ELSE 5172 WRITE (time_average_text, '('', '',F7.1,'' s average'')') & 5173 averaging_interval 4813 WRITE ( time_average_text, '('', '',F7.1,'' s average'')' ) averaging_interval 5174 4814 ENDIF 5175 4815 nc_stat = NF90_REDEF( id_set_yz(av) ) 5176 4816 CALL netcdf_handle_error( 'netcdf_define_header', 435 ) 5177 nc_stat = NF90_PUT_ATT( id_set_yz(av), NF90_GLOBAL, 'title', & 5178 TRIM( run_description_header ) // & 5179 TRIM( time_average_text ) ) 4817 nc_stat = NF90_PUT_ATT( id_set_yz(av), NF90_GLOBAL, 'title', & 4818 TRIM( run_description_header ) // TRIM( time_average_text ) ) 5180 4819 CALL netcdf_handle_error( 'netcdf_define_header', 217 ) 5181 4820 nc_stat = NF90_ENDDEF( id_set_yz(av) ) 5182 4821 CALL netcdf_handle_error( 'netcdf_define_header', 436 ) 5183 message_string = 'netCDF file for cross-sections ' // &5184 TRIM( var ) // ' from previous run found.' // &4822 message_string = 'netCDF file for cross-sections ' // & 4823 TRIM( var ) // ' from previous run found.' // & 5185 4824 '&This file will be extended.' 5186 4825 CALL message( 'define_netcdf_header', 'PA0253', 0, 0, 0, 6, 0 ) … … 5193 4832 5194 4833 IF ( averaging_interval_pr /= 0.0_wp ) THEN 5195 CALL netcdf_create_global_atts( id_set_pr, 'podsprav', TRIM( run_description_header ), 451 ) 4834 CALL netcdf_create_global_atts( id_set_pr, 'podsprav', TRIM( run_description_header ),& 4835 451 ) 5196 4836 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval_pr 5197 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, 'time_avg', & 5198 TRIM( time_average_text ) ) 4837 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, 'time_avg', TRIM( time_average_text ) ) 5199 4838 ELSE 5200 CALL netcdf_create_global_atts( id_set_pr, 'podspr', TRIM( run_description_header ), 451 ) 4839 CALL netcdf_create_global_atts( id_set_pr, 'podspr', TRIM( run_description_header ), & 4840 451 ) 5201 4841 ENDIF 5202 4842 CALL netcdf_handle_error( 'netcdf_define_header', 219 ) 5203 4843 ! 5204 !-- Write number of columns and rows of coordinate systems to be plotted 5205 !-- on one page to thenetcdf header.4844 !-- Write number of columns and rows of coordinate systems to be plotted on one page to the 4845 !-- netcdf header. 5206 4846 !-- This information can be used by palmplot. 5207 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, &5208 'no_rows', &4847 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, & 4848 'no_rows', & 5209 4849 profile_rows ) 5210 4850 CALL netcdf_handle_error( 'netcdf_define_header', 519 ) 5211 4851 5212 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, &5213 'no_columns', &4852 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, & 4853 'no_columns', & 5214 4854 profile_columns ) 5215 4855 CALL netcdf_handle_error( 'netcdf_define_header', 520 ) … … 5221 4861 5222 4862 ! 5223 !-- Each profile defined in cross_profiles is written to an array 5224 !-- (cross_profiles_char). The number of the respective coordinate5225 !-- system is assigned in a second array(cross_profiles_numb).4863 !-- Each profile defined in cross_profiles is written to an array (cross_profiles_char). The 4864 !-- number of the respective coordinate system is assigned in a second array 4865 !-- (cross_profiles_numb). 5226 4866 k = 1 5227 4867 … … 5235 4875 IF ( delim == 1 ) EXIT 5236 4876 kk = MIN( crmax, k ) 5237 cross_profiles_char(kk) = cross_profiles_adj(i)(delim_old+1: & 5238 delim_old+delim-1) 4877 cross_profiles_char(kk) = cross_profiles_adj(i)(delim_old+1:delim_old+delim-1) 5239 4878 cross_profiles_numb(kk) = i 5240 4879 k = k + 1 … … 5247 4886 cross_profiles_count = MIN( crmax, k-1 ) 5248 4887 ! 5249 !-- Check if all profiles defined in cross_profiles are defined in 5250 !-- data_output_pr. If not,they will be skipped.4888 !-- Check if all profiles defined in cross_profiles are defined in data_output_pr. If not, 4889 !-- they will be skipped. 5251 4890 DO i = 1, cross_profiles_count 5252 4891 DO j = 1, dopr_n 5253 4892 5254 IF ( TRIM(cross_profiles_char(i)) == TRIM(data_output_pr(j)) ) & 5255 THEN 4893 IF ( TRIM( cross_profiles_char(i) ) == TRIM( data_output_pr(j) ) ) THEN 5256 4894 EXIT 5257 4895 ENDIF … … 5267 4905 IF ( cross_profiles_numb(i) == 999999 ) THEN 5268 4906 DO j = i + 1, crmax 5269 IF ( cross_profiles_numb(j) /= 999999 ) THEN4907 IF ( cross_profiles_numb(j) /= 999999 ) THEN 5270 4908 cross_profiles_char(i) = cross_profiles_char(j) 5271 4909 cross_profiles_numb(i) = cross_profiles_numb(j) … … 5284 4922 ENDDO 5285 4923 ! 5286 !-- Check if all profiles defined in data_output_pr are defined in 5287 !- - cross_profiles. If not,they will be added to cross_profiles.4924 !-- Check if all profiles defined in data_output_pr are defined in cross_profiles. If not, 4925 !- they will be added to cross_profiles. 5288 4926 DO i = 1, dopr_n 5289 4927 DO j = 1, cross_profiles_count 5290 4928 5291 IF ( TRIM(cross_profiles_char(j)) == TRIM(data_output_pr(i))) & 5292 THEN 4929 IF ( TRIM( cross_profiles_char(j) ) == TRIM( data_output_pr(i) ) ) THEN 5293 4930 EXIT 5294 4931 ENDIF 5295 4932 5296 IF ( ( j == cross_profiles_count ) .AND.&5297 ( cross_profiles_count <= crmax - 1))THEN4933 IF ( ( j == cross_profiles_count ) .AND. ( cross_profiles_count <= crmax - 1) ) & 4934 THEN 5298 4935 cross_profiles_count = cross_profiles_count + 1 5299 4936 cross_profiles_maxi = cross_profiles_maxi + 1 5300 cross_profiles_char(MIN( crmax, cross_profiles_count )) = & 5301 TRIM( data_output_pr(i) ) 5302 cross_profiles_numb(MIN( crmax, cross_profiles_count )) = & 5303 cross_profiles_maxi 4937 cross_profiles_char(MIN( crmax, cross_profiles_count )) = & 4938 TRIM( data_output_pr(i) ) 4939 cross_profiles_numb(MIN( crmax, cross_profiles_count )) = cross_profiles_maxi 5304 4940 ENDIF 5305 4941 … … 5308 4944 5309 4945 IF ( cross_profiles_count >= crmax ) THEN 5310 message_string = 'It is not allowed to arrange more than ' & 5311 // '100 profiles with & cross_profiles. Apart' & 5312 // ' from that, all profiles are saved & to ' & 5313 // 'the netCDF file.' 4946 message_string = 'It is not allowed to arrange more than ' // & 4947 '100 profiles with & cross_profiles. Apart' // & 4948 ' from that, all profiles are saved & to ' // 'the netCDF file.' 5314 4949 CALL message( 'define_netcdf_header', 'PA0354', 0, 0, 0, 6, 0 ) 5315 4950 ENDIF 5316 4951 5317 4952 ! 5318 !-- Writing cross_profiles to netcdf header. This information can be 5319 !-- used by palmplot. Each profile is separated by ",", each cross is 5320 !-- separated by ";". 4953 !-- Writing cross_profiles to netcdf header. This information can be used by palmplot. Each 4954 !-- profile is separated by ",", each cross is separated by ";". 5321 4955 char_cross_profiles = ';' 5322 4956 id_last = 1 … … 5327 4961 IF ( cross_profiles_numb(i) /= 999999 ) THEN 5328 4962 IF ( TRIM( char_cross_profiles ) == ';' ) THEN 5329 char_cross_profiles = TRIM( char_cross_profiles ) // &4963 char_cross_profiles = TRIM( char_cross_profiles ) // & 5330 4964 TRIM( cross_profiles_char(i) ) 5331 4965 ELSEIF ( id_last == cross_profiles_numb(i) ) THEN 5332 char_cross_profiles = TRIM( char_cross_profiles ) // &4966 char_cross_profiles = TRIM( char_cross_profiles ) // & 5333 4967 ',' // TRIM( cross_profiles_char(i) ) 5334 4968 ELSE 5335 char_cross_profiles = TRIM( char_cross_profiles ) // &4969 char_cross_profiles = TRIM( char_cross_profiles ) // & 5336 4970 ';' // TRIM( cross_profiles_char(i) ) 5337 4971 ENDIF … … 5343 4977 char_cross_profiles = TRIM( char_cross_profiles ) // ';' 5344 4978 5345 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, 'cross_profiles', &4979 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, 'cross_profiles', & 5346 4980 TRIM( char_cross_profiles ) ) 5347 4981 CALL netcdf_handle_error( 'netcdf_define_header', 521 ) … … 5349 4983 ! 5350 4984 !-- Define time coordinate for profiles (unlimited dimension) 5351 CALL netcdf_create_dim( id_set_pr, 'time', NF90_UNLIMITED, & 5352 id_dim_time_pr, 220 ) 5353 CALL netcdf_create_var( id_set_pr, (/ id_dim_time_pr /), 'time', & 5354 NF90_DOUBLE, id_var_time_pr, 'seconds', 'time', & 5355 221, 222, 000 ) 4985 CALL netcdf_create_dim( id_set_pr, 'time', NF90_UNLIMITED, id_dim_time_pr, 220 ) 4986 CALL netcdf_create_var( id_set_pr, (/ id_dim_time_pr /), 'time', NF90_DOUBLE, & 4987 id_var_time_pr, 'seconds', 'time', 221, 222, 000 ) 5356 4988 CALL netcdf_create_att( id_set_pr, id_var_time_pr, 'standard_name', 'time', 000) 5357 4989 CALL netcdf_create_att( id_set_pr, id_var_time_pr, 'axis', 'T', 000) … … 5365 4997 ! 5366 4998 !-- Define the z-axes (each variable gets its own z-axis) 5367 CALL netcdf_create_dim( id_set_pr, & 5368 'z' // TRIM( data_output_pr(i) ), & 5369 nzt+2-nzb, id_dim_z_pr(i,0), 223 ) 5370 CALL netcdf_create_var( id_set_pr, (/ id_dim_z_pr(i,0) /), & 5371 'z' // TRIM( data_output_pr(i) ), & 5372 NF90_DOUBLE, id_var_z_pr(i,0), & 4999 CALL netcdf_create_dim( id_set_pr, 'z' // TRIM( data_output_pr(i) ), nzt+2-nzb, & 5000 id_dim_z_pr(i,0), 223 ) 5001 CALL netcdf_create_var( id_set_pr, (/ id_dim_z_pr(i,0) /), 'z' // & 5002 TRIM( data_output_pr(i) ), NF90_DOUBLE, id_var_z_pr(i,0), & 5373 5003 'meters', '', 224, 225, 000 ) 5374 CALL netcdf_create_att( id_set_pr, id_var_z_pr(i,0), 'axis', & 5375 'Z', 000) 5004 CALL netcdf_create_att( id_set_pr, id_var_z_pr(i,0), 'axis', 'Z', 000) 5376 5005 ! 5377 5006 !-- Define the variable 5378 CALL netcdf_create_var( id_set_pr, (/ id_dim_z_pr(i,0), & 5379 id_dim_time_pr /), data_output_pr(i), & 5380 nc_precision(5), id_var_dopr(i,0), & 5381 TRIM( dopr_unit(i) ), & 5382 TRIM( data_output_pr(i) ), 226, 227, & 5007 CALL netcdf_create_var( id_set_pr, (/ id_dim_z_pr(i,0), id_dim_time_pr /), & 5008 data_output_pr(i), nc_precision(5), id_var_dopr(i,0), & 5009 TRIM( dopr_unit(i) ), TRIM( data_output_pr(i) ), 226, 227, & 5383 5010 228 ) 5384 5011 … … 5387 5014 ELSE 5388 5015 ! 5389 !-- If statistic regions are defined, add suffix _SR+#SR to the 5390 !-- names 5016 !-- If statistic regions are defined, add suffix _SR+#SR to the names. 5391 5017 DO j = 0, statistic_regions 5392 5018 WRITE ( suffix, '(''_'',I2.2)' ) j … … 5394 5020 ! 5395 5021 !-- Define the z-axes (each variable gets it own z-axis) 5396 CALL netcdf_create_dim( id_set_pr, 'z' // & 5397 TRIM(data_output_pr(i)) // suffix, & 5022 CALL netcdf_create_dim( id_set_pr, 'z' // TRIM(data_output_pr(i)) // suffix, & 5398 5023 nzt+2-nzb, id_dim_z_pr(i,j), 229 ) 5399 CALL netcdf_create_var( id_set_pr, (/ id_dim_z_pr(i,j) /), & 5400 'z' // TRIM(data_output_pr(i)) // & 5401 suffix, NF90_DOUBLE, & 5402 id_var_z_pr(i,j), 'meters', '', & 5403 230, 231, 000 ) 5404 CALL netcdf_create_att( id_set_pr, id_var_z_pr(i,j), 'axis',& 5405 'Z', 000) 5024 CALL netcdf_create_var( id_set_pr, (/ id_dim_z_pr(i,j) /),'z' // & 5025 TRIM(data_output_pr(i)) // suffix, NF90_DOUBLE, & 5026 id_var_z_pr(i,j), 'meters', '', 230, 231, 000 ) 5027 CALL netcdf_create_att( id_set_pr, id_var_z_pr(i,j), 'axis', 'Z', 000) 5406 5028 ! 5407 5029 !-- Define the variable 5408 CALL netcdf_create_var( id_set_pr, (/ id_dim_z_pr(i,j), & 5409 id_dim_time_pr /), & 5410 TRIM(data_output_pr(i)) // suffix, & 5411 nc_precision(5), id_var_dopr(i,j), & 5412 TRIM( dopr_unit(i) ), & 5413 TRIM( data_output_pr(i) ) // & 5414 ' SR ', 232, 233, 234 ) 5415 5416 var_list = TRIM( var_list ) // TRIM( data_output_pr(i) ) // & 5417 suffix // ';' 5030 CALL netcdf_create_var( id_set_pr, (/ id_dim_z_pr(i,j), id_dim_time_pr /), & 5031 TRIM(data_output_pr(i)) // suffix, nc_precision(5), & 5032 id_var_dopr(i,j), TRIM( dopr_unit(i) ), & 5033 TRIM( data_output_pr(i) ) // ' SR ', 232, 233, 234 ) 5034 5035 var_list = TRIM( var_list ) // TRIM( data_output_pr(i) ) // suffix // ';' 5418 5036 5419 5037 ENDDO … … 5424 5042 5425 5043 ! 5426 !-- Write the list of variables as global attribute (this is used by 5427 !-- restart runs) 5044 !-- Write the list of variables as global attribute (this is used by restart runs). 5428 5045 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, 'VAR_LIST', var_list ) 5429 5046 CALL netcdf_handle_error( 'netcdf_define_header', 235 ) … … 5433 5050 DO i = 1, dopr_norm_num 5434 5051 5435 CALL netcdf_create_var( id_set_pr, (/ id_dim_time_pr /), & 5436 'NORM_' // TRIM( dopr_norm_names(i) ), & 5437 nc_precision(5), id_var_norm_dopr(i), & 5438 '', TRIM( dopr_norm_longnames(i) ), 236, & 5052 CALL netcdf_create_var( id_set_pr, (/ id_dim_time_pr /), 'NORM_' // & 5053 TRIM( dopr_norm_names(i) ), nc_precision(5), & 5054 id_var_norm_dopr(i), '', TRIM( dopr_norm_longnames(i) ), 236, & 5439 5055 000, 237 ) 5440 5056 … … 5451 5067 DO j = 0, statistic_regions 5452 5068 5453 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_z_pr(i,j), &5454 hom(nzb:nzt+1,2,dopr_index(i),0), &5455 start = (/ 1 /), &5069 nc_stat = NF90_PUT_VAR( id_set_pr, id_var_z_pr(i,j), & 5070 hom(nzb:nzt+1,2,dopr_index(i),0), & 5071 start = (/ 1 /), & 5456 5072 count = (/ nzt-nzb+2 /) ) 5457 5073 CALL netcdf_handle_error( 'netcdf_define_header', 239 ) … … 5465 5081 ! 5466 5082 !-- Get the list of variables and compare with the actual run. 5467 !-- First var_list_old has to be reset, since GET_ATT does not assign 5468 !-- trailing blanks. 5083 !-- First var_list_old has to be reset, since GET_ATT does not assign trailing blanks. 5469 5084 var_list_old = ' ' 5470 nc_stat = NF90_GET_ATT( id_set_pr, NF90_GLOBAL, 'VAR_LIST', & 5471 var_list_old ) 5085 nc_stat = NF90_GET_ATT( id_set_pr, NF90_GLOBAL, 'VAR_LIST', var_list_old ) 5472 5086 CALL netcdf_handle_error( 'netcdf_define_header', 240 ) 5473 5087 … … 5480 5094 DO j = 0, statistic_regions 5481 5095 WRITE ( suffix, '(''_'',I2.2)' ) j 5482 var_list = TRIM( var_list ) // TRIM( data_output_pr(i) ) // & 5483 suffix // ';' 5096 var_list = TRIM( var_list ) // TRIM( data_output_pr(i) ) // suffix // ';' 5484 5097 ENDDO 5485 5098 ENDIF … … 5488 5101 5489 5102 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 5490 message_string = 'netCDF file for vertical profiles ' // & 5491 'from previous run found,' // & 5492 '&but this file cannot be extended due to' // & 5493 ' variable mismatch.' // & 5494 '&New file is created instead.' 5103 message_string = 'netCDF file for vertical profiles ' // 'from previous run found,' //& 5104 '&but this file cannot be extended due to' // & 5105 ' variable mismatch.' // '&New file is created instead.' 5495 5106 CALL message( 'define_netcdf_header', 'PA0254', 0, 1, 0, 6, 0 ) 5496 5107 extend = .FALSE. … … 5499 5110 5500 5111 ! 5501 !-- Get the id of the time coordinate (unlimited coordinate) and its 5502 !-- last index on the file. The next time level is dopr..count+1. 5503 !-- The current time must be larger than the last output time 5504 !-- on the file. 5112 !-- Get the id of the time coordinate (unlimited coordinate) and its last index on the file. 5113 !-- The next time level is dopr..count+1. 5114 !-- The current time must be larger than the last output time on the file. 5505 5115 nc_stat = NF90_INQ_VARID( id_set_pr, 'time', id_var_time_pr ) 5506 5116 CALL netcdf_handle_error( 'netcdf_define_header', 241 ) 5507 5117 5508 nc_stat = NF90_INQUIRE_VARIABLE( id_set_pr, id_var_time_pr, & 5509 dimids = id_dim_time_old ) 5118 nc_stat = NF90_INQUIRE_VARIABLE( id_set_pr, id_var_time_pr, dimids = id_dim_time_old ) 5510 5119 CALL netcdf_handle_error( 'netcdf_define_header', 242 ) 5511 5120 id_dim_time_pr = id_dim_time_old(1) 5512 5121 5513 nc_stat = NF90_INQUIRE_DIMENSION( id_set_pr, id_dim_time_pr, & 5514 len = dopr_time_count ) 5122 nc_stat = NF90_INQUIRE_DIMENSION( id_set_pr, id_dim_time_pr, LEN = dopr_time_count ) 5515 5123 CALL netcdf_handle_error( 'netcdf_define_header', 243 ) 5516 5124 5517 nc_stat = NF90_GET_VAR( id_set_pr, id_var_time_pr, &5518 last_time_coordinate, &5519 start = (/ dopr_time_count /), &5125 nc_stat = NF90_GET_VAR( id_set_pr, id_var_time_pr, & 5126 last_time_coordinate, & 5127 start = (/ dopr_time_count /), & 5520 5128 count = (/ 1 /) ) 5521 5129 CALL netcdf_handle_error( 'netcdf_define_header', 244 ) 5522 5130 5523 5131 IF ( last_time_coordinate(1) >= simulated_time ) THEN 5524 message_string = 'netCDF file for vertical profiles ' // & 5525 'from previous run found,' // & 5526 '&but this file cannot be extended becaus' // & 5527 'e the current output time' // & 5528 '&is less or equal than the last output t' // & 5529 'ime on this file.' // & 5132 message_string = 'netCDF file for vertical profiles ' // 'from previous run found,' //& 5133 '&but this file cannot be extended because' // & 5134 ' the current output time' // & 5135 '&is less or equal than the last output ' // 'time on this file.' // & 5530 5136 '&New file is created instead.' 5531 5137 CALL message( 'define_netcdf_header', 'PA0255', 0, 1, 0, 6, 0 ) … … 5542 5148 5543 5149 IF ( statistic_regions == 0 ) THEN 5544 nc_stat = NF90_INQ_VARID( id_set_pr, data_output_pr(i), & 5545 id_var_dopr(i,0) ) 5150 nc_stat = NF90_INQ_VARID( id_set_pr, data_output_pr(i), id_var_dopr(i,0) ) 5546 5151 CALL netcdf_handle_error( 'netcdf_define_header', 245 ) 5547 5152 ELSE … … 5549 5154 WRITE ( suffix, '(''_'',I2.2)' ) j 5550 5155 netcdf_var_name = TRIM( data_output_pr(i) ) // suffix 5551 nc_stat = NF90_INQ_VARID( id_set_pr, netcdf_var_name, & 5552 id_var_dopr(i,j) ) 5156 nc_stat = NF90_INQ_VARID( id_set_pr, netcdf_var_name, id_var_dopr(i,j) ) 5553 5157 CALL netcdf_handle_error( 'netcdf_define_header', 246 ) 5554 5158 ENDDO … … 5560 5164 !-- Get ids of the normalization variables 5561 5165 DO i = 1, dopr_norm_num 5562 nc_stat = NF90_INQ_VARID( id_set_pr, & 5563 'NORM_' // TRIM( dopr_norm_names(i) ), & 5166 nc_stat = NF90_INQ_VARID( id_set_pr, 'NORM_' // TRIM( dopr_norm_names(i) ), & 5564 5167 id_var_norm_dopr(i) ) 5565 5168 CALL netcdf_handle_error( 'netcdf_define_header', 247 ) … … 5567 5170 5568 5171 ! 5569 !-- Update the title attribute on file 5570 !-- In order to avoid 'data mode' errors if updated attributes are larger 5571 !-- than their original size, NF90_PUT_ATT is called in 'define mode' 5572 !-- enclosed by NF90_REDEF and NF90_ENDDEF calls. This implies a possible 5573 !-- performance loss due to data copying; an alternative strategy would be 5574 !-- to ensure equal attribute size in a job chain. Maybe revise later. 5172 !-- Update the title attribute on file. 5173 !-- In order to avoid 'data mode' errors if updated attributes are larger than their original 5174 !-- size, NF90_PUT_ATT is called in 'define mode' enclosed by NF90_REDEF and NF90_ENDDEF 5175 !-- calls. This implies a possible performance loss due to data copying; an alternative 5176 !-- strategy would be to ensure equal attribute size in a job chain. Maybe revise later. 5575 5177 IF ( averaging_interval_pr == 0.0_wp ) THEN 5576 5178 time_average_text = ' ' 5577 5179 ELSE 5578 WRITE (time_average_text, '('', '',F7.1,'' s average'')') & 5579 averaging_interval_pr 5180 WRITE ( time_average_text, '('', '',F7.1,'' s average'')' ) averaging_interval_pr 5580 5181 ENDIF 5581 5182 nc_stat = NF90_REDEF( id_set_pr ) 5582 5183 CALL netcdf_handle_error( 'netcdf_define_header', 437 ) 5583 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, 'title', & 5584 TRIM( run_description_header ) // & 5585 TRIM( time_average_text ) ) 5184 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, 'title', & 5185 TRIM( run_description_header ) // TRIM( time_average_text ) ) 5586 5186 CALL netcdf_handle_error( 'netcdf_define_header', 248 ) 5587 5187 5588 5188 nc_stat = NF90_ENDDEF( id_set_pr ) 5589 5189 CALL netcdf_handle_error( 'netcdf_define_header', 438 ) 5590 message_string = 'netCDF file for vertical profiles ' // & 5591 'from previous run found.' // & 5190 message_string = 'netCDF file for vertical profiles ' // 'from previous run found.' // & 5592 5191 '&This file will be extended.' 5593 5192 CALL message( 'define_netcdf_header', 'PA0256', 0, 0, 0, 6, 0 ) … … 5600 5199 CALL netcdf_create_global_atts( id_set_ts, 'podsts', TRIM(run_description_header), 329 ) 5601 5200 5602 ! nc_stat = NF90_PUT_ATT( id_set_ts, NF90_GLOBAL, 'title', & 5603 ! TRIM( run_description_header ) ) 5201 ! nc_stat = NF90_PUT_ATT( id_set_ts, NF90_GLOBAL, 'title', TRIM( run_description_header ) ) 5604 5202 ! CALL netcdf_handle_error( 'netcdf_define_header', 249 ) 5605 5203 5606 5204 ! 5607 5205 !-- Define time coordinate for time series (unlimited dimension) 5608 CALL netcdf_create_dim( id_set_ts, 'time', NF90_UNLIMITED, & 5609 id_dim_time_ts, 250 ) 5610 CALL netcdf_create_var( id_set_ts, (/ id_dim_time_ts /), 'time', & 5611 NF90_DOUBLE, id_var_time_ts, 'seconds', 'time', & 5612 251, 252, 000 ) 5206 CALL netcdf_create_dim( id_set_ts, 'time', NF90_UNLIMITED, id_dim_time_ts, 250 ) 5207 CALL netcdf_create_var( id_set_ts, (/ id_dim_time_ts /), 'time', NF90_DOUBLE, & 5208 id_var_time_ts, 'seconds', 'time', 251, 252, 000 ) 5613 5209 CALL netcdf_create_att( id_set_ts, id_var_time_ts, 'standard_name', 'time', 000) 5614 5210 CALL netcdf_create_att( id_set_ts, id_var_time_ts, 'axis', 'T', 000) … … 5620 5216 IF ( statistic_regions == 0 ) THEN 5621 5217 5622 CALL netcdf_create_var( id_set_ts, (/ id_dim_time_ts /), & 5623 dots_label(i), nc_precision(6), & 5624 id_var_dots(i,0), & 5625 TRIM( dots_unit(i) ), & 5218 CALL netcdf_create_var( id_set_ts, (/ id_dim_time_ts /), dots_label(i), & 5219 nc_precision(6), id_var_dots(i,0), TRIM( dots_unit(i) ), & 5626 5220 TRIM( dots_label(i) ), 253, 254, 255 ) 5627 5221 … … 5630 5224 ELSE 5631 5225 ! 5632 !-- If statistic regions are defined, add suffix _SR+#SR to the 5633 !-- names 5226 !-- If statistic regions are defined, add suffix _SR+#SR to the names. 5634 5227 DO j = 0, statistic_regions 5635 5228 WRITE ( suffix, '(''_'',I2.2)' ) j 5636 5229 5637 CALL netcdf_create_var( id_set_ts, (/ id_dim_time_ts /), & 5638 TRIM( dots_label(i) ) // suffix, & 5639 nc_precision(6), id_var_dots(i,j), & 5640 TRIM( dots_unit(i) ), & 5641 TRIM( dots_label(i) ) // ' SR ' // & 5230 CALL netcdf_create_var( id_set_ts, (/ id_dim_time_ts /), TRIM( dots_label(i) ) & 5231 // suffix, nc_precision(6), id_var_dots(i,j), & 5232 TRIM( dots_unit(i) ), TRIM( dots_label(i) ) // ' SR ' //& 5642 5233 suffix(2:2), 256, 257, 347) 5643 5234 … … 5652 5243 5653 5244 ! 5654 !-- Write the list of variables as global attribute (this is used by 5655 !-- restart runs) 5245 !-- Write the list of variables as global attribute (this is used by restart runs). 5656 5246 nc_stat = NF90_PUT_ATT( id_set_ts, NF90_GLOBAL, 'VAR_LIST', var_list ) 5657 5247 CALL netcdf_handle_error( 'netcdf_define_header', 258 ) … … 5667 5257 ! 5668 5258 !-- Get the list of variables and compare with the actual run. 5669 !-- First var_list_old has to be reset, since GET_ATT does not assign 5670 !-- trailing blanks. 5259 !-- First var_list_old has to be reset, since GET_ATT does not assign trailing blanks. 5671 5260 var_list_old = ' ' 5672 nc_stat = NF90_GET_ATT( id_set_ts, NF90_GLOBAL, 'VAR_LIST', & 5673 var_list_old ) 5261 nc_stat = NF90_GET_ATT( id_set_ts, NF90_GLOBAL, 'VAR_LIST', var_list_old ) 5674 5262 CALL netcdf_handle_error( 'netcdf_define_header', 260 ) 5675 5263 … … 5683 5271 DO j = 0, statistic_regions 5684 5272 WRITE ( suffix, '(''_'',I2.2)' ) j 5685 var_list = TRIM( var_list ) // TRIM( dots_label(i) ) // & 5686 suffix // ';' 5273 var_list = TRIM( var_list ) // TRIM( dots_label(i) ) // suffix // ';' 5687 5274 ENDDO 5688 5275 ENDIF … … 5691 5278 5692 5279 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 5693 message_string = 'netCDF file for time series ' // & 5694 'from previous run found,' // & 5695 '&but this file cannot be extended due to' // & 5696 ' variable mismatch.' // & 5697 '&New file is created instead.' 5280 message_string = 'netCDF file for time series ' // 'from previous run found,' // & 5281 '&but this file cannot be extended due to' // & 5282 ' variable mismatch.' // '&New file is created instead.' 5698 5283 CALL message( 'define_netcdf_header', 'PA0257', 0, 1, 0, 6, 0 ) 5699 5284 extend = .FALSE. … … 5702 5287 5703 5288 ! 5704 !-- Get the id of the time coordinate (unlimited coordinate) and its 5705 !-- last index on the file. The next time level is dots..count+1. 5706 !-- The current time must be larger than the last output time 5707 !-- on the file. 5289 !-- Get the id of the time coordinate (unlimited coordinate) and its last index on the file. 5290 !-- The next time level is dots..count+1. 5291 !-- The current time must be larger than the last output time on the file. 5708 5292 nc_stat = NF90_INQ_VARID( id_set_ts, 'time', id_var_time_ts ) 5709 5293 CALL netcdf_handle_error( 'netcdf_define_header', 261 ) 5710 5294 5711 nc_stat = NF90_INQUIRE_VARIABLE( id_set_ts, id_var_time_ts, & 5712 dimids = id_dim_time_old ) 5295 nc_stat = NF90_INQUIRE_VARIABLE( id_set_ts, id_var_time_ts, dimids = id_dim_time_old ) 5713 5296 CALL netcdf_handle_error( 'netcdf_define_header', 262 ) 5714 5297 id_dim_time_ts = id_dim_time_old(1) 5715 5298 5716 nc_stat = NF90_INQUIRE_DIMENSION( id_set_ts, id_dim_time_ts, & 5717 len = dots_time_count ) 5299 nc_stat = NF90_INQUIRE_DIMENSION( id_set_ts, id_dim_time_ts, LEN = dots_time_count ) 5718 5300 CALL netcdf_handle_error( 'netcdf_define_header', 263 ) 5719 5301 5720 nc_stat = NF90_GET_VAR( id_set_ts, id_var_time_ts, &5721 last_time_coordinate, &5722 start = (/ dots_time_count /), &5302 nc_stat = NF90_GET_VAR( id_set_ts, id_var_time_ts, & 5303 last_time_coordinate, & 5304 start = (/ dots_time_count /), & 5723 5305 count = (/ 1 /) ) 5724 5306 CALL netcdf_handle_error( 'netcdf_define_header', 264 ) 5725 5307 5726 5308 IF ( last_time_coordinate(1) >= simulated_time ) THEN 5727 message_string = 'netCDF file for time series ' // & 5728 'from previous run found,' // & 5729 '&but this file cannot be extended becaus' // & 5730 'e the current output time' // & 5731 '&is less or equal than the last output t' // & 5732 'ime on this file.' // & 5309 message_string = 'netCDF file for time series ' // 'from previous run found,' // & 5310 '&but this file cannot be extended because' // & 5311 ' the current output time' // & 5312 '&is less or equal than the last output ' // 'time on this file.' // & 5733 5313 '&New file is created instead.' 5734 5314 CALL message( 'define_netcdf_header', 'PA0258', 0, 1, 0, 6, 0 ) … … 5745 5325 5746 5326 IF ( statistic_regions == 0 ) THEN 5747 nc_stat = NF90_INQ_VARID( id_set_ts, dots_label(i), & 5748 id_var_dots(i,0) ) 5327 nc_stat = NF90_INQ_VARID( id_set_ts, dots_label(i), id_var_dots(i,0) ) 5749 5328 CALL netcdf_handle_error( 'netcdf_define_header', 265 ) 5750 5329 ELSE … … 5752 5331 WRITE ( suffix, '(''_'',I2.2)' ) j 5753 5332 netcdf_var_name = TRIM( dots_label(i) ) // suffix 5754 nc_stat = NF90_INQ_VARID( id_set_ts, netcdf_var_name, & 5755 id_var_dots(i,j) ) 5333 nc_stat = NF90_INQ_VARID( id_set_ts, netcdf_var_name, id_var_dots(i,j) ) 5756 5334 CALL netcdf_handle_error( 'netcdf_define_header', 266 ) 5757 5335 ENDDO … … 5761 5339 5762 5340 ! 5763 !-- Update the title attribute on file 5764 !-- In order to avoid 'data mode' errors if updated attributes are larger 5765 !-- than their original size, NF90_PUT_ATT is called in 'define mode' 5766 !-- enclosed by NF90_REDEF and NF90_ENDDEF calls. This implies a possible 5767 !-- performance loss due to data copying; an alternative strategy would be 5768 !-- to ensure equal attribute size in a job chain. Maybe revise later. 5341 !-- Update the title attribute on file. 5342 !-- In order to avoid 'data mode' errors if updated attributes are larger than their original 5343 !-- size, NF90_PUT_ATT is called in 'define mode' enclosed by NF90_REDEF and NF90_ENDDEF 5344 !-- calls. This implies a possible performance loss due to data copying; an alternative 5345 !-- strategy would be to ensure equal attribute size in a job chain. Maybe revise later. 5769 5346 nc_stat = NF90_REDEF( id_set_ts ) 5770 5347 CALL netcdf_handle_error( 'netcdf_define_header', 439 ) 5771 nc_stat = NF90_PUT_ATT( id_set_ts, NF90_GLOBAL, 'title', & 5772 TRIM( run_description_header ) ) 5348 nc_stat = NF90_PUT_ATT( id_set_ts, NF90_GLOBAL, 'title', TRIM( run_description_header ) ) 5773 5349 CALL netcdf_handle_error( 'netcdf_define_header', 267 ) 5774 5350 nc_stat = NF90_ENDDEF( id_set_ts ) 5775 5351 CALL netcdf_handle_error( 'netcdf_define_header', 440 ) 5776 message_string = 'netCDF file for time series ' // & 5777 'from previous run found.' // & 5352 message_string = 'netCDF file for time series ' // 'from previous run found.' // & 5778 5353 '&This file will be extended.' 5779 5354 CALL message( 'define_netcdf_header', 'PA0259', 0, 0, 0, 6, 0 ) … … 5785 5360 !-- Define some global attributes of the dataset 5786 5361 IF ( averaging_interval_sp /= 0.0_wp ) THEN 5787 WRITE (time_average_text,'('', '',F7.1,'' s average'')') & 5788 averaging_interval_sp 5789 nc_stat = NF90_PUT_ATT( id_set_sp, NF90_GLOBAL, 'title', & 5790 TRIM( run_description_header ) // & 5791 TRIM( time_average_text ) ) 5362 WRITE ( time_average_text,'('', '',F7.1,'' s average'')' ) averaging_interval_sp 5363 nc_stat = NF90_PUT_ATT( id_set_sp, NF90_GLOBAL, 'title', & 5364 TRIM( run_description_header ) // TRIM( time_average_text ) ) 5792 5365 CALL netcdf_handle_error( 'netcdf_define_header', 268 ) 5793 5366 5794 5367 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval_sp 5795 nc_stat = NF90_PUT_ATT( id_set_sp, NF90_GLOBAL, 'time_avg', & 5796 TRIM( time_average_text ) ) 5368 nc_stat = NF90_PUT_ATT( id_set_sp, NF90_GLOBAL, 'time_avg', TRIM( time_average_text ) ) 5797 5369 ELSE 5798 nc_stat = NF90_PUT_ATT( id_set_sp, NF90_GLOBAL, 'title', &5370 nc_stat = NF90_PUT_ATT( id_set_sp, NF90_GLOBAL, 'title', & 5799 5371 TRIM( run_description_header ) ) 5800 5372 ENDIF … … 5803 5375 ! 5804 5376 !-- Define time coordinate for spectra (unlimited dimension) 5805 CALL netcdf_create_dim( id_set_sp, 'time', NF90_UNLIMITED, & 5806 id_dim_time_sp, 270 ) 5807 CALL netcdf_create_var( id_set_sp, (/ id_dim_time_sp /), 'time', & 5808 NF90_DOUBLE, id_var_time_sp, 'seconds', 'time', & 5809 271, 272, 000 ) 5377 CALL netcdf_create_dim( id_set_sp, 'time', NF90_UNLIMITED, id_dim_time_sp, 270 ) 5378 CALL netcdf_create_var( id_set_sp, (/ id_dim_time_sp /), 'time', NF90_DOUBLE, & 5379 id_var_time_sp, 'seconds', 'time', 271, 272, 000 ) 5810 5380 CALL netcdf_create_att( id_set_sp, id_var_time_sp, 'standard_name', 'time', 000) 5811 5381 CALL netcdf_create_att( id_set_sp, id_var_time_sp, 'axis', 'T', 000) 5812 5382 ! 5813 5383 !-- Define the spatial dimensions and coordinates for spectra. 5814 !-- First, determine the number of vertical levels for which spectra 5815 !-- are to be output. 5384 !-- First, determine the number of vertical levels for which spectra are to be output. 5816 5385 ns = 1 5817 5386 DO WHILE ( comp_spectra_level(ns) /= 999999 .AND. ns <= 100 ) … … 5823 5392 !-- Define vertical coordinate grid (zu grid) 5824 5393 CALL netcdf_create_dim( id_set_sp, 'zu_sp', ns, id_dim_zu_sp, 273 ) 5825 CALL netcdf_create_var( id_set_sp, (/ id_dim_zu_sp /), 'zu_sp', & 5826 NF90_DOUBLE, id_var_zu_sp, 'meters', '', & 5827 274, 275, 000 ) 5394 CALL netcdf_create_var( id_set_sp, (/ id_dim_zu_sp /), 'zu_sp', NF90_DOUBLE, & 5395 id_var_zu_sp, 'meters', '', 274, 275, 000 ) 5828 5396 CALL netcdf_create_att( id_set_sp, id_var_zu_sp, 'axis', 'Z', 000) 5829 5397 ! 5830 5398 !-- Define vertical coordinate grid (zw grid) 5831 5399 CALL netcdf_create_dim( id_set_sp, 'zw_sp', ns, id_dim_zw_sp, 276 ) 5832 CALL netcdf_create_var( id_set_sp, (/ id_dim_zw_sp /), 'zw_sp', & 5833 NF90_DOUBLE, id_var_zw_sp, 'meters', '', & 5834 277, 278, 000 ) 5400 CALL netcdf_create_var( id_set_sp, (/ id_dim_zw_sp /), 'zw_sp', NF90_DOUBLE, & 5401 id_var_zw_sp, 'meters', '', 277, 278, 000 ) 5835 5402 CALL netcdf_create_att( id_set_sp, id_var_zw_sp, 'axis', 'Z', 000) 5836 5403 ! 5837 5404 !-- Define x-axis 5838 5405 CALL netcdf_create_dim( id_set_sp, 'k_x', nx/2, id_dim_x_sp, 279 ) 5839 CALL netcdf_create_var( id_set_sp, (/ id_dim_x_sp /), 'k_x', & 5840 NF90_DOUBLE, id_var_x_sp, 'm-1', '', 280, & 5841 281, 000 ) 5406 CALL netcdf_create_var( id_set_sp, (/ id_dim_x_sp /), 'k_x', NF90_DOUBLE, & 5407 id_var_x_sp, 'm-1', '', 280, 281, 000 ) 5842 5408 CALL netcdf_create_att( id_set_sp, id_var_x_sp, 'axis', 'X', 000) 5843 5409 ! 5844 5410 !-- Define y-axis 5845 5411 CALL netcdf_create_dim( id_set_sp, 'k_y', ny/2, id_dim_y_sp, 282 ) 5846 CALL netcdf_create_var( id_set_sp, (/ id_dim_y_sp /), 'k_y', & 5847 NF90_DOUBLE, id_var_y_sp, 'm-1', '', 283, & 5848 284, 000 ) 5412 CALL netcdf_create_var( id_set_sp, (/ id_dim_y_sp /), 'k_y', NF90_DOUBLE, & 5413 id_var_y_sp, 'm-1', '', 283, 284, 000 ) 5849 5414 CALL netcdf_create_att( id_set_sp, id_var_y_sp, 'axis', 'Y', 000) 5850 5415 ! … … 5873 5438 CASE DEFAULT 5874 5439 ! 5875 !-- Check for user-defined quantities (found, grid_x and grid_y 5876 !-- are dummies) 5440 !-- Check for user-defined quantities (found, grid_x and grid_y are dummies). 5877 5441 IF ( user_module_enabled ) THEN 5878 CALL user_define_netcdf_grid( data_output_sp(i), found, &5879 grid_ x, grid_y, grid_z )5442 CALL user_define_netcdf_grid( data_output_sp(i), found, grid_x, grid_y, & 5443 grid_z ) 5880 5444 ENDIF 5881 5445 … … 5888 5452 netcdf_var_name = TRIM( data_output_sp(i) ) // '_x' 5889 5453 IF ( TRIM( grid_z ) == 'zw' ) THEN 5890 CALL netcdf_create_var( id_set_sp, (/ id_dim_x_sp, & 5891 id_dim_zw_sp, id_dim_time_sp /), & 5892 netcdf_var_name, nc_precision(7), & 5893 id_var_dospx(i), 'unknown', & 5894 netcdf_var_name, 285, 286, 287 ) 5454 CALL netcdf_create_var( id_set_sp, (/ id_dim_x_sp, id_dim_zw_sp, & 5455 id_dim_time_sp /), netcdf_var_name, nc_precision(7), & 5456 id_var_dospx(i), 'unknown', netcdf_var_name, 285, 286, & 5457 287 ) 5895 5458 ELSE 5896 CALL netcdf_create_var( id_set_sp, (/ id_dim_x_sp, & 5897 id_dim_zu_sp, id_dim_time_sp /), & 5898 netcdf_var_name, nc_precision(7), & 5899 id_var_dospx(i), 'unknown', & 5900 netcdf_var_name, 285, 286, 287 ) 5459 CALL netcdf_create_var( id_set_sp, (/ id_dim_x_sp, id_dim_zu_sp, & 5460 id_dim_time_sp /), netcdf_var_name, nc_precision(7), & 5461 id_var_dospx(i), 'unknown', netcdf_var_name, 285, 286, & 5462 287 ) 5901 5463 ENDIF 5902 5464 … … 5911 5473 netcdf_var_name = TRIM( data_output_sp(i) ) // '_y' 5912 5474 IF ( TRIM( grid_z ) == 'zw' ) THEN 5913 CALL netcdf_create_var( id_set_sp, (/ id_dim_y_sp, & 5914 id_dim_zw_sp, id_dim_time_sp /), & 5915 netcdf_var_name, nc_precision(7), & 5916 id_var_dospy(i), 'unknown', & 5917 netcdf_var_name, 288, 289, 290 ) 5475 CALL netcdf_create_var( id_set_sp, (/ id_dim_y_sp, id_dim_zw_sp, & 5476 id_dim_time_sp /), netcdf_var_name, nc_precision(7), & 5477 id_var_dospy(i), 'unknown', netcdf_var_name, 288, 289, & 5478 290 ) 5918 5479 ELSE 5919 CALL netcdf_create_var( id_set_sp, (/ id_dim_y_sp, & 5920 id_dim_zu_sp, id_dim_time_sp /), & 5921 netcdf_var_name, nc_precision(7), & 5922 id_var_dospy(i), 'unknown', & 5923 netcdf_var_name, 288, 289, 290 ) 5480 CALL netcdf_create_var( id_set_sp, (/ id_dim_y_sp, id_dim_zu_sp, & 5481 id_dim_time_sp /), netcdf_var_name, nc_precision(7), & 5482 id_var_dospy(i), 'unknown', netcdf_var_name, 288, 289, & 5483 290 ) 5924 5484 ENDIF 5925 5485 … … 5933 5493 5934 5494 ! 5935 !-- Write the list of variables as global attribute (this is used by 5936 !-- restart runs) 5495 !-- Write the list of variables as global attribute (this is used by restart runs) 5937 5496 nc_stat = NF90_PUT_ATT( id_set_sp, NF90_GLOBAL, 'VAR_LIST', var_list ) 5938 5497 CALL netcdf_handle_error( 'netcdf_define_header', 291 ) … … 5950 5509 !-- Write zu data 5951 5510 netcdf_data(1:ns) = zu( comp_spectra_level(1:ns) ) 5952 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_zu_sp, netcdf_data, & 5953 start = (/ 1 /), count = (/ ns /) ) 5511 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_zu_sp, netcdf_data, & 5512 start = (/ 1 /), & 5513 count = (/ ns /) ) 5954 5514 CALL netcdf_handle_error( 'netcdf_define_header', 293 ) 5955 5515 … … 5957 5517 !-- Write zw data 5958 5518 netcdf_data(1:ns) = zw( comp_spectra_level(1:ns) ) 5959 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_zw_sp, netcdf_data, & 5960 start = (/ 1 /), count = (/ ns /) ) 5519 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_zw_sp, netcdf_data, & 5520 start = (/ 1 /), & 5521 count = (/ ns /) ) 5961 5522 CALL netcdf_handle_error( 'netcdf_define_header', 294 ) 5962 5523 … … 5970 5531 ENDDO 5971 5532 5972 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_x_sp, netcdf_data, & 5973 start = (/ 1 /), count = (/ nx/2 /) ) 5533 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_x_sp, netcdf_data, & 5534 start = (/ 1 /), & 5535 count = (/ nx/2 /) ) 5974 5536 CALL netcdf_handle_error( 'netcdf_define_header', 295 ) 5975 5537 … … 5981 5543 ENDDO 5982 5544 5983 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_y_sp, netcdf_data, & 5984 start = (/ 1 /), count = (/ ny/2 /) ) 5545 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_y_sp, netcdf_data, & 5546 start = (/ 1 /), & 5547 count = (/ ny/2 /) ) 5985 5548 CALL netcdf_handle_error( 'netcdf_define_header', 296 ) 5986 5549 … … 5992 5555 ! 5993 5556 !-- Get the list of variables and compare with the actual run. 5994 !-- First var_list_old has to be reset, since GET_ATT does not assign 5995 !-- trailing blanks. 5557 !-- First var_list_old has to be reset, since GET_ATT does not assign trailing blanks. 5996 5558 var_list_old = ' ' 5997 nc_stat = NF90_GET_ATT( id_set_sp, NF90_GLOBAL, 'VAR_LIST', & 5998 var_list_old ) 5559 nc_stat = NF90_GET_ATT( id_set_sp, NF90_GLOBAL, 'VAR_LIST', var_list_old ) 5999 5560 CALL netcdf_handle_error( 'netcdf_define_header', 297 ) 6000 5561 var_list = ';' 6001 5562 i = 1 6002 DO WHILE ( data_output_sp(i) /= ' ' .AND. i <= 10 )5563 DO WHILE ( data_output_sp(i) /= ' ' .AND. i <= 10 ) 6003 5564 6004 5565 IF ( INDEX( spectra_direction(i), 'x' ) /= 0 ) THEN … … 6017 5578 6018 5579 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 6019 message_string = 'netCDF file for spectra ' // & 6020 'from previous run found,' // & 6021 '&but this file cannot be extended due to' // & 6022 ' variable mismatch.' // & 6023 '&New file is created instead.' 5580 message_string = 'netCDF file for spectra ' // 'from previous run found,' // & 5581 '&but this file cannot be extended due to' // & 5582 ' variable mismatch.' // '&New file is created instead.' 6024 5583 CALL message( 'define_netcdf_header', 'PA0260', 0, 1, 0, 6, 0 ) 6025 5584 extend = .FALSE. … … 6028 5587 6029 5588 ! 6030 !-- Determine the number of current vertical levels for which spectra 6031 !-- shall be output 5589 !-- Determine the number of current vertical levels for which spectra shall be output. 6032 5590 ns = 1 6033 DO WHILE ( comp_spectra_level(ns) /= 999999 .AND. ns <= 100 )5591 DO WHILE ( comp_spectra_level(ns) /= 999999 .AND. ns <= 100 ) 6034 5592 ns = ns + 1 6035 5593 ENDDO … … 6041 5599 CALL netcdf_handle_error( 'netcdf_define_header', 298 ) 6042 5600 6043 nc_stat = NF90_INQUIRE_VARIABLE( id_set_sp, id_var_zu_sp, & 6044 dimids = id_dim_zu_sp_old ) 5601 nc_stat = NF90_INQUIRE_VARIABLE( id_set_sp, id_var_zu_sp, dimids = id_dim_zu_sp_old ) 6045 5602 CALL netcdf_handle_error( 'netcdf_define_header', 299 ) 6046 5603 id_dim_zu_sp = id_dim_zu_sp_old(1) 6047 5604 6048 nc_stat = NF90_INQUIRE_DIMENSION( id_set_sp, id_dim_zu_sp, & 6049 len = ns_old ) 5605 nc_stat = NF90_INQUIRE_DIMENSION( id_set_sp, id_dim_zu_sp, LEN = ns_old ) 6050 5606 CALL netcdf_handle_error( 'netcdf_define_header', 300 ) 6051 5607 6052 5608 IF ( ns /= ns_old ) THEN 6053 message_string = 'netCDF file for spectra ' // & 6054 ' from previous run found,' // & 6055 '&but this file cannot be extended due to' // & 6056 ' mismatch in number of' // & 6057 ' vertical levels.' // & 5609 message_string = 'netCDF file for spectra ' // ' from previous run found,' // & 5610 '&but this file cannot be extended due to' // & 5611 ' mismatch in number of' // ' vertical levels.' // & 6058 5612 '&New file is created instead.' 6059 5613 CALL message( 'define_netcdf_header', 'PA0261', 0, 1, 0, 6, 0 ) … … 6071 5625 DO i = 1, ns 6072 5626 IF ( zu(comp_spectra_level(i)) /= netcdf_data(i) ) THEN 6073 message_string = 'netCDF file for spectra ' // & 6074 ' from previous run found,' // & 6075 '&but this file cannot be extended due to' // & 6076 ' mismatch in heights of' // & 6077 ' vertical levels.' // & 5627 message_string = 'netCDF file for spectra ' // ' from previous run found,' // & 5628 '&but this file cannot be extended due to' // & 5629 ' mismatch in heights of' // ' vertical levels.' // & 6078 5630 '&New file is created instead.' 6079 5631 CALL message( 'define_netcdf_header', 'PA0262', 0, 1, 0, 6, 0 ) … … 6086 5638 6087 5639 ! 6088 !-- Get the id of the time coordinate (unlimited coordinate) and its 6089 !-- last index on the file. The next time level is plsp..count+1. 6090 !-- The current time must be larger than the last output time 6091 !-- on the file. 5640 !-- Get the id of the time coordinate (unlimited coordinate) and its last index on the file. 5641 !-- The next time level is plsp..count+1. 5642 !-- The current time must be larger than the last output time on the file. 6092 5643 nc_stat = NF90_INQ_VARID( id_set_sp, 'time', id_var_time_sp ) 6093 5644 CALL netcdf_handle_error( 'netcdf_define_header', 302 ) 6094 5645 6095 nc_stat = NF90_INQUIRE_VARIABLE( id_set_sp, id_var_time_sp, & 6096 dimids = id_dim_time_old ) 5646 nc_stat = NF90_INQUIRE_VARIABLE( id_set_sp, id_var_time_sp, dimids = id_dim_time_old ) 6097 5647 CALL netcdf_handle_error( 'netcdf_define_header', 303 ) 6098 5648 id_dim_time_sp = id_dim_time_old(1) 6099 5649 6100 nc_stat = NF90_INQUIRE_DIMENSION( id_set_sp, id_dim_time_sp, & 6101 len = dosp_time_count ) 5650 nc_stat = NF90_INQUIRE_DIMENSION( id_set_sp, id_dim_time_sp, LEN = dosp_time_count ) 6102 5651 CALL netcdf_handle_error( 'netcdf_define_header', 304 ) 6103 5652 6104 nc_stat = NF90_GET_VAR( id_set_sp, id_var_time_sp, &6105 last_time_coordinate, &6106 start = (/ dosp_time_count /), &5653 nc_stat = NF90_GET_VAR( id_set_sp, id_var_time_sp, & 5654 last_time_coordinate, & 5655 start = (/ dosp_time_count /), & 6107 5656 count = (/ 1 /) ) 6108 5657 CALL netcdf_handle_error( 'netcdf_define_header', 305 ) 6109 5658 6110 5659 IF ( last_time_coordinate(1) >= simulated_time ) THEN 6111 message_string = 'netCDF file for spectra ' // & 6112 'from previous run found,' // & 6113 '&but this file cannot be extended becaus' // & 6114 'e the current output time' // & 6115 '&is less or equal than the last output t' // & 6116 'ime on this file.' // & 5660 message_string = 'netCDF file for spectra ' // 'from previous run found,' // & 5661 '&but this file cannot be extended because' // & 5662 ' the current output time' // & 5663 '&is less or equal than the last output ' // 'time on this file.' // & 6117 5664 '&New file is created instead.' 6118 5665 CALL message( 'define_netcdf_header', 'PA0263', 0, 1, 0, 6, 0 ) … … 6126 5673 !-- Now get the variable ids. 6127 5674 i = 1 6128 DO WHILE ( data_output_sp(i) /= ' ' .AND. i <= 10 )5675 DO WHILE ( data_output_sp(i) /= ' ' .AND. i <= 10 ) 6129 5676 6130 5677 IF ( INDEX( spectra_direction(i), 'x' ) /= 0 ) THEN 6131 5678 netcdf_var_name = TRIM( data_output_sp(i) ) // '_x' 6132 nc_stat = NF90_INQ_VARID( id_set_sp, netcdf_var_name, & 6133 id_var_dospx(i) ) 5679 nc_stat = NF90_INQ_VARID( id_set_sp, netcdf_var_name, id_var_dospx(i) ) 6134 5680 CALL netcdf_handle_error( 'netcdf_define_header', 306 ) 6135 5681 ENDIF … … 6137 5683 IF ( INDEX( spectra_direction(i), 'y' ) /= 0 ) THEN 6138 5684 netcdf_var_name = TRIM( data_output_sp(i) ) // '_y' 6139 nc_stat = NF90_INQ_VARID( id_set_sp, netcdf_var_name, & 6140 id_var_dospy(i) ) 5685 nc_stat = NF90_INQ_VARID( id_set_sp, netcdf_var_name, id_var_dospy(i) ) 6141 5686 CALL netcdf_handle_error( 'netcdf_define_header', 307 ) 6142 5687 ENDIF … … 6147 5692 6148 5693 ! 6149 !-- Update the title attribute on file 6150 !-- In order to avoid 'data mode' errors if updated attributes are larger 6151 !-- than their original size, NF90_PUT_ATT is called in 'define mode' 6152 !-- enclosed by NF90_REDEF and NF90_ENDDEF calls. This implies a possible 6153 !-- performance loss due to data copying; an alternative strategy would be 6154 !-- to ensure equal attribute size in a job chain. Maybe revise later. 5694 !-- Update the title attribute on file. 5695 !-- In order to avoid 'data mode' errors if updated attributes are larger than their original 5696 !-- size, NF90_PUT_ATT is called in 'define mode'enclosed by NF90_REDEF and NF90_ENDDEF 5697 !-- calls. This implies a possible performance loss due to data copying; an alternative 5698 !-- strategy would be to ensure equal attribute size in a job chain. Maybe revise later. 6155 5699 nc_stat = NF90_REDEF( id_set_sp ) 6156 5700 CALL netcdf_handle_error( 'netcdf_define_header', 441 ) 6157 5701 IF ( averaging_interval_sp /= 0.0_wp ) THEN 6158 WRITE (time_average_text,'('', '',F7.1,'' s average'')') & 6159 averaging_interval_sp 6160 nc_stat = NF90_PUT_ATT( id_set_sp, NF90_GLOBAL, 'title', & 6161 TRIM( run_description_header ) // & 6162 TRIM( time_average_text ) ) 5702 WRITE ( time_average_text, '('', '',F7.1,'' s average'')' ) averaging_interval_sp 5703 nc_stat = NF90_PUT_ATT( id_set_sp, NF90_GLOBAL, 'title', & 5704 TRIM( run_description_header ) // TRIM( time_average_text ) ) 6163 5705 CALL netcdf_handle_error( 'netcdf_define_header', 308 ) 6164 5706 6165 5707 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval_sp 6166 nc_stat = NF90_PUT_ATT( id_set_sp, NF90_GLOBAL, 'time_avg', & 6167 TRIM( time_average_text ) ) 5708 nc_stat = NF90_PUT_ATT( id_set_sp, NF90_GLOBAL, 'time_avg', TRIM( time_average_text ) ) 6168 5709 ELSE 6169 nc_stat = NF90_PUT_ATT( id_set_sp, NF90_GLOBAL, 'title', &5710 nc_stat = NF90_PUT_ATT( id_set_sp, NF90_GLOBAL, 'title', & 6170 5711 TRIM( run_description_header ) ) 6171 5712 ENDIF … … 6173 5714 nc_stat = NF90_ENDDEF( id_set_sp ) 6174 5715 CALL netcdf_handle_error( 'netcdf_define_header', 442 ) 6175 message_string = 'netCDF file for spectra ' // & 6176 'from previous run found.' // & 5716 message_string = 'netCDF file for spectra ' // 'from previous run found.' // & 6177 5717 '&This file will be extended.' 6178 5718 CALL message( 'define_netcdf_header', 'PA0264', 0, 0, 0, 6, 0 ) … … 6184 5724 ! 6185 5725 !-- Define some global attributes of the dataset 6186 ! nc_stat = NF90_PUT_ATT( id_set_prt, NF90_GLOBAL, 'title', & 6187 ! TRIM( run_description_header ) ) 5726 ! nc_stat = NF90_PUT_ATT( id_set_prt, NF90_GLOBAL, 'title', TRIM( run_description_header ) ) 6188 5727 ! CALL netcdf_handle_error( 'netcdf_define_header', 310 ) 6189 5728 6190 5729 ! 6191 5730 !-- Define time coordinate for particles (unlimited dimension) 6192 ! CALL netcdf_create_dim( id_set_prt, 'time', NF90_UNLIMITED, & 6193 ! id_dim_time_prt, 311 ) 6194 ! CALL netcdf_create_var( id_set_prt, (/ id_dim_time_prt /), 'time', & 6195 ! NF90_DOUBLE, id_var_time_prt, 'seconds', '', & 6196 ! 312, 313, 000 ) 5731 ! CALL netcdf_create_dim( id_set_prt, 'time', NF90_UNLIMITED, id_dim_time_prt, 311 ) 5732 ! CALL netcdf_create_var( id_set_prt, (/ id_dim_time_prt /), 'time', NF90_DOUBLE, & 5733 ! id_var_time_prt, 'seconds', '', 312, 313, 000 ) 6197 5734 ! 6198 5735 !-- netCDF4 allows more than one unlimited dimension 6199 ! CALL netcdf_create_dim( id_set_prt, 'particle_number', & 6200 ! NF90_UNLIMITED, id_dim_prtnum, 314 ) 6201 6202 ! CALL netcdf_create_var( id_set_prt, (/ id_dim_prtnum /), & 6203 ! 'particle_number', NF90_DOUBLE, & 6204 ! id_var_prtnum, 'particle number', '', 315, & 6205 ! 316, 000 ) 5736 ! CALL netcdf_create_dim( id_set_prt, 'particle_number', NF90_UNLIMITED, id_dim_prtnum, & 5737 ! 314 ) 5738 5739 ! CALL netcdf_create_var( id_set_prt, (/ id_dim_prtnum /), 'particle_number', NF90_DOUBLE, & 5740 ! id_var_prtnum, 'particle number', '', 315, 316, 000 ) 6206 5741 ! 6207 5742 !-- Define variable which contains the real number of particles in use 6208 ! CALL netcdf_create_var( id_set_prt, (/ id_dim_time_prt /), & 6209 ! 'real_num_of_prt', NF90_DOUBLE, & 6210 ! id_var_rnop_prt, 'particle number', '', 317, & 6211 ! 318, 000 ) 5743 ! CALL netcdf_create_var( id_set_prt, (/ id_dim_time_prt /), 'real_num_of_prt', & 5744 ! NF90_DOUBLE, id_var_rnop_prt, 'particle number', '', 317, 318, & 5745 ! 000 ) 6212 5746 ! 6213 5747 !-- Define the variables 6214 5748 ! DO i = 1, 17 6215 5749 6216 ! CALL netcdf_create_var( id_set_prt, (/ id_dim_prtnum, & 6217 ! id_dim_time_prt /), prt_var_names(i), & 6218 ! nc_precision(8), id_var_prt(i), & 6219 ! TRIM( prt_var_units(i) ), & 6220 ! TRIM( prt_var_names(i) ), 319, 320, 321 ) 5750 ! CALL netcdf_create_var( id_set_prt, (/ id_dim_prtnum, id_dim_time_prt /), & 5751 ! prt_var_names(i), nc_precision(8), id_var_prt(i), & 5752 ! TRIM( prt_var_units(i) ), TRIM( prt_var_names(i) ), 319, 320, & 5753 ! 321 ) 6221 5754 6222 5755 ! ENDDO … … 6232 5765 6233 5766 ! 6234 !-- Get the id of the time coordinate (unlimited coordinate) and its 6235 !-- last index on the file. The next time level is prt..count+1. 6236 !-- The current time must be larger than the last output time 6237 !-- on the file. 5767 !-- Get the id of the time coordinate (unlimited coordinate) and its last index on the file. 5768 !-- The next time level is prt..count+1. 5769 !-- The current time must be larger than the last output time on the file. 6238 5770 ! nc_stat = NF90_INQ_VARID( id_set_prt, 'time', id_var_time_prt ) 6239 5771 ! CALL netcdf_handle_error( 'netcdf_define_header', 323 ) 6240 5772 6241 ! nc_stat = NF90_INQUIRE_VARIABLE( id_set_prt, id_var_time_prt, & 6242 ! dimids = id_dim_time_old ) 5773 ! nc_stat = NF90_INQUIRE_VARIABLE( id_set_prt, id_var_time_prt, dimids = id_dim_time_old ) 6243 5774 ! CALL netcdf_handle_error( 'netcdf_define_header', 324 ) 6244 5775 ! id_dim_time_prt = id_dim_time_old(1) 6245 5776 6246 ! nc_stat = NF90_INQUIRE_DIMENSION( id_set_prt, id_dim_time_prt, & 6247 ! len = prt_time_count ) 5777 ! nc_stat = NF90_INQUIRE_DIMENSION( id_set_prt, id_dim_time_prt, LEN = prt_time_count ) 6248 5778 ! CALL netcdf_handle_error( 'netcdf_define_header', 325 ) 6249 5779 6250 ! nc_stat = NF90_GET_VAR( id_set_prt, id_var_time_prt, &6251 ! last_time_coordinate, &6252 ! start = (/ prt_time_count /), &5780 ! nc_stat = NF90_GET_VAR( id_set_prt, id_var_time_prt, & 5781 ! last_time_coordinate, & 5782 ! start = (/ prt_time_count /), & 6253 5783 ! count = (/ 1 /) ) 6254 5784 ! CALL netcdf_handle_error( 'netcdf_define_header', 326 ) 6255 5785 6256 5786 ! IF ( last_time_coordinate(1) >= simulated_time ) THEN 6257 ! message_string = 'netCDF file for particles ' // & 6258 ! 'from previous run found,' // & 6259 ! '&but this file cannot be extended becaus' // & 6260 ! 'e the current output time' // & 6261 ! '&is less or equal than the last output t' // & 6262 ! 'ime on this file.' // & 5787 ! message_string = 'netCDF file for particles ' // 'from previous run found,' // & 5788 ! '&but this file cannot be extended because' // & 5789 ! ' the current output time' // & 5790 ! '&is less or equal than the last output ' // 'time on this file.' // & 6263 5791 ! '&New file is created instead.' 6264 5792 ! CALL message( 'define_netcdf_header', 'PA0265', 0, 1, 0, 6, 0 ) … … 6271 5799 !-- Dataset seems to be extendable. 6272 5800 !-- Now get the variable ids. 6273 ! nc_stat = NF90_INQ_VARID( id_set_prt, 'real_num_of_prt', & 6274 ! id_var_rnop_prt ) 5801 ! nc_stat = NF90_INQ_VARID( id_set_prt, 'real_num_of_prt',id_var_rnop_prt ) 6275 5802 ! CALL netcdf_handle_error( 'netcdf_define_header', 327 ) 6276 5803 6277 5804 ! DO i = 1, 17 6278 5805 6279 ! nc_stat = NF90_INQ_VARID( id_set_prt, prt_var_names(i), & 6280 ! id_var_prt(i) ) 5806 ! nc_stat = NF90_INQ_VARID( id_set_prt, prt_var_names(i), id_var_prt(i) ) 6281 5807 ! CALL netcdf_handle_error( 'netcdf_define_header', 328 ) 6282 5808 6283 5809 ! ENDDO 6284 5810 6285 ! message_string = 'netCDF file for particles ' // & 6286 ! 'from previous run found.' // & 5811 ! message_string = 'netCDF file for particles ' // 'from previous run found.' // & 6287 5812 ! '&This file will be extended.' 6288 5813 ! CALL message( 'define_netcdf_header', 'PA0266', 0, 0, 0, 6, 0 ) … … 6294 5819 ! 6295 5820 !-- Define some global attributes of the dataset 6296 nc_stat = NF90_PUT_ATT( id_set_pts, NF90_GLOBAL, 'title', & 6297 TRIM( run_description_header ) ) 5821 nc_stat = NF90_PUT_ATT( id_set_pts, NF90_GLOBAL, 'title', TRIM( run_description_header ) ) 6298 5822 CALL netcdf_handle_error( 'netcdf_define_header', 396 ) 6299 5823 6300 5824 ! 6301 5825 !-- Define time coordinate for particle time series (unlimited dimension) 6302 CALL netcdf_create_dim( id_set_pts, 'time', NF90_UNLIMITED, & 6303 id_dim_time_pts, 397 ) 6304 CALL netcdf_create_var( id_set_pts, (/ id_dim_time_pts /), 'time', & 6305 NF90_DOUBLE, id_var_time_pts, 'seconds', 'time', & 6306 398, 399, 000 ) 5826 CALL netcdf_create_dim( id_set_pts, 'time', NF90_UNLIMITED, id_dim_time_pts, 397 ) 5827 CALL netcdf_create_var( id_set_pts, (/ id_dim_time_pts /), 'time', NF90_DOUBLE, & 5828 id_var_time_pts, 'seconds', 'time', 398, 399, 000 ) 6307 5829 CALL netcdf_create_att( id_set_pts, id_var_time_pts, 'standard_name', 'time', 000) 6308 5830 CALL netcdf_create_att( id_set_pts, id_var_time_pts, 'axis', 'T', 000) 6309 5831 ! 6310 !-- Define the variables. If more than one particle group is defined, 6311 !-- define seperate variables for each group5832 !-- Define the variables. If more than one particle group is defined, define seperate 5833 !-- variables for each group. 6312 5834 var_list = ';' 6313 5835 DO i = 1, dopts_num … … 6322 5844 6323 5845 IF ( j == 0 ) THEN 6324 CALL netcdf_create_var( id_set_pts, (/ id_dim_time_pts /), & 6325 TRIM( dopts_label(i) ) // suffix, & 6326 nc_precision(6), id_var_dopts(i,j), & 6327 TRIM( dopts_unit(i) ), & 6328 TRIM( dopts_label(i) ), 400, 401, & 6329 402 ) 5846 CALL netcdf_create_var( id_set_pts, (/ id_dim_time_pts /), & 5847 TRIM( dopts_label(i) ) // suffix, nc_precision(6), & 5848 id_var_dopts(i,j), TRIM( dopts_unit(i) ), & 5849 TRIM( dopts_label(i) ), 400, 401, 402 ) 6330 5850 ELSE 6331 CALL netcdf_create_var( id_set_pts, (/ id_dim_time_pts /), & 6332 TRIM( dopts_label(i) ) // suffix, & 6333 nc_precision(6), id_var_dopts(i,j), & 6334 TRIM( dopts_unit(i) ), & 6335 TRIM( dopts_label(i) ) // ' PG ' // & 6336 suffix(2:3), 400, 401, 402 ) 5851 CALL netcdf_create_var( id_set_pts, (/ id_dim_time_pts /), & 5852 TRIM( dopts_label(i) ) // suffix, nc_precision(6), & 5853 id_var_dopts(i,j), TRIM( dopts_unit(i) ), & 5854 TRIM( dopts_label(i) ) // ' PG ' // suffix(2:3), & 5855 400, 401, 402 ) 6337 5856 ENDIF 6338 5857 6339 var_list = TRIM( var_list ) // TRIM( dopts_label(i) ) // & 6340 suffix // ';' 5858 var_list = TRIM( var_list ) // TRIM( dopts_label(i) ) // suffix // ';' 6341 5859 6342 5860 IF ( number_of_particle_groups == 1 ) EXIT … … 6347 5865 6348 5866 ! 6349 !-- Write the list of variables as global attribute (this is used by 6350 !-- restart runs) 6351 nc_stat = NF90_PUT_ATT( id_set_pts, NF90_GLOBAL, 'VAR_LIST', & 6352 var_list ) 5867 !-- Write the list of variables as global attribute (this is used by restart runs) 5868 nc_stat = NF90_PUT_ATT( id_set_pts, NF90_GLOBAL, 'VAR_LIST', var_list ) 6353 5869 CALL netcdf_handle_error( 'netcdf_define_header', 403 ) 6354 5870 … … 6364 5880 ! 6365 5881 !-- Get the list of variables and compare with the actual run. 6366 !-- First var_list_old has to be reset, since GET_ATT does not assign 6367 !-- trailing blanks. 5882 !-- First var_list_old has to be reset, since GET_ATT does not assign trailing blanks. 6368 5883 var_list_old = ' ' 6369 nc_stat = NF90_GET_ATT( id_set_pts, NF90_GLOBAL, 'VAR_LIST', & 6370 var_list_old ) 5884 nc_stat = NF90_GET_ATT( id_set_pts, NF90_GLOBAL, 'VAR_LIST', var_list_old ) 6371 5885 CALL netcdf_handle_error( 'netcdf_define_header', 405 ) 6372 5886 … … 6383 5897 ENDIF 6384 5898 6385 var_list = TRIM( var_list ) // TRIM( dopts_label(i) ) // & 6386 suffix // ';' 5899 var_list = TRIM( var_list ) // TRIM( dopts_label(i) ) // suffix // ';' 6387 5900 6388 5901 IF ( number_of_particle_groups == 1 ) EXIT … … 6393 5906 6394 5907 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 6395 message_string = 'netCDF file for particle time series ' // & 6396 'from previous run found,' // & 6397 '&but this file cannot be extended due to' // & 6398 ' variable mismatch.' // & 6399 '&New file is created instead.' 5908 message_string = 'netCDF file for particle time series ' // & 5909 'from previous run found,' // & 5910 '&but this file cannot be extended due to' // & 5911 ' variable mismatch.' // '&New file is created instead.' 6400 5912 CALL message( 'define_netcdf_header', 'PA0267', 0, 1, 0, 6, 0 ) 6401 5913 extend = .FALSE. … … 6404 5916 6405 5917 ! 6406 !-- Get the id of the time coordinate (unlimited coordinate) and its 6407 !-- last index on the file. The next time level is dots..count+1. 6408 !-- The current time must be larger than the last output time 6409 !-- on the file. 5918 !-- Get the id of the time coordinate (unlimited coordinate) and its last index on the file. 5919 !-- The next time level is dots..count+1. 5920 !-- The current time must be larger than the last output time on the file. 6410 5921 nc_stat = NF90_INQ_VARID( id_set_pts, 'time', id_var_time_pts ) 6411 5922 CALL netcdf_handle_error( 'netcdf_define_header', 406 ) 6412 5923 6413 nc_stat = NF90_INQUIRE_VARIABLE( id_set_pts, id_var_time_pts, & 6414 dimids = id_dim_time_old ) 5924 nc_stat = NF90_INQUIRE_VARIABLE( id_set_pts, id_var_time_pts, dimids = id_dim_time_old ) 6415 5925 CALL netcdf_handle_error( 'netcdf_define_header', 407 ) 6416 5926 id_dim_time_pts = id_dim_time_old(1) 6417 5927 6418 nc_stat = NF90_INQUIRE_DIMENSION( id_set_pts, id_dim_time_pts, & 6419 len = dopts_time_count ) 5928 nc_stat = NF90_INQUIRE_DIMENSION( id_set_pts, id_dim_time_pts, LEN = dopts_time_count ) 6420 5929 CALL netcdf_handle_error( 'netcdf_define_header', 408 ) 6421 5930 6422 nc_stat = NF90_GET_VAR( id_set_pts, id_var_time_pts, &6423 last_time_coordinate, &6424 start = (/ dopts_time_count /), &5931 nc_stat = NF90_GET_VAR( id_set_pts, id_var_time_pts, & 5932 last_time_coordinate, & 5933 start = (/ dopts_time_count /), & 6425 5934 count = (/ 1 /) ) 6426 5935 CALL netcdf_handle_error( 'netcdf_define_header', 409 ) 6427 5936 6428 5937 IF ( last_time_coordinate(1) >= simulated_time ) THEN 6429 message_string = 'netCDF file for particle time series ' // & 6430 'from previous run found,' // & 6431 '&but this file cannot be extended becaus' // & 6432 'e the current output time' // & 6433 '&is less or equal than the last output t' // & 6434 'ime on this file.' // & 5938 message_string = 'netCDF file for particle time series ' // & 5939 'from previous run found,' // & 5940 '&but this file cannot be extended because' // & 5941 ' the current output time' // & 5942 '&is less or equal than the last output ' // 'time on this file.' // & 6435 5943 '&New file is created instead.' 6436 5944 CALL message( 'define_netcdf_header', 'PA0268', 0, 1, 0, 6, 0 ) … … 6456 5964 netcdf_var_name = TRIM( dopts_label(i) ) // suffix 6457 5965 6458 nc_stat = NF90_INQ_VARID( id_set_pts, netcdf_var_name, & 6459 id_var_dopts(i,j) ) 5966 nc_stat = NF90_INQ_VARID( id_set_pts, netcdf_var_name, id_var_dopts(i,j) ) 6460 5967 CALL netcdf_handle_error( 'netcdf_define_header', 410 ) 6461 5968 … … 6467 5974 6468 5975 ! 6469 !-- Update the title attribute on file 6470 !-- In order to avoid 'data mode' errors if updated attributes are larger 6471 !-- than their original size, NF90_PUT_ATT is called in 'define mode' 6472 !-- enclosed by NF90_REDEF and NF90_ENDDEF calls. This implies a possible 6473 !-- performance loss due to data copying; an alternative strategy would be 6474 !-- to ensure equal attribute size in a job chain. Maybe revise later. 5976 !-- Update the title attribute on file. 5977 !-- In order to avoid 'data mode' errors if updated attributes are larger than their original 5978 !-- size, NF90_PUT_ATT is called in 'define mode' enclosed by NF90_REDEF and NF90_ENDDEF 5979 !-- calls. This implies a possible performance loss due to data copying; an alternative 5980 !-- strategy would be to ensure equal attribute size in a job chain. Maybe revise later. 6475 5981 nc_stat = NF90_REDEF( id_set_pts ) 6476 5982 CALL netcdf_handle_error( 'netcdf_define_header', 443 ) 6477 nc_stat = NF90_PUT_ATT( id_set_pts, NF90_GLOBAL, 'title', & 6478 TRIM( run_description_header ) ) 5983 nc_stat = NF90_PUT_ATT( id_set_pts, NF90_GLOBAL, 'title', TRIM( run_description_header ) ) 6479 5984 CALL netcdf_handle_error( 'netcdf_define_header', 411 ) 6480 5985 nc_stat = NF90_ENDDEF( id_set_pts ) 6481 5986 CALL netcdf_handle_error( 'netcdf_define_header', 444 ) 6482 message_string = 'netCDF file for particle time series ' // & 6483 'from previous run found.' // & 5987 message_string = 'netCDF file for particle time series ' // 'from previous run found.' //& 6484 5988 '&This file will be extended.' 6485 5989 CALL message( 'netcdf_define_header', 'PA0269', 0, 0, 0, 6, 0 ) … … 6490 5994 ! 6491 5995 !-- Define some global attributes of the dataset 6492 nc_stat = NF90_PUT_ATT( id_set_fl, NF90_GLOBAL, 'title', & 6493 TRIM( run_description_header ) ) 5996 nc_stat = NF90_PUT_ATT( id_set_fl, NF90_GLOBAL, 'title', TRIM( run_description_header ) ) 6494 5997 CALL netcdf_handle_error( 'netcdf_define_header', 249 ) 6495 5998 6496 5999 ! 6497 !-- Define time and location coordinates for flight space-time series 6498 !-- (unlimited dimension) 6000 !-- Define time and location coordinates for flight space-time series (unlimited dimension). 6499 6001 !-- Error number must still be set appropriately. 6500 CALL netcdf_create_dim( id_set_fl, 'time', NF90_UNLIMITED, & 6501 id_dim_time_fl, 250 ) 6502 CALL netcdf_create_var( id_set_fl, (/ id_dim_time_fl /), 'time', & 6503 NF90_DOUBLE, id_var_time_fl, 'seconds', 'time', & 6504 251, 252, 000 ) 6002 CALL netcdf_create_dim( id_set_fl, 'time', NF90_UNLIMITED, id_dim_time_fl, 250 ) 6003 CALL netcdf_create_var( id_set_fl, (/ id_dim_time_fl /), 'time', NF90_DOUBLE, & 6004 id_var_time_fl, 'seconds', 'time', 251, 252, 000 ) 6505 6005 CALL netcdf_create_att( id_set_fl, id_var_time_fl, 'standard_name', 'time', 000) 6506 6006 CALL netcdf_create_att( id_set_fl, id_var_time_fl, 'axis', 'T', 000) 6507 6007 6508 6008 DO l = 1, num_leg 6509 CALL netcdf_create_dim( id_set_fl, dofl_dim_label_x(l), & 6510 NF90_UNLIMITED, id_dim_x_fl(l), 250 ) 6511 CALL netcdf_create_dim( id_set_fl, dofl_dim_label_y(l), & 6512 NF90_UNLIMITED, id_dim_y_fl(l), 250 ) 6513 CALL netcdf_create_dim( id_set_fl, dofl_dim_label_z(l), & 6514 NF90_UNLIMITED, id_dim_z_fl(l), 250 ) 6515 6516 CALL netcdf_create_var( id_set_fl, (/ id_dim_x_fl(l) /), & 6517 dofl_dim_label_x(l), NF90_DOUBLE, & 6518 id_var_x_fl(l), 'm', '', 251, 252, 000 ) 6519 CALL netcdf_create_var( id_set_fl, (/ id_dim_y_fl(l) /), & 6520 dofl_dim_label_y(l), NF90_DOUBLE, & 6521 id_var_y_fl(l), 'm', '', 251, 252, 000 ) 6522 CALL netcdf_create_var( id_set_fl, (/ id_dim_z_fl(l) /), & 6523 dofl_dim_label_z(l), NF90_DOUBLE, & 6524 id_var_z_fl(l), 'm', '', 251, 252, 000 ) 6009 CALL netcdf_create_dim( id_set_fl, dofl_dim_label_x(l), NF90_UNLIMITED, & 6010 id_dim_x_fl(l), 250 ) 6011 CALL netcdf_create_dim( id_set_fl, dofl_dim_label_y(l), NF90_UNLIMITED, & 6012 id_dim_y_fl(l), 250 ) 6013 CALL netcdf_create_dim( id_set_fl, dofl_dim_label_z(l), NF90_UNLIMITED, & 6014 id_dim_z_fl(l), 250 ) 6015 6016 CALL netcdf_create_var( id_set_fl, (/ id_dim_x_fl(l) /), dofl_dim_label_x(l), & 6017 NF90_DOUBLE, id_var_x_fl(l), 'm', '', 251, 252, 000 ) 6018 CALL netcdf_create_var( id_set_fl, (/ id_dim_y_fl(l) /), dofl_dim_label_y(l), & 6019 NF90_DOUBLE, id_var_y_fl(l), 'm', '', 251, 252, 000 ) 6020 CALL netcdf_create_var( id_set_fl, (/ id_dim_z_fl(l) /), dofl_dim_label_z(l), & 6021 NF90_DOUBLE, id_var_z_fl(l), 'm', '', 251, 252, 000 ) 6525 6022 ENDDO 6526 6023 ! … … 6531 6028 DO i = 1, num_var_fl 6532 6029 6533 CALL netcdf_create_var( id_set_fl, (/ id_dim_time_fl /), & 6534 dofl_label(k), nc_precision(9), & 6535 id_var_dofl(k), & 6536 TRIM( dofl_unit(k) ), & 6030 CALL netcdf_create_var( id_set_fl, (/ id_dim_time_fl /), dofl_label(k), & 6031 nc_precision(9), id_var_dofl(k), TRIM( dofl_unit(k) ), & 6537 6032 TRIM( dofl_label(k) ), 253, 254, 255 ) 6538 6033 … … 6544 6039 6545 6040 ! 6546 !-- Write the list of variables as global attribute (this is used by 6547 !-- restart runs) 6041 !-- Write the list of variables as global attribute (this is used by restart runs). 6548 6042 nc_stat = NF90_PUT_ATT( id_set_fl, NF90_GLOBAL, 'VAR_LIST', var_list ) 6549 6043 CALL netcdf_handle_error( 'netcdf_define_header', 258 ) … … 6559 6053 ! 6560 6054 !-- Get the list of variables and compare with the actual run. 6561 !-- First var_list_old has to be reset, since GET_ATT does not assign 6562 !-- trailing blanks. 6055 !-- First var_list_old has to be reset, since GET_ATT does not assign trailing blanks. 6563 6056 var_list_old = ' ' 6564 nc_stat = NF90_GET_ATT( id_set_fl, NF90_GLOBAL, 'VAR_LIST', & 6565 var_list_old ) 6057 nc_stat = NF90_GET_ATT( id_set_fl, NF90_GLOBAL, 'VAR_LIST', var_list_old ) 6566 6058 CALL netcdf_handle_error( 'netcdf_define_header', 260 ) 6567 6059 … … 6575 6067 6576 6068 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 6577 message_string = 'netCDF file for flight time series ' // & 6578 'from previous run found,' // & 6579 '&but this file cannot be extended due to' // & 6580 ' variable mismatch.' // & 6581 '&New file is created instead.' 6069 message_string = 'netCDF file for flight time series ' // & 6070 'from previous run found,' // & 6071 '&but this file cannot be extended due to' // & 6072 ' variable mismatch.' // '&New file is created instead.' 6582 6073 CALL message( 'define_netcdf_header', 'PA0257', 0, 1, 0, 6, 0 ) 6583 6074 extend = .FALSE. … … 6586 6077 6587 6078 ! 6588 !-- Get the id of the time coordinate (unlimited coordinate) and its 6589 !-- last index on the file. The next time level is dofl_time_count+1. 6590 !-- The current time must be larger than the last output time 6591 !-- on the file. 6079 !-- Get the id of the time coordinate (unlimited coordinate) and its last index on the file. 6080 !-- The next time level is dofl_time_count+1. 6081 !-- The current time must be larger than the last output time on the file. 6592 6082 nc_stat = NF90_INQ_VARID( id_set_fl, 'time', id_var_time_fl ) 6593 6083 CALL netcdf_handle_error( 'netcdf_define_header', 261 ) 6594 6084 6595 nc_stat = NF90_INQUIRE_VARIABLE( id_set_fl, id_var_time_fl, & 6596 dimids = id_dim_time_old ) 6085 nc_stat = NF90_INQUIRE_VARIABLE( id_set_fl, id_var_time_fl, dimids = id_dim_time_old ) 6597 6086 CALL netcdf_handle_error( 'netcdf_define_header', 262 ) 6598 6087 id_dim_time_fl = id_dim_time_old(1) 6599 6088 6600 nc_stat = NF90_INQUIRE_DIMENSION( id_set_fl, id_dim_time_fl, & 6601 len = dofl_time_count ) 6089 nc_stat = NF90_INQUIRE_DIMENSION( id_set_fl, id_dim_time_fl, LEN = dofl_time_count ) 6602 6090 CALL netcdf_handle_error( 'netcdf_define_header', 263 ) 6603 6091 6604 nc_stat = NF90_GET_VAR( id_set_fl, id_var_time_fl, &6605 last_time_coordinate, &6606 start = (/ dofl_time_count /), &6092 nc_stat = NF90_GET_VAR( id_set_fl, id_var_time_fl, & 6093 last_time_coordinate, & 6094 start = (/ dofl_time_count /), & 6607 6095 count = (/ 1 /) ) 6608 6096 CALL netcdf_handle_error( 'netcdf_define_header', 264 ) 6609 6097 6610 6098 IF ( last_time_coordinate(1) >= simulated_time ) THEN 6611 message_string = 'netCDF file for flight-time series ' // & 6612 'from previous run found,' // & 6613 '&but this file cannot be extended becaus' // & 6614 'e the current output time' // & 6615 '&is less or equal than the last output t' // & 6616 'ime on this file.' // & 6099 message_string = 'netCDF file for flight-time series ' // & 6100 'from previous run found,' // & 6101 '&but this file cannot be extended because' // & 6102 ' the current output time' // & 6103 '&is less or equal than the last output ' // 'time on this file.' // & 6617 6104 '&New file is created instead.' 6618 6105 CALL message( 'define_netcdf_header', 'PA0258', 0, 1, 0, 6, 0 ) … … 6624 6111 ! 6625 6112 !-- Dataset seems to be extendable. 6626 !-- Now get the remaining dimension and variable ids 6113 !-- Now get the remaining dimension and variable ids. 6627 6114 DO l = 1, num_leg 6628 nc_stat = NF90_INQ_VARID( id_set_fl, dofl_dim_label_x(l), & 6629 id_var_x_fl(l) ) 6115 nc_stat = NF90_INQ_VARID( id_set_fl, dofl_dim_label_x(l), id_var_x_fl(l) ) 6630 6116 CALL netcdf_handle_error( 'netcdf_define_header', 265 ) 6631 nc_stat = NF90_INQ_VARID( id_set_fl, dofl_dim_label_y(l), & 6632 id_var_y_fl(l) ) 6117 nc_stat = NF90_INQ_VARID( id_set_fl, dofl_dim_label_y(l), id_var_y_fl(l) ) 6633 6118 CALL netcdf_handle_error( 'netcdf_define_header', 265 ) 6634 nc_stat = NF90_INQ_VARID( id_set_fl, dofl_dim_label_z(l), & 6635 id_var_z_fl(l) ) 6119 nc_stat = NF90_INQ_VARID( id_set_fl, dofl_dim_label_z(l), id_var_z_fl(l) ) 6636 6120 CALL netcdf_handle_error( 'netcdf_define_header', 265 ) 6637 6121 … … 6641 6125 DO i = 1, num_leg * num_var_fl 6642 6126 6643 nc_stat = NF90_INQ_VARID( id_set_fl, dofl_label(i), & 6644 id_var_dofl(i) ) 6127 nc_stat = NF90_INQ_VARID( id_set_fl, dofl_label(i), id_var_dofl(i) ) 6645 6128 CALL netcdf_handle_error( 'netcdf_define_header', 265 ) 6646 6129 … … 6648 6131 6649 6132 ! 6650 !-- Update the title attribute on file 6651 !-- In order to avoid 'data mode' errors if updated attributes are larger 6652 !-- than their original size, NF90_PUT_ATT is called in 'define mode' 6653 !-- enclosed by NF90_REDEF and NF90_ENDDEF calls. This implies a possible 6654 !-- performance loss due to data copying; an alternative strategy would be 6655 !-- to ensure equal attribute size in a job chain. Maybe revise later. 6133 !-- Update the title attribute on file. 6134 !-- In order to avoid 'data mode' errors if updated attributes are larger than their original 6135 !-- size, NF90_PUT_ATT is called in 'define mode' enclosed by NF90_REDEF and NF90_ENDDEF 6136 !-- calls. This implies a possible performance loss due to data copying; an alternative 6137 !-- strategy would be to ensure equal attribute size in a job chain. Maybe revise later. 6656 6138 nc_stat = NF90_REDEF( id_set_fl ) 6657 6139 CALL netcdf_handle_error( 'netcdf_define_header', 439 ) 6658 nc_stat = NF90_PUT_ATT( id_set_fl, NF90_GLOBAL, 'title', & 6659 TRIM( run_description_header ) ) 6140 nc_stat = NF90_PUT_ATT( id_set_fl, NF90_GLOBAL, 'title', TRIM( run_description_header ) ) 6660 6141 CALL netcdf_handle_error( 'netcdf_define_header', 267 ) 6661 6142 nc_stat = NF90_ENDDEF( id_set_fl ) 6662 6143 CALL netcdf_handle_error( 'netcdf_define_header', 440 ) 6663 message_string = 'netCDF file for flight-time series ' // & 6664 'from previous run found.' // & 6144 message_string = 'netCDF file for flight-time series ' // 'from previous run found.' // & 6665 6145 '&This file will be extended.' 6666 6146 CALL message( 'define_netcdf_header', 'PA0259', 0, 0, 0, 6, 0 ) … … 6678 6158 6679 6159 6680 !------------------------------------------------------------------------------ !6160 !--------------------------------------------------------------------------------------------------! 6681 6161 ! Description: 6682 6162 ! ------------ 6683 !> Creates a netCDF file and give back the id. The parallel flag has to be TRUE 6684 !> for parallel netCDF output support. 6685 !------------------------------------------------------------------------------! 6686 6163 !> Creates a netCDF file and give back the id. The parallel flag has to be TRUE for parallel netCDF 6164 !> output support. 6165 !--------------------------------------------------------------------------------------------------! 6687 6166 SUBROUTINE netcdf_create_file( filename , id, parallel, errno ) 6688 6167 #if defined( __netcdf ) … … 6693 6172 6694 6173 CHARACTER (LEN=*), INTENT(IN) :: filename 6174 6695 6175 INTEGER, INTENT(IN) :: errno 6696 6176 INTEGER, INTENT(OUT) :: id 6697 6177 INTEGER :: idum !< dummy variable used to avoid compiler warnings about unused variables 6178 6698 6179 LOGICAL, INTENT(IN) :: parallel 6699 6180 … … 6712 6193 ! 6713 6194 !-- 64bit-offset format 6714 nc_stat = NF90_CREATE( filename, & 6715 IOR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ), id ) 6195 nc_stat = NF90_CREATE( filename, IOR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ), id ) 6716 6196 6717 6197 #if defined( __netcdf4 ) 6718 ELSEIF ( netcdf_data_format == 3 .OR. 6719 ( .NOT. parallel .AND. netcdf_data_format == 5 ) )THEN6198 ELSEIF ( netcdf_data_format == 3 .OR. ( .NOT. parallel .AND. netcdf_data_format == 5 ) ) & 6199 THEN 6720 6200 ! 6721 6201 !-- netCDF4/HDF5 format 6722 6202 nc_stat = NF90_CREATE( filename, IOR( NF90_NOCLOBBER, NF90_NETCDF4 ), id ) 6723 6203 6724 ELSEIF ( netcdf_data_format == 4 .OR. 6725 ( .NOT. parallel .AND. netcdf_data_format == 6 ) )THEN6204 ELSEIF ( netcdf_data_format == 4 .OR. ( .NOT. parallel .AND. netcdf_data_format == 6 ) ) & 6205 THEN 6726 6206 ! 6727 6207 !-- netCDF4/HDF5 format with classic model flag 6728 nc_stat = NF90_CREATE( filename, & 6729 IOR( NF90_NOCLOBBER, & 6730 IOR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ), id ) 6208 nc_stat = NF90_CREATE( filename, & 6209 IOR( NF90_NOCLOBBER, IOR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ), id ) 6731 6210 6732 6211 #if defined( __netcdf4_parallel ) … … 6734 6213 ! 6735 6214 !-- netCDF4/HDF5 format, parallel 6736 nc_stat = NF90_CREATE( filename, & 6737 IOR( NF90_NOCLOBBER, & 6738 IOR( NF90_NETCDF4, NF90_MPIIO ) ), & 6215 nc_stat = NF90_CREATE( filename, IOR( NF90_NOCLOBBER, IOR( NF90_NETCDF4, NF90_MPIIO ) ), & 6739 6216 id, COMM = comm2d, INFO = MPI_INFO_NULL ) 6740 6217 … … 6742 6219 ! 6743 6220 !-- netCDF4/HDF5 format with classic model flag, parallel 6744 nc_stat = NF90_CREATE( filename, & 6745 IOR( NF90_NOCLOBBER, & 6746 IOR( NF90_MPIIO, & 6747 IOR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ) ), & 6221 nc_stat = NF90_CREATE( filename, & 6222 IOR( NF90_NOCLOBBER, & 6223 IOR( NF90_MPIIO, IOR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ) ), & 6748 6224 id, COMM = comm2d, INFO = MPI_INFO_NULL ) 6749 6225 … … 6756 6232 END SUBROUTINE netcdf_create_file 6757 6233 6758 !------------------------------------------------------------------------------ !6234 !--------------------------------------------------------------------------------------------------! 6759 6235 ! Description: 6760 6236 ! ------------ 6761 6237 !> Opens an existing netCDF file for writing and gives back the id. 6762 6238 !> The parallel flag has to be TRUE for parallel netCDF output support. 6763 !------------------------------------------------------------------------------ !6239 !--------------------------------------------------------------------------------------------------! 6764 6240 SUBROUTINE netcdf_open_write_file( filename, id, parallel, errno ) 6765 6241 #if defined( __netcdf ) … … 6770 6246 6771 6247 CHARACTER (LEN=*), INTENT(IN) :: filename 6248 6772 6249 INTEGER, INTENT(IN) :: errno 6773 6250 INTEGER, INTENT(OUT) :: id … … 6780 6257 #if defined( __netcdf4_parallel ) 6781 6258 ELSEIF ( netcdf_data_format > 4 .AND. parallel ) THEN 6782 nc_stat = NF90_OPEN( filename, IOR( NF90_WRITE, NF90_MPIIO ), id, &6783 COMM = comm2d,INFO = MPI_INFO_NULL )6259 nc_stat = NF90_OPEN( filename, IOR( NF90_WRITE, NF90_MPIIO ), id, COMM = comm2d, & 6260 INFO = MPI_INFO_NULL ) 6784 6261 #endif 6785 6262 #endif … … 6791 6268 6792 6269 6793 !------------------------------------------------------------------------------ !6270 !--------------------------------------------------------------------------------------------------! 6794 6271 ! Description: 6795 6272 ! ------------ 6796 6273 !> Prints out a text message corresponding to the current status. 6797 !------------------------------------------------------------------------------! 6798 6274 !--------------------------------------------------------------------------------------------------! 6799 6275 SUBROUTINE netcdf_handle_error( routine_name, errno ) 6800 6276 #if defined( __netcdf ) 6801 6277 6802 6278 6803 USE control_parameters, &6279 USE control_parameters, & 6804 6280 ONLY: message_string 6805 6281 … … 6811 6287 INTEGER(iwp) :: errno 6812 6288 6289 6813 6290 IF ( nc_stat /= NF90_NOERR ) THEN 6814 6291 … … 6825 6302 6826 6303 6827 !------------------------------------------------------------------------------ !6304 !--------------------------------------------------------------------------------------------------! 6828 6305 ! Description: 6829 6306 ! ------------ 6830 6307 !> Create a dimension in NetCDF file 6831 !------------------------------------------------------------------------------ !6832 6833 SUBROUTINE netcdf_create_dim( ncid, dim_name, ncdim_type, ncdim_id, error_no)6308 !--------------------------------------------------------------------------------------------------! 6309 6310 SUBROUTINE netcdf_create_dim( ncid, dim_name, ncdim_type, ncdim_id, error_no ) 6834 6311 6835 6312 #if defined( __netcdf ) … … 6856 6333 6857 6334 6858 !------------------------------------------------------------------------------ !6335 !--------------------------------------------------------------------------------------------------! 6859 6336 ! Description: 6860 6337 ! ------------ 6861 6338 !> Create a one dimensional variable in specific units in NetCDF file 6862 !------------------------------------------------------------------------------! 6863 6864 SUBROUTINE netcdf_create_var( ncid, dim_id, var_name, var_type, var_id, & 6865 unit_name, long_name, error_no1, error_no2, & 6866 error_no3, fill ) 6339 !--------------------------------------------------------------------------------------------------! 6340 6341 SUBROUTINE netcdf_create_var( ncid, dim_id, var_name, var_type, var_id, unit_name, long_name, & 6342 error_no1, error_no2, error_no3, fill ) 6867 6343 6868 6344 #if defined( __netcdf ) … … 6872 6348 CHARACTER(LEN=*), INTENT(IN) :: unit_name 6873 6349 CHARACTER(LEN=*), INTENT(IN) :: var_name 6874 6875 LOGICAL, OPTIONAL :: fill !< indicates setting of _FillValue attribute6876 6350 6877 6351 INTEGER, INTENT(IN) :: error_no1 … … 6884 6358 INTEGER, DIMENSION(:), INTENT(IN) :: dim_id 6885 6359 6360 LOGICAL, OPTIONAL :: fill !< indicates setting of _FillValue attribute 6361 6362 6886 6363 ! 6887 6364 !-- Define variable … … 6891 6368 #if defined( __netcdf4 ) 6892 6369 ! 6893 !-- Check if variable should be deflate (including shuffling) 6894 !-- and if it is possible (only NetCDF4 with HDF5 supports compression)6370 !-- Check if variable should be deflate (including shuffling) and if it is possible (only NetCDF4 6371 !-- with HDF5 supports compression). 6895 6372 IF ( netcdf_data_format > 2 .AND. netcdf_deflate > 0 ) THEN 6896 6373 nc_stat = NF90_DEF_VAR_DEFLATE( ncid, var_id, 1, 1, netcdf_deflate ) … … 6917 6394 IF ( PRESENT( fill ) ) THEN 6918 6395 IF ( var_type == NF90_REAL4 ) THEN 6919 nc_stat = NF90_PUT_ATT( ncid, var_id, '_FillValue', & 6920 REAL( fill_value, KIND = 4 ) ) 6396 nc_stat = NF90_PUT_ATT( ncid, var_id, '_FillValue', REAL( fill_value, KIND = 4 ) ) 6921 6397 CALL netcdf_handle_error( 'netcdf_create_var', 0 ) 6922 6398 ELSE 6923 nc_stat = NF90_PUT_ATT( ncid, var_id, '_FillValue', & 6924 REAL( fill_value, KIND = 8 ) ) 6399 nc_stat = NF90_PUT_ATT( ncid, var_id, '_FillValue', REAL( fill_value, KIND = 8 ) ) 6925 6400 CALL netcdf_handle_error( 'netcdf_create_var', 0 ) 6926 6401 ENDIF … … 6931 6406 6932 6407 6933 !------------------------------------------------------------------------------ !6408 !--------------------------------------------------------------------------------------------------! 6934 6409 ! Description: 6935 6410 ! ------------ 6936 6411 !> Write attributes to file. 6937 !------------------------------------------------------------------------------ !6412 !--------------------------------------------------------------------------------------------------! 6938 6413 SUBROUTINE netcdf_create_att_string( ncid, varid, name, value, err ) 6939 6414 … … 6947 6422 6948 6423 INTEGER, INTENT(IN), OPTIONAL :: varid !< variable id 6424 6949 6425 6950 6426 #if defined( __netcdf ) … … 6960 6436 6961 6437 6962 !------------------------------------------------------------------------------ !6438 !--------------------------------------------------------------------------------------------------! 6963 6439 ! Description: 6964 6440 ! ------------ 6965 6441 !> Write a set of global attributes to file. 6966 !------------------------------------------------------------------------------ !6442 !--------------------------------------------------------------------------------------------------! 6967 6443 SUBROUTINE netcdf_create_global_atts( ncid, data_content, title, error_no ) 6968 6444 6969 USE control_parameters, &6445 USE control_parameters, & 6970 6446 ONLY: revision, run_date, run_time, run_zone, runnr, version 6971 6447 6972 USE netcdf_data_input_mod, &6448 USE netcdf_data_input_mod, & 6973 6449 ONLY: input_file_atts 6974 6450 6975 USE palm_date_time_mod, &6451 USE palm_date_time_mod, & 6976 6452 ONLY: date_time_str_len, get_date_time 6977 6453 … … 6985 6461 INTEGER, INTENT(IN) :: error_no !< error number 6986 6462 INTEGER, INTENT(IN) :: ncid !< file id 6463 6987 6464 ! 6988 6465 !-- Get date-time string for origin_time … … 6994 6471 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'Conventions', 'CF-1.7' ) 6995 6472 CALL netcdf_handle_error( 'netcdf_create_global_atts 2', error_no ) 6996 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'creation_time', TRIM( run_date )//' '//TRIM( run_time )//' '//run_zone(1:3) ) 6473 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'creation_time', TRIM( run_date ) // ' ' // & 6474 TRIM( run_time ) // ' ' // run_zone(1:3) ) 6997 6475 CALL netcdf_handle_error( 'netcdf_create_global_atts 3', error_no ) 6998 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'data_content', TRIM( data_content) )6476 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'data_content', TRIM( data_content ) ) 6999 6477 CALL netcdf_handle_error( 'netcdf_create_global_atts 4', error_no ) 7000 6478 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'version', runnr+1 ) … … 7021 6499 CALL netcdf_handle_error( 'netcdf_create_global_atts 14', error_no ) 7022 6500 7023 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%author_char ), TRIM( input_file_atts%author ) ) 6501 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%author_char ), & 6502 TRIM( input_file_atts%author ) ) 7024 6503 CALL netcdf_handle_error( 'netcdf_create_global_atts 15', error_no ) 7025 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%contact_person_char ), TRIM( input_file_atts%contact_person ) ) 6504 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%contact_person_char ), & 6505 TRIM( input_file_atts%contact_person ) ) 7026 6506 CALL netcdf_handle_error( 'netcdf_create_global_atts 16', error_no ) 7027 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%institution_char ), TRIM( input_file_atts%institution ) ) 6507 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%institution_char ), & 6508 TRIM( input_file_atts%institution ) ) 7028 6509 CALL netcdf_handle_error( 'netcdf_create_global_atts 17', error_no ) 7029 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%acronym_char ), TRIM( input_file_atts%acronym ) ) 6510 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%acronym_char ), & 6511 TRIM( input_file_atts%acronym ) ) 7030 6512 CALL netcdf_handle_error( 'netcdf_create_global_atts 18', error_no ) 7031 6513 7032 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%campaign_char ), TRIM( input_file_atts%campaign ) ) 6514 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%campaign_char ), & 6515 TRIM( input_file_atts%campaign ) ) 7033 6516 CALL netcdf_handle_error( 'netcdf_create_global_atts 19', error_no ) 7034 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%location_char ), TRIM( input_file_atts%location ) ) 6517 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%location_char ), & 6518 TRIM( input_file_atts%location ) ) 7035 6519 CALL netcdf_handle_error( 'netcdf_create_global_atts 20', error_no ) 7036 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%site_char ), TRIM( input_file_atts%site ) ) 6520 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%site_char ), & 6521 TRIM( input_file_atts%site ) ) 7037 6522 CALL netcdf_handle_error( 'netcdf_create_global_atts 21', error_no ) 7038 6523 7039 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'source', TRIM( version )//' '//TRIM( revision ) ) 6524 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'source', TRIM( version ) // ' ' // & 6525 TRIM( revision ) ) 7040 6526 CALL netcdf_handle_error( 'netcdf_create_global_atts 22', error_no ) 7041 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%references_char ), TRIM( input_file_atts%references ) ) 6527 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%references_char ), & 6528 TRIM( input_file_atts%references ) ) 7042 6529 CALL netcdf_handle_error( 'netcdf_create_global_atts 23', error_no ) 7043 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%keywords_char ), TRIM( input_file_atts%keywords ) ) 6530 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%keywords_char ), & 6531 TRIM( input_file_atts%keywords ) ) 7044 6532 CALL netcdf_handle_error( 'netcdf_create_global_atts 24', error_no ) 7045 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%licence_char ), TRIM( input_file_atts%licence ) ) 6533 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%licence_char ), & 6534 TRIM( input_file_atts%licence ) ) 7046 6535 CALL netcdf_handle_error( 'netcdf_create_global_atts 25', error_no ) 7047 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%comment_char ), TRIM( input_file_atts%comment ) ) 6536 nc_stat = NF90_PUT_ATT( ncid, NF90_GLOBAL, TRIM( input_file_atts%comment_char ), & 6537 TRIM( input_file_atts%comment ) ) 7048 6538 CALL netcdf_handle_error( 'netcdf_create_global_atts 26', error_no ) 7049 6539 … … 7052 6542 END SUBROUTINE netcdf_create_global_atts 7053 6543 7054 !------------------------------------------------------------------------------ !6544 !--------------------------------------------------------------------------------------------------! 7055 6545 ! Description: 7056 6546 ! ------------ 7057 6547 !> Create a variable holding the coordinate-reference-system information. 7058 !------------------------------------------------------------------------------ !6548 !--------------------------------------------------------------------------------------------------! 7059 6549 SUBROUTINE netcdf_create_crs( ncid, error_no ) 7060 6550 … … 7072 6562 ! 7073 6563 !-- Set attributes 7074 nc_stat = NF90_PUT_ATT( ncid, var_id, 'epsg_code', & 7075 coord_ref_sys%epsg_code ) 6564 nc_stat = NF90_PUT_ATT( ncid, var_id, 'epsg_code', coord_ref_sys%epsg_code ) 7076 6565 CALL netcdf_handle_error( 'netcdf_create_crs', error_no ) 7077 6566 7078 nc_stat = NF90_PUT_ATT( ncid, var_id, 'false_easting', & 7079 coord_ref_sys%false_easting ) 6567 nc_stat = NF90_PUT_ATT( ncid, var_id, 'false_easting', coord_ref_sys%false_easting ) 7080 6568 CALL netcdf_handle_error( 'netcdf_create_crs', error_no ) 7081 6569 7082 nc_stat = NF90_PUT_ATT( ncid, var_id, 'false_northing', & 7083 coord_ref_sys%false_northing ) 6570 nc_stat = NF90_PUT_ATT( ncid, var_id, 'false_northing', coord_ref_sys%false_northing ) 7084 6571 CALL netcdf_handle_error( 'netcdf_create_crs', error_no ) 7085 6572 7086 nc_stat = NF90_PUT_ATT( ncid, var_id, 'grid_mapping_name', & 7087 coord_ref_sys%grid_mapping_name ) 6573 nc_stat = NF90_PUT_ATT( ncid, var_id, 'grid_mapping_name', coord_ref_sys%grid_mapping_name ) 7088 6574 CALL netcdf_handle_error( 'netcdf_create_crs', error_no ) 7089 6575 7090 nc_stat = NF90_PUT_ATT( ncid, var_id, 'inverse_flattening', & 7091 coord_ref_sys%inverse_flattening ) 6576 nc_stat = NF90_PUT_ATT( ncid, var_id, 'inverse_flattening', coord_ref_sys%inverse_flattening ) 7092 6577 CALL netcdf_handle_error( 'netcdf_create_crs', error_no ) 7093 6578 7094 nc_stat = NF90_PUT_ATT( ncid, var_id, 'latitude_of_projection_origin', &6579 nc_stat = NF90_PUT_ATT( ncid, var_id, 'latitude_of_projection_origin', & 7095 6580 coord_ref_sys%latitude_of_projection_origin ) 7096 6581 CALL netcdf_handle_error( 'netcdf_create_crs', error_no ) 7097 6582 7098 nc_stat = NF90_PUT_ATT( ncid, var_id, 'long_name', & 7099 coord_ref_sys%long_name ) 6583 nc_stat = NF90_PUT_ATT( ncid, var_id, 'long_name', coord_ref_sys%long_name ) 7100 6584 CALL netcdf_handle_error( 'netcdf_create_crs', error_no ) 7101 6585 7102 nc_stat = NF90_PUT_ATT( ncid, var_id, 'longitude_of_central_meridian', &6586 nc_stat = NF90_PUT_ATT( ncid, var_id, 'longitude_of_central_meridian', & 7103 6587 coord_ref_sys%longitude_of_central_meridian ) 7104 6588 CALL netcdf_handle_error( 'netcdf_create_crs', error_no ) 7105 6589 7106 nc_stat = NF90_PUT_ATT( ncid, var_id, 'longitude_of_prime_meridian', &6590 nc_stat = NF90_PUT_ATT( ncid, var_id, 'longitude_of_prime_meridian', & 7107 6591 coord_ref_sys%longitude_of_prime_meridian ) 7108 6592 CALL netcdf_handle_error( 'netcdf_create_crs', error_no ) 7109 6593 7110 nc_stat = NF90_PUT_ATT( ncid, var_id, 'scale_factor_at_central_meridian', &6594 nc_stat = NF90_PUT_ATT( ncid, var_id, 'scale_factor_at_central_meridian', & 7111 6595 coord_ref_sys%scale_factor_at_central_meridian ) 7112 6596 CALL netcdf_handle_error( 'netcdf_create_crs', error_no ) 7113 6597 7114 nc_stat = NF90_PUT_ATT( ncid, var_id, 'semi_major_axis', & 7115 coord_ref_sys%semi_major_axis ) 6598 nc_stat = NF90_PUT_ATT( ncid, var_id, 'semi_major_axis', coord_ref_sys%semi_major_axis ) 7116 6599 CALL netcdf_handle_error( 'netcdf_create_crs', error_no ) 7117 6600 7118 nc_stat = NF90_PUT_ATT( ncid, var_id, 'units', & 7119 coord_ref_sys%units ) 6601 nc_stat = NF90_PUT_ATT( ncid, var_id, 'units', coord_ref_sys%units ) 7120 6602 CALL netcdf_handle_error( 'netcdf_create_crs', error_no ) 7121 6603 … … 7124 6606 7125 6607 7126 !------------------------------------------------------------------------------ !6608 !--------------------------------------------------------------------------------------------------! 7127 6609 ! Description: 7128 6610 ! ------------ 7129 6611 !> Define UTM coordinates and longitude and latitude in file. 7130 !------------------------------------------------------------------------------! 7131 SUBROUTINE define_geo_coordinates( id_set, id_dim_x, id_dim_y, id_var_eutm, id_var_nutm, id_var_lat, id_var_lon ) 6612 !--------------------------------------------------------------------------------------------------! 6613 SUBROUTINE define_geo_coordinates( id_set, id_dim_x, id_dim_y, id_var_eutm, id_var_nutm, & 6614 id_var_lat, id_var_lon ) 7132 6615 7133 6616 IMPLICIT NONE … … 7143 6626 INTEGER(iwp), DIMENSION(0:2), INTENT(OUT) :: id_var_lon !< variable id for longitude coordinates 7144 6627 INTEGER(iwp), DIMENSION(0:2), INTENT(OUT) :: id_var_nutm !< variable id for N_UTM coordinates 6628 7145 6629 7146 6630 ! … … 7155 6639 !-- Define UTM coordinates 7156 6640 IF ( rotation_angle == 0.0_wp ) THEN 7157 CALL netcdf_create_var( id_set, (/ id_dim_x(0) /), 'E_UTM', NF90_DOUBLE, id_var_eutm(0), 'm', 'easting', 000, 000, 000 ) 7158 CALL netcdf_create_var( id_set, (/ id_dim_y(0) /), 'N_UTM', NF90_DOUBLE, id_var_nutm(0), 'm', 'northing', 000, 000, 000 ) 7159 CALL netcdf_create_var( id_set, (/ id_dim_x(1) /), 'Eu_UTM', NF90_DOUBLE, id_var_eutm(1), 'm', 'easting', 000, 000, 000 ) 7160 CALL netcdf_create_var( id_set, (/ id_dim_y(0) /), 'Nu_UTM', NF90_DOUBLE, id_var_nutm(1), 'm', 'northing', 000, 000, 000 ) 7161 CALL netcdf_create_var( id_set, (/ id_dim_x(0) /), 'Ev_UTM', NF90_DOUBLE, id_var_eutm(2), 'm', 'easting', 000, 000, 000 ) 7162 CALL netcdf_create_var( id_set, (/ id_dim_y(1) /), 'Nv_UTM', NF90_DOUBLE, id_var_nutm(2), 'm', 'northing', 000, 000, 000 ) 6641 CALL netcdf_create_var( id_set, (/ id_dim_x(0) /), 'E_UTM', NF90_DOUBLE, id_var_eutm(0), & 6642 'm', 'easting', 000, 000, 000 ) 6643 CALL netcdf_create_var( id_set, (/ id_dim_y(0) /), 'N_UTM', NF90_DOUBLE, id_var_nutm(0), & 6644 'm', 'northing', 000, 000, 000 ) 6645 CALL netcdf_create_var( id_set, (/ id_dim_x(1) /), 'Eu_UTM', NF90_DOUBLE, id_var_eutm(1), & 6646 'm', 'easting', 000, 000, 000 ) 6647 CALL netcdf_create_var( id_set, (/ id_dim_y(0) /), 'Nu_UTM', NF90_DOUBLE, id_var_nutm(1), & 6648 'm', 'northing', 000, 000, 000 ) 6649 CALL netcdf_create_var( id_set, (/ id_dim_x(0) /), 'Ev_UTM', NF90_DOUBLE, id_var_eutm(2), & 6650 'm', 'easting', 000, 000, 000 ) 6651 CALL netcdf_create_var( id_set, (/ id_dim_y(1) /), 'Nv_UTM', NF90_DOUBLE, id_var_nutm(2), & 6652 'm', 'northing', 000, 000, 000 ) 7163 6653 ELSE 7164 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(0) /), & 7165 'E_UTM', NF90_DOUBLE, id_var_eutm(0), 'm', 'easting', 000, 000, 000 ) 7166 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(0) /), & 7167 'N_UTM', NF90_DOUBLE, id_var_nutm(0), 'm', 'northing', 000, 000, 000 ) 7168 CALL netcdf_create_var( id_set, (/ id_dim_x(1), id_dim_y(0) /), & 7169 'Eu_UTM', NF90_DOUBLE, id_var_eutm(1), 'm', 'easting', 000, 000, 000 ) 7170 CALL netcdf_create_var( id_set, (/ id_dim_x(1), id_dim_y(0) /), & 7171 'Nu_UTM', NF90_DOUBLE, id_var_nutm(1), 'm', 'northing', 000, 000, 000 ) 7172 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(1) /), & 7173 'Ev_UTM', NF90_DOUBLE, id_var_eutm(2), 'm', 'easting', 000, 000, 000 ) 7174 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(1) /), & 7175 'Nv_UTM', NF90_DOUBLE, id_var_nutm(2), 'm', 'northing', 000, 000, 000 ) 6654 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(0) /), & 6655 'E_UTM', NF90_DOUBLE, id_var_eutm(0), 'm', 'easting', & 6656 000, 000, 000 ) 6657 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(0) /), & 6658 'N_UTM', NF90_DOUBLE, id_var_nutm(0), 'm', 'northing', & 6659 000, 000, 000 ) 6660 CALL netcdf_create_var( id_set, (/ id_dim_x(1), id_dim_y(0) /), & 6661 'Eu_UTM', NF90_DOUBLE, id_var_eutm(1), 'm', 'easting', & 6662 000, 000, 000 ) 6663 CALL netcdf_create_var( id_set, (/ id_dim_x(1), id_dim_y(0) /), & 6664 'Nu_UTM', NF90_DOUBLE, id_var_nutm(1), 'm', 'northing', & 6665 000, 000, 000 ) 6666 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(1) /), & 6667 'Ev_UTM', NF90_DOUBLE, id_var_eutm(2), 'm', 'easting', & 6668 000, 000, 000 ) 6669 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(1) /), & 6670 'Nv_UTM', NF90_DOUBLE, id_var_nutm(2), 'm', 'northing', & 6671 000, 000, 000 ) 7176 6672 ENDIF 7177 6673 ! 7178 6674 !-- Define geographic coordinates 7179 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(0) /), 'lon', NF90_DOUBLE, id_var_lon(0),&7180 'degrees_east', 'longitude', 000, 000, 000 )7181 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(0) /), 'lat', NF90_DOUBLE, id_var_lat(0),&7182 'degrees_north', 'latitude', 000, 000, 000 )7183 CALL netcdf_create_var( id_set, (/ id_dim_x(1), id_dim_y(0) /), 'lonu', NF90_DOUBLE, id_var_lon(1),&7184 'degrees_east', 'longitude', 000, 000, 000 )7185 CALL netcdf_create_var( id_set, (/ id_dim_x(1), id_dim_y(0) /), 'latu', NF90_DOUBLE, id_var_lat(1),&7186 'degrees_north', 'latitude', 000, 000, 000 )7187 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(1) /), 'lonv', NF90_DOUBLE, id_var_lon(2),&7188 'degrees_east', 'longitude', 000, 000, 000 )7189 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(1) /), 'latv', NF90_DOUBLE, id_var_lat(2),&7190 'degrees_north', 'latitude', 000, 000, 000 )6675 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(0) /), 'lon', NF90_DOUBLE, & 6676 id_var_lon(0), 'degrees_east', 'longitude', 000, 000, 000 ) 6677 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(0) /), 'lat', NF90_DOUBLE, & 6678 id_var_lat(0), 'degrees_north', 'latitude', 000, 000, 000 ) 6679 CALL netcdf_create_var( id_set, (/ id_dim_x(1), id_dim_y(0) /), 'lonu', NF90_DOUBLE, & 6680 id_var_lon(1), 'degrees_east', 'longitude', 000, 000, 000 ) 6681 CALL netcdf_create_var( id_set, (/ id_dim_x(1), id_dim_y(0) /), 'latu', NF90_DOUBLE, & 6682 id_var_lat(1), 'degrees_north', 'latitude', 000, 000, 000 ) 6683 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(1) /), 'lonv', NF90_DOUBLE, & 6684 id_var_lon(2), 'degrees_east', 'longitude', 000, 000, 000 ) 6685 CALL netcdf_create_var( id_set, (/ id_dim_x(0), id_dim_y(1) /), 'latv', NF90_DOUBLE, & 6686 id_var_lat(2), 'degrees_north', 'latitude', 000, 000, 000 ) 7191 6687 7192 6688 DO i = 0, 2 7193 CALL netcdf_create_att( id_set, id_var_eutm(i), 'standard_name', 'projection_x_coordinate', 000) 7194 CALL netcdf_create_att( id_set, id_var_nutm(i), 'standard_name', 'projection_y_coordinate', 000) 7195 7196 CALL netcdf_create_att( id_set, id_var_lat(i), 'standard_name', 'latitude', 000) 7197 CALL netcdf_create_att( id_set, id_var_lon(i), 'standard_name', 'longitude', 000) 6689 CALL netcdf_create_att( id_set, id_var_eutm(i), 'standard_name', 'projection_x_coordinate', & 6690 000 ) 6691 CALL netcdf_create_att( id_set, id_var_nutm(i), 'standard_name', 'projection_y_coordinate', & 6692 000 ) 6693 6694 CALL netcdf_create_att( id_set, id_var_lat(i), 'standard_name', 'latitude', 000 ) 6695 CALL netcdf_create_att( id_set, id_var_lon(i), 'standard_name', 'longitude', 000 ) 7198 6696 ENDDO 7199 6697
Note: See TracChangeset
for help on using the changeset viewer.