libsim Versione 7.2.6

◆ 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]thisobject in which to import
[in]gridinfogridinfo object to be imported
[in]forceif provided and .TRUE., the gridinfo is forced into an empty element of this, if required and possible
[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]isanavarif provides and .TRUE., the gridinfo object is treated as time-independent and replicated for every time and timerange

Definizione alla linea 1009 del file volgrid6d_class.F90.

1011 CALL copy(gaid_template, gaid)
1012#ifdef DEBUG
1013 CALL l4f_category_log(this%category,l4f_debug,"template cloned to a new gaid")
1014#endif
1015 usetemplate = c_e(gaid)
1016ENDIF
1017
1018IF (.NOT.usetemplate) THEN
1019 IF (optio_log(clone)) THEN
1020 CALL copy(this%gaid(ilevel,itime,itimerange,ivar), gaid)
1021#ifdef DEBUG
1022 CALL l4f_category_log(this%category,l4f_debug,"original gaid cloned to a new one")
1023#endif
1024 ELSE
1025 gaid = this%gaid(ilevel,itime,itimerange,ivar)
1026 ENDIF
1027ENDIF
1028
1029IF (this%time_definition == 1 .OR. this%time_definition == 2) THEN
1030 correctedtime = this%time(itime) - &
1031 timedelta_new(sec=this%timerange(itimerange)%p1)
1032ELSE
1033 correctedtime = this%time(itime)
1034ENDIF
1035
1036CALL init(gridinfo,gaid, this%griddim, correctedtime, this%timerange(itimerange), &
1037 this%level(ilevel), this%var(ivar))
1038
1039! reset the gridinfo, bad but necessary at this point for encoding the field
1040CALL export(gridinfo%griddim, gridinfo%gaid)
1041! encode the field
1042IF (ASSOCIATED(this%voldati)) THEN
1043 CALL encode_gridinfo(gridinfo, this%voldati(:,:,ilevel,itime,itimerange,ivar))
1044ELSE IF (usetemplate) THEN ! field must be forced into template in this case
1045 NULLIFY(voldati)
1046 CALL volgrid_get_vol_2d(this, ilevel, itime, itimerange, ivar, voldati)
1047 CALL encode_gridinfo(gridinfo, voldati)
1048 DEALLOCATE(voldati)
1049ENDIF
1050
1051END SUBROUTINE export_to_gridinfo
1052
1053
1054!> Import an array of \a gridinfo objects into an array of \a
1055!! volgrid6d objects.
1056!! This method imports an array of gridded fields from an \a
1057!! arrayof_gridinfo object into a suitable number of \a volgrid6d
1058!! objects. The number of \a volgrid6d allocated is determined by the
1059!! number of different grids encountered in \a arrayof_gridinfo.
1060!! Unlike the import for a single \a gridinfo, here the \a volgrid6d
1061!! object is a non-associated pointer to a 1-d array of uninitialized
1062!! objects, and all the dimension descriptors in each of the objects
1063!! are allocated and assigned within the method according to the data
1064!! contained in \a gridinfov.
1065!! If the \a anavar array argument is provided, all the input messages
1066!! whose variable maps to one of the B-table variables contained in \a
1067!! anavar are treated as time-independent (AKA anagraphic data,
1068!! station data, etc.), thus their time and timerange are ignored and
1069!! they are replicated for every time and timerange present in the
1070!! corresponding data volume.
1071SUBROUTINE import_from_gridinfovv(this, gridinfov, dup_mode, clone, decode, &
1072 time_definition, anavar, categoryappend)
1073TYPE(volgrid6d),POINTER :: this(:) !< object in which to import
1074TYPE(arrayof_gridinfo),INTENT(in) :: gridinfov !< array of gridinfo objects to be imported
1075INTEGER,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
1076LOGICAL , INTENT(in),OPTIONAL :: clone !< if provided and \c .TRUE. , clone the gaid's from \a gridinfo to \a this
1077LOGICAL,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
1078INTEGER,INTENT(IN),OPTIONAL :: time_definition !< 0=time is reference time; 1=time is validity time
1079CHARACTER(len=*),INTENT(IN),OPTIONAL :: anavar(:) !< list of variables (B-table code equivalent) to be treated as time-independent data
1080CHARACTER(len=*),INTENT(in),OPTIONAL :: categoryappend !< append this suffix to log4fortran namespace category
1081
1082INTEGER :: i, j, stallo
1083INTEGER :: ngrid, ntime, ntimerange, nlevel, nvar, ltime_definition
1084INTEGER :: category
1085CHARACTER(len=512) :: a_name
1086TYPE(datetime),ALLOCATABLE :: correctedtime(:)
1087LOGICAL,ALLOCATABLE :: isanavar(:)
1088TYPE(vol7d_var) :: lvar
1089TYPE(vol7d_timerange),ALLOCATABLE :: correctedtimerange(:)
1090
1091! category temporanea (altrimenti non possiamo loggare)
1092if (present(categoryappend))then
1093 call l4f_launcher(a_name,a_name_append=trim(subcategory)//"."//trim(categoryappend))
1094else
1095 call l4f_launcher(a_name,a_name_append=trim(subcategory))
1096endif
1097category=l4f_category_get(a_name)
1098
1099#ifdef DEBUG
1100call l4f_category_log(category,l4f_debug,"start import_from_gridinfovv")
1101#endif
1102
1103IF (PRESENT(time_definition)) THEN
1104 ltime_definition = max(min(time_definition, 2), 0)
1105ELSE
1106 ltime_definition = 0
1107ENDIF
1108
1109ngrid=count_distinct(gridinfov%array(1:gridinfov%arraysize)%griddim,back=.true.)
1110CALL l4f_category_log(category,l4f_info, t2c(ngrid)// &
1111 ' different grid definition(s) found in input data')
1112
1113ALLOCATE(this(ngrid),stat=stallo)
1114IF (stallo /= 0)THEN
1115 CALL l4f_category_log(category,l4f_fatal,"allocating memory")
1116 CALL raise_fatal_error()
1117ENDIF
1118DO i = 1, ngrid
1119 IF (PRESENT(categoryappend))THEN
1120 CALL init(this(i), time_definition=ltime_definition, categoryappend=trim(categoryappend)//"-vol"//t2c(i))
1121 ELSE
1122 CALL init(this(i), time_definition=ltime_definition, categoryappend="vol"//t2c(i))
1123 ENDIF
1124ENDDO
1125
1126this(:)%griddim=pack_distinct(gridinfov%array(1:gridinfov%arraysize)%griddim, &
1127 ngrid, back=.true.)
1128
1129! mark elements as ana variables (time-independent)
1130ALLOCATE(isanavar(gridinfov%arraysize))
1131isanavar(:) = .false.
1132IF (PRESENT(anavar)) THEN
1133 DO i = 1, gridinfov%arraysize
1134 DO j = 1, SIZE(anavar)
1135 lvar = convert(gridinfov%array(i)%var)
1136 IF (lvar%btable == anavar(j)) THEN
1137 isanavar(i) = .true.
1138 EXIT
1139 ENDIF
1140 ENDDO
1141 ENDDO
1142 CALL l4f_category_log(category,l4f_info,t2c(count(isanavar))//'/'// &
1143 t2c(gridinfov%arraysize)//' constant-data messages found in input data')
1144ENDIF
1145
1146IF (ltime_definition == 1 .OR. ltime_definition == 2) THEN ! verification time
1147 ALLOCATE(correctedtime(gridinfov%arraysize))
1148 correctedtime(:) = gridinfov%array(1:gridinfov%arraysize)%time
1149 DO i = 1, gridinfov%arraysize
1150 correctedtime(i) = correctedtime(i) + &
1151 timedelta_new(sec=gridinfov%array(i)%timerange%p1)
1152 ENDDO
1153ENDIF
1154IF (ltime_definition == 2) THEN ! set all to analysis
1155 ALLOCATE(correctedtimerange(gridinfov%arraysize))
1156 correctedtimerange(:) = gridinfov%array(1:gridinfov%arraysize)%timerange
1157 correctedtimerange(:)%p1 = 0
1158ENDIF
1159
1160DO i = 1, ngrid
1161 IF (PRESENT(anavar)) THEN
1162 j = count((this(i)%griddim == gridinfov%array(1:gridinfov%arraysize)%griddim) &

Generated with Doxygen.