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 4245 for branches/2013/dev_LOCEAN_CMCC_INGV_MERC_UKMO_2013/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90 – NEMO

Ignore:
Timestamp:
2013-11-19T12:19:21+01:00 (10 years ago)
Author:
cetlod
Message:

dev_locean_cmcc_ingv_ukmo_merc : merge in the MERC_UKMO dev branch with trunk rev 4119

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2013/dev_LOCEAN_CMCC_INGV_MERC_UKMO_2013/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90

    r4230 r4245  
    2323   USE lib_mpp         ! MPP library 
    2424   USE wrk_nemo        ! work arrays 
     25   USE lbclnk          ! ocean lateral boundary conditions (C1D case) 
    2526   USE ioipsl, ONLY :   ymds2ju, ju2ymds   ! for calendar 
    2627   USE sbc_oce 
     
    3435   TYPE, PUBLIC ::   FLD_N      !: Namelist field informations 
    3536      CHARACTER(len = 256) ::   clname      ! generic name of the NetCDF flux file 
    36       INTEGER              ::   nfreqh      ! frequency of each flux file 
     37      REAL(wp)             ::   nfreqh      ! frequency of each flux file 
    3738      CHARACTER(len = 34)  ::   clvar       ! generic name of the variable in the NetCDF flux file 
    3839      LOGICAL              ::   ln_tint     ! time interpolation or not (T/F) 
     
    5051      CHARACTER(len = 256)            ::   clrootname   ! generic name of the NetCDF file 
    5152      CHARACTER(len = 256)            ::   clname       ! current name of the NetCDF file 
    52       INTEGER                         ::   nfreqh       ! frequency of each flux file 
     53      REAL(wp)                        ::   nfreqh       ! frequency of each flux file 
    5354      CHARACTER(len = 34)             ::   clvar        ! generic name of the variable in the NetCDF flux file 
    5455      LOGICAL                         ::   ln_tint      ! time interpolation or not (T/F) 
     
    200201                  sd(jf)%fdta(:,:,:,1) = sd(jf)%fdta(:,:,:,2)   ! re-swap before record field 
    201202                  sd(jf)%nrec_b(1) = sd(jf)%nrec_a(1)           ! update before record informations 
    202                   sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - sd(jf)%nfreqh * 3600  ! assume freq to be in hours in this case 
     203                  sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%nfreqh * 3600 )  ! assume freq to be in hours in this case 
    203204                  sd(jf)%rotn(1)   = sd(jf)%rotn(2)             ! update before rotate informations 
    204205                  sd(jf)%nrec_a(1) = itmp                       ! move back to after record  
     
    218219                     sd(jf)%fdta(:,:,:,1) = sd(jf)%fdta(:,:,:,2)   ! re-swap before record field 
    219220                     sd(jf)%nrec_b(1) = sd(jf)%nrec_a(1)           ! update before record informations 
    220                      sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - sd(jf)%nfreqh * 3600  ! assume freq to be in hours in this case 
     221                     sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%nfreqh * 3600 )  ! assume freq to be in hours in this case 
    221222                     sd(jf)%rotn(1)   = sd(jf)%rotn(2)             ! update before rotate informations 
    222223                     sd(jf)%nrec_a(1) = sd(jf)%nrec_a(1) + 1       ! move back to after record 
     
    271272            IF( sd(jf)%ln_tint ) THEN              ! temporal interpolation 
    272273               IF(lwp .AND. kt - nit000 <= 100 ) THEN  
    273                   clfmt = "('fld_read: var ', a, ' kt = ', i8, ' (', f7.2,' days), Y/M/D = ', i4.4,'/', i2.2,'/', i2.2," //   & 
    274                      &    "', records b/a: ', i4.4, '/', i4.4, ' (days ', f7.2,'/', f7.2, ')')" 
     274                  clfmt = "('fld_read: var ', a, ' kt = ', i8, ' (', f9.4,' days), Y/M/D = ', i4.4,'/', i2.2,'/', i2.2," //   & 
     275                     &    "', records b/a: ', i6.4, '/', i6.4, ' (days ', f9.4,'/', f9.4, ')')" 
    275276                  WRITE(numout, clfmt)  TRIM( sd(jf)%clvar ), kt, REAL(isecsbc,wp)/rday, nyear, nmonth, nday,   &             
    276277                     & sd(jf)%nrec_b(1), sd(jf)%nrec_a(1), REAL(sd(jf)%nrec_b(2),wp)/rday, REAL(sd(jf)%nrec_a(2),wp)/rday 
     
    284285            ELSE   ! nothing to do... 
    285286               IF(lwp .AND. kt - nit000 <= 100 ) THEN 
    286                   clfmt = "('fld_read: var ', a, ' kt = ', i8,' (', f7.2,' days), Y/M/D = ', i4.4,'/', i2.2,'/', i2.2," //   & 
    287                      &    "', record: ', i4.4, ' (days ', f7.2, ' <-> ', f7.2, ')')" 
     287                  clfmt = "('fld_read: var ', a, ' kt = ', i8,' (', f9.4,' days), Y/M/D = ', i4.4,'/', i2.2,'/', i2.2," //   & 
     288                     &    "', record: ', i6.4, ' (days ', f9.4, ' <-> ', f9.4, ')')" 
    288289                  WRITE(numout, clfmt) TRIM(sd(jf)%clvar), kt, REAL(isecsbc,wp)/rday, nyear, nmonth, nday,    & 
    289290                     &                 sd(jf)%nrec_a(1), REAL(sd(jf)%nrec_b(2),wp)/rday, REAL(sd(jf)%nrec_a(2),wp)/rday 
     
    356357            ELSE                                ! higher frequency mean (in hours)  
    357358               IF    ( sdjf%cltype      == 'monthly' ) THEN   ! monthly file 
    358                   sdjf%nrec_a(1) = 24 * nmonth_len(nmonth-1) / sdjf%nfreqh                 ! last record of previous month 
     359                  sdjf%nrec_a(1) = NINT( 24 * nmonth_len(nmonth-1) / sdjf%nfreqh )         ! last record of previous month 
    359360                  llprevmth = .TRUE.                                                       ! use previous month file? 
    360361                  llprevyr  = llprevmth .AND. nmonth == 1                                  ! use previous year  file? 
    361362               ELSEIF( sdjf%cltype(1:4) == 'week'    ) THEN   ! weekly file 
    362363                  llprevweek = .TRUE.                                                      ! use previous week  file? 
    363                   sdjf%nrec_a(1) = 24 * 7 / sdjf%nfreqh                                    ! last record of previous week 
     364                  sdjf%nrec_a(1) = NINT( 24 * 7 / sdjf%nfreqh )                            ! last record of previous week 
    364365                  isec_week = NINT(rday) * 7                                               ! add a shift toward previous week 
    365366               ELSEIF( sdjf%cltype      == 'daily'   ) THEN   ! daily file 
    366                   sdjf%nrec_a(1) = 24 / sdjf%nfreqh                                        ! last record of previous day 
     367                  sdjf%nrec_a(1) = NINT( 24 / sdjf%nfreqh )                                ! last record of previous day 
    367368                  llprevday = .TRUE.                                                       ! use previous day   file? 
    368369                  llprevmth = llprevday .AND. nday   == 1                                  ! use previous month file? 
    369370                  llprevyr  = llprevmth .AND. nmonth == 1                                  ! use previous year  file? 
    370371               ELSE                                           ! yearly file 
    371                   sdjf%nrec_a(1) = 24 * nyear_len(0) / sdjf%nfreqh                         ! last record of previous year  
     372                  sdjf%nrec_a(1) = NINT( 24 * nyear_len(0) / sdjf%nfreqh )                 ! last record of previous year  
    372373                  llprevyr = .NOT. sdjf%ln_clim                                            ! use previous year  file? 
    373374               ENDIF 
     
    408409         CALL fld_get( sdjf, map ) 
    409410 
    410          clfmt = "('fld_init : time-interpolation for ', a, ' read previous record = ', i4, ' at time = ', f7.2, ' days')" 
     411         clfmt = "('fld_init : time-interpolation for ', a, ' read previous record = ', i6, ' at time = ', f7.2, ' days')" 
    411412         IF(lwp) WRITE(numout, clfmt) TRIM(sdjf%clvar), sdjf%nrec_a(1), REAL(sdjf%nrec_a(2),wp)/rday 
    412413 
     
    518519         !                                   ! ================================ ! 
    519520         ! 
    520          ifreq_sec = sdjf%nfreqh * 3600                                                 ! frequency mean (in seconds) 
     521         ifreq_sec = NINT( sdjf%nfreqh * 3600 )                                         ! frequency mean (in seconds) 
    521522         IF( sdjf%cltype(1:4) == 'week' )   isec_week = ksec_week( sdjf%cltype(6:8) )   ! since the first day of the current week 
    522523         ! number of second since the beginning of the file 
     
    588589      INTEGER                  ::   iw     ! index into wgts array 
    589590      INTEGER                  ::   ipdom  ! index of the domain 
     591      INTEGER                  ::   idvar  ! variable ID 
     592      INTEGER                  ::   idmspc ! number of spatial dimensions 
     593      LOGICAL                  ::   lmoor  ! C1D case: point data 
    590594      !!--------------------------------------------------------------------- 
    591595      ! 
     
    607611         ELSE                                  ;  ipdom = jpdom_unknown 
    608612         ENDIF 
     613         ! C1D case: If product of spatial dimensions == ipk, then x,y are of 
     614         ! size 1 (point/mooring data): this must be read onto the central grid point 
     615         idvar  = iom_varid( sdjf%num, sdjf%clvar ) 
     616         idmspc = iom_file( sdjf%num )%ndims( idvar ) 
     617         IF( iom_file( sdjf%num )%luld( idvar ) )   idmspc = idmspc - 1 
     618         lmoor  = (idmspc == 0 .OR. PRODUCT( iom_file( sdjf%num )%dimsz( 1:MAX(idmspc,1) ,idvar ) ) == ipk) 
     619         ! 
    609620         SELECT CASE( ipk ) 
    610621         CASE(1) 
    611             IF( sdjf%ln_tint ) THEN   ;   CALL iom_get( sdjf%num, ipdom, sdjf%clvar, sdjf%fdta(:,:,1,2), sdjf%nrec_a(1) ) 
    612             ELSE                      ;   CALL iom_get( sdjf%num, ipdom, sdjf%clvar, sdjf%fnow(:,:,1  ), sdjf%nrec_a(1) ) 
     622            IF( lk_c1d .AND. lmoor ) THEN 
     623               IF( sdjf%ln_tint ) THEN 
     624                  CALL iom_get( sdjf%num, sdjf%clvar, sdjf%fdta(2,2,1,2), sdjf%nrec_a(1) ) 
     625                  CALL lbc_lnk( sdjf%fdta(:,:,1,2),'Z',1. ) 
     626               ELSE 
     627                  CALL iom_get( sdjf%num, sdjf%clvar, sdjf%fnow(2,2,1  ), sdjf%nrec_a(1) ) 
     628                  CALL lbc_lnk( sdjf%fnow(:,:,1  ),'Z',1. ) 
     629               ENDIF 
     630            ELSE 
     631               IF( sdjf%ln_tint ) THEN   ;   CALL iom_get( sdjf%num, ipdom, sdjf%clvar, sdjf%fdta(:,:,1,2), sdjf%nrec_a(1) ) 
     632               ELSE                      ;   CALL iom_get( sdjf%num, ipdom, sdjf%clvar, sdjf%fnow(:,:,1  ), sdjf%nrec_a(1) ) 
     633               ENDIF 
    613634            ENDIF 
    614635         CASE DEFAULT 
    615             IF( sdjf%ln_tint ) THEN   ;   CALL iom_get( sdjf%num, ipdom, sdjf%clvar, sdjf%fdta(:,:,:,2), sdjf%nrec_a(1) ) 
    616             ELSE                      ;   CALL iom_get( sdjf%num, ipdom, sdjf%clvar, sdjf%fnow(:,:,:  ), sdjf%nrec_a(1) ) 
     636            IF (lk_c1d .AND. lmoor ) THEN 
     637               IF( sdjf%ln_tint ) THEN 
     638                  CALL iom_get( sdjf%num, jpdom_unknown, sdjf%clvar, sdjf%fdta(2,2,:,2), sdjf%nrec_a(1) ) 
     639                  CALL lbc_lnk( sdjf%fdta(:,:,:,2),'Z',1. ) 
     640               ELSE 
     641                  CALL iom_get( sdjf%num, jpdom_unknown, sdjf%clvar, sdjf%fnow(2,2,:  ), sdjf%nrec_a(1) ) 
     642                  CALL lbc_lnk( sdjf%fnow(:,:,:  ),'Z',1. ) 
     643               ENDIF 
     644            ELSE 
     645               IF( sdjf%ln_tint ) THEN   ;   CALL iom_get( sdjf%num, ipdom, sdjf%clvar, sdjf%fdta(:,:,:,2), sdjf%nrec_a(1) ) 
     646               ELSE                      ;   CALL iom_get( sdjf%num, ipdom, sdjf%clvar, sdjf%fnow(:,:,:  ), sdjf%nrec_a(1) ) 
     647               ENDIF 
    617648            ENDIF 
    618649         END SELECT 
     
    826857            ENDIF 
    827858         ELSE                                                                       ! higher frequency mean (in hours) 
    828             IF(     sdjf%cltype      == 'monthly' ) THEN   ;   sdjf%nreclast = 24 * imonth_len / sdjf%nfreqh  
    829             ELSEIF( sdjf%cltype(1:4) == 'week'    ) THEN   ;   sdjf%nreclast = 24 * 7          / sdjf%nfreqh 
    830             ELSEIF( sdjf%cltype      == 'daily'   ) THEN   ;   sdjf%nreclast = 24              / sdjf%nfreqh 
    831             ELSE                                           ;   sdjf%nreclast = 24 * iyear_len  / sdjf%nfreqh  
     859            IF(     sdjf%cltype      == 'monthly' ) THEN   ;   sdjf%nreclast = NINT( 24 * imonth_len / sdjf%nfreqh ) 
     860            ELSEIF( sdjf%cltype(1:4) == 'week'    ) THEN   ;   sdjf%nreclast = NINT( 24 * 7          / sdjf%nfreqh ) 
     861            ELSEIF( sdjf%cltype      == 'daily'   ) THEN   ;   sdjf%nreclast = NINT( 24              / sdjf%nfreqh ) 
     862            ELSE                                           ;   sdjf%nreclast = NINT( 24 * iyear_len  / sdjf%nfreqh ) 
    832863            ENDIF 
    833864         ENDIF 
Note: See TracChangeset for help on using the changeset viewer.