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 3432 for branches/2011/DEV_r2739_STFC_dCSE/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90 – NEMO

Ignore:
Timestamp:
2012-07-11T13:22:58+02:00 (12 years ago)
Author:
trackstand2
Message:

Merge branch 'ksection_partition'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2011/DEV_r2739_STFC_dCSE/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90

    r3211 r3432  
    3535# endif 
    3636   USE zpermute, ONLY : permute_z_last   ! Re-order a 3d array back to external (z-last) ordering 
    37  
     37   USE timing,   ONLY : timing_start, timing_stop 
    3838   IMPLICIT NONE 
    3939   PUBLIC   !   must be public to be able to access iom_def through iom 
     
    184184      ! end halo size for x,y dimensions 
    185185      !--------------------------------------------------------------------- 
     186 
     187      CALL timing_start('iom_open') 
     188 
    186189      ! Initializations and control 
    187190      ! ============= 
     
    323326      ENDIF 
    324327      ! 
     328      CALL timing_stop('iom_open') 
     329 
    325330   END SUBROUTINE iom_open 
    326331 
     
    340345      CHARACTER(LEN=100)    ::   clinfo    ! info character 
    341346      !--------------------------------------------------------------------- 
     347      ! 
     348      CALL timing_start('iom_close') 
    342349      ! 
    343350      clinfo = '                    iom_close ~~~  ' 
     
    373380      ENDIF 
    374381      !     
     382      CALL timing_stop('iom_close') 
     383 
    375384   END SUBROUTINE iom_close 
    376385 
     
    392401      LOGICAL                        ::   llstop                   ! local definition of ldstop 
    393402      !!----------------------------------------------------------------------- 
     403      CALL timing_start('iom_varid') 
     404 
    394405      iom_varid = 0                         ! default definition 
    395406      ! do we call ctl_stop if we look for non-existing variable? 
     
    441452      ENDIF 
    442453      ! 
     454      CALL timing_stop('iom_varid') 
     455      ! 
    443456   END FUNCTION iom_varid 
    444457 
     
    455468      ! 
    456469      IF( kiomid > 0 ) THEN 
     470         CALL timing_start('iom_g0d') 
    457471         idvar = iom_varid( kiomid, cdvar ) 
    458472         IF( iom_file(kiomid)%nfid > 0 .AND. idvar > 0 ) THEN 
     
    465479            END SELECT 
    466480         ENDIF 
     481         CALL timing_stop('iom_g0d') 
    467482      ENDIF 
    468483   END SUBROUTINE iom_g0d 
    469484 
    470    SUBROUTINE iom_g1d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount ) 
     485   SUBROUTINE iom_g1d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lzfirst ) 
    471486      INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file 
    472487      INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read 
     
    476491      INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kstart    ! start axis position of the reading  
    477492      INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kcount    ! number of points in each axis 
     493      LOGICAL         , INTENT(in   )              , OPTIONAL ::   lzfirst   ! Whether array being read has been  
     494                                                                             ! ftrans'd to make z index first 
    478495      ! 
    479496      IF( kiomid > 0 ) THEN 
    480497         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r1d=pvar,   & 
    481               &                                                     ktime=ktime, kstart=kstart, kcount=kcount ) 
     498              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, lzfirst=lzfirst ) 
    482499      ENDIF 
    483500   END SUBROUTINE iom_g1d 
    484501 
    485    SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount ) 
     502   SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lzfirst ) 
    486503      INTEGER         , INTENT(in   )                           ::   kiomid    ! Identifier of the file 
    487504      INTEGER         , INTENT(in   )                           ::   kdom      ! Type of domain to be read 
     
    491508      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kstart    ! start axis position of the reading  
    492509      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kcount    ! number of points in each axis 
     510      LOGICAL         , INTENT(in   )                , OPTIONAL ::   lzfirst   ! Whether array being read has been  
     511                                                                               ! ftrans'd to make z index first 
    493512      ! 
    494513      IF( kiomid > 0 ) THEN 
    495514         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r2d=pvar,   & 
    496               &                                                     ktime=ktime, kstart=kstart, kcount=kcount ) 
     515              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, lzfirst=lzfirst ) 
    497516      ENDIF 
    498517   END SUBROUTINE iom_g2d 
    499518 
    500    SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount ) 
     519   SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lzfirst ) 
    501520      INTEGER         , INTENT(in   )                             ::   kiomid    ! Identifier of the file 
    502521      INTEGER         , INTENT(in   )                             ::   kdom      ! Type of domain to be read 
     
    506525      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kstart    ! start axis position of the reading  
    507526      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kcount    ! number of points in each axis 
     527      LOGICAL                    , INTENT(in   ), OPTIONAL ::   lzfirst    ! Whether array being read has been  
     528                                                                           ! ftrans'd to make z index first 
    508529      ! 
    509530      IF( kiomid > 0 ) THEN 
    510531         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r3d=pvar,   & 
    511               &                                                     ktime=ktime, kstart=kstart, kcount=kcount ) 
     532              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, lzfirst=lzfirst ) 
    512533      ENDIF 
    513534   END SUBROUTINE iom_g3d 
     
    516537   SUBROUTINE iom_get_123d( kiomid, kdom  , cdvar ,   & 
    517538         &                  pv_r1d, pv_r2d, pv_r3d,   & 
    518          &                  ktime , kstart, kcount  ) 
     539         &                  ktime , kstart, kcount, lzfirst  ) 
    519540      !!----------------------------------------------------------------------- 
    520541      !!                  ***  ROUTINE  iom_get_123d  *** 
     
    533554      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kstart     ! start position of the reading in each axis  
    534555      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kcount     ! number of points to be read in each axis 
     556      LOGICAL                    , INTENT(in   ), OPTIONAL ::   lzfirst    ! Whether array being read has been  
     557                                                                           ! ftrans'd to make z index first 
    535558      ! 
    536559      LOGICAL                        ::   llnoov      ! local definition to read overlap 
     
    556579      CHARACTER(LEN=1)               ::   clrankpv, cldmspc      !  
    557580 
    558 #if defined key_z_first 
     581!#if defined key_z_first 
    559582      !! DCSE_NEMO: need a work array to match layout on disk, which is always z-last 
    560583      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   wpv_r3d         ! copy of pv_r3d with dimensions permuted 
     
    562585      INTEGER, DIMENSION(3)                   ::   ishape_pv_r3d   ! size of the dimensions of pv_r3d 
    563586      INTEGER                                 ::   jk              ! loop counter 
     587!#endif 
     588      LOGICAL                                 ::   lftrans         ! DCSE_NEMO: Whether ftrans is 
     589                                                                   ! in effect for the array we're reading 
     590      !--------------------------------------------------------------------- 
     591      ! 
     592      CALL timing_start('iom_get_123d') 
     593 
     594#if defined key_z_first 
     595      IF( PRESENT(lzfirst) )THEN 
     596         lftrans = lzfirst 
     597      ELSE 
     598         ! DCSE_NEMO: If we're built with key_z_first then we assume array  
     599         ! being read has been ftrans'd in the calling routine unless told  
     600         ! otherwise 
     601         lftrans = .TRUE. 
     602      END IF 
     603#else 
     604      ! If we've not been built with key_z_first then we effectively ignore 
     605      ! the lzfirst argument because ftrans can't have been used. 
     606      lftrans = .FALSE. 
    564607#endif 
    565608 
    566       !--------------------------------------------------------------------- 
    567       ! 
    568609      clname = iom_file(kiomid)%name   !   esier to read 
    569610      clinfo = '          iom_get_123d, file: '//trim(clname)//', var: '//trim(cdvar) 
     
    650691            ELSE  
    651692               IF( .NOT. PRESENT(pv_r1d) ) THEN   !   not a 1D array 
    652                   IF(     idom == jpdom_data    ) THEN ; istart(1:2) = (/ mig(1), mjg(1) /)  ! icnt(1:2) done bellow 
    653                   ELSEIF( idom == jpdom_global  ) THEN ; istart(1:2) = (/ nimpp , njmpp  /)  ! icnt(1:2) done bellow 
     693                  IF(     idom == jpdom_data    ) THEN ; istart(1:2) = (/ mig(1), mjg(1) /)  ! icnt(1:2) done below 
     694                  ELSEIF( idom == jpdom_global  ) THEN ; istart(1:2) = (/ nimpp , njmpp  /)  ! icnt(1:2) done below 
    654695                  ENDIF 
    655696                  ! we do not read the overlap                     -> we start to read at nldi, nldj 
     
    683724         END DO 
    684725 
    685 #if defined key_z_first 
    686726         !! DCSE_NEMO: Allocate 3d work-array with z-index last 
    687          !!            to match layout on disk 
    688          IF (PRESENT(pv_r3d)) THEN 
     727         !!            to match layout on disk if ftrans in use 
     728         IF (lftrans .AND. PRESENT(pv_r3d)) THEN 
    689729            ishape_pv_r3d = SHAPE(pv_r3d) 
    690730            IF (ishape_pv_r3d(1) /= jpk) THEN 
     
    693733               CALL ctl_warn( trim(clinfo), 'beware: possible problem with 3d array, ', ctmp1 )  
    694734            ENDIF 
    695             ALLOCATE(wpv_r3d(ishape_pv_r3d(2),ishape_pv_r3d(3),ishape_pv_r3d(1)),STAT=istat_wpv_r3d) 
     735            ! This assumes that the array we're to read has been ftrans'd in the 
     736            ! calling routine and therefore that it's z/depth index is its 1st 
     737            ! whereas on disk it will be its 3rd. 
     738            ALLOCATE(wpv_r3d(ishape_pv_r3d(2),ishape_pv_r3d(3),ishape_pv_r3d(1)),& 
     739                     STAT=istat_wpv_r3d) 
    696740            IF (istat_wpv_r3d /= 0) THEN 
    697741               CALL ctl_stop( trim(clinfo), 'failed to allocate wpv_r3d' ) 
    698742            ENDIF 
    699743         ENDIF 
    700 #endif 
    701744 
    702745         ! check that icnt matches the input array 
     
    708751            IF( irankpv == 1 )        ishape(1:1) = SHAPE(pv_r1d) 
    709752            IF( irankpv == 2 )        ishape(1:2) = SHAPE(pv_r2d) 
    710 #if defined key_z_first 
    711             IF( irankpv == 3 )        ishape(1:3) = SHAPE(wpv_r3d) 
    712 #else 
    713             IF( irankpv == 3 )        ishape(1:3) = SHAPE(pv_r3d) 
    714 #endif 
     753            IF( irankpv == 3 )THEN 
     754               IF( lftrans )THEN 
     755                  ishape(1:3) = SHAPE(wpv_r3d) 
     756               ELSE 
     757                  ishape(1:3) = SHAPE(pv_r3d) 
     758               END IF 
     759            END IF 
    715760            ctmp1 = 'd' 
    716761         ELSE 
     
    725770! JMM + SM: ugly patch before getting the new version of lib_mpp) 
    726771!               ishape(1:3) = SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:))   ;   ctmp1 = 'd(nldi:nlei,nldj:nlej,:)' 
    727 #if defined key_z_first 
    728                IF( llnoov ) THEN 
    729                   ishape(1:3)=SHAPE(wpv_r3d(nldi:nlei,nldj:nlej,:)) 
    730                   ctmp1='d(nldi:nlei,nldj:nlej,:)' 
     772               IF( lftrans )THEN 
     773                  IF( llnoov ) THEN 
     774                     ishape(1:3)=SHAPE(wpv_r3d(nldi:nlei,nldj:nlej,:)) 
     775                     ctmp1='d(nldi:nlei,nldj:nlej,:)' 
     776                  ELSE 
     777                     ishape(1:3)=SHAPE(wpv_r3d(1   :nlci,1   :nlcj,:)) 
     778                     ctmp1='d(1:nlci,1:nlcj,:)' 
     779                  ENDIF 
    731780               ELSE 
    732                   ishape(1:3)=SHAPE(wpv_r3d(1   :nlci,1   :nlcj,:)) 
    733                   ctmp1='d(1:nlci,1:nlcj,:)' 
    734                ENDIF 
    735 #else 
    736                IF( llnoov ) THEN 
    737                   ishape(1:3)=SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:)) 
    738                   ctmp1='d(nldi:nlei,nldj:nlej,:)' 
    739                ELSE 
    740                   ishape(1:3)=SHAPE(pv_r3d(1   :nlci,1   :nlcj,:)) 
    741                   ctmp1='d(1:nlci,1:nlcj,:)' 
    742                ENDIF 
    743 #endif 
    744             ENDIF 
    745          ENDIF 
     781                  IF( llnoov ) THEN 
     782                     ishape(1:3)=SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:)) 
     783                     ctmp1='d(nldi:nlei,nldj:nlej,:)' 
     784                  ELSE 
     785                     ishape(1:3)=SHAPE(pv_r3d(1   :nlci,1   :nlcj,:)) 
     786                     ctmp1='d(1:nlci,1:nlcj,:)' 
     787                  ENDIF 
     788               ENDIF ! ftrans in use 
     789            ENDIF 
     790         ENDIF ! ipdom == jpdom_unknown 
    746791          
    747792         DO jl = 1, irankpv 
     
    771816         ENDIF 
    772817       
    773 #if defined key_z_first 
    774818         SELECT CASE (iom_file(kiomid)%iolib) 
    775819         CASE (jpioipsl ) 
    776             IF  (PRESENT(pv_r3d)) THEN 
     820            IF  (lftrans) THEN 
    777821               CALL iom_ioipsl_get(  kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2, pv_r1d, pv_r2d, wpv_r3d ) 
    778822            ELSE 
    779                CALL iom_ioipsl_get(  kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2, pv_r1d, pv_r2d ) 
     823               CALL iom_ioipsl_get(  kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2, pv_r1d, pv_r2d, pv_r3d ) 
    780824            ENDIF 
    781825         CASE (jpnf90   ) 
    782             IF (PRESENT(pv_r3d)) THEN 
     826            IF (lftrans) THEN 
    783827               CALL iom_nf90_get(    kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2, pv_r1d, pv_r2d, wpv_r3d ) 
    784828            ELSE 
    785                CALL iom_nf90_get(    kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2, pv_r1d, pv_r2d ) 
     829               CALL iom_nf90_get(    kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2, pv_r1d, pv_r2d, pv_r3d ) 
    786830            ENDIF 
    787831         CASE (jprstdimg) 
    788             IF (PRESENT(pv_r3d)) THEN 
     832            IF (lftrans) THEN 
    789833               CALL iom_rstdimg_get( kiomid, idom, idvar, ix1, ix2, iy1, iy2, pv_r1d, pv_r2d, wpv_r3d ) 
    790834            ELSE 
    791                CALL iom_rstdimg_get( kiomid, idom, idvar, ix1, ix2, iy1, iy2, pv_r1d, pv_r2d ) 
     835               CALL iom_rstdimg_get( kiomid, idom, idvar, ix1, ix2, iy1, iy2, pv_r1d, pv_r2d, pv_r3d ) 
    792836            ENDIF 
    793837         CASE DEFAULT     
    794838            CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' ) 
    795839         END SELECT 
    796 #else 
    797          SELECT CASE (iom_file(kiomid)%iolib) 
    798          CASE (jpioipsl )   ;   CALL iom_ioipsl_get(  kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   & 
    799             &                                         pv_r1d, pv_r2d, pv_r3d ) 
    800          CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   & 
    801             &                                         pv_r1d, pv_r2d, pv_r3d ) 
    802          CASE (jprstdimg)   ;   CALL iom_rstdimg_get( kiomid, idom, idvar, ix1, ix2, iy1, iy2,   & 
    803             &                                         pv_r1d, pv_r2d, pv_r3d ) 
    804          CASE DEFAULT     
    805             CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' ) 
    806          END SELECT 
    807 #endif 
    808  
    809 #if defined key_z_first 
     840 
    810841         !! DCSE_NEMO: if necessary, copy 3d work array back into pv_r3d, 
    811842         !!            and de-allocate the work array 
    812          IF (PRESENT(pv_r3d)) THEN 
    813             ! This assumes that pv_r3d is not ftransed 
    814             DO jk = 1, ishape_pv_r3d(3) 
    815                DO jj = 1, ishape_pv_r3d(2) 
    816                   DO ji = 1, ishape_pv_r3d(1) 
     843         IF (lftrans .AND. PRESENT(pv_r3d)) THEN 
     844            ! This assumes that pv_r3d is ftrans'd in the calling routine so that 
     845            ! its first dimension rather than last dimension is 'z' 
     846            ! wpv_r3d is allocated with SHAPE(ishape_pv_r3d(2),ishape_pv_r3d(3),ishape_pv_r3d(1)) 
     847            DO ji = 1, ishape_pv_r3d(2) 
     848               DO jj = 1, ishape_pv_r3d(3) 
     849                  DO jk = 1, ishape_pv_r3d(1) 
    817850                     pv_r3d(jk, ji, jj) = wpv_r3d(ji, jj, jk) 
    818851                  ENDDO 
     
    821854            DEALLOCATE(wpv_r3d) 
    822855         ENDIF 
    823 #endif 
    824856 
    825857         IF( istop == nstop ) THEN   ! no additional errors until this point... 
     
    861893      ENDIF 
    862894      ! 
     895      CALL timing_stop('iom_get_123d') 
     896 
    863897   END SUBROUTINE iom_get_123d 
    864898 
     
    883917      !--------------------------------------------------------------------- 
    884918      ! 
     919      CALL timing_start('iom_gettime') 
     920 
    885921      IF ( PRESENT(cdvar) ) THEN 
    886922         tname = cdvar 
     
    924960      ENDIF 
    925961      ! 
     962      CALL timing_stop('iom_gettime') 
     963      ! 
    926964   END SUBROUTINE iom_gettime 
    927965 
     
    961999      INTEGER :: ivid   ! variable id 
    9621000      IF( kiomid > 0 ) THEN 
     1001!         CALL timing_start('iom_rp0d') 
    9631002         IF( iom_file(kiomid)%nfid > 0 ) THEN 
    9641003            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) 
     
    9711010            END SELECT 
    9721011         ENDIF 
     1012!         CALL timing_stop('iom_rp0d') 
    9731013      ENDIF 
    9741014   END SUBROUTINE iom_rp0d 
     
    9831023      INTEGER :: ivid   ! variable id 
    9841024      IF( kiomid > 0 ) THEN 
     1025!         CALL timing_start('iom_rp1d') 
    9851026         IF( iom_file(kiomid)%nfid > 0 ) THEN 
    9861027            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) 
     
    9931034            END SELECT 
    9941035         ENDIF 
     1036!         CALL timing_stop('iom_rp1d') 
    9951037      ENDIF 
    9961038   END SUBROUTINE iom_rp1d 
     
    10051047      INTEGER :: ivid   ! variable id 
    10061048      IF( kiomid > 0 ) THEN 
     1049!         CALL timing_start('iom_rp2d') 
    10071050         IF( iom_file(kiomid)%nfid > 0 ) THEN 
    10081051            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) 
     
    10151058            END SELECT 
    10161059         ENDIF 
     1060!         CALL timing_stop('iom_rp2d') 
    10171061      ENDIF 
    10181062   END SUBROUTINE iom_rp2d 
     
    10321076      INTEGER                                              ::   ji, jj, jk    ! Dummy loop indices 
    10331077      IF( kiomid > 0 ) THEN 
     1078!         CALL timing_start('iom_rp3d') 
    10341079         IF( iom_file(kiomid)%nfid > 0 ) THEN 
    10351080            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) 
     
    10561101            DEALLOCATE( pvar_trans ) 
    10571102         ENDIF 
     1103!         CALL timing_stop('iom_rp3d') 
    10581104      ENDIF 
    10591105#else 
    10601106      IF( kiomid > 0 ) THEN 
     1107!         CALL timing_start('iom_rp3d') 
    10611108         IF( iom_file(kiomid)%nfid > 0 ) THEN 
    10621109            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. ) 
     
    10691116            END SELECT 
    10701117         ENDIF 
     1118!         CALL timing_stop('iom_rp3d') 
    10711119      ENDIF 
    10721120#endif 
Note: See TracChangeset for help on using the changeset viewer.