- Timestamp:
- 2016-10-13T11:08:38+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2016/dev_r6999_CONFIGMAN_1/NEMOGCM/TOOLS/SIREN/src/grid.f90
r6393 r7025 218 218 !> @date February, 2015 219 219 !> - add function grid_fill_small_msk to fill small domain inside bigger one 220 !> @ February, 2016220 !> @date February, 2016 221 221 !> - improve way to check coincidence (bug fix) 222 222 !> - manage grid cases for T,U,V or F point, with even or odd refinment (bug fix) 223 !> @date April, 2016 224 !> - add function to get closest grid point using coarse grid coordinates strucutre 223 225 ! 224 226 !> @note Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) … … 271 273 PRIVATE :: grid__get_coarse_index_cc ! - using coarse and fine grid array of lon,lat 272 274 275 ! return closest coarse grid point from another point 276 PRIVATE :: grid__get_closest_str ! - using coarse grid coordinates strucutre 277 PRIVATE :: grid__get_closest_arr ! - using coarse grid array of lon,lat 278 273 279 ! get offset between fine and coarse grid 274 280 PRIVATE :: grid__get_fine_offset_ff ! - using coarse and fine grid coordinates files … … 333 339 MODULE PROCEDURE grid__get_ghost_mpp 334 340 END INTERFACE grid_get_ghost 341 342 INTERFACE grid_get_closest 343 MODULE PROCEDURE grid__get_closest_str 344 MODULE PROCEDURE grid__get_closest_arr 345 END INTERFACE grid_get_closest 335 346 336 347 INTERFACE grid_get_coarse_index … … 1365 1376 END SELECT 1366 1377 ELSE 1378 il_perio=-1 1367 1379 ! check periodicity 1368 1380 IF(ANY(td_var%d_value( 1 ,:,1,1)/=td_var%d_fill).OR.& … … 3020 3032 !> 3021 3033 !> @author J.Paul 3034 !> @date April, 2016 - Initial Version 3035 ! 3036 !> @param[in] td_coord0 coarse grid coordinate mpp structure 3037 !> @param[in] dd_lon1 fine grid longitude 3038 !> @param[in] dd_lat1 fine grid latitude 3039 !> @param[in] cd_pos relative position of grid point from point 3040 !> @param[in] dd_fill fill value 3041 !> @return coarse grid indices of closest point of fine grid point 3042 !------------------------------------------------------------------- 3043 FUNCTION grid__get_closest_str( td_coord0, dd_lon1, dd_lat1, cd_pos, dd_fill ) & 3044 & RESULT(id_res) 3045 3046 IMPLICIT NONE 3047 ! Argument 3048 TYPE(TMPP ) , INTENT(IN) :: td_coord0 3049 REAL(dp), INTENT(IN) :: dd_lon1 3050 REAL(dp), INTENT(IN) :: dd_lat1 3051 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: cd_pos 3052 REAL(dp), INTENT(IN), OPTIONAL :: dd_fill 3053 3054 ! function 3055 INTEGER(i4), DIMENSION(2) :: id_res 3056 3057 ! local variable 3058 CHARACTER(LEN=lc) :: cl_point 3059 CHARACTER(LEN=lc) :: cl_name 3060 3061 INTEGER(i4) :: il_ind 3062 3063 REAL(dp) , DIMENSION(:,:), ALLOCATABLE :: dl_lon0 3064 REAL(dp) , DIMENSION(:,:), ALLOCATABLE :: dl_lat0 3065 3066 TYPE(TVAR) :: tl_lon0 3067 TYPE(TVAR) :: tl_lat0 3068 TYPE(TMPP) :: tl_coord0 3069 !---------------------------------------------------------------- 3070 3071 id_res(:)=-1 3072 cl_point='T' 3073 3074 ! copy structure 3075 tl_coord0=mpp_copy(td_coord0) 3076 3077 IF( .NOT. ASSOCIATED(tl_coord0%t_proc) )THEN 3078 3079 CALL logger_error("GRID GET CLOSEST: decompsition of mpp "//& 3080 & "file "//TRIM(tl_coord0%c_name)//" not defined." ) 3081 3082 ELSE 3083 3084 ! open mpp files 3085 CALL iom_mpp_open(tl_coord0) 3086 3087 ! read coarse longitue and latitude 3088 WRITE(cl_name,*) 'longitude_'//TRIM(cl_point) 3089 il_ind=var_get_id(tl_coord0%t_proc(1)%t_var(:), cl_name) 3090 IF( il_ind == 0 )THEN 3091 CALL logger_warn("GRID GET CLOSEST: no variable "//& 3092 & TRIM(cl_name)//"in file "//TRIM(tl_coord0%c_name)//". & 3093 & try to use longitude.") 3094 WRITE(cl_name,*) 'longitude' 3095 ENDIF 3096 tl_lon0=iom_mpp_read_var(tl_coord0, TRIM(cl_name)) 3097 3098 WRITE(cl_name,*) 'latitude_'//TRIM(cl_point) 3099 il_ind=var_get_id(tl_coord0%t_proc(1)%t_var(:), cl_name) 3100 IF( il_ind == 0 )THEN 3101 CALL logger_warn("GRID GET CLOSEST: no variable "//& 3102 & TRIM(cl_name)//"in file "//TRIM(tl_coord0%c_name)//". & 3103 & try to use latitude.") 3104 WRITE(cl_name,*) 'latitude' 3105 ENDIF 3106 tl_lat0=iom_mpp_read_var(tl_coord0, TRIM(cl_name)) 3107 3108 ! close mpp files 3109 CALL iom_mpp_close(tl_coord0) 3110 3111 ALLOCATE(dl_lon0(tl_coord0%t_dim(jp_I)%i_len-tl_coord0%i_ew, & 3112 & tl_coord0%t_dim(jp_J)%i_len) ) 3113 ALLOCATE(dl_lat0(tl_coord0%t_dim(jp_I)%i_len-tl_coord0%i_ew, & 3114 & tl_coord0%t_dim(jp_J)%i_len) ) 3115 3116 dl_lon0(:,:)=tl_lon0%d_value(tl_coord0%i_ew+1:,:,1,1) 3117 dl_lat0(:,:)=tl_lat0%d_value(tl_coord0%i_ew+1:,:,1,1) 3118 3119 id_res(:)=grid_get_closest( dl_lon0, dl_lat0, dd_lon1, dd_lat1, cd_pos, dd_fill ) 3120 3121 DEALLOCATE(dl_lon0, dl_lat0) 3122 CALL var_clean(tl_lon0) 3123 CALL var_clean(tl_lat0) 3124 CALL mpp_clean(tl_coord0) 3125 3126 ENDIF 3127 3128 END FUNCTION grid__get_closest_str 3129 !------------------------------------------------------------------- 3130 !> @brief This function return grid indices of the closest point 3131 !> from point (lon1,lat1) 3132 !> 3133 !> @details 3134 !> 3135 !> @note overlap band should have been already removed from coarse grid array 3136 !> of longitude and latitude, before running this function 3137 !> 3138 !> if you add cd_pos argument, you could choice to return closest point at 3139 !> - lower left (ll) of the point 3140 !> - lower right (lr) of the point 3141 !> - upper left (ul) of the point 3142 !> - upper right (ur) of the point 3143 !> - lower (lo) of the point 3144 !> - upper (up) of the point 3145 !> - left (le) of the point 3146 !> - right (ri) of the point 3147 !> 3148 !> @author J.Paul 3022 3149 !> @date November, 2013 - Initial Version 3023 3150 !> @date February, 2015 … … 3034 3161 !> @return coarse grid indices of closest point of fine grid point 3035 3162 !------------------------------------------------------------------- 3036 FUNCTION grid_ get_closest( dd_lon0, dd_lat0, dd_lon1, dd_lat1, cd_pos, dd_fill )3163 FUNCTION grid__get_closest_arr( dd_lon0, dd_lat0, dd_lon1, dd_lat1, cd_pos, dd_fill ) 3037 3164 IMPLICIT NONE 3038 3165 ! Argument … … 3045 3172 3046 3173 ! function 3047 INTEGER(i4), DIMENSION(2) :: grid_ get_closest3174 INTEGER(i4), DIMENSION(2) :: grid__get_closest_arr 3048 3175 3049 3176 ! local variable … … 3261 3388 END SELECT 3262 3389 ENDIF 3263 grid_ get_closest(:)=MINLOC(dl_dist(:,:),dl_dist(:,:)/=NF90_FILL_DOUBLE)3264 3265 grid_ get_closest(1)=grid_get_closest(1)+il_iinf-13266 grid_ get_closest(2)=grid_get_closest(2)+il_jinf-13390 grid__get_closest_arr(:)=MINLOC(dl_dist(:,:),dl_dist(:,:)/=NF90_FILL_DOUBLE) 3391 3392 grid__get_closest_arr(1)=grid__get_closest_arr(1)+il_iinf-1 3393 grid__get_closest_arr(2)=grid__get_closest_arr(2)+il_jinf-1 3267 3394 3268 3395 DEALLOCATE( dl_dist ) 3269 3396 DEALLOCATE( dl_lon0 ) 3270 3397 3271 END FUNCTION grid_ get_closest3398 END FUNCTION grid__get_closest_arr 3272 3399 !------------------------------------------------------------------- 3273 3400 !> @brief This function compute the distance between a point A and grid points. … … 4647 4774 4648 4775 IF( ll_even )THEN 4776 4649 4777 ! look for variable value on domain for F point 4650 4778 il_ind=var_get_index(tl_coord0%t_proc(1)%t_var(:), 'longitude_F')
Note: See TracChangeset
for help on using the changeset viewer.