input_nc_weighted_mean Subroutine

public subroutine input_nc_weighted_mean(ivar, v_sb, mb)

Uses

    • netcdf
  • proc~~input_nc_weighted_mean~~UsesGraph proc~input_nc_weighted_mean input_nc_weighted_mean netcdf netcdf proc~input_nc_weighted_mean->netcdf

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: ivar
real(kind=dp), intent(out) :: v_sb(:)
integer, intent(in) :: mb

Calls

proc~~input_nc_weighted_mean~~CallsGraph proc~input_nc_weighted_mean input_nc_weighted_mean proc~input_nc_check_error input_nc_check_error proc~input_nc_weighted_mean->proc~input_nc_check_error nf90_get_var nf90_get_var proc~input_nc_weighted_mean->nf90_get_var nf90_strerror nf90_strerror proc~input_nc_check_error->nf90_strerror proc~log_error log_error proc~input_nc_check_error->proc~log_error proc~log_message log_message proc~log_error->proc~log_message proc~log_write log_write proc~log_message->proc~log_write proc~log_format_message log_format_message proc~log_message->proc~log_format_message proc~to_string to_string proc~log_write->proc~to_string proc~date_time_str date_time_str proc~log_format_message->proc~date_time_str proc~colourise colourise proc~log_format_message->proc~colourise proc~string_index string_index proc~colourise->proc~string_index

Called by

proc~~input_nc_weighted_mean~~CalledByGraph proc~input_nc_weighted_mean input_nc_weighted_mean proc~input_nc_read_climate input_nc_read_climate proc~input_nc_read_climate->proc~input_nc_weighted_mean proc~time_process_day time_process_day proc~time_process_day->proc~input_nc_read_climate proc~time_process_month time_process_month proc~time_process_month->proc~time_process_day proc~time_process_years time_process_years proc~time_process_years->proc~time_process_month program~swim swim program~swim->proc~time_process_years

Contents


Source Code

  subroutine input_nc_weighted_mean(ivar, v_sb, mb)
    use netcdf, only : nf90_get_var
    integer, intent(in) :: mb
    ! variable index
    integer, intent (in) :: ivar
    real(dp), intent (out) :: v_sb(:) ! the subbasin variable to be filled
    integer :: start(3), count(3) ! to supply to nc_get_var
    ! looping ints
    integer sb, i

    ! Read 1 record of NLONS*NLATS*NLVLS values, starting at the beginning
    ! of the record (the (1, 1, rec) element in the netCDF file).
    count = (/ nc_nx, nc_ny, 1 /)
    start = (/ nc_xmin, nc_ymin, nc_nday /)

    ! read one day/record
    call input_nc_check_error( nf90_get_var(nc_ids(ivar), nc_var_ids(ivar), nc_var_in, start, count) )
    ! apply offset and scale_factor
    nc_var_in = nc_var_in * nc_attr_vals(ivar, 1) + nc_attr_vals(ivar, 2)

    ! interpolate and fill v_sb
    v_sb = 0
    do sb = 1, mb
      do i = 1, nc_ncells_sb(sb)
        v_sb(sb) = v_sb(sb) + nc_var_in(nc_x_sb(sb, i), nc_y_sb(sb, i)) * nc_weight_sb(sb, i)
      end do
    enddo

  end subroutine input_nc_weighted_mean