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