Changeset 1783 for palm/trunk/SOURCE/netcdf_interface.f90
- Timestamp:
- Mar 6, 2016 6:36:17 PM (7 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/netcdf_interface.f90
r1782 r1783 1 !> @file netcdf .f901 !> @file netcdf_interface.f90 2 2 !--------------------------------------------------------------------------------! 3 3 ! This file is part of PALM. … … 19 19 ! Current revisions: 20 20 ! ------------------ 21 ! 21 ! netcdf interface has been modularized, former file netcdf renamed to 22 ! netcdf_interface, creation of netcdf-dimensions and -variables moved to 23 ! specific new subroutines create_netcdf_dim and create_netcdf_var, 24 ! compression (deflation) of variables implemented, 25 ! ibmy special cpp directive removed 22 26 ! 23 27 ! Former revisions: … … 120 124 !> cover every exception (change of dt_do, end_time in restart) 121 125 !------------------------------------------------------------------------------! 122 #if defined( __ibmy_special ) 123 @PROCESS NOOPTimize 126 MODULE netcdf_interface 127 128 USE control_parameters, ONLY: max_masks 129 USE kinds 130 #if defined( __netcdf ) 131 USE NETCDF 124 132 #endif 125 SUBROUTINE define_netcdf_header( callmode, extend, av ) 133 134 PRIVATE 135 136 INTEGER(iwp), PARAMETER :: dopr_norm_num = 7, dopts_num = 29, dots_max = 100 137 138 CHARACTER (LEN=6), DIMENSION(dopr_norm_num) :: dopr_norm_names = & 139 (/ 'wpt0 ', 'ws2 ', 'tsw2 ', 'ws3 ', 'ws2tsw', 'wstsw2', & 140 'z_i ' /) 141 142 CHARACTER (LEN=6), DIMENSION(dopr_norm_num) :: dopr_norm_longnames = & 143 (/ 'wpt0 ', 'w*2 ', 't*w2 ', 'w*3 ', 'w*2t*w', 'w*t*w2', & 144 'z_i ' /) 145 146 CHARACTER (LEN=7), DIMENSION(dopts_num) :: dopts_label = & 147 (/ 'tnpt ', 'x_ ', 'y_ ', 'z_ ', 'z_abs ', 'u ', & 148 'v ', 'w ', 'u" ', 'v" ', 'w" ', 'npt_up ', & 149 'w_up ', 'w_down ', 'radius ', 'r_min ', 'r_max ', 'npt_max', & 150 'npt_min', 'x*2 ', 'y*2 ', 'z*2 ', 'u*2 ', 'v*2 ', & 151 'w*2 ', 'u"2 ', 'v"2 ', 'w"2 ', 'npt*2 ' /) 152 153 CHARACTER (LEN=7), DIMENSION(dopts_num) :: dopts_unit = & 154 (/ 'number ', 'm ', 'm ', 'm ', 'm ', 'm/s ', & 155 'm/s ', 'm/s ', 'm/s ', 'm/s ', 'm/s ', 'number ', & 156 'm/s ', 'm/s ', 'm ', 'm ', 'm ', 'number ', & 157 'number ', 'm2 ', 'm2 ', 'm2 ', 'm2/s2 ', 'm2/s2 ', & 158 'm2/s2 ', 'm2/s2 ', 'm2/s2 ', 'm2/s2 ', 'number2' /) 159 160 INTEGER(iwp) :: dots_num = 31 !< number of timeseries defined by default 161 INTEGER(iwp) :: dots_soil = 24 !< starting index for soil-timeseries 162 INTEGER(iwp) :: dots_rad = 32 !< starting index for radiation-timeseries 163 164 CHARACTER (LEN=13), DIMENSION(dots_max) :: dots_label = & 165 (/ 'E ', 'E* ', 'dt ', & 166 'u* ', 'th* ', 'umax ', & 167 'vmax ', 'wmax ', 'div_new ', & 168 'div_old ', 'z_i_wpt ', 'z_i_pt ', & 169 'w* ', 'w"pt"0 ', 'w"pt" ', & 170 'wpt ', 'pt(0) ', 'pt(z_mo) ', & 171 'w"u"0 ', 'w"v"0 ', 'w"q"0 ', & 172 'ol ', 'q* ', 'ghf_eb ', & 173 'shf_eb ', 'qsws_eb ', 'qsws_liq_eb ', & 174 'qsws_soil_eb ', 'qsws_veg_eb ', 'r_a ', & 175 'r_s ', 'rad_net ', 'rad_lw_in ', & 176 'rad_lw_out ', 'rad_sw_in ', 'rad_sw_out ', & 177 'rrtm_aldif ', 'rrtm_aldir ', 'rrtm_asdif ', & 178 'rrtm_asdir ', & 179 ( 'unknown ', i9 = 1, dots_max-40 ) /) 180 181 CHARACTER (LEN=13), DIMENSION(dots_max) :: dots_unit = & 182 (/ 'm2/s2 ', 'm2/s2 ', 's ', & 183 'm/s ', 'K ', 'm/s ', & 184 'm/s ', 'm/s ', 's-1 ', & 185 's-1 ', 'm ', 'm ', & 186 'm/s ', 'K m/s ', 'K m/s ', & 187 'K m/s ', 'K ', 'K ', & 188 'm2/s2 ', 'm2/s2 ', 'kg m/s ', & 189 'm ', 'kg/kg ', ' ', & 190 ' ', ' ', ' ', & 191 ' ', 'W/m2 ', 's/m ', & 192 ' ', 'W/m2 ', 'W/m2 ', & 193 'W/m2 ', 'W/m2 ', 'W/m2 ', & 194 ' ', ' ', ' ', & 195 ' ', & 196 ( 'unknown ', i9 = 1, dots_max-40 ) /) 197 198 CHARACTER (LEN=9), DIMENSION(300) :: dopr_unit = 'unknown' 199 200 CHARACTER (LEN=7), DIMENSION(0:1,100) :: do2d_unit, do3d_unit 201 202 CHARACTER (LEN=16), DIMENSION(25) :: prt_var_names = & 203 (/ 'pt_age ', 'pt_dvrp_size ', 'pt_origin_x ', & 204 'pt_origin_y ', 'pt_origin_z ', 'pt_radius ', & 205 'pt_speed_x ', 'pt_speed_y ', 'pt_speed_z ', & 206 'pt_weight_factor', 'pt_x ', 'pt_y ', & 207 'pt_z ', 'pt_color ', 'pt_group ', & 208 'pt_tailpoints ', 'pt_tail_id ', 'pt_density_ratio', & 209 'pt_exp_arg ', 'pt_exp_term ', 'not_used ', & 210 'not_used ', 'not_used ', 'not_used ', & 211 'not_used ' /) 212 213 CHARACTER (LEN=16), DIMENSION(25) :: prt_var_units = & 214 (/ 'seconds ', 'meters ', 'meters ', & 215 'meters ', 'meters ', 'meters ', & 216 'm/s ', 'm/s ', 'm/s ', & 217 'factor ', 'meters ', 'meters ', & 218 'meters ', 'none ', 'none ', & 219 'none ', 'none ', 'ratio ', & 220 'none ', 'none ', 'not_used ', & 221 'not_used ', 'not_used ', 'not_used ', & 222 'not_used ' /) 223 224 CHARACTER(LEN=20), DIMENSION(11) :: netcdf_precision = ' ' 225 CHARACTER(LEN=40) :: netcdf_data_format_string 226 227 INTEGER(iwp) :: id_dim_prtnum, id_dim_time_pr, id_dim_time_prt, & 228 id_dim_time_pts, id_dim_time_sp, id_dim_time_ts, id_dim_x_sp, & 229 id_dim_y_sp, id_dim_zu_sp, id_dim_zw_sp, id_set_pr, & 230 id_set_prt, id_set_pts, id_set_sp, id_set_ts, id_var_prtnum, & 231 id_var_rnop_prt, id_var_time_pr, id_var_time_prt, & 232 id_var_time_pts, id_var_time_sp, id_var_time_ts, id_var_x_sp, & 233 id_var_y_sp, id_var_zu_sp, id_var_zw_sp, nc_stat 234 235 INTEGER(iwp), DIMENSION(0:1) :: id_dim_time_xy, id_dim_time_xz, & 236 id_dim_time_yz, id_dim_time_3d, id_dim_x_xy, id_dim_xu_xy, & 237 id_dim_x_xz, id_dim_xu_xz, id_dim_x_yz, id_dim_xu_yz, & 238 id_dim_x_3d, id_dim_xu_3d, id_dim_y_xy, id_dim_yv_xy, & 239 id_dim_y_xz, id_dim_yv_xz, id_dim_y_yz, id_dim_yv_yz, & 240 id_dim_y_3d, id_dim_yv_3d, id_dim_zs_xy, id_dim_zs_xz, & 241 id_dim_zs_yz, id_dim_zs_3d, id_dim_zu_xy, id_dim_zu1_xy, & 242 id_dim_zu_xz, id_dim_zu_yz, id_dim_zu_3d, id_dim_zw_xy, & 243 id_dim_zw_xz, id_dim_zw_yz, id_dim_zw_3d, id_set_xy, & 244 id_set_xz, id_set_yz, id_set_3d, id_var_ind_x_yz, & 245 id_var_ind_y_xz, id_var_ind_z_xy, id_var_time_xy, & 246 id_var_time_xz, id_var_time_yz, id_var_time_3d, id_var_x_xy, & 247 id_var_xu_xy, id_var_x_xz, id_var_xu_xz, id_var_x_yz, & 248 id_var_xu_yz, id_var_x_3d, id_var_xu_3d, id_var_y_xy, & 249 id_var_yv_xy, id_var_y_xz, id_var_yv_xz, id_var_y_yz, & 250 id_var_yv_yz, id_var_y_3d, id_var_yv_3d, id_var_zs_xy, & 251 id_var_zs_xz, id_var_zs_yz, id_var_zs_3d, id_var_zusi_xy, & 252 id_var_zusi_3d, id_var_zu_xy, id_var_zu1_xy, id_var_zu_xz, & 253 id_var_zu_yz, id_var_zu_3d, id_var_zwwi_xy, id_var_zwwi_3d, & 254 id_var_zw_xy, id_var_zw_xz, id_var_zw_yz, id_var_zw_3d 255 256 INTEGER :: netcdf_data_format = 2 !< NetCDF3 64bit offset format 257 INTEGER :: netcdf_deflate = 0 !< NetCDF compression, default: no 258 !< compression 259 260 INTEGER(iwp), DIMENSION(10) :: id_var_dospx, id_var_dospy 261 INTEGER(iwp), DIMENSION(20) :: id_var_prt 262 INTEGER(iwp), DIMENSION(11) :: nc_precision 263 INTEGER(iwp), DIMENSION(dopr_norm_num) :: id_var_norm_dopr 264 265 INTEGER(iwp), DIMENSION(dopts_num,0:10) :: id_var_dopts 266 INTEGER(iwp), DIMENSION(0:1,100) :: id_var_do2d, id_var_do3d 267 INTEGER(iwp), DIMENSION(100,0:9) :: id_dim_z_pr, id_var_dopr, & 268 id_var_z_pr 269 INTEGER(iwp), DIMENSION(dots_max,0:9) :: id_var_dots 270 271 ! 272 !-- Masked output 273 CHARACTER (LEN=7), DIMENSION(max_masks,0:1,100) :: domask_unit 274 275 LOGICAL :: output_for_t0 = .FALSE. 276 277 INTEGER(iwp), DIMENSION(1:max_masks,0:1) :: id_dim_time_mask, id_dim_x_mask, & 278 id_dim_xu_mask, id_dim_y_mask, id_dim_yv_mask, id_dim_zs_mask, & 279 id_dim_zu_mask, id_dim_zw_mask, & 280 id_set_mask, & 281 id_var_time_mask, id_var_x_mask, id_var_xu_mask, & 282 id_var_y_mask, id_var_yv_mask, id_var_zs_mask, & 283 id_var_zu_mask, id_var_zw_mask, & 284 id_var_zusi_mask, id_var_zwwi_mask 285 286 INTEGER(iwp), DIMENSION(1:max_masks,0:1,100) :: id_var_domask 287 288 289 PUBLIC domask_unit, dopr_unit, dopts_num, dots_label, dots_max, dots_num, & 290 dots_rad, dots_soil, dots_unit, do2d_unit, do3d_unit, id_set_mask, & 291 id_set_pr, id_set_prt, id_set_pts, id_set_sp, id_set_ts, & 292 id_set_xy, id_set_xz, id_set_yz, id_set_3d, id_var_domask, & 293 id_var_dopr, id_var_dopts, id_var_dospx, id_var_dospy, & 294 id_var_dots, id_var_do2d, id_var_do3d, id_var_norm_dopr, & 295 id_var_time_mask, id_var_time_pr, id_var_time_pts, id_var_time_ts, & 296 id_var_time_xy, id_var_time_xz, id_var_time_yz,id_var_time_3d, & 297 nc_stat, netcdf_data_format, netcdf_data_format_string, & 298 netcdf_deflate, netcdf_precision, output_for_t0 299 300 SAVE 301 302 INTERFACE netcdf_create_dim 303 MODULE PROCEDURE netcdf_create_dim 304 END INTERFACE netcdf_create_dim 305 306 INTERFACE netcdf_create_file 307 MODULE PROCEDURE netcdf_create_file 308 END INTERFACE netcdf_create_file 309 310 INTERFACE netcdf_create_var 311 MODULE PROCEDURE netcdf_create_var 312 END INTERFACE netcdf_create_var 313 314 INTERFACE netcdf_define_header 315 MODULE PROCEDURE netcdf_define_header 316 END INTERFACE netcdf_define_header 317 318 INTERFACE netcdf_handle_error 319 MODULE PROCEDURE netcdf_handle_error 320 END INTERFACE netcdf_handle_error 321 322 INTERFACE netcdf_open_write_file 323 MODULE PROCEDURE netcdf_open_write_file 324 END INTERFACE netcdf_open_write_file 325 326 PUBLIC netcdf_create_file, netcdf_define_header, netcdf_handle_error, & 327 netcdf_open_write_file 328 329 CONTAINS 330 331 SUBROUTINE netcdf_define_header( callmode, extend, av ) 126 332 127 333 #if defined( __netcdf ) … … 141 347 dt_do2d_yz, dt_do3d, mask_size, do2d_xy_time_count, & 142 348 do3d_time_count, domask_time_count, end_time, mask_i_global, & 143 mask_j_global, mask_k_global, message_string, mid, & 144 netcdf_data_format, netcdf_precision, ntdim_2d_xy, & 349 mask_j_global, mask_k_global, message_string, mid, ntdim_2d_xy, & 145 350 ntdim_2d_xz, ntdim_2d_yz, ntdim_3d, nz_do3d, prt_time_count, & 146 351 run_description_header, section, simulated_time, & … … 155 360 ONLY: nx, ny, nz ,nzb, nzt 156 361 157 USE netcdf_control158 159 362 USE kinds 160 363 161 364 USE land_surface_model_mod, & 162 ONLY: land_surface, nzb_soil, nzt_soil, id_dim_zs_xy, id_dim_zs_xz, & 163 id_dim_zs_yz, id_dim_zs_3d, id_dim_zs_mask, id_var_zs_xy, & 164 id_var_zs_xz, id_var_zs_yz ,id_var_zs_3d, id_var_zs_mask, & 165 nzs, zs 365 ONLY: land_surface, nzb_soil, nzt_soil, nzs, zs 166 366 167 367 USE pegrid … … 172 372 USE profil_parameter, & 173 373 ONLY: crmax, cross_profiles, dopr_index, profile_columns, profile_rows 174 175 USE radiation_model_mod, &176 ONLY: rad_lw_in, rad_lw_out, rad_lw_cs_hr, rad_lw_hr, &177 rad_sw_in, rad_sw_out, rad_sw_cs_hr, rad_sw_hr178 179 374 180 375 USE spectrum, & … … 250 445 251 446 ! 252 !-- Initializing actions (return to calling routine check_parameters afterwards)447 !-- Initializing actions 253 448 IF ( .NOT. init_netcdf ) THEN 254 449 ! … … 263 458 '"_"netcdf_precision(', i, ')="', & 264 459 TRIM( netcdf_precision(i) ),'"' 265 CALL message( ' define_netcdf_header', 'PA0241', 1, 2, 0, 6, 0 )460 CALL message( 'netcdf_define_header', 'PA0241', 2, 2, 0, 6, 0 ) 266 461 ENDIF 267 462 … … 277 472 'netcdf_precision(', i, ')="', & 278 473 TRIM( netcdf_precision(i) ),'"' 279 CALL message( ' define_netcdf_header', 'PA0242', 1, 2, 0, 6, 0 )474 CALL message( 'netcdf_define_header', 'PA0242', 1, 2, 0, 6, 0 ) 280 475 ENDIF 281 476 … … 308 503 'assignment: netcdf_precision(', i, ')="', & 309 504 TRIM( netcdf_precision(i) ),'"' 310 CALL message( ' define_netcdf_header', 'PA0243', 1, 2, 0, 6, 0 )505 CALL message( 'netcdf_define_header', 'PA0243', 1, 2, 0, 6, 0 ) 311 506 312 507 END SELECT … … 316 511 ENDDO 317 512 513 ! 514 !-- Check for allowed parameter range 515 IF ( netcdf_deflate < 0 .OR. netcdf_deflate > 9 ) THEN 516 WRITE ( message_string, '(A,I3,A)' ) 'netcdf_deflate out of ' // & 517 'range & given value: ', netcdf_deflate, & 518 ', allowed range: 0-9' 519 CALL message( 'netcdf_define_header', 'PA0355', 2, 2, 0, 6, 0 ) 520 ENDIF 521 ! 522 !-- Data compression does not work with parallel NetCDF/HDF5 523 IF ( netcdf_deflate > 0 .AND. netcdf_data_format /= 3 ) THEN 524 message_string = 'netcdf_deflate reset to 0' 525 CALL message( 'netcdf_define_header', 'PA0356', 0, 1, 0, 6, 0 ) 526 527 netcdf_deflate = 0 528 ENDIF 529 318 530 init_netcdf = .TRUE. 319 320 RETURN321 531 322 532 ENDIF … … 352 562 !-- Define some global attributes of the dataset 353 563 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), NF90_GLOBAL, & 354 'Conventions', 'COARDS' )355 CALL handle_netcdf_error( 'netcdf', 464 )564 'Conventions', 'COARDS' ) 565 CALL netcdf_handle_error( 'netcdf_define_header', 464 ) 356 566 357 567 IF ( av == 0 ) THEN … … 364 574 TRIM( run_description_header ) // & 365 575 TRIM( time_average_text ) ) 366 CALL handle_netcdf_error( 'netcdf', 465 )576 CALL netcdf_handle_error( 'netcdf_define_header', 465 ) 367 577 IF ( av == 1 ) THEN 368 578 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval 369 579 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), NF90_GLOBAL, & 370 580 'time_avg', TRIM( time_average_text ) ) 371 CALL handle_netcdf_error( 'netcdf', 466 )581 CALL netcdf_handle_error( 'netcdf_define_header', 466 ) 372 582 ENDIF 373 583 374 584 ! 375 585 !-- Define time coordinate for volume data (unlimited dimension) 376 nc_stat = NF90_DEF_DIM( id_set_mask(mid,av), 'time', NF90_UNLIMITED, & 377 id_dim_time_mask(mid,av) ) 378 CALL handle_netcdf_error( 'netcdf', 467 ) 379 380 nc_stat = NF90_DEF_VAR( id_set_mask(mid,av), 'time', NF90_DOUBLE, & 381 id_dim_time_mask(mid,av), & 382 id_var_time_mask(mid,av) ) 383 CALL handle_netcdf_error( 'netcdf', 468 ) 384 385 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), & 386 id_var_time_mask(mid,av), 'units', & 387 'seconds') 388 CALL handle_netcdf_error( 'netcdf', 469 ) 389 586 CALL netcdf_create_dim( id_set_mask(mid,av), 'time', NF90_UNLIMITED, & 587 id_dim_time_mask(mid,av), 467 ) 588 CALL netcdf_create_var( id_set_mask(mid,av), & 589 (/ id_dim_time_mask(mid,av) /), 'time', & 590 NF90_DOUBLE, id_var_time_mask(mid,av), & 591 'seconds', '', 468, 469, 000 ) 390 592 ! 391 593 !-- Define spatial dimensions and coordinates: 392 594 !-- Define vertical coordinate grid (zu grid) 393 nc_stat = NF90_DEF_DIM( id_set_mask(mid,av), 'zu_3d', & 394 mask_size(mid,3), id_dim_zu_mask(mid,av) ) 395 CALL handle_netcdf_error( 'netcdf', 470 ) 396 397 nc_stat = NF90_DEF_VAR( id_set_mask(mid,av), 'zu_3d', NF90_DOUBLE, & 398 id_dim_zu_mask(mid,av), & 399 id_var_zu_mask(mid,av) ) 400 CALL handle_netcdf_error( 'netcdf', 471 ) 401 402 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), id_var_zu_mask(mid,av), & 403 'units', 'meters' ) 404 CALL handle_netcdf_error( 'netcdf', 472 ) 405 595 CALL netcdf_create_dim( id_set_mask(mid,av), 'zu_3d', & 596 mask_size(mid,3), id_dim_zu_mask(mid,av), & 597 470 ) 598 CALL netcdf_create_var( id_set_mask(mid,av), & 599 (/ id_dim_zu_mask(mid,av) /), 'zu_3d', & 600 NF90_DOUBLE, id_var_zu_mask(mid,av), & 601 'meters', '', 471, 472, 000 ) 406 602 ! 407 603 !-- Define vertical coordinate grid (zw grid) 408 nc_stat = NF90_DEF_DIM( id_set_mask(mid,av), 'zw_3d', & 409 mask_size(mid,3), id_dim_zw_mask(mid,av) ) 410 CALL handle_netcdf_error( 'netcdf', 473 ) 411 412 nc_stat = NF90_DEF_VAR( id_set_mask(mid,av), 'zw_3d', NF90_DOUBLE, & 413 id_dim_zw_mask(mid,av), & 414 id_var_zw_mask(mid,av) ) 415 CALL handle_netcdf_error( 'netcdf', 474 ) 416 417 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), id_var_zw_mask(mid,av), & 418 'units', 'meters' ) 419 CALL handle_netcdf_error( 'netcdf', 475 ) 420 604 CALL netcdf_create_dim( id_set_mask(mid,av), 'zw_3d', & 605 mask_size(mid,3), id_dim_zw_mask(mid,av), & 606 473 ) 607 CALL netcdf_create_var( id_set_mask(mid,av), & 608 (/ id_dim_zw_mask(mid,av) /), 'zw_3d', & 609 NF90_DOUBLE, id_var_zw_mask(mid,av), & 610 'meters', '', 474, 475, 000 ) 421 611 ! 422 612 !-- Define x-axis (for scalar position) 423 nc_stat = NF90_DEF_DIM( id_set_mask(mid,av), 'x', & 424 mask_size(mid,1), id_dim_x_mask(mid,av) ) 425 CALL handle_netcdf_error( 'netcdf', 476 ) 426 427 nc_stat = NF90_DEF_VAR( id_set_mask(mid,av), 'x', NF90_DOUBLE, & 428 id_dim_x_mask(mid,av), id_var_x_mask(mid,av) ) 429 CALL handle_netcdf_error( 'netcdf', 477 ) 430 431 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), id_var_x_mask(mid,av), & 432 'units', 'meters' ) 433 CALL handle_netcdf_error( 'netcdf', 478 ) 434 613 CALL netcdf_create_dim( id_set_mask(mid,av), 'x', mask_size(mid,1), & 614 id_dim_x_mask(mid,av), 476 ) 615 CALL netcdf_create_var( id_set_mask(mid,av), & 616 (/ id_dim_x_mask(mid,av) /), 'x', & 617 NF90_DOUBLE, id_var_x_mask(mid,av), & 618 'meters', '', 477, 478, 000 ) 435 619 ! 436 620 !-- Define x-axis (for u position) 437 nc_stat = NF90_DEF_DIM( id_set_mask(mid,av), 'xu', & 438 mask_size(mid,1), id_dim_xu_mask(mid,av) ) 439 CALL handle_netcdf_error( 'netcdf', 479 ) 440 441 nc_stat = NF90_DEF_VAR( id_set_mask(mid,av), 'xu', NF90_DOUBLE, & 442 id_dim_xu_mask(mid,av), & 443 id_var_xu_mask(mid,av) ) 444 CALL handle_netcdf_error( 'netcdf', 480 ) 445 446 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), id_var_xu_mask(mid,av), & 447 'units', 'meters' ) 448 CALL handle_netcdf_error( 'netcdf', 481 ) 449 621 CALL netcdf_create_dim( id_set_mask(mid,av), 'xu', mask_size(mid,1), & 622 id_dim_xu_mask(mid,av), 479 ) 623 CALL netcdf_create_var( id_set_mask(mid,av), & 624 (/ id_dim_xu_mask(mid,av) /), 'xu', & 625 NF90_DOUBLE, id_var_xu_mask(mid,av), & 626 'meters', '', 480, 481, 000 ) 450 627 ! 451 628 !-- Define y-axis (for scalar position) 452 nc_stat = NF90_DEF_DIM( id_set_mask(mid,av), 'y', & 453 mask_size(mid,2), id_dim_y_mask(mid,av) ) 454 CALL handle_netcdf_error( 'netcdf', 482 ) 455 456 nc_stat = NF90_DEF_VAR( id_set_mask(mid,av), 'y', NF90_DOUBLE, & 457 id_dim_y_mask(mid,av), id_var_y_mask(mid,av) ) 458 CALL handle_netcdf_error( 'netcdf', 483 ) 459 460 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), id_var_y_mask(mid,av), & 461 'units', 'meters' ) 462 CALL handle_netcdf_error( 'netcdf', 484 ) 463 629 CALL netcdf_create_dim( id_set_mask(mid,av), 'y', mask_size(mid,2), & 630 id_dim_y_mask(mid,av), 482 ) 631 CALL netcdf_create_var( id_set_mask(mid,av), & 632 (/ id_dim_y_mask(mid,av) /), 'y', & 633 NF90_DOUBLE, id_var_y_mask(mid,av), & 634 'meters', '', 483, 484, 000 ) 464 635 ! 465 636 !-- Define y-axis (for v position) 466 nc_stat = NF90_DEF_DIM( id_set_mask(mid,av), 'yv', & 467 mask_size(mid,2), id_dim_yv_mask(mid,av) ) 468 CALL handle_netcdf_error( 'netcdf', 485 ) 469 470 nc_stat = NF90_DEF_VAR( id_set_mask(mid,av), 'yv', NF90_DOUBLE, & 471 id_dim_yv_mask(mid,av), & 472 id_var_yv_mask(mid,av) ) 473 CALL handle_netcdf_error( 'netcdf', 486 ) 474 475 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), id_var_yv_mask(mid,av), & 476 'units', 'meters' ) 477 CALL handle_netcdf_error( 'netcdf', 487 ) 478 637 CALL netcdf_create_dim( id_set_mask(mid,av), 'yv', mask_size(mid,2), & 638 id_dim_yv_mask(mid,av), 485 ) 639 CALL netcdf_create_var( id_set_mask(mid,av), & 640 (/ id_dim_yv_mask(mid,av) /), & 641 'yv', NF90_DOUBLE, id_var_yv_mask(mid,av), & 642 'meters', '', 486, 487, 000 ) 479 643 ! 480 644 !-- In case of non-flat topography define 2d-arrays containing the height … … 483 647 ! 484 648 !-- Define zusi = zu(nzb_s_inner) 485 nc_stat = NF90_DEF_VAR( id_set_mask(mid,av), 'zusi', NF90_DOUBLE, & 486 (/ id_dim_x_mask(mid,av), & 487 id_dim_y_mask(mid,av) /), & 488 id_var_zusi_mask(mid,av) ) 489 CALL handle_netcdf_error( 'netcdf', 488 ) 490 491 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), & 492 id_var_zusi_mask(mid,av), & 493 'units', 'meters' ) 494 CALL handle_netcdf_error( 'netcdf', 489 ) 495 496 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), & 497 id_var_zusi_mask(mid,av), & 498 'long_name', 'zu(nzb_s_inner)' ) 499 CALL handle_netcdf_error( 'netcdf', 490 ) 500 649 CALL netcdf_create_var( id_set_mask(mid,av), & 650 (/ id_dim_x_mask(mid,av), & 651 id_dim_y_mask(mid,av) /), 'zusi', & 652 NF90_DOUBLE, id_var_zusi_mask(mid,av), & 653 'meters', 'zu(nzb_s_inner)', 488, 489, & 654 490 ) 501 655 ! 502 656 !-- Define zwwi = zw(nzb_w_inner) 503 nc_stat = NF90_DEF_VAR( id_set_mask(mid,av), 'zwwi', NF90_DOUBLE, & 504 (/ id_dim_x_mask(mid,av), & 505 id_dim_y_mask(mid,av) /), & 506 id_var_zwwi_mask(mid,av) ) 507 CALL handle_netcdf_error( 'netcdf', 491 ) 508 509 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), & 510 id_var_zwwi_mask(mid,av), & 511 'units', 'meters' ) 512 CALL handle_netcdf_error( 'netcdf', 492 ) 513 514 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), & 515 id_var_zwwi_mask(mid,av), & 516 'long_name', 'zw(nzb_w_inner)' ) 517 CALL handle_netcdf_error( 'netcdf', 493 ) 518 657 CALL netcdf_create_var( id_set_mask(mid,av), & 658 (/ id_dim_x_mask(mid,av), & 659 id_dim_y_mask(mid,av) /), 'zwwi', & 660 NF90_DOUBLE, id_var_zwwi_mask(mid,av), & 661 'meters', 'zw(nzb_w_inner)', 491, 492, & 662 493 ) 519 663 ENDIF 520 664 … … 522 666 ! 523 667 !-- Define vertical coordinate grid (zw grid) 524 nc_stat = NF90_DEF_DIM( id_set_mask(mid,av), 'zs_3d', & 525 mask_size(mid,3), id_dim_zs_mask(mid,av) ) 526 CALL handle_netcdf_error( 'netcdf', 536 ) 527 528 nc_stat = NF90_DEF_VAR( id_set_mask(mid,av), 'zs_3d', NF90_DOUBLE, & 529 id_dim_zs_mask(mid,av), & 530 id_var_zs_mask(mid,av) ) 531 CALL handle_netcdf_error( 'netcdf', 536 ) 532 533 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), id_var_zs_mask(mid,av), & 534 'units', 'meters' ) 535 CALL handle_netcdf_error( 'netcdf', 537 ) 536 668 CALL netcdf_create_dim( id_set_mask(mid,av), 'zs_3d', & 669 mask_size(mid,3), id_dim_zs_mask(mid,av), & 670 536 ) 671 CALL netcdf_create_var( id_set_mask(mid,av), & 672 (/ id_dim_zs_mask(mid,av) /), 'zs_3d', & 673 NF90_DOUBLE, id_var_zs_mask(mid,av), & 674 'meters', '', 537, 555, 000 ) 537 675 ENDIF 538 676 … … 591 729 ! 592 730 !-- Check for user-defined quantities 593 CALL user_define_netcdf_grid( domask(mid,av,i), found, &731 CALL user_define_netcdf_grid( domask(mid,av,i), found, & 594 732 grid_x, grid_y, grid_z ) 733 734 IF ( .NOT. found ) THEN 735 WRITE ( message_string, * ) 'no grid defined for', & 736 ' variable ', TRIM( domask(mid,av,i) ) 737 CALL message( 'define_netcdf_header', 'PA0244', 0, 1, 0, & 738 6, 0 ) 739 ENDIF 595 740 596 741 END SELECT … … 620 765 ! 621 766 !-- Define the grid 622 nc_stat = NF90_DEF_VAR( id_set_mask(mid,av), domask(mid,av,i), & 623 nc_precision(11), & 624 (/ id_x, id_y, id_z, & 625 id_dim_time_mask(mid,av) /), & 626 id_var_domask(mid,av,i) ) 627 628 IF ( .NOT. found ) THEN 629 WRITE ( message_string, * ) 'no grid defined for', & 630 ' variable ', TRIM( domask(mid,av,i) ) 631 CALL message( 'define_netcdf_header', 'PA0244', 0, 1, 0, 6, 0 ) 632 ENDIF 767 CALL netcdf_create_var( id_set_mask(mid,av), (/ id_x, id_y, id_z, & 768 id_dim_time_mask(mid,av) /), & 769 domask(mid,av,i), nc_precision(11), & 770 id_var_domask(mid,av,i), & 771 TRIM( domask_unit(mid,av,i) ), & 772 domask(mid,av,i), 494, 495, 496 ) 633 773 634 774 var_list = TRIM( var_list ) // TRIM( domask(mid,av,i) ) // ';' 635 636 CALL handle_netcdf_error( 'netcdf', 494 )637 !638 !-- Store the 'real' name of the variable (with *, for example)639 !-- in the long_name attribute. This is evaluated by Ferret,640 !-- for example.641 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), &642 id_var_domask(mid,av,i), &643 'long_name', domask(mid,av,i) )644 CALL handle_netcdf_error( 'netcdf', 495 )645 !646 !-- Define the variable's unit647 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), &648 id_var_domask(mid,av,i), &649 'units', TRIM( domask_unit(mid,av,i) ) )650 CALL handle_netcdf_error( 'netcdf', 496 )651 775 652 776 i = i + 1 … … 663 787 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), NF90_GLOBAL, & 664 788 'VAR_LIST', var_list ) 665 CALL handle_netcdf_error( 'netcdf', 497 )789 CALL netcdf_handle_error( 'netcdf_define_header', 497 ) 666 790 667 791 ! 668 792 !-- Leave netCDF define mode 669 793 nc_stat = NF90_ENDDEF( id_set_mask(mid,av) ) 670 CALL handle_netcdf_error( 'netcdf', 498 )794 CALL netcdf_handle_error( 'netcdf_define_header', 498 ) 671 795 672 796 ! … … 679 803 netcdf_data, start = (/ 1 /), & 680 804 count = (/ mask_size(mid,1) /) ) 681 CALL handle_netcdf_error( 'netcdf', 499 )805 CALL netcdf_handle_error( 'netcdf_define_header', 499 ) 682 806 683 807 netcdf_data = mask_i_global(mid,:mask_size(mid,1)) * dx … … 686 810 netcdf_data, start = (/ 1 /), & 687 811 count = (/ mask_size(mid,1) /) ) 688 CALL handle_netcdf_error( 'netcdf', 500 )812 CALL netcdf_handle_error( 'netcdf_define_header', 500 ) 689 813 690 814 DEALLOCATE( netcdf_data ) … … 699 823 netcdf_data, start = (/ 1 /), & 700 824 count = (/ mask_size(mid,2) /)) 701 CALL handle_netcdf_error( 'netcdf', 501 )825 CALL netcdf_handle_error( 'netcdf_define_header', 501 ) 702 826 703 827 netcdf_data = mask_j_global(mid,:mask_size(mid,2)) * dy … … 706 830 netcdf_data, start = (/ 1 /), & 707 831 count = (/ mask_size(mid,2) /)) 708 CALL handle_netcdf_error( 'netcdf', 502 )832 CALL netcdf_handle_error( 'netcdf_define_header', 502 ) 709 833 710 834 DEALLOCATE( netcdf_data ) … … 719 843 netcdf_data, start = (/ 1 /), & 720 844 count = (/ mask_size(mid,3) /) ) 721 CALL handle_netcdf_error( 'netcdf', 503 )845 CALL netcdf_handle_error( 'netcdf_define_header', 503 ) 722 846 723 847 netcdf_data = zw( mask_k_global(mid,:mask_size(mid,3)) ) … … 726 850 netcdf_data, start = (/ 1 /), & 727 851 count = (/ mask_size(mid,3) /) ) 728 CALL handle_netcdf_error( 'netcdf', 504 )852 CALL netcdf_handle_error( 'netcdf_define_header', 504 ) 729 853 730 854 DEALLOCATE( netcdf_data ) … … 744 868 count = (/ mask_size(mid,1), & 745 869 mask_size(mid,2) /) ) 746 CALL handle_netcdf_error( 'netcdf', 505 )870 CALL netcdf_handle_error( 'netcdf_define_header', 505 ) 747 871 748 872 netcdf_data_2d = zw_w_inner( mask_i_global(mid,:mask_size(mid,1)),& … … 755 879 count = (/ mask_size(mid,1), & 756 880 mask_size(mid,2) /) ) 757 CALL handle_netcdf_error( 'netcdf', 506 )881 CALL netcdf_handle_error( 'netcdf_define_header', 506 ) 758 882 759 883 DEALLOCATE( netcdf_data_2d ) … … 772 896 netcdf_data, start = (/ 1 /), & 773 897 count = (/ mask_size(mid,3) /) ) 774 CALL handle_netcdf_error( 'netcdf', 538 )898 CALL netcdf_handle_error( 'netcdf_define_header', 538 ) 775 899 776 900 DEALLOCATE( netcdf_data ) … … 804 928 nc_stat = NF90_GET_ATT( id_set_mask(mid,av), NF90_GLOBAL, 'VAR_LIST',& 805 929 var_list_old ) 806 CALL handle_netcdf_error( 'netcdf', 507 )930 CALL netcdf_handle_error( 'netcdf_define_header', 507 ) 807 931 808 932 var_list = ';' … … 833 957 nc_stat = NF90_INQ_VARID( id_set_mask(mid,av), 'zu_3d', & 834 958 id_var_zu_mask(mid,av) ) 835 CALL handle_netcdf_error( 'netcdf', 508 )959 CALL netcdf_handle_error( 'netcdf_define_header', 508 ) 836 960 837 961 nc_stat = NF90_INQUIRE_VARIABLE( id_set_mask(mid,av), & 838 962 id_var_zu_mask(mid,av), & 839 963 dimids = id_dim_zu_mask_old ) 840 CALL handle_netcdf_error( 'netcdf', 509 )964 CALL netcdf_handle_error( 'netcdf_define_header', 509 ) 841 965 id_dim_zu_mask(mid,av) = id_dim_zu_mask_old(1) 842 966 … … 844 968 id_dim_zu_mask(mid,av), & 845 969 len = nz_old ) 846 CALL handle_netcdf_error( 'netcdf', 510 )970 CALL netcdf_handle_error( 'netcdf_define_header', 510 ) 847 971 848 972 IF ( mask_size(mid,3) /= nz_old ) THEN … … 864 988 nc_stat = NF90_INQ_VARID( id_set_mask(mid,av), 'time', & 865 989 id_var_time_mask(mid,av) ) 866 CALL handle_netcdf_error( 'netcdf', 511 )990 CALL netcdf_handle_error( 'netcdf_define_header', 511 ) 867 991 868 992 nc_stat = NF90_INQUIRE_VARIABLE( id_set_mask(mid,av), & 869 993 id_var_time_mask(mid,av), & 870 994 dimids = id_dim_time_old ) 871 CALL handle_netcdf_error( 'netcdf', 512 )995 CALL netcdf_handle_error( 'netcdf_define_header', 512 ) 872 996 id_dim_time_mask(mid,av) = id_dim_time_old(1) 873 997 … … 875 999 id_dim_time_mask(mid,av), & 876 1000 len = domask_time_count(mid,av) ) 877 CALL handle_netcdf_error( 'netcdf', 513 )1001 CALL netcdf_handle_error( 'netcdf_define_header', 513 ) 878 1002 879 1003 nc_stat = NF90_GET_VAR( id_set_mask(mid,av), & … … 882 1006 start = (/ domask_time_count(mid,av) /), & 883 1007 count = (/ 1 /) ) 884 CALL handle_netcdf_error( 'netcdf', 514 )1008 CALL netcdf_handle_error( 'netcdf_define_header', 514 ) 885 1009 886 1010 IF ( last_time_coordinate(1) >= simulated_time ) THEN … … 904 1028 TRIM( domask(mid,av,i) ), & 905 1029 id_var_domask(mid,av,i) ) 906 CALL handle_netcdf_error( 'netcdf', 515 )1030 CALL netcdf_handle_error( 'netcdf_define_header', 515 ) 907 1031 i = i + 1 908 1032 ENDDO … … 922 1046 ENDIF 923 1047 nc_stat = NF90_REDEF( id_set_mask(mid,av) ) 924 CALL handle_netcdf_error( 'netcdf', 516 )1048 CALL netcdf_handle_error( 'netcdf_define_header', 516 ) 925 1049 nc_stat = NF90_PUT_ATT( id_set_mask(mid,av), NF90_GLOBAL, 'title', & 926 1050 TRIM( run_description_header ) // & 927 1051 TRIM( time_average_text ) ) 928 CALL handle_netcdf_error( 'netcdf', 517 )1052 CALL netcdf_handle_error( 'netcdf_define_header', 517 ) 929 1053 nc_stat = NF90_ENDDEF( id_set_mask(mid,av) ) 930 CALL handle_netcdf_error( 'netcdf', 518 )1054 CALL netcdf_handle_error( 'netcdf_define_header', 518 ) 931 1055 WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), & 932 1056 ' data for mask', mid, ' from previous run found.', & … … 944 1068 nc_stat = NF90_PUT_ATT( id_set_3d(av), NF90_GLOBAL, 'Conventions', & 945 1069 'COARDS' ) 946 CALL handle_netcdf_error( 'netcdf', 62 )1070 CALL netcdf_handle_error( 'netcdf_define_header', 62 ) 947 1071 948 1072 IF ( av == 0 ) THEN … … 955 1079 TRIM( run_description_header ) // & 956 1080 TRIM( time_average_text ) ) 957 CALL handle_netcdf_error( 'netcdf', 63 )1081 CALL netcdf_handle_error( 'netcdf_define_header', 63 ) 958 1082 IF ( av == 1 ) THEN 959 1083 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval 960 1084 nc_stat = NF90_PUT_ATT( id_set_3d(av), NF90_GLOBAL, 'time_avg', & 961 1085 TRIM( time_average_text ) ) 962 CALL handle_netcdf_error( 'netcdf', 63 )1086 CALL netcdf_handle_error( 'netcdf_define_header', 63 ) 963 1087 ENDIF 964 1088 … … 968 1092 !-- the performance drops significantly. 969 1093 IF ( netcdf_data_format < 5 ) THEN 970 nc_stat = NF90_DEF_DIM( id_set_3d(av), 'time', NF90_UNLIMITED, & 971 id_dim_time_3d(av) ) 972 CALL handle_netcdf_error( 'netcdf', 64 ) 1094 CALL netcdf_create_dim( id_set_3d(av), 'time', NF90_UNLIMITED, & 1095 id_dim_time_3d(av), 64 ) 973 1096 ELSE 974 nc_stat = NF90_DEF_DIM( id_set_3d(av), 'time', ntdim_3d(av), & 975 id_dim_time_3d(av) ) 976 CALL handle_netcdf_error( 'netcdf', 523 ) 977 ENDIF 978 979 nc_stat = NF90_DEF_VAR( id_set_3d(av), 'time', NF90_DOUBLE, & 980 id_dim_time_3d(av), id_var_time_3d(av) ) 981 CALL handle_netcdf_error( 'netcdf', 65 ) 982 983 nc_stat = NF90_PUT_ATT( id_set_3d(av), id_var_time_3d(av), 'units', & 984 'seconds') 985 CALL handle_netcdf_error( 'netcdf', 66 ) 986 1097 CALL netcdf_create_dim( id_set_3d(av), 'time', ntdim_3d(av), & 1098 id_dim_time_3d(av), 523 ) 1099 ENDIF 1100 1101 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_time_3d(av) /), & 1102 'time', NF90_DOUBLE, id_var_time_3d(av), & 1103 'seconds', '', 65, 66, 00 ) 987 1104 ! 988 1105 !-- Define spatial dimensions and coordinates: 989 1106 !-- Define vertical coordinate grid (zu grid) 990 nc_stat = NF90_DEF_DIM( id_set_3d(av), 'zu_3d', nz_do3d-nzb+1, & 991 id_dim_zu_3d(av) ) 992 CALL handle_netcdf_error( 'netcdf', 67 ) 993 994 nc_stat = NF90_DEF_VAR( id_set_3d(av), 'zu_3d', NF90_DOUBLE, & 995 id_dim_zu_3d(av), id_var_zu_3d(av) ) 996 CALL handle_netcdf_error( 'netcdf', 68 ) 997 998 nc_stat = NF90_PUT_ATT( id_set_3d(av), id_var_zu_3d(av), 'units', & 999 'meters' ) 1000 CALL handle_netcdf_error( 'netcdf', 69 ) 1001 1107 CALL netcdf_create_dim( id_set_3d(av), 'zu_3d', nz_do3d-nzb+1, & 1108 id_dim_zu_3d(av), 67 ) 1109 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_zu_3d(av) /), & 1110 'zu_3d', NF90_DOUBLE, id_var_zu_3d(av), & 1111 'meters', '', 68, 69, 00 ) 1002 1112 ! 1003 1113 !-- Define vertical coordinate grid (zw grid) 1004 nc_stat = NF90_DEF_DIM( id_set_3d(av), 'zw_3d', nz_do3d-nzb+1, & 1005 id_dim_zw_3d(av) ) 1006 CALL handle_netcdf_error( 'netcdf', 70 ) 1007 1008 nc_stat = NF90_DEF_VAR( id_set_3d(av), 'zw_3d', NF90_DOUBLE, & 1009 id_dim_zw_3d(av), id_var_zw_3d(av) ) 1010 CALL handle_netcdf_error( 'netcdf', 71 ) 1011 1012 nc_stat = NF90_PUT_ATT( id_set_3d(av), id_var_zw_3d(av), 'units', & 1013 'meters' ) 1014 CALL handle_netcdf_error( 'netcdf', 72 ) 1015 1114 CALL netcdf_create_dim( id_set_3d(av), 'zw_3d', nz_do3d-nzb+1, & 1115 id_dim_zw_3d(av), 70 ) 1116 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_zw_3d(av) /), & 1117 'zw_3d', NF90_DOUBLE, id_var_zw_3d(av), & 1118 'meters', '', 71, 72, 00 ) 1016 1119 ! 1017 1120 !-- Define x-axis (for scalar position) 1018 nc_stat = NF90_DEF_DIM( id_set_3d(av), 'x', nx+2, id_dim_x_3d(av) ) 1019 CALL handle_netcdf_error( 'netcdf', 73 ) 1020 1021 nc_stat = NF90_DEF_VAR( id_set_3d(av), 'x', NF90_DOUBLE, & 1022 id_dim_x_3d(av), id_var_x_3d(av) ) 1023 CALL handle_netcdf_error( 'netcdf', 74 ) 1024 1025 nc_stat = NF90_PUT_ATT( id_set_3d(av), id_var_x_3d(av), 'units', & 1026 'meters' ) 1027 CALL handle_netcdf_error( 'netcdf', 75 ) 1028 1121 CALL netcdf_create_dim( id_set_3d(av), 'x', nx+2, id_dim_x_3d(av), & 1122 73 ) 1123 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_x_3d(av) /), 'x', & 1124 NF90_DOUBLE, id_var_x_3d(av), 'meters', '', & 1125 74, 75, 00 ) 1029 1126 ! 1030 1127 !-- Define x-axis (for u position) 1031 nc_stat = NF90_DEF_DIM( id_set_3d(av), 'xu', nx+2, id_dim_xu_3d(av) ) 1032 CALL handle_netcdf_error( 'netcdf', 358 ) 1033 1034 nc_stat = NF90_DEF_VAR( id_set_3d(av), 'xu', NF90_DOUBLE, & 1035 id_dim_xu_3d(av), id_var_xu_3d(av) ) 1036 CALL handle_netcdf_error( 'netcdf', 359 ) 1037 1038 nc_stat = NF90_PUT_ATT( id_set_3d(av), id_var_xu_3d(av), 'units', & 1039 'meters' ) 1040 CALL handle_netcdf_error( 'netcdf', 360 ) 1041 1128 CALL netcdf_create_dim( id_set_3d(av), 'xu', nx+2, id_dim_xu_3d(av), & 1129 358 ) 1130 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_xu_3d(av) /), 'xu', & 1131 NF90_DOUBLE, id_var_xu_3d(av), 'meters', '', & 1132 359, 360, 000 ) 1042 1133 ! 1043 1134 !-- Define y-axis (for scalar position) 1044 nc_stat = NF90_DEF_DIM( id_set_3d(av), 'y', ny+2, id_dim_y_3d(av) ) 1045 CALL handle_netcdf_error( 'netcdf', 76 ) 1046 1047 nc_stat = NF90_DEF_VAR( id_set_3d(av), 'y', NF90_DOUBLE, & 1048 id_dim_y_3d(av), id_var_y_3d(av) ) 1049 CALL handle_netcdf_error( 'netcdf', 77 ) 1050 1051 nc_stat = NF90_PUT_ATT( id_set_3d(av), id_var_y_3d(av), 'units', & 1052 'meters' ) 1053 CALL handle_netcdf_error( 'netcdf', 78 ) 1054 1135 CALL netcdf_create_dim( id_set_3d(av), 'y', ny+2, id_dim_y_3d(av), & 1136 76 ) 1137 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_y_3d(av) /), 'y', & 1138 NF90_DOUBLE, id_var_y_3d(av), 'meters', '', & 1139 77, 78, 00 ) 1055 1140 ! 1056 1141 !-- Define y-axis (for v position) 1057 nc_stat = NF90_DEF_DIM( id_set_3d(av), 'yv', ny+2, id_dim_yv_3d(av) ) 1058 CALL handle_netcdf_error( 'netcdf', 361 ) 1059 1060 nc_stat = NF90_DEF_VAR( id_set_3d(av), 'yv', NF90_DOUBLE, & 1061 id_dim_yv_3d(av), id_var_yv_3d(av) ) 1062 CALL handle_netcdf_error( 'netcdf', 362 ) 1063 1064 nc_stat = NF90_PUT_ATT( id_set_3d(av), id_var_yv_3d(av), 'units', & 1065 'meters' ) 1066 CALL handle_netcdf_error( 'netcdf', 363 ) 1067 1142 CALL netcdf_create_dim( id_set_3d(av), 'yv', ny+2, id_dim_yv_3d(av), & 1143 361 ) 1144 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_yv_3d(av) /), 'yv', & 1145 NF90_DOUBLE, id_var_yv_3d(av), 'meters', '', & 1146 362, 363, 000 ) 1068 1147 ! 1069 1148 !-- In case of non-flat topography define 2d-arrays containing the height … … 1072 1151 ! 1073 1152 !-- Define zusi = zu(nzb_s_inner) 1074 nc_stat = NF90_DEF_VAR( id_set_3d(av), 'zusi', NF90_DOUBLE, & 1075 (/ id_dim_x_3d(av), id_dim_y_3d(av) /), & 1076 id_var_zusi_3d(av) ) 1077 CALL handle_netcdf_error( 'netcdf', 413 ) 1078 1079 nc_stat = NF90_PUT_ATT( id_set_3d(av), id_var_zusi_3d(av), & 1080 'units', 'meters' ) 1081 CALL handle_netcdf_error( 'netcdf', 414 ) 1082 1083 nc_stat = NF90_PUT_ATT( id_set_3d(av), id_var_zusi_3d(av), & 1084 'long_name', 'zu(nzb_s_inner)' ) 1085 CALL handle_netcdf_error( 'netcdf', 415 ) 1086 1153 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_x_3d(av), & 1154 id_dim_y_3d(av) /), 'zusi', NF90_DOUBLE, & 1155 id_var_zusi_3d(av), 'meters', & 1156 'zu(nzb_s_inner)', 413, 414, 415 ) 1087 1157 ! 1088 1158 !-- Define zwwi = zw(nzb_w_inner) 1089 nc_stat = NF90_DEF_VAR( id_set_3d(av), 'zwwi', NF90_DOUBLE, & 1090 (/ id_dim_x_3d(av), id_dim_y_3d(av) /), & 1091 id_var_zwwi_3d(av) ) 1092 CALL handle_netcdf_error( 'netcdf', 416 ) 1093 1094 nc_stat = NF90_PUT_ATT( id_set_3d(av), id_var_zwwi_3d(av), & 1095 'units', 'meters' ) 1096 CALL handle_netcdf_error( 'netcdf', 417 ) 1097 1098 nc_stat = NF90_PUT_ATT( id_set_3d(av), id_var_zwwi_3d(av), & 1099 'long_name', 'zw(nzb_w_inner)' ) 1100 CALL handle_netcdf_error( 'netcdf', 418 ) 1159 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_x_3d(av), & 1160 id_dim_y_3d(av) /), 'zwwi', NF90_DOUBLE, & 1161 id_var_zwwi_3d(av), 'meters', & 1162 'zw(nzb_w_inner)', 416, 417, 418 ) 1101 1163 1102 1164 ENDIF … … 1105 1167 ! 1106 1168 !-- Define vertical coordinate grid (zs grid) 1107 nc_stat = NF90_DEF_DIM( id_set_3d(av), 'zs_3d', nzt_soil-nzb_soil+1, & 1108 id_dim_zs_3d(av) ) 1109 CALL handle_netcdf_error( 'netcdf', 70 ) 1110 1111 nc_stat = NF90_DEF_VAR( id_set_3d(av), 'zs_3d', NF90_DOUBLE, & 1112 id_dim_zs_3d(av), id_var_zs_3d(av) ) 1113 CALL handle_netcdf_error( 'netcdf', 71 ) 1114 1115 nc_stat = NF90_PUT_ATT( id_set_3d(av), id_var_zs_3d(av), 'units', & 1116 'meters' ) 1117 CALL handle_netcdf_error( 'netcdf', 72 ) 1169 CALL netcdf_create_dim( id_set_3d(av), 'zs_3d', & 1170 nzt_soil-nzb_soil+1, id_dim_zs_3d(av), 70 ) 1171 CALL netcdf_create_var( id_set_3d(av), (/ id_dim_zs_3d(av) /), & 1172 'zs_3d', NF90_DOUBLE, id_var_zs_3d(av), & 1173 'meters', '', 71, 72, 00 ) 1118 1174 1119 1175 ENDIF … … 1175 1231 CALL user_define_netcdf_grid( do3d(av,i), found, grid_x, & 1176 1232 grid_y, grid_z ) 1233 1234 IF ( .NOT. found ) THEN 1235 WRITE ( message_string, * ) 'no grid defined for varia', & 1236 'ble ', TRIM( do3d(av,i) ) 1237 CALL message( 'define_netcdf_header', 'PA0244', 0, 1, 0, & 1238 6, 0 ) 1239 ENDIF 1177 1240 1178 1241 END SELECT … … 1202 1265 ! 1203 1266 !-- Define the grid 1204 nc_stat = NF90_DEF_VAR( id_set_3d(av), do3d(av,i), & 1205 nc_precision(4), & 1206 (/ id_x, id_y, id_z, id_dim_time_3d(av) /), & 1207 id_var_do3d(av,i) ) 1208 1209 IF ( .NOT. found ) THEN 1210 WRITE ( message_string, * ) 'no grid defined for', & 1211 ' variable ', TRIM( do3d(av,i) ) 1212 CALL message( 'define_netcdf_header', 'PA0244', 0, 1, 0, 6, 0 ) 1213 ENDIF 1214 1215 var_list = TRIM( var_list ) // TRIM( do3d(av,i) ) // ';' 1216 1217 CALL handle_netcdf_error( 'netcdf', 79 ) 1218 ! 1219 !-- Store the 'real' name of the variable (with *, for example) 1220 !-- in the long_name attribute. This is evaluated by Ferret, 1221 !-- for example. 1222 nc_stat = NF90_PUT_ATT( id_set_3d(av), id_var_do3d(av,i), & 1223 'long_name', do3d(av,i) ) 1224 CALL handle_netcdf_error( 'netcdf', 80 ) 1225 ! 1226 !-- Define the variable's unit 1227 nc_stat = NF90_PUT_ATT( id_set_3d(av), id_var_do3d(av,i), & 1228 'units', TRIM( do3d_unit(av,i) ) ) 1229 CALL handle_netcdf_error( 'netcdf', 357 ) 1267 CALL netcdf_create_var( id_set_3d(av),(/ id_x, id_y, id_z, & 1268 id_dim_time_3d(av) /), do3d(av,i), & 1269 nc_precision(4), id_var_do3d(av,i), & 1270 TRIM( do3d_unit(av,i) ), do3d(av,i), 79, & 1271 80, 357 ) 1230 1272 #if defined( __netcdf4_parallel ) 1231 1273 IF ( netcdf_data_format > 4 ) THEN … … 1235 1277 id_var_do3d(av,i), & 1236 1278 1, 0 ) 1237 CALL handle_netcdf_error( 'netcdf', 532 )1279 CALL netcdf_handle_error( 'netcdf_define_header', 532 ) 1238 1280 ! 1239 1281 !-- Set collective io operations for parallel io … … 1241 1283 id_var_do3d(av,i), & 1242 1284 NF90_COLLECTIVE ) 1243 CALL handle_netcdf_error( 'netcdf', 445 )1285 CALL netcdf_handle_error( 'netcdf_define_header', 445 ) 1244 1286 ENDIF 1245 1287 #endif 1288 var_list = TRIM( var_list ) // TRIM( do3d(av,i) ) // ';' 1289 1246 1290 i = i + 1 1247 1291 … … 1257 1301 nc_stat = NF90_PUT_ATT( id_set_3d(av), NF90_GLOBAL, 'VAR_LIST', & 1258 1302 var_list ) 1259 CALL handle_netcdf_error( 'netcdf', 81 )1303 CALL netcdf_handle_error( 'netcdf_define_header', 81 ) 1260 1304 1261 1305 ! … … 1263 1307 !-- parallel output. 1264 1308 nc_stat = NF90_SET_FILL( id_set_3d(av), NF90_NOFILL, oldmode ) 1265 CALL handle_netcdf_error( 'netcdf', 528 )1309 CALL netcdf_handle_error( 'netcdf_define_header', 528 ) 1266 1310 1267 1311 ! 1268 1312 !-- Leave netCDF define mode 1269 1313 nc_stat = NF90_ENDDEF( id_set_3d(av) ) 1270 CALL handle_netcdf_error( 'netcdf', 82 )1314 CALL netcdf_handle_error( 'netcdf_define_header', 82 ) 1271 1315 1272 1316 ! … … 1285 1329 netcdf_data, start = (/ 1 /), & 1286 1330 count = (/ nx+2 /) ) 1287 CALL handle_netcdf_error( 'netcdf', 83 )1331 CALL netcdf_handle_error( 'netcdf_define_header', 83 ) 1288 1332 1289 1333 DO i = 0, nx+1 … … 1294 1338 netcdf_data, start = (/ 1 /), & 1295 1339 count = (/ nx+2 /) ) 1296 CALL handle_netcdf_error( 'netcdf', 385 )1340 CALL netcdf_handle_error( 'netcdf_define_header', 385 ) 1297 1341 1298 1342 DEALLOCATE( netcdf_data ) … … 1309 1353 netcdf_data, start = (/ 1 /), & 1310 1354 count = (/ ny+2 /) ) 1311 CALL handle_netcdf_error( 'netcdf', 84 )1355 CALL netcdf_handle_error( 'netcdf_define_header', 84 ) 1312 1356 1313 1357 DO i = 0, ny+1 … … 1318 1362 netcdf_data, start = (/ 1 /), & 1319 1363 count = (/ ny+2 /)) 1320 CALL handle_netcdf_error( 'netcdf', 387 )1364 CALL netcdf_handle_error( 'netcdf_define_header', 387 ) 1321 1365 1322 1366 DEALLOCATE( netcdf_data ) … … 1327 1371 zu(nzb:nz_do3d), start = (/ 1 /), & 1328 1372 count = (/ nz_do3d-nzb+1 /) ) 1329 CALL handle_netcdf_error( 'netcdf', 85 )1373 CALL netcdf_handle_error( 'netcdf_define_header', 85 ) 1330 1374 1331 1375 … … 1333 1377 zw(nzb:nz_do3d), start = (/ 1 /), & 1334 1378 count = (/ nz_do3d-nzb+1 /) ) 1335 CALL handle_netcdf_error( 'netcdf', 86 )1379 CALL netcdf_handle_error( 'netcdf_define_header', 86 ) 1336 1380 1337 1381 ! … … 1343 1387 start = (/ 1, 1 /), & 1344 1388 count = (/ nx+2, ny+2 /) ) 1345 CALL handle_netcdf_error( 'netcdf', 419 )1389 CALL netcdf_handle_error( 'netcdf_define_header', 419 ) 1346 1390 1347 1391 nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_zwwi_3d(av), & … … 1349 1393 start = (/ 1, 1 /), & 1350 1394 count = (/ nx+2, ny+2 /) ) 1351 CALL handle_netcdf_error( 'netcdf', 420 )1395 CALL netcdf_handle_error( 'netcdf_define_header', 420 ) 1352 1396 1353 1397 ENDIF … … 1359 1403 - zs(nzb_soil:nzt_soil), start = (/ 1 /), & 1360 1404 count = (/ nzt_soil-nzb_soil+1 /) ) 1361 CALL handle_netcdf_error( 'netcdf', 86 )1405 CALL netcdf_handle_error( 'netcdf_define_header', 86 ) 1362 1406 ENDIF 1363 1407 … … 1373 1417 nc_stat = NF90_GET_ATT( id_set_3d(av), NF90_GLOBAL, 'VAR_LIST', & 1374 1418 var_list_old ) 1375 CALL handle_netcdf_error( 'netcdf', 87 )1419 CALL netcdf_handle_error( 'netcdf_define_header', 87 ) 1376 1420 1377 1421 var_list = ';' … … 1402 1446 !-- Get and compare the number of vertical gridpoints 1403 1447 nc_stat = NF90_INQ_VARID( id_set_3d(av), 'zu_3d', id_var_zu_3d(av) ) 1404 CALL handle_netcdf_error( 'netcdf', 88 )1448 CALL netcdf_handle_error( 'netcdf_define_header', 88 ) 1405 1449 1406 1450 nc_stat = NF90_INQUIRE_VARIABLE( id_set_3d(av), id_var_zu_3d(av), & 1407 1451 dimids = id_dim_zu_3d_old ) 1408 CALL handle_netcdf_error( 'netcdf', 89 )1452 CALL netcdf_handle_error( 'netcdf_define_header', 89 ) 1409 1453 id_dim_zu_3d(av) = id_dim_zu_3d_old(1) 1410 1454 1411 1455 nc_stat = NF90_INQUIRE_DIMENSION( id_set_3d(av), id_dim_zu_3d(av), & 1412 1456 len = nz_old ) 1413 CALL handle_netcdf_error( 'netcdf', 90 )1457 CALL netcdf_handle_error( 'netcdf_define_header', 90 ) 1414 1458 1415 1459 IF ( nz_do3d-nzb+1 /= nz_old ) THEN … … 1431 1475 !-- on the file. 1432 1476 nc_stat = NF90_INQ_VARID( id_set_3d(av), 'time', id_var_time_3d(av) ) 1433 CALL handle_netcdf_error( 'netcdf', 91 )1477 CALL netcdf_handle_error( 'netcdf_define_header', 91 ) 1434 1478 1435 1479 nc_stat = NF90_INQUIRE_VARIABLE( id_set_3d(av), id_var_time_3d(av), & 1436 1480 dimids = id_dim_time_old ) 1437 CALL handle_netcdf_error( 'netcdf', 92 )1481 CALL netcdf_handle_error( 'netcdf_define_header', 92 ) 1438 1482 1439 1483 id_dim_time_3d(av) = id_dim_time_old(1) … … 1441 1485 nc_stat = NF90_INQUIRE_DIMENSION( id_set_3d(av), id_dim_time_3d(av), & 1442 1486 len = ntime_count ) 1443 CALL handle_netcdf_error( 'netcdf', 93 )1487 CALL netcdf_handle_error( 'netcdf_define_header', 93 ) 1444 1488 1445 1489 ! … … 1454 1498 start = (/ do3d_time_count(av) /), & 1455 1499 count = (/ 1 /) ) 1456 CALL handle_netcdf_error( 'netcdf', 94 )1500 CALL netcdf_handle_error( 'netcdf_define_header', 94 ) 1457 1501 1458 1502 IF ( last_time_coordinate(1) >= simulated_time ) THEN … … 1524 1568 nc_stat = NF90_INQ_VARID( id_set_3d(av), TRIM( do3d(av,i) ), & 1525 1569 id_var_do3d(av,i) ) 1526 CALL handle_netcdf_error( 'netcdf', 95 )1570 CALL netcdf_handle_error( 'netcdf_define_header', 95 ) 1527 1571 #if defined( __netcdf4_parallel ) 1528 1572 ! … … 1532 1576 id_var_do3d(av,i), & 1533 1577 NF90_COLLECTIVE ) 1534 CALL handle_netcdf_error( 'netcdf', 453 )1578 CALL netcdf_handle_error( 'netcdf_define_header', 453 ) 1535 1579 ENDIF 1536 1580 #endif … … 1552 1596 ENDIF 1553 1597 nc_stat = NF90_REDEF( id_set_3d(av) ) 1554 CALL handle_netcdf_error( 'netcdf', 429 )1598 CALL netcdf_handle_error( 'netcdf_define_header', 429 ) 1555 1599 nc_stat = NF90_PUT_ATT( id_set_3d(av), NF90_GLOBAL, 'title', & 1556 1600 TRIM( run_description_header ) // & 1557 1601 TRIM( time_average_text ) ) 1558 CALL handle_netcdf_error( 'netcdf', 96 )1602 CALL netcdf_handle_error( 'netcdf_define_header', 96 ) 1559 1603 nc_stat = NF90_ENDDEF( id_set_3d(av) ) 1560 CALL handle_netcdf_error( 'netcdf', 430 )1604 CALL netcdf_handle_error( 'netcdf_define_header', 430 ) 1561 1605 message_string = 'netCDF file for volume data ' // & 1562 1606 TRIM( var ) // ' from previous run found.' // & … … 1570 1614 nc_stat = NF90_PUT_ATT( id_set_xy(av), NF90_GLOBAL, 'Conventions', & 1571 1615 'COARDS' ) 1572 CALL handle_netcdf_error( 'netcdf', 97 )1616 CALL netcdf_handle_error( 'netcdf_define_header', 97 ) 1573 1617 1574 1618 IF ( av == 0 ) THEN … … 1581 1625 TRIM( run_description_header ) // & 1582 1626 TRIM( time_average_text ) ) 1583 CALL handle_netcdf_error( 'netcdf', 98 )1627 CALL netcdf_handle_error( 'netcdf_define_header', 98 ) 1584 1628 IF ( av == 1 ) THEN 1585 1629 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval 1586 1630 nc_stat = NF90_PUT_ATT( id_set_xy(av), NF90_GLOBAL, 'time_avg', & 1587 1631 TRIM( time_average_text ) ) 1588 CALL handle_netcdf_error( 'netcdf', 98 )1632 CALL netcdf_handle_error( 'netcdf_define_header', 98 ) 1589 1633 ENDIF 1590 1634 … … 1594 1638 !-- the performance drops significantly. 1595 1639 IF ( netcdf_data_format < 5 ) THEN 1596 nc_stat = NF90_DEF_DIM( id_set_xy(av), 'time', NF90_UNLIMITED, & 1597 id_dim_time_xy(av) ) 1598 CALL handle_netcdf_error( 'netcdf', 99 ) 1640 CALL netcdf_create_dim( id_set_xy(av), 'time', NF90_UNLIMITED, & 1641 id_dim_time_xy(av), 99 ) 1599 1642 ELSE 1600 nc_stat = NF90_DEF_DIM( id_set_xy(av), 'time', ntdim_2d_xy(av), & 1601 id_dim_time_xy(av) ) 1602 CALL handle_netcdf_error( 'netcdf', 524 ) 1603 ENDIF 1604 1605 nc_stat = NF90_DEF_VAR( id_set_xy(av), 'time', NF90_DOUBLE, & 1606 id_dim_time_xy(av), id_var_time_xy(av) ) 1607 CALL handle_netcdf_error( 'netcdf', 100 ) 1608 1609 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_time_xy(av), 'units', & 1610 'seconds') 1611 CALL handle_netcdf_error( 'netcdf', 101 ) 1612 1643 CALL netcdf_create_dim( id_set_xy(av), 'time', ntdim_2d_xy(av), & 1644 id_dim_time_xy(av), 524 ) 1645 ENDIF 1646 1647 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_time_xy(av) /), & 1648 'time', NF90_DOUBLE, id_var_time_xy(av), & 1649 'seconds', '', 100, 101, 000 ) 1613 1650 ! 1614 1651 !-- Define the spatial dimensions and coordinates for xy-sections. … … 1626 1663 ! 1627 1664 !-- Define vertical coordinate grid (zu grid) 1628 nc_stat = NF90_DEF_DIM( id_set_xy(av), 'zu_xy', ns, id_dim_zu_xy(av) ) 1629 CALL handle_netcdf_error( 'netcdf', 102 ) 1630 1631 nc_stat = NF90_DEF_VAR( id_set_xy(av), 'zu_xy', NF90_DOUBLE, & 1632 id_dim_zu_xy(av), id_var_zu_xy(av) ) 1633 CALL handle_netcdf_error( 'netcdf', 103 ) 1634 1635 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_zu_xy(av), 'units', & 1636 'meters' ) 1637 CALL handle_netcdf_error( 'netcdf', 104 ) 1638 1665 CALL netcdf_create_dim( id_set_xy(av), 'zu_xy', ns, & 1666 id_dim_zu_xy(av), 102 ) 1667 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zu_xy(av) /), & 1668 'zu_xy', NF90_DOUBLE, id_var_zu_xy(av), & 1669 'meters', '', 103, 104, 000 ) 1639 1670 ! 1640 1671 !-- Define vertical coordinate grid (zw grid) 1641 nc_stat = NF90_DEF_DIM( id_set_xy(av), 'zw_xy', ns, id_dim_zw_xy(av) ) 1642 CALL handle_netcdf_error( 'netcdf', 105 ) 1643 1644 nc_stat = NF90_DEF_VAR( id_set_xy(av), 'zw_xy', NF90_DOUBLE, & 1645 id_dim_zw_xy(av), id_var_zw_xy(av) ) 1646 CALL handle_netcdf_error( 'netcdf', 106 ) 1647 1648 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_zw_xy(av), 'units', & 1649 'meters' ) 1650 CALL handle_netcdf_error( 'netcdf', 107 ) 1651 1672 CALL netcdf_create_dim( id_set_xy(av), 'zw_xy', ns, & 1673 id_dim_zw_xy(av), 105 ) 1674 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zw_xy(av) /), & 1675 'zw_xy', NF90_DOUBLE, id_var_zw_xy(av), & 1676 'meters', '', 106, 107, 000 ) 1652 1677 1653 1678 IF ( land_surface ) THEN … … 1659 1684 ! 1660 1685 !-- Define vertical coordinate grid (zs grid) 1661 nc_stat = NF90_DEF_DIM( id_set_xy(av), 'zs_xy', ns_do, id_dim_zs_xy(av) ) 1662 CALL handle_netcdf_error( 'netcdf', 539 ) 1663 1664 nc_stat = NF90_DEF_VAR( id_set_xy(av), 'zs_xy', NF90_DOUBLE, & 1665 id_dim_zs_xy(av), id_var_zs_xy(av) ) 1666 CALL handle_netcdf_error( 'netcdf', 540 ) 1667 1668 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_zs_xy(av), 'units', & 1669 'meters' ) 1670 CALL handle_netcdf_error( 'netcdf', 541 ) 1686 CALL netcdf_create_dim( id_set_xy(av), 'zs_xy', ns_do, & 1687 id_dim_zs_xy(av), 539 ) 1688 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zs_xy(av) /), & 1689 'zs_xy', NF90_DOUBLE, id_var_zs_xy(av), & 1690 'meters', '', 540, 541, 000 ) 1671 1691 1672 1692 ENDIF … … 1675 1695 !-- Define a pseudo vertical coordinate grid for the surface variables 1676 1696 !-- u* and t* to store their height level 1677 nc_stat = NF90_DEF_DIM( id_set_xy(av), 'zu1_xy', 1, & 1678 id_dim_zu1_xy(av) ) 1679 CALL handle_netcdf_error( 'netcdf', 108 ) 1680 1681 nc_stat = NF90_DEF_VAR( id_set_xy(av), 'zu1_xy', NF90_DOUBLE, & 1682 id_dim_zu1_xy(av), id_var_zu1_xy(av) ) 1683 CALL handle_netcdf_error( 'netcdf', 109 ) 1684 1685 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_zu1_xy(av), 'units', & 1686 'meters' ) 1687 CALL handle_netcdf_error( 'netcdf', 110 ) 1688 1697 CALL netcdf_create_dim( id_set_xy(av), 'zu1_xy', 1, & 1698 id_dim_zu1_xy(av), 108 ) 1699 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zu1_xy(av) /), & 1700 'zu1_xy', NF90_DOUBLE, id_var_zu1_xy(av), & 1701 'meters', '', 109, 110, 000 ) 1689 1702 ! 1690 1703 !-- Define a variable to store the layer indices of the horizontal cross 1691 1704 !-- sections, too 1692 nc_stat = NF90_DEF_VAR( id_set_xy(av), 'ind_z_xy', NF90_DOUBLE, & 1693 id_dim_zu_xy(av), id_var_ind_z_xy(av) ) 1694 CALL handle_netcdf_error( 'netcdf', 111 ) 1695 1696 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_ind_z_xy(av), 'units', & 1697 'gridpoints') 1698 CALL handle_netcdf_error( 'netcdf', 112 ) 1699 1705 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_zu_xy(av) /), & 1706 'ind_z_xy', NF90_DOUBLE, & 1707 id_var_ind_z_xy(av), 'gridpoints', '', 111, & 1708 112, 000 ) 1700 1709 ! 1701 1710 !-- Define x-axis (for scalar position) 1702 nc_stat = NF90_DEF_DIM( id_set_xy(av), 'x', nx+2, id_dim_x_xy(av) ) 1703 CALL handle_netcdf_error( 'netcdf', 113 ) 1704 1705 nc_stat = NF90_DEF_VAR( id_set_xy(av), 'x', NF90_DOUBLE, & 1706 id_dim_x_xy(av), id_var_x_xy(av) ) 1707 CALL handle_netcdf_error( 'netcdf', 114 ) 1708 1709 1710 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_x_xy(av), 'units', & 1711 'meters' ) 1712 CALL handle_netcdf_error( 'netcdf', 115 ) 1713 1711 CALL netcdf_create_dim( id_set_xy(av), 'x', nx+2, id_dim_x_xy(av), & 1712 113 ) 1713 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_x_xy(av) /), 'x', & 1714 NF90_DOUBLE, id_var_x_xy(av), 'meters', '', & 1715 114, 115, 000 ) 1714 1716 ! 1715 1717 !-- Define x-axis (for u position) 1716 nc_stat = NF90_DEF_DIM( id_set_xy(av), 'xu', nx+2, id_dim_xu_xy(av) ) 1717 CALL handle_netcdf_error( 'netcdf', 388 ) 1718 1719 nc_stat = NF90_DEF_VAR( id_set_xy(av), 'xu', NF90_DOUBLE, & 1720 id_dim_xu_xy(av), id_var_xu_xy(av) ) 1721 CALL handle_netcdf_error( 'netcdf', 389 ) 1722 1723 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_xu_xy(av), 'units', & 1724 'meters' ) 1725 CALL handle_netcdf_error( 'netcdf', 390 ) 1726 1718 CALL netcdf_create_dim( id_set_xy(av), 'xu', nx+2, & 1719 id_dim_xu_xy(av), 388 ) 1720 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_xu_xy(av) /), 'xu', & 1721 NF90_DOUBLE, id_var_xu_xy(av), 'meters', '', & 1722 389, 390, 000 ) 1727 1723 ! 1728 1724 !-- Define y-axis (for scalar position) 1729 nc_stat = NF90_DEF_DIM( id_set_xy(av), 'y', ny+2, id_dim_y_xy(av) ) 1730 CALL handle_netcdf_error( 'netcdf', 116 ) 1731 1732 nc_stat = NF90_DEF_VAR( id_set_xy(av), 'y', NF90_DOUBLE, & 1733 id_dim_y_xy(av), id_var_y_xy(av) ) 1734 CALL handle_netcdf_error( 'netcdf', 117 ) 1735 1736 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_y_xy(av), 'units', & 1737 'meters' ) 1738 CALL handle_netcdf_error( 'netcdf', 118 ) 1739 1725 CALL netcdf_create_dim( id_set_xy(av), 'y', ny+2, id_dim_y_xy(av), & 1726 116 ) 1727 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_y_xy(av) /), 'y', & 1728 NF90_DOUBLE, id_var_y_xy(av), 'meters', '', & 1729 117, 118, 000 ) 1740 1730 ! 1741 1731 !-- Define y-axis (for scalar position) 1742 nc_stat = NF90_DEF_DIM( id_set_xy(av), 'yv', ny+2, id_dim_yv_xy(av) ) 1743 CALL handle_netcdf_error( 'netcdf', 364 ) 1744 1745 nc_stat = NF90_DEF_VAR( id_set_xy(av), 'yv', NF90_DOUBLE, & 1746 id_dim_yv_xy(av), id_var_yv_xy(av) ) 1747 CALL handle_netcdf_error( 'netcdf', 365 ) 1748 1749 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_yv_xy(av), 'units', & 1750 'meters' ) 1751 CALL handle_netcdf_error( 'netcdf', 366 ) 1752 1732 CALL netcdf_create_dim( id_set_xy(av), 'yv', ny+2, & 1733 id_dim_yv_xy(av), 364 ) 1734 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_yv_xy(av) /), 'yv', & 1735 NF90_DOUBLE, id_var_yv_xy(av), 'meters', '', & 1736 365, 366, 000 ) 1753 1737 ! 1754 1738 !-- In case of non-flat topography define 2d-arrays containing the height … … 1757 1741 ! 1758 1742 !-- Define zusi = zu(nzb_s_inner) 1759 nc_stat = NF90_DEF_VAR( id_set_xy(av), 'zusi', NF90_DOUBLE, & 1760 (/ id_dim_x_xy(av), id_dim_y_xy(av) /), & 1761 id_var_zusi_xy(av) ) 1762 CALL handle_netcdf_error( 'netcdf', 421 ) 1763 1764 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_zusi_xy(av), & 1765 'units', 'meters' ) 1766 CALL handle_netcdf_error( 'netcdf', 422 ) 1767 1768 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_zusi_xy(av), & 1769 'long_name', 'zu(nzb_s_inner)' ) 1770 CALL handle_netcdf_error( 'netcdf', 423 ) 1771 1743 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_x_xy(av), & 1744 id_dim_y_xy(av) /), 'zusi', NF90_DOUBLE, & 1745 id_var_zusi_xy(av), 'meters', & 1746 'zu(nzb_s_inner)', 421, 422, 423 ) 1772 1747 ! 1773 1748 !-- Define zwwi = zw(nzb_w_inner) 1774 nc_stat = NF90_DEF_VAR( id_set_xy(av), 'zwwi', NF90_DOUBLE, & 1775 (/ id_dim_x_xy(av), id_dim_y_xy(av) /), & 1776 id_var_zwwi_xy(av) ) 1777 CALL handle_netcdf_error( 'netcdf', 424 ) 1778 1779 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_zwwi_xy(av), & 1780 'units', 'meters' ) 1781 CALL handle_netcdf_error( 'netcdf', 425 ) 1782 1783 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_zwwi_xy(av), & 1784 'long_name', 'zw(nzb_w_inner)' ) 1785 CALL handle_netcdf_error( 'netcdf', 426 ) 1749 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_x_xy(av), & 1750 id_dim_y_xy(av) /), 'zwwi', NF90_DOUBLE, & 1751 id_var_zwwi_xy(av), 'meters', & 1752 'zw(nzb_w_inner)', 424, 425, 426 ) 1786 1753 1787 1754 ENDIF … … 1800 1767 IF ( INDEX( do2d(av,i), '*' ) /= 0 ) THEN 1801 1768 1802 nc_stat = NF90_DEF_VAR( id_set_xy(av), do2d(av,i), & 1803 nc_precision(1), & 1804 (/ id_dim_x_xy(av), id_dim_y_xy(av),& 1805 id_dim_zu1_xy(av), & 1806 id_dim_time_xy(av) /), & 1807 id_var_do2d(av,i) ) 1808 1809 var_list = TRIM(var_list) // TRIM( do2d(av,i) ) // ';' 1769 CALL netcdf_create_var( id_set_xy(av), (/ id_dim_x_xy(av), & 1770 id_dim_y_xy(av), id_dim_zu1_xy(av), & 1771 id_dim_time_xy(av) /), do2d(av,i), & 1772 nc_precision(1), id_var_do2d(av,i), & 1773 TRIM( do2d_unit(av,i) ), & 1774 do2d(av,i), 119, 120, 354 ) 1810 1775 1811 1776 ELSE … … 1862 1827 grid_x, grid_y, grid_z ) 1863 1828 1829 IF ( .NOT. found ) THEN 1830 WRITE ( message_string, * ) 'no grid defined for', & 1831 ' variable ', TRIM( do2d(av,i) ) 1832 CALL message( 'define_netcdf_header', 'PA0244', & 1833 0, 1, 0, 6, 0 ) 1834 ENDIF 1835 1864 1836 END SELECT 1865 1837 … … 1888 1860 ! 1889 1861 !-- Define the grid 1890 nc_stat = NF90_DEF_VAR( id_set_xy(av), do2d(av,i), & 1891 nc_precision(1), & 1892 (/ id_x, id_y, id_z, id_dim_time_xy(av) /), & 1893 id_var_do2d(av,i) ) 1894 1895 IF ( .NOT. found ) THEN 1896 WRITE ( message_string, * ) 'no grid defined for', & 1897 ' variable ', TRIM( do2d(av,i) ) 1898 CALL message( 'define_netcdf_header', 'PA0244',& 1899 0, 1, 0, 6, 0 ) 1900 ENDIF 1901 1902 var_list = TRIM( var_list ) // TRIM( do2d(av,i) ) // ';' 1862 CALL netcdf_create_var( id_set_xy(av), (/ id_x, id_y, id_z, & 1863 id_dim_time_xy(av) /), do2d(av,i), & 1864 nc_precision(1), id_var_do2d(av,i), & 1865 TRIM( do2d_unit(av,i) ), & 1866 do2d(av,i), 119, 120, 354 ) 1903 1867 1904 1868 ENDIF 1905 1869 1906 CALL handle_netcdf_error( 'netcdf', 119 )1907 !1908 !-- Store the 'real' name of the variable (with *, for example)1909 !-- in the long_name attribute. This is evaluated by Ferret,1910 !-- for example.1911 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_do2d(av,i), &1912 'long_name', do2d(av,i) )1913 CALL handle_netcdf_error( 'netcdf', 120 )1914 !1915 !-- Define the variable's unit1916 nc_stat = NF90_PUT_ATT( id_set_xy(av), id_var_do2d(av,i), &1917 'units', TRIM( do2d_unit(av,i) ) )1918 CALL handle_netcdf_error( 'netcdf', 354 )1919 1870 #if defined( __netcdf4_parallel ) 1920 1871 IF ( netcdf_data_format > 4 ) THEN … … 1924 1875 id_var_do2d(av,i), & 1925 1876 1, 0 ) 1926 CALL handle_netcdf_error( 'netcdf', 533 )1877 CALL netcdf_handle_error( 'netcdf_define_header', 533 ) 1927 1878 ! 1928 1879 !-- Set collective io operations for parallel io … … 1930 1881 id_var_do2d(av,i), & 1931 1882 NF90_COLLECTIVE ) 1932 CALL handle_netcdf_error( 'netcdf', 448 )1883 CALL netcdf_handle_error( 'netcdf_define_header', 448 ) 1933 1884 ENDIF 1934 1885 #endif 1886 var_list = TRIM( var_list) // TRIM( do2d(av,i) ) // ';' 1887 1935 1888 ENDIF 1936 1889 … … 1948 1901 nc_stat = NF90_PUT_ATT( id_set_xy(av), NF90_GLOBAL, 'VAR_LIST', & 1949 1902 var_list ) 1950 CALL handle_netcdf_error( 'netcdf', 121 )1903 CALL netcdf_handle_error( 'netcdf_define_header', 121 ) 1951 1904 1952 1905 ! … … 1954 1907 !-- parallel output. 1955 1908 nc_stat = NF90_SET_FILL( id_set_xy(av), NF90_NOFILL, oldmode ) 1956 CALL handle_netcdf_error( 'netcdf', 529 )1909 CALL netcdf_handle_error( 'netcdf_define_header', 529 ) 1957 1910 1958 1911 ! 1959 1912 !-- Leave netCDF define mode 1960 1913 nc_stat = NF90_ENDDEF( id_set_xy(av) ) 1961 CALL handle_netcdf_error( 'netcdf', 122 )1914 CALL netcdf_handle_error( 'netcdf_define_header', 122 ) 1962 1915 1963 1916 ! … … 1982 1935 netcdf_data, start = (/ 1 /), & 1983 1936 count = (/ ns /) ) 1984 CALL handle_netcdf_error( 'netcdf', 123 )1937 CALL netcdf_handle_error( 'netcdf_define_header', 123 ) 1985 1938 1986 1939 ! … … 1996 1949 netcdf_data, start = (/ 1 /), & 1997 1950 count = (/ ns /) ) 1998 CALL handle_netcdf_error( 'netcdf', 124 )1951 CALL netcdf_handle_error( 'netcdf_define_header', 124 ) 1999 1952 2000 1953 ! … … 2015 1968 netcdf_data(1:ns_do), start = (/ 1 /), & 2016 1969 count = (/ ns_do /) ) 2017 CALL handle_netcdf_error( 'netcdf', 124 )1970 CALL netcdf_handle_error( 'netcdf_define_header', 124 ) 2018 1971 2019 1972 ENDIF … … 2025 1978 netcdf_data, start = (/ 1 /), & 2026 1979 count = (/ ns /) ) 2027 CALL handle_netcdf_error( 'netcdf', 125 )1980 CALL netcdf_handle_error( 'netcdf_define_header', 125 ) 2028 1981 2029 1982 DEALLOCATE( netcdf_data ) … … 2034 1987 (/ zu(nzb+1) /), start = (/ 1 /), & 2035 1988 count = (/ 1 /) ) 2036 CALL handle_netcdf_error( 'netcdf', 126 )1989 CALL netcdf_handle_error( 'netcdf_define_header', 126 ) 2037 1990 2038 1991 ! … … 2047 2000 netcdf_data, start = (/ 1 /), & 2048 2001 count = (/ nx+2 /) ) 2049 CALL handle_netcdf_error( 'netcdf', 127 )2002 CALL netcdf_handle_error( 'netcdf_define_header', 127 ) 2050 2003 2051 2004 DO i = 0, nx+1 … … 2056 2009 netcdf_data, start = (/ 1 /), & 2057 2010 count = (/ nx+2 /) ) 2058 CALL handle_netcdf_error( 'netcdf', 367 )2011 CALL netcdf_handle_error( 'netcdf_define_header', 367 ) 2059 2012 2060 2013 DEALLOCATE( netcdf_data ) … … 2071 2024 netcdf_data, start = (/ 1 /), & 2072 2025 count = (/ ny+2 /)) 2073 CALL handle_netcdf_error( 'netcdf', 128 )2026 CALL netcdf_handle_error( 'netcdf_define_header', 128 ) 2074 2027 2075 2028 DO i = 0, ny+1 … … 2080 2033 netcdf_data, start = (/ 1 /), & 2081 2034 count = (/ ny+2 /)) 2082 CALL handle_netcdf_error( 'netcdf', 368 )2035 CALL netcdf_handle_error( 'netcdf_define_header', 368 ) 2083 2036 2084 2037 DEALLOCATE( netcdf_data ) … … 2092 2045 start = (/ 1, 1 /), & 2093 2046 count = (/ nx+2, ny+2 /) ) 2094 CALL handle_netcdf_error( 'netcdf', 427 )2047 CALL netcdf_handle_error( 'netcdf_define_header', 427 ) 2095 2048 2096 2049 nc_stat = NF90_PUT_VAR( id_set_xy(av), id_var_zwwi_xy(av), & … … 2098 2051 start = (/ 1, 1 /), & 2099 2052 count = (/ nx+2, ny+2 /) ) 2100 CALL handle_netcdf_error( 'netcdf', 428 )2053 CALL netcdf_handle_error( 'netcdf_define_header', 428 ) 2101 2054 2102 2055 ENDIF … … 2115 2068 nc_stat = NF90_GET_ATT( id_set_xy(av), NF90_GLOBAL, 'VAR_LIST', & 2116 2069 var_list_old ) 2117 CALL handle_netcdf_error( 'netcdf', 129 )2070 CALL netcdf_handle_error( 'netcdf_define_header', 129 ) 2118 2071 2119 2072 var_list = ';' … … 2154 2107 !-- Get and compare the number of horizontal cross sections 2155 2108 nc_stat = NF90_INQ_VARID( id_set_xy(av), 'zu_xy', id_var_zu_xy(av) ) 2156 CALL handle_netcdf_error( 'netcdf', 130 )2109 CALL netcdf_handle_error( 'netcdf_define_header', 130 ) 2157 2110 2158 2111 nc_stat = NF90_INQUIRE_VARIABLE( id_set_xy(av), id_var_zu_xy(av), & 2159 2112 dimids = id_dim_zu_xy_old ) 2160 CALL handle_netcdf_error( 'netcdf', 131 )2113 CALL netcdf_handle_error( 'netcdf_define_header', 131 ) 2161 2114 id_dim_zu_xy(av) = id_dim_zu_xy_old(1) 2162 2115 2163 2116 nc_stat = NF90_INQUIRE_DIMENSION( id_set_xy(av), id_dim_zu_xy(av), & 2164 2117 len = ns_old ) 2165 CALL handle_netcdf_error( 'netcdf', 132 )2118 CALL netcdf_handle_error( 'netcdf_define_header', 132 ) 2166 2119 2167 2120 IF ( ns /= ns_old ) THEN … … 2182 2135 2183 2136 nc_stat = NF90_GET_VAR( id_set_xy(av), id_var_zu_xy(av), netcdf_data ) 2184 CALL handle_netcdf_error( 'netcdf', 133 )2137 CALL netcdf_handle_error( 'netcdf_define_header', 133 ) 2185 2138 2186 2139 DO i = 1, ns … … 2222 2175 !-- on the file. 2223 2176 nc_stat = NF90_INQ_VARID( id_set_xy(av), 'time', id_var_time_xy(av) ) 2224 CALL handle_netcdf_error( 'netcdf', 134 )2177 CALL netcdf_handle_error( 'netcdf_define_header', 134 ) 2225 2178 2226 2179 nc_stat = NF90_INQUIRE_VARIABLE( id_set_xy(av), id_var_time_xy(av), & 2227 2180 dimids = id_dim_time_old ) 2228 CALL handle_netcdf_error( 'netcdf', 135 )2181 CALL netcdf_handle_error( 'netcdf_define_header', 135 ) 2229 2182 id_dim_time_xy(av) = id_dim_time_old(1) 2230 2183 2231 2184 nc_stat = NF90_INQUIRE_DIMENSION( id_set_xy(av), id_dim_time_xy(av), & 2232 2185 len = ntime_count ) 2233 CALL handle_netcdf_error( 'netcdf', 136 )2186 CALL netcdf_handle_error( 'netcdf_define_header', 136 ) 2234 2187 2235 2188 ! … … 2244 2197 start = (/ do2d_xy_time_count(av) /), & 2245 2198 count = (/ 1 /) ) 2246 CALL handle_netcdf_error( 'netcdf', 137 )2199 CALL netcdf_handle_error( 'netcdf_define_header', 137 ) 2247 2200 2248 2201 IF ( last_time_coordinate(1) >= simulated_time ) THEN … … 2315 2268 nc_stat = NF90_INQ_VARID( id_set_xy(av), do2d(av,i), & 2316 2269 id_var_do2d(av,i) ) 2317 CALL handle_netcdf_error( 'netcdf', 138 )2270 CALL netcdf_handle_error( 'netcdf_define_header', 138 ) 2318 2271 #if defined( __netcdf4_parallel ) 2319 2272 ! … … 2323 2276 id_var_do2d(av,i), & 2324 2277 NF90_COLLECTIVE ) 2325 CALL handle_netcdf_error( 'netcdf', 454 )2278 CALL netcdf_handle_error( 'netcdf_define_header', 454 ) 2326 2279 ENDIF 2327 2280 #endif … … 2344 2297 ENDIF 2345 2298 nc_stat = NF90_REDEF( id_set_xy(av) ) 2346 CALL handle_netcdf_error( 'netcdf', 431 )2299 CALL netcdf_handle_error( 'netcdf_define_header', 431 ) 2347 2300 nc_stat = NF90_PUT_ATT( id_set_xy(av), NF90_GLOBAL, 'title', & 2348 2301 TRIM( run_description_header ) // & 2349 2302 TRIM( time_average_text ) ) 2350 CALL handle_netcdf_error( 'netcdf', 139 )2303 CALL netcdf_handle_error( 'netcdf_define_header', 139 ) 2351 2304 nc_stat = NF90_ENDDEF( id_set_xy(av) ) 2352 CALL handle_netcdf_error( 'netcdf', 432 )2305 CALL netcdf_handle_error( 'netcdf_define_header', 432 ) 2353 2306 message_string = 'netCDF file for cross-sections ' // & 2354 2307 TRIM( var ) // ' from previous run found.' // & … … 2363 2316 nc_stat = NF90_PUT_ATT( id_set_xz(av), NF90_GLOBAL, 'Conventions', & 2364 2317 'COARDS' ) 2365 CALL handle_netcdf_error( 'netcdf', 140 )2318 CALL netcdf_handle_error( 'netcdf_define_header', 140 ) 2366 2319 2367 2320 IF ( av == 0 ) THEN … … 2374 2327 TRIM( run_description_header ) // & 2375 2328 TRIM( time_average_text ) ) 2376 CALL handle_netcdf_error( 'netcdf', 141 )2329 CALL netcdf_handle_error( 'netcdf_define_header', 141 ) 2377 2330 IF ( av == 1 ) THEN 2378 2331 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval 2379 2332 nc_stat = NF90_PUT_ATT( id_set_xz(av), NF90_GLOBAL, 'time_avg', & 2380 2333 TRIM( time_average_text ) ) 2381 CALL handle_netcdf_error( 'netcdf', 141 )2334 CALL netcdf_handle_error( 'netcdf_define_header', 141 ) 2382 2335 ENDIF 2383 2336 … … 2387 2340 !-- the performance drops significantly. 2388 2341 IF ( netcdf_data_format < 5 ) THEN 2389 nc_stat = NF90_DEF_DIM( id_set_xz(av), 'time', NF90_UNLIMITED, & 2390 id_dim_time_xz(av) ) 2391 CALL handle_netcdf_error( 'netcdf', 142 ) 2342 CALL netcdf_create_dim( id_set_xz(av), 'time', NF90_UNLIMITED, & 2343 id_dim_time_xz(av), 142 ) 2392 2344 ELSE 2393 nc_stat = NF90_DEF_DIM( id_set_xz(av), 'time', ntdim_2d_xz(av), & 2394 id_dim_time_xz(av) ) 2395 CALL handle_netcdf_error( 'netcdf', 525 ) 2396 ENDIF 2397 2398 nc_stat = NF90_DEF_VAR( id_set_xz(av), 'time', NF90_DOUBLE, & 2399 id_dim_time_xz(av), id_var_time_xz(av) ) 2400 CALL handle_netcdf_error( 'netcdf', 143 ) 2401 2402 nc_stat = NF90_PUT_ATT( id_set_xz(av), id_var_time_xz(av), 'units', & 2403 'seconds') 2404 CALL handle_netcdf_error( 'netcdf', 144 ) 2405 2345 CALL netcdf_create_dim( id_set_xz(av), 'time', ntdim_2d_xz(av), & 2346 id_dim_time_xz(av), 525 ) 2347 ENDIF 2348 2349 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_time_xz(av) /), & 2350 'time', NF90_DOUBLE, id_var_time_xz(av), & 2351 'seconds', '', 143, 144, 000 ) 2406 2352 ! 2407 2353 !-- Define the spatial dimensions and coordinates for xz-sections. … … 2419 2365 ! 2420 2366 !-- Define y-axis (for scalar position) 2421 nc_stat = NF90_DEF_DIM( id_set_xz(av), 'y_xz', ns, id_dim_y_xz(av) ) 2422 CALL handle_netcdf_error( 'netcdf', 145 ) 2423 2424 nc_stat = NF90_DEF_VAR( id_set_xz(av), 'y_xz', NF90_DOUBLE, & 2425 id_dim_y_xz(av), id_var_y_xz(av) ) 2426 CALL handle_netcdf_error( 'netcdf', 146 ) 2427 2428 nc_stat = NF90_PUT_ATT( id_set_xz(av), id_var_y_xz(av), 'units', & 2429 'meters' ) 2430 CALL handle_netcdf_error( 'netcdf', 147 ) 2431 2367 CALL netcdf_create_dim( id_set_xz(av), 'y_xz', ns, id_dim_y_xz(av), & 2368 145 ) 2369 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_y_xz(av) /), & 2370 'y_xz', NF90_DOUBLE, id_var_y_xz(av), & 2371 'meters', '', 146, 147, 000 ) 2432 2372 ! 2433 2373 !-- Define y-axis (for v position) 2434 nc_stat = NF90_DEF_DIM( id_set_xz(av), 'yv_xz', ns, id_dim_yv_xz(av) ) 2435 CALL handle_netcdf_error( 'netcdf', 369 ) 2436 2437 nc_stat = NF90_DEF_VAR( id_set_xz(av), 'yv_xz', NF90_DOUBLE, & 2438 id_dim_yv_xz(av), id_var_yv_xz(av) ) 2439 CALL handle_netcdf_error( 'netcdf', 370 ) 2440 2441 nc_stat = NF90_PUT_ATT( id_set_xz(av), id_var_yv_xz(av), 'units', & 2442 'meters' ) 2443 CALL handle_netcdf_error( 'netcdf', 371 ) 2444 2374 CALL netcdf_create_dim( id_set_xz(av), 'yv_xz', ns, & 2375 id_dim_yv_xz(av), 369 ) 2376 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_yv_xz(av) /), & 2377 'yv_xz', NF90_DOUBLE, id_var_yv_xz(av), & 2378 'meters', '', 370, 371, 000 ) 2445 2379 ! 2446 2380 !-- Define a variable to store the layer indices of the vertical cross 2447 2381 !-- sections 2448 nc_stat = NF90_DEF_VAR( id_set_xz(av), 'ind_y_xz', NF90_DOUBLE, & 2449 id_dim_y_xz(av), id_var_ind_y_xz(av) ) 2450 CALL handle_netcdf_error( 'netcdf', 148 ) 2451 2452 nc_stat = NF90_PUT_ATT( id_set_xz(av), id_var_ind_y_xz(av), 'units', & 2453 'gridpoints') 2454 CALL handle_netcdf_error( 'netcdf', 149 ) 2455 2382 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_y_xz(av) /), & 2383 'ind_y_xz', NF90_DOUBLE, & 2384 id_var_ind_y_xz(av), 'gridpoints', '', 148, & 2385 149, 000 ) 2456 2386 ! 2457 2387 !-- Define x-axis (for scalar position) 2458 nc_stat = NF90_DEF_DIM( id_set_xz(av), 'x', nx+2, id_dim_x_xz(av) ) 2459 CALL handle_netcdf_error( 'netcdf', 150 ) 2460 2461 nc_stat = NF90_DEF_VAR( id_set_xz(av), 'x', NF90_DOUBLE, & 2462 id_dim_x_xz(av), id_var_x_xz(av) ) 2463 CALL handle_netcdf_error( 'netcdf', 151 ) 2464 2465 nc_stat = NF90_PUT_ATT( id_set_xz(av), id_var_x_xz(av), 'units', & 2466 'meters' ) 2467 CALL handle_netcdf_error( 'netcdf', 152 ) 2468 2388 CALL netcdf_create_dim( id_set_xz(av), 'x', nx+2, id_dim_x_xz(av), & 2389 150 ) 2390 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_x_xz(av) /), 'x', & 2391 NF90_DOUBLE, id_var_x_xz(av), 'meters', '', & 2392 151, 152, 000 ) 2469 2393 ! 2470 2394 !-- Define x-axis (for u position) 2471 nc_stat = NF90_DEF_DIM( id_set_xz(av), 'xu', nx+2, id_dim_xu_xz(av) ) 2472 CALL handle_netcdf_error( 'netcdf', 372 ) 2473 2474 nc_stat = NF90_DEF_VAR( id_set_xz(av), 'xu', NF90_DOUBLE, & 2475 id_dim_xu_xz(av), id_var_xu_xz(av) ) 2476 CALL handle_netcdf_error( 'netcdf', 373 ) 2477 2478 nc_stat = NF90_PUT_ATT( id_set_xz(av), id_var_xu_xz(av), 'units', & 2479 'meters' ) 2480 CALL handle_netcdf_error( 'netcdf', 374 ) 2481 2395 CALL netcdf_create_dim( id_set_xz(av), 'xu', nx+2, id_dim_xu_xz(av), & 2396 372 ) 2397 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_xu_xz(av) /), 'xu', & 2398 NF90_DOUBLE, id_var_xu_xz(av), 'meters', '', & 2399 373, 374, 000 ) 2482 2400 ! 2483 2401 !-- Define the three z-axes (zu, zw, and zs) 2484 nc_stat = NF90_DEF_DIM( id_set_xz(av), 'zu', nz+2, id_dim_zu_xz(av) ) 2485 CALL handle_netcdf_error( 'netcdf', 153 ) 2486 2487 nc_stat = NF90_DEF_VAR( id_set_xz(av), 'zu', NF90_DOUBLE, & 2488 id_dim_zu_xz(av), id_var_zu_xz(av) ) 2489 CALL handle_netcdf_error( 'netcdf', 154 ) 2490 2491 nc_stat = NF90_PUT_ATT( id_set_xz(av), id_var_zu_xz(av), 'units', & 2492 'meters' ) 2493 CALL handle_netcdf_error( 'netcdf', 155 ) 2494 2495 nc_stat = NF90_DEF_DIM( id_set_xz(av), 'zw', nz+2, id_dim_zw_xz(av) ) 2496 CALL handle_netcdf_error( 'netcdf', 156 ) 2497 2498 nc_stat = NF90_DEF_VAR( id_set_xz(av), 'zw', NF90_DOUBLE, & 2499 id_dim_zw_xz(av), id_var_zw_xz(av) ) 2500 CALL handle_netcdf_error( 'netcdf', 157 ) 2501 2502 nc_stat = NF90_PUT_ATT( id_set_xz(av), id_var_zw_xz(av), 'units', & 2503 'meters' ) 2504 CALL handle_netcdf_error( 'netcdf', 158 ) 2402 CALL netcdf_create_dim( id_set_xz(av), 'zu', nz+2, id_dim_zu_xz(av), & 2403 153 ) 2404 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_zu_xz(av) /), 'zu', & 2405 NF90_DOUBLE, id_var_zu_xz(av), 'meters', '', & 2406 154, 155, 000 ) 2407 CALL netcdf_create_dim( id_set_xz(av), 'zw', nz+2, id_dim_zw_xz(av), & 2408 156 ) 2409 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_zw_xz(av) /), 'zw', & 2410 NF90_DOUBLE, id_var_zw_xz(av), 'meters', '', & 2411 157, 158, 000 ) 2505 2412 2506 2413 IF ( land_surface ) THEN 2507 2414 2508 nc_stat = NF90_DEF_DIM( id_set_xz(av), 'zs', nzs, id_dim_zs_xz(av) ) 2509 CALL handle_netcdf_error( 'netcdf', 542 ) 2510 2511 nc_stat = NF90_DEF_VAR( id_set_xz(av), 'zs', NF90_DOUBLE, & 2512 id_dim_zs_xz(av), id_var_zs_xz(av) ) 2513 CALL handle_netcdf_error( 'netcdf', 543 ) 2514 2515 nc_stat = NF90_PUT_ATT( id_set_xz(av), id_var_zs_xz(av), 'units', & 2516 'meters' ) 2517 CALL handle_netcdf_error( 'netcdf', 544 ) 2415 CALL netcdf_create_dim( id_set_xz(av), 'zs', nzs, & 2416 id_dim_zs_xz(av), 542 ) 2417 CALL netcdf_create_var( id_set_xz(av), (/ id_dim_zs_xz(av) /), & 2418 'zs', NF90_DOUBLE, id_var_zs_xz(av), & 2419 'meters', '', 543, 544, 000 ) 2518 2420 2519 2421 ENDIF … … 2580 2482 CALL user_define_netcdf_grid( do2d(av,i), found, & 2581 2483 grid_x, grid_y, grid_z ) 2484 IF ( .NOT. found ) THEN 2485 WRITE ( message_string, * ) 'no grid defined for', & 2486 ' variable ', TRIM( do2d(av,i) ) 2487 CALL message( 'define_netcdf_header', 'PA0244', & 2488 0, 1, 0, 6, 0 ) 2489 ENDIF 2582 2490 2583 2491 END SELECT … … 2607 2515 ! 2608 2516 !-- Define the grid 2609 nc_stat = NF90_DEF_VAR( id_set_xz(av), do2d(av,i), & 2610 nc_precision(2), & 2611 (/ id_x, id_y, id_z, id_dim_time_xz(av) /), & 2612 id_var_do2d(av,i) ) 2613 2614 IF ( .NOT. found ) THEN 2615 WRITE ( message_string, * ) 'no grid defined for', & 2616 ' variable ', TRIM( do2d(av,i) ) 2617 CALL message( 'define_netcdf_header', 'PA0244',& 2618 0, 1, 0, 6, 0 ) 2619 ENDIF 2620 2621 var_list = TRIM( var_list ) // TRIM( do2d(av,i) ) // ';' 2622 2623 CALL handle_netcdf_error( 'netcdf', 159 ) 2624 ! 2625 !-- Store the 'real' name of the variable (with *, for example) 2626 !-- in the long_name attribute. This is evaluated by Ferret, 2627 !-- for example. 2628 nc_stat = NF90_PUT_ATT( id_set_xz(av), id_var_do2d(av,i), & 2629 'long_name', do2d(av,i) ) 2630 CALL handle_netcdf_error( 'netcdf', 160 ) 2631 ! 2632 !-- Define the variable's unit 2633 nc_stat = NF90_PUT_ATT( id_set_xz(av), id_var_do2d(av,i), & 2634 'units', TRIM( do2d_unit(av,i) ) ) 2635 CALL handle_netcdf_error( 'netcdf', 355 ) 2517 CALL netcdf_create_var( id_set_xz(av), (/ id_x, id_y, id_z, & 2518 id_dim_time_xz(av) /), do2d(av,i), & 2519 nc_precision(2), id_var_do2d(av,i), & 2520 TRIM( do2d_unit(av,i) ), do2d(av,i), & 2521 159, 160, 355 ) 2522 2636 2523 #if defined( __netcdf4_parallel ) 2637 2524 … … 2642 2529 id_var_do2d(av,i), & 2643 2530 1, 0 ) 2644 CALL handle_netcdf_error( 'netcdf', 534 )2531 CALL netcdf_handle_error( 'netcdf_define_header', 534 ) 2645 2532 ! 2646 2533 !-- Set independent io operations for parallel io. Collective io … … 2664 2551 ! NF90_INDEPENDENT ) 2665 2552 ENDIF 2666 CALL handle_netcdf_error( 'netcdf', 449 )2553 CALL netcdf_handle_error( 'netcdf_define_header', 449 ) 2667 2554 ENDIF 2668 2555 #endif 2556 var_list = TRIM( var_list ) // TRIM( do2d(av,i) ) // ';' 2557 2669 2558 ENDIF 2670 2559 … … 2682 2571 nc_stat = NF90_PUT_ATT( id_set_xz(av), NF90_GLOBAL, 'VAR_LIST', & 2683 2572 var_list ) 2684 CALL handle_netcdf_error( 'netcdf', 161 )2573 CALL netcdf_handle_error( 'netcdf_define_header', 161 ) 2685 2574 2686 2575 ! … … 2688 2577 !-- parallel output. 2689 2578 nc_stat = NF90_SET_FILL( id_set_xz(av), NF90_NOFILL, oldmode ) 2690 CALL handle_netcdf_error( 'netcdf', 530 )2579 CALL netcdf_handle_error( 'netcdf_define_header', 530 ) 2691 2580 2692 2581 ! 2693 2582 !-- Leave netCDF define mode 2694 2583 nc_stat = NF90_ENDDEF( id_set_xz(av) ) 2695 CALL handle_netcdf_error( 'netcdf', 162 )2584 CALL netcdf_handle_error( 'netcdf_define_header', 162 ) 2696 2585 2697 2586 ! … … 2716 2605 netcdf_data, start = (/ 1 /), & 2717 2606 count = (/ ns /) ) 2718 CALL handle_netcdf_error( 'netcdf', 163 )2607 CALL netcdf_handle_error( 'netcdf_define_header', 163 ) 2719 2608 2720 2609 ! … … 2730 2619 netcdf_data, start = (/ 1 /), & 2731 2620 count = (/ ns /) ) 2732 CALL handle_netcdf_error( 'netcdf', 375 )2621 CALL netcdf_handle_error( 'netcdf_define_header', 375 ) 2733 2622 2734 2623 ! … … 2738 2627 netcdf_data, start = (/ 1 /), & 2739 2628 count = (/ ns /) ) 2740 CALL handle_netcdf_error( 'netcdf', 164 )2629 CALL netcdf_handle_error( 'netcdf_define_header', 164 ) 2741 2630 2742 2631 … … 2754 2643 netcdf_data, start = (/ 1 /), & 2755 2644 count = (/ nx+2 /) ) 2756 CALL handle_netcdf_error( 'netcdf', 165 )2645 CALL netcdf_handle_error( 'netcdf_define_header', 165 ) 2757 2646 2758 2647 DO i = 0, nx+1 … … 2763 2652 netcdf_data, start = (/ 1 /), & 2764 2653 count = (/ nx+2 /) ) 2765 CALL handle_netcdf_error( 'netcdf', 377 )2654 CALL netcdf_handle_error( 'netcdf_define_header', 377 ) 2766 2655 2767 2656 DEALLOCATE( netcdf_data ) … … 2775 2664 netcdf_data, start = (/ 1 /), & 2776 2665 count = (/ nz+2 /) ) 2777 CALL handle_netcdf_error( 'netcdf', 166 )2666 CALL netcdf_handle_error( 'netcdf_define_header', 166 ) 2778 2667 2779 2668 netcdf_data(0:nz+1) = zw(nzb:nzt+1) … … 2781 2670 netcdf_data, start = (/ 1 /), & 2782 2671 count = (/ nz+2 /) ) 2783 CALL handle_netcdf_error( 'netcdf', 167 )2672 CALL netcdf_handle_error( 'netcdf_define_header', 167 ) 2784 2673 2785 2674 ! … … 2790 2679 netcdf_data(0:nzs), start = (/ 1 /), & 2791 2680 count = (/ nzt_soil-nzb_soil+1 /) ) 2792 CALL handle_netcdf_error( 'netcdf', 548 )2681 CALL netcdf_handle_error( 'netcdf_define_header', 548 ) 2793 2682 ENDIF 2794 2683 … … 2808 2697 nc_stat = NF90_GET_ATT( id_set_xz(av), NF90_GLOBAL, 'VAR_LIST', & 2809 2698 var_list_old ) 2810 CALL handle_netcdf_error( 'netcdf', 168 )2699 CALL netcdf_handle_error( 'netcdf_define_header', 168 ) 2811 2700 2812 2701 var_list = ';' … … 2847 2736 !-- Get and compare the number of vertical cross sections 2848 2737 nc_stat = NF90_INQ_VARID( id_set_xz(av), 'y_xz', id_var_y_xz(av) ) 2849 CALL handle_netcdf_error( 'netcdf', 169 )2738 CALL netcdf_handle_error( 'netcdf_define_header', 169 ) 2850 2739 2851 2740 nc_stat = NF90_INQUIRE_VARIABLE( id_set_xz(av), id_var_y_xz(av), & 2852 2741 dimids = id_dim_y_xz_old ) 2853 CALL handle_netcdf_error( 'netcdf', 170 )2742 CALL netcdf_handle_error( 'netcdf_define_header', 170 ) 2854 2743 id_dim_y_xz(av) = id_dim_y_xz_old(1) 2855 2744 2856 2745 nc_stat = NF90_INQUIRE_DIMENSION( id_set_xz(av), id_dim_y_xz(av), & 2857 2746 len = ns_old ) 2858 CALL handle_netcdf_error( 'netcdf', 171 )2747 CALL netcdf_handle_error( 'netcdf_define_header', 171 ) 2859 2748 2860 2749 IF ( ns /= ns_old ) THEN … … 2875 2764 2876 2765 nc_stat = NF90_GET_VAR( id_set_xz(av), id_var_y_xz(av), netcdf_data ) 2877 CALL handle_netcdf_error( 'netcdf', 172 )2766 CALL netcdf_handle_error( 'netcdf_define_header', 172 ) 2878 2767 2879 2768 DO i = 1, ns … … 2915 2804 !-- on the file. 2916 2805 nc_stat = NF90_INQ_VARID( id_set_xz(av), 'time', id_var_time_xz(av) ) 2917 CALL handle_netcdf_error( 'netcdf', 173 )2806 CALL netcdf_handle_error( 'netcdf_define_header', 173 ) 2918 2807 2919 2808 nc_stat = NF90_INQUIRE_VARIABLE( id_set_xz(av), id_var_time_xz(av), & 2920 2809 dimids = id_dim_time_old ) 2921 CALL handle_netcdf_error( 'netcdf', 174 )2810 CALL netcdf_handle_error( 'netcdf_define_header', 174 ) 2922 2811 id_dim_time_xz(av) = id_dim_time_old(1) 2923 2812 2924 2813 nc_stat = NF90_INQUIRE_DIMENSION( id_set_xz(av), id_dim_time_xz(av), & 2925 2814 len = ntime_count ) 2926 CALL handle_netcdf_error( 'netcdf', 175 )2815 CALL netcdf_handle_error( 'netcdf_define_header', 175 ) 2927 2816 2928 2817 ! … … 2937 2826 start = (/ do2d_xz_time_count(av) /), & 2938 2827 count = (/ 1 /) ) 2939 CALL handle_netcdf_error( 'netcdf', 176 )2828 CALL netcdf_handle_error( 'netcdf_define_header', 176 ) 2940 2829 2941 2830 IF ( last_time_coordinate(1) >= simulated_time ) THEN … … 3008 2897 nc_stat = NF90_INQ_VARID( id_set_xz(av), do2d(av,i), & 3009 2898 id_var_do2d(av,i) ) 3010 CALL handle_netcdf_error( 'netcdf', 177 )2899 CALL netcdf_handle_error( 'netcdf_define_header', 177 ) 3011 2900 #if defined( __netcdf4_parallel ) 3012 2901 ! … … 3032 2921 ! NF90_INDEPENDENT ) 3033 2922 ENDIF 3034 CALL handle_netcdf_error( 'netcdf', 455 )2923 CALL netcdf_handle_error( 'netcdf_define_header', 455 ) 3035 2924 ENDIF 3036 2925 #endif … … 3053 2942 ENDIF 3054 2943 nc_stat = NF90_REDEF( id_set_xz(av) ) 3055 CALL handle_netcdf_error( 'netcdf', 433 )2944 CALL netcdf_handle_error( 'netcdf_define_header', 433 ) 3056 2945 nc_stat = NF90_PUT_ATT( id_set_xz(av), NF90_GLOBAL, 'title', & 3057 2946 TRIM( run_description_header ) // & 3058 2947 TRIM( time_average_text ) ) 3059 CALL handle_netcdf_error( 'netcdf', 178 )2948 CALL netcdf_handle_error( 'netcdf_define_header', 178 ) 3060 2949 nc_stat = NF90_ENDDEF( id_set_xz(av) ) 3061 CALL handle_netcdf_error( 'netcdf', 434 )2950 CALL netcdf_handle_error( 'netcdf_define_header', 434 ) 3062 2951 message_string = 'netCDF file for cross-sections ' // & 3063 2952 TRIM( var ) // ' from previous run found.' // & … … 3072 2961 nc_stat = NF90_PUT_ATT( id_set_yz(av), NF90_GLOBAL, 'Conventions', & 3073 2962 'COARDS' ) 3074 CALL handle_netcdf_error( 'netcdf', 179 )2963 CALL netcdf_handle_error( 'netcdf_define_header', 179 ) 3075 2964 3076 2965 IF ( av == 0 ) THEN … … 3083 2972 TRIM( run_description_header ) // & 3084 2973 TRIM( time_average_text ) ) 3085 CALL handle_netcdf_error( 'netcdf', 180 )2974 CALL netcdf_handle_error( 'netcdf_define_header', 180 ) 3086 2975 IF ( av == 1 ) THEN 3087 2976 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval 3088 2977 nc_stat = NF90_PUT_ATT( id_set_yz(av), NF90_GLOBAL, 'time_avg', & 3089 2978 TRIM( time_average_text ) ) 3090 CALL handle_netcdf_error( 'netcdf', 180 )2979 CALL netcdf_handle_error( 'netcdf_define_header', 180 ) 3091 2980 ENDIF 3092 2981 … … 3096 2985 !-- the performance drops significantly. 3097 2986 IF ( netcdf_data_format < 5 ) THEN 3098 nc_stat = NF90_DEF_DIM( id_set_yz(av), 'time', NF90_UNLIMITED, & 3099 id_dim_time_yz(av) ) 3100 CALL handle_netcdf_error( 'netcdf', 181 ) 2987 CALL netcdf_create_dim( id_set_yz(av), 'time', NF90_UNLIMITED, & 2988 id_dim_time_yz(av), 181 ) 3101 2989 ELSE 3102 nc_stat = NF90_DEF_DIM( id_set_yz(av), 'time', ntdim_2d_yz(av), & 3103 id_dim_time_yz(av) ) 3104 CALL handle_netcdf_error( 'netcdf', 526 ) 3105 ENDIF 3106 3107 nc_stat = NF90_DEF_VAR( id_set_yz(av), 'time', NF90_DOUBLE, & 3108 id_dim_time_yz(av), id_var_time_yz(av) ) 3109 CALL handle_netcdf_error( 'netcdf', 182 ) 3110 3111 nc_stat = NF90_PUT_ATT( id_set_yz(av), id_var_time_yz(av), 'units', & 3112 'seconds') 3113 CALL handle_netcdf_error( 'netcdf', 183 ) 3114 2990 CALL netcdf_create_dim( id_set_yz(av), 'time', ntdim_2d_yz(av), & 2991 id_dim_time_yz(av), 526 ) 2992 ENDIF 2993 2994 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_time_yz(av) /), & 2995 'time', NF90_DOUBLE, id_var_time_yz(av), & 2996 'seconds', '', 182, 183, 000 ) 3115 2997 ! 3116 2998 !-- Define the spatial dimensions and coordinates for yz-sections. … … 3128 3010 ! 3129 3011 !-- Define x axis (for scalar position) 3130 nc_stat = NF90_DEF_DIM( id_set_yz(av), 'x_yz', ns, id_dim_x_yz(av) ) 3131 CALL handle_netcdf_error( 'netcdf', 184 ) 3132 3133 nc_stat = NF90_DEF_VAR( id_set_yz(av), 'x_yz', NF90_DOUBLE, & 3134 id_dim_x_yz(av), id_var_x_yz(av) ) 3135 CALL handle_netcdf_error( 'netcdf', 185 ) 3136 3137 nc_stat = NF90_PUT_ATT( id_set_yz(av), id_var_x_yz(av), 'units', & 3138 'meters' ) 3139 CALL handle_netcdf_error( 'netcdf', 186 ) 3140 3012 CALL netcdf_create_dim( id_set_yz(av), 'x_yz', ns, id_dim_x_yz(av), & 3013 184 ) 3014 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_x_yz(av) /), & 3015 'x_yz', NF90_DOUBLE, id_var_x_yz(av), & 3016 'meters', '', 185, 186, 000 ) 3141 3017 ! 3142 3018 !-- Define x axis (for u position) 3143 nc_stat = NF90_DEF_DIM( id_set_yz(av), 'xu_yz', ns, id_dim_xu_yz(av) ) 3144 CALL handle_netcdf_error( 'netcdf', 377 ) 3145 3146 nc_stat = NF90_DEF_VAR( id_set_yz(av), 'xu_yz', NF90_DOUBLE, & 3147 id_dim_xu_yz(av), id_var_xu_yz(av) ) 3148 CALL handle_netcdf_error( 'netcdf', 378 ) 3149 3150 nc_stat = NF90_PUT_ATT( id_set_yz(av), id_var_xu_yz(av), 'units', & 3151 'meters' ) 3152 CALL handle_netcdf_error( 'netcdf', 379 ) 3153 3019 CALL netcdf_create_dim( id_set_yz(av), 'xu_yz', ns, & 3020 id_dim_xu_yz(av), 377 ) 3021 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_xu_yz(av) /), & 3022 'xu_yz', NF90_DOUBLE, id_var_xu_yz(av), & 3023 'meters', '', 378, 379, 000 ) 3154 3024 ! 3155 3025 !-- Define a variable to store the layer indices of the vertical cross 3156 3026 !-- sections 3157 nc_stat = NF90_DEF_VAR( id_set_yz(av), 'ind_x_yz', NF90_DOUBLE, & 3158 id_dim_x_yz(av), id_var_ind_x_yz(av) ) 3159 CALL handle_netcdf_error( 'netcdf', 187 ) 3160 3161 nc_stat = NF90_PUT_ATT( id_set_yz(av), id_var_ind_x_yz(av), 'units', & 3162 'gridpoints') 3163 CALL handle_netcdf_error( 'netcdf', 188 ) 3164 3027 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_x_yz(av) /), & 3028 'ind_x_yz', NF90_DOUBLE, & 3029 id_var_ind_x_yz(av), 'gridpoints', '', 187, & 3030 188, 000 ) 3165 3031 ! 3166 3032 !-- Define y-axis (for scalar position) 3167 nc_stat = NF90_DEF_DIM( id_set_yz(av), 'y', ny+2, id_dim_y_yz(av) ) 3168 CALL handle_netcdf_error( 'netcdf', 189 ) 3169 3170 nc_stat = NF90_DEF_VAR( id_set_yz(av), 'y', NF90_DOUBLE, & 3171 id_dim_y_yz(av), id_var_y_yz(av) ) 3172 CALL handle_netcdf_error( 'netcdf', 190 ) 3173 3174 nc_stat = NF90_PUT_ATT( id_set_yz(av), id_var_y_yz(av), 'units', & 3175 'meters' ) 3176 CALL handle_netcdf_error( 'netcdf', 191 ) 3177 3033 CALL netcdf_create_dim( id_set_yz(av), 'y', ny+2, id_dim_y_yz(av), & 3034 189 ) 3035 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_y_yz(av) /), 'y', & 3036 NF90_DOUBLE, id_var_y_yz(av), 'meters', '', & 3037 190, 191, 000 ) 3178 3038 ! 3179 3039 !-- Define y-axis (for v position) 3180 nc_stat = NF90_DEF_DIM( id_set_yz(av), 'yv', ny+2, id_dim_yv_yz(av) ) 3181 CALL handle_netcdf_error( 'netcdf', 380 ) 3182 3183 nc_stat = NF90_DEF_VAR( id_set_yz(av), 'yv', NF90_DOUBLE, & 3184 id_dim_yv_yz(av), id_var_yv_yz(av) ) 3185 CALL handle_netcdf_error( 'netcdf', 381 ) 3186 3187 nc_stat = NF90_PUT_ATT( id_set_yz(av), id_var_yv_yz(av), 'units', & 3188 'meters' ) 3189 CALL handle_netcdf_error( 'netcdf', 382 ) 3190 3040 CALL netcdf_create_dim( id_set_yz(av), 'yv', ny+2, id_dim_yv_yz(av), & 3041 380 ) 3042 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_yv_yz(av) /), 'yv', & 3043 NF90_DOUBLE, id_var_yv_yz(av), 'meters', '', & 3044 381, 382, 000 ) 3191 3045 ! 3192 3046 !-- Define the two z-axes (zu and zw) 3193 nc_stat = NF90_DEF_DIM( id_set_yz(av), 'zu', nz+2, id_dim_zu_yz(av) ) 3194 CALL handle_netcdf_error( 'netcdf', 192 ) 3195 3196 nc_stat = NF90_DEF_VAR( id_set_yz(av), 'zu', NF90_DOUBLE, & 3197 id_dim_zu_yz(av), id_var_zu_yz(av) ) 3198 CALL handle_netcdf_error( 'netcdf', 193 ) 3199 3200 nc_stat = NF90_PUT_ATT( id_set_yz(av), id_var_zu_yz(av), 'units', & 3201 'meters' ) 3202 CALL handle_netcdf_error( 'netcdf', 194 ) 3203 3204 nc_stat = NF90_DEF_DIM( id_set_yz(av), 'zw', nz+2, id_dim_zw_yz(av) ) 3205 CALL handle_netcdf_error( 'netcdf', 195 ) 3206 3207 nc_stat = NF90_DEF_VAR( id_set_yz(av), 'zw', NF90_DOUBLE, & 3208 id_dim_zw_yz(av), id_var_zw_yz(av) ) 3209 CALL handle_netcdf_error( 'netcdf', 196 ) 3210 3211 nc_stat = NF90_PUT_ATT( id_set_yz(av), id_var_zw_yz(av), 'units', & 3212 'meters' ) 3213 CALL handle_netcdf_error( 'netcdf', 197 ) 3047 CALL netcdf_create_dim( id_set_yz(av), 'zu', nz+2, id_dim_zu_yz(av), & 3048 192 ) 3049 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_zu_yz(av) /), 'zu', & 3050 NF90_DOUBLE, id_var_zu_yz(av), 'meters', '', & 3051 193, 194, 000 ) 3052 3053 CALL netcdf_create_dim( id_set_yz(av), 'zw', nz+2, id_dim_zw_yz(av), & 3054 195 ) 3055 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_zw_yz(av) /), 'zw', & 3056 NF90_DOUBLE, id_var_zw_yz(av), 'meters', '', & 3057 196, 197, 000 ) 3214 3058 3215 3059 IF ( land_surface ) THEN 3216 3060 3217 nc_stat = NF90_DEF_DIM( id_set_yz(av), 'zs', nzs, id_dim_zs_yz(av) ) 3218 CALL handle_netcdf_error( 'netcdf', 545 ) 3219 3220 nc_stat = NF90_DEF_VAR( id_set_yz(av), 'zs', NF90_DOUBLE, & 3221 id_dim_zs_yz(av), id_var_zs_yz(av) ) 3222 CALL handle_netcdf_error( 'netcdf', 546 ) 3223 3224 nc_stat = NF90_PUT_ATT( id_set_yz(av), id_var_zs_yz(av), 'units', & 3225 'meters' ) 3226 CALL handle_netcdf_error( 'netcdf', 547 ) 3227 3228 ENDIF 3229 3061 CALL netcdf_create_dim( id_set_yz(av), 'zs', nzs, & 3062 id_dim_zs_yz(av), 545 ) 3063 CALL netcdf_create_var( id_set_yz(av), (/ id_dim_zs_yz(av) /), & 3064 'zs', NF90_DOUBLE, id_var_zs_yz(av), & 3065 'meters', '', 546, 547, 000 ) 3066 3067 ENDIF 3230 3068 3231 3069 ! … … 3290 3128 grid_x, grid_y, grid_z ) 3291 3129 3130 IF ( .NOT. found ) THEN 3131 WRITE ( message_string, * ) 'no grid defined for', & 3132 ' variable ', TRIM( do2d(av,i) ) 3133 CALL message( 'define_netcdf_header', 'PA0244', & 3134 0, 1, 0, 6, 0 ) 3135 ENDIF 3136 3292 3137 END SELECT 3293 3138 … … 3316 3161 ! 3317 3162 !-- Define the grid 3318 nc_stat = NF90_DEF_VAR( id_set_yz(av), do2d(av,i), & 3319 nc_precision(3), & 3320 (/ id_x, id_y, id_z, id_dim_time_yz(av) /), & 3321 id_var_do2d(av,i) ) 3322 3323 IF ( .NOT. found ) THEN 3324 WRITE ( message_string, * ) 'no grid defined for', & 3325 ' variable ', TRIM( do2d(av,i) ) 3326 CALL message( 'define_netcdf_header', 'PA0244',& 3327 0, 1, 0, 6, 0 ) 3328 ENDIF 3329 3330 var_list = TRIM( var_list ) // TRIM( do2d(av,i) ) // ';' 3331 3332 CALL handle_netcdf_error( 'netcdf', 198 ) 3333 ! 3334 !-- Store the 'real' name of the variable (with *, for example) 3335 !-- in the long_name attribute. This is evaluated by Ferret, 3336 !-- for example. 3337 nc_stat = NF90_PUT_ATT( id_set_yz(av), id_var_do2d(av,i), & 3338 'long_name', do2d(av,i) ) 3339 CALL handle_netcdf_error( 'netcdf', 199 ) 3340 ! 3341 !-- Define the variable's unit 3342 nc_stat = NF90_PUT_ATT( id_set_yz(av), id_var_do2d(av,i), & 3343 'units', TRIM( do2d_unit(av,i) ) ) 3344 CALL handle_netcdf_error( 'netcdf', 356 ) 3163 CALL netcdf_create_var( id_set_yz(av), (/ id_x, id_y, id_z, & 3164 id_dim_time_yz(av) /), do2d(av,i), & 3165 nc_precision(3), id_var_do2d(av,i), & 3166 TRIM( do2d_unit(av,i) ), do2d(av,i), & 3167 198, 199, 356 ) 3168 3345 3169 #if defined( __netcdf4_parallel ) 3346 3170 IF ( netcdf_data_format > 4 ) THEN … … 3350 3174 id_var_do2d(av,i), & 3351 3175 1, 0 ) 3352 CALL handle_netcdf_error( 'netcdf', 535 )3176 CALL netcdf_handle_error( 'netcdf_define_header', 535 ) 3353 3177 ! 3354 3178 !-- Set independent io operations for parallel io. Collective io … … 3372 3196 ! NF90_INDEPENDENT ) 3373 3197 ENDIF 3374 CALL handle_netcdf_error( 'netcdf', 450 )3198 CALL netcdf_handle_error( 'netcdf_define_header', 450 ) 3375 3199 ENDIF 3376 3200 #endif 3201 var_list = TRIM( var_list ) // TRIM( do2d(av,i) ) // ';' 3202 3377 3203 ENDIF 3378 3204 … … 3390 3216 nc_stat = NF90_PUT_ATT( id_set_yz(av), NF90_GLOBAL, 'VAR_LIST', & 3391 3217 var_list ) 3392 CALL handle_netcdf_error( 'netcdf', 200 )3218 CALL netcdf_handle_error( 'netcdf_define_header', 200 ) 3393 3219 3394 3220 ! … … 3396 3222 !-- parallel output. 3397 3223 nc_stat = NF90_SET_FILL( id_set_yz(av), NF90_NOFILL, oldmode ) 3398 CALL handle_netcdf_error( 'netcdf', 531 )3224 CALL netcdf_handle_error( 'netcdf_define_header', 531 ) 3399 3225 3400 3226 ! 3401 3227 !-- Leave netCDF define mode 3402 3228 nc_stat = NF90_ENDDEF( id_set_yz(av) ) 3403 CALL handle_netcdf_error( 'netcdf', 201 )3229 CALL netcdf_handle_error( 'netcdf_define_header', 201 ) 3404 3230 3405 3231 ! … … 3424 3250 netcdf_data, start = (/ 1 /), & 3425 3251 count = (/ ns /) ) 3426 CALL handle_netcdf_error( 'netcdf', 202 )3252 CALL netcdf_handle_error( 'netcdf_define_header', 202 ) 3427 3253 3428 3254 ! … … 3438 3264 netcdf_data, start = (/ 1 /), & 3439 3265 count = (/ ns /) ) 3440 CALL handle_netcdf_error( 'netcdf', 383 )3266 CALL netcdf_handle_error( 'netcdf_define_header', 383 ) 3441 3267 3442 3268 ! … … 3446 3272 netcdf_data, start = (/ 1 /), & 3447 3273 count = (/ ns /) ) 3448 CALL handle_netcdf_error( 'netcdf', 203 )3274 CALL netcdf_handle_error( 'netcdf_define_header', 203 ) 3449 3275 3450 3276 DEALLOCATE( netcdf_data ) … … 3461 3287 netcdf_data, start = (/ 1 /), & 3462 3288 count = (/ ny+2 /) ) 3463 CALL handle_netcdf_error( 'netcdf', 204 )3289 CALL netcdf_handle_error( 'netcdf_define_header', 204 ) 3464 3290 3465 3291 DO j = 0, ny+1 … … 3470 3296 netcdf_data, start = (/ 1 /), & 3471 3297 count = (/ ny+2 /) ) 3472 CALL handle_netcdf_error( 'netcdf', 384 )3298 CALL netcdf_handle_error( 'netcdf_define_header', 384 ) 3473 3299 3474 3300 DEALLOCATE( netcdf_data ) … … 3482 3308 netcdf_data, start = (/ 1 /), & 3483 3309 count = (/ nz+2 /) ) 3484 CALL handle_netcdf_error( 'netcdf', 205 )3310 CALL netcdf_handle_error( 'netcdf_define_header', 205 ) 3485 3311 3486 3312 netcdf_data(0:nz+1) = zw(nzb:nzt+1) … … 3488 3314 netcdf_data, start = (/ 1 /), & 3489 3315 count = (/ nz+2 /) ) 3490 CALL handle_netcdf_error( 'netcdf', 206 )3316 CALL netcdf_handle_error( 'netcdf_define_header', 206 ) 3491 3317 3492 3318 DEALLOCATE( netcdf_data ) … … 3504 3330 nc_stat = NF90_GET_ATT( id_set_yz(av), NF90_GLOBAL, 'VAR_LIST', & 3505 3331 var_list_old ) 3506 CALL handle_netcdf_error( 'netcdf', 207 )3332 CALL netcdf_handle_error( 'netcdf_define_header', 207 ) 3507 3333 3508 3334 var_list = ';' … … 3543 3369 !-- Get and compare the number of vertical cross sections 3544 3370 nc_stat = NF90_INQ_VARID( id_set_yz(av), 'x_yz', id_var_x_yz(av) ) 3545 CALL handle_netcdf_error( 'netcdf', 208 )3371 CALL netcdf_handle_error( 'netcdf_define_header', 208 ) 3546 3372 3547 3373 nc_stat = NF90_INQUIRE_VARIABLE( id_set_yz(av), id_var_x_yz(av), & 3548 3374 dimids = id_dim_x_yz_old ) 3549 CALL handle_netcdf_error( 'netcdf', 209 )3375 CALL netcdf_handle_error( 'netcdf_define_header', 209 ) 3550 3376 id_dim_x_yz(av) = id_dim_x_yz_old(1) 3551 3377 3552 3378 nc_stat = NF90_INQUIRE_DIMENSION( id_set_yz(av), id_dim_x_yz(av), & 3553 3379 len = ns_old ) 3554 CALL handle_netcdf_error( 'netcdf', 210 )3380 CALL netcdf_handle_error( 'netcdf_define_header', 210 ) 3555 3381 3556 3382 IF ( ns /= ns_old ) THEN … … 3571 3397 3572 3398 nc_stat = NF90_GET_VAR( id_set_yz(av), id_var_x_yz(av), netcdf_data ) 3573 CALL handle_netcdf_error( 'netcdf', 211 )3399 CALL netcdf_handle_error( 'netcdf_define_header', 211 ) 3574 3400 3575 3401 DO i = 1, ns … … 3611 3437 !-- on the file. 3612 3438 nc_stat = NF90_INQ_VARID( id_set_yz(av), 'time', id_var_time_yz(av) ) 3613 CALL handle_netcdf_error( 'netcdf', 212 )3439 CALL netcdf_handle_error( 'netcdf_define_header', 212 ) 3614 3440 3615 3441 nc_stat = NF90_INQUIRE_VARIABLE( id_set_yz(av), id_var_time_yz(av), & 3616 3442 dimids = id_dim_time_old ) 3617 CALL handle_netcdf_error( 'netcdf', 213 )3443 CALL netcdf_handle_error( 'netcdf_define_header', 213 ) 3618 3444 id_dim_time_yz(av) = id_dim_time_old(1) 3619 3445 3620 3446 nc_stat = NF90_INQUIRE_DIMENSION( id_set_yz(av), id_dim_time_yz(av), & 3621 3447 len = ntime_count ) 3622 CALL handle_netcdf_error( 'netcdf', 214 )3448 CALL netcdf_handle_error( 'netcdf_define_header', 214 ) 3623 3449 3624 3450 ! … … 3633 3459 start = (/ do2d_yz_time_count(av) /), & 3634 3460 count = (/ 1 /) ) 3635 CALL handle_netcdf_error( 'netcdf', 215 )3461 CALL netcdf_handle_error( 'netcdf_define_header', 215 ) 3636 3462 3637 3463 IF ( last_time_coordinate(1) >= simulated_time ) THEN … … 3704 3530 nc_stat = NF90_INQ_VARID( id_set_yz(av), do2d(av,i), & 3705 3531 id_var_do2d(av,i) ) 3706 CALL handle_netcdf_error( 'netcdf', 216 )3532 CALL netcdf_handle_error( 'netcdf_define_header', 216 ) 3707 3533 #if defined( __netcdf4_parallel ) 3708 3534 ! … … 3728 3554 ! NF90_INDEPENDENT ) 3729 3555 ENDIF 3730 CALL handle_netcdf_error( 'netcdf', 450 )3556 CALL netcdf_handle_error( 'netcdf_define_header', 450 ) 3731 3557 ENDIF 3732 3558 #endif … … 3749 3575 ENDIF 3750 3576 nc_stat = NF90_REDEF( id_set_yz(av) ) 3751 CALL handle_netcdf_error( 'netcdf', 435 )3577 CALL netcdf_handle_error( 'netcdf_define_header', 435 ) 3752 3578 nc_stat = NF90_PUT_ATT( id_set_yz(av), NF90_GLOBAL, 'title', & 3753 3579 TRIM( run_description_header ) // & 3754 3580 TRIM( time_average_text ) ) 3755 CALL handle_netcdf_error( 'netcdf', 217 )3581 CALL netcdf_handle_error( 'netcdf_define_header', 217 ) 3756 3582 nc_stat = NF90_ENDDEF( id_set_yz(av) ) 3757 CALL handle_netcdf_error( 'netcdf', 436 )3583 CALL netcdf_handle_error( 'netcdf_define_header', 436 ) 3758 3584 message_string = 'netCDF file for cross-sections ' // & 3759 3585 TRIM( var ) // ' from previous run found.' // & … … 3772 3598 TRIM( run_description_header ) // & 3773 3599 TRIM( time_average_text ) ) 3774 CALL handle_netcdf_error( 'netcdf', 218 )3600 CALL netcdf_handle_error( 'netcdf_define_header', 218 ) 3775 3601 3776 3602 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval_pr … … 3781 3607 TRIM( run_description_header ) ) 3782 3608 ENDIF 3783 CALL handle_netcdf_error( 'netcdf', 219 )3609 CALL netcdf_handle_error( 'netcdf_define_header', 219 ) 3784 3610 3785 3611 ! … … 3790 3616 'no_rows', & 3791 3617 profile_rows ) 3792 CALL handle_netcdf_error( 'netcdf', 519 )3618 CALL netcdf_handle_error( 'netcdf_define_header', 519 ) 3793 3619 3794 3620 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, & 3795 3621 'no_columns', & 3796 3622 profile_columns ) 3797 CALL handle_netcdf_error( 'netcdf', 520 )3623 CALL netcdf_handle_error( 'netcdf_define_header', 520 ) 3798 3624 3799 3625 … … 3831 3657 !-- Check if all profiles defined in cross_profiles are defined in 3832 3658 !-- data_output_pr. If not, they will be skipped. 3833 3834 3659 DO i = 1, cross_profiles_count 3835 3660 DO j = 1, dopr_n … … 3869 3694 !-- Check if all profiles defined in data_output_pr are defined in 3870 3695 !-- cross_profiles. If not, they will be added to cross_profiles. 3871 3872 3696 DO i = 1, dopr_n 3873 3697 DO j = 1, cross_profiles_count … … 3929 3753 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, 'cross_profiles', & 3930 3754 TRIM( char_cross_profiles ) ) 3931 CALL handle_netcdf_error( 'netcdf', 521 )3755 CALL netcdf_handle_error( 'netcdf_define_header', 521 ) 3932 3756 3933 3757 ! 3934 3758 !-- Define time coordinate for profiles (unlimited dimension) 3935 nc_stat = NF90_DEF_DIM( id_set_pr, 'time', NF90_UNLIMITED, & 3936 id_dim_time_pr ) 3937 CALL handle_netcdf_error( 'netcdf', 220 ) 3938 3939 nc_stat = NF90_DEF_VAR( id_set_pr, 'time', NF90_DOUBLE, & 3940 id_dim_time_pr, id_var_time_pr ) 3941 CALL handle_netcdf_error( 'netcdf', 221 ) 3942 3943 nc_stat = NF90_PUT_ATT( id_set_pr, id_var_time_pr, 'units', 'seconds') 3944 CALL handle_netcdf_error( 'netcdf', 222 ) 3945 3759 CALL netcdf_create_dim( id_set_pr, 'time', NF90_UNLIMITED, & 3760 id_dim_time_pr, 220 ) 3761 CALL netcdf_create_var( id_set_pr, (/ id_dim_time_pr /), 'time', & 3762 NF90_DOUBLE, id_var_time_pr, 'seconds', '', & 3763 221, 222, 000 ) 3946 3764 ! 3947 3765 !-- Define the variables … … 3953 3771 ! 3954 3772 !-- Define the z-axes (each variable gets its own z-axis) 3955 nc_stat = NF90_DEF_DIM( id_set_pr, & 3956 'z' // TRIM( data_output_pr(i) ), & 3957 nzt+2-nzb, id_dim_z_pr(i,0) ) 3958 CALL handle_netcdf_error( 'netcdf', 223 ) 3959 3960 nc_stat = NF90_DEF_VAR( id_set_pr, & 3961 'z' // TRIM( data_output_pr(i) ), & 3962 NF90_DOUBLE, id_dim_z_pr(i,0), & 3963 id_var_z_pr(i,0) ) 3964 CALL handle_netcdf_error( 'netcdf', 224 ) 3965 3966 nc_stat = NF90_PUT_ATT( id_set_pr, id_var_z_pr(i,0), 'units', & 3967 'meters' ) 3968 CALL handle_netcdf_error( 'netcdf', 225 ) 3773 CALL netcdf_create_dim( id_set_pr, & 3774 'z' // TRIM( data_output_pr(i) ), & 3775 nzt+2-nzb, id_dim_z_pr(i,0), 223 ) 3776 CALL netcdf_create_var( id_set_pr, (/ id_dim_z_pr(i,0) /), & 3777 'z' // TRIM( data_output_pr(i) ), & 3778 NF90_DOUBLE, id_var_z_pr(i,0), & 3779 'meters', '', 224, 225, 000 ) 3969 3780 ! 3970 3781 !-- Define the variable 3971 nc_stat = NF90_DEF_VAR( id_set_pr, data_output_pr(i), & 3972 nc_precision(5), (/ id_dim_z_pr(i,0), & 3973 id_dim_time_pr /), id_var_dopr(i,0) ) 3974 CALL handle_netcdf_error( 'netcdf', 226 ) 3975 3976 nc_stat = NF90_PUT_ATT( id_set_pr, id_var_dopr(i,0), & 3977 'long_name', TRIM( data_output_pr(i) ) ) 3978 CALL handle_netcdf_error( 'netcdf', 227 ) 3979 3980 nc_stat = NF90_PUT_ATT( id_set_pr, id_var_dopr(i,0), & 3981 'units', TRIM( dopr_unit(i) ) ) 3982 CALL handle_netcdf_error( 'netcdf', 228 ) 3782 CALL netcdf_create_var( id_set_pr, (/ id_dim_z_pr(i,0), & 3783 id_dim_time_pr /), data_output_pr(i), & 3784 nc_precision(5), id_var_dopr(i,0), & 3785 TRIM( dopr_unit(i) ), & 3786 TRIM( data_output_pr(i) ), 226, 227, & 3787 228 ) 3983 3788 3984 3789 var_list = TRIM( var_list ) // TRIM( data_output_pr(i) ) // ';' … … 3993 3798 ! 3994 3799 !-- Define the z-axes (each variable gets it own z-axis) 3995 nc_stat = NF90_DEF_DIM( id_set_pr, & 3996 'z'//TRIM(data_output_pr(i))//suffix, & 3997 nzt+2-nzb, id_dim_z_pr(i,j) ) 3998 CALL handle_netcdf_error( 'netcdf', 229 ) 3999 4000 nc_stat = NF90_DEF_VAR( id_set_pr, & 4001 'z'//TRIM(data_output_pr(i))//suffix, & 4002 nc_precision(5), id_dim_z_pr(i,j), & 4003 id_var_z_pr(i,j) ) 4004 CALL handle_netcdf_error( 'netcdf', 230 ) 4005 4006 nc_stat = NF90_PUT_ATT( id_set_pr, id_var_z_pr(i,j), & 4007 'units', 'meters' ) 4008 CALL handle_netcdf_error( 'netcdf', 231 ) 4009 3800 CALL netcdf_create_dim( id_set_pr, 'z' // & 3801 TRIM(data_output_pr(i)) // suffix, & 3802 nzt+2-nzb, id_dim_z_pr(i,j), 229 ) 3803 CALL netcdf_create_var( id_set_pr, (/ id_dim_z_pr(i,j) /), & 3804 'z' // TRIM(data_output_pr(i)) // & 3805 suffix, NF90_DOUBLE, & 3806 id_var_z_pr(i,j), 'meters', '', & 3807 230, 231, 000 ) 4010 3808 ! 4011 3809 !-- Define the variable 4012 nc_stat = NF90_DEF_VAR( id_set_pr, & 4013 TRIM(data_output_pr(i)) // suffix, & 4014 nc_precision(5), & 4015 (/ id_dim_z_pr(i,j), & 4016 id_dim_time_pr /), id_var_dopr(i,j) ) 4017 CALL handle_netcdf_error( 'netcdf', 232 ) 4018 4019 nc_stat = NF90_PUT_ATT( id_set_pr, id_var_dopr(i,j), & 4020 'long_name', & 4021 TRIM( data_output_pr(i) ) // ' SR ' & 4022 // suffix(2:2) ) 4023 CALL handle_netcdf_error( 'netcdf', 233 ) 4024 4025 nc_stat = NF90_PUT_ATT( id_set_pr, id_var_dopr(i,j), & 4026 'units', TRIM( dopr_unit(i) ) ) 4027 CALL handle_netcdf_error( 'netcdf', 234 ) 3810 CALL netcdf_create_var( id_set_pr, (/ id_dim_z_pr(i,j), & 3811 id_dim_time_pr /), & 3812 TRIM(data_output_pr(i)) // suffix, & 3813 nc_precision(5), id_var_dopr(i,j), & 3814 TRIM( dopr_unit(i) ), & 3815 TRIM( data_output_pr(i) ) // & 3816 ' SR ', 232, 233, 234 ) 4028 3817 4029 3818 var_list = TRIM( var_list ) // TRIM( data_output_pr(i) ) // & … … 4040 3829 !-- restart runs) 4041 3830 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, 'VAR_LIST', var_list ) 4042 CALL handle_netcdf_error( 'netcdf', 235 )3831 CALL netcdf_handle_error( 'netcdf_define_header', 235 ) 4043 3832 4044 3833 ! … … 4046 3835 DO i = 1, dopr_norm_num 4047 3836 4048 nc_stat = NF90_DEF_VAR( id_set_pr, 'NORM_' // & 4049 TRIM( dopr_norm_names(i) ), & 4050 nc_precision(5), (/ id_dim_time_pr /), & 4051 id_var_norm_dopr(i) ) 4052 CALL handle_netcdf_error( 'netcdf', 236 ) 4053 4054 nc_stat = NF90_PUT_ATT( id_set_pr, id_var_norm_dopr(i), & 4055 'long_name', & 4056 TRIM( dopr_norm_longnames(i) ) ) 4057 CALL handle_netcdf_error( 'netcdf', 237 ) 3837 CALL netcdf_create_var( id_set_pr, (/ id_dim_time_pr /), & 3838 'NORM_' // TRIM( dopr_norm_names(i) ), & 3839 nc_precision(5), id_var_norm_dopr(i), & 3840 '', TRIM( dopr_norm_longnames(i) ), 236, & 3841 000, 237 ) 4058 3842 4059 3843 ENDDO … … 4062 3846 !-- Leave netCDF define mode 4063 3847 nc_stat = NF90_ENDDEF( id_set_pr ) 4064 CALL handle_netcdf_error( 'netcdf', 238 )3848 CALL netcdf_handle_error( 'netcdf_define_header', 238 ) 4065 3849 4066 3850 ! … … 4073 3857 start = (/ 1 /), & 4074 3858 count = (/ nzt-nzb+2 /) ) 4075 CALL handle_netcdf_error( 'netcdf', 239 )3859 CALL netcdf_handle_error( 'netcdf_define_header', 239 ) 4076 3860 4077 3861 ENDDO … … 4088 3872 nc_stat = NF90_GET_ATT( id_set_pr, NF90_GLOBAL, 'VAR_LIST', & 4089 3873 var_list_old ) 4090 CALL handle_netcdf_error( 'netcdf', 240 )3874 CALL netcdf_handle_error( 'netcdf_define_header', 240 ) 4091 3875 4092 3876 var_list = ';' … … 4122 3906 !-- on the file. 4123 3907 nc_stat = NF90_INQ_VARID( id_set_pr, 'time', id_var_time_pr ) 4124 CALL handle_netcdf_error( 'netcdf', 241 )3908 CALL netcdf_handle_error( 'netcdf_define_header', 241 ) 4125 3909 4126 3910 nc_stat = NF90_INQUIRE_VARIABLE( id_set_pr, id_var_time_pr, & 4127 3911 dimids = id_dim_time_old ) 4128 CALL handle_netcdf_error( 'netcdf', 242 )3912 CALL netcdf_handle_error( 'netcdf_define_header', 242 ) 4129 3913 id_dim_time_pr = id_dim_time_old(1) 4130 3914 4131 3915 nc_stat = NF90_INQUIRE_DIMENSION( id_set_pr, id_dim_time_pr, & 4132 3916 len = dopr_time_count ) 4133 CALL handle_netcdf_error( 'netcdf', 243 )3917 CALL netcdf_handle_error( 'netcdf_define_header', 243 ) 4134 3918 4135 3919 nc_stat = NF90_GET_VAR( id_set_pr, id_var_time_pr, & … … 4137 3921 start = (/ dopr_time_count /), & 4138 3922 count = (/ 1 /) ) 4139 CALL handle_netcdf_error( 'netcdf', 244 )3923 CALL netcdf_handle_error( 'netcdf_define_header', 244 ) 4140 3924 4141 3925 IF ( last_time_coordinate(1) >= simulated_time ) THEN … … 4162 3946 nc_stat = NF90_INQ_VARID( id_set_pr, data_output_pr(i), & 4163 3947 id_var_dopr(i,0) ) 4164 CALL handle_netcdf_error( 'netcdf', 245 )3948 CALL netcdf_handle_error( 'netcdf_define_header', 245 ) 4165 3949 ELSE 4166 3950 DO j = 0, statistic_regions … … 4169 3953 nc_stat = NF90_INQ_VARID( id_set_pr, netcdf_var_name, & 4170 3954 id_var_dopr(i,j) ) 4171 CALL handle_netcdf_error( 'netcdf', 246 )3955 CALL netcdf_handle_error( 'netcdf_define_header', 246 ) 4172 3956 ENDDO 4173 3957 ENDIF … … 4181 3965 'NORM_' // TRIM( dopr_norm_names(i) ), & 4182 3966 id_var_norm_dopr(i) ) 4183 CALL handle_netcdf_error( 'netcdf', 247 )3967 CALL netcdf_handle_error( 'netcdf_define_header', 247 ) 4184 3968 ENDDO 4185 3969 … … 4198 3982 ENDIF 4199 3983 nc_stat = NF90_REDEF( id_set_pr ) 4200 CALL handle_netcdf_error( 'netcdf', 437 )3984 CALL netcdf_handle_error( 'netcdf_define_header', 437 ) 4201 3985 nc_stat = NF90_PUT_ATT( id_set_pr, NF90_GLOBAL, 'title', & 4202 3986 TRIM( run_description_header ) // & 4203 3987 TRIM( time_average_text ) ) 4204 CALL handle_netcdf_error( 'netcdf', 248 )3988 CALL netcdf_handle_error( 'netcdf_define_header', 248 ) 4205 3989 4206 3990 nc_stat = NF90_ENDDEF( id_set_pr ) 4207 CALL handle_netcdf_error( 'netcdf', 438 )3991 CALL netcdf_handle_error( 'netcdf_define_header', 438 ) 4208 3992 message_string = 'netCDF file for vertical profiles ' // & 4209 3993 'from previous run found.' // & … … 4218 4002 nc_stat = NF90_PUT_ATT( id_set_ts, NF90_GLOBAL, 'title', & 4219 4003 TRIM( run_description_header ) ) 4220 CALL handle_netcdf_error( 'netcdf', 249 )4004 CALL netcdf_handle_error( 'netcdf_define_header', 249 ) 4221 4005 4222 4006 ! 4223 4007 !-- Define time coordinate for time series (unlimited dimension) 4224 nc_stat = NF90_DEF_DIM( id_set_ts, 'time', NF90_UNLIMITED, & 4225 id_dim_time_ts ) 4226 CALL handle_netcdf_error( 'netcdf', 250 ) 4227 4228 nc_stat = NF90_DEF_VAR( id_set_ts, 'time', NF90_DOUBLE, & 4229 id_dim_time_ts, id_var_time_ts ) 4230 CALL handle_netcdf_error( 'netcdf', 251 ) 4231 4232 nc_stat = NF90_PUT_ATT( id_set_ts, id_var_time_ts, 'units', 'seconds') 4233 CALL handle_netcdf_error( 'netcdf', 252 ) 4234 4008 CALL netcdf_create_dim( id_set_ts, 'time', NF90_UNLIMITED, & 4009 id_dim_time_ts, 250 ) 4010 CALL netcdf_create_var( id_set_ts, (/ id_dim_time_ts /), 'time', & 4011 NF90_DOUBLE, id_var_time_ts, 'seconds', '', & 4012 251, 252, 000 ) 4235 4013 ! 4236 4014 !-- Define the variables … … 4240 4018 IF ( statistic_regions == 0 ) THEN 4241 4019 4242 nc_stat = NF90_DEF_VAR( id_set_ts, dots_label(i), & 4243 nc_precision(6), (/ id_dim_time_ts /), & 4244 id_var_dots(i,0) ) 4245 CALL handle_netcdf_error( 'netcdf', 253 ) 4246 4247 nc_stat = NF90_PUT_ATT( id_set_ts, id_var_dots(i,0), & 4248 'long_name', TRIM( dots_label(i) ) ) 4249 CALL handle_netcdf_error( 'netcdf', 254 ) 4250 4251 nc_stat = NF90_PUT_ATT( id_set_ts, id_var_dots(i,0), & 4252 'units', TRIM( dots_unit(i) ) ) 4253 CALL handle_netcdf_error( 'netcdf', 255 ) 4254 4255 var_list = TRIM( var_list ) // TRIM( dots_label(i) ) // ';' 4020 CALL netcdf_create_var( id_set_ts, (/ id_dim_time_ts /), & 4021 dots_label(i), nc_precision(6), & 4022 id_var_dots(i,0), & 4023 TRIM( dots_unit(i) ), & 4024 TRIM( dots_label(i) ), 253, 254, 255 ) 4256 4025 4257 4026 ELSE … … 4262 4031 WRITE ( suffix, '(''_'',I1)' ) j 4263 4032 4264 nc_stat = NF90_DEF_VAR( id_set_ts, & 4265 TRIM( dots_label(i) ) // suffix, & 4266 nc_precision(6), & 4267 (/ id_dim_time_ts /), & 4268 id_var_dots(i,j) ) 4269 CALL handle_netcdf_error( 'netcdf', 256 ) 4270 4271 nc_stat = NF90_PUT_ATT( id_set_ts, id_var_dots(i,j), & 4272 'long_name', & 4273 TRIM( dots_label(i) ) // ' SR ' // & 4274 suffix(2:2) ) 4275 CALL handle_netcdf_error( 'netcdf', 257 ) 4276 4277 nc_stat = NF90_PUT_ATT( id_set_ts, id_var_dots(i,j), & 4278 'units', TRIM( dots_unit(i) ) ) 4279 CALL handle_netcdf_error( 'netcdf', 347 ) 4280 4281 var_list = TRIM( var_list ) // TRIM( dots_label(i) ) // & 4282 suffix // ';' 4033 CALL netcdf_create_var( id_set_ts, (/ id_dim_time_ts /), & 4034 TRIM( dots_label(i) ) // suffix, & 4035 nc_precision(6), id_var_dots(i,j), & 4036 TRIM( dots_unit(i) ), & 4037 TRIM( dots_label(i) ) // ' SR ' // & 4038 suffix(2:2), 256, 257, 347) 4283 4039 4284 4040 ENDDO … … 4292 4048 !-- restart runs) 4293 4049 nc_stat = NF90_PUT_ATT( id_set_ts, NF90_GLOBAL, 'VAR_LIST', var_list ) 4294 CALL handle_netcdf_error( 'netcdf', 258 )4050 CALL netcdf_handle_error( 'netcdf_define_header', 258 ) 4295 4051 4296 4052 ! 4297 4053 !-- Leave netCDF define mode 4298 4054 nc_stat = NF90_ENDDEF( id_set_ts ) 4299 CALL handle_netcdf_error( 'netcdf', 259 )4055 CALL netcdf_handle_error( 'netcdf_define_header', 259 ) 4300 4056 4301 4057 … … 4309 4065 nc_stat = NF90_GET_ATT( id_set_ts, NF90_GLOBAL, 'VAR_LIST', & 4310 4066 var_list_old ) 4311 CALL handle_netcdf_error( 'netcdf', 260 )4067 CALL netcdf_handle_error( 'netcdf_define_header', 260 ) 4312 4068 4313 4069 var_list = ';' … … 4344 4100 !-- on the file. 4345 4101 nc_stat = NF90_INQ_VARID( id_set_ts, 'time', id_var_time_ts ) 4346 CALL handle_netcdf_error( 'netcdf', 261 )4102 CALL netcdf_handle_error( 'netcdf_define_header', 261 ) 4347 4103 4348 4104 nc_stat = NF90_INQUIRE_VARIABLE( id_set_ts, id_var_time_ts, & 4349 4105 dimids = id_dim_time_old ) 4350 CALL handle_netcdf_error( 'netcdf', 262 )4106 CALL netcdf_handle_error( 'netcdf_define_header', 262 ) 4351 4107 id_dim_time_ts = id_dim_time_old(1) 4352 4108 4353 4109 nc_stat = NF90_INQUIRE_DIMENSION( id_set_ts, id_dim_time_ts, & 4354 4110 len = dots_time_count ) 4355 CALL handle_netcdf_error( 'netcdf', 263 )4111 CALL netcdf_handle_error( 'netcdf_define_header', 263 ) 4356 4112 4357 4113 nc_stat = NF90_GET_VAR( id_set_ts, id_var_time_ts, & … … 4359 4115 start = (/ dots_time_count /), & 4360 4116 count = (/ 1 /) ) 4361 CALL handle_netcdf_error( 'netcdf', 264 )4117 CALL netcdf_handle_error( 'netcdf_define_header', 264 ) 4362 4118 4363 4119 IF ( last_time_coordinate(1) >= simulated_time ) THEN … … 4384 4140 nc_stat = NF90_INQ_VARID( id_set_ts, dots_label(i), & 4385 4141 id_var_dots(i,0) ) 4386 CALL handle_netcdf_error( 'netcdf', 265 )4142 CALL netcdf_handle_error( 'netcdf_define_header', 265 ) 4387 4143 ELSE 4388 4144 DO j = 0, statistic_regions … … 4391 4147 nc_stat = NF90_INQ_VARID( id_set_ts, netcdf_var_name, & 4392 4148 id_var_dots(i,j) ) 4393 CALL handle_netcdf_error( 'netcdf', 266 )4149 CALL netcdf_handle_error( 'netcdf_define_header', 266 ) 4394 4150 ENDDO 4395 4151 ENDIF … … 4405 4161 !-- to ensure equal attribute size in a job chain. Maybe revise later. 4406 4162 nc_stat = NF90_REDEF( id_set_ts ) 4407 CALL handle_netcdf_error( 'netcdf', 439 )4163 CALL netcdf_handle_error( 'netcdf_define_header', 439 ) 4408 4164 nc_stat = NF90_PUT_ATT( id_set_ts, NF90_GLOBAL, 'title', & 4409 4165 TRIM( run_description_header ) ) 4410 CALL handle_netcdf_error( 'netcdf', 267 )4166 CALL netcdf_handle_error( 'netcdf_define_header', 267 ) 4411 4167 nc_stat = NF90_ENDDEF( id_set_ts ) 4412 CALL handle_netcdf_error( 'netcdf', 440 )4168 CALL netcdf_handle_error( 'netcdf_define_header', 440 ) 4413 4169 message_string = 'netCDF file for time series ' // & 4414 4170 'from previous run found.' // & … … 4427 4183 TRIM( run_description_header ) // & 4428 4184 TRIM( time_average_text ) ) 4429 CALL handle_netcdf_error( 'netcdf', 268 )4185 CALL netcdf_handle_error( 'netcdf_define_header', 268 ) 4430 4186 4431 4187 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval_sp … … 4436 4192 TRIM( run_description_header ) ) 4437 4193 ENDIF 4438 CALL handle_netcdf_error( 'netcdf', 269 )4194 CALL netcdf_handle_error( 'netcdf_define_header', 269 ) 4439 4195 4440 4196 ! 4441 4197 !-- Define time coordinate for spectra (unlimited dimension) 4442 nc_stat = NF90_DEF_DIM( id_set_sp, 'time', NF90_UNLIMITED, & 4443 id_dim_time_sp ) 4444 CALL handle_netcdf_error( 'netcdf', 270 ) 4445 4446 nc_stat = NF90_DEF_VAR( id_set_sp, 'time', NF90_DOUBLE, & 4447 id_dim_time_sp, id_var_time_sp ) 4448 CALL handle_netcdf_error( 'netcdf', 271 ) 4449 4450 nc_stat = NF90_PUT_ATT( id_set_sp, id_var_time_sp, 'units', 'seconds') 4451 CALL handle_netcdf_error( 'netcdf', 272 ) 4452 4198 CALL netcdf_create_dim( id_set_sp, 'time', NF90_UNLIMITED, & 4199 id_dim_time_sp, 270 ) 4200 CALL netcdf_create_var( id_set_sp, (/ id_dim_time_sp /), 'time', & 4201 NF90_DOUBLE, id_var_time_sp, 'seconds', '', & 4202 271, 272, 000 ) 4453 4203 ! 4454 4204 !-- Define the spatial dimensions and coordinates for spectra. … … 4463 4213 ! 4464 4214 !-- Define vertical coordinate grid (zu grid) 4465 nc_stat = NF90_DEF_DIM( id_set_sp, 'zu_sp', ns, id_dim_zu_sp ) 4466 CALL handle_netcdf_error( 'netcdf', 273 ) 4467 4468 nc_stat = NF90_DEF_VAR( id_set_sp, 'zu_sp', NF90_DOUBLE, & 4469 id_dim_zu_sp, id_var_zu_sp ) 4470 CALL handle_netcdf_error( 'netcdf', 274 ) 4471 4472 nc_stat = NF90_PUT_ATT( id_set_sp, id_var_zu_sp, 'units', 'meters' ) 4473 CALL handle_netcdf_error( 'netcdf', 275 ) 4474 4215 CALL netcdf_create_dim( id_set_sp, 'zu_sp', ns, id_dim_zu_sp, 273 ) 4216 CALL netcdf_create_var( id_set_sp, (/ id_dim_zu_sp /), 'zu_sp', & 4217 NF90_DOUBLE, id_var_zu_sp, 'meters', '', & 4218 274, 275, 000 ) 4475 4219 ! 4476 4220 !-- Define vertical coordinate grid (zw grid) 4477 nc_stat = NF90_DEF_DIM( id_set_sp, 'zw_sp', ns, id_dim_zw_sp ) 4478 CALL handle_netcdf_error( 'netcdf', 276 ) 4479 4480 nc_stat = NF90_DEF_VAR( id_set_sp, 'zw_sp', NF90_DOUBLE, & 4481 id_dim_zw_sp, id_var_zw_sp ) 4482 CALL handle_netcdf_error( 'netcdf', 277 ) 4483 4484 nc_stat = NF90_PUT_ATT( id_set_sp, id_var_zw_sp, 'units', 'meters' ) 4485 CALL handle_netcdf_error( 'netcdf', 278 ) 4486 4221 CALL netcdf_create_dim( id_set_sp, 'zw_sp', ns, id_dim_zw_sp, 276 ) 4222 CALL netcdf_create_var( id_set_sp, (/ id_dim_zw_sp /), 'zw_sp', & 4223 NF90_DOUBLE, id_var_zw_sp, 'meters', '', & 4224 277, 278, 000 ) 4487 4225 ! 4488 4226 !-- Define x-axis 4489 nc_stat = NF90_DEF_DIM( id_set_sp, 'k_x', nx/2, id_dim_x_sp ) 4490 CALL handle_netcdf_error( 'netcdf', 279 ) 4491 4492 nc_stat = NF90_DEF_VAR( id_set_sp, 'k_x', NF90_DOUBLE, id_dim_x_sp, & 4493 id_var_x_sp ) 4494 CALL handle_netcdf_error( 'netcdf', 280 ) 4495 4496 nc_stat = NF90_PUT_ATT( id_set_sp, id_var_x_sp, 'units', 'm-1' ) 4497 CALL handle_netcdf_error( 'netcdf', 281 ) 4498 4227 CALL netcdf_create_dim( id_set_sp, 'k_x', nx/2, id_dim_x_sp, 279 ) 4228 CALL netcdf_create_var( id_set_sp, (/ id_dim_x_sp /), 'k_x', & 4229 NF90_DOUBLE, id_var_x_sp, 'm-1', '', 280, & 4230 281, 000 ) 4499 4231 ! 4500 4232 !-- Define y-axis 4501 nc_stat = NF90_DEF_DIM( id_set_sp, 'k_y', ny/2, id_dim_y_sp ) 4502 CALL handle_netcdf_error( 'netcdf', 282 ) 4503 4504 nc_stat = NF90_DEF_VAR( id_set_sp, 'k_y', NF90_DOUBLE, id_dim_y_sp, & 4505 id_var_y_sp ) 4506 CALL handle_netcdf_error( 'netcdf', 283 ) 4507 4508 nc_stat = NF90_PUT_ATT( id_set_sp, id_var_y_sp, 'units', 'm-1' ) 4509 CALL handle_netcdf_error( 'netcdf', 284 ) 4510 4233 CALL netcdf_create_dim(id_set_sp, 'k_y', ny/2, id_dim_y_sp, 282 ) 4234 CALL netcdf_create_var( id_set_sp, (/ id_dim_y_sp /), 'k_y', & 4235 NF90_DOUBLE, id_var_y_sp, 'm-1', '', 283, & 4236 284, 000 ) 4511 4237 ! 4512 4238 !-- Define the variables … … 4546 4272 netcdf_var_name = TRIM( data_output_sp(i) ) // '_x' 4547 4273 IF ( TRIM( grid_z ) == 'zw' ) THEN 4548 nc_stat = NF90_DEF_VAR( id_set_sp, netcdf_var_name, & 4549 nc_precision(7), (/ id_dim_x_sp, & 4550 id_dim_zw_sp, id_dim_time_sp /), & 4551 id_var_dospx(i) ) 4274 CALL netcdf_create_var( id_set_sp, (/ id_dim_x_sp, & 4275 id_dim_zw_sp, id_dim_time_sp /), & 4276 netcdf_var_name, nc_precision(7), & 4277 id_var_dospx(i), 'unknown', & 4278 netcdf_var_name, 285, 286, 287 ) 4552 4279 ELSE 4553 nc_stat = NF90_DEF_VAR( id_set_sp, netcdf_var_name, & 4554 nc_precision(7), (/ id_dim_x_sp, & 4555 id_dim_zu_sp, id_dim_time_sp /), & 4556 id_var_dospx(i) ) 4280 CALL netcdf_create_var( id_set_sp, (/ id_dim_x_sp, & 4281 id_dim_zu_sp, id_dim_time_sp /), & 4282 netcdf_var_name, nc_precision(7), & 4283 id_var_dospx(i), 'unknown', & 4284 netcdf_var_name, 285, 286, 287 ) 4557 4285 ENDIF 4558 CALL handle_netcdf_error( 'netcdf', 285 )4559 4560 nc_stat = NF90_PUT_ATT( id_set_sp, id_var_dospx(i), &4561 'long_name', netcdf_var_name )4562 CALL handle_netcdf_error( 'netcdf', 286 )4563 4564 nc_stat = NF90_PUT_ATT( id_set_sp, id_var_dospx(i), &4565 'units', 'unknown' )4566 CALL handle_netcdf_error( 'netcdf', 287 )4567 4286 4568 4287 var_list = TRIM( var_list ) // TRIM( netcdf_var_name ) // ';' … … 4576 4295 netcdf_var_name = TRIM( data_output_sp(i) ) // '_y' 4577 4296 IF ( TRIM( grid_z ) == 'zw' ) THEN 4578 nc_stat = NF90_DEF_VAR( id_set_sp, netcdf_var_name, & 4579 nc_precision(7), (/ id_dim_y_sp, & 4580 id_dim_zw_sp, id_dim_time_sp /), & 4581 id_var_dospy(i) ) 4297 CALL netcdf_create_var( id_set_sp, (/ id_dim_y_sp, & 4298 id_dim_zw_sp, id_dim_time_sp /), & 4299 netcdf_var_name, nc_precision(7), & 4300 id_var_dospy(i), 'unknown', & 4301 netcdf_var_name, 288, 289, 290 ) 4582 4302 ELSE 4583 nc_stat = NF90_DEF_VAR( id_set_sp, netcdf_var_name, & 4584 nc_precision(7), (/ id_dim_y_sp, & 4585 id_dim_zu_sp, id_dim_time_sp /), & 4586 id_var_dospy(i) ) 4303 CALL netcdf_create_var( id_set_sp, (/ id_dim_y_sp, & 4304 id_dim_zu_sp, id_dim_time_sp /), & 4305 netcdf_var_name, nc_precision(7), & 4306 id_var_dospy(i), 'unknown', & 4307 netcdf_var_name, 288, 289, 290 ) 4587 4308 ENDIF 4588 CALL handle_netcdf_error( 'netcdf', 288 )4589 4590 nc_stat = NF90_PUT_ATT( id_set_sp, id_var_dospy(i), &4591 'long_name', netcdf_var_name )4592 CALL handle_netcdf_error( 'netcdf', 289 )4593 4594 nc_stat = NF90_PUT_ATT( id_set_sp, id_var_dospy(i), &4595 'units', 'unknown' )4596 CALL handle_netcdf_error( 'netcdf', 290 )4597 4309 4598 4310 var_list = TRIM( var_list ) // TRIM( netcdf_var_name ) // ';' … … 4608 4320 !-- restart runs) 4609 4321 nc_stat = NF90_PUT_ATT( id_set_sp, NF90_GLOBAL, 'VAR_LIST', var_list ) 4610 CALL handle_netcdf_error( 'netcdf', 291 )4322 CALL netcdf_handle_error( 'netcdf_define_header', 291 ) 4611 4323 4612 4324 ! 4613 4325 !-- Leave netCDF define mode 4614 4326 nc_stat = NF90_ENDDEF( id_set_sp ) 4615 CALL handle_netcdf_error( 'netcdf', 292 )4327 CALL netcdf_handle_error( 'netcdf_define_header', 292 ) 4616 4328 4617 4329 ! … … 4624 4336 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_zu_sp, netcdf_data, & 4625 4337 start = (/ 1 /), count = (/ ns /) ) 4626 CALL handle_netcdf_error( 'netcdf', 293 )4338 CALL netcdf_handle_error( 'netcdf_define_header', 293 ) 4627 4339 4628 4340 ! … … 4631 4343 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_zw_sp, netcdf_data, & 4632 4344 start = (/ 1 /), count = (/ ns /) ) 4633 CALL handle_netcdf_error( 'netcdf', 294 )4345 CALL netcdf_handle_error( 'netcdf_define_header', 294 ) 4634 4346 4635 4347 DEALLOCATE( netcdf_data ) … … 4644 4356 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_x_sp, netcdf_data, & 4645 4357 start = (/ 1 /), count = (/ nx/2 /) ) 4646 CALL handle_netcdf_error( 'netcdf', 295 )4358 CALL netcdf_handle_error( 'netcdf_define_header', 295 ) 4647 4359 4648 4360 DEALLOCATE( netcdf_data ) … … 4655 4367 nc_stat = NF90_PUT_VAR( id_set_sp, id_var_y_sp, netcdf_data, & 4656 4368 start = (/ 1 /), count = (/ ny/2 /) ) 4657 CALL handle_netcdf_error( 'netcdf', 296 )4369 CALL netcdf_handle_error( 'netcdf_define_header', 296 ) 4658 4370 4659 4371 DEALLOCATE( netcdf_data ) … … 4669 4381 nc_stat = NF90_GET_ATT( id_set_sp, NF90_GLOBAL, 'VAR_LIST', & 4670 4382 var_list_old ) 4671 CALL handle_netcdf_error( 'netcdf', 297 )4383 CALL netcdf_handle_error( 'netcdf_define_header', 297 ) 4672 4384 var_list = ';' 4673 4385 i = 1 … … 4711 4423 !-- Get and compare the number of vertical levels 4712 4424 nc_stat = NF90_INQ_VARID( id_set_sp, 'zu_sp', id_var_zu_sp ) 4713 CALL handle_netcdf_error( 'netcdf', 298 )4425 CALL netcdf_handle_error( 'netcdf_define_header', 298 ) 4714 4426 4715 4427 nc_stat = NF90_INQUIRE_VARIABLE( id_set_sp, id_var_zu_sp, & 4716 4428 dimids = id_dim_zu_sp_old ) 4717 CALL handle_netcdf_error( 'netcdf', 299 )4429 CALL netcdf_handle_error( 'netcdf_define_header', 299 ) 4718 4430 id_dim_zu_sp = id_dim_zu_sp_old(1) 4719 4431 4720 4432 nc_stat = NF90_INQUIRE_DIMENSION( id_set_sp, id_dim_zu_sp, & 4721 4433 len = ns_old ) 4722 CALL handle_netcdf_error( 'netcdf', 300 )4434 CALL netcdf_handle_error( 'netcdf_define_header', 300 ) 4723 4435 4724 4436 IF ( ns /= ns_old ) THEN … … 4739 4451 4740 4452 nc_stat = NF90_GET_VAR( id_set_sp, id_var_zu_sp, netcdf_data ) 4741 CALL handle_netcdf_error( 'netcdf', 301 )4453 CALL netcdf_handle_error( 'netcdf_define_header', 301 ) 4742 4454 4743 4455 DO i = 1, ns … … 4763 4475 !-- on the file. 4764 4476 nc_stat = NF90_INQ_VARID( id_set_sp, 'time', id_var_time_sp ) 4765 CALL handle_netcdf_error( 'netcdf', 302 )4477 CALL netcdf_handle_error( 'netcdf_define_header', 302 ) 4766 4478 4767 4479 nc_stat = NF90_INQUIRE_VARIABLE( id_set_sp, id_var_time_sp, & 4768 4480 dimids = id_dim_time_old ) 4769 CALL handle_netcdf_error( 'netcdf', 303 )4481 CALL netcdf_handle_error( 'netcdf_define_header', 303 ) 4770 4482 id_dim_time_sp = id_dim_time_old(1) 4771 4483 4772 4484 nc_stat = NF90_INQUIRE_DIMENSION( id_set_sp, id_dim_time_sp, & 4773 4485 len = dosp_time_count ) 4774 CALL handle_netcdf_error( 'netcdf', 304 )4486 CALL netcdf_handle_error( 'netcdf_define_header', 304 ) 4775 4487 4776 4488 nc_stat = NF90_GET_VAR( id_set_sp, id_var_time_sp, & … … 4778 4490 start = (/ dosp_time_count /), & 4779 4491 count = (/ 1 /) ) 4780 CALL handle_netcdf_error( 'netcdf', 305 )4492 CALL netcdf_handle_error( 'netcdf_define_header', 305 ) 4781 4493 4782 4494 IF ( last_time_coordinate(1) >= simulated_time ) THEN … … 4804 4516 nc_stat = NF90_INQ_VARID( id_set_sp, netcdf_var_name, & 4805 4517 id_var_dospx(i) ) 4806 CALL handle_netcdf_error( 'netcdf', 306 )4518 CALL netcdf_handle_error( 'netcdf_define_header', 306 ) 4807 4519 ENDIF 4808 4520 … … 4811 4523 nc_stat = NF90_INQ_VARID( id_set_sp, netcdf_var_name, & 4812 4524 id_var_dospy(i) ) 4813 CALL handle_netcdf_error( 'netcdf', 307 )4525 CALL netcdf_handle_error( 'netcdf_define_header', 307 ) 4814 4526 ENDIF 4815 4527 … … 4826 4538 !-- to ensure equal attribute size in a job chain. Maybe revise later. 4827 4539 nc_stat = NF90_REDEF( id_set_sp ) 4828 CALL handle_netcdf_error( 'netcdf', 441 )4540 CALL netcdf_handle_error( 'netcdf_define_header', 441 ) 4829 4541 IF ( averaging_interval_sp /= 0.0_wp ) THEN 4830 4542 WRITE (time_average_text,'('', '',F7.1,'' s average'')') & … … 4833 4545 TRIM( run_description_header ) // & 4834 4546 TRIM( time_average_text ) ) 4835 CALL handle_netcdf_error( 'netcdf', 308 )4547 CALL netcdf_handle_error( 'netcdf_define_header', 308 ) 4836 4548 4837 4549 WRITE ( time_average_text,'(F7.1,'' s avg'')' ) averaging_interval_sp … … 4842 4554 TRIM( run_description_header ) ) 4843 4555 ENDIF 4844 CALL handle_netcdf_error( 'netcdf', 309 )4556 CALL netcdf_handle_error( 'netcdf_define_header', 309 ) 4845 4557 nc_stat = NF90_ENDDEF( id_set_sp ) 4846 CALL handle_netcdf_error( 'netcdf', 442 )4558 CALL netcdf_handle_error( 'netcdf_define_header', 442 ) 4847 4559 message_string = 'netCDF file for spectra ' // & 4848 4560 'from previous run found.' // & … … 4857 4569 nc_stat = NF90_PUT_ATT( id_set_prt, NF90_GLOBAL, 'title', & 4858 4570 TRIM( run_description_header ) ) 4859 CALL handle_netcdf_error( 'netcdf', 310 )4571 CALL netcdf_handle_error( 'netcdf_define_header', 310 ) 4860 4572 4861 4573 ! 4862 4574 !-- Define time coordinate for particles (unlimited dimension) 4863 nc_stat = NF90_DEF_DIM( id_set_prt, 'time', NF90_UNLIMITED, & 4864 id_dim_time_prt ) 4865 CALL handle_netcdf_error( 'netcdf', 311 ) 4866 4867 nc_stat = NF90_DEF_VAR( id_set_prt, 'time', NF90_DOUBLE, & 4868 id_dim_time_prt, id_var_time_prt ) 4869 CALL handle_netcdf_error( 'netcdf', 312 ) 4870 4871 nc_stat = NF90_PUT_ATT( id_set_prt, id_var_time_prt, 'units', & 4872 'seconds' ) 4873 CALL handle_netcdf_error( 'netcdf', 313 ) 4874 4575 CALL netcdf_create_dim( id_set_prt, 'time', NF90_UNLIMITED, & 4576 id_dim_time_prt, 311 ) 4577 CALL netcdf_create_var( id_set_prt, (/ id_dim_time_prt /), 'time', & 4578 NF90_DOUBLE, id_var_time_prt, 'seconds', '', & 4579 312, 313, 000 ) 4875 4580 ! 4876 4581 !-- Define particle coordinate (maximum particle number) 4877 4582 IF ( netcdf_data_format < 3 ) THEN 4878 nc_stat = NF90_DEF_DIM( id_set_prt, 'particle_number', & 4879 maximum_number_of_particles, id_dim_prtnum) 4583 CALL netcdf_create_dim( id_set_prt, 'particle_number', & 4584 maximum_number_of_particles, & 4585 id_dim_prtnum, 314 ) 4880 4586 ELSE 4881 4587 ! 4882 4588 !-- netCDF4 allows more than one unlimited dimension 4883 nc_stat = NF90_DEF_DIM( id_set_prt, 'particle_number', & 4884 NF90_UNLIMITED, id_dim_prtnum) 4885 ENDIF 4886 CALL handle_netcdf_error( 'netcdf', 314 ) 4887 4888 nc_stat = NF90_DEF_VAR( id_set_prt, 'particle_number', NF90_DOUBLE, & 4889 id_dim_prtnum, id_var_prtnum ) 4890 CALL handle_netcdf_error( 'netcdf', 315 ) 4891 4892 nc_stat = NF90_PUT_ATT( id_set_prt, id_var_prtnum, 'units', & 4893 'particle number' ) 4894 CALL handle_netcdf_error( 'netcdf', 316 ) 4895 4589 CALL netcdf_create_dim( id_set_prt, 'particle_number', & 4590 NF90_UNLIMITED, id_dim_prtnum, 314 ) 4591 ENDIF 4592 4593 CALL netcdf_create_var( id_set_prt, (/ id_dim_prtnum /), & 4594 'particle_number', NF90_DOUBLE, & 4595 id_var_prtnum, 'particle number', '', 315, & 4596 316, 000 ) 4896 4597 ! 4897 4598 !-- Define variable which contains the real number of particles in use 4898 nc_stat = NF90_DEF_VAR( id_set_prt, 'real_num_of_prt', NF90_INT, & 4899 id_dim_time_prt, id_var_rnop_prt ) 4900 CALL handle_netcdf_error( 'netcdf', 317 ) 4901 4902 nc_stat = NF90_PUT_ATT( id_set_prt, id_var_rnop_prt, 'units', & 4903 'particle number' ) 4904 CALL handle_netcdf_error( 'netcdf', 318 ) 4905 4599 CALL netcdf_create_var( id_set_prt, (/ id_dim_time_prt /), & 4600 'real_num_of_prt', NF90_DOUBLE, & 4601 id_var_rnop_prt, 'particle number', '', 317, & 4602 318, 000 ) 4906 4603 ! 4907 4604 !-- Define the variables 4908 4605 DO i = 1, 17 4909 4606 4910 nc_stat = NF90_DEF_VAR( id_set_prt, prt_var_names(i), & 4911 nc_precision(8), & 4912 (/ id_dim_prtnum, id_dim_time_prt /), & 4913 id_var_prt(i) ) 4914 CALL handle_netcdf_error( 'netcdf', 319 ) 4915 4916 nc_stat = NF90_PUT_ATT( id_set_prt, id_var_prt(i), & 4917 'long_name', TRIM( prt_var_names(i) ) ) 4918 CALL handle_netcdf_error( 'netcdf', 320 ) 4919 4920 nc_stat = NF90_PUT_ATT( id_set_prt, id_var_prt(i), & 4921 'units', TRIM( prt_var_units(i) ) ) 4922 CALL handle_netcdf_error( 'netcdf', 321 ) 4607 CALL netcdf_create_var( id_set_prt, (/ id_dim_prtnum, & 4608 id_dim_time_prt /), prt_var_names(i), & 4609 nc_precision(8), id_var_prt(i), & 4610 TRIM( prt_var_units(i) ), & 4611 TRIM( prt_var_names(i) ), 319, 320, 321 ) 4923 4612 4924 4613 ENDDO … … 4927 4616 !-- Leave netCDF define mode 4928 4617 nc_stat = NF90_ENDDEF( id_set_prt ) 4929 CALL handle_netcdf_error( 'netcdf', 322 )4618 CALL netcdf_handle_error( 'netcdf_define_header', 322 ) 4930 4619 4931 4620 … … 4938 4627 !-- on the file. 4939 4628 nc_stat = NF90_INQ_VARID( id_set_prt, 'time', id_var_time_prt ) 4940 CALL handle_netcdf_error( 'netcdf', 323 )4629 CALL netcdf_handle_error( 'netcdf_define_header', 323 ) 4941 4630 4942 4631 nc_stat = NF90_INQUIRE_VARIABLE( id_set_prt, id_var_time_prt, & 4943 4632 dimids = id_dim_time_old ) 4944 CALL handle_netcdf_error( 'netcdf', 324 )4633 CALL netcdf_handle_error( 'netcdf_define_header', 324 ) 4945 4634 id_dim_time_prt = id_dim_time_old(1) 4946 4635 4947 4636 nc_stat = NF90_INQUIRE_DIMENSION( id_set_prt, id_dim_time_prt, & 4948 4637 len = prt_time_count ) 4949 CALL handle_netcdf_error( 'netcdf', 325 )4638 CALL netcdf_handle_error( 'netcdf_define_header', 325 ) 4950 4639 4951 4640 nc_stat = NF90_GET_VAR( id_set_prt, id_var_time_prt, & … … 4953 4642 start = (/ prt_time_count /), & 4954 4643 count = (/ 1 /) ) 4955 CALL handle_netcdf_error( 'netcdf', 326 )4644 CALL netcdf_handle_error( 'netcdf_define_header', 326 ) 4956 4645 4957 4646 IF ( last_time_coordinate(1) >= simulated_time ) THEN … … 4974 4663 nc_stat = NF90_INQ_VARID( id_set_prt, 'real_num_of_prt', & 4975 4664 id_var_rnop_prt ) 4976 CALL handle_netcdf_error( 'netcdf', 327 )4665 CALL netcdf_handle_error( 'netcdf_define_header', 327 ) 4977 4666 4978 4667 DO i = 1, 17 … … 4980 4669 nc_stat = NF90_INQ_VARID( id_set_prt, prt_var_names(i), & 4981 4670 id_var_prt(i) ) 4982 CALL handle_netcdf_error( 'netcdf', 328 )4671 CALL netcdf_handle_error( 'netcdf_define_header', 328 ) 4983 4672 4984 4673 ENDDO … … 4997 4686 nc_stat = NF90_PUT_ATT( id_set_pts, NF90_GLOBAL, 'title', & 4998 4687 TRIM( run_description_header ) ) 4999 CALL handle_netcdf_error( 'netcdf', 396 )4688 CALL netcdf_handle_error( 'netcdf_define_header', 396 ) 5000 4689 5001 4690 ! 5002 4691 !-- Define time coordinate for particle time series (unlimited dimension) 5003 nc_stat = NF90_DEF_DIM( id_set_pts, 'time', NF90_UNLIMITED, & 5004 id_dim_time_pts ) 5005 CALL handle_netcdf_error( 'netcdf', 397 ) 5006 5007 nc_stat = NF90_DEF_VAR( id_set_pts, 'time', NF90_DOUBLE, & 5008 id_dim_time_pts, id_var_time_pts ) 5009 CALL handle_netcdf_error( 'netcdf', 398 ) 5010 5011 nc_stat = NF90_PUT_ATT( id_set_pts, id_var_time_pts, 'units', & 5012 'seconds') 5013 CALL handle_netcdf_error( 'netcdf', 399 ) 5014 4692 CALL netcdf_create_dim( id_set_pts, 'time', NF90_UNLIMITED, & 4693 id_dim_time_pts, 397 ) 4694 CALL netcdf_create_var( id_set_pts, (/ id_dim_time_pts /), 'time', & 4695 NF90_DOUBLE, id_var_time_pts, 'seconds', '', & 4696 398, 399, 000 ) 5015 4697 ! 5016 4698 !-- Define the variables. If more than one particle group is defined, … … 5027 4709 ENDIF 5028 4710 5029 nc_stat = NF90_DEF_VAR( id_set_pts, &5030 TRIM( dopts_label(i) ) // suffix1, &5031 nc_precision(6), &5032 (/ id_dim_time_pts /), &5033 id_var_dopts(i,j) )5034 CALL handle_netcdf_error( 'netcdf', 400 )5035 5036 4711 IF ( j == 0 ) THEN 5037 nc_stat = NF90_PUT_ATT( id_set_pts, id_var_dopts(i,j), & 5038 'long_name', & 5039 TRIM( dopts_label(i) ) ) 4712 CALL netcdf_create_var( id_set_pts, (/ id_dim_time_pts /), & 4713 TRIM( dopts_label(i) ) // suffix1, & 4714 nc_precision(6), id_var_dopts(i,j), & 4715 TRIM( dopts_unit(i) ), & 4716 TRIM( dopts_label(i) ), 400, 401, & 4717 402 ) 5040 4718 ELSE 5041 nc_stat = NF90_PUT_ATT( id_set_pts, id_var_dopts(i,j), & 5042 'long_name', & 4719 CALL netcdf_create_var( id_set_pts, (/ id_dim_time_pts /), & 4720 TRIM( dopts_label(i) ) // suffix1, & 4721 nc_precision(6), id_var_dopts(i,j), & 4722 TRIM( dopts_unit(i) ), & 5043 4723 TRIM( dopts_label(i) ) // ' PG ' // & 5044 suffix1(2:3) )4724 suffix1(2:3), 400, 401, 402 ) 5045 4725 ENDIF 5046 CALL handle_netcdf_error( 'netcdf', 401 )5047 5048 nc_stat = NF90_PUT_ATT( id_set_pts, id_var_dopts(i,j), &5049 'units', TRIM( dopts_unit(i) ) )5050 CALL handle_netcdf_error( 'netcdf', 402 )5051 4726 5052 4727 var_list = TRIM( var_list ) // TRIM( dopts_label(i) ) // & … … 5064 4739 nc_stat = NF90_PUT_ATT( id_set_pts, NF90_GLOBAL, 'VAR_LIST', & 5065 4740 var_list ) 5066 CALL handle_netcdf_error( 'netcdf', 403 )4741 CALL netcdf_handle_error( 'netcdf_define_header', 403 ) 5067 4742 5068 4743 … … 5070 4745 !-- Leave netCDF define mode 5071 4746 nc_stat = NF90_ENDDEF( id_set_pts ) 5072 CALL handle_netcdf_error( 'netcdf', 404 )4747 CALL netcdf_handle_error( 'netcdf_define_header', 404 ) 5073 4748 5074 4749 … … 5082 4757 nc_stat = NF90_GET_ATT( id_set_pts, NF90_GLOBAL, 'VAR_LIST', & 5083 4758 var_list_old ) 5084 CALL handle_netcdf_error( 'netcdf', 405 )4759 CALL netcdf_handle_error( 'netcdf_define_header', 405 ) 5085 4760 5086 4761 var_list = ';' … … 5122 4797 !-- on the file. 5123 4798 nc_stat = NF90_INQ_VARID( id_set_pts, 'time', id_var_time_pts ) 5124 CALL handle_netcdf_error( 'netcdf', 406 )4799 CALL netcdf_handle_error( 'netcdf_define_header', 406 ) 5125 4800 5126 4801 nc_stat = NF90_INQUIRE_VARIABLE( id_set_pts, id_var_time_pts, & 5127 4802 dimids = id_dim_time_old ) 5128 CALL handle_netcdf_error( 'netcdf', 407 )4803 CALL netcdf_handle_error( 'netcdf_define_header', 407 ) 5129 4804 id_dim_time_pts = id_dim_time_old(1) 5130 4805 5131 4806 nc_stat = NF90_INQUIRE_DIMENSION( id_set_pts, id_dim_time_pts, & 5132 4807 len = dopts_time_count ) 5133 CALL handle_netcdf_error( 'netcdf', 408 )4808 CALL netcdf_handle_error( 'netcdf_define_header', 408 ) 5134 4809 5135 4810 nc_stat = NF90_GET_VAR( id_set_pts, id_var_time_pts, & … … 5137 4812 start = (/ dopts_time_count /), & 5138 4813 count = (/ 1 /) ) 5139 CALL handle_netcdf_error( 'netcdf', 409 )4814 CALL netcdf_handle_error( 'netcdf_define_header', 409 ) 5140 4815 5141 4816 IF ( last_time_coordinate(1) >= simulated_time ) THEN … … 5171 4846 nc_stat = NF90_INQ_VARID( id_set_pts, netcdf_var_name, & 5172 4847 id_var_dopts(i,j) ) 5173 CALL handle_netcdf_error( 'netcdf', 410 )4848 CALL netcdf_handle_error( 'netcdf_define_header', 410 ) 5174 4849 5175 4850 IF ( number_of_particle_groups == 1 ) EXIT … … 5187 4862 !-- to ensure equal attribute size in a job chain. Maybe revise later. 5188 4863 nc_stat = NF90_REDEF( id_set_pts ) 5189 CALL handle_netcdf_error( 'netcdf', 443 )4864 CALL netcdf_handle_error( 'netcdf_define_header', 443 ) 5190 4865 nc_stat = NF90_PUT_ATT( id_set_pts, NF90_GLOBAL, 'title', & 5191 4866 TRIM( run_description_header ) ) 5192 CALL handle_netcdf_error( 'netcdf', 411 )4867 CALL netcdf_handle_error( 'netcdf_define_header', 411 ) 5193 4868 nc_stat = NF90_ENDDEF( id_set_pts ) 5194 CALL handle_netcdf_error( 'netcdf', 444 )4869 CALL netcdf_handle_error( 'netcdf_define_header', 444 ) 5195 4870 message_string = 'netCDF file for particle time series ' // & 5196 4871 'from previous run found.' // & 5197 4872 '&This file will be extended.' 5198 CALL message( ' define_netcdf_header', 'PA0269', 0, 0, 0, 6, 0 )4873 CALL message( 'netcdf_define_header', 'PA0269', 0, 0, 0, 6, 0 ) 5199 4874 5200 4875 … … 5202 4877 5203 4878 message_string = 'mode "' // TRIM( mode) // '" not supported' 5204 CALL message( ' define_netcdf_header', 'PA0270', 0, 0, 0, 6, 0 )4879 CALL message( 'netcdf_define_header', 'PA0270', 0, 0, 0, 6, 0 ) 5205 4880 5206 4881 END SELECT 5207 4882 5208 4883 #endif 5209 END SUBROUTINE define_netcdf_header4884 END SUBROUTINE netcdf_define_header 5210 4885 5211 4886 … … 5217 4892 !------------------------------------------------------------------------------! 5218 4893 5219 SUBROUTINE create_netcdf_file( filename , id, parallel, errno )4894 SUBROUTINE netcdf_create_file( filename , id, parallel, errno ) 5220 4895 #if defined( __netcdf ) 5221 4896 5222 5223 USE control_parameters5224 USE netcdf5225 USE netcdf_control5226 4897 USE pegrid 5227 4898 … … 5284 4955 ENDIF 5285 4956 5286 CALL handle_netcdf_error( 'create_netcdf_file', errno )4957 CALL netcdf_handle_error( 'netcdf_create_file', errno ) 5287 4958 #endif 5288 END SUBROUTINE create_netcdf_file4959 END SUBROUTINE netcdf_create_file 5289 4960 5290 4961 … … 5296 4967 !------------------------------------------------------------------------------! 5297 4968 5298 SUBROUTINE open_write_netcdf_file( filename, id, parallel, errno )4969 SUBROUTINE netcdf_open_write_file( filename, id, parallel, errno ) 5299 4970 #if defined( __netcdf ) 5300 5301 5302 USE control_parameters, &5303 ONLY: netcdf_data_format5304 5305 USE netcdf5306 5307 USE netcdf_control5308 4971 5309 4972 USE pegrid … … 5328 4991 ENDIF 5329 4992 5330 CALL handle_netcdf_error( 'open_write_netcdf_file', errno )4993 CALL netcdf_handle_error( 'netcdf_open_write_file', errno ) 5331 4994 #endif 5332 END SUBROUTINE open_write_netcdf_file4995 END SUBROUTINE netcdf_open_write_file 5333 4996 5334 4997 … … 5339 5002 !------------------------------------------------------------------------------! 5340 5003 5341 SUBROUTINE handle_netcdf_error( routine_name, errno )5004 SUBROUTINE netcdf_handle_error( routine_name, errno ) 5342 5005 #if defined( __netcdf ) 5343 5006 … … 5346 5009 ONLY: message_string 5347 5010 5348 USE netcdf5349 5350 USE netcdf_control5351 5352 USE pegrid5353 5354 5011 IMPLICIT NONE 5355 5012 … … 5369 5026 5370 5027 #endif 5371 END SUBROUTINE handle_netcdf_error 5028 END SUBROUTINE netcdf_handle_error 5029 5030 5031 !------------------------------------------------------------------------------! 5032 ! Description: 5033 ! ------------ 5034 !> Create a dimension in NetCDF file 5035 !------------------------------------------------------------------------------! 5036 5037 SUBROUTINE netcdf_create_dim(ncid, dim_name, ncdim_type, ncdim_id, error_no) 5038 5039 #if defined( __netcdf ) 5040 5041 USE kinds 5042 5043 IMPLICIT NONE 5044 5045 CHARACTER(LEN=*), INTENT(IN) :: dim_name 5046 5047 INTEGER, INTENT(IN) :: error_no 5048 INTEGER, INTENT(IN) :: ncid 5049 INTEGER, INTENT(OUT) :: ncdim_id 5050 INTEGER, INTENT(IN) :: ncdim_type 5051 5052 ! 5053 !-- Define time coordinate for volume data (unlimited dimension) 5054 nc_stat = NF90_DEF_DIM( ncid, dim_name, ncdim_type, ncdim_id ) 5055 CALL netcdf_handle_error( 'netcdf_create_dim', error_no ) 5056 5057 #endif 5058 5059 END SUBROUTINE netcdf_create_dim 5060 5061 5062 !------------------------------------------------------------------------------! 5063 ! Description: 5064 ! ------------ 5065 !> Create a one dimensional variable in specific units in NetCDF file 5066 !------------------------------------------------------------------------------! 5067 5068 SUBROUTINE netcdf_create_var( ncid, dim_id, var_name, var_type, var_id, & 5069 unit_name, long_name, error_no1, error_no2, & 5070 error_no3 ) 5071 5072 #if defined( __netcdf ) 5073 IMPLICIT NONE 5074 5075 CHARACTER(LEN=*), INTENT(IN) :: long_name 5076 CHARACTER(LEN=*), INTENT(IN) :: unit_name 5077 CHARACTER(LEN=*), INTENT(IN) :: var_name 5078 5079 INTEGER, INTENT(IN) :: error_no1 5080 INTEGER, INTENT(IN) :: error_no2 5081 INTEGER, INTENT(IN) :: error_no3 5082 INTEGER, INTENT(IN) :: ncid 5083 INTEGER, INTENT(OUT) :: var_id 5084 INTEGER, INTENT(IN) :: var_type 5085 5086 INTEGER, DIMENSION(:), INTENT(IN) :: dim_id 5087 5088 ! 5089 !-- Define variable 5090 nc_stat = NF90_DEF_VAR( ncid, var_name, var_type, dim_id, var_id ) 5091 CALL netcdf_handle_error( 'netcdf_create_var', error_no1 ) 5092 5093 #if defined( __netcdf4 ) 5094 ! 5095 !-- Check if variable should be deflate (including shuffling) 5096 !-- and if it is possible (only NetCDF4 with HDF5 supports compression) 5097 IF ( netcdf_data_format > 2 .AND. netcdf_deflate > 0 ) THEN 5098 nc_stat = NF90_DEF_VAR_DEFLATE( ncid, var_id, 1, 1, netcdf_deflate ) 5099 CALL netcdf_handle_error( 'netcdf_create_var_deflate', error_no1 ) 5100 ENDIF 5101 #endif 5102 ! 5103 !-- Set unit name if set 5104 IF ( unit_name /= '' ) THEN 5105 nc_stat = NF90_PUT_ATT( ncid, var_id, 'units', unit_name ) 5106 CALL netcdf_handle_error( 'netcdf_create_var', error_no2 ) 5107 ENDIF 5108 5109 ! 5110 !-- Set long name if set 5111 IF ( long_name /= '' ) THEN 5112 nc_stat = NF90_PUT_ATT( ncid, var_id, 'long_name', long_name ) 5113 CALL netcdf_handle_error( 'netcdf_create_var', error_no3 ) 5114 ENDIF 5115 5116 #endif 5117 END SUBROUTINE netcdf_create_var 5118 5119 END MODULE netcdf_interface
Note: See TracChangeset
for help on using the changeset viewer.