From a89b37c005c7718e2ef59334a2a6d81ed0c588bc Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 13 Aug 2026 10:35:20 -0600 Subject: [PATCH 1/3] In dglc restart read, check file existence on all tasks Previously, the dglc restart read was only returning from the main task if the restart file didn't exist. Other tasks would proceed into the pio_openfile with a non-existent file. There were two specific problems behind this: - 'exists' (or its 'tmp' equivalent) was not being broadcast - The return for '.not. exists' was only done for the main task This commit fixes the logic to broadcast exists and return on all tasks if exists is false. This makes the logic more similar to what's in dshr_restart_read. --- dglc/dglc_datamode_noevolve_mod.F90 | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dglc/dglc_datamode_noevolve_mod.F90 b/dglc/dglc_datamode_noevolve_mod.F90 index c33daa49f..903087934 100644 --- a/dglc/dglc_datamode_noevolve_mod.F90 +++ b/dglc/dglc_datamode_noevolve_mod.F90 @@ -630,13 +630,16 @@ subroutine dglc_datamode_noevolve_restart_read(model_meshes, restfilem, rpfile, !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - ! Determine restart file + call ESMF_VMGetCurrent(vm, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! Determine restart file + ! + ! Note that we first determine existence only on the main task, then broadcast this to + ! other tasks. + exists = .false. if (trim(restfilem) == trim(nullstr)) then - exists = .false. - call ESMF_VMGetCurrent(vm, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return if (my_task == main_task) then write(logunit,'(a)') subname//' restart filename from rpointer '//trim(rpfile) open(newunit=nu, file=trim(rpfile), form='formatted') @@ -655,9 +658,13 @@ subroutine dglc_datamode_noevolve_restart_read(model_meshes, restfilem, rpfile, endif tmp = 0 if(exists) tmp=1 + call ESMF_VMBroadCast(vm, tmp, 1, main_task, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return exists = (tmp(1) == 1) - if (.not. exists .and. my_task == main_task) then - write(logunit, '(a)') subname//' file not found, skipping '//trim(restfilem) + if (.not. exists) then + if (my_task == main_task) then + write(logunit, '(a)') subname//' file not found, skipping '//trim(restfilem) + end if return end if From 92fe160700941a820dd981d4617dd43ebf9fa631 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 13 Aug 2026 10:39:27 -0600 Subject: [PATCH 2/3] Remove unused mpicom argument Note that the same issue of an unused mpicom argument exists in dshr_restart_read; I have not yet fixed it there because the changes would be more extensive. --- dglc/dglc_datamode_noevolve_mod.F90 | 3 +-- dglc/glc_comp_nuopc.F90 | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/dglc/dglc_datamode_noevolve_mod.F90 b/dglc/dglc_datamode_noevolve_mod.F90 index 903087934..8da2ef2aa 100644 --- a/dglc/dglc_datamode_noevolve_mod.F90 +++ b/dglc/dglc_datamode_noevolve_mod.F90 @@ -595,7 +595,7 @@ end subroutine dglc_datamode_noevolve_restart_write !=============================================================================== subroutine dglc_datamode_noevolve_restart_read(model_meshes, restfilem, rpfile, & - logunit, my_task, main_task, mpicom, & + logunit, my_task, main_task, & pio_subsystem, io_type, nx_global, ny_global, rc) ! input/output arguments @@ -605,7 +605,6 @@ subroutine dglc_datamode_noevolve_restart_read(model_meshes, restfilem, rpfile, integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: main_task - integer , intent(in) :: mpicom type(iosystem_desc_t) , pointer :: pio_subsystem ! pio info integer , intent(in) :: io_type ! pio info integer , intent(in) :: nx_global(:) diff --git a/dglc/glc_comp_nuopc.F90 b/dglc/glc_comp_nuopc.F90 index e7ada6953..d5d81879d 100644 --- a/dglc/glc_comp_nuopc.F90 +++ b/dglc/glc_comp_nuopc.F90 @@ -554,7 +554,7 @@ subroutine dglc_comp_run(gcomp, clock, target_ymd, target_tod, restart_write, va call shr_get_rpointer_name(gcomp, 'glc', target_ymd, target_tod, rpfile, 'read', rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call dglc_datamode_noevolve_restart_read(model_meshes, restfilm, rpfile, & - logunit, my_task, main_task, mpicom, & + logunit, my_task, main_task, & sdat(1)%pio_subsystem, sdat(1)%io_type, nx_global, ny_global, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if From 338bf1c3a7441613f840e137ad5de809d8d63bc7 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 13 Aug 2026 10:40:27 -0600 Subject: [PATCH 3/3] Fix broadcasts of restart file name to broadcast full file name --- dglc/dglc_datamode_noevolve_mod.F90 | 2 +- dshr/dshr_mod.F90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dglc/dglc_datamode_noevolve_mod.F90 b/dglc/dglc_datamode_noevolve_mod.F90 index 8da2ef2aa..1c6a332d7 100644 --- a/dglc/dglc_datamode_noevolve_mod.F90 +++ b/dglc/dglc_datamode_noevolve_mod.F90 @@ -646,7 +646,7 @@ subroutine dglc_datamode_noevolve_restart_read(model_meshes, restfilem, rpfile, close(nu) inquire(file=trim(restfilem), exist=exists) endif - call ESMF_VMBroadCast(vm, restfilem, CL, main_task, rc=rc) + call ESMF_VMBroadCast(vm, restfilem, len(restfilem), main_task, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else ! use namelist already read diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index f36ee48b7..a88561502 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -616,7 +616,7 @@ subroutine dshr_restart_read(rest_filem, rpfile, & close(nu) inquire(file=trim(rest_filem), exist=exists) endif - call ESMF_VMBroadCast(vm, rest_filem, CL, main_task, rc=rc) + call ESMF_VMBroadCast(vm, rest_filem, len(rest_filem), main_task, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else ! use namelist already read