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 5602 for branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90 – NEMO

Ignore:
Timestamp:
2015-07-16T13:55:15+02:00 (9 years ago)
Author:
cbricaud
Message:

merge change from trunk rev 5003 to 5519 ( rev where branche 3.6_stable were created )

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90

    r5105 r5602  
    3838   USE icb_oce, ONLY :   nclasses, class_num       !  !: iceberg classes 
    3939#if defined key_lim3 
    40    USE par_ice 
     40   USE ice    , ONLY :   jpl 
    4141#elif defined key_lim2 
    4242   USE par_ice_2 
     
    6666#if defined key_iomput 
    6767   PRIVATE iom_set_domain_attr, iom_set_axis_attr, iom_set_field_attr, iom_set_file_attr, iom_get_file_attr, iom_set_grid_attr 
    68    PRIVATE set_grid, set_scalar, set_xmlatt, set_mooring, iom_update_file_name, iom_sdate 
     68   PRIVATE set_grid, set_grid_bounds, set_scalar, set_xmlatt, set_mooring, iom_update_file_name, iom_sdate 
    6969# endif 
    7070 
     
    103103      CHARACTER(len=10) :: clname 
    104104      INTEGER           ::   ji 
    105       !!---------------------------------------------------------------------- 
     105      ! 
     106      REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: z_bnds 
     107      !!---------------------------------------------------------------------- 
     108 
     109      ALLOCATE( z_bnds(jpk,2) ) 
    106110 
    107111      clname = cdname 
    108112      IF( TRIM(Agrif_CFixed()) /= '0' )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(cdname) 
    109 # if defined key_mpp_mpi 
    110113      CALL xios_context_initialize(TRIM(clname), mpi_comm_opa) 
    111 # else 
    112       CALL xios_context_initialize(TRIM(clname), 0) 
    113 # endif 
    114114      CALL iom_swap( cdname ) 
    115115 
     
    126126      CALL set_scalar 
    127127 
    128       IF( TRIM(cdname) == "nemo" ) THEN   
     128      IF( TRIM(cdname) == TRIM(cxios_context) ) THEN   
    129129         CALL set_grid( "T", glamt, gphit )  
    130130         CALL set_grid( "U", glamu, gphiu ) 
    131131         CALL set_grid( "V", glamv, gphiv ) 
    132132         CALL set_grid( "W", glamt, gphit ) 
    133       ENDIF 
    134  
    135       IF( TRIM(cdname) == "nemo_crs" ) THEN   
     133         CALL set_grid_znl( gphit ) 
     134         ! 
     135         IF( ln_cfmeta ) THEN   ! Add additional grid metadata 
     136            CALL iom_set_domain_attr("grid_T", area = e12t(nldi:nlei, nldj:nlej)) 
     137            CALL iom_set_domain_attr("grid_U", area = e12u(nldi:nlei, nldj:nlej)) 
     138            CALL iom_set_domain_attr("grid_V", area = e12v(nldi:nlei, nldj:nlej)) 
     139            CALL iom_set_domain_attr("grid_W", area = e12t(nldi:nlei, nldj:nlej)) 
     140            CALL set_grid_bounds( "T", glamf, gphif, glamt, gphit ) 
     141            CALL set_grid_bounds( "U", glamv, gphiv, glamu, gphiu ) 
     142            CALL set_grid_bounds( "V", glamu, gphiu, glamv, gphiv ) 
     143            CALL set_grid_bounds( "W", glamf, gphif, glamt, gphit ) 
     144         ENDIF 
     145      ENDIF 
     146 
     147      IF( TRIM(cdname) == TRIM(cxios_context)//"_crs" ) THEN   
    136148         CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain 
    137149         ! 
     
    140152         CALL set_grid( "V", glamv_crs, gphiv_crs )  
    141153         CALL set_grid( "W", glamt_crs, gphit_crs )  
     154         CALL set_grid_znl( gphit_crs ) 
    142155          ! 
    143156         CALL dom_grid_glo   ! Return to parent grid domain 
    144       ENDIF 
    145  
     157         ! 
     158         IF( ln_cfmeta ) THEN   ! Add additional grid metadata 
     159            CALL iom_set_domain_attr("grid_T", area = e1e2t_crs(nldi:nlei, nldj:nlej)) 
     160            CALL iom_set_domain_attr("grid_U", area = e1u_crs(nldi:nlei, nldj:nlej) * e2u_crs(nldi:nlei, nldj:nlej)) 
     161            CALL iom_set_domain_attr("grid_V", area = e1v_crs(nldi:nlei, nldj:nlej) * e2v_crs(nldi:nlei, nldj:nlej)) 
     162            CALL iom_set_domain_attr("grid_W", area = e1e2t_crs(nldi:nlei, nldj:nlej)) 
     163            CALL set_grid_bounds( "T", glamf_crs, gphif_crs, glamt_crs, gphit_crs ) 
     164            CALL set_grid_bounds( "U", glamv_crs, gphiv_crs, glamu_crs, gphiu_crs ) 
     165            CALL set_grid_bounds( "V", glamu_crs, gphiu_crs, glamv_crs, gphiv_crs ) 
     166            CALL set_grid_bounds( "W", glamf_crs, gphif_crs, glamt_crs, gphit_crs ) 
     167         ENDIF 
     168      ENDIF 
    146169 
    147170      ! vertical grid definition 
     
    150173      CALL iom_set_axis_attr( "depthv", gdept_1d ) 
    151174      CALL iom_set_axis_attr( "depthw", gdepw_1d ) 
     175 
     176      ! Add vertical grid bounds 
     177      z_bnds(:      ,1) = gdepw_1d(:) 
     178      z_bnds(1:jpkm1,2) = gdepw_1d(2:jpk) 
     179      z_bnds(jpk:   ,2) = gdepw_1d(jpk) + e3t_1d(jpk) 
     180      CALL iom_set_axis_attr( "deptht", bounds=z_bnds ) 
     181      CALL iom_set_axis_attr( "depthu", bounds=z_bnds ) 
     182      CALL iom_set_axis_attr( "depthv", bounds=z_bnds ) 
     183      z_bnds(:    ,2) = gdept_1d(:) 
     184      z_bnds(2:jpk,1) = gdept_1d(1:jpkm1) 
     185      z_bnds(1    ,1) = gdept_1d(1) - e3w_1d(1) 
     186      CALL iom_set_axis_attr( "depthw", bounds=z_bnds ) 
     187 
    152188# if defined key_floats 
    153189      CALL iom_set_axis_attr( "nfloat", (/ (REAL(ji,wp), ji=1,nfloat) /) ) 
     
    157193#endif 
    158194      CALL iom_set_axis_attr( "icbcla", class_num ) 
     195      CALL iom_set_axis_attr( "iax_20C", (/ REAL(20,wp) /) ) 
     196      CALL iom_set_axis_attr( "iax_28C", (/ REAL(28,wp) /) ) 
    159197       
    160198      ! automatic definitions of some of the xml attributs 
     
    167205       
    168206      CALL xios_update_calendar(0) 
     207 
     208      DEALLOCATE( z_bnds ) 
     209 
    169210#endif 
    170211       
     
    548589   END SUBROUTINE iom_g1d 
    549590 
    550    SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount ) 
     591   SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr ) 
    551592      INTEGER         , INTENT(in   )                           ::   kiomid    ! Identifier of the file 
    552593      INTEGER         , INTENT(in   )                           ::   kdom      ! Type of domain to be read 
     
    556597      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kstart    ! start axis position of the reading  
    557598      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kcount    ! number of points in each axis 
     599      LOGICAL         , INTENT(in   )                , OPTIONAL ::   lrowattr  ! logical flag telling iom_get to 
     600                                                                               ! look for and use a file attribute 
     601                                                                               ! called open_ocean_jstart to set the start 
     602                                                                               ! value for the 2nd dimension (netcdf only) 
    558603      ! 
    559604      IF( kiomid > 0 ) THEN 
    560605         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r2d=pvar,   & 
    561               &                                                     ktime=ktime, kstart=kstart, kcount=kcount ) 
     606              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, & 
     607              &                                                     lrowattr=lrowattr ) 
    562608      ENDIF 
    563609   END SUBROUTINE iom_g2d 
    564610 
    565    SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount ) 
     611   SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr ) 
    566612      INTEGER         , INTENT(in   )                             ::   kiomid    ! Identifier of the file 
    567613      INTEGER         , INTENT(in   )                             ::   kdom      ! Type of domain to be read 
     
    571617      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kstart    ! start axis position of the reading  
    572618      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kcount    ! number of points in each axis 
     619      LOGICAL         , INTENT(in   )                  , OPTIONAL ::   lrowattr  ! logical flag telling iom_get to 
     620                                                                                 ! look for and use a file attribute 
     621                                                                                 ! called open_ocean_jstart to set the start 
     622                                                                                 ! value for the 2nd dimension (netcdf only) 
    573623      ! 
    574624      IF( kiomid > 0 ) THEN 
    575625         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r3d=pvar,   & 
    576               &                                                     ktime=ktime, kstart=kstart, kcount=kcount ) 
     626              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, & 
     627              &                                                     lrowattr=lrowattr ) 
    577628      ENDIF 
    578629   END SUBROUTINE iom_g3d 
     
    581632   SUBROUTINE iom_get_123d( kiomid, kdom  , cdvar ,   & 
    582633         &                  pv_r1d, pv_r2d, pv_r3d,   & 
    583          &                  ktime , kstart, kcount  ) 
     634         &                  ktime , kstart, kcount,   & 
     635         &                  lrowattr                ) 
    584636      !!----------------------------------------------------------------------- 
    585637      !!                  ***  ROUTINE  iom_get_123d  *** 
     
    598650      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kstart     ! start position of the reading in each axis  
    599651      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kcount     ! number of points to be read in each axis 
     652      LOGICAL                    , INTENT(in   ), OPTIONAL ::   lrowattr   ! logical flag telling iom_get to 
     653                                                                           ! look for and use a file attribute 
     654                                                                           ! called open_ocean_jstart to set the start 
     655                                                                           ! value for the 2nd dimension (netcdf only) 
    600656      ! 
    601657      LOGICAL                        ::   llnoov      ! local definition to read overlap 
     658      LOGICAL                        ::   luse_jattr  ! local definition to read open_ocean_jstart file attribute 
     659      INTEGER                        ::   jstartrow   ! start point for 2nd dimension optionally set by file attribute 
    602660      INTEGER                        ::   jl          ! loop on number of dimension  
    603661      INTEGER                        ::   idom        ! type of domain 
     
    609667      INTEGER                        ::   ix1, ix2, iy1, iy2   ! subdomain indexes 
    610668      INTEGER                        ::   ji, jj      ! loop counters 
    611       INTEGER                        ::   irankpv       !  
     669      INTEGER                        ::   irankpv     !  
    612670      INTEGER                        ::   ind1, ind2  ! substring index 
    613671      INTEGER, DIMENSION(jpmax_dims) ::   istart      ! starting point to read for each axis 
     
    633691      IF( PRESENT(kstart) .AND. (.NOT. PRESENT(kcount)) ) CALL ctl_stop(trim(clinfo), 'kstart present needs kcount present') 
    634692      IF( PRESENT(kstart) .AND. idom /= jpdom_unknown   ) CALL ctl_stop(trim(clinfo), 'kstart present needs kdom = jpdom_unknown') 
     693 
     694      luse_jattr = .false. 
     695      IF( PRESENT(lrowattr) ) THEN 
     696         IF( lrowattr .AND. idom /= jpdom_data   ) CALL ctl_stop(trim(clinfo), 'lrowattr present and true needs kdom = jpdom_data') 
     697         IF( lrowattr .AND. idom == jpdom_data   ) luse_jattr = .true. 
     698      ENDIF 
     699      IF( luse_jattr ) THEN 
     700         SELECT CASE (iom_file(kiomid)%iolib) 
     701         CASE (jpioipsl, jprstdimg ) 
     702             CALL ctl_warn(trim(clinfo), 'lrowattr present and true but this only works with netcdf (jpnf90)') 
     703             luse_jattr = .false. 
     704         CASE (jpnf90   )    
     705             ! Ok 
     706         CASE DEFAULT     
     707            CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' ) 
     708         END SELECT 
     709      ENDIF 
    635710 
    636711      ! Search for the variable in the data base (eventually actualize data) 
     
    706781            ELSE  
    707782               IF( .NOT. PRESENT(pv_r1d) ) THEN   !   not a 1D array 
    708                   IF(     idom == jpdom_data    ) THEN ; istart(1:2) = (/ mig(1), mjg(1) /)  ! icnt(1:2) done bellow 
    709                   ELSEIF( idom == jpdom_global  ) THEN ; istart(1:2) = (/ nimpp , njmpp  /)  ! icnt(1:2) done bellow 
     783                  IF(     idom == jpdom_data    ) THEN 
     784                     jstartrow = 1 
     785                     IF( luse_jattr ) THEN 
     786                        CALL iom_getatt(kiomid, 'open_ocean_jstart', jstartrow ) ! -999 is returned if the attribute is not found 
     787                        jstartrow = MAX(1,jstartrow) 
     788                     ENDIF 
     789                     istart(1:2) = (/ mig(1), mjg(1) + jstartrow - 1 /)  ! icnt(1:2) done below 
     790                  ELSEIF( idom == jpdom_global  ) THEN ; istart(1:2) = (/ nimpp , njmpp  /)  ! icnt(1:2) done below 
    710791                  ENDIF 
    711792                  ! we do not read the overlap                     -> we start to read at nldi, nldj 
     
    10721153 
    10731154   SUBROUTINE iom_set_domain_attr( cdid, ni_glo, nj_glo, ibegin, jbegin, ni, nj, zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj,   & 
    1074       &                                    data_dim, data_ibegin, data_ni, data_jbegin, data_nj, lonvalue, latvalue, mask ) 
    1075       CHARACTER(LEN=*)                 , INTENT(in) ::   cdid 
    1076       INTEGER                , OPTIONAL, INTENT(in) ::   ni_glo, nj_glo, ibegin, jbegin, ni, nj 
    1077       INTEGER                , OPTIONAL, INTENT(in) ::   data_dim, data_ibegin, data_ni, data_jbegin, data_nj 
    1078       INTEGER                , OPTIONAL, INTENT(in) ::   zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj 
    1079       REAL(wp), DIMENSION(:) , OPTIONAL, INTENT(in) ::   lonvalue, latvalue 
    1080       LOGICAL, DIMENSION(:,:), OPTIONAL, INTENT(in) ::   mask 
     1155      &                                    data_dim, data_ibegin, data_ni, data_jbegin, data_nj, lonvalue, latvalue, mask,     & 
     1156      &                                    nvertex, bounds_lon, bounds_lat, area ) 
     1157      CHARACTER(LEN=*)                   , INTENT(in) ::   cdid 
     1158      INTEGER                  , OPTIONAL, INTENT(in) ::   ni_glo, nj_glo, ibegin, jbegin, ni, nj 
     1159      INTEGER                  , OPTIONAL, INTENT(in) ::   data_dim, data_ibegin, data_ni, data_jbegin, data_nj 
     1160      INTEGER                  , OPTIONAL, INTENT(in) ::   zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj, nvertex 
     1161      REAL(wp), DIMENSION(:)   , OPTIONAL, INTENT(in) ::   lonvalue, latvalue 
     1162      REAL(wp), DIMENSION(:,:) , OPTIONAL, INTENT(in) ::   bounds_lon, bounds_lat, area 
     1163      LOGICAL,  DIMENSION(:,:) , OPTIONAL, INTENT(in) ::   mask 
    10811164 
    10821165      IF ( xios_is_valid_domain     (cdid) ) THEN 
     
    10841167            &    data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj ,   & 
    10851168            &    zoom_ibegin=zoom_ibegin, zoom_jbegin=zoom_jbegin, zoom_ni=zoom_ni, zoom_nj=zoom_nj,                       & 
    1086             &    lonvalue=lonvalue, latvalue=latvalue,mask=mask ) 
     1169            &    lonvalue=lonvalue, latvalue=latvalue, mask=mask, nvertex=nvertex, bounds_lon=bounds_lon,                  & 
     1170            &    bounds_lat=bounds_lat, area=area ) 
    10871171      ENDIF 
    10881172 
     
    10911175            &    data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj ,   & 
    10921176            &    zoom_ibegin=zoom_ibegin, zoom_jbegin=zoom_jbegin, zoom_ni=zoom_ni, zoom_nj=zoom_nj,                       & 
    1093             &    lonvalue=lonvalue, latvalue=latvalue,mask=mask ) 
     1177            &    lonvalue=lonvalue, latvalue=latvalue, mask=mask, nvertex=nvertex, bounds_lon=bounds_lon,                  & 
     1178            &    bounds_lat=bounds_lat, area=area ) 
    10941179      ENDIF 
    10951180      CALL xios_solve_inheritance() 
     
    10981183 
    10991184 
    1100    SUBROUTINE iom_set_axis_attr( cdid, paxis ) 
     1185   SUBROUTINE iom_set_axis_attr( cdid, paxis, bounds ) 
    11011186      CHARACTER(LEN=*)      , INTENT(in) ::   cdid 
    1102       REAL(wp), DIMENSION(:), INTENT(in) ::   paxis 
    1103       IF ( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, size=size(paxis),value=paxis ) 
    1104       IF ( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, size=size(paxis),value=paxis ) 
     1187      REAL(wp), DIMENSION(:)  , OPTIONAL, INTENT(in) ::   paxis 
     1188      REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(in) ::   bounds 
     1189      IF ( PRESENT(paxis) ) THEN 
     1190         IF ( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, size=SIZE(paxis), value=paxis ) 
     1191         IF ( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, size=SIZE(paxis), value=paxis ) 
     1192      ENDIF 
     1193      IF ( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, bounds=bounds ) 
     1194      IF ( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, bounds=bounds ) 
    11051195      CALL xios_solve_inheritance() 
    11061196   END SUBROUTINE iom_set_axis_attr 
     
    11651255      CALL iom_swap( cdname )   ! swap to cdname context 
    11661256      CALL xios_update_calendar(kt) 
    1167       IF( cdname /= "nemo" ) CALL iom_swap( "nemo" )   ! return back to nemo context 
     1257      IF( cdname /= TRIM(cxios_context) ) CALL iom_swap( TRIM(cxios_context) )   ! return back to nemo context 
    11681258      ! 
    11691259   END SUBROUTINE iom_setkt 
     
    11751265         CALL iom_swap( cdname )   ! swap to cdname context 
    11761266         CALL xios_context_finalize() ! finalize the context 
    1177          IF( cdname /= "nemo" ) CALL iom_swap( "nemo" )   ! return back to nemo context 
     1267         IF( cdname /= TRIM(cxios_context) ) CALL iom_swap( TRIM(cxios_context) )   ! return back to nemo context 
    11781268      ENDIF 
    11791269      ! 
     
    12071297         CASE('T')   ;   zmask(:,:,:)       = tmask(:,:,:) 
    12081298         CASE('U')   ;   zmask(2:jpim1,:,:) = tmask(2:jpim1,:,:) + tmask(3:jpi,:,:)   ;   CALL lbc_lnk( zmask, 'U', 1. ) 
    1209          CASE('V')   ;   zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpi,:)   ;   CALL lbc_lnk( zmask, 'V', 1. ) 
     1299         CASE('V')   ;   zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpj,:)   ;   CALL lbc_lnk( zmask, 'V', 1. ) 
    12101300         CASE('W')   ;   zmask(:,:,2:jpk  ) = tmask(:,:,1:jpkm1) + tmask(:,:,2:jpk)   ;   zmask(:,:,1) = tmask(:,:,1) 
    12111301         END SELECT 
     
    12181308 
    12191309 
     1310   SUBROUTINE set_grid_bounds( cdgrd, plon_cnr, plat_cnr, plon_pnt, plat_pnt ) 
     1311      !!---------------------------------------------------------------------- 
     1312      !!                   ***  ROUTINE set_grid_bounds  *** 
     1313      !! 
     1314      !! ** Purpose :   define horizontal grid corners 
     1315      !! 
     1316      !!---------------------------------------------------------------------- 
     1317      CHARACTER(LEN=1) , INTENT(in) :: cdgrd 
     1318      ! 
     1319      REAL(wp), DIMENSION(jpi,jpj), INTENT(in)           :: plon_cnr, plat_cnr  ! Lat/lon coordinates of a contiguous vertex of cell (i,j) 
     1320      REAL(wp), DIMENSION(jpi,jpj), OPTIONAL, INTENT(in) :: plon_pnt, plat_pnt  ! Lat/lon coordinates of the point of cell (i,j) 
     1321      ! 
     1322      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:)   :: z_bnds      ! Lat/lon coordinates of the vertices of cell (i,j) 
     1323      REAL(wp), ALLOCATABLE, DIMENSION(:,:)       :: z_fld       ! Working array to determine where to rotate cells 
     1324      REAL(wp), ALLOCATABLE, DIMENSION(:,:)       :: z_rot       ! Lat/lon working array for rotation of cells 
     1325      ! 
     1326      INTEGER :: icnr, jcnr                                      ! Offset such that the vertex coordinate (i+icnr,j+jcnr) 
     1327      !                                                          ! represents the bottom-left corner of cell (i,j) 
     1328      INTEGER :: ji, jj, jn, ni, nj 
     1329 
     1330      ALLOCATE( z_bnds(4,jpi,jpj,2), z_fld(jpi,jpj), z_rot(4,2)  ) 
     1331 
     1332      ! Offset of coordinate representing bottom-left corner 
     1333      SELECT CASE ( TRIM(cdgrd) ) 
     1334         CASE ('T', 'W') 
     1335            icnr = -1 ; jcnr = -1 
     1336         CASE ('U') 
     1337            icnr =  0 ; jcnr = -1 
     1338         CASE ('V') 
     1339            icnr = -1 ; jcnr =  0 
     1340      END SELECT 
     1341 
     1342      ni = nlei-nldi+1 ; nj = nlej-nldj+1  ! Dimensions of subdomain interior 
     1343 
     1344      z_fld(:,:) = 1._wp 
     1345      CALL lbc_lnk( z_fld, cdgrd, -1. )    ! Working array for location of northfold 
     1346 
     1347      ! Cell vertices that can be defined 
     1348      DO jj = 2, jpjm1 
     1349         DO ji = 2, jpim1 
     1350            z_bnds(1,ji,jj,1) = plat_cnr(ji+icnr,  jj+jcnr  ) ! Bottom-left 
     1351            z_bnds(2,ji,jj,1) = plat_cnr(ji+icnr+1,jj+jcnr  ) ! Bottom-right 
     1352            z_bnds(3,ji,jj,1) = plat_cnr(ji+icnr+1,jj+jcnr+1) ! Top-right 
     1353            z_bnds(4,ji,jj,1) = plat_cnr(ji+icnr,  jj+jcnr+1) ! Top-left 
     1354            z_bnds(1,ji,jj,2) = plon_cnr(ji+icnr,  jj+jcnr  ) ! Bottom-left 
     1355            z_bnds(2,ji,jj,2) = plon_cnr(ji+icnr+1,jj+jcnr  ) ! Bottom-right 
     1356            z_bnds(3,ji,jj,2) = plon_cnr(ji+icnr+1,jj+jcnr+1) ! Top-right 
     1357            z_bnds(4,ji,jj,2) = plon_cnr(ji+icnr,  jj+jcnr+1) ! Top-left 
     1358         END DO 
     1359      END DO 
     1360 
     1361      ! Cell vertices on boundries 
     1362      DO jn = 1, 4 
     1363         CALL lbc_lnk( z_bnds(jn,:,:,1), cdgrd, 1., pval=999._wp ) 
     1364         CALL lbc_lnk( z_bnds(jn,:,:,2), cdgrd, 1., pval=999._wp ) 
     1365      END DO 
     1366 
     1367      ! Zero-size cells at closed boundaries if cell points provided, 
     1368      ! otherwise they are closed cells with unrealistic bounds 
     1369      IF( PRESENT(plon_pnt) .AND. PRESENT(plat_pnt) ) THEN 
     1370         IF( (nbondi == -1 .OR. nbondi == 2) .AND. .NOT. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6) ) THEN 
     1371            DO jn = 1, 4        ! (West or jpni = 1), closed E-W 
     1372               z_bnds(jn,1,:,1) = plat_pnt(1,:)  ;  z_bnds(jn,1,:,2) = plon_pnt(1,:) 
     1373            END DO 
     1374         ENDIF 
     1375         IF( (nbondi == 1 .OR. nbondi == 2) .AND. .NOT. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6) ) THEN 
     1376            DO jn = 1, 4        ! (East or jpni = 1), closed E-W 
     1377               z_bnds(jn,nlci,:,1) = plat_pnt(nlci,:)  ;  z_bnds(jn,nlci,:,2) = plon_pnt(nlci,:) 
     1378            END DO 
     1379         ENDIF 
     1380         IF( nbondj == -1 .OR. (nbondj == 2 .AND. jperio /= 2) ) THEN 
     1381            DO jn = 1, 4        ! South or (jpnj = 1, not symmetric) 
     1382               z_bnds(jn,:,1,1) = plat_pnt(:,1)  ;  z_bnds(jn,:,1,2) = plon_pnt(:,1) 
     1383            END DO 
     1384         ENDIF 
     1385         IF( (nbondj == 1 .OR. nbondj == 2) .AND. jperio  < 3 ) THEN 
     1386            DO jn = 1, 4        ! (North or jpnj = 1), no north fold 
     1387               z_bnds(jn,:,nlcj,1) = plat_pnt(:,nlcj)  ;  z_bnds(jn,:,nlcj,2) = plon_pnt(:,nlcj) 
     1388            END DO 
     1389         ENDIF 
     1390      ENDIF 
     1391 
     1392      ! Rotate cells at the north fold 
     1393      IF( (nbondj == 1 .OR. nbondj == 2) .AND. jperio >= 3 ) THEN 
     1394         DO jj = 1, jpj 
     1395            DO ji = 1, jpi 
     1396               IF( z_fld(ji,jj) == -1. ) THEN 
     1397                  z_rot(1,:) = z_bnds(3,ji,jj,:) ; z_rot(2,:) = z_bnds(4,ji,jj,:) 
     1398                  z_rot(3,:) = z_bnds(1,ji,jj,:) ; z_rot(4,:) = z_bnds(2,ji,jj,:) 
     1399                  z_bnds(:,ji,jj,:) = z_rot(:,:) 
     1400               ENDIF 
     1401            END DO 
     1402         END DO 
     1403 
     1404      ! Invert cells at the symmetric equator 
     1405      ELSE IF( nbondj == 2 .AND. jperio == 2 ) THEN 
     1406         DO ji = 1, jpi 
     1407            z_rot(1:2,:) = z_bnds(3:4,ji,1,:) 
     1408            z_rot(3:4,:) = z_bnds(1:2,ji,1,:) 
     1409            z_bnds(:,ji,1,:) = z_rot(:,:) 
     1410         END DO 
     1411      ENDIF 
     1412 
     1413      CALL iom_set_domain_attr("grid_"//cdgrd, bounds_lat = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,1),(/ 4,ni*nj /)),           & 
     1414                                               bounds_lon = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,2),(/ 4,ni*nj /)), nvertex=4 ) 
     1415 
     1416      DEALLOCATE( z_bnds, z_fld, z_rot )  
     1417 
     1418   END SUBROUTINE set_grid_bounds 
     1419 
     1420 
     1421   SUBROUTINE set_grid_znl( plat ) 
     1422      !!---------------------------------------------------------------------- 
     1423      !!                     ***  ROUTINE set_grid_znl  *** 
     1424      !! 
     1425      !! ** Purpose :   define grids for zonal mean 
     1426      !! 
     1427      !!---------------------------------------------------------------------- 
     1428      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plat 
     1429      ! 
     1430      REAL(wp), DIMENSION(:), ALLOCATABLE  ::   zlon 
     1431      INTEGER  :: ni,nj, ix, iy 
     1432 
     1433       
     1434      ni=nlei-nldi+1 ; nj=nlej-nldj+1            ! define zonal mean domain (jpj*jpk) 
     1435      ALLOCATE( zlon(ni*nj) )       ;       zlon(:) = 0. 
     1436 
     1437      CALL iom_set_domain_attr("gznl", ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-1, jbegin=njmpp+nldj-1, ni=ni, nj=nj) 
     1438      CALL iom_set_domain_attr("gznl", data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj) 
     1439      CALL iom_set_domain_attr("gznl", lonvalue = zlon,   & 
     1440         &                             latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /)))   
     1441      ! 
     1442      CALL dom_ngb( 180., 90., ix, iy, 'T' ) !  i-line that passes near the North Pole : Reference latitude (used in plots) 
     1443      CALL iom_set_domain_attr ('ptr', zoom_ibegin=ix, zoom_nj=jpjglo) 
     1444      CALL iom_update_file_name('ptr') 
     1445      ! 
     1446   END SUBROUTINE set_grid_znl 
     1447 
    12201448   SUBROUTINE set_scalar 
    12211449      !!---------------------------------------------------------------------- 
     
    12251453      !! 
    12261454      !!---------------------------------------------------------------------- 
    1227       REAL(wp), DIMENSION(1) ::   zz = 1. 
     1455      REAL(wp), DIMENSION(1)   ::   zz = 1. 
    12281456      !!---------------------------------------------------------------------- 
    12291457      CALL iom_set_domain_attr('scalarpoint', ni_glo=jpnij, nj_glo=1, ibegin=narea, jbegin=1, ni=1, nj=1) 
    12301458      CALL iom_set_domain_attr('scalarpoint', data_dim=2, data_ibegin = 1, data_ni = 1, data_jbegin = 1, data_nj = 1) 
     1459       
    12311460      zz=REAL(narea,wp) 
    12321461      CALL iom_set_domain_attr('scalarpoint', lonvalue=zz, latvalue=zz) 
     
    13011530      zlatpira = (/ -19.0, -14.0,  -8.0, 0.0, 4.0, 8.0, 12.0, 15.0, 20.0 /) 
    13021531      CALL set_mooring( zlonpira, zlatpira ) 
     1532 
    13031533       
    13041534   END SUBROUTINE set_xmlatt 
Note: See TracChangeset for help on using the changeset viewer.