Changeset 1031 for palm/trunk/SOURCE/netcdf.f90
- Timestamp:
- Oct 19, 2012 2:35:30 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/netcdf.f90
r993 r1031 7 7 ! Current revisions: 8 8 ! ------------------ 9 ! 9 ! netCDF4 without parallel file support implemented, new routines 10 ! create_netcdf_file and open_write_netcdf_file at end 10 11 ! 11 12 ! Former revisions: … … 27 28 ! 28 29 ! 951 2012-07-19 14:22:52Z hoffmann 29 ! cross_profiles, profile_rows, profile_columns are written to NetCDF header30 ! cross_profiles, profile_rows, profile_columns are written to netCDF header 30 31 ! 31 32 ! 771 2011-10-27 10:56:21Z heinze … … 41 42 ! 42 43 ! 519 2010-03-19 05:30:02Z raasch 43 ! particle number defined as unlimited dimension in case of NetCDF4 output,44 ! special characters like * and " are now allowed for NetCDF variable names,44 ! particle number defined as unlimited dimension in case of netCDF4 output, 45 ! special characters like * and " are now allowed for netCDF variable names, 45 46 ! replacement of these characters removed, routine clean_netcdf_varname 46 47 ! removed 47 48 ! 48 49 ! 493 2010-03-01 08:30:24Z raasch 49 ! Extensions for NetCDF4 output50 ! Extensions for netCDF4 output 50 51 ! 51 52 ! 410 2009-12-04 17:05:40Z letzel … … 53 54 ! 54 55 ! 359 2009-08-19 16:56:44Z letzel 55 ! for extended NetCDF files, the updated title attribute includes an update of56 ! for extended netCDF files, the updated title attribute includes an update of 56 57 ! time_average_text where appropriate. 57 ! Bugfix for extended NetCDF files: In order to avoid 'data mode' errors if58 ! Bugfix for extended netCDF files: In order to avoid 'data mode' errors if 58 59 ! updated attributes are larger than their original size, NF90_PUT_ATT is called 59 60 ! in 'define mode' enclosed by NF90_REDEF and NF90_ENDDEF calls. This implies a 60 61 ! possible performance loss; an alternative strategy would be to ensure equal 61 62 ! attribute size in a job chain. 62 ! NetCDF unit attribute in timeseries output in case of statistic63 ! netCDF unit attribute in timeseries output in case of statistic 63 64 ! regions added. 64 ! Output of NetCDF messages with aid of message handling routine.65 ! Output of netCDF messages with aid of message handling routine. 65 66 ! Output of messages replaced by message handling routine. 66 67 ! Typographical errors fixed. … … 95 96 ! In case of extend = .FALSE.: 96 97 ! Define all necessary dimensions, axes and variables for the different 97 ! NetCDF datasets. This subroutine is called from check_open after a new98 ! dataset is created. It leaves the open NetCDF files ready to write.98 ! netCDF datasets. This subroutine is called from check_open after a new 99 ! dataset is created. It leaves the open netCDF files ready to write. 99 100 ! 100 101 ! In case of extend = .TRUE.: … … 163 164 IF ( .NOT. init_netcdf ) THEN 164 165 ! 165 !-- Check and set accuracy for NetCDF output. First set default value166 !-- Check and set accuracy for netCDF output. First set default value 166 167 nc_precision = NF90_REAL4 167 168 … … 547 548 548 549 ! 549 !-- Leave NetCDF define mode550 !-- Leave netCDF define mode 550 551 nc_stat = NF90_ENDDEF( id_set_mask(mid,av) ) 551 552 CALL handle_netcdf_error( 'netcdf', 498 ) … … 683 684 684 685 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 685 WRITE ( message_string, * ) ' NetCDF file for ', TRIM( var ), &686 WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), & 686 687 ' data for mask', mid, ' from previous run found,', & 687 688 '&but this file cannot be extended due to variable ', & … … 710 711 711 712 IF ( mask_size(mid,3) /= nz_old ) THEN 712 WRITE ( message_string, * ) ' NetCDF file for ', TRIM( var ), &713 WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), & 713 714 ' data for mask', mid, ' from previous run found,', & 714 715 '&but this file cannot be extended due to mismatch in ', & … … 748 749 749 750 IF ( last_time_coordinate(1) >= simulated_time ) THEN 750 WRITE ( message_string, * ) ' NetCDF file for ', TRIM( var ), &751 WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), & 751 752 ' data for mask', mid, ' from previous run found,', & 752 753 '&but this file cannot be extended because the current ', & … … 792 793 nc_stat = NF90_ENDDEF( id_set_mask(mid,av) ) 793 794 CALL handle_netcdf_error( 'netcdf', 518 ) 794 WRITE ( message_string, * ) ' NetCDF file for ', TRIM( var ), &795 WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), & 795 796 ' data for mask', mid, ' from previous run found.', & 796 797 '&This file will be extended.' … … 1055 1056 'units', TRIM( do3d_unit(av,i) ) ) 1056 1057 CALL handle_netcdf_error( 'netcdf', 357 ) 1057 #if defined( __netcdf4 )1058 #if defined( __netcdf4_parallel ) 1058 1059 ! 1059 1060 !-- Set collective io operations for parallel io 1060 IF ( netcdf_data_format > 2) THEN1061 IF ( netcdf_data_format > 4 ) THEN 1061 1062 nc_stat = NF90_VAR_PAR_ACCESS( id_set_3d(av), & 1062 1063 id_var_do3d(av,i), & … … 1081 1082 1082 1083 ! 1083 !-- Leave NetCDF define mode1084 !-- Leave netCDF define mode 1084 1085 nc_stat = NF90_ENDDEF( id_set_3d(av) ) 1085 1086 CALL handle_netcdf_error( 'netcdf', 82 ) … … 1188 1189 1189 1190 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 1190 message_string = ' NetCDF file for volume data ' // &1191 message_string = 'netCDF file for volume data ' // & 1191 1192 TRIM( var ) // ' from previous run found,' // & 1192 1193 '&but this file cannot be extended due to' // & … … 1213 1214 1214 1215 IF ( nz_do3d-nzb+1 /= nz_old ) THEN 1215 message_string = ' NetCDF file for volume data ' // &1216 message_string = 'netCDF file for volume data ' // & 1216 1217 TRIM( var ) // ' from previous run found,' // & 1217 1218 '&but this file cannot be extended due to' // & … … 1249 1250 1250 1251 IF ( last_time_coordinate(1) >= simulated_time ) THEN 1251 message_string = ' NetCDF file for volume data ' // &1252 message_string = 'netCDF file for volume data ' // & 1252 1253 TRIM( var ) // ' from previous run found,' // & 1253 1254 '&but this file cannot be extended becaus' // & … … 1270 1271 id_var_do3d(av,i) ) 1271 1272 CALL handle_netcdf_error( 'netcdf', 95 ) 1272 #if defined( __netcdf4 )1273 #if defined( __netcdf4_parallel ) 1273 1274 ! 1274 1275 !-- Set collective io operations for parallel io 1275 IF ( netcdf_data_format > 2) THEN1276 IF ( netcdf_data_format > 4 ) THEN 1276 1277 nc_stat = NF90_VAR_PAR_ACCESS( id_set_3d(av), & 1277 1278 id_var_do3d(av,i), & … … 1304 1305 nc_stat = NF90_ENDDEF( id_set_3d(av) ) 1305 1306 CALL handle_netcdf_error( 'netcdf', 430 ) 1306 message_string = ' NetCDF file for volume data ' // &1307 message_string = 'netCDF file for volume data ' // & 1307 1308 TRIM( var ) // ' from previous run found.' // & 1308 1309 '&This file will be extended.' … … 1621 1622 'units', TRIM( do2d_unit(av,i) ) ) 1622 1623 CALL handle_netcdf_error( 'netcdf', 354 ) 1623 #if defined( __netcdf4 )1624 #if defined( __netcdf4_parallel ) 1624 1625 ! 1625 1626 !-- Set collective io operations for parallel io 1626 IF ( netcdf_data_format > 2) THEN1627 IF ( netcdf_data_format > 4 ) THEN 1627 1628 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xy(av), & 1628 1629 id_var_do2d(av,i), & … … 1649 1650 1650 1651 ! 1651 !-- Leave NetCDF define mode1652 !-- Leave netCDF define mode 1652 1653 nc_stat = NF90_ENDDEF( id_set_xy(av) ) 1653 1654 CALL handle_netcdf_error( 'netcdf', 122 ) … … 1794 1795 1795 1796 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 1796 message_string = ' NetCDF file for cross-sections ' // &1797 message_string = 'netCDF file for cross-sections ' // & 1797 1798 TRIM( var ) // ' from previous run found,' // & 1798 1799 '& but this file cannot be extended due to' // & … … 1827 1828 1828 1829 IF ( ns /= ns_old ) THEN 1829 message_string = ' NetCDF file for cross-sections ' // &1830 message_string = 'netCDF file for cross-sections ' // & 1830 1831 TRIM( var ) // ' from previous run found,' // & 1831 1832 '&but this file cannot be extended due to' // & … … 1848 1849 IF ( section(i,1) /= -1 ) THEN 1849 1850 IF ( zu(section(i,1)) /= netcdf_data(i) ) THEN 1850 message_string = ' NetCDF file for cross-sections ' // &1851 message_string = 'netCDF file for cross-sections ' // & 1851 1852 TRIM( var ) // ' from previous run found,' // & 1852 1853 '&but this file cannot be extended' // & … … 1861 1862 ELSE 1862 1863 IF ( -1.0 /= netcdf_data(i) ) THEN 1863 message_string = ' NetCDF file for cross-sections ' // &1864 message_string = 'netCDF file for cross-sections ' // & 1864 1865 TRIM( var ) // ' from previous run found,' // & 1865 1866 '&but this file cannot be extended' // & … … 1901 1902 1902 1903 IF ( last_time_coordinate(1) >= simulated_time ) THEN 1903 message_string = ' NetCDF file for cross sections ' // &1904 message_string = 'netCDF file for cross sections ' // & 1904 1905 TRIM( var ) // ' from previous run found,' // & 1905 1906 '&but this file cannot be extended becaus' // & … … 1923 1924 id_var_do2d(av,i) ) 1924 1925 CALL handle_netcdf_error( 'netcdf', 138 ) 1925 #if defined( __netcdf4 )1926 #if defined( __netcdf4_parallel ) 1926 1927 ! 1927 1928 !-- Set collective io operations for parallel io 1928 IF ( netcdf_data_format > 2) THEN1929 IF ( netcdf_data_format > 4 ) THEN 1929 1930 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xy(av), & 1930 1931 id_var_do2d(av,i), & … … 1958 1959 nc_stat = NF90_ENDDEF( id_set_xy(av) ) 1959 1960 CALL handle_netcdf_error( 'netcdf', 432 ) 1960 message_string = ' NetCDF file for cross-sections ' // &1961 message_string = 'netCDF file for cross-sections ' // & 1961 1962 TRIM( var ) // ' from previous run found.' // & 1962 1963 '&This file will be extended.' … … 2205 2206 'units', TRIM( do2d_unit(av,i) ) ) 2206 2207 CALL handle_netcdf_error( 'netcdf', 355 ) 2207 #if defined( __netcdf4 )2208 #if defined( __netcdf4_parallel ) 2208 2209 ! 2209 2210 !-- Set independent io operations for parallel io. Collective io 2210 2211 !-- is only allowed in case of a 1d-decomposition along x, because 2211 2212 !-- otherwise, not all PEs have output data. 2212 IF ( netcdf_data_format > 2) THEN2213 IF ( netcdf_data_format > 4 ) THEN 2213 2214 IF ( npey == 1 ) THEN 2214 2215 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av), & … … 2217 2218 ELSE 2218 2219 ! 2219 !-- ATTENTION: Due to a probable bug in the NetCDF42220 !-- ATTENTION: Due to a probable bug in the netCDF4 2220 2221 !-- installation, independet output does not work 2221 2222 !-- A workaround is used in data_output_2d on those … … 2249 2250 2250 2251 ! 2251 !-- Leave NetCDF define mode2252 !-- Leave netCDF define mode 2252 2253 nc_stat = NF90_ENDDEF( id_set_xz(av) ) 2253 2254 CALL handle_netcdf_error( 'netcdf', 162 ) … … 2364 2365 2365 2366 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 2366 message_string = ' NetCDF file for cross-sections ' // &2367 message_string = 'netCDF file for cross-sections ' // & 2367 2368 TRIM( var ) // ' from previous run found,' // & 2368 2369 '& but this file cannot be extended due to' // & … … 2397 2398 2398 2399 IF ( ns /= ns_old ) THEN 2399 message_string = ' NetCDF file for cross-sections ' // &2400 message_string = 'netCDF file for cross-sections ' // & 2400 2401 TRIM( var ) // ' from previous run found,' // & 2401 2402 '&but this file cannot be extended due to' // & … … 2418 2419 IF ( section(i,2) /= -1 ) THEN 2419 2420 IF ( ( ( section(i,2) + 0.5 ) * dy ) /= netcdf_data(i) ) THEN 2420 message_string = ' NetCDF file for cross-sections ' // &2421 message_string = 'netCDF file for cross-sections ' // & 2421 2422 TRIM( var ) // ' from previous run found,' // & 2422 2423 '&but this file cannot be extended' // & … … 2431 2432 ELSE 2432 2433 IF ( -1.0 /= netcdf_data(i) ) THEN 2433 message_string = ' NetCDF file for cross-sections ' // &2434 message_string = 'netCDF file for cross-sections ' // & 2434 2435 TRIM( var ) // ' from previous run found,' // & 2435 2436 '&but this file cannot be extended' // & … … 2471 2472 2472 2473 IF ( last_time_coordinate(1) >= simulated_time ) THEN 2473 message_string = ' NetCDF file for cross sections ' // &2474 message_string = 'netCDF file for cross sections ' // & 2474 2475 TRIM( var ) // ' from previous run found,' // & 2475 2476 '&but this file cannot be extended becaus' // & … … 2493 2494 id_var_do2d(av,i) ) 2494 2495 CALL handle_netcdf_error( 'netcdf', 177 ) 2495 #if defined( __netcdf4 )2496 #if defined( __netcdf4_parallel ) 2496 2497 ! 2497 2498 !-- Set independent io operations for parallel io. Collective io 2498 2499 !-- is only allowed in case of a 1d-decomposition along x, because 2499 2500 !-- otherwise, not all PEs have output data. 2500 IF ( netcdf_data_format > 2) THEN2501 IF ( netcdf_data_format > 4 ) THEN 2501 2502 IF ( npey == 1 ) THEN 2502 2503 nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av), & … … 2505 2506 ELSE 2506 2507 ! 2507 !-- ATTENTION: Due to a probable bug in the NetCDF42508 !-- ATTENTION: Due to a probable bug in the netCDF4 2508 2509 !-- installation, independet output does not work 2509 2510 !-- A workaround is used in data_output_2d on those … … 2544 2545 nc_stat = NF90_ENDDEF( id_set_xz(av) ) 2545 2546 CALL handle_netcdf_error( 'netcdf', 434 ) 2546 message_string = ' NetCDF file for cross-sections ' // &2547 message_string = 'netCDF file for cross-sections ' // & 2547 2548 TRIM( var ) // ' from previous run found.' // & 2548 2549 '&This file will be extended.' … … 2791 2792 'units', TRIM( do2d_unit(av,i) ) ) 2792 2793 CALL handle_netcdf_error( 'netcdf', 356 ) 2793 #if defined( __netcdf4 )2794 #if defined( __netcdf4_parallel ) 2794 2795 ! 2795 2796 !-- Set independent io operations for parallel io. Collective io 2796 2797 !-- is only allowed in case of a 1d-decomposition along y, because 2797 2798 !-- otherwise, not all PEs have output data. 2798 IF ( netcdf_data_format > 2) THEN2799 IF ( netcdf_data_format > 4 ) THEN 2799 2800 IF ( npex == 1 ) THEN 2800 2801 nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av), & … … 2803 2804 ELSE 2804 2805 ! 2805 !-- ATTENTION: Due to a probable bug in the NetCDF42806 !-- ATTENTION: Due to a probable bug in the netCDF4 2806 2807 !-- installation, independet output does not work 2807 2808 !-- A workaround is used in data_output_2d on those … … 2835 2836 2836 2837 ! 2837 !-- Leave NetCDF define mode2838 !-- Leave netCDF define mode 2838 2839 nc_stat = NF90_ENDDEF( id_set_yz(av) ) 2839 2840 CALL handle_netcdf_error( 'netcdf', 201 ) … … 2948 2949 2949 2950 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 2950 message_string = ' NetCDF file for cross-sections ' // &2951 message_string = 'netCDF file for cross-sections ' // & 2951 2952 TRIM( var ) // ' from previous run found,' // & 2952 2953 '& but this file cannot be extended due to' // & … … 2981 2982 2982 2983 IF ( ns /= ns_old ) THEN 2983 message_string = ' NetCDF file for cross-sections ' // &2984 message_string = 'netCDF file for cross-sections ' // & 2984 2985 TRIM( var ) // ' from previous run found,' // & 2985 2986 '&but this file cannot be extended due to' // & … … 3002 3003 IF ( section(i,3) /= -1 ) THEN 3003 3004 IF ( ( ( section(i,3) + 0.5 ) * dx ) /= netcdf_data(i) ) THEN 3004 message_string = ' NetCDF file for cross-sections ' // &3005 message_string = 'netCDF file for cross-sections ' // & 3005 3006 TRIM( var ) // ' from previous run found,' // & 3006 3007 '&but this file cannot be extended' // & … … 3015 3016 ELSE 3016 3017 IF ( -1.0 /= netcdf_data(i) ) THEN 3017 message_string = ' NetCDF file for cross-sections ' // &3018 message_string = 'netCDF file for cross-sections ' // & 3018 3019 TRIM( var ) // ' from previous run found,' // & 3019 3020 '&but this file cannot be extended' // & … … 3055 3056 3056 3057 IF ( last_time_coordinate(1) >= simulated_time ) THEN 3057 message_string = ' NetCDF file for cross sections ' // &3058 message_string = 'netCDF file for cross sections ' // & 3058 3059 TRIM( var ) // ' from previous run found,' // & 3059 3060 '&but this file cannot be extended becaus' // & … … 3077 3078 id_var_do2d(av,i) ) 3078 3079 CALL handle_netcdf_error( 'netcdf', 216 ) 3079 #if defined( __netcdf4 )3080 #if defined( __netcdf4_parallel ) 3080 3081 ! 3081 3082 !-- Set independent io operations for parallel io. Collective io 3082 3083 !-- is only allowed in case of a 1d-decomposition along y, because 3083 3084 !-- otherwise, not all PEs have output data. 3084 IF ( netcdf_data_format > 2) THEN3085 IF ( netcdf_data_format > 4 ) THEN 3085 3086 IF ( npex == 1 ) THEN 3086 3087 nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av), & … … 3089 3090 ELSE 3090 3091 ! 3091 !-- ATTENTION: Due to a probable bug in the NetCDF43092 !-- ATTENTION: Due to a probable bug in the netCDF4 3092 3093 !-- installation, independet output does not work 3093 3094 !-- A workaround is used in data_output_2d on those … … 3128 3129 nc_stat = NF90_ENDDEF( id_set_yz(av) ) 3129 3130 CALL handle_netcdf_error( 'netcdf', 436 ) 3130 message_string = ' NetCDF file for cross-sections ' // &3131 message_string = 'netCDF file for cross-sections ' // & 3131 3132 TRIM( var ) // ' from previous run found.' // & 3132 3133 '&This file will be extended.' … … 3432 3433 3433 3434 ! 3434 !-- Leave NetCDF define mode3435 !-- Leave netCDF define mode 3435 3436 nc_stat = NF90_ENDDEF( id_set_pr ) 3436 3437 CALL handle_netcdf_error( 'netcdf', 238 ) … … 3478 3479 3479 3480 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 3480 message_string = ' NetCDF file for vertical profiles ' // &3481 message_string = 'netCDF file for vertical profiles ' // & 3481 3482 'from previous run found,' // & 3482 3483 '& but this file cannot be extended due to' // & … … 3512 3513 3513 3514 IF ( last_time_coordinate(1) >= simulated_time ) THEN 3514 message_string = ' NetCDF file for vertical profiles ' // &3515 message_string = 'netCDF file for vertical profiles ' // & 3515 3516 'from previous run found,' // & 3516 3517 '&but this file cannot be extended becaus' // & … … 3578 3579 nc_stat = NF90_ENDDEF( id_set_pr ) 3579 3580 CALL handle_netcdf_error( 'netcdf', 438 ) 3580 message_string = ' NetCDF file for vertical profiles ' // &3581 message_string = 'netCDF file for vertical profiles ' // & 3581 3582 'from previous run found.' // & 3582 3583 '&This file will be extended.' … … 3667 3668 3668 3669 ! 3669 !-- Leave NetCDF define mode3670 !-- Leave netCDF define mode 3670 3671 nc_stat = NF90_ENDDEF( id_set_ts ) 3671 3672 CALL handle_netcdf_error( 'netcdf', 259 ) … … 3700 3701 3701 3702 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 3702 message_string = ' NetCDF file for time series ' // &3703 message_string = 'netCDF file for time series ' // & 3703 3704 'from previous run found,' // & 3704 3705 '& but this file cannot be extended due to' // & … … 3734 3735 3735 3736 IF ( last_time_coordinate(1) >= simulated_time ) THEN 3736 message_string = ' NetCDF file for time series ' // &3737 message_string = 'netCDF file for time series ' // & 3737 3738 'from previous run found,' // & 3738 3739 '&but this file cannot be extended becaus' // & … … 3783 3784 nc_stat = NF90_ENDDEF( id_set_ts ) 3784 3785 CALL handle_netcdf_error( 'netcdf', 440 ) 3785 message_string = ' NetCDF file for time series ' // &3786 message_string = 'netCDF file for time series ' // & 3786 3787 'from previous run found.' // & 3787 3788 '&This file will be extended.' … … 3982 3983 3983 3984 ! 3984 !-- Leave NetCDF define mode3985 !-- Leave netCDF define mode 3985 3986 nc_stat = NF90_ENDDEF( id_set_sp ) 3986 3987 CALL handle_netcdf_error( 'netcdf', 292 ) … … 4060 4061 4061 4062 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 4062 message_string = ' NetCDF file for spectra ' // &4063 message_string = 'netCDF file for spectra ' // & 4063 4064 'from previous run found,' // & 4064 4065 '& but this file cannot be extended due to' // & … … 4094 4095 4095 4096 IF ( ns /= ns_old ) THEN 4096 message_string = ' NetCDF file for spectra ' // &4097 message_string = 'netCDF file for spectra ' // & 4097 4098 ' from previous run found,' // & 4098 4099 '&but this file cannot be extended due to' // & … … 4114 4115 DO i = 1, ns 4115 4116 IF ( zu(comp_spectra_level(i)) /= netcdf_data(i) ) THEN 4116 message_string = ' NetCDF file for spectra ' // &4117 message_string = 'netCDF file for spectra ' // & 4117 4118 ' from previous run found,' // & 4118 4119 '&but this file cannot be extended due to' // & … … 4152 4153 4153 4154 IF ( last_time_coordinate(1) >= simulated_time ) THEN 4154 message_string = ' NetCDF file for spectra ' // &4155 message_string = 'netCDF file for spectra ' // & 4155 4156 'from previous run found,' // & 4156 4157 '&but this file cannot be extended becaus' // & … … 4216 4217 nc_stat = NF90_ENDDEF( id_set_sp ) 4217 4218 CALL handle_netcdf_error( 'netcdf', 442 ) 4218 message_string = ' NetCDF file for spectra ' // &4219 message_string = 'netCDF file for spectra ' // & 4219 4220 'from previous run found.' // & 4220 4221 '&This file will be extended.' … … 4251 4252 ELSE 4252 4253 ! 4253 !-- NetCDF4 allows more than one unlimited dimension4254 !-- netCDF4 allows more than one unlimited dimension 4254 4255 nc_stat = NF90_DEF_DIM( id_set_prt, 'particle_number', & 4255 4256 NF90_UNLIMITED, id_dim_prtnum) … … 4296 4297 4297 4298 ! 4298 !-- Leave NetCDF define mode4299 !-- Leave netCDF define mode 4299 4300 nc_stat = NF90_ENDDEF( id_set_prt ) 4300 4301 CALL handle_netcdf_error( 'netcdf', 322 ) … … 4327 4328 4328 4329 IF ( last_time_coordinate(1) >= simulated_time ) THEN 4329 message_string = ' NetCDF file for particles ' // &4330 message_string = 'netCDF file for particles ' // & 4330 4331 'from previous run found,' // & 4331 4332 '&but this file cannot be extended becaus' // & … … 4355 4356 ENDDO 4356 4357 4357 message_string = ' NetCDF file for particles ' // &4358 message_string = 'netCDF file for particles ' // & 4358 4359 'from previous run found.' // & 4359 4360 '&This file will be extended.' … … 4439 4440 4440 4441 ! 4441 !-- Leave NetCDF define mode4442 !-- Leave netCDF define mode 4442 4443 nc_stat = NF90_ENDDEF( id_set_pts ) 4443 4444 CALL handle_netcdf_error( 'netcdf', 404 ) … … 4477 4478 4478 4479 IF ( TRIM( var_list ) /= TRIM( var_list_old ) ) THEN 4479 message_string = ' NetCDF file for particle time series ' // &4480 message_string = 'netCDF file for particle time series ' // & 4480 4481 'from previous run found,' // & 4481 4482 '& but this file cannot be extended due to' // & … … 4511 4512 4512 4513 IF ( last_time_coordinate(1) >= simulated_time ) THEN 4513 message_string = ' NetCDF file for particle time series ' // &4514 message_string = 'netCDF file for particle time series ' // & 4514 4515 'from previous run found,' // & 4515 4516 '&but this file cannot be extended becaus' // & … … 4564 4565 nc_stat = NF90_ENDDEF( id_set_pts ) 4565 4566 CALL handle_netcdf_error( 'netcdf', 444 ) 4566 message_string = ' NetCDF file for particle time series ' // &4567 message_string = 'netCDF file for particle time series ' // & 4567 4568 'from previous run found.' // & 4568 4569 '&This file will be extended.' … … 4581 4582 4582 4583 4583 SUBROUTINE handle_netcdf_error( routine_name, errno )4584 SUBROUTINE create_netcdf_file( filename , id, parallel, errno ) 4584 4585 #if defined( __netcdf ) 4585 4586 4586 4587 !------------------------------------------------------------------------------! 4587 ! 4588 ! Description: 4589 ! ------------ 4590 ! Creates a netCDF file and give back the id. The parallel flag has to be TRUE 4591 ! for parallel netCDF output support. 4592 !------------------------------------------------------------------------------! 4593 4594 USE control_parameters 4595 USE netcdf 4596 USE netcdf_control 4597 USE pegrid 4598 4599 IMPLICIT NONE 4600 4601 CHARACTER (LEN=*), INTENT(IN) :: filename 4602 INTEGER, INTENT(IN) :: errno 4603 INTEGER, INTENT(OUT) :: id 4604 LOGICAL, INTENT(IN) :: parallel 4605 4606 4607 ! 4608 !-- Create a new netCDF output file with requested netCDF format 4609 IF ( netcdf_data_format == 1 ) THEN 4610 ! 4611 !-- Classic netCDF format 4612 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id ) 4613 4614 ELSEIF ( netcdf_data_format == 2 ) THEN 4615 ! 4616 !-- 64bit-offset format 4617 nc_stat = NF90_CREATE( filename, & 4618 OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ), id ) 4619 4620 #if defined( __netcdf4 ) 4621 ELSEIF ( netcdf_data_format == 3 .OR. & 4622 ( .NOT. parallel .AND. netcdf_data_format == 5 ) ) THEN 4623 ! 4624 !-- netCDF4/HDF5 format 4625 nc_stat = NF90_CREATE( filename, OR( NF90_NOCLOBBER, NF90_NETCDF4 ), id ) 4626 4627 ELSEIF ( netcdf_data_format == 4 .OR. & 4628 ( .NOT. parallel .AND. netcdf_data_format == 6 ) ) THEN 4629 ! 4630 !-- netCDF4/HDF5 format with classic model flag 4631 nc_stat = NF90_CREATE( filename, & 4632 OR( NF90_NOCLOBBER, & 4633 OR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ), id ) 4634 4635 #if defined( __netcdf4_parallel ) 4636 ELSEIF ( netcdf_data_format == 5 .AND. parallel ) THEN 4637 ! 4638 !-- netCDF4/HDF5 format, parallel 4639 nc_stat = NF90_CREATE( filename, OR( NF90_NOCLOBBER, NF90_NETCDF4 ), & 4640 id, COMM = comm2d, INFO = MPI_INFO_NULL ) 4641 4642 ELSEIF ( netcdf_data_format == 6 .AND. parallel ) THEN 4643 ! 4644 !-- netCDF4/HDF5 format with classic model flag, parallel 4645 nc_stat = NF90_CREATE( filename, & 4646 OR( NF90_NOCLOBBER, & 4647 OR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ), & 4648 id, COMM = comm2d, INFO = MPI_INFO_NULL ) 4649 4650 #endif 4651 #endif 4652 ENDIF 4653 4654 CALL handle_netcdf_error( 'create_netcdf_file', errno ) 4655 #endif 4656 END SUBROUTINE create_netcdf_file 4657 4658 4659 SUBROUTINE open_write_netcdf_file( filename, id, parallel, errno ) 4660 #if defined( __netcdf ) 4661 4662 !------------------------------------------------------------------------------! 4663 ! Description: 4664 ! ------------ 4665 ! Opens an existing netCDF file for writing and gives back the id. 4666 ! The parallel flag has to be TRUE for parallel netCDF output support. 4667 !------------------------------------------------------------------------------! 4668 4669 USE control_parameters 4670 USE netcdf 4671 USE netcdf_control 4672 USE pegrid 4673 4674 IMPLICIT NONE 4675 4676 CHARACTER (LEN=*), INTENT(IN) :: filename 4677 INTEGER, INTENT(IN) :: errno 4678 INTEGER, INTENT(OUT) :: id 4679 LOGICAL, INTENT(IN) :: parallel 4680 4681 4682 IF ( netcdf_data_format < 5 .OR. .NOT. parallel ) THEN 4683 nc_stat = NF90_OPEN( filename, NF90_WRITE, id ) 4684 #if defined( __netcdf4 ) 4685 #if defined( __netcdf4par ) 4686 ELSEIF ( netcdf_data_format > 4 .AND. parallel ) THEN 4687 nc_stat = NF90_OPEN( filename, NF90_WRITE, id, COMM = comm2d, & 4688 INFO = MPI_INFO_NULL ) 4689 #endif 4690 #endif 4691 ENDIF 4692 4693 CALL handle_netcdf_error( 'open_write_netcdf_file', errno ) 4694 #endif 4695 END SUBROUTINE open_write_netcdf_file 4696 4697 4698 SUBROUTINE handle_netcdf_error( routine_name, errno ) 4699 #if defined( __netcdf ) 4700 4701 !------------------------------------------------------------------------------! 4588 4702 ! Description: 4589 4703 ! ------------
Note: See TracChangeset
for help on using the changeset viewer.