Changeset 13369 for utils/tools/SIREN/src/create_bathy.f90
- Timestamp:
- 2020-07-31T10:50:52+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
utils/tools/SIREN/src/create_bathy.f90
r12080 r13369 5 5 ! DESCRIPTION: 6 6 !> @file 7 !> This program creates fine grid bathymetry file.7 !> This program creates target/fine grid bathymetry file. 8 8 !> 9 9 !> @section sec1 method 10 10 !> This bathymetry could be : 11 !> - extracted from a wider fine grid bathymetry file12 !> - interpolated from a wider coarse grid bathymetry file11 !> - extracted from a wider target/fine grid bathymetry file 12 !> - interpolated from a wider source/coarse grid bathymetry file 13 13 !> - handwritten 14 14 !> 15 !> @image html bathy_40.png 15 !> @image html bathy_40.png 16 16 !> <center>@image latex bathy_30.png 17 17 !> </center> … … 45 45 !> 46 46 !> here after, each sub-namelist parameters is detailed. 47 !> @note 47 !> @note 48 48 !> default values are specified between brackets 49 49 !> … … 64 64 !> - none 65 65 !> 66 !> - **in_maxerror** [@a 5]<br/> 66 !> - **in_maxerror** [@a 5]<br/> 67 67 !> maximum number of error allowed 68 68 !> … … 72 72 !> - **cn_varcfg** [@a ./cfg/variable.cfg]<br/> 73 73 !> path to the variable configuration file.<br/> 74 !> the variable configuration file defines standard name, 75 !> default interpolation method, axis,... 76 !> to be used for some known variables.<br/> 77 !> 78 !> - **cn_dimcfg** [@a ./cfg/dimension.cfg]<br/> 79 !> path to the dimension configuration file.<br/> 80 !> the dimension configuration file defines dimensions allowed.<br/> 81 !> 82 !> - **cn_dumcfg** [@a ./cfg/dummy.cfg]<br/> 74 !> the variable configuration file defines standard name, 75 !> default interpolation method, axis,... 76 !> to be used for some known variables.<br/> 77 !> 78 !> - **cn_dimcfg** [@a ./cfg/dimension.cfg]<br/> 79 !> path to the dimension configuration file.<br/> 80 !> the dimension configuration file defines dimensions allowed.<br/> 81 !> 82 !> - **cn_dumcfg** [@a ./cfg/dummy.cfg]<br/> 83 83 !> path to the useless (dummy) configuration file.<br/> 84 !> the dummy configuration file defines useless 84 !> the dummy configuration file defines useless 85 85 !> dimension or variable. these dimension(s) or variable(s) will not be 86 86 !> processed.<br/> 87 87 !> 88 !> @subsection subsrc namsrc 88 !> @subsection subsrc namsrc 89 89 !> the source/coarse grid sub-namelist parameters are : 90 90 !> 91 !> - **cn_coord0** [@a ]<br/> 91 !> - **cn_coord0** [@a ]<br/> 92 92 !> path to the coordinate file 93 93 !> 94 !> - **in_perio0** [@a ]<br/> 95 !> NEMO periodicity index<br/> 94 !> - **in_perio0** [@a ]<br/> 95 !> NEMO periodicity index<br/> 96 96 !> the NEMO periodicity could be choose between 0 to 6: 97 97 !> <dl> … … 115 115 !> </dl> 116 116 !> @sa For more information see @ref md_src_docsrc_6_perio 117 !> and Model Boundary Condition paragraph in the 117 !> and Model Boundary Condition paragraph in the 118 118 !> [NEMO documentation](https://forge.ipsl.jussieu.fr/nemo/chrome/site/doc/NEMO/manual/pdf/NEMO_manual.pdf) 119 119 !> 120 !> @subsection subtgt namtgt 120 !> @subsection subtgt namtgt 121 121 !> the target/fine grid sub-namelist parameters are : 122 122 !> 123 !> - **cn_coord1** [@a ]<br/> 123 !> - **cn_coord1** [@a ]<br/> 124 124 !> path to coordinate file 125 125 !> … … 133 133 !> logical to fill closed sea or not 134 134 !> 135 !> @subsection subvar namvar 135 !> @subsection subvar namvar 136 136 !> the variable sub-namelist parameters are : 137 137 !> 138 !> - **cn_varfile** [@a ]<br/> 139 !> list of variable, and associated file 140 !> @warning 138 !> - **cn_varfile** [@a ]<br/> 139 !> list of variable, and associated file 140 !> @warning 141 141 !> variable name must be __Bathymetry__ here. 142 142 !> 143 143 !> *cn_varfile* is the path and filename of the file where find 144 144 !> variable. 145 !> @note 145 !> @note 146 146 !> *cn_varfile* could be a matrix of value, if you want to handwrite 147 147 !> variable value.<br/> 148 148 !> the variable array of value is split into equal subdomain.<br/> 149 !> each subdomain is filled with the corresponding value 150 !> of the matrix.<br/> 149 !> each subdomain is filled with the corresponding value 150 !> of the matrix.<br/> 151 151 !> separators used to defined matrix are: 152 152 !> - ',' for line … … 157 157 !> 1 & 4 & 5 \end{array} \right) @f$ 158 158 !> 159 !> Examples: 159 !> Examples: 160 160 !> - 'Bathymetry:gridT.nc' 161 161 !> - 'Bathymetry:5000,5000,5000/5000,3000,5000/5000,5000,5000'<br/> 162 162 !> 163 !> @note 163 !> @note 164 164 !> Optionnaly, NEMO periodicity could be added following the filename. 165 165 !> the periodicity must be separated by ';' … … 168 168 !> - 'Bathymetry:gridT.nc ; perio=4'<br/> 169 169 !> 170 !> - **cn_varinfo** [@a ]<br/> 170 !> - **cn_varinfo** [@a ]<br/> 171 171 !> list of variable and extra information about request(s) to be used<br/> 172 172 !> 173 173 !> each elements of *cn_varinfo* is a string character (separated by ',').<br/> 174 !> it is composed of the variable name follow by ':', 175 !> then request(s) to be used on this variable.<br/> 174 !> it is composed of the variable name follow by ':', 175 !> then request(s) to be used on this variable.<br/> 176 176 !> request could be: 177 177 !> - int = interpolation method … … 188 188 !> informations about available method could be find in @ref interp, 189 189 !> @ref extrap and @ref filter modules.<br/> 190 !> Example: 190 !> Example: 191 191 !> - 'Bathymetry: flt=2*hamming(2,3); min=0' 192 192 !> 193 !> @note 194 !> If you do not specify a method which is required, 193 !> @note 194 !> If you do not specify a method which is required, 195 195 !> default one is apply. 196 196 !> 197 !> - **ln_rand** [@a .False.]<br/> 197 !> - **ln_rand** [@a .False.]<br/> 198 198 !> logical to add random value to Bathymetry<br/> 199 !> Only for handmade Bathymetry. 199 !> Only for handmade Bathymetry. 200 200 !> A random value (+/- 0.1% of the maximum depth) will 201 201 !> will be added to avoid flat Bathymetry (which may cause issue). 202 202 !> 203 !> @subsection subnst namnst 203 !> @subsection subnst namnst 204 204 !> the nesting sub-namelist parameters are : 205 205 !> 206 !> - **in_rhoi** [@a 1]<br/> 206 !> - **in_rhoi** [@a 1]<br/> 207 207 !> refinement factor in i-direction 208 208 !> 209 !> - **in_rhoj** [@a 1]<br/> 209 !> - **in_rhoj** [@a 1]<br/> 210 210 !> refinement factor in j-direction 211 211 !> 212 !> @note 213 !> coarse grid indices will be deduced fromfine grid212 !> @note 213 !> source/coarse grid indices will be deduced from target/fine grid 214 214 !> coordinate file. 215 215 !> 216 !> @subsection subout namout 216 !> @subsection subout namout 217 217 !> the output sub-namelist parameter is : 218 218 !> … … 224 224 !> 225 225 !> @date November, 2013 - Initial Version 226 !> @date Sepember, 2014 226 !> @date Sepember, 2014 227 227 !> - add header for user 228 228 !> - Bug fix, compute offset depending of grid point … … 317 317 318 318 TYPE(TATT) :: tl_att 319 319 320 320 TYPE(TVAR) :: tl_lon 321 321 TYPE(TVAR) :: tl_lat … … 325 325 TYPE(TVAR) :: tl_tmp 326 326 TYPE(TVAR) , DIMENSION(:), ALLOCATABLE :: tl_var 327 327 328 328 TYPE(TDIM) , DIMENSION(ip_maxdim) :: tl_dim 329 329 … … 341 341 ! namelist variable 342 342 ! namlog 343 CHARACTER(LEN=lc) :: cn_logfile = 'create_bathy.log' 344 CHARACTER(LEN=lc) :: cn_verbosity = 'warning' 343 CHARACTER(LEN=lc) :: cn_logfile = 'create_bathy.log' 344 CHARACTER(LEN=lc) :: cn_verbosity = 'warning' 345 345 INTEGER(i4) :: in_maxerror = 5 346 346 347 347 ! namcfg 348 CHARACTER(LEN=lc) :: cn_varcfg = './cfg/variable.cfg' 348 CHARACTER(LEN=lc) :: cn_varcfg = './cfg/variable.cfg' 349 349 CHARACTER(LEN=lc) :: cn_dimcfg = './cfg/dimension.cfg' 350 350 CHARACTER(LEN=lc) :: cn_dumcfg = './cfg/dummy.cfg' 351 351 352 352 ! namsrc 353 CHARACTER(LEN=lc) :: cn_coord0 = '' 353 CHARACTER(LEN=lc) :: cn_coord0 = '' 354 354 INTEGER(i4) :: in_perio0 = -1 355 355 … … 369 369 370 370 ! namout 371 CHARACTER(LEN=lc) :: cn_fileout = 'bathy_fine.nc' 371 CHARACTER(LEN=lc) :: cn_fileout = 'bathy_fine.nc' 372 372 !------------------------------------------------------------------- 373 373 … … 390 390 & in_perio1, & !< periodicity index 391 391 & ln_fillclosed !< fill closed sea 392 392 393 393 NAMELIST /namvar/ & !< variable namelist 394 394 & cn_varfile, & !< list of variable file 395 395 & cn_varinfo, & !< list of variable and interpolation method to be used. (ex: 'votemper:linear','vosaline:cubic' ) 396 396 & ln_rand !< add random value to avoid flat bathymetry 397 397 398 398 NAMELIST /namnst/ & !< nesting namelist 399 399 & in_rhoi, & !< refinement factor in i-direction … … 401 401 402 402 NAMELIST /namout/ & !< output namelist 403 & cn_fileout !< fine grid bathymetry file403 & cn_fileout !< target/fine grid bathymetry file 404 404 !------------------------------------------------------------------- 405 405 … … 414 414 IF( il_narg /= 1 )THEN 415 415 WRITE(cl_errormsg,*) ' ERROR : one argument is needed ' 416 CALL fct_help(cp_myname,cl_errormsg) 416 CALL fct_help(cp_myname,cl_errormsg) 417 417 CALL EXIT(1) 418 418 ELSE … … 449 449 IF( il_status /= 0 )THEN 450 450 WRITE(cl_errormsg,*) " ERROR : error opening "//TRIM(cl_namelist) 451 CALL fct_help(cp_myname,cl_errormsg) 451 CALL fct_help(cp_myname,cl_errormsg) 452 452 CALL EXIT(1) 453 453 ENDIF 454 454 455 455 READ( il_fileid, NML = namlog ) 456 456 457 457 ! define logger file 458 458 CALL logger_open(TRIM(cn_logfile),TRIM(cn_verbosity),in_maxerror) … … 493 493 494 494 WRITE(cl_errormsg,*) " ERROR : can't find "//TRIM(cl_namelist) 495 CALL fct_help(cp_myname,cl_errormsg) 495 CALL fct_help(cp_myname,cl_errormsg) 496 496 CALL EXIT(1) 497 497 … … 511 511 CALL grid_get_info(tl_coord0) 512 512 ELSE 513 CALL logger_fatal("CREATE BATHY: no coarse grid coordinate found. "//&514 & "check namelist") 513 CALL logger_fatal("CREATE BATHY: no source/coarse grid coordinate found. "//& 514 & "check namelist") 515 515 ENDIF 516 516 … … 522 522 CALL grid_get_info(tl_coord1) 523 523 ELSE 524 CALL logger_fatal("CREATE BATHY: no fine grid coordinate found. "//&524 CALL logger_fatal("CREATE BATHY: no target/fine grid coordinate found. "//& 525 525 & "check namelist") 526 526 ENDIF … … 550 550 551 551 ! check domain indices 552 ! compute coarse grid indices aroundfine grid552 ! compute source/coarse grid indices around target/fine grid 553 553 il_ind(:,:)=grid_get_coarse_index( tl_coord0, tl_coord1, & 554 554 & id_rho=il_rho(:) ) … … 560 560 CALL grid_check_dom(tl_coord0, il_imin0, il_imax0, il_jmin0, il_jmax0) 561 561 562 ! check coincidence between coarse and fine grid562 ! check coincidence between coarse and target/fine grid 563 563 CALL grid_check_coincidence( tl_coord0, tl_coord1, & 564 564 & il_imin0, il_imax0, & … … 574 574 jk=0 575 575 DO ji=1,tl_multi%i_nmpp 576 576 577 577 WRITE(cl_data,'(a,i2.2)') 'data-',jk+1 578 578 IF( .NOT. ASSOCIATED(tl_multi%t_mpp(ji)%t_proc(1)%t_var) )THEN … … 622 622 IF( ANY(tl_mpp%t_dim(1:2)%i_len /= tl_coord0%t_dim(1:2)%i_len).OR.& 623 623 & ALL(il_rho(:)==1) )THEN 624 !- extract bathymetry from fine grid bathymetry624 !- extract bathymetry from target/fine grid bathymetry 625 625 DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar 626 626 jk=jk+1 627 627 tl_tmp=var_copy(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)) 628 628 629 629 tl_var(jk)=create_bathy_extract( tl_tmp, tl_mpp, & 630 630 & tl_coord1 ) … … 633 633 CALL var_clean(tl_tmp) 634 634 ELSE 635 !- get bathymetry from coarse grid bathymetry635 !- get bathymetry from source/coarse grid bathymetry 636 636 DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar 637 637 jk=jk+1 … … 792 792 CALL file_add_att(tl_fileout,tl_att) 793 793 ENDIF 794 794 795 795 ! create file 796 796 CALL iom_create(tl_fileout) … … 821 821 !> @brief 822 822 !> This function create variable, filled with matrix value 823 !> 824 !> @details 825 !> A variable is create with the same name that the input variable, 826 !> and with dimension of the coordinate file.<br/> 823 !> 824 !> @details 825 !> A variable is create with the same name that the input variable, 826 !> and with dimension of the coordinate file.<br/> 827 827 !> Then the variable array of value is split into equal subdomain. 828 828 !> Each subdomain is filled with the corresponding value of the matrix. … … 834 834 !> @date November, 2013 - Initial Version 835 835 !> 836 !> @param[in] td_var variable structure 836 !> @param[in] td_var variable structure 837 837 !> @param[in] td_coord coordinate file structure 838 838 !> @param[in] ld_rand add random value to bathymetry … … 903 903 CALL var_clean(tl_lon) 904 904 905 ! split output domain in N subdomain depending of matrix dimension 905 ! split output domain in N subdomain depending of matrix dimension 906 906 il_size(:) = tl_dim(1:2)%i_len / il_dim(:) 907 907 il_rest(:) = MOD(tl_dim(1:2)%i_len, il_dim(:)) … … 923 923 il_jshape(il_dim(2)+1)=il_jshape(il_dim(2)+1)+il_rest(2) 924 924 925 ! write ouput array of value 925 ! write ouput array of value 926 926 ALLOCATE(dl_value( tl_dim(1)%i_len, & 927 927 & tl_dim(2)%i_len, & … … 932 932 DO jj=2,il_dim(2)+1 933 933 DO ji=2,il_dim(1)+1 934 934 935 935 dl_value( 1+il_ishape(ji-1):il_ishape(ji), & 936 936 & 1+il_jshape(jj-1):il_jshape(jj), & … … 944 944 ALLOCATE(dl_ran(tl_dim(1)%i_len, & 945 945 & tl_dim(2)%i_len) ) 946 946 947 947 ! set random value between 0 and 1 948 948 CALL RANDOM_NUMBER(dl_ran(:,:)) … … 953 953 954 954 dl_value(:,:,1,1)=dl_value(:,:,1,1)+dl_ran(:,:) 955 955 956 956 DEALLOCATE(dl_ran) 957 957 ENDIF … … 976 976 !> This function extract variable from file over coordinate domain and 977 977 !> return variable structure 978 !> 978 !> 979 979 !> @author J.Paul 980 980 !> @date November, 2013 - Initial Version 981 981 !> 982 !> @param[in] td_var variable structure 982 !> @param[in] td_var variable structure 983 983 !> @param[in] td_mpp mpp file structure 984 984 !> @param[in] td_coord coordinate file structure … … 989 989 990 990 ! Argument 991 TYPE(TVAR), INTENT(IN) :: td_var 991 TYPE(TVAR), INTENT(IN) :: td_var 992 992 TYPE(TMPP), INTENT(IN) :: td_mpp 993 993 TYPE(TMPP), INTENT(IN) :: td_coord … … 1071 1071 ! add attribute to variable 1072 1072 tl_att=att_init('src_file',TRIM(fct_basename(tl_mpp%c_name))) 1073 CALL var_move_att(tf_var, tl_att) 1073 CALL var_move_att(tf_var, tl_att) 1074 1074 1075 1075 tl_att=att_init('src_i_indices',(/tl_dom%i_imin, tl_dom%i_imax/)) … … 1094 1094 !------------------------------------------------------------------- 1095 1095 !> @brief 1096 !> This function get coarse grid variable, interpolate variable, and return1097 !> variable structure over fine grid1098 !> 1096 !> This function get source/coarse grid variable, interpolate variable, and return 1097 !> variable structure over target/fine grid 1098 !> 1099 1099 !> @author J.Paul 1100 1100 !> @date November, 2013 - Initial Version … … 1102 1102 !> @param[in] td_var variable structure 1103 1103 !> @param[in] td_mpp mpp file structure 1104 !> @param[in] id_imin i-direction lower left corner indice 1105 !> @param[in] id_imax i-direction upper right corner indice 1104 !> @param[in] id_imin i-direction lower left corner indice 1105 !> @param[in] id_imax i-direction upper right corner indice 1106 1106 !> @param[in] id_jmin j-direction lower left corner indice 1107 !> @param[in] id_jmax j-direction upper right corner indice 1108 !> @param[in] id_offset offset between fine grid andcoarse grid1107 !> @param[in] id_jmax j-direction upper right corner indice 1108 !> @param[in] id_offset offset between target/fine grid and source/coarse grid 1109 1109 !> @param[in] id_rho array of refinement factor 1110 1110 !> @return variable structure … … 1114 1114 1115 1115 ! Argument 1116 TYPE(TVAR) , INTENT(IN) :: td_var 1117 TYPE(TMPP) , INTENT(IN) :: td_mpp 1116 TYPE(TVAR) , INTENT(IN) :: td_var 1117 TYPE(TMPP) , INTENT(IN) :: td_mpp 1118 1118 INTEGER(i4) , INTENT(IN) :: id_imin 1119 1119 INTEGER(i4) , INTENT(IN) :: id_imax … … 1164 1164 ALLOCATE( il_rho(il_size) ) 1165 1165 il_rho(:)=id_rho(:) 1166 1166 1167 1167 !- interpolate variable 1168 1168 CALL create_bathy_interp(tf_var, il_rho(:), id_offset(:,:)) … … 1175 1175 !- add ghost cell 1176 1176 CALL grid_add_ghost(tf_var,tl_dom%i_ghost(:,:)) 1177 1177 1178 1178 !- add attribute to variable 1179 1179 tl_att=att_init('src_file',TRIM(fct_basename(tl_mpp%c_name))) … … 1196 1196 CALL att_clean(tl_att) 1197 1197 CALL mpp_clean(tl_mpp) 1198 1198 1199 1199 END FUNCTION create_bathy_get_var 1200 1200 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 1204 1204 !> @brief 1205 1205 !> This subroutine interpolate variable 1206 !> 1206 !> 1207 1207 !> @author J.Paul 1208 1208 !> @date November, 2013 - Initial Version 1209 1209 !> 1210 !> @param[inout] td_var variable structure 1210 !> @param[inout] td_var variable structure 1211 1211 !> @param[in] id_rho array of refinment factor 1212 !> @param[in] id_offset array of offset between fine andcoarse grid1212 !> @param[in] id_offset array of offset between target/fine and source/coarse grid 1213 1213 !> @param[in] id_iext i-direction size of extra bands (default=im_minext) 1214 1214 !> @param[in] id_jext j-direction size of extra bands (default=im_minext) … … 1262 1262 1263 1263 bl_mask(:,:,:,:)=1 1264 WHERE(td_var%d_value(:,:,:,:)==td_var%d_fill) bl_mask(:,:,:,:)=0 1264 WHERE(td_var%d_value(:,:,:,:)==td_var%d_fill) bl_mask(:,:,:,:)=0 1265 1265 1266 1266 SELECT CASE(TRIM(td_var%c_point)) … … 1295 1295 CALL extrap_del_extrabands(td_var, il_iext*id_rho(jp_I), il_jext*id_rho(jp_J)) 1296 1296 1297 ! keep original mask 1297 ! keep original mask 1298 1298 WHERE( tl_mask%d_value(:,:,:,:) == 0 ) 1299 1299 td_var%d_value(:,:,:,:)=td_var%d_fill … … 1310 1310 !> This subroutine get depth variable value in an open mpp structure 1311 1311 !> and check if agree with already input depth variable. 1312 !> 1313 !> @details 1312 !> 1313 !> @details 1314 1314 !> 1315 1315 !> @author J.Paul … … 1317 1317 !> 1318 1318 !> @param[in] td_mpp mpp structure 1319 !> @param[inout] td_depth depth variable structure 1319 !> @param[inout] td_depth depth variable structure 1320 1320 !------------------------------------------------------------------- 1321 1321 … … 1355 1355 1356 1356 ENDIF 1357 1357 1358 1358 END SUBROUTINE create_bathy_check_depth 1359 1359 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 1363 1363 !> This subroutine get date and time in an open mpp structure 1364 1364 !> and check if agree with date and time already read. 1365 !> 1366 !> @details 1365 !> 1366 !> @details 1367 1367 !> 1368 1368 !> @author J.Paul … … 1370 1370 !> 1371 1371 !> @param[in] td_mpp mpp structure 1372 !> @param[inout] td_time time variable structure 1372 !> @param[inout] td_time time variable structure 1373 1373 !------------------------------------------------------------------- 1374 1374 … … 1412 1412 1413 1413 ENDIF 1414 1414 1415 1415 END SUBROUTINE create_bathy_check_time 1416 1416 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note: See TracChangeset
for help on using the changeset viewer.