New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 6225 for branches/2014/dev_r4704_NOC5_MPP_BDY_UPDATE/NEMOGCM/TOOLS/SIREN/src/merge_bathy.f90 – NEMO

Ignore:
Timestamp:
2016-01-08T10:35:19+01:00 (8 years ago)
Author:
jamesharle
Message:

Update MPP_BDY_UPDATE branch to be consistent with head of trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2014/dev_r4704_NOC5_MPP_BDY_UPDATE/NEMOGCM/TOOLS/SIREN/src/merge_bathy.f90

    r4213 r6225  
    77! 
    88! DESCRIPTION: 
     9!> @file 
    910!> @brief  
    1011!> This program merge bathymetry file at boundaries. 
    1112!> 
    1213!> @details 
     14!> @section sec1 method 
    1315!> Coarse grid Bathymetry is interpolated on fine grid.  
    14 !> Then fine Bathymetry and refined coarse bathymetry are merged at boundaries. 
    15 !> 
    16 !> BathyFine= weight * BathyCoarse + (1-weight)*BathyFine 
    17 !> 
    18 !> The weight function used is : 0.5 + 0.5*COS( (pi*dist) / width )  
    19 !> 
    20 !> @author 
    21 !> J.Paul 
     16!> Then fine Bathymetry and refined coarse bathymetry are merged at boundaries.<br/> 
     17!>    @f[BathyFine= Weight * BathyCoarse + (1-Weight)*BathyFine@f] 
     18!> The weight function used is :<br/> 
     19!>       @f[Weight = 0.5 + 0.5*COS( \frac{\pi*dist}{width} )@f]<br/> 
     20!> with 
     21!> - dist : number of point to border  
     22!> - width : boundary size 
     23!> 
     24!> @section sec2 how to 
     25!>    to merge bathymetry file:<br/> 
     26!> @code{.sh} 
     27!>    ./SIREN/bin/merge_bathy merge_bathy.nam 
     28!> @endcode 
     29!>     
     30!> @note  
     31!>    you could find a template of the namelist in templates directory. 
     32!> 
     33!>    merge_bathy.nam comprise 8 namelists: 
     34!>       - logger namelist (namlog) 
     35!>       - config namelist (namcfg) 
     36!>       - coarse grid namelist (namcrs) 
     37!>       - fine grid namelist (namfin) 
     38!>       - variable namelist (namvar) 
     39!>       - nesting namelist (namnst) 
     40!>       - boundary namelist (nambdy) 
     41!>       - output namelist (namout) 
     42!>  
     43!>    @note  
     44!>       All namelists have to be in file merge_bathy.nam,  
     45!>       however variables of those namelists are all optional. 
     46!> 
     47!>    * _logger namelist (namlog)_: 
     48!>       - cn_logfile   : logger filename 
     49!>       - cn_verbosity : verbosity ('trace','debug','info', 
     50!>  'warning','error','fatal','none') 
     51!>       - in_maxerror  : maximum number of error allowed 
     52!> 
     53!>    * _config namelist (namcfg)_: 
     54!>       - cn_varcfg : variable configuration file (see ./SIREN/cfg/variable.cfg) 
     55!> 
     56!>    * _coarse grid namelist (namcrs)_: 
     57!>       - cn_bathy0 : bathymetry file 
     58!>       - in_perio0 : NEMO periodicity index (see Model Boundary Condition in 
     59!> [NEMO documentation](http://www.nemo-ocean.eu/About-NEMO/Reference-manuals)) 
     60!> 
     61!>    * _fine grid namelist (namfin)_: 
     62!>       - cn_bathy1 : bathymetry file 
     63!>       - in_perio1 : NEMO periodicity index 
     64!> 
     65!>    * _variable namelist (namvar)_: 
     66!>       - cn_varinfo : list of variable and extra information about request(s)  
     67!>       to be used (separated by ',').<br/> 
     68!>          each elements of *cn_varinfo* is a string character.<br/> 
     69!>          it is composed of the variable name follow by ':',  
     70!>          then request(s) to be used on this variable.<br/>  
     71!>          request could be: 
     72!>             - int = interpolation method 
     73!>  
     74!>                requests must be separated by ';'.<br/> 
     75!>                order of requests does not matter.<br/> 
     76!> 
     77!>          informations about available method could be find in  
     78!>          @ref interp modules.<br/> 
     79!>          Example: 'bathymetry: int=cubic' 
     80!>          @note  
     81!>             If you do not specify a method which is required,  
     82!>             default one is apply. 
     83!>          @warning  
     84!>             variable name must be __Bathymetry__ here. 
     85!> 
     86!>    * _nesting namelist (namnst)_: 
     87!>       - in_rhoi  : refinement factor in i-direction 
     88!>       - in_rhoj  : refinement factor in j-direction 
     89!> 
     90!>    * _boundary namelist (nambdy)_: 
     91!>       - ln_north : use north boundary or not 
     92!>       - ln_south : use south boundary or not 
     93!>       - ln_east  : use east  boundary or not 
     94!>       - ln_west  : use west  boundary or not 
     95!>       - cn_north : north boundary indices on fine grid<br/> 
     96!>          *cn_north* is a string character defining boundary 
     97!>          segmentation.<br/> 
     98!>          segments are separated by '|'.<br/> 
     99!>          each segments of the boundary is composed of: 
     100!>             - indice of velocity (orthogonal to boundary .ie.  
     101!>                for north boundary, J-indice).  
     102!>             - indice of segment start (I-indice for north boundary)  
     103!>             - indice of segment end   (I-indice for north boundary)<br/> 
     104!>                indices must be separated by ':' .<br/> 
     105!>             - optionally, boundary size could be added between '(' and ')'  
     106!>             in the first segment defined. 
     107!>                @note  
     108!>                   boundary size is the same for all segments of one boundary. 
     109!> 
     110!>          Examples: 
     111!>             - cn_north='index1,first1:last1(width)' 
     112!>             - cn_north='index1(width),first1:last1|index2,first2:last2' 
     113!> 
     114!>       - cn_south : south boundary indices on fine grid<br/> 
     115!>       - cn_east  : east  boundary indices on fine grid<br/> 
     116!>       - cn_west  : west  boundary indices on fine grid<br/> 
     117!>       - ln_oneseg: use only one segment for each boundary or not 
     118!> 
     119!>    * _output namelist (namout)_: 
     120!>       - cn_fileout : merged bathymetry file 
     121!> 
     122!> @author J.Paul 
    22123! REVISION HISTORY: 
    23 !> @date Nov, 2013 - Initial Version 
    24 ! 
     124!> @date November, 2013 - Initial Version 
     125!> @date Sepember, 2014  
     126!> - add header for user 
     127!> @date July, 2015  
     128!> - extrapolate all land points 
     129!> - add attributes with boundary string character (as in namelist) 
     130!> 
    25131!> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
    26 !> 
    27 !> @todo 
    28132!---------------------------------------------------------------------- 
    29 !> @code 
    30133PROGRAM merge_bathy 
    31134 
     
    43146   USE boundary                        ! boundary manager 
    44147   USE iom                             ! I/O manager 
    45    USE dom                             ! domain manager 
    46148   USE grid                            ! grid manager 
    47149   USE extrap                          ! extrapolation manager 
     
    49151   USE filter                          ! filter manager 
    50152   USE mpp                             ! MPP manager 
     153   USE dom                             ! domain manager 
    51154   USE iom_mpp                         ! MPP I/O manager 
     155   USE iom_dom                         ! DOM I/O manager 
    52156 
    53157   IMPLICIT NONE 
     
    56160   CHARACTER(LEN=lc)                                  :: cl_namelist 
    57161   CHARACTER(LEN=lc)                                  :: cl_date 
     162   CHARACTER(LEN=lc)                                  :: cl_tmp 
    58163 
    59164   INTEGER(i4)                                        :: il_narg 
    60165   INTEGER(i4)                                        :: il_status 
    61166   INTEGER(i4)                                        :: il_fileid 
    62    INTEGER(i4)                                        :: il_attid 
     167   INTEGER(i4)                                        :: il_attind 
    63168   INTEGER(i4)                                        :: il_imin0 
    64169   INTEGER(i4)                                        :: il_imax0 
    65170   INTEGER(i4)                                        :: il_jmin0 
    66171   INTEGER(i4)                                        :: il_jmax0 
     172   INTEGER(i4)                                        :: il_shift 
    67173   INTEGER(i4)      , DIMENSION(ip_maxdim)            :: il_rho 
    68    INTEGER(i4)      , DIMENSION(2,2)                  :: il_offset 
    69    INTEGER(i4)      , DIMENSION(2,2,2)                :: il_ind 
    70 !   INTEGER(i4)      , DIMENSION(:,:,:,:), ALLOCATABLE :: il_value 
     174   INTEGER(i4)      , DIMENSION(2,2)                  :: il_ind 
    71175 
    72176   LOGICAL                                            :: ll_exist 
     
    76180   REAL(dp)         , DIMENSION(:,:,:,:), ALLOCATABLE :: dl_weight 
    77181 
    78    TYPE(TFILE)                                        :: tl_bathy0 
    79    TYPE(TFILE)                                        :: tl_bathy1 
     182   TYPE(TMPP)                                         :: tl_bathy0 
     183   TYPE(TMPP)                                         :: tl_bathy1 
    80184   TYPE(TFILE)                                        :: tl_fileout 
    81185    
     
    85189   TYPE(TVAR)                                         :: tl_lon 
    86190   TYPE(TVAR)                                         :: tl_lat 
    87 !   TYPE(TVAR)                                         :: tl_depth 
    88 !   TYPE(TVAR)                                         :: tl_time 
    89191    
    90192   TYPE(TDIM)       , DIMENSION(ip_maxdim)            :: tl_dim 
     
    98200 
    99201   ! namelist variable 
     202   ! namlog 
    100203   CHARACTER(LEN=lc)                       :: cn_logfile = 'merge_bathy.log'  
    101204   CHARACTER(LEN=lc)                       :: cn_verbosity = 'warning'  
    102  
     205   INTEGER(i4)                             :: in_maxerror = 5 
     206 
     207   ! namcfg 
     208   CHARACTER(LEN=lc)                       :: cn_varcfg = 'variable.cfg'  
     209 
     210   ! namcrs 
    103211   CHARACTER(LEN=lc)                       :: cn_bathy0 = ''  
    104212   INTEGER(i4)                             :: in_perio0 = -1 
    105213 
     214   ! namfin 
    106215   CHARACTER(LEN=lc)                       :: cn_bathy1 = ''  
    107216   INTEGER(i4)                             :: in_perio1 = -1 
    108217 
    109    CHARACTER(LEN=lc)                       :: cn_varcfg = 'variable.cfg'  
    110  
    111    CHARACTER(LEN=lc), DIMENSION(ig_maxvar) :: cn_varinfo = '' 
    112  
    113    INTEGER(i4)                             :: in_imin0 = 0 
    114    INTEGER(i4)                             :: in_imax0 = 0 
    115    INTEGER(i4)                             :: in_jmin0 = 0 
    116    INTEGER(i4)                             :: in_jmax0 = 0 
     218   ! namvar 
     219   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varinfo = '' 
     220 
     221   ! namnst 
    117222   INTEGER(i4)                             :: in_rhoi  = 0 
    118223   INTEGER(i4)                             :: in_rhoj  = 0 
    119224 
     225   ! nambdy 
    120226   LOGICAL                                 :: ln_north = .TRUE. 
    121227   LOGICAL                                 :: ln_south = .TRUE. 
     
    128234   CHARACTER(LEN=lc)                       :: cn_west  = '' 
    129235 
     236   ! namout 
    130237   CHARACTER(LEN=lc)                       :: cn_fileout = 'bathy_merged.nc'  
    131238   !------------------------------------------------------------------- 
     
    133240   NAMELIST /namlog/ &  !< logger namelist 
    134241   &  cn_logfile,    &  !< log file 
    135    &  cn_verbosity      !< log verbosity 
     242   &  cn_verbosity,  &  !< log verbosity 
     243   &  in_maxerror       !< logger maximum error 
    136244 
    137245   NAMELIST /namcfg/ &  !< config namelist 
     
    152260    
    153261   NAMELIST /namnst/ &  !< nesting namelist 
    154    &  in_imin0,   &     !< i-direction lower left  point indice on coarse grid  
    155    &  in_imax0,   &     !< i-direction upper right point indice on coarse grid 
    156    &  in_jmin0,   &     !< j-direction lower left  point indice on coarse grid 
    157    &  in_jmax0,   &     !< j-direction upper right point indice on coarse grid 
    158262   &  in_rhoi,    &     !< refinement factor in i-direction 
    159263   &  in_rhoj           !< refinement factor in j-direction 
     
    171275 
    172276   NAMELIST /namout/ &  !< output namelist 
    173    &  cn_fileout       !< fine grid merged bathymetry file    
     277   &  cn_fileout        !< fine grid merged bathymetry file    
    174278   !------------------------------------------------------------------- 
    175279 
    176    !1- namelist 
    177    !1-1 get namelist 
     280   ! namelist 
     281   ! get namelist 
    178282   il_narg=COMMAND_ARGUMENT_COUNT() !f03 intrinsec 
    179283   IF( il_narg/=1 )THEN 
     
    184288   ENDIF 
    185289    
    186    !1-2 read namelist 
     290   ! read namelist 
    187291   INQUIRE(FILE=TRIM(cl_namelist), EXIST=ll_exist) 
    188292   IF( ll_exist )THEN 
     
    203307 
    204308      READ( il_fileid, NML = namlog ) 
    205       !1-2-1 define log file 
    206       CALL logger_open(TRIM(cn_logfile),TRIM(cn_verbosity)) 
     309      ! define log file 
     310      CALL logger_open(TRIM(cn_logfile),TRIM(cn_verbosity),in_maxerror) 
    207311      CALL logger_header() 
    208312 
    209313      READ( il_fileid, NML = namcfg ) 
    210       !1-2-2 get variable extra information 
     314      ! get variable extra information 
    211315      CALL var_def_extra(TRIM(cn_varcfg)) 
    212316 
     
    214318      READ( il_fileid, NML = namfin ) 
    215319      READ( il_fileid, NML = namvar ) 
    216       !1-2-3 add user change in extra information 
     320      ! add user change in extra information 
    217321      CALL var_chg_extra(cn_varinfo) 
    218322 
     
    234338   ENDIF 
    235339 
    236    !2- open files 
     340   ! open files 
    237341   IF( TRIM(cn_bathy0) /= '' )THEN 
    238       tl_bathy0=file_init(TRIM(cn_bathy0),id_perio=in_perio0) 
    239       CALL iom_open(tl_bathy0) 
     342      tl_bathy0=mpp_init( file_init(TRIM(cn_bathy0)), id_perio=in_perio0) 
     343      CALL grid_get_info(tl_bathy0) 
    240344   ELSE 
    241345      CALL logger_fatal("MERGE BATHY: can not find coarse grid bathymetry "//& 
     
    244348 
    245349   IF( TRIM(cn_bathy1) /= '' )THEN 
    246       tl_bathy1=file_init(TRIM(cn_bathy1),id_perio=in_perio1) 
    247       CALL iom_open(tl_bathy1) 
     350      tl_bathy1=mpp_init( file_init(TRIM(cn_bathy1)), id_perio=in_perio1) 
     351      CALL grid_get_info(tl_bathy1) 
    248352   ELSE 
    249353      CALL logger_fatal("MERGE BATHY: can not find fine grid bathymetry "//& 
     
    251355   ENDIF 
    252356 
    253    !3- check 
    254    !3-1 check output file do not already exist 
     357   ! check 
     358   ! check output file do not already exist 
    255359   INQUIRE(FILE=TRIM(cn_fileout), EXIST=ll_exist) 
    256360   IF( ll_exist )THEN 
     
    259363   ENDIF 
    260364 
    261    !3-2 check namelist 
    262    !3-2-1 check refinament factor 
     365   ! check namelist 
     366   ! check refinament factor 
    263367   il_rho(:)=1 
    264368   IF( in_rhoi < 1 .OR. in_rhoj < 1 )THEN 
     
    270374   ENDIF 
    271375 
    272    !3-2-2 check domain indices 
    273    IF( in_imin0 < 1 .OR. in_imax0 < 1 .OR. in_jmin0 < 1 .OR. in_jmax0 < 1)THEN 
    274       ! compute coarse grid indices around fine grid 
    275       il_ind(:,:,:)=grid_get_coarse_index(tl_bathy0, tl_bathy1 ) 
    276  
    277       il_imin0=il_ind(1,1,1) ; il_imax0=il_ind(1,2,1) 
    278       il_jmin0=il_ind(2,1,1) ; il_jmax0=il_ind(2,2,1) 
    279  
    280       il_offset(:,:)=il_ind(:,:,2) 
    281    ELSE 
    282       il_imin0=in_imin0 ; il_imax0=in_imax0 
    283       il_jmin0=in_jmin0 ; il_jmax0=in_jmax0 
    284  
    285       il_offset(1,:)=FLOOR(REAL(il_rho(jp_I)-1,dp)*0.5) 
    286       il_offset(2,:)=FLOOR(REAL(il_rho(jp_J)-1,dp)*0.5) 
    287    ENDIF 
    288  
    289    !3-3 check domain validity 
     376   ! check domain indices 
     377   ! compute coarse grid indices around fine grid 
     378   il_ind(:,:)=grid_get_coarse_index(tl_bathy0, tl_bathy1, & 
     379   &                                 id_rho=il_rho(:) ) 
     380 
     381   il_imin0=il_ind(1,1) ; il_imax0=il_ind(1,2) 
     382   il_jmin0=il_ind(2,1) ; il_jmax0=il_ind(2,2) 
     383 
     384   ! check domain validity 
    290385   CALL grid_check_dom(tl_bathy0, il_imin0, il_imax0, il_jmin0, il_jmax0) 
    291386 
    292    !3-4 check coincidence between coarse and fine grid 
     387   ! check coincidence between coarse and fine grid 
    293388   CALL grid_check_coincidence( tl_bathy0, tl_bathy1, & 
    294389   &                            il_imin0, il_imax0, & 
     
    296391   &                            il_rho(:) ) 
    297392 
    298    !4- read or compute boundary 
    299    tl_var=iom_read_var(tl_bathy1,'Bathymetry') 
     393   ! open mpp files 
     394   CALL iom_mpp_open(tl_bathy1) 
     395 
     396   ! read or compute boundary 
     397   tl_var=iom_mpp_read_var(tl_bathy1,'Bathymetry') 
     398 
     399   ! close mpp files 
     400   CALL iom_mpp_close(tl_bathy1) 
    300401 
    301402   tl_bdy(:)=boundary_init(tl_var, ln_north, ln_south, ln_east, ln_west, & 
     
    303404   &                               ln_oneseg )  
    304405 
    305    !5- get boundary on coarse grid 
    306    !5-1 define refined bathymetry table (for coarse grid) 
     406   ! get boundary on coarse grid 
     407   ! define refined bathymetry array (for coarse grid) 
    307408   dl_fill=tl_var%d_fill 
    308409   ALLOCATE( dl_refined(tl_var%t_dim(1)%i_len, & 
     
    313414   dl_refined(:,:,:,:)=dl_fill 
    314415 
    315    !5-2 define weight table 
     416   ! define weight array 
    316417   ALLOCATE( dl_weight(tl_var%t_dim(1)%i_len, & 
    317418   &                   tl_var%t_dim(2)%i_len, & 
     
    320421   dl_weight(:,:,:,:)=dl_fill  
    321422 
    322    !5-3 compute coarse grid refined bathymetry on boundary. 
     423   ! compute coarse grid refined bathymetry on boundary. 
    323424   DO jk=1,ip_ncard 
    324  
    325425      CALL merge_bathy_get_boundary(tl_bathy0, tl_bathy1, tl_bdy(jk), & 
    326426      &                             il_rho(:),                        & 
     
    330430   ENDDO 
    331431 
    332    !6- merge bathy on boundary 
     432   ! merge bathy on boundary 
    333433   DO jl=1,tl_var%t_dim(4)%i_len 
    334434      DO jk=1,tl_var%t_dim(3)%i_len 
     
    348448   DEALLOCATE(dl_refined) 
    349449 
    350    !7- create file 
     450   ! create file 
    351451   tl_fileout=file_init(TRIM(cn_fileout),id_perio=in_perio1) 
    352452 
    353    !7-1 add dimension 
    354    tl_dim(:)=tl_var%t_dim(:) 
     453   ! add dimension 
     454   tl_dim(:)=dim_copy(tl_var%t_dim(:)) 
    355455 
    356456   DO ji=1,ip_maxdim 
     
    358458   ENDDO 
    359459 
    360    !7-2 add variables 
     460   ! add variables 
    361461   IF( ALL( tl_dim(1:2)%l_use ) )THEN 
    362  
    363       tl_lon=iom_read_var(tl_bathy1,'longitude') 
     462      ! open mpp files 
     463      CALL iom_mpp_open(tl_bathy1) 
     464 
     465      ! add longitude 
     466      tl_lon=iom_mpp_read_var(tl_bathy1,'longitude') 
    364467      CALL file_add_var(tl_fileout, tl_lon) 
    365468      CALL var_clean(tl_lon) 
    366469 
    367       tl_lat=iom_read_var(tl_bathy1,'latitude') 
     470      ! add latitude 
     471      tl_lat=iom_mpp_read_var(tl_bathy1,'latitude') 
    368472      CALL file_add_var(tl_fileout, tl_lat) 
    369473      CALL var_clean(tl_lat) 
    370474 
     475      ! close mpp files 
     476      CALL iom_mpp_close(tl_bathy1)       
    371477   ENDIF 
    372478 
     
    375481 
    376482   ! only 2 first dimension to be used 
    377    tl_dim(:)=tl_fileout%t_dim(:) 
     483   tl_dim(:)=dim_copy(tl_fileout%t_dim(:)) 
    378484   tl_dim(3:4)%l_use=.FALSE. 
    379485   tl_var=var_init('weight',dl_weight(:,:,:,:),td_dim=tl_dim(:),dd_fill=dl_fill) 
     
    381487   CALL var_clean(tl_var) 
    382488 
    383    !7-3 add some attribute 
     489   ! add some attribute 
    384490   tl_att=att_init("Created_by","SIREN merge_bathy") 
    385491   CALL file_add_att(tl_fileout, tl_att) 
     
    395501   CALL file_add_att(tl_fileout, tl_att) 
    396502 
    397    ! a voir 
    398503   ! add attribute periodicity 
    399    il_attid=0 
     504   il_attind=0 
    400505   IF( ASSOCIATED(tl_fileout%t_att) )THEN 
    401       il_attid=att_get_id(tl_fileout%t_att(:),'periodicity') 
    402    ENDIF 
    403    IF( tl_bathy1%i_perio >= 0 .AND. il_attid == 0 )THEN 
     506      il_attind=att_get_index(tl_fileout%t_att(:),'periodicity') 
     507   ENDIF 
     508   IF( tl_bathy1%i_perio >= 0 .AND. il_attind == 0 )THEN 
    404509      tl_att=att_init('periodicity',tl_bathy1%i_perio) 
    405510      CALL file_add_att(tl_fileout,tl_att) 
    406511   ENDIF 
    407512 
    408    il_attid=0 
     513   il_attind=0 
    409514   IF( ASSOCIATED(tl_fileout%t_att) )THEN 
    410       il_attid=att_get_id(tl_fileout%t_att(:),'ew_overlap') 
    411    ENDIF 
    412    IF( tl_bathy1%i_ew >= 0 .AND. il_attid == 0 )THEN 
     515      il_attind=att_get_index(tl_fileout%t_att(:),'ew_overlap') 
     516   ENDIF 
     517   IF( tl_bathy1%i_ew >= 0 .AND. il_attind == 0 )THEN 
    413518      tl_att=att_init('ew_overlap',tl_bathy1%i_ew) 
    414519      CALL file_add_att(tl_fileout,tl_att) 
    415520   ENDIF 
    416521 
    417    !7-4 create file 
     522 
     523   IF( tl_bdy(jp_north)%l_use )THEN 
     524      ! add shift on north boundary 
     525      ! boundary compute on T point but express on U or V point 
     526      il_shift=1 
     527 
     528      cl_tmp=TRIM(fct_str(tl_bdy(jp_north)%t_seg(1)%i_index-il_shift))//','//& 
     529         &   TRIM(fct_str(tl_bdy(jp_north)%t_seg(1)%i_first))//':'//& 
     530         &   TRIM(fct_str(tl_bdy(jp_north)%t_seg(1)%i_last))//& 
     531         &   '('//TRIM(fct_str(tl_bdy(jp_north)%t_seg(1)%i_width))//')' 
     532      DO ji=2,tl_bdy(jp_north)%i_nseg 
     533         cl_tmp=TRIM(cl_tmp)//'|'//& 
     534            &   TRIM(fct_str(tl_bdy(jp_north)%t_seg(ji)%i_index-il_shift))//','//& 
     535            &   TRIM(fct_str(tl_bdy(jp_north)%t_seg(ji)%i_first))//':'//& 
     536            &   TRIM(fct_str(tl_bdy(jp_north)%t_seg(ji)%i_last)) 
     537      ENDDO 
     538      tl_att=att_init("bdy_north",TRIM(cl_tmp)) 
     539      CALL file_add_att(tl_fileout, tl_att) 
     540   ENDIF 
     541 
     542   IF( tl_bdy(jp_south)%l_use )THEN 
     543       
     544      cl_tmp=TRIM(fct_str(tl_bdy(jp_south)%t_seg(1)%i_index))//','//& 
     545         &   TRIM(fct_str(tl_bdy(jp_south)%t_seg(1)%i_first))//':'//& 
     546         &   TRIM(fct_str(tl_bdy(jp_south)%t_seg(1)%i_last))//& 
     547         &   '('//TRIM(fct_str(tl_bdy(jp_south)%t_seg(1)%i_width))//')' 
     548      DO ji=2,tl_bdy(jp_south)%i_nseg 
     549         cl_tmp=TRIM(cl_tmp)//'|'//& 
     550            &   TRIM(fct_str(tl_bdy(jp_south)%t_seg(ji)%i_index))//','//& 
     551            &   TRIM(fct_str(tl_bdy(jp_south)%t_seg(ji)%i_first))//':'//& 
     552            &   TRIM(fct_str(tl_bdy(jp_south)%t_seg(ji)%i_last)) 
     553      ENDDO 
     554 
     555      tl_att=att_init("bdy_south",TRIM(cl_tmp)) 
     556      CALL file_add_att(tl_fileout, tl_att) 
     557   ENDIF 
     558 
     559   IF( tl_bdy(jp_east)%l_use )THEN 
     560      ! add shift on east boundary 
     561      ! boundary compute on T point but express on U or V point 
     562      il_shift=1 
     563 
     564      cl_tmp=TRIM(fct_str(tl_bdy(jp_east)%t_seg(1)%i_index-il_shift))//','//& 
     565         &   TRIM(fct_str(tl_bdy(jp_east)%t_seg(1)%i_first))//':'//& 
     566         &   TRIM(fct_str(tl_bdy(jp_east)%t_seg(1)%i_last))//& 
     567         &   '('//TRIM(fct_str(tl_bdy(jp_east)%t_seg(1)%i_width))//')' 
     568      DO ji=2,tl_bdy(jp_east)%i_nseg 
     569         cl_tmp=TRIM(cl_tmp)//'|'//& 
     570            &   TRIM(fct_str(tl_bdy(jp_east)%t_seg(ji)%i_index-il_shift))//','//& 
     571            &   TRIM(fct_str(tl_bdy(jp_east)%t_seg(ji)%i_first))//':'//& 
     572            &   TRIM(fct_str(tl_bdy(jp_east)%t_seg(ji)%i_last)) 
     573      ENDDO 
     574 
     575      tl_att=att_init("bdy_east",TRIM(cl_tmp)) 
     576      CALL file_add_att(tl_fileout, tl_att) 
     577   ENDIF 
     578 
     579   IF( tl_bdy(jp_west)%l_use )THEN 
     580 
     581      cl_tmp=TRIM(fct_str(tl_bdy(jp_west)%t_seg(1)%i_index))//','//& 
     582         &   TRIM(fct_str(tl_bdy(jp_west)%t_seg(1)%i_first))//':'//& 
     583         &   TRIM(fct_str(tl_bdy(jp_west)%t_seg(1)%i_last))//& 
     584         &   '('//TRIM(fct_str(tl_bdy(jp_west)%t_seg(1)%i_width))//')' 
     585      DO ji=2,tl_bdy(jp_west)%i_nseg 
     586         cl_tmp=TRIM(cl_tmp)//'|'//& 
     587            &   TRIM(fct_str(tl_bdy(jp_west)%t_seg(ji)%i_index))//','//& 
     588            &   TRIM(fct_str(tl_bdy(jp_west)%t_seg(ji)%i_first))//':'//& 
     589            &   TRIM(fct_str(tl_bdy(jp_west)%t_seg(ji)%i_last)) 
     590      ENDDO 
     591 
     592      tl_att=att_init("bdy_west",TRIM(cl_tmp)) 
     593      CALL file_add_att(tl_fileout, tl_att) 
     594   ENDIF 
     595 
     596   ! create file 
    418597   CALL iom_create(tl_fileout) 
    419598 
    420    !7-5 write file 
     599   ! write file 
    421600   CALL iom_write_file(tl_fileout) 
    422601 
    423    !7-6 close file 
     602   ! close file 
    424603   CALL iom_close(tl_fileout) 
    425604 
    426    CALL iom_close(tl_bathy1) 
    427    CALL iom_close(tl_bathy0) 
    428  
    429    !8- clean 
     605   ! clean 
     606   CALL att_clean(tl_att) 
    430607   CALL file_clean(tl_fileout) 
    431    CALL file_clean(tl_bathy1) 
    432    CALL file_clean(tl_bathy0) 
     608   CALL mpp_clean(tl_bathy1) 
     609   CALL mpp_clean(tl_bathy0) 
    433610   DEALLOCATE(dl_weight) 
     611   CALL boundary_clean(tl_bdy(:)) 
    434612 
    435613   ! close log file 
     
    437615   CALL logger_close() 
    438616 
    439 !> @endcode 
    440617CONTAINS 
    441618   !------------------------------------------------------------------- 
    442619   !> @brief 
    443    !> This subroutine 
     620   !> This subroutine compute refined bathymetry on boundary from coarse grid. 
    444621   !>  
    445    !> @details  
     622   !> @author J.Paul 
     623   !> @date November, 2013 - Initial Version 
    446624   !> 
    447    !> @author J.Paul 
    448    !> - Nov, 2013- Initial Version 
    449    !> 
    450    !> @param[in]  
    451    !> @todo  
     625   !> @param[in] td_bathy0       coarse grid bathymetry file structure  
     626   !> @param[in] td_bathy1       fine grid bathymetry file structure 
     627   !> @param[in] td_bdy          boundary structure 
     628   !> @param[in] id_rho          array of refinement factor 
     629   !> @param[inout] dd_refined   array of refined bathymetry  
     630   !> @param[inout] dd_weight    array of weight 
     631   !> @param[in] dd_fill         fillValue 
    452632   !------------------------------------------------------------------- 
    453    !> @code 
    454633   SUBROUTINE merge_bathy_get_boundary( td_bathy0, td_bathy1, td_bdy, & 
    455634   &                                    id_rho,                       & 
     
    459638 
    460639      ! Argument 
    461       TYPE(TFILE)                    , INTENT(IN   ) :: td_bathy0 
    462       TYPE(TFILE)                    , INTENT(IN   ) :: td_bathy1 
     640      TYPE(TMPP)                     , INTENT(IN   ) :: td_bathy0 
     641      TYPE(TMPP)                     , INTENT(IN   ) :: td_bathy1 
    463642      TYPE(TBDY)                     , INTENT(IN   ) :: td_bdy 
    464643      INTEGER(i4), DIMENSION(:)      , INTENT(IN   ) :: id_rho 
     
    478657      INTEGER(i4) :: il_jmax0 
    479658 
    480       INTEGER(i4) :: il_imin 
    481       INTEGER(i4) :: il_imax 
    482       INTEGER(i4) :: il_jmin 
    483       INTEGER(i4) :: il_jmax 
    484  
    485659      INTEGER(i4), DIMENSION(2,2)         :: il_offset 
    486       INTEGER(i4), DIMENSION(2,2,2)       :: il_ind 
     660      INTEGER(i4), DIMENSION(2,2       :: il_ind 
    487661 
    488662      REAL(dp)   , DIMENSION(:)      , ALLOCATABLE :: dl_tmp1d 
     
    494668      TYPE(TVAR) :: tl_lat1 
    495669 
    496       TYPE(TFILE) :: tl_bathy1 
    497       TYPE(TFILE) :: tl_bathy0 
    498  
    499       TYPE(TMPP)  :: tl_mppbathy1 
    500       TYPE(TMPP)  :: tl_mppbathy0 
     670      TYPE(TMPP)  :: tl_bathy1 
     671      TYPE(TMPP)  :: tl_bathy0 
    501672 
    502673      TYPE(TDOM)  :: tl_dom1 
     
    510681      IF( td_bdy%l_use )THEN 
    511682         DO jl=1,td_bdy%i_nseg 
    512              
    513             !1- get boundary definition 
     683            ! get boundary definition 
    514684            SELECT CASE(TRIM(td_bdy%c_card)) 
    515685            CASE('north') 
     
    520690               il_jmax1=td_bdy%t_seg(jl)%i_index 
    521691 
    522                il_imin=1 
    523                il_imax=il_imax1-il_imin1+1 
    524                il_jmin=td_bdy%t_seg(jl)%i_width 
    525                il_jmax=1 
    526  
    527692            CASE('south') 
    528693 
     
    532697               il_jmax1=td_bdy%t_seg(jl)%i_index+(td_bdy%t_seg(jl)%i_width-1) 
    533698 
    534                il_imin=1 
    535                il_imax=il_imax1-il_imin1+1 
    536                il_jmin=1 
    537                il_jmax=td_bdy%t_seg(jl)%i_width 
    538                 
    539699            CASE('east') 
    540700 
     
    544704               il_jmax1=td_bdy%t_seg(jl)%i_last  
    545705 
    546                il_imin=td_bdy%t_seg(jl)%i_width 
    547                il_imax=1 
    548                il_jmin=1 
    549                il_jmax=il_jmax1-il_jmin1+1 
    550  
    551706            CASE('west') 
    552707 
     
    556711               il_jmax1=td_bdy%t_seg(jl)%i_last  
    557712 
    558                il_imin=1 
    559                il_imax=td_bdy%t_seg(jl)%i_width 
    560                il_jmin=1 
    561                il_jmax=il_jmax1-il_jmin1+1 
    562  
    563713            END SELECT 
    564714 
    565             !2 -read fine grid domain 
    566             tl_bathy1=td_bathy1 
    567             CALL iom_open(tl_bathy1) 
    568  
    569             !2-1 compute domain 
     715            ! -read fine grid domain 
     716            tl_bathy1=mpp_copy(td_bathy1) 
     717 
     718            ! compute domain 
    570719            tl_dom1=dom_init( tl_bathy1,         & 
    571720            &                 il_imin1, il_imax1,& 
    572             &                 il_jmin1, il_jmax1 ) 
    573  
    574             !2-2 close file 
    575             CALL iom_close(tl_bathy1) 
    576  
    577             !2-3 read variables on domain (ugly way to do it, have to work on it) 
    578             !2-3-1 init mpp structure 
    579             tl_mppbathy1=mpp_init(tl_bathy1) 
    580   
    581             CALL file_clean(tl_bathy1) 
    582  
    583             !2-3-2 get processor to be used 
    584             CALL mpp_get_use( tl_mppbathy1, tl_dom1 ) 
    585  
    586             !2-3-3 open mpp files 
    587             CALL iom_mpp_open(tl_mppbathy1) 
    588  
    589             !2-3-4 read variable value on domain 
    590             tl_lon1=iom_mpp_read_var(tl_mppbathy1,'longitude',td_dom=tl_dom1) 
    591             tl_lat1=iom_mpp_read_var(tl_mppbathy1,'latitude' ,td_dom=tl_dom1) 
    592  
    593             !2-3-5 close mpp files 
    594             CALL iom_mpp_close(tl_mppbathy1) 
    595  
    596             !2-3-6 clean structure 
    597             CALL mpp_clean(tl_mppbathy1) 
    598  
    599             !3- get coarse grid indices 
    600             il_ind(:,:,:)=grid_get_coarse_index(td_bathy0, tl_lon1, tl_lat1, & 
    601             &                                   id_rho=id_rho(:)) 
    602  
    603             il_imin0=il_ind(1,1,1) 
    604             il_imax0=il_ind(1,2,1) 
    605  
    606             il_jmin0=il_ind(2,1,1) 
    607             il_jmax0=il_ind(2,2,1) 
    608  
    609             il_offset(:,:)=il_ind(:,:,2) 
    610  
    611             !4- read coarse grid bathymetry on domain 
    612             tl_bathy0=td_bathy0 
    613             CALL iom_open(tl_bathy0) 
    614  
    615             !4-1 compute domain 
     721            &                 il_jmin1, il_jmax1,& 
     722            &                 TRIM(td_bdy%c_card)) 
     723 
     724            ! add extra band to fine grid domain (if possible) 
     725            ! to avoid dimension of one and so be able to compute offset 
     726            CALL dom_add_extra(tl_dom1, id_rho(jp_I), id_rho(jp_J)) 
     727 
     728            ! open mpp files over domain 
     729            CALL iom_dom_open(tl_bathy1, tl_dom1) 
     730 
     731            ! read variable value on domain 
     732            tl_lon1=iom_dom_read_var(tl_bathy1,'longitude',tl_dom1) 
     733            tl_lat1=iom_dom_read_var(tl_bathy1,'latitude' ,tl_dom1) 
     734 
     735            ! close mpp files 
     736            CALL iom_dom_close(tl_bathy1) 
     737 
     738            ! clean structure 
     739            CALL mpp_clean(tl_bathy1) 
     740 
     741            ! get coarse grid indices 
     742            il_ind(:,:)=grid_get_coarse_index(td_bathy0, tl_lon1, tl_lat1, & 
     743            &                                 id_rho=id_rho(:)) 
     744 
     745            il_imin0=il_ind(1,1) 
     746            il_imax0=il_ind(1,2) 
     747 
     748            il_jmin0=il_ind(2,1) 
     749            il_jmax0=il_ind(2,2) 
     750 
     751            ! read coarse grid bathymetry on domain 
     752            tl_bathy0=mpp_copy(td_bathy0) 
     753 
     754            ! compute domain 
    616755            tl_dom0=dom_init( tl_bathy0,         & 
    617756            &                 il_imin0, il_imax0,& 
    618757            &                 il_jmin0, il_jmax0 ) 
    619758 
    620             !4-2 close file 
    621             CALL iom_close(tl_bathy0) 
    622  
    623             !4-3 add extra band (if possible) to compute interpolation 
     759            il_offset(:,:)= grid_get_fine_offset(tl_bathy0,         & 
     760            &                                    il_imin0, il_jmin0,& 
     761            &                                    il_imax0, il_jmax0,& 
     762            &                                    tl_lon1%d_value(:,:,1,1), & 
     763            &                                    tl_lat1%d_value(:,:,1,1), & 
     764            &                                    id_rho=id_rho(:)) 
     765 
     766            ! clean 
     767            CALL var_clean(tl_lon1) 
     768            CALL var_clean(tl_lat1) 
     769 
     770            ! add extra band (if possible) to compute interpolation 
    624771            CALL dom_add_extra(tl_dom0) 
    625772 
    626             !4-4 read variables on domain (ugly way to do it, have to work on it) 
    627             !4-4-1 init mpp structure 
    628             tl_mppbathy0=mpp_init(tl_bathy0) 
    629              
    630             CALL file_clean(tl_bathy0) 
    631  
    632             !4-4-2 get processor to be used 
    633             CALL mpp_get_use( tl_mppbathy0, tl_dom0 ) 
    634  
    635             !4-4-3 open mpp files 
    636             CALL iom_mpp_open(tl_mppbathy0) 
    637  
    638             !4-4-4 read variable value on domain 
    639             tl_var0=iom_mpp_read_var(tl_mppbathy0,'Bathymetry',td_dom=tl_dom0) 
    640  
    641             !4-4-5 close mpp files 
    642             CALL iom_mpp_close(tl_mppbathy0) 
    643  
    644             !4-4-6 clean structure 
    645             CALL mpp_clean(tl_mppbathy0) 
    646  
    647             !5- interpolate variable 
     773            ! open mpp files over domain 
     774            CALL iom_dom_open(tl_bathy0, tl_dom0) 
     775 
     776            ! read variable value on domain 
     777            tl_var0=iom_dom_read_var(tl_bathy0,'Bathymetry',tl_dom0) 
     778 
     779            ! close mpp files 
     780            CALL iom_dom_close(tl_bathy0) 
     781 
     782            ! clean structure 
     783            CALL mpp_clean(tl_bathy0) 
     784 
     785            ! interpolate variable 
    648786            CALL merge_bathy_interp( tl_var0,         & 
    649787            &                        id_rho(:),       & 
    650788            &                        il_offset(:,:) ) 
    651789 
    652             !6- remove extraband added to domain 
     790            ! remove extraband added to domain 
    653791            CALL dom_del_extra( tl_var0, tl_dom0, id_rho(:) ) 
    654792 
    655             !6-1 remove extraband added to domain 
     793            ! remove extraband added to domain 
    656794            CALL dom_clean_extra( tl_dom0 ) 
    657795 
    658             !7- fill refined table   
    659             !7-1 keep only useful point 
    660             ! interpolation could create more point than necessary 
    661             CALL boundary_clean_interp(tl_var0, td_bdy ) 
    662  
    663             ! use add request ???? 
    664  
    665             !7-2 fill refined table 
     796            ! remove extraband added to fine grid domain 
     797            CALL dom_del_extra( tl_var0, tl_dom1 ) 
     798 
     799            ! remove extraband added to fine grid domain 
     800            CALL dom_clean_extra( tl_dom1 ) 
     801 
     802            ! fill refined array 
    666803            dd_refined( il_imin1:il_imax1, & 
    667804            &           il_jmin1:il_jmax1, & 
    668805            &           :,: )= tl_var0%d_value(:,:,:,:) 
    669806 
    670             !8- compute weight function 
     807            ! clean 
     808            CALL var_clean(tl_var0) 
     809 
     810            ! compute weight function 
    671811            ALLOCATE( dl_tmp1d(td_bdy%t_seg(jl)%i_width) ) 
    672812 
     
    678818 
    679819               ! compute weight on segment 
    680                dl_tmp1d(:)= 0.5 + 0.5*COS( (dg_pi*dl_tmp1d(:)) / & 
     820               dl_tmp1d(:)= 0.5 + 0.5*COS( (dp_pi*dl_tmp1d(:)) / & 
    681821               &                           (td_bdy%t_seg(jl)%i_width) ) 
    682822 
     
    694834 
    695835               ! compute weight on segment 
    696                dl_tmp1d(:)= 0.5 + 0.5*COS( (dg_pi*dl_tmp1d(:)) / & 
     836               dl_tmp1d(:)= 0.5 + 0.5*COS( (dp_pi*dl_tmp1d(:)) / & 
    697837               &                           (td_bdy%t_seg(jl)%i_width) ) 
    698838 
     
    710850 
    711851               ! compute weight on segment 
    712                dl_tmp1d(:)= 0.5 + 0.5*COS( (dg_pi*dl_tmp1d(:)) / & 
     852               dl_tmp1d(:)= 0.5 + 0.5*COS( (dp_pi*dl_tmp1d(:)) / & 
    713853               &                           (td_bdy%t_seg(jl)%i_width) ) 
    714854 
     
    726866 
    727867               ! compute weight on segment 
    728                dl_tmp1d(:)= 0.5 + 0.5*COS( (dg_pi*dl_tmp1d(:)) / & 
     868               dl_tmp1d(:)= 0.5 + 0.5*COS( (dp_pi*dl_tmp1d(:)) / & 
    729869               &                           (td_bdy%t_seg(jl)%i_width) ) 
    730870 
     
    740880            DEALLOCATE( dl_tmp1d ) 
    741881 
    742             !8-1 fill weight table 
     882            ! fill weight array 
    743883            ALLOCATE( dl_tmp2d( tl_dom1%t_dim(1)%i_len, & 
    744884            &                   tl_dom1%t_dim(2)%i_len) ) 
     
    764904      ENDIF 
    765905   END SUBROUTINE merge_bathy_get_boundary 
    766    !> @endcode 
    767906   !------------------------------------------------------------------- 
    768907   !> @brief 
    769    !> This subroutine 
     908   !> This subroutine interpolate variable. 
    770909   !>  
    771    !> @details  
     910   !> @author J.Paul 
     911   !> @date November, 2013 - Initial Version 
    772912   !> 
    773    !> @author J.Paul 
    774    !> - Nov, 2013- Initial Version 
    775    !> 
    776    !> @param[in]  
    777    !> @todo  
     913   !> @param[inout] td_var variable structure 
     914   !> @param[in] id_rho    array of refinment factor 
     915   !> @param[in] id_offset array of offset between fine and coarse grid 
     916   !> @param[in] id_iext   i-direction size of extra bands (default=im_minext)  
     917   !> @param[in] id_jext   j-direction size of extra bands (default=im_minext) 
    778918   !------------------------------------------------------------------- 
    779    !> @code 
    780919   SUBROUTINE merge_bathy_interp( td_var,          & 
    781920   &                              id_rho,          & 
     
    793932 
    794933      ! local variable 
    795       TYPE(TVAR)  :: tl_var 
    796934      TYPE(TVAR)  :: tl_mask 
    797935 
     
    803941      ! loop indices 
    804942      !---------------------------------------------------------------- 
    805  
    806       ! copy variable 
    807       tl_var=td_var 
    808943 
    809944      !WARNING: two extrabands are required for cubic interpolation 
     
    815950 
    816951      IF( il_iext < 2 .AND. td_var%c_interp(1) == 'cubic' )THEN 
    817          CALL logger_warn("CREATE BATHY INTERP: at least extrapolation "//& 
     952         CALL logger_warn("MERGE BATHY INTERP: at least extrapolation "//& 
    818953         &  "on two points are required with cubic interpolation ") 
    819954         il_iext=2 
     
    821956 
    822957      IF( il_jext < 2 .AND. td_var%c_interp(1) == 'cubic' )THEN 
    823          CALL logger_warn("CREATE BATHY INTERP: at least extrapolation "//& 
     958         CALL logger_warn("MERGE BATHY INTERP: at least extrapolation "//& 
    824959         &  "on two points are required with cubic interpolation ") 
    825960         il_jext=2 
    826961      ENDIF 
    827962 
    828       !1- work on mask 
    829       !1-1 create mask 
    830       ALLOCATE(bl_mask(tl_var%t_dim(1)%i_len, & 
    831       &                tl_var%t_dim(2)%i_len, & 
    832       &                tl_var%t_dim(3)%i_len, & 
    833       &                tl_var%t_dim(4)%i_len) ) 
     963      ! work on mask 
     964      ! create mask 
     965      ALLOCATE(bl_mask(td_var%t_dim(1)%i_len, & 
     966      &                td_var%t_dim(2)%i_len, & 
     967      &                td_var%t_dim(3)%i_len, & 
     968      &                td_var%t_dim(4)%i_len) ) 
    834969 
    835970      bl_mask(:,:,:,:)=1 
    836       WHERE(tl_var%d_value(:,:,:,:)==tl_var%d_fill) bl_mask(:,:,:,:)=0       
    837  
    838       SELECT CASE(TRIM(tl_var%c_point)) 
     971      WHERE(td_var%d_value(:,:,:,:)==td_var%d_fill) bl_mask(:,:,:,:)=0       
     972 
     973      SELECT CASE(TRIM(td_var%c_point)) 
    839974      CASE DEFAULT ! 'T' 
    840          tl_mask=var_init('tmask', bl_mask(:,:,:,:), td_dim=tl_var%t_dim(:)) 
    841       CASE('U') 
    842          tl_mask=var_init('umask', bl_mask(:,:,:,:), td_dim=tl_var%t_dim(:)) 
    843       CASE('V') 
    844          tl_mask=var_init('vmask', bl_mask(:,:,:,:), td_dim=tl_var%t_dim(:)) 
    845       CASE('F') 
    846          tl_mask=var_init('fmask', bl_mask(:,:,:,:), td_dim=tl_var%t_dim(:)) 
     975         tl_mask=var_init('tmask',bl_mask(:,:,:,:),td_dim=td_var%t_dim(:),& 
     976         &                id_ew=td_var%i_ew ) 
     977      CASE('U','V','F') 
     978         CALL logger_fatal("MERGE BATHY INTERP: can not computed "//& 
     979         &                 "interpolation on "//TRIM(td_var%c_point)//& 
     980         &                 " grid point (variable "//TRIM(td_var%c_name)//& 
     981         &                 "). check namelist.") 
    847982      END SELECT 
    848983 
    849984      DEALLOCATE(bl_mask) 
    850985 
    851       !1-2 interpolate mask 
     986      ! interpolate mask 
    852987      CALL interp_fill_value( tl_mask, id_rho(:),  & 
    853988      &                       id_offset=id_offset(:,:) ) 
    854989 
    855       !2- work on variable 
    856       !2-0 add extraband 
    857       CALL extrap_add_extrabands(tl_var, il_iext, il_iext) 
    858  
    859       !2-1 extrapolate variable 
    860       CALL extrap_fill_value( tl_var, id_offset=id_offset(:,:), & 
    861       &                               id_rho=id_rho(:),         & 
    862       &                               id_iext=il_iext, id_jext=il_jext ) 
    863  
    864       !2-2 interpolate Bathymetry 
    865       CALL interp_fill_value( tl_var, id_rho(:), & 
     990      ! work on variable 
     991      ! add extraband 
     992      CALL extrap_add_extrabands(td_var, il_iext, il_iext) 
     993 
     994      ! extrapolate variable 
     995      CALL extrap_fill_value( td_var ) 
     996 
     997      ! interpolate Bathymetry 
     998      CALL interp_fill_value( td_var, id_rho(:), & 
    866999      &                       id_offset=id_offset(:,:) ) 
    8671000 
    868       !2-3 remove extraband 
    869       CALL extrap_del_extrabands(tl_var, il_iext*id_rho(jp_I), il_jext*id_rho(jp_J)) 
    870  
    871       !2-4 keep original mask  
     1001      ! remove extraband 
     1002      CALL extrap_del_extrabands(td_var, il_iext*id_rho(jp_I), il_jext*id_rho(jp_J)) 
     1003 
     1004      ! keep original mask  
    8721005      WHERE( tl_mask%d_value(:,:,:,:) == 0 ) 
    873          tl_var%d_value(:,:,:,:)=tl_var%d_fill 
     1006         td_var%d_value(:,:,:,:)=td_var%d_fill 
    8741007      END WHERE 
    8751008 
    876       !3- save result 
    877       td_var=tl_var 
    878  
    879       ! clean variable structure 
    880       CALL var_clean(tl_var) 
    881  
    8821009   END SUBROUTINE merge_bathy_interp 
    883    !> @endcode 
    8841010END PROGRAM merge_bathy 
Note: See TracChangeset for help on using the changeset viewer.