From f1431489f7e7a46a71a3286ce01b1c39811403f3 Mon Sep 17 00:00:00 2001 From: Qing Liu Date: Wed, 21 Feb 2024 09:33:35 -0500 Subject: [PATCH 1/4] read precipcor daily nc files --- .../GEOSmetforce_GridComp/LDAS_Forcing.F90 | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 b/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 index 772183dc..39bc99f2 100755 --- a/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 +++ b/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 @@ -3207,7 +3207,7 @@ subroutine get_GEOS( date_time, force_dtstep, met_path, met_tag, & logical :: minimize_shift, use_prec_corr, use_Predictor, tmp_init - logical :: daily_met_files + logical :: daily_met_files, daily_precipcorr_files integer :: nv_id, ierr, icount(3), istart(3), lonid, latid @@ -3696,9 +3696,9 @@ subroutine get_GEOS( date_time, force_dtstep, met_path, met_tag, & if ( (use_prec_corr) .and. (GEOSgcm_defs(GEOSgcm_var,1)(1:4)=='PREC') ) then call get_GEOS_corr_prec_filename(fname_full,file_exists,date_time_tmp, & - prec_path_tmp, met_tag_tmp, GEOSgcm_defs(GEOSgcm_var,:), precip_corr_file_ext ) + prec_path_tmp, met_tag_tmp, GEOSgcm_defs(GEOSgcm_var,:), precip_corr_file_ext,daily_precipcorr_files ) - single_time_in_file = .true. ! corr precip files are always hourly (incl. MERRA-2) + single_time_in_file = .not. daily_precipcorr_files ! corr precip files are always hourly (incl. MERRA-2) else @@ -5622,26 +5622,27 @@ subroutine GEOS_closefile(fid) ! **************************************************************** subroutine get_GEOS_corr_prec_filename(fname_full,file_exists, date_time, met_path, met_tag, & - GEOSgcm_defs, file_ext ) + GEOSgcm_defs, file_ext,daily_files ) implicit none character(*), intent(inout) :: fname_full logical,intent(out) :: file_exists + logical,intent(out) :: daily_files type(date_time_type), intent(in) :: date_time character(*), intent(in) :: met_path character(*), intent(in) :: met_tag character( 40), dimension(5), intent(in) :: GEOSgcm_defs character(*), intent(in) :: file_ext - + ! local variables - character(100) :: fname + character(100) :: fname, fname_tmp character(200) :: fdir - character(300) :: fname_full_tmp1, fname_full_tmp2 + character(300) :: fname_full_tmp1, fname_full_tmp2, fname_full_tmp3 character( 4) :: YYYY, HHMM character( 2) :: MM, DD - integer :: tmpind, tmpindend + integer :: tmpind, tmpindend,is character(len=*), parameter :: Iam = 'get_GEOS_corr_prec_filename' @@ -5678,7 +5679,7 @@ subroutine get_GEOS_corr_prec_filename(fname_full,file_exists, date_time, met_pa ! ----------------------------------------------------------------------- file_exists = .false. ! initialize - + daily_files = .false. ! first try: look for file in year/month dir ! (LDAS standard for corrected G5DAS precip) @@ -5691,8 +5692,20 @@ subroutine get_GEOS_corr_prec_filename(fname_full,file_exists, date_time, met_pa fname_full_tmp1 = trim(fname_full) ! remember for error log below + ! second try: look for daily file in year/month dir + is = index(fname,'z.nc') + fname_tmp = fname(1:is-6)//'.'//trim(file_ext) + fname_full = trim(fdir) // 'M' // MM // '/' // trim(fname_tmp) - ! second try: *without* "/Mmm" (month) dir + inquire(file=fname_full, exist=file_exists) + + if (file_exists) then + daily_files = .true. + return + endif ! done + fname_full_tmp2 = trim(fname_full) ! remember for error log below + + ! third try: *without* "/Mmm" (month) dir ! THIS TRY IS PROBABLY OBSOLETE BUT COULD EASILY BE TWEAKED TO LOOK ! IN year/month/day DIRECTORY (WHICH POSSIBLY APPLIES TO CORRECTED @@ -5705,7 +5718,7 @@ subroutine get_GEOS_corr_prec_filename(fname_full,file_exists, date_time, met_pa if (file_exists) return ! done - fname_full_tmp2 = trim(fname_full) ! remember for error log below + fname_full_tmp3 = trim(fname_full) ! remember for error log below ! last try: for GEOS FP with generic file names, try product counter '.V02.' in year/month dir From 911a37a6ad48ed923bf2578141ade59420cd9c32 Mon Sep 17 00:00:00 2001 From: Qing Liu Date: Fri, 23 Feb 2024 08:29:04 -0500 Subject: [PATCH 2/4] update filename parse --- .../GEOSmetforce_GridComp/LDAS_Forcing.F90 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 b/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 index 39bc99f2..349430d9 100755 --- a/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 +++ b/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 @@ -5663,12 +5663,18 @@ subroutine get_GEOS_corr_prec_filename(fname_full,file_exists, date_time, met_pa fname = trim(met_tag) // '.' // trim(GEOSgcm_defs(3)) // '_corr.' // & YYYY // MM // DD // '_' // trim(HHMM) // '.V01.' // trim(file_ext) - + + fname_tmp = trim(met_tag) // '.' // trim(GEOSgcm_defs(3)) // '_corr.' // & + YYYY // MM // DD // '.V01.' // trim(file_ext) + else fname = trim(met_tag) // '.' // trim(GEOSgcm_defs(3)) // '_corr.' // & YYYY // MM // DD // '_' // trim(HHMM) // 'z.' // trim(file_ext) - + + fname_tmp = trim(met_tag) // '.' // trim(GEOSgcm_defs(3)) // '_corr.' // & + YYYY // MM // DD // '.' // trim(file_ext) + end if ! assemble dir name with "/Yyy" (year) dir but without "/Mmm" (month) dir @@ -5693,8 +5699,6 @@ subroutine get_GEOS_corr_prec_filename(fname_full,file_exists, date_time, met_pa fname_full_tmp1 = trim(fname_full) ! remember for error log below ! second try: look for daily file in year/month dir - is = index(fname,'z.nc') - fname_tmp = fname(1:is-6)//'.'//trim(file_ext) fname_full = trim(fdir) // 'M' // MM // '/' // trim(fname_tmp) inquire(file=fname_full, exist=file_exists) From d31e5cbd54c4f5db3997f19ce6a9a9b598ece5c7 Mon Sep 17 00:00:00 2001 From: Rolf Reichle <54944691+gmao-rreichle@users.noreply.github.com> Date: Sat, 24 Feb 2024 09:20:57 -0500 Subject: [PATCH 3/4] minimal cleanup (white space, alignment, unnecessary declaration) from previous commits (LDAS_Forcing.F90) --- .../GEOSmetforce_GridComp/LDAS_Forcing.F90 | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 b/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 index 349430d9..c2290547 100755 --- a/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 +++ b/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 @@ -3696,7 +3696,7 @@ subroutine get_GEOS( date_time, force_dtstep, met_path, met_tag, & if ( (use_prec_corr) .and. (GEOSgcm_defs(GEOSgcm_var,1)(1:4)=='PREC') ) then call get_GEOS_corr_prec_filename(fname_full,file_exists,date_time_tmp, & - prec_path_tmp, met_tag_tmp, GEOSgcm_defs(GEOSgcm_var,:), precip_corr_file_ext,daily_precipcorr_files ) + prec_path_tmp, met_tag_tmp, GEOSgcm_defs(GEOSgcm_var,:), precip_corr_file_ext, daily_precipcorr_files) single_time_in_file = .not. daily_precipcorr_files ! corr precip files are always hourly (incl. MERRA-2) @@ -5622,7 +5622,7 @@ subroutine GEOS_closefile(fid) ! **************************************************************** subroutine get_GEOS_corr_prec_filename(fname_full,file_exists, date_time, met_path, met_tag, & - GEOSgcm_defs, file_ext,daily_files ) + GEOSgcm_defs, file_ext, daily_files) implicit none character(*), intent(inout) :: fname_full @@ -5642,7 +5642,7 @@ subroutine get_GEOS_corr_prec_filename(fname_full,file_exists, date_time, met_pa character( 4) :: YYYY, HHMM character( 2) :: MM, DD - integer :: tmpind, tmpindend,is + integer :: tmpind, tmpindend character(len=*), parameter :: Iam = 'get_GEOS_corr_prec_filename' @@ -5661,19 +5661,19 @@ subroutine get_GEOS_corr_prec_filename(fname_full,file_exists, date_time, met_pa ! (as of 7 May 2020, no V02 or higher was issued for GEOS FP "lfo" products ! going back to Jun 2013) - fname = trim(met_tag) // '.' // trim(GEOSgcm_defs(3)) // '_corr.' // & + fname = trim(met_tag) // '.' // trim(GEOSgcm_defs(3)) // '_corr.' // & YYYY // MM // DD // '_' // trim(HHMM) // '.V01.' // trim(file_ext) fname_tmp = trim(met_tag) // '.' // trim(GEOSgcm_defs(3)) // '_corr.' // & - YYYY // MM // DD // '.V01.' // trim(file_ext) + YYYY // MM // DD // '.V01.' // trim(file_ext) else - fname = trim(met_tag) // '.' // trim(GEOSgcm_defs(3)) // '_corr.' // & + fname = trim(met_tag) // '.' // trim(GEOSgcm_defs(3)) // '_corr.' // & YYYY // MM // DD // '_' // trim(HHMM) // 'z.' // trim(file_ext) fname_tmp = trim(met_tag) // '.' // trim(GEOSgcm_defs(3)) // '_corr.' // & - YYYY // MM // DD // '.' // trim(file_ext) + YYYY // MM // DD // '.' // trim(file_ext) end if @@ -5705,8 +5705,9 @@ subroutine get_GEOS_corr_prec_filename(fname_full,file_exists, date_time, met_pa if (file_exists) then daily_files = .true. - return - endif ! done + return ! done + endif + fname_full_tmp2 = trim(fname_full) ! remember for error log below ! third try: *without* "/Mmm" (month) dir From d0b04fb58a391d0624e34b813c0af5d2183b3c4d Mon Sep 17 00:00:00 2001 From: Rolf Reichle <54944691+gmao-rreichle@users.noreply.github.com> Date: Sat, 24 Feb 2024 09:24:35 -0500 Subject: [PATCH 4/4] Fixed error log associated with previous changes in get_GEOS_corr_prec_filename() (LDAS_Forcing.F90) --- .../GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 b/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 index c2290547..b87e6734 100755 --- a/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 +++ b/src/Components/GEOSldas_GridComp/GEOSmetforce_GridComp/LDAS_Forcing.F90 @@ -5754,6 +5754,7 @@ subroutine get_GEOS_corr_prec_filename(fname_full,file_exists, date_time, met_pa print '(400A)', trim(Iam) // ': Could not find any of the following files:' print '(400A)', trim(fname_full_tmp1) print '(400A)', trim(fname_full_tmp2) + print '(400A)', trim(fname_full_tmp3) print '(400A)', trim(fname_full) endif endif