|
◆ grid_file_id_new()
type(grid_file_id) function grid_id_class::grid_file_id_new |
( |
character(len=*), intent(in) |
filename, |
|
|
character(len=*), intent(in) |
mode, |
|
|
integer, intent(in), optional |
driver, |
|
|
type(grid_id), intent(in), optional |
from_grid_id |
|
) |
| |
Constructor for the grid_file_id class.
It opens the associated file(s); the driver to be used for file access is selected according to the filename argument, to the optional argument driver, or to the optional argument from_grid_id, with increasing priority. If driver and from_grid_id are not provided and filename does not contain driver information, a default is chosen. If filename is an empty string or missing value, the object will be empty, the same will happen in case the file cannot be successfully opened. This condition can be tested with the function c_e() . The driver string provided with the filename can also contain driver-specific options separated by commas, e.g. 'gdal ,8,44,10,46:globe.dat'.
- Parametri
-
[in] | filename | name of file containing gridded data, in the format [driver:]pathname |
[in] | mode | access mode for file, 'r' or 'w' |
[in] | driver | select the driver that will be associated to the grid_file_id created, use the constants grid_id_notype, grid_id_grib_api, grid_id_gdal |
[in] | from_grid_id | select the driver as the one associated to the provided grid_id object |
Definizione alla linea 420 del file grid_id_class.F90.
420 no_driver_id) result(this) 421 TYPE(grid_file_id), INTENT(inout), OPTIONAL, TARGET :: from_grid_file_id 422 CHARACTER(len=*), INTENT(in), OPTIONAL :: grib_api_template 423 INTEGER, INTENT(in), OPTIONAL :: grib_api_id 424 INTEGER, INTENT(in), OPTIONAL :: no_driver_id 425 TYPE(grid_id) :: this 430 CALL gdalnullify(this%gdalid) 433 IF ( PRESENT(from_grid_file_id)) THEN 434 this%driver = from_grid_file_id%driver 436 #ifdef HAVE_LIBGRIBAPI 437 IF (this%driver == grid_id_grib_api) THEN 438 IF (c_e(from_grid_file_id%gaid)) THEN 439 CALL grib_new_from_file(from_grid_file_id%gaid, this%gaid, ier) 440 IF (ier /= grib_success) this%gaid = imiss 445 IF (this%driver == grid_id_gdal) THEN 446 IF (gdalassociated(from_grid_file_id%gdalid) .AND. & 447 ASSOCIATED(from_grid_file_id%file_id_copy)) THEN 448 IF (from_grid_file_id%nlastband < & 449 gdalgetrastercount(from_grid_file_id%gdalid)) THEN 450 from_grid_file_id%nlastband = from_grid_file_id%nlastband + 1 452 gdalgetrasterband(from_grid_file_id%gdalid, from_grid_file_id%nlastband) 453 this%file_id => from_grid_file_id%file_id_copy 460 #ifdef HAVE_LIBGRIBAPI 461 ELSE IF ( PRESENT(grib_api_template)) THEN 462 this%driver = grid_id_grib_api 463 CALL grib_new_from_samples(this%gaid, grib_api_template, ier) 464 IF (ier /= grib_success) this%gaid = imiss 465 ELSE IF ( PRESENT(grib_api_id)) THEN 466 this%driver = grid_id_grib_api 467 this%gaid = grib_api_id 469 ELSE IF ( PRESENT(no_driver_id)) THEN 470 this%driver = grid_id_no_driver 471 this%nodriverid = no_driver_id 474 END FUNCTION grid_id_new 481 SUBROUTINE grid_id_delete(this) 482 TYPE(grid_id), INTENT(inout) :: this 484 this%nodriverid = imiss 485 #ifdef HAVE_LIBGRIBAPI 486 IF (this%driver == grid_id_grib_api) THEN 487 IF (c_e(this%gaid)) CALL grib_release(this%gaid) 492 CALL gdalnullify(this%gdalid) 493 NULLIFY(this%file_id)
|