Ignore:
Timestamp:
Oct 19, 2012 2:35:30 PM (12 years ago)
Author:
raasch
Message:

netCDF4 without parallel file support implemented
additional define string netcdf4_parallel is required to switch on parallel file support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/netcdf.f90

    r993 r1031  
    77! Current revisions:
    88! ------------------
    9 !
     9! netCDF4 without parallel file support implemented, new routines
     10! create_netcdf_file and open_write_netcdf_file at end
    1011!
    1112! Former revisions:
     
    2728!
    2829! 951 2012-07-19 14:22:52Z hoffmann
    29 ! cross_profiles, profile_rows, profile_columns are written to NetCDF header
     30! cross_profiles, profile_rows, profile_columns are written to netCDF header
    3031!
    3132! 771 2011-10-27 10:56:21Z heinze
     
    4142!
    4243! 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,
    4546! replacement of these characters removed, routine clean_netcdf_varname
    4647! removed
    4748!
    4849! 493 2010-03-01 08:30:24Z raasch
    49 ! Extensions for NetCDF4 output
     50! Extensions for netCDF4 output
    5051!
    5152! 410 2009-12-04 17:05:40Z letzel
     
    5354!
    5455! 359 2009-08-19 16:56:44Z letzel
    55 ! for extended NetCDF files, the updated title attribute includes an update of
     56! for extended netCDF files, the updated title attribute includes an update of
    5657! time_average_text where appropriate.
    57 ! Bugfix for extended NetCDF files: In order to avoid 'data mode' errors if
     58! Bugfix for extended netCDF files: In order to avoid 'data mode' errors if
    5859! updated attributes are larger than their original size, NF90_PUT_ATT is called
    5960! in 'define mode' enclosed by NF90_REDEF and NF90_ENDDEF calls. This implies a
    6061! possible performance loss; an alternative strategy would be to ensure equal
    6162! attribute size in a job chain.
    62 ! NetCDF unit attribute in timeseries output in case of statistic
     63! netCDF unit attribute in timeseries output in case of statistic
    6364! regions added.
    64 ! Output of NetCDF messages with aid of message handling routine.
     65! Output of netCDF messages with aid of message handling routine.
    6566! Output of messages replaced by message handling routine.
    6667! Typographical errors fixed.
     
    9596! In case of extend = .FALSE.:
    9697! Define all necessary dimensions, axes and variables for the different
    97 ! NetCDF datasets. This subroutine is called from check_open after a new
    98 ! 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.
    99100!
    100101! In case of extend = .TRUE.:
     
    163164    IF ( .NOT. init_netcdf )  THEN
    164165!
    165 !--    Check and set accuracy for NetCDF output. First set default value
     166!--    Check and set accuracy for netCDF output. First set default value
    166167       nc_precision = NF90_REAL4
    167168
     
    547548
    548549!
    549 !--       Leave NetCDF define mode
     550!--       Leave netCDF define mode
    550551          nc_stat = NF90_ENDDEF( id_set_mask(mid,av) )
    551552          CALL handle_netcdf_error( 'netcdf', 498 )
     
    683684
    684685          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 ), &
    686687                  ' data for mask', mid, ' from previous run found,', &
    687688                  '&but this file cannot be extended due to variable ', &
     
    710711
    711712          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 ), &
    713714                  ' data for mask', mid, ' from previous run found,', &
    714715                  '&but this file cannot be extended due to mismatch in ', &
     
    748749
    749750          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 ), &
    751752                  ' data for mask', mid, ' from previous run found,', &
    752753                  '&but this file cannot be extended because the current ', &
     
    792793          nc_stat = NF90_ENDDEF( id_set_mask(mid,av) )
    793794          CALL handle_netcdf_error( 'netcdf', 518 )
    794           WRITE ( message_string, * ) 'NetCDF file for ', TRIM( var ), &
     795          WRITE ( message_string, * ) 'netCDF file for ', TRIM( var ), &
    795796               ' data for mask', mid, ' from previous run found.', &
    796797               '&This file will be extended.'
     
    10551056                                     'units', TRIM( do3d_unit(av,i) ) )
    10561057             CALL handle_netcdf_error( 'netcdf', 357 )
    1057 #if defined( __netcdf4 )
     1058#if defined( __netcdf4_parallel )
    10581059!
    10591060!--          Set collective io operations for parallel io
    1060              IF ( netcdf_data_format > 2 )  THEN
     1061             IF ( netcdf_data_format > 4 )  THEN
    10611062                nc_stat = NF90_VAR_PAR_ACCESS( id_set_3d(av),     &
    10621063                                               id_var_do3d(av,i), &
     
    10811082
    10821083!
    1083 !--       Leave NetCDF define mode
     1084!--       Leave netCDF define mode
    10841085          nc_stat = NF90_ENDDEF( id_set_3d(av) )
    10851086          CALL handle_netcdf_error( 'netcdf', 82 )
     
    11881189
    11891190          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 ' //             &
    11911192                              TRIM( var ) // ' from previous run found,' // &
    11921193                              '&but this file cannot be extended due to' // &
     
    12131214
    12141215          IF ( nz_do3d-nzb+1 /= nz_old )  THEN
    1215               message_string = 'NetCDF file for volume data ' //             &
     1216              message_string = 'netCDF file for volume data ' //             &
    12161217                               TRIM( var ) // ' from previous run found,' // &
    12171218                               '&but this file cannot be extended due to' // &
     
    12491250
    12501251          IF ( last_time_coordinate(1) >= simulated_time )  THEN
    1251              message_string = 'NetCDF file for volume data ' // &
     1252             message_string = 'netCDF file for volume data ' // &
    12521253                              TRIM( var ) // ' from previous run found,' // &
    12531254                              '&but this file cannot be extended becaus' // &
     
    12701271                                       id_var_do3d(av,i) )
    12711272             CALL handle_netcdf_error( 'netcdf', 95 )
    1272 #if defined( __netcdf4 )
     1273#if defined( __netcdf4_parallel )
    12731274!
    12741275!--          Set collective io operations for parallel io
    1275              IF ( netcdf_data_format > 2 )  THEN
     1276             IF ( netcdf_data_format > 4 )  THEN
    12761277                nc_stat = NF90_VAR_PAR_ACCESS( id_set_3d(av),     &
    12771278                                               id_var_do3d(av,i), &
     
    13041305          nc_stat = NF90_ENDDEF( id_set_3d(av) )
    13051306          CALL handle_netcdf_error( 'netcdf', 430 )
    1306           message_string = 'NetCDF file for volume data ' //             &
     1307          message_string = 'netCDF file for volume data ' //             &
    13071308                           TRIM( var ) // ' from previous run found.' // &
    13081309                           '&This file will be extended.'
     
    16211622                                        'units', TRIM( do2d_unit(av,i) ) )
    16221623                CALL handle_netcdf_error( 'netcdf', 354 )
    1623 #if defined( __netcdf4 )
     1624#if defined( __netcdf4_parallel )
    16241625!
    16251626!--             Set collective io operations for parallel io
    1626                 IF ( netcdf_data_format > 2 )  THEN
     1627                IF ( netcdf_data_format > 4 )  THEN
    16271628                   nc_stat = NF90_VAR_PAR_ACCESS( id_set_xy(av),     &
    16281629                                                  id_var_do2d(av,i), &
     
    16491650
    16501651!
    1651 !--       Leave NetCDF define mode
     1652!--       Leave netCDF define mode
    16521653          nc_stat = NF90_ENDDEF( id_set_xy(av) )
    16531654          CALL handle_netcdf_error( 'netcdf', 122 )
     
    17941795
    17951796          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 ' //           &
    17971798                              TRIM( var ) // ' from previous run found,' //  &
    17981799                              '& but this file cannot be extended due to' // &
     
    18271828
    18281829          IF ( ns /= ns_old )  THEN
    1829              message_string = 'NetCDF file for cross-sections ' //          &
     1830             message_string = 'netCDF file for cross-sections ' //          &
    18301831                              TRIM( var ) // ' from previous run found,' // &
    18311832                              '&but this file cannot be extended due to' // &
     
    18481849             IF ( section(i,1) /= -1 )  THEN
    18491850                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 ' //     &
    18511852                               TRIM( var ) // ' from previous run found,' // &
    18521853                               '&but this file cannot be extended' //        &
     
    18611862             ELSE
    18621863                IF ( -1.0 /= netcdf_data(i) )  THEN
    1863                    message_string = 'NetCDF file for cross-sections ' //     &
     1864                   message_string = 'netCDF file for cross-sections ' //     &
    18641865                               TRIM( var ) // ' from previous run found,' // &
    18651866                               '&but this file cannot be extended' //        &
     
    19011902
    19021903          IF ( last_time_coordinate(1) >= simulated_time )  THEN
    1903              message_string = 'NetCDF file for cross sections ' //          &
     1904             message_string = 'netCDF file for cross sections ' //          &
    19041905                              TRIM( var ) // ' from previous run found,' // &
    19051906                              '&but this file cannot be extended becaus' // &
     
    19231924                                          id_var_do2d(av,i) )
    19241925                CALL handle_netcdf_error( 'netcdf', 138 )
    1925 #if defined( __netcdf4 )
     1926#if defined( __netcdf4_parallel )
    19261927!
    19271928!--             Set collective io operations for parallel io
    1928                 IF ( netcdf_data_format > 2 )  THEN
     1929                IF ( netcdf_data_format > 4 )  THEN
    19291930                   nc_stat = NF90_VAR_PAR_ACCESS( id_set_xy(av),     &
    19301931                                                  id_var_do2d(av,i), &
     
    19581959          nc_stat = NF90_ENDDEF( id_set_xy(av) )
    19591960          CALL handle_netcdf_error( 'netcdf', 432 )
    1960           message_string = 'NetCDF file for cross-sections ' //           &
     1961          message_string = 'netCDF file for cross-sections ' //           &
    19611962                            TRIM( var ) // ' from previous run found.' // &
    19621963                           '&This file will be extended.'
     
    22052206                                        'units', TRIM( do2d_unit(av,i) ) )
    22062207                CALL handle_netcdf_error( 'netcdf', 355 )
    2207 #if defined( __netcdf4 )
     2208#if defined( __netcdf4_parallel )
    22082209!
    22092210!--             Set independent io operations for parallel io. Collective io
    22102211!--             is only allowed in case of a 1d-decomposition along x, because
    22112212!--             otherwise, not all PEs have output data.
    2212                 IF ( netcdf_data_format > 2 )  THEN
     2213                IF ( netcdf_data_format > 4 )  THEN
    22132214                   IF ( npey == 1 )  THEN
    22142215                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av),     &
     
    22172218                   ELSE
    22182219!
    2219 !--                   ATTENTION: Due to a probable bug in the NetCDF4
     2220!--                   ATTENTION: Due to a probable bug in the netCDF4
    22202221!--                              installation, independet output does not work
    22212222!--                              A workaround is used in data_output_2d on those
     
    22492250
    22502251!
    2251 !--       Leave NetCDF define mode
     2252!--       Leave netCDF define mode
    22522253          nc_stat = NF90_ENDDEF( id_set_xz(av) )
    22532254          CALL handle_netcdf_error( 'netcdf', 162 )
     
    23642365
    23652366          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 ' //           &
    23672368                              TRIM( var ) // ' from previous run found,' //  &
    23682369                              '& but this file cannot be extended due to' // &
     
    23972398
    23982399          IF ( ns /= ns_old )  THEN
    2399              message_string = 'NetCDF file for cross-sections ' //          &
     2400             message_string = 'netCDF file for cross-sections ' //          &
    24002401                              TRIM( var ) // ' from previous run found,' // &
    24012402                              '&but this file cannot be extended due to' // &
     
    24182419             IF ( section(i,2) /= -1 )  THEN
    24192420                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 ' //     &
    24212422                               TRIM( var ) // ' from previous run found,' // &
    24222423                               '&but this file cannot be extended' //        &
     
    24312432             ELSE
    24322433                IF ( -1.0 /= netcdf_data(i) )  THEN
    2433                    message_string = 'NetCDF file for cross-sections ' //     &
     2434                   message_string = 'netCDF file for cross-sections ' //     &
    24342435                               TRIM( var ) // ' from previous run found,' // &
    24352436                               '&but this file cannot be extended' //        &
     
    24712472
    24722473          IF ( last_time_coordinate(1) >= simulated_time )  THEN
    2473              message_string = 'NetCDF file for cross sections ' //          &
     2474             message_string = 'netCDF file for cross sections ' //          &
    24742475                              TRIM( var ) // ' from previous run found,' // &
    24752476                              '&but this file cannot be extended becaus' // &
     
    24932494                                          id_var_do2d(av,i) )
    24942495                CALL handle_netcdf_error( 'netcdf', 177 )
    2495 #if defined( __netcdf4 )
     2496#if defined( __netcdf4_parallel )
    24962497!
    24972498!--             Set independent io operations for parallel io. Collective io
    24982499!--             is only allowed in case of a 1d-decomposition along x, because
    24992500!--             otherwise, not all PEs have output data.
    2500                 IF ( netcdf_data_format > 2 )  THEN
     2501                IF ( netcdf_data_format > 4 )  THEN
    25012502                   IF ( npey == 1 )  THEN
    25022503                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av),     &
     
    25052506                   ELSE
    25062507!
    2507 !--                   ATTENTION: Due to a probable bug in the NetCDF4
     2508!--                   ATTENTION: Due to a probable bug in the netCDF4
    25082509!--                              installation, independet output does not work
    25092510!--                              A workaround is used in data_output_2d on those
     
    25442545          nc_stat = NF90_ENDDEF( id_set_xz(av) )
    25452546          CALL handle_netcdf_error( 'netcdf', 434 )
    2546           message_string = 'NetCDF file for cross-sections ' //           &
     2547          message_string = 'netCDF file for cross-sections ' //           &
    25472548                            TRIM( var ) // ' from previous run found.' // &
    25482549                           '&This file will be extended.'
     
    27912792                                        'units', TRIM( do2d_unit(av,i) ) )
    27922793                CALL handle_netcdf_error( 'netcdf', 356 )
    2793 #if defined( __netcdf4 )
     2794#if defined( __netcdf4_parallel )
    27942795!
    27952796!--             Set independent io operations for parallel io. Collective io
    27962797!--             is only allowed in case of a 1d-decomposition along y, because
    27972798!--             otherwise, not all PEs have output data.
    2798                 IF ( netcdf_data_format > 2 )  THEN
     2799                IF ( netcdf_data_format > 4 )  THEN
    27992800                   IF ( npex == 1 )  THEN
    28002801                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av),     &
     
    28032804                   ELSE
    28042805!
    2805 !--                   ATTENTION: Due to a probable bug in the NetCDF4
     2806!--                   ATTENTION: Due to a probable bug in the netCDF4
    28062807!--                              installation, independet output does not work
    28072808!--                              A workaround is used in data_output_2d on those
     
    28352836
    28362837!
    2837 !--       Leave NetCDF define mode
     2838!--       Leave netCDF define mode
    28382839          nc_stat = NF90_ENDDEF( id_set_yz(av) )
    28392840          CALL handle_netcdf_error( 'netcdf', 201 )
     
    29482949
    29492950          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 ' //           &
    29512952                              TRIM( var ) // ' from previous run found,' //  &
    29522953                              '& but this file cannot be extended due to' // &
     
    29812982
    29822983          IF ( ns /= ns_old )  THEN
    2983              message_string = 'NetCDF file for cross-sections ' //          &
     2984             message_string = 'netCDF file for cross-sections ' //          &
    29842985                              TRIM( var ) // ' from previous run found,' // &
    29852986                              '&but this file cannot be extended due to' // &
     
    30023003             IF ( section(i,3) /= -1 )  THEN
    30033004                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 ' //    &
    30053006                              TRIM( var ) // ' from previous run found,' // &
    30063007                              '&but this file cannot be extended' //        &
     
    30153016             ELSE
    30163017                IF ( -1.0 /= netcdf_data(i) )  THEN
    3017                    message_string = 'NetCDF file for cross-sections ' //    &
     3018                   message_string = 'netCDF file for cross-sections ' //    &
    30183019                              TRIM( var ) // ' from previous run found,' // &
    30193020                              '&but this file cannot be extended' //        &
     
    30553056
    30563057          IF ( last_time_coordinate(1) >= simulated_time )  THEN
    3057              message_string = 'NetCDF file for cross sections ' //          &
     3058             message_string = 'netCDF file for cross sections ' //          &
    30583059                              TRIM( var ) // ' from previous run found,' // &
    30593060                              '&but this file cannot be extended becaus' // &
     
    30773078                                          id_var_do2d(av,i) )
    30783079                CALL handle_netcdf_error( 'netcdf', 216 )
    3079 #if defined( __netcdf4 )
     3080#if defined( __netcdf4_parallel )
    30803081!
    30813082!--             Set independent io operations for parallel io. Collective io
    30823083!--             is only allowed in case of a 1d-decomposition along y, because
    30833084!--             otherwise, not all PEs have output data.
    3084                 IF ( netcdf_data_format > 2 )  THEN
     3085                IF ( netcdf_data_format > 4 )  THEN
    30853086                   IF ( npex == 1 )  THEN
    30863087                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av),     &
     
    30893090                   ELSE
    30903091!
    3091 !--                   ATTENTION: Due to a probable bug in the NetCDF4
     3092!--                   ATTENTION: Due to a probable bug in the netCDF4
    30923093!--                              installation, independet output does not work
    30933094!--                              A workaround is used in data_output_2d on those
     
    31283129          nc_stat = NF90_ENDDEF( id_set_yz(av) )
    31293130          CALL handle_netcdf_error( 'netcdf', 436 )
    3130           message_string = 'NetCDF file for cross-sections ' //           &
     3131          message_string = 'netCDF file for cross-sections ' //           &
    31313132                            TRIM( var ) // ' from previous run found.' // &
    31323133                           '&This file will be extended.'
     
    34323433
    34333434!
    3434 !--       Leave NetCDF define mode
     3435!--       Leave netCDF define mode
    34353436          nc_stat = NF90_ENDDEF( id_set_pr )
    34363437          CALL handle_netcdf_error( 'netcdf', 238 )
     
    34783479
    34793480          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 ' //        &
    34813482                              'from previous run found,' //                  &
    34823483                              '& but this file cannot be extended due to' // &
     
    35123513
    35133514          IF ( last_time_coordinate(1) >= simulated_time )  THEN
    3514              message_string = 'NetCDF file for vertical profiles ' //       &
     3515             message_string = 'netCDF file for vertical profiles ' //       &
    35153516                              'from previous run found,' //                 &
    35163517                              '&but this file cannot be extended becaus' // &
     
    35783579          nc_stat = NF90_ENDDEF( id_set_pr )
    35793580          CALL handle_netcdf_error( 'netcdf', 438 )
    3580           message_string = 'NetCDF file for vertical profiles ' // &
     3581          message_string = 'netCDF file for vertical profiles ' // &
    35813582                           'from previous run found.' //           &
    35823583                           '&This file will be extended.'
     
    36673668
    36683669!
    3669 !--       Leave NetCDF define mode
     3670!--       Leave netCDF define mode
    36703671          nc_stat = NF90_ENDDEF( id_set_ts )
    36713672          CALL handle_netcdf_error( 'netcdf', 259 )
     
    37003701
    37013702          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 ' //              &
    37033704                              'from previous run found,' //                  &
    37043705                              '& but this file cannot be extended due to' // &
     
    37343735
    37353736          IF ( last_time_coordinate(1) >= simulated_time )  THEN
    3736              message_string = 'NetCDF file for time series ' //             &
     3737             message_string = 'netCDF file for time series ' //             &
    37373738                              'from previous run found,' //                 &
    37383739                              '&but this file cannot be extended becaus' // &
     
    37833784          nc_stat = NF90_ENDDEF( id_set_ts )
    37843785          CALL handle_netcdf_error( 'netcdf', 440 )
    3785           message_string = 'NetCDF file for time series ' // &
     3786          message_string = 'netCDF file for time series ' // &
    37863787                           'from previous run found.' //     &
    37873788                           '&This file will be extended.'
     
    39823983
    39833984!
    3984 !--       Leave NetCDF define mode
     3985!--       Leave netCDF define mode
    39853986          nc_stat = NF90_ENDDEF( id_set_sp )
    39863987          CALL handle_netcdf_error( 'netcdf', 292 )
     
    40604061
    40614062          IF ( TRIM( var_list ) /= TRIM( var_list_old ) )  THEN
    4062              message_string = 'NetCDF file for spectra  ' //                 &
     4063             message_string = 'netCDF file for spectra  ' //                 &
    40634064                              'from previous run found,' //                  &
    40644065                              '& but this file cannot be extended due to' // &
     
    40944095
    40954096          IF ( ns /= ns_old )  THEN
    4096              message_string = 'NetCDF file for spectra ' //                 &
     4097             message_string = 'netCDF file for spectra ' //                 &
    40974098                              ' from previous run found,' //                &
    40984099                              '&but this file cannot be extended due to' // &
     
    41144115          DO  i = 1, ns
    41154116             IF ( zu(comp_spectra_level(i)) /= netcdf_data(i) )  THEN
    4116                 message_string = 'NetCDF file for spectra ' //                 &
     4117                message_string = 'netCDF file for spectra ' //                 &
    41174118                                 ' from previous run found,' //                &
    41184119                                 '&but this file cannot be extended due to' // &
     
    41524153
    41534154          IF ( last_time_coordinate(1) >= simulated_time )  THEN
    4154              message_string = 'NetCDF file for spectra ' //                 &
     4155             message_string = 'netCDF file for spectra ' //                 &
    41554156                              'from previous run found,' //                 &
    41564157                              '&but this file cannot be extended becaus' // &
     
    42164217          nc_stat = NF90_ENDDEF( id_set_sp )
    42174218          CALL handle_netcdf_error( 'netcdf', 442 )
    4218           message_string = 'NetCDF file for spectra ' //     &
     4219          message_string = 'netCDF file for spectra ' //     &
    42194220                           'from previous run found.' //     &
    42204221                           '&This file will be extended.'
     
    42514252          ELSE
    42524253!
    4253 !--          NetCDF4 allows more than one unlimited dimension
     4254!--          netCDF4 allows more than one unlimited dimension
    42544255             nc_stat = NF90_DEF_DIM( id_set_prt, 'particle_number', &
    42554256                                     NF90_UNLIMITED, id_dim_prtnum)
     
    42964297
    42974298!
    4298 !--       Leave NetCDF define mode
     4299!--       Leave netCDF define mode
    42994300          nc_stat = NF90_ENDDEF( id_set_prt )
    43004301          CALL handle_netcdf_error( 'netcdf', 322 )
     
    43274328
    43284329          IF ( last_time_coordinate(1) >= simulated_time )  THEN
    4329              message_string = 'NetCDF file for particles ' //               &
     4330             message_string = 'netCDF file for particles ' //               &
    43304331                              'from previous run found,' //                 &
    43314332                              '&but this file cannot be extended becaus' // &
     
    43554356          ENDDO
    43564357
    4357           message_string = 'NetCDF file for particles ' // &
     4358          message_string = 'netCDF file for particles ' // &
    43584359                           'from previous run found.' //   &
    43594360                           '&This file will be extended.'
     
    44394440
    44404441!
    4441 !--       Leave NetCDF define mode
     4442!--       Leave netCDF define mode
    44424443          nc_stat = NF90_ENDDEF( id_set_pts )
    44434444          CALL handle_netcdf_error( 'netcdf', 404 )
     
    44774478
    44784479          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 ' //     &
    44804481                              'from previous run found,' //                  &
    44814482                              '& but this file cannot be extended due to' // &
     
    45114512
    45124513          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 ' //    &
    45144515                              'from previous run found,' //                 &
    45154516                              '&but this file cannot be extended becaus' // &
     
    45644565          nc_stat = NF90_ENDDEF( id_set_pts )
    45654566          CALL handle_netcdf_error( 'netcdf', 444 )
    4566           message_string = 'NetCDF file for particle time series ' // &
     4567          message_string = 'netCDF file for particle time series ' // &
    45674568                           'from previous run found.' //              &
    45684569                           '&This file will be extended.'
     
    45814582
    45824583
    4583 SUBROUTINE handle_netcdf_error( routine_name, errno )
     4584 SUBROUTINE create_netcdf_file( filename , id, parallel, errno )
    45844585#if defined( __netcdf )
    45854586
    45864587!------------------------------------------------------------------------------!
    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!------------------------------------------------------------------------------!
    45884702! Description:
    45894703! ------------
Note: See TracChangeset for help on using the changeset viewer.