Changeset 11267 for NEMO/branches/2019/dev_r10984_HPC-13_IRRMANN_BDY_optimization/src/OCE/SBC/fldread.F90
- Timestamp:
- 2019-07-15T12:58:45+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
NEMO/branches/2019/dev_r10984_HPC-13_IRRMANN_BDY_optimization/src/OCE/SBC/fldread.F90
r11258 r11267 48 48 TYPE, PUBLIC :: FLD_N !: Namelist field informations 49 49 CHARACTER(len = 256) :: clname ! generic name of the NetCDF flux file 50 REAL(wp) :: nfreqh! frequency of each flux file50 REAL(wp) :: freqh ! frequency of each flux file 51 51 CHARACTER(len = 34) :: clvar ! generic name of the variable in the NetCDF flux file 52 52 LOGICAL :: ln_tint ! time interpolation or not (T/F) … … 64 64 CHARACTER(len = 256) :: clrootname ! generic name of the NetCDF file 65 65 CHARACTER(len = 256) :: clname ! current name of the NetCDF file 66 REAL(wp) :: nfreqh! frequency of each flux file66 REAL(wp) :: freqh ! frequency of each flux file 67 67 CHARACTER(len = 34) :: clvar ! generic name of the variable in the NetCDF flux file 68 68 LOGICAL :: ln_tint ! time interpolation or not (T/F) … … 80 80 INTEGER :: nreclast ! last record to be read in the current file 81 81 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) 87 88 END TYPE FLD 88 89 … … 201 202 CALL fld_rec( kn_fsbc, sd(jf), kt_offset = it_offset, kit = kit ) ! update after record informations 202 203 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), 204 205 ! it is possible that the before value is no more the good one... we have to re-read it 205 206 ! if before is not the last record of the file currently opened and after is the first record to be read … … 213 214 sd(jf)%fdta(:,:,:,1) = sd(jf)%fdta(:,:,:,2) ! re-swap before record field 214 215 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 case216 sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%freqh * 3600. ) ! assume freq to be in hours in this case 216 217 sd(jf)%rotn(1) = sd(jf)%rotn(2) ! update before rotate informations 217 218 sd(jf)%nrec_a(1) = itmp ! move back to after record … … 222 223 IF( sd(jf)%ln_tint ) THEN 223 224 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), 225 226 ! it is possible that the before value is no more the good one... we have to re-read it 226 227 ! if before record is not just just before the after record... … … 231 232 sd(jf)%fdta(:,:,:,1) = sd(jf)%fdta(:,:,:,2) ! re-swap before record field 232 233 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 case234 sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%freqh * 3600. ) ! assume freq to be in hours in this case 234 235 sd(jf)%rotn(1) = sd(jf)%rotn(2) ! update before rotate informations 235 236 sd(jf)%nrec_a(1) = sd(jf)%nrec_a(1) + 1 ! move back to after record … … 256 257 ! year/month/week/day, next year/month/week/day file must exist 257 258 isecend = nsec_year + nsec1jan000 + (nitend - kt) * NINT(rdt) ! second at the end of the run 258 llstop = isecend > sd(jf)%nrec_a(2) 259 llstop = isecend > sd(jf)%nrec_a(2) ! read more than 1 record of next year 259 260 ! we suppose that the date of next file is next day (should be ok even for weekly files...) 260 261 CALL fld_clopn( sd(jf), nyear + COUNT((/llnxtyr /)) , & … … 265 266 CALL ctl_warn('next year/month/week/day file: '//TRIM(sd(jf)%clname)// & 266 267 & ' not present -> back to current year/month/day') 267 CALL fld_clopn( sd(jf) ) ! back to the current year/month/day268 CALL fld_clopn( sd(jf) ) ! back to the current year/month/day 268 269 sd(jf)%nrec_a(1) = sd(jf)%nreclast ! force to read the last record in the current year file 269 270 ENDIF … … 350 351 ! 351 352 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 mean353 IF ( NINT(sdjf%freqh) == -12 ) THEN ! yearly mean 353 354 IF( sdjf%cltype == 'yearly' ) THEN ! yearly file 354 355 sdjf%nrec_a(1) = 1 ! force to read the unique record … … 357 358 CALL ctl_stop( "fld_init: yearly mean file must be in a yearly type of file: "//TRIM(sdjf%clrootname) ) 358 359 ENDIF 359 ELSEIF( sdjf%nfreqh== -1 ) THEN ! monthly mean360 ELSEIF( NINT(sdjf%freqh) == -1 ) THEN ! monthly mean 360 361 IF( sdjf%cltype == 'monthly' ) THEN ! monthly file 361 362 sdjf%nrec_a(1) = 1 ! force to read the unique record … … 366 367 llprevyr = .NOT. sdjf%ln_clim ! use previous year file? 367 368 ENDIF 368 ELSE ! higher frequency mean (in hours)369 ELSE ! higher frequency mean (in hours) 369 370 IF ( sdjf%cltype == 'monthly' ) THEN ! monthly file 370 sdjf%nrec_a(1) = NINT( 24 * nmonth_len(nmonth-1) / sdjf%nfreqh )! last record of previous month371 sdjf%nrec_a(1) = NINT( 24. * REAL(nmonth_len(nmonth-1),wp) / sdjf%freqh )! last record of previous month 371 372 llprevmth = .TRUE. ! use previous month file? 372 373 llprevyr = llprevmth .AND. nmonth == 1 ! use previous year file? 373 374 ELSEIF( sdjf%cltype(1:4) == 'week' ) THEN ! weekly file 374 375 llprevweek = .TRUE. ! use previous week file? 375 sdjf%nrec_a(1) = NINT( 24 * 7 / sdjf%nfreqh )! last record of previous week376 sdjf%nrec_a(1) = NINT( 24. * 7. / sdjf%freqh ) ! last record of previous week 376 377 isec_week = NINT(rday) * 7 ! add a shift toward previous week 377 378 ELSEIF( sdjf%cltype == 'daily' ) THEN ! daily file 378 sdjf%nrec_a(1) = NINT( 24 / sdjf%nfreqh ) ! last record of previous day379 sdjf%nrec_a(1) = NINT( 24. / sdjf%freqh ) ! last record of previous day 379 380 llprevday = .TRUE. ! use previous day file? 380 381 llprevmth = llprevday .AND. nday == 1 ! use previous month file? 381 382 llprevyr = llprevmth .AND. nmonth == 1 ! use previous year file? 382 383 ELSE ! yearly file 383 sdjf%nrec_a(1) = NINT( 24 * nyear_len(0) / sdjf%nfreqh )! last record of previous year384 sdjf%nrec_a(1) = NINT( 24. * REAL(nyear_len(0),wp) / sdjf%freqh ) ! last record of previous year 384 385 llprevyr = .NOT. sdjf%ln_clim ! use previous year file? 385 386 ENDIF … … 437 438 !! if sdjf%ln_tint = .FALSE. 438 439 !! 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 440 441 !!---------------------------------------------------------------------- 441 442 INTEGER , INTENT(in ) :: kn_fsbc ! sbc computation period (in time step) … … 470 471 ENDIF 471 472 ! 472 ! ! =========== !473 IF ( sdjf%nfreqh== -12 ) THEN ! yearly mean474 ! ! =========== !475 ! 476 IF( sdjf%ln_tint ) THEN ! time interpolation, shift by 1/2 record473 ! ! =========== ! 474 IF ( NINT(sdjf%freqh) == -12 ) THEN ! yearly mean 475 ! ! =========== ! 476 ! 477 IF( sdjf%ln_tint ) THEN ! time interpolation, shift by 1/2 record 477 478 ! 478 479 ! INT( ztmp ) … … 495 496 & INT(ztmp) * INT(rday) * nyear_len(1) + INT(ztmp) * NINT( 0.5 * rday) * nyear_len(2) 496 497 ENDIF 497 ELSE ! no time interpolation498 ELSE ! no time interpolation 498 499 sdjf%nrec_a(1) = 1 499 500 sdjf%nrec_a(2) = NINT(rday) * nyear_len(1) + nsec1jan000 ! swap at the end of the year … … 501 502 ENDIF 502 503 ! 503 ! ! ============ !504 ELSEIF( sdjf%nfreqh== -1 ) THEN ! monthly mean !505 ! ! ============ !506 ! 507 IF( sdjf%ln_tint ) THEN ! time interpolation, shift by 1/2 record504 ! ! ============ ! 505 ELSEIF( NINT(sdjf%freqh) == -1 ) THEN ! monthly mean ! 506 ! ! ============ ! 507 ! 508 IF( sdjf%ln_tint ) THEN ! time interpolation, shift by 1/2 record 508 509 ! 509 510 ! INT( ztmp ) … … 532 533 ENDIF 533 534 ! 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) 539 540 IF( sdjf%cltype(1:4) == 'week' ) isec_week = ksec_week( sdjf%cltype(6:8) ) ! since the first day of the current week 540 541 ! number of second since the beginning of the file … … 546 547 ztmp = ztmp + 0.5 * REAL(kn_fsbc - 1, wp) * rdt + REAL( it_offset, wp ) ! centrered in the middle of sbc time step 547 548 ztmp = ztmp + 0.01 * rdt ! avoid truncation error 548 IF( sdjf%ln_tint ) THEN ! time interpolation, shift by 1/2 record549 IF( sdjf%ln_tint ) THEN ! time interpolation, shift by 1/2 record 549 550 ! 550 551 ! INT( ztmp/ifreq_sec + 0.5 ) … … 560 561 ! 561 562 ztmp= ztmp / REAL(ifreq_sec, wp) + 0.5 562 ELSE ! no time interpolation563 ELSE ! no time interpolation 563 564 ! 564 565 ! INT( ztmp/ifreq_sec ) … … 590 591 ! 591 592 ENDIF 593 ! 594 IF( .NOT. sdjf%ln_tint ) sdjf%nrec_a(2) = sdjf%nrec_a(2) - 1 ! last second belongs to bext record : *----( 592 595 ! 593 596 END SUBROUTINE fld_rec … … 1050 1053 LOGICAL, OPTIONAL, INTENT(in ) :: ldstop ! stop if open to read a non-existing file (default = .TRUE.) 1051 1054 ! 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 dd1055 INTEGER :: isec_week ! number of seconds since start of the weekly file1056 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 name1055 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 1059 1062 !!---------------------------------------------------------------------- 1060 1063 IF( PRESENT(kyear) ) THEN ! use given values … … 1107 1110 ! find the last record to be read -> update sdjf%nreclast 1108 1111 indexyr = iyear - nyear + 1 1109 iyear_len = nyear_len( indexyr)1112 zyear_len = REAL(nyear_len( indexyr ), wp) 1110 1113 SELECT CASE ( indexyr ) 1111 CASE ( 0 ) ; imonth_len = 31! previous year -> imonth = 121112 CASE ( 1 ) ; imonth_len = nmonth_len(imonth)1113 CASE ( 2 ) ; imonth_len = 31! next year -> imonth = 11114 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 1114 1117 END SELECT 1115 1118 ! 1116 1119 ! last record to be read in the current file 1117 IF ( sdjf% nfreqh == -12) THEN ; sdjf%nreclast = 1 ! yearly mean1118 ELSEIF( sdjf% nfreqh == -1) THEN ! monthly mean1120 IF ( sdjf%freqh == -12. ) THEN ; sdjf%nreclast = 1 ! yearly mean 1121 ELSEIF( sdjf%freqh == -1. ) THEN ! monthly mean 1119 1122 IF( sdjf%cltype == 'monthly' ) THEN ; sdjf%nreclast = 1 1120 1123 ELSE ; sdjf%nreclast = 12 1121 1124 ENDIF 1122 1125 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 ) 1127 1130 ENDIF 1128 1131 ENDIF … … 1155 1158 IF( TRIM(sdf_n(jf)%clname) /= 'NOT USED' ) sdf(jf)%clrootname = TRIM( cdir )//sdf(jf)%clrootname 1156 1159 sdf(jf)%clname = "not yet defined" 1157 sdf(jf)% nfreqh = sdf_n(jf)%nfreqh1160 sdf(jf)%freqh = sdf_n(jf)%freqh 1158 1161 sdf(jf)%clvar = sdf_n(jf)%clvar 1159 1162 sdf(jf)%ln_tint = sdf_n(jf)%ln_tint … … 1189 1192 DO jf = 1, SIZE(sdf) 1190 1193 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 , & 1192 1195 & ' time interp: ' , sdf(jf)%ln_tint , & 1193 1196 & ' climatology: ' , sdf(jf)%ln_clim
Note: See TracChangeset
for help on using the changeset viewer.