libsim  Versione 7.1.7

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

1005  CALL copy(this%gaid(ilevel,itime,itimerange,ivar), gaid)
1006 #ifdef DEBUG
1007  CALL l4f_category_log(this%category,l4f_debug,"original gaid cloned to a new one")
1008 #endif
1009  ELSE
1010  gaid = this%gaid(ilevel,itime,itimerange,ivar)
1011  ENDIF
1012 ENDIF
1013 
1014 IF (this%time_definition == 1) THEN
1015  correctedtime = this%time(itime) - &
1016  timedelta_new(sec=this%timerange(itimerange)%p1)
1017 ELSE
1018  correctedtime = this%time(itime)
1019 ENDIF
1020 
1021 CALL init(gridinfo,gaid, this%griddim, correctedtime, this%timerange(itimerange), &
1022  this%level(ilevel), this%var(ivar))
1023 
1024 ! reset the gridinfo, bad but necessary at this point for encoding the field
1025 CALL export(gridinfo%griddim, gridinfo%gaid)
1026 ! encode the field
1027 IF (ASSOCIATED(this%voldati)) THEN
1028  CALL encode_gridinfo(gridinfo, this%voldati(:,:,ilevel,itime,itimerange,ivar))
1029 ELSE IF (usetemplate) THEN ! field must be forced into template in this case
1030  NULLIFY(voldati)
1031  CALL volgrid_get_vol_2d(this, ilevel, itime, itimerange, ivar, voldati)
1032  CALL encode_gridinfo(gridinfo, voldati)
1033  DEALLOCATE(voldati)
1034 ENDIF
1035 
1036 END SUBROUTINE export_to_gridinfo
1037 
1038 
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
1066 
1067 INTEGER :: i, j, stallo
1068 INTEGER :: ngrid, ntime, ntimerange, nlevel, nvar
1069 INTEGER :: category
1070 CHARACTER(len=512) :: a_name
1071 TYPE(datetime),ALLOCATABLE :: correctedtime(:)
1072 LOGICAL,ALLOCATABLE :: isanavar(:)
1073 TYPE(vol7d_var) :: lvar
1074 
1075 ! category temporanea (altrimenti non possiamo loggare)
1076 if (present(categoryappend))then
1077  call l4f_launcher(a_name,a_name_append=trim(subcategory)//"."//trim(categoryappend))
1078 else
1079  call l4f_launcher(a_name,a_name_append=trim(subcategory))
1080 endif
1081 category=l4f_category_get(a_name)
1082 
1083 #ifdef DEBUG
1084 call l4f_category_log(category,l4f_debug,"start import_from_gridinfovv")
1085 #endif
1086 
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')
1090 
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()
1095 ENDIF
1096 DO i = 1, ngrid
1097  IF (PRESENT(categoryappend))THEN
1098  CALL init(this(i), time_definition=time_definition, categoryappend=trim(categoryappend)//"-vol"//t2c(i))
1099  ELSE
1100  CALL init(this(i), time_definition=time_definition, categoryappend="vol"//t2c(i))
1101  ENDIF
1102 ENDDO
1103 
1104 this(:)%griddim=pack_distinct(gridinfov%array(1:gridinfov%arraysize)%griddim, &
1105  ngrid, back=.true.)
1106 
1107 ! mark elements as ana variables (time-independent)
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.
1116  EXIT
1117  ENDIF
1118  ENDDO
1119  ENDDO
1120  CALL l4f_category_log(category,l4f_info,t2c(count(isanavar))//'/'// &
1121  t2c(gridinfov%arraysize)//' constant-data messages found in input data')
1122 ENDIF
1123 
1124 ! create time corrected for time_definition
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)
1132  ENDDO
1133  ENDIF
1134 ENDIF
1135 
1136 DO i = 1, ngrid
1137  IF (PRESENT(anavar)) THEN
1138  j = count((this(i)%griddim == gridinfov%array(1:gridinfov%arraysize)%griddim) &
1139  .AND. .NOT.isanavar(:))
1140  IF (j <= 0) THEN
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()
1145  ENDIF
1146  ENDIF
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, &

Generated with Doxygen.