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 5942 for branches/UKMO/dev_r5518_Surge_Modelling/NEMOGCM/TOOLS/SIREN/src/create_boundary.f90 – NEMO

Ignore:
Timestamp:
2015-11-27T17:35:41+01:00 (8 years ago)
Author:
rfurner
Message:

merged bug fixes from vn3.6_stable to this branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/UKMO/dev_r5518_Surge_Modelling/NEMOGCM/TOOLS/SIREN/src/create_boundary.f90

    r5037 r5942  
    2323!>    ./SIREN/bin/create_boundary create_boundary.nam 
    2424!> @endcode 
    25 !>     
     25!>  <br/>  
     26!> \image html  boundary_NEATL36_70.png  
     27!> \image latex boundary_NEATL36_70.png 
     28!> 
     29!> @note  
     30!>    you could find a template of the namelist in templates directory. 
     31!> 
    2632!>    create_boundary.nam comprise 9 namelists:<br/> 
    2733!>       - logger namelist (namlog) 
     
    4248!>       - cn_logfile   : log filename 
    4349!>       - cn_verbosity : verbosity ('trace','debug','info', 
    44 !> 'warning','error','fatal') 
     50!> 'warning','error','fatal','none') 
    4551!>       - in_maxerror  : maximum number of error allowed 
    4652!> 
     
    7985!>    * _variable namelist (namvar)_:<br/> 
    8086!>       - cn_varinfo : list of variable and extra information about request(s) 
    81 !> to be used.<br/> 
     87!>          to be used (separated by ',').<br/> 
    8288!>          each elements of *cn_varinfo* is a string character.<br/> 
    8389!>          it is composed of the variable name follow by ':',  
    8490!>          then request(s) to be used on this variable.<br/>  
    8591!>          request could be: 
    86 !>             - interpolation method 
    87 !>             - extrapolation method 
    88 !>             - filter method 
     92!>             - int = interpolation method 
     93!>             - ext = extrapolation method 
     94!>             - flt = filter method 
     95!>             - unt = new units 
     96!>             - unf = unit scale factor (linked to new units) 
    8997!> 
    9098!>                requests must be separated by ';'.<br/> 
     
    94102!>          @ref extrap and @ref filter.<br/> 
    95103!> 
    96 !>          Example: 'votemper:linear;hann;dist_weight', 'vosaline:cubic' 
     104!>          Example: 'votemper:int=linear;flt=hann;ext=dist_weight', 'vosaline:int=cubic' 
    97105!>          @note  
    98106!>             If you do not specify a method which is required,  
     
    136144!>          segments are separated by '|'.<br/> 
    137145!>          each segments of the boundary is composed of: 
    138 !>             - orthogonal indice (.ie. for north boundary, 
    139 !>             J-indice where boundary are).  
    140 !>             - first indice of boundary (I-indice for north boundary)  
    141 !>             - last  indice of boundary (I-indice for north boundary)<br/> 
    142 !>                indices must be separated by ',' .<br/> 
     146!>             - indice of velocity (orthogonal to boundary .ie.  
     147!>                for north boundary, J-indice).  
     148!>             - indice of segemnt start (I-indice for north boundary)  
     149!>             - indice of segment end  (I-indice for north boundary)<br/> 
     150!>                indices must be separated by ':' .<br/> 
    143151!>             - optionally, boundary size could be added between '(' and ')'  
    144152!>             in the first segment defined. 
     
    147155!> 
    148156!>          Examples: 
    149 !>             - cn_north='index1,first1,last1(width)' 
    150 !>             - cn_north='index1(width),first1,last1|index2,first2,last2' 
    151 !> 
    152 !>          \image html  boundary_50.png  
    153 !>          \image latex boundary_50.png 
    154 !> 
     157!>             - cn_north='index1,first1:last1(width)' 
     158!>             - cn_north='index1(width),first1:last1|index2,first2:last2' 
     159!>             \image html  boundary_50.png  
     160!>             \image latex boundary_50.png 
    155161!>       - cn_south  : south boundary indices on fine grid 
    156162!>       - cn_east   : east  boundary indices on fine grid 
    157163!>       - cn_west   : west  boundary indices on fine grid 
    158164!>       - ln_oneseg : use only one segment for each boundary or not 
    159 !>       - in_extrap : number of mask point to be extrapolated 
    160 !> 
    161 !>   * _output namelist (namout)_:<br/> 
     165!> 
     166!>    * _output namelist (namout)_:<br/> 
    162167!>       - cn_fileout : fine grid boundary basename 
    163168!>         (cardinal and segment number will be automatically added) 
     169!>       - dn_dayofs  : date offset in day (change only ouput file name) 
     170!>       - ln_extrap  : extrapolate land point or not 
     171!> 
     172!>          Examples:  
     173!>             - cn_fileout=boundary.nc<br/> 
     174!>                if time_counter (16/07/2015 00h) is read on input file (see varfile),  
     175!>                west boundary will be named boundary_west_y2015m07d16 
     176!>             - dn_dayofs=-2.<br/> 
     177!>                if you use day offset you get boundary_west_y2015m07d14 
     178!>        
    164179!> 
    165180!> @author J.Paul 
     
    169184!> - add header for user 
    170185!> - take into account grid point to compue boundaries 
    171 !> - reorder output dimension for north and south boundaries  
     186!> - reorder output dimension for north and south boundaries 
     187!> @date June, 2015 
     188!> - extrapolate all land points, and add ln_extrap in namelist. 
     189!> - allow to change unit. 
     190!> @date July, 2015 
     191!> - add namelist parameter to shift date of output file name.   
    172192!> 
    173193!> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
     
    191211   USE dom                             ! domain manager 
    192212   USE grid                            ! grid manager 
    193    USE vgrid                           ! vartical grid manager 
     213   USE vgrid                           ! vertical grid manager 
    194214   USE extrap                          ! extrapolation manager 
    195215   USE interp                          ! interpolation manager 
     
    213233   INTEGER(i4)                                        :: il_status 
    214234   INTEGER(i4)                                        :: il_fileid 
    215    INTEGER(i4)                                        :: il_dim 
    216235   INTEGER(i4)                                        :: il_imin0 
    217236   INTEGER(i4)                                        :: il_imax0 
     
    239258 
    240259   TYPE(TDIM)       , DIMENSION(ip_maxdim)            :: tl_dim 
     260 
     261   TYPE(TDATE)                                        :: tl_date 
    241262    
    242263   TYPE(TBDY)       , DIMENSION(ip_ncard)             :: tl_bdy 
     
    265286   ! namelist variable 
    266287   ! namlog 
    267    CHARACTER(LEN=lc)                       :: cn_logfile = 'create_boundary.log'  
    268    CHARACTER(LEN=lc)                       :: cn_verbosity = 'warning'  
    269    INTEGER(i4)                             :: in_maxerror = 5 
     288   CHARACTER(LEN=lc)  :: cn_logfile = 'create_boundary.log'  
     289   CHARACTER(LEN=lc)  :: cn_verbosity = 'warning'  
     290   INTEGER(i4)        :: in_maxerror = 5 
    270291 
    271292   ! namcfg 
    272    CHARACTER(LEN=lc)                       :: cn_varcfg = 'variable.cfg'  
     293   CHARACTER(LEN=lc)  :: cn_varcfg = 'variable.cfg'  
    273294 
    274295   ! namcrs 
    275    CHARACTER(LEN=lc)                       :: cn_coord0 = ''  
    276    INTEGER(i4)                             :: in_perio0 = -1 
     296   CHARACTER(LEN=lc)  :: cn_coord0 = ''  
     297   INTEGER(i4)        :: in_perio0 = -1 
    277298 
    278299   ! namfin 
    279    CHARACTER(LEN=lc)                       :: cn_coord1 = ''  
    280    CHARACTER(LEN=lc)                       :: cn_bathy1 = ''  
    281    INTEGER(i4)                             :: in_perio1 = -1 
     300   CHARACTER(LEN=lc)  :: cn_coord1 = ''  
     301   CHARACTER(LEN=lc)  :: cn_bathy1 = ''  
     302   INTEGER(i4)        :: in_perio1 = -1 
    282303 
    283304   !namzgr 
    284    INTEGER(i4)                             :: in_nlevel = 75 
     305   REAL(dp)          :: dn_pp_to_be_computed = 0._dp 
     306   REAL(dp)          :: dn_ppsur     = -3958.951371276829_dp 
     307   REAL(dp)          :: dn_ppa0      =   103.9530096000000_dp 
     308   REAL(dp)          :: dn_ppa1      =     2.4159512690000_dp 
     309   REAL(dp)          :: dn_ppa2      =   100.7609285000000_dp 
     310   REAL(dp)          :: dn_ppkth     =    15.3510137000000_dp 
     311   REAL(dp)          :: dn_ppkth2    =    48.0298937200000_dp 
     312   REAL(dp)          :: dn_ppacr     =     7.0000000000000_dp 
     313   REAL(dp)          :: dn_ppacr2    =    13.000000000000_dp 
     314   REAL(dp)          :: dn_ppdzmin   = 6._dp 
     315   REAL(dp)          :: dn_pphmax    = 5750._dp 
     316   INTEGER(i4)       :: in_nlevel    = 75 
     317 
     318   !namzps 
     319   REAL(dp)          :: dn_e3zps_min = 25._dp 
     320   REAL(dp)          :: dn_e3zps_rat = 0.2_dp 
    285321 
    286322   ! namvar 
     
    289325 
    290326   ! namnst 
    291    INTEGER(i4)                             :: in_rhoi  = 0 
    292    INTEGER(i4)                             :: in_rhoj  = 0 
     327   INTEGER(i4)       :: in_rhoi  = 0 
     328   INTEGER(i4)       :: in_rhoj  = 0 
    293329 
    294330   ! nambdy 
    295    LOGICAL                                 :: ln_north   = .TRUE. 
    296    LOGICAL                                 :: ln_south   = .TRUE. 
    297    LOGICAL                                 :: ln_east    = .TRUE. 
    298    LOGICAL                                 :: ln_west    = .TRUE. 
    299    CHARACTER(LEN=lc)                       :: cn_north   = '' 
    300    CHARACTER(LEN=lc)                       :: cn_south   = '' 
    301    CHARACTER(LEN=lc)                       :: cn_east    = '' 
    302    CHARACTER(LEN=lc)                       :: cn_west    = '' 
    303    LOGICAL                                 :: ln_oneseg  = .TRUE. 
    304    INTEGER(i4)                             :: in_extrap  = 0 
     331   LOGICAL           :: ln_north   = .TRUE. 
     332   LOGICAL           :: ln_south   = .TRUE. 
     333   LOGICAL           :: ln_east    = .TRUE. 
     334   LOGICAL           :: ln_west    = .TRUE. 
     335   CHARACTER(LEN=lc) :: cn_north   = '' 
     336   CHARACTER(LEN=lc) :: cn_south   = '' 
     337   CHARACTER(LEN=lc) :: cn_east    = '' 
     338   CHARACTER(LEN=lc) :: cn_west    = '' 
     339   LOGICAL           :: ln_oneseg  = .TRUE. 
    305340 
    306341   ! namout 
    307    CHARACTER(LEN=lc)                       :: cn_fileout = 'boundary.nc'  
     342   CHARACTER(LEN=lc) :: cn_fileout = 'boundary.nc'  
     343   REAL(dp)          :: dn_dayofs  = 0._dp 
     344   LOGICAL           :: ln_extrap  = .FALSE. 
    308345   !------------------------------------------------------------------- 
    309346 
     
    319356   &  cn_coord0,     &  !< coordinate file 
    320357   &  in_perio0         !< periodicity index 
    321     
     358  
    322359   NAMELIST /namfin/ &  !< fine grid namelist 
    323360   &  cn_coord1,     &  !< coordinate file 
     
    326363  
    327364   NAMELIST /namzgr/ & 
    328    &  in_nlevel 
     365   &  dn_pp_to_be_computed, & 
     366   &  dn_ppsur,     & 
     367   &  dn_ppa0,      & 
     368   &  dn_ppa1,      & 
     369   &  dn_ppa2,      & 
     370   &  dn_ppkth,     & 
     371   &  dn_ppkth2,    & 
     372   &  dn_ppacr,     & 
     373   &  dn_ppacr2,    & 
     374   &  dn_ppdzmin,   & 
     375   &  dn_pphmax,    & 
     376   &  in_nlevel         !< number of vertical level 
     377 
     378   NAMELIST /namzps/ & 
     379   &  dn_e3zps_min, & 
     380   &  dn_e3zps_rat 
    329381 
    330382   NAMELIST /namvar/ &  !< variable namelist 
    331383   &  cn_varinfo,    &  !< list of variable and method to apply on. (ex: 'votemper:linear','vosaline:cubic' ) 
    332384   &  cn_varfile        !< list of variable and file where find it. (ex: 'votemper:GLORYS_gridT.nc' )  
    333     
     385  
    334386   NAMELIST /namnst/ &  !< nesting namelist 
    335387   &  in_rhoi,       &  !< refinement factor in i-direction 
     
    345397   &  cn_east ,      &  !< east  boundary indices on fine grid 
    346398   &  cn_west ,      &  !< west  boundary indices on fine grid 
    347    &  ln_oneseg,     &  !< use only one segment for each boundary or not 
    348    &  in_extrap         !< number of mask point to be extrapolated 
     399   &  ln_oneseg         !< use only one segment for each boundary or not 
    349400 
    350401   NAMELIST /namout/ &  !< output namelist 
    351    &  cn_fileout    !< fine grid boundary file basename    
     402   &  cn_fileout,    &  !< fine grid boundary file basename    
     403   &  dn_dayofs,     &  !< date offset in day (change only ouput file name) 
     404   &  ln_extrap         !< extrapolate or not 
    352405   !------------------------------------------------------------------- 
    353406 
     
    448501   ! check 
    449502   ! check output file do not already exist 
     503   ! WARNING: do not work when use time to create output file name 
    450504   DO jk=1,ip_ncard 
    451505      cl_bdyout=boundary_set_filename( TRIM(cn_fileout), & 
    452506      &                                TRIM(cp_card(jk)), 1 ) 
     507      INQUIRE(FILE=TRIM(cl_bdyout), EXIST=ll_exist) 
     508      IF( ll_exist )THEN 
     509         CALL logger_fatal("CREATE BOUNDARY: output file "//TRIM(cl_bdyout)//& 
     510         &  " already exist.") 
     511      ENDIF 
     512 
     513      cl_bdyout=boundary_set_filename( TRIM(cn_fileout), & 
     514      &                                TRIM(cp_card(jk)) ) 
    453515      INQUIRE(FILE=TRIM(cl_bdyout), EXIST=ll_exist) 
    454516      IF( ll_exist )THEN 
     
    490552 
    491553   CALL iom_mpp_open(tl_bathy1) 
    492     
     554  
    493555   tl_var1=iom_mpp_read_var(tl_bathy1,'Bathymetry') 
    494     
     556  
    495557   CALL iom_mpp_close(tl_bathy1) 
    496558 
     559   ! get boundaries indices 
    497560   tl_bdy(:)=boundary_init(tl_var1, ln_north, ln_south, ln_east, ln_west, & 
    498561   &                                cn_north, cn_south, cn_east, cn_west, & 
     
    505568   tl_level(:)=vgrid_get_level(tl_bathy1, cl_namelist ) 
    506569 
    507    ! get coordinate on each segment of each boundary 
     570   ! get coordinate for each segment of each boundary 
    508571   ALLOCATE( tl_segdom1(ip_npoint,ip_maxseg,ip_ncard) ) 
    509572   ALLOCATE( tl_seglvl1(ip_npoint,ip_maxseg,ip_ncard) ) 
    510     
     573  
    511574   DO jl=1,ip_ncard 
    512575      IF( tl_bdy(jl)%l_use )THEN 
     
    516579            tl_segdom1(:,jk,jl)=create_boundary_get_dom( tl_bathy1, & 
    517580            &                                            tl_bdy(jl), jk ) 
     581 
     582            IF( .NOT. ln_extrap )THEN 
     583               ! get fine grid level 
     584               tl_seglvl1(:,jk,jl)= & 
     585                  & create_boundary_get_level( tl_level(:), & 
     586                  &                            tl_segdom1(:,jk,jl)) 
     587            ENDIF 
    518588 
    519589            ! add extra band to fine grid domain (if possible) 
     
    523593               &                  il_rho(jp_I), il_rho(jp_J)) 
    524594            ENDDO 
    525  
    526             ! get fine grid level 
    527             tl_seglvl1(:,jk,jl)=create_boundary_get_level( tl_level(:), & 
    528                                                            tl_segdom1(:,jk,jl)) 
    529595 
    530596         ENDDO 
     
    594660                        &                          in_nlevel ) 
    595661 
    596                         ! use mask 
    597                         CALL create_boundary_use_mask( tl_segvar1(jvar,jk,jl), & 
    598                         &                         tl_seglvl1(jpoint,jk,jl)) 
    599  
    600662                        !del extra 
    601663                        CALL dom_del_extra( tl_segvar1(jvar,jk,jl), & 
     
    654716                  IF( tl_bdy(jl)%l_use )THEN 
    655717                      
    656                      WRITE(*,'(2x,a,a)') 'work on '//TRIM(tl_bdy(jl)%c_card)//' boundary' 
     718                     WRITE(*,'(2x,a,a)') 'work on '//TRIM(tl_bdy(jl)%c_card)//& 
     719                        &  ' boundary' 
    657720                     DO jk=1,tl_bdy(jl)%i_nseg 
    658721                        ! compute domain on fine grid 
     
    662725                            
    663726                           cl_name=tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_name 
    664                            WRITE(*,'(4x,a,a)') "work on variable "//TRIM(cl_name) 
     727                           WRITE(*,'(4x,a,a)') "work on (extract) variable "//& 
     728                              &  TRIM(cl_name) 
    665729 
    666730                           cl_point=tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_point 
     
    678742 
    679743                           tl_dom1=dom_copy(tl_segdom1(jpoint,jk,jl)) 
    680                            tl_lvl1=var_copy(tl_seglvl1(jpoint,jk,jl)) 
    681744 
    682745                           ! open mpp files 
     
    687750                           &                     tl_mpp, TRIM(cl_name), tl_dom1) 
    688751 
    689                            ! use mask 
    690                            CALL create_boundary_use_mask( & 
    691                            &                 tl_segvar1(jvar+jj,jk,jl), tl_lvl1) 
    692  
    693752                           ! del extra point 
    694753                           CALL dom_del_extra( tl_segvar1(jvar+jj,jk,jl), & 
     
    699758 
    700759                           ! add attribute to variable 
    701                            tl_att=att_init('src_file',TRIM(fct_basename(tl_mpp%c_name))) 
     760                           tl_att=att_init('src_file', & 
     761                              &  TRIM(fct_basename(tl_mpp%c_name))) 
    702762                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), tl_att) 
    703763 
    704                            tl_att=att_init('src_i_indices',(/tl_dom1%i_imin, tl_dom1%i_imax/)) 
     764                           tl_att=att_init('src_i_indices', & 
     765                              &  (/tl_dom1%i_imin, tl_dom1%i_imax/)) 
    705766                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), tl_att) 
    706767 
    707                            tl_att=att_init('src_j_indices',(/tl_dom1%i_jmin, tl_dom1%i_jmax/)) 
     768                           tl_att=att_init('src_j_indices', & 
     769                              &  (/tl_dom1%i_jmin, tl_dom1%i_jmax/)) 
    708770                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), tl_att) 
    709771 
     
    736798                  IF( tl_bdy(jl)%l_use )THEN 
    737799 
    738                      WRITE(*,'(2x,a,a)') 'work on '//TRIM(tl_bdy(jl)%c_card)//' boundary' 
     800                     WRITE(*,'(2x,a,a)') 'work on '//TRIM(tl_bdy(jl)%c_card)//& 
     801                        &  ' boundary' 
    739802                     DO jk=1,tl_bdy(jl)%i_nseg 
    740803                         
    741804                        ! for each variable of this file 
    742805                        DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar 
    743                             
    744                            WRITE(*,'(4x,a,a)') "work on variable "//& 
     806  
     807                           WRITE(*,'(4x,a,a)') "work on (interp) variable "//& 
    745808                           &  TRIM(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_name) 
    746809 
     
    759822 
    760823                           tl_dom1=dom_copy(tl_segdom1(jpoint,jk,jl)) 
    761                            tl_lvl1=var_copy(tl_seglvl1(jpoint,jk,jl)) 
    762824 
    763825                           CALL create_boundary_get_coord( tl_coord1, tl_dom1, & 
     
    795857                           &                 il_jmin0, il_jmax0 ) 
    796858 
    797                            ! add extra band (if possible) to compute interpolation 
     859                           ! add extra band (if possible) to compute  
     860                           ! interpolation 
    798861                           CALL dom_add_extra(tl_dom0) 
    799862 
     
    815878                           CALL dom_del_extra( tl_segvar1(jvar+jj,jk,jl), & 
    816879                           &                   tl_dom0, il_rho(:) ) 
    817  
    818                            ! use mask 
    819                            CALL create_boundary_use_mask( & 
    820                            &     tl_segvar1(jvar+jj,jk,jl), tl_lvl1) 
    821880 
    822881                           ! del extra point on fine grid 
     
    889948 
    890949   IF( jvar /= tl_multi%i_nvar )THEN 
    891       CALL logger_error("CREATE BOUNDARY: it seems some variable can not be read") 
     950      CALL logger_error("CREATE BOUNDARY: it seems some variable "//& 
     951         &  "can not be read") 
    892952   ENDIF 
    893  
    894    CALL var_clean(tl_seglvl1(:,:,:)) 
    895    DEALLOCATE( tl_seglvl1 ) 
    896953 
    897954   ! write file for each segment of each boundary 
    898955   DO jl=1,ip_ncard 
    899956      IF( tl_bdy(jl)%l_use )THEN 
    900  
    901          SELECT CASE(TRIM(tl_bdy(jk)%c_card)) 
    902          CASE('north','south') 
    903             il_dim=1 
    904          CASE('east','west') 
    905             il_dim=2 
    906          END SELECT    
    907957 
    908958         DO jk=1,tl_bdy(jl)%i_nseg 
     
    911961            &                               'T', tl_lon1, tl_lat1 ) 
    912962 
     963            ! force to use nav_lon, nav_lat as variable name 
     964            tl_lon1%c_name='nav_lon' 
     965            tl_lat1%c_name='nav_lat' 
     966 
    913967            ! del extra point on fine grid 
    914968            CALL dom_del_extra( tl_lon1, tl_segdom1(jp_T,jk,jl) ) 
     
    924978            CALL boundary_swap(tl_lat1, tl_bdy(jl)) 
    925979            DO jvar=1,tl_multi%i_nvar 
    926                CALL boundary_swap(tl_segvar1(jvar,jk,jl), tl_bdy(jl)) 
    927980 
    928981               ! use additional request 
     982               ! change unit and apply factor 
     983               CALL var_chg_unit(tl_segvar1(jvar,jk,jl)) 
     984 
    929985               ! forced min and max value 
    930986               CALL var_limit_value(tl_segvar1(jvar,jk,jl)) 
     
    933989               CALL filter_fill_value(tl_segvar1(jvar,jk,jl)) 
    934990 
    935                ! extrapolate 
    936                CALL extrap_fill_value( tl_segvar1(jvar,jk,jl), & 
    937                &                       id_iext=in_extrap,      & 
    938                &                       id_jext=in_extrap,      & 
    939                &                       id_kext=in_extrap ) 
     991               IF( .NOT. ln_extrap )THEN 
     992                  ! use mask 
     993                  SELECT CASE(TRIM(tl_segvar1(jvar,jk,jl)%c_point)) 
     994                  CASE DEFAULT !'T' 
     995                     jpoint=jp_T 
     996                  CASE('U') 
     997                     jpoint=jp_U 
     998                  CASE('V') 
     999                     jpoint=jp_V 
     1000                  CASE('F') 
     1001                     jpoint=jp_F 
     1002                  END SELECT 
     1003 
     1004                  CALL create_boundary_use_mask(tl_segvar1(jvar,jk,jl), & 
     1005                  &                             tl_seglvl1(jpoint,jk,jl)) 
     1006               ENDIF 
     1007 
     1008               ! swap dimension order 
     1009               CALL boundary_swap(tl_segvar1(jvar,jk,jl), tl_bdy(jl)) 
    9401010 
    9411011            ENDDO 
     
    9441014            ! create file structure 
    9451015            ! set file namearray of level variable structure 
    946             IF( ASSOCIATED(tl_time%d_value) )THEN 
    947                cl_fmt="('y',i0.4,'m',i0.2,'d',i0.2)" 
    948                cl_date=date_print( var_to_date(tl_time), cl_fmt )  
    949  
    950                cl_bdyout=boundary_set_filename( TRIM(cn_fileout), & 
    951                &                                TRIM(tl_bdy(jl)%c_card), jk, TRIM(cl_date) ) 
     1016            IF( tl_bdy(jl)%i_nseg > 1 )THEN 
     1017               IF( ASSOCIATED(tl_time%d_value) )THEN 
     1018                  cl_fmt="('y',i0.4,'m',i0.2,'d',i0.2)" 
     1019                  tl_date=var_to_date(tl_time) 
     1020                  tl_date=tl_date+dn_dayofs 
     1021                  cl_date=date_print( tl_date, cl_fmt )  
     1022 
     1023                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), & 
     1024                  &                                TRIM(tl_bdy(jl)%c_card), jk,& 
     1025                  &                                cd_date=TRIM(cl_date) ) 
     1026               ELSE 
     1027                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), & 
     1028                  &                                TRIM(tl_bdy(jl)%c_card), jk ) 
     1029               ENDIF 
    9521030            ELSE 
    953                cl_bdyout=boundary_set_filename( TRIM(cn_fileout), & 
    954                &                                TRIM(tl_bdy(jl)%c_card), jk ) 
     1031               IF( ASSOCIATED(tl_time%d_value) )THEN 
     1032                  cl_fmt="('y',i0.4,'m',i0.2,'d',i0.2)" 
     1033                  tl_date=var_to_date(tl_time) 
     1034                  tl_date=tl_date+dn_dayofs 
     1035                  cl_date=date_print( tl_date, cl_fmt ) 
     1036 
     1037                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), & 
     1038                  &                                TRIM(tl_bdy(jl)%c_card), & 
     1039                  &                                cd_date=TRIM(cl_date) ) 
     1040               ELSE 
     1041                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), & 
     1042                  &                                TRIM(tl_bdy(jl)%c_card) ) 
     1043               ENDIF 
    9551044            ENDIF 
    9561045            !  
     
    9601049            tl_dim(:)=var_max_dim(tl_segvar1(:,jk,jl)) 
    9611050 
    962             CALL dim_unorder(tl_dim(:)) 
    9631051            SELECT CASE(TRIM(tl_bdy(jl)%c_card)) 
    9641052               CASE DEFAULT ! 'north','south' 
    9651053                  cl_dimorder='xyzt' 
    966                   CALL dim_reorder(tl_dim(:),TRIM(cl_dimorder)) 
    9671054               CASE('east','west') 
    9681055                  cl_dimorder='yxzt' 
    969                   CALL dim_reorder(tl_dim(:),TRIM(cl_dimorder)) 
    970                   ! reorder coordinates dimension 
    971                   CALL var_reorder(tl_lon1,TRIM(cl_dimorder)) 
    972                   CALL var_reorder(tl_lat1,TRIM(cl_dimorder)) 
    973                   ! reorder other variable dimension 
    974                   DO jvar=1,tl_multi%i_nvar 
    975                      CALL var_reorder(tl_segvar1(jvar,jk,jl),TRIM(cl_dimorder)) 
    976                   ENDDO 
    9771056            END SELECT 
    9781057 
     
    9921071            ENDIF 
    9931072             
     1073 
     1074 
    9941075            IF( tl_dim(3)%l_use )THEN 
    995                ! add depth 
    996                CALL file_add_var(tl_fileout, tl_depth) 
     1076               IF( ASSOCIATED(tl_depth%d_value) )THEN 
     1077                  ! add depth 
     1078                  CALL file_add_var(tl_fileout, tl_depth) 
     1079               ENDIF 
    9971080            ENDIF 
    9981081 
    9991082            IF( tl_dim(4)%l_use )THEN 
    1000                ! add time 
    1001                CALL file_add_var(tl_fileout, tl_time) 
     1083               IF( ASSOCIATED(tl_time%d_value) )THEN 
     1084                  ! add time 
     1085                  CALL file_add_var(tl_fileout, tl_time) 
     1086               ENDIF 
    10021087            ENDIF 
    10031088 
    10041089            ! add other variable 
    1005             DO jvar=1,tl_multi%i_nvar 
     1090            DO jvar=tl_multi%i_nvar,1,-1 
    10061091               CALL file_add_var(tl_fileout, tl_segvar1(jvar,jk,jl)) 
    10071092               CALL var_clean(tl_segvar1(jvar,jk,jl)) 
     
    10481133 
    10491134            ! write file 
    1050             CALL iom_write_file(tl_fileout) 
     1135            CALL iom_write_file(tl_fileout, cl_dimorder) 
    10511136 
    10521137            ! close file 
     
    10661151   DEALLOCATE( tl_segdom1 ) 
    10671152   DEALLOCATE( tl_segvar1 ) 
     1153   CALL var_clean(tl_seglvl1(:,:,:)) 
     1154   DEALLOCATE( tl_seglvl1 ) 
     1155 
    10681156 
    10691157   CALL mpp_clean(tl_coord1) 
     
    10821170   !>  
    10831171   !> @author J.Paul 
    1084    !> - November, 2013- Initial Version 
     1172   !> @date November, 2013 - Initial Version 
    10851173   !> @date September, 2014 
    10861174   !> - take into account grid point to compute boundary indices 
     
    11861274   !------------------------------------------------------------------- 
    11871275   !> @brief 
    1188    !> This subroutine get coordinates over boudnary domain 
     1276   !> This subroutine get coordinates over boundary domain 
    11891277   !>  
    11901278   !> @author J.Paul 
    1191    !> - November, 2013- Initial Version 
    1192    !> @date September, 2014 - take into account grid point 
     1279   !> @date November, 2013 - Initial Version 
     1280   !> @date September, 2014  
     1281   !> - take into account grid point 
    11931282   !> 
    11941283   !> @param[in] td_coord1 coordinates file structure 
     
    12371326   !------------------------------------------------------------------- 
    12381327   !> @brief 
    1239    !> This subroutine interpolate variable over boundary 
     1328   !> This subroutine interpolate variable on boundary 
    12401329   !>  
    12411330   !> @details  
    12421331   !> 
    12431332   !> @author J.Paul 
    1244    !> - Nov, 2013- Initial Version 
     1333   !> @date November, 2013 - Initial Version 
    12451334   !> 
    12461335   !> @param[inout] td_var variable structure  
     
    12961385 
    12971386      ! extrapolate variable 
    1298       CALL extrap_fill_value( td_var, id_iext=il_iext, id_jext=il_jext ) 
     1387      CALL extrap_fill_value( td_var ) 
    12991388 
    13001389      ! interpolate Bathymetry 
     
    13031392 
    13041393      ! remove extraband 
    1305       CALL extrap_del_extrabands(td_var, il_iext*id_rho(jp_I), il_jext*id_rho(jp_J)) 
     1394      CALL extrap_del_extrabands(td_var, il_iext*id_rho(jp_I), & 
     1395         &                               il_jext*id_rho(jp_J)) 
    13061396 
    13071397   END SUBROUTINE create_boundary_interp 
     
    13171407   !> 
    13181408   !> @author J.Paul 
    1319    !> - November, 2013- Initial Version 
     1409   !> @date November, 2013 - Initial Version 
    13201410   !> 
    13211411   !> @param[in] td_var    variable structure  
     
    14221512   !> 
    14231513   !> @author J.Paul 
    1424    !> - November, 2013- Initial Version 
     1514   !> @date November, 2013 - Initial Version 
    14251515   !> 
    14261516   !> @param[inout] td_var variable structure  
     
    14751565   !> 
    14761566   !> @author J.Paul 
    1477    !> - November, 2013- Initial Version 
     1567   !> @date November, 2013 - Initial Version 
    14781568   !> 
    14791569   !> @param[in] td_level  array of level variable structure 
     
    15371627   !> 
    15381628   !> @author J.Paul 
    1539    !> - November, 2014- Initial Version 
     1629   !> @date November, 2014 - Initial Version 
    15401630   !> 
    15411631   !> @param[in] td_mpp       mpp structure 
     
    15881678   !> 
    15891679   !> @author J.Paul 
    1590    !> - November, 2014- Initial Version 
     1680   !> @date November, 2014 - Initial Version 
    15911681   !> 
    15921682   !> @param[in] td_mpp      mpp structure 
Note: See TracChangeset for help on using the changeset viewer.