diff --git a/lis/metforcing/usaf/AGRMET_forcingMod.F90 b/lis/metforcing/usaf/AGRMET_forcingMod.F90 index fe408fdff..394f7bafc 100644 --- a/lis/metforcing/usaf/AGRMET_forcingMod.F90 +++ b/lis/metforcing/usaf/AGRMET_forcingMod.F90 @@ -555,8 +555,9 @@ module AGRMET_forcingMod ! EMK END integer :: lastSfcalcHour integer :: lastPcpHour + integer :: lastRadHour !new - integer :: ncol, nrow + integer :: ncol, nrow integer, allocatable :: n11_1_gfs(:) integer, allocatable :: n12_1_gfs(:) integer, allocatable :: n21_1_gfs(:) @@ -2108,6 +2109,8 @@ subroutine init_AGRMET(findex) agrmet_struc(n)%pcp_ready = .false. agrmet_struc(n)%lastSfcalcHour = 0 agrmet_struc(n)%lastPcpHour = 0 + agrmet_struc(n)%lastRadHour = 0 + call AGRMET_read_pcpclimodata(n) agrmet_struc(n)%albAlarmTime = 0.0 diff --git a/lis/metforcing/usaf/AGRMET_sfcalc.F90 b/lis/metforcing/usaf/AGRMET_sfcalc.F90 index 034ed947f..f73853cc6 100644 --- a/lis/metforcing/usaf/AGRMET_sfcalc.F90 +++ b/lis/metforcing/usaf/AGRMET_sfcalc.F90 @@ -231,7 +231,7 @@ subroutine AGRMET_sfcalc(n) 0,0,jultmp) if(jultmp .gt. agrmet_struc(n)%lastSfcalcHour) then timeToReadGFS = .true. - else + else timeToReadGFS = .false. endif diff --git a/lis/metforcing/usaf/USAF_fldbld_radflux.F90 b/lis/metforcing/usaf/USAF_fldbld_radflux.F90 index eedd4cece..c78502cbf 100644 --- a/lis/metforcing/usaf/USAF_fldbld_radflux.F90 +++ b/lis/metforcing/usaf/USAF_fldbld_radflux.F90 @@ -22,14 +22,15 @@ ! 28 May 2024 Generated reader for radiation fluxese...K. Arsenault/SAIC ! ! !INTERFACE: -subroutine USAF_fldbld_radflux(n,order,julhr,swdown,longwv) +!subroutine USAF_fldbld_radflux(n,order,julhr,swdown,longwv) +subroutine USAF_fldbld_radflux(n,order,swdown,longwv) ! !USES: use AGRMET_forcingMod, only : agrmet_struc use LIS_coreMod, only : LIS_rc, LIS_masterproc use LIS_logMod, only : LIS_logunit, LIS_endrun, LIS_abort,& LIS_alert - use LIS_timeMgrMod, only : LIS_julhr_date + use LIS_timeMgrMod, only : LIS_julhr_date, LIS_get_julhr #if (defined USE_GRIBAPI) use grib_api @@ -39,7 +40,7 @@ subroutine USAF_fldbld_radflux(n,order,julhr,swdown,longwv) ! !ARGUMENTS: integer, intent(in) :: n integer, intent(in) :: order - integer, intent(inout) :: julhr +! integer, intent(inout) :: julhr real, intent(out) :: swdown(LIS_rc%lnc(n), LIS_rc%lnr(n)) real, intent(out) :: longwv(LIS_rc%lnc(n), LIS_rc%lnr(n)) ! @@ -70,9 +71,15 @@ subroutine USAF_fldbld_radflux(n,order,julhr,swdown,longwv) integer :: rc character(len=255) :: message(20) - character(len=10) :: yyyymmddhh - integer :: fc_hr - integer :: ierr + character(len=10) :: yyyymmddhh + integer :: julhr + integer :: jultmp + integer :: istart + integer :: julend + integer :: ordertmp ! Temporary placeholder +! integer :: fc_hr + integer :: ierr + logical :: timetoReadRad ! Sanity check if ( agrmet_struc(n)%first_guess_source .ne. 'GALWEM' .and. & @@ -81,53 +88,98 @@ subroutine USAF_fldbld_radflux(n,order,julhr,swdown,longwv) call LIS_endrun end if - call AGRMET_julhr_date10(julhr, yyyymmddhh) - write(LIS_logunit,*) & + ! Estimate julian hour to trigger reading of radiation fields: + call LIS_get_julhr(LIS_rc%yr,LIS_rc%mo,LIS_rc%da,LIS_rc%hr,& + 0,0,jultmp) + + if(jultmp .gt. agrmet_struc(n)%lastRadHour) then + timeToReadRad = .true. + else + timeToReadRad = .false. + endif + + if(timeToReadRad) then +!------------------------------------------------------------------ +! Find the time to start the processing from +!------------------------------------------------------------------ + call find_agrfld_starttime(LIS_rc%yr,LIS_rc%mo,LIS_rc%da,LIS_rc%hr,istart) + + julend = istart+6 + + agrmet_struc(n)%lastRadHour = julend + +! ------------------------------------------------------------------ +! check if the current instance is a restart or continuation of a run +! if the run is a cold start, read current and previous 6 hour data +! else copy the current to previous and read the new current data. +! ------------------------------------------------------------------ + if(agrmet_struc(n)%findtime1.eq.1.and.agrmet_struc(n)%findtime2.eq.1) then + ordertmp = 2 +! order = 2 +! call AGRMET_fldbld(n,order,istart) + +! order = 1 +! call AGRMET_fldbld(n,order,julend) + else + ordertmp = 1 +! order = 1 +! call AGRMET_fldbld(n,order,julend) + endif + + ! Generate 10-digit Year-Month-Day-Hour for "julhr": + call AGRMET_julhr_date10(julend, yyyymmddhh) + write(LIS_logunit,*) " " + write(LIS_logunit,*) & '[INFO] Searching for NWP radiation fields, valid ',yyyymmddhh - ! Try fetching GALWEM, if requested - ierr = 0 - if ( agrmet_struc(n)%first_guess_source == 'GALWEM' ) then + ! Try fetching GALWEM, if requested + ierr = 0 + if ( agrmet_struc(n)%first_guess_source == 'GALWEM' ) then - fc_hr = LIS_rc%hr ! KRA - TEMPORARY PLACEHOLDER FOR FC_HR ... - write(LIS_logunit,*) '[INFO] NWP radiation fc_hr: ',fc_hr + julhr = julend ! KRA -- Temporary placeholder - call USAF_fldbld_radflux_galwem(n,julhr,fc_hr,swdown,longwv,rc) - ierr = rc - end if +! fc_hr = LIS_rc%hr ! KRA - TEMPORARY PLACEHOLDER FOR FC_HR ... +! write(LIS_logunit,*) '[INFO] NWP radiation fc_hr: ',fc_hr - ! Try fetching GFS, if requested, or if GALWEM is not available. - if ( agrmet_struc(n)%first_guess_source == "GFS" .or. & - ierr .ne. 0) then - if (ierr .ne. 0) then - write(LIS_logunit,*)'[WARN] Unable to find GALWEM data!' - write(LIS_logunit,*)'[WARN] Rolling back to GFS...' +! call USAF_fldbld_radflux_galwem(n,julhr,fc_hr,swdown,longwv,rc) + call USAF_fldbld_radflux_galwem(n,julhr,swdown,longwv,rc) + ierr = rc end if -! call USAF_fldbld_radflux_gfs(n,order,julhr,rc) - - if (rc .ne. 0) then - call AGRMET_julhr_date10(julhr, yyyymmddhh) - if (ierr .ne. 0) then - write(LIS_logunit,*) & - '[ERR] No GALWEM or GFS background found for ',yyyymmddhh - else - write(LIS_logunit,*) & - '[ERR] No GFS background found for ',yyyymmddhh - end if - write(LIS_logunit,*) ' ABORTING!' - flush(LIS_logunit) - message(:) = '' - message(1) = '[ERR] Program: LIS' - message(2) = ' Routine: USAF_fldbld_radflux.' - message(3) = ' GALWEM and GFS GRIB data not available for '//& + ! Try fetching GFS, if requested, or if GALWEM is not available. + if ( agrmet_struc(n)%first_guess_source == "GFS" .or. & + ierr .ne. 0) then + if (ierr .ne. 0) then + write(LIS_logunit,*)'[WARN] Unable to find GALWEM data!' + write(LIS_logunit,*)'[WARN] Rolling back to GFS...' + end if + +! call USAF_fldbld_radflux_gfs(n,order,julhr,rc) + + if (rc .ne. 0) then + call AGRMET_julhr_date10(julhr, yyyymmddhh) + if (ierr .ne. 0) then + write(LIS_logunit,*) & + '[ERR] No GALWEM or GFS background found for ',yyyymmddhh + else + write(LIS_logunit,*) & + '[ERR] No GFS background found for ',yyyymmddhh + end if + write(LIS_logunit,*) ' ABORTING!' + flush(LIS_logunit) + message(:) = '' + message(1) = '[ERR] Program: LIS' + message(2) = ' Routine: USAF_fldbld_radflux.' + message(3) = ' GALWEM and GFS GRIB data not available for '//& yyyymmddhh - if(LIS_masterproc) then - call LIS_alert( 'LIS.USAF_fldbld_radflux.', 1, & - message ) - call LIS_abort( message) - endif - end if - end if + if(LIS_masterproc) then + call LIS_alert( 'LIS.USAF_fldbld_radflux.', 1, & + message ) + call LIS_abort( message) + endif + end if + end if + + endif ! End to timeToReadRad check end subroutine USAF_fldbld_radflux diff --git a/lis/metforcing/usaf/USAF_fldbld_radflux_galwem.F90 b/lis/metforcing/usaf/USAF_fldbld_radflux_galwem.F90 index 2c35cc0d3..0234b10c7 100644 --- a/lis/metforcing/usaf/USAF_fldbld_radflux_galwem.F90 +++ b/lis/metforcing/usaf/USAF_fldbld_radflux_galwem.F90 @@ -20,7 +20,8 @@ ! ...........................................K. Arsenault/SAIC ! ! !INTERFACE: -subroutine USAF_fldbld_radflux_galwem(n,julhr,fc_hr,fg_swdata,fg_lwdata,rc) +!subroutine USAF_fldbld_radflux_galwem(n,julhr,fc_hr,fg_swdata,fg_lwdata,rc) +subroutine USAF_fldbld_radflux_galwem(n,julhr,fg_swdata,fg_lwdata,rc) ! !USES: use LIS_coreMod, only : LIS_rc, LIS_masterproc @@ -37,7 +38,7 @@ subroutine USAF_fldbld_radflux_galwem(n,julhr,fc_hr,fg_swdata,fg_lwdata,rc) ! !ARGUMENTS: integer, intent(in) :: n integer :: julhr - integer :: fc_hr +! integer :: fc_hr real, intent(out) :: fg_swdata(LIS_rc%lnc(n), LIS_rc%lnr(n)) real, intent(out) :: fg_lwdata(LIS_rc%lnc(n), LIS_rc%lnr(n)) integer, intent(out):: rc @@ -82,12 +83,8 @@ subroutine USAF_fldbld_radflux_galwem(n,julhr,fc_hr,fg_swdata,fg_lwdata,rc) ! LWdown radiation flux data to be interpolated to lis grid ! \item[fg\_swdown1] ! 3 hour forecast swdown radiation flux data -! \item[fg\_swdown2] -! 6 hour forecast swdown radiation flux data ! \item[fg\_lwdown1] ! 3 hour forecast lwdown radiation flux data -! \item[fg\_lwdown2] -! 6 hour forecast lwdown radiation flux data ! \item[alert\_number] ! number of alerts that occur in the program ! \item[ifguess] @@ -137,75 +134,69 @@ subroutine USAF_fldbld_radflux_galwem(n,julhr,fc_hr,fg_swdata,fg_lwdata,rc) integer :: ftn, igrib character*250 :: avnfile, avnfile2 integer :: yr1, mo1, da1, hr1 -! integer :: julhr + integer :: fc_hr character*255 :: message ( 20 ) integer :: iginfo ( 2 ) real :: gridres integer :: alert_number real, allocatable :: fg_swdown ( : , : ) real, allocatable :: fg_swdown1 ( : , : ) - real, allocatable :: fg_swdown2 ( : , : ) real, allocatable :: fg_lwdown ( : , : ) real, allocatable :: fg_lwdown1 ( : , : ) - real, allocatable :: fg_lwdown2 ( : , : ) integer :: ifguess, jfguess integer :: center integer :: ierr logical*1 :: found, found2 + logical :: first_time integer :: yr_2d integer :: file_julhr - integer :: getsixhr +! integer :: getsixhr integer :: dataDate, dataTime character*100 :: gtype logical :: found_inq ! --------------------------------------------------- + ! Initialize return code to "no error". We will change it below if + ! necessary. rc = 0 - found = .false. - found2 = .false. - call LIS_julhr_date(julhr,yr1,mo1,da1,hr1) - file_julhr = julhr + ! Will search previous GALWEM cycles every six hours, up to 24 hours, + ! until we find an acceptable file. + fc_hr = 0 ! Incremented below + file_julhr = julhr ! Decremented below + call LIS_julhr_date(file_julhr,yr1,mo1,da1,hr1) -! ------------------------------------------------------------------ -! Need to process the current and previous 6 hour instances -! Search for an analysis or forecast file for upto 24 hours with -! the needed valid time -! ------------------------------------------------------------------ - - do while( ((.not.found) .or. (.not.found2)) .and. (fc_hr <= 12)) - found = .false. + found = .FALSE. + first_time = .true. + do while ( .not. found ) -! -------------------------------------------------------------------- -! determine if we need the 6 hour forecast file -! -------------------------------------------------------------------- - if (mod(fc_hr,6) .eq. 0) then - getsixhr=1 - found2=.false. - else - getsixhr=0 - found2=.true. - endif + ! Make sure we start with the previous GALWEM cycle. + if ( (.not. first_time) .or. & + (first_time .and. fc_hr < 6)) then + fc_hr = fc_hr + 6 + if (fc_hr > 24) exit ! Give up + file_julhr = file_julhr - 6 + call LIS_julhr_date(file_julhr,yr1,mo1,da1,hr1) + end if + first_time = .false. yr_2d = mod(yr1,100) if(yr_2d.eq.0) yr_2d = 100 - !EMK...Added support for 10-km GALWEM call AGRMET_getGALWEMfilename(avnfile, agrmet_struc(n)%agrmetdir,& - agrmet_struc(n)%galwemraddir,agrmet_struc(n)%use_timestamp,& + agrmet_struc(n)%galwemraddir, agrmet_struc(n)%use_timestamp,& agrmet_struc(n)%galwem_res, yr1,mo1,da1,hr1,fc_hr) - if (getsixhr.eq.1) then - call AGRMET_getGALWEMfilename(avnfile2, agrmet_struc(n)%agrmetdir,& - agrmet_struc(n)%galwemraddir,agrmet_struc(n)%use_timestamp,& - agrmet_struc(n)%galwem_res, yr1,mo1,da1,hr1,fc_hr-3) - endif - ! ------------------------------------------------------------------ ! open first guess grib data using library utility. just read ! the first file only, as all data will be of the same type ! (avn or nogaps) because the search script ensures that it is. ! ------------------------------------------------------------------ + inquire(file=trim(avnfile),exist=found_inq) + if (.not. found_inq) then + write(LIS_logunit,*) '[WARN] Cannot find file '//trim(avnfile) + cycle + end if #if (defined USE_GRIBAPI) @@ -214,7 +205,6 @@ subroutine USAF_fldbld_radflux_galwem(n,julhr,fc_hr,fg_swdata,fg_lwdata,rc) ! writing error messages to stdout/stderr, which may lead to runtime ! problems. - inquire(file=trim(avnfile),exist=found_inq) if (found_inq) then call grib_open_file(ftn,trim(avnfile),'r',ierr) else @@ -290,100 +280,30 @@ subroutine USAF_fldbld_radflux_galwem(n,julhr,fc_hr,fg_swdata,fg_lwdata,rc) call grib_close_file(ftn) endif #else - write(LIS_logunit,*) '[ERR]: USAF_fldbld_radflux_galwem requires GRIB-API' - write(LIS_logunit,*) '[ERR]: please recompile LIS' - call LIS_endrun + write(LIS_logunit,*) '[ERR]: USAF_fldbld_radflux_galwem requires GRIB-API' + write(LIS_logunit,*) '[ERR]: please recompile LIS' + call LIS_endrun #endif -! ------------------------------------------------------------------- -! if we need to get the six hour forecast file, repeat steps above -! for that file -! ------------------------------------------------------------------- - if (getsixhr.eq.1) then + ! At this point, we have everything we need. + found = .true. + if (found) exit -#if (defined USE_GRIBAPI) - ! EMK...Before using ECCODES/GRIB_API, see if the GRIB file exists - ! using a simple inquire statement. This avoids ECCODES/GRIB_API - ! writing error messages to stdout/stderr, which may lead to runtime - ! problems. - - inquire(file=trim(avnfile2),exist=found_inq) - if (found_inq) then - call grib_open_file(ftn,trim(avnfile2),'r',ierr) - else - ierr = 1 - end if - if(ierr.ne.0) then - write(LIS_logunit,*) '[WARN] (2) Failed to open 6-hr fcst file - ', trim(avnfile2) - else - ! ------------------------------------------------------------------ - ! read in the first grib record, unpack the header and extract - ! section 1 and section 2 information. - ! ------------------------------------------------------------------ - call grib_new_from_file(ftn,igrib,ierr) - call LIS_verify(ierr, 'failed to read - '//trim(avnfile2)) - - call grib_get(igrib,'centre',center,ierr) - call LIS_verify(ierr, 'error in grib_get: centre in ' // & - 'USAF_fldbld_radflux_galwem') - - call grib_get(igrib,'gridType',gtype,ierr) - call LIS_verify(ierr, 'error in grid_get: gridtype in ' // & - 'USAF_fldbld_radflux_galwem') - - call grib_get(igrib,'Ni',iginfo(1),ierr) - call LIS_verify(ierr, 'error in grid_get:Ni in ' // & - 'USAF_fldbld_radflux_galwem') - - call grib_get(igrib,'Nj',iginfo(2),ierr) - call LIS_verify(ierr, 'error in grid_get:Nj in ' // & - 'USAF_fldbld_radflux_galwem') - - call grib_get(igrib,'jDirectionIncrementInDegrees',gridres,ierr) - call LIS_verify(ierr, & - 'error in grid_get:jDirectionIncrementInDegrees in ' // & - 'USAF_fldbld_radflux_galwem') - - call grib_get(igrib,'dataDate',dataDate,ierr) - call LIS_verify(ierr, 'error in grid_get:dataDate in ' // & - 'USAF_fldbld_radflux_galwem') - - call grib_get(igrib,'dataTime',dataTime,ierr) - call LIS_verify(ierr, 'error in grid_get:dataTime in ' // & - 'USAF_fldbld_radflux_galwem') - - if ( yr1*10000+mo1*100+da1 == dataDate .and. & - hr1*100 == dataTime ) then - found2 = .TRUE. - if ( gtype /= "regular_ll" ) then - message(1) = 'program: LIS' - message(2) = ' Subroutine: USAF_fldbld_radflux_galwem' - message(3) = ' First guess source is not a lat/lon grid' - message(4) = ' USAF_fldbld_radflux_galwem expects lat/lon data' - call lis_abort(message) - endif - endif + enddo ! Loop through cycles and forecast hours - call grib_release(igrib,ierr) - call grib_close_file(ftn) - endif -#endif - endif + ! Give up if no acceptable GALWEM file was found + if (.not. found) then + write(LIS_logunit,*)'[WARN] No matching GALWEM Radiation file found!' + rc = 1 + return + end if -! ------------------------------------------------------------------ -! If the correct valid time is not found: -! Increment forecast hour by 6. -! Decrement file_julhr by 6 and get the new filename elements. -! ------------------------------------------------------------------ - if ((.not. found).or.(.not. found2)) then - fc_hr = fc_hr + 6 - file_julhr = file_julhr - 6 - call LIS_julhr_date(file_julhr,yr1,mo1,da1,hr1) - endif - enddo ! End while loop + write(LIS_logunit,*) & + '[INFO] Using NWP Radiation fields from ',trim(avnfile) + rc = 0 - if ((found) .and. (found2)) then + if( found ) then write(LIS_logunit,*)'- FIRST GUESS DATA IS ON A ', gridres,& ' DEGREE LAT/LON GRID' ifguess = iginfo(1) @@ -401,36 +321,17 @@ subroutine USAF_fldbld_radflux_galwem(n,julhr,fc_hr,fg_swdata,fg_lwdata,rc) allocate ( fg_swdown1 (ifguess, jfguess) ) allocate ( fg_lwdown1 (ifguess, jfguess) ) - if (getsixhr.eq.1) allocate ( fg_swdown2 (ifguess, jfguess) ) - if (getsixhr.eq.1) allocate ( fg_lwdown2 (ifguess, jfguess) ) - - ! ------------------------------------------------------------------ -! read in first guess data for this julian hour. +! read in first guess data for this julian hour. ! ------------------------------------------------------------------ alert_number = 0 call USAF_fldbld_read_radflux_galwem(avnfile, ifguess, jfguess,& fg_swdown1, fg_lwdown1, alert_number) - if (getsixhr.eq.1) & - call USAF_fldbld_read_radflux_galwem(avnfile2, ifguess, jfguess,& - fg_swdown2, fg_lwdown2, alert_number) allocate ( fg_swdown (ifguess, jfguess) ) allocate ( fg_lwdown (ifguess, jfguess) ) -! ----------------------------------------------------------------------- -! if we need 6 hour radiation data, subtract from 3 hour radiation data -! since the data are originally for the 0-6 hour forecast. -! ----------------------------------------------------------------------- - if (getsixhr.eq.1) then - fg_swdown = fg_swdown1 - fg_swdown2 - fg_lwdown = fg_lwdown1 - fg_lwdown2 - else - fg_swdown = fg_swdown1 - fg_lwdown = fg_lwdown1 - endif - ! ----------------------------------------------------------------------- ! sometimes the subtraction of 3 hour radiation from 6 hour rad fluxes causes ! slightly negative radiation values, set back to 0 @@ -451,7 +352,6 @@ subroutine USAF_fldbld_radflux_galwem(n,julhr,fc_hr,fg_swdata,fg_lwdata,rc) deallocate ( fg_swdown, fg_swdown1 ) deallocate ( fg_lwdown, fg_lwdown1 ) - if (getsixhr.eq.1) deallocate ( fg_swdown2, fg_lwdown2 ) else write(LIS_logunit,*)'[WARN] ** GALWEM RADIATION FLUX data not available **' diff --git a/lis/metforcing/usaf/get_agrmet.F90 b/lis/metforcing/usaf/get_agrmet.F90 index 422e7434a..9f9af7f02 100644 --- a/lis/metforcing/usaf/get_agrmet.F90 +++ b/lis/metforcing/usaf/get_agrmet.F90 @@ -44,10 +44,10 @@ subroutine get_agrmet(n, findex) ! The strategy for missing data is to go backwards up to 10 days to get ! forcing at the same time of day. This entry point code also ! calls different routines based on the running mode. The AGRMET -! mode will generate the surface analysis, merged precipitaition, +! mode will generate the surface analysis, merged precipitation, ! whereas the analysis mode will simply use the previously generated ! data. -!. +! ! The arguments are: ! \begin{description} ! \item[n] diff --git a/lis/metforcing/usaf/readagrmetforcing.F90 b/lis/metforcing/usaf/readagrmetforcing.F90 index c6adac056..d4158d94a 100644 --- a/lis/metforcing/usaf/readagrmetforcing.F90 +++ b/lis/metforcing/usaf/readagrmetforcing.F90 @@ -199,13 +199,13 @@ subroutine readagrmetforcing(n,findex, order) integer :: julhr character(len=255) :: message(20) - real,allocatable :: cldamt(:,:,:) - integer,allocatable :: cldamt_nh( :,:,:) - integer,allocatable :: cldtyp_nh( :,:,:) - integer,allocatable :: cldamt_sh( :,:,:) - integer,allocatable :: cldtyp_sh( :,:,:) - logical,allocatable :: fog_nh( :,:) - logical,allocatable :: fog_sh( :,:) + real,allocatable :: cldamt(:,:,:) + integer,allocatable :: cldamt_nh( :,:,:) + integer,allocatable :: cldtyp_nh( :,:,:) + integer,allocatable :: cldamt_sh( :,:,:) + integer,allocatable :: cldtyp_sh( :,:,:) + logical,allocatable :: fog_nh( :,:) + logical,allocatable :: fog_sh( :,:) integer :: thres(5) !needs to be read in. real :: q2sat real :: e,esat @@ -216,9 +216,9 @@ subroutine readagrmetforcing(n,findex, order) real*8 :: backtime1 real :: gmt1,ts1 logical :: fog, bare - real,allocatable :: albedo(:) - real,allocatable :: albedo_tmp(:) - integer,allocatable :: ncount(:) + real,allocatable :: albedo(:) + real,allocatable :: albedo_tmp(:) + integer,allocatable :: ncount(:) real :: snup(24) integer :: dindex @@ -243,6 +243,7 @@ subroutine readagrmetforcing(n,findex, order) .040, .080, .025, .040, .040, .040, .025, .025/ data THRES /12600, 12300, 12000, 11700, 11400/ +! ___________________________________________________________ TRACE_ENTER("agrmet_readforc") allocate(varfield(LIS_rc%lnc(n),LIS_rc%lnr(n))) @@ -328,6 +329,7 @@ subroutine readagrmetforcing(n,findex, order) ! print*,'EMK: minval(agrmet_struc(n)%sfcrlh(dindex,:,:) = ', & ! minval(agrmet_struc(n)%sfcrlh(dindex,:,:)) + ! Humidity field: do c =1, LIS_rc%lnc(n) do r = 1,LIS_rc%lnr(n) if (LIS_domain(n)%gindex(c,r).ne. -1) then @@ -355,24 +357,22 @@ subroutine readagrmetforcing(n,findex, order) ss1 = LIS_rc%ss ! Downward Longwave + Shortwave Radiation, read in from GALWEM / GFS: + ! -- KRA: Initial setup if ( agrmet_struc(n)%compute_radiation == 'GALWEM_RAD' ) then - call find_agrfld_starttime(LIS_rc%yr,LIS_rc%mo,LIS_rc%da,LIS_rc%hr,istart) - julend = istart+6 +! call find_agrfld_starttime(LIS_rc%yr,LIS_rc%mo,LIS_rc%da,LIS_rc%hr,istart) +! julend = istart+6 if(LIS_masterproc) then print *, "READ IN GALWEM RADIATION FIELDS -- ", yr1, mo1, da1, hr1 print *, "order :: ",order - print *, "istart, julend :: ",istart,julend -! call LIS_endrun +! print *, "istart, julend :: ",istart,julend endif - ! Target fields: swdown(lnc,lnr), longwv(lnc,lnr) - longwv = 200. ! KRA - Just testing a sample value ... - swdown = 100. ! KRA - Just testing a sample value ... - ! Call to the NWP Radiation Flux main routines: - call USAF_fldbld_radflux(n,order,julend,swdown,longwv) + ! Target fields: swdown(lnc,lnr), longwv(lnc,lnr) +! call USAF_fldbld_radflux(n,order,julend,swdown,longwv) + call USAF_fldbld_radflux(n,order,swdown,longwv) endif @@ -391,10 +391,11 @@ subroutine readagrmetforcing(n,findex, order) ! EMK...Calculate for all valid grid indices ! if(LIS_LMLC(n)%landmask(c,r).eq.1) then if ( LIS_domain(n)%gindex(c,r) /= -1 ) then - call AGRMET_svp(q2sat,esat,& - psurf(c,r), tair(c,r)) + call AGRMET_svp(q2sat, esat, & + psurf(c,r), tair(c,r)) e = esat*rlh(c,r) - call AGRMET_longwv(tair(c,r),e,cldamt(:,c,r),longwv(c,r)) + call AGRMET_longwv(tair(c,r), e, cldamt(:,c,r),& + longwv(c,r)) else longwv(c,r) = LIS_rc%udef endif