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 11267 for NEMO/branches/2019/dev_r10984_HPC-13_IRRMANN_BDY_optimization/src/OCE/SBC/fldread.F90 – NEMO

Ignore:
Timestamp:
2019-07-15T12:58:45+02:00 (5 years ago)
Author:
smasson
Message:

dev_r10984_HPC-13 : cleanup the use of freqh as REAL in fldread (done old commit [4144]), see #2285

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2019/dev_r10984_HPC-13_IRRMANN_BDY_optimization/src/OCE/SBC/fldread.F90

    r11258 r11267  
    4848   TYPE, PUBLIC ::   FLD_N      !: Namelist field informations 
    4949      CHARACTER(len = 256) ::   clname      ! generic name of the NetCDF flux file 
    50       REAL(wp)             ::   nfreqh      ! frequency of each flux file 
     50      REAL(wp)             ::   freqh       ! frequency of each flux file 
    5151      CHARACTER(len = 34)  ::   clvar       ! generic name of the variable in the NetCDF flux file 
    5252      LOGICAL              ::   ln_tint     ! time interpolation or not (T/F) 
     
    6464      CHARACTER(len = 256)            ::   clrootname   ! generic name of the NetCDF file 
    6565      CHARACTER(len = 256)            ::   clname       ! current name of the NetCDF file 
    66       REAL(wp)                        ::   nfreqh       ! frequency of each flux file 
     66      REAL(wp)                        ::   freqh        ! frequency of each flux file 
    6767      CHARACTER(len = 34)             ::   clvar        ! generic name of the variable in the NetCDF flux file 
    6868      LOGICAL                         ::   ln_tint      ! time interpolation or not (T/F) 
     
    8080      INTEGER                         ::   nreclast     ! last record to be read in the current file 
    8181      CHARACTER(len = 256)            ::   lsmname      ! current name of the NetCDF mask file acting as a key 
    82       !                                                 ! variables related to BDY 
    83       INTEGER                         ::   igrd         ! grid type for bdy data 
    84       INTEGER                         ::   ibdy         ! bdy set id number 
    85       INTEGER, POINTER, DIMENSION(:)  ::   imap         ! Array of integer pointers to 1D arrays 
    86       LOGICAL                         ::   ltotvel      ! total velocity or not (T/F) 
     82      !                                                 !  
     83      !                                                 ! Variables related to BDY 
     84      INTEGER                         ::   igrd         !   grid type for bdy data 
     85      INTEGER                         ::   ibdy         !   bdy set id number 
     86      INTEGER, POINTER, DIMENSION(:)  ::   imap         !   Array of integer pointers to 1D arrays 
     87      LOGICAL                         ::   ltotvel      !   total velocity or not (T/F) 
    8788   END TYPE FLD 
    8889 
     
    201202               CALL fld_rec( kn_fsbc, sd(jf), kt_offset = it_offset, kit = kit )    ! update after record informations 
    202203 
    203                ! if kn_fsbc*rdt is larger than nfreqh (which is kind of odd), 
     204               ! if kn_fsbc*rdt is larger than freqh (which is kind of odd), 
    204205               ! it is possible that the before value is no more the good one... we have to re-read it 
    205206               ! if before is not the last record of the file currently opened and after is the first record to be read 
     
    213214                  sd(jf)%fdta(:,:,:,1) = sd(jf)%fdta(:,:,:,2)   ! re-swap before record field 
    214215                  sd(jf)%nrec_b(1) = sd(jf)%nrec_a(1)           ! update before record informations 
    215                   sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%nfreqh * 3600 )  ! assume freq to be in hours in this case 
     216                  sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%freqh * 3600. )  ! assume freq to be in hours in this case 
    216217                  sd(jf)%rotn(1)   = sd(jf)%rotn(2)             ! update before rotate informations 
    217218                  sd(jf)%nrec_a(1) = itmp                       ! move back to after record  
     
    222223               IF( sd(jf)%ln_tint ) THEN 
    223224                   
    224                   ! if kn_fsbc*rdt is larger than nfreqh (which is kind of odd), 
     225                  ! if kn_fsbc*rdt is larger than freqh (which is kind of odd), 
    225226                  ! it is possible that the before value is no more the good one... we have to re-read it 
    226227                  ! if before record is not just just before the after record... 
     
    231232                     sd(jf)%fdta(:,:,:,1) = sd(jf)%fdta(:,:,:,2)   ! re-swap before record field 
    232233                     sd(jf)%nrec_b(1) = sd(jf)%nrec_a(1)           ! update before record informations 
    233                      sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%nfreqh * 3600 )  ! assume freq to be in hours in this case 
     234                     sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%freqh * 3600. )  ! assume freq to be in hours in this case 
    234235                     sd(jf)%rotn(1)   = sd(jf)%rotn(2)             ! update before rotate informations 
    235236                     sd(jf)%nrec_a(1) = sd(jf)%nrec_a(1) + 1       ! move back to after record 
     
    256257                     ! year/month/week/day, next year/month/week/day file must exist 
    257258                     isecend = nsec_year + nsec1jan000 + (nitend - kt) * NINT(rdt)   ! second at the end of the run 
    258                      llstop = isecend > sd(jf)%nrec_a(2)                                   ! read more than 1 record of next year 
     259                     llstop = isecend > sd(jf)%nrec_a(2)                             ! read more than 1 record of next year 
    259260                     ! we suppose that the date of next file is next day (should be ok even for weekly files...) 
    260261                     CALL fld_clopn( sd(jf), nyear  + COUNT((/llnxtyr /))                                           ,         & 
     
    265266                        CALL ctl_warn('next year/month/week/day file: '//TRIM(sd(jf)%clname)//     & 
    266267                           &     ' not present -> back to current year/month/day') 
    267                         CALL fld_clopn( sd(jf) )       ! back to the current year/month/day 
     268                        CALL fld_clopn( sd(jf) )               ! back to the current year/month/day 
    268269                        sd(jf)%nrec_a(1) = sd(jf)%nreclast     ! force to read the last record in the current year file 
    269270                     ENDIF 
     
    350351         ! 
    351352         IF( sdjf%nrec_a(1) == 0  ) THEN   ! we redefine record sdjf%nrec_a(1) with the last record of previous year file 
    352             IF    ( sdjf%nfreqh == -12 ) THEN   ! yearly mean 
     353            IF    ( NINT(sdjf%freqh) == -12 ) THEN   ! yearly mean 
    353354               IF( sdjf%cltype == 'yearly' ) THEN             ! yearly file 
    354355                  sdjf%nrec_a(1) = 1                                                       ! force to read the unique record 
     
    357358                  CALL ctl_stop( "fld_init: yearly mean file must be in a yearly type of file: "//TRIM(sdjf%clrootname) ) 
    358359               ENDIF 
    359             ELSEIF( sdjf%nfreqh ==  -1 ) THEN   ! monthly mean 
     360            ELSEIF( NINT(sdjf%freqh) ==  -1 ) THEN   ! monthly mean 
    360361               IF( sdjf%cltype == 'monthly' ) THEN            ! monthly file 
    361362                  sdjf%nrec_a(1) = 1                                                       ! force to read the unique record 
     
    366367                  llprevyr = .NOT. sdjf%ln_clim                                            ! use previous year  file? 
    367368               ENDIF 
    368             ELSE                                ! higher frequency mean (in hours)  
     369            ELSE                                     ! higher frequency mean (in hours)  
    369370               IF    ( sdjf%cltype      == 'monthly' ) THEN   ! monthly file 
    370                   sdjf%nrec_a(1) = NINT( 24 * nmonth_len(nmonth-1) / sdjf%nfreqh )         ! last record of previous month 
     371                  sdjf%nrec_a(1) = NINT( 24. * REAL(nmonth_len(nmonth-1),wp) / sdjf%freqh )! last record of previous month 
    371372                  llprevmth = .TRUE.                                                       ! use previous month file? 
    372373                  llprevyr  = llprevmth .AND. nmonth == 1                                  ! use previous year  file? 
    373374               ELSEIF( sdjf%cltype(1:4) == 'week'    ) THEN   ! weekly file 
    374375                  llprevweek = .TRUE.                                                      ! use previous week  file? 
    375                   sdjf%nrec_a(1) = NINT( 24 * 7 / sdjf%nfreqh )                            ! last record of previous week 
     376                  sdjf%nrec_a(1) = NINT( 24. * 7. / sdjf%freqh )                           ! last record of previous week 
    376377                  isec_week = NINT(rday) * 7                                               ! add a shift toward previous week 
    377378               ELSEIF( sdjf%cltype      == 'daily'   ) THEN   ! daily file 
    378                   sdjf%nrec_a(1) = NINT( 24 / sdjf%nfreqh )                                ! last record of previous day 
     379                  sdjf%nrec_a(1) = NINT( 24. / sdjf%freqh )                                ! last record of previous day 
    379380                  llprevday = .TRUE.                                                       ! use previous day   file? 
    380381                  llprevmth = llprevday .AND. nday   == 1                                  ! use previous month file? 
    381382                  llprevyr  = llprevmth .AND. nmonth == 1                                  ! use previous year  file? 
    382383               ELSE                                           ! yearly file 
    383                   sdjf%nrec_a(1) = NINT( 24 * nyear_len(0) / sdjf%nfreqh )                 ! last record of previous year  
     384                  sdjf%nrec_a(1) = NINT( 24. * REAL(nyear_len(0),wp) / sdjf%freqh )        ! last record of previous year  
    384385                  llprevyr = .NOT. sdjf%ln_clim                                            ! use previous year  file? 
    385386               ENDIF 
     
    437438      !!              if sdjf%ln_tint = .FALSE. 
    438439      !!                  nrec_a(1): record number 
    439       !!                  nrec_b(2) and nrec_a(2): time of the beginning and end of the record (for print only) 
     440      !!                  nrec_b(2) and nrec_a(2): time of the beginning and end of the record 
    440441      !!---------------------------------------------------------------------- 
    441442      INTEGER  , INTENT(in   )           ::   kn_fsbc   ! sbc computation period (in time step)  
     
    470471      ENDIF 
    471472      ! 
    472       !                                      ! =========== ! 
    473       IF    ( sdjf%nfreqh == -12 ) THEN      ! yearly mean 
    474          !                                   ! =========== ! 
    475          ! 
    476          IF( sdjf%ln_tint ) THEN                 ! time interpolation, shift by 1/2 record 
     473      !                                           ! =========== ! 
     474      IF    ( NINT(sdjf%freqh) == -12 ) THEN      ! yearly mean 
     475         !                                        ! =========== ! 
     476         ! 
     477         IF( sdjf%ln_tint ) THEN                  ! time interpolation, shift by 1/2 record 
    477478            ! 
    478479            !                  INT( ztmp ) 
     
    495496                                    & INT(ztmp) * INT(rday) * nyear_len(1) + INT(ztmp) * NINT( 0.5 * rday) * nyear_len(2)  
    496497            ENDIF 
    497          ELSE                                    ! no time interpolation 
     498         ELSE                                     ! no time interpolation 
    498499            sdjf%nrec_a(1) = 1 
    499500            sdjf%nrec_a(2) = NINT(rday) * nyear_len(1) + nsec1jan000   ! swap at the end    of the year 
     
    501502         ENDIF 
    502503         ! 
    503          !                                   ! ============ ! 
    504       ELSEIF( sdjf%nfreqh ==  -1 ) THEN      ! monthly mean ! 
    505          !                                   ! ============ ! 
    506          ! 
    507          IF( sdjf%ln_tint ) THEN                 ! time interpolation, shift by 1/2 record 
     504         !                                        ! ============ ! 
     505      ELSEIF( NINT(sdjf%freqh) ==  -1 ) THEN      ! monthly mean ! 
     506         !                                        ! ============ ! 
     507         ! 
     508         IF( sdjf%ln_tint ) THEN                  ! time interpolation, shift by 1/2 record 
    508509            ! 
    509510            !                  INT( ztmp ) 
     
    532533         ENDIF 
    533534         ! 
    534          !                                   ! ================================ ! 
    535       ELSE                                   ! higher frequency mean (in hours) 
    536          !                                   ! ================================ ! 
    537          ! 
    538          ifreq_sec = NINT( sdjf%nfreqh * 3600 )                                         ! frequency mean (in seconds) 
     535         !                                        ! ================================ ! 
     536      ELSE                                        ! higher frequency mean (in hours) 
     537         !                                        ! ================================ ! 
     538         ! 
     539         ifreq_sec = NINT( sdjf%freqh * 3600. )                                         ! frequency mean (in seconds) 
    539540         IF( sdjf%cltype(1:4) == 'week' )   isec_week = ksec_week( sdjf%cltype(6:8) )   ! since the first day of the current week 
    540541         ! number of second since the beginning of the file 
     
    546547         ztmp = ztmp + 0.5 * REAL(kn_fsbc - 1, wp) * rdt + REAL( it_offset, wp )        ! centrered in the middle of sbc time step 
    547548         ztmp = ztmp + 0.01 * rdt                                                       ! avoid truncation error  
    548          IF( sdjf%ln_tint ) THEN                ! time interpolation, shift by 1/2 record 
     549         IF( sdjf%ln_tint ) THEN                 ! time interpolation, shift by 1/2 record 
    549550            ! 
    550551            !          INT( ztmp/ifreq_sec + 0.5 ) 
     
    560561            !                    
    561562            ztmp= ztmp / REAL(ifreq_sec, wp) + 0.5 
    562          ELSE                                   ! no time interpolation 
     563         ELSE                                    ! no time interpolation 
    563564            ! 
    564565            !           INT( ztmp/ifreq_sec ) 
     
    590591         ! 
    591592      ENDIF 
     593      ! 
     594      IF( .NOT. sdjf%ln_tint ) sdjf%nrec_a(2) = sdjf%nrec_a(2) - 1   ! last second belongs to bext record : *----( 
    592595      ! 
    593596   END SUBROUTINE fld_rec 
     
    10501053      LOGICAL, OPTIONAL, INTENT(in   ) ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.) 
    10511054      ! 
    1052       LOGICAL :: llprevyr              ! are we reading previous year  file? 
    1053       LOGICAL :: llprevmth             ! are we reading previous month file? 
    1054       INTEGER :: iyear, imonth, iday   ! first day of the current file in yyyy mm dd 
    1055       INTEGER :: isec_week             ! number of seconds since start of the weekly file 
    1056       INTEGER :: indexyr               ! year undex (O/1/2: previous/current/next) 
    1057       INTEGER :: iyear_len, imonth_len ! length (days) of iyear and imonth             !  
    1058       CHARACTER(len = 256)::   clname  ! temporary file name 
     1055      LOGICAL  :: llprevyr              ! are we reading previous year  file? 
     1056      LOGICAL  :: llprevmth             ! are we reading previous month file? 
     1057      INTEGER  :: iyear, imonth, iday   ! first day of the current file in yyyy mm dd 
     1058      INTEGER  :: isec_week             ! number of seconds since start of the weekly file 
     1059      INTEGER  :: indexyr               ! year undex (O/1/2: previous/current/next) 
     1060      REAL(wp) :: zyear_len, zmonth_len ! length (days) of iyear and imonth             !  
     1061      CHARACTER(len = 256) ::   clname  ! temporary file name 
    10591062      !!---------------------------------------------------------------------- 
    10601063      IF( PRESENT(kyear) ) THEN                             ! use given values  
     
    11071110         ! find the last record to be read -> update sdjf%nreclast 
    11081111         indexyr = iyear - nyear + 1 
    1109          iyear_len = nyear_len( indexyr ) 
     1112         zyear_len = REAL(nyear_len( indexyr ), wp) 
    11101113         SELECT CASE ( indexyr ) 
    1111          CASE ( 0 )   ;   imonth_len = 31   ! previous year -> imonth = 12 
    1112          CASE ( 1 )   ;   imonth_len = nmonth_len(imonth)  
    1113          CASE ( 2 )   ;   imonth_len = 31   ! next     year -> imonth = 1 
     1114         CASE ( 0 )   ;   zmonth_len = 31.   ! previous year -> imonth = 12 
     1115         CASE ( 1 )   ;   zmonth_len = REAL(nmonth_len(imonth), wp) 
     1116         CASE ( 2 )   ;   zmonth_len = 31.   ! next     year -> imonth = 1 
    11141117         END SELECT 
    11151118         ! 
    11161119         ! last record to be read in the current file 
    1117          IF    ( sdjf%nfreqh == -12 ) THEN                 ;   sdjf%nreclast = 1    !  yearly mean 
    1118          ELSEIF( sdjf%nfreqh ==  -1 ) THEN                                          ! monthly mean 
     1120         IF    ( sdjf%freqh == -12. ) THEN                 ;   sdjf%nreclast = 1    !  yearly mean 
     1121         ELSEIF( sdjf%freqh ==  -1. ) THEN                                          ! monthly mean 
    11191122            IF(     sdjf%cltype      == 'monthly' ) THEN   ;   sdjf%nreclast = 1 
    11201123            ELSE                                           ;   sdjf%nreclast = 12 
    11211124            ENDIF 
    11221125         ELSE                                                                       ! higher frequency mean (in hours) 
    1123             IF(     sdjf%cltype      == 'monthly' ) THEN   ;   sdjf%nreclast = NINT( 24 * imonth_len / sdjf%nfreqh ) 
    1124             ELSEIF( sdjf%cltype(1:4) == 'week'    ) THEN   ;   sdjf%nreclast = NINT( 24 * 7          / sdjf%nfreqh ) 
    1125             ELSEIF( sdjf%cltype      == 'daily'   ) THEN   ;   sdjf%nreclast = NINT( 24              / sdjf%nfreqh ) 
    1126             ELSE                                           ;   sdjf%nreclast = NINT( 24 * iyear_len  / sdjf%nfreqh ) 
     1126            IF(     sdjf%cltype      == 'monthly' ) THEN   ;   sdjf%nreclast = NINT( 24. * zmonth_len / sdjf%freqh ) 
     1127            ELSEIF( sdjf%cltype(1:4) == 'week'    ) THEN   ;   sdjf%nreclast = NINT( 24. * 7.         / sdjf%freqh ) 
     1128            ELSEIF( sdjf%cltype      == 'daily'   ) THEN   ;   sdjf%nreclast = NINT( 24.              / sdjf%freqh ) 
     1129            ELSE                                           ;   sdjf%nreclast = NINT( 24. * zyear_len  / sdjf%freqh ) 
    11271130            ENDIF 
    11281131         ENDIF 
     
    11551158         IF( TRIM(sdf_n(jf)%clname) /= 'NOT USED' )   sdf(jf)%clrootname = TRIM( cdir )//sdf(jf)%clrootname 
    11561159         sdf(jf)%clname     = "not yet defined" 
    1157          sdf(jf)%nfreqh     = sdf_n(jf)%nfreqh 
     1160         sdf(jf)%freqh      = sdf_n(jf)%freqh 
    11581161         sdf(jf)%clvar      = sdf_n(jf)%clvar 
    11591162         sdf(jf)%ln_tint    = sdf_n(jf)%ln_tint 
     
    11891192         DO jf = 1, SIZE(sdf) 
    11901193            WRITE(numout,*) '      root filename: '  , TRIM( sdf(jf)%clrootname ), '   variable name: ', TRIM( sdf(jf)%clvar ) 
    1191             WRITE(numout,*) '         frequency: '      ,       sdf(jf)%nfreqh      ,   & 
     1194            WRITE(numout,*) '         frequency: '      ,       sdf(jf)%freqh       ,   & 
    11921195               &                  '   time interp: '    ,       sdf(jf)%ln_tint     ,   & 
    11931196               &                  '   climatology: '    ,       sdf(jf)%ln_clim 
Note: See TracChangeset for help on using the changeset viewer.