Changeset 4421


Ignore:
Timestamp:
Feb 24, 2020 3:33:45 PM (4 years ago)
Author:
suehring
Message:

Output of character station_name (required for UC2 standard); bugfix - missing coupling_char for opening NetCDF file

File:
1 edited

Legend:

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

    r4408 r4421  
    2525! -----------------
    2626! $Id$
     27! - Output of character string station_name after DOM has been enabled to
     28!   output character variables
     29! - Bugfix, missing coupling char statement when opening the input file
     30!
     31! 4408 2020-02-14 10:04:39Z gronemeier
    2732! write fill_value attribute
    2833!
     
    111116!> which allows for straight-forward comparison of model results with
    112117!> observations.
    113 !>
    114 !> @todo Check why there is an error when _FillValue attributes are added via
    115 !>       dom.
    116 !> @todo Output of character variable station_name (dom hasn't this feature
    117 !>       yet implemented).
    118118!------------------------------------------------------------------------------!
    119119 MODULE virtual_measurement_mod
     
    882882!
    883883!-- Open the input file.
    884     CALL open_read_file( input_file_vm, pids_id )
     884    CALL open_read_file( input_file_vm // TRIM( coupling_char ), pids_id )
    885885!
    886886!-- Obtain number of sites.
     
    14621462!
    14631463!--    Define output file.
    1464        WRITE( vmea(l)%nc_filename, '(A,I4.4)') 'VM_OUTPUT' //                 &
     1464       WRITE( vmea(l)%nc_filename, '(A,I4.4)' ) 'VM_OUTPUT' //                 &
    14651465                                                TRIM( coupling_char ) // '/' //&
    14661466                                                'site', l
     
    16151615                                   dimension_name = 'max_name_len',            &
    16161616                                   output_type = 'int32',                      &
    1617                                    bounds = (/1_iwp, 32_iwp/),                 &
     1617                                   bounds = (/1_iwp, maximum_name_length /),   &
    16181618                                   values_int32 = ndim )
    16191619       DEALLOCATE( ndim )
     
    16281628                                   output_type = 'real32' )
    16291629!
    1630 !--    station_name. DOM needs to be enabled to define CHARACTER variables.
    1631 !        variable_name = 'station_name'
    1632 !        return_value = dom_def_var( vmea(l)%nc_filename,                        &
    1633 !                                    variable_name = variable_name,              &
    1634 !                                    dimension_names = (/ 'max_name_len',        &
    1635 !                                                         'station     '/),      &
    1636 !                                    output_type = 'char' )
     1630!--    station_name
     1631       variable_name = 'station_name'
     1632       return_value = dom_def_var( vmea(l)%nc_filename,                        &
     1633                                   variable_name = variable_name,              &
     1634                                   dimension_names = (/ 'max_name_len',        &
     1635                                                        'station     ' /),     &
     1636                                   output_type = 'char' )
    16371637!
    16381638!--    vrs (vertical reference system)
     
    19661966                                      variable_name = variable_name,           &
    19671967                                      dimension_names = (/ 'max_name_len',     &
    1968                                                            'station_soil'/),   &
     1968                                                           'station_soil' /),  &
    19691969                                      output_type = 'char' )
    19701970!
     
    22602260
    22612261    CHARACTER(LEN=100) ::  variable_name !< name of output variable
    2262 
    2263     INTEGER(iwp)       ::  l             !< loop index
    2264     INTEGER(iwp)       ::  n             !< loop index
     2262    CHARACTER(LEN=maximum_name_length), DIMENSION(:), ALLOCATABLE :: station_name !< string for station name, consecutively ordered
     2263
     2264    CHARACTER(LEN=1), DIMENSION(:,:), ALLOCATABLE, TARGET ::  output_values_2d_char_target  !< target for output name arrays
     2265    CHARACTER(LEN=1), DIMENSION(:,:), POINTER             ::  output_values_2d_char_pointer !< pointer for output name arrays
     2266
     2267    INTEGER(iwp)       ::  l             !< loop index for the number of sites
     2268    INTEGER(iwp)       ::  n             !< loop index for observation points
     2269    INTEGER(iwp)       ::  nn            !< loop index for number of characters in a name
    22652270    INTEGER            ::  return_value  !< returned status value of called function
    22662271
     
    23472352          DEALLOCATE( oro_rel )
    23482353          DEALLOCATE( output_values_1d_target )
     2354!
     2355!--       Write station name
     2356          ALLOCATE ( station_name(vmea(l)%start_coord_a:vmea(l)%end_coord_a) )
     2357          ALLOCATE ( output_values_2d_char_target(vmea(l)%start_coord_a:vmea(l)%end_coord_a, &
     2358                                                  1:maximum_name_length) )
     2359
     2360          DO  n = vmea(l)%start_coord_a, vmea(l)%end_coord_a
     2361             station_name(n) = REPEAT( ' ', maximum_name_length )
     2362             WRITE( station_name(n), '(A,I10.10)') "station", n
     2363             DO  nn = 1, maximum_name_length
     2364                output_values_2d_char_target(n,nn) = station_name(n)(nn:nn)
     2365             ENDDO
     2366          ENDDO
     2367
     2368          output_values_2d_char_pointer => output_values_2d_char_target
     2369
     2370          return_value =                                                       &
     2371                  dom_write_var( vmea(l)%nc_filename,                          &
     2372                                 'station_name',                               &
     2373                                 values_char_2d = output_values_2d_char_pointer,&
     2374                                 bounds_start = (/ 1,                   vmea(l)%start_coord_a /),&
     2375                                 bounds_end   = (/ maximum_name_length, vmea(l)%end_coord_a /) )
     2376
     2377          DEALLOCATE( station_name )
     2378          DEALLOCATE( output_values_2d_char_target )
    23492379!
    23502380!--       In case of sampled soil quantities, output also the respective
     
    24142444             DEALLOCATE( output_values_1d_target )
    24152445!
    2416 !--          Write the stations name
     2446!--          Write station name
     2447             ALLOCATE ( station_name(vmea(l)%start_coord_s:vmea(l)%end_coord_s) )
     2448             ALLOCATE ( output_values_2d_char_target(vmea(l)%start_coord_s:vmea(l)%end_coord_s, &
     2449                                                     1:maximum_name_length) )
     2450
     2451             DO  n = vmea(l)%start_coord_s, vmea(l)%end_coord_s
     2452                station_name(n) = REPEAT( ' ', maximum_name_length )
     2453                WRITE( station_name(n), '(A,I10.10)') "station", n
     2454                DO  nn = 1, maximum_name_length
     2455                   output_values_2d_char_target(n,nn) = station_name(n)(nn:nn)
     2456                ENDDO
     2457             ENDDO
     2458             output_values_2d_char_pointer => output_values_2d_char_target
     2459
     2460             return_value =                                                    &
     2461                  dom_write_var( vmea(l)%nc_filename,                          &
     2462                                 'station_name_soil',                          &
     2463                                 values_char_2d = output_values_2d_char_pointer,&
     2464                                 bounds_start = (/ 1,                   vmea(l)%start_coord_s /),&
     2465                                 bounds_end   = (/ maximum_name_length, vmea(l)%end_coord_s   /) )
     2466
     2467             DEALLOCATE( station_name )
     2468             DEALLOCATE( output_values_2d_char_target )
    24172469
    24182470          ENDIF
Note: See TracChangeset for help on using the changeset viewer.