Ignore:
Timestamp:
Nov 22, 2018 4:01:22 PM (3 years ago)
Author:
eckhard
Message:

inifor: Updated documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/UTIL/inifor/src/inifor_io.f90

    r3537 r3557  
    2626! -----------------
    2727! $Id$
     28! Updated documentation, removed unused subroutine write_netcdf_variable_2d()
     29!
     30!
     31! 3537 2018-11-20 10:53:14Z eckhard
    2832! New routine get_netcdf_dim_vector()
    2933!
     
    7377! Authors:
    7478! --------
    75 ! @author Eckhard Kadasch
     79!> @author Eckhard Kadasch (Deutscher Wetterdienst, Offenbach)
    7680!
    7781! Description:
     
    9296    IMPLICIT NONE
    9397
     98!------------------------------------------------------------------------------!
     99! Description:
     100! ------------
     101!> get_netcdf_variable() reads the netCDF data and metadate for the netCDF
     102!> variable 'in_var % name' from the file 'in_file'. The netCDF data array is
     103!> stored in the 'buffer' array and metadata added to the respective members of
     104!> the given 'in_var'.
     105!------------------------------------------------------------------------------!
    94106    INTERFACE get_netcdf_variable
    95107        MODULE PROCEDURE get_netcdf_variable_int
     
    101113 CONTAINS
    102114
     115!------------------------------------------------------------------------------!
     116! Description:
     117! ------------
     118!> get_netcdf_variable_int() implements the integer variant for the
     119!> get_netcdf_variable interface.
     120!------------------------------------------------------------------------------!
    103121    SUBROUTINE get_netcdf_variable_int(in_file, in_var, buffer)
    104122
     
    139157
    140158
     159!------------------------------------------------------------------------------!
     160! Description:
     161! ------------
     162!> get_netcdf_variable_real() implements the real variant for the
     163!> get_netcdf_variable interface.
     164!------------------------------------------------------------------------------!
    141165    SUBROUTINE get_netcdf_variable_real(in_file, in_var, buffer)
    142166
     
    177201
    178202
    179     SUBROUTINE get_netcdf_dim_vector(filename, varname, array)
     203!------------------------------------------------------------------------------!
     204! Description:
     205! ------------
     206!> get_netcdf_dim_vector() reads the coordinate array 'coordname' from the
     207!> netCDF file 'filename'.
     208!------------------------------------------------------------------------------!
     209    SUBROUTINE get_netcdf_dim_vector(filename, coordname, coords)
    180210
    181211       CHARACTER(LEN=*), INTENT(IN)         ::  filename
    182        CHARACTER(LEN=*), INTENT(IN)         ::  varname
    183        REAL(dp), ALLOCATABLE, INTENT(INOUT) ::  array(:)
     212       CHARACTER(LEN=*), INTENT(IN)         ::  coordname
     213       REAL(dp), ALLOCATABLE, INTENT(INOUT) ::  coords(:)
    184214
    185215       INTEGER ::  ncid, varid, dimlen
     
    187217
    188218       IF ( nf90_open( TRIM(filename), NF90_NOWRITE, ncid ) .EQ. NF90_NOERR .AND. &
    189             nf90_inq_varid( ncid, varname, varid ) .EQ. NF90_NOERR )  THEN
     219            nf90_inq_varid( ncid, coordname, varid ) .EQ. NF90_NOERR )  THEN
    190220
    191221          CALL check(nf90_inquire_variable( ncid, varid, dimids = dimids ))
    192222          CALL check(nf90_inquire_dimension( ncid, dimids(1), len = dimlen ))
    193223
    194           ALLOCATE(array(dimlen))
    195           CALL check(nf90_get_var( ncid, varid, array ))
     224          ALLOCATE(coords(dimlen))
     225          CALL check(nf90_get_var( ncid, varid, coords))
    196226
    197227       ELSE
    198228
    199           message = "Failed to read '" // TRIM(varname) // &
     229          message = "Failed to read '" // TRIM(coordname) // &
    200230             "' from file '" // TRIM(filename) // "'."
    201231          CALL abort('get_netcdf_dim_vector', message)
     
    206236
    207237
     238!------------------------------------------------------------------------------!
     239! Description:
     240! ------------
     241!> get_input_dimensions() reads dimensions metadata of the netCDF variable given
     242!> by 'in_var % name' into 'in_var' data structure.
     243!------------------------------------------------------------------------------!
    208244    SUBROUTINE get_input_dimensions(in_var, ncid)
    209245
     
    232268
    233269
     270!------------------------------------------------------------------------------!
     271! Description:
     272! ------------
     273!> get_netcdf_start_and_count() gets the start position and element counts for
     274!> the given netCDF file. This information is used in get_netcdf_variable_int()
     275!> and _real() for reading input variables..
     276!------------------------------------------------------------------------------!
    234277    SUBROUTINE get_netcdf_start_and_count(in_var, start, count)
    235278
     
    251294       start = (/ 1, 1, 1 /)
    252295       IF ( TRIM(in_var % name) .EQ. 'T_SO' )  THEN
    253           ! Skip depth = 0.0 for T_SO and reduce number of depths from 9 to 8
     296!
     297!--       Skip depth = 0.0 for T_SO and reduce number of depths from 9 to 8
    254298          in_var % dimlen(3) = in_var % dimlen(3) - 1
    255299
    256           ! Start reading from second level, e.g. depth = 0.005 instead of 0.0
     300!
     301!--       Start reading from second level, e.g. depth = 0.005 instead of 0.0
    257302          start(3) = 2
    258303       END IF
     
    269314
    270315
     316!------------------------------------------------------------------------------!
     317! Description:
     318! ------------
     319!> Routine for defining netCDF variables in the dynamic driver, INIFOR's netCDF
     320!> output.
     321!------------------------------------------------------------------------------!
    271322    SUBROUTINE netcdf_define_variable(var, ncid)
    272323
     
    286337   
    287338
     339!------------------------------------------------------------------------------!
     340! Description:
     341! ------------
     342!> netcdf_get_dimensions() reads in all dimensions and their lengths and stores
     343!> them in the given the 'var' data structure. This information is used later
     344!> for writing output variables in update_output().
     345!------------------------------------------------------------------------------!
    288346    SUBROUTINE netcdf_get_dimensions(var, ncid)
    289347
     
    293351        CHARACTER(SNAME)            ::  null
    294352
    295         ! Remember dimension lenghts for NetCDF writing routine
    296353        DO i = 1, var % ndim
    297354           CALL check(nf90_inquire_dimension(ncid, var % dimids(i), &
     
    306363! Description:
    307364! ------------
    308 !> This routine initializes Inifor. This includes parsing command-line
    309 !> arguments, setting the names of the input and output file names as well as
    310 !> the name of the input namelist and, subsequently, reading in and setting grid
    311 !> parameters for the PALM-4U computational grid.
     365!> This routine parses and interpretes the command-line options and stores the
     366!> resulting settings in the 'cfg' data structure.
    312367!------------------------------------------------------------------------------!
    313368    SUBROUTINE parse_command_line_arguments( cfg )
     
    330385       IF (arg_count .GT. 0)  THEN
    331386
    332           ! Every option should have an argument.
    333           !IF ( MOD(arg_count, 2) .NE. 0 )  THEN
    334           !   message = "Syntax error in command line."
    335           !   CALL abort('parse_command_line_arguments', message)
    336           !END IF
    337          
    338387          message = "The -clon and -clat command line options are depricated. " // &
    339388             "Please remove them form your inifor command and specify the " // &
     
    360409                cfg % debug = .TRUE.
    361410
    362              ! Elevation of the PALM-4U domain above sea level
    363411             CASE( '-z0', '-z', '--elevation' )
    364412                CALL get_option_argument( i, arg )
    365413                READ(arg, *) cfg % z0
    366414
    367              ! surface pressure, at z0
    368415             CASE( '-p0', '-r', '--surface-pressure' )
    369416                cfg % p0_is_set = .TRUE.
     
    371418                READ(arg, *) cfg % p0
    372419
    373              ! geostrophic wind in x direction
    374420             CASE( '-ug', '-u', '--geostrophic-u' )
    375421                cfg % ug_is_set = .TRUE.
     
    377423                READ(arg, *) cfg % ug
    378424
    379              ! geostrophic wind in y direction
    380425             CASE( '-vg', '-v', '--geostrophic-v' )
    381426                cfg % vg_is_set = .TRUE.
     
    383428                READ(arg, *) cfg % vg
    384429
    385              ! domain centre geographical longitude and latitude
    386430             CASE( '-clon', '-clat' )
    387431                CALL abort('parse_command_line_arguments', message)         
    388                 !READ(arg, *) lambda_cg
    389                 !lambda_cg = lambda_cg * TO_RADIANS
    390                 !READ(arg, *) phi_cg
    391                 !phi_cg = phi_cg * TO_RADIANS
    392432
    393433             CASE( '-path', '-p', '--path' )
     
    444484                cfg % namelist_file = TRIM(arg)
    445485
    446              ! initial condition mode: 'profile' / 'volume'
    447486             CASE( '-mode', '-i', '--init-mode' )
    448487                CALL get_option_argument( i, arg )
    449488                cfg % ic_mode = TRIM(arg)
    450489
    451              ! boundary conditions / forcing mode: 'ideal' / 'real'
    452490             CASE( '-f', '--forcing-mode' )
    453491                CALL get_option_argument( i, arg )
     
    484522
    485523   
     524!------------------------------------------------------------------------------!
     525! Description:
     526! ------------
     527!> Get the argument of the i'th command line option, which is at the location
     528!> i+1 of the argument list.
     529!------------------------------------------------------------------------------!
    486530   SUBROUTINE get_option_argument(i, arg)
    487531      CHARACTER(LEN=PATH), INTENT(INOUT) ::  arg
     
    494538
    495539
     540!------------------------------------------------------------------------------!
     541! Description:
     542! ------------
     543!> Checks the INIFOR configuration 'cfg' for plausibility.
     544!------------------------------------------------------------------------------!
    496545   SUBROUTINE validate_config(cfg)
    497546      TYPE(inifor_config), INTENT(IN) ::  cfg
     
    503552      all_files_present = all_files_present .AND. file_present(cfg % soiltyp_file, 'SOILTYP')
    504553
    505       ! Only check optional static driver file name, if it has been given.
     554!
     555!--   Only check optional static driver file name, if it has been given.
    506556      IF (TRIM(cfg % static_driver_file) .NE. '')  THEN
    507557         all_files_present = all_files_present .AND. file_present(cfg % static_driver_file, 'static driver')
     
    557607
    558608
     609!------------------------------------------------------------------------------!
     610! Description:
     611! ------------
     612!> Check whether the given file is present on the filesystem.
     613!------------------------------------------------------------------------------!
    559614   LOGICAL FUNCTION file_present(filename, kind)
    560615      CHARACTER(LEN=PATH), INTENT(IN) ::  filename
     
    585640! Description:
    586641! ------------
    587 !> This routine initializes the Inifor output file, i.e. the PALM-4U
    588 !> initializing and forcing data as a NetCDF file.
     642!> This routine initializes the dynamic driver file, i.e. INIFOR's netCDF output
     643!> file.
    589644!>
    590645!> Besides writing metadata, such as global attributes, coordinates, variables,
    591 !> in the NetCDF file, various NetCDF IDs are saved for later, when Inifor
     646!> in the netCDF file, various netCDF IDs are saved for later, when INIFOR
    592647!> writes the actual data.
    593648!------------------------------------------------------------------------------!
     
    611666       CALL report('setup_netcdf_dimensions', message)
    612667
    613        ! Create the NetCDF file. NF90_CLOBBER selects overwrite mode.
     668!
     669!--    Create the netCDF file as in netCDF-4/HDF5 format if __netcdf4 preprocessor flag is given
    614670#if defined( __netcdf4 )
    615671       CALL check(nf90_create(TRIM(output_file % name), OR(NF90_CLOBBER, NF90_HDF5), ncid))
     
    646702       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_lat',     TRIM(real_to_str(origin_lat*TO_DEGREES, '(F18.13)'))))
    647703       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_lon',     TRIM(real_to_str(origin_lon*TO_DEGREES, '(F18.13)'))))
    648        ! FIXME: This is the elevation relative to COSMO-DE/D2 sea level and does
    649        ! FIXME: not necessarily comply with DHHN2016 (c.f. PALM Input Data
    650        ! FIXME: Standard v1.9., origin_z)
     704!
     705!--    FIXME: This is the elevation relative to COSMO-DE/D2 sea level and does
     706!--    FIXME: not necessarily comply with DHHN2016 (c.f. PALM Input Data
     707!--    FIXME: Standard v1.9., origin_z)
    651708       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_z',       TRIM(real_to_str(z0, '(F18.13)'))))
    652709       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'inifor_version', TRIM(VERSION)))
     
    658715!- Section 2a: Define dimensions for cell centers (scalars in soil and atmosph.)
    659716!------------------------------------------------------------------------------
    660        dimids = (/0, 0, 0/) ! reset dimids
    661           CALL check( nf90_def_dim(ncid, "x", nx+1, dimids(1)) )
    662           CALL check( nf90_def_dim(ncid, "y", ny+1, dimids(2)) )
    663           CALL check( nf90_def_dim(ncid, "z", nz, dimids(3)) )
    664           output_file % dimids_scl = dimids ! save dimids for later
    665 
    666        dimvarids = (/0, 0, 0/) ! reset dimvarids
    667           CALL check(nf90_def_var(ncid, "x", NF90_FLOAT, dimids(1), dimvarids(1)))
    668           CALL check(nf90_put_att(ncid, dimvarids(1), "standard_name", "x coordinate of cell centers"))
    669           CALL check(nf90_put_att(ncid, dimvarids(1), "units", "m"))
    670 
    671           CALL check(nf90_def_var(ncid, "y", NF90_FLOAT, dimids(2), dimvarids(2)))
    672           CALL check(nf90_put_att(ncid, dimvarids(2), "standard_name", "y coordinate of cell centers"))
    673           CALL check(nf90_put_att(ncid, dimvarids(2), "units", "m"))
    674 
    675           CALL check(nf90_def_var(ncid, "z", NF90_FLOAT, dimids(3), dimvarids(3)))
    676           CALL check(nf90_put_att(ncid, dimvarids(3), "standard_name", "z coordinate of cell centers"))
    677           CALL check(nf90_put_att(ncid, dimvarids(3), "units", "m"))
    678        output_file % dimvarids_scl = dimvarids ! save dimvarids for later
    679 
    680        ! overwrite third dimid with the one of depth
     717!
     718!--    reset dimids first
     719       dimids = (/0, 0, 0/)
     720       CALL check( nf90_def_dim(ncid, "x", nx+1, dimids(1)) )
     721       CALL check( nf90_def_dim(ncid, "y", ny+1, dimids(2)) )
     722       CALL check( nf90_def_dim(ncid, "z", nz, dimids(3)) )
     723!
     724!--    save dimids for later
     725       output_file % dimids_scl = dimids
     726
     727!
     728!--    reset dimvarids first
     729       dimvarids = (/0, 0, 0/)
     730       CALL check(nf90_def_var(ncid, "x", NF90_FLOAT, dimids(1), dimvarids(1)))
     731       CALL check(nf90_put_att(ncid, dimvarids(1), "standard_name", "x coordinate of cell centers"))
     732       CALL check(nf90_put_att(ncid, dimvarids(1), "units", "m"))
     733
     734       CALL check(nf90_def_var(ncid, "y", NF90_FLOAT, dimids(2), dimvarids(2)))
     735       CALL check(nf90_put_att(ncid, dimvarids(2), "standard_name", "y coordinate of cell centers"))
     736       CALL check(nf90_put_att(ncid, dimvarids(2), "units", "m"))
     737
     738       CALL check(nf90_def_var(ncid, "z", NF90_FLOAT, dimids(3), dimvarids(3)))
     739       CALL check(nf90_put_att(ncid, dimvarids(3), "standard_name", "z coordinate of cell centers"))
     740       CALL check(nf90_put_att(ncid, dimvarids(3), "units", "m"))
     741!
     742!--    save dimvarids for later
     743       output_file % dimvarids_scl = dimvarids
     744
     745!
     746!--    overwrite third dimid with the one of depth
    681747       CALL check(nf90_def_dim(ncid, "zsoil", SIZE(palm_grid % depths), dimids(3)) )
    682        output_file % dimids_soil = dimids ! save dimids for later
    683 
    684        ! overwrite third dimvarid with the one of depth
     748!
     749!--    save dimids for later
     750       output_file % dimids_soil = dimids
     751
     752!
     753!--    overwrite third dimvarid with the one of depth
    685754       CALL check(nf90_def_var(ncid, "zsoil", NF90_FLOAT, output_file % dimids_soil(3), dimvarids(3)))
    686755       CALL check(nf90_put_att(ncid, dimvarids(3), "standard_name", "depth_below_land"))
    687756       CALL check(nf90_put_att(ncid, dimvarids(3), "positive", "down"))
    688757       CALL check(nf90_put_att(ncid, dimvarids(3), "units", "m"))
    689        output_file % dimvarids_soil = dimvarids ! save dimvarids for later
     758!
     759!--    save dimvarids for later
     760       output_file % dimvarids_soil = dimvarids
    690761!
    691762!------------------------------------------------------------------------------
    692763!- Section 2b: Define dimensions for cell faces/velocities
    693764!------------------------------------------------------------------------------
    694        dimids = (/0, 0, 0/) ! reset dimids
    695           CALL check(nf90_def_dim(ncid, "xu", nx, dimids(1)) )
    696           CALL check(nf90_def_dim(ncid, "yv", ny, dimids(2)) )
    697           CALL check(nf90_def_dim(ncid, "zw", nz-1, dimids(3)) )
    698        output_file % dimids_vel = dimids ! save dimids for later
    699 
    700        dimvarids = (/0, 0, 0/) ! reset dimvarids
    701           CALL check(nf90_def_var(ncid, "xu", NF90_FLOAT, dimids(1), dimvarids(1)))
    702           CALL check(nf90_put_att(ncid, dimvarids(1), "standard_name", "x coordinate of cell faces"))
    703           CALL check(nf90_put_att(ncid, dimvarids(1), "units", "m"))
    704 
    705           CALL check(nf90_def_var(ncid, "yv", NF90_FLOAT, dimids(2), dimvarids(2)))
    706           CALL check(nf90_put_att(ncid, dimvarids(2), "standard_name", "y coordinate of cell faces"))
    707           CALL check(nf90_put_att(ncid, dimvarids(2), "units", "m"))
    708 
    709           CALL check(nf90_def_var(ncid, "zw", NF90_FLOAT, dimids(3), dimvarids(3)))
    710           CALL check(nf90_put_att(ncid, dimvarids(3), "standard_name", "z coordinate of cell faces"))
    711           CALL check(nf90_put_att(ncid, dimvarids(3), "units", "m"))
    712        output_file % dimvarids_vel = dimvarids ! save dimvarids for later
     765!
     766!--    reset dimids first
     767       dimids = (/0, 0, 0/)
     768       CALL check(nf90_def_dim(ncid, "xu", nx, dimids(1)) )
     769       CALL check(nf90_def_dim(ncid, "yv", ny, dimids(2)) )
     770       CALL check(nf90_def_dim(ncid, "zw", nz-1, dimids(3)) )
     771!
     772!--    save dimids for later
     773       output_file % dimids_vel = dimids
     774
     775!
     776!--    reset dimvarids first
     777       dimvarids = (/0, 0, 0/)
     778       CALL check(nf90_def_var(ncid, "xu", NF90_FLOAT, dimids(1), dimvarids(1)))
     779       CALL check(nf90_put_att(ncid, dimvarids(1), "standard_name", "x coordinate of cell faces"))
     780       CALL check(nf90_put_att(ncid, dimvarids(1), "units", "m"))
     781
     782       CALL check(nf90_def_var(ncid, "yv", NF90_FLOAT, dimids(2), dimvarids(2)))
     783       CALL check(nf90_put_att(ncid, dimvarids(2), "standard_name", "y coordinate of cell faces"))
     784       CALL check(nf90_put_att(ncid, dimvarids(2), "units", "m"))
     785
     786       CALL check(nf90_def_var(ncid, "zw", NF90_FLOAT, dimids(3), dimvarids(3)))
     787       CALL check(nf90_put_att(ncid, dimvarids(3), "standard_name", "z coordinate of cell faces"))
     788       CALL check(nf90_put_att(ncid, dimvarids(3), "units", "m"))
     789!
     790!--    save dimvarids for later
     791       output_file % dimvarids_vel = dimvarids
    713792
    714793!
     
    739818       CALL check(nf90_put_var(ncid, output_file % dimvarids_vel(3), palm_grid%zw))
    740819
    741        ! TODO Read in soil depths from input file before this.
     820!
     821!--    TODO Read in soil depths from input file before this.
    742822       CALL check(nf90_put_var(ncid, output_file % dimvarids_soil(3), palm_grid%depths))
    743823
    744        ! Write time vector
     824!
     825!--    Write time vector
    745826       CALL check(nf90_put_var(ncid, output_file % dimvarid_time, output_file % time))
    746827
    747        ! Close the file
     828!
     829!--    Close the file
    748830       CALL check(nf90_close(ncid))
    749831
     
    751833
    752834
     835!------------------------------------------------------------------------------!
     836! Description:
     837! ------------
     838!> Defines the netCDF variables to be written to the dynamic driver file
     839!------------------------------------------------------------------------------!
    753840    SUBROUTINE setup_netcdf_variables(filename, output_variable_table, debug)
    754841
     
    824911!- Section 1: Load input buffers for accumulated variables
    825912!------------------------------------------------------------------------------
     913!
     914!--    radiation budgets, precipitation
    826915       IF (group % kind == 'running average' .OR.                              &
    827            group % kind == 'accumulated')  THEN ! radiation budgets, precipitation
     916           group % kind == 'accumulated')  THEN
    828917
    829918          IF (SIZE(group % in_var_list) .GT. 1 ) THEN
     
    835924          END IF
    836925
    837           ! use two buffer arrays
     926!
     927!--       use two buffer arrays
    838928          nbuffers = 2
    839929          IF ( .NOT. ALLOCATED( buffer ) )  ALLOCATE( buffer(nbuffers) )
    840930
    841           ! chose correct buffer array
    842           hour = iter - 1! hour of the day
     931!
     932!--       hour of the day
     933          hour = iter - 1
     934!
     935!--       chose correct buffer array
    843936          buf_id = select_buffer(hour)
    844937
     
    859952       ELSE
    860953
    861           ! Allocate one input buffer per input_variable. If more quantities
    862           ! have to be computed than input variables exist in this group,
    863           ! allocate more buffers. For instance, in the thermodynamics group,
    864           ! there are three input variabels (PP, T, Qv) and four quantities
    865           ! necessart (P, Theta, Rho, qv) for the corresponding output fields
    866           ! (p0, Theta, qv, ug, and vg)
     954!
     955!--       Allocate one input buffer per input_variable. If more quantities
     956!--       have to be computed than input variables exist in this group,
     957!--       allocate more buffers. For instance, in the thermodynamics group,
     958!--       there are three input variabels (PP, T, Qv) and four quantities
     959!--       necessart (P, Theta, Rho, qv) for the corresponding output fields
     960!--       (p0, Theta, qv, ug, and vg)
    867961          nbuffers = MAX( group % n_inputs, group % n_output_quantities )
    868962          ALLOCATE( buffer(nbuffers) )
    869963 CALL run_control('time', 'alloc')
    870964         
    871           ! Read in all input variables, leave extra buffers-if any-untouched.
     965!
     966!--       Read in all input variables, leave extra buffers-if any-untouched.
    872967          DO ivar = 1, group % n_inputs
    873968
    874969             input_var => group % in_var_list(ivar)
    875970
    876              ! Check wheather P or PP is present in input file
     971!
     972!            Check wheather P or PP is present in input file
    877973             IF (input_var % name == 'P')  THEN
    878974                input_var % name = TRIM( get_pressure_varname(input_file) )
     
    891987
    892988
     989!------------------------------------------------------------------------------!
     990! Description:
     991! ------------
     992!> Select the appropriate buffer ID for accumulated COSMO input variables
     993!> depending on the current hour.
     994!------------------------------------------------------------------------------!
    893995    INTEGER FUNCTION select_buffer(hour)
    894996       INTEGER, INTENT(IN) ::  hour
     
    9431045
    9441046
     1047!------------------------------------------------------------------------------!
     1048! Description:
     1049! ------------
     1050!> Read the given global attribute form the given netCDF file.
     1051!------------------------------------------------------------------------------!
    9451052    FUNCTION get_netcdf_attribute(filename, attribute) RESULT(attribute_value)
    9461053
     
    9481055       REAL(dp)                     ::  attribute_value
    9491056
    950        INTEGER                      :: ncid
     1057       INTEGER                      ::  ncid
    9511058
    9521059       IF ( nf90_open( TRIM(filename), NF90_NOWRITE, ncid ) == NF90_NOERR )  THEN
     
    9661073
    9671074
     1075
     1076!------------------------------------------------------------------------------!
     1077! Description:
     1078! ------------
     1079!> Updates the dynamic driver with the interpolated field of the current
     1080!> variable at the current time step.
     1081!------------------------------------------------------------------------------!
    9681082    SUBROUTINE update_output(var, array, iter, output_file, cfg)
    9691083       TYPE(nc_var), INTENT(IN)  ::  var
     
    9801094       )
    9811095
    982        ! Skip time dimension for output
     1096!
     1097!--    Skip time dimension for output
    9831098       ndim = var % ndim
    9841099       IF ( var_is_time_dependent )  ndim = var % ndim - 1
     
    9901105       CALL check(nf90_open(output_file % name, NF90_WRITE, ncid))
    9911106
    992        ! Reduce dimension of output array according to variable kind
     1107!
     1108!--    Reduce dimension of output array according to variable kind
    9931109       SELECT CASE (TRIM(var % kind))
    9941110       
     
    10861202
    10871203
    1088     SUBROUTINE write_netcdf_variable_2d(var, iter, output_file, buffer)
    1089        TYPE(nc_var), INTENT(IN)          ::  var
    1090        INTEGER, INTENT(IN)               ::  iter
    1091        TYPE(nc_file), INTENT(IN)         ::  output_file
    1092        REAL(dp), INTENT(IN)              ::  buffer(:,:,:)
    1093 
    1094        INTEGER ::  ncid, ndim_out, start(4), count(4)
    1095        LOGICAL ::  last_dimension_is_time
    1096 
    1097        ndim_out = var % ndim
    1098 
    1099        last_dimension_is_time = var % dimids( var % ndim ) == output_file % dimid_time
    1100        IF ( last_dimension_is_time )  THEN
    1101           ndim_out = ndim_out - 1
    1102        END IF
    1103 
    1104        start(:)      = (/1,1,1,iter/)
    1105        count(1:ndim_out) = var%dimlen(1:ndim_out)
    1106 
    1107        CALL check(nf90_open(output_file % name, NF90_WRITE, ncid))
    1108 
    1109        IF (TRIM(var % kind) .EQ. 'left/right scalar')  THEN
    1110 
    1111           CALL check(nf90_put_var( ncid, var%varid, buffer(1,:,:) ) )
    1112 
    1113        ELSE IF (TRIM(var % kind) .EQ. 'north/south scalar')  THEN
    1114 
    1115           CALL check(nf90_put_var( ncid, var%varid, buffer(:,1,:) ) )
    1116 
    1117        ELSE IF (TRIM(var % kind) .EQ. 'top scalar')  THEN
    1118 
    1119           CALL check(nf90_put_var( ncid, var%varid, buffer(:,:,1) ) )
    1120        ELSE
    1121 
    1122           CALL check(nf90_put_var( ncid, var%varid, buffer ) )
    1123 
    1124        END IF
    1125        CALL check(nf90_close(ncid))
    1126 
    1127     END SUBROUTINE write_netcdf_variable_2d
    1128 
    1129 
     1204!------------------------------------------------------------------------------!
     1205! Description:
     1206! ------------
     1207!> Checks the status of a netCDF API call and aborts if an error occured
     1208!------------------------------------------------------------------------------!
    11301209    SUBROUTINE check(status)
    11311210
Note: See TracChangeset for help on using the changeset viewer.