00001
00002
00003
00004
00005
00006
00007
00008
00009 SUBROUTINE get_regrid_details ( id_XML_doc, &
00010 cda_xpath, &
00011 id_nb_regrid, &
00012 sd_interp, &
00013 id_error )
00014
00015
00016
00017
00018
00019
00020
00021 USE PSMILe_smioc
00022 IMPLICIT NONE
00023
00024
00025
00026
00027
00028
00029
00030 INTEGER, INTENT(In) :: id_XML_doc
00031
00032
00033 CHARACTER(len=*), INTENT(In) :: cda_xpath
00034
00035
00036 INTEGER, INTENT(In) :: id_nb_regrid
00037
00038
00039 TYPE(PSMILe_interp), INTENT(InOut) :: sd_interp
00040
00041
00042 INTEGER, INTENT(Out):: id_error
00043
00044
00045 CHARACTER(LEN=max_name) :: cla_dimension, cla_method
00046
00047 INTEGER :: il_regridding
00048
00049 CHARACTER(LEN=max_name) :: cla_char
00050 INTEGER :: il_test, il_length
00051
00052 INTEGER :: sasa_c_get_number_3rd_level, sasa_c_get_number_4th_level
00053 INTEGER :: sasa_c_get_element_3rd_level_i
00054 INTEGER :: sasa_c_get_element_2nd_level_c , sasa_c_get_element_3rd_level_c
00055 INTEGER :: sasa_c_get_element_7th_level_c
00056 INTEGER :: sasa_c_get_element_3rd_level_d
00057 INTEGER :: sasa_c_get_attri_2nd_level
00058 INTEGER :: sasa_c_convert_char2int
00059
00060 #ifdef DEBUG
00061 print *, "LEN_TRIM(cda_xpath), cda_xpath", LEN_TRIM(cda_xpath), cda_xpath
00062 call psmile_flushstd
00063 #endif
00064
00065
00066 DO il_regridding = 1, id_nb_regrid
00067
00068
00069 cla_dimension = ' '
00070 id_error = &
00071 sasa_c_get_attri_2nd_level (id_XML_doc, cda_xpath, 0, "spatialRegridding", il_regridding, &
00072 "spatialRegriddingDimension", cla_dimension, il_length)
00073
00074
00075
00076 cla_method = ' '
00077 id_error = &
00078 sasa_c_get_element_2nd_level_c (id_XML_doc, cda_xpath, 0, "spatialRegridding", il_regridding, &
00079 "spatialRegriddingStandardMethod", 0, cla_method, il_length)
00080
00081 if (il_length == 0) then
00082
00083 id_error = &
00084 sasa_c_get_number_3rd_level (id_XML_doc, cda_xpath, 0, "spatialRegridding", il_regridding, &
00085 "spatialRegriddingUserMethod", il_test)
00086 if (il_test == 0) then
00087 PRINT *, '**************************'
00088 PRINT *, 'Regridding method missing '
00089 PRINT *, '**************************'
00090 CALL PSMILe_Flushstd
00091 CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00092 endif
00093 endif
00094
00095
00096 IF (cla_dimension .eq. "3D" .or. cla_dimension .eq. "3d") THEN
00097
00098 sd_interp%ig_interp_type = PSMILe_3D
00099
00100
00101 IF (cla_method .eq. "near-neighbour") THEN
00102
00103 sd_interp%iga_interp_meth(1) = PSMILe_nnghbr3D
00104
00105
00106 cla_char = ' '
00107 id_error = &
00108 sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0, &
00109 "spatialRegridding", il_regridding, &
00110 'SpatialRegriddingProperty[name="para_search"]', 0, "value", 0, &
00111 cla_char, il_length)
00112
00113 IF (il_length == 0) THEN
00114 #ifdef VERBOSE
00115 PRINT *, '*******************************************'
00116 PRINT *, 'Type of search for nneighbour3D missing '
00117 PRINT *, 'Default value PSMILe_global will be used '
00118 PRINT *, '*******************************************'
00119 #endif
00120 sd_interp%iga_arg3(1) = PSMILe_global
00121 ELSE
00122 sd_interp%iga_arg3(1) = sasa_c_convert_char2int(cla_char(1:il_length))
00123 ENDIF
00124
00125
00126 il_test = 0
00127
00128 id_error = &
00129 sasa_c_get_number_4th_level (id_XML_doc, cda_xpath, 0, &
00130 "spatialRegridding", il_regridding, &
00131 'SpatialRegriddingProperty[name="nbr_neighbours"]', 0, "value", &
00132 il_test)
00133
00134 IF (il_test == 0) THEN
00135 PRINT *, '*******************************************'
00136 PRINT *, 'nbr_neighbours must be specified'
00137 PRINT *, 'for nneighbour3D interpolation'
00138 PRINT *, '*******************************************'
00139 CALL PSMILe_Flushstd
00140 CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00141 ELSE
00142 id_error = &
00143 sasa_c_get_element_3rd_level_i (id_XML_doc, cda_xpath, 0, &
00144 "spatialRegridding", il_regridding, &
00145 'SpatialRegriddingProperty[name="nbr_neighbours"]', 0, "value", 0, &
00146 sd_interp%iga_arg2(1))
00147 ENDIF
00148
00149
00150 id_error = &
00151 sasa_c_get_element_3rd_level_d (id_XML_doc, cda_xpath, 0, &
00152 "spatialRegridding", il_regridding, &
00153 'SpatialRegriddingProperty[name="gaussian_variance"]', 0, &
00154 "value", 0, sd_interp%dg_arg8)
00155
00156
00157 cla_char = ' '
00158 id_error = &
00159 sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0, &
00160 "spatialRegridding", il_regridding, &
00161 'SpatialRegriddingProperty[name="if_masked"]', 0, "value", 0, &
00162 cla_char, il_length)
00163
00164 IF (il_length .ne. 0) THEN
00165 sd_interp%iga_arg4(1) = sasa_c_convert_char2int(cla_char(1:il_length))
00166
00167 IF (sd_interp%iga_arg4(1) /= PSMILE_novalue) THEN
00168 PRINT *, '********************************************'
00169 PRINT *, 'Only novalue is implemented for if_masked'
00170 PRINT *, 'for nneighbour3D interpolation'
00171 PRINT *, '********************************************'
00172 CALL PSMILe_Flushstd
00173 CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00174 END IF
00175 ENDIF
00176
00177
00178 ELSE IF (cla_method .eq. "linear") THEN
00179
00180 sd_interp%iga_interp_meth(1) = PSMILe_trilinear
00181
00182
00183 cla_char = ' '
00184 id_error = &
00185 sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0, &
00186 "spatialRegridding", il_regridding, &
00187 'SpatialRegriddingProperty[name="para_search"]', 0, "value", 0, &
00188 cla_char, il_length)
00189
00190 IF (il_length == 0) THEN
00191 #ifdef VERBOSE
00192 PRINT *, '*******************************************'
00193 PRINT *, 'Type of search for trilinear missing '
00194 PRINT *, 'Default value PSMILe_global will be used '
00195 PRINT *, '*******************************************'
00196 #endif
00197 sd_interp%iga_arg3(1) = PSMILe_global
00198 ELSE
00199 sd_interp%iga_arg3(1) = sasa_c_convert_char2int(cla_char(1:il_length))
00200 ENDIF
00201
00202
00203 cla_char = ' '
00204 id_error = &
00205 sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0, &
00206 "spatialRegridding", il_regridding, &
00207 'SpatialRegriddingProperty[name="if_masked"]', 0, "value", 0, &
00208 cla_char, il_length)
00209
00210 IF (il_length == 0) THEN
00211 PRINT *, '********************************************'
00212 PRINT *, 'if_masked must be specified'
00213 PRINT *, 'for trilinear interpolation'
00214 PRINT *, '********************************************'
00215 CALL PSMILe_Flushstd
00216
00217 CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00218 ELSE
00219 sd_interp%iga_arg4(1) = sasa_c_convert_char2int(cla_char(1:il_length))
00220 ENDIF
00221
00222
00223 ELSE IF ( cla_method .eq. "conservative-first-order" &
00224 .OR. cla_method .eq. "conservative-second-order" ) THEN
00225
00226 PRINT *, '******************************************************'
00227 PRINT *, 'The 3D conservative interpolation is not yet supported'
00228 PRINT *, '******************************************************'
00229 CALL PSMILe_Flushstd
00230
00231 CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00232
00233
00234 ELSE
00235
00236 sd_interp%iga_interp_meth(1) = PSMILe_user3D
00237
00238 id_error = &
00239 sasa_c_get_element_7th_level_c (id_XML_doc, cda_xpath, 0, &
00240 "spatialRegridding", il_regridding, &
00241 "SpatialRegriddingUserMethod", 0, "file", 0, "dataObject", 0, &
00242 "storage", 0, "fileStorage", 0, "fileName", 0, &
00243 cla_char, il_length)
00244 sd_interp%sg_arg10%cg_file_name = cla_char(1:il_length)
00245 ENDIF
00246
00247
00248 ELSE IF (cla_dimension .eq. "2D" .or. cla_dimension .eq. "2d") THEN
00249 sd_interp%ig_interp_type = PSMILe_2D1D
00250
00251
00252 IF (cla_method .eq. "near-neighbour") THEN
00253
00254 sd_interp%iga_interp_meth(1) = PSMILe_nnghbr2D
00255
00256
00257 cla_char = ' '
00258 id_error = &
00259 sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0, &
00260 "spatialRegridding", il_regridding, &
00261 'SpatialRegriddingProperty[name="para_search"]', 0, "value", 0, &
00262 cla_char, il_length)
00263
00264 IF (il_length == 0) THEN
00265 #ifdef VERBOSE
00266 PRINT *, '*******************************************'
00267 PRINT *, 'Type of search for nneighbour2D missing '
00268 PRINT *, 'Default value PSMILe_global will be used '
00269 PRINT *, '*******************************************'
00270 #endif
00271 sd_interp%iga_arg3(1) = PSMILe_global
00272 ELSE
00273 sd_interp%iga_arg3(1) = sasa_c_convert_char2int(cla_char(1:il_length))
00274 ENDIF
00275
00276
00277 il_test = 0
00278
00279 id_error = &
00280 sasa_c_get_number_4th_level (id_XML_doc, cda_xpath, 0, &
00281 "spatialRegridding", il_regridding, &
00282 'SpatialRegriddingProperty[name="nbr_neighbours"]', 0, "value", &
00283 il_test)
00284
00285 IF (il_test == 0) THEN
00286 PRINT *, '*******************************************'
00287 PRINT *, 'nbr_neighbours must be specified'
00288 PRINT *, 'for nneighbour2D interpolation'
00289 PRINT *, '*******************************************'
00290 CALL PSMILe_Flushstd
00291 CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00292 ELSE
00293 id_error = &
00294 sasa_c_get_element_3rd_level_i (id_XML_doc, cda_xpath, 0, &
00295 "spatialRegridding", il_regridding, &
00296 'SpatialRegriddingProperty[name="nbr_neighbours"]', 0, "value", 0, &
00297 sd_interp%iga_arg2(1))
00298 ENDIF
00299
00300
00301 id_error = &
00302 sasa_c_get_element_3rd_level_d (id_XML_doc, cda_xpath, 0, &
00303 "spatialRegridding", il_regridding, &
00304 'SpatialRegriddingProperty[name="gaussian_variance"]', 0, &
00305 "value", 0, sd_interp%dg_arg8)
00306
00307
00308 cla_char = ' '
00309 id_error = &
00310 sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0, &
00311 "spatialRegridding", il_regridding, &
00312 'SpatialRegriddingProperty[name="if_masked"]', 0, "value", 0, &
00313 cla_char, il_length)
00314
00315 IF (il_length .ne. 0) THEN
00316 sd_interp%iga_arg4(1) = sasa_c_convert_char2int(cla_char(1:il_length))
00317
00318 IF (sd_interp%iga_arg4(1) /= PSMILE_novalue) THEN
00319 PRINT *, '********************************************'
00320 PRINT *, 'Only novalue is implemented for if_masked'
00321 PRINT *, 'for nneighbour3D interpolation'
00322 PRINT *, '********************************************'
00323 CALL PSMILe_Flushstd
00324 CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00325 END IF
00326 ENDIF
00327
00328
00329 ELSE IF (cla_method .eq. "linear") THEN
00330
00331 sd_interp%iga_interp_meth(1) = PSMILe_bilinear
00332
00333
00334 cla_char = ' '
00335 id_error = &
00336 sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0, &
00337 "spatialRegridding", il_regridding, &
00338 'SpatialRegriddingProperty[name="para_search"]', 0, "value", 0, &
00339 cla_char, il_length)
00340
00341 IF (il_length == 0) THEN
00342 #ifdef VERBOSE
00343 PRINT *, '*******************************************'
00344 PRINT *, 'Type of search for bilinear missing '
00345 PRINT *, 'Default value PSMILe_global will be used '
00346 PRINT *, '*******************************************'
00347 #endif
00348 sd_interp%iga_arg3(1) = PSMILe_global
00349 ELSE
00350 sd_interp%iga_arg3(1) = sasa_c_convert_char2int(cla_char(1:il_length))
00351 ENDIF
00352
00353
00354 cla_char = ' '
00355 id_error = &
00356 sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0, &
00357 "spatialRegridding", il_regridding, &
00358 'SpatialRegriddingProperty[name="if_masked"]', 0, "value", 0, &
00359 cla_char, il_length)
00360
00361 IF (il_length == 0) THEN
00362 PRINT *, '********************************************'
00363 PRINT *, 'if_masked must be specified'
00364 PRINT *, 'for bilinear interpolation'
00365 PRINT *, '********************************************'
00366 CALL PSMILe_Flushstd
00367
00368 CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00369 ELSE
00370 sd_interp%iga_arg4(1) = sasa_c_convert_char2int(cla_char(1:il_length))
00371 ENDIF
00372
00373
00374 ELSE IF (cla_method .eq. "cubic") THEN
00375
00376 sd_interp%iga_interp_meth(1) = PSMILe_bicubic
00377
00378
00379 cla_char = ' '
00380 id_error = &
00381 sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0, &
00382 "spatialRegridding", il_regridding, &
00383 'SpatialRegriddingProperty[name="para_search"]', 0, "value", 0, &
00384 cla_char, il_length)
00385
00386 IF (il_length == 0) THEN
00387 #ifdef VERBOSE
00388 PRINT *, '*******************************************'
00389 PRINT *, 'Type of search for bicubic missing '
00390 PRINT *, 'Default value PSMILe_global will be used '
00391 PRINT *, '*******************************************'
00392 #endif
00393 sd_interp%iga_arg3(1) = PSMILe_global
00394 ELSE
00395 sd_interp%iga_arg3(1) = sasa_c_convert_char2int(cla_char(1:il_length))
00396 ENDIF
00397
00398
00399 cla_char = ' '
00400 id_error = &
00401 sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0, &
00402 "spatialRegridding", il_regridding, &
00403 'SpatialRegriddingProperty[name="if_masked"]', 0, "value", 0, &
00404 cla_char, il_length)
00405
00406 IF (il_length == 0) THEN
00407 PRINT *, '********************************************'
00408 PRINT *, 'if_masked must be specified'
00409 PRINT *, 'for bicubic interpolation'
00410 PRINT *, '********************************************'
00411 CALL PSMILe_Flushstd
00412
00413 CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00414 ELSE
00415 sd_interp%iga_arg4(1) = sasa_c_convert_char2int(cla_char(1:il_length))
00416 ENDIF
00417
00418
00419 cla_char = ' '
00420 id_error = &
00421 sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0, &
00422 "spatialRegridding", il_regridding, &
00423 'SpatialRegriddingProperty[name="bicubic_method"]', 0, "value", 0, &
00424 cla_char, il_length)
00425
00426 IF (il_length == 0) THEN
00427 PRINT *, '********************************************'
00428 PRINT *, 'bicubic_method must be specified'
00429 PRINT *, 'for bicubic interpolation'
00430 PRINT *, '********************************************'
00431 CALL PSMILe_Flushstd
00432
00433 CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00434 ELSE
00435 sd_interp%iga_arg5(1) = sasa_c_convert_char2int(cla_char(1:il_length))
00436 ENDIF
00437
00438
00439 ELSE IF ( cla_method .eq. "conservative-first-order" &
00440 .or. cla_method .eq. "conservative-second-order") THEN
00441
00442 sd_interp%iga_interp_meth(1) = PSMILe_conserv2D
00443
00444 IF (cla_method .eq. "conservative-first-order") THEN
00445 sd_interp%iga_arg2(1) = PSMILe_first
00446 ELSE
00447 sd_interp%iga_arg2(1) = PSMILe_second
00448 ENDIF
00449
00450
00451 cla_char = ' '
00452 id_error = &
00453 sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0, &
00454 "spatialRegridding", il_regridding, &
00455 'SpatialRegriddingProperty[name="para_search"]', 0, "value", 0, &
00456 cla_char, il_length)
00457
00458 IF (il_length == 0) THEN
00459 #ifdef VERBOSE
00460 PRINT *, '*******************************************'
00461 PRINT *, 'Type of search for conservative 2D missing '
00462 PRINT *, 'Default value PSMILe_global will be used '
00463 PRINT *, '*******************************************'
00464 #endif
00465 sd_interp%iga_arg3(1) = PSMILe_global
00466 ELSE
00467 sd_interp%iga_arg3(1) = sasa_c_convert_char2int(cla_char(1:il_length))
00468 ENDIF
00469
00470
00471 cla_char = ' '
00472 id_error = &
00473 sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0, &
00474 "spatialRegridding", il_regridding, &
00475 'SpatialRegriddingProperty[name="normalisation2D"]', 0, "value", 0, &
00476 cla_char, il_length)
00477
00478 IF (il_length == 0) THEN
00479 PRINT *, '********************************************'
00480 PRINT *, 'No normalisation options for conservative 2D '
00481 PRINT *, 'By default, no normalisation will be applied '
00482 PRINT *, '********************************************'
00483 sd_interp%iga_arg4(1) = PSMILe_none
00484 sd_interp%iga_arg5(1) = PSMILe_false
00485 ELSE
00486 sd_interp%iga_arg4(1) = sasa_c_convert_char2int(cla_char(1:il_length))
00487
00488 sd_interp%iga_arg5(1) = PSMILe_false
00489 IF (sd_interp%iga_arg4(1) == PSMILe_undef) THEN
00490 PRINT *, '*****************************************************'
00491 PRINT *, 'Normalisation method for conservative 2D is not known'
00492 PRINT *, '*****************************************************'
00493 CALL PSMILe_Flushstd
00494 CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00495 ENDIF
00496 ENDIF
00497
00498 ELSE IF (cla_method == ' ') THEN
00499 PRINT *, '*****************************************************'
00500 PRINT *, 'User defined interpolation in 2D is not yet supported'
00501 PRINT *, '*****************************************************'
00502 CALL PSMILe_Flushstd
00503 CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00504 ENDIF
00505
00506
00507 if (id_nb_regrid == 1) then
00508
00509 sd_interp%iga_interp_meth(2) = PSMILe_none
00510 endif
00511
00512
00513 ELSE IF (cla_dimension .eq. "1D" .or. cla_dimension .eq. "1d") THEN
00514
00515
00516 IF (cla_method .eq. "linear") THEN
00517 sd_interp%iga_interp_meth(2) = PSMILe_linear
00518 ELSE
00519 sd_interp%iga_interp_meth(2) = PSMILe_none
00520 ENDIF
00521 ENDIF
00522
00523 ENDDO
00524
00525 END SUBROUTINE get_regrid_details
00526
00527
00528