libsim  Versione8.0.0

◆ import_from_gridinfo()

subroutine volgrid6d_class::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 
)
private

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 1026 del file volgrid6d_class.F90.

1026 #ifdef DEBUG
1027  CALL l4f_category_log(this%category,l4f_debug,"original gaid cloned to a new one")
1028 #endif
1029  ELSE
1030  gaid = this%gaid(ilevel,itime,itimerange,ivar)
1031  ENDIF
1032 ENDIF
1033 
1034 IF (this%time_definition == 1 .OR. this%time_definition == 2) THEN
1035  correctedtime = this%time(itime) - &
1036  timedelta_new(sec=this%timerange(itimerange)%p1)
1037 ELSE
1038  correctedtime = this%time(itime)
1039 ENDIF
1040 
1041 CALL init(gridinfo,gaid, this%griddim, correctedtime, this%timerange(itimerange), &
1042  this%level(ilevel), this%var(ivar))
1043 
1044 ! reset the gridinfo, bad but necessary at this point for encoding the field
1045 CALL export(gridinfo%griddim, gridinfo%gaid)
1046 ! encode the field
1047 IF (ASSOCIATED(this%voldati)) THEN
1048  CALL encode_gridinfo(gridinfo, this%voldati(:,:,ilevel,itime,itimerange,ivar))
1049 ELSE IF (usetemplate) THEN ! field must be forced into template in this case
1050  NULLIFY(voldati)
1051  CALL volgrid_get_vol_2d(this, ilevel, itime, itimerange, ivar, voldati)
1052  CALL encode_gridinfo(gridinfo, voldati)
1053  DEALLOCATE(voldati)
1054 ENDIF
1055 
1056 END SUBROUTINE export_to_gridinfo
1057 
1058 
1076 SUBROUTINE import_from_gridinfovv(this, gridinfov, dup_mode, clone, decode, &
1077  time_definition, anavar, categoryappend)
1078 TYPE(volgrid6d),POINTER :: this(:)
1079 TYPE(arrayof_gridinfo),INTENT(in) :: gridinfov
1080 INTEGER,INTENT(in),OPTIONAL :: dup_mode
1081 LOGICAL , INTENT(in),OPTIONAL :: clone
1082 LOGICAL,INTENT(in),OPTIONAL :: decode
1083 INTEGER,INTENT(IN),OPTIONAL :: time_definition
1084 CHARACTER(len=*),INTENT(IN),OPTIONAL :: anavar(:)
1085 CHARACTER(len=*),INTENT(in),OPTIONAL :: categoryappend
1086 
1087 INTEGER :: i, j, stallo
1088 INTEGER :: ngrid, ntime, ntimerange, nlevel, nvar, ltime_definition
1089 TYPE(l4f_handle) :: category
1090 CHARACTER(len=512) :: a_name
1091 TYPE(datetime),ALLOCATABLE :: correctedtime(:)
1092 LOGICAL,ALLOCATABLE :: isanavar(:)
1093 TYPE(vol7d_var) :: lvar
1094 TYPE(vol7d_timerange),ALLOCATABLE :: correctedtimerange(:)
1095 
1096 ! category temporanea (altrimenti non possiamo loggare)
1097 if (present(categoryappend))then
1098  call l4f_launcher(a_name,a_name_append=trim(subcategory)//"."//trim(categoryappend))
1099 else
1100  call l4f_launcher(a_name,a_name_append=trim(subcategory))
1101 endif
1102 category=l4f_category_get_handle(a_name)
1103 
1104 #ifdef DEBUG
1105 call l4f_category_log(category,l4f_debug,"start import_from_gridinfovv")
1106 #endif
1107 
1108 IF (PRESENT(time_definition)) THEN
1109  ltime_definition = max(min(time_definition, 2), 0)
1110 ELSE
1111  ltime_definition = 0
1112 ENDIF
1113 
1114 ngrid=count_distinct(gridinfov%array(1:gridinfov%arraysize)%griddim,back=.true.)
1115 CALL l4f_category_log(category,l4f_info, t2c(ngrid)// &
1116  ' different grid definition(s) found in input data')
1117 
1118 ALLOCATE(this(ngrid),stat=stallo)
1119 IF (stallo /= 0)THEN
1120  CALL l4f_category_log(category,l4f_fatal,"allocating memory")
1121  CALL raise_fatal_error()
1122 ENDIF
1123 DO i = 1, ngrid
1124  IF (PRESENT(categoryappend))THEN
1125  CALL init(this(i), time_definition=ltime_definition, categoryappend=trim(categoryappend)//"-vol"//t2c(i))
1126  ELSE
1127  CALL init(this(i), time_definition=ltime_definition, categoryappend="vol"//t2c(i))
1128  ENDIF
1129 ENDDO
1130 
1131 this(:)%griddim=pack_distinct(gridinfov%array(1:gridinfov%arraysize)%griddim, &
1132  ngrid, back=.true.)
1133 
1134 ! mark elements as ana variables (time-independent)
1135 ALLOCATE(isanavar(gridinfov%arraysize))
1136 isanavar(:) = .false.
1137 IF (PRESENT(anavar)) THEN
1138  DO i = 1, gridinfov%arraysize
1139  DO j = 1, SIZE(anavar)
1140  lvar = convert(gridinfov%array(i)%var)
1141  IF (lvar%btable == anavar(j)) THEN
1142  isanavar(i) = .true.
1143  EXIT
1144  ENDIF
1145  ENDDO
1146  ENDDO
1147  CALL l4f_category_log(category,l4f_info,t2c(count(isanavar))//'/'// &
1148  t2c(gridinfov%arraysize)//' constant-data messages found in input data')
1149 ENDIF
1150 
1151 IF (ltime_definition == 1 .OR. ltime_definition == 2) THEN ! verification time
1152  ALLOCATE(correctedtime(gridinfov%arraysize))
1153  correctedtime(:) = gridinfov%array(1:gridinfov%arraysize)%time
1154  DO i = 1, gridinfov%arraysize
1155  correctedtime(i) = correctedtime(i) + &
1156  timedelta_new(sec=gridinfov%array(i)%timerange%p1)
1157  ENDDO
1158 ENDIF
1159 IF (ltime_definition == 2) THEN ! set all to analysis
1160  ALLOCATE(correctedtimerange(gridinfov%arraysize))
1161  correctedtimerange(:) = gridinfov%array(1:gridinfov%arraysize)%timerange
1162  correctedtimerange(:)%p1 = 0
1163 ENDIF
1164 
1165 DO i = 1, ngrid
1166  IF (PRESENT(anavar)) THEN
1167  j = count((this(i)%griddim == gridinfov%array(1:gridinfov%arraysize)%griddim) &
1168  .AND. .NOT.isanavar(:))
1169  IF (j <= 0) THEN
1170  CALL l4f_category_log(category, l4f_fatal, 'grid n.'//t2c(i)// &
1171  ' has only constant data, this is not allowed')
1172  CALL l4f_category_log(category, l4f_fatal, 'please check anavar argument')
1173  CALL raise_fatal_error()
1174  ENDIF
1175  ENDIF
1176  IF (ltime_definition == 1 .OR. ltime_definition == 2) THEN ! verification time
1177  ntime = count_distinct(correctedtime, &

Generated with Doxygen.