|
◆ import_from_gridinfo()
subroutine import_from_gridinfo |
( |
type(volgrid6d), intent(inout) |
this, |
|
|
type(gridinfo_def), intent(in) |
gridinfo, |
|
|
logical, intent(in), optional |
force, |
|
|
integer, intent(in), optional |
dup_mode, |
|
|
logical, intent(in), optional |
clone, |
|
|
logical, intent(in), optional |
isanavar |
|
) |
| |
Import a single gridinfo object into a volgrid6d object.
This methods imports a single gridded field from a gridinfo object into a volgrid6d object, inserting it into the multidimensional structure of volgrid6d. The volgrid6d object must have been already initialized and the dimensions specified with volgrid6d_alloc(). If the force argument is missing or .FALSE. , the volgrid6d object dimension descriptors (time, timerange, vertical level, physical variable) must already have space for the corresponding values coming from gridinfo, otherwise the object will be rejected; this means that all the volgrid6d dimension descriptors should be correctly assigned. If force is .TRUE. , the gridinfo dimension descriptors that do not fit into available descriptors in the volgrid6d structure, will be accomodated in a empty (i.e. equal to missing value) descriptor, if available, otherwise the gridinfo will be rejected. The descriptor of the grid in the volgrid object is assigned to the descriptor contained in gridinfo if it is missing in volgrid, otherwise it is checked and the object is rejected if grids do not match. - Parametri
-
[in,out] | this | object in which to import |
[in] | gridinfo | gridinfo object to be imported |
[in] | force | if provided and .TRUE., the gridinfo is forced into an empty element of this, if required and possible |
[in] | dup_mode | determines 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] | clone | if provided and .TRUE. , clone the gaid's from gridinfo to this |
[in] | isanavar | if provides and .TRUE., the gridinfo object is treated as time-independent and replicated for every time and timerange |
Definizione alla linea 1003 del file volgrid6d_class.F90.
1005 CALL copy(this%gaid(ilevel,itime,itimerange,ivar), gaid)
1007 CALL l4f_category_log(this%category,l4f_debug, "original gaid cloned to a new one")
1010 gaid = this%gaid(ilevel,itime,itimerange,ivar)
1014 IF (this%time_definition == 1) THEN
1015 correctedtime = this%time(itime) - &
1016 timedelta_new(sec=this%timerange(itimerange)%p1)
1018 correctedtime = this%time(itime)
1021 CALL init(gridinfo,gaid, this%griddim, correctedtime, this%timerange(itimerange), &
1022 this%level(ilevel), this%var(ivar))
1025 CALL export(gridinfo%griddim, gridinfo%gaid)
1027 IF ( ASSOCIATED(this%voldati)) THEN
1028 CALL encode_gridinfo(gridinfo, this%voldati(:,:,ilevel,itime,itimerange,ivar))
1029 ELSE IF (usetemplate) THEN
1031 CALL volgrid_get_vol_2d(this, ilevel, itime, itimerange, ivar, voldati)
1032 CALL encode_gridinfo(gridinfo, voldati)
1036 END SUBROUTINE export_to_gridinfo
1056 SUBROUTINE import_from_gridinfovv(this, gridinfov, dup_mode, clone, decode, &
1057 time_definition, anavar, categoryappend)
1058 TYPE(volgrid6d), POINTER :: this(:)
1059 TYPE(arrayof_gridinfo), INTENT(in) :: gridinfov
1060 INTEGER, INTENT(in), OPTIONAL :: dup_mode
1061 LOGICAL , INTENT(in), OPTIONAL :: clone
1062 LOGICAL, INTENT(in), OPTIONAL :: decode
1063 INTEGER, INTENT(IN), OPTIONAL :: time_definition
1064 CHARACTER(len=*), INTENT(IN), OPTIONAL :: anavar(:)
1065 CHARACTER(len=*), INTENT(in), OPTIONAL :: categoryappend
1067 INTEGER :: i, j, stallo
1068 INTEGER :: ngrid, ntime, ntimerange, nlevel, nvar
1070 CHARACTER(len=512) :: a_name
1071 TYPE(datetime), ALLOCATABLE :: correctedtime(:)
1072 LOGICAL, ALLOCATABLE :: isanavar(:)
1073 TYPE(vol7d_var) :: lvar
1076 if ( present(categoryappend)) then
1077 call l4f_launcher(a_name,a_name_append=trim(subcategory)// "."//trim(categoryappend))
1079 call l4f_launcher(a_name,a_name_append=trim(subcategory))
1081 category=l4f_category_get(a_name)
1084 call l4f_category_log(category,l4f_debug, "start import_from_gridinfovv")
1087 ngrid=count_distinct(gridinfov%array(1:gridinfov%arraysize)%griddim,back=.true.)
1088 CALL l4f_category_log(category,l4f_info, t2c(ngrid)// &
1089 ' different grid definition(s) found in input data')
1091 ALLOCATE(this(ngrid),stat=stallo)
1092 IF (stallo /= 0) THEN
1093 CALL l4f_category_log(category,l4f_fatal, "allocating memory")
1094 CALL raise_fatal_error()
1097 IF ( PRESENT(categoryappend)) THEN
1098 CALL init(this(i), time_definition=time_definition, categoryappend=trim(categoryappend)// "-vol"//t2c(i))
1100 CALL init(this(i), time_definition=time_definition, categoryappend= "vol"//t2c(i))
1104 this(:)%griddim=pack_distinct(gridinfov%array(1:gridinfov%arraysize)%griddim, &
1108 ALLOCATE(isanavar(gridinfov%arraysize))
1109 isanavar(:) = .false.
1110 IF ( PRESENT(anavar)) THEN
1111 DO i = 1, gridinfov%arraysize
1112 DO j = 1, SIZE(anavar)
1113 lvar = convert(gridinfov%array(i)%var)
1114 IF (lvar%btable == anavar(j)) THEN
1115 isanavar(i) = .true.
1120 CALL l4f_category_log(category,l4f_info,t2c(count(isanavar))// '/'// &
1121 t2c(gridinfov%arraysize)// ' constant-data messages found in input data')
1125 ALLOCATE(correctedtime(gridinfov%arraysize))
1126 correctedtime(:) = gridinfov%array(1:gridinfov%arraysize)%time
1127 IF ( PRESENT(time_definition)) THEN
1128 IF (time_definition == 1) THEN
1129 DO i = 1, gridinfov%arraysize
1130 correctedtime(i) = correctedtime(i) + &
1131 timedelta_new(sec=gridinfov%array(i)%timerange%p1)
1137 IF ( PRESENT(anavar)) THEN
1138 j = count((this(i)%griddim == gridinfov%array(1:gridinfov%arraysize)%griddim) &
1139 .AND. .NOT.isanavar(:))
1141 CALL l4f_category_log(category, l4f_fatal, 'grid n.'//t2c(i)// &
1142 ' has only constant data, this is not allowed')
1143 CALL l4f_category_log(category, l4f_fatal, 'please check anavar argument')
1144 CALL raise_fatal_error()
1147 ntime = count_distinct(correctedtime, &
1148 mask=(this(i)%griddim == gridinfov%array(1:gridinfov%arraysize)%griddim) &
1149 .AND. .NOT.isanavar(:), back=.true.)
1150 ntimerange = count_distinct(gridinfov%array(1:gridinfov%arraysize)%timerange, &
1151 mask=(this(i)%griddim == gridinfov%array(1:gridinfov%arraysize)%griddim) &
1152 .AND. .NOT.isanavar(:), back=.true.)
1153 nlevel = count_distinct(gridinfov%array(1:gridinfov%arraysize)%level, &
|