Changeset 519 for palm/trunk/SOURCE


Ignore:
Timestamp:
Mar 19, 2010 5:30:02 AM (14 years ago)
Author:
raasch
Message:

NetCDF4 support for particle data; special character allowed for NetCDF variable names

Location:
palm/trunk/SOURCE
Files:
4 edited

Legend:

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

    r482 r519  
    55! -----------------
    66! TEST: PRINT statements on unit 9 (commented out)
     7! NetCDF4 output format allows size of particle array to be extended
    78!
    89! Former revisions:
     
    19781979          IF ( number_of_particles + number_of_initial_particles > &
    19791980               maximum_number_of_particles  )  THEN
    1980              IF ( netcdf_output )  THEN
     1981             IF ( netcdf_output  .AND.  netcdf_data_format < 3 )  THEN
    19811982                message_string = 'maximum_number_of_particles ' //   &
    19821983                                 'needs to be increased ' //         &
    19831984                                 '&but this is not allowed with ' // &
    1984                                  'NetCDF output switched on'
     1985                                 'netcdf_data_format < 3'
    19851986                CALL message( 'advec_particles', 'PA0146', 2, 2, -1, 6, 1 )
    19861987             ELSE
     
    19981999             IF ( number_of_tails + number_of_initial_tails > &
    19992000                  maximum_number_of_tails  )  THEN
    2000                 IF ( netcdf_output )  THEN
     2001                IF ( netcdf_output  .AND.  netcdf_data_format < 3 )  THEN
    20012002                   message_string = 'maximum_number_of_tails ' //    &
    20022003                                    'needs to be increased ' //      &
    20032004                                    '&but this is not allowed wi' // &
    2004                                     'th NetCDF output switched on'
     2005                                    'th netcdf_data_format < 3'
    20052006                   CALL message( 'advec_particles', 'PA0147', 2, 2, -1, 6, 1 )
    20062007                ELSE
     
    23892390               maximum_number_of_particles )           &
    23902391          THEN
    2391              IF ( netcdf_output )  THEN
     2392             IF ( netcdf_output  .AND.  netcdf_data_format < 3 )  THEN
    23922393                 message_string = 'maximum_number_of_particles ' //    &
    23932394                                  'needs to be increased ' //          &
    23942395                                  '&but this is not allowed with ' //  &
    2395                                   'NetCDF output switched on'
     2396                                  'netcdf-data_format < 3'
    23962397                CALL message( 'advec_particles', 'PA0146', 2, 2, -1, 6, 1 )
    23972398             ELSE
     
    24172418             IF ( number_of_tails+trrpt_count_recv > maximum_number_of_tails ) &
    24182419             THEN
    2419                 IF ( netcdf_output )  THEN
     2420                IF ( netcdf_output  .AND.  netcdf_data_format < 3 )  THEN
    24202421                   message_string = 'maximum_number_of_tails ' //   &
    24212422                                    'needs to be increased ' //     &
    24222423                                    '&but this is not allowed wi'// &
    2423                                     'th NetCDF output switched on'
     2424                                    'th netcdf_data_format < 3'
    24242425                   CALL message( 'advec_particles', 'PA0147', 2, 2, -1, 6, 1 )
    24252426                ELSE
     
    24662467               maximum_number_of_particles )           &
    24672468          THEN
    2468              IF ( netcdf_output )  THEN
     2469             IF ( netcdf_output  .AND.  netcdf_data_format < 3 )  THEN
    24692470                message_string = 'maximum_number_of_particles ' //  &
    24702471                                 'needs to be increased ' //        &
    24712472                                 '&but this is not allowed with '// &
    2472                                  'NetCDF output switched on'
     2473                                 'netcdf_data_format < 3'
    24732474                CALL message( 'advec_particles', 'PA0146', 2, 2, -1, 6, 1 )
    24742475             ELSE
     
    24942495             IF ( number_of_tails+trlpt_count_recv > maximum_number_of_tails ) &
    24952496             THEN
    2496                 IF ( netcdf_output )  THEN
     2497                IF ( netcdf_output  .AND.  netcdf_data_format < 3 )  THEN
    24972498                   message_string = 'maximum_number_of_tails ' //   &
    24982499                                    'needs to be increased ' //     &
    24992500                                    '&but this is not allowed wi'// &
    2500                                     'th NetCDF output switched on'
     2501                                    'th netcdf_data_format < 3'
    25012502                   CALL message( 'advec_particles', 'PA0147', 2, 2, -1, 6, 1 )
    25022503                ELSE
     
    28362837               maximum_number_of_particles )           &
    28372838          THEN
    2838              IF ( netcdf_output )  THEN
     2839             IF ( netcdf_output  .AND.  netcdf_data_format < 3 )  THEN
    28392840                message_string = 'maximum_number_of_particles ' //  &
    28402841                                 'needs to be increased ' //        &
    28412842                                 '&but this is not allowed with '// &
    2842                                  'NetCDF output switched on'
     2843                                 'netcdf_data_format < 3'
    28432844                CALL message( 'advec_particles', 'PA0146', 2, 2, -1, 6, 1 )
    28442845             ELSE
     
    28642865             IF ( number_of_tails+trnpt_count_recv > maximum_number_of_tails ) &
    28652866             THEN
    2866                 IF ( netcdf_output )  THEN
     2867                IF ( netcdf_output  .AND.  netcdf_data_format < 3 )  THEN
    28672868                   message_string = 'maximum_number_of_tails ' //    &
    28682869                                    'needs to be increased ' //      &
    28692870                                    '&but this is not allowed wi' // &
    2870                                     'th NetCDF output switched on'
     2871                                    'th netcdf_data_format < 3'
    28712872                   CALL message( 'advec_particles', 'PA0147', 2, 2, -1, 6, 1 )
    28722873                ELSE
     
    29142915               maximum_number_of_particles )           &
    29152916          THEN
    2916              IF ( netcdf_output )  THEN
     2917             IF ( netcdf_output  .AND.  netcdf_data_format < 3 )  THEN
    29172918                message_string = 'maximum_number_of_particles ' //   &
    29182919                                 'needs to be increased ' //         &
    29192920                                 '&but this is not allowed with ' // &
    2920                                  'NetCDF output switched on'
     2921                                 'netcdf_data_format < 3'
    29212922               CALL message( 'advec_particles', 'PA0146', 2, 2, -1, 6, 1 ) 
    29222923             ELSE
     
    29422943             IF ( number_of_tails+trspt_count_recv > maximum_number_of_tails ) &
    29432944             THEN
    2944                 IF ( netcdf_output )  THEN
     2945                IF ( netcdf_output  .AND.  netcdf_data_format < 3 )  THEN
    29452946                   message_string = 'maximum_number_of_tails ' //   &
    29462947                                    'needs to be increased ' //     &
  • palm/trunk/SOURCE/check_open.f90

    r494 r519  
    44! Current revisions:
    55! -----------------
    6 !
     6! NetCDF4 support for particle data
    77!
    88! Former revisions:
     
    12751275
    12761276!
    1277 !--          Create a new NetCDF output file
    1278              IF ( netcdf_data_format > 1 )  THEN
     1277!--          Create a new NetCDF output file with requested NetCDF format
     1278             IF ( netcdf_data_format == 1 )  THEN
     1279!
     1280!--             Classic NetCDF format
     1281                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_prt )
     1282
     1283             ELSEIF ( netcdf_data_format == 2 )  THEN
     1284!
     1285!--             64bit-offset format
    12791286                nc_stat = NF90_CREATE( filename,                               &
    12801287                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
    12811288                                       id_set_prt )
    1282              ELSE
    1283                 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_prt )
    1284              ENDIF
     1289
     1290#if defined( __netcdf4 )
     1291             ELSEIF ( netcdf_data_format == 3 )  THEN
     1292!
     1293!--             NetCDF4/HDF5 format, but no parallel output into a single file!
     1294                nc_stat = NF90_CREATE( filename,                               &
     1295                                       OR( NF90_NOCLOBBER, NF90_NETCDF4 ),     &
     1296                                       id_set_prt )
     1297
     1298             ELSEIF ( netcdf_data_format == 4 )  THEN
     1299!
     1300!--             NetCDF4/HDF5 format with classic model flag, but no parallel
     1301!--             output into a single file!
     1302                nc_stat = NF90_CREATE( filename,                               &
     1303                                       OR( NF90_NOCLOBBER,                     &
     1304                                        OR( NF90_CLASSIC_MODEL, NF90_HDF5 ) ), &
     1305                                       id_set_prt )
     1306#endif
     1307             ENDIF
     1308
    12851309             CALL handle_netcdf_error( 'check_open', 43 ) 
    12861310
  • palm/trunk/SOURCE/modules.f90

    r494 r519  
    55! Current revisions:
    66! -----------------
    7 !
     7! -replace_char, replace_by
    88!
    99! Former revisions:
     
    976976#endif
    977977
    978     INTEGER, PARAMETER ::  dopr_norm_num = 7, dopts_num = 26, dots_max = 100, &
    979                            replace_num = 6
     978    INTEGER, PARAMETER ::  dopr_norm_num = 7, dopts_num = 26, dots_max = 100
    980979
    981980    INTEGER ::  dots_num = 23
    982 
    983     CHARACTER, DIMENSION( replace_num ) :: &
    984                            replace_char = (/ '''', '"', '*', '/', '(', ')' /), &
    985                            replace_by   = (/ 'p' , 'p', 's', 'o', '_', '_' /)
    986981
    987982    CHARACTER (LEN=6), DIMENSION(dopr_norm_num) ::  dopr_norm_names =   &
  • palm/trunk/SOURCE/netcdf.f90

    r494 r519  
    77! Current revisions:
    88! ------------------
    9 !
     9! Particle number defined as unlimited dimension in case of NetCDF4 output,
     10! special characters like * and " are now allowed for NetCDF variable names,
     11! replacement of these characters removed, routine clean_netcdf_varname
     12! removed
    1013!
    1114! Former revisions:
     
    9598    CHARACTER (LEN=4)              ::  grid_x, grid_y, grid_z
    9699    CHARACTER (LEN=6)              ::  mode
    97     CHARACTER (LEN=10)             ::  netcdf_var_name, netcdf_var_name_base, &
    98                                        precision, var
     100    CHARACTER (LEN=10)             ::  netcdf_var_name, precision, var
    99101    CHARACTER (LEN=80)             ::  time_average_text
    100102    CHARACTER (LEN=2000)           ::  var_list, var_list_old
     
    15561558!--             surface variable. Define it with id_dim_zu1_xy.
    15571559                IF ( INDEX( do2d(av,i), '*' ) /= 0 )  THEN
    1558 !
    1559 !--                First, remove those characters not allowed by NetCDF
    1560                    netcdf_var_name = do2d(av,i)
    1561                    CALL clean_netcdf_varname( netcdf_var_name )
    1562 
    1563                    nc_stat = NF90_DEF_VAR( id_set_xy(av), netcdf_var_name,     &
     1560
     1561                   nc_stat = NF90_DEF_VAR( id_set_xy(av),  do2d(av,i),         &
    15641562                                           nc_precision(1),                    &
    15651563                                           (/ id_dim_x_xy(av), id_dim_y_xy(av),&
     
    15681566                                           id_var_do2d(av,i) )
    15691567
    1570                    var_list = TRIM(var_list) // TRIM(netcdf_var_name) // ';'
     1568                   var_list = TRIM(var_list) // TRIM( do2d(av,i) ) // ';'
    15711569
    15721570                ELSE
     
    18271825          DO WHILE ( do2d(av,i)(1:1) /= ' ' )
    18281826             IF ( INDEX( do2d(av,i), 'xy' ) /= 0 )  THEN
    1829                 netcdf_var_name = do2d(av,i)
    1830                 CALL clean_netcdf_varname( netcdf_var_name )
    1831                 var_list = TRIM(var_list) // TRIM(netcdf_var_name) // ';'
     1827                var_list = TRIM( var_list ) // TRIM( do2d(av,i) ) // ';'
    18321828             ENDIF
    18331829             i = i + 1
     
    19671963          DO WHILE ( do2d(av,i)(1:1) /= ' ' )
    19681964             IF ( INDEX( do2d(av,i), 'xy' ) /= 0 )  THEN
    1969                 netcdf_var_name = do2d(av,i)
    1970                 CALL clean_netcdf_varname( netcdf_var_name )
    1971                 nc_stat = NF90_INQ_VARID( id_set_xy(av), netcdf_var_name, &
     1965                nc_stat = NF90_INQ_VARID( id_set_xy(av), do2d(av,i), &
    19721966                                          id_var_do2d(av,i) )
    19731967                CALL handle_netcdf_error( 'netcdf', 138 )
     
    24012395          DO WHILE ( do2d(av,i)(1:1) /= ' ' )
    24022396             IF ( INDEX( do2d(av,i), 'xz' ) /= 0 )  THEN
    2403                 netcdf_var_name = do2d(av,i)
    2404                 CALL clean_netcdf_varname( netcdf_var_name )
    2405                 var_list = TRIM(var_list) // TRIM(netcdf_var_name) // ';'
     2397                var_list = TRIM( var_list ) // TRIM( do2d(av,i) ) // ';'
    24062398             ENDIF
    24072399             i = i + 1
     
    25412533          DO WHILE ( do2d(av,i)(1:1) /= ' ' )
    25422534             IF ( INDEX( do2d(av,i), 'xz' ) /= 0 )  THEN
    2543                 netcdf_var_name = do2d(av,i)
    2544                 CALL clean_netcdf_varname( netcdf_var_name )
    2545                 nc_stat = NF90_INQ_VARID( id_set_xz(av), netcdf_var_name, &
     2535                nc_stat = NF90_INQ_VARID( id_set_xz(av), do2d(av,i), &
    25462536                                          id_var_do2d(av,i) )
    25472537                CALL handle_netcdf_error( 'netcdf', 177 )
     
    29892979          DO WHILE ( do2d(av,i)(1:1) /= ' ' )
    29902980             IF ( INDEX( do2d(av,i), 'yz' ) /= 0 )  THEN
    2991                 netcdf_var_name = do2d(av,i)
    2992                 CALL clean_netcdf_varname( netcdf_var_name )
    2993                 var_list = TRIM(var_list) // TRIM(netcdf_var_name) // ';'
     2981                var_list = TRIM( var_list ) // TRIM( do2d(av,i) ) // ';'
    29942982             ENDIF
    29952983             i = i + 1
     
    31293117          DO WHILE ( do2d(av,i)(1:1) /= ' ' )
    31303118             IF ( INDEX( do2d(av,i), 'yz' ) /= 0 )  THEN
    3131                 netcdf_var_name = do2d(av,i)
    3132                 CALL clean_netcdf_varname( netcdf_var_name )
    3133                 nc_stat = NF90_INQ_VARID( id_set_yz(av), netcdf_var_name, &
     3119                nc_stat = NF90_INQ_VARID( id_set_yz(av), do2d(av,i), &
    31343120                                          id_var_do2d(av,i) )
    31353121                CALL handle_netcdf_error( 'netcdf', 216 )
     
    32293215          var_list = ';'
    32303216          DO  i = 1, dopr_n
    3231 !
    3232 !--          First, remove those characters not allowed by NetCDF
    3233              netcdf_var_name = data_output_pr(i)
    3234              CALL clean_netcdf_varname( netcdf_var_name )
    32353217
    32363218             IF ( statistic_regions == 0 )  THEN
     
    32383220!
    32393221!--             Define the z-axes (each variable gets its own z-axis)
    3240                 nc_stat = NF90_DEF_DIM( id_set_pr, 'z'//TRIM(netcdf_var_name), &
     3222                nc_stat = NF90_DEF_DIM( id_set_pr,                        &
     3223                                        'z' // TRIM( data_output_pr(i) ), &
    32413224                                        nzt+2-nzb, id_dim_z_pr(i,0) )
    32423225                CALL handle_netcdf_error( 'netcdf', 223 )
    32433226
    3244                 nc_stat = NF90_DEF_VAR( id_set_pr, 'z'//TRIM(netcdf_var_name), &
    3245                                         NF90_DOUBLE, id_dim_z_pr(i,0),         &
     3227                nc_stat = NF90_DEF_VAR( id_set_pr,                        &
     3228                                        'z' // TRIM( data_output_pr(i) ), &
     3229                                        NF90_DOUBLE, id_dim_z_pr(i,0),    &
    32463230                                        id_var_z_pr(i,0) )
    32473231                CALL handle_netcdf_error( 'netcdf', 224 )
     
    32523236!
    32533237!--             Define the variable
    3254                 nc_stat = NF90_DEF_VAR( id_set_pr, netcdf_var_name,           &
     3238                nc_stat = NF90_DEF_VAR( id_set_pr, data_output_pr(i),         &
    32553239                                        nc_precision(5), (/ id_dim_z_pr(i,0), &
    32563240                                        id_dim_time_pr /), id_var_dopr(i,0) )
     
    32653249                CALL handle_netcdf_error( 'netcdf', 228 )
    32663250
    3267                 var_list = TRIM(var_list) // TRIM(netcdf_var_name) // ';'
     3251                var_list = TRIM( var_list ) // TRIM( data_output_pr(i) ) // ';'
    32683252
    32693253             ELSE
     
    32773261!--                Define the z-axes (each variable gets it own z-axis)
    32783262                   nc_stat = NF90_DEF_DIM( id_set_pr,                          &
    3279                                            'z'//TRIM(netcdf_var_name)//suffix, &
     3263                                         'z'//TRIM(data_output_pr(i))//suffix, &
    32803264                                           nzt+2-nzb, id_dim_z_pr(i,j) )
    32813265                   CALL handle_netcdf_error( 'netcdf', 229 )
    32823266
    32833267                   nc_stat = NF90_DEF_VAR( id_set_pr,                          &
    3284                                            'z'//TRIM(netcdf_var_name)//suffix, &
     3268                                         'z'//TRIM(data_output_pr(i))//suffix, &
    32853269                                           nc_precision(5), id_dim_z_pr(i,j),  &
    32863270                                           id_var_z_pr(i,j) )
     
    32943278!--                Define the variable
    32953279                   nc_stat = NF90_DEF_VAR( id_set_pr,                         &
    3296                                            TRIM( netcdf_var_name ) // suffix, &
     3280                                           TRIM(data_output_pr(i)) // suffix, &
    32973281                                           nc_precision(5),                   &
    32983282                                           (/ id_dim_z_pr(i,j),               &
     
    33103294                   CALL handle_netcdf_error( 'netcdf', 234 )
    33113295
    3312                    var_list = TRIM(var_list) // TRIM(netcdf_var_name) // &
     3296                   var_list = TRIM( var_list ) // TRIM( data_output_pr(i) ) // &
    33133297                              suffix // ';'
    33143298
     
    33763360          DO  i = 1, dopr_n
    33773361
    3378              netcdf_var_name = data_output_pr(i)
    3379              CALL clean_netcdf_varname( netcdf_var_name )
    3380 
    33813362             IF ( statistic_regions == 0 )  THEN
    3382                 var_list = TRIM(var_list) // TRIM(netcdf_var_name) // ';'
     3363                var_list = TRIM( var_list ) // TRIM( data_output_pr(i) ) // ';'
    33833364             ELSE
    33843365                DO  j = 0, statistic_regions
    33853366                   WRITE ( suffix, '(''_'',I1)' )  j
    3386                    var_list = TRIM(var_list) // TRIM(netcdf_var_name) // &
     3367                   var_list = TRIM( var_list ) // TRIM( data_output_pr(i) ) // &
    33873368                              suffix // ';'
    33883369                ENDDO
     
    34453426          DO  i = 1, dopr_n
    34463427 
    3447              netcdf_var_name_base = data_output_pr(i)
    3448              CALL clean_netcdf_varname( netcdf_var_name_base )
    3449 
    34503428             IF ( statistic_regions == 0 )  THEN
    3451                 nc_stat = NF90_INQ_VARID( id_set_pr, netcdf_var_name_base, &
     3429                nc_stat = NF90_INQ_VARID( id_set_pr, data_output_pr(i), &
    34523430                                          id_var_dopr(i,0) )
    34533431                CALL handle_netcdf_error( 'netcdf', 245 )
     
    34553433                DO  j = 0, statistic_regions
    34563434                   WRITE ( suffix, '(''_'',I1)' )  j
    3457                    netcdf_var_name = TRIM( netcdf_var_name_base ) // suffix
     3435                   netcdf_var_name = TRIM( data_output_pr(i) ) // suffix
    34583436                   nc_stat = NF90_INQ_VARID( id_set_pr, netcdf_var_name, &
    34593437                                             id_var_dopr(i,j) )
     
    35253503          var_list = ';'
    35263504          DO  i = 1, dots_num
    3527 !
    3528 !--          First, remove those characters not allowed by NetCDF
    3529              netcdf_var_name = dots_label(i)
    3530              CALL clean_netcdf_varname( netcdf_var_name )
    35313505
    35323506             IF ( statistic_regions == 0 )  THEN
    35333507
    3534                 nc_stat = NF90_DEF_VAR( id_set_ts, netcdf_var_name,            &
     3508                nc_stat = NF90_DEF_VAR( id_set_ts, dots_label(i),              &
    35353509                                        nc_precision(6), (/ id_dim_time_ts /), &
    35363510                                        id_var_dots(i,0) )
     
    35453519                CALL handle_netcdf_error( 'netcdf', 255 )
    35463520
    3547                 var_list = TRIM(var_list) // TRIM(netcdf_var_name) // ';'
     3521                var_list = TRIM( var_list ) // TRIM( dots_label(i) ) // ';'
    35483522
    35493523             ELSE
     
    35553529
    35563530                   nc_stat = NF90_DEF_VAR( id_set_ts,                         &
    3557                                            TRIM( netcdf_var_name ) // suffix, &
     3531                                           TRIM( dots_label(i) ) // suffix,  &
    35583532                                           nc_precision(6),                   &
    35593533                                           (/ id_dim_time_ts /),              &
     
    35713545                   CALL handle_netcdf_error( 'netcdf', 347 )
    35723546
    3573                    var_list = TRIM(var_list) // TRIM(netcdf_var_name) // &
     3547                   var_list = TRIM( var_list ) // TRIM( dots_label(i) ) // &
    35743548                              suffix // ';'
    35753549
     
    36073581          DO  i = 1, dots_num
    36083582
    3609              netcdf_var_name = dots_label(i)
    3610              CALL clean_netcdf_varname( netcdf_var_name )
    3611 
    36123583             IF ( statistic_regions == 0 )  THEN
    3613                 var_list = TRIM(var_list) // TRIM(netcdf_var_name) // ';'
     3584                var_list = TRIM( var_list ) // TRIM( dots_label(i) ) // ';'
    36143585             ELSE
    36153586                DO  j = 0, statistic_regions
    36163587                   WRITE ( suffix, '(''_'',I1)' )  j
    3617                    var_list = TRIM(var_list) // TRIM(netcdf_var_name) // &
     3588                   var_list = TRIM( var_list ) // TRIM( dots_label(i) ) // &
    36183589                              suffix // ';'
    36193590                ENDDO
     
    36763647          DO  i = 1, dots_num
    36773648 
    3678              netcdf_var_name_base = dots_label(i)
    3679              CALL clean_netcdf_varname( netcdf_var_name_base )
    3680 
    36813649             IF ( statistic_regions == 0 )  THEN
    3682                 nc_stat = NF90_INQ_VARID( id_set_ts, netcdf_var_name_base, &
     3650                nc_stat = NF90_INQ_VARID( id_set_ts, dots_label(i), &
    36833651                                          id_var_dots(i,0) )
    36843652                CALL handle_netcdf_error( 'netcdf', 265 )
     
    36863654                DO  j = 0, statistic_regions
    36873655                   WRITE ( suffix, '(''_'',I1)' )  j
    3688                    netcdf_var_name = TRIM( netcdf_var_name_base ) // suffix
     3656                   netcdf_var_name = TRIM( dots_label(i) ) // suffix
    36893657                   nc_stat = NF90_INQ_VARID( id_set_ts, netcdf_var_name, &
    36903658                                             id_var_dots(i,j) )
     
    38423810!--             Define the variable
    38433811                netcdf_var_name = TRIM( data_output_sp(i) ) // '_x'
    3844                 CALL clean_netcdf_varname( netcdf_var_name )
    38453812                IF ( TRIM( grid_z ) == 'zw' )  THEN
    38463813                   nc_stat = NF90_DEF_VAR( id_set_sp, netcdf_var_name,      &
     
    38733840!--             Define the variable
    38743841                netcdf_var_name = TRIM( data_output_sp(i) ) // '_y'
    3875                 CALL clean_netcdf_varname( netcdf_var_name )
    38763842                IF ( TRIM( grid_z ) == 'zw' )  THEN
    38773843                   nc_stat = NF90_DEF_VAR( id_set_sp, netcdf_var_name,      &
     
    41744140!
    41754141!--       Define particle coordinate (maximum particle number)
    4176           nc_stat = NF90_DEF_DIM( id_set_prt, 'particle_number', &
    4177                                   maximum_number_of_particles, id_dim_prtnum )
     4142          IF ( netcdf_data_format < 3 )  THEN
     4143             nc_stat = NF90_DEF_DIM( id_set_prt, 'particle_number', &
     4144                                     maximum_number_of_particles, id_dim_prtnum)
     4145          ELSE
     4146!
     4147!--          NetCDF4 allows more than one unlimited dimension
     4148             nc_stat = NF90_DEF_DIM( id_set_prt, 'particle_number', &
     4149                                     NF90_UNLIMITED, id_dim_prtnum)
     4150          ENDIF
    41784151          CALL handle_netcdf_error( 'netcdf', 314 )
    41794152
     
    43114284          DO  i = 1, dopts_num
    43124285
    4313 !
    4314 !--          First, remove those characters not allowed by NetCDF
    4315              netcdf_var_name = dopts_label(i)
    4316              CALL clean_netcdf_varname( netcdf_var_name )
    4317 
    43184286             DO  j = 0, number_of_particle_groups
    43194287
     
    43254293
    43264294                nc_stat = NF90_DEF_VAR( id_set_pts,                         &
    4327                                         TRIM( netcdf_var_name ) // suffix1, &
     4295                                        TRIM( dopts_label(i) ) // suffix1, &
    43284296                                        nc_precision(6),                    &
    43294297                                        (/ id_dim_time_pts /),              &
     
    43474315                CALL handle_netcdf_error( 'netcdf', 402 )
    43484316
    4349                 var_list = TRIM(var_list) // TRIM(netcdf_var_name) // &
     4317                var_list = TRIM( var_list ) // TRIM( dopts_label(i) ) // &
    43504318                           suffix1 // ';'
    43514319
     
    43854353          DO  i = 1, dopts_num
    43864354
    4387              netcdf_var_name = dopts_label(i)
    4388              CALL clean_netcdf_varname( netcdf_var_name )
    4389 
    43904355             DO  j = 0, number_of_particle_groups
    43914356
     
    43964361                ENDIF
    43974362
    4398                 var_list = TRIM(var_list) // TRIM(netcdf_var_name) // &
     4363                var_list = TRIM( var_list ) // TRIM( dopts_label(i) ) // &
    43994364                           suffix1 // ';'
    44004365
     
    44594424          DO  i = 1, dopts_num
    44604425 
    4461              netcdf_var_name_base = dopts_label(i)
    4462              CALL clean_netcdf_varname( netcdf_var_name_base )
    4463 
    44644426             DO  j = 0, number_of_particle_groups
    44654427
     
    44704432                ENDIF
    44714433
    4472                 netcdf_var_name = TRIM( netcdf_var_name_base ) // suffix1
     4434                netcdf_var_name = TRIM( dopts_label(i) ) // suffix1
    44734435
    44744436                nc_stat = NF90_INQ_VARID( id_set_pts, netcdf_var_name, &
     
    45464508#endif
    45474509 END SUBROUTINE handle_netcdf_error
    4548 
    4549 
    4550 
    4551  SUBROUTINE clean_netcdf_varname( string )
    4552 #if defined( __netcdf )
    4553 
    4554 !------------------------------------------------------------------------------!
    4555 !
    4556 ! Description:
    4557 ! ------------
    4558 ! Replace those characters in string which are not allowed by NetCDF.
    4559 !------------------------------------------------------------------------------!
    4560 
    4561     USE netcdf_control
    4562 
    4563     IMPLICIT NONE
    4564 
    4565     CHARACTER (LEN=10), INTENT(INOUT) ::  string
    4566 
    4567     INTEGER ::  i, ic
    4568 
    4569     DO  i = 1, replace_num
    4570        DO
    4571           ic = INDEX( string, replace_char(i) )
    4572           IF ( ic /= 0 )  THEN
    4573              string(ic:ic) = replace_by(i)
    4574           ELSE
    4575              EXIT
    4576           ENDIF
    4577        ENDDO
    4578     ENDDO
    4579 
    4580 #endif
    4581  END SUBROUTINE clean_netcdf_varname
Note: See TracChangeset for help on using the changeset viewer.