libsim  Versione6.3.0

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

1027 ! reset the gridinfo, bad but necessary at this point for encoding the field
1028 CALL export(gridinfo%griddim, gridinfo%gaid)
1029 ! encode the field
1030 IF (ASSOCIATED(this%voldati)) THEN
1031  CALL encode_gridinfo(gridinfo, this%voldati(:,:,ilevel,itime,itimerange,ivar))
1032 ELSE IF (usetemplate) THEN ! field must be forced into template in this case
1033  NULLIFY(voldati)
1034  CALL volgrid_get_vol_2d(this, ilevel, itime, itimerange, ivar, voldati)
1035  CALL encode_gridinfo(gridinfo, voldati)
1036  DEALLOCATE(voldati)
1037 ENDIF
1038 
1039 END SUBROUTINE export_to_gridinfo
1040 
1041 
1059 SUBROUTINE import_from_gridinfovv(this, gridinfov, dup_mode, clone, decode, &
1060  time_definition, anavar, categoryappend)
1061 TYPE(volgrid6d),POINTER :: this(:)
1062 TYPE(arrayof_gridinfo),INTENT(in) :: gridinfov
1063 INTEGER,INTENT(in),OPTIONAL :: dup_mode
1064 LOGICAL , INTENT(in),OPTIONAL :: clone
1065 LOGICAL,INTENT(in),OPTIONAL :: decode
1066 INTEGER,INTENT(IN),OPTIONAL :: time_definition
1067 CHARACTER(len=*),INTENT(IN),OPTIONAL :: anavar(:) !< list of variables (B-table code equivalent) to be treated as time-independent data
1068 CHARACTER(len=*),INTENT(in),OPTIONAL :: categoryappend !< append this suffix to log4fortran namespace category
1069 
1070 INTEGER :: i, j, stallo
1071 INTEGER :: ngrid, ntime, ntimerange, nlevel, nvar
1072 INTEGER :: category
1073 CHARACTER(len=512) :: a_name
1074 TYPE(datetime),ALLOCATABLE :: correctedtime(:)
1075 LOGICAL,ALLOCATABLE :: isanavar(:)
1076 TYPE(vol7d_var) :: lvar
1077 
1078 ! category temporanea (altrimenti non possiamo loggare)
1079 if (present(categoryappend))then
1080  call l4f_launcher(a_name,a_name_append=trim(subcategory)//"."//trim(categoryappend))
1081 else
1082  call l4f_launcher(a_name,a_name_append=trim(subcategory))
1083 endif
1084 category=l4f_category_get(a_name)
1085 
1086 #ifdef DEBUG
1087 call l4f_category_log(category,L4F_DEBUG,"start import_from_gridinfovv")
1088 #endif
1089 
1090 ngrid=count_distinct(gridinfov%array(1:gridinfov%arraysize)%griddim,back=.true.)
1091 CALL l4f_category_log(category,L4F_INFO, t2c(ngrid)// &
1092  ' different grid definition(s) found in input data')
1093 
1094 ALLOCATE(this(ngrid),stat=stallo)
1095 IF (stallo /= 0)THEN
1096  CALL l4f_category_log(category,l4f_fatal,"allocating memory")
1097  CALL raise_fatal_error()
1098 ENDIF
1099 DO i = 1, ngrid
1100  IF (PRESENT(categoryappend))THEN
1101  CALL init(this(i), time_definition=time_definition, categoryappend=trim(categoryappend)//"-vol"//t2c(i))
1102  ELSE
1103  CALL init(this(i), time_definition=time_definition, categoryappend="vol"//t2c(i))
1104  ENDIF
1105 ENDDO
1106 
1107 this(:)%griddim=pack_distinct(gridinfov%array(1:gridinfov%arraysize)%griddim, &
1108  ngrid, back=.true.)
1109 
1110 ! mark elements as ana variables (time-independent)
1111 ALLOCATE(isanavar(gridinfov%arraysize))
1112 isanavar(:) = .false.
1113 IF (PRESENT(anavar)) THEN
1114  DO i = 1, gridinfov%arraysize
1115  DO j = 1, SIZE(anavar)
1116  lvar = convert(gridinfov%array(i)%var)
1117  IF (lvar%btable == anavar(j)) THEN
1118  isanavar(i) = .true.
1119  EXIT
1120  ENDIF
1121  ENDDO
1122  ENDDO
1123  CALL l4f_category_log(category,l4f_info,t2c(count(isanavar))//'/'// &
1124  t2c(gridinfov%arraysize)//' constant-data messages found in input data')
1125 ENDIF
1126 
1127 ! create time corrected for time_definition
1128 ALLOCATE(correctedtime(gridinfov%arraysize))
1129 correctedtime(:) = gridinfov%array(1:gridinfov%arraysize)%time
1130 IF (PRESENT(time_definition)) THEN
1131  IF (time_definition == 1) THEN
1132  DO i = 1, gridinfov%arraysize
1133  correctedtime(i) = correctedtime(i) + &
1134  timedelta_new(sec=gridinfov%array(i)%timerange%p1)
1135  ENDDO
1136  ENDIF
1137 ENDIF
1138 
1139 DO i = 1, ngrid
1140  IF (PRESENT(anavar)) THEN
1141  j = count((this(i)%griddim == gridinfov%array(1:gridinfov%arraysize)%griddim) &
1142  .AND. .NOT.isanavar(:))
1143  IF (j <= 0) THEN
1144  CALL l4f_category_log(category, l4f_fatal, 'grid n.'//t2c(i)// &
1145  ' has only constant data, this is not allowed')
1146  CALL l4f_category_log(category, l4f_fatal, 'please check anavar argument')
1147  CALL raise_fatal_error()
1148  ENDIF
1149  ENDIF
1150  ntime = count_distinct(correctedtime, &
1151  mask=(this(i)%griddim == gridinfov%array(1:gridinfov%arraysize)%griddim) &
1152  .AND. .NOT.isanavar(:), back=.true.)
1153  ntimerange = count_distinct(gridinfov%array(1:gridinfov%arraysize)%timerange, &
1154  mask=(this(i)%griddim == gridinfov%array(1:gridinfov%arraysize)%griddim) &
1155  .AND. .NOT.isanavar(:), back=.true.)
1156  nlevel = count_distinct(gridinfov%array(1:gridinfov%arraysize)%level, &
1157  mask=(this(i)%griddim == gridinfov%array(1:gridinfov%arraysize)%griddim), &
1158  back=.true.)
1159  nvar = count_distinct(gridinfov%array(1:gridinfov%arraysize)%var, &
1160  mask=(this(i)%griddim == gridinfov%array(1:gridinfov%arraysize)%griddim), &
1161  back=.true.)
1162 
1163 #ifdef DEBUG
1164  CALL l4f_category_log(this(i)%category,l4f_debug,"alloc volgrid6d index: "//t2c(i))
1165 #endif
1166 
1167  CALL volgrid6d_alloc(this(i),this(i)%griddim%dim,ntime=ntime, &
1168  ntimerange=ntimerange,nlevel=nlevel,nvar=nvar)
1169 
1170  this(i)%time = pack_distinct(correctedtime, ntime, &
1171  mask=(this(i)%griddim == gridinfov%array(1:gridinfov%arraysize)%griddim) &
1172  .AND. .NOT.isanavar(:), back=.true.)
1173  CALL sort(this(i)%time)
1174 
1175  this(i)%timerange = pack_distinct(gridinfov%array( &
Functions that return a trimmed CHARACTER representation of the input variable.
Costruttori per le classi datetime e timedelta.

Generated with Doxygen.