try_get_bathymetry_var Subroutine

private subroutine try_get_bathymetry_var(ncid, varid, ierr)

Uses

    • netcdf
  • proc~~try_get_bathymetry_var~~UsesGraph proc~try_get_bathymetry_var try_get_bathymetry_var netcdf netcdf proc~try_get_bathymetry_var->netcdf

Try to find the bathymetry variable by common names

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ncid
integer, intent(out) :: varid
integer, intent(out), optional :: ierr

Non-zero when none of the recognised variable names is found, when present; absent behaves as today (leaves varid unset and lets the caller’s next NetCDF call fail).


Calls

proc~~try_get_bathymetry_var~~CallsGraph proc~try_get_bathymetry_var try_get_bathymetry_var error error proc~try_get_bathymetry_var->error nf90_inq_varid nf90_inq_varid proc~try_get_bathymetry_var->nf90_inq_varid

Called by

proc~~try_get_bathymetry_var~~CalledByGraph proc~try_get_bathymetry_var try_get_bathymetry_var proc~load_bathymetry_into_array load_bathymetry_into_array proc~load_bathymetry_into_array->proc~try_get_bathymetry_var proc~ocean_state_seed_from_cfg ocean_state_seed_from_cfg proc~ocean_state_seed_from_cfg->proc~load_bathymetry_into_array proc~engine_setup engine_setup proc~engine_setup->proc~ocean_state_seed_from_cfg proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean proc~rdb_ocean_create_finalize rdb_ocean_create_finalize proc~rdb_ocean_create_finalize->proc~complete_ocean_create proc~rdb_ocean_create_from_string rdb_ocean_create_from_string proc~rdb_ocean_create_from_string->proc~complete_ocean_create

Variables

Type Visibility Attributes Name Initial
integer, private :: status

Source Code

   subroutine try_get_bathymetry_var(ncid, varid, ierr)
      !! Try to find the bathymetry variable by common names
      use netcdf, only: nf90_inq_varid
      integer, intent(in) :: ncid
      integer, intent(out) :: varid
      integer, intent(out), optional :: ierr
         !! Non-zero when none of the recognised variable names is found,
         !! when present; absent behaves as today (leaves `varid`
         !! unset and lets the caller's next NetCDF call fail).

      integer :: status

      ! Try "b" first (our convention)
      status = nf90_inq_varid(ncid, "b", varid)
      if (status == nf90_noerr) then
         if (present(ierr)) ierr = OCEAN_STATUS_OK
         return
      end if

      ! Try "elevation"
      status = nf90_inq_varid(ncid, "elevation", varid)
      if (status == nf90_noerr) then
         if (present(ierr)) ierr = OCEAN_STATUS_OK
         return
      end if

      ! Try "depth"
      status = nf90_inq_varid(ncid, "depth", varid)
      if (status == nf90_noerr) then
         if (present(ierr)) ierr = OCEAN_STATUS_OK
         return
      end if

      ! None found
      call logger%error("No bathymetry variable found (tried: b, elevation, depth)")
      if (present(ierr)) then
         ierr = OCEAN_STATUS_ERR_IO
         return
      end if

   end subroutine try_get_bathymetry_var