From 5c715db17308f78ba1ec4805266d223803f9efe1 Mon Sep 17 00:00:00 2001
From: Jim Edwards <jedwards@ucar.edu>
Date: Thu, 23 Jan 2025 12:28:48 -0700
Subject: [PATCH 1/6] replace calls to esmf_logmsg_error with shr_abort

---
 docn/docn_import_data_mod.F90 |  5 +--
 dshr/dshr_mod.F90             |  4 +--
 share/nuopc_shr_methods.F90   | 62 ++++++++++-------------------------
 share/shr_abort_mod.F90       | 23 +++++++++----
 streams/dshr_methods_mod.F90  | 53 ++++++++++--------------------
 5 files changed, 56 insertions(+), 91 deletions(-)

diff --git a/docn/docn_import_data_mod.F90 b/docn/docn_import_data_mod.F90
index cb7d95136..150d15e46 100644
--- a/docn/docn_import_data_mod.F90
+++ b/docn/docn_import_data_mod.F90
@@ -1,7 +1,6 @@
 module docn_import_data_mod
 
    use ESMF             , only : ESMF_State, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_SUCCESS
-   use ESMF             , only : ESMF_LOGMSG_ERROR, ESMF_FAILURE
    use NUOPC            , only : NUOPC_Advertise
    use shr_kind_mod     , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs
    use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add
@@ -99,9 +98,7 @@ subroutine docn_get_import_fields(str, flds, rc)
          valid = .false.
       end if
       if (.not. valid) then
-         call ESMF_LogWrite("ERROR: invalid list = "//trim(str), ESMF_LOGMSG_ERROR)
-         rc = ESMF_FAILURE
-         return
+         call shr_sys_abort("ERROR: invalid list = "//trim(str))
       end if
       ! get number of fields in a colon delimited string list
       nflds = 0
diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90
index fb5010ace..7230e35a9 100644
--- a/dshr/dshr_mod.F90
+++ b/dshr/dshr_mod.F90
@@ -89,6 +89,7 @@ module dshr_mod
 
   subroutine dshr_model_initphase(gcomp, importState, exportState, clock, rc)
     use ESMF, only : ESMF_ClockIsCreated, ESMF_StateIsCreated
+    use shr_sys_mod, only : shr_sys_abort
     ! input/output variables
     type(ESMF_GridComp)   :: gcomp
     type(ESMF_State)      :: importState, exportState
@@ -100,8 +101,7 @@ subroutine dshr_model_initphase(gcomp, importState, exportState, clock, rc)
     rc = ESMF_SUCCESS
     ! To prevent an unused variable warning
     if(.not. (ESMF_StateIsCreated(importState) .or. ESMF_StateIsCreated(exportState) .or. ESMF_ClockIsCreated(clock))) then
-       call ESMF_LogWrite(trim(subname)//' state or clock not created', ESMF_LOGMSG_ERROR)
-
+       call shr_sys_abort(trim(subname)//' state or clock not created', ESMF_LOGMSG_ERROR)
     endif
 
     ! Switch to IPDv01 by filtering all other phaseMap entries
diff --git a/share/nuopc_shr_methods.F90 b/share/nuopc_shr_methods.F90
index 7055cc83c..6d542e546 100644
--- a/share/nuopc_shr_methods.F90
+++ b/share/nuopc_shr_methods.F90
@@ -2,7 +2,7 @@ module nuopc_shr_methods
   use ESMF         , only : operator(<), operator(/=), operator(+)
   use ESMF         , only : operator(-), operator(*) , operator(>=)
   use ESMF         , only : operator(<=), operator(>), operator(==), MOD
-  use ESMF         , only : ESMF_LOGERR_PASSTHRU, ESMF_LogFoundError, ESMF_LOGMSG_ERROR, ESMF_MAXSTR
+  use ESMF         , only : ESMF_LOGERR_PASSTHRU, ESMF_LogFoundError, ESMF_MAXSTR
   use ESMF         , only : ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_FAILURE
   use ESMF         , only : ESMF_State, ESMF_StateGet
   use ESMF         , only : ESMF_Field, ESMF_FieldGet
@@ -373,9 +373,7 @@ subroutine state_diagnose(State, string, rc)
              call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO)
           endif
        else
-          call ESMF_LogWrite(trim(subname)//": ERROR rank not supported ", ESMF_LOGMSG_ERROR)
-          rc = ESMF_FAILURE
-          return
+          call shr_sys_abort(trim(subname)//": ERROR rank not supported ")
        endif
     enddo
 
@@ -411,10 +409,8 @@ subroutine field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc)
     ! ----------------------------------------------
 
     if (.not.present(rc)) then
-       call ESMF_LogWrite(trim(subname)//": ERROR rc not present ", &
-            ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u)
-       rc = ESMF_FAILURE
-       return
+       call shr_sys_abort(trim(subname)//": ERROR rc not present ", &
+            line=__LINE__, file=u_FILE_u)
     endif
 
     rc = ESMF_SUCCESS
@@ -465,27 +461,21 @@ subroutine field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc)
                ESMF_LOGMSG_INFO)
        elseif (lrank == 1) then
           if (.not.present(fldptr1)) then
-             call ESMF_LogWrite(trim(subname)//": ERROR missing rank=1 array ", &
-                  ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u)
-             rc = ESMF_FAILURE
-             return
+             call shr_abort_mod(trim(subname)//": ERROR missing rank=1 array ", &
+                  line=__LINE__, file=u_FILE_u)
           endif
           call ESMF_FieldGet(field, farrayPtr=fldptr1, rc=rc)
           if (chkerr(rc,__LINE__,u_FILE_u)) return
        elseif (lrank == 2) then
           if (.not.present(fldptr2)) then
-             call ESMF_LogWrite(trim(subname)//": ERROR missing rank=2 array ", &
-                  ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u)
-             rc = ESMF_FAILURE
-             return
+             call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array ", &
+                  line=__LINE__, file=u_FILE_u)
           endif
           call ESMF_FieldGet(field, farrayPtr=fldptr2, rc=rc)
           if (chkerr(rc,__LINE__,u_FILE_u)) return
        else
-          call ESMF_LogWrite(trim(subname)//": ERROR in rank ", &
-               ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u)
-          rc = ESMF_FAILURE
-          return
+          call shr_sys_abort(trim(subname)//": ERROR in rank ", &
+               line=__LINE__, file=u_FILE_u)
        endif
 
     endif  ! status
@@ -566,14 +556,10 @@ subroutine alarmInit( clock, alarm, option, &
     ! Error checks
     if (trim(option) == optdate) then
        if (.not. present(opt_ymd)) then
-          call ESMF_LogWrite(trim(subname)//trim(option)//' requires opt_ymd', ESMF_LOGMSG_ERROR)
-          rc = ESMF_FAILURE
-          return
+          call shr_sys_abort(trim(subname)//trim(option)//' requires opt_ymd')
        end if
        if (lymd < 0 .or. ltod < 0) then
-          call ESMF_LogWrite(subname//trim(option)//'opt_ymd, opt_tod invalid', ESMF_LOGMSG_ERROR)
-          rc = ESMF_FAILURE
-          return
+          call shr_sys_abort(subname//trim(option)//'opt_ymd, opt_tod invalid')
        end if
     else if (&
          trim(option) == optNSteps   .or. trim(option) == trim(optNSteps)//'s'   .or. &
@@ -584,14 +570,10 @@ subroutine alarmInit( clock, alarm, option, &
          trim(option) == optNMonths  .or. trim(option) == trim(optNMonths)//'s'  .or. &
          trim(option) == optNYears   .or. trim(option) == trim(optNYears)//'s' ) then
        if (.not.present(opt_n)) then
-          call ESMF_LogWrite(subname//trim(option)//' requires opt_n', ESMF_LOGMSG_ERROR)
-          rc = ESMF_FAILURE
-          return
+          call shr_sys_abort(subname//trim(option)//' requires opt_n')
        end if
        if (opt_n <= 0) then
-          call ESMF_LogWrite(subname//trim(option)//' invalid opt_n', ESMF_LOGMSG_ERROR)
-          rc = ESMF_FAILURE
-          return
+          call shr_sys_abort(subname//trim(option)//' invalid opt_n')
        end if
     end if
     call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc)
@@ -629,9 +611,7 @@ subroutine alarmInit( clock, alarm, option, &
       AlarmInterval = AlarmInterval * opt_n
       ! timestepinterval*0 is 0 of kind ESMF_TimeStepInterval
       if (mod(AlarmInterval, TimestepInterval) /= (TimestepInterval*0)) then
-         call ESMF_LogWrite(subname//'illegal Alarm setting for '//trim(alarmname), ESMF_LOGMSG_ERROR)
-         rc = ESMF_FAILURE
-         return
+         call shr_sys_abort(subname//'illegal Alarm setting for '//trim(alarmname))
       endif
       update_nextalarm  = .true.
 
@@ -691,9 +671,7 @@ subroutine alarmInit( clock, alarm, option, &
        if (ChkErr(rc,__LINE__,u_FILE_u)) return
        
     case default
-       call ESMF_LogWrite(subname//'unknown option '//trim(option), ESMF_LOGMSG_ERROR)
-       rc = ESMF_FAILURE
-       return
+       call shr_sys_abort(subname//'unknown option '//trim(option))
 
     end select
 
@@ -804,14 +782,10 @@ integer function get_minimum_timestep(gcomp, rc)
     enddo
 
     if(get_minimum_timestep == huge(1)) then
-       call ESMF_LogWrite('minimum_timestep_error: this option is not supported ', ESMF_LOGMSG_ERROR)
-       rc = ESMF_FAILURE
-       return
+       call shr_sys_abort('minimum_timestep_error: this option is not supported ')
     endif
     if(get_minimum_timestep <= 0) then
-       call ESMF_LogWrite('minimum_timestep_error ERROR ', ESMF_LOGMSG_ERROR)
-       rc = ESMF_FAILURE
-       return
+       call shr_sys_abort('minimum_timestep_error ERROR ')
     endif
   end function get_minimum_timestep
 
diff --git a/share/shr_abort_mod.F90 b/share/shr_abort_mod.F90
index 230cb61e2..a8d422f34 100644
--- a/share/shr_abort_mod.F90
+++ b/share/shr_abort_mod.F90
@@ -8,8 +8,9 @@ module shr_abort_mod
   ! when these routines were defined in shr_sys_mod.)
 
   use, intrinsic :: iso_fortran_env, only: output_unit, error_unit
-  use ESMF,         only : ESMF_Finalize, ESMF_END_ABORT, ESMF_LOGMSG_ERROR, ESMF_LogWrite
+
   use shr_kind_mod, only : shr_kind_in, shr_kind_cx
+  use shr_mpi_mod , only : shr_mpi_initialized, shr_mpi_abort
   use shr_log_mod , only : s_logunit => shr_log_Unit
 
 #ifdef CPRNAG
@@ -34,14 +35,18 @@ module shr_abort_mod
 contains
 
   !===============================================================================
-  subroutine shr_abort_abort(string,rc)
+  subroutine shr_abort_abort(string,rc, line, file)
+    use esmf, only : ESMF_LOGWRITE, ESMF_LOGMSG_ERROR
     ! Consistent stopping mechanism
 
     !----- arguments -----
     character(len=*)    , intent(in), optional :: string  ! error message string
     integer(shr_kind_in), intent(in), optional :: rc      ! error code
+    integer(shr_kind_in), intent(in), optional :: line
+    character(len=*), intent(in), optional :: file
 
     !----- local -----
+    logical :: flag
 
     ! Local version of the string.
     ! (Gets a default value if string is not present.)
@@ -56,13 +61,19 @@ subroutine shr_abort_abort(string,rc)
 
     call print_error_to_logs("ERROR", local_string)
 
+    call ESMF_LogWrite(local_string, ESMF_LOGMSG_ERROR, line=line, file=file)
+    
     call shr_abort_backtrace()
 
-    if(present(rc)) then
-       write(local_string, *) trim(local_string), ' rc=',rc
+    call shr_mpi_initialized(flag)
+
+    if (flag) then
+       if (present(rc)) then
+          call shr_mpi_abort(trim(local_string),rc)
+       else
+          call shr_mpi_abort(trim(local_string))
+       endif
     endif
-    call ESMF_LogWrite(local_string, ESMF_LOGMSG_ERROR)
-    call ESMF_Finalize(endflag=ESMF_END_ABORT)
 
     ! A compiler's abort method may print a backtrace or do other nice
     ! things, but in fact we can rarely leverage this, because MPI_Abort
diff --git a/streams/dshr_methods_mod.F90 b/streams/dshr_methods_mod.F90
index 0ce787596..c5aa946d1 100644
--- a/streams/dshr_methods_mod.F90
+++ b/streams/dshr_methods_mod.F90
@@ -6,14 +6,15 @@ module dshr_methods_mod
   use ESMF         , only : ESMF_LogWrite, ESMF_SUCCESS, ESMF_FAILURE
   use ESMF         , only : ESMF_StateRemove, ESMF_StateGet, ESMF_RouteHandle
   use ESMF         , only : ESMF_Region_Flag, ESMF_FieldStatus_Flag, ESMF_LOGMSG_INFO
-  use ESMF         , only : ESMF_MAXSTR, ESMF_LOGMSG_ERROR, ESMF_LOGERR_PASSTHRU
+  use ESMF         , only : ESMF_MAXSTR, ESMF_LOGERR_PASSTHRU
   use ESMF         , only : ESMF_FieldBundleGet, ESMF_FieldBundleAdd, ESMF_FieldGet
   use ESMF         , only : ESMF_REGION_TOTAL, ESMF_END_ABORT, ESMF_ITEMORDER_ADDORDER
   use ESMF         , only : ESMF_LogFoundError, ESMF_FieldRegrid, ESMF_Finalize, ESMF_FIELDSTATUS_COMPLETE
   use ESMF         , only : ESMF_TERMORDER_SRCSEQ, operator(/=)
   use ESMF         , only : ESMF_TraceRegionEnter, ESMF_TraceRegionExit
   use shr_kind_mod , only : r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl
-
+  use shr_sys_mod  , only : shr_sys_abort
+  
   implicit none
   public
 
@@ -139,9 +140,7 @@ subroutine dshr_state_diagnose(State, flds_scalar_name, string, rc)
                 write(msgString,'(A,a)') trim(string)//': '//trim(lfieldnamelist(n))," no data"
              endif
           else
-             call ESMF_LogWrite(trim(subname)//": ERROR rank not supported ", ESMF_LOGMSG_ERROR)
-             rc = ESMF_FAILURE
-             return
+             call shr_sys_abort(trim(subname)//": ERROR rank not supported ")
           endif
           call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO)
        end if
@@ -177,9 +176,7 @@ subroutine dshr_fldbun_GetFldPtr(FB, fldname, fldptr1, fldptr2, rank, field, rc)
     rc = ESMF_SUCCESS
 
     if (.not. dshr_fldbun_FldChk(FB, trim(fldname), rc=rc)) then
-       call ESMF_LogWrite(trim(subname)//": ERROR field "//trim(fldname)//" not in FB ", ESMF_LOGMSG_ERROR)
-      rc = ESMF_FAILURE
-      return
+       call shr_sys_abort(trim(subname)//": ERROR field "//trim(fldname)//" not in FB ")
     endif
     call ESMF_FieldBundleGet(FB, fieldName=trim(fldname), field=lfield, rc=rc)
     if (chkerr(rc,__LINE__,u_FILE_u)) return
@@ -187,20 +184,16 @@ subroutine dshr_fldbun_GetFldPtr(FB, fldname, fldptr1, fldptr2, rank, field, rc)
     if (chkerr(rc,__LINE__,u_FILE_u)) return
     if (ungriddedUBound(1) > 0) then
        if (.not.present(fldptr2)) then
-          call ESMF_LogWrite(trim(subname)//": ERROR missing rank=2 array ", &
-               ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u)
-          rc = ESMF_FAILURE
-          return
+          call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array ", &
+               line=__LINE__, file=u_FILE_u)
        endif
        call ESMF_FieldGet(lfield, farrayptr=fldptr2, rc=rc)
        if (chkerr(rc,__LINE__,u_FILE_u)) return
        lrank = 2
     else
        if (.not.present(fldptr1)) then
-          call ESMF_LogWrite(trim(subname)//": ERROR missing rank=1 array ", &
-               ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u)
-          rc = ESMF_FAILURE
-          return
+          call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array ", &
+               line=__LINE__, file=u_FILE_u)
        endif
        call ESMF_FieldGet(lfield, farrayptr=fldptr1, rc=rc)
        if (chkerr(rc,__LINE__,u_FILE_u)) return
@@ -339,9 +332,7 @@ subroutine dshr_fldbun_getNameN(FB, fieldnum, fieldname, rc)
     call ESMF_FieldBundleGet(FB, fieldCount=fieldCount, rc=rc)
     if (chkerr(rc,__LINE__,u_FILE_u)) return
     if (fieldnum > fieldCount) then
-      call ESMF_LogWrite(trim(subname)//": ERROR fieldnum > fieldCount ", ESMF_LOGMSG_ERROR)
-      rc = ESMF_FAILURE
-      return
+      call shr_sys_abort(trim(subname)//": ERROR fieldnum > fieldCount ")
     endif
 
     allocate(lfieldnamelist(fieldCount))
@@ -377,9 +368,7 @@ logical function dshr_fldbun_FldChk(FB, fldname, rc)
 
     call ESMF_FieldBundleGet(FB, fieldName=trim(fldname), isPresent=isPresent, rc=rc)
     if (chkerr(rc,__LINE__,u_FILE_u)) then
-       call ESMF_LogWrite(trim(subname)//" Error checking field: "//trim(fldname), ESMF_LOGMSG_ERROR)
-       rc = ESMF_FAILURE
-       return
+       call shr_sys_abort(trim(subname)//" Error checking field: "//trim(fldname))
     endif
 
     if (isPresent) then
@@ -434,9 +423,7 @@ subroutine dshr_fldbun_Field_diagnose(FB, fieldname, string, rc)
           write(msgString,'(A,a)') trim(subname)//' '//trim(lstring)//': '//trim(fieldname)," no data"
        endif
     else
-       call ESMF_LogWrite(trim(subname)//": ERROR rank not supported ", ESMF_LOGMSG_ERROR)
-       rc = ESMF_FAILURE
-       return
+       call shr_sys_abort(trim(subname)//": ERROR rank not supported ")
     endif
     call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO)
 
@@ -505,9 +492,7 @@ subroutine dshr_fldbun_diagnose(FB, string, rc)
           endif
 
        else
-          call ESMF_LogWrite(trim(subname)//": ERROR rank not supported ", ESMF_LOGMSG_ERROR)
-          rc = ESMF_FAILURE
-          return
+          call shr_sys_abort(trim(subname)//": ERROR rank not supported ")
        endif
        call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO)
     enddo
@@ -557,9 +542,7 @@ subroutine dshr_field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc)
        if (labort) then
           call ESMF_FieldGet(field, name=name, rc=rc)
           if (chkerr(rc,__LINE__,u_FILE_u)) return
-          call ESMF_LogWrite(trim(subname)//": field "//trim(name)//" has no data not allocated ", ESMF_LOGMSG_ERROR, rc=rc)
-          rc = ESMF_FAILURE
-          return
+          call shr_sys_abort(trim(subname)//": field "//trim(name)//" has no data not allocated ", rc=rc)
        else
           call ESMF_LogWrite(trim(subname)//": WARNING data not allocated ", ESMF_LOGMSG_INFO, rc=rc)
        endif
@@ -568,8 +551,8 @@ subroutine dshr_field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc)
         if (chkerr(rc,__LINE__,u_FILE_u)) return
         if (ungriddedUBound(1) > 0) then
            if (.not.present(fldptr2)) then
-              call ESMF_LogWrite(trim(subname)//": ERROR missing rank=2 array for "//trim(name), &
-                   ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u)
+              call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array for "//trim(name), &
+                   line=__LINE__, file=u_FILE_u)
               rc = ESMF_FAILURE
               return
            endif
@@ -578,8 +561,8 @@ subroutine dshr_field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc)
            lrank = 2
         else
            if (.not.present(fldptr1)) then
-              call ESMF_LogWrite(trim(subname)//": ERROR missing rank=1 array for "//trim(name), &
-                   ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u)
+              call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array for "//trim(name), &
+                   line=__LINE__, file=u_FILE_u)
               rc = ESMF_FAILURE
               return
            endif

From a4de12dcfa74442226adb8dce568fefee8d9fbfc Mon Sep 17 00:00:00 2001
From: Jim Edwards <jedwards@ucar.edu>
Date: Thu, 23 Jan 2025 12:57:03 -0700
Subject: [PATCH 2/6] use ESMF_FINALIZE here

---
 share/shr_abort_mod.F90 | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/share/shr_abort_mod.F90 b/share/shr_abort_mod.F90
index a8d422f34..f3fe018c8 100644
--- a/share/shr_abort_mod.F90
+++ b/share/shr_abort_mod.F90
@@ -10,7 +10,6 @@ module shr_abort_mod
   use, intrinsic :: iso_fortran_env, only: output_unit, error_unit
 
   use shr_kind_mod, only : shr_kind_in, shr_kind_cx
-  use shr_mpi_mod , only : shr_mpi_initialized, shr_mpi_abort
   use shr_log_mod , only : s_logunit => shr_log_Unit
 
 #ifdef CPRNAG
@@ -36,7 +35,7 @@ module shr_abort_mod
 
   !===============================================================================
   subroutine shr_abort_abort(string,rc, line, file)
-    use esmf, only : ESMF_LOGWRITE, ESMF_LOGMSG_ERROR
+    use esmf, only : ESMF_LOGWRITE, ESMF_LOGMSG_ERROR, ESMF_FINALIZE, ESMF_END_ABORT
     ! Consistent stopping mechanism
 
     !----- arguments -----
@@ -58,6 +57,9 @@ subroutine shr_abort_abort(string,rc, line, file)
     else
        local_string = "Unknown error submitted to shr_abort_abort."
     end if
+    if(present(rc)) then
+       write(local_string, *) trim(local_string), ' rc=',rc
+    endif
 
     call print_error_to_logs("ERROR", local_string)
 
@@ -65,15 +67,7 @@ subroutine shr_abort_abort(string,rc, line, file)
     
     call shr_abort_backtrace()
 
-    call shr_mpi_initialized(flag)
-
-    if (flag) then
-       if (present(rc)) then
-          call shr_mpi_abort(trim(local_string),rc)
-       else
-          call shr_mpi_abort(trim(local_string))
-       endif
-    endif
+    call ESMF_Finalize(endflag=ESMF_END_ABORT)
 
     ! A compiler's abort method may print a backtrace or do other nice
     ! things, but in fact we can rarely leverage this, because MPI_Abort

From 0e3a3cab0c5fe5334439ab1d784d3e90bd2e93b5 Mon Sep 17 00:00:00 2001
From: Jim Edwards <jedwards@ucar.edu>
Date: Thu, 23 Jan 2025 13:18:37 -0700
Subject: [PATCH 3/6] remove unused variable

---
 share/shr_abort_mod.F90 | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/share/shr_abort_mod.F90 b/share/shr_abort_mod.F90
index f3fe018c8..6e3a90680 100644
--- a/share/shr_abort_mod.F90
+++ b/share/shr_abort_mod.F90
@@ -44,9 +44,6 @@ subroutine shr_abort_abort(string,rc, line, file)
     integer(shr_kind_in), intent(in), optional :: line
     character(len=*), intent(in), optional :: file
 
-    !----- local -----
-    logical :: flag
-
     ! Local version of the string.
     ! (Gets a default value if string is not present.)
     character(len=shr_kind_cx) :: local_string

From 3539203d74d16f4b2cfd58588113b1c9f3197ee1 Mon Sep 17 00:00:00 2001
From: Jim Edwards <jedwards@ucar.edu>
Date: Thu, 23 Jan 2025 13:31:33 -0700
Subject: [PATCH 4/6] fix typo

---
 share/nuopc_shr_methods.F90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/share/nuopc_shr_methods.F90 b/share/nuopc_shr_methods.F90
index 6d542e546..f67e08f5f 100644
--- a/share/nuopc_shr_methods.F90
+++ b/share/nuopc_shr_methods.F90
@@ -461,7 +461,7 @@ subroutine field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc)
                ESMF_LOGMSG_INFO)
        elseif (lrank == 1) then
           if (.not.present(fldptr1)) then
-             call shr_abort_mod(trim(subname)//": ERROR missing rank=1 array ", &
+             call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array ", &
                   line=__LINE__, file=u_FILE_u)
           endif
           call ESMF_FieldGet(field, farrayPtr=fldptr1, rc=rc)

From 27c145ba9c13e557c34a999d116f98607140d9f3 Mon Sep 17 00:00:00 2001
From: Jim Edwards <jedwards@ucar.edu>
Date: Thu, 23 Jan 2025 13:43:14 -0700
Subject: [PATCH 5/6] fix syntax error

---
 dshr/dshr_mod.F90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90
index 7230e35a9..7073ea923 100644
--- a/dshr/dshr_mod.F90
+++ b/dshr/dshr_mod.F90
@@ -101,7 +101,7 @@ subroutine dshr_model_initphase(gcomp, importState, exportState, clock, rc)
     rc = ESMF_SUCCESS
     ! To prevent an unused variable warning
     if(.not. (ESMF_StateIsCreated(importState) .or. ESMF_StateIsCreated(exportState) .or. ESMF_ClockIsCreated(clock))) then
-       call shr_sys_abort(trim(subname)//' state or clock not created', ESMF_LOGMSG_ERROR)
+       call shr_sys_abort(trim(subname)//' state or clock not created')
     endif
 
     ! Switch to IPDv01 by filtering all other phaseMap entries

From c492b6add3a2ddf2707917fa098c5020003199ed Mon Sep 17 00:00:00 2001
From: Jim Edwards <jedwards@ucar.edu>
Date: Fri, 24 Jan 2025 11:45:50 -0700
Subject: [PATCH 6/6] add missing module import

---
 docn/docn_import_data_mod.F90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docn/docn_import_data_mod.F90 b/docn/docn_import_data_mod.F90
index 150d15e46..ff4ba7d68 100644
--- a/docn/docn_import_data_mod.F90
+++ b/docn/docn_import_data_mod.F90
@@ -69,7 +69,7 @@ end subroutine docn_import_data_advertise
 
    !===============================================================================
    subroutine docn_get_import_fields(str, flds, rc)
-
+      use shr_sys_mod          , only : shr_sys_abort
       ! input/output variables
       character(len=*)               , intent(in)  :: str     ! colon deliminted string to search
       character(len=*) , allocatable , intent(out) :: flds(:) ! memory will be allocate for flds