libsim Versione 7.2.1

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

999#endif
1000 usetemplate = c_e(gaid)
1001ENDIF
1002
1003IF (.NOT.usetemplate) THEN
1004 IF (optio_log(clone)) THEN
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
1012ENDIF
1013
1014IF (this%time_definition == 1) THEN
1015 correctedtime = this%time(itime) - &
1016 timedelta_new(sec=this%timerange(itimerange)%p1)
1017ELSE
1018 correctedtime = this%time(itime)
1019ENDIF
1020
1021CALL 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
1025CALL export(gridinfo%griddim, gridinfo%gaid)
1026! encode the field
1027IF (ASSOCIATED(this%voldati)) THEN
1028 CALL encode_gridinfo(gridinfo, this%voldati(:,:,ilevel,itime,itimerange,ivar))
1029ELSE 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)
1034ENDIF
1035
1036END SUBROUTINE export_to_gridinfo
1037
1038
1056SUBROUTINE import_from_gridinfovv(this, gridinfov, dup_mode, clone, decode, &
1057 time_definition, anavar, categoryappend)
1058TYPE(volgrid6d),POINTER :: this(:)
1059TYPE(arrayof_gridinfo),INTENT(in) :: gridinfov
1060INTEGER,INTENT(in),OPTIONAL :: dup_mode
1061LOGICAL , INTENT(in),OPTIONAL :: clone
1062LOGICAL,INTENT(in),OPTIONAL :: decode
1063INTEGER,INTENT(IN),OPTIONAL :: time_definition
1064CHARACTER(len=*),INTENT(IN),OPTIONAL :: anavar(:)
1065CHARACTER(len=*),INTENT(in),OPTIONAL :: categoryappend
1066
1067INTEGER :: i, j, stallo
1068INTEGER :: ngrid, ntime, ntimerange, nlevel, nvar
1069INTEGER :: category
1070CHARACTER(len=512) :: a_name
1071TYPE(datetime),ALLOCATABLE :: correctedtime(:)
1072LOGICAL,ALLOCATABLE :: isanavar(:)
1073TYPE(vol7d_var) :: lvar
1074
1075! category temporanea (altrimenti non possiamo loggare)
1076if (present(categoryappend))then
1077 call l4f_launcher(a_name,a_name_append=trim(subcategory)//"."//trim(categoryappend))
1078else
1079 call l4f_launcher(a_name,a_name_append=trim(subcategory))
1080endif
1081category=l4f_category_get(a_name)
1082
1083#ifdef DEBUG
1084call l4f_category_log(category,l4f_debug,"start import_from_gridinfovv")
1085#endif
1086
1087ngrid=count_distinct(gridinfov%array(1:gridinfov%arraysize)%griddim,back=.true.)
1088CALL l4f_category_log(category,l4f_info, t2c(ngrid)// &
1089 ' different grid definition(s) found in input data')
1090
1091ALLOCATE(this(ngrid),stat=stallo)
1092IF (stallo /= 0)THEN
1093 CALL l4f_category_log(category,l4f_fatal,"allocating memory")
1094 CALL raise_fatal_error()
1095ENDIF
1096DO 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
1102ENDDO
1103
1104this(:)%griddim=pack_distinct(gridinfov%array(1:gridinfov%arraysize)%griddim, &
1105 ngrid, back=.true.)
1106
1107! mark elements as ana variables (time-independent)
1108ALLOCATE(isanavar(gridinfov%arraysize))
1109isanavar(:) = .false.
1110IF (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')
1122ENDIF
1123
1124! create time corrected for time_definition
1125ALLOCATE(correctedtime(gridinfov%arraysize))
1126correctedtime(:) = gridinfov%array(1:gridinfov%arraysize)%time
1127IF (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
1134ENDIF
1135
1136DO 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, &

Generated with Doxygen.