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 2455 for branches/nemo_v3_3_beta – NEMO

Ignore:
Timestamp:
2010-12-06T12:55:53+01:00 (13 years ago)
Author:
smasson
Message:

v3_3_bet: bugfix in nesting tools, see #773

Location:
branches/nemo_v3_3_beta/NEMOGCM/TOOLS/NESTING
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/nemo_v3_3_beta/NEMOGCM/TOOLS/NESTING/agulhas

    r2143 r2455  
    55&coarse_grid_files     
    66    parent_coordinate_file = 'coordinates.nc' 
    7     parent_bathy_level    = 'bathy_level.nc'   
     7    parent_meshmask_file   = 'meshmask.nc'   
    88/     
    99     
     
    1111    new_topo = true 
    1212    elevation_database = 'bathymetry_meter_ORCA_R05.nc' 
     13    elevation_name = 'topo' 
    1314    smoothing = true 
    1415    smoothing_factor = 0.6 
     
    4344    partial_steps = true 
    4445    parent_bathy_meter = 'bathy_meter.nc' 
     46    parent_batmet_name = 'Bathymetry' 
    4547    e3zps_min = 25. 
    4648    e3zps_rat = 0.2 
     
    5254/ 
    5355&forcing_files        
    54     U_FILES = taux_1m.nc 
     56    U_FILES = 'taux_1m.nc' 
    5557!'dyna_grid_U.nc'                              ! needed for Offline 
    56     V_FILES =  tauy_1m.nc 
     58    V_FILES =  'tauy_1m.nc' 
    5759!'dyna_grid_V.nc'                              ! needed for Offline 
    5860    FLX_FILES =  
  • branches/nemo_v3_3_beta/NEMOGCM/TOOLS/NESTING/src/agrif_create_bathy.f90

    r2143 r2455  
    1818  !************************************************************************ 
    1919  !                           * 
    20   ! PROGRAM  CREATE_BATHY                    * 
     20  ! PROGRAM  CREATE_BATHY                 * 
    2121  !                           * 
    2222  ! program to implement bathymetry interpolation to generate     * 
     
    2626  !                           * 
    2727  ! 1- Interpolation directly from parent bathymetry file (z-coord)  * 
    28   ! 2- Use new topo file in meters (for example etopo)         * 
     28  ! 2- Use new topo file in meters (for example etopo)      * 
    2929  !                           * 
    3030  ! vertical coordinates permitted : z-coord and partial steps    * 
     
    7676  ! 
    7777  CALL set_child_name(parent_coordinate_file,Child_coordinates)  
    78   IF( TRIM(parent_bathy_level) .NE. '/NULL' ) & 
    79        CALL set_child_name(parent_bathy_level,Childlevel_file)             
     78  IF( TRIM(parent_meshmask_file) .NE. '/NULL' ) & 
     79       CALL set_child_name(parent_meshmask_file,Childlevel_file)             
    8080  ! 
    8181  ! 
     
    100100     WRITE(*,*) 'No new topo file ...' 
    101101     status = Read_Coordinates(TRIM(parent_coordinate_file),G0)     
    102      status = Read_bathy_level(TRIM(parent_bathy_level),G0) 
     102     status = Read_bathy_level(TRIM(parent_meshmask_file),G0) 
    103103     !            
    104104     IF( imax > SIZE(G0%glamt,1) .OR. jmax > SIZE(G0%glamt,2) .OR. & 
     
    587587        G1%bathy_level=NINT(G1%bathy_level) 
    588588        ! 
    589         IF( TRIM(parent_bathy_level) .NE. '/NULL' ) & 
     589        IF( TRIM(parent_meshmask_file) .NE. '/NULL' ) & 
    590590             status = Write_Bathy_level(TRIM(Childlevel_file),G1) 
    591591        ! 
     
    599599     ! 
    600600     ! 
    601      status = Read_bathy_level(TRIM(parent_bathy_level),G0) 
     601     status = Read_bathy_level(TRIM(parent_meshmask_file),G0) 
    602602     !             
    603603     CALL levels_to_meter(G0) 
  • branches/nemo_v3_3_beta/NEMOGCM/TOOLS/NESTING/src/agrif_create_restart.f90

    r2143 r2455  
    113113  !        
    114114  CALL set_child_name(parent_coordinate_file,Childcoordinates)    
    115   CALL set_child_name(parent_bathy_level,Childbathy)  
     115  CALL set_child_name(parent_meshmask_file,Childbathy)  
    116116  CALL set_child_name(parent_bathy_meter,Childbathymeter)    
    117117  ! 
     
    165165  ENDIF 
    166166  ! 
    167   CALL Init_mask(parent_bathy_level,G0,x,y) 
     167  CALL Init_mask(parent_meshmask_file,G0,x,y) 
    168168  CALL Init_mask(childbathy,G1,1,1) 
    169169 
  • branches/nemo_v3_3_beta/NEMOGCM/TOOLS/NESTING/src/agrif_create_restart_trc.f90

    r2143 r2455  
    100100  !        
    101101  CALL set_child_name(parent_coordinate_file,Childcoordinates)    
    102   CALL set_child_name(parent_bathy_level,Childbathy)  
     102  CALL set_child_name(parent_meshmask_file,Childbathy)  
    103103  CALL set_child_name(parent_bathy_meter,Childbathymeter)    
    104104  ! 
     
    142142  ENDIF 
    143143  ! 
    144   CALL Init_tmask(parent_bathy_level,G0,x,y) 
     144  CALL Init_tmask(parent_meshmask_file,G0,x,y) 
    145145  CALL Init_tmask(childbathy,G1,nxfin,nyfin) 
    146146   
  • branches/nemo_v3_3_beta/NEMOGCM/TOOLS/NESTING/src/agrif_interpolation.f90

    r2143 r2455  
    2222  ! module containing subroutine used for :           * 
    2323  !   - Forcing data interpolation              * 
    24   !   - Parent to Child coordinates interpolation           * 
     24  !   - Parent to Child coordinates interpolation        * 
    2525  !                           * 
    2626  !************************************************************************ 
     
    3333  !   subroutine agrif_interp             * 
    3434  !                        * 
    35   ! subroutine to interpolate coordinates          * 
     35  ! subroutine to interpolate coordinates       * 
    3636  !                        * 
    3737  ! - input :                    * 
    38   !     tabin : coarse grid coordinate variable          * 
     38  !     tabin : coarse grid coordinate variable       * 
    3939  !   typevar : position of interpolated variable on cells  * 
    4040  !                        * 
     
    499499    CALL set_child_name(filename,Child_file)  
    500500    CALL set_child_name(parent_coordinate_file,Childcoordinates) 
    501     CALL set_child_name(parent_bathy_level,childbathy) 
     501    CALL set_child_name(parent_meshmask_file,childbathy) 
    502502    WRITE(*,*) 'Child grid file name = ',TRIM(Child_file) 
    503503    ! 
     
    541541       ALLOCATE(mask(numlon,numlat,N)) 
    542542       CALL Init_mask(childbathy,G1,1,1) 
    543        CALL Init_mask(parent_bathy_level,G0,1,1) 
     543       CALL Init_mask(parent_meshmask_file,G0,1,1) 
    544544       ! 
    545545    ENDIF 
  • branches/nemo_v3_3_beta/NEMOGCM/TOOLS/NESTING/src/agrif_readwrite.f90

    r2143 r2455  
    1919  !                           * 
    2020  ! module containing subroutine used for :           * 
    21   !   - Coordinates files reading/writing             * 
     21  !   - Coordinates files reading/writing          * 
    2222  !   - Bathymetry files reading/writing (meter and levels)    * 
    2323  !   - Naming of child grid files              * 
     
    139139    CHARACTER(*) name 
    140140    TYPE(Coordinates) :: Grid 
    141     INTEGER :: status,ncid,z 
    142     REAL*8,DIMENSION(:),POINTER :: tabtemp 
    143     INTEGER,DIMENSION(:),POINTER :: tabint 
    144     CHARACTER(len=20),DIMENSION(4) :: dimnames 
     141    INTEGER :: status,ncid 
     142    CHARACTER(len=1),DIMENSION(2) :: dimnames 
    145143    ! 
    146144    status = nf90_create(name,NF90_WRITE,ncid) 
    147145    status = nf90_close(ncid) 
    148146    !            
    149     CALL Write_Ncdf_dim('x',name,nxfin) 
    150     CALL Write_Ncdf_dim('y',name,nyfin) 
    151     IF(.NOT. iom_activated) CALL Write_Ncdf_dim('z',name,1) 
    152     CALL Write_Ncdf_dim('time',name,0) 
    153     !       
    154     dimnames(1)='x' 
    155     dimnames(2)='y' 
    156     CALL Write_Ncdf_var('nav_lon',dimnames(1:2),name,Grid%nav_lon,'float')       
    157     CALL Write_Ncdf_var('nav_lat',dimnames(1:2),name,Grid%nav_lat,'float') 
    158     ! 
    159     IF(.NOT. iom_activated) THEN 
    160        ! copy nav_lev variable -> IOIPSL 
    161        CALL Read_Ncdf_dim('z',parent_coordinate_file,z) 
    162        ALLOCATE(tabtemp(z)) 
    163        CALL Read_Ncdf_var('nav_lev',TRIM(parent_coordinate_file),tabtemp) 
    164        CALL Write_Ncdf_var('nav_lev','z',name,tabtemp,'float')            
    165        DEALLOCATE(tabtemp) 
    166     ENDIF 
    167     ! 
    168     CALL Read_Ncdf_var('time',TRIM(parent_coordinate_file),tabtemp) 
    169     CALL Write_Ncdf_var('time','time',name,tabtemp,'float')            
    170     DEALLOCATE(tabtemp)       
    171     CALL Read_Ncdf_var('time_steps',TRIM(parent_coordinate_file),tabint) 
    172     CALL Write_Ncdf_var('time_steps','time',name,tabint)  
    173     !       
    174     dimnames(1)='x' 
    175     dimnames(2)='y' 
    176     IF(iom_activated) THEN 
    177        dimnames(3)='time' 
    178     ELSE 
    179        dimnames(3)='z' 
    180        dimnames(4)='time' 
    181     ENDIF 
    182  
    183     CALL Write_Ncdf_var('glamt',dimnames,name,Grid%glamt,3,'double') 
    184     CALL Write_Ncdf_var('glamu',dimnames,name,Grid%glamu,3,'double') 
    185     CALL Write_Ncdf_var('glamv',dimnames,name,Grid%glamv,3,'double') 
    186     CALL Write_Ncdf_var('glamf',dimnames,name,Grid%glamf,3,'double') 
    187     CALL Write_Ncdf_var('gphit',dimnames,name,Grid%gphit,3,'double') 
    188     CALL Write_Ncdf_var('gphiu',dimnames,name,Grid%gphiu,3,'double') 
    189     CALL Write_Ncdf_var('gphiv',dimnames,name,Grid%gphiv,3,'double') 
    190     CALL Write_Ncdf_var('gphif',dimnames,name,Grid%gphif,3,'double')       
    191     CALL Write_Ncdf_var('e1t',dimnames,name,Grid%e1t,3,'double')       
    192     CALL Write_Ncdf_var('e1u',dimnames,name,Grid%e1u,3,'double')      
    193     CALL Write_Ncdf_var('e1v',dimnames,name,Grid%e1v,3,'double')       
    194     CALL Write_Ncdf_var('e1f',dimnames,name,Grid%e1f,3,'double') 
    195     CALL Write_Ncdf_var('e2t',dimnames,name,Grid%e2t,3,'double') 
    196     CALL Write_Ncdf_var('e2u',dimnames,name,Grid%e2u,3,'double') 
    197     CALL Write_Ncdf_var('e2v',dimnames,name,Grid%e2v,3,'double') 
    198     CALL Write_Ncdf_var('e2f',dimnames,name,Grid%e2f,3,'double') 
    199     !       
    200     CALL Copy_Ncdf_att('nav_lon',TRIM(parent_coordinate_file),name,& 
    201          MINVAL(Grid%nav_lon),MAXVAL(Grid%nav_lon)) 
    202     CALL Copy_Ncdf_att('nav_lat',TRIM(parent_coordinate_file),name,& 
    203          MINVAL(Grid%nav_lat),MAXVAL(Grid%nav_lat)) 
    204     CALL Copy_Ncdf_att('nav_lev',TRIM(parent_coordinate_file),name) 
    205     CALL Copy_Ncdf_att('time',TRIM(parent_coordinate_file),name) 
    206     CALL Copy_Ncdf_att('time_steps',TRIM(parent_coordinate_file),name) 
     147    dimnames = (/ 'x','y' /) 
     148    CALL Write_Ncdf_dim(dimnames(1),name,nxfin) 
     149    CALL Write_Ncdf_dim(dimnames(2),name,nyfin) 
     150    !       
     151    CALL Write_Ncdf_var('nav_lon',dimnames,name,Grid%nav_lon,'float')       
     152    CALL Write_Ncdf_var('nav_lat',dimnames,name,Grid%nav_lat,'float') 
     153    ! 
     154    CALL Write_Ncdf_var('glamt',dimnames,name,Grid%glamt,'double') 
     155    CALL Write_Ncdf_var('glamu',dimnames,name,Grid%glamu,'double') 
     156    CALL Write_Ncdf_var('glamv',dimnames,name,Grid%glamv,'double') 
     157    CALL Write_Ncdf_var('glamf',dimnames,name,Grid%glamf,'double') 
     158    CALL Write_Ncdf_var('gphit',dimnames,name,Grid%gphit,'double') 
     159    CALL Write_Ncdf_var('gphiu',dimnames,name,Grid%gphiu,'double') 
     160    CALL Write_Ncdf_var('gphiv',dimnames,name,Grid%gphiv,'double') 
     161    CALL Write_Ncdf_var('gphif',dimnames,name,Grid%gphif,'double')       
     162    CALL Write_Ncdf_var('e1t',dimnames,name,Grid%e1t,'double')       
     163    CALL Write_Ncdf_var('e1u',dimnames,name,Grid%e1u,'double')      
     164    CALL Write_Ncdf_var('e1v',dimnames,name,Grid%e1v,'double')       
     165    CALL Write_Ncdf_var('e1f',dimnames,name,Grid%e1f,'double') 
     166    CALL Write_Ncdf_var('e2t',dimnames,name,Grid%e2t,'double') 
     167    CALL Write_Ncdf_var('e2u',dimnames,name,Grid%e2u,'double') 
     168    CALL Write_Ncdf_var('e2v',dimnames,name,Grid%e2v,'double') 
     169    CALL Write_Ncdf_var('e2f',dimnames,name,Grid%e2f,'double') 
     170    !       
     171    CALL Copy_Ncdf_att('nav_lon',TRIM(parent_coordinate_file),name,MINVAL(Grid%nav_lon),MAXVAL(Grid%nav_lon)) 
     172    CALL Copy_Ncdf_att('nav_lat',TRIM(parent_coordinate_file),name,MINVAL(Grid%nav_lat),MAXVAL(Grid%nav_lat)) 
    207173    CALL Copy_Ncdf_att('glamt',TRIM(parent_coordinate_file),name) 
    208174    CALL Copy_Ncdf_att('glamu',TRIM(parent_coordinate_file),name) 
     
    224190    WRITE(*,*) ' ' 
    225191    WRITE(*,*) 'Writing coordinates file: ',name 
    226     IF(.NOT. iom_activated) WRITE(*,*) 'IOISPL format' 
    227     IF(iom_activated) WRITE(*,*) 'IOM format'       
    228192    WRITE(*,*) ' ' 
    229193    ! 
     
    245209    TYPE(Coordinates) :: Grid 
    246210    ! 
    247     CALL Read_Ncdf_var('Bathy_level',name,Grid%Bathy_level)     
     211    CALL Read_Ncdf_var('mbathy',name,Grid%Bathy_level)     
    248212    ! 
    249213    WRITE(*,*) ' ' 
     
    265229    CHARACTER(*) name 
    266230    TYPE(Coordinates) :: Grid 
    267     INTEGER :: status,ncid,deptht 
    268     REAL*8,DIMENSION(:),POINTER :: timedepth_temp 
    269     REAL*8,DIMENSION(:,:,:),POINTER :: bathy3d 
    270     REAL*8,DIMENSION(:,:,:,:),POINTER :: bathy4d 
    271     CHARACTER(len=20),DIMENSION(4) :: dimnames 
     231    INTEGER :: status,ncid 
     232    CHARACTER(len=1),DIMENSION(2) :: dimnames 
    272233    ! 
    273234    status = nf90_create(name,NF90_WRITE,ncid) 
    274235    status = nf90_close(ncid)           
    275236    ! 
    276     CALL Write_Ncdf_dim('x',name,nxfin) 
    277     CALL Write_Ncdf_dim('y',name,nyfin) 
    278     IF(.NOT. iom_activated ) CALL Write_Ncdf_dim('deptht',name,1) 
    279     CALL Write_Ncdf_dim('time_counter',name,0) 
    280     !       
    281     dimnames(1)='x' 
    282     dimnames(2)='y'   
    283     IF(iom_activated ) THEN 
    284        dimnames(3)='time_counter' 
    285     ELSE        
    286        dimnames(3)='deptht' 
    287        dimnames(4)='time_counter'        
    288     ENDIF 
    289     !       
    290     CALL Write_Ncdf_var('nav_lon',dimnames(1:2),name,Grid%nav_lon,'float') 
    291     CALL Write_Ncdf_var('nav_lat',dimnames(1:2),name,Grid%nav_lat,'float') 
    292     ! 
    293     ! deptht must be considered for IOIPSL format 
    294     ! 
    295     IF ( Dims_Existence( 'deptht' , TRIM(parent_bathy_level) ) & 
    296          .AND. .NOT. iom_activated) THEN 
    297        CALL Read_Ncdf_dim('deptht',TRIM(parent_bathy_level),deptht) 
    298        ALLOCATE(timedepth_temp(deptht)) 
    299        CALL Read_Ncdf_var('deptht',TRIM(parent_bathy_level),timedepth_temp) 
    300        CALL Write_Ncdf_var('deptht','deptht',name,timedepth_temp,'float') 
    301        CALL Copy_Ncdf_att('deptht',TRIM(parent_bathy_level),name) 
    302        DEALLOCATE(timedepth_temp) 
    303     ENDIF 
    304     ! 
    305     CALL Read_Ncdf_var('time_counter',TRIM(parent_bathy_level),timedepth_temp) 
    306     CALL Write_Ncdf_var('time_counter','time_counter',name,timedepth_temp,'float')                   
    307     ! 
    308     IF(iom_activated) THEN 
    309        ALLOCATE(bathy3d(nxfin,nyfin,1)) 
    310        bathy3d(:,:,1) = Grid%bathy_level(:,:) 
    311        CALL Write_Ncdf_var('Bathy_level',dimnames(1:3),name,bathy3d,'float') 
    312        DEALLOCATE(bathy3d) 
    313     ELSE 
    314        ALLOCATE(bathy4d(nxfin,nyfin,1,1)) 
    315        bathy4d(:,:,1,1) = Grid%bathy_level(:,:) 
    316        CALL Write_Ncdf_var('Bathy_level',dimnames,name,bathy4d,'float') 
    317        DEALLOCATE(bathy4d)               
    318     ENDIF 
    319     ! 
    320     CALL Copy_Ncdf_att('nav_lon',TRIM(parent_bathy_level),name,   & 
    321          MINVAL(Grid%nav_lon),MAXVAL(Grid%nav_lon)) 
    322     CALL Copy_Ncdf_att('nav_lat',TRIM(parent_bathy_level),name,   & 
    323          MINVAL(Grid%nav_lat),MAXVAL(Grid%nav_lat)) 
    324     IF(.NOT. iom_activated )  & 
    325          CALL Copy_Ncdf_att('deptht',TRIM(parent_bathy_level),name) 
    326     CALL Copy_Ncdf_att('time_counter',TRIM(parent_bathy_level),name) 
    327     CALL Copy_Ncdf_att('Bathy_level',TRIM(parent_bathy_level),name)        
     237    dimnames = (/ 'x','y' /) 
     238    CALL Write_Ncdf_dim(dimnames(1),name,nxfin) 
     239    CALL Write_Ncdf_dim(dimnames(2),name,nyfin) 
     240    !       
     241    CALL Write_Ncdf_var('nav_lon',dimnames,name,Grid%nav_lon    ,'float') 
     242    CALL Write_Ncdf_var('nav_lat',dimnames,name,Grid%nav_lat    ,'float') 
     243    CALL Write_Ncdf_var('mbathy' ,dimnames,name,Grid%bathy_level,'float') 
     244    ! 
     245    CALL Copy_Ncdf_att('nav_lon',TRIM(parent_meshmask_file),name,MINVAL(Grid%nav_lon),MAXVAL(Grid%nav_lon)) 
     246    CALL Copy_Ncdf_att('nav_lat',TRIM(parent_meshmask_file),name,MINVAL(Grid%nav_lat),MAXVAL(Grid%nav_lat)) 
     247    CALL Copy_Ncdf_att('mbathy' ,TRIM(parent_meshmask_file),name)        
    328248    ! 
    329249    WRITE(*,*) ' ' 
    330250    WRITE(*,*) 'Writing bathymetry file: ',name 
    331     IF(.NOT. iom_activated) WRITE(*,*) 'IOISPL format' 
    332     IF(iom_activated) WRITE(*,*) 'IOM format'   
    333251    WRITE(*,*) ' ' 
    334252    ! 
     
    352270    TYPE(Coordinates) :: CoarseGrid,ChildGrid 
    353271    ! 
    354     IF( Dims_Existence('lon',name) .AND. &  
    355          Dims_Existence('lat',name)) THEN 
     272    IF( Dims_Existence('lon',name) .AND. Dims_Existence('lat',name) ) THEN 
    356273       WRITE(*,*) '****' 
    357274       WRITE(*,*) ' etopo format for external high resolution database  ' 
     
    359276       CALL Read_Ncdf_var('lon',name,topo_lon) 
    360277       CALL Read_Ncdf_var('lat',name,topo_lat) 
    361     ELSE IF( Dims_Existence('x',name) & 
    362          .AND. Dims_Existence('y',name) ) THEN 
     278    ELSE IF( Dims_Existence('x',name) .AND. Dims_Existence('y',name) ) THEN 
    363279       WRITE(*,*) '****' 
    364280       WRITE(*,*) ' OPA format for external high resolution database  ' 
     
    366282       CALL Read_Ncdf_var('nav_lon',name,CoarseGrid%nav_lon) 
    367283       CALL Read_Ncdf_var('nav_lat',name,CoarseGrid%nav_lat) 
    368        CALL Read_Ncdf_var('Bathymetry',name,CoarseGrid%Bathy_meter) 
     284       CALL Read_Ncdf_var(parent_batmet_name,name,CoarseGrid%Bathy_meter) 
    369285       !             
    370286       IF ( PRESENT(Pacifique) ) THEN 
     
    392308       !           
    393309       i_min = MAXLOC(topo_lon,mask = topo_lon < MINVAL(ChildGrid%nav_lon)) 
    394  
    395        ! 
    396310       i_max = MINLOC(topo_lon,mask = topo_lon > MAXVAL(ChildGrid%nav_lon))                     
    397        ! 
    398311       j_min = MAXLOC(topo_lat,mask = topo_lat < MINVAL(ChildGrid%nav_lat)) 
    399312       j_max = MINLOC(topo_lat,mask = topo_lat > MAXVAL(ChildGrid%nav_lat)) 
     
    402315       !           
    403316       IF(j_min(1)-2 >= 1 .AND. j_max(1)+3 <= SIZE(topo_lat,1) ) THEN 
    404           tabdim2 = j_max(1)-j_min(1)+5  
    405        ELSE       
    406           tabdim2 = j_max(1)-j_min(1)+1    
     317          j_min(1) = j_min(1)-2 
     318          j_max(1) = j_max(1)+3 
    407319       ENDIF 
     320       tabdim2 = j_max(1) - j_min(1) + 1 
    408321       ! 
    409322       ALLOCATE(CoarseGrid%nav_lon(tabdim1,tabdim2)) 
     
    411324       ALLOCATE(CoarseGrid%Bathy_meter(tabdim1,tabdim2))           
    412325       ! 
    413        DO j = 1,SIZE(CoarseGrid%nav_lat,1)  
    414           IF( j_min(1)-2 >= 1 .AND. j_max(1)+3 <= SIZE(topo_lat,1) ) THEN 
    415              CoarseGrid%nav_lat(j,1:tabdim2) = topo_lat(j_min(1)-2:j_max(1)+3)  
    416           ELSE 
    417              CoarseGrid%nav_lat(j,1:tabdim2) = topo_lat(j_min(1):j_max(1)+1) 
    418           ENDIF 
     326       DO i = 1,tabdim1 
     327          CoarseGrid%nav_lat(i,:) = topo_lat(j_min(1):j_max(1)) 
    419328       END DO 
    420329       ! 
    421        DO i = 1,SIZE(CoarseGrid%nav_lon,2)  
     330       DO j = 1, tabdim2 
    422331          !                      
    423           CoarseGrid%nav_lon(1:SIZE(topo_lon)-i_min(1),i) = topo_lon(i_min(1):SIZE(topo_lon)) 
    424           CoarseGrid%nav_lon(1+SIZE(topo_lon)-i_min(1):tabdim1,i) = topo_lon(1:i_max(1)) 
     332          CoarseGrid%nav_lon(1:SIZE(topo_lon)-i_min(1)+1      ,j) = topo_lon(i_min(1):SIZE(topo_lon)) 
     333          CoarseGrid%nav_lon(2+SIZE(topo_lon)-i_min(1):tabdim1,j) = topo_lon(1:i_max(1)) 
    425334          !     
    426335       END DO 
    427336       status = nf90_open(name,NF90_NOWRITE,ncid) 
    428        status = nf90_inq_varid(ncid,'topo',varid) 
     337       status = nf90_inq_varid(ncid,elevation_name,varid) 
    429338       !           
    430        status=nf90_get_var(ncid,varid,CoarseGrid%Bathy_meter(1:SIZE(topo_lon)-i_min(1),:), & 
    431             start=(/i_min(1),j_min(1)-2/),count=(/SIZE(topo_lon)-i_min(1),tabdim2/)) 
    432  
    433        status=nf90_get_var(ncid,varid,CoarseGrid%Bathy_meter(1+SIZE(topo_lon)-i_min(1):tabdim1,:), & 
    434             start=(/1,j_min(1)-2/),count=(/i_max(1)+1,tabdim2/))                 
     339       status=nf90_get_var(ncid,varid,CoarseGrid%Bathy_meter(1:SIZE(topo_lon)-i_min(1)+1,:), & 
     340            start=(/i_min(1),j_min(1)/),count=(/SIZE(topo_lon)-i_min(1),tabdim2/)) 
     341 
     342       status=nf90_get_var(ncid,varid,CoarseGrid%Bathy_meter(2+SIZE(topo_lon)-i_min(1):tabdim1,:), & 
     343            start=(/1,j_min(1)/),count=(/i_max(1),tabdim2/))                 
    435344       ! 
    436345    ELSE 
     
    442351       !       
    443352       IF(i_min(1)-2 >= 1 .AND. i_max(1)+3 <= SIZE(topo_lon,1) ) THEN 
    444           tabdim1 = i_max(1)-i_min(1)+5  
    445        ELSE       
    446           tabdim1 = i_max(1)-i_min(1)+1    
     353          i_min(1) = i_min(1)-2 
     354          i_max(1) = i_max(1)+3 
    447355       ENDIF 
     356       tabdim1 = i_max(1) - i_min(1) + 1 
    448357       ! 
    449358       IF(j_min(1)-2 >= 1 .AND. j_max(1)+3 <= SIZE(topo_lat,1) ) THEN 
    450           tabdim2 = j_max(1)-j_min(1)+5  
    451        ELSE       
    452           tabdim2 = j_max(1)-j_min(1)+1    
     359          j_min(1) = j_min(1)-2 
     360          j_max(1) = j_max(1)+3 
    453361       ENDIF 
     362       tabdim2 = j_max(1) - j_min(1) + 1 
    454363       ! 
    455364       WRITE(*,*) ' ' 
     
    461370       ALLOCATE(CoarseGrid%Bathy_meter(tabdim1,tabdim2)) 
    462371       ! 
    463        DO i = 1,SIZE(CoarseGrid%nav_lon,2) 
    464           IF(i_min(1)-2 >= 1 .AND. i_max(1)+3 <= SIZE(topo_lon,1) ) THEN 
    465              CoarseGrid%nav_lon(1:tabdim1,i) = topo_lon(i_min(1)-2:i_max(1)+3) 
    466           ELSE       
    467              CoarseGrid%nav_lon(1:tabdim1,i) = topo_lon(i_min(1):i_max(1)+1) 
    468           ENDIF 
    469           !             
     372       DO j = 1,tabdim2 
     373          CoarseGrid%nav_lon(:,j) = topo_lon(i_min(1):i_max(1)) 
    470374       END DO 
    471375       !       
    472        DO j = 1,SIZE(CoarseGrid%nav_lat,1)  
    473           IF( j_min(1)-2 >= 1 .AND. j_max(1)+3 <= SIZE(topo_lat,1) ) THEN 
    474              CoarseGrid%nav_lat(j,1:tabdim2) = topo_lat(j_min(1)-2:j_max(1)+3)  
    475           ELSE 
    476              CoarseGrid%nav_lat(j,1:tabdim2) = topo_lat(j_min(1):j_max(1)+1) 
    477           ENDIF 
     376       DO i = 1,tabdim1 
     377          CoarseGrid%nav_lat(i,:) = topo_lat(j_min(1):j_max(1))  
    478378       END DO 
    479379       ! 
    480        !       
    481380       status = nf90_open(name,NF90_NOWRITE,ncid) 
    482        status = nf90_inq_varid(ncid,'topo',varid) 
    483        IF( j_min(1)-2 >= 1 .AND. i_min(1)-2 >= 1 ) THEN  
    484           status=nf90_get_var(ncid,varid,CoarseGrid%Bathy_meter, & 
    485                start=(/i_min(1)-2,j_min(1)-2/),count=(/tabdim1,tabdim2/)) 
    486        ELSE 
    487           status=nf90_get_var(ncid,varid,CoarseGrid%Bathy_meter, & 
    488                start=(/i_min(1),j_min(1)/),count=(/tabdim1,tabdim2/))  
    489        ENDIF 
     381       status = nf90_inq_varid(ncid,elevation_name,varid) 
     382       status = nf90_get_var(ncid,varid,CoarseGrid%Bathy_meter, & 
     383          &                  start=(/i_min(1),j_min(1)/),count=(/tabdim1,tabdim2/)) 
    490384       ! 
    491385    ENDIF 
    492     ! 
    493386    ! 
    494387    status = nf90_close(ncid)      
     
    498391    END WHERE 
    499392    !       
    500     DO j = 1,SIZE(CoarseGrid%Bathy_meter,2) 
    501        DO i = 1,SIZE(CoarseGrid%Bathy_meter,1) 
    502  
    503           CoarseGrid%Bathy_meter(i,j) = -1.0*CoarseGrid%Bathy_meter(i,j)       
    504  
    505        END DO 
    506     END DO 
     393    CoarseGrid%Bathy_meter(:,:) = -1.0 * CoarseGrid%Bathy_meter(:,:) 
    507394    !       
    508395    Read_Bathy_meter = 1 
     
    524411    TYPE(Coordinates) :: Grid 
    525412    ! 
    526     CALL Read_Ncdf_var('Bathymetry',name,Grid%Bathy_meter)     
     413    CALL Read_Ncdf_var(parent_batmet_name,name,Grid%Bathy_meter)     
    527414    ! 
    528415    WRITE(*,*) ' ' 
     
    544431    CHARACTER(*) name 
    545432    TYPE(Coordinates) :: Grid 
    546     INTEGER :: status,ncid,deptht 
    547     REAL*8,DIMENSION(:),POINTER :: timedepth_temp 
    548     REAL*8,DIMENSION(:,:,:),POINTER :: bathy3d 
    549     CHARACTER(len=20),DIMENSION(4) :: dimnames 
    550     REAL*8,DIMENSION(:,:,:,:),POINTER :: bathy4d 
     433    INTEGER :: status,ncid 
     434    CHARACTER(len=1),DIMENSION(2) :: dimnames 
    551435    INTEGER :: nx,ny 
    552436    ! 
     
    556440    nx = SIZE(Grid%bathy_meter,1) 
    557441    ny = SIZE(Grid%bathy_meter,2) 
    558  
    559     CALL Write_Ncdf_dim('x',name,nx) 
    560     CALL Write_Ncdf_dim('y',name,ny) 
    561     IF(.NOT. iom_activated) CALL Write_Ncdf_dim('deptht',name,1) 
    562     IF(Dims_Existence('time_counter' , TRIM(parent_bathy_meter))) & 
    563          CALL Write_Ncdf_dim('time_counter',name,0) 
    564     !  
    565     dimnames(1)='x' 
    566     dimnames(2)='y'  
    567     IF( iom_activated ) THEN 
    568        dimnames(3)='time_counter' 
    569     ELSE         
    570        dimnames(3)='deptht' 
    571        dimnames(4)='time_counter'         
    572     ENDIF 
     442    dimnames = (/ 'x','y' /) 
     443 
     444    CALL Write_Ncdf_dim(dimnames(1),name,nx) 
     445    CALL Write_Ncdf_dim(dimnames(2),name,ny) 
    573446    !      
    574     CALL Write_Ncdf_var('nav_lon',dimnames(1:2),name,Grid%nav_lon,'float') 
    575     CALL Write_Ncdf_var('nav_lat',dimnames(1:2),name,Grid%nav_lat,'float') 
    576     ! 
    577     IF ( Dims_Existence( 'deptht' , TRIM(parent_bathy_meter) ) & 
    578          .AND. .NOT. iom_activated ) THEN 
    579        CALL Read_Ncdf_dim('deptht',TRIM(parent_bathy_level),deptht) 
    580        ALLOCATE(timedepth_temp(deptht))       
    581        CALL Read_Ncdf_var('deptht',TRIM(parent_bathy_meter),timedepth_temp) 
    582        CALL Write_Ncdf_var('deptht','deptht',name,timedepth_temp,'float') 
    583        CALL Copy_Ncdf_att('deptht',TRIM(parent_bathy_meter),name) 
    584        DEALLOCATE(timedepth_temp) 
    585     ENDIF 
    586     ! 
    587     IF ( Dims_Existence( 'time_counter' , TRIM(parent_bathy_meter) ) ) THEN 
    588        CALL Read_Ncdf_var('time_counter',TRIM(parent_bathy_meter),timedepth_temp) 
    589        CALL Write_Ncdf_var('time_counter','time_counter',name,timedepth_temp,'float') 
    590        CALL Copy_Ncdf_att('time_counter',TRIM(parent_bathy_meter),name) 
    591        DEALLOCATE(timedepth_temp)             
    592     ENDIF 
    593     ! 
    594     IF(iom_activated) THEN 
    595        ALLOCATE(bathy3d(nx,ny,1)) 
    596        bathy3d(:,:,1) = Grid%bathy_meter(:,:) 
    597        CALL Write_Ncdf_var('Bathymetry',dimnames(1:3),name,bathy3d,'float') 
    598        DEALLOCATE(bathy3d) 
    599     ELSE IF( .NOT. Dims_Existence( 'time_counter' , TRIM(parent_bathy_meter) ) .AND. & 
    600          .NOT. Dims_Existence( 'deptht' , TRIM(parent_bathy_meter) ) ) THEN 
    601        CALL Write_Ncdf_var('Bathymetry',dimnames(1:2),name,Grid%bathy_meter,'float') 
    602     ELSE 
    603        ALLOCATE(bathy4d(nx,ny,1,1)) 
    604        bathy4d(:,:,1,1) = Grid%bathy_meter(:,:) 
    605        CALL Write_Ncdf_var('Bathymetry',dimnames,name,bathy4d,'float') 
    606        DEALLOCATE(bathy4d)       
    607     ENDIF 
    608     ! 
    609     CALL Copy_Ncdf_att('nav_lon',TRIM(parent_bathy_meter),name,   & 
    610          MINVAL(Grid%nav_lon),MAXVAL(Grid%nav_lon)) 
    611     CALL Copy_Ncdf_att('nav_lat',TRIM(parent_bathy_meter),name,   & 
    612          MINVAL(Grid%nav_lat),MAXVAL(Grid%nav_lat)) 
    613     !       
    614     !             
    615     CALL Copy_Ncdf_att('Bathymetry',TRIM(parent_bathy_meter),name) 
     447    CALL Write_Ncdf_var('nav_lon'         ,dimnames,name,Grid%nav_lon    ,'float') 
     448    CALL Write_Ncdf_var('nav_lat'         ,dimnames,name,Grid%nav_lat    ,'float') 
     449    CALL Write_Ncdf_var(parent_batmet_name,dimnames,name,Grid%bathy_meter,'float') 
     450    ! 
     451    CALL Copy_Ncdf_att('nav_lon'         ,TRIM(parent_bathy_meter),name,MINVAL(Grid%nav_lon),MAXVAL(Grid%nav_lon)) 
     452    CALL Copy_Ncdf_att('nav_lat'         ,TRIM(parent_bathy_meter),name,MINVAL(Grid%nav_lat),MAXVAL(Grid%nav_lat))   
     453    CALL Copy_Ncdf_att(parent_batmet_name,TRIM(parent_bathy_meter),name) 
    616454    ! 
    617455    WRITE(*,*) ' ' 
    618456    WRITE(*,*) 'Writing bathymetry file: ',name 
    619     IF(.NOT. iom_activated) WRITE(*,*) 'IOISPL format' 
    620     IF(iom_activated) WRITE(*,*) 'IOM format'       
    621457    WRITE(*,*) ' ' 
    622458    ! 
     
    689525             k=0 
    690526             conservation = .FALSE.          
    691              DO WHILE( k <= SIZE(flxtab) .AND. .NOT.find )  
     527             DO WHILE( k < SIZE(flxtab) .AND. .NOT.find )  
    692528                k = k+1 
    693529                IF( TRIM(varname) .EQ. TRIM(flxtab(k)) ) THEN        
  • branches/nemo_v3_3_beta/NEMOGCM/TOOLS/NESTING/src/agrif_types.f90

    r2143 r2455  
    5757  LOGICAL new_topo,removeclosedseas,dimg,iom_activated 
    5858  !        
    59   CHARACTER*100 parent_bathy_level,elevation_database,parent_bathy_meter 
     59  CHARACTER*100 parent_meshmask_file,elevation_database,parent_bathy_meter 
     60  CHARACTER*100 elevation_name,parent_batmet_name 
    6061  CHARACTER*100 parent_coordinate_file,restart_file,updated_parent_file,restart_trc_file 
    6162  CHARACTER*100 dimg_output_file,interp_type 
     
    6667  NAMELIST /input_output/iom_activated 
    6768  ! 
    68   NAMELIST /coarse_grid_files/parent_coordinate_file,parent_bathy_level 
    69   !       
    70   NAMELIST /bathymetry/new_topo,elevation_database,smoothing,smoothing_factor, & 
     69  NAMELIST /coarse_grid_files/parent_coordinate_file,parent_meshmask_file 
     70  !       
     71  NAMELIST /bathymetry/new_topo,elevation_database,elevation_name,smoothing,smoothing_factor, & 
    7172       nb_connection_pts,removeclosedseas,type_bathy_interp       
    7273  !       
     
    7576  NAMELIST /vertical_grid/ppkth,ppacr,ppdzmin,pphmax,psur,pa0,pa1,N 
    7677  !  
    77   NAMELIST /partial_cells/partial_steps,parent_bathy_meter,e3zps_min,e3zps_rat       
     78  NAMELIST /partial_cells/partial_steps,parent_bathy_meter,parent_batmet_name,e3zps_min,e3zps_rat       
    7879  ! 
    7980  NAMELIST /nemo_coarse_grid/ jpizoom,jpjzoom  
Note: See TracChangeset for help on using the changeset viewer.