@@ -851,11 +851,12 @@ subroutine interp(localpet)
851
851
if (localpet == 0 ) then
852
852
where (mask_target_one_tile == 1 ) mask_target_one_tile = 0
853
853
where (mask_target_one_tile == 2 ) mask_target_one_tile = 1
854
+ call search_many(num_fields,bundle_seaice_target,tile, search_nums,localpet, &
855
+ mask= mask_target_one_tile)
856
+ else
857
+ call search_many(num_fields,bundle_seaice_target, tile,search_nums,localpet)
854
858
endif
855
859
856
-
857
- call search_many(num_fields,bundle_seaice_target,data_one_tile, mask_target_one_tile,tile,search_nums,localpet, &
858
- field_data_3d= data_one_tile_3d)
859
860
enddo
860
861
861
862
deallocate (search_nums)
@@ -977,10 +978,12 @@ subroutine interp(localpet)
977
978
allocate (water_target_one_tile(i_target,j_target))
978
979
water_target_one_tile = 0
979
980
where (mask_target_one_tile == 0 ) water_target_one_tile = 1
980
- endif
981
981
982
- call search_many(num_fields,bundle_water_target,data_one_tile, water_target_one_tile,&
983
- tile,search_nums,localpet,latitude= latitude_one_tile)
982
+ call search_many(num_fields,bundle_water_target, tile,search_nums,localpet, &
983
+ latitude= latitude_one_tile,mask= water_target_one_tile)
984
+ else
985
+ call search_many(num_fields,bundle_water_target, tile,search_nums,localpet)
986
+ endif
984
987
985
988
if (localpet == 0 ) deallocate (water_target_one_tile)
986
989
@@ -1068,10 +1071,12 @@ subroutine interp(localpet)
1068
1071
allocate (land_target_one_tile(i_target,j_target))
1069
1072
land_target_one_tile = 0
1070
1073
where (mask_target_one_tile == 1 ) land_target_one_tile = 1
1071
- endif
1072
1074
1073
- call search_many(num_fields,bundle_allland_target,data_one_tile, land_target_one_tile,&
1074
- tile,search_nums,localpet)
1075
+ call search_many(num_fields,bundle_allland_target, &
1076
+ tile,search_nums,localpet, mask= land_target_one_tile)
1077
+ else
1078
+ call search_many(num_fields,bundle_allland_target, tile,search_nums,localpet)
1079
+ endif
1075
1080
1076
1081
if (localpet == 0 ) deallocate (land_target_one_tile)
1077
1082
enddo
@@ -1202,8 +1207,12 @@ subroutine interp(localpet)
1202
1207
if (ESMF_logFoundError(rcToCheck= rc,msg= ESMF_LOGERR_PASSTHRU,line= __LINE__,file= __FILE__)) &
1203
1208
call error_handler(" IN FieldGather" , rc)
1204
1209
1205
- call search_many(num_fields,bundle_landice_target,data_one_tile, land_target_one_tile,&
1206
- tile,search_nums,localpet,terrain_land= data_one_tile2,field_data_3d= data_one_tile_3d)
1210
+ if (localpet== 0 ) then
1211
+ call search_many(num_fields,bundle_landice_target,tile,search_nums,localpet,&
1212
+ terrain_land= data_one_tile2,mask= land_target_one_tile)
1213
+ else
1214
+ call search_many(num_fields,bundle_landice_target,tile,search_nums,localpet)
1215
+ endif
1207
1216
enddo
1208
1217
1209
1218
deallocate (veg_type_target_one_tile)
@@ -1416,9 +1425,12 @@ subroutine interp(localpet)
1416
1425
call ESMF_FieldGather(soil_type_target_grid, data_one_tile2, rootPet= 0 ,tile= tile, rc= rc)
1417
1426
if (ESMF_logFoundError(rcToCheck= rc,msg= ESMF_LOGERR_PASSTHRU,line= __LINE__,file= __FILE__))&
1418
1427
call error_handler(" IN FieldGather" , rc)
1419
-
1420
- call search_many(num_fields,bundle_nolandice_target,data_one_tile, mask_target_one_tile,&
1421
- tile,search_nums,localpet,soilt_climo= data_one_tile2, field_data_3d= data_one_tile_3d)
1428
+ if (localpet== 0 ) then
1429
+ call search_many(num_fields,bundle_nolandice_target,tile,search_nums,localpet, &
1430
+ soilt_climo= data_one_tile2, mask= mask_target_one_tile)
1431
+ else
1432
+ call search_many(num_fields,bundle_nolandice_target, tile,search_nums,localpet)
1433
+ endif
1422
1434
1423
1435
print * ," - CALL FieldGather FOR TARGET GRID TOTAL SOIL MOISTURE, TILE: " , tile
1424
1436
call ESMF_FieldGather(soilm_tot_target_grid, data_one_tile_3d, rootPet= 0 , tile= tile, rc= rc)
@@ -3290,20 +3302,18 @@ end subroutine regrid_many
3290
3302
! !
3291
3303
! ! @param[in] num_field Number of fields to process.
3292
3304
! ! @param[inout] bundle_target ESMF FieldBundle holding target fields to search
3293
- ! ! @param[inout] field_data_2d A real array of size i_target,j_target to temporarily hold data for searching
3294
- ! ! @param[inout] mask An integer array of size i_target,j_target that holds masked (0) and unmasked (1)
3295
- ! ! values indicating where to execute search (only at unmasked points).
3296
3305
! ! @param[in] tile Current cubed sphere tile.
3297
3306
! ! @param[inout] search_nums Array length num_field holding search field numbers corresponding to each field provided for searching.
3298
3307
! ! @param[in] localpet ESMF local persistent execution thread.
3299
3308
! ! @param[in] latitude (optional) A real array size i_target,j_target of latitude on the target grid
3300
3309
! ! @param[in] terrain_land (optional) A real array size i_target,j_target of terrain height (m) on the target grid
3301
3310
! ! @param[in] soilt_climo (optional) A real array size i_target,j_target of climatological soil type on the target grid
3302
- ! ! @param[in] field_data_3d (optional) An empty real array of size i_target,j_target,lsoil_target to temporarily hold soil data for searching
3311
+ ! ! @param[inout] mask (optional) An integer array of size i_target,j_target that holds masked (0) and unmasked (1)
3312
+ ! ! values indicating where to execute search (only at
3313
+ ! unmasked points).
3303
3314
! ! @author Larissa Reames, OU CIMMS/NOAA/NSSL
3304
- subroutine search_many (num_field ,bundle_target ,field_data_2d ,mask , tile , &
3305
- search_nums ,localpet ,latitude ,terrain_land ,soilt_climo ,&
3306
- field_data_3d )
3315
+ subroutine search_many (num_field ,bundle_target ,tile ,search_nums ,localpet ,latitude , &
3316
+ terrain_land ,soilt_climo , mask )
3307
3317
3308
3318
use model_grid, only : i_target,j_target, lsoil_target
3309
3319
use program_setup, only : external_model, input_type
@@ -3313,14 +3323,14 @@ subroutine search_many(num_field,bundle_target,field_data_2d,mask, tile, &
3313
3323
3314
3324
integer , intent (in ) :: num_field
3315
3325
type (esmf_fieldbundle), intent (inout ) :: bundle_target
3316
- real (esmf_kind_r8 ), intent (inout ) :: field_data_2d(i_target,j_target)
3317
- real (esmf_kind_r8 ), intent (inout ), optional :: field_data_3d(i_target,j_target,lsoil_target)
3326
+
3318
3327
real (esmf_kind_r8 ), intent (inout ), optional :: latitude(i_target,j_target)
3319
3328
real (esmf_kind_r8 ), intent (inout ), optional :: terrain_land(i_target,j_target)
3320
3329
real (esmf_kind_r8 ), intent (inout ), optional :: soilt_climo(i_target,j_target)
3321
- integer (esmf_kind_i8), intent (inout ) :: mask(i_target,j_target)
3330
+ integer (esmf_kind_i8), intent (inout ), optional :: mask(i_target,j_target)
3322
3331
3323
-
3332
+ real (esmf_kind_r8 ), allocatable :: field_data_2d(:,:)
3333
+ real (esmf_kind_r8 ), allocatable :: field_data_3d(:,:,:)
3324
3334
integer , intent (in ) :: tile,localpet
3325
3335
integer , intent (inout ) :: search_nums(num_field)
3326
3336
@@ -3331,46 +3341,45 @@ subroutine search_many(num_field,bundle_target,field_data_2d,mask, tile, &
3331
3341
integer , parameter :: TERRAIN_FIELD_NUM= 7
3332
3342
integer :: j,k, rc, ndims
3333
3343
3344
+
3334
3345
do k = 1 ,num_field
3335
3346
call ESMF_FieldBundleGet(bundle_target,k,temp_field, rc= rc)
3336
3347
if (ESMF_logFoundError(rcToCheck= rc,msg= ESMF_LOGERR_PASSTHRU,line= __LINE__,file= __FILE__))&
3337
3348
call error_handler(" IN FieldGet" , rc)
3338
3349
call ESMF_FieldGet(temp_field, name= fname, dimcount= ndims,rc= rc)
3339
3350
if (ESMF_logFoundError(rcToCheck= rc,msg= ESMF_LOGERR_PASSTHRU,line= __LINE__,file= __FILE__))&
3340
3351
call error_handler(" IN FieldGet" , rc)
3352
+ if (localpet== 0 ) then
3353
+ allocate (field_data_2d(i_target,j_target))
3354
+ else
3355
+ allocate (field_data_2d(0 ,0 ))
3356
+ endif
3341
3357
if (ndims .eq. 2 ) then
3342
- print * , " processing 2d field " , trim (fname)
3343
- print * , " FieldGather"
3344
3358
call ESMF_FieldGather(temp_field,field_data_2d,rootPet= 0 ,tile= tile, rc= rc)
3345
3359
if (ESMF_logFoundError(rcToCheck= rc,msg= ESMF_LOGERR_PASSTHRU,line= __LINE__,file= __FILE__))&
3346
3360
call error_handler(" IN FieldGather" , rc)
3347
3361
if (localpet == 0 ) then
3348
3362
if (present (latitude) .and. search_nums(k).eq. SST_FIELD_NUM) then
3349
3363
! Sea surface temperatures; pass latitude field to search
3350
- print * , " search1"
3351
3364
call search(field_data_2d, mask, i_target, j_target, tile,search_nums(k),latitude= latitude)
3352
3365
elseif (present (terrain_land) .and. search_nums(k) .eq. TERRAIN_FIELD_NUM) then
3353
3366
! Terrain height; pass optional climo terrain array to search
3354
- print * , " search2"
3355
3367
call search(field_data_2d, mask, i_target, j_target, tile,search_nums(k),terrain_land= terrain_land)
3356
3368
elseif (search_nums(k) .eq. SOTYP_LAND_FIELD_NUM) then
3357
3369
! Soil type over land
3358
3370
if (fname .eq. " soil_type_target_grid" ) then
3359
3371
! Soil type over land when interpolating input data to target grid
3360
3372
! *with* the intention of retaining interpolated data in output
3361
- print * , " search3"
3362
3373
call search(field_data_2d, mask, i_target, j_target, tile,search_nums(k),soilt_climo= soilt_climo)
3363
3374
elseif (present (soilt_climo)) then
3364
3375
if (maxval (field_data_2d) > 0 .and. (trim (external_model) .ne. " GFS" .or. trim (input_type) .ne. " grib2" )) then
3365
3376
! Soil type over land when interpolating input data to target grid
3366
3377
! *without* the intention of retaining data in output file
3367
- print * , " search4"
3368
3378
call search(field_data_2d, mask, i_target, j_target, tile, search_nums(k))
3369
3379
else
3370
3380
! If no soil type field exists in input data (e.g., GFS grib2) then don't search
3371
3381
! but simply set data to the climo field. This may result in
3372
3382
! somewhat inaccurate soil moistures as no scaling will occur
3373
- print * , " search5"
3374
3383
field_data_2d = soilt_climo
3375
3384
endif ! check field value
3376
3385
endif ! sotype from target grid
@@ -3384,12 +3393,17 @@ subroutine search_many(num_field,bundle_target,field_data_2d,mask, tile, &
3384
3393
if (ESMF_logFoundError(rcToCheck= rc,msg= ESMF_LOGERR_PASSTHRU,line= __LINE__,file= __FILE__))&
3385
3394
call error_handler(" IN FieldScatter" , rc)
3386
3395
else
3396
+ if (localpet== 0 ) then
3397
+ allocate (field_data_3d(i_target,j_target,lsoil_target))
3398
+ else
3399
+ allocate (field_data_3d(0 ,0 ,0 ))
3400
+ endif
3401
+
3387
3402
! Process 3d fields soil temperature, moisture, and liquid
3388
- print * , " FieldGather"
3389
3403
call ESMF_FieldGather(temp_field,field_data_3d,rootPet= 0 ,tile= tile,rc= rc)
3390
3404
if (ESMF_logFoundError(rcToCheck= rc,msg= ESMF_LOGERR_PASSTHRU,line= __LINE__,file= __FILE__))&
3391
3405
call error_handler(" IN FieldGather" , rc)
3392
- print * , " processing 3d field " , trim (fname)
3406
+
3393
3407
if (localpet== 0 ) then
3394
3408
do j = 1 , lsoil_target
3395
3409
field_data_2d = field_data_3d(:,:,j)
@@ -3400,7 +3414,9 @@ subroutine search_many(num_field,bundle_target,field_data_2d,mask, tile, &
3400
3414
call ESMF_FieldScatter(temp_field, field_data_3d, rootPet= 0 , tile= tile,rc= rc)
3401
3415
if (ESMF_logFoundError(rcToCheck= rc,msg= ESMF_LOGERR_PASSTHRU,line= __LINE__,file= __FILE__))&
3402
3416
call error_handler(" IN FieldScatter" , rc)
3417
+ deallocate (field_data_3d)
3403
3418
endif ! ndims
3419
+ deallocate (field_data_2d)
3404
3420
end do ! fields
3405
3421
3406
3422
end subroutine search_many
0 commit comments