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 5581 for branches/2014/dev_r4765_CNRS_agrif/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90 – NEMO

Ignore:
Timestamp:
2015-07-10T13:28:53+02:00 (9 years ago)
Author:
timgraham
Message:

Merged head of trunk into branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2014/dev_r4765_CNRS_agrif/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90

    r4663 r5581  
    6969   END TYPE FLD 
    7070 
    71    TYPE, PUBLIC ::   MAP_POINTER      !: Array of integer pointers to 1D arrays 
    72       INTEGER, POINTER   ::  ptr(:) 
     71   TYPE, PUBLIC ::   MAP_POINTER      !: Map from input data file to local domain 
     72      INTEGER, POINTER, DIMENSION(:)  ::  ptr           ! Array of integer pointers to 1D arrays 
     73      LOGICAL                         ::  ll_unstruc    ! Unstructured (T) or structured (F) boundary data file 
    7374   END TYPE MAP_POINTER 
    7475 
     
    153154      IF( PRESENT(kit) )   ll_firstcall = ll_firstcall .and. kit == 1 
    154155 
    155       it_offset = 0 
     156      IF ( nn_components == jp_iam_sas ) THEN   ;   it_offset = nn_fsbc 
     157      ELSE                                      ;   it_offset = 0 
     158      ENDIF 
    156159      IF( PRESENT(kt_offset) )   it_offset = kt_offset 
    157160 
     
    451454      ENDIF 
    452455      ! 
    453       it_offset = 0 
     456      IF ( nn_components == jp_iam_sas ) THEN   ;   it_offset = nn_fsbc 
     457      ELSE                                      ;   it_offset = 0 
     458      ENDIF 
    454459      IF( PRESENT(kt_offset) )   it_offset = kt_offset 
    455460      IF( PRESENT(kit) ) THEN   ;   it_offset = ( kit + it_offset ) * NINT( rdt/REAL(nn_baro,wp) ) 
     
    473478            !       forcing record :    1  
    474479            !                             
    475             ztmp = REAL( nday, wp ) / REAL( nyear_len(1), wp ) + 0.5 + REAL( it_offset, wp ) 
     480            ztmp = REAL( nsec_year, wp ) / ( REAL( nyear_len(1), wp ) * rday ) + 0.5 & 
     481           &       + REAL( it_offset, wp ) / ( REAL( nyear_len(1), wp ) * rday ) 
    476482            sdjf%nrec_a(1) = 1 + INT( ztmp ) - COUNT((/llbefore/)) 
    477483            ! swap at the middle of the year 
    478             IF( llbefore ) THEN   ;   sdjf%nrec_a(2) = nsec1jan000 - NINT(0.5 * rday) * nyear_len(0) 
    479             ELSE                  ;   sdjf%nrec_a(2) = nsec1jan000 + NINT(0.5 * rday) * nyear_len(1)    
     484            IF( llbefore ) THEN   ;   sdjf%nrec_a(2) = nsec1jan000 - (1 - INT(ztmp)) * NINT(0.5 * rday) * nyear_len(0) + & 
     485                                    & INT(ztmp) * NINT( 0.5 * rday) * nyear_len(1)  
     486            ELSE                  ;   sdjf%nrec_a(2) = nsec1jan000 + (1 - INT(ztmp)) * NINT(0.5 * rday) * nyear_len(1) + & 
     487                                    & INT(ztmp) * INT(rday) * nyear_len(1) + INT(ztmp) * NINT( 0.5 * rday) * nyear_len(2)  
    480488            ENDIF 
    481489         ELSE                                    ! no time interpolation 
     
    501509            !       forcing record :  nmonth  
    502510            !                             
    503             ztmp = REAL( nday, wp ) / REAL( nmonth_len(nmonth), wp ) + 0.5 + REAL( it_offset, wp ) 
     511            ztmp = REAL( nsec_month, wp ) / ( REAL( nmonth_len(nmonth), wp ) * rday ) + 0.5 & 
     512           &       + REAL( it_offset, wp ) / ( REAL( nmonth_len(nmonth), wp ) * rday ) 
    504513            imth = nmonth + INT( ztmp ) - COUNT((/llbefore/)) 
    505514            IF( sdjf%cltype == 'monthly' ) THEN   ;   sdjf%nrec_a(1) = 1 + INT( ztmp ) - COUNT((/llbefore/)) 
     
    597606      ! 
    598607      IF( ASSOCIATED(map%ptr) ) THEN 
    599          IF( sdjf%ln_tint ) THEN   ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fdta(:,:,:,2), sdjf%nrec_a(1), map%ptr ) 
    600          ELSE                      ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fnow(:,:,:  ), sdjf%nrec_a(1), map%ptr ) 
     608         IF( sdjf%ln_tint ) THEN   ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fdta(:,:,:,2), sdjf%nrec_a(1), map ) 
     609         ELSE                      ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fnow(:,:,:  ), sdjf%nrec_a(1), map ) 
    601610         ENDIF 
    602611      ELSE IF( LEN(TRIM(sdjf%wgtname)) > 0 ) THEN 
     
    668677      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   dta   ! output field on model grid (2 dimensional) 
    669678      INTEGER                   , INTENT(in ) ::   nrec    ! record number to read (ie time slice) 
    670       INTEGER,  DIMENSION(:)    , INTENT(in ) ::   map     ! global-to-local mapping indices 
     679      TYPE(MAP_POINTER)         , INTENT(in ) ::   map     ! global-to-local mapping indices 
    671680      !! 
    672681      INTEGER                                 ::   ipi      ! length of boundary data on local process 
     
    689698#if defined key_bdy 
    690699      ipj = iom_file(num)%dimsz(2,idvar) 
    691       IF (ipj == 1) THEN ! we assume that this is a structured open boundary file 
     700      IF ( map%ll_unstruc) THEN ! unstructured open boundary data file 
    692701         dta_read => dta_global 
    693       ELSE 
     702      ELSE                      ! structured open boundary data file 
    694703         dta_read => dta_global2 
    695704      ENDIF 
     
    704713      END SELECT 
    705714      ! 
    706       IF (ipj==1) THEN 
     715      IF ( map%ll_unstruc ) THEN ! unstructured open boundary data file 
    707716         DO ib = 1, ipi 
    708717            DO ik = 1, ipk 
    709                dta(ib,1,ik) =  dta_read(map(ib),1,ik) 
     718               dta(ib,1,ik) =  dta_read(map%ptr(ib),1,ik) 
    710719            END DO 
    711720         END DO 
    712       ELSE ! we assume that this is a structured open boundary file 
     721      ELSE                       ! structured open boundary data file 
    713722         DO ib = 1, ipi 
    714             jj=1+floor(REAL(map(ib)-1)/REAL(ilendta)) 
    715             ji=map(ib)-(jj-1)*ilendta 
     723            jj=1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta)) 
     724            ji=map%ptr(ib)-(jj-1)*ilendta 
    716725            DO ik = 1, ipk 
    717726               dta(ib,1,ik) =  dta_read(ji,jj,ik) 
     
    10161025      INTEGER                           ::   ipk           ! temporary vertical dimension 
    10171026      CHARACTER (len=5)                 ::   aname 
    1018       INTEGER , DIMENSION(3)            ::   ddims 
     1027      INTEGER , DIMENSION(:), ALLOCATABLE ::   ddims 
    10191028      INTEGER , POINTER, DIMENSION(:,:) ::   data_src 
    10201029      REAL(wp), POINTER, DIMENSION(:,:) ::   data_tmp 
     
    10391048 
    10401049      !! get dimensions 
     1050      IF ( SIZE(sd%fnow, 3) > 1 ) THEN 
     1051         ALLOCATE( ddims(4) ) 
     1052      ELSE 
     1053         ALLOCATE( ddims(3) ) 
     1054      ENDIF 
    10411055      id = iom_varid( inum, sd%clvar, ddims ) 
    10421056 
     
    11351149         CALL ctl_stop( '    fld_weight : unable to read the file ' ) 
    11361150      ENDIF 
     1151 
     1152      DEALLOCATE (ddims ) 
    11371153 
    11381154      CALL wrk_dealloc( jpi,jpj, data_src )   ! integer 
Note: See TracChangeset for help on using the changeset viewer.