Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shr log error #535

Merged
merged 4 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/extbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
CPPFLAGS: "-I/usr/include -I/usr/local/include"

# Versions of all dependencies can be updated here
ESMF_VERSION: v8.7.0
ESMF_VERSION: v8.8.0
PNETCDF_VERSION: checkpoint.1.14.0
NETCDF_FORTRAN_VERSION: v4.6.1
PIO_VERSION: pio2_6_3
CDEPS_VERSION: cdeps1.0.62
PIO_VERSION: pio2_6_4
CDEPS_VERSION: cdeps1.0.64
steps:
- uses: actions/checkout@v4
# Build the ESMF library, if the cache contains a previous build
Expand Down
77 changes: 45 additions & 32 deletions cesm/driver/esm.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ module ESM
!-----------------------------------------------------------------------------

use shr_kind_mod , only : r8=>shr_kind_r8, cl=>shr_kind_cl, cs=>shr_kind_cs
use shr_sys_mod , only : shr_sys_abort
use shr_mpi_mod , only : shr_mpi_bcast
use shr_mem_mod , only : shr_mem_init
use shr_log_mod , only : shr_log_setLogunit
use shr_log_mod , only : shr_log_setLogunit, shr_log_error
use esm_utils_mod, only : logunit, maintask, dbug_flag, chkerr

use esmf , only : ESMF_FAILURE
implicit none
private

Expand Down Expand Up @@ -490,10 +489,14 @@ subroutine InitAttributes(driver, rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

if (.not. shr_wv_sat_valid_idx(shr_wv_sat_get_scheme_idx(trim(wv_sat_scheme)))) then
call shr_sys_abort(subname//': "'//trim(wv_sat_scheme)//'" is not a recognized saturation vapor pressure scheme name')
call shr_log_error(subname//': "'//trim(wv_sat_scheme)//'" is not a recognized saturation vapor pressure scheme name')
rc = ESMF_FAILURE
return
end if
if (.not. shr_wv_sat_set_default(wv_sat_scheme)) then
call shr_sys_abort('Invalid wv_sat_scheme.')
call shr_log_error('Invalid wv_sat_scheme.')
rc = ESMF_FAILURE
return
end if

call NUOPC_CompAttributeGet(driver, name="wv_sat_transition_start", value=cvalue, rc=rc)
Expand Down Expand Up @@ -522,7 +525,9 @@ subroutine InitAttributes(driver, rc)

call shr_wv_sat_init(shr_const_tkfrz, shr_const_tktrip, wv_sat_transition_start, epsilo, errstring)
if (errstring /= "") then
call shr_sys_abort('shr_wv_sat_init: '//trim(errstring))
call shr_log_error('shr_wv_sat_init: '//trim(errstring))
rc = ESMF_FAILURE
return
end if

! The below produces internal lookup tables in the range 175-374K for
Expand Down Expand Up @@ -567,26 +572,34 @@ subroutine CheckAttributes( driver, rc )
call NUOPC_CompAttributeGet(driver, name="cime_model", value=cime_model, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if ( trim(cime_model) /= 'cesm' .and. trim(cime_model) /= 'ufs') then
call shr_sys_abort( subname//': cime_model must be set to cesm or ufs, aborting')
call shr_log_error( subname//': cime_model must be set to cesm or ufs, aborting')
rc = ESMF_FAILURE
return
end if

! --- LogFile ending name -----
call NUOPC_CompAttributeGet(driver, name="logFilePostFix", value=logFilePostFix, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

if ( len_trim(logFilePostFix) == 0 ) then
call shr_sys_abort( subname//': logFilePostFix must be set to something not blank' )
call shr_log_error( subname//': logFilePostFix must be set to something not blank' )
rc = ESMF_FAILURE
return
end if

! --- Output path root directory -----
call NUOPC_CompAttributeGet(driver, name="outPathRoot", value=outPathRoot, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

if ( len_trim(outPathRoot) == 0 ) then
call shr_sys_abort( subname//': outPathRoot must be set' )
call shr_log_error( subname//': outPathRoot must be set' )
rc = ESMF_FAILURE
return
end if
if ( index(outPathRoot, "/", back=.true.) /= len_trim(outPathRoot) ) then
call shr_sys_abort( subname//': outPathRoot must end with a slash' )
call shr_log_error( subname//': outPathRoot must end with a slash' )
rc = ESMF_FAILURE
return
end if

end subroutine CheckAttributes
Expand Down Expand Up @@ -1256,7 +1269,7 @@ subroutine esm_set_single_column_attributes(compname, gcomp, rc)

if ( (scol_lon < scol_spval .and. scol_lat > scol_spval) .or. &
(scol_lon > scol_spval .and. scol_lat < scol_spval)) then
call shr_sys_abort(subname//' ERROR: '//trim(compname)//' both scol_lon and scol_lat must be greater than -999 ')
call shr_log_error(subname//' ERROR: '//trim(compname)//' both scol_lon and scol_lat must be greater than -999 ')
end if

! Set the special value for single column - if pts_lat or pts_lon are equal to the special value
Expand All @@ -1271,7 +1284,7 @@ subroutine esm_set_single_column_attributes(compname, gcomp, rc)
! ATM, LND, OCN and ICE components only
! verify that WAV and LND are not trying to use single column mode
if (trim(compname) == 'WAV' .or. trim(compname) == 'ROF' .or. trim(compname) == 'GLC') then
call shr_sys_abort(subname//' ERROR: '//trim(compname)//' does not support single column mode ')
call shr_log_error(subname//' ERROR: '//trim(compname)//' does not support single column mode ')
end if

! ensure that single column mode is only run on 1 pet
Expand All @@ -1280,7 +1293,7 @@ subroutine esm_set_single_column_attributes(compname, gcomp, rc)
call ESMF_VMGet(vm, petcount=petcount, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (petcount > 1) then
call shr_sys_abort(subname//' ERROR: single column mode must be run on 1 pe')
call shr_log_error(subname//' ERROR: single column mode must be run on 1 pe')
endif

write(logunit,'(a,2(f10.5,2x))')trim(subname)//' single column point for '//trim(compname)//&
Expand All @@ -1304,27 +1317,27 @@ subroutine esm_set_single_column_attributes(compname, gcomp, rc)
! the closest point in the domin file to scol_lon and scol_lat

status = nf90_open(single_column_lnd_domainfile, NF90_NOWRITE, ncid)
if (status /= nf90_noerr) call shr_sys_abort (trim(subname) //': opening '//&
if (status /= nf90_noerr) call shr_log_error (trim(subname) //': opening '//&
trim(single_column_lnd_domainfile))
status = nf90_inq_dimid (ncid, 'ni', dimid)
if (status /= nf90_noerr) call shr_sys_abort (trim(subname) //': inq_dimid ni')
if (status /= nf90_noerr) call shr_log_error (trim(subname) //': inq_dimid ni')
status = nf90_inquire_dimension(ncid, dimid, len=ni)
if (status /= nf90_noerr) call shr_sys_abort (trim(subname) //': inquire_dimension ni')
if (status /= nf90_noerr) call shr_log_error (trim(subname) //': inquire_dimension ni')
status = nf90_inq_dimid (ncid, 'nj', dimid)
if (status /= nf90_noerr) call shr_sys_abort (trim(subname) //': inq_dimid nj')
if (status /= nf90_noerr) call shr_log_error (trim(subname) //': inq_dimid nj')
status = nf90_inquire_dimension(ncid, dimid, len=nj)
if (status /= nf90_noerr) call shr_sys_abort (trim(subname) //': inquire_dimension nj')
if (status /= nf90_noerr) call shr_log_error (trim(subname) //': inquire_dimension nj')

status = nf90_inq_varid(ncid, 'xc' , varid_xc)
if (status /= nf90_noerr) call shr_sys_abort (subname//' inq_varid xc')
if (status /= nf90_noerr) call shr_log_error (subname//' inq_varid xc')
status = nf90_inq_varid(ncid, 'yc' , varid_yc)
if (status /= nf90_noerr) call shr_sys_abort (subname//' inq_varid yc')
if (status /= nf90_noerr) call shr_log_error (subname//' inq_varid yc')
status = nf90_inq_varid(ncid, 'area' , varid_area)
if (status /= nf90_noerr) call shr_sys_abort (subname//' inq_varid area')
if (status /= nf90_noerr) call shr_log_error (subname//' inq_varid area')
status = nf90_inq_varid(ncid, 'mask' , varid_mask)
if (status /= nf90_noerr) call shr_sys_abort (subname//' inq_varid mask')
if (status /= nf90_noerr) call shr_log_error (subname//' inq_varid mask')
status = nf90_inq_varid(ncid, 'frac' , varid_frac)
if (status /= nf90_noerr) call shr_sys_abort (subname//' inq_varid frac')
if (status /= nf90_noerr) call shr_log_error (subname//' inq_varid frac')

! Read in domain file for single column
! Check for unstructured data ni>1 and nj==1
Expand All @@ -1344,10 +1357,10 @@ subroutine esm_set_single_column_attributes(compname, gcomp, rc)
start3=(/1,1,1/)
count3=(/ni,nj,1/)
status = nf90_get_var(ncid, varid_xc, glob_grid, start3, count3)
if (status /= nf90_noerr) call shr_sys_abort (subname//' get_var xc')
if (status /= nf90_noerr) call shr_log_error (subname//' get_var xc')
lons(1:ni) = glob_grid(1:ni,1)
status = nf90_get_var(ncid, varid_yc, glob_grid, start3, count3)
if (status /= nf90_noerr) call shr_sys_abort (subname//' get_var yc')
if (status /= nf90_noerr) call shr_log_error (subname//' get_var yc')
if (unstructured) then
lats(1:ni) = glob_grid(1:ni,1)
else
Expand Down Expand Up @@ -1379,31 +1392,31 @@ subroutine esm_set_single_column_attributes(compname, gcomp, rc)
! read in value of nearest neighbor lon and RESET scol_lon and scol_lat
! also get area of gridcell, mask and frac
status = nf90_get_var(ncid, varid_xc, scol_lon, start)
if (status /= nf90_noerr) call shr_sys_abort (subname//' get_var xc')
if (status /= nf90_noerr) call shr_log_error (subname//' get_var xc')

status = nf90_get_var(ncid, varid_yc, scol_lat, start)
if (status /= nf90_noerr) call shr_sys_abort (subname//' get_var yc')
if (status /= nf90_noerr) call shr_log_error (subname//' get_var yc')

status = nf90_get_var(ncid, varid_area, scol_area, start)
if (status /= nf90_noerr) call shr_sys_abort (subname//' get_var area')
if (status /= nf90_noerr) call shr_log_error (subname//' get_var area')

status = nf90_get_var(ncid, varid_mask, iscol_data, start)
if (status /= nf90_noerr) call shr_sys_abort (subname//' get_var mask')
if (status /= nf90_noerr) call shr_log_error (subname//' get_var mask')
scol_lndmask = iscol_data(1)
scol_ocnmask = 1 - scol_lndmask

status = nf90_get_var(ncid, varid_frac, scol_data, start)
if (status /= nf90_noerr) call shr_sys_abort (subname//' get_var frac')
if (status /= nf90_noerr) call shr_log_error (subname//' get_var frac')
scol_lndfrac = scol_data(1)
scol_ocnfrac = 1._r8 - scol_lndfrac

if (scol_ocnmask == 0 .and. scol_lndmask == 0) then
call shr_sys_abort(trim(subname)//' in single column mode '&
call shr_log_error(trim(subname)//' in single column mode '&
//' ocean and land mask cannot both be zero')
end if

status = nf90_close(ncid)
if (status /= nf90_noerr) call shr_sys_abort (trim(subname) //': closing '//&
if (status /= nf90_noerr) call shr_log_error (trim(subname) //': closing '//&
trim(single_column_lnd_domainfile))

! Now read in mesh file to get exact values of scol_lon and scol_lat that will be used
Expand Down
56 changes: 41 additions & 15 deletions cesm/driver/esm_time_mod.F90
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module esm_time_mod

use shr_kind_mod , only : cx=>shr_kind_cx, cs=>shr_kind_cs, cl=>shr_kind_cl, r8=>shr_kind_r8
use shr_sys_mod , only : shr_sys_abort
use shr_log_mod , only : shr_log_error
use ESMF , only : ESMF_GridComp, ESMF_GridCompGet, ESMF_GridCompSet
use ESMF , only : ESMF_Clock, ESMF_ClockCreate, ESMF_ClockGet, ESMF_ClockSet
use ESMF , only : ESMF_ClockAdvance
use ESMF , only : ESMF_ClockAdvance, ESMF_FAILURE
use ESMF , only : ESMF_Alarm, ESMF_AlarmCreate, ESMF_AlarmGet
use ESMF , only : ESMF_Calendar, ESMF_CalKind_Flag, ESMF_CalendarCreate
use ESMF , only : ESMF_CALKIND_NOLEAP, ESMF_CALKIND_GREGORIAN
Expand Down Expand Up @@ -141,20 +141,26 @@ subroutine esm_time_clockinit(ensemble_driver, instance_driver, logunit, maintas
write(logunit,*) " read rpointer file = "//trim(restart_pfile)
inquire( file=trim(restart_pfile), exist=exists)
if (.not. exists) then
call shr_sys_abort(trim(subname)//' ERROR rpointer file '//trim(restart_pfile)//' not found',&
call shr_log_error( trim(subname)//' ERROR rpointer file '//trim(restart_pfile)//' not found',&
line=__LINE__, file=__FILE__)
rc = ESMF_FAILURE
return
endif
call ESMF_LogWrite(trim(subname)//" read rpointer file = "//trim(restart_pfile), &
ESMF_LOGMSG_INFO)
open(newunit=unitn, file=restart_pfile, form='FORMATTED', status='old',iostat=ierr)
if (ierr < 0) then
call shr_sys_abort(trim(subname)//' ERROR rpointer file open returns error', &
call shr_log_error( trim(subname)//' ERROR rpointer file open returns error', &
line=__LINE__, file=__FILE__)
rc = ESMF_FAILURE
return
end if
read(unitn,'(a)', iostat=ierr) restart_file
if (ierr < 0) then
call shr_sys_abort(trim(subname)//' ERROR rpointer file read returns error', &
call shr_log_error( trim(subname)//' ERROR rpointer file read returns error', &
line=__LINE__, file=__FILE__)
rc = ESMF_FAILURE
return
end if
close(unitn)
if (maintask) then
Expand Down Expand Up @@ -367,58 +373,78 @@ subroutine esm_time_read_restart(restart_file, start_ymd, start_tod, curr_ymd, c
rc = ESMF_SUCCESS
status = nf90_open(restart_file, NF90_NOWRITE, ncid)
if (status /= nf90_NoErr) then
call shr_sys_abort(trim(subname)//' ERROR: nf90_open: '//trim(restart_file),&
call shr_log_error( trim(subname)//' ERROR: nf90_open: '//trim(restart_file),&
file=__FILE__, line=__LINE__)
rc = ESMF_FAILURE
return
endif

status = nf90_inq_varid(ncid, 'start_ymd', varid)
if (status /= nf90_NoErr) then
call shr_sys_abort(trim(subname)//' ERROR: nf90_inq_varid start_ymd', &
call shr_log_error( trim(subname)//' ERROR: nf90_inq_varid start_ymd', &
file=__FILE__, line=__LINE__)
rc = ESMF_FAILURE
return
end if
status = nf90_get_var(ncid, varid, start_ymd)
if (status /= nf90_NoErr) then
call shr_sys_abort(trim(subname)//' ERROR: nf90_get_var start_ymd', &
call shr_log_error( trim(subname)//' ERROR: nf90_get_var start_ymd', &
file=__FILE__, line=__LINE__)
rc = ESMF_FAILURE
return
end if

status = nf90_inq_varid(ncid, 'start_tod', varid)
if (status /= nf90_NoErr) then
call shr_sys_abort(trim(subname)//' ERROR: nf90_inq_varid start_tod', &
call shr_log_error( trim(subname)//' ERROR: nf90_inq_varid start_tod', &
file=__FILE__, line=__LINE__)
rc = ESMF_FAILURE
return
end if
status = nf90_get_var(ncid, varid, start_tod)
if (status /= nf90_NoErr) then
call shr_sys_abort(trim(subname)//' ERROR: nf90_get_var start_tod', &
call shr_log_error( trim(subname)//' ERROR: nf90_get_var start_tod', &
file=__FILE__, line=__LINE__)
rc = ESMF_FAILURE
return
end if

status = nf90_inq_varid(ncid, 'curr_ymd', varid)
if (status /= nf90_NoErr) then
call shr_sys_abort(trim(subname)//' ERROR: nf90_inq_varid curr_ymd', &
call shr_log_error( trim(subname)//' ERROR: nf90_inq_varid curr_ymd', &
file=__FILE__, line=__LINE__)
rc = ESMF_FAILURE
return
end if
status = nf90_get_var(ncid, varid, curr_ymd)
if (status /= nf90_NoErr) then
call shr_sys_abort(trim(subname)//' ERROR: nf90_get_var curr_ymd', &
call shr_log_error( trim(subname)//' ERROR: nf90_get_var curr_ymd', &
file=__FILE__, line=__LINE__)
rc = ESMF_FAILURE
return
end if

status = nf90_inq_varid(ncid, 'curr_tod', varid)
if (status /= nf90_NoErr) then
call shr_sys_abort(trim(subname)//' ERROR: nf90_inq_varid curr_tod', &
call shr_log_error( trim(subname)//' ERROR: nf90_inq_varid curr_tod', &
file=__FILE__, line=__LINE__)
rc = ESMF_FAILURE
return
end if
status = nf90_get_var(ncid, varid, curr_tod)
if (status /= nf90_NoErr) then
call shr_sys_abort(trim(subname)//' ERROR: nf90_get_var curr_tod', &
call shr_log_error( trim(subname)//' ERROR: nf90_get_var curr_tod', &
file=__FILE__, line=__LINE__)
rc = ESMF_FAILURE
return
end if

status = nf90_close(ncid)
if (status /= nf90_NoErr) then
call shr_sys_abort(trim(subname)//' ERROR: nf90_close', &
call shr_log_error( trim(subname)//' ERROR: nf90_close', &
file=__FILE__, line=__LINE__)
rc = ESMF_FAILURE
return
end if

write(tmpstr,*) trim(subname)//" read start_ymd = ",start_ymd
Expand Down
7 changes: 4 additions & 3 deletions cesm/flux_atmocn/shr_flux_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ module shr_flux_mod
! !USES:

use shr_kind_mod, only : R8=>SHR_KIND_R8, IN=>SHR_KIND_IN ! shared kinds
use shr_const_mod ! shared constants
use shr_sys_mod ! shared system routines

use shr_const_mod, only : shr_const_zvir, shr_const_cpdair, shr_const_cpvir, shr_const_karman, shr_const_g ! shared constants
use shr_const_mod, only : shr_const_latvap, shr_const_latice, shr_const_stebol, shr_const_tkfrz, shr_const_pi, shr_const_spval
use shr_const_mod, only : shr_const_ocn_ref_sal, shr_const_zsrflyr, shr_const_rgas
use shr_sys_mod, only : shr_sys_abort ! shared system routines
implicit none

private ! default private
Expand Down
10 changes: 6 additions & 4 deletions cesm/nuopc_cap_share/driver_pio_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module driver_pio_mod
use pio , only : pio_set_blocksize, pio_set_buffer_size_limit, pio_finalize
use shr_pio_mod, only : io_compname, pio_comp_settings, iosystems, io_compid, shr_pio_getindex
use shr_kind_mod, only : CS=>shr_kind_CS, shr_kind_cl, shr_kind_in
use shr_log_mod, only : shr_log_getLogUnit
use shr_sys_mod, only : shr_sys_abort
use shr_log_mod, only : shr_log_getLogUnit, shr_log_error

#ifndef NO_MPI2
use mpi, only : mpi_comm_null, mpi_comm_world, mpi_finalize
#endif
Expand Down Expand Up @@ -424,7 +424,8 @@ subroutine driver_pio_component_init(driver, inst_comm, asyncio_petlist, rc)
call MPI_AllReduce(MPI_IN_PLACE, comp_proc_list(:,i), maxprocspercomp, MPI_INTEGER, MPI_MAX, Inst_comm, ierr)
enddo
if(asyncio_ntasks == 0) then
call shr_sys_abort(subname//' ERROR: ASYNC IO Requested but no IO PES assigned')
call shr_log_error(subname//' ERROR: ASYNC IO Requested but no IO PES assigned', rc=rc)
return
endif

allocate(async_iosystems(do_async_init))
Expand All @@ -440,7 +441,8 @@ subroutine driver_pio_component_init(driver, inst_comm, asyncio_petlist, rc)
async_rearr = pio_comp_settings(i)%pio_rearranger
elseif(async_rearr .ne. pio_comp_settings(i)%pio_rearranger .and. pio_comp_settings(i)%pio_rearranger > 0) then
write(msgstr,*) i,async_rearr,pio_comp_settings(i)%pio_rearranger
call shr_sys_abort(subname//' ERROR: all async component rearrangers must match '//msgstr)
call shr_log_error( subname//' ERROR: all async component rearrangers must match '//msgstr, rc=rc)
return
endif
endif
endif
Expand Down
Loading