libsim  Versione7.2.6

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

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
1027 ENDIF
1028 
1029 IF (this%time_definition == 1 .OR. this%time_definition == 2) THEN
1030  correctedtime = this%time(itime) - &
1031  timedelta_new(sec=this%timerange(itimerange)%p1)
1032 ELSE
1033  correctedtime = this%time(itime)
1034 ENDIF
1035 
1036 CALL 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
1040 CALL export(gridinfo%griddim, gridinfo%gaid)
1041 ! encode the field
1042 IF (ASSOCIATED(this%voldati)) THEN
1043  CALL encode_gridinfo(gridinfo, this%voldati(:,:,ilevel,itime,itimerange,ivar))
1044 ELSE 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)
1049 ENDIF
1050 
1051 END SUBROUTINE export_to_gridinfo
1052 
1053 
1071 SUBROUTINE import_from_gridinfovv(this, gridinfov, dup_mode, clone, decode, &
1072  time_definition, anavar, categoryappend)
1073 TYPE(volgrid6d),POINTER :: this(:)
1074 TYPE(arrayof_gridinfo),INTENT(in) :: gridinfov
1075 INTEGER,INTENT(in),OPTIONAL :: dup_mode
1076 LOGICAL , INTENT(in),OPTIONAL :: clone
1077 LOGICAL,INTENT(in),OPTIONAL :: decode
1078 INTEGER,INTENT(IN),OPTIONAL :: time_definition
1079 CHARACTER(len=*),INTENT(IN),OPTIONAL :: anavar(:)
1080 CHARACTER(len=*),INTENT(in),OPTIONAL :: categoryappend
1081 
1082 INTEGER :: i, j, stallo
1083 INTEGER :: ngrid, ntime, ntimerange, nlevel, nvar, ltime_definition
1084 INTEGER :: category
1085 CHARACTER(len=512) :: a_name
1086 TYPE(datetime),ALLOCATABLE :: correctedtime(:)
1087 LOGICAL,ALLOCATABLE :: isanavar(:)
1088 TYPE(vol7d_var) :: lvar
1089 TYPE(vol7d_timerange),ALLOCATABLE :: correctedtimerange(:)
1090 
1091 ! category temporanea (altrimenti non possiamo loggare)
1092 if (present(categoryappend))then
1093  call l4f_launcher(a_name,a_name_append=trim(subcategory)//"."//trim(categoryappend))
1094 else
1095  call l4f_launcher(a_name,a_name_append=trim(subcategory))
1096 endif
1097 category=l4f_category_get(a_name)
1098 
1099 #ifdef DEBUG
1100 call l4f_category_log(category,l4f_debug,"start import_from_gridinfovv")
1101 #endif
1102 
1103 IF (PRESENT(time_definition)) THEN
1104  ltime_definition = max(min(time_definition, 2), 0)
1105 ELSE
1106  ltime_definition = 0
1107 ENDIF
1108 
1109 ngrid=count_distinct(gridinfov%array(1:gridinfov%arraysize)%griddim,back=.true.)
1110 CALL l4f_category_log(category,l4f_info, t2c(ngrid)// &
1111  ' different grid definition(s) found in input data')
1112 
1113 ALLOCATE(this(ngrid),stat=stallo)
1114 IF (stallo /= 0)THEN
1115  CALL l4f_category_log(category,l4f_fatal,"allocating memory")
1116  CALL raise_fatal_error()
1117 ENDIF
1118 DO 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
1124 ENDDO
1125 
1126 this(:)%griddim=pack_distinct(gridinfov%array(1:gridinfov%arraysize)%griddim, &
1127  ngrid, back=.true.)
1128 
1129 ! mark elements as ana variables (time-independent)
1130 ALLOCATE(isanavar(gridinfov%arraysize))
1131 isanavar(:) = .false.
1132 IF (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')
1144 ENDIF
1145 
1146 IF (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
1153 ENDIF
1154 IF (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
1158 ENDIF
1159 
1160 DO i = 1, ngrid
1161  IF (PRESENT(anavar)) THEN
1162  j = count((this(i)%griddim == gridinfov%array(1:gridinfov%arraysize)%griddim) &
1163  .AND. .NOT.isanavar(:))
1164  IF (j <= 0) THEN
1165  CALL l4f_category_log(category, l4f_fatal, 'grid n.'//t2c(i)// &
1166  ' has only constant data, this is not allowed')
1167  CALL l4f_category_log(category, l4f_fatal, 'please check anavar argument')
1168  CALL raise_fatal_error()
1169  ENDIF
1170  ENDIF
1171  IF (ltime_definition == 1 .OR. ltime_definition == 2) THEN ! verification time
1172  ntime = count_distinct(correctedtime, &

Generated with Doxygen.