Changeset 3557 for palm/trunk/UTIL/inifor/src/inifor_io.f90
- Timestamp:
- Nov 22, 2018 4:01:22 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/UTIL/inifor/src/inifor_io.f90
r3537 r3557 26 26 ! ----------------- 27 27 ! $Id$ 28 ! Updated documentation, removed unused subroutine write_netcdf_variable_2d() 29 ! 30 ! 31 ! 3537 2018-11-20 10:53:14Z eckhard 28 32 ! New routine get_netcdf_dim_vector() 29 33 ! … … 73 77 ! Authors: 74 78 ! -------- 75 ! @author Eckhard Kadasch79 !> @author Eckhard Kadasch (Deutscher Wetterdienst, Offenbach) 76 80 ! 77 81 ! Description: … … 92 96 IMPLICIT NONE 93 97 98 !------------------------------------------------------------------------------! 99 ! Description: 100 ! ------------ 101 !> get_netcdf_variable() reads the netCDF data and metadate for the netCDF 102 !> variable 'in_var % name' from the file 'in_file'. The netCDF data array is 103 !> stored in the 'buffer' array and metadata added to the respective members of 104 !> the given 'in_var'. 105 !------------------------------------------------------------------------------! 94 106 INTERFACE get_netcdf_variable 95 107 MODULE PROCEDURE get_netcdf_variable_int … … 101 113 CONTAINS 102 114 115 !------------------------------------------------------------------------------! 116 ! Description: 117 ! ------------ 118 !> get_netcdf_variable_int() implements the integer variant for the 119 !> get_netcdf_variable interface. 120 !------------------------------------------------------------------------------! 103 121 SUBROUTINE get_netcdf_variable_int(in_file, in_var, buffer) 104 122 … … 139 157 140 158 159 !------------------------------------------------------------------------------! 160 ! Description: 161 ! ------------ 162 !> get_netcdf_variable_real() implements the real variant for the 163 !> get_netcdf_variable interface. 164 !------------------------------------------------------------------------------! 141 165 SUBROUTINE get_netcdf_variable_real(in_file, in_var, buffer) 142 166 … … 177 201 178 202 179 SUBROUTINE get_netcdf_dim_vector(filename, varname, array) 203 !------------------------------------------------------------------------------! 204 ! Description: 205 ! ------------ 206 !> get_netcdf_dim_vector() reads the coordinate array 'coordname' from the 207 !> netCDF file 'filename'. 208 !------------------------------------------------------------------------------! 209 SUBROUTINE get_netcdf_dim_vector(filename, coordname, coords) 180 210 181 211 CHARACTER(LEN=*), INTENT(IN) :: filename 182 CHARACTER(LEN=*), INTENT(IN) :: varname183 REAL(dp), ALLOCATABLE, INTENT(INOUT) :: array(:)212 CHARACTER(LEN=*), INTENT(IN) :: coordname 213 REAL(dp), ALLOCATABLE, INTENT(INOUT) :: coords(:) 184 214 185 215 INTEGER :: ncid, varid, dimlen … … 187 217 188 218 IF ( nf90_open( TRIM(filename), NF90_NOWRITE, ncid ) .EQ. NF90_NOERR .AND. & 189 nf90_inq_varid( ncid, varname, varid ) .EQ. NF90_NOERR ) THEN219 nf90_inq_varid( ncid, coordname, varid ) .EQ. NF90_NOERR ) THEN 190 220 191 221 CALL check(nf90_inquire_variable( ncid, varid, dimids = dimids )) 192 222 CALL check(nf90_inquire_dimension( ncid, dimids(1), len = dimlen )) 193 223 194 ALLOCATE( array(dimlen))195 CALL check(nf90_get_var( ncid, varid, array))224 ALLOCATE(coords(dimlen)) 225 CALL check(nf90_get_var( ncid, varid, coords)) 196 226 197 227 ELSE 198 228 199 message = "Failed to read '" // TRIM( varname) // &229 message = "Failed to read '" // TRIM(coordname) // & 200 230 "' from file '" // TRIM(filename) // "'." 201 231 CALL abort('get_netcdf_dim_vector', message) … … 206 236 207 237 238 !------------------------------------------------------------------------------! 239 ! Description: 240 ! ------------ 241 !> get_input_dimensions() reads dimensions metadata of the netCDF variable given 242 !> by 'in_var % name' into 'in_var' data structure. 243 !------------------------------------------------------------------------------! 208 244 SUBROUTINE get_input_dimensions(in_var, ncid) 209 245 … … 232 268 233 269 270 !------------------------------------------------------------------------------! 271 ! Description: 272 ! ------------ 273 !> get_netcdf_start_and_count() gets the start position and element counts for 274 !> the given netCDF file. This information is used in get_netcdf_variable_int() 275 !> and _real() for reading input variables.. 276 !------------------------------------------------------------------------------! 234 277 SUBROUTINE get_netcdf_start_and_count(in_var, start, count) 235 278 … … 251 294 start = (/ 1, 1, 1 /) 252 295 IF ( TRIM(in_var % name) .EQ. 'T_SO' ) THEN 253 ! Skip depth = 0.0 for T_SO and reduce number of depths from 9 to 8 296 ! 297 !-- Skip depth = 0.0 for T_SO and reduce number of depths from 9 to 8 254 298 in_var % dimlen(3) = in_var % dimlen(3) - 1 255 299 256 ! Start reading from second level, e.g. depth = 0.005 instead of 0.0 300 ! 301 !-- Start reading from second level, e.g. depth = 0.005 instead of 0.0 257 302 start(3) = 2 258 303 END IF … … 269 314 270 315 316 !------------------------------------------------------------------------------! 317 ! Description: 318 ! ------------ 319 !> Routine for defining netCDF variables in the dynamic driver, INIFOR's netCDF 320 !> output. 321 !------------------------------------------------------------------------------! 271 322 SUBROUTINE netcdf_define_variable(var, ncid) 272 323 … … 286 337 287 338 339 !------------------------------------------------------------------------------! 340 ! Description: 341 ! ------------ 342 !> netcdf_get_dimensions() reads in all dimensions and their lengths and stores 343 !> them in the given the 'var' data structure. This information is used later 344 !> for writing output variables in update_output(). 345 !------------------------------------------------------------------------------! 288 346 SUBROUTINE netcdf_get_dimensions(var, ncid) 289 347 … … 293 351 CHARACTER(SNAME) :: null 294 352 295 ! Remember dimension lenghts for NetCDF writing routine296 353 DO i = 1, var % ndim 297 354 CALL check(nf90_inquire_dimension(ncid, var % dimids(i), & … … 306 363 ! Description: 307 364 ! ------------ 308 !> This routine initializes Inifor. This includes parsing command-line 309 !> arguments, setting the names of the input and output file names as well as 310 !> the name of the input namelist and, subsequently, reading in and setting grid 311 !> parameters for the PALM-4U computational grid. 365 !> This routine parses and interpretes the command-line options and stores the 366 !> resulting settings in the 'cfg' data structure. 312 367 !------------------------------------------------------------------------------! 313 368 SUBROUTINE parse_command_line_arguments( cfg ) … … 330 385 IF (arg_count .GT. 0) THEN 331 386 332 ! Every option should have an argument.333 !IF ( MOD(arg_count, 2) .NE. 0 ) THEN334 ! message = "Syntax error in command line."335 ! CALL abort('parse_command_line_arguments', message)336 !END IF337 338 387 message = "The -clon and -clat command line options are depricated. " // & 339 388 "Please remove them form your inifor command and specify the " // & … … 360 409 cfg % debug = .TRUE. 361 410 362 ! Elevation of the PALM-4U domain above sea level363 411 CASE( '-z0', '-z', '--elevation' ) 364 412 CALL get_option_argument( i, arg ) 365 413 READ(arg, *) cfg % z0 366 414 367 ! surface pressure, at z0368 415 CASE( '-p0', '-r', '--surface-pressure' ) 369 416 cfg % p0_is_set = .TRUE. … … 371 418 READ(arg, *) cfg % p0 372 419 373 ! geostrophic wind in x direction374 420 CASE( '-ug', '-u', '--geostrophic-u' ) 375 421 cfg % ug_is_set = .TRUE. … … 377 423 READ(arg, *) cfg % ug 378 424 379 ! geostrophic wind in y direction380 425 CASE( '-vg', '-v', '--geostrophic-v' ) 381 426 cfg % vg_is_set = .TRUE. … … 383 428 READ(arg, *) cfg % vg 384 429 385 ! domain centre geographical longitude and latitude386 430 CASE( '-clon', '-clat' ) 387 431 CALL abort('parse_command_line_arguments', message) 388 !READ(arg, *) lambda_cg389 !lambda_cg = lambda_cg * TO_RADIANS390 !READ(arg, *) phi_cg391 !phi_cg = phi_cg * TO_RADIANS392 432 393 433 CASE( '-path', '-p', '--path' ) … … 444 484 cfg % namelist_file = TRIM(arg) 445 485 446 ! initial condition mode: 'profile' / 'volume'447 486 CASE( '-mode', '-i', '--init-mode' ) 448 487 CALL get_option_argument( i, arg ) 449 488 cfg % ic_mode = TRIM(arg) 450 489 451 ! boundary conditions / forcing mode: 'ideal' / 'real'452 490 CASE( '-f', '--forcing-mode' ) 453 491 CALL get_option_argument( i, arg ) … … 484 522 485 523 524 !------------------------------------------------------------------------------! 525 ! Description: 526 ! ------------ 527 !> Get the argument of the i'th command line option, which is at the location 528 !> i+1 of the argument list. 529 !------------------------------------------------------------------------------! 486 530 SUBROUTINE get_option_argument(i, arg) 487 531 CHARACTER(LEN=PATH), INTENT(INOUT) :: arg … … 494 538 495 539 540 !------------------------------------------------------------------------------! 541 ! Description: 542 ! ------------ 543 !> Checks the INIFOR configuration 'cfg' for plausibility. 544 !------------------------------------------------------------------------------! 496 545 SUBROUTINE validate_config(cfg) 497 546 TYPE(inifor_config), INTENT(IN) :: cfg … … 503 552 all_files_present = all_files_present .AND. file_present(cfg % soiltyp_file, 'SOILTYP') 504 553 505 ! Only check optional static driver file name, if it has been given. 554 ! 555 !-- Only check optional static driver file name, if it has been given. 506 556 IF (TRIM(cfg % static_driver_file) .NE. '') THEN 507 557 all_files_present = all_files_present .AND. file_present(cfg % static_driver_file, 'static driver') … … 557 607 558 608 609 !------------------------------------------------------------------------------! 610 ! Description: 611 ! ------------ 612 !> Check whether the given file is present on the filesystem. 613 !------------------------------------------------------------------------------! 559 614 LOGICAL FUNCTION file_present(filename, kind) 560 615 CHARACTER(LEN=PATH), INTENT(IN) :: filename … … 585 640 ! Description: 586 641 ! ------------ 587 !> This routine initializes the Inifor output file, i.e. the PALM-4U588 !> initializing and forcing data as a NetCDFfile.642 !> This routine initializes the dynamic driver file, i.e. INIFOR's netCDF output 643 !> file. 589 644 !> 590 645 !> Besides writing metadata, such as global attributes, coordinates, variables, 591 !> in the NetCDF file, various NetCDF IDs are saved for later, when Inifor646 !> in the netCDF file, various netCDF IDs are saved for later, when INIFOR 592 647 !> writes the actual data. 593 648 !------------------------------------------------------------------------------! … … 611 666 CALL report('setup_netcdf_dimensions', message) 612 667 613 ! Create the NetCDF file. NF90_CLOBBER selects overwrite mode. 668 ! 669 !-- Create the netCDF file as in netCDF-4/HDF5 format if __netcdf4 preprocessor flag is given 614 670 #if defined( __netcdf4 ) 615 671 CALL check(nf90_create(TRIM(output_file % name), OR(NF90_CLOBBER, NF90_HDF5), ncid)) … … 646 702 CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_lat', TRIM(real_to_str(origin_lat*TO_DEGREES, '(F18.13)')))) 647 703 CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_lon', TRIM(real_to_str(origin_lon*TO_DEGREES, '(F18.13)')))) 648 ! FIXME: This is the elevation relative to COSMO-DE/D2 sea level and does 649 ! FIXME: not necessarily comply with DHHN2016 (c.f. PALM Input Data 650 ! FIXME: Standard v1.9., origin_z) 704 ! 705 !-- FIXME: This is the elevation relative to COSMO-DE/D2 sea level and does 706 !-- FIXME: not necessarily comply with DHHN2016 (c.f. PALM Input Data 707 !-- FIXME: Standard v1.9., origin_z) 651 708 CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_z', TRIM(real_to_str(z0, '(F18.13)')))) 652 709 CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'inifor_version', TRIM(VERSION))) … … 658 715 !- Section 2a: Define dimensions for cell centers (scalars in soil and atmosph.) 659 716 !------------------------------------------------------------------------------ 660 dimids = (/0, 0, 0/) ! reset dimids 661 CALL check( nf90_def_dim(ncid, "x", nx+1, dimids(1)) ) 662 CALL check( nf90_def_dim(ncid, "y", ny+1, dimids(2)) ) 663 CALL check( nf90_def_dim(ncid, "z", nz, dimids(3)) ) 664 output_file % dimids_scl = dimids ! save dimids for later 665 666 dimvarids = (/0, 0, 0/) ! reset dimvarids 667 CALL check(nf90_def_var(ncid, "x", NF90_FLOAT, dimids(1), dimvarids(1))) 668 CALL check(nf90_put_att(ncid, dimvarids(1), "standard_name", "x coordinate of cell centers")) 669 CALL check(nf90_put_att(ncid, dimvarids(1), "units", "m")) 670 671 CALL check(nf90_def_var(ncid, "y", NF90_FLOAT, dimids(2), dimvarids(2))) 672 CALL check(nf90_put_att(ncid, dimvarids(2), "standard_name", "y coordinate of cell centers")) 673 CALL check(nf90_put_att(ncid, dimvarids(2), "units", "m")) 674 675 CALL check(nf90_def_var(ncid, "z", NF90_FLOAT, dimids(3), dimvarids(3))) 676 CALL check(nf90_put_att(ncid, dimvarids(3), "standard_name", "z coordinate of cell centers")) 677 CALL check(nf90_put_att(ncid, dimvarids(3), "units", "m")) 678 output_file % dimvarids_scl = dimvarids ! save dimvarids for later 679 680 ! overwrite third dimid with the one of depth 717 ! 718 !-- reset dimids first 719 dimids = (/0, 0, 0/) 720 CALL check( nf90_def_dim(ncid, "x", nx+1, dimids(1)) ) 721 CALL check( nf90_def_dim(ncid, "y", ny+1, dimids(2)) ) 722 CALL check( nf90_def_dim(ncid, "z", nz, dimids(3)) ) 723 ! 724 !-- save dimids for later 725 output_file % dimids_scl = dimids 726 727 ! 728 !-- reset dimvarids first 729 dimvarids = (/0, 0, 0/) 730 CALL check(nf90_def_var(ncid, "x", NF90_FLOAT, dimids(1), dimvarids(1))) 731 CALL check(nf90_put_att(ncid, dimvarids(1), "standard_name", "x coordinate of cell centers")) 732 CALL check(nf90_put_att(ncid, dimvarids(1), "units", "m")) 733 734 CALL check(nf90_def_var(ncid, "y", NF90_FLOAT, dimids(2), dimvarids(2))) 735 CALL check(nf90_put_att(ncid, dimvarids(2), "standard_name", "y coordinate of cell centers")) 736 CALL check(nf90_put_att(ncid, dimvarids(2), "units", "m")) 737 738 CALL check(nf90_def_var(ncid, "z", NF90_FLOAT, dimids(3), dimvarids(3))) 739 CALL check(nf90_put_att(ncid, dimvarids(3), "standard_name", "z coordinate of cell centers")) 740 CALL check(nf90_put_att(ncid, dimvarids(3), "units", "m")) 741 ! 742 !-- save dimvarids for later 743 output_file % dimvarids_scl = dimvarids 744 745 ! 746 !-- overwrite third dimid with the one of depth 681 747 CALL check(nf90_def_dim(ncid, "zsoil", SIZE(palm_grid % depths), dimids(3)) ) 682 output_file % dimids_soil = dimids ! save dimids for later 683 684 ! overwrite third dimvarid with the one of depth 748 ! 749 !-- save dimids for later 750 output_file % dimids_soil = dimids 751 752 ! 753 !-- overwrite third dimvarid with the one of depth 685 754 CALL check(nf90_def_var(ncid, "zsoil", NF90_FLOAT, output_file % dimids_soil(3), dimvarids(3))) 686 755 CALL check(nf90_put_att(ncid, dimvarids(3), "standard_name", "depth_below_land")) 687 756 CALL check(nf90_put_att(ncid, dimvarids(3), "positive", "down")) 688 757 CALL check(nf90_put_att(ncid, dimvarids(3), "units", "m")) 689 output_file % dimvarids_soil = dimvarids ! save dimvarids for later 758 ! 759 !-- save dimvarids for later 760 output_file % dimvarids_soil = dimvarids 690 761 ! 691 762 !------------------------------------------------------------------------------ 692 763 !- Section 2b: Define dimensions for cell faces/velocities 693 764 !------------------------------------------------------------------------------ 694 dimids = (/0, 0, 0/) ! reset dimids 695 CALL check(nf90_def_dim(ncid, "xu", nx, dimids(1)) ) 696 CALL check(nf90_def_dim(ncid, "yv", ny, dimids(2)) ) 697 CALL check(nf90_def_dim(ncid, "zw", nz-1, dimids(3)) ) 698 output_file % dimids_vel = dimids ! save dimids for later 699 700 dimvarids = (/0, 0, 0/) ! reset dimvarids 701 CALL check(nf90_def_var(ncid, "xu", NF90_FLOAT, dimids(1), dimvarids(1))) 702 CALL check(nf90_put_att(ncid, dimvarids(1), "standard_name", "x coordinate of cell faces")) 703 CALL check(nf90_put_att(ncid, dimvarids(1), "units", "m")) 704 705 CALL check(nf90_def_var(ncid, "yv", NF90_FLOAT, dimids(2), dimvarids(2))) 706 CALL check(nf90_put_att(ncid, dimvarids(2), "standard_name", "y coordinate of cell faces")) 707 CALL check(nf90_put_att(ncid, dimvarids(2), "units", "m")) 708 709 CALL check(nf90_def_var(ncid, "zw", NF90_FLOAT, dimids(3), dimvarids(3))) 710 CALL check(nf90_put_att(ncid, dimvarids(3), "standard_name", "z coordinate of cell faces")) 711 CALL check(nf90_put_att(ncid, dimvarids(3), "units", "m")) 712 output_file % dimvarids_vel = dimvarids ! save dimvarids for later 765 ! 766 !-- reset dimids first 767 dimids = (/0, 0, 0/) 768 CALL check(nf90_def_dim(ncid, "xu", nx, dimids(1)) ) 769 CALL check(nf90_def_dim(ncid, "yv", ny, dimids(2)) ) 770 CALL check(nf90_def_dim(ncid, "zw", nz-1, dimids(3)) ) 771 ! 772 !-- save dimids for later 773 output_file % dimids_vel = dimids 774 775 ! 776 !-- reset dimvarids first 777 dimvarids = (/0, 0, 0/) 778 CALL check(nf90_def_var(ncid, "xu", NF90_FLOAT, dimids(1), dimvarids(1))) 779 CALL check(nf90_put_att(ncid, dimvarids(1), "standard_name", "x coordinate of cell faces")) 780 CALL check(nf90_put_att(ncid, dimvarids(1), "units", "m")) 781 782 CALL check(nf90_def_var(ncid, "yv", NF90_FLOAT, dimids(2), dimvarids(2))) 783 CALL check(nf90_put_att(ncid, dimvarids(2), "standard_name", "y coordinate of cell faces")) 784 CALL check(nf90_put_att(ncid, dimvarids(2), "units", "m")) 785 786 CALL check(nf90_def_var(ncid, "zw", NF90_FLOAT, dimids(3), dimvarids(3))) 787 CALL check(nf90_put_att(ncid, dimvarids(3), "standard_name", "z coordinate of cell faces")) 788 CALL check(nf90_put_att(ncid, dimvarids(3), "units", "m")) 789 ! 790 !-- save dimvarids for later 791 output_file % dimvarids_vel = dimvarids 713 792 714 793 ! … … 739 818 CALL check(nf90_put_var(ncid, output_file % dimvarids_vel(3), palm_grid%zw)) 740 819 741 ! TODO Read in soil depths from input file before this. 820 ! 821 !-- TODO Read in soil depths from input file before this. 742 822 CALL check(nf90_put_var(ncid, output_file % dimvarids_soil(3), palm_grid%depths)) 743 823 744 ! Write time vector 824 ! 825 !-- Write time vector 745 826 CALL check(nf90_put_var(ncid, output_file % dimvarid_time, output_file % time)) 746 827 747 ! Close the file 828 ! 829 !-- Close the file 748 830 CALL check(nf90_close(ncid)) 749 831 … … 751 833 752 834 835 !------------------------------------------------------------------------------! 836 ! Description: 837 ! ------------ 838 !> Defines the netCDF variables to be written to the dynamic driver file 839 !------------------------------------------------------------------------------! 753 840 SUBROUTINE setup_netcdf_variables(filename, output_variable_table, debug) 754 841 … … 824 911 !- Section 1: Load input buffers for accumulated variables 825 912 !------------------------------------------------------------------------------ 913 ! 914 !-- radiation budgets, precipitation 826 915 IF (group % kind == 'running average' .OR. & 827 group % kind == 'accumulated') THEN ! radiation budgets, precipitation916 group % kind == 'accumulated') THEN 828 917 829 918 IF (SIZE(group % in_var_list) .GT. 1 ) THEN … … 835 924 END IF 836 925 837 ! use two buffer arrays 926 ! 927 !-- use two buffer arrays 838 928 nbuffers = 2 839 929 IF ( .NOT. ALLOCATED( buffer ) ) ALLOCATE( buffer(nbuffers) ) 840 930 841 ! chose correct buffer array 842 hour = iter - 1! hour of the day 931 ! 932 !-- hour of the day 933 hour = iter - 1 934 ! 935 !-- chose correct buffer array 843 936 buf_id = select_buffer(hour) 844 937 … … 859 952 ELSE 860 953 861 ! Allocate one input buffer per input_variable. If more quantities 862 ! have to be computed than input variables exist in this group, 863 ! allocate more buffers. For instance, in the thermodynamics group, 864 ! there are three input variabels (PP, T, Qv) and four quantities 865 ! necessart (P, Theta, Rho, qv) for the corresponding output fields 866 ! (p0, Theta, qv, ug, and vg) 954 ! 955 !-- Allocate one input buffer per input_variable. If more quantities 956 !-- have to be computed than input variables exist in this group, 957 !-- allocate more buffers. For instance, in the thermodynamics group, 958 !-- there are three input variabels (PP, T, Qv) and four quantities 959 !-- necessart (P, Theta, Rho, qv) for the corresponding output fields 960 !-- (p0, Theta, qv, ug, and vg) 867 961 nbuffers = MAX( group % n_inputs, group % n_output_quantities ) 868 962 ALLOCATE( buffer(nbuffers) ) 869 963 CALL run_control('time', 'alloc') 870 964 871 ! Read in all input variables, leave extra buffers-if any-untouched. 965 ! 966 !-- Read in all input variables, leave extra buffers-if any-untouched. 872 967 DO ivar = 1, group % n_inputs 873 968 874 969 input_var => group % in_var_list(ivar) 875 970 876 ! Check wheather P or PP is present in input file 971 ! 972 ! Check wheather P or PP is present in input file 877 973 IF (input_var % name == 'P') THEN 878 974 input_var % name = TRIM( get_pressure_varname(input_file) ) … … 891 987 892 988 989 !------------------------------------------------------------------------------! 990 ! Description: 991 ! ------------ 992 !> Select the appropriate buffer ID for accumulated COSMO input variables 993 !> depending on the current hour. 994 !------------------------------------------------------------------------------! 893 995 INTEGER FUNCTION select_buffer(hour) 894 996 INTEGER, INTENT(IN) :: hour … … 943 1045 944 1046 1047 !------------------------------------------------------------------------------! 1048 ! Description: 1049 ! ------------ 1050 !> Read the given global attribute form the given netCDF file. 1051 !------------------------------------------------------------------------------! 945 1052 FUNCTION get_netcdf_attribute(filename, attribute) RESULT(attribute_value) 946 1053 … … 948 1055 REAL(dp) :: attribute_value 949 1056 950 INTEGER :: ncid1057 INTEGER :: ncid 951 1058 952 1059 IF ( nf90_open( TRIM(filename), NF90_NOWRITE, ncid ) == NF90_NOERR ) THEN … … 966 1073 967 1074 1075 1076 !------------------------------------------------------------------------------! 1077 ! Description: 1078 ! ------------ 1079 !> Updates the dynamic driver with the interpolated field of the current 1080 !> variable at the current time step. 1081 !------------------------------------------------------------------------------! 968 1082 SUBROUTINE update_output(var, array, iter, output_file, cfg) 969 1083 TYPE(nc_var), INTENT(IN) :: var … … 980 1094 ) 981 1095 982 ! Skip time dimension for output 1096 ! 1097 !-- Skip time dimension for output 983 1098 ndim = var % ndim 984 1099 IF ( var_is_time_dependent ) ndim = var % ndim - 1 … … 990 1105 CALL check(nf90_open(output_file % name, NF90_WRITE, ncid)) 991 1106 992 ! Reduce dimension of output array according to variable kind 1107 ! 1108 !-- Reduce dimension of output array according to variable kind 993 1109 SELECT CASE (TRIM(var % kind)) 994 1110 … … 1086 1202 1087 1203 1088 SUBROUTINE write_netcdf_variable_2d(var, iter, output_file, buffer) 1089 TYPE(nc_var), INTENT(IN) :: var 1090 INTEGER, INTENT(IN) :: iter 1091 TYPE(nc_file), INTENT(IN) :: output_file 1092 REAL(dp), INTENT(IN) :: buffer(:,:,:) 1093 1094 INTEGER :: ncid, ndim_out, start(4), count(4) 1095 LOGICAL :: last_dimension_is_time 1096 1097 ndim_out = var % ndim 1098 1099 last_dimension_is_time = var % dimids( var % ndim ) == output_file % dimid_time 1100 IF ( last_dimension_is_time ) THEN 1101 ndim_out = ndim_out - 1 1102 END IF 1103 1104 start(:) = (/1,1,1,iter/) 1105 count(1:ndim_out) = var%dimlen(1:ndim_out) 1106 1107 CALL check(nf90_open(output_file % name, NF90_WRITE, ncid)) 1108 1109 IF (TRIM(var % kind) .EQ. 'left/right scalar') THEN 1110 1111 CALL check(nf90_put_var( ncid, var%varid, buffer(1,:,:) ) ) 1112 1113 ELSE IF (TRIM(var % kind) .EQ. 'north/south scalar') THEN 1114 1115 CALL check(nf90_put_var( ncid, var%varid, buffer(:,1,:) ) ) 1116 1117 ELSE IF (TRIM(var % kind) .EQ. 'top scalar') THEN 1118 1119 CALL check(nf90_put_var( ncid, var%varid, buffer(:,:,1) ) ) 1120 ELSE 1121 1122 CALL check(nf90_put_var( ncid, var%varid, buffer ) ) 1123 1124 END IF 1125 CALL check(nf90_close(ncid)) 1126 1127 END SUBROUTINE write_netcdf_variable_2d 1128 1129 1204 !------------------------------------------------------------------------------! 1205 ! Description: 1206 ! ------------ 1207 !> Checks the status of a netCDF API call and aborts if an error occured 1208 !------------------------------------------------------------------------------! 1130 1209 SUBROUTINE check(status) 1131 1210
Note: See TracChangeset
for help on using the changeset viewer.