libsim Versione 7.2.6

◆ import_from_gridinfovv()

subroutine import_from_gridinfovv ( type(volgrid6d), dimension(:), pointer this,
type(arrayof_gridinfo), intent(in) gridinfov,
integer, intent(in), optional dup_mode,
logical, intent(in), optional clone,
logical, intent(in), optional decode,
integer, intent(in), optional time_definition,
character(len=*), dimension(:), intent(in), optional anavar,
character(len=*), intent(in), optional categoryappend )

Import an array of gridinfo objects into an array of volgrid6d objects.

This method imports an array of gridded fields from an arrayof_gridinfo object into a suitable number of volgrid6d objects. The number of volgrid6d allocated is determined by the number of different grids encountered in arrayof_gridinfo. Unlike the import for a single gridinfo, here the volgrid6d object is a non-associated pointer to a 1-d array of uninitialized objects, and all the dimension descriptors in each of the objects are allocated and assigned within the method according to the data contained in gridinfov. If the anavar array argument is provided, all the input messages whose variable maps to one of the B-table variables contained in anavar are treated as time-independent (AKA anagraphic data, station data, etc.), thus their time and timerange are ignored and they are replicated for every time and timerange present in the corresponding data volume.

Parametri
thisobject in which to import
[in]gridinfovarray of gridinfo objects to be imported
[in]dup_modedetermines the behavior in case of duplicate metadata: if dup_mode is not provided or 0, a duplicate field overwrites, if dup_mode is 1, duplicate fields are merged with priority to the last
[in]cloneif provided and .TRUE. , clone the gaid's from gridinfo to this
[in]decodeif provided and .FALSE. the data volume in the elements of this is not allocated and successive work will be performed on grid_id's
[in]time_definition0=time is reference time; 1=time is validity time
[in]anavarlist of variables (B-table code equivalent) to be treated as time-independent data
[in]categoryappendappend this suffix to log4fortran namespace category

Definizione alla linea 1259 del file volgrid6d_class.F90.

1261
1262
1263!> Export a \a volgrid6d object to an \a arrayof_gridinfo object.
1264!! The multidimensional \a volgrid6d structure is serialized into a
1265!! one-dimensional array of gridinfo_def objects, which is allocated
1266!! to the proper size if not already allocated, or it is extended
1267!! keeping the old data if any.
1268SUBROUTINE export_to_gridinfov(this, gridinfov, gaid_template, clone)
1269TYPE(volgrid6d),INTENT(inout) :: this !< volume to be exported
1270TYPE(arrayof_gridinfo),INTENT(inout) :: gridinfov !< output array of gridinfo_def objects
1271TYPE(grid_id),INTENT(in),OPTIONAL :: gaid_template !< \a grid_id template to be used for output data replacing the one contained in \a this
1272LOGICAL,INTENT(in),OPTIONAL :: clone !< if provided and \c .TRUE., clone the grid_id included in \a this rather than making a shallow copy
1273
1274INTEGER :: i ,itime, itimerange, ilevel, ivar
1275INTEGER :: ntime, ntimerange, nlevel, nvar
1276TYPE(gridinfo_def) :: gridinfol
1277
1278#ifdef DEBUG
1279CALL l4f_category_log(this%category,l4f_debug,"start export_to_gridinfov")
1280#endif
1281
1282! this is necessary in order not to repeatedly and uselessly copy the
1283! same array of coordinates for each 2d grid during export, the
1284! side-effect is that the computed projection in this is lost
1285CALL dealloc(this%griddim%dim)
1286
1287i=0
1288ntime=size(this%time)
1289ntimerange=size(this%timerange)
1290nlevel=size(this%level)
1291nvar=size(this%var)
1292
1293DO itime=1,ntime
1294 DO itimerange=1,ntimerange
1295 DO ilevel=1,nlevel
1296 DO ivar=1,nvar
1297
1298 CALL init(gridinfol)
1299 CALL export(this, gridinfol, itime, itimerange, ilevel, ivar, &
1300 gaid_template=gaid_template, clone=clone)
1301 IF (c_e(gridinfol%gaid)) THEN
1302 CALL insert(gridinfov, gridinfol)
1303 ELSE
1304 CALL delete(gridinfol)
1305 ENDIF
1306
1307 ENDDO
1308 ENDDO
1309 ENDDO
1310ENDDO
1311
1312END SUBROUTINE export_to_gridinfov
1313
1314
1315!> Export an array of \a volgrid6d objects to an \a arrayof_gridinfo object.
1316!! The multidimensional \a volgrid6d structures are serialized into a
1317!! one-dimensional array of gridinfo_def objects, which is allocated
1318!! to the proper size if not already allocated, or it is extended
1319!! keeping the old data if any.
1320SUBROUTINE export_to_gridinfovv(this, gridinfov, gaid_template, clone)
1321!, &
1322! categoryappend)
1323TYPE(volgrid6d),INTENT(inout) :: this(:) !< volume array to be exported
1324TYPE(arrayof_gridinfo),INTENT(inout) :: gridinfov !< output array of gridinfo_def objects
1325TYPE(grid_id),INTENT(in),OPTIONAL :: gaid_template !< \a grid_id template to be used for output data replacing the one contained in \a this
1326LOGICAL,INTENT(in),OPTIONAL :: clone !< if provided and \c .TRUE., clone the grid_id included in \a this rather than making a shallow copy
1327
1328INTEGER :: i
1329
1330DO i = 1, SIZE(this)
1331#ifdef DEBUG
1332 CALL l4f_category_log(this(i)%category,l4f_debug, &
1333 "export_to_gridinfovv grid index: "//t2c(i))
1334#endif
1335 CALL export(this(i), gridinfov, gaid_template=gaid_template, clone=clone)
1336ENDDO
1337
1338END SUBROUTINE export_to_gridinfovv
1339
1340
1341!> Import the content of a supported file (like grib or gdal-supported
1342!! format) into an array of \a volgrid6d objects. This method imports
1343!! a set of gridded fields from a file object into a suitable number
1344!! of \a volgrid6d objects. The data are imported by creating a
1345!! temporary \a gridinfo object, importing it into the \a volgrid6d
1346!! object cloning the gaid's and then destroying the gridinfo, so it
1347!! works similarly to volgrid6d_class::import_from_gridinfovv() method.
1348!! For a detailed explanation of the \a anavar argument, see the
1349!! documentation of volgrid6d_class::import_from_gridinfovv() method.
1350SUBROUTINE volgrid6d_import_from_file(this, filename, dup_mode, decode, &
1351 time_definition, anavar, categoryappend)
1352TYPE(volgrid6d),POINTER :: this(:) !< object in which to import
1353CHARACTER(len=*),INTENT(in) :: filename !< name of file from which to import
1354INTEGER,INTENT(in),OPTIONAL :: dup_mode !< determines the behavior in case of duplicate metadata: if \a dup_mode is not provided or 0, a duplicate field overwrites, if \a dup_mode is 1, duplicate fields are merged with priority to the last
1355LOGICAL,INTENT(in),OPTIONAL :: decode !< if provided and \a .FALSE. the data volume in the elements of \a this is not allocated and successive work will be performed on grid_id's
1356INTEGER,INTENT(IN),OPTIONAL :: time_definition !< 0=time is reference time; 1=time is validity time
1357CHARACTER(len=*),INTENT(IN),OPTIONAL :: anavar(:) !< list of variables (B-table code equivalent) to be treated as time-independent data
1358character(len=*),INTENT(in),OPTIONAL :: categoryappend !< append this suffix to log4fortran namespace category
1359
1360TYPE(arrayof_gridinfo) :: gridinfo
1361INTEGER :: category
1362CHARACTER(len=512) :: a_name
1363
1364NULLIFY(this)
1365
1366IF (PRESENT(categoryappend))THEN
1367 CALL l4f_launcher(a_name,a_name_append= &
1368 trim(subcategory)//"."//trim(categoryappend))
1369ELSE
1370 CALL l4f_launcher(a_name,a_name_append=trim(subcategory))
1371ENDIF
1372category=l4f_category_get(a_name)
1373
1374CALL import(gridinfo, filename=filename, categoryappend=categoryappend)
1375
1376IF (gridinfo%arraysize > 0) THEN
1377
1378 CALL import(this, gridinfo, dup_mode=dup_mode, clone=.true., decode=decode, &
1379 time_definition=time_definition, anavar=anavar, &
1380 categoryappend=categoryappend)
1381
1382 CALL l4f_category_log(category,l4f_info,"deleting gridinfo")
1383 CALL delete(gridinfo)
1384
1385ELSE
1386 CALL l4f_category_log(category,l4f_info,"file does not contain gridded data")
1387ENDIF
1388
1389! close logger
1390CALL l4f_category_delete(category)
1391
1392END SUBROUTINE volgrid6d_import_from_file
1393
1394
1395!> High level method for exporting a volume array to file.
1396!! All the information contained into an array of \a volgrid6d
1397!! objects, i.e. dimension descriptors and data, is exported to a file
1398!! using the proper output driver (typically grib_api for grib
1399!! format). If a template is provided, it will determine the
1400!! characteristic of the output file, otherwise the \a grid_id
1401!! descriptors contained in the volgrid6d object will be used
1402SUBROUTINE volgrid6d_export_to_file(this, filename, gaid_template, categoryappend)
1403TYPE(volgrid6d) :: this(:) !< volume(s) to be exported
1404CHARACTER(len=*),INTENT(in) :: filename !< output file name
1405TYPE(grid_id),INTENT(in),OPTIONAL :: gaid_template !< template for the output file, if provided the grid_id information stored in the volgrid6d objects will be ignored
1406character(len=*),INTENT(in),OPTIONAL :: categoryappend !< append this suffix to log4fortran namespace category
1407
1408TYPE(arrayof_gridinfo) :: gridinfo
1409INTEGER :: category
1410CHARACTER(len=512) :: a_name
1411
1412IF (PRESENT(categoryappend)) THEN
1413 CALL l4f_launcher(a_name,a_name_append=trim(subcategory)//"."//trim(categoryappend))
1414ELSE
1415 CALL l4f_launcher(a_name,a_name_append=trim(subcategory))
1416ENDIF
1417category=l4f_category_get(a_name)
1418
1419#ifdef DEBUG
1420CALL l4f_category_log(category,l4f_debug,"start export to file")
1421#endif
1422
1423CALL l4f_category_log(category,l4f_info,"writing volgrid6d to grib file: "//trim(filename))
1424
1425!IF (ASSOCIATED(this)) THEN
1426 CALL export(this, gridinfo, gaid_template=gaid_template, clone=.true.)
1427 IF (gridinfo%arraysize > 0) THEN
1428 CALL export(gridinfo, filename)
1429 CALL delete(gridinfo)
1430 ENDIF
1431!ELSE
1432! CALL l4f_category_log(category,L4F_INFO,"volume volgrid6d is not associated")
1433!ENDIF
1434
1435! close logger
1436CALL l4f_category_delete(category)
1437
1438END SUBROUTINE volgrid6d_export_to_file
1439
1440
1441!> Array destructor for \a volgrid6d class.
1442!! Delete an array of \a volgrid6d objects and deallocate the array
1443!! itself.
1444SUBROUTINE volgrid6dv_delete(this)
1445TYPE(volgrid6d),POINTER :: this(:) !< vector of volgrid6d object
1446
1447INTEGER :: i

Generated with Doxygen.